GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_pixelmap_prompt_background_draw.c Lines: 35 35 100.0 %
Date: 2024-12-05 08:52:37 Branches: 24 24 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
/**   Pixelmap Prompt Management (Prompt)                                 */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_system.h"
28
#include "gx_canvas.h"
29
#include "gx_context.h"
30
#include "gx_widget.h"
31
#include "gx_prompt.h"
32
#include "gx_pixelmap_prompt.h"
33
34
35
/**************************************************************************/
36
/*                                                                        */
37
/*  FUNCTION                                               RELEASE        */
38
/*                                                                        */
39
/*    _gx_pixelmap_prompt_background_draw                 PORTABLE C      */
40
/*                                                           6.1          */
41
/*  AUTHOR                                                                */
42
/*                                                                        */
43
/*    Kenneth Maxwell, Microsoft Corporation                              */
44
/*                                                                        */
45
/*  DESCRIPTION                                                           */
46
/*                                                                        */
47
/*    This function draws the background of a pixelmap prompt widget.     */
48
/*                                                                        */
49
/*  INPUT                                                                 */
50
/*                                                                        */
51
/*    prompt                                Pixelmap prompt control block */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    None                                                                */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_widget_background_draw            Draw the widget's background  */
60
/*    _gx_context_pixelmap_get              Retrieve pixelmap image       */
61
/*    _gx_canvas_pixelmap_draw              Draw a pixelmap               */
62
/*    _gx_canvas_pixelmap_tile              Tile a pixelmap               */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    Application Code                                                    */
67
/*    GUIX Internal Code                                                  */
68
/*                                                                        */
69
/*  RELEASE HISTORY                                                       */
70
/*                                                                        */
71
/*    DATE              NAME                      DESCRIPTION             */
72
/*                                                                        */
73
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
74
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
75
/*                                            resulting in version 6.1    */
76
/*                                                                        */
77
/**************************************************************************/
78
19057
VOID  _gx_pixelmap_prompt_background_draw(GX_PIXELMAP_PROMPT *prompt)
79
{
80
19057
GX_WIDGET     *widget = (GX_WIDGET *)prompt;
81
19057
GX_RECTANGLE   fill_rect = widget -> gx_widget_size;
82
GX_PIXELMAP   *map;
83
GX_RESOURCE_ID fill_id;
84
GX_RESOURCE_ID left_id;
85
GX_RESOURCE_ID right_id;
86
87
88
19057
    fill_id = prompt -> gx_normal_fill_pixelmap_id;
89
19057
    left_id = prompt -> gx_normal_left_pixelmap_id;
90
19057
    right_id = prompt -> gx_normal_right_pixelmap_id;
91
92
19057
    if (prompt -> gx_widget_style & GX_STYLE_DRAW_SELECTED)
93
    {
94
79
        if (prompt -> gx_selected_fill_pixelmap_id)
95
        {
96
3
            fill_id = prompt -> gx_selected_fill_pixelmap_id;
97
        }
98
79
        if (prompt -> gx_selected_left_pixelmap_id)
99
        {
100
3
            left_id = prompt -> gx_selected_left_pixelmap_id;
101
        }
102
79
        if (prompt -> gx_selected_right_pixelmap_id)
103
        {
104
3
            right_id = prompt -> gx_selected_right_pixelmap_id;
105
        }
106
    }
107
108
109
    /* draw the background */
110
19057
    if (fill_id == 0 &&
111
10198
        !(prompt -> gx_widget_style & GX_STYLE_TRANSPARENT))
112
    {
113
927
        _gx_widget_background_draw(widget);
114
    }
115
116
    /* draw the left-end pixelmap if one was provided */
117
19057
    if (left_id)
118
    {
119
15014
        _gx_context_pixelmap_get(left_id, &map);
120
15014
        if (map)
121
        {
122
15013
            _gx_widget_context_fill_set(widget);
123
15013
            _gx_canvas_pixelmap_draw(fill_rect.gx_rectangle_left,
124
15013
                                     fill_rect.gx_rectangle_top, map);
125
15013
            fill_rect.gx_rectangle_left = (GX_VALUE)(fill_rect.gx_rectangle_left + map -> gx_pixelmap_width);
126
        }
127
    }
128
129
    /* draw the right end pixelmap, if one was provided */
130
19057
    if (right_id)
131
    {
132
7175
        _gx_context_pixelmap_get(right_id, &map);
133
7175
        if (map)
134
        {
135
7174
            _gx_widget_context_fill_set(widget);
136
7174
            _gx_canvas_pixelmap_draw((GX_VALUE)(fill_rect.gx_rectangle_right - map -> gx_pixelmap_width + 1),
137
7174
                                     fill_rect.gx_rectangle_top, map);
138
7174
            fill_rect.gx_rectangle_right = (GX_VALUE)(fill_rect.gx_rectangle_right - map -> gx_pixelmap_width);
139
        }
140
    }
141
142
    /* now fill the remaining area with the fill pixelmap */
143
19057
    if (fill_id)
144
    {
145
8859
        _gx_context_pixelmap_get(fill_id, &map);
146
8859
        if (map)
147
        {
148
8858
            _gx_canvas_pixelmap_tile(&fill_rect, map);
149
        }
150
    }
151
19057
}
152