GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gxe_string_scroll_wheel_create.c Lines: 34 34 100.0 %
Date: 2026-03-06 19:21:09 Branches: 46 46 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
/**   String Scroll Wheel Management (Scroll Wheel)                       */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_scroll_wheel.h"
29
#include "gx_utility.h"
30
31
GX_CALLER_CHECKING_EXTERNS
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gxe_string_scroll_wheel_create                     PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function checks for errors in string scroll wheel create call. */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    wheel                                 Scroll wheel control block    */
50
/*    name                                  Name of widget                */
51
/*    parent                                Parent widget control block   */
52
/*    total_rows                            Total rows of the scroll wheel*/
53
/*    string_list                           String list for display       */
54
/*    callback                              Callback for retrieved row    */
55
/*                                            string                      */
56
/*    style                                 Style of widget               */
57
/*    Id                                    Application-defined ID of the */
58
/*                                            the widget                  */
59
/*    size                                  Widget size                   */
60
/*    control_block_size                    Size of the scroll wheel      */
61
/*                                            control block               */
62
/*                                                                        */
63
/*  OUTPUT                                                                */
64
/*                                                                        */
65
/*    status                                Completion status             */
66
/*                                                                        */
67
/*  CALLS                                                                 */
68
/*                                                                        */
69
/*    _gx_text_scroll_wheel_create          Actual text scroll wheel      */
70
/*                                            create call                 */
71
/*                                                                        */
72
/*  CALLED BY                                                             */
73
/*                                                                        */
74
/*    Application Code                                                    */
75
/*                                                                        */
76
/**************************************************************************/
77
#if defined(GX_ENABLE_DEPRECATED_STRING_API)
78
11
UINT  _gxe_string_scroll_wheel_create(GX_STRING_SCROLL_WHEEL *wheel,
79
                                      GX_CONST GX_CHAR *name,
80
                                      GX_WIDGET *parent, INT total_rows,
81
                                      GX_CONST GX_CHAR **string_list,
82
                                      ULONG style, USHORT Id,
83
                                      GX_CONST GX_RECTANGLE *size, UINT control_block_size)
84
{
85
UINT status;
86
87
    /* Check for appropriate caller.  */
88

11
    GX_INIT_AND_THREADS_CALLER_CHECKING
89
90
    /* Check for invalid pointer. */
91

9
    if ((wheel == GX_NULL) || (size == GX_NULL))
92
    {
93
2
        return GX_PTR_ERROR;
94
    }
95
96
    /* Check for invalid value. */
97
7
    if (control_block_size != sizeof(GX_STRING_SCROLL_WHEEL))
98
    {
99
1
        return GX_INVALID_SIZE;
100
    }
101
102
    /* Check for widget already created.  */
103
6
    if (wheel -> gx_widget_type != 0)
104
    {
105
1
        return(GX_ALREADY_CREATED);
106
    }
107
108
    /* Check for invalid widget. */
109

5
    if (parent && (parent -> gx_widget_type == 0))
110
    {
111
1
        return(GX_INVALID_WIDGET);
112
    }
113
114
4
    status = _gx_string_scroll_wheel_create(wheel, name, parent, total_rows, string_list, style, Id, size);
115
4
    return status;
116
}
117
#endif
118
119
/**************************************************************************/
120
/*                                                                        */
121
/*  FUNCTION                                               RELEASE        */
122
/*                                                                        */
123
/*    _gxe_string_scroll_wheel_create_ext                 PORTABLE C      */
124
/*                                                           6.1          */
125
/*  AUTHOR                                                                */
126
/*                                                                        */
127
/*    Kenneth Maxwell, Microsoft Corporation                              */
128
/*                                                                        */
129
/*  DESCRIPTION                                                           */
130
/*                                                                        */
131
/*    This function checks for errors in string scroll wheel create call. */
132
/*                                                                        */
133
/*  INPUT                                                                 */
134
/*                                                                        */
135
/*    wheel                                 Scroll wheel control block    */
136
/*    name                                  Name of widget                */
137
/*    parent                                Parent widget control block   */
138
/*    total_rows                            Total rows of the scroll wheel*/
139
/*    string_list                           String list for display       */
140
/*    callback                              Callback for retrieved row    */
141
/*                                            string                      */
142
/*    style                                 Style of widget               */
143
/*    Id                                    Application-defined ID of the */
144
/*                                            the widget                  */
145
/*    size                                  Widget size                   */
146
/*    control_block_size                    Size of the scroll wheel      */
147
/*                                            control block               */
148
/*                                                                        */
149
/*  OUTPUT                                                                */
150
/*                                                                        */
151
/*    status                                Completion status             */
152
/*                                                                        */
153
/*  CALLS                                                                 */
154
/*                                                                        */
155
/*    _gx_text_scroll_wheel_create_ext      Actual text scroll wheel      */
156
/*                                            create ext call             */
157
/*                                                                        */
158
/*  CALLED BY                                                             */
159
/*                                                                        */
160
/*    Application Code                                                    */
161
/*                                                                        */
162
/**************************************************************************/
163
199
UINT _gxe_string_scroll_wheel_create_ext(GX_STRING_SCROLL_WHEEL *wheel, GX_CONST GX_CHAR *name, GX_WIDGET *parent, INT total_rows,
164
                                         GX_CONST GX_STRING *string_list,
165
                                         ULONG style, USHORT Id, GX_CONST GX_RECTANGLE *size, UINT control_block_size)
166
{
167
UINT                status;
168
INT                 string_id;
169
GX_CONST GX_STRING *string;
170
UINT                string_length;
171
172
    /* Check for appropriate caller.  */
173

199
    GX_INIT_AND_THREADS_CALLER_CHECKING
174
175
    /* Check for invalid pointer. */
176

197
    if ((wheel == GX_NULL) || (size == GX_NULL))
177
    {
178
2
        return GX_PTR_ERROR;
179
    }
180
181
    /* Check for invalid value. */
182
195
    if (control_block_size != sizeof(GX_STRING_SCROLL_WHEEL))
183
    {
184
1
        return GX_INVALID_SIZE;
185
    }
186
187
    /* Check for widget already created.  */
188
194
    if (wheel -> gx_widget_type != 0)
189
    {
190
1
        return(GX_ALREADY_CREATED);
191
    }
192
193
    /* Check for invalid widget. */
194

193
    if (parent && (parent -> gx_widget_type == 0))
195
    {
196
1
        return(GX_INVALID_WIDGET);
197
    }
198
199
192
    if (string_list)
200
    {
201
        /* Test string length. */
202
6
        for (string_id = 0; string_id < total_rows; string_id++)
203
        {
204
5
            string = &string_list[string_id];
205
5
            if (string -> gx_string_ptr)
206
            {
207
4
                status = _gx_utility_string_length_check(string -> gx_string_ptr, &string_length, string -> gx_string_length);
208
209
4
                if (status != GX_SUCCESS)
210
                {
211
1
                    return status;
212
                }
213
            }
214
            else
215
            {
216
1
                string_length = 0;
217
            }
218
219
4
            if (string_length != string -> gx_string_length)
220
            {
221
1
                return GX_INVALID_STRING_LENGTH;
222
            }
223
        }
224
    }
225
226
190
    status = _gx_string_scroll_wheel_create_ext(wheel, name, parent, total_rows, string_list, style, Id, size);
227
190
    return status;
228
}
229