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