libt3widget
interfaces.h
1 /* Copyright (C) 2011-2012 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_INTERFACES_H
15 #define T3_WIDGET_INTERFACES_H
16 
17 #include <list>
18 #include <map>
19 #include <t3window/window.h>
20 
21 #include <t3widget/key.h>
22 #include <t3widget/mouse.h>
23 #include <t3widget/util.h>
24 
25 namespace t3_widget {
26 
28 class T3_WIDGET_API window_component_t {
29  protected:
31  cleanup_t3_window_ptr window;
32  public:
33  enum focus_t {
34  FOCUS_OUT = 0,
35  FOCUS_SET,
36  FOCUS_IN_FWD,
37  FOCUS_IN_BCK,
38  FOCUS_REVERT
39  };
40 
42  window_component_t(void);
44  /* Virtual destructor is required for proper functioning of the delete
45  operator in multiple-inheritance situations. */
46  virtual ~window_component_t(void);
51  virtual t3_window_t *get_base_window(void);
56  virtual bool process_key(key_t key) = 0;
59  virtual void set_position(optint top, optint left) = 0;
66  virtual bool set_size(optint height, optint width) = 0;
68  virtual void update_contents(void) = 0;
75  virtual void set_focus(focus_t focus) = 0;
77  virtual void show(void) = 0;
79  virtual void hide(void) = 0;
81  virtual void force_redraw(void) = 0;
82 };
83 
84 class widget_t;
86 class T3_WIDGET_API container_t : protected virtual window_component_t {
87  protected:
89  virtual bool set_widget_parent(window_component_t *widget);
91  virtual void unset_widget_parent(window_component_t *widget);
92  public:
94  virtual void set_child_focus(window_component_t *target) = 0;
96  virtual bool is_child(window_component_t *component) = 0;
97 };
98 
109 class T3_WIDGET_API center_component_t : protected virtual window_component_t {
110  protected:
113  public:
117  center_component_t(void);
119  virtual void set_center_window(window_component_t *_center_window);
120 };
121 
122 class T3_WIDGET_API mouse_target_t : protected virtual window_component_t {
123  typedef std::map<t3_window_t *, mouse_target_t *> mouse_target_map_t;
124  private:
125  static mouse_target_map_t targets;
126  static mouse_target_t *grab_target;
127  static t3_window_t *grab_window;
128  protected:
129  mouse_target_t(bool use_window = true);
130 
131  public:
133  void register_mouse_target(t3_window_t *target);
134 
136  void unregister_mouse_target(t3_window_t *target);
137 
142  virtual bool process_mouse_event(mouse_event_t event) = 0;
143  ~mouse_target_t(void);
144 
151  void grab_mouse(void);
153  void release_mouse_grab(void);
154 
155  static bool handle_mouse_event(mouse_event_t event);
156 };
157 
167 class T3_WIDGET_API bad_draw_recheck_t {
168  private:
170  static std::list<bad_draw_recheck_t *> to_signal;
172  static signals::connection initialized;
174  static void bad_draw_recheck_all(void);
175 
176  public:
180  bad_draw_recheck_t(void);
182  virtual ~bad_draw_recheck_t(void);
183 
185  virtual void bad_draw_recheck(void) = 0;
186 };
187 
188 }; // namespace
189 #endif
Base class for widgets that need handle user text and draw differently based on the t3_win_can_draw f...
Definition: interfaces.h:167
The t3_widget namespace is contains all classes, functions and global variables in the libt3widget li...
Definition: autocompleter.cc:18
cleanup_t3_window_ptr window
The t3_window_t used for presenting this item on screen (see libt3window).
Definition: interfaces.h:31
Abstract base class for all items displayed on screen.
Definition: interfaces.h:28
window_component_t * center_window
The window_component_t to center over.
Definition: interfaces.h:112
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
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
Structure holding the relevant elements of a mouse event.
Definition: mouse.h:23
Definition: interfaces.h:122