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 "system_screen_stack_resources.h"
6 #include "system_screen_stack_specifications.h"
7
8 /* Define the ThreadX demo thread control block and stack. */
9
10 #define SYSTEM_SCREEN_STACK_SIZE 20
11 #define MEMORY_SIZE (MAIN_DISPLAY_X_RESOLUTION * MAIN_DISPLAY_Y_RESOLUTION)
12
13 TX_THREAD demo_thread;
14 UCHAR demo_thread_stack[4096];
15
16 GX_WINDOW_ROOT *root;
17 TX_BYTE_POOL memory_pool;
18 GX_COLOR memory_buffer[MEMORY_SIZE];
19 GX_WIDGET *system_screen_stack_memory[SYSTEM_SCREEN_STACK_SIZE];
20
21 /* Define prototypes. */
22 VOID start_guix(VOID);
23 extern UINT win32_graphics_driver_setup_24xrgb(GX_DISPLAY *display);
24
main(int argc,char ** argv)25 int main(int argc, char ** argv)
26 {
27 tx_kernel_enter();
28 return(0);
29 }
30
31
tx_application_define(void * first_unused_memory)32 VOID tx_application_define(void *first_unused_memory)
33 {
34 /* create byte pool for rotate to use */
35 tx_byte_pool_create(&memory_pool, "memory_pool", memory_buffer, MEMORY_SIZE * sizeof(GX_COLOR));
36
37 /* Create the main demo thread. */
38 start_guix();
39 }
40
memory_allocate(ULONG size)41 VOID *memory_allocate(ULONG size)
42 {
43 VOID *memptr;
44
45 if (tx_byte_allocate(&memory_pool, &memptr, size, TX_NO_WAIT) == TX_SUCCESS)
46 {
47 return memptr;
48 }
49
50 return NULL;
51 }
52
memory_free(VOID * mem)53 VOID memory_free(VOID *mem)
54 {
55 tx_byte_release(mem);
56 }
57
start_guix(VOID)58 VOID start_guix(VOID)
59 {
60 /* Initialize GUIX. */
61 gx_system_initialize();
62
63 /* install our memory allocator and de-allocator */
64 gx_system_memory_allocator_set(memory_allocate, memory_free);
65
66 gx_studio_display_configure(MAIN_DISPLAY, win32_graphics_driver_setup_24xrgb,
67 LANGUAGE_ENGLISH, MAIN_DISPLAY_THEME_1, &root);
68
69 /* create the top menu screen */
70 gx_studio_named_widget_create("main_screen", (GX_WIDGET *) root, GX_NULL);
71
72 gx_studio_named_widget_create("bookshelf_screen", GX_NULL, GX_NULL);
73
74 gx_studio_named_widget_create("book_screen", GX_NULL, GX_NULL);
75
76 gx_studio_named_widget_create("language_screen", GX_NULL, GX_NULL);
77
78 /* Create system screen stack. */
79 gx_system_screen_stack_create(system_screen_stack_memory, sizeof(GX_WIDGET *)* SYSTEM_SCREEN_STACK_SIZE);
80
81 /* Show the root window to make it and child screen visible. */
82 gx_widget_show(root);
83
84 /* let GUIX run */
85 gx_system_start();
86 }