1 /* This is a small demo of the high-performance GUIX graphics framework. */
2 
3 #include <stdio.h>
4 #include <string.h>
5 #include "gx_api.h"
6 
7 #include "pixelmaps_4444argb_resources.h"
8 #include "pixelmaps_4444argb_specifications.h"
9 
10 MAIN_WINDOW_CONTROL_BLOCK *pMainWin;
11 GX_WINDOW *pic_window;
12 
13 /* Define the ThreadX demo thread control block and stack.  */
14 
15 TX_THREAD          demo_thread;
16 UCHAR              demo_thread_stack[4096];
17 
18 GX_WINDOW_ROOT    *root;
19 INT                alpha = 1;
20 INT                compress = 2;
21 INT                style_index = 3;
22 INT                depth_inex = 0;
23 GX_UBYTE           brush_alpha = 0xff;
24 
25 /* maps[depth_inex][style_index] */
26 GX_RESOURCE_ID   maps[4] = { GX_PIXELMAP_ID_RAW_4444ARGB, GX_PIXELMAP_ID_ALPHA_4444ARGB, GX_PIXELMAP_ID_COMPRESS_4444ARGB, GX_PIXELMAP_ID_COMPRESS_ALPHA_4444ARGB };
27 
28 /* Define prototypes.   */
29 VOID  demo_thread_entry(ULONG thread_input);
30 extern UINT win32_graphics_driver_setup_4444argb(GX_DISPLAY *display);
31 
32 
main(int argc,char ** argv)33 int main(int argc, char ** argv)
34 {
35   tx_kernel_enter();
36   return(0);
37 }
38 
39 
tx_application_define(void * first_unused_memory)40 VOID tx_application_define(void *first_unused_memory)
41 {
42 
43     /* Create the main demo thread.  */
44     tx_thread_create(&demo_thread, "GUIX Demo Thread", demo_thread_entry,
45                      0,  demo_thread_stack, sizeof(demo_thread_stack),
46                      1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
47 }
48 
49 
demo_thread_entry(ULONG thread_input)50 VOID  demo_thread_entry(ULONG thread_input)
51 {
52     /* Initialize GUIX.  */
53     gx_system_initialize();
54 
55 
56     gx_studio_display_configure(DISPLAY_1, win32_graphics_driver_setup_4444argb,
57                                 LANGUAGE_ENGLISH, DISPLAY_1_DEFAULT_THEME, &root);
58 
59     /* create the main screen */
60     gx_studio_named_widget_create("main_window", (GX_WIDGET *) root, (GX_WIDGET **) &pMainWin);
61     pic_window = &pMainWin ->main_window_pic_window;
62 
63     /* Show the root window to make it and patients screen visible.  */
64     gx_widget_show(root);
65 
66     /* let GUIX run */
67     gx_system_start();
68 }
69 
update_prompt_value(GX_PROMPT * pp,INT value)70 VOID update_prompt_value(GX_PROMPT *pp, INT value)
71 {
72     static GX_CHAR str_buf[10];
73     GX_STRING str;
74 
75     if (pp)
76     {
77         gx_utility_ltoa(value, str_buf, 10);
78         str.gx_string_ptr = str_buf;
79         str.gx_string_length = strnlen(str_buf, sizeof(str_buf) - 1);
80         gx_prompt_text_set_ext(pp, &str);
81     }
82 }
83 
main_event_handler(GX_WINDOW * window,GX_EVENT * myevent)84 UINT main_event_handler(GX_WINDOW *window, GX_EVENT *myevent)
85 {
86     GX_PROMPT *prompt;
87 
88     switch (myevent->gx_event_type)
89     {
90     case GX_SIGNAL(ID_BRUSH_ALPHA_SLIDER, GX_EVENT_SLIDER_VALUE):
91         brush_alpha = (GX_UBYTE)myevent->gx_event_payload.gx_event_longdata;
92         prompt = &pMainWin -> main_window_prompt_12_1;
93         update_prompt_value(prompt, brush_alpha);
94         break;
95 
96     case GX_SIGNAL(ID_ALPHA, GX_EVENT_TOGGLE_ON):
97         alpha = 1;
98         break;
99 
100     case GX_SIGNAL(ID_ALPHA, GX_EVENT_TOGGLE_OFF):
101         alpha = 0;
102         break;
103 
104     case GX_SIGNAL(ID_COMPRESSED, GX_EVENT_TOGGLE_ON):
105         compress = 2;
106         break;
107 
108     case GX_SIGNAL(ID_COMPRESSED, GX_EVENT_TOGGLE_OFF):
109         compress = 0;
110         break;
111 
112     default:
113         return gx_window_event_process(window, myevent);
114     }
115 
116     style_index = alpha + compress;
117     gx_window_wallpaper_set(pic_window, maps[style_index], GX_FALSE);
118     return 0;
119 }
120 
pic_win_draw(GX_WINDOW * window)121 VOID pic_win_draw(GX_WINDOW *window)
122 {
123 GX_BRUSH *brush;
124 
125     gx_context_brush_get(&brush);
126     brush -> gx_brush_alpha = brush_alpha;
127 
128     gx_window_draw((GX_WINDOW*) window);
129 }
130