GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_checkbox_create.c Lines: 12 12 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 (checkbox)                                        */
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_checkbox_create                                 PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function creates a checkbox, which is a special type of        */
44
/*    button (widget).                                                    */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    checkbox                              Checkbox control block        */
49
/*    name                                  Name of checkbox              */
50
/*    parent                                Parent widget control block   */
51
/*    text_id                               Text resource id              */
52
/*    style                                 Style of checkbox             */
53
/*    checkbox_id                           Checkbox id                   */
54
/*    size                                  Checkbox size                 */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    status                                Completion status             */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    _gx_text_button_create                Create the underlying button  */
63
/*    _gx_widget_link                       Link the widget to its parent */
64
/*                                                                        */
65
/*  CALLED BY                                                             */
66
/*                                                                        */
67
/*    Application Code                                                    */
68
/*                                                                        */
69
/*  RELEASE HISTORY                                                       */
70
/*                                                                        */
71
/*    DATE              NAME                      DESCRIPTION             */
72
/*                                                                        */
73
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
74
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
75
/*                                            fixed compiler warnings,    */
76
/*                                            resulting in version 6.1    */
77
/*                                                                        */
78
/**************************************************************************/
79
3968
UINT  _gx_checkbox_create(GX_CHECKBOX *checkbox, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
80
                          GX_RESOURCE_ID text_id, ULONG style, USHORT checkbox_id,
81
                          GX_CONST GX_RECTANGLE *size)
82
{
83
84
3968
    style |= GX_STYLE_BUTTON_TOGGLE;
85
86
    /* Call the prompt create function.  */
87
3968
    _gx_text_button_create((GX_TEXT_BUTTON *)checkbox, name, GX_NULL, text_id, style, checkbox_id, size);
88
89
    /* Populate the rest of button control block - overriding as necessary.  */
90
3968
    checkbox -> gx_widget_type = GX_TYPE_CHECKBOX;
91
3968
    checkbox -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_checkbox_draw;
92
3968
    checkbox -> gx_button_select_handler = (VOID (*)(GX_WIDGET *))(void (*)(void))_gx_checkbox_select;
93
3968
    checkbox -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_checkbox_event_process;
94
3968
    checkbox -> gx_checkbox_checked_pixelmap_id = GX_PIXELMAP_CHECKBOX_ON_ID;
95
3968
    checkbox -> gx_checkbox_unchecked_pixelmap_id = GX_PIXELMAP_CHECKBOX_OFF_ID;
96
97
    /* Determine if a parent widget was provided.  */
98
3968
    if (parent)
99
    {
100
3967
        _gx_widget_link(parent, (GX_WIDGET *)checkbox);
101
    }
102
103
    /* Return the status from button create.  */
104
3968
    return(GX_SUCCESS);
105
}
106