diff --git a/src/gui/panel/infobox-panel.cpp b/src/gui/panel/infobox-panel.cpp index f4cd59ebd..0f4330e50 100644 --- a/src/gui/panel/infobox-panel.cpp +++ b/src/gui/panel/infobox-panel.cpp @@ -40,8 +40,7 @@ namespace panel{ , twoParts_{Gtk::ORIENTATION_VERTICAL} , buttons_{} , frame_{"UI Integration Experiments"} - , scroller_{} - , textLog_{} + , errorLog_{} { twoParts_.pack_start(frame_); twoParts_.pack_start(buttons_, Gtk::PACK_SHRINK); @@ -57,17 +56,8 @@ namespace panel{ buttons_.add (button_1_); //(End)buttons... - frame_.add (scroller_); frame_.set_border_width (5); - - scroller_.set_shadow_type (Gtk::SHADOW_NONE); - scroller_.set_border_width (10); - - // the vertical scrollbar will always be necessary.... - scroller_.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); - scroller_.add (textLog_); - - textLog_.set_editable (false); + frame_.add (errorLog_); // show everything.... this->add (twoParts_); @@ -96,15 +86,7 @@ namespace panel{ static uint bangNo{0}; static _Fmt msgTemplate{"Bang #%d\n"}; - // According to the Gtkmm tutorial, TextView::scroll_to(iter) is not reliable; - // rather we need to use a text mark and set that text mark to the insert position. - // Actually, there is always one predefined text mark called "insert", which corresponds - // to the text cursor. Thus it suffices to navigate to text end, insert and scroll into view. - auto buff = textLog_.get_buffer(); - auto cursor = buff->get_insert(); - buff->move_mark (cursor, buff->end()); - buff->insert (buff->end(), ustring{msgTemplate % ++bangNo}); - textLog_.scroll_to (cursor); + errorLog_.showMsg(NOTE_WARN, msgTemplate % ++bangNo); } diff --git a/src/gui/panel/infobox-panel.hpp b/src/gui/panel/infobox-panel.hpp index fb6340d70..3b508bcba 100644 --- a/src/gui/panel/infobox-panel.hpp +++ b/src/gui/panel/infobox-panel.hpp @@ -36,6 +36,7 @@ #include "gui/panel/panel.hpp" +#include "gui/widget/error-log-widget.hpp" namespace gui { namespace panel{ @@ -61,9 +62,7 @@ namespace panel{ Gtk::ButtonBox buttons_; Gtk::Button button_1_; Gtk::Frame frame_; - Gtk::ScrolledWindow scroller_; - Gtk::TextView textLog_; ////////////TICKET #1047 : as a temporary solution, host the error log here - ////////////////////////////////////////////////TICKET #1102 : build a message display box widget + widget::ErrorLogWidget errorLog_; void experiment_1(); }; diff --git a/src/gui/widget/error-log-widget.hpp b/src/gui/widget/error-log-widget.hpp new file mode 100644 index 000000000..4533e8add --- /dev/null +++ b/src/gui/widget/error-log-widget.hpp @@ -0,0 +1,121 @@ +/* + ERROR-LOG-WIDGET.hpp - display of error messages in a text box + + Copyright (C) Lumiera.org + 2017, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +/** @file error-log-widget.hpp + ** Widget to display error messages to the use in non-modal way. + ** Notifications are shown in a simple text window with scrollbars; new + ** entries can be added with a severity level, causing the widget to scroll + ** down to the last line of the content buffer. + ** + ** @todo WIP-WIP-WIP as of 9/2017 this is a first draft of a widget to be + ** used as receiver by the GuiNotificationService. + ** + */ + + +#ifndef GUI_WIDGET_ERROR_LOG_WIDGET_H +#define GUI_WIDGET_ERROR_LOG_WIDGET_H + +#include "gui/gtk-base.hpp" +#include "include/gui-notification-facade.h" + +//#include "lib/util.hpp" + +//#include +//#include + + + +namespace gui { +namespace widget { + + + /** + * @todo WIP-WIP as of 9/2017 + * Just a text display box with scrollbars. + * Need to add formatting etc. + */ + class ErrorLogWidget + : public Gtk::ScrolledWindow + { + public: + ~ErrorLogWidget() { }; + + ErrorLogWidget() + : Gtk::ScrolledWindow() + , textLog_{} + { + set_size_request (200, 50); + set_border_width (10); + set_shadow_type (Gtk::SHADOW_NONE); + + // the vertical scrollbar will always be necessary.... + set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); + this->add (textLog_); + textLog_.set_editable (false); + + } + + + void + showMsg (NotifyLevel severity, string const& text) + { + //////////////////////////////////////////////////TICKET #1102 : add formatting according to the error level + switch (severity) { + case NOTE_ERROR: + addEntry ("ERROR: "+text); + break; + case NOTE_WARN: + addEntry ("WARN: "+text); + break; + default: + addEntry (text); + break; + } + } + + + private:/* ===== Internals ===== */ + + Gtk::TextView textLog_; + + /** add message entry to the (ever growing) text buffer. + * @remark According to the Gtkmm tutorial, TextView::scroll_to(iter) is not reliable; + * rather we need to use a text mark and set that text mark to the insert position. + * Actually, there is always one predefined text mark called "insert", which corresponds + * to the text cursor. Thus it suffices to navigate to text end, insert and scroll into view. + */ + void + addEntry (string const& text) + { + auto buff = textLog_.get_buffer(); + auto cursor = buff->get_insert(); + buff->move_mark (cursor, buff->end()); + buff->insert (buff->end(), text); + textLog_.scroll_to (cursor); + } + }; + + +}}// namespace gui::widget +#endif /*GUI_WIDGET_ERROR_LOG_WIDGET_H*/ diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 2f78df523..d9e1892c8 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -1416,8 +1416,10 @@ + + + -