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 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_checkbox_create                                 PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function creates a checkbox, which is a special type of        */
45 /*    button (widget).                                                    */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    checkbox                              Checkbox control block        */
50 /*    name                                  Name of checkbox              */
51 /*    parent                                Parent widget control block   */
52 /*    text_id                               Text resource id              */
53 /*    style                                 Style of checkbox             */
54 /*    checkbox_id                           Checkbox id                   */
55 /*    size                                  Checkbox size                 */
56 /*                                                                        */
57 /*  OUTPUT                                                                */
58 /*                                                                        */
59 /*    status                                Completion status             */
60 /*                                                                        */
61 /*  CALLS                                                                 */
62 /*                                                                        */
63 /*    _gx_text_button_create                Create the underlying button  */
64 /*    _gx_widget_link                       Link the widget to its parent */
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    Application Code                                                    */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
75 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
76 /*                                            fixed compiler warnings,    */
77 /*                                            resulting in version 6.1    */
78 /*                                                                        */
79 /**************************************************************************/
_gx_checkbox_create(GX_CHECKBOX * checkbox,GX_CONST GX_CHAR * name,GX_WIDGET * parent,GX_RESOURCE_ID text_id,ULONG style,USHORT checkbox_id,GX_CONST GX_RECTANGLE * size)80 UINT  _gx_checkbox_create(GX_CHECKBOX *checkbox, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
81                           GX_RESOURCE_ID text_id, ULONG style, USHORT checkbox_id,
82                           GX_CONST GX_RECTANGLE *size)
83 {
84 
85     style |= GX_STYLE_BUTTON_TOGGLE;
86 
87     /* Call the prompt create function.  */
88     _gx_text_button_create((GX_TEXT_BUTTON *)checkbox, name, GX_NULL, text_id, style, checkbox_id, size);
89 
90     /* Populate the rest of button control block - overriding as necessary.  */
91     checkbox -> gx_widget_type = GX_TYPE_CHECKBOX;
92     checkbox -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_checkbox_draw;
93     checkbox -> gx_button_select_handler = (VOID (*)(GX_WIDGET *))(void (*)(void))_gx_checkbox_select;
94     checkbox -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_checkbox_event_process;
95     checkbox -> gx_checkbox_checked_pixelmap_id = GX_PIXELMAP_CHECKBOX_ON_ID;
96     checkbox -> gx_checkbox_unchecked_pixelmap_id = GX_PIXELMAP_CHECKBOX_OFF_ID;
97 
98     /* Determine if a parent widget was provided.  */
99     if (parent)
100     {
101         _gx_widget_link(parent, (GX_WIDGET *)checkbox);
102     }
103 
104     /* Return the status from button create.  */
105     return(GX_SUCCESS);
106 }
107 
108