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
Label.h
Go to the documentation of this file.
1
5
6#ifndef LABEL_H_
7#define LABEL_H_
8
9#include "../Core/UIElement.h"
10#include "../Core/UI_Manager.h"
11
12#define DEFAULT_LABEL_STRING_LENGTH 50
13#define LABEL_COLOR_NOTSET RGB565(0x2B, 0x23, 0x10)
14
18class Label : public UIElement
19{
20 private:
22 const GFXfont* _font;
23 uint16_t _color;
24
25 public:
26 char* Text;
28
38 Label(const char* text, uint16_t color = LABEL_COLOR_NOTSET, const GFXfont* font = NULL, uint16_t locX = 0, uint16_t locY = 0, uint16_t maxStringLength = DEFAULT_LABEL_STRING_LENGTH);
39
44 {
45 delete Text;
46 Text = NULL;
47 }
48
52 virtual void Draw(bool redraw) override;
53
58 void SetText(const char* text);
59
63 virtual void RecalculateDimensions() override;
64};
65
66#endif /* LABEL_H_ */
#define DEFAULT_LABEL_STRING_LENGTH
Default string length for a label.
Definition Label.h:12
#define LABEL_COLOR_NOTSET
Define one color that is used to indicate that the user doesn't set the color.
Definition Label.h:13
Containing a class that is used to handle the drawing and key handling of all UI_Elements.
Containing the abstract base class for all user interface elements (controls, indicators,...
virtual void RecalculateDimensions() override
Recalculate the Height and Width of the UIElement.
Definition Label.cpp:67
~Label()
Destructor of the Label.
Definition Label.h:43
const GFXfont * _font
Font that is used to draw the Label.
Definition Label.h:22
Label(const char *text, uint16_t color=LABEL_COLOR_NOTSET, const GFXfont *font=NULL, uint16_t locX=0, uint16_t locY=0, uint16_t maxStringLength=DEFAULT_LABEL_STRING_LENGTH)
Constructor of the Label.
Definition Label.cpp:8
void SetText(const char *text)
Change the string that is drawn to the screen by this Label.
Definition Label.cpp:60
virtual void Draw(bool redraw) override
Method used for drawing of the Label.
Definition Label.cpp:17
char * Text
Character buffer holding the string drawn by the Label.
Definition Label.h:26
bool WasTextChangedSinceLastDraw
Flag indicating if the Text was changed since the last draw.
Definition Label.h:27
uint16_t _color
Text color that is used to draw the Label.
Definition Label.h:23
uint16_t _maxStringLength
Maximum string length that the Label can hold.
Definition Label.h:21
UIElement(UIElementType type)
Constructor of the UIElement.
Definition UIElement.h:43