GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_circular_gauge_create.c Lines: 17 17 100.0 %
Date: 2026-03-06 19:21:09 Branches: 4 4 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
/**   Circular Gauge Management (Circular Gauge)                          */
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
#include "gx_icon.h"
30
#include "gx_window.h"
31
#include "gx_system.h"
32
#include "gx_circular_gauge.h"
33
34
35
/**************************************************************************/
36
/*                                                                        */
37
/*  FUNCTION                                               RELEASE        */
38
/*                                                                        */
39
/*    _gx_circular_gauge_create                           PORTABLE C      */
40
/*                                                           6.1.10       */
41
/*  AUTHOR                                                                */
42
/*                                                                        */
43
/*    Kenneth Maxwell, Microsoft Corporation                              */
44
/*                                                                        */
45
/*  DESCRIPTION                                                           */
46
/*                                                                        */
47
/*    This functon creates a circular gauge with the specified properties.*/
48
/*                                                                        */
49
/*  INPUT                                                                 */
50
/*                                                                        */
51
/*    gauge                                 Pointer to circular gauge     */
52
/*                                            control block               */
53
/*    name                                  Logical name of circular gauge*/
54
/*                                            widget                      */
55
/*    parent                                Pointer to the parent widget  */
56
/*    info                                  Pointer to                    */
57
/*                                            GX_CIRCULAR_GAUGE_INFO      */
58
/*                                            structure                   */
59
/*    style                                 Style of circular gauge.      */
60
/*    circular_gauge_id                     Application-defined ID of     */
61
/*                                            circular gauge              */
62
/*    xpos                                  Gauge x-coordinate position   */
63
/*    ypos                                  Gauge y-coordinate position   */
64
/*                                                                        */
65
/*  OUTPUT                                                                */
66
/*                                                                        */
67
/*    status                                Completion status             */
68
/*                                                                        */
69
/*  CALLS                                                                 */
70
/*                                                                        */
71
/*    _gx_widget_create                     Creates a widget.             */
72
/*    _gx_widget_link                       Links a child widget to its   */
73
/*                                            parent.                     */
74
/*    _gx_circular_gauge_angle_increment_calculate                        */
75
/*                                          Calculate increment angle for */
76
/*                                            each step.                  */
77
/*                                                                        */
78
/*  CALLED BY                                                             */
79
/*                                                                        */
80
/*    Application Code                                                    */
81
/*                                                                        */
82
/**************************************************************************/
83
451
UINT  _gx_circular_gauge_create(GX_CIRCULAR_GAUGE *gauge,
84
                                GX_CONST GX_CHAR *name,
85
                                GX_WIDGET *parent,
86
                                GX_CIRCULAR_GAUGE_INFO *info,
87
                                GX_RESOURCE_ID background_id,
88
                                ULONG style,
89
                                USHORT circular_gauge_id,
90
                                GX_VALUE xpos, GX_VALUE ypos)
91
{
92
    /* Call the widget create function.  */
93
451
    _gx_icon_create((GX_ICON *)gauge, name, GX_NULL, background_id, style, circular_gauge_id, xpos, ypos);
94
95
    /* Populate the rest of gauge control block - overriding as necessary.  */
96
451
    gauge -> gx_widget_type = GX_TYPE_CIRCULAR_GAUGE;
97
98
451
    gauge -> gx_circular_gauge_info = *info;
99
100
451
    if (gauge -> gx_circular_gauge_info.gx_circular_gauge_info_animation_delay <= 0)
101
    {
102
2
        gauge -> gx_circular_gauge_info.gx_circular_gauge_info_animation_delay = GX_DEFAULT_CIRCULAR_GAUGE_ANIMATION_DELAY;
103
    }
104
105
451
    gauge -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_circular_gauge_draw;
106
451
    gauge -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_circular_gauge_event_process;
107
108
    /* Initiate rotate needle pixelmap.  */
109
451
    memset(&gauge -> gx_circular_gauge_needle_rotated, 0, sizeof(GX_PIXELMAP));
110
451
    gauge -> gx_circular_gauge_needle_source = GX_NULL;
111
451
    gauge -> gx_circular_gauge_start_angle = 0;
112
451
    gauge -> gx_circular_gauge_current_angle = 0;
113
451
    gauge -> gx_circular_gauge_target_angle = 0;
114
451
    gauge -> gx_widget_status |= GX_STATUS_RESIZE_NOTIFY;
115
116
    /* Determine if a parent widget was provided.  */
117
451
    if (parent)
118
    {
119
449
        _gx_widget_link(parent, (GX_WIDGET *)gauge);
120
    }
121
122
    /* Return completion status. */
123
451
    return(GX_SUCCESS);
124
}
125