1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** GUIX Component                                                        */
17 /**                                                                       */
18 /**   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_utility.h"
31 
32 /* Bring in externs for caller checking code.  */
33 GX_CALLER_CHECKING_EXTERNS
34 
35 
36 /**************************************************************************/
37 /*                                                                        */
38 /*  FUNCTION                                               RELEASE        */
39 /*                                                                        */
40 /*    _gxe_multi_line_text_button_text_set                PORTABLE C      */
41 /*                                                           6.1          */
42 /*  AUTHOR                                                                */
43 /*                                                                        */
44 /*    Kenneth Maxwell, Microsoft Corporation                              */
45 /*                                                                        */
46 /*  DESCRIPTION                                                           */
47 /*                                                                        */
48 /*    This function checks for errors in the text assigment.              */
49 /*                                                                        */
50 /*  INPUT                                                                 */
51 /*                                                                        */
52 /*    button                                Pointer to the button         */
53 /*                                            control block               */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    status                                Completion status             */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    _gx_multi_line_text_button_text_set   Actual text assignment        */
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)
_gxe_multi_line_text_button_text_set(GX_MULTI_LINE_TEXT_BUTTON * button,GX_CONST GX_CHAR * text)76 UINT  _gxe_multi_line_text_button_text_set(GX_MULTI_LINE_TEXT_BUTTON *button,
77                                            GX_CONST GX_CHAR *text)
78 {
79 UINT status;
80 
81     /* Check for appropriate caller.  */
82     GX_INIT_AND_THREADS_CALLER_CHECKING
83 
84     /* Check for invalid input pointers.  */
85     if (button == GX_NULL)
86     {
87         return(GX_PTR_ERROR);
88     }
89 
90     /* Call the actual button draw function.  */
91     status = _gx_multi_line_text_button_text_set(button, text);
92 
93     /* Return completion status.  */
94     return status;
95 }
96 #endif
97 
98 /**************************************************************************/
99 /*                                                                        */
100 /*  FUNCTION                                               RELEASE        */
101 /*                                                                        */
102 /*    _gxe_multi_line_text_button_text_set_ext            PORTABLE C      */
103 /*                                                           6.1          */
104 /*  AUTHOR                                                                */
105 /*                                                                        */
106 /*    Kenneth Maxwell, Microsoft Corporation                              */
107 /*                                                                        */
108 /*  DESCRIPTION                                                           */
109 /*                                                                        */
110 /*    This function checks for errors in the text assigment.              */
111 /*                                                                        */
112 /*  INPUT                                                                 */
113 /*                                                                        */
114 /*    button                                Pointer to the button         */
115 /*                                            control block               */
116 /*    text                                  Text to be set                */
117 /*                                                                        */
118 /*  OUTPUT                                                                */
119 /*                                                                        */
120 /*    status                                Completion status             */
121 /*                                                                        */
122 /*  CALLS                                                                 */
123 /*                                                                        */
124 /*    _gx_multi_line_text_button_text_set_ext                             */
125 /*                                          Actual text assignment        */
126 /*                                                                        */
127 /*  CALLED BY                                                             */
128 /*                                                                        */
129 /*    Application Code                                                    */
130 /*                                                                        */
131 /*  RELEASE HISTORY                                                       */
132 /*                                                                        */
133 /*    DATE              NAME                      DESCRIPTION             */
134 /*                                                                        */
135 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
136 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
137 /*                                            resulting in version 6.1    */
138 /*                                                                        */
139 /**************************************************************************/
_gxe_multi_line_text_button_text_set_ext(GX_MULTI_LINE_TEXT_BUTTON * button,GX_CONST GX_STRING * text)140 UINT _gxe_multi_line_text_button_text_set_ext(GX_MULTI_LINE_TEXT_BUTTON *button, GX_CONST GX_STRING *text)
141 {
142 UINT status;
143 UINT text_length = 0;
144 
145     /* Check for appropriate caller.  */
146     GX_INIT_AND_THREADS_CALLER_CHECKING
147 
148     /* Check for invalid input pointers.  */
149     if (button == GX_NULL)
150     {
151         return(GX_PTR_ERROR);
152     }
153 
154     if (text)
155     {
156         if (text -> gx_string_ptr)
157         {
158             status = _gx_utility_string_length_check(text -> gx_string_ptr, &text_length, text -> gx_string_length);
159 
160             if (status != GX_SUCCESS)
161             {
162                 return status;
163             }
164         }
165 
166         if (text_length != text -> gx_string_length)
167         {
168             return GX_INVALID_STRING_LENGTH;
169         }
170     }
171 
172     /* Call the actual button draw function.  */
173     status = _gx_multi_line_text_button_text_set_ext(button, text);
174 
175     /* Return completion status.  */
176     return status;
177 }
178 
179