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