1 /* This is a small demo of the high-performance GUIX graphics framework. */
2 
3 #include <stdio.h>
4 #include "tx_api.h"
5 #include "gx_api.h"
6 #include "gx_validation_utility.h"
7 
8 TEST_PARAM test_parameter = {
9     "guix_prompt_24xrgb", /* Test name */
10     51, 26, 369, 192  /* Define the coordinates of the capture area.
11                       In this test, we only need to capture the prompt
12                       drawing area.  */
13 };
14 
15 static VOID      control_thread_entry(ULONG);
main(int argc,char ** argv)16 int main(int argc, char ** argv)
17 {
18     /* Parse the command prompt argument. */
19     gx_validation_setup(argc, argv);
20 
21     /* Start ThreadX system */
22     tx_kernel_enter();
23     return(0);
24 }
25 
tx_application_define(void * first_unused_memory)26 VOID tx_application_define(void *first_unused_memory)
27 {
28 
29     /* Create a dedicated thread to perform various operations
30     on the prompt drawing example. These operations simulate
31     user input. */
32     gx_validation_control_thread_create(control_thread_entry);
33 
34     /* Termiante the test if it runs for more than 100 ticks */
35     /* This function is not implemented yet. */
36     gx_validation_watchdog_create(100);
37 
38     /* Call the actual prompt routine. */
39     gx_validation_application_define(first_unused_memory);
40 
41 }
42 
43 
44 /* Replace the default graphics driver with the validation driver. */
45 #ifdef win32_graphics_driver_setup_24xrgb
46 #undef win32_graphics_driver_setup_24xrgb
47 #endif
48 #define win32_graphics_driver_setup_24xrgb  gx_validation_graphics_driver_setup_24xrgb
49 
50 
51 #ifdef WIN32
52 #undef WIN32
53 #endif
54 
55 #include "gx_validation_wrapper.h"
56 
57 #include "demo_guix_all_widgets.c"
58 
59 static int prompt_value[] = {ID_PROMPT_1, ID_PROMPT_3, ID_PROMPT_2, ID_PROMPT_4};
60 
61 static char* text_value[] = {"text_1", "text_2"};
62 
63 static int text_color[] = {GX_COLOR_ID_TEXT, GX_COLOR_ID_BLUE};
64 
65 char test_comment[256];
66 
67 
control_thread_entry(ULONG input)68 static VOID control_thread_entry(ULONG input)
69 {
70 int prompt_index;
71 int text_index;
72 int text_color_index;
73 int frame_id = 1;
74 GX_PROMPT *prompt;
75 
76     ToggleScreen(pTextScreen, pButtonScreen);
77 
78     for(prompt_index = 0; prompt_index < (INT)(sizeof(prompt_value) / sizeof(int)); prompt_index++)
79     {
80         gx_widget_find(pTextScreen, prompt_value[prompt_index], 0, &prompt);
81 
82         if(prompt_value[prompt_index] == ID_PROMPT_1)
83         {
84             gx_widget_style_add((GX_WIDGET *)prompt, GX_STYLE_TEXT_COPY);
85             gx_prompt_text_set(prompt, text_value[0]);
86         }
87 
88         gx_prompt_font_set(prompt, GX_FONT_ID_PROMPT);
89         gx_prompt_text_id_set(prompt, GX_STRING_ID_STRING_5);
90 
91         for(text_color_index = 0; text_color_index < (INT)(sizeof(text_color) / sizeof(int)); text_color_index++)
92         {
93             gx_prompt_text_color_set(prompt, text_color[text_color_index], text_color[text_color_index], text_color[text_color_index]);
94             for(text_index = 0; text_index < 2; text_index++)
95             {
96                 gx_prompt_text_set(prompt, text_value[text_index]);
97 
98                 sprintf(test_comment, "%s ", text_value[text_index]);
99 
100                 if(prompt_value[prompt_index] == ID_PROMPT_1)
101                 {
102                     strcat(test_comment, "PROMPT_1 ");
103                 }
104                 else if(prompt_value[prompt_index] == ID_PROMPT_2)
105                 {
106                     strcat(test_comment, "PROMPT_2 ");
107                 }
108                 else if(prompt_value[prompt_index] == ID_PROMPT_3)
109                 {
110                     strcat(test_comment, "PROMPT_3 ");
111                 }
112                 else if(prompt_value[prompt_index] == ID_PROMPT_4)
113                 {
114                     strcat(test_comment, "PROMPT_4 ");
115                     if(text_index)
116                     {
117                         gx_widget_style_add((GX_WIDGET *)prompt, GX_STYLE_DRAW_SELECTED);
118                         strcat(test_comment, "Added GX_STYLE_DRAW_SELECTED style ");
119                         gx_pixelmap_prompt_pixelmap_set((GX_PIXELMAP_PROMPT *)prompt, GX_PIXELMAP_ID_TFIELD_LEFT_SMALL,
120                             GX_PIXELMAP_ID_TFIELD_FILL_SMALL, GX_PIXELMAP_ID_TFIELD_RIGHT_SMALL,
121                             GX_PIXELMAP_ID_I_ORANGEFILL_LEFT, GX_PIXELMAP_ID_FILL, GX_PIXELMAP_ID_I_EMPTYFILL_RIGHT);
122                     }
123                     else
124                     {
125                         gx_widget_style_remove((GX_WIDGET *)prompt, GX_STYLE_DRAW_SELECTED);
126                         strcat(test_comment, "Removed GX_STYLE_DRAW_SELECTED style ");
127                     }
128                 }
129                 if(text_color[text_color_index] == GX_COLOR_ID_TEXT)
130                     strcat(test_comment, "GX_COLOR_ID_TEXT ");
131                 else
132                     strcat(test_comment, "GX_COLOR_ID_BLUE ");
133 
134                 gx_validation_set_frame_id(frame_id);
135                 gx_validation_set_frame_comment(test_comment);
136 
137                 /* Force a screen refresh. */
138                 gx_validation_screen_refresh();
139 
140                 /* Increment frame ID */
141                 frame_id ++;
142             }
143         }
144     }
145 
146     /* Signal the end of the test case.  Verify the output. */
147     gx_validation_end();
148 
149     exit(0);
150 }
151 
152 
153 
154 
155 
156