diff options
Diffstat (limited to 'src/user/include/cxx/raleigh/widget.h')
-rw-r--r-- | src/user/include/cxx/raleigh/widget.h | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/user/include/cxx/raleigh/widget.h b/src/user/include/cxx/raleigh/widget.h index 54b9287..1b2cf6f 100644 --- a/src/user/include/cxx/raleigh/widget.h +++ b/src/user/include/cxx/raleigh/widget.h @@ -12,12 +12,15 @@ namespace raleigh { namespace raleigh { class widget { public: - coord size; - - //set by window class (or parent widget) + //these three are set by window class (or parent widget) + widget *parent;//set to zero when root widget window *w; coord window_offset; + //derived classes should not set this outside of the initializer + //instead, they should call widget::set_size(coord) + coord size; + //fewest steps up that a widget can be redrawn without needing its parents //if a widget is opaque, it will set this to a pointer to itself, and then call // notify_has_opaque_parent on any children, passing itself as an argument. @@ -25,14 +28,21 @@ namespace raleigh { // and then call notify_has_opaque_parent on any children (with the opaque parent). widget *closest_opaque; - //called by window class (or parent widget) - virtual void notify_window_change() = 0; + //these are called by window class (or parent widgets) + virtual void notify_window_change(); virtual void paint(_pixel_t *pixbuf, uint32_t pitch) = 0; - virtual void handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) = 0; + virtual void handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up); virtual void notify_has_opaque_parent(widget *parent) = 0; - virtual void handle_key(struct key_packet kp) = 0; - virtual void on_focus() = 0; - virtual void on_unfocus() = 0; + virtual void handle_key(struct key_packet kp); + virtual void on_focus(); + virtual void on_unfocus(); + //this next one is not to be called by child widgets + //they should call window::notify_widget_size_change(widget &), which will call this if necessary + virtual void notify_child_size_change(widget &child, coord old_size); + + protected: + widget(); + void set_size(coord to); }; } |