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_all_widgets_progress_bar_32bpp", /* Test name */
10 270, 220, 450, 280 /* Define the coordinates of the capture area.
11 In this test, we only need to capture the line
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 line 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 line 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 line example 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 typedef struct PROPERTY_STRUCT{
60 GX_RESOURCE_ID text_color_id;
61 GX_RESOURCE_ID pixelmap_id;
62 GX_RESOURCE_ID font_id;
63 UINT min_value;
64 UINT max_value;
65 }PROPERTY;
66
67 PROPERTY property[] = {
68 {GX_COLOR_ID_BTN_BORDER, GX_NULL, GX_FONT_ID_SYSTEM, 0, 100},
69 {GX_COLOR_ID_WINDOW_BORDER, GX_PIXELMAP_ID_TFIELD_FILL_SMALL, GX_FONT_ID_TEXT_INPUT, 24, 88}
70 };
71
72 ULONG border_style[] = {GX_STYLE_BORDER_NONE, GX_STYLE_BORDER_THIN, GX_STYLE_BORDER_THICK, GX_STYLE_BORDER_RAISED, GX_STYLE_BORDER_RECESSED};
73
74 char test_comment[255];
75
control_thread_entry(ULONG input)76 static VOID control_thread_entry(ULONG input)
77 {
78 UINT frame_id = 1;
79 UINT index, property_index = 0, style_index = 0, border_index = 0, val;
80 GX_PROGRESS_BAR *progress_bar;
81
82 /* Switch to indicator screen. */
83 ToggleScreen(pIndicatorScreen, pButtonScreen);
84
85 /* Get progress bar widget. */
86 progress_bar = &((INDICATOR_SCREEN_CONTROL_BLOCK *)pIndicatorScreen) -> indicator_screen_progress_bar_1;
87
88 for(index = 0; index < 2; index ++)
89 {
90 if(index > 0)
91 {
92 gx_widget_style_add(progress_bar, GX_STYLE_PROGRESS_VERTICAL);
93 }
94
95 for(property_index = 0; property_index < sizeof(property)/sizeof(PROPERTY); property_index ++)
96 {
97 /* Set progress bar range. */
98 gx_progress_bar_range_set(progress_bar, property[property_index].min_value, property[property_index].max_value);
99
100 /* Set text color. */
101 gx_progress_bar_text_color_set(progress_bar, property[property_index].text_color_id,
102 property[property_index].text_color_id, property[property_index].text_color_id);
103
104 /* Set font. */
105 gx_progress_bar_font_set(progress_bar, property[property_index].font_id);
106
107 /* Set pixelmap fill. */
108 gx_progress_bar_pixelmap_set(progress_bar, property[property_index].pixelmap_id);
109
110 for(val = property[property_index].min_value; val < property[property_index].max_value; val += 10)
111 {
112 /* Inform the validation system
113 (1) Frame ID, which identifies a specific test configuration;
114 (2) Start recording frame on the next toggle operation.
115 */
116 /* Set progress bar value. */
117 gx_progress_bar_value_set(progress_bar, val);
118
119 sprintf(test_comment, "Value: %d, ", val);
120
121 if(index > 0)
122 {
123 strcat(test_comment, "Vertical, ");
124 }
125 else
126 {
127 strcat(test_comment, "Horizontal, ");
128 }
129
130 switch(style_index)
131 {
132 case 0:
133 if(progress_bar->gx_widget_style & GX_STYLE_PROGRESS_SEGMENTED_FILL)
134 {
135 gx_widget_style_remove(progress_bar, GX_STYLE_PROGRESS_SEGMENTED_FILL);
136 strcat(test_comment, "solid fill");
137 }
138 else
139 {
140 gx_widget_style_add(progress_bar, GX_STYLE_PROGRESS_SEGMENTED_FILL);
141 strcat(test_comment, "segment fill");
142 }
143 style_index ++;
144 break;
145 case 1:
146 /* Set text style*/
147 if(progress_bar->gx_widget_style & GX_STYLE_PROGRESS_TEXT_DRAW)
148 {
149 gx_widget_style_remove(progress_bar, GX_STYLE_PROGRESS_TEXT_DRAW);
150 strcat(test_comment, "no text");
151 }
152 else
153 {
154 gx_widget_style_add(progress_bar, GX_STYLE_PROGRESS_TEXT_DRAW);
155 strcat(test_comment, "draw text, ");
156
157 if(progress_bar -> gx_widget_style & GX_STYLE_PROGRESS_PERCENT)
158 {
159 gx_widget_style_remove(progress_bar, GX_STYLE_PROGRESS_PERCENT);
160 strcat(test_comment, "no percent sign");
161 }
162 else
163 {
164 gx_widget_style_add(progress_bar, GX_STYLE_PROGRESS_PERCENT);
165 strcat(test_comment, "with percent sign");
166 }
167 }
168 style_index ++;
169 break;
170 case 2:
171 /* Set border style. */
172 if(border_index >= sizeof(border_style)/sizeof(ULONG))
173 {
174 border_index = 0;
175 }
176 gx_widget_border_style_set(progress_bar, border_style[border_index]);
177 sprintf(test_comment, "%s border_style_id %ld", test_comment, border_style[border_index++]);
178 style_index = 0;
179 break;
180 }
181
182 gx_validation_set_frame_id(frame_id);
183
184 gx_validation_set_frame_comment(test_comment);
185
186 /* Mark the window "dirty" */
187 gx_system_dirty_mark(progress_bar);
188
189 /* Force a screen refresh. */
190 gx_validation_screen_refresh();
191
192 /* Increment frame ID */
193 frame_id ++;
194 }
195 }
196 }
197
198 /* Signal the end of the test case. Verify the output. */
199 gx_validation_end();
200
201 exit(0);
202 }
203
204
205
206
207
208