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