3 This file is part of libmspgltk
4 Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_GLTK_WIDGET_H_
9 #define MSP_GLTK_WIDGET_H_
12 #include <msp/datafile/objectloader.h>
25 Base class for all widgets. Derived classes should call update_style in
26 constructor, because it can't be done correctly in the Widget constructor.
30 friend class Container;
33 class Loader: public DataFile::ObjectLoader<Widget>
38 void position(int, int);
39 void size(unsigned, unsigned);
40 void style(const std::string &);
43 sigc::signal<void, bool> signal_visibility_changed;
44 sigc::signal<void> signal_request_focus;
45 sigc::signal<void> signal_grab_pointer;
46 sigc::signal<void> signal_ungrab_pointer;
50 std::string style_name;
63 Returns the name of the widget class. Used for style lookup.
65 virtual const char *get_class() const { return "widget"; }
67 void set_position(int, int);
68 void set_size(unsigned, unsigned);
69 virtual void autosize() { }
70 void set_geometry(const Geometry &);
71 const Geometry &get_geometry() const { return geom; }
75 Sets the widget's parent Container. The widget must be unparented when
76 calling this function with a non-null parameter.
78 void set_parent(Container *);
82 Sets the widget style. The final style name is constructed by concatenating
83 the widget class and the style name with a dash.
85 void set_style(const std::string &);
86 const Style &get_style() const { return *style; }
90 Gets a style object from the resource collection based on the class and
91 style names of the widget.
96 void set_tooltip(const std::string &);
97 const std::string &get_tooltip() const { return tooltip; }
99 void set_visible(bool);
100 bool is_visible() const { return visible; }
101 void set_focusable(bool);
102 bool is_focusable() const { return focusable; }
107 virtual void render_special(const Part &) const { }
111 virtual void button_press(int, int, unsigned) { }
112 virtual void button_release(int, int, unsigned) { }
113 virtual void pointer_motion(int, int) { }
114 virtual void pointer_enter();
115 virtual void pointer_leave();
116 virtual void key_press(unsigned, unsigned, wchar_t) { }
117 virtual void key_release(unsigned, unsigned) { }
118 virtual void focus_in();
119 virtual void focus_out();
121 virtual void on_geometry_change() { }
122 virtual void on_style_change() { }
123 virtual void on_reparent() { }