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_system.h"
29 #include "gx_button.h"
30 #include "gx_widget.h"
31 #include "gx_utility.h"
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _gx_text_button_text_get PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Kenneth Maxwell, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION (deprecated) */
44 /* */
45 /* This function assigns a string literal to the specified prompt */
46 /* */
47 /* */
48 /* INPUT */
49 /* */
50 /* button Button control block */
51 /* return_text String used in the button */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* status Completion status */
56 /* */
57 /* CALLS */
58 /* */
59 /* _gx_system_string_get Get the string based on ID */
60 /* */
61 /* CALLED BY */
62 /* */
63 /* Application Code */
64 /* */
65 /* RELEASE HISTORY */
66 /* */
67 /* DATE NAME DESCRIPTION */
68 /* */
69 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
70 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
71 /* resulting in version 6.1 */
72 /* */
73 /**************************************************************************/
74 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
_gx_text_button_text_get(GX_TEXT_BUTTON * button,GX_CONST GX_CHAR ** return_text)75 UINT _gx_text_button_text_get(GX_TEXT_BUTTON *button, GX_CONST GX_CHAR **return_text)
76 {
77 UINT status = GX_SUCCESS;
78 GX_STRING string;
79
80 status = _gx_text_button_text_get_ext(button, &string);
81
82 if (status == GX_SUCCESS)
83 {
84 *return_text = string.gx_string_ptr;
85 }
86 return status;
87 }
88 #endif
89
90 /**************************************************************************/
91 /* */
92 /* FUNCTION RELEASE */
93 /* */
94 /* _gx_text_button_text_get_ext PORTABLE C */
95 /* 6.1.10 */
96 /* AUTHOR */
97 /* */
98 /* Kenneth Maxwell, Microsoft Corporation */
99 /* */
100 /* DESCRIPTION */
101 /* */
102 /* This function assigns a string literal to the specified prompt */
103 /* */
104 /* */
105 /* INPUT */
106 /* */
107 /* button Button control block */
108 /* return_text String used in the button */
109 /* */
110 /* OUTPUT */
111 /* */
112 /* status Completion status */
113 /* */
114 /* CALLS */
115 /* */
116 /* _gx_system_string_get_ext Get the string based on ID */
117 /* _gx_system_private_string_get Get private string copy */
118 /* */
119 /* CALLED BY */
120 /* */
121 /* Application Code */
122 /* */
123 /* RELEASE HISTORY */
124 /* */
125 /* DATE NAME DESCRIPTION */
126 /* */
127 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
128 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
129 /* added logic to retrieve */
130 /* dynamic bidi text, */
131 /* resulting in version 6.1 */
132 /* 01-31-2022 Ting Zhu Modified comment(s), */
133 /* updated with new bidi text */
134 /* reorder function call, */
135 /* resulting in version 6.1.10 */
136 /* */
137 /**************************************************************************/
_gx_text_button_text_get_ext(GX_TEXT_BUTTON * button,GX_STRING * return_text)138 UINT _gx_text_button_text_get_ext(GX_TEXT_BUTTON *button, GX_STRING *return_text)
139 {
140 UINT status = GX_SUCCESS;
141
142 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
143 GX_BIDI_TEXT_INFO text_info;
144 GX_BIDI_RESOLVED_TEXT_INFO *resolved_info;
145 GX_CANVAS *canvas;
146 GX_DISPLAY *display;
147 #endif
148
149 if (button -> gx_text_button_text_id)
150 {
151 status = _gx_widget_string_get_ext((GX_WIDGET *)button, button -> gx_text_button_text_id, return_text);
152 }
153 else
154 {
155 _gx_system_private_string_get(&button -> gx_text_button_string, return_text, button -> gx_widget_style);
156 }
157
158 #if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
159 if (_gx_system_bidi_text_enabled)
160 {
161 if (button -> gx_text_button_bidi_resolved_text_info)
162 {
163 *return_text = *button -> gx_text_button_bidi_resolved_text_info -> gx_bidi_resolved_text_info_text;
164 }
165 else
166 {
167 text_info.gx_bidi_text_info_text = *return_text;
168 text_info.gx_bidi_text_info_font = GX_NULL;
169 text_info.gx_bidi_text_info_display_width = -1;
170 GX_UTILITY_TEXT_DIRECTION_GET(text_info.gx_bidi_text_info_direction, button, canvas, display);
171
172 if (_gx_utility_bidi_paragraph_reorder_ext(&text_info, &resolved_info) == GX_SUCCESS)
173 {
174 button -> gx_text_button_bidi_resolved_text_info = resolved_info;
175 *return_text = *resolved_info -> gx_bidi_resolved_text_info_text;
176 }
177 }
178 }
179 #endif
180
181 return(status);
182 }
183
184