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

11
    GX_INIT_AND_THREADS_CALLER_CHECKING
96
97
    /* Check for invalid pointer. */
98

9
    if ((wheel == GX_NULL) || (size == GX_NULL))
99
    {
100
2
        return GX_PTR_ERROR;
101
    }
102
103
    /* Check for invalid value. */
104
7
    if (control_block_size != sizeof(GX_STRING_SCROLL_WHEEL))
105
    {
106
1
        return GX_INVALID_SIZE;
107
    }
108
109
    /* Check for widget already created.  */
110
6
    if (wheel -> gx_widget_type != 0)
111
    {
112
1
        return(GX_ALREADY_CREATED);
113
    }
114
115
    /* Check for invalid widget. */
116

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

199
    GX_INIT_AND_THREADS_CALLER_CHECKING
189
190
    /* Check for invalid pointer. */
191

197
    if ((wheel == GX_NULL) || (size == GX_NULL))
192
    {
193
2
        return GX_PTR_ERROR;
194
    }
195
196
    /* Check for invalid value. */
197
195
    if (control_block_size != sizeof(GX_STRING_SCROLL_WHEEL))
198
    {
199
1
        return GX_INVALID_SIZE;
200
    }
201
202
    /* Check for widget already created.  */
203
194
    if (wheel -> gx_widget_type != 0)
204
    {
205
1
        return(GX_ALREADY_CREATED);
206
    }
207
208
    /* Check for invalid widget. */
209

193
    if (parent && (parent -> gx_widget_type == 0))
210
    {
211
1
        return(GX_INVALID_WIDGET);
212
    }
213
214
192
    if (string_list)
215
    {
216
        /* Test string length. */
217
6
        for (string_id = 0; string_id < total_rows; string_id++)
218
        {
219
5
            string = &string_list[string_id];
220
5
            if (string -> gx_string_ptr)
221
            {
222
4
                status = _gx_utility_string_length_check(string -> gx_string_ptr, &string_length, string -> gx_string_length);
223
224
4
                if (status != GX_SUCCESS)
225
                {
226
1
                    return status;
227
                }
228
            }
229
            else
230
            {
231
1
                string_length = 0;
232
            }
233
234
4
            if (string_length != string -> gx_string_length)
235
            {
236
1
                return GX_INVALID_STRING_LENGTH;
237
            }
238
        }
239
    }
240
241
190
    status = _gx_string_scroll_wheel_create_ext(wheel, name, parent, total_rows, string_list, style, Id, size);
242
190
    return status;
243
}
244