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.h
Go to the documentation of this file.
1
5
6#ifndef CONTAINER_H_
7#define CONTAINER_H_
8
9#include "../Core/UIElement.h"
10
11#define DEFAULT_MAX_CONTAINER_ITEMS 20
12
16class Container : public UIElement
17{
18 protected:
19 uint8_t _maxNumItems;
21 uint8_t _numItems;
23
24 public:
29 Container(uint8_t maxNumItems = DEFAULT_MAX_CONTAINER_ITEMS);
30
35 {
36 delete _items;
37 _items = NULL;
38 }
39
43 virtual void Draw() { } //= 0;
44
53 virtual bool KeyInput(Keys_t key) { return false; } // = 0;
54
61
67 bool AddItem(UIElement* item);
68
72 void ClearAllItems();
73
78 bool NextItem();
79
84 bool PreviousItem();
85
90 bool NextControlItem();
91
97
105 void GetItemsBoundingBox(uint16_t* x, uint16_t* y, uint16_t* w, uint16_t* h);
106};
107
108#endif /* CONTAINER_H_ */
#define DEFAULT_MAX_CONTAINER_ITEMS
Default maximum number of items, each container can hold.
Definition Container.h:11
enum Keys Keys_t
Available input keys.
Containing the abstract base class for all user interface elements (controls, indicators,...
uint8_t _numItems
Number of items in the container (number of valid items in the _items array).
Definition Container.h:21
bool PreviousControlItem()
Select the previous item in the container that is of UI_CONTROL type.
Definition Container.cpp:109
bool NextItem()
Select the next item in the container.
Definition Container.cpp:45
bool PreviousItem()
Select the previous item in the container.
Definition Container.cpp:63
bool NextControlItem()
Select the next item in the container that is of UI_CONTROL type.
Definition Container.cpp:81
void GetItemsBoundingBox(uint16_t *x, uint16_t *y, uint16_t *w, uint16_t *h)
Get a bounding box around all items in the Container.
Definition Container.cpp:137
uint8_t _selectedItemIndex
Index of the selected container item.
Definition Container.h:22
virtual void Draw()
Virtual method used for drawing of the container UIElement.
Definition Container.h:43
bool AddItem(UIElement *item)
Add a new element to the container and activate it as active child.
Definition Container.cpp:19
Container(uint8_t maxNumItems=DEFAULT_MAX_CONTAINER_ITEMS)
Constructor of the Container.
Definition Container.cpp:7
uint8_t _maxNumItems
Maximum number of items, each container can hold.
Definition Container.h:19
UIElement ** _items
Array holding pointers to all UIElement that are items of the container.
Definition Container.h:20
void ClearAllItems()
Clear all items in the container.
Definition Container.cpp:32
UIElement * GetSelectedItem()
Get the selected item.
Definition Container.cpp:14
virtual bool KeyInput(Keys_t key)
Process the given key.
Definition Container.h:53
~Container()
Destructor of the Container.
Definition Container.h:34
Abstract base class for all user interface elements (controls, indicators, containers).
Definition UIElement.h:24
UIElement(UIElementType type)
Constructor of the UIElement.
Definition UIElement.h:43