]> git.tdb.fi Git - libs/gltk.git/blob - source/panel.h
typedef tweaks
[libs/gltk.git] / source / panel.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007-2011  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GLTK_PANEL_H_
9 #define MSP_GLTK_PANEL_H_
10
11 #include "container.h"
12
13 namespace Msp {
14 namespace GLtk {
15
16 /**
17 Panels are containers for other widgets.  Panel styles should have a special
18 part "children" to render the child widgets.  All properties of this part are
19 ignored.
20 */
21 class Panel: public Container
22 {
23 public:
24         class Loader: public Widget::Loader
25         {
26         public:
27                 typedef std::map<std::string, Widget *> WidgetMap;
28
29         private:
30                 Panel &pnl;
31                 WidgetMap &wdg_map;
32         
33         public:
34                 Loader(Panel &, WidgetMap &);
35         private:
36                 template<typename T>
37                 void child(const std::string &);
38                 void panel(const std::string &);
39         };
40
41 protected:
42         struct Child: public Container::Child
43         {
44                 Child(Panel &, Widget *);
45                 virtual ~Child();
46
47                 void visibility_changed(bool);
48                 void request_focus();
49                 void grab_pointer();
50                 void ungrab_pointer();
51                 void raise();
52         };
53
54         Widget *pointer_focus;
55         bool pointer_grabbed;
56         Widget *input_focus;
57
58         Panel(const Panel &);
59         Panel &operator=(const Panel &);
60 public:
61         Panel();
62
63         virtual const char *get_class() const { return "panel"; }
64
65 protected:
66         virtual Child *create_child(Widget *);
67
68 public:
69         void raise(Widget &);
70         Widget *get_input_focus() const { return input_focus; }
71         Widget *get_final_input_focus() const;
72
73 protected:
74         virtual void render_special(const Part &) const;
75
76 public:
77         virtual void button_press(int, int, unsigned);
78         virtual void button_release(int, int, unsigned);
79         virtual void pointer_motion(int, int);
80         virtual void pointer_leave();
81         virtual void key_press(unsigned, unsigned, wchar_t);
82         virtual void key_release(unsigned, unsigned);
83         virtual void focus_out();
84
85 protected:
86         void set_pointer_focus(Widget *);
87         void set_input_focus(Widget *);
88 };
89
90 } // namespace GLtk
91 } // namespace Msp
92
93 #endif