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