]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/widget.h
Make widgets aware of their parents
[libs/gltk.git] / source / widget.h
index 255f0425bcc719f3161ccb32e8aaa3b75888d1e5..6cb5e4a1bd670ae13bb930a6b06c9db7af887e40 100644 (file)
@@ -15,6 +15,7 @@ Distributed under the LGPL
 namespace Msp {
 namespace GLtk {
 
+class Panel;
 class Part;
 class Resources;
 class Style;
@@ -47,10 +48,11 @@ protected:
        const Style *style;
        State state;
        bool visible;
+       Panel *parent;
 
        Widget(const Resources &);
 public:
-       virtual ~Widget() { }
+       virtual ~Widget();
        void set_position(int, int);
        void set_size(unsigned, unsigned);
        void set_geometry(const Geometry &);
@@ -88,7 +90,22 @@ protected:
        */
        virtual const char *get_class() const { return "widget"; }
 
+       /**
+       Gets a style object from the resource collection based on the class and
+       style names of the widget.
+       */
        void update_style();
+
+       /**
+       Sets the widget's parent Panel.  The widget must be unparented when calling
+       this function.
+       */
+       void set_parent(Panel *);
+
+       /**
+       A helper function to set the parent of another widget.
+       */
+       void set_parent(Widget &, Panel *);
 };
 
 } // namespace GLtk