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 /**   Widget Management (Widget)                                          */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  COMPONENT DEFINITION                                   RELEASE        */
26 /*                                                                        */
27 /*    gx_widget.h                                         PORTABLE C      */
28 /*                                                           6.1.7        */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    Kenneth Maxwell, Microsoft Corporation                              */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file defines the GUIX widget 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 /*                                            resulting in version 6.1    */
46 /*  06-02-2021     Ting Zhu                 Modified comment(s),          */
47 /*                                            added new child widget      */
48 /*                                            search prototypes,          */
49 /*                                            resulting in version 6.1.7  */
50 /*                                                                        */
51 /**************************************************************************/
52 
53 #ifndef GX_WIDGET_H
54 #define GX_WIDGET_H
55 
56 
57 /* Define widget management function prototypes.  */
58 
59 UINT       _gx_widget_allocate(GX_WIDGET **widget, ULONG memsize);
60 UINT       _gx_widget_attach(GX_WIDGET *parent, GX_WIDGET *child);
61 UINT       _gx_widget_back_attach(GX_WIDGET *parent, GX_WIDGET *child);
62 VOID       _gx_widget_background_draw(GX_WIDGET *widget);
63 UINT       _gx_widget_back_move(GX_WIDGET *widget, GX_BOOL *widget_moved);
64 UINT       _gx_widget_block_move(GX_WIDGET *widget, GX_RECTANGLE *block, INT x_shift, INT y_shift);
65 VOID       _gx_widget_border_draw(GX_WIDGET *widget, GX_RESOURCE_ID border_color, GX_RESOURCE_ID upper_color, GX_RESOURCE_ID lower_color, GX_BOOL fill);
66 UINT       _gx_widget_border_style_set(GX_WIDGET *widget, ULONG Style);
67 UINT       _gx_widget_border_width_get(GX_WIDGET *widget, GX_VALUE *return_width);
68 UINT       _gx_widget_canvas_get(GX_WIDGET *widget, GX_CANVAS **return_canvas);
69 UINT       _gx_widget_child_detect(GX_WIDGET *parent, GX_WIDGET *child, GX_BOOL *return_detect);
70 VOID       _gx_widget_children_draw(GX_WIDGET *widget);
71 VOID       _gx_widget_children_event_process(GX_WIDGET *widget, GX_EVENT *event_ptr);
72 UINT       _gx_widget_client_get(GX_WIDGET *widget, GX_VALUE border_width, GX_RECTANGLE *return_size);
73 VOID       _gx_widget_clipping_update(GX_WIDGET *widget);
74 UINT       _gx_widget_color_get(GX_WIDGET *widget, GX_RESOURCE_ID color_id, GX_COLOR *color);
75 VOID       _gx_widget_child_clipping_update(GX_WIDGET *parent);
76 VOID       _gx_widget_child_focus_assign(GX_WIDGET *parent);
77 VOID       _gx_widget_context_fill_set(GX_WIDGET *widget);
78 UINT       _gx_widget_create(GX_WIDGET *widget, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
79                              ULONG style, USHORT Id, GX_CONST GX_RECTANGLE *size);
80 UINT       _gx_widget_created_test(GX_WIDGET *widget, GX_BOOL *return_test);
81 UINT       _gx_widget_detach(GX_WIDGET *child);
82 UINT       _gx_widget_delete(GX_WIDGET *widget);
83 VOID       _gx_widget_draw(GX_WIDGET *widget);
84 UINT       _gx_widget_draw_set(GX_WIDGET *widget, VOID (*draw_func)(GX_WIDGET *));
85 UINT       _gx_widget_event_generate(GX_WIDGET *widget, USHORT event_type, LONG value);
86 UINT       _gx_widget_event_process(GX_WIDGET *widget, GX_EVENT *event_ptr);
87 UINT       _gx_widget_event_process_set(GX_WIDGET *widget, UINT (*event_processing_function)(GX_WIDGET *, GX_EVENT *));
88 UINT       _gx_widget_event_to_parent(GX_WIDGET *widget, GX_EVENT *event_ptr);
89 UINT       _gx_widget_fill_color_set(GX_WIDGET *widget, GX_RESOURCE_ID normal_color, GX_RESOURCE_ID selected_color, GX_RESOURCE_ID disabled_color);
90 UINT       _gx_widget_find(GX_WIDGET *parent, USHORT widget_id, INT search_depth, GX_WIDGET **return_widget);
91 UINT       _gx_widget_first_child_get(GX_WIDGET *parent, GX_WIDGET **child_return);
92 UINT       _gx_widget_font_get(GX_WIDGET *widget, GX_RESOURCE_ID font_id, GX_FONT **return_font);
93 UINT       _gx_widget_free(GX_WIDGET *widget);
94 UINT       _gx_widget_front_move(GX_WIDGET *widget, GX_BOOL *return_moved);
95 UINT       _gx_widget_focus_next(GX_WIDGET *widget);
96 UINT       _gx_widget_focus_previous(GX_WIDGET *widget);
97 UINT       _gx_widget_height_get(GX_WIDGET *widget, GX_VALUE *return_height);
98 UINT       _gx_widget_hide(GX_WIDGET *widget);
99 UINT       _gx_widget_last_child_get(GX_WIDGET *parent, GX_WIDGET **child_return);
100 VOID       _gx_widget_link(GX_WIDGET *parent, GX_WIDGET *child);
101 VOID       _gx_widget_nav_order_initialize(GX_WIDGET *widget);
102 UINT       _gx_widget_next_sibling_get(GX_WIDGET *current, GX_WIDGET **sibling_return);
103 UINT       _gx_widget_parent_get(GX_WIDGET *current, GX_WIDGET **parent_return);
104 UINT       _gx_widget_previous_sibling_get(GX_WIDGET *current, GX_WIDGET **sibling_return);
105 UINT       _gx_widget_pixelmap_get(GX_WIDGET *widget, GX_RESOURCE_ID pixelmap_id, GX_PIXELMAP **return_map);
106 VOID       _gx_widget_back_link(GX_WIDGET *parent, GX_WIDGET *child);
107 UINT       _gx_widget_resize(GX_WIDGET *widget, GX_RECTANGLE *new_size);
108 UINT       _gx_widget_scroll_shift(GX_WIDGET *widget, INT xShift, INT yShift, GX_BOOL clip);
109 UINT       _gx_widget_shift(GX_WIDGET *widget, GX_VALUE x_shift, GX_VALUE  y_shift, GX_BOOL mark_dirty);
110 UINT       _gx_widget_show(GX_WIDGET *widget);
111 UINT       _gx_widget_status_add(GX_WIDGET *widget, ULONG status);
112 UINT       _gx_widget_status_get(GX_WIDGET *widget, ULONG *return_status);
113 UINT       _gx_widget_status_remove(GX_WIDGET *widget, ULONG status);
114 UINT       _gx_widget_status_test(GX_WIDGET *widget, ULONG status, GX_BOOL *return_test);
115 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
116 UINT       _gx_widget_string_get(GX_WIDGET *widget, GX_RESOURCE_ID string_id, GX_CONST GX_CHAR **return_string);
117 #endif
118 UINT       _gx_widget_string_get_ext(GX_WIDGET *widget, GX_RESOURCE_ID string_id, GX_STRING *return_string);
119 
120 UINT       _gx_widget_style_add(GX_WIDGET *widget, ULONG style);
121 UINT       _gx_widget_style_get(GX_WIDGET *widget, ULONG *return_style);
122 UINT       _gx_widget_style_remove(GX_WIDGET *widget, ULONG style);
123 UINT       _gx_widget_style_set(GX_WIDGET *widget, ULONG style);
124 
125 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
126 UINT       _gx_widget_text_blend(GX_WIDGET *widget, UINT tColor, UINT font_id, GX_CONST GX_CHAR *string,
127                            INT x_offset, INT y_offset, UCHAR alpha);
128 VOID       _gx_widget_text_draw(GX_WIDGET *widget, UINT tColor, UINT font_id, GX_CONST GX_CHAR *string,
129                           INT x_offset, INT y_offset);
130 #endif
131 UINT       _gx_widget_text_blend_ext(GX_WIDGET *widget, UINT tColor, UINT font_id, GX_CONST GX_STRING *string,
132                                      INT x_offset, INT y_offset, UCHAR alpha);
133 VOID       _gx_widget_text_draw_ext(GX_WIDGET *widget, UINT tColor, UINT font_id, GX_CONST GX_STRING *string,
134                                     INT x_offset, INT y_offset);
135 VOID       _gx_widget_text_id_draw(GX_WIDGET *widget, UINT tColor, UINT font_id, UINT text_id,
136                                    INT x_offset, INT y_offset);
137 UINT       _gx_widget_top_visible_child_find(GX_WIDGET *parent, GX_WIDGET **child_return);
138 GX_BOOL    _gx_widget_transparent_pixelmap_detect(GX_WIDGET *widget, GX_RESOURCE_ID pixelmap_id);
139 UINT       _gx_widget_type_find(GX_WIDGET *parent, USHORT widget_id, GX_WIDGET **return_widget);
140 
141 GX_WIDGET *_gx_widget_unlink(GX_WIDGET *widget);
142 GX_WIDGET *_gx_widget_first_client_child_get(GX_WIDGET *parent);
143 GX_WIDGET *_gx_widget_first_visible_client_child_get(GX_WIDGET *parent);
144 GX_WIDGET *_gx_widget_last_client_child_get(GX_WIDGET *parent);
145 GX_WIDGET *_gx_widget_last_visible_client_child_get(GX_WIDGET *parent);
146 GX_WIDGET *_gx_widget_next_client_child_get(GX_WIDGET *current);
147 GX_WIDGET *_gx_widget_next_visible_client_child_get(GX_WIDGET *current);
148 INT        _gx_widget_client_index_get(GX_WIDGET *parent, GX_WIDGET *child);
149 
150 UINT       _gx_widget_width_get(GX_WIDGET *widget, GX_VALUE *return_width);
151 
152 
153 /* Define error checking shells for API services.  These are only referenced by the
154    application.  */
155 
156 UINT _gxe_widget_allocate(GX_WIDGET **widget, ULONG memsize);
157 UINT _gxe_widget_attach(GX_WIDGET *parent, GX_WIDGET *child);
158 UINT _gxe_widget_back_attach(GX_WIDGET *parent, GX_WIDGET *child);
159 UINT _gxe_widget_back_move(GX_WIDGET *widget, GX_BOOL *widget_moved);
160 UINT _gxe_widget_block_move(GX_WIDGET *widget, GX_RECTANGLE *block, INT x_shift, INT y_shift);
161 UINT _gxe_widget_border_style_set(GX_WIDGET *widget, ULONG Style);
162 UINT _gxe_widget_border_width_get(GX_WIDGET *widget, GX_VALUE *return_width);
163 UINT _gxe_widget_canvas_get(GX_WIDGET *widget, GX_CANVAS **return_canvas);
164 UINT _gxe_widget_child_detect(GX_WIDGET *parent, GX_WIDGET *child, GX_BOOL *return_detect);
165 UINT _gxe_widget_client_get(GX_WIDGET *widget, GX_VALUE border_width, GX_RECTANGLE *return_size);
166 UINT _gxe_widget_color_get(GX_WIDGET *widget, GX_RESOURCE_ID color_id, GX_COLOR *return_color);
167 UINT _gxe_widget_create(GX_WIDGET *widget, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
168                         ULONG style, USHORT Id, GX_CONST GX_RECTANGLE *size, UINT widget_block_size);
169 UINT _gxe_widget_created_test(GX_WIDGET *widget, GX_BOOL *return_test);
170 UINT _gxe_widget_delete(GX_WIDGET *widget);
171 UINT _gxe_widget_detach(GX_WIDGET *widget);
172 UINT _gxe_widget_draw_set(GX_WIDGET *widget, VOID (*draw_func)(GX_WIDGET *));
173 UINT _gxe_widget_event_generate(GX_WIDGET *widget, USHORT event_type, LONG value);
174 UINT _gxe_widget_event_process(GX_WIDGET *widget, GX_EVENT *event_ptr);
175 UINT _gxe_widget_event_process_set(GX_WIDGET *widget, UINT (*event_processing_function)(GX_WIDGET *, GX_EVENT *));
176 UINT _gxe_widget_fill_color_set(GX_WIDGET *widget, GX_RESOURCE_ID normal_color, GX_RESOURCE_ID selected_color, GX_RESOURCE_ID disabled_color);
177 UINT _gxe_widget_find(GX_WIDGET *parent, USHORT widget_id, INT search_depth, GX_WIDGET **return_widget);
178 UINT _gxe_widget_first_child_get(GX_WIDGET *parent, GX_WIDGET **child_return);
179 UINT _gxe_widget_focus_next(GX_WIDGET *widget);
180 UINT _gxe_widget_focus_previous(GX_WIDGET *widget);
181 UINT _gxe_widget_font_get(GX_WIDGET *widget, GX_RESOURCE_ID resource_id, GX_FONT **return_font);
182 UINT _gxe_widget_free(GX_WIDGET *widget);
183 UINT _gxe_widget_front_move(GX_WIDGET *widget, GX_BOOL *return_moved);
184 UINT _gxe_widget_height_get(GX_WIDGET *widget, GX_VALUE *return_height);
185 UINT _gxe_widget_hide(GX_WIDGET *widget);
186 UINT _gxe_widget_last_child_get(GX_WIDGET *parent, GX_WIDGET **child_return);
187 UINT _gxe_widget_next_sibling_get(GX_WIDGET *current, GX_WIDGET **sibling_return);
188 UINT _gxe_widget_parent_get(GX_WIDGET *current, GX_WIDGET **parent_return);
189 UINT _gxe_widget_previous_sibling_get(GX_WIDGET *current, GX_WIDGET **sibling_return);
190 UINT _gxe_widget_pixelmap_get(GX_WIDGET *widget, GX_RESOURCE_ID resource_id, GX_PIXELMAP **return_pixelmap);
191 UINT _gxe_widget_resize(GX_WIDGET *widget, GX_RECTANGLE *new_size);
192 UINT _gxe_widget_shift(GX_WIDGET *widget, GX_VALUE x_shift, GX_VALUE y_shift, GX_BOOL mark_dirty);
193 UINT _gxe_widget_show(GX_WIDGET *widget);
194 UINT _gxe_widget_status_add(GX_WIDGET *widget, ULONG status);
195 UINT _gxe_widget_status_get(GX_WIDGET *widget, ULONG *return_status);
196 UINT _gxe_widget_status_remove(GX_WIDGET *widget, ULONG status);
197 UINT _gxe_widget_status_test(GX_WIDGET *widget, ULONG status, GX_BOOL *return_test);
198 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
199 UINT _gxe_widget_string_get(GX_WIDGET *widget, GX_RESOURCE_ID string_id, GX_CONST GX_CHAR **return_string);
200 #endif
201 UINT _gxe_widget_string_get_ext(GX_WIDGET *widget, GX_RESOURCE_ID string_id, GX_STRING *return_string);
202 UINT _gxe_widget_style_add(GX_WIDGET *widget, ULONG style);
203 UINT _gxe_widget_style_get(GX_WIDGET *widget, ULONG *return_style);
204 UINT _gxe_widget_style_set(GX_WIDGET *widget, ULONG style);
205 UINT _gxe_widget_style_remove(GX_WIDGET *widget, ULONG style);
206 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
207 UINT _gxe_widget_text_blend(GX_WIDGET *widget,
208                             UINT tColor, UINT font_id,
209                             GX_CONST GX_CHAR *string, INT x_offset, INT y_offset, UCHAR alpha);
210 #endif
211 UINT _gxe_widget_text_blend_ext(GX_WIDGET *widget,
212                                 UINT tColor, UINT font_id,
213                                 GX_CONST GX_STRING *string, INT x_offset, INT y_offset, UCHAR alpha);
214 UINT _gxe_widget_top_visible_child_find(GX_WIDGET *parent, GX_WIDGET **child_return);
215 UINT _gxe_widget_type_find(GX_WIDGET *parent, USHORT widget_id, GX_WIDGET **return_widget);
216 UINT _gxe_widget_width_get(GX_WIDGET *widget, GX_VALUE *return_width);
217 UINT _gxe_widget_event_to_parent(GX_WIDGET *widget, GX_EVENT *event_ptr);
218 
219 #endif
220 
221