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