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
BoolControl.h
Go to the documentation of this file.
1
5
6#ifndef BOOLCONTROL_H_
7#define BOOLCONTROL_H_
8
10
20
21#define DEFAULT_BOOLCONTROL_TOGGLESWITCH_WIDTH 40
22#define DEFAULT_BOOLCONTROL_TOGGLESWITCH_HEIGHT 20
23#define DEFAULT_BOOLCONTROL_TOGGLESWITCH_SLIDER_SPACING 3
24
25#define DEFAULT_BOOLCONTROL_CHECKBOX_SIZE 20
26#define DEFAULT_BOOLCONTROL_CHECKBOX_CHECK_SPACING 3
27
31class BoolControl : public UIElement
32{
33 protected:
37
38 public:
40 void(*OnValueChanged)(void* controlContext);
41
51 BoolControl(bool* valuePointer, void* controlContext = NULL, void(*onValueChanged)(void* controlContext) = NULL, BoolControlStyles_t style = BOOLCONTROL_STYLE_TOGGLESWITCH, uint16_t locX = 0, uint16_t locY = 0);
52
56 virtual void Draw(bool redraw) override;
57
64 virtual bool KeyInput(Keys_t key) override;
65
73 virtual bool TouchInput(uint16_t x, uint16_t y, TouchTypes touchType) override;
74
78 void ToggleValue();
79
83 virtual void RecalculateDimensions() override;
84};
85
86#endif /* BOOLCONTROL_H_ */
enum BoolControlStyles BoolControlStyles_t
Available boolean control styles.
BoolControlStyles
Available boolean control styles.
Definition BoolControl.h:15
@ BOOLCONTROL_STYLE_TOGGLESWITCH
The boolean control is styled like a toggle switch.
Definition BoolControl.h:16
@ BOOLCONTROL_STYLE_CHECKBOX
The boolean control is styled like a check box.
Definition BoolControl.h:17
@ BOOLCONTROL_STYLE_CLASSIC
The boolean control is styled with a rectangle with ON/OFF text.
Definition BoolControl.h:18
Containing a class for a boolean indicator that is only showing a boolean variable value.
enum Keys Keys_t
Available input keys.
TouchTypes
Available touch types.
Definition TouchTypes.h:13
void ToggleValue()
Toggle the value of the boolean variable referenced by the valuePointer.
Definition BoolControl.cpp:103
virtual void RecalculateDimensions() override
Recalculate the Height and Width of the UIElement.
Definition BoolControl.cpp:109
virtual bool KeyInput(Keys_t key) override
Process the given key.
Definition BoolControl.cpp:81
BoolControlStyles_t _style
Style used by the boolean control.
Definition BoolControl.h:36
BoolControl(bool *valuePointer, void *controlContext=NULL, void(*onValueChanged)(void *controlContext)=NULL, BoolControlStyles_t style=BOOLCONTROL_STYLE_TOGGLESWITCH, uint16_t locX=0, uint16_t locY=0)
Constructor of the BoolControl.
Definition BoolControl.cpp:8
virtual bool TouchInput(uint16_t x, uint16_t y, TouchTypes touchType) override
Process a touch input at the given point (x, y)
Definition BoolControl.cpp:93
bool * _valuePointer
Pointer to the boolean variable that is shown by this control.
Definition BoolControl.h:34
void(* OnValueChanged)(void *controlContext)
Function pointer for OnValueChanged event.
Definition BoolControl.h:40
virtual void Draw(bool redraw) override
Method used for drawing of the BoolControl.
Definition BoolControl.cpp:16
bool _lastValueDraw
Last drawn bool value.
Definition BoolControl.h:35
void * ControlContext
Context pointer that is returned with the OnValueChanged function pointer.
Definition BoolControl.h:39
UIElement(UIElementType type)
Constructor of the UIElement.
Definition UIElement.h:43