The Checkbox Gui-Element is a clickable, rectangular box with an optional tickmark inside of it. When the checkbox is pressed and released it's tick state changes and you will be notified via the provided callback.
#define CHECKBOX_WIN_FG_COLOR RGB(32,161,34) |
typedef void(* CHECKBOX_CALLBACK) (void *checkbox, bool checked) |
Prototype for Event Listeners (called when the checkbox state has changed)
- Note
- You should NOT execute long running things in this callback nor should you update the gui. But you can call gui_screen_navigate() for instance.
- Parameters
-
checkbox | The pointer to the CHECKBOX_STRUCT where to corresponding Checkbox has changed the state |
checked | A boolean which indicates whether the checkbox is now checked or not. |
Definition at line 45 of file checkbox.h.
Adds a checkbox. Your Callback will be called from now on, if the checkbox changes state
- Parameters
-
- Returns
- true on success
Definition at line 70 of file checkbox.c.
73 unsigned char size = 0;
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Receive an event when the pen goes down inside the region.
uint16_t y1
Top Left Y-Coordinate of Area.
uint16_t x1
Top Left X-Coordinate of Area.
uint16_t y2
Bottom Right Y-Coordinate of Area.
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
uint16_t x2
Bottom Right X-Coordinate of Area.
TOUCH_ACTION hookedActions
Actions to listen to.
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
bool touch_have_empty(unsigned char num)
void gui_checkbox_redraw(CHECKBOX_STRUCT *checkbox)
void checkboxes_cb(void *touchArea, TOUCH_ACTION triggeredAction)
Redraws the checkbox. Call this method if you have to redraw the entire screen or if you want to draw a checkbox on top of an image.
- Parameters
-
Definition at line 108 of file checkbox.c.
uint16_t y1
Top Left Y-Coordinate of Area.
void gui_checkbox_update(CHECKBOX_STRUCT *checkbox)
uint16_t x1
Top Left X-Coordinate of Area.
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
uint16_t y2
Bottom Right Y-Coordinate of Area.
uint16_t x2
Bottom Right X-Coordinate of Area.
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Removes the checkbox. You will no longer receive events for this checkbox. This function will not overdraw the region where the checkbox was located.
- Parameters
-
Definition at line 119 of file checkbox.c.
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Updates the checkbox. Call this function when you change the state of the checkbox through code.
- Parameters
-
Definition at line 125 of file checkbox.c.
130 unsigned int xcent = checkbox->
base.
x1 + (checkbox->
base.
x2 - checkbox->
base.
x1) * 6 / 14;
131 unsigned int yleft = checkbox->
base.
y2 - (xcent - checkbox->
base.
x1) - 1 ;
132 unsigned int yright = checkbox->
base.
y2 - (checkbox->
base.
x2 - xcent) - 1 ;
133 unsigned int ybot = checkbox->
base.
y2 - 4;
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
uint16_t x1
Top Left X-Coordinate of Area.
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
uint16_t y2
Bottom Right Y-Coordinate of Area.
uint16_t x2
Bottom Right X-Coordinate of Area.
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
uint16_t fgcolor
The 16-bit color of the tickmark.