GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_text_button_text_get.c Lines: 12 12 100.0 %
Date: 2026-03-06 19:21:09 Branches: 4 4 100.0 %

Line Branch Exec Source
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_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
/**************************************************************************/
66
#if defined(GX_ENABLE_DEPRECATED_STRING_API)
67
3
UINT _gx_text_button_text_get(GX_TEXT_BUTTON *button, GX_CONST GX_CHAR **return_text)
68
{
69
3
UINT      status = GX_SUCCESS;
70
GX_STRING string;
71
72
3
    status = _gx_text_button_text_get_ext(button, &string);
73
74
3
    if (status == GX_SUCCESS)
75
    {
76
2
        *return_text = string.gx_string_ptr;
77
    }
78
3
    return status;
79
}
80
#endif
81
82
/**************************************************************************/
83
/*                                                                        */
84
/*  FUNCTION                                               RELEASE        */
85
/*                                                                        */
86
/*    _gx_text_button_text_get_ext                        PORTABLE C      */
87
/*                                                           6.1.10       */
88
/*  AUTHOR                                                                */
89
/*                                                                        */
90
/*    Kenneth Maxwell, Microsoft Corporation                              */
91
/*                                                                        */
92
/*  DESCRIPTION                                                           */
93
/*                                                                        */
94
/*    This function assigns a string literal to the specified prompt      */
95
/*                                                                        */
96
/*                                                                        */
97
/*  INPUT                                                                 */
98
/*                                                                        */
99
/*    button                                Button control block          */
100
/*    return_text                           String used in the button     */
101
/*                                                                        */
102
/*  OUTPUT                                                                */
103
/*                                                                        */
104
/*    status                                Completion status             */
105
/*                                                                        */
106
/*  CALLS                                                                 */
107
/*                                                                        */
108
/*    _gx_system_string_get_ext             Get the string based on ID    */
109
/*    _gx_system_private_string_get         Get private string copy       */
110
/*                                                                        */
111
/*  CALLED BY                                                             */
112
/*                                                                        */
113
/*    Application Code                                                    */
114
/*                                                                        */
115
/**************************************************************************/
116
361737
UINT _gx_text_button_text_get_ext(GX_TEXT_BUTTON *button, GX_STRING *return_text)
117
{
118
361737
UINT status = GX_SUCCESS;
119
120
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
121
GX_BIDI_TEXT_INFO           text_info;
122
GX_BIDI_RESOLVED_TEXT_INFO *resolved_info;
123
GX_CANVAS                  *canvas;
124
GX_DISPLAY                 *display;
125
#endif
126
127
361737
    if (button -> gx_text_button_text_id)
128
    {
129
361647
        status = _gx_widget_string_get_ext((GX_WIDGET *)button, button -> gx_text_button_text_id, return_text);
130
    }
131
    else
132
    {
133
90
        _gx_system_private_string_get(&button -> gx_text_button_string, return_text, button -> gx_widget_style);
134
    }
135
136
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
137
    if (_gx_system_bidi_text_enabled)
138
    {
139
        if (button -> gx_text_button_bidi_resolved_text_info)
140
        {
141
            *return_text = *button -> gx_text_button_bidi_resolved_text_info -> gx_bidi_resolved_text_info_text;
142
        }
143
        else
144
        {
145
            text_info.gx_bidi_text_info_text = *return_text;
146
            text_info.gx_bidi_text_info_font = GX_NULL;
147
            text_info.gx_bidi_text_info_display_width = -1;
148
            GX_UTILITY_TEXT_DIRECTION_GET(text_info.gx_bidi_text_info_direction, button, canvas, display);
149
150
            if (_gx_utility_bidi_paragraph_reorder_ext(&text_info, &resolved_info) == GX_SUCCESS)
151
            {
152
                button -> gx_text_button_bidi_resolved_text_info = resolved_info;
153
                *return_text = *resolved_info -> gx_bidi_resolved_text_info_text;
154
            }
155
        }
156
    }
157
#endif
158
159
361737
    return(status);
160
}
161