GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_language_table_set.c Lines: 36 36 100.0 %
Date: 2024-12-05 08:52:37 Branches: 16 16 100.0 %

Line Branch Exec Source
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
/**   Display Management (Display)                                        */
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_display.h"
29
#include "gx_utility.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_display_language_table_set                      PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION  (Deprecated)                                             */
43
/*                                                                        */
44
/*    This service sets the language table.                               */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    language_table                        The language table to be set  */
49
/*    num_languages                         Number of languages in the    */
50
/*                                            table                       */
51
/*    number_of_strings                     Number of strings in each     */
52
/*                                            language                    */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    status                                Completion status             */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _gx_system_all_canvas_dirty           Mark canvas dirty             */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    Application Code                                                    */
65
/*                                                                        */
66
/*  RELEASE HISTORY                                                       */
67
/*                                                                        */
68
/*    DATE              NAME                      DESCRIPTION             */
69
/*                                                                        */
70
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
71
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
72
/*                                            resulting in version 6.1    */
73
/*                                                                        */
74
/**************************************************************************/
75
#if defined(GX_ENABLE_DEPRECATED_STRING_API)
76
11
UINT  _gx_display_language_table_set(GX_DISPLAY *display, GX_CHAR ***language_table,
77
                                    GX_UBYTE num_languages, UINT number_of_strings)
78
{
79
GX_EVENT            language_event;
80
GX_WINDOW_ROOT     *root;
81
11
GX_CONST GX_CHAR ***old_table = display -> gx_display_language_table_deprecated;
82
83
     /* Setup the system string table information.  */
84
11
    display -> gx_display_language_table_deprecated = (GX_CONST GX_CHAR ***)language_table;
85
11
    display -> gx_display_language_table = GX_NULL;
86
87
11
    display -> gx_display_language_table_size = num_languages;
88
11
    display -> gx_display_string_table_size = number_of_strings;
89
90
11
    if (old_table)
91
    {
92
4
        memset(&language_event, 0, sizeof(GX_EVENT));
93
4
        language_event.gx_event_type = GX_EVENT_LANGUAGE_CHANGE;
94
95
4
        root = (GX_WINDOW_ROOT *)_gx_system_root_window_created_list;
96
97
9
        while (root)
98
        {
99
5
            if (root -> gx_window_root_canvas)
100
            {
101
4
                if (root -> gx_window_root_canvas -> gx_canvas_display == display)
102
                {
103
3
                    language_event.gx_event_target = (GX_WIDGET *) root;
104
3
                    _gx_system_event_send(&language_event);
105
                }
106
            }
107
108
5
            root = (GX_WINDOW_ROOT *)root -> gx_widget_next;
109
        }
110
111
        /* mark all visible canvases as dirty when there is a resource change */
112
4
        _gx_system_all_canvas_dirty();
113
    }
114
115
    /* Return success.  */
116
11
    return(GX_SUCCESS);
117
}
118
#endif
119
120
/**************************************************************************/
121
/*                                                                        */
122
/*  FUNCTION                                               RELEASE        */
123
/*                                                                        */
124
/*    _gx_display_language_table_set_ext                  PORTABLE C      */
125
/*                                                           6.1          */
126
/*  AUTHOR                                                                */
127
/*                                                                        */
128
/*    Kenneth Maxwell, Microsoft Corporation                              */
129
/*                                                                        */
130
/*  DESCRIPTION                                                           */
131
/*                                                                        */
132
/*    This service sets the language table.                               */
133
/*                                                                        */
134
/*  INPUT                                                                 */
135
/*                                                                        */
136
/*    language_table                        The language table to be set  */
137
/*    num_languages                         Number of languages in the    */
138
/*                                            table                       */
139
/*    number_of_strings                     Number of strings in each     */
140
/*                                            language                    */
141
/*                                                                        */
142
/*  OUTPUT                                                                */
143
/*                                                                        */
144
/*    status                                Completion status             */
145
/*                                                                        */
146
/*  CALLS                                                                 */
147
/*                                                                        */
148
/*    _gx_system_all_canvas_dirty           Mark canvas dirty             */
149
/*                                                                        */
150
/*  CALLED BY                                                             */
151
/*                                                                        */
152
/*    Application Code                                                    */
153
/*                                                                        */
154
/*  RELEASE HISTORY                                                       */
155
/*                                                                        */
156
/*    DATE              NAME                      DESCRIPTION             */
157
/*                                                                        */
158
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
159
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
160
/*                                            resulting in version 6.1    */
161
/*                                                                        */
162
/**************************************************************************/
163
768
UINT  _gx_display_language_table_set_ext(GX_DISPLAY *display, GX_CONST GX_STRING **language_table,
164
                                    GX_UBYTE num_languages, UINT number_of_strings)
165
{
166
GX_EVENT   language_event;
167
GX_WINDOW_ROOT *root;
168
768
GX_CONST GX_STRING **old_table = display -> gx_display_language_table;
169
170
    /* Setup the system string table information.  */
171
768
    display -> gx_display_language_table = language_table;
172
173
#if defined(GX_ENABLE_DEPRECATED_STRING_API)
174
768
    display -> gx_display_language_table_deprecated = GX_NULL;
175
#endif
176
177
768
    display -> gx_display_language_table_size = num_languages;
178
768
    display -> gx_display_string_table_size = number_of_strings;
179
180
768
    if (old_table)
181
    {
182
40
        memset(&language_event, 0, sizeof(GX_EVENT));
183
40
        language_event.gx_event_type = GX_EVENT_LANGUAGE_CHANGE;
184
185
40
        root = (GX_WINDOW_ROOT *)_gx_system_root_window_created_list;
186
187
83
        while (root)
188
        {
189
43
            if (root -> gx_window_root_canvas)
190
            {
191
42
                if (root -> gx_window_root_canvas -> gx_canvas_display == display)
192
                {
193
39
                    language_event.gx_event_target = (GX_WIDGET *) root;
194
39
                    _gx_system_event_send(&language_event);
195
                }
196
            }
197
198
43
            root = (GX_WINDOW_ROOT *)root -> gx_widget_next;
199
        }
200
201
        /* mark all visible canvases as dirty when there is a resource change */
202
40
        _gx_system_all_canvas_dirty();
203
    }
204
205
    /* Return success.  */
206
768
    return(GX_SUCCESS);
207
}
208
209
/**************************************************************************/
210
/*                                                                        */
211
/*  FUNCTION                                               RELEASE        */
212
/*                                                                        */
213
/*    _gx_display_language_direction_table_set_ext        PORTABLE C      */
214
/*                                                           6.3.0        */
215
/*  AUTHOR                                                                */
216
/*                                                                        */
217
/*    Ting Zhu, Microsoft Corporation                                     */
218
/*                                                                        */
219
/*  DESCRIPTION                                                           */
220
/*                                                                        */
221
/*    This service sets the language direction table.                     */
222
/*                                                                        */
223
/*  INPUT                                                                 */
224
/*                                                                        */
225
/*    display                               Pointer to display            */
226
/*    language_direction_table              The language direction table  */
227
/*                                            to be set                   */
228
/*    num_languages                         Number of languages in the    */
229
/*                                            table                       */
230
/*                                                                        */
231
/*  OUTPUT                                                                */
232
/*                                                                        */
233
/*    status                                Completion status             */
234
/*                                                                        */
235
/*  CALLS                                                                 */
236
/*                                                                        */
237
/*    None                                                                */
238
/*                                                                        */
239
/*  CALLED BY                                                             */
240
/*                                                                        */
241
/*    Application Code                                                    */
242
/*                                                                        */
243
/*  RELEASE HISTORY                                                       */
244
/*                                                                        */
245
/*    DATE              NAME                      DESCRIPTION             */
246
/*                                                                        */
247
/*  01-31-2022     Ting Zhu                 Initial Version 6.1.10        */
248
/*  10-31-2023     Ting Zhu                 Modified comment(s),          */
249
/*                                            resulting in version 6.3.0  */
250
/*                                                                        */
251
/**************************************************************************/
252
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
253
UINT  _gx_display_language_direction_table_set(GX_DISPLAY *display, GX_CONST GX_UBYTE *language_direction_table, GX_UBYTE num_languages)
254
{
255
256
    if (num_languages != display->gx_display_language_table_size)
257
    {
258
        return(GX_INVALID_VALUE);
259
    }
260
261
    /* Setup the system string table information.  */
262
    display -> gx_display_language_direction_table = language_direction_table;
263
264
    /* Return success.  */
265
    return(GX_SUCCESS);
266
}
267
#endif