GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_menu_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
/**   Menu Management (Menu)                                              */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_menu.h"
29
#include "gx_pixelmap_prompt.h"
30
#include "gx_widget.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_menu_create                                     PORTABLE C      */
37
/*                                                           6.1.3        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function creates an menu widget.                               */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    menu                                  Pointer to the menu control   */
49
/*                                            block                       */
50
/*    name                                  Name of the menu              */
51
/*    parent                                Parent control block          */
52
/*    text_id                               String id of menu text        */
53
/*    fill_id                               Pixelmap id for fill area     */
54
/*    style                                 Style of the widget           */
55
/*    menu_id                               Application-defined ID of     */
56
/*                                          the menu                      */
57
/*    size                                  Menu size                     */
58
/*                                                                        */
59
/*  OUTPUT                                                                */
60
/*                                                                        */
61
/*    status                                Completion status             */
62
/*                                                                        */
63
/*  CALLS                                                                 */
64
/*                                                                        */
65
/*    _gx_pixelmap_prompt_create            Create a pixelmap prompt      */
66
/*    _gx_widget_create                     Create a widget               */
67
/*    _gx_widget_link                       Link a child widget to its    */
68
/*                                            parent                      */
69
/*                                                                        */
70
/*  CALLED BY                                                             */
71
/*                                                                        */
72
/*    Application Code                                                    */
73
/*                                                                        */
74
/**************************************************************************/
75
11852
UINT  _gx_menu_create(GX_MENU *menu, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
76
                      GX_RESOURCE_ID text_id, GX_RESOURCE_ID fill_id,
77
                      ULONG style, USHORT menu_id, GX_CONST GX_RECTANGLE *size)
78
{
79
80
    /* Call the widget create function.  */
81
11852
    _gx_pixelmap_prompt_create((GX_PIXELMAP_PROMPT *)menu, name, GX_NULL, text_id, fill_id, style, menu_id, size);
82
83
    /* Populate the rest of menu control block - overriding as necessary.  */
84
11852
    menu -> gx_widget_type = GX_TYPE_MENU;
85
11852
    menu -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_menu_draw;
86
11852
    menu -> gx_widget_event_process_function = (UINT(*)(GX_WIDGET*, GX_EVENT*))_gx_menu_event_process;
87
11852
    menu -> gx_widget_style |= GX_STYLE_ENABLED;
88
11852
    menu -> gx_menu_text_x_offset = 10;
89
11852
    menu -> gx_menu_text_y_offset = 0;
90
11852
    menu -> gx_menu_list_total_count = 0;
91
92
11852
    if (!(menu -> gx_widget_style & GX_STYLE_TEXT_ALIGNMENT_MASK))
93
    {
94
4
        menu -> gx_widget_style |= GX_STYLE_TEXT_LEFT;
95
    }
96
97
    /* create the menu list */
98
11852
    _gx_widget_create((GX_WIDGET *)&menu -> gx_menu_list, "menu_list", GX_NULL, GX_STYLE_TRANSPARENT, menu_id, size);
99
100
11852
    menu -> gx_menu_list.gx_widget_type = GX_TYPE_MENU_LIST;
101
11852
    menu -> gx_menu_list.gx_menu_list_owner = (GX_WIDGET *)menu;
102
103
    /* Determine if a parent widget was provided.  */
104
11852
    if (parent)
105
    {
106
11850
        _gx_widget_link(parent, (GX_WIDGET *)menu);
107
    }
108
109
    /* Return completion status code. */
110
11852
    return(GX_SUCCESS);
111
}
112