1 /*******************************************************************************/
2 /*  This file is auto-generated by Azure RTOS GUIX Studio. Do not edit this    */
3 /*  file by hand. Modifications to this file should only be made by running    */
4 /*  the Azure RTOS GUIX Studio application and re-generating the application   */
5 /*  specification file(s). For more information please refer to the Azure RTOS */
6 /*  GUIX Studio User Guide, or visit our web site at azure.com/rtos            */
7 /*                                                                             */
8 /*  GUIX Studio Revision 6.1.12.0                                              */
9 /*  Date (dd.mm.yyyy): 25. 8.2022   Time (hh:mm): 18:22                        */
10 /*******************************************************************************/
11 
12 
13 #define GUIX_STUDIO_GENERATED_FILE
14 #include <stddef.h>
15 #include "guix_keyboard_resources.h"
16 #include "guix_keyboard_specifications.h"
17 
18 static GX_WIDGET *gx_studio_nested_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent);
19 KEYBOARD_SCREEN_CONTROL_BLOCK keyboard_screen;
20 GX_DISPLAY display_1_control_block;
21 GX_WINDOW_ROOT display_1_root_window;
22 GX_CANVAS  display_1_canvas_control_block;
23 ULONG      display_1_canvas_memory[136240];
24 
25 extern GX_CONST GX_THEME *display_1_theme_table[];
26 extern GX_CONST GX_STRING *display_1_language_table[];
27 
28 GX_STUDIO_DISPLAY_INFO guix_keyboard_display_table[1] =
29 {
30     {
31     "display_1",
32     "display_1_canvas",
33     display_1_theme_table,
34     display_1_language_table,
35     DISPLAY_1_THEME_TABLE_SIZE,
36     DISPLAY_1_LANGUAGE_TABLE_SIZE,
37     DISPLAY_1_STRING_TABLE_SIZE,
38     520,                                     /* x resolution                   */
39     262,                                     /* y resolution                   */
40     &display_1_control_block,
41     &display_1_canvas_control_block,
42     &display_1_root_window,
43     display_1_canvas_memory,                 /* canvas memory area             */
44     544960,                                  /* canvas memory size in bytes    */
45     GX_SCREEN_ROTATION_NONE                  /* rotation angle                 */
46     }
47 };
48 
49 
gx_studio_pixelmap_button_create(GX_CONST GX_STUDIO_WIDGET * info,GX_WIDGET * control_block,GX_WIDGET * parent)50 UINT gx_studio_pixelmap_button_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
51 {
52     UINT status;
53     GX_PIXELMAP_BUTTON *button = (GX_PIXELMAP_BUTTON *) control_block;
54     GX_PIXELMAP_BUTTON_PROPERTIES *props = (GX_PIXELMAP_BUTTON_PROPERTIES *) info->properties;
55     status = gx_pixelmap_button_create(button, info->widget_name, parent,
56                props->normal_pixelmap_id,
57                props->selected_pixelmap_id,
58                props->disabled_pixelmap_id,
59                info->style, info->widget_id, &info->size);
60     return status;
61 }
62 
gx_studio_icon_create(GX_CONST GX_STUDIO_WIDGET * info,GX_WIDGET * control_block,GX_WIDGET * parent)63 UINT gx_studio_icon_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
64 {
65     UINT status;
66     GX_ICON *icon = (GX_ICON *) control_block;
67     GX_ICON_PROPERTIES *props = (GX_ICON_PROPERTIES *) info->properties;
68     status = gx_icon_create(icon, info->widget_name, parent, props->normal_pixelmap_id, info->style, info->widget_id, info->size.gx_rectangle_left, info->size.gx_rectangle_top);
69     if (props->selected_pixelmap_id)
70     {
71         gx_icon_pixelmap_set(icon, props->normal_pixelmap_id, props->selected_pixelmap_id);
72     }
73     else
74     {
75         gx_widget_resize((GX_WIDGET *)icon, (GX_RECTANGLE *)&info->size);
76     }
77     return status;
78 }
79 
gx_studio_window_create(GX_CONST GX_STUDIO_WIDGET * info,GX_WIDGET * control_block,GX_WIDGET * parent)80 UINT gx_studio_window_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
81 {
82     UINT status;
83     GX_WINDOW *window = (GX_WINDOW *) control_block;
84     GX_WINDOW_PROPERTIES *props = (GX_WINDOW_PROPERTIES *) info->properties;
85     status = gx_window_create(window, info->widget_name, parent, info->style, info->widget_id, &info->size);
86     if (status == GX_SUCCESS)
87     {
88         if (props->wallpaper_id)
89         {
90             gx_window_wallpaper_set(window, props->wallpaper_id, info->style & GX_STYLE_TILE_WALLPAPER);
91         }
92     }
93     return status;
94 }
95 
gx_studio_text_input_create(GX_CONST GX_STUDIO_WIDGET * info,GX_WIDGET * control_block,GX_WIDGET * parent)96 UINT gx_studio_text_input_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
97 {
98     UINT status;
99     GX_STRING text;
100     GX_SINGLE_LINE_TEXT_INPUT *input = (GX_SINGLE_LINE_TEXT_INPUT *) control_block;
101     GX_PROMPT *prompt = (GX_PROMPT *) input;
102     GX_SINGLE_LINE_TEXT_INPUT_PROPERTIES *props = (GX_SINGLE_LINE_TEXT_INPUT_PROPERTIES *) info->properties;
103     status = gx_single_line_text_input_create(input, info->widget_name, parent, props->buffer, props->buffer_size, info->style, info->widget_id, &info->size);
104     if (status == GX_SUCCESS)
105     {
106         gx_prompt_font_set(prompt, props->font_id);
107         gx_single_line_text_input_text_color_set(input, props->normal_text_color_id, props->selected_text_color_id,
108                                                  props->disabled_text_color_id, props->readonly_text_color_id);
109         gx_single_line_text_input_fill_color_set(input, input->gx_widget_normal_fill_color, input->gx_widget_selected_fill_color,
110                                                  input->gx_widget_disabled_fill_color, props->readonly_fill_color_id);
111         if (props->buffer && props->buffer_size > 0 && props->string_id)
112         {
113              gx_display_string_get_ext(guix_keyboard_display_table[0].display, props->string_id, &text);
114 
115              if (text.gx_string_ptr)
116              {
117                  gx_single_line_text_input_text_set_ext(input, &text);
118              }
119         }
120     }
121     return status;
122 }
123 GX_WINDOW_PROPERTIES keyboard_screen_properties =
124 {
125     0                                        /* wallpaper pixelmap id          */
126 };
127 GX_CHAR keyboard_screen_keyboard_input_field_buffer[100];
128 GX_SINGLE_LINE_TEXT_INPUT_PROPERTIES keyboard_screen_keyboard_input_field_properties =
129 {
130     GX_STRING_ID_STRING_2,                   /* string id                      */
131     GX_FONT_ID_MIDSIZE,                      /* font id                        */
132     GX_COLOR_ID_DARK_GRAY,                   /* normal text color              */
133     GX_COLOR_ID_DARK_GRAY,                   /* selected text color            */
134     GX_COLOR_ID_DARK_GRAY,                   /* disabled text color            */
135     GX_COLOR_ID_READONLY_FILL,               /* readonly fill color            */
136     GX_COLOR_ID_READONLY_TEXT,               /* readonly text color            */
137     keyboard_screen_keyboard_input_field_buffer, /* buffer                     */
138     100,                                     /* buffer size                    */
139 };
140 GX_PIXELMAP_BUTTON_PROPERTIES keyboard_screen_pixelmap_button_1_properties =
141 {
142     GX_PIXELMAP_ID_B_BACKSPACE,              /* normal pixelmap id             */
143     GX_PIXELMAP_ID_B_BACKSPACE_H,            /* selected pixelmap id           */
144     0                                        /* disabled pixelmap id           */
145 };
146 GX_WINDOW_PROPERTIES keyboard_screen_keyboard_frame_properties =
147 {
148     0                                        /* wallpaper pixelmap id          */
149 };
150 GX_ICON_PROPERTIES keyboard_screen_icon_1_properties =
151 {
152     GX_PIXELMAP_ID_MS_AZURE_LOGO_SMALL,      /* normal pixelmap id             */
153     0                                        /* selected pixelmap id           */
154 };
155 
156 GX_CONST GX_STUDIO_WIDGET keyboard_screen_pixelmap_button_1_define =
157 {
158     "pixelmap_button_1",
159     GX_TYPE_PIXELMAP_BUTTON,                 /* widget type                    */
160     IDB_BACKSPACE,                           /* widget id                      */
161     #if defined(GX_WIDGET_USER_DATA)
162     0,                                       /* user data                      */
163     #endif
164     GX_STYLE_BORDER_NONE|GX_STYLE_ENABLED|GX_STYLE_HALIGN_RIGHT|GX_STYLE_VALIGN_CENTER,   /* style flags */
165     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
166     sizeof(GX_PIXELMAP_BUTTON),              /* control block size             */
167     GX_COLOR_ID_BTN_LOWER,                   /* normal color id                */
168     GX_COLOR_ID_BTN_UPPER,                   /* selected color id              */
169     GX_COLOR_ID_BTN_LOWER,                   /* disabled color id              */
170     gx_studio_pixelmap_button_create,        /* create function                */
171     GX_NULL,                                 /* drawing function override      */
172     GX_NULL,                                 /* event function override        */
173     {441, 33, 511, 64},                      /* widget size                    */
174     GX_NULL,                                 /* no next widget                 */
175     GX_NULL,                                 /* no child widgets               */
176     offsetof(KEYBOARD_SCREEN_CONTROL_BLOCK, keyboard_screen_pixelmap_button_1), /* control block */
177     (void *) &keyboard_screen_pixelmap_button_1_properties /* extended properties */
178 };
179 
180 GX_CONST GX_STUDIO_WIDGET keyboard_screen_icon_1_define =
181 {
182     "icon_1",
183     GX_TYPE_ICON,                            /* widget type                    */
184     GX_ID_NONE,                              /* widget id                      */
185     #if defined(GX_WIDGET_USER_DATA)
186     0,                                       /* user data                      */
187     #endif
188     GX_STYLE_BORDER_NONE|GX_STYLE_ENABLED|GX_STYLE_HALIGN_LEFT|GX_STYLE_VALIGN_TOP,   /* style flags */
189     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
190     sizeof(GX_ICON),                         /* control block size             */
191     GX_COLOR_ID_WIDGET_FILL,                 /* normal color id                */
192     GX_COLOR_ID_SELECTED_FILL,               /* selected color id              */
193     GX_COLOR_ID_WIDGET_FILL,                 /* disabled color id              */
194     gx_studio_icon_create,                   /* create function                */
195     GX_NULL,                                 /* drawing function override      */
196     GX_NULL,                                 /* event function override        */
197     {8, 8, 133, 27},                         /* widget size                    */
198     GX_NULL,                                 /* no next widget                 */
199     GX_NULL,                                 /* no child widgets               */
200     offsetof(KEYBOARD_SCREEN_CONTROL_BLOCK, keyboard_screen_icon_1), /* control block */
201     (void *) &keyboard_screen_icon_1_properties /* extended properties         */
202 };
203 
204 GX_CONST GX_STUDIO_WIDGET keyboard_screen_keyboard_frame_define =
205 {
206     "keyboard_frame",
207     GX_TYPE_WINDOW,                          /* widget type                    */
208     GX_ID_NONE,                              /* widget id                      */
209     #if defined(GX_WIDGET_USER_DATA)
210     0,                                       /* user data                      */
211     #endif
212     GX_STYLE_BORDER_NONE,                    /* style flags                    */
213     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
214     sizeof(GX_WINDOW),                       /* control block size             */
215     GX_COLOR_ID_BLACK,                       /* normal color id                */
216     GX_COLOR_ID_BLACK,                       /* selected color id              */
217     GX_COLOR_ID_BLACK,                       /* disabled color id              */
218     gx_studio_window_create,                 /* create function                */
219     GX_NULL,                                 /* drawing function override      */
220     (UINT (*)(GX_WIDGET *, GX_EVENT *)) keyboard_frame_event_handler, /* event function override */
221     {36, 67, 515, 256},                      /* widget size                    */
222     &keyboard_screen_icon_1_define,          /* next widget definition         */
223     GX_NULL,                                 /* no child widgets               */
224     offsetof(KEYBOARD_SCREEN_CONTROL_BLOCK, keyboard_screen_keyboard_frame), /* control block */
225     (void *) &keyboard_screen_keyboard_frame_properties /* extended properties */
226 };
227 
228 GX_CONST GX_STUDIO_WIDGET keyboard_screen_keyboard_input_field_define =
229 {
230     "keyboard_input_field",
231     GX_TYPE_SINGLE_LINE_TEXT_INPUT,          /* widget type                    */
232     ID_INPUT_FIELD,                          /* widget id                      */
233     #if defined(GX_WIDGET_USER_DATA)
234     0,                                       /* user data                      */
235     #endif
236     GX_STYLE_BORDER_THIN|GX_STYLE_ENABLED|GX_STYLE_TEXT_LEFT,   /* style flags */
237     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
238     sizeof(GX_SINGLE_LINE_TEXT_INPUT),       /* control block size             */
239     GX_COLOR_ID_TEXT_INPUT_FILL,             /* normal color id                */
240     GX_COLOR_ID_TEXT_INPUT_FILL,             /* selected color id              */
241     GX_COLOR_ID_TEXT_INPUT_FILL,             /* disabled color id              */
242     gx_studio_text_input_create,             /* create function                */
243     GX_NULL,                                 /* drawing function override      */
244     (UINT (*)(GX_WIDGET *, GX_EVENT *)) input_field_event_process, /* event function override */
245     {43, 33, 510, 62},                       /* widget size                    */
246     &keyboard_screen_keyboard_frame_define,  /* next widget definition         */
247     &keyboard_screen_pixelmap_button_1_define, /* child widget definition      */
248     offsetof(KEYBOARD_SCREEN_CONTROL_BLOCK, keyboard_screen_keyboard_input_field), /* control block */
249     (void *) &keyboard_screen_keyboard_input_field_properties /* extended properties */
250 };
251 
252 GX_CONST GX_STUDIO_WIDGET keyboard_screen_define =
253 {
254     "keyboard_screen",
255     GX_TYPE_WINDOW,                          /* widget type                    */
256     GX_ID_NONE,                              /* widget id                      */
257     #if defined(GX_WIDGET_USER_DATA)
258     0,                                       /* user data                      */
259     #endif
260     GX_STYLE_BORDER_NONE,                    /* style flags                    */
261     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
262     sizeof(KEYBOARD_SCREEN_CONTROL_BLOCK),   /* control block size             */
263     GX_COLOR_ID_CANVAS,                      /* normal color id                */
264     GX_COLOR_ID_CANVAS,                      /* selected color id              */
265     GX_COLOR_ID_CANVAS,                      /* disabled color id              */
266     gx_studio_window_create,                 /* create function                */
267     GX_NULL,                                 /* drawing function override      */
268     GX_NULL,                                 /* event function override        */
269     {0, 0, 519, 271},                        /* widget size                    */
270     GX_NULL,                                 /* next widget                    */
271     &keyboard_screen_keyboard_input_field_define, /* child widget              */
272     0,                                       /* control block                  */
273     (void *) &keyboard_screen_properties     /* extended properties            */
274 };
275 GX_CONST GX_STUDIO_WIDGET_ENTRY guix_keyboard_widget_table[] =
276 {
277     { &keyboard_screen_define, (GX_WIDGET *) &keyboard_screen },
278     {GX_NULL, GX_NULL}
279 };
280 
gx_studio_nested_widget_create(GX_BYTE * control,GX_CONST GX_STUDIO_WIDGET * definition,GX_WIDGET * parent)281 static GX_WIDGET *gx_studio_nested_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)
282 {
283     UINT status = GX_SUCCESS;
284     GX_WIDGET *widget = GX_NULL;
285     GX_VALUE   list_count = 0;
286     GX_VALUE   list_total_count = 0;
287 
288     if(parent && (parent->gx_widget_type == GX_TYPE_MENU))
289     {
290         list_total_count = ((GX_MENU *)parent)->gx_menu_list_total_count;
291     }
292 
293     while(definition && status == GX_SUCCESS)
294     {
295         if (definition->create_function)
296         {
297             if (definition->style & GX_STYLE_DYNAMICALLY_ALLOCATED)
298             {
299                 status = gx_widget_allocate(&widget, definition->control_block_size);
300                 if (status != GX_SUCCESS)
301                 {
302                     return GX_NULL;
303                 }
304             }
305             else
306             {
307                 if (control == GX_NULL)
308                 {
309                     return GX_NULL;
310                 }
311                 widget = (GX_WIDGET *) (control + definition->control_block_offset);
312             }
313 
314             status = definition->create_function(definition, widget, parent);
315 
316             if(list_count < list_total_count)
317             {
318                 gx_menu_insert((GX_MENU *)parent, widget);
319                 ((GX_MENU *)parent)->gx_menu_list_total_count--;
320                 list_count++;
321             }
322 
323             if (status == GX_SUCCESS)
324             {
325                 if (definition->widget_type != GX_TYPE_TEMPLATE)
326                 {
327 #if defined(GUIX_5_4_0_COMPATIBILITY)
328                     gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id);
329 #else
330                     gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id, definition->disabled_fill_color_id);
331 #endif
332                 }
333 
334                 if (!(definition->status & GX_STATUS_ACCEPTS_FOCUS))
335                 {
336                     gx_widget_status_remove(widget, GX_STATUS_ACCEPTS_FOCUS);
337                 }
338 
339                 if (definition->draw_function)
340                 {
341                     gx_widget_draw_set(widget, definition->draw_function);
342                 }
343                 if (definition->event_function)
344                 {
345                     gx_widget_event_process_set(widget, definition->event_function);
346                 }
347 
348                 #if defined(GX_WIDGET_USER_DATA)
349                 widget->gx_widget_user_data = definition->user_data;
350                 #endif
351 
352                 if (definition->child_widget)
353                 {
354                     gx_studio_nested_widget_create(control, definition->child_widget, widget);
355                 }
356             }
357             definition = definition->next_widget;
358         }
359     }
360     return widget;
361 }
362 
gx_studio_widget_create(GX_BYTE * control,GX_CONST GX_STUDIO_WIDGET * definition,GX_WIDGET * parent)363 GX_WIDGET *gx_studio_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)
364 {
365     GX_WIDGET *widget;
366     widget = gx_studio_nested_widget_create(control, definition, GX_NULL);
367 
368     if (parent && widget)
369     {
370         gx_widget_attach(parent, widget);
371     }
372     return widget;
373 }
374 
gx_studio_named_widget_create(char * name,GX_WIDGET * parent,GX_WIDGET ** new_widget)375 UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget)
376 {
377     UINT status = GX_FAILURE;
378     GX_CONST GX_STUDIO_WIDGET_ENTRY *entry = guix_keyboard_widget_table;
379     GX_WIDGET *widget = GX_NULL;
380 
381     while(entry->widget_information)
382     {
383         if (!strcmp(name, entry->widget_information->widget_name))
384         {
385             widget = gx_studio_widget_create((GX_BYTE *) entry->widget, entry->widget_information, parent);
386             if (widget)
387             {
388                 status = GX_SUCCESS;
389             }
390             break;
391         }
392         entry++;
393     }
394 
395     if (new_widget)
396     {
397         *new_widget = widget;
398     }
399     return status;
400 }
401 
402 
gx_studio_display_configure(USHORT display,UINT (* driver)(GX_DISPLAY *),GX_UBYTE language,USHORT theme,GX_WINDOW_ROOT ** return_root)403 UINT gx_studio_display_configure(USHORT display, UINT (*driver)(GX_DISPLAY *),
404     GX_UBYTE language, USHORT theme, GX_WINDOW_ROOT **return_root)
405 {
406     GX_CONST GX_THEME *theme_ptr;
407     GX_RECTANGLE size;
408 
409     GX_STUDIO_DISPLAY_INFO *display_info = &guix_keyboard_display_table[display];
410 
411 
412 /* create the requested display                                                */
413 
414     gx_display_create(display_info->display,
415                       display_info->name,
416                       driver,
417                       (GX_VALUE) display_info->x_resolution,
418                       (GX_VALUE) display_info->y_resolution);
419 
420 
421 /* install the request theme                                                   */
422 
423     if(display_info->theme_table)
424     {
425         theme_ptr = display_info->theme_table[theme];
426         if(theme_ptr)
427         {
428             gx_display_color_table_set(display_info->display, theme_ptr->theme_color_table, theme_ptr->theme_color_table_size);
429 
430 /* install the color palette if required                                       */
431             if (display_info->display->gx_display_driver_palette_set &&
432                 theme_ptr->theme_palette != NULL)
433             {
434                 display_info->display->gx_display_driver_palette_set(display_info->display, theme_ptr->theme_palette, theme_ptr->theme_palette_size);
435             }
436 
437             gx_display_font_table_set(display_info->display, theme_ptr->theme_font_table, theme_ptr->theme_font_table_size);
438             gx_display_pixelmap_table_set(display_info->display, theme_ptr->theme_pixelmap_table, theme_ptr->theme_pixelmap_table_size);
439             gx_system_scroll_appearance_set(theme_ptr->theme_vertical_scroll_style, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_vertical_scrollbar_appearance);
440             gx_system_scroll_appearance_set(theme_ptr->theme_horizontal_scroll_style, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_horizontal_scrollbar_appearance);
441         }
442     }
443 
444 /* Install the language table.                                                 */
445 
446     if(display_info->language_table)
447     {
448         gx_display_language_table_set_ext(display_info->display, display_info->language_table, (GX_UBYTE) display_info->language_table_size, display_info->string_table_size);
449         gx_display_active_language_set(display_info->display, language);
450     }
451 
452 /* Set screen rotation angle.                                                  */
453 
454     display_info->display->gx_display_rotation_angle = display_info->rotation_angle;
455 
456 /* create the canvas for this display                                          */
457 
458     gx_canvas_create(display_info->canvas,
459                      display_info->canvas_name,
460                      display_info->display,
461                      GX_CANVAS_MANAGED | GX_CANVAS_VISIBLE,
462                      display_info->x_resolution,
463                      display_info->y_resolution,
464                      display_info->canvas_memory,
465                      display_info->canvas_memory_size);
466 
467 /* Create the root window for this canvas                                      */
468 
469     gx_utility_rectangle_define(&size,
470                                 0, 0,
471                                 (GX_VALUE) (display_info->x_resolution - 1),
472                                 (GX_VALUE) (display_info->y_resolution - 1));
473 
474     gx_window_root_create(display_info->root_window,
475                           display_info->name,
476                           display_info->canvas, GX_STYLE_NONE, 0, &size);
477     if (return_root)
478     {
479         *return_root = display_info->root_window;
480     }
481     return GX_SUCCESS;
482 }
483 #undef GUIX_STUDIO_GENERATED_FILE
484