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.2.0.1                                               */
9 /*  Date (dd.mm.yyyy): 31.10.2022   Time (hh:mm): 14:09                        */
10 /*******************************************************************************/
11 
12 
13 #define GUIX_STUDIO_GENERATED_FILE
14 #include <stddef.h>
15 #include "focus_management_resources.h"
16 #include "focus_management_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 MAIN_SCREEN_CONTROL_BLOCK main_screen;
20 GX_DISPLAY Primary_control_block;
21 GX_WINDOW_ROOT Primary_root_window;
22 GX_CANVAS  Primary_canvas_control_block;
23 ULONG      Primary_canvas_memory[307200];
24 
25 extern GX_CONST GX_THEME *Primary_theme_table[];
26 extern GX_CONST GX_STRING *Primary_language_table[];
27 
28 GX_STUDIO_DISPLAY_INFO focus_management_display_table[1] =
29 {
30     {
31     "Primary",
32     "Primary_canvas",
33     Primary_theme_table,
34     Primary_language_table,
35     PRIMARY_THEME_TABLE_SIZE,
36     PRIMARY_LANGUAGE_TABLE_SIZE,
37     PRIMARY_STRING_TABLE_SIZE,
38     640,                                     /* x resolution                   */
39     480,                                     /* y resolution                   */
40     &Primary_control_block,
41     &Primary_canvas_control_block,
42     &Primary_root_window,
43     Primary_canvas_memory,                   /* canvas memory area             */
44     1228800,                                 /* canvas memory size in bytes    */
45     0                                        /* rotation angle                 */
46     }
47 };
48 
49 
gx_studio_prompt_create(GX_CONST GX_STUDIO_WIDGET * info,GX_WIDGET * control_block,GX_WIDGET * parent)50 UINT gx_studio_prompt_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
51 {
52     UINT status;
53     GX_PROMPT *prompt = (GX_PROMPT *) control_block;
54     GX_PROMPT_PROPERTIES *props = (GX_PROMPT_PROPERTIES *) info->properties;
55     status = gx_prompt_create(prompt, info->widget_name, parent, props->string_id, info->style, info->widget_id, &info->size);
56     if (status == GX_SUCCESS)
57     {
58         gx_prompt_font_set(prompt, props->font_id);
59 #if defined(GUIX_5_4_0_COMPATIBILITY)
60         gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id);
61 #else
62         gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id, props->disabled_text_color_id);
63 #endif
64     }
65     return status;
66 }
67 
gx_studio_window_create(GX_CONST GX_STUDIO_WIDGET * info,GX_WIDGET * control_block,GX_WIDGET * parent)68 UINT gx_studio_window_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
69 {
70     UINT status;
71     GX_WINDOW *window = (GX_WINDOW *) control_block;
72     GX_WINDOW_PROPERTIES *props = (GX_WINDOW_PROPERTIES *) info->properties;
73     status = gx_window_create(window, info->widget_name, parent, info->style, info->widget_id, &info->size);
74     if (status == GX_SUCCESS)
75     {
76         if (props->wallpaper_id)
77         {
78             gx_window_wallpaper_set(window, props->wallpaper_id, info->style & GX_STYLE_TILE_WALLPAPER);
79         }
80     }
81     return status;
82 }
83 GX_WINDOW_PROPERTIES main_screen_properties =
84 {
85     0                                        /* wallpaper pixelmap id          */
86 };
87 GX_WINDOW_PROPERTIES main_screen_window_properties =
88 {
89     0                                        /* wallpaper pixelmap id          */
90 };
91 GX_PROMPT_PROPERTIES main_screen_prompt_2_properties =
92 {
93     GX_STRING_ID_STRING_2,                   /* string id                      */
94     GX_FONT_ID_PROMPT,                       /* font id                        */
95     GX_COLOR_ID_TEXT,                        /* normal text color              */
96     GX_COLOR_ID_SELECTED_TEXT,               /* selected text color            */
97     GX_COLOR_ID_DISABLED_TEXT                /* disabled text color            */
98 };
99 GX_PROMPT_PROPERTIES main_screen_prompt_3_properties =
100 {
101     GX_STRING_ID_STRING_3,                   /* string id                      */
102     GX_FONT_ID_PROMPT,                       /* font id                        */
103     GX_COLOR_ID_TEXT,                        /* normal text color              */
104     GX_COLOR_ID_SELECTED_TEXT,               /* selected text color            */
105     GX_COLOR_ID_DISABLED_TEXT                /* disabled text color            */
106 };
107 GX_PROMPT_PROPERTIES main_screen_prompt_4_properties =
108 {
109     GX_STRING_ID_STRING_5,                   /* string id                      */
110     GX_FONT_ID_PROMPT,                       /* font id                        */
111     GX_COLOR_ID_TEXT,                        /* normal text color              */
112     GX_COLOR_ID_SELECTED_TEXT,               /* selected text color            */
113     GX_COLOR_ID_DISABLED_TEXT                /* disabled text color            */
114 };
115 GX_PROMPT_PROPERTIES main_screen_prompt_1_properties =
116 {
117     GX_STRING_ID_STRING_1,                   /* string id                      */
118     GX_FONT_ID_PROMPT,                       /* font id                        */
119     GX_COLOR_ID_TEXT,                        /* normal text color              */
120     GX_COLOR_ID_SELECTED_TEXT,               /* selected text color            */
121     GX_COLOR_ID_DISABLED_TEXT                /* disabled text color            */
122 };
123 
124 GX_CONST GX_STUDIO_WIDGET main_screen_prompt_4_define =
125 {
126     "prompt_4",
127     GX_TYPE_PROMPT,                          /* widget type                    */
128     GX_ID_NONE,                              /* widget id                      */
129     #if defined(GX_WIDGET_USER_DATA)
130     0,                                       /* user data                      */
131     #endif
132     GX_STYLE_BORDER_THIN|GX_STYLE_ENABLED|GX_STYLE_TEXT_CENTER,   /* style flags */
133     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
134     sizeof(GX_PROMPT),                       /* control block size             */
135     GX_COLOR_ID_WIDGET_FILL,                 /* normal color id                */
136     GX_COLOR_ID_SELECTED_FILL,               /* selected color id              */
137     GX_COLOR_ID_DISABLED_FILL,               /* disabled color id              */
138     gx_studio_prompt_create,                 /* create function                */
139     GX_NULL,                                 /* drawing function override      */
140     GX_NULL,                                 /* event function override        */
141     {326, 223, 405, 246},                    /* widget size                    */
142     GX_NULL,                                 /* no next widget                 */
143     GX_NULL,                                 /* no child widgets               */
144     offsetof(MAIN_SCREEN_CONTROL_BLOCK, main_screen_prompt_4), /* control block */
145     (void *) &main_screen_prompt_4_properties /* extended properties           */
146 };
147 
148 GX_CONST GX_STUDIO_WIDGET main_screen_prompt_3_define =
149 {
150     "prompt_3",
151     GX_TYPE_PROMPT,                          /* widget type                    */
152     GX_ID_NONE,                              /* widget id                      */
153     #if defined(GX_WIDGET_USER_DATA)
154     0,                                       /* user data                      */
155     #endif
156     GX_STYLE_BORDER_THIN|GX_STYLE_ENABLED|GX_STYLE_TEXT_CENTER,   /* style flags */
157     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
158     sizeof(GX_PROMPT),                       /* control block size             */
159     GX_COLOR_ID_WIDGET_FILL,                 /* normal color id                */
160     GX_COLOR_ID_SELECTED_FILL,               /* selected color id              */
161     GX_COLOR_ID_DISABLED_FILL,               /* disabled color id              */
162     gx_studio_prompt_create,                 /* create function                */
163     GX_NULL,                                 /* drawing function override      */
164     GX_NULL,                                 /* event function override        */
165     {276, 162, 355, 185},                    /* widget size                    */
166     &main_screen_prompt_4_define,            /* next widget definition         */
167     GX_NULL,                                 /* no child widgets               */
168     offsetof(MAIN_SCREEN_CONTROL_BLOCK, main_screen_prompt_3), /* control block */
169     (void *) &main_screen_prompt_3_properties /* extended properties           */
170 };
171 
172 GX_CONST GX_STUDIO_WIDGET main_screen_prompt_2_define =
173 {
174     "prompt_2",
175     GX_TYPE_PROMPT,                          /* widget type                    */
176     GX_ID_NONE,                              /* widget id                      */
177     #if defined(GX_WIDGET_USER_DATA)
178     0,                                       /* user data                      */
179     #endif
180     GX_STYLE_BORDER_THIN|GX_STYLE_ENABLED|GX_STYLE_TEXT_CENTER,   /* style flags */
181     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
182     sizeof(GX_PROMPT),                       /* control block size             */
183     GX_COLOR_ID_WIDGET_FILL,                 /* normal color id                */
184     GX_COLOR_ID_SELECTED_FILL,               /* selected color id              */
185     GX_COLOR_ID_DISABLED_FILL,               /* disabled color id              */
186     gx_studio_prompt_create,                 /* create function                */
187     GX_NULL,                                 /* drawing function override      */
188     GX_NULL,                                 /* event function override        */
189     {223, 116, 302, 139},                    /* widget size                    */
190     &main_screen_prompt_3_define,            /* next widget definition         */
191     GX_NULL,                                 /* no child widgets               */
192     offsetof(MAIN_SCREEN_CONTROL_BLOCK, main_screen_prompt_2), /* control block */
193     (void *) &main_screen_prompt_2_properties /* extended properties           */
194 };
195 
196 GX_CONST GX_STUDIO_WIDGET main_screen_prompt_1_define =
197 {
198     "prompt_1",
199     GX_TYPE_PROMPT,                          /* widget type                    */
200     GX_ID_NONE,                              /* widget id                      */
201     #if defined(GX_WIDGET_USER_DATA)
202     0,                                       /* user data                      */
203     #endif
204     GX_STYLE_BORDER_THIN|GX_STYLE_ENABLED|GX_STYLE_TEXT_CENTER,   /* style flags */
205     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
206     sizeof(GX_PROMPT),                       /* control block size             */
207     GX_COLOR_ID_WIDGET_FILL,                 /* normal color id                */
208     GX_COLOR_ID_SELECTED_FILL,               /* selected color id              */
209     GX_COLOR_ID_DISABLED_FILL,               /* disabled color id              */
210     gx_studio_prompt_create,                 /* create function                */
211     GX_NULL,                                 /* drawing function override      */
212     GX_NULL,                                 /* event function override        */
213     {44, 23, 123, 46},                       /* widget size                    */
214     GX_NULL,                                 /* no next widget                 */
215     GX_NULL,                                 /* no child widgets               */
216     offsetof(MAIN_SCREEN_CONTROL_BLOCK, main_screen_prompt_1), /* control block */
217     (void *) &main_screen_prompt_1_properties /* extended properties           */
218 };
219 
220 GX_CONST GX_STUDIO_WIDGET main_screen_window_define =
221 {
222     "window",
223     GX_TYPE_WINDOW,                          /* widget type                    */
224     GX_ID_NONE,                              /* widget id                      */
225     #if defined(GX_WIDGET_USER_DATA)
226     0,                                       /* user data                      */
227     #endif
228     GX_STYLE_BORDER_THIN|GX_STYLE_ENABLED,   /* style flags                    */
229     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
230     sizeof(GX_WINDOW),                       /* control block size             */
231     GX_COLOR_ID_WINDOW_FILL,                 /* normal color id                */
232     GX_COLOR_ID_WINDOW_FILL,                 /* selected color id              */
233     GX_COLOR_ID_DISABLED_FILL,               /* disabled color id              */
234     gx_studio_window_create,                 /* create function                */
235     GX_NULL,                                 /* drawing function override      */
236     GX_NULL,                                 /* event function override        */
237     {201, 101, 420, 263},                    /* widget size                    */
238     &main_screen_prompt_1_define,            /* next widget definition         */
239     &main_screen_prompt_2_define,            /* child widget definition        */
240     offsetof(MAIN_SCREEN_CONTROL_BLOCK, main_screen_window), /* control block  */
241     (void *) &main_screen_window_properties  /* extended properties            */
242 };
243 
244 GX_CONST GX_STUDIO_WIDGET main_screen_define =
245 {
246     "main_screen",
247     GX_TYPE_WINDOW,                          /* widget type                    */
248     GX_ID_NONE,                              /* widget id                      */
249     #if defined(GX_WIDGET_USER_DATA)
250     0,                                       /* user data                      */
251     #endif
252     GX_STYLE_BORDER_THIN|GX_STYLE_ENABLED,   /* style flags                    */
253     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
254     sizeof(MAIN_SCREEN_CONTROL_BLOCK),       /* control block size             */
255     GX_COLOR_ID_WINDOW_FILL,                 /* normal color id                */
256     GX_COLOR_ID_WINDOW_FILL,                 /* selected color id              */
257     GX_COLOR_ID_DISABLED_FILL,               /* disabled color id              */
258     gx_studio_window_create,                 /* create function                */
259     GX_NULL,                                 /* drawing function override      */
260     GX_NULL,                                 /* event function override        */
261     {0, 0, 639, 479},                        /* widget size                    */
262     GX_NULL,                                 /* next widget                    */
263     &main_screen_window_define,              /* child widget                   */
264     0,                                       /* control block                  */
265     (void *) &main_screen_properties         /* extended properties            */
266 };
267 GX_CONST GX_STUDIO_WIDGET_ENTRY focus_management_widget_table[] =
268 {
269     { &main_screen_define, (GX_WIDGET *) &main_screen },
270     {GX_NULL, GX_NULL}
271 };
272 
gx_studio_nested_widget_create(GX_BYTE * control,GX_CONST GX_STUDIO_WIDGET * definition,GX_WIDGET * parent)273 static GX_WIDGET *gx_studio_nested_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)
274 {
275     UINT status = GX_SUCCESS;
276     GX_WIDGET *widget = GX_NULL;
277     GX_VALUE   list_count = 0;
278     GX_VALUE   list_total_count = 0;
279 
280     if(parent && (parent->gx_widget_type == GX_TYPE_MENU))
281     {
282         list_total_count = ((GX_MENU *)parent)->gx_menu_list_total_count;
283     }
284 
285     while(definition && status == GX_SUCCESS)
286     {
287         if (definition->create_function)
288         {
289             if (definition->style & GX_STYLE_DYNAMICALLY_ALLOCATED)
290             {
291                 status = gx_widget_allocate(&widget, definition->control_block_size);
292                 if (status != GX_SUCCESS)
293                 {
294                     return GX_NULL;
295                 }
296             }
297             else
298             {
299                 if (control == GX_NULL)
300                 {
301                     return GX_NULL;
302                 }
303                 widget = (GX_WIDGET *) (control + definition->control_block_offset);
304             }
305 
306             status = definition->create_function(definition, widget, parent);
307 
308             if(list_count < list_total_count)
309             {
310                 gx_menu_insert((GX_MENU *)parent, widget);
311                 ((GX_MENU *)parent)->gx_menu_list_total_count--;
312                 list_count++;
313             }
314 
315             if (status == GX_SUCCESS)
316             {
317                 if (definition->widget_type != GX_TYPE_TEMPLATE)
318                 {
319 #if defined(GUIX_5_4_0_COMPATIBILITY)
320                     gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id);
321 #else
322                     gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id, definition->disabled_fill_color_id);
323 #endif
324                 }
325 
326                 if (!(definition->status & GX_STATUS_ACCEPTS_FOCUS))
327                 {
328                     gx_widget_status_remove(widget, GX_STATUS_ACCEPTS_FOCUS);
329                 }
330 
331                 if (definition->draw_function)
332                 {
333                     gx_widget_draw_set(widget, definition->draw_function);
334                 }
335                 if (definition->event_function)
336                 {
337                     gx_widget_event_process_set(widget, definition->event_function);
338                 }
339 
340                 #if defined(GX_WIDGET_USER_DATA)
341                 widget->gx_widget_user_data = definition->user_data;
342                 #endif
343 
344                 if (definition->child_widget)
345                 {
346                     gx_studio_nested_widget_create(control, definition->child_widget, widget);
347                 }
348             }
349             definition = definition->next_widget;
350         }
351     }
352     return widget;
353 }
354 
gx_studio_widget_create(GX_BYTE * control,GX_CONST GX_STUDIO_WIDGET * definition,GX_WIDGET * parent)355 GX_WIDGET *gx_studio_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)
356 {
357     GX_WIDGET *widget;
358     widget = gx_studio_nested_widget_create(control, definition, GX_NULL);
359 
360     if (parent && widget)
361     {
362         gx_widget_attach(parent, widget);
363     }
364     return widget;
365 }
366 
gx_studio_named_widget_create(char * name,GX_WIDGET * parent,GX_WIDGET ** new_widget)367 UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget)
368 {
369     UINT status = GX_FAILURE;
370     GX_CONST GX_STUDIO_WIDGET_ENTRY *entry = focus_management_widget_table;
371     GX_WIDGET *widget = GX_NULL;
372 
373     while(entry->widget_information)
374     {
375         if (!strcmp(name, entry->widget_information->widget_name))
376         {
377             widget = gx_studio_widget_create((GX_BYTE *) entry->widget, entry->widget_information, parent);
378             if (widget)
379             {
380                 status = GX_SUCCESS;
381             }
382             break;
383         }
384         entry++;
385     }
386 
387     if (new_widget)
388     {
389         *new_widget = widget;
390     }
391     return status;
392 }
393 
394 
gx_studio_display_configure(USHORT display,UINT (* driver)(GX_DISPLAY *),GX_UBYTE language,USHORT theme,GX_WINDOW_ROOT ** return_root)395 UINT gx_studio_display_configure(USHORT display, UINT (*driver)(GX_DISPLAY *),
396     GX_UBYTE language, USHORT theme, GX_WINDOW_ROOT **return_root)
397 {
398     GX_CONST GX_THEME *theme_ptr;
399     GX_RECTANGLE size;
400 
401     GX_STUDIO_DISPLAY_INFO *display_info = &focus_management_display_table[display];
402 
403 
404 /* create the requested display                                                */
405 
406     gx_display_create(display_info->display,
407                       display_info->name,
408                       driver,
409                       (GX_VALUE) display_info->x_resolution,
410                       (GX_VALUE) display_info->y_resolution);
411 
412 
413 /* install the request theme                                                   */
414 
415     if(display_info->theme_table)
416     {
417         theme_ptr = display_info->theme_table[theme];
418         if(theme_ptr)
419         {
420             gx_display_color_table_set(display_info->display, theme_ptr->theme_color_table, theme_ptr->theme_color_table_size);
421 
422 /* install the color palette if required                                       */
423             if (display_info->display->gx_display_driver_palette_set &&
424                 theme_ptr->theme_palette != NULL)
425             {
426                 display_info->display->gx_display_driver_palette_set(display_info->display, theme_ptr->theme_palette, theme_ptr->theme_palette_size);
427             }
428 
429             gx_display_font_table_set(display_info->display, theme_ptr->theme_font_table, theme_ptr->theme_font_table_size);
430             gx_display_pixelmap_table_set(display_info->display, theme_ptr->theme_pixelmap_table, theme_ptr->theme_pixelmap_table_size);
431             gx_system_scroll_appearance_set(theme_ptr->theme_vertical_scroll_style, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_vertical_scrollbar_appearance);
432             gx_system_scroll_appearance_set(theme_ptr->theme_horizontal_scroll_style, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_horizontal_scrollbar_appearance);
433         }
434     }
435 
436 /* Install the language table.                                                 */
437 
438     if(display_info->language_table)
439     {
440         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);
441         gx_display_active_language_set(display_info->display, language);
442     }
443 
444 /* Set screen rotation angle.                                                  */
445 
446     display_info->display->gx_display_rotation_angle = display_info->rotation_angle;
447 
448 /* create the canvas for this display                                          */
449 
450     gx_canvas_create(display_info->canvas,
451                      display_info->canvas_name,
452                      display_info->display,
453                      GX_CANVAS_MANAGED | GX_CANVAS_VISIBLE,
454                      display_info->x_resolution,
455                      display_info->y_resolution,
456                      display_info->canvas_memory,
457                      display_info->canvas_memory_size);
458 
459 /* Create the root window for this canvas                                      */
460 
461     gx_utility_rectangle_define(&size,
462                                 0, 0,
463                                 (GX_VALUE) (display_info->x_resolution - 1),
464                                 (GX_VALUE) (display_info->y_resolution - 1));
465 
466     gx_window_root_create(display_info->root_window,
467                           display_info->name,
468                           display_info->canvas, GX_STYLE_NONE, 0, &size);
469     if (return_root)
470     {
471         *return_root = display_info->root_window;
472     }
473     return GX_SUCCESS;
474 }
475 #undef GUIX_STUDIO_GENERATED_FILE
476