3 This file is part of libmspgltk
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_GLTK_WIDGET_H_
9 #define MSP_GLTK_WIDGET_H_
23 Base class for all widgets. Derived classes should call update_style in
24 constructor, because it can't be done correctly in the Widget constructor.
29 class Loader: public Msp::DataFile::Loader
36 Widget &get_object() const { return wdg; }
38 void position(int, int);
39 void size(unsigned, unsigned);
40 void style(const std::string &);
46 std::string style_name;
51 Widget(const Resources &);
54 void set_position(int, int);
55 void set_size(unsigned, unsigned);
56 void set_geometry(const Geometry &);
59 Sets the widget style. The final style name is constructed by concatenating
60 the widget class and the style name with a dash.
62 void set_style(const std::string &);
64 const Geometry &get_geometry() const { return geom; }
65 bool is_visible() const { return visible; }
69 virtual void render_part(const Part &) const;
70 void render_graphic(const Part &) const;
71 void render_text(const Part &, const std::string &) const;
75 virtual void button_press(int, int, unsigned) { }
76 virtual void button_release(int, int, unsigned) { }
77 virtual void pointer_motion(int, int) { }
78 virtual void pointer_enter() { }
79 virtual void pointer_leave() { }
80 virtual void key_press(unsigned, unsigned, wchar_t) { }
81 virtual void key_release(unsigned, unsigned) { }
82 virtual void focus_in() { }
83 virtual void focus_out() { }
87 Returns the name of the widget class. Used for style lookup.
89 virtual const char *get_class() const { return "widget"; }