MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_radiobutton.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_radiobutton.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements radio button widget functions.
38 *******************************************************************************/
39 
46 #ifndef LEGATO_RADIOBUTTON_H
47 #define LEGATO_RADIOBUTTON_H
48 
50 
51 #if LE_RADIOBUTTON_WIDGET_ENABLED == 1
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
61 
62 typedef struct leRadioButtonWidget leRadioButtonWidget;
63 typedef struct leRadioButtonGroup leRadioButtonGroup;
64 
65 // *****************************************************************************
66 /* Function Pointer:
67  leRadioButtonWidget_SelectedEvent
68 
69  Summary:
70  Radio button selected function callback type
71 */
78 typedef void (* leRadioButtonWidget_SelectedEvent)(leRadioButtonWidget*);
79 
80 // *****************************************************************************
81 /* Function Pointer:
82  leRadioButtonWidget_DeselectedEvent
83 
84  Summary:
85  Radio button deselected function callback type
86 */
93 typedef void (* leRadioButtonWidget_DeselectedEvent)(leRadioButtonWidget*);
94 
95 // *****************************************************************************
96 // *****************************************************************************
97 // Section: Data Types and Constants
98 // *****************************************************************************
99 // *****************************************************************************
100 
101 /* internal use only */typedef struct leRadioButtonWidget leRadioButtonWidget;
106 
107 #define LE_RADIOBUTTONWIDGET_VTABLE(THIS_TYPE) \
108  LE_WIDGET_VTABLE(THIS_TYPE) \
109  \
110  leRadioButtonGroup* (*getGroup)(const THIS_TYPE* _this); \
111  leBool (*getSelected)(const THIS_TYPE* _this); \
112  leResult (*setSelected)(THIS_TYPE* _this); \
113  void (*select)(THIS_TYPE* _this); \
114  void (*deselect)(THIS_TYPE* _this); \
115  leString* (*getString)(const THIS_TYPE* _this); \
116  leResult (*setString)(THIS_TYPE* _this, const leString* str); \
117  leImage* (*getSelectedImage)(const THIS_TYPE* _this); \
118  leResult (*setSelectedImage)(THIS_TYPE* _this, const leImage* img); \
119  leImage* (*getUnselectedImage)(const THIS_TYPE* _this); \
120  leResult (*setUnselectedImage)(THIS_TYPE* _this, const leImage* img); \
121  leRelativePosition (*getImagePosition)(const THIS_TYPE* _this); \
122  leResult (*setImagePosition)(THIS_TYPE* _this, leRelativePosition pos); \
123  uint32_t (*getImageMargin)(const THIS_TYPE* _this); \
124  leResult (*setImageMargin)(THIS_TYPE* _this, uint32_t mg); \
125  leRadioButtonWidget_SelectedEvent (*getSelectedEventCallback)(const THIS_TYPE* _this); \
126  leResult (*setSelectedEventCallback)(THIS_TYPE* _this, leRadioButtonWidget_SelectedEvent cb); \
127  leRadioButtonWidget_DeselectedEvent (*getDeselectedEventCallback)(const THIS_TYPE* _this); \
128  leResult (*setDeselectedEventCallback)(THIS_TYPE* _this, leRadioButtonWidget_DeselectedEvent cb); \
129  uint32_t (*getCircleButtonSize)(const THIS_TYPE* _this); \
130  leResult (*setCircleButtonSize)(THIS_TYPE* _this, uint32_t sz); \
131 
132 typedef struct leRadioButtonWidgetVTable
133 {
134  LE_RADIOBUTTONWIDGET_VTABLE(leRadioButtonWidget)
135 } leRadioButtonWidgetVTable;
136 
142 // *****************************************************************************
143 /* Enumeration:
144  leRadioButtonWidget
145 
146  Summary:
147  Implementation of a radio button widget struct
148 
149  Description:
150  A radio button is similar to a checkbox widget in that it has an on and
151  off state. It is further capable of being added to a radio button group.
152  This group provides a mutually exclusive selection capability so that
153  only one radio button may be selected at any one time.
154 
155  Remarks:
156  None.
157 */
165 typedef struct leRadioButtonWidget
166 {
167  leWidget widget; // widget base class
168 
169  const leRadioButtonWidgetVTable* fn;
170 
171  leBool selected; // indicates if the radio button is selected
172 
173  const leString* string; // radio button text
174 
175  const leImage* selectedImage; // button custom selected image
176  const leImage* unselectedImage; // buton custom unselected image
177 
178  leRelativePosition imagePosition; // image icon relative position
179 
180  uint32_t imageMargin; // image margin
181  uint32_t circleButtonSize; // size of radio circle button in pixels
182 
183  leRadioButtonWidget_SelectedEvent selectedEvent; // button selected event callback
184  leRadioButtonWidget_DeselectedEvent deselectedEvent; // button deselected event callback
185 
186  leRadioButtonGroup* group; // radio button group
187 } leRadioButtonWidget;
188 
189 
190 // *****************************************************************************
191 // *****************************************************************************
192 // Section: Routines
193 // *****************************************************************************
194 // *****************************************************************************
195 
196 // *****************************************************************************
197 /* Function:
198  leRadioButtonWidget* leRadioButtonWidget_New()
199 
200  Summary:
201  Allocates memory for a new widget of this type. The application is
202  responsible for the managment of this memory until the widget is added to
203  a widget tree.
204 
205  Description:
206 
207 
208  Parameters:
209 
210  Returns:
211  leRadioButtonWidget*
212 
213  Remarks:
214  Use leWidget_Delete() to free this pointer.
215 */
227 leRadioButtonWidget* leRadioButtonWidget_New(void);
228 
239 void leRadioButtonWidget_Constructor(leRadioButtonWidget* wgt);
240 
241 #ifdef _DOXYGEN_
242 #define THIS_TYPE struct leWidget
243 
244 
245 // *****************************************************************************
246 /* Virtual Member Function:
247  leRadioButtonGroup* getGroup(const leRadioButtonWidget* _this)
248 
249  Summary:
250  Gets the button's group pointer
251 
252  Description:
253  Gets the button's group pointer
254 
255  Parameters:
256  const leRadioButtonWidget* _this - The radio button widget to operate on
257 
258  Remarks:
259  Usage - _this->fn->getGroup(_this);
260 
261  Returns:
262  leRadioButtonGroup* - the radio button group
263 */
274 virtual leBool getSelected(const leRadioButtonWidget* _this);
275 
276 // *****************************************************************************
277 /* Virtual Member Function:
278  leBool getSelected(const leRadioButtonWidget* _this)
279 
280  Summary:
281  Gets the button's selection state
282 
283  Description:
284  Gets the button's selection state
285 
286  Parameters:
287  const leRadioButtonWidget* _this - The radio button widget to operate on
288 
289  Remarks:
290  Usage - _this->fn->getSelected(_this);
291 
292  Returns:
293  leBool - the selected state
294 */
305 virtual leBool getSelected(const leRadioButtonWidget* _this);
306 
307 
308 // *****************************************************************************
309 /* Virtual Member Function:
310  leResult setSelected(leRadioButtonWidget* _this)
311 
312  Summary:
313  Selects the button
314 
315  Description:
316  Selects the button
317 
318  Parameters:
319  leRadioButtonWidget* _this - The radio button widget to operate on
320 
321  Remarks:
322  Usage - _this->fn->setSelected(_this);
323 
324  Returns:
325  leResult - the result of the operation
326 */
337 virtual leResult setSelected(leRadioButtonWidget* _this);
338 
339 
340 // *****************************************************************************
341 /* Virtual Member Function:
342  void selected(leRadioButtonWidget* _this)
343 
344  Summary:
345  internal use only
346 */
347 
348 // *****************************************************************************
349 /* Virtual Member Function:
350  void deselected(leRadioButtonWidget* _this)
351 
352  Summary:
353  internal use only
354 */
355 
356 // *****************************************************************************
357 /* Virtual Member Function:
358  leString* getString(const leRadioButtonWidget* _this)
359 
360  Summary:
361  Gets the text string pointer
362 
363  Description:
364  Gets the text string pointer
365 
366  Parameters:
367  const leRadioButtonWidget* _this - The radio button widget to operate on
368 
369  Remarks:
370  Usage - _this->fn->getString(_this);
371 
372  Returns:
373  leString* - the string pointer
374 */
385 virtual leString* getString(const leRadioButtonWidget* _this);
386 
387 // *****************************************************************************
388 /* Virtual Member Function:
389  leResult setString(leRadioButtonWidget* _this,
390  const leString* str)
391 
392  Summary:
393  Sets the text string pointer
394 
395  Description:
396  Sets the text string pointer
397 
398  Parameters:
399  leRadioButtonWidget* _this - The radio button widget to operate on
400  const leString* str - the string pointer
401 
402  Remarks:
403  Usage - _this->fn->setString(_this, str);
404 
405  Returns:
406  leResult - the result of the operation
407 */
421 virtual leResult setString(leRadioButtonWidget* _this,
422  const leString* str);
423 
424 
425 // *****************************************************************************
426 /* Virtual Member Function:
427  leImage* getSelectedImage(const leRadioButtonWidget* _this)
428 
429  Summary:
430  Gets the selected image pointer
431 
432  Description:
433  Gets the selected image pointer
434 
435  Parameters:
436  const leRadioButtonWidget* _this - The radio button widget to operate on
437 
438  Remarks:
439  Usage - _this->fn->getSelectedImage(_this);
440 
441  Returns:
442  leImage* - the image pointer
443 */
454 virtual leString* getString(const leRadioButtonWidget* _this);
455 
456 
457 // *****************************************************************************
458 /* Virtual Member Function:
459  leResult setSelectedImage(leRadioButtonWidget* _this,
460  const leImage* img)
461 
462  Summary:
463  Sets the selected image pointer
464 
465  Description:
466  Sets the selected image pointer
467 
468  Parameters:
469  leRadioButtonWidget* _this - The radio button widget to operate on
470  const leImage* img - the image pointer
471 
472  Remarks:
473  Usage - _this->fn->setSelectedImage(_this, img);
474 
475  Returns:
476  leResult - the result of the operation
477 */
491 virtual leResult setSelectedImage(leRadioButtonWidget* _this,
492  const leImage* img);
493 
494 
495 // *****************************************************************************
496 /* Virtual Member Function:
497  leImage* getUnselectedImage(const leRadioButtonWidget* _this)
498 
499  Summary:
500  Gets the unselected image pointer
501 
502  Description:
503  Gets the unselected image pointer
504 
505  Parameters:
506  const leRadioButtonWidget* _this - The radio button widget to operate on
507 
508  Remarks:
509  Usage - _this->fn->getUnselectedImage(_this);
510 
511  Returns:
512  leImage* - the image pointer
513 */
524 virtual leImage* getUnselectedImage(const leRadioButtonWidget* _this);
525 
526 // *****************************************************************************
527 /* Virtual Member Function:
528  leResult setUnselectedImage(leRadioButtonWidget* _this,
529  const leImage* img)
530 
531  Summary:
532  Sets the unselected image pointer
533 
534  Description:
535  Sets the unselected image pointer
536 
537  Parameters:
538  leRadioButtonWidget* _this - The radio button widget to operate on
539  const leImage* img - the image pointer
540 
541  Remarks:
542  Usage - _this->fn->setUnselectedImage(_this, img);
543 
544  Returns:
545  leResult - the result of the operation
546 */
560 virtual leResult setUnselectedImage(leRadioButtonWidget* _this,
561  const leImage* img);
562 
563 // *****************************************************************************
564 /* Virtual Member Function:
565  leRelativePosition getImagePosition(const leRadioButtonWidget* _this)
566 
567  Summary:
568  Gets the image position
569 
570  Description:
571  Gets the image position
572 
573  Parameters:
574  const leRadioButtonWidget* _this - The radio button widget to operate on
575 
576  Remarks:
577  Usage - _this->fn->getImagePosition(_this);
578 
579  Returns:
580  leRelativePosition - the position
581 */
592 virtual leRelativePosition getImagePosition(const leRadioButtonWidget* _this);
593 
594 // *****************************************************************************
595 /* Virtual Member Function:
596  leResult setImagePosition(leRadioButtonWidget* _this,
597  leRelativePosition pos)
598 
599  Summary:
600  Sets the image position
601 
602  Description:
603  Sets the image position
604 
605  Parameters:
606  leRadioButtonWidget* _this - The radio button widget to operate on
607  leRelativePosition pos - the position value
608 
609  Remarks:
610  Usage - _this->fn->setImagePosition(_this, pos);
611 
612  Returns:
613  leResult - the result of the operation
614 */
628 virtual leResult setImagePosition(leRadioButtonWidget* _this,
629  leRelativePosition pos);
630 
631 
632 // *****************************************************************************
633 /* Virtual Member Function:
634  uint32_t getImageMargin(const leRadioButtonWidget* _this)
635 
636  Summary:
637  Gets the image margin
638 
639  Description:
640  Gets the image margin
641 
642  Parameters:
643  const leRadioButtonWidget* _this - The radio button widget to operate on
644 
645  Remarks:
646  Usage - _this->fn->getImageMargin(_this);
647 
648  Returns:
649  uint32_t - the margin value
650 */
661 virtual uint32_t getImageMargin(const leRadioButtonWidget* _this);
662 
663 // *****************************************************************************
664 /* Virtual Member Function:
665  leResult setImageMargin(leRadioButtonWidget* _this,
666  uint32_t mg)
667 
668  Summary:
669  Sets the image margin
670 
671  Description:
672  Sets the image margin
673 
674  Parameters:
675  leRadioButtonWidget* _this - The radio button widget to operate on
676  uint32_t mg - the margin value
677 
678  Remarks:
679  Usage - _this->fn->setImageMargin(_this, mg);
680 
681  Returns:
682  leResult - the result of the operation
683 */
697 virtual leResult setImageMargin(leRadioButtonWidget* _this,
698  uint32_t mg);
699 
700 // *****************************************************************************
711 uint32_t getCircleButtonSize(const leRadioButtonWidget* _this);
712 
713 // *****************************************************************************
727 virtual leResult setCircleButtonSize(leRadioButtonWidget* _this,
728  uint32_t sz);
729 
740 virtual leRadioButtonWidget_SelectedEvent getSelectedEventCallback
741  (const leRadioButtonWidget* _this);
742 
756 virtual leResult setSelectedEventCallback(leRadioButtonWidget* _this,
757  leRadioButtonWidget_SelectedEvent cb);
758 
769 virtual leRadioButtonWidget_DeselectedEvent getDeselectedEventCallback
770  (const leRadioButtonWidget* _this);
771 
785 virtual leResult setDeselectedEventCallback(leRadioButtonWidget* _this,
786  leRadioButtonWidget_DeselectedEvent cb);
787 
788 #undef THIS_TYPE
789 #endif
790 
791 #ifdef __cplusplus
792 }
793 #endif
794 
795 #endif // LE_RADIOBUTTON_WIDGET_ENABLED
796 #endif /* LEGATO_RADIOBUTTON_H */
Radiobutton widget functions and definitions.
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.