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 /**   Text 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_display.h"
30 #include "gx_context.h"
31 #include "gx_widget.h"
32 #include "gx_button.h"
33 
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _gx_text_button_text_draw                           PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    Kenneth Maxwell, Microsoft Corporation                              */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This function draws the button text                                 */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    button                                Text button control block     */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    None                                                                */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _gx_widget_text_id_draw               Draw text using resource ID   */
59 /*    _gx_widget_text_draw                  Draw text string              */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application Code                                                    */
64 /*    GUIX Internal 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 /*                                            improved logic,             */
73 /*                                            resulting in version 6.1    */
74 
75 /*                                                                        */
76 /**************************************************************************/
_gx_text_button_text_draw(GX_TEXT_BUTTON * button)77 VOID  _gx_text_button_text_draw(GX_TEXT_BUTTON *button)
78 {
79 GX_WIDGET     *widget;
80 INT            xtextoffset = 0;
81 INT            ytextoffset = 0;
82 GX_RESOURCE_ID color;
83 GX_STRING      string;
84 
85     /* Setup the button.  */
86     widget = (GX_WIDGET *)button;
87 
88     /* draw the text */
89 
90     if (widget -> gx_widget_style & GX_STYLE_ENABLED)
91     {
92         if (widget -> gx_widget_style & GX_STYLE_BUTTON_PUSHED)
93         {
94             xtextoffset = ytextoffset = 1;
95             color = button -> gx_text_button_selected_text_color;
96         }
97         else
98         {
99             color = button -> gx_text_button_normal_text_color;
100         }
101     }
102     else
103     {
104         color = button -> gx_text_button_disabled_text_color;
105     }
106 
107     _gx_text_button_text_get_ext(button, &string);
108 
109     if (string.gx_string_ptr)
110     {
111         _gx_widget_text_draw_ext(widget, color,
112                                  button -> gx_text_button_font_id,
113                                  &string, xtextoffset, ytextoffset);
114     }
115 }
116 
117