1 /* This is a small demo of the high-performance GUIX graphics framework. */
2 
3 #include <stdio.h>
4 #include "gx_api.h"
5 #include "widget_find_resources.h"
6 #include "widget_find_specifications.h"
7 
8 /* Define the ThreadX demo thread control block and stack.  */
9 
10 GX_WINDOW_ROOT    *root;
11 ULONG *canvas_memory;
12 
13 
14 /* Define prototypes.   */
15 VOID start_guix(VOID);
16 extern UINT win32_graphics_driver_setup_24xrgb(GX_DISPLAY *display);
17 
main(int argc,char ** argv)18 int main(int argc, char ** argv)
19 {
20     tx_kernel_enter();
21     return(0);
22 }
23 
tx_application_define(void * first_unused_memory)24 VOID tx_application_define(void *first_unused_memory)
25 {
26     start_guix();
27 }
28 
start_guix(void)29 VOID start_guix(void)
30 {
31     /* Initialize GUIX.  */
32     gx_system_initialize();
33 
34     gx_studio_display_configure(PRIMARY, win32_graphics_driver_setup_24xrgb,
35                                 LANGUAGE_ENGLISH, PRIMARY_THEME_1, &root);
36 
37    // Use the canvas memory define API
38     canvas_memory = (ULONG *) malloc(PRIMARY_X_RESOLUTION * PRIMARY_Y_RESOLUTION * sizeof(ULONG));
39     gx_canvas_memory_define(root->gx_window_root_canvas, canvas_memory,
40                             PRIMARY_X_RESOLUTION * PRIMARY_Y_RESOLUTION * sizeof(ULONG));
41 
42     /* create the main screen */
43     gx_studio_named_widget_create("main_screen", (GX_WIDGET *) root, GX_NULL);
44 
45     /* Show the root window to make it and patients screen visible.  */
46     gx_widget_show(root);
47 
48     /* start the GUIX thread */
49     gx_system_start();
50 }
51 
main_screen_event_process(GX_WINDOW * widget,GX_EVENT * event_ptr)52 UINT main_screen_event_process(GX_WINDOW *widget, GX_EVENT *event_ptr)
53 {
54     GX_WIDGET *test_1;
55     GX_WIDGET *test_2;
56 
57     if (event_ptr->gx_event_type == GX_EVENT_SHOW)
58     {
59         // Use gx_widget_first_child_get API:
60         gx_widget_first_child_get(&main_screen, &test_1);
61 
62         if (!test_1)
63         {
64             return GX_FAILURE;
65         }
66 
67         // Use the gx_widget_next_sibling_get API:
68         gx_widget_next_sibling_get(test_1, &test_2);
69 
70         if (!test_2)
71         {
72             return GX_FAILURE;
73         }
74 
75         // Use gx_widget_last_child_get API:
76         gx_widget_last_child_get(&main_screen, &test_1);
77 
78         if (!test_1)
79         {
80             return GX_FAILURE;
81         }
82 
83         // Use the gx_widget_previous_sibling_get API:
84         gx_widget_previous_sibling_get(test_1, &test_2);
85         if (!test_2)
86         {
87             return GX_FAILURE;
88         }
89 
90         // Use gx_widget_parent_get API
91         gx_widget_parent_get(test_2, &test_1);
92         if (test_1 != (GX_WIDGET *) &main_screen)
93         {
94             return GX_FAILURE;
95         }
96 
97         // Use gx_widget_top_visible_child_find
98         gx_widget_top_visible_child_find(&main_screen, &test_1);
99 
100         if (!test_1)
101         {
102             return GX_FAILURE;
103         }
104     }
105     return gx_window_event_process(widget, event_ptr);
106 }