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