modm API documentation
modm::gui::Widget Class Referenceabstract

#include <modm/ui/gui/widgets/widget.hpp>

Inheritance diagram for modm::gui::Widget:
modm::gui::ArrowButton modm::gui::ButtonWidget modm::gui::CheckboxWidget modm::gui::FilledAreaButton modm::gui::Label modm::gui::NumberField< T > modm::gui::StringField modm::gui::WidgetGroup modm::gui::NumberField< float >

Public Member Functions

 Widget (Dimension dimension, bool is_interactive)
 
virtual void render (View *view) = 0
 Draws the widget on screen. Each widget need to implement this.
 
void draw (View *view)
 
virtual bool handleInputEvent (const InputEvent *ev)
 
bool checkIntersection (Widget *w)
 
void updateIntersections (WidgetContainer *widgets)
 
bool hasIntersections ()
 Whether there are other widgets overlapping this one on top
 
virtual void activate (const InputEvent &ev, void *data)
 Interface for activating widget. Calls callback function if specified.
 
virtual void deactivate (const InputEvent &ev, void *data)
 Interface for deactivating widget. Calls callback function if specified.
 
ColorPalettegetColorPalette ()
 Get widget-specific color palette. NOT YET USED.
 
virtual void setColorPalette (ColorPalette &cp)
 Set widget-specific color palette.
 
void setColor (modm::gui::Color name, modm::color::Rgb565 color)
 
virtual void setPosition (const modm::glcd::Point &pos)
 
modm::glcd::Point getPosition ()
 Get absolute position of widget on screen.
 
modm::glcd::Point getRelativePosition ()
 Get position of widget relative to its parent.
 
void setRelativePosition (const modm::glcd::Point &pos)
 Only set the relative position.
 
virtual void updatePosition ()
 
void setParent (Widget *parent)
 Set parent for widget, updates the absolute position afterwards.
 
modm::gui::Dimension getDimension ()
 Get dimension of widget.
 
int16_t getWidth ()
 Get width of widget. Shortcut for getDimension().width.
 
int16_t getHeight ()
 Get height of widget. Shortcut for getDimension().height.
 
virtual bool isDirty ()
 Whether widget needs to be redrawn or not.
 
bool isInteractive ()
 Whether widget can handle input events.
 
virtual void markDrawn ()
 Mark widget, that it doesn't need to be redrawn anymore.
 
virtual void markDirty ()
 Mark widget, that it needs to be redrawn.
 
virtual void setFont (const uint8_t *newFont)
 Set widget-specific font. Use modm::font::FontName as argument.
 
virtual void setFont (const modm::accessor::Flash< uint8_t > *font)
 Set widget-specific font. Use pointer to Flash as argument.
 
void setCallbackData (void *data)
 

Public Attributes

Widget * parent
 Parent widget, NULL when there's no parent.
 
int16_t uid
 Unique id for every widget.
 
Dimension dimension
 dimensions
 
bool activated
 where this widget is active or not (e.g. clicked)
 
void * cbData
 arbitrary data that is passed to callbacks
 
eventCallback cb_activate
 callbacks for activation and deactivation event
 
eventCallback cb_deactivate
 
ColorPalette color_palette
 for now unused, maybe needed later for custom styles
 
modm::glcd::Point position
 
modm::glcd::Point relative_position
 relative position inside a WidgetGroup for exemple
 
bool dirty
 has changes to be drawed
 
bool is_interactive
 whether widget will receive events
 
modm::accessor::Flash< uint8_t > font
 widget specific font
 
WidgetContainer intersecting_widgets
 list of widgets that intersect with this widget
 

Detailed Description

Author
Daniel Krebs

Member Function Documentation

bool modm::gui::Widget::checkIntersection ( Widget *  w)

Check if given Widget w overlaps on top. For widgets overlapping below this function also returns false.

void modm::gui::Widget::draw ( View view)
inline

Interface for drawing widgets. Basically calls render(), but has some logic that needs to be executed before and after rendering a widget

bool modm::gui::Widget::handleInputEvent ( const InputEvent ev)
virtual

Handles InputEvents and calls activate/deactivate if event coordinates are within widgets dimensions. Returning true means, that the event was inside these dimensions, false if not.

Reimplemented in modm::gui::WidgetGroup.

virtual void modm::gui::Widget::setPosition ( const modm::glcd::Point pos)
inlinevirtual

Set position of widget relative to its parent. Also updates the absolute position by looping through parents.

Reimplemented in modm::gui::WidgetGroup.

void modm::gui::Widget::updateIntersections ( WidgetContainer widgets)

Clear old list of intersecting widgets and rebuild on the basis of the given widgets container.

virtual void modm::gui::Widget::updatePosition ( )
inlinevirtual

Updates the absolute position by looping through all parents and adding up their relative positions.

Reimplemented in modm::gui::WidgetGroup.

Member Data Documentation

modm::glcd::Point modm::gui::Widget::position

position on screen (used for rendering), may be recomputed based on relative position


The documentation for this class was generated from the following files: