GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_color_get.c Lines: 13 13 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
/**   System Management (System)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_widget.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_widget_color_get                                PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This service gets the color associated with the supplied            */
44
/*      resource ID from the system color table.                          */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    widget                                caller identify               */
49
/*    color_id                              Resource ID of color          */
50
/*    return_color                          Pointer to destination for    */
51
/*                                            color                       */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_widget_canvas_get                 Get canvas pointer            */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    Application Code                                                    */
64
/*    GUIX default draw funtions                                          */
65
/*                                                                        */
66
/**************************************************************************/
67
4
UINT _gx_widget_color_get(GX_WIDGET *widget, GX_RESOURCE_ID color_id, GX_COLOR *return_color)
68
{
69
4
UINT        status = GX_INVALID_CANVAS;
70
4
GX_COLOR    colorval = 0;
71
GX_CANVAS  *canvas;
72
GX_DISPLAY *display;
73
74
4
    if (widget -> gx_widget_status & GX_STATUS_VISIBLE)
75
    {
76
3
        _gx_widget_canvas_get(widget, &canvas);
77
78
3
        if (canvas)
79
        {
80
2
            display = canvas -> gx_canvas_display;
81
82
            /* Determine if the ID is within range.  */
83
2
            if (color_id < display -> gx_display_color_table_size)
84
            {
85
                /* Yes, the ID is within range. Perform a table lookup and return the
86
                   color.  */
87
1
                colorval = display -> gx_display_color_table[color_id];
88
1
                status = GX_SUCCESS;
89
            }
90
            else
91
            {
92
1
                status = GX_INVALID_RESOURCE_ID;
93
            }
94
        }
95
    }
96
4
    *return_color = colorval;
97
4
    return(status);
98
}
99