1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** GUIX Component                                                        */
17 /**                                                                       */
18 /**   Button Management (Checkbox)                                        */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_widget.h"
29 #include "gx_button.h"
30 #include "gx_system.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _gx_checkbox_select                                 PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Kenneth Maxwell, Microsoft Corporation                              */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function deselects one button, invalidating and eventing as    */
46 /*    necessary.                                                          */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    checkbox                              Checkbox control block        */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    status                                Completion status             */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _gx_widget_event_generate             Generate event to notify      */
59 /*                                             parent widget              */
60 /*    _gx_system_dirty_mark                 Set the dirty flag            */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    Application Code                                                    */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
71 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
72 /*                                            resulting in version 6.1    */
73 /*                                                                        */
74 /**************************************************************************/
_gx_checkbox_select(GX_CHECKBOX * checkbox)75 UINT  _gx_checkbox_select(GX_CHECKBOX *checkbox)
76 {
77 GX_WIDGET *widget = (GX_WIDGET *)checkbox;
78 
79     if (checkbox -> gx_widget_style & GX_STYLE_ENABLED)
80     {
81         if (!(checkbox -> gx_widget_style & GX_STYLE_BUTTON_PUSHED))
82         {
83             checkbox -> gx_widget_style |= GX_STYLE_BUTTON_PUSHED;
84             _gx_widget_event_generate(widget, GX_EVENT_TOGGLE_ON, 0);
85         }
86         else
87         {
88             checkbox -> gx_widget_style &= ~GX_STYLE_BUTTON_PUSHED;
89             _gx_widget_event_generate(widget, GX_EVENT_TOGGLE_OFF, 0);
90         }
91 
92         /* Mark as dirty.  */
93         _gx_system_dirty_mark(widget);
94 
95     }
96 
97     return(GX_SUCCESS);
98 }
99