1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
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 /* RELEASE HISTORY */
75 /* */
76 /* DATE NAME DESCRIPTION */
77 /* */
78 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
79 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
80 /* resulting in version 6.1 */
81 /* 12-31-2020 Kenneth Maxwell Modified comment(s), */
82 /* set menu event process, */
83 /* resulting in version 6.1.3 */
84 /* */
85 /**************************************************************************/
_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)86 UINT _gx_menu_create(GX_MENU *menu, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
87 GX_RESOURCE_ID text_id, GX_RESOURCE_ID fill_id,
88 ULONG style, USHORT menu_id, GX_CONST GX_RECTANGLE *size)
89 {
90
91 /* Call the widget create function. */
92 _gx_pixelmap_prompt_create((GX_PIXELMAP_PROMPT *)menu, name, GX_NULL, text_id, fill_id, style, menu_id, size);
93
94 /* Populate the rest of menu control block - overriding as necessary. */
95 menu -> gx_widget_type = GX_TYPE_MENU;
96 menu -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_menu_draw;
97 menu -> gx_widget_event_process_function = (UINT(*)(GX_WIDGET*, GX_EVENT*))_gx_menu_event_process;
98 menu -> gx_widget_style |= GX_STYLE_ENABLED;
99 menu -> gx_menu_text_x_offset = 10;
100 menu -> gx_menu_text_y_offset = 0;
101 menu -> gx_menu_list_total_count = 0;
102
103 if (!(menu -> gx_widget_style & GX_STYLE_TEXT_ALIGNMENT_MASK))
104 {
105 menu -> gx_widget_style |= GX_STYLE_TEXT_LEFT;
106 }
107
108 /* create the menu list */
109 _gx_widget_create((GX_WIDGET *)&menu -> gx_menu_list, "menu_list", GX_NULL, GX_STYLE_TRANSPARENT, menu_id, size);
110
111 menu -> gx_menu_list.gx_widget_type = GX_TYPE_MENU_LIST;
112 menu -> gx_menu_list.gx_menu_list_owner = (GX_WIDGET *)menu;
113
114 /* Determine if a parent widget was provided. */
115 if (parent)
116 {
117 _gx_widget_link(parent, (GX_WIDGET *)menu);
118 }
119
120 /* Return completion status code. */
121 return(GX_SUCCESS);
122 }
123
124