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_widget_text_draw", /* Test name */
10 0, 0, 639, 479 /* Define the coordinates of the capture area.
11 In this test, we only need to capture the pixelmap
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 #include "demo_guix_all_widgets.c"
57
test_widget_text_draw(GX_WINDOW * window)58 static void test_widget_text_draw(GX_WINDOW * window)
59 {
60 GX_STRING string;
61
62 gx_window_background_draw(window);
63
64 #ifdef GX_ENABLE_DEPRECATED_STRING_API
65 gx_widget_text_draw(window, GX_COLOR_ID_ORANGE, GX_FONT_ID_SYSTEM, "test string 1", 10, 10);
66 #endif
67
68 string.gx_string_ptr = "test string 3";
69 string.gx_string_length = strlen(string.gx_string_ptr);
70 gx_widget_text_blend_ext(window, GX_COLOR_ID_ORANGE, 1024, &string, 10, 50, 128);
71
72 string.gx_string_ptr = GX_NULL;
73 string.gx_string_length = 0;
74 gx_widget_text_blend_ext(window, GX_COLOR_ID_ORANGE, GX_FONT_ID_SYSTEM, &string, 10, 100, 128);
75
76 }
77
test_widget_text_id_draw(GX_WINDOW * window)78 static void test_widget_text_id_draw(GX_WINDOW *window)
79 {
80
81 gx_window_background_draw(window);
82
83 /* Draw text at (20, 30) of current window. */
84 gx_widget_text_id_draw(window, GX_COLOR_ID_ORANGE, GX_FONT_ID_PROMPT,
85 GX_STRING_ID_STRING_5, 20, 30);
86
87 /* Draw a null string at (10, 20) of current window. */
88 gx_widget_text_id_draw(window, GX_COLOR_ID_ORANGE, GX_FONT_ID_PROMPT,
89 0, 10, 20);
90 }
91
92 /* This thread simulates user input. Its priority is lower
93 than the GUIX thread, so that GUIX finishes an operation
94 before this thread is able to issue the next command. */
control_thread_entry(ULONG input)95 static VOID control_thread_entry(ULONG input)
96 {
97 INT frame_id = 1;
98
99 gx_widget_draw_set(pButtonScreen, test_widget_text_draw);
100 gx_validation_set_frame_id(frame_id++);
101 gx_validation_set_frame_comment("Test gx_widget_text_draw");
102 gx_validation_screen_refresh();
103
104 gx_widget_draw_set(pButtonScreen, test_widget_text_id_draw);
105 gx_validation_set_frame_id(frame_id++);
106 gx_validation_set_frame_comment("Test gx_widget_text_id_draw");
107 gx_validation_screen_refresh();
108
109 /* Signal the end of the test case. Verify the output. */
110 gx_validation_end();
111
112 exit(0);
113 }
114