]> git.tdb.fi Git - libs/gltk.git/blob - source/container.h
Add child_added/removed events to Container
[libs/gltk.git] / source / container.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2009-2011  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();
37 public:
38         virtual ~Container();
39
40         void add(Widget &);
41         void remove(Widget &);
42 protected:
43         virtual Child *create_child(Widget *);
44 public:
45         std::list<Widget *> get_children() const;
46         Widget *get_child_at(int, int);
47         Widget *get_descendant_at(int, int);
48
49         virtual void button_press(int, int, unsigned);
50         virtual void button_release(int, int, unsigned);
51         virtual void pointer_motion(int, int);
52         virtual void pointer_leave();
53 protected:
54         virtual void on_reparent();
55         virtual void on_child_added(Widget &) { }
56         virtual void on_child_removed(Widget &) { }
57 };
58
59 } // namespace GLtk
60 } // namespace Msp
61
62 #endif