1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** GUIX Component */
17 /** */
18 /** Text Button Management (Button) */
19 /** */
20 /**************************************************************************/
21
22 #define GX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "gx_api.h"
28 #include "gx_widget.h"
29 #include "gx_button.h"
30 #include "gx_system.h"
31 #include "gx_utility.h"
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _gx_multi_line_text_button_line_pointers_set PORTABLE C */
38 /* 6.1.10 */
39 /* AUTHOR */
40 /* */
41 /* Kenneth Maxwell, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function creates a multi-line text button, which is a special */
46 /* type of button (widget). */
47 /* */
48 /* INPUT */
49 /* */
50 /* button Button control block */
51 /* name Name of button */
52 /* parent Parent widget control block */
53 /* text_id text resource id */
54 /* style Style of button */
55 /* size Button size */
56 /* */
57 /* OUTPUT */
58 /* */
59 /* status Completion status */
60 /* */
61 /* CALLS */
62 /* */
63 /* _gx_system_string_get */
64 /* */
65 /* CALLED BY */
66 /* */
67 /* Application Code */
68 /* */
69 /* RELEASE HISTORY */
70 /* */
71 /* DATE NAME DESCRIPTION */
72 /* */
73 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
74 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
75 /* added line pointers set */
76 /* loigc for dynamic bidi text,*/
77 /* resulting in version 6.1 */
78 /* 01-31-2022 Ting Zhu Modified comment(s), */
79 /* updated with new bidi text */
80 /* reorder function call, */
81 /* resulting in version 6.1.10 */
82 /* */
83 /**************************************************************************/
_gx_multi_line_text_button_line_pointers_set(GX_MULTI_LINE_TEXT_BUTTON * button)84 VOID _gx_multi_line_text_button_line_pointers_set(GX_MULTI_LINE_TEXT_BUTTON *button)
85 {
86 INT line_index;
87 GX_STRING string;
88 GX_CONST GX_CHAR *text;
89
90 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
91 GX_BIDI_TEXT_INFO text_info;
92 GX_BIDI_RESOLVED_TEXT_INFO *next;
93 GX_CANVAS *canvas;
94 GX_DISPLAY *display;
95 #endif
96
97
98 button -> gx_multi_line_text_button_line_count = 1;
99
100 for (line_index = 0; line_index < GX_MULTI_LINE_TEXT_BUTTON_MAX_LINES; line_index++)
101 {
102 button -> gx_multi_line_text_button_lines[line_index].gx_string_ptr = GX_NULL;
103 button -> gx_multi_line_text_button_lines[line_index].gx_string_length = 0;
104 }
105 line_index = 0;
106
107 if (button -> gx_text_button_text_id)
108 {
109 _gx_widget_string_get_ext((GX_WIDGET *)button, button -> gx_text_button_text_id, &string);
110 }
111 else
112 {
113 _gx_system_private_string_get(&button -> gx_text_button_string, &string, button -> gx_widget_style);
114 }
115
116 text = string.gx_string_ptr;
117
118 if (!text)
119 {
120 return;
121 }
122
123 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
124 if (_gx_system_bidi_text_enabled)
125 {
126 if (!button -> gx_text_button_bidi_resolved_text_info)
127 {
128 text_info.gx_bidi_text_info_display_width = -1;
129 text_info.gx_bidi_text_info_font = GX_NULL;
130 text_info.gx_bidi_text_info_text = string;
131 GX_UTILITY_TEXT_DIRECTION_GET(text_info.gx_bidi_text_info_direction, button, canvas, display);
132 _gx_utility_bidi_paragraph_reorder_ext(&text_info, &button -> gx_text_button_bidi_resolved_text_info);
133 }
134
135 next = button -> gx_text_button_bidi_resolved_text_info;
136
137 while (next)
138 {
139 button -> gx_multi_line_text_button_lines[line_index++] = *next -> gx_bidi_resolved_text_info_text;
140 next = next -> gx_bidi_resolved_text_info_next;
141
142 if (line_index >= GX_MULTI_LINE_TEXT_BUTTON_MAX_LINES)
143 {
144 break;
145 }
146 }
147
148 if (line_index)
149 {
150 button -> gx_multi_line_text_button_line_count = line_index;
151 }
152 }
153 else
154 {
155 #endif
156 while (*text)
157 {
158 if ((*text == GX_KEY_CARRIAGE_RETURN) || (*text == GX_KEY_LINE_FEED))
159 {
160 if ((*text == GX_KEY_CARRIAGE_RETURN) && (*(text + 1) == GX_KEY_LINE_FEED))
161 {
162 text += 2;
163 }
164 else
165 {
166 text++;
167 }
168 line_index++;
169
170 if (line_index >= GX_MULTI_LINE_TEXT_BUTTON_MAX_LINES)
171 {
172 break;
173 }
174 else
175 {
176 button -> gx_multi_line_text_button_line_count++;
177 }
178 }
179 else
180 {
181 if (button -> gx_multi_line_text_button_lines[line_index].gx_string_ptr == GX_NULL)
182 {
183 button -> gx_multi_line_text_button_lines[line_index].gx_string_ptr = text;
184 }
185 button -> gx_multi_line_text_button_lines[line_index].gx_string_length++;
186 text++;
187 }
188 }
189 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
190 }
191 #endif
192 }
193
194