![]() |
Max OS 0.3
|
A box that can be used to input text. More...
#include <inputbox.h>
Public Member Functions | |
| InputBox (int32_t left, int32_t top, uint32_t width, uint32_t height) | |
| Construct a new Input Box object at a specific position and size. | |
| InputBox (int32_t left, int32_t top, uint32_t width, uint32_t height, const string &text) | |
| Construct a new Input Box object at a specific position and size with initial text. | |
| void | draw (common::GraphicsContext *gc, common::Rectangle< int32_t > &area) override |
| Draw an area of the input box onto a graphics context. | |
| void | on_focus () override |
| Update the border when the input box is focussed. | |
| void | on_focus_lost () override |
| Reset to the original input box style when it is no longer focussed. | |
| void | on_key_down (drivers::peripherals::KeyCode key_down_code, const drivers::peripherals::KeyboardState &key_down_state) override |
| Handles a keypress event by updating the rendered text in the input box. | |
| void | update_text (const string &) |
| Update the text in the input box. | |
| string | text () |
| Get the text currently in the input box. | |
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 void | add_child (Widget *child) |
| Set the parent of a widget to this widget, making it into a child. | |
| 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. | |
| void | bring_to_front () |
| Brings this widget to the front of the screen. | |
| virtual void | on_mouse_enter_widget (uint32_t to_x, uint32_t to_y) |
| Handles the event when the mouse is moved on to the widget. | |
| virtual void | on_mouse_leave_widget (uint32_t from_x, uint32_t from_y) |
| Handles the event when the mouse is moved out of the widget. | |
| virtual void | on_mouse_move_widget (uint32_t from_x, uint32_t from_y, uint32_t to_x, uint32_t to_y) |
| Handles the event when the mouse is moved over the widget. | |
| virtual drivers::peripherals::MouseEventHandler * | on_mouse_button_pressed (uint32_t x, uint32_t y, uint8_t button) |
| Handles the event when the mouse is pressed on the widget. | |
| virtual void | on_mouse_button_released (uint32_t x, uint32_t y, uint8_t button) |
| Handles the event when the mouse is released on the widget. | |
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_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. | |
Public Member Functions inherited from MaxOS::common::EventManager< InputBoxEvents > | |
| void | connect_event_handler (EventHandler< InputBoxEvents > *handler) |
| connect an event handler to the event manager if it is not already connected | |
| void | disconnect_event_handler (EventHandler< InputBoxEvents > *handler) |
| disconnect an event handler from the event manager if it is connected | |
| Vector< Event< InputBoxEvents > * > | raise_event (Event< InputBoxEvents > *event) |
| Calls the on_event function of all the event m_handlers connected to the event manager and returns a list of the results. | |
Public Attributes | |
| common::Colour | background_colour |
| The background colour of the input box. | |
| common::Colour | foreground_colour |
| The colour of the text in the input box. | |
| common::Colour | border_colour |
| The colour of the bar around the input box. | |
| gui::Font | font |
| The font to use for the input box text. | |
| uint32_t | cursor_position { 0 } |
| How many characters into the text the cursor is. | |
Protected Attributes | |
| string | m_widget_text = " " |
| The text in the input box. | |
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. | |
Protected Attributes inherited from MaxOS::common::EventManager< InputBoxEvents > | |
| Vector< EventHandler< InputBoxEvents > * > | m_handlers |
Additional Inherited Members | |
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. | |
A box that can be used to input text.
Definition at line 58 of file inputbox.h.
Construct a new Input Box object at a specific position and size.
| left | How many pixels from the left of the parent widget the input box is |
| top | How many pixels from the top of the parent widget the input box is |
| width | How many pixels wide the input box is |
| height | How many pixels tall the input box is |
Definition at line 56 of file inputbox.cpp.
| InputBox::InputBox | ( | int32_t | left, |
| int32_t | top, | ||
| uint32_t | width, | ||
| uint32_t | height, | ||
| const string & | text | ||
| ) |
Construct a new Input Box object at a specific position and size with initial text.
| left | The left position of the input box |
| top | The top position of the input box |
| width | The width of the input box |
| height | The height of the input box |
| text | The initial text in the input box |
Definition at line 75 of file inputbox.cpp.
References text(), and update_text().
|
overridevirtual |
Draw an area of the input box onto a graphics context.
| gc | The context to draw onto |
| area | What part of the input box to draw |
Reimplemented from MaxOS::gui::Widget.
Definition at line 96 of file inputbox.cpp.
References MaxOS::gui::Widget::absolute_coordinates(), background_colour, border_colour, MaxOS::gui::Widget::draw(), MaxOS::gui::Font::draw_text(), font, foreground_colour, MaxOS::common::Rectangle< Type >::height, MaxOS::common::Rectangle< Type >::intersects(), MaxOS::common::Rectangle< Type >::left, m_widget_text, MaxOS::gui::Widget::position(), MaxOS::common::Rectangle< Type >::top, and MaxOS::common::Rectangle< Type >::width.
|
overridevirtual |
Update the border when the input box is focussed.
Reimplemented from MaxOS::gui::Widget.
Definition at line 157 of file inputbox.cpp.
References border_colour, and MaxOS::gui::Widget::invalidate().
|
overridevirtual |
Reset to the original input box style when it is no longer focussed.
Reimplemented from MaxOS::gui::Widget.
Definition at line 167 of file inputbox.cpp.
References border_colour, and MaxOS::gui::Widget::invalidate().
|
overridevirtual |
Handles a keypress event by updating the rendered text in the input box.
| key_down_code | The key being pressed |
| key_down_state | The state of the key being pressed |
Reimplemented from MaxOS::drivers::peripherals::KeyboardEventHandler.
Definition at line 180 of file inputbox.cpp.
References cursor_position, MaxOS::gui::Widget::invalidate(), m_widget_text, and MaxOS::common::EventManager< InputBoxEvents >::raise_event().
| string InputBox::text | ( | ) |
Get the text currently in the input box.
Definition at line 281 of file inputbox.cpp.
References m_widget_text.
Referenced by InputBox().
Update the text in the input box.
| new_text | The new text to display |
Definition at line 264 of file inputbox.cpp.
References cursor_position, MaxOS::gui::Widget::invalidate(), m_widget_text, and MaxOS::common::EventManager< InputBoxEvents >::raise_event().
Referenced by InputBox().
| common::Colour MaxOS::gui::widgets::InputBox::background_colour |
The background colour of the input box.
Definition at line 80 of file inputbox.h.
Referenced by draw().
| common::Colour MaxOS::gui::widgets::InputBox::border_colour |
The colour of the bar around the input box.
Definition at line 82 of file inputbox.h.
Referenced by draw(), on_focus(), and on_focus_lost().
| uint32_t MaxOS::gui::widgets::InputBox::cursor_position { 0 } |
How many characters into the text the cursor is.
Definition at line 84 of file inputbox.h.
Referenced by on_key_down(), and update_text().
| gui::Font MaxOS::gui::widgets::InputBox::font |
The font to use for the input box text.
Definition at line 83 of file inputbox.h.
Referenced by draw().
| common::Colour MaxOS::gui::widgets::InputBox::foreground_colour |
The colour of the text in the input box.
Definition at line 81 of file inputbox.h.
Referenced by draw().
|
protected |
The text in the input box.
Definition at line 62 of file inputbox.h.
Referenced by draw(), on_key_down(), text(), and update_text().