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
ContainerTabs.h
Go to the documentation of this file.
1
5
6#ifndef ContainerTabs_H_
7#define ContainerTabs_H_
8
9#include "Container.h"
10
11#define DEFAULT_MAX_ContainerTabs_TABS 5
12#define DEFAULT_ContainerTabs_TABHEADER_MARGIN 2
13
22
27{
28 private:
33
35 void(*_onSelectedTabChanged)(void* controlContext);
36
37 public:
38 uint16_t TabRegionSize;
39
50 ContainerTabs(uint16_t width, uint16_t height, TabPositions_t tabPosition = TAB_POSITION_LEFT, void* controlContext = NULL, void(*onSelectedTabChanged)(void* controlContext) = NULL, uint8_t maxNumItems = DEFAULT_MAX_ContainerTabs_TABS, uint8_t tabHeaderMargin = DEFAULT_ContainerTabs_TABHEADER_MARGIN);
51
64 ContainerTabs(uint16_t locX, uint16_t locY, uint16_t width, uint16_t height, TabPositions_t tabPosition = TAB_POSITION_LEFT, void* controlContext = NULL, void(*onSelectedTabChanged)(void* controlContext) = NULL, uint8_t maxNumItems = DEFAULT_MAX_ContainerTabs_TABS, uint8_t tabHeaderMargin = DEFAULT_ContainerTabs_TABHEADER_MARGIN);
65
70 {
71 delete _headers;
72 _headers = NULL;
73 }
74
78 virtual void Draw(bool redraw) override;
79
86 virtual bool KeyInput(Keys_t key) override;
87
95 virtual bool TouchInput(uint16_t x, uint16_t y, TouchTypes touchType) override;
96
103 bool AddItem(UIElement* header, UIElement* tabContent);
104
109 void SelectTab(int index);
110
115
121 void GetContentRegionSize(uint16_t* w, uint16_t* h);
122
126 virtual void RecalculateDimensions() override;
127
131 virtual void RecalculateLayout() override;
132};
133
134#endif /* ContainerTabs_H_ */
Containing the base class for container elements.
#define DEFAULT_MAX_ContainerTabs_TABS
Maximum number of tabs that are supported.
Definition ContainerTabs.h:11
#define DEFAULT_ContainerTabs_TABHEADER_MARGIN
Margin around the tab page tabs.
Definition ContainerTabs.h:12
enum TabPositions TabPositions_t
Available tab positions.
TabPositions
Available tab positions.
Definition ContainerTabs.h:18
@ TAB_POSITION_TOP
Tabs are on the top.
Definition ContainerTabs.h:20
@ TAB_POSITION_LEFT
Tabs are on the left side.
Definition ContainerTabs.h:19
enum Keys Keys_t
Available input keys.
TouchTypes
Available touch types.
Definition TouchTypes.h:13
virtual void Draw()
Virtual method used for drawing of the container UIElement.
Definition Container.h:43
Container(uint8_t maxNumItems=DEFAULT_MAX_CONTAINER_ITEMS)
Constructor of the Container.
Definition Container.cpp:7
TabPositions_t _tabPosition
Position of the tabs.
Definition ContainerTabs.h:31
virtual void RecalculateLayout() override
Recalculate the UIElement layout (containers update the X- and Y-Location of all their items,...
Definition ContainerTabs.cpp:205
int GetSelectedTabIndex()
Return the value of the selected tab index.
Definition ContainerTabs.cpp:165
UIElement ** _headers
Array with all tab page tab header elements.
Definition ContainerTabs.h:29
virtual void RecalculateDimensions() override
Recalculate the Height and Width of the UIElement.
Definition ContainerTabs.cpp:186
uint16_t TabRegionSize
Width or height of the Tabs in pixel.
Definition ContainerTabs.h:38
ContainerTabs(uint16_t width, uint16_t height, TabPositions_t tabPosition=TAB_POSITION_LEFT, void *controlContext=NULL, void(*onSelectedTabChanged)(void *controlContext)=NULL, uint8_t maxNumItems=DEFAULT_MAX_ContainerTabs_TABS, uint8_t tabHeaderMargin=DEFAULT_ContainerTabs_TABHEADER_MARGIN)
Constructor of the ContainerTabs.
Definition ContainerTabs.cpp:9
void SelectTab(int index)
Select the tab at the requested index (after range checking).
Definition ContainerTabs.cpp:154
~ContainerTabs()
Destructor of the ContainerTabs.
Definition ContainerTabs.h:69
bool AddItem(UIElement *header, UIElement *tabContent)
Add a new tab to the tab control.
Definition ContainerTabs.cpp:142
void GetContentRegionSize(uint16_t *w, uint16_t *h)
Get the size of the content region of the ContainerTabs.
Definition ContainerTabs.cpp:170
virtual bool KeyInput(Keys_t key) override
Definition ContainerTabs.cpp:93
uint8_t _tabHeaderMargin
Margin around the tab page tabs.
Definition ContainerTabs.h:32
void(* _onSelectedTabChanged)(void *controlContext)
Function pointer for _onSelectedTabChanged event.
Definition ContainerTabs.h:35
void * _controlContext
Context pointer that is returned with the _onSelectedTabChanged function pointer.
Definition ContainerTabs.h:34
virtual bool TouchInput(uint16_t x, uint16_t y, TouchTypes touchType) override
Process a touch input at the given point (x, y)
Definition ContainerTabs.cpp:108
uint8_t _lastDrawnTabIndex
Index of the last drawn tab.
Definition ContainerTabs.h:30
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