]> git.tdb.fi Git - libs/gltk.git/blob - source/container.h
Add Container class
[libs/gltk.git] / source / container.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2009  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GLTK_CONTAINER_H_
9 #define MSP_GLTK_CONTAINER_H_
10
11 #include <list>
12 #include <sigc++/trackable.h>
13 #include "widget.h"
14
15 namespace Msp {
16 namespace GLtk {
17
18 class Container: virtual public Widget
19 {
20 protected:
21         struct Child: public sigc::trackable
22         {
23                 Container &container;
24                 Widget *widget;
25
26                 Child(Container &, Widget *);
27                 virtual ~Child();
28
29                 void visibility_changed(bool);
30         };
31
32         std::list<Child *> children;
33         Widget *click_focus;
34         unsigned click_button;
35
36         Container(const Resources &);
37 public:
38         virtual ~Container();
39
40         void add(Widget &);
41         void remove(Widget &);
42         std::list<Widget *> get_children() const;
43         Widget *get_child_at(int, int);
44         Widget *get_descendant_at(int, int);
45
46         virtual void button_press(int, int, unsigned);
47         virtual void button_release(int, int, unsigned);
48         virtual void pointer_motion(int, int);
49         virtual void pointer_leave();
50 protected:
51         virtual Child *create_child(Widget *);
52 };
53
54 } // namespace GLtk
55 } // namespace Msp
56
57 #endif