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 (Button)                                          */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  COMPONENT DEFINITION                                   RELEASE        */
26 /*                                                                        */
27 /*    gx_button.h                                         PORTABLE C      */
28 /*                                                           6.1          */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    Kenneth Maxwell, Microsoft Corporation                              */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file defines the GUIX button management component,             */
36 /*    including all data types and external references.  It is assumed    */
37 /*    that gx_api.h and gx_port.h have already been included.             */
38 /*                                                                        */
39 /*  RELEASE HISTORY                                                       */
40 /*                                                                        */
41 /*    DATE              NAME                      DESCRIPTION             */
42 /*                                                                        */
43 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
44 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
45 /*                                            added new prototypes,       */
46 /*                                            resulting in version 6.1    */
47 /*                                                                        */
48 /**************************************************************************/
49 
50 #ifndef GX_BUTTON_H
51 #define GX_BUTTON_H
52 
53 
54 /* Define button management function prototypes.  */
55 
56 UINT _gx_button_create(GX_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
57                        ULONG style, USHORT Id, GX_CONST GX_RECTANGLE *size);
58 VOID _gx_button_background_draw(GX_BUTTON *button);
59 UINT _gx_button_deselect(GX_BUTTON *button, GX_BOOL generate_event);
60 VOID _gx_button_draw(GX_BUTTON *button);
61 UINT _gx_button_event_process(GX_BUTTON *button, GX_EVENT *event_ptr);
62 VOID _gx_button_siblings_deselect(GX_BUTTON *button);
63 UINT _gx_button_select(GX_BUTTON *button);
64 
65 UINT _gx_checkbox_create(GX_CHECKBOX *checkbox, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
66                          GX_RESOURCE_ID text_id, ULONG style, USHORT checkbox_id,
67                          GX_CONST GX_RECTANGLE *size);
68 VOID _gx_checkbox_draw(GX_CHECKBOX *checkbox);
69 UINT _gx_checkbox_event_process(GX_CHECKBOX *checkbox, GX_EVENT *event_ptr);
70 UINT _gx_checkbox_pixelmap_set(GX_CHECKBOX *button, GX_RESOURCE_ID unchecked_id, GX_RESOURCE_ID checked_id,
71                                GX_RESOURCE_ID unchecked_disabled_id, GX_RESOURCE_ID checked_disabled_id);
72 UINT _gx_checkbox_select(GX_CHECKBOX *checkbox);
73 
74 UINT _gx_icon_button_create(GX_ICON_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
75                             GX_RESOURCE_ID icon_id,
76                             ULONG style, USHORT icon_button_id, GX_CONST GX_RECTANGLE *size);
77 VOID _gx_icon_button_draw(GX_ICON_BUTTON *button);
78 UINT _gx_icon_button_pixelmap_set(GX_ICON_BUTTON *button, GX_RESOURCE_ID icon_id);
79 
80 
81 UINT _gx_multi_line_text_button_create(GX_MULTI_LINE_TEXT_BUTTON *button, GX_CONST GX_CHAR *name,
82                                        GX_WIDGET *parent, GX_RESOURCE_ID text_id, ULONG style, USHORT Id,
83                                        GX_CONST GX_RECTANGLE *size);
84 
85 VOID _gx_multi_line_text_button_draw(GX_MULTI_LINE_TEXT_BUTTON *button);
86 UINT _gx_multi_line_text_button_event_process(GX_MULTI_LINE_TEXT_BUTTON *button, GX_EVENT *event_ptr);
87 VOID _gx_multi_line_text_button_line_pointers_set(GX_MULTI_LINE_TEXT_BUTTON *button);
88 VOID _gx_multi_line_text_button_text_draw(GX_MULTI_LINE_TEXT_BUTTON *button);
89 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
90 UINT _gx_multi_line_text_button_text_set(GX_MULTI_LINE_TEXT_BUTTON *button, GX_CONST GX_CHAR *text);
91 #endif
92 UINT _gx_multi_line_text_button_text_set_ext(GX_MULTI_LINE_TEXT_BUTTON *button, GX_CONST GX_STRING *text);
93 
94 UINT _gx_multi_line_text_button_text_id_set(GX_MULTI_LINE_TEXT_BUTTON *button, GX_RESOURCE_ID string_id);
95 
96 UINT _gx_pixelmap_button_create(GX_PIXELMAP_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
97                                 GX_RESOURCE_ID normal_id, GX_RESOURCE_ID selected_id, GX_RESOURCE_ID disabled_id,
98                                 ULONG style, USHORT pixelmap_button_id,
99                                 GX_CONST GX_RECTANGLE *size);
100 VOID _gx_pixelmap_button_draw(GX_PIXELMAP_BUTTON *button);
101 UINT _gx_pixelmap_button_event_process(GX_PIXELMAP_BUTTON *button, GX_EVENT *event_ptr);
102 
103 UINT _gx_pixelmap_button_pixelmap_set(GX_PIXELMAP_BUTTON *button, GX_RESOURCE_ID normal_id, GX_RESOURCE_ID selected_id,
104                                       GX_RESOURCE_ID disabled_id);
105 VOID _gx_pixelmap_button_transparent_detect(GX_PIXELMAP_BUTTON *button);
106 
107 UINT _gx_radio_button_create(GX_RADIO_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
108                              GX_RESOURCE_ID text_id, ULONG style, USHORT radio_button_id,
109                              GX_CONST GX_RECTANGLE *size);
110 VOID _gx_radio_button_draw(GX_RADIO_BUTTON *button);
111 UINT _gx_radio_button_pixelmap_set(GX_RADIO_BUTTON *button, GX_RESOURCE_ID off_id, GX_RESOURCE_ID on_id,
112                                    GX_RESOURCE_ID off_disabled_id, GX_RESOURCE_ID on_disabled_id);
113 
114 UINT _gx_text_button_create(GX_TEXT_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
115                             GX_RESOURCE_ID text_id, ULONG style, USHORT Id,
116                             GX_CONST GX_RECTANGLE *size);
117 VOID _gx_text_button_draw(GX_TEXT_BUTTON *button);
118 UINT _gx_text_button_event_process(GX_TEXT_BUTTON *button, GX_EVENT *event_ptr);
119 VOID _gx_text_button_text_draw(GX_TEXT_BUTTON *button);
120 UINT _gx_text_button_text_color_set(GX_TEXT_BUTTON *text_button,
121                                     GX_RESOURCE_ID normal_text_color_id,
122                                     GX_RESOURCE_ID selected_text_color_id,
123                                     GX_RESOURCE_ID disabled_text_color_id);
124 UINT _gx_text_button_font_set(GX_TEXT_BUTTON *button, GX_RESOURCE_ID font_id);
125 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
126 UINT _gx_text_button_text_get(GX_TEXT_BUTTON *button, GX_CONST GX_CHAR **return_text);
127 UINT _gx_text_button_text_set(GX_TEXT_BUTTON *button, GX_CONST GX_CHAR *text);
128 #endif
129 UINT _gx_text_button_text_get_ext(GX_TEXT_BUTTON *button, GX_STRING *return_text);
130 UINT _gx_text_button_text_set_ext(GX_TEXT_BUTTON *button, GX_CONST GX_STRING *text);
131 UINT _gx_text_button_text_id_set(GX_TEXT_BUTTON *button, GX_RESOURCE_ID string_id);
132 
133 VOID _gx_monochrome_driver_disabled_button_line_draw(GX_BUTTON *button);
134 
135 /* Define error checking shells for API services.  These are only referenced by the
136    application.  */
137 
138 UINT _gxe_button_create(GX_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent, ULONG style,
139                         USHORT Id, GX_CONST GX_RECTANGLE *size, UINT button_control_block_size);
140 UINT _gxe_button_deselect(GX_BUTTON *button, GX_BOOL gen_event);
141 UINT _gxe_button_event_process(GX_BUTTON *button, GX_EVENT *event_ptr);
142 UINT _gxe_button_select(GX_BUTTON *button);
143 
144 UINT _gxe_checkbox_create(GX_CHECKBOX *checkbox, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
145                           GX_RESOURCE_ID text_id, ULONG style,
146                           USHORT checkbox_id, GX_CONST GX_RECTANGLE *size, UINT checkbox_control_block_size);
147 UINT _gxe_checkbox_event_process(GX_CHECKBOX *checkbox, GX_EVENT *event_ptr);
148 UINT _gxe_checkbox_pixelmap_set(GX_CHECKBOX *checkbox,
149                                 GX_RESOURCE_ID unchecked_id,
150                                 GX_RESOURCE_ID checked_id,
151                                 GX_RESOURCE_ID unchecked_disabled_id,
152                                 GX_RESOURCE_ID checked_disabled_id);
153 UINT _gxe_checkbox_select(GX_CHECKBOX *checkbox);
154 
155 UINT _gxe_icon_button_create(GX_ICON_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent, GX_RESOURCE_ID icon_id,
156                              ULONG style, USHORT icon_button_id, GX_CONST GX_RECTANGLE *size, UINT button_control_block_size);
157 UINT _gxe_icon_button_pixelmap_set(GX_ICON_BUTTON *button, GX_RESOURCE_ID pixelmap_id);
158 
159 
160 UINT _gxe_multi_line_text_button_create(GX_MULTI_LINE_TEXT_BUTTON *button, GX_CONST GX_CHAR *name,
161                                         GX_WIDGET *parent, GX_RESOURCE_ID text_id, ULONG style, USHORT Id,
162                                         GX_CONST GX_RECTANGLE *size, UINT text_button_control_block);
163 
164 UINT _gxe_multi_line_text_button_event_process(GX_MULTI_LINE_TEXT_BUTTON *button, GX_EVENT *event_ptr);
165 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
166 UINT _gxe_multi_line_text_button_text_set(GX_MULTI_LINE_TEXT_BUTTON *button, GX_CONST GX_CHAR *text);
167 #endif
168 UINT _gxe_multi_line_text_button_text_set_ext(GX_MULTI_LINE_TEXT_BUTTON *button, GX_CONST GX_STRING *text);
169 UINT _gxe_multi_line_text_button_text_id_set(GX_MULTI_LINE_TEXT_BUTTON *button, GX_RESOURCE_ID string_id);
170 
171 UINT _gxe_pixelmap_button_event_process(GX_PIXELMAP_BUTTON *button, GX_EVENT *event_ptr);
172 UINT _gxe_pixelmap_button_create(GX_PIXELMAP_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent, GX_RESOURCE_ID normal_id,
173                                  GX_RESOURCE_ID selected_id, GX_RESOURCE_ID disabled_id, ULONG style, USHORT pixelmap_button_id,
174                                  GX_CONST GX_RECTANGLE *size, UINT button_control_block_size);
175 UINT _gxe_pixelmap_button_pixelmap_set(GX_PIXELMAP_BUTTON *button, GX_RESOURCE_ID normal_id, GX_RESOURCE_ID selected_id,
176                                        GX_RESOURCE_ID disabled_id);
177 
178 UINT _gxe_radio_button_create(GX_RADIO_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent, GX_RESOURCE_ID text_id, ULONG style,
179                               USHORT radio_button_id, GX_CONST GX_RECTANGLE *size, UINT radio_button_control_block_size);
180 UINT _gxe_radio_button_pixelmap_set(GX_RADIO_BUTTON *button, GX_RESOURCE_ID off_id, GX_RESOURCE_ID on_id, GX_RESOURCE_ID off_disabled_id,
181                                     GX_RESOURCE_ID on_disabled_id);
182 
183 UINT _gxe_text_button_create(GX_TEXT_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
184                              GX_RESOURCE_ID text_id, ULONG style, USHORT Id,
185                              GX_CONST GX_RECTANGLE *size, UINT text_button_control_block);
186 UINT _gxe_text_button_event_process(GX_TEXT_BUTTON *button, GX_EVENT *event_ptr);
187 UINT _gxe_text_button_font_set(GX_TEXT_BUTTON *button, GX_RESOURCE_ID font_id);
188 UINT _gxe_text_button_text_color_set(GX_TEXT_BUTTON *text_button,
189                                      GX_RESOURCE_ID normal_text_color_id,
190                                      GX_RESOURCE_ID selected_text_color_id,
191                                      GX_RESOURCE_ID disabled_text_color_id);
192 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
193 UINT _gxe_text_button_text_get(GX_TEXT_BUTTON *button, GX_CONST GX_CHAR **return_text);
194 UINT _gxe_text_button_text_set(GX_TEXT_BUTTON *button, GX_CONST GX_CHAR *text);
195 #endif
196 UINT _gxe_text_button_text_get_ext(GX_TEXT_BUTTON *button, GX_STRING *return_text);
197 UINT _gxe_text_button_text_set_ext(GX_TEXT_BUTTON *button, GX_CONST GX_STRING *text);
198 UINT _gxe_text_button_text_id_set(GX_TEXT_BUTTON *button, GX_RESOURCE_ID string_id);
199 
200 #endif
201 
202