GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_drop_list_background_draw.c Lines: 18 18 100.0 %
Date: 2024-12-05 08:52:37 Branches: 6 6 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
/**   Drop List (List)                                                    */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
#include "gx_api.h"
26
#include "gx_widget.h"
27
#include "gx_system.h"
28
#include "gx_drop_list.h"
29
#include "gx_context.h"
30
#include "gx_canvas.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_drop_list_background_draw                       PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function draws the background of drop list, which is a special */
45
/*    type of widget.                                                     */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    drop list                             Drop List control block       */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    None                                                                */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    _gx_widget_border_draw                Draw the border               */
58
/*    _gx_context_pixelmap_get              Retrieve pixelmap image       */
59
/*    _gx_widget_border_width_get           Get the border width          */
60
/*    _gx_widget_client_get                 Find the client area of a     */
61
/*                                            widget                      */
62
/*    _gx_canvas_pixelmap_tile              Tile a pixelmap               */
63
/*    _gx_canvas_pixelmap_draw              Draw a pixelmap               */
64
/*    _gx_widget_background_draw            Draw widget background        */
65
/*                                                                        */
66
/*  CALLED BY                                                             */
67
/*                                                                        */
68
/*    _gx_drop_list_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
6398
VOID  _gx_drop_list_background_draw(GX_DROP_LIST *drop_list)
80
{
81
GX_RESOURCE_ID      pixelmap_id;
82
GX_PIXELMAP        *map;
83
GX_VALUE            xpos;
84
GX_VALUE            ypos;
85
GX_WIDGET          *widget;
86
GX_VALUE            border_width;
87
GX_COLOR            color;
88
GX_RECTANGLE        client;
89
90
6398
    widget = (GX_WIDGET *)drop_list;
91
6398
    map = GX_NULL;
92
6398
    pixelmap_id = drop_list -> gx_drop_list_pixelmap;
93
94
6398
    if (pixelmap_id)
95
    {
96
1409
        _gx_context_pixelmap_get(pixelmap_id, &map);
97
    }
98
99
6398
    if (map)
100
    {
101
1409
        _gx_widget_border_width_get(widget, &border_width);
102
1409
        color = widget -> gx_widget_normal_fill_color;
103
1409
        _gx_widget_border_draw(widget, GX_COLOR_ID_DEFAULT_BORDER, color, color, GX_TRUE);
104
105
1409
        if (drop_list -> gx_widget_style & GX_STYLE_TILE_BACKGROUND)
106
        {
107
1406
            _gx_widget_client_get(widget, border_width, &client);
108
1406
            _gx_canvas_pixelmap_tile(&client, map);
109
        }
110
        else
111
        {
112
3
            xpos = (GX_VALUE)(widget->gx_widget_clip.gx_rectangle_left + border_width + 1);
113
3
            ypos = (GX_VALUE)(widget->gx_widget_clip.gx_rectangle_top + border_width + 1);
114
3
            _gx_canvas_pixelmap_draw(xpos, ypos, map);
115
        }
116
    }
117
    else
118
    {
119
4989
        _gx_widget_background_draw((GX_WIDGET *)drop_list);
120
    }
121
6398
}
122