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 "guix_drop_list_resources.h"
6 #include "guix_drop_list_specifications.h"
7 
8 #define DROP_LIST_VISIBLE_ROWS  4
9 #define DROP_LIST_MAX_TEXT 80
10 
11 extern UINT win32_graphics_driver_setup_24xrgb(GX_DISPLAY *display);
12 
13 GX_WINDOW_ROOT    *root;
14 GX_SCROLLBAR       list_scroll;
15 
16 /* A structure to hold control block and text for each drop-list item */
17 typedef struct {
18     DROP_LIST_CHILD_WIN_CONTROL_BLOCK child_win;
19     GX_CHAR   text[DROP_LIST_MAX_TEXT + 1];
20 } DROP_LIST_CHILD;
21 
22 DROP_LIST_CHILD drop_list_widgets[DROP_LIST_VISIBLE_ROWS + 1];
23 
24 /* Define prototypes.   */
25 VOID populate_drop_list();
26 VOID start_guix(void);
27 
28 /*****************************************************************************/
29 /* Application entry.                                                        */
30 /*****************************************************************************/
main(int argc,char ** argv)31 int main(int argc, char ** argv)
32 {
33   tx_kernel_enter();
34   return(0);
35 }
36 /*****************************************************************************/
37 /* Function called by ThreadX startup to define initial system               */
38 /*****************************************************************************/
tx_application_define(void * first_unused_memory)39 VOID tx_application_define(void *first_unused_memory)
40 {
41     start_guix();
42 }
43 
44 /*****************************************************************************/
45 /* Called by tx_application_define (above), configure and start GUIX         */
46 /*****************************************************************************/
start_guix(void)47 VOID start_guix(void)
48 {
49     /* Initialize GUIX.  */
50     gx_system_initialize();
51 
52     gx_studio_display_configure(PRIMARY, win32_graphics_driver_setup_24xrgb,
53                                 LANGUAGE_ENGLISH, PRIMARY_THEME_1, &root);
54 
55     /* create the button screen */
56     gx_studio_named_widget_create("main_screen", (GX_WIDGET*)root, GX_NULL);
57 
58     /* Add child widgets to the drop-down list */
59     populate_drop_list();
60 
61     /* Show the root window to make it and patients screen visible.  */
62     gx_widget_show(root);
63 
64     /* start the GUIX thread */
65     gx_system_start();
66 }
67 
68 /*****************************************************************************/
69 /* Create child element for the drop list. This function is called during    */
70 /* initial setup to populate children, and also called as the drop-list is   */
71 /* scrolled to update the child elements.                                    */
72 /*****************************************************************************/
73 extern GX_STUDIO_WIDGET drop_list_child_win_define;
74 
drop_list_row_create(GX_VERTICAL_LIST * list,GX_WIDGET * widget,INT index)75 VOID drop_list_row_create(GX_VERTICAL_LIST *list, GX_WIDGET *widget, INT index)
76 {
77     GX_BOOL created;
78     GX_CHAR temp[10];
79     GX_STRING string;
80 
81     DROP_LIST_CHILD *entry = (DROP_LIST_CHILD *) widget;
82 
83     strcpy(entry->text, "List Entry #");
84     gx_utility_ltoa(index + 1, temp, 10);
85     strcat(entry->text, (char*)temp);
86 
87     gx_widget_created_test(&entry->child_win, &created);
88 
89     if (!created)
90     {
91         gx_studio_widget_create((GX_BYTE *) &entry->child_win, &drop_list_child_win_define, (GX_WIDGET *) list);
92     }
93 
94     string.gx_string_ptr = entry->text;
95     string.gx_string_length = strnlen(entry->text, DROP_LIST_MAX_TEXT);
96     gx_prompt_text_set_ext(&entry->child_win.drop_list_child_win_drop_list_child_prompt, &string);
97 }
98 
99 /*****************************************************************************/
100 /* Create initial set of child elements for drop list                        */
101 /*****************************************************************************/
populate_drop_list(void)102 VOID populate_drop_list(void)
103 {
104     int index;
105     GX_VERTICAL_LIST *list;
106     GX_SCROLLBAR_APPEARANCE sa;
107     GX_DROP_LIST *drop = &main_screen.main_screen_droplist;
108     gx_drop_list_popup_get(drop, &list);
109 
110     for (index = 0; index <= DROP_LIST_VISIBLE_ROWS; index++)
111     {
112         drop_list_row_create(list, (GX_WIDGET *)&drop_list_widgets[index], index);
113     }
114 
115     sa.gx_scroll_thumb_pixelmap = GX_PIXELMAP_ID_LIST_SCROLL_THUMB;
116     sa.gx_scroll_thumb_travel_min = 4;
117     sa.gx_scroll_thumb_travel_max = 4;
118     sa.gx_scroll_thumb_width = 8;
119     sa.gx_scroll_width = 10;
120 
121     gx_vertical_scrollbar_create(&list_scroll, "list_scroll", list, &sa, GX_SCROLLBAR_VERTICAL|GX_STYLE_ENABLED);
122 }