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:11                        */
10 /*******************************************************************************/
11 
12 
13 #define GUIX_STUDIO_GENERATED_FILE
14 #include <stddef.h>
15 #include "sprite_16bpp_resources.h"
16 #include "sprite_16bpp_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_WINDOW_CONTROL_BLOCK main_window;
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[153600];
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 sprite_16bpp_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     640,                                     /* x resolution                   */
39     480,                                     /* 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     614400,                                  /* canvas memory size in bytes    */
45     0                                        /* rotation angle                 */
46     }
47 };
48 
49 
gx_studio_slider_create(GX_CONST GX_STUDIO_WIDGET * info,GX_WIDGET * control_block,GX_WIDGET * parent)50 UINT gx_studio_slider_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
51 {
52     UINT status;
53     GX_SLIDER *slider = (GX_SLIDER *) control_block;
54     GX_SLIDER_PROPERTIES *props = (GX_SLIDER_PROPERTIES *) info->properties;
55     GX_SLIDER_INFO slider_info;
56     slider_info.gx_slider_info_min_val = props->minval;
57     slider_info.gx_slider_info_max_val = props->maxval;
58     slider_info.gx_slider_info_current_val = props->current_val;
59     slider_info.gx_slider_info_increment = props->increment;
60     slider_info.gx_slider_info_min_travel = props->min_travel;
61     slider_info.gx_slider_info_max_travel = props->max_travel;
62     slider_info.gx_slider_info_needle_width = props->needle_width;
63     slider_info.gx_slider_info_needle_height = props->needle_height;
64     slider_info.gx_slider_info_needle_inset = props->needle_inset;
65     slider_info.gx_slider_info_needle_hotspot_offset = props->needle_hotspot;
66     status = gx_slider_create(slider,
67                     info->widget_name,
68                     parent,
69                     props->tickmark_count,
70                     &slider_info,
71                     info->style,
72                     info->widget_id,
73                     &info->size);
74     return status;
75 }
76 
gx_studio_prompt_create(GX_CONST GX_STUDIO_WIDGET * info,GX_WIDGET * control_block,GX_WIDGET * parent)77 UINT gx_studio_prompt_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
78 {
79     UINT status;
80     GX_PROMPT *prompt = (GX_PROMPT *) control_block;
81     GX_PROMPT_PROPERTIES *props = (GX_PROMPT_PROPERTIES *) info->properties;
82     status = gx_prompt_create(prompt, info->widget_name, parent, props->string_id, info->style, info->widget_id, &info->size);
83     if (status == GX_SUCCESS)
84     {
85         gx_prompt_font_set(prompt, props->font_id);
86 #if defined(GUIX_5_4_0_COMPATIBILITY)
87         gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id);
88 #else
89         gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id, props->disabled_text_color_id);
90 #endif
91     }
92     return status;
93 }
94 
gx_studio_window_create(GX_CONST GX_STUDIO_WIDGET * info,GX_WIDGET * control_block,GX_WIDGET * parent)95 UINT gx_studio_window_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
96 {
97     UINT status;
98     GX_WINDOW *window = (GX_WINDOW *) control_block;
99     GX_WINDOW_PROPERTIES *props = (GX_WINDOW_PROPERTIES *) info->properties;
100     status = gx_window_create(window, info->widget_name, parent, info->style, info->widget_id, &info->size);
101     if (status == GX_SUCCESS)
102     {
103         if (props->wallpaper_id)
104         {
105             gx_window_wallpaper_set(window, props->wallpaper_id, info->style & GX_STYLE_TILE_WALLPAPER);
106         }
107     }
108     return status;
109 }
110 GX_WINDOW_PROPERTIES main_window_properties =
111 {
112     0                                        /* wallpaper pixelmap id          */
113 };
114 GX_WINDOW_PROPERTIES main_window_AppleWindow_properties =
115 {
116     GX_PIXELMAP_ID_RED_APPLE                 /* wallpaper pixelmap id          */
117 };
118 GX_PROMPT_PROPERTIES main_window_alpha_label_properties =
119 {
120     GX_STRING_ID_STRING_13,                  /* string id                      */
121     GX_FONT_ID_PROMPT,                       /* font id                        */
122     GX_COLOR_ID_TEXT,                        /* normal text color              */
123     GX_COLOR_ID_SELECTED_TEXT,               /* selected text color            */
124     GX_COLOR_ID_TEXT                         /* disabled text color            */
125 };
126 GX_SLIDER_PROPERTIES main_window_alpha_slider_properties =
127 {
128     10,                                      /* tickmark count                 */
129     0,                                       /* mimimun value                  */
130     255,                                     /* maximum value                  */
131     255,                                     /* current value                  */
132     10,                                      /* increment                      */
133     10,                                      /* minimum travel                 */
134     10,                                      /* maximum travel                 */
135     5,                                       /* needle width                   */
136     20,                                      /* needle height                  */
137     4,                                       /* needle inset                   */
138     2                                        /* needle hotspot                 */
139 };
140 GX_PROMPT_PROPERTIES main_window_alpha_display_properties =
141 {
142     GX_STRING_ID_STRING_14,                  /* string id                      */
143     GX_FONT_ID_PROMPT,                       /* font id                        */
144     GX_COLOR_ID_TEXT,                        /* normal text color              */
145     GX_COLOR_ID_SELECTED_TEXT,               /* selected text color            */
146     GX_COLOR_ID_TEXT                         /* disabled text color            */
147 };
148 
149 GX_CONST GX_STUDIO_WIDGET main_window_alpha_display_define =
150 {
151     "alpha_display",
152     GX_TYPE_PROMPT,                          /* widget type                    */
153     ID_ALPHA_DISPLAY,                        /* widget id                      */
154     #if defined(GX_WIDGET_USER_DATA)
155     0,                                       /* user data                      */
156     #endif
157     GX_STYLE_BORDER_RECESSED|GX_STYLE_ENABLED|GX_STYLE_TEXT_CENTER,   /* style flags */
158     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
159     sizeof(GX_PROMPT),                       /* control block size             */
160     GX_COLOR_ID_LIGHTGRAY,                   /* normal color id                */
161     GX_COLOR_ID_SELECTED_FILL,               /* selected color id              */
162     GX_COLOR_ID_LIGHTGRAY,                   /* disabled color id              */
163     gx_studio_prompt_create,                 /* create function                */
164     GX_NULL,                                 /* drawing function override      */
165     GX_NULL,                                 /* event function override        */
166     {342, 42, 390, 65},                      /* widget size                    */
167     GX_NULL,                                 /* no next widget                 */
168     GX_NULL,                                 /* no child widgets               */
169     offsetof(MAIN_WINDOW_CONTROL_BLOCK, main_window_alpha_display), /* control block */
170     (void *) &main_window_alpha_display_properties /* extended properties      */
171 };
172 
173 GX_CONST GX_STUDIO_WIDGET main_window_alpha_slider_define =
174 {
175     "alpha_slider",
176     GX_TYPE_SLIDER,                          /* widget type                    */
177     ID_ALPHA_SLIDER,                         /* widget id                      */
178     #if defined(GX_WIDGET_USER_DATA)
179     0,                                       /* user data                      */
180     #endif
181     GX_STYLE_BORDER_RAISED|GX_STYLE_ENABLED|GX_STYLE_SHOW_NEEDLE|GX_STYLE_SHOW_TICKMARKS,   /* style flags */
182     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
183     sizeof(GX_SLIDER),                       /* control block size             */
184     GX_COLOR_ID_BTN_UPPER,                   /* normal color id                */
185     GX_COLOR_ID_BTN_UPPER,                   /* selected color id              */
186     GX_COLOR_ID_BTN_UPPER,                   /* disabled color id              */
187     gx_studio_slider_create,                 /* create function                */
188     GX_NULL,                                 /* drawing function override      */
189     GX_NULL,                                 /* event function override        */
190     {223, 418, 408, 454},                    /* widget size                    */
191     &main_window_alpha_display_define,       /* next widget definition         */
192     GX_NULL,                                 /* no child widgets               */
193     offsetof(MAIN_WINDOW_CONTROL_BLOCK, main_window_alpha_slider), /* control block */
194     (void *) &main_window_alpha_slider_properties /* extended properties       */
195 };
196 
197 GX_CONST GX_STUDIO_WIDGET main_window_alpha_label_define =
198 {
199     "alpha_label",
200     GX_TYPE_PROMPT,                          /* widget type                    */
201     GX_ID_NONE,                              /* widget id                      */
202     #if defined(GX_WIDGET_USER_DATA)
203     0,                                       /* user data                      */
204     #endif
205     GX_STYLE_BORDER_NONE|GX_STYLE_TRANSPARENT|GX_STYLE_TEXT_CENTER,   /* style flags */
206     0,                                       /* status flags                   */
207     sizeof(GX_PROMPT),                       /* control block size             */
208     GX_COLOR_ID_WIDGET_FILL,                 /* normal color id                */
209     GX_COLOR_ID_SELECTED_FILL,               /* selected color id              */
210     GX_COLOR_ID_WIDGET_FILL,                 /* disabled color id              */
211     gx_studio_prompt_create,                 /* create function                */
212     GX_NULL,                                 /* drawing function override      */
213     GX_NULL,                                 /* event function override        */
214     {243, 45, 332, 62},                      /* widget size                    */
215     &main_window_alpha_slider_define,        /* next widget definition         */
216     GX_NULL,                                 /* no child widgets               */
217     offsetof(MAIN_WINDOW_CONTROL_BLOCK, main_window_alpha_label), /* control block */
218     (void *) &main_window_alpha_label_properties /* extended properties        */
219 };
220 
221 GX_CONST GX_STUDIO_WIDGET main_window_AppleWindow_define =
222 {
223     "AppleWindow",
224     GX_TYPE_WINDOW,                          /* widget type                    */
225     GX_ID_NONE,                              /* widget id                      */
226     #if defined(GX_WIDGET_USER_DATA)
227     0,                                       /* user data                      */
228     #endif
229     GX_STYLE_BORDER_NONE|GX_STYLE_TRANSPARENT,   /* style flags                */
230     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
231     sizeof(GX_WINDOW),                       /* control block size             */
232     GX_COLOR_ID_WHITE,                       /* normal color id                */
233     GX_COLOR_ID_WHITE,                       /* selected color id              */
234     GX_COLOR_ID_WHITE,                       /* disabled color id              */
235     gx_studio_window_create,                 /* create function                */
236     (VOID (*)(GX_WIDGET *)) AppleWindowDraw, /* drawing function override      */
237     GX_NULL,                                 /* event function override        */
238     {219, 96, 413, 362},                     /* widget size                    */
239     &main_window_alpha_label_define,         /* next widget definition         */
240     GX_NULL,                                 /* no child widgets               */
241     offsetof(MAIN_WINDOW_CONTROL_BLOCK, main_window_AppleWindow), /* control block */
242     (void *) &main_window_AppleWindow_properties /* extended properties        */
243 };
244 
245 GX_CONST GX_STUDIO_WIDGET main_window_define =
246 {
247     "main_window",
248     GX_TYPE_WINDOW,                          /* widget type                    */
249     GX_ID_NONE,                              /* widget id                      */
250     #if defined(GX_WIDGET_USER_DATA)
251     0,                                       /* user data                      */
252     #endif
253     GX_STYLE_BORDER_NONE,                    /* style flags                    */
254     GX_STATUS_ACCEPTS_FOCUS,                 /* status flags                   */
255     sizeof(MAIN_WINDOW_CONTROL_BLOCK),       /* control block size             */
256     GX_COLOR_ID_WHITE,                       /* normal color id                */
257     GX_COLOR_ID_WHITE,                       /* selected color id              */
258     GX_COLOR_ID_WHITE,                       /* disabled color id              */
259     gx_studio_window_create,                 /* create function                */
260     GX_NULL,                                 /* drawing function override      */
261     (UINT (*)(GX_WIDGET *, GX_EVENT *)) MainWindowEventProcess, /* event function override */
262     {-1, -2, 638, 477},                      /* widget size                    */
263     GX_NULL,                                 /* next widget                    */
264     &main_window_AppleWindow_define,         /* child widget                   */
265     0,                                       /* control block                  */
266     (void *) &main_window_properties         /* extended properties            */
267 };
268 GX_CONST GX_STUDIO_WIDGET_ENTRY sprite_16bpp_widget_table[] =
269 {
270     { &main_window_define, (GX_WIDGET *) &main_window },
271     {GX_NULL, GX_NULL}
272 };
273 
gx_studio_nested_widget_create(GX_BYTE * control,GX_CONST GX_STUDIO_WIDGET * definition,GX_WIDGET * parent)274 static GX_WIDGET *gx_studio_nested_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)
275 {
276     UINT status = GX_SUCCESS;
277     GX_WIDGET *widget = GX_NULL;
278     GX_VALUE   list_count = 0;
279     GX_VALUE   list_total_count = 0;
280 
281     if(parent && (parent->gx_widget_type == GX_TYPE_MENU))
282     {
283         list_total_count = ((GX_MENU *)parent)->gx_menu_list_total_count;
284     }
285 
286     while(definition && status == GX_SUCCESS)
287     {
288         if (definition->create_function)
289         {
290             if (definition->style & GX_STYLE_DYNAMICALLY_ALLOCATED)
291             {
292                 status = gx_widget_allocate(&widget, definition->control_block_size);
293                 if (status != GX_SUCCESS)
294                 {
295                     return GX_NULL;
296                 }
297             }
298             else
299             {
300                 if (control == GX_NULL)
301                 {
302                     return GX_NULL;
303                 }
304                 widget = (GX_WIDGET *) (control + definition->control_block_offset);
305             }
306 
307             status = definition->create_function(definition, widget, parent);
308 
309             if(list_count < list_total_count)
310             {
311                 gx_menu_insert((GX_MENU *)parent, widget);
312                 ((GX_MENU *)parent)->gx_menu_list_total_count--;
313                 list_count++;
314             }
315 
316             if (status == GX_SUCCESS)
317             {
318                 if (definition->widget_type != GX_TYPE_TEMPLATE)
319                 {
320 #if defined(GUIX_5_4_0_COMPATIBILITY)
321                     gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id);
322 #else
323                     gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id, definition->disabled_fill_color_id);
324 #endif
325                 }
326 
327                 if (!(definition->status & GX_STATUS_ACCEPTS_FOCUS))
328                 {
329                     gx_widget_status_remove(widget, GX_STATUS_ACCEPTS_FOCUS);
330                 }
331 
332                 if (definition->draw_function)
333                 {
334                     gx_widget_draw_set(widget, definition->draw_function);
335                 }
336                 if (definition->event_function)
337                 {
338                     gx_widget_event_process_set(widget, definition->event_function);
339                 }
340 
341                 #if defined(GX_WIDGET_USER_DATA)
342                 widget->gx_widget_user_data = definition->user_data;
343                 #endif
344 
345                 if (definition->child_widget)
346                 {
347                     gx_studio_nested_widget_create(control, definition->child_widget, widget);
348                 }
349             }
350             definition = definition->next_widget;
351         }
352     }
353     return widget;
354 }
355 
gx_studio_widget_create(GX_BYTE * control,GX_CONST GX_STUDIO_WIDGET * definition,GX_WIDGET * parent)356 GX_WIDGET *gx_studio_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)
357 {
358     GX_WIDGET *widget;
359     widget = gx_studio_nested_widget_create(control, definition, GX_NULL);
360 
361     if (parent && widget)
362     {
363         gx_widget_attach(parent, widget);
364     }
365     return widget;
366 }
367 
gx_studio_named_widget_create(char * name,GX_WIDGET * parent,GX_WIDGET ** new_widget)368 UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget)
369 {
370     UINT status = GX_FAILURE;
371     GX_CONST GX_STUDIO_WIDGET_ENTRY *entry = sprite_16bpp_widget_table;
372     GX_WIDGET *widget = GX_NULL;
373 
374     while(entry->widget_information)
375     {
376         if (!strcmp(name, entry->widget_information->widget_name))
377         {
378             widget = gx_studio_widget_create((GX_BYTE *) entry->widget, entry->widget_information, parent);
379             if (widget)
380             {
381                 status = GX_SUCCESS;
382             }
383             break;
384         }
385         entry++;
386     }
387 
388     if (new_widget)
389     {
390         *new_widget = widget;
391     }
392     return status;
393 }
394 
395 
gx_studio_display_configure(USHORT display,UINT (* driver)(GX_DISPLAY *),GX_UBYTE language,USHORT theme,GX_WINDOW_ROOT ** return_root)396 UINT gx_studio_display_configure(USHORT display, UINT (*driver)(GX_DISPLAY *),
397     GX_UBYTE language, USHORT theme, GX_WINDOW_ROOT **return_root)
398 {
399     GX_CONST GX_THEME *theme_ptr;
400     GX_RECTANGLE size;
401 
402     GX_STUDIO_DISPLAY_INFO *display_info = &sprite_16bpp_display_table[display];
403 
404 
405 /* create the requested display                                                */
406 
407     gx_display_create(display_info->display,
408                       display_info->name,
409                       driver,
410                       (GX_VALUE) display_info->x_resolution,
411                       (GX_VALUE) display_info->y_resolution);
412 
413 
414 /* install the request theme                                                   */
415 
416     if(display_info->theme_table)
417     {
418         theme_ptr = display_info->theme_table[theme];
419         if(theme_ptr)
420         {
421             gx_display_color_table_set(display_info->display, theme_ptr->theme_color_table, theme_ptr->theme_color_table_size);
422 
423 /* install the color palette if required                                       */
424             if (display_info->display->gx_display_driver_palette_set &&
425                 theme_ptr->theme_palette != NULL)
426             {
427                 display_info->display->gx_display_driver_palette_set(display_info->display, theme_ptr->theme_palette, theme_ptr->theme_palette_size);
428             }
429 
430             gx_display_font_table_set(display_info->display, theme_ptr->theme_font_table, theme_ptr->theme_font_table_size);
431             gx_display_pixelmap_table_set(display_info->display, theme_ptr->theme_pixelmap_table, theme_ptr->theme_pixelmap_table_size);
432             gx_system_scroll_appearance_set(theme_ptr->theme_vertical_scroll_style, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_vertical_scrollbar_appearance);
433             gx_system_scroll_appearance_set(theme_ptr->theme_horizontal_scroll_style, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_horizontal_scrollbar_appearance);
434         }
435     }
436 
437 /* Install the language table.                                                 */
438 
439     if(display_info->language_table)
440     {
441         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);
442         gx_display_active_language_set(display_info->display, language);
443     }
444 
445 /* Set screen rotation angle.                                                  */
446 
447     display_info->display->gx_display_rotation_angle = display_info->rotation_angle;
448 
449 /* create the canvas for this display                                          */
450 
451     gx_canvas_create(display_info->canvas,
452                      display_info->canvas_name,
453                      display_info->display,
454                      GX_CANVAS_MANAGED | GX_CANVAS_VISIBLE,
455                      display_info->x_resolution,
456                      display_info->y_resolution,
457                      display_info->canvas_memory,
458                      display_info->canvas_memory_size);
459 
460 /* Create the root window for this canvas                                      */
461 
462     gx_utility_rectangle_define(&size,
463                                 0, 0,
464                                 (GX_VALUE) (display_info->x_resolution - 1),
465                                 (GX_VALUE) (display_info->y_resolution - 1));
466 
467     gx_window_root_create(display_info->root_window,
468                           display_info->name,
469                           display_info->canvas, GX_STYLE_NONE, 0, &size);
470     if (return_root)
471     {
472         *return_root = display_info->root_window;
473     }
474     return GX_SUCCESS;
475 }
476 #undef GUIX_STUDIO_GENERATED_FILE
477