GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_text_button_text_draw.c Lines: 15 15 100.0 %
Date: 2026-03-06 19:21:09 Branches: 6 6 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
/**   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
/**************************************************************************/
67
87299
VOID  _gx_text_button_text_draw(GX_TEXT_BUTTON *button)
68
{
69
GX_WIDGET     *widget;
70
87299
INT            xtextoffset = 0;
71
87299
INT            ytextoffset = 0;
72
GX_RESOURCE_ID color;
73
GX_STRING      string;
74
75
    /* Setup the button.  */
76
87299
    widget = (GX_WIDGET *)button;
77
78
    /* draw the text */
79
80
87299
    if (widget -> gx_widget_style & GX_STYLE_ENABLED)
81
    {
82
87220
        if (widget -> gx_widget_style & GX_STYLE_BUTTON_PUSHED)
83
        {
84
42
            xtextoffset = ytextoffset = 1;
85
42
            color = button -> gx_text_button_selected_text_color;
86
        }
87
        else
88
        {
89
87178
            color = button -> gx_text_button_normal_text_color;
90
        }
91
    }
92
    else
93
    {
94
79
        color = button -> gx_text_button_disabled_text_color;
95
    }
96
97
87299
    _gx_text_button_text_get_ext(button, &string);
98
99
87299
    if (string.gx_string_ptr)
100
    {
101
87288
        _gx_widget_text_draw_ext(widget, color,
102
87288
                                 button -> gx_text_button_font_id,
103
                                 &string, xtextoffset, ytextoffset);
104
    }
105
87299
}
106