UI_Lib  a1366e08a59cc549a65fa26081e6409aa12f26d5
This is a user interface library for graphical LCDs. It offers many different controls and indicators that can be nested depending on the element types.
Loading...
Searching...
No Matches
Container Class Reference

Base class for container elements. More...

#include <Container.h>

Inheritance diagram for Container:
UIElement ContainerGrid ContainerList ContainerPage ContainerStack ContainerTabs

Public Member Functions

 Container (uint8_t maxNumItems=DEFAULT_MAX_CONTAINER_ITEMS)
 Constructor of the Container.
 
 ~Container ()
 Destructor of the Container.
 
virtual void Draw ()
 Virtual method used for drawing of the container UIElement.
 
virtual bool KeyInput (Keys_t key)
 Process the given key.
 
UIElementGetSelectedItem ()
 Get the selected item.
 
bool AddItem (UIElement *item)
 Add a new element to the container and activate it as active child.
 
void ClearAllItems ()
 Clear all items in the container.
 
bool NextItem ()
 Select the next item in the container.
 
bool PreviousItem ()
 Select the previous item in the container.
 
bool NextControlItem ()
 Select the next item in the container that is of UI_CONTROL type.
 
bool PreviousControlItem ()
 Select the previous item in the container that is of UI_CONTROL type.
 
void GetItemsBoundingBox (uint16_t *x, uint16_t *y, uint16_t *w, uint16_t *h)
 Get a bounding box around all items in the Container.
 
- Public Member Functions inherited from UIElement
 UIElement (UIElementType type)
 Constructor of the UIElement.
 
 UIElement (uint16_t locX, uint16_t locY, UIElementType type)
 Constructor of the UIElement.
 
virtual void Draw (bool redraw)=0
 Virtual method used for drawing of the UIElement.
 
virtual bool TouchInput (uint16_t x, uint16_t y, TouchTypes touchType)
 Process a touch input at the given point (x, y)
 
virtual void RecalculateDimensions ()=0
 Recalculate the Height and Width of the UIElement.
 
virtual void RecalculateLayout ()
 Recalculate the UIElement layout (containers update the X- and Y-Location of all their items, all other items can do other layout update stuff)
 
bool HitTest (uint16_t x, uint16_t y)
 Check if the given point (x, y) is inside this UIElement.
 

Protected Attributes

uint8_t _maxNumItems
 Maximum number of items, each container can hold.
 
UIElement ** _items
 Array holding pointers to all UIElement that are items of the container.
 
uint8_t _numItems
 Number of items in the container (number of valid items in the _items array).
 
uint8_t _selectedItemIndex
 Index of the selected container item.
 
- Protected Attributes inherited from UIElement
bool _lastDrawnVisible
 The Visible value that was last drawn.
 

Additional Inherited Members

- Public Attributes inherited from UIElement
UIElementType Type
 Element type (control, indicator, container)
 
uint16_t LocX
 X Location of the upper left corner of the UIElement.
 
uint16_t LocY
 Y Location of the upper left corner of the UIElement.
 
uint16_t Width
 Drawing width of the UIElement.
 
uint16_t Height
 Drawing height of the UIElement.
 
bool Visible
 The UIElement is only drawn if the visibility is set to true.
 
bool IsInEditMode
 Is the UIElement in edit mode?
 
UIElementParent
 Parent UIElement that this UIElement belongs to.
 
UIElementActiveChild
 Child element that is currently active (receiving all key inputs).
 

Detailed Description

Base class for container elements.

Constructor & Destructor Documentation

◆ Container()

Container::Container ( uint8_t maxNumItems = DEFAULT_MAX_CONTAINER_ITEMS)

Constructor of the Container.

Parameters
maxNumItemsMaximum number of items, each container can hold. Lower this value if you don't need that much items to save memory.

Member Function Documentation

◆ AddItem()

bool Container::AddItem ( UIElement * item)

Add a new element to the container and activate it as active child.

Parameters
itemPointer to the UIElement that should be added to the container.
Returns
true, if added; otherwise false (if container is full)

◆ GetItemsBoundingBox()

void Container::GetItemsBoundingBox ( uint16_t * x,
uint16_t * y,
uint16_t * w,
uint16_t * h )

Get a bounding box around all items in the Container.

Parameters
xX coordinate of the upper left corner of the bounding box
yY coordinate of the upper left corner of the bounding box
wWidth of the bounding box
hHeight of the bounding box

◆ GetSelectedItem()

UIElement * Container::GetSelectedItem ( )

Get the selected item.

This is the UIElement in the _items array at the _selectedItemIndex.

Returns
Pointer to the selected UIElement in the container.

◆ KeyInput()

virtual bool Container::KeyInput ( Keys_t key)
inlinevirtual

Process the given key.

This method can be overwritten in all derived classes. If it's not overwritten, no keys are supported by the container UIElement. If this element doesn't support the key type, the key is forwarded to the parent. This is done until the key is processed or the root of the visual tree is reached.

Parameters
keyKey that should be processed.
Returns
true if the key was processed; false if not.

Reimplemented from UIElement.

Reimplemented in ContainerGrid, ContainerList, ContainerPage, ContainerStack, and ContainerTabs.

◆ NextControlItem()

bool Container::NextControlItem ( )

Select the next item in the container that is of UI_CONTROL type.

Returns
true if there was a next control item (if the selected item wasn't the last one).

◆ NextItem()

bool Container::NextItem ( )

Select the next item in the container.

Returns
true if there was a next item (if the selected item wasn't the last one).

◆ PreviousControlItem()

bool Container::PreviousControlItem ( )

Select the previous item in the container that is of UI_CONTROL type.

Returns
true if there was a previous control item (if the selected item wasn't the first one).

◆ PreviousItem()

bool Container::PreviousItem ( )

Select the previous item in the container.

Returns
true if there was a previous item (if the selected item wasn't the first one).

Member Data Documentation

◆ _maxNumItems

uint8_t Container::_maxNumItems
protected

Maximum number of items, each container can hold.

Lower this value if you don't need that much items to save memory.


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