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 "menu_resources.h"
6 #include "menu_specifications.h"
7 
8 #define SCREEN_STACK_SIZE  20
9 /* Define the ThreadX demo thread control block and stack.  */
10 
11 TX_THREAD          demo_thread;
12 UCHAR              demo_thread_stack[4096];
13 
14 GX_WINDOW_ROOT            *root;
15 GX_SCREEN_STACK_CONTROL   screen_stack_ctrl;
16 GX_WIDGET                *screen_stack[SCREEN_STACK_SIZE];
17 GX_BOOL                   show_toolbar = GX_FALSE;
18 
19 extern BOOKSHELF_SCREEN_CONTROL_BLOCK bookshelf_screen;
20 extern BOOK_SCREEN_CONTROL_BLOCK      book_screen;
21 extern TOOLBAR_SCREEN_CONTROL_BLOCK   toolbar_screen;
22 extern MAIN_SCREEN_CONTROL_BLOCK      main_screen;
23 /* Define prototypes.   */
24 VOID  start_guix(VOID);
25 extern UINT win32_graphics_driver_setup_24xrgb(GX_DISPLAY *display);
26 
27 GX_CHAR text[] = {
28     "\r\n2002 - 2015 by Express Logic, Inc.\r\n\r\n\
29     All rights reserved.\
30     Inc.Each contains proprietary information of Express Logic, Inc.\
31     Any portion of this document without the prior ...\r\n\r\n\
32     Express Logic, Inc.reserves the right to ... \
33     without notice in order to improve design or reliability of GUIX.\
34     carefully checked for accuracy; however, Express Logic, Inc."
35 };
36 
main(int argc,char ** argv)37 int main(int argc, char ** argv)
38 {
39   tx_kernel_enter();
40   return(0);
41 }
42 
43 
tx_application_define(void * first_unused_memory)44 VOID tx_application_define(void *first_unused_memory)
45 {
46     /* Create the main demo thread.  */
47     start_guix();
48 }
49 
50 
start_guix(VOID)51 VOID  start_guix(VOID)
52 {
53     GX_STRING str;
54 
55     /* Initialize GUIX.  */
56     gx_system_initialize();
57 
58     gx_studio_display_configure(MAIN_DISPLAY, win32_graphics_driver_setup_24xrgb,
59                                 LANGUAGE_ENGLISH, MAIN_DISPLAY_THEME_1, &root);
60 
61     /* create the top menu screen */
62     gx_studio_named_widget_create("main_screen", (GX_WIDGET *) root, (GX_WIDGET **)&main_screen);
63 
64     gx_studio_named_widget_create("bookshelf_screen", GX_NULL, (GX_WIDGET **)&bookshelf_screen);
65 
66     gx_studio_named_widget_create("book_screen", GX_NULL, (GX_WIDGET **)&book_screen);
67 
68     gx_studio_named_widget_create("toolbar_screen", GX_NULL, (GX_WIDGET **)&toolbar_screen);
69 
70     str.gx_string_ptr = text;
71     str.gx_string_length = strnlen(text, sizeof(text));
72     gx_multi_line_text_view_text_set_ext(&book_screen.book_screen_text_view_1, &str);
73 
74     gx_screen_stack_create(&screen_stack_ctrl, screen_stack, SCREEN_STACK_SIZE * sizeof(GX_WIDGET *));
75 
76     /* Show the root window to make it and child screen visible.  */
77     gx_widget_show(root);
78 
79     /* let GUIX run */
80     gx_system_start();
81 }
82 
toolbar_detach_attach()83 void toolbar_detach_attach()
84 {
85     if (show_toolbar)
86     {
87         gx_widget_detach(&toolbar_screen);
88         show_toolbar = GX_FALSE;
89     }
90     else
91     {
92         gx_widget_attach(&book_screen, &toolbar_screen);
93         show_toolbar = GX_TRUE;
94     }
95 }
96 
sub_menu_event(GX_WINDOW * window,GX_EVENT * my_event)97 UINT sub_menu_event(GX_WINDOW *window, GX_EVENT *my_event)
98 {
99     switch (my_event->gx_event_type)
100     {
101     case GX_SIGNAL(ID_BTN_BOOKSHELF, GX_EVENT_CLICKED):
102         gx_screen_stack_push(&screen_stack_ctrl, (GX_WIDGET *)window, (GX_WIDGET *)&bookshelf_screen);
103         break;
104 
105     case GX_SIGNAL(ID_PROMPT_BOOK, GX_EVENT_CLICKED):
106         gx_screen_stack_push(&screen_stack_ctrl, (GX_WIDGET *)window, (GX_WIDGET *)&book_screen);
107         break;
108 
109     case GX_SIGNAL(ID_BACK, GX_EVENT_CLICKED):
110         gx_screen_stack_pop(&screen_stack_ctrl);
111 
112         if (show_toolbar)
113         {
114             toolbar_detach_attach();
115         }
116         break;
117     case GX_SIGNAL(ID_HOME_BUTTON,GX_EVENT_CLICKED):
118         gx_widget_detach(window);
119         gx_widget_attach(root, (GX_WIDGET *)&main_screen);
120         gx_screen_stack_reset(&screen_stack_ctrl);
121 
122         if (show_toolbar)
123         {
124             toolbar_detach_attach();
125         }
126         break;
127 
128     case GX_EVENT_PEN_DOWN:
129         if (window->gx_widget_id == ID_BOOK_SCREEN)
130         {
131             toolbar_detach_attach();
132         }
133         break;
134 
135     default:
136         gx_window_event_process(window, my_event);
137         break;
138     }
139     return GX_SUCCESS;
140 }
141