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 "pixelmap_32bpp_resources.h"
7 #include "pixelmap_32bpp_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            alpha = GX_FALSE;
19 GX_BOOL            compressed = GX_FALSE;
20 INT                xshift;
21 INT                yshift;
22 INT                horizontal_slider = 0;
23 INT                vertical_slider = 0;
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     GX_SLIDER *slider = &pMainWin ->main_window_slider_1;
71     GX_SLIDER *slider2 = &pMainWin ->main_window_slider_2;
72 
73     switch(myevent -> gx_event_type)
74     {
75     case GX_SIGNAL(ID_ALPHA, GX_EVENT_TOGGLE_ON):
76         alpha = GX_TRUE;
77         gx_system_dirty_mark(pic_window);
78         break;
79 
80     case GX_SIGNAL(ID_ALPHA, GX_EVENT_TOGGLE_OFF):
81         alpha = GX_FALSE;
82         gx_system_dirty_mark(pic_window);
83         break;
84 
85     case GX_SIGNAL(ID_COMPRESSED, GX_EVENT_TOGGLE_ON):
86         compressed = GX_TRUE;
87         gx_system_dirty_mark(pic_window);
88         break;
89 
90     case GX_SIGNAL(ID_COMPRESSED, GX_EVENT_TOGGLE_OFF):
91         compressed = GX_FALSE;
92         gx_system_dirty_mark(pic_window);
93         break;
94 
95     case GX_SIGNAL(ID_HORIZONTALMOVE, GX_EVENT_SLIDER_VALUE):
96         xshift = myevent ->gx_event_payload.gx_event_longdata;
97 
98         if(horizontal_slider == 0)
99         {
100             horizontal_slider = (slider ->gx_slider_info.gx_slider_info_max_val + slider ->gx_slider_info.gx_slider_info_min_val) >> 1;
101         }
102             gx_widget_shift(pic_window, xshift - horizontal_slider, 0, GX_TRUE);
103             horizontal_slider = xshift;
104         break;
105 
106     case GX_SIGNAL(ID_VERTICALMOVE, GX_EVENT_SLIDER_VALUE):
107         yshift = myevent ->gx_event_payload.gx_event_longdata;
108 
109         if(vertical_slider == 0)
110         {
111             vertical_slider = (slider2 ->gx_slider_info.gx_slider_info_max_val + slider2 ->gx_slider_info.gx_slider_info_min_val) >> 1;
112         }
113             gx_widget_shift(pic_window, 0, vertical_slider - yshift, GX_TRUE);
114             vertical_slider = yshift;
115         break;
116 
117     default:
118         status = gx_window_event_process(window, myevent);
119         break;
120     }
121     return status;
122 }
123 
124 
125 
pic_win_draw(GX_WINDOW * window)126 VOID pic_win_draw(GX_WINDOW *window)
127 {
128     if(alpha)
129     {
130         if(compressed)
131         {
132             gx_window_wallpaper_set(window, GX_PIXELMAP_ID_RAINBOW200_ALPHA_COMPRESS, GX_FALSE);
133         }
134         else
135         {
136             gx_window_wallpaper_set(window, GX_PIXELMAP_ID_RAINBOW200_ALPHA_NONCOMPRESS, GX_FALSE);
137         }
138     }
139     else
140     {
141         if(compressed)
142         {
143             gx_window_wallpaper_set(window, GX_PIXELMAP_ID_RAINBOW200_NOALPHA_COMPRESS, GX_FALSE);
144         }
145         else
146         {
147             gx_window_wallpaper_set(window, GX_PIXELMAP_ID_RAINBOW200_NOALPHA_NONCOMPRESS, GX_FALSE);
148         }
149     }
150 
151     gx_window_draw((GX_WINDOW*) window);
152 }
153