GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_monochrome_driver_disabled_button_line_draw.c Lines: 13 13 100.0 %
Date: 2024-12-05 08:52:37 Branches: 2 2 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
/**   Button Management (Button)                                          */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_button.h"
28
#include "gx_system.h"
29
#include "gx_widget.h"
30
#include "gx_context.h"
31
#include "gx_canvas.h"
32
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gx_monochrome_driver_disabled_button_line_draw     PORTABLE C      */
39
/*                                                           6.1          */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    Kenneth Maxwell, Microsoft Corporation                              */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This function draws a line over button text to indicate the         */
47
/*    button is disabled. Used only for monochrome format.                */
48
/*                                                                        */
49
/*  INPUT                                                                 */
50
/*                                                                        */
51
/*    button                                Button control block          */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    None                                                                */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_context_raw_line_color_set      Set raw line color              */
60
/*    _gx_context_color_get               Get color associated with the   */
61
/*                                           supplied color id            */
62
/*    _gx_context_brush_width_set         Set brush width                 */
63
/*    _gx_canvas_line_draw                Draw a line                     */
64
/*                                                                        */
65
/*  CALLED BY                                                             */
66
/*                                                                        */
67
/*    _gx_text_button_draw                                                */
68
/*    _gx_multi_line_text_button_draw                                     */
69
/*                                                                        */
70
/*  RELEASE HISTORY                                                       */
71
/*                                                                        */
72
/*    DATE              NAME                      DESCRIPTION             */
73
/*                                                                        */
74
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
75
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
76
/*                                            resulting in version 6.1    */
77
/*                                                                        */
78
/**************************************************************************/
79
103
VOID  _gx_monochrome_driver_disabled_button_line_draw(GX_BUTTON *button)
80
{
81
GX_CANVAS *canvas;
82
INT        display_format;
83
GX_VALUE   start;
84
GX_VALUE   end;
85
GX_VALUE   yval;
86
GX_COLOR   line_color;
87
88
89
103
    canvas = _gx_system_current_draw_context -> gx_draw_context_canvas;
90
103
    display_format = canvas -> gx_canvas_display -> gx_display_color_format;
91
92
103
    if (display_format != GX_COLOR_FORMAT_MONOCHROME)
93
    {
94
61
        return;
95
    }
96
97
    /* Get fill color; */
98
42
    _gx_context_color_get(button -> gx_widget_normal_fill_color, &line_color);
99
100
    /* Set line color. */
101
42
    line_color = ~line_color;
102
103
42
    _gx_context_raw_line_color_set(line_color);
104
105
42
    _gx_context_brush_width_set(2);
106
107
108
42
    start = (GX_VALUE)(button -> gx_widget_size.gx_rectangle_left + 5);
109
42
    end = (GX_VALUE)(button -> gx_widget_size.gx_rectangle_right - 5);
110
42
    yval = (GX_VALUE)((button -> gx_widget_size.gx_rectangle_top + button -> gx_widget_size.gx_rectangle_bottom) >> 1);
111
112
42
    _gx_canvas_line_draw((GX_VALUE)start, (GX_VALUE)yval, (GX_VALUE)end, (GX_VALUE)yval);
113
}
114