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 "generic_16bpp_32bppdriver_resources.h"
7 #include "generic_16bpp_32bppdriver_specifications.h"
8
9 #define format_565rgb 0
10 #define format_4444argb 1
11
12 MAIN_WINDOW_CONTROL_BLOCK *pMainWin;
13 GX_WINDOW *pic_window;
14
15 /* Define the ThreadX demo thread control block and stack. */
16
17 TX_THREAD demo_thread;
18 UCHAR demo_thread_stack[4096];
19
20 GX_WINDOW_ROOT *root;
21 GX_BOOL alpha = GX_FALSE;
22 GX_BOOL compressed = GX_FALSE;
23 GX_UBYTE format = format_565rgb;
24
25 /* Define prototypes. */
26 VOID demo_thread_entry(ULONG thread_input);
27 extern UINT win32_graphics_driver_setup_24xrgb(GX_DISPLAY *display);
28
29
main(int argc,char ** argv)30 int main(int argc, char ** argv)
31 {
32 tx_kernel_enter();
33 return(0);
34 }
35
36
tx_application_define(void * first_unused_memory)37 VOID tx_application_define(void *first_unused_memory)
38 {
39
40 /* Create the main demo thread. */
41 tx_thread_create(&demo_thread, "GUIX Demo Thread", demo_thread_entry,
42 0, demo_thread_stack, sizeof(demo_thread_stack),
43 1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
44 }
45
46
demo_thread_entry(ULONG thread_input)47 VOID demo_thread_entry(ULONG thread_input)
48 {
49 /* Initialize GUIX. */
50 gx_system_initialize();
51
52
53 gx_studio_display_configure(DISPLAY_1, win32_graphics_driver_setup_24xrgb,
54 LANGUAGE_ENGLISH, DISPLAY_1_DEFAULT_THEME, &root);
55
56 /* create the main screen */
57 gx_studio_named_widget_create("main_window", (GX_WIDGET *) root, (GX_WIDGET **) &pMainWin);
58 pic_window = &pMainWin ->main_window_pic_window;
59
60 /* Show the root window to make it and patients screen visible. */
61 gx_widget_show(root);
62
63 /* let GUIX run */
64 gx_system_start();
65 }
66
main_event_handler(GX_WINDOW * window,GX_EVENT * myevent)67 UINT main_event_handler(GX_WINDOW *window, GX_EVENT *myevent)
68 {
69 UINT status = 0;
70
71 switch(myevent -> gx_event_type)
72 {
73 case GX_SIGNAL(ID_ALPHA, GX_EVENT_TOGGLE_ON):
74 alpha = GX_TRUE;
75 gx_system_dirty_mark(pic_window);
76 break;
77
78 case GX_SIGNAL(ID_ALPHA, GX_EVENT_TOGGLE_OFF):
79 alpha = GX_FALSE;
80 gx_system_dirty_mark(pic_window);
81 break;
82
83 case GX_SIGNAL(ID_COMPRESSED, GX_EVENT_TOGGLE_ON):
84 compressed = GX_TRUE;
85 gx_system_dirty_mark(pic_window);
86 break;
87
88 case GX_SIGNAL(ID_COMPRESSED, GX_EVENT_TOGGLE_OFF):
89 compressed = GX_FALSE;
90 gx_system_dirty_mark(pic_window);
91 break;
92
93 case GX_SIGNAL(ID_565RGB,GX_EVENT_RADIO_SELECT):
94 format = format_565rgb;
95 gx_system_dirty_mark(pic_window);
96 break;
97
98 case GX_SIGNAL(ID_4444ARGB,GX_EVENT_RADIO_SELECT):
99 format = format_4444argb;
100 gx_system_dirty_mark(pic_window);
101 break;
102
103 default:
104 status = gx_window_event_process(window, myevent);
105 break;
106 }
107 return status;
108 }
109
110
111
pic_win_draw(GX_WINDOW * window)112 VOID pic_win_draw(GX_WINDOW *window)
113 {
114 switch(format)
115 {
116 case format_4444argb:
117 if(compressed)
118 {
119 gx_window_wallpaper_set(window, GX_PIXELMAP_ID_RAINBOW200_ALPHA_COMPRESS, GX_FALSE);
120 }
121 else
122 {
123 gx_window_wallpaper_set(window, GX_PIXELMAP_ID_RAINBOW200_ALPHA_NONCOMPRESS, GX_FALSE);
124 }
125 break;
126
127 case format_565rgb:
128 if(alpha)
129 {
130 if(compressed)
131 {
132 gx_window_wallpaper_set(window, GX_PIXELMAP_ID_CAPSULE, GX_FALSE);
133 }
134 else
135 {
136 gx_window_wallpaper_set(window, GX_PIXELMAP_ID_ICON_FOOT_ALPHA, GX_FALSE);
137 }
138 }
139 else
140 {
141 if(compressed)
142 {
143 gx_window_wallpaper_set(window, GX_PIXELMAP_ID_FISH, GX_FALSE);
144 }
145 else
146 {
147 gx_window_wallpaper_set(window, GX_PIXELMAP_ID_RED_APPLE, GX_FALSE);
148 }
149 }
150 break;
151 }
152
153 gx_window_draw((GX_WINDOW*) window);
154 }
155