1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
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 |
|
|
/**************************************************************************/ |
70 |
|
278 |
VOID _gx_multi_line_text_button_line_pointers_set(GX_MULTI_LINE_TEXT_BUTTON *button) |
71 |
|
|
{ |
72 |
|
|
INT line_index; |
73 |
|
|
GX_STRING string; |
74 |
|
|
GX_CONST GX_CHAR *text; |
75 |
|
|
|
76 |
|
|
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT) |
77 |
|
|
GX_BIDI_TEXT_INFO text_info; |
78 |
|
|
GX_BIDI_RESOLVED_TEXT_INFO *next; |
79 |
|
|
GX_CANVAS *canvas; |
80 |
|
|
GX_DISPLAY *display; |
81 |
|
|
#endif |
82 |
|
|
|
83 |
|
|
|
84 |
|
278 |
button -> gx_multi_line_text_button_line_count = 1; |
85 |
|
|
|
86 |
✓✓ |
1390 |
for (line_index = 0; line_index < GX_MULTI_LINE_TEXT_BUTTON_MAX_LINES; line_index++) |
87 |
|
|
{ |
88 |
|
1112 |
button -> gx_multi_line_text_button_lines[line_index].gx_string_ptr = GX_NULL; |
89 |
|
1112 |
button -> gx_multi_line_text_button_lines[line_index].gx_string_length = 0; |
90 |
|
|
} |
91 |
|
278 |
line_index = 0; |
92 |
|
|
|
93 |
✓✓ |
278 |
if (button -> gx_text_button_text_id) |
94 |
|
|
{ |
95 |
|
273 |
_gx_widget_string_get_ext((GX_WIDGET *)button, button -> gx_text_button_text_id, &string); |
96 |
|
|
} |
97 |
|
|
else |
98 |
|
|
{ |
99 |
|
5 |
_gx_system_private_string_get(&button -> gx_text_button_string, &string, button -> gx_widget_style); |
100 |
|
|
} |
101 |
|
|
|
102 |
|
278 |
text = string.gx_string_ptr; |
103 |
|
|
|
104 |
✓✓ |
278 |
if (!text) |
105 |
|
|
{ |
106 |
|
5 |
return; |
107 |
|
|
} |
108 |
|
|
|
109 |
|
|
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT) |
110 |
|
|
if (_gx_system_bidi_text_enabled) |
111 |
|
|
{ |
112 |
|
|
if (!button -> gx_text_button_bidi_resolved_text_info) |
113 |
|
|
{ |
114 |
|
|
text_info.gx_bidi_text_info_display_width = -1; |
115 |
|
|
text_info.gx_bidi_text_info_font = GX_NULL; |
116 |
|
|
text_info.gx_bidi_text_info_text = string; |
117 |
|
|
GX_UTILITY_TEXT_DIRECTION_GET(text_info.gx_bidi_text_info_direction, button, canvas, display); |
118 |
|
|
_gx_utility_bidi_paragraph_reorder_ext(&text_info, &button -> gx_text_button_bidi_resolved_text_info); |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
next = button -> gx_text_button_bidi_resolved_text_info; |
122 |
|
|
|
123 |
|
|
while (next) |
124 |
|
|
{ |
125 |
|
|
button -> gx_multi_line_text_button_lines[line_index++] = *next -> gx_bidi_resolved_text_info_text; |
126 |
|
|
next = next -> gx_bidi_resolved_text_info_next; |
127 |
|
|
|
128 |
|
|
if (line_index >= GX_MULTI_LINE_TEXT_BUTTON_MAX_LINES) |
129 |
|
|
{ |
130 |
|
|
break; |
131 |
|
|
} |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
if (line_index) |
135 |
|
|
{ |
136 |
|
|
button -> gx_multi_line_text_button_line_count = line_index; |
137 |
|
|
} |
138 |
|
|
} |
139 |
|
|
else |
140 |
|
|
{ |
141 |
|
|
#endif |
142 |
✓✓ |
4959 |
while (*text) |
143 |
|
|
{ |
144 |
✓✓✓✓
|
4688 |
if ((*text == GX_KEY_CARRIAGE_RETURN) || (*text == GX_KEY_LINE_FEED)) |
145 |
|
|
{ |
146 |
✓✓✓✓
|
546 |
if ((*text == GX_KEY_CARRIAGE_RETURN) && (*(text + 1) == GX_KEY_LINE_FEED)) |
147 |
|
|
{ |
148 |
|
2 |
text += 2; |
149 |
|
|
} |
150 |
|
|
else |
151 |
|
|
{ |
152 |
|
544 |
text++; |
153 |
|
|
} |
154 |
|
546 |
line_index++; |
155 |
|
|
|
156 |
✓✓ |
546 |
if (line_index >= GX_MULTI_LINE_TEXT_BUTTON_MAX_LINES) |
157 |
|
|
{ |
158 |
|
2 |
break; |
159 |
|
|
} |
160 |
|
|
else |
161 |
|
|
{ |
162 |
|
544 |
button -> gx_multi_line_text_button_line_count++; |
163 |
|
|
} |
164 |
|
|
} |
165 |
|
|
else |
166 |
|
|
{ |
167 |
✓✓ |
4142 |
if (button -> gx_multi_line_text_button_lines[line_index].gx_string_ptr == GX_NULL) |
168 |
|
|
{ |
169 |
|
816 |
button -> gx_multi_line_text_button_lines[line_index].gx_string_ptr = text; |
170 |
|
|
} |
171 |
|
4142 |
button -> gx_multi_line_text_button_lines[line_index].gx_string_length++; |
172 |
|
4142 |
text++; |
173 |
|
|
} |
174 |
|
|
} |
175 |
|
|
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT) |
176 |
|
|
} |
177 |
|
|
#endif |
178 |
|
|
} |
179 |
|
|
|