![]() |
Max OS 0.3
|
A widget that can contain other widgets. More...
#include <widget.h>
Public Member Functions | |
| CompositeWidget (int32_t left, int32_t top, uint32_t width, uint32_t height) | |
| Construct a new Composite Widget object at a specific position and size. | |
| void | draw (common::GraphicsContext *gc, common::Rectangle< int32_t > &area) override |
| Draws a section of the widget and its m_children. | |
| void | add_child (Widget *child) override |
| Adds a child to the widget. | |
| void | on_mouse_enter_widget (uint32_t to_x, uint32_t to_y) override |
| Passes the event to the child that the mouse is over. (Event handling should be done by the derived class) | |
| void | on_mouse_leave_widget (uint32_t from_x, uint32_t from_y) override |
| Passes the event to the child that the mouse is over. (Event handling should be done by the derived class) | |
| void | on_mouse_move_widget (uint32_t from_x, uint32_t from_y, uint32_t to_x, uint32_t to_y) override |
| Passes the event to the child that the mouse is over, also generates a leave/enter event for children. | |
| drivers::peripherals::MouseEventHandler * | on_mouse_button_pressed (uint32_t x, uint32_t y, uint8_t button) override |
| Passes the event to the child that the mouse is over. | |
| void | on_mouse_button_released (uint32_t x, uint32_t y, uint8_t button) override |
| Passes the event to the child that the mouse is over. (Event handling should be done by the derived class) | |
Public Member Functions inherited from MaxOS::gui::Widget | |
| Widget () | |
| Construct a new Widget object. | |
| Widget (int32_t left, int32_t top, uint32_t width, uint32_t height) | |
| Construct a new Widget object at a specific position and size. | |
| void | invalidate () |
| Invalidates the entire widget. This forces the widget to be redrawn on the next screen update. | |
| virtual void | invalidate (common::Rectangle< int32_t > &area) |
| Invalidates a specific area of the widget. This forces that part of the screen to be redrawn on the next screen update. | |
| virtual common::Coordinates | absolute_coordinates (common::Coordinates coordinates) |
| Get the absolute coordinates of the widget (relative to the screen) | |
| virtual bool | contains_coordinate (uint32_t x, uint32_t y) |
| Check if the widget contains a specific coordinate. | |
| common::Rectangle< int32_t > | position () |
| Get the position of the widget. | |
| void | move (int32_t left, int32_t top) |
| Set the position of the widget, and invalidate the old and new positions so they are redrawn. | |
| void | resize (int32_t width, int32_t height) |
| Set the size of the widget, and invalidate the old and new positions so they are redrawn. | |
| void | focus () |
| Set the current focused widget to be this widget. | |
| virtual void | on_focus () |
| Handles the event when the widget is focussed. | |
| virtual void | on_focus_lost () |
| Handles the event when the widget is unfocused. | |
| void | bring_to_front () |
| Brings this widget to the front of the screen. | |
Public Member Functions inherited from MaxOS::drivers::peripherals::KeyboardEventHandler | |
| common::Event< KeyboardEvents > * | on_event (common::Event< KeyboardEvents > *) override |
| Handle the trigger of an event. | |
| virtual void | on_key_down (KeyCode, const KeyboardState &) |
| Handle the key down event. | |
| virtual void | on_key_up (KeyCode, const KeyboardState &) |
| Handle the key up event. | |
Public Member Functions inherited from MaxOS::common::EventHandler< KeyboardEvents > | |
| virtual Event< KeyboardEvents > * | on_event (Event< KeyboardEvents > *event) |
| This function is called when an event is raised. | |
Protected Member Functions | |
| void | draw (common::GraphicsContext *gc, common::Rectangle< int32_t > &area, common::Vector< Widget * >::iterator start) |
| Draws a section of the widget and the m_children after a specific child. | |
| virtual void | draw_self (common::GraphicsContext *gc, common::Rectangle< int32_t > &area) |
| Draws the widget itself (should be overridden by the derived class) | |
Protected Member Functions inherited from MaxOS::gui::Widget | |
| virtual void | set_focus (Widget *) |
| Sets the widget that is currently focussed. | |
| virtual void | bring_to_front (Widget *) |
| Brings a specific widget to the front of the screen. | |
Protected Attributes | |
| common::Vector< Widget * > | m_children |
| Widgets contained within this composite widget. | |
Protected Attributes inherited from MaxOS::gui::Widget | |
| common::Rectangle< int32_t > | m_position |
| The position and size of the widget (relative to its parent) | |
| Widget * | m_parent { nullptr } |
| The widget that owns this widget. | |
| bool | m_valid { false } |
| Is the widget drawn to the screen and up to date. | |
| uint32_t | m_min_width { 5 } |
| The smallest m_width the widget can be resized to. | |
| uint32_t | m_min_height { 5 } |
| The smallest m_height the widget can be resized to. | |
| uint32_t | m_max_width { 0x8FFFFFFF } |
| The largest m_width the widget can be resized to. | |
| uint32_t | m_max_height { 0x8FFFFFFF } |
| The largest m_height the widget can be resized to. | |
Construct a new Composite Widget object at a specific position and size.
| left | The left position of the widget relative to its parent |
| top | The top position of the widget relative to its parent |
| width | How many pixels wide the widget is |
| height | How many pixels tall the widget is |
Definition at line 322 of file widget.cpp.
Adds a child to the widget.
| child | The child to add |
Reimplemented from MaxOS::gui::Widget.
Reimplemented in MaxOS::gui::Desktop, and MaxOS::gui::Window.
Definition at line 403 of file widget.cpp.
References MaxOS::gui::Widget::add_child(), and m_children.
Referenced by MaxOS::gui::Desktop::add_child(), and MaxOS::gui::Window::add_child().
|
overridevirtual |
Draws a section of the widget and its m_children.
| gc | The graphics context to draw to |
| area | The area to draw |
Reimplemented from MaxOS::gui::Widget.
Definition at line 335 of file widget.cpp.
References draw(), and m_children.
|
protected |
Draws a section of the widget and the m_children after a specific child.
| gc | The graphics context to draw to |
| area | The area to draw |
| start | The child to start drawing from |
Definition at line 348 of file widget.cpp.
References MaxOS::gui::Widget::draw(), draw(), draw_self(), MaxOS::common::Rectangle< Type >::intersection(), MaxOS::common::Rectangle< Type >::intersects(), MaxOS::common::Rectangle< Type >::left, m_children, MaxOS::gui::Widget::position(), MaxOS::common::Rectangle< Type >::subtract(), and MaxOS::common::Rectangle< Type >::top.
Referenced by draw(), draw(), and MaxOS::gui::Desktop::on_time().
|
protectedvirtual |
Draws the widget itself (should be overridden by the derived class)
| gc | The graphics context to draw to |
| area | The area to draw |
Reimplemented in MaxOS::gui::Desktop, and MaxOS::gui::Window.
Definition at line 394 of file widget.cpp.
Referenced by draw().
|
overridevirtual |
Passes the event to the child that the mouse is over.
| x | The x coordinate of the mouse |
| y | The y coordinate of the mouse |
| button | The button that was pressed |
Reimplemented from MaxOS::gui::Widget.
Reimplemented in MaxOS::gui::Window.
Definition at line 520 of file widget.cpp.
References MaxOS::common::Rectangle< Type >::left, m_children, and MaxOS::common::Rectangle< Type >::top.
Referenced by MaxOS::gui::Window::on_mouse_button_pressed(), and MaxOS::gui::Desktop::on_mouse_down_event().
|
overridevirtual |
Passes the event to the child that the mouse is over. (Event handling should be done by the derived class)
| x | The x coordinate of the mouse |
| y | The y coordinate of the mouse |
| button | The button that was released |
Reimplemented from MaxOS::gui::Widget.
Definition at line 544 of file widget.cpp.
References MaxOS::common::Rectangle< Type >::left, m_children, and MaxOS::common::Rectangle< Type >::top.
Referenced by MaxOS::gui::Desktop::on_mouse_up_event().
Passes the event to the child that the mouse is over. (Event handling should be done by the derived class)
| to_x | The x coordinate of the mouse |
| to_y | The y coordinate of the mouse |
Reimplemented from MaxOS::gui::Widget.
Definition at line 416 of file widget.cpp.
References MaxOS::common::Rectangle< Type >::contains(), MaxOS::common::Rectangle< Type >::left, m_children, and MaxOS::common::Rectangle< Type >::top.
Referenced by MaxOS::gui::Desktop::add_child().
Passes the event to the child that the mouse is over. (Event handling should be done by the derived class)
| from_x | The x coordinate of the mouse |
| from_y | The y coordinate of the mouse |
Reimplemented from MaxOS::gui::Widget.
Definition at line 443 of file widget.cpp.
References MaxOS::common::Rectangle< Type >::contains(), MaxOS::common::Rectangle< Type >::left, m_children, and MaxOS::common::Rectangle< Type >::top.
Referenced by MaxOS::gui::Desktop::add_child().
|
overridevirtual |
Passes the event to the child that the mouse is over, also generates a leave/enter event for children.
| from_x | The x coordinate of the mouse |
| from_y | The y coordinate of the mouse |
| to_x | The x coordinate of the mouse |
| to_y | The y coordinate of the mouse |
Reimplemented from MaxOS::gui::Widget.
Definition at line 472 of file widget.cpp.
References MaxOS::common::Rectangle< Type >::contains(), and m_children.
Referenced by MaxOS::gui::Desktop::on_mouse_move_event().
|
protected |
Widgets contained within this composite widget.
Definition at line 92 of file widget.h.
Referenced by add_child(), MaxOS::gui::Desktop::bring_to_front(), draw(), draw(), on_mouse_button_pressed(), on_mouse_button_released(), on_mouse_enter_widget(), on_mouse_leave_widget(), and on_mouse_move_widget().