1 /* This is a small demo of the high-performance GUIX graphics framework. */
2 
3 #include <stdio.h>
4 #include "gx_api.h"
5 
6 #include "palette_16bpp_resources.h"
7 #include "palette_16bpp_specifications.h"
8 
9 MAIN_WINDOW_CONTROL_BLOCK *pMainWin;
10 GX_WINDOW *pic_window;
11 
12 /* Define the ThreadX demo thread control block and stack.  */
13 
14 TX_THREAD          demo_thread;
15 UCHAR              demo_thread_stack[4096];
16 
17 GX_WINDOW_ROOT    *root;
18 GX_BOOL            transparent = GX_FALSE;
19 GX_BOOL            compressed = GX_FALSE;
20 
21 /* Define prototypes.   */
22 VOID  demo_thread_entry(ULONG thread_input);
23 extern UINT win32_graphics_driver_setup_565rgb(GX_DISPLAY *display);
24 
25 
main(int argc,char ** argv)26 int main(int argc, char ** argv)
27 {
28   tx_kernel_enter();
29   return(0);
30 }
31 
32 
tx_application_define(void * first_unused_memory)33 VOID tx_application_define(void *first_unused_memory)
34 {
35 
36     /* Create the main demo thread.  */
37     tx_thread_create(&demo_thread, "GUIX Demo Thread", demo_thread_entry,
38                      0,  demo_thread_stack, sizeof(demo_thread_stack),
39                      1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
40 }
41 
42 
demo_thread_entry(ULONG thread_input)43 VOID  demo_thread_entry(ULONG thread_input)
44 {
45     /* Initialize GUIX.  */
46     gx_system_initialize();
47 
48 
49     gx_studio_display_configure(DISPLAY_1, win32_graphics_driver_setup_565rgb,
50                                 LANGUAGE_ENGLISH, DISPLAY_1_DEFAULT_THEME, &root);
51 
52     /* create the main screen */
53     gx_studio_named_widget_create("main_window", (GX_WIDGET *) root, (GX_WIDGET **) &pMainWin);
54     pic_window = &pMainWin ->main_window_pic_window;
55 
56     /* Show the root window to make it and patients screen visible.  */
57     gx_widget_show(root);
58 
59     /* let GUIX run */
60     gx_system_start();
61 }
62 
main_event_handler(GX_WINDOW * window,GX_EVENT * myevent)63 UINT main_event_handler(GX_WINDOW *window, GX_EVENT *myevent)
64 {
65     UINT status = 0;
66 
67     switch(myevent -> gx_event_type)
68     {
69     case GX_SIGNAL(ID_TRANSPARENT, GX_EVENT_TOGGLE_ON):
70         transparent = GX_TRUE;
71         gx_system_dirty_mark(pic_window);
72         break;
73 
74     case GX_SIGNAL(ID_TRANSPARENT, GX_EVENT_TOGGLE_OFF):
75         transparent = GX_FALSE;
76         gx_system_dirty_mark(pic_window);
77         break;
78 
79     case GX_SIGNAL(ID_COMPRESSED, GX_EVENT_TOGGLE_ON):
80         compressed = GX_TRUE;
81         gx_system_dirty_mark(pic_window);
82         break;
83 
84     case GX_SIGNAL(ID_COMPRESSED, GX_EVENT_TOGGLE_OFF):
85         compressed = GX_FALSE;
86         gx_system_dirty_mark(pic_window);
87         break;
88 
89     default:
90         status = gx_window_event_process(window, myevent);
91         break;
92     }
93     return status;
94 }
95 
96 
97 
pic_win_draw(GX_WINDOW * window)98 VOID pic_win_draw(GX_WINDOW *window)
99 {
100     if(transparent)
101     {
102         if(compressed)
103         {
104             gx_window_wallpaper_set(window, GX_PIXELMAP_ID_RED_APPLE, GX_FALSE);
105         }
106         else
107         {
108             gx_window_wallpaper_set(window, GX_PIXELMAP_ID_ICON_FOOT_ALPHA, GX_FALSE);
109         }
110     }
111     else
112     {
113         if(compressed)
114         {
115             gx_window_wallpaper_set(window, GX_PIXELMAP_ID_FISH, GX_FALSE);
116         }
117         else
118         {
119             gx_window_wallpaper_set(window, GX_PIXELMAP_ID_SAVE_ICON, GX_FALSE);
120         }
121     }
122 
123     gx_window_draw((GX_WINDOW*) window);
124 }
125