GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_button_create.c Lines: 13 13 100.0 %
Date: 2024-12-05 08:52:37 Branches: 2 2 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
/**   Button Management (Button)                                          */
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_button.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_button_create                                   PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function creates a vector button, which is a special type of   */
44
/*    prompt (widget).                                                    */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    button                                Pointer to button control     */
49
/*                                            block                       */
50
/*    name                                  Logical name of button        */
51
/*    parent                                Pointer to parent widget      */
52
/*                                            of button                   */
53
/*    style                                 Button stuyle                 */
54
/*    button_id                             Application-defined ID of     */
55
/*                                             the button                 */
56
/*    size                                  Size of the button            */
57
/*                                                                        */
58
/*  OUTPUT                                                                */
59
/*                                                                        */
60
/*    status                                Completion status             */
61
/*                                                                        */
62
/*  CALLS                                                                 */
63
/*                                                                        */
64
/*    _gx_widget_create                     Create the underlying prompt  */
65
/*    _gx_widget_status_add                 Set the widget status         */
66
/*    _gx_widget_link                       Link the widget to its parent */
67
/*                                                                        */
68
/*  CALLED BY                                                             */
69
/*                                                                        */
70
/*    Application Code                                                    */
71
/*    _gx_horizontal_scrollbar_create                                     */
72
/*    _gx_icon_button_create                                              */
73
/*    _gx_pixelmap_button_create                                          */
74
/*    _gx_scroll_thumb_create                                             */
75
/*    _gx_text_button_create                                              */
76
/*    _gx_vertical_scrollbar_create                                       */
77
/*    _gx_scroll_thumb_create                                             */
78
/*    _gx_text_button_create                                              */
79
/*                                                                        */
80
/*  RELEASE HISTORY                                                       */
81
/*                                                                        */
82
/*    DATE              NAME                      DESCRIPTION             */
83
/*                                                                        */
84
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
85
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
86
/*                                            fixed compiler warnings,    */
87
/*                                            resulting in version 6.1    */
88
/*                                                                        */
89
/**************************************************************************/
90
30787
UINT  _gx_button_create(GX_BUTTON *button, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
91
                        ULONG style, USHORT button_id, GX_CONST GX_RECTANGLE *size)
92
{
93
94
    /* Call the widget create function.  */
95
30787
    _gx_widget_create((GX_WIDGET *)button, name, GX_NULL, style, button_id, size);
96
97
    /* Check for completion status on the prompt create.  */
98
    /* Yes, the prompt widget was created successfully.  Populate the rest of
99
       button control block - overriding as necessary.  */
100
30787
    button -> gx_widget_type = GX_TYPE_BUTTON;
101
102
30787
    _gx_widget_status_add((GX_WIDGET *)button, GX_STATUS_BUTTON_DERIVED);
103
104
30787
    button -> gx_button_select_handler = (VOID (*)(GX_WIDGET *))(void (*)(void))_gx_button_select;
105
30787
    button -> gx_button_deselect_handler = (VOID (*)(GX_WIDGET *, GX_BOOL))(void (*)(void))_gx_button_deselect;
106
30787
    button -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_button_draw;
107
30787
    button -> gx_widget_event_process_function =  (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_button_event_process;
108
30787
    button -> gx_widget_normal_fill_color =       GX_COLOR_ID_BUTTON_LOWER;
109
30787
    button -> gx_widget_selected_fill_color =     GX_COLOR_ID_BUTTON_UPPER;
110
111
    /* Determine if a parent widget was provided.  */
112
30787
    if (parent)
113
    {
114
5582
        _gx_widget_link(parent, (GX_WIDGET *)button);
115
    }
116
117
    /* Return the completion status code */
118
30787
    return(GX_SUCCESS);
119
}
120