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_rich_text_view", /* Test name */
10 99, 94, 295, 357 /* 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_565rgb
46 #undef win32_graphics_driver_setup_565rgb
47 #endif
48 #define win32_graphics_driver_setup_565rgb gx_validation_graphics_driver_setup_565rgb
49
50
51 #ifdef WIN32
52 #undef WIN32
53 #endif
54
55 #include "gx_validation_wrapper.h"
56
57 #include "demo_guix_rich_text_view_16bpp.c"
58
59 typedef struct TEXT_INFO_STRUCT{
60 GX_RESOURCE_ID text_id;
61 char id_name[30];
62 }TEXT_INFO;
63
64 TEXT_INFO text_info_list[]={
65 {GX_STRING_ID_RICH_TEXT_1, "GX_STRING_ID_RICH_TEXT_1"},
66 {GX_STRING_ID_RICH_TEXT_2, "GX_STRING_ID_RICH_TEXT_2"},
67 {GX_STRING_ID_RICH_TEXT_3, "GX_STRING_ID_RICH_TEXT_3"},
68 {GX_STRING_ID_RICH_TEXT_4, "GX_STRING_ID_RICH_TEXT_4"},
69 {GX_STRING_ID_RICH_TEXT_5, "GX_STRING_ID_RICH_TEXT_5"},
70 {GX_STRING_ID_RICH_TEXT_LEFT_ALIGN, "GX_STRING_ID_RICH_TEXT_LEFT_ALIGN"},
71 {GX_STRING_ID_RICH_TEXT_CENTER_ALIGN, "GX_STRING_ID_RICH_TEXT_CENTER_ALIGN"},
72 {GX_STRING_ID_RICH_TEXT_RIGHT_ALIGN, "GX_STRING_ID_RICH_TEXT_RIGHT_ALIGN"},
73 {GX_STRING_ID_RICH_TEXT_BOLD_ITALIC, "GX_STRING_ID_RICH_TEXT_BOLD_ITALIC"},
74 {GX_STRING_ID_RICH_TEXT_ITALIC_BOLD, "GX_STRING_ID_RICH_TEXT_ITALIC_BOLD"},
75 {GX_STRING_ID_RICH_TEXT_TAG_TEST_1, "GX_STRING_ID_RICH_TEXT_TAG_TEST_1"},
76 {GX_STRING_ID_RICH_TEXT_TAG_TEST_2, "GX_STRING_ID_RICH_TEXT_TAG_TEST_2"},
77 {GX_STRING_ID_RICH_TEXT_TAG_TEST_3, "GX_STRING_ID_RICH_TEXT_TAG_TEST_3"},
78 {GX_STRING_ID_RICH_TEXT_TAG_TEST_4, "GX_STRING_ID_RICH_TEXT_TAG_TEST_4"},
79 {GX_STRING_ID_RICH_TEXT_TAG_TEST_5, "GX_STRING_ID_RICH_TEXT_TAG_TEST_5"},
80 {GX_STRING_ID_RICH_TEXT_TAG_TEST_6, "GX_STRING_ID_RICH_TEXT_TAG_TEST_6"},
81 {GX_STRING_ID_RICH_TEXT_TAG_TEST_7, "GX_STRING_ID_RICH_TEXT_TAG_TEST_7"},
82 {GX_STRING_ID_RICH_TEXT_TAG_TEST_8, "GX_STRING_ID_RICH_TEXT_TAG_TEST_8"},
83 {GX_STRING_ID_RICH_TEXT_TAG_TEST_9, "GX_STRING_ID_RICH_TEXT_TAG_TEST_9"},
84 {GX_STRING_ID_RICH_TEXT_TAG_TEST_10, "GX_STRING_ID_RICH_TEXT_TAG_TEST_10"},
85 {GX_STRING_ID_RICH_TEXT_TAG_TEST_11, "GX_STRING_ID_RICH_TEXT_TAG_TEST_11"},
86 {GX_STRING_ID_RICH_TEXT_TAG_TEST_12, "GX_STRING_ID_RICH_TEXT_TAG_TEST_12"},
87 {GX_STRING_ID_RICH_TEXT_TAG_TEST_13, "GX_STRING_ID_RICH_TEXT_TAG_TEST_13"},
88 {GX_STRING_ID_RICH_TEXT_TAG_TEST_14, "GX_STRING_ID_RICH_TEXT_TAG_TEST_14"},
89 {GX_STRING_ID_RICH_TEXT_TAG_TEST_15, "GX_STRING_ID_RICH_TEXT_TAG_TEST_15"},
90 {GX_STRING_ID_RICH_TEXT_TAG_TEST_16, "GX_STRING_ID_RICH_TEXT_TAG_TEST_16"},
91 {GX_STRING_ID_RICH_TEXT_TAG_TEST_17, "GX_STRING_ID_RICH_TEXT_TAG_TEST_17"},
92 {GX_STRING_ID_RICH_TEXT_TAG_TEST_18, "GX_STRING_ID_RICH_TEXT_TAG_TEST_18"},
93 {GX_STRING_ID_RICH_TEXT_TAG_TEST_19, "GX_STRING_ID_RICH_TEXT_TAG_TEST_19"},
94 {GX_STRING_ID_RICH_TEXT_TAG_TEST_20, "GX_STRING_ID_RICH_TEXT_TAG_TEST_2-"},
95 {GX_STRING_ID_RICH_TEXT_LINE_BREAK_TEST_1, "GX_STRING_ID_RICH_TEXT_LINE_BREAK_TEST_1"},
96 {GX_STRING_ID_RICH_TEXT_LINE_BREAK_TEST_2, "GX_STRING_ID_RICH_TEXT_LINE_BREAK_TEST_2"},
97 {GX_STRING_ID_RICH_TEXT_UTF8_TEST, "GX_STRING_ID_RICH_TEXT_UTF8_TEST"},
98 {0, ""}
99 };
100
101 typedef struct align_info_struct{
102 GX_RESOURCE_ID style;
103 char *comment;
104 }align_info;
105
106 align_info align_info_list[]=
107 {
108 {GX_STYLE_TEXT_LEFT, "left alignment"},
109 {GX_STYLE_TEXT_CENTER, "center alignment"},
110 {GX_STYLE_TEXT_RIGHT, "right alignment"}
111 };
112
113 char comment[256];
114
control_thread_entry(ULONG input)115 static VOID control_thread_entry(ULONG input)
116 {
117 INT frame_id = 1;
118 UINT alignment;
119 GX_RICH_TEXT_VIEW *rich_view = &main_screen.main_screen_rich_text_view;
120 GX_STRING string;
121 GX_RICH_TEXT_FONTS fonts;
122 TEXT_INFO *info = text_info_list;
123
124 while(info->text_id)
125 {
126 gx_multi_line_text_view_text_id_set((GX_MULTI_LINE_TEXT_VIEW *)rich_view, info->text_id);
127
128 if(info->text_id == GX_STRING_ID_RICH_TEXT_UTF8_TEST)
129 {
130 /* Set fonts to test utf8 string. */
131 fonts.gx_rich_text_fonts_normal_id = GX_FONT_ID_CJK;
132 fonts.gx_rich_text_fonts_bold_id = GX_FONT_ID_CJK_BOLD;
133 fonts.gx_rich_text_fonts_italic_id = GX_FONT_ID_CJK_ITALIC;
134 fonts.gx_rich_text_fonts_bold_italic_id = GX_FONT_ID_CJK_BOLD_ITALIC;
135 gx_rich_text_view_fonts_set(rich_view, &fonts);
136 }
137
138 for(alignment = 0; alignment < sizeof(align_info_list)/sizeof(align_info); alignment++)
139 {
140 gx_widget_style_remove(rich_view, GX_STYLE_TEXT_ALIGNMENT_MASK);
141 gx_widget_style_add(rich_view, align_info_list[alignment].style);
142
143 gx_widget_string_get_ext(rich_view, info->text_id, &string);
144 sprintf(comment, "%s, test string id: %s", align_info_list[alignment].comment, info->id_name);
145 gx_validation_set_frame_id(frame_id++);
146 gx_validation_set_frame_comment(comment);
147 gx_validation_screen_refresh();
148 }
149
150 info++;
151 }
152
153 gx_multi_line_text_view_text_id_set((GX_MULTI_LINE_TEXT_VIEW *)rich_view, 0);
154 gx_validation_set_frame_id(frame_id++);
155 gx_validation_set_frame_comment("set string id to 0");
156 gx_validation_screen_refresh();
157
158 /* Signal the end of the test case. Verify the output. */
159 gx_validation_end();
160
161 exit(0);
162 }
163