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 #include "gx_system.h"
8
9 TEST_PARAM test_parameter = {
10 "guix_sl_input_draw", /* Test name */
11 114, 69, 538, 119 /* Define the coordinates of the capture area.
12 In this test, we only need to capture the pixelmap
13 drawing area. */
14 };
15
16 static VOID control_thread_entry(ULONG);
main(int argc,char ** argv)17 int main(int argc, char ** argv)
18 {
19 /* Parse the command line argument. */
20 gx_validation_setup(argc, argv);
21
22 /* Start ThreadX system */
23 tx_kernel_enter();
24 return(0);
25 }
26
tx_application_define(void * first_unused_memory)27 VOID tx_application_define(void *first_unused_memory)
28 {
29
30 /* Create a dedicated thread to perform various operations
31 on the line drawing example. These operations simulate
32 user input. */
33 gx_validation_control_thread_create(control_thread_entry);
34
35 /* Termiante the test if it runs for more than 100 ticks */
36 /* This function is not implemented yet. */
37 gx_validation_watchdog_create(100);
38
39 /* Call the actual line example routine. */
40 gx_validation_application_define(first_unused_memory);
41
42 }
43
44
45 /* Replace the default graphics driver with the validation driver. */
46 #ifdef win32_graphics_driver_setup_565rgb
47 #undef win32_graphics_driver_setup_565rgb
48 #endif
49 #define win32_graphics_driver_setup_565rgb gx_validation_graphics_driver_setup_565rgb
50
51
52 #ifdef WIN32
53 #undef WIN32
54 #endif
55
56 #include "gx_validation_wrapper.h"
57 #include "demo_guix_sl_text_input_16bpp.c"
58
59 static GX_CONST GX_UBYTE SINGLE_LINE_TEXT[] = "12345";
60 static char test_comment[255];
61 /* This thread simulates user input. Its priority is lower
62 than the GUIX thread, so that GUIX finishes an operation
63 before this thread is able to issue the next command. */
64 char test_string[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789012345";
control_thread_entry(ULONG input)65 static VOID control_thread_entry(ULONG input)
66 {
67 GX_SINGLE_LINE_TEXT_INPUT *text_input_ptr;
68 int frame_id = 1;
69 GX_BOOL stop = GX_FALSE;
70 int index = 0;
71
72 text_input_ptr = &pMainScreen->window_sl_text_input;
73
74 /* Remove cursor blink style. */
75 gx_single_line_text_input_style_remove(text_input_ptr, GX_STYLE_CURSOR_BLINK);
76 gx_single_line_text_input_style_remove(text_input_ptr, GX_STYLE_TEXT_ALIGNMENT_MASK);
77
78 gx_system_focus_claim((GX_WIDGET *)text_input_ptr);
79
80 /* Set input test. */
81 gx_single_line_text_input_text_set(text_input_ptr, (GX_CONST GX_CHAR *)SINGLE_LINE_TEXT);
82
83 while(stop == GX_FALSE)
84 {
85 switch(index)
86 {
87 case 0:
88 gx_text_input_cursor_height_set(&text_input_ptr->gx_single_line_text_input_cursor_instance, 20);
89 sprintf(test_comment, "set cursor height 20");
90 break;
91
92 case 1:
93 gx_single_line_text_input_text_select(text_input_ptr, 0, 1);
94 sprintf(test_comment, "select text[0, 1]");
95 break;
96
97 case 2:
98 gx_single_line_text_input_text_set(text_input_ptr, test_string);
99 GX_ENTER_CRITICAL
100 gx_single_line_text_input_style_remove(text_input_ptr, GX_STYLE_TEXT_ALIGNMENT_MASK);
101 gx_single_line_text_input_style_add(text_input_ptr, GX_STYLE_TEXT_RIGHT);
102 GX_EXIT_CRITICAL
103 sprintf(test_comment, "set test string, set right alignment");
104 break;
105
106 case 3:
107 GX_ENTER_CRITICAL
108 gx_single_line_text_input_style_remove(text_input_ptr, GX_STYLE_TEXT_ALIGNMENT_MASK);
109 gx_single_line_text_input_style_add(text_input_ptr, GX_STYLE_TEXT_CENTER);
110 GX_EXIT_CRITICAL
111 sprintf(test_comment, "set center alignment");
112 break;
113
114 case 4:
115 text_input_ptr->gx_single_line_text_input_buffer = GX_NULL;
116 sprintf(test_comment, "set buffer null");
117 stop = GX_TRUE;
118 break;
119 }
120 gx_validation_set_frame_id(frame_id++);
121 gx_validation_set_frame_comment(test_comment);
122 gx_validation_screen_refresh();
123
124 index++;
125 }
126
127 /* Signal the end of the test case. Verify the output. */
128 gx_validation_end();
129
130 exit(0);
131 }
132