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 |
|
|
/** System Management (System) */ |
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_display.h" |
30 |
|
|
#include "gx_utility.h" |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _gx_display_string_get PORTABLE C */ |
38 |
|
|
/* 6.1 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION (deprecated) */ |
44 |
|
|
/* */ |
45 |
|
|
/* This service return the string associated with the specified string */ |
46 |
|
|
/* ID. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* display Pointer to display instance */ |
51 |
|
|
/* string_id String resource ID */ |
52 |
|
|
/* return_string Pointer to return string */ |
53 |
|
|
/* pointer */ |
54 |
|
|
/* */ |
55 |
|
|
/* OUTPUT */ |
56 |
|
|
/* */ |
57 |
|
|
/* status Completion status */ |
58 |
|
|
/* */ |
59 |
|
|
/* CALLS */ |
60 |
|
|
/* */ |
61 |
|
|
/* None */ |
62 |
|
|
/* */ |
63 |
|
|
/* CALLED BY */ |
64 |
|
|
/* */ |
65 |
|
|
/* Application Code */ |
66 |
|
|
/* _gx_context_string_get */ |
67 |
|
|
/* _gx_widget_string_get Drew the text onto the wdiget */ |
68 |
|
|
/* */ |
69 |
|
|
/**************************************************************************/ |
70 |
|
|
#if defined(GX_ENABLE_DEPRECATED_STRING_API) |
71 |
|
106 |
UINT _gx_display_string_get(GX_DISPLAY *display, GX_RESOURCE_ID string_id, GX_CONST GX_CHAR **return_string) |
72 |
|
|
{ |
73 |
|
106 |
UINT status = GX_SUCCESS; |
74 |
|
|
GX_RESOURCE_ID string_table_size; |
75 |
|
106 |
GX_CONST GX_CHAR *string_ptr = GX_NULL; |
76 |
|
|
INT language; |
77 |
|
|
|
78 |
|
|
/* Pickup size of string table. */ |
79 |
|
106 |
string_table_size = display -> gx_display_string_table_size; |
80 |
|
|
|
81 |
|
|
/* Check to make sure the string ID is valid. */ |
82 |
✓✓ |
106 |
if(string_id >= string_table_size) |
83 |
|
|
{ |
84 |
|
7 |
status = GX_INVALID_RESOURCE_ID; |
85 |
|
|
} |
86 |
✓✓ |
99 |
else if (string_id > 0) |
87 |
|
|
{ |
88 |
|
|
/* Setup return string pointer associated with this ID. */ |
89 |
|
|
/* first try the active language */ |
90 |
|
98 |
language = display -> gx_display_active_language; |
91 |
✓✓ |
98 |
if (display -> gx_display_language_table) |
92 |
|
|
{ |
93 |
|
5 |
string_ptr = display -> gx_display_language_table[language][string_id].gx_string_ptr; |
94 |
✓✓✓✓
|
5 |
if (language && string_ptr == GX_NULL) |
95 |
|
|
{ |
96 |
|
|
/* If active language string is NULL, return reference language string */ |
97 |
|
1 |
string_ptr = display -> gx_display_language_table[0][string_id].gx_string_ptr; |
98 |
|
|
} |
99 |
|
|
} |
100 |
|
|
else |
101 |
|
|
{ |
102 |
✓✓ |
93 |
if (display -> gx_display_language_table_deprecated) |
103 |
|
|
{ |
104 |
|
92 |
string_ptr = display -> gx_display_language_table_deprecated[language][string_id]; |
105 |
✓✓✓✓
|
92 |
if (language && string_ptr == GX_NULL) |
106 |
|
|
{ |
107 |
|
|
/* If active language string is NULL, return reference language string */ |
108 |
|
1 |
string_ptr = display -> gx_display_language_table_deprecated[0][string_id]; |
109 |
|
|
} |
110 |
|
|
} |
111 |
|
|
} |
112 |
|
|
} |
113 |
|
|
|
114 |
|
106 |
*return_string = string_ptr; |
115 |
|
106 |
return status; |
116 |
|
|
} |
117 |
|
|
#endif |
118 |
|
|
|
119 |
|
|
/**************************************************************************/ |
120 |
|
|
/* */ |
121 |
|
|
/* FUNCTION RELEASE */ |
122 |
|
|
/* */ |
123 |
|
|
/* _gx_display_string_get_ext PORTABLE C */ |
124 |
|
|
/* 6.1 */ |
125 |
|
|
/* AUTHOR */ |
126 |
|
|
/* */ |
127 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
128 |
|
|
/* */ |
129 |
|
|
/* DESCRIPTION */ |
130 |
|
|
/* */ |
131 |
|
|
/* This service return the string associated with the specified string */ |
132 |
|
|
/* ID. */ |
133 |
|
|
/* */ |
134 |
|
|
/* INPUT */ |
135 |
|
|
/* */ |
136 |
|
|
/* display Pointer to display instance */ |
137 |
|
|
/* string_id String resource ID */ |
138 |
|
|
/* return_string Pointer to return string */ |
139 |
|
|
/* pointer */ |
140 |
|
|
/* */ |
141 |
|
|
/* OUTPUT */ |
142 |
|
|
/* */ |
143 |
|
|
/* status Completion status */ |
144 |
|
|
/* */ |
145 |
|
|
/* CALLS */ |
146 |
|
|
/* */ |
147 |
|
|
/* None */ |
148 |
|
|
/* */ |
149 |
|
|
/* CALLED BY */ |
150 |
|
|
/* */ |
151 |
|
|
/* Application Code */ |
152 |
|
|
/* _gx_context_string_get */ |
153 |
|
|
/* _gx_widget_string_get Drew the text onto the wdiget */ |
154 |
|
|
/* */ |
155 |
|
|
/**************************************************************************/ |
156 |
|
791817 |
UINT _gx_display_string_get_ext(GX_DISPLAY *display, GX_RESOURCE_ID string_id, GX_STRING *return_string) |
157 |
|
|
{ |
158 |
|
|
GX_RESOURCE_ID string_table_size; |
159 |
|
|
GX_STRING string; |
160 |
|
|
INT language; |
161 |
|
791817 |
UINT status = GX_SUCCESS; |
162 |
|
|
|
163 |
|
|
#if defined(GX_ENABLE_DEPRECATED_STRING_API) |
164 |
|
|
GX_CONST GX_CHAR *old_string; |
165 |
|
|
UINT string_length; |
166 |
|
|
#endif |
167 |
|
|
|
168 |
|
791817 |
string.gx_string_ptr = GX_NULL; |
169 |
|
791817 |
string.gx_string_length = 0; |
170 |
|
|
|
171 |
|
|
#if defined(GX_ENABLE_DEPRECATED_STRING_API) |
172 |
|
|
/* If application is used the deprecated API to assign string table, |
173 |
|
|
convert to GX_STRING here |
174 |
|
|
*/ |
175 |
✓✓ |
791817 |
if (display -> gx_display_language_table_deprecated) |
176 |
|
|
{ |
177 |
|
96 |
status = _gx_display_string_get(display, string_id, &old_string); |
178 |
✓✓ |
96 |
if (status == GX_SUCCESS) |
179 |
|
|
{ |
180 |
|
90 |
status = _gx_utility_string_length_check(old_string, &string_length, GX_MAX_STRING_LENGTH); |
181 |
✓✓ |
90 |
if (status == GX_SUCCESS) |
182 |
|
|
{ |
183 |
|
64 |
string.gx_string_length = string_length; |
184 |
|
64 |
string.gx_string_ptr = old_string; |
185 |
|
|
} |
186 |
|
|
} |
187 |
|
96 |
*return_string = string; |
188 |
|
96 |
return status; |
189 |
|
|
} |
190 |
|
|
#endif |
191 |
|
|
|
192 |
|
|
/* Pickup size of string table. */ |
193 |
|
791721 |
string_table_size = display -> gx_display_string_table_size; |
194 |
|
|
|
195 |
|
|
/* Check to make sure the string ID is valid. */ |
196 |
✓✓ |
791721 |
if(string_id >= string_table_size) |
197 |
|
|
{ |
198 |
|
7 |
status = GX_INVALID_RESOURCE_ID; |
199 |
|
|
} |
200 |
✓✓ |
791714 |
else if(string_id > 0) |
201 |
|
|
{ |
202 |
✓✓ |
791709 |
if (display -> gx_display_language_table) |
203 |
|
|
{ |
204 |
|
|
/* Setup return string pointer associated with this ID. */ |
205 |
|
|
/* first try the active language */ |
206 |
|
791708 |
language = display -> gx_display_active_language; |
207 |
|
791708 |
string = display -> gx_display_language_table[language][string_id]; |
208 |
|
|
|
209 |
✓✓✓✓
|
791708 |
if (language && string.gx_string_ptr == GX_NULL) |
210 |
|
|
{ |
211 |
|
|
/* If active language string is NULL, return reference language string */ |
212 |
|
2742 |
string = display -> gx_display_language_table[0][string_id]; |
213 |
|
|
} |
214 |
|
|
} |
215 |
|
|
} |
216 |
|
|
|
217 |
|
791721 |
*return_string = string; |
218 |
|
791721 |
return status; |
219 |
|
|
} |