MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_checkbox.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries.
3 *
4 * Subject to your compliance with these terms, you may use Microchip software
5 * and any derivatives exclusively with Microchip products. It is your
6 * responsibility to comply with third party license terms applicable to your
7 * use of third party software (including open source software) that may
8 * accompany Microchip software.
9 *
10 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
11 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
12 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
13 * PARTICULAR PURPOSE.
14 *
15 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
16 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
17 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
18 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
19 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
20 * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
21 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
22 *******************************************************************************/
23 
24 /*******************************************************************************
25  Module for Microchip Graphics Library - Legato User Interface Library
26 
27  Company:
28  Microchip Technology Inc.
29 
30  File Name:
31  legato_widget_button.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements button widget functions.
38 *******************************************************************************/
39 
46 #ifndef LEGATO_CHECKBOX_H
47 #define LEGATO_CHECKBOX_H
48 
50 
51 #if LE_CHECKBOX_WIDGET_ENABLED == 1
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
60 
61 typedef struct leCheckBoxWidget leCheckBoxWidget;
62 
63 // *****************************************************************************
64 /* Function Pointer:
65  leCheckBoxWidget_CheckedEvent
66 
67  Summary:
68  Checkbox checked event function callback type
69 */
75 typedef void (*leCheckBoxWidget_CheckedEvent)(leCheckBoxWidget*);
76 
77 // *****************************************************************************
78 /* Function Pointer:
79  leCheckBoxWidget_UncheckedEvent
80 
81  Summary:
82  Checkbox unchecked event function callback type
83 */
89 typedef void (*leCheckBoxWidget_UncheckedEvent)(leCheckBoxWidget*);
90 
91 // *****************************************************************************
92 // *****************************************************************************
93 // Section: Data Types and Constants
94 // *****************************************************************************
95 // *****************************************************************************
96 
97 /* internal use only */
102 typedef struct leCheckBoxWidget leCheckBoxWidget;
103 
104 #define LE_CHECKBOXWIDGET_VTABLE(THIS_TYPE) \
105  LE_WIDGET_VTABLE(THIS_TYPE) \
106  \
107  leBool (*getChecked)(const THIS_TYPE* _this); \
108  leResult (*setChecked)(THIS_TYPE* _this, leBool toggleable); \
109  leImage* (*getCheckedImage)(const THIS_TYPE* _this); \
110  leResult (*setCheckedImage)(THIS_TYPE* _this, leImage* img); \
111  leImage* (*getUncheckedImage)(const THIS_TYPE* _this); \
112  leResult (*setUncheckedImage)(THIS_TYPE* _this, leImage* img); \
113  leRelativePosition (*getImagePosition)(const THIS_TYPE* _this); \
114  leResult (*setImagePosition)(THIS_TYPE* _this, leRelativePosition pos); \
115  uint32_t (*getImageMargin)(const THIS_TYPE* _this); \
116  leResult (*setImageMargin)(THIS_TYPE* _this, uint32_t mg); \
117  leString* (*getString)(const THIS_TYPE* _this); \
118  leResult (*setString)(THIS_TYPE* _this, const leString* str); \
119  leCheckBoxWidget_CheckedEvent (*getCheckedEventCallback)(const THIS_TYPE* _this); \
120  leResult (*setCheckedEventCallback)(THIS_TYPE* _this, leCheckBoxWidget_CheckedEvent cb); \
121  leCheckBoxWidget_UncheckedEvent (*getUncheckedEventCallback)(const THIS_TYPE* _this); \
122  leResult (*setUncheckedEventCallback)(THIS_TYPE* _this, leCheckBoxWidget_UncheckedEvent cb); \
123 
124 
125 typedef struct leCheckBoxWidgetVTable
126 {
127  LE_CHECKBOXWIDGET_VTABLE(leCheckBoxWidget)
128 } leCheckBoxWidgetVTable;
129 
136 // *****************************************************************************
137 /* Structure:
138  leCheckBoxWidget
139 
140  Summary:
141  Implementation of a checkbox widget.
142 
143  Description:
144  A check box widget contains an interactive two-state box indicating on or
145  off. The check box may also contain descriptive text. Custom images for
146  the check box may be used in place of the default box graphic.
147 
148  Remarks:
149  None.
150 */
151 typedef struct leCheckBoxWidget
152 {
153  leWidget widget; // base class properties
154 
155  const leCheckBoxWidgetVTable* fn;
156 
157  leBool checked; // the state of the box
158 
159  const leString* string; // the text of the box
160 
161  const leImage* checkedImage; // pointer to a custom image to use for the
162  // checked image
163  const leImage* uncheckedImage; // pointer to a custom image to use for the
164  // unchecked image
165 
166  leRelativePosition imagePosition; // postition of the image relative to the text
167  // of the box
168  uint32_t imageMargin; // the distance between the image and the text
169 
170  leCheckBoxWidget_CheckedEvent checkedEvent; // callback for checked events
171  leCheckBoxWidget_CheckedEvent uncheckedEvent; // callback for unchecked events
172 } leCheckBoxWidget;
173 
174 // *****************************************************************************
175 // *****************************************************************************
176 // Section: Routines
177 // *****************************************************************************
178 // *****************************************************************************
179 
191 leCheckBoxWidget* leCheckBoxWidget_New(void);
192 
203 void leCheckBoxWidget_Constructor(leCheckBoxWidget* _this);
204 
205 #ifdef _DOXYGEN_
206 #define THIS_TYPE struct leWidget
207 
208 // *****************************************************************************
219 virtual leBool getChecked(const leCheckBoxWidget* _this);
220 
221 
222 // *****************************************************************************
236 virtual leResult setChecked(leCheckBoxWidget* _this,
237  leBool toggleable);
238 
239 
240 // *****************************************************************************
251 virtual leImage* getCheckedImage(const leCheckBoxWidget* _this);
252 
253 // *****************************************************************************
267 virtual leResult setCheckedImage(leCheckBoxWidget* _this,
268  leImage* img);
269 
270 
271 // *****************************************************************************
282 virtual leImage* getUncheckedImage(const leCheckBoxWidget* _this);
283 
284 
285 // *****************************************************************************
299 virtual leResult setUncheckedImage(leCheckBoxWidget* _this,
300  leImage* img);
301 
302 
303 // *****************************************************************************
315 virtual leRelativePosition getImagePosition(const leCheckBoxWidget* _this);
316 
317 
318 // *****************************************************************************
333 virtual setImagePosition(leCheckBoxWidget* _this,
334  leRelativePosition pos);
335 
336 
337 // *****************************************************************************
348 virtual uint32_t getImageMargin(const leCheckBoxWidget* _this);
349 
350 
351 // *****************************************************************************
365 virtual leResult setImageMargin(leCheckBoxWidget* _this,
366  uint32_t mg));
367 
368 
379 virtual leString* getString(const leCheckBoxWidget* _this);
380 
381 
382 // *****************************************************************************
396 virtual setString(leCheckBoxWidget* _this,
397  const leString* str);
398 
399 
411 virtual leCheckBoxWidget_CheckedEvent getCheckedEventCallback(const leCheckBoxWidget* _this);
412 
413 
427 virtual leResult setCheckedEventCallback(leCheckBoxWidget* _this,
428  leCheckBoxWidget_CheckedEvent cb);
429 
430 
442 virtual leCheckBoxWidget_UncheckedEvent getUncheckedEventCallback
443  (const leCheckBoxWidget* _this);
444 
458 virtual leResult setUncheckedEventCallback(leCheckBoxWidget* _this,
459  leCheckBoxWidget_UncheckedEvent cb);
460 
461 #undef THIS_TYPE
462 #endif
463 
464 #ifdef __cplusplus
465 }
466 #endif
467 
468 #endif // LE_CHECKBOX_WIDGET_ENABLED
469 #endif /* LEGATO_BUTTON_H */
Common macros and definitions used by Legato.
Image functions and defintions.
Definition: legato_image.h:181
This struct represents a string.
Definition: legato_string.h:107
leResult
This enum represents function call results.
Definition: legato_common.h:123
Used to define a widget.
Definition: legato_widget.h:624
leRelativePosition
This enum represents the relative position modes for objects.
Definition: legato_common.h:302
Legato widget definitions.
leBool
This enum represents booleans.
Definition: legato_common.h:146
Definition: widget.py:1
Fixed string functions and definitions.