GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_font_get.c Lines: 14 14 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
/**   Widget Management (Widget)                                          */
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_font_get                                 PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This service gets the font associated with the specified            */
44
/*    resource ID.                                                        */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    widget                                Widget control block pointer  */
49
/*    resource_id                           Resource ID of font           */
50
/*    return_font                           Pointer to destination for    */
51
/*                                            font pointer                */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_widget_canvas_get                 Get widget canvas pointer     */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    Application Code                                                    */
64
/*    GUIX default drawing functions                                      */
65
/*                                                                        */
66
/**************************************************************************/
67
197012
UINT  _gx_widget_font_get(GX_WIDGET *widget, GX_RESOURCE_ID resource_id, GX_FONT **return_font)
68
{
69
197012
GX_FONT       *font = GX_NULL;
70
197012
UINT           status = GX_INVALID_CANVAS;
71
72
GX_CANVAS     *canvas;
73
GX_DISPLAY    *display;
74
GX_RESOURCE_ID font_table_size;
75
76
197012
    if (widget -> gx_widget_status & GX_STATUS_VISIBLE)
77
    {
78
196706
        _gx_widget_canvas_get(widget, &canvas);
79
80
196706
        if (canvas)
81
        {
82
196705
            display = canvas -> gx_canvas_display;
83
84
            /* Pickup the font table size.  */
85
196705
            font_table_size =  display -> gx_display_font_table_size;
86
87
            /* Determine if the ID is within range.  */
88
196705
            if (resource_id < font_table_size)
89
            {
90
                /* Yes, the ID is within range. Perform a table lookup and return the
91
                   font poiner.  */
92
196592
                font = display -> gx_display_font_table[resource_id];
93
196592
                status = GX_SUCCESS;
94
            }
95
            else
96
            {
97
113
                status = GX_INVALID_RESOURCE_ID;
98
            }
99
        }
100
    }
101
197012
    *return_font = font;
102
197012
    return(status);
103
}
104