libt3widget
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
textwindow.h
1 /* Copyright (C) 2011-2013 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_WIDGET_TEXTWINDOW_H
15 #define T3_WIDGET_TEXTWINDOW_H
16 
17 #include <t3widget/widgets/widget.h>
18 #include <t3widget/widgets/scrollbar.h>
19 #include <t3widget/textbuffer.h>
20 #include <t3widget/interfaces.h>
21 #include <t3widget/wrapinfo.h>
22 
23 namespace t3_widget {
24 
25 class T3_WIDGET_API text_window_t : public widget_t, public center_component_t, public container_t {
26  private:
27  struct T3_WIDGET_LOCAL implementation_t {
28  cleanup_ptr<scrollbar_t>::t scrollbar;
29  text_buffer_t *text;
30  cleanup_ptr<wrap_info_t>::t wrap_info;
32  bool focus;
33 
34  implementation_t(void) : top(0, 0), focus(false) {}
35  };
36  pimpl_ptr<implementation_t>::t impl;
37 
38  void scroll_up(int lines);
39  void scroll_down(int lines);
40  void scrollbar_clicked(scrollbar_t::step_t step);
41  void scrollbar_dragged(int start);
42 
43  public:
44  text_window_t(text_buffer_t *_text = NULL, bool with_scrollbar = true);
45  virtual bool process_key(key_t key);
46  virtual bool set_size(optint height, optint width);
47  virtual void update_contents(void);
48  virtual void set_focus(focus_t _focus);
49  virtual void set_child_focus(window_component_t *target);
50  virtual bool is_child(window_component_t *component);
51  virtual bool process_mouse_event(mouse_event_t event);
52 
53  void set_scrollbar(bool with_scrollbar);
54  void set_text(text_buffer_t *_text);
55  text_buffer_t *get_text(void);
56  void set_tabsize(int size);
57  int get_text_height(void);
58 
59  T3_WIDGET_SIGNAL(activate, void);
60 };
61 
62 }; // namespace
63 #endif
Definition: textbuffer.h:34
Abstract base class for all items displayed on screen.
Definition: interfaces.h:28
Base class for components which need to center dialogs.
Definition: interfaces.h:109
long key_t
Integer type holding a single key symbol.
Definition: key.h:24
Definition: util.h:49
Base class for widgets.
Definition: widget.h:24
Base class for window_component_t's that are the parents of other window_component_t's.
Definition: interfaces.h:86
Class defining values with a separate validity check.
Definition: util.h:29
Definition: textwindow.h:25
Structure holding the relevant elements of a mouse event.
Definition: mouse.h:23
step_t
Definition: scrollbar.h:46