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_system.h"
29 #include "gx_widget.h"
30 #include "gx_utility.h"
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _gx_string_scroll_wheel_text_get PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Kenneth Maxwell, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION (Deprecated) */
43 /* */
44 /* This function returns pointer into string list. */
45 /* */
46 /* INPUT */
47 /* */
48 /* wheel Scroll wheel control block */
49 /* row desired text row */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* status Completion status */
54 /* */
55 /* CALLS */
56 /* */
57 /* _gx_system_string_get Retrieve string by ID */
58 /* _gx_system_private_string_get Retrieve string pointer in */
59 /* dynamically copied string buffer */
60 /* */
61 /* CALLED BY */
62 /* */
63 /* _gx_text_scroll_wheel_draw */
64 /* */
65 /* RELEASE HISTORY */
66 /* */
67 /* DATE NAME DESCRIPTION */
68 /* */
69 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
70 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
71 /* resulting in version 6.1 */
72 /* */
73 /**************************************************************************/
_gx_string_scroll_wheel_text_get(GX_STRING_SCROLL_WHEEL * wheel,INT row,GX_STRING * string)74 UINT _gx_string_scroll_wheel_text_get(GX_STRING_SCROLL_WHEEL *wheel, INT row, GX_STRING *string)
75 {
76 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
77 GX_CONST GX_CHAR **string_list_deprecated;
78 UINT status = GX_SUCCESS;
79 #endif
80
81 string -> gx_string_ptr = GX_NULL;
82 string -> gx_string_length = 0;
83
84 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
85 if ((wheel -> gx_string_scroll_wheel_string_list_deprecated == GX_NULL &&
86 wheel -> gx_string_scroll_wheel_string_list == GX_NULL &&
87 wheel -> gx_string_scroll_wheel_string_id_list == GX_NULL) ||
88 (row >= wheel -> gx_scroll_wheel_total_rows))
89 {
90 return GX_SUCCESS;
91 }
92 #else
93 if ((wheel -> gx_string_scroll_wheel_string_list == GX_NULL &&
94 wheel -> gx_string_scroll_wheel_string_id_list == GX_NULL) ||
95 row >= wheel -> gx_scroll_wheel_total_rows)
96 {
97 return GX_SUCCESS;
98 }
99 #endif
100
101 if (wheel -> gx_string_scroll_wheel_string_id_list)
102 {
103 _gx_widget_string_get_ext((GX_WIDGET *)wheel, wheel -> gx_string_scroll_wheel_string_id_list[row], string);
104 }
105 else
106 {
107 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
108 if (wheel -> gx_string_scroll_wheel_string_list_deprecated)
109 {
110 _gx_system_private_string_list_get(wheel -> gx_string_scroll_wheel_string_list_deprecated, &string_list_deprecated, wheel -> gx_widget_style);
111 string -> gx_string_ptr = string_list_deprecated[row];
112
113 status = _gx_utility_string_length_check(string -> gx_string_ptr, &string -> gx_string_length, GX_MAX_STRING_LENGTH);
114
115 if (status != GX_SUCCESS)
116 {
117 string -> gx_string_ptr = GX_NULL;
118 string -> gx_string_length = 0;
119 }
120 return status;
121 }
122 #endif
123
124 *string = wheel -> gx_string_scroll_wheel_string_list[row];
125 }
126
127 return GX_SUCCESS;
128 }
129
130