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_widget_text_blend", /* Test name */
10     73, 7, 576, 100  /* 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 char test_comment[255];
60 
61 static UINT color_ids[] = {GX_COLOR_ID_BLUE, GX_COLOR_ID_WHITE, GX_COLOR_ID_BLACK};
62 static UINT font_ids[] = {GX_FONT_ID_SYSTEM, GX_FONT_ID_NORMAL_FONT, GX_FONT_ID_SELECTED_FONT};
63 static GX_UBYTE alpha_values[] = {0, 100, 180, 255};
64 static ULONG aligned[] = {GX_STYLE_TEXT_RIGHT, GX_STYLE_TEXT_LEFT, GX_STYLE_TEXT_CENTER};
65 static int       offset;
66 static UINT      font_index, alpha_index, aligned_index;
67 
68 static GX_CONST GX_CHAR test_string[] = "widget text blend test.";
widget_text_draw_function(GX_PROMPT * prompt)69 static void widget_text_draw_function(GX_PROMPT *prompt)
70 {
71 ULONG old_style;
72 GX_STRING string;
73 
74     old_style = prompt->gx_widget_style;
75     old_style &= ~GX_STYLE_TEXT_CENTER;
76     prompt->gx_widget_style |= aligned[aligned_index];
77     gx_prompt_draw(prompt);
78 
79     if(aligned_index == 0)
80     {
81         gx_widget_text_blend((GX_WIDGET *)prompt, color_ids[font_index], font_ids[font_index], test_string, offset, offset, alpha_values[alpha_index]);
82     }
83     else
84     {
85         string.gx_string_ptr = test_string;
86         string.gx_string_length = sizeof(test_string) - 1;
87         gx_widget_text_blend_ext((GX_WIDGET *)prompt, color_ids[font_index], font_ids[font_index], &string, offset, offset, alpha_values[alpha_index]);
88     }
89 
90     prompt->gx_widget_style = old_style;
91 }
92 
control_thread_entry(ULONG input)93 static VOID control_thread_entry(ULONG input)
94 {
95 int       frame_id = 1;
96 
97     gx_widget_draw_set((GX_WIDGET *)&button_screen.button_screen_title_1, widget_text_draw_function);
98 
99     for(aligned_index = 0; aligned_index < sizeof(aligned)/sizeof(ULONG); aligned_index++)
100     {
101         for(font_index = 0; font_index < sizeof(font_ids)/sizeof(UINT); font_index++)
102         {
103             for(alpha_index = 0; alpha_index < sizeof(alpha_values)/sizeof(GX_UBYTE); alpha_index++)
104             {
105                 for(offset = -20; offset <= 30; offset += 10)
106                 {
107                     sprintf(test_comment, "xoffset: %d, yoffset: %d, alpha: %d, ", offset, offset, alpha_values[alpha_index]);
108 
109                     switch(font_index)
110                     {
111                         case 0:
112                             strcat(test_comment, "font: GX_FONT_ID_SYSTEM, color:  GX_COLOR_ID_BLUE, ");
113                             break;
114 
115                         case 1:
116                             strcat(test_comment, "font: GX_FONT_ID_NORMAL_FONT, color:  GX_COLOR_ID_WHITE, ");
117                             break;
118 
119                         case 2:
120                             strcat(test_comment, "font: GX_FONT_ID_SELECTED_FONT, color:  GX_COLOR_ID_BLACK, ");
121                             break;
122                     }
123 
124                     switch(aligned_index)
125                     {
126                         case 0:
127                             strcat(test_comment, "aligned: right");
128                             break;
129 
130                         case 1:
131                             strcat(test_comment, "aligned: left");
132                             break;
133 
134                         case 2:
135                             strcat(test_comment, "aligned: center");
136                             break;
137                     }
138 
139 
140                     gx_validation_set_frame_id(frame_id++);
141                     gx_validation_set_frame_comment(test_comment);
142                     gx_validation_screen_refresh();
143                 }
144             }
145         }
146     }
147 
148     /* Signal the end of the test case.  Verify the output. */
149     gx_validation_end();
150 
151     exit(0);
152 }
153