Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
error-log-widget.hpp
Go to the documentation of this file.
1 /*
2  ERROR-LOG-WIDGET.hpp - display of error messages in a text box
3 
4  Copyright (C) Lumiera.org
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
36 #ifndef GUI_WIDGET_ERROR_LOG_WIDGET_H
37 #define GUI_WIDGET_ERROR_LOG_WIDGET_H
38 
39 #include "gui/gtk-base.hpp"
41 
42 //#include "lib/util.hpp"
43 
44 //#include <memory>
45 //#include <vector>
46 
47 
48 
49 namespace gui {
50 namespace widget {
51 
52 
59  : public Gtk::ScrolledWindow
60  {
61  public:
63 
65  : Gtk::ScrolledWindow()
66  , textLog_{}
67  {
68  set_size_request (200, 50);
69  set_border_width (10);
70  set_shadow_type (Gtk::SHADOW_NONE);
71 
72  // the vertical scrollbar will always be necessary....
73  set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
74  this->add (textLog_);
75  textLog_.set_editable (false);
76 
77  }
78 
79 
80  void
81  showMsg (NotifyLevel severity, string const& text)
82  {
84  switch (severity) {
85  case NOTE_ERROR:
86  addEntry ("ERROR: "+text);
87  break;
88  case NOTE_WARN:
89  addEntry ("WARN: "+text);
90  break;
91  default:
92  addEntry (text);
93  break;
94  }
95  }
96 
97 
98  private:/* ===== Internals ===== */
99 
100  Gtk::TextView textLog_;
101 
108  void
109  addEntry (string const& text)
110  {
111  auto buff = textLog_.get_buffer();
112  auto cursor = buff->get_insert();
113  buff->move_mark (cursor, buff->end());
114  buff->insert (buff->end(), text);
115  textLog_.scroll_to (cursor);
116  }
117  };
118 
119 
120 }}// namespace gui::widget
121 #endif /*GUI_WIDGET_ERROR_LOG_WIDGET_H*/
something to be aware of, to be indicated unobtrusively
Major public Interface of the Lumiera GUI.
void addEntry(string const &text)
add message entry to the (ever growing) text buffer.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:47
severe condition to be indicated prominently
A set of basic GTK includes for the UI.
void showMsg(NotifyLevel severity, string const &text)