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 (Button)                                          */
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_button_create                                   PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function creates a vector button, which is a special type of   */
45 /*    prompt (widget).                                                    */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    button                                Pointer to button control     */
50 /*                                            block                       */
51 /*    name                                  Logical name of button        */
52 /*    parent                                Pointer to parent widget      */
53 /*                                            of button                   */
54 /*    style                                 Button stuyle                 */
55 /*    button_id                             Application-defined ID of     */
56 /*                                             the button                 */
57 /*    size                                  Size of the button            */
58 /*                                                                        */
59 /*  OUTPUT                                                                */
60 /*                                                                        */
61 /*    status                                Completion status             */
62 /*                                                                        */
63 /*  CALLS                                                                 */
64 /*                                                                        */
65 /*    _gx_widget_create                     Create the underlying prompt  */
66 /*    _gx_widget_status_add                 Set the widget status         */
67 /*    _gx_widget_link                       Link the widget to its parent */
68 /*                                                                        */
69 /*  CALLED BY                                                             */
70 /*                                                                        */
71 /*    Application Code                                                    */
72 /*    _gx_horizontal_scrollbar_create                                     */
73 /*    _gx_icon_button_create                                              */
74 /*    _gx_pixelmap_button_create                                          */
75 /*    _gx_scroll_thumb_create                                             */
76 /*    _gx_text_button_create                                              */
77 /*    _gx_vertical_scrollbar_create                                       */
78 /*    _gx_scroll_thumb_create                                             */
79 /*    _gx_text_button_create                                              */
80 /*                                                                        */
81 /*  RELEASE HISTORY                                                       */
82 /*                                                                        */
83 /*    DATE              NAME                      DESCRIPTION             */
84 /*                                                                        */
85 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
86 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
87 /*                                            fixed compiler warnings,    */
88 /*                                            resulting in version 6.1    */
89 /*                                                                        */
90 /**************************************************************************/
_gx_button_create(GX_BUTTON * button,GX_CONST GX_CHAR * name,GX_WIDGET * parent,ULONG style,USHORT button_id,GX_CONST GX_RECTANGLE * size)91 UINT  _gx_button_create(GX_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
92                         ULONG style, USHORT button_id, GX_CONST GX_RECTANGLE *size)
93 {
94 
95     /* Call the widget create function.  */
96     _gx_widget_create((GX_WIDGET *)button, name, GX_NULL, style, button_id, size);
97 
98     /* Check for completion status on the prompt create.  */
99     /* Yes, the prompt widget was created successfully.  Populate the rest of
100        button control block - overriding as necessary.  */
101     button -> gx_widget_type = GX_TYPE_BUTTON;
102 
103     _gx_widget_status_add((GX_WIDGET *)button, GX_STATUS_BUTTON_DERIVED);
104 
105     button -> gx_button_select_handler = (VOID (*)(GX_WIDGET *))(void (*)(void))_gx_button_select;
106     button -> gx_button_deselect_handler = (VOID (*)(GX_WIDGET *, GX_BOOL))(void (*)(void))_gx_button_deselect;
107     button -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_button_draw;
108     button -> gx_widget_event_process_function =  (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_button_event_process;
109     button -> gx_widget_normal_fill_color =       GX_COLOR_ID_BUTTON_LOWER;
110     button -> gx_widget_selected_fill_color =     GX_COLOR_ID_BUTTON_UPPER;
111 
112     /* Determine if a parent widget was provided.  */
113     if (parent)
114     {
115         _gx_widget_link(parent, (GX_WIDGET *)button);
116     }
117 
118     /* Return the completion status code */
119     return(GX_SUCCESS);
120 }
121 
122