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 
29 /* Bring in externs for caller checking code.  */
30 GX_CALLER_CHECKING_EXTERNS
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gxe_menu_create                                    PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function checks for errors in menu create function call.       */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    menu                                  Pointer to the menu control   */
49 /*                                            block                       */
50 /*    name                                  Name of the menu              */
51 /*    parent                                Parent menu control block     */
52 /*    text_id                               Resource string id            */
53 /*    fill_id                               Pixelmap id for fill area     */
54 /*    style                                 Style of the widget           */
55 /*    menu_id                               Application-defined ID of     */
56 /*                                          the menu menu                 */
57 /*    size                                  Menu size                     */
58 /*    control_block_size                    Control block size            */
59 /*                                                                        */
60 /*  OUTPUT                                                                */
61 /*                                                                        */
62 /*    status                                Completion status             */
63 /*                                                                        */
64 /*  CALLS                                                                 */
65 /*                                                                        */
66 /*    _gx_menu_create                       Actual menu create call       */
67 /*                                                                        */
68 /*  CALLED BY                                                             */
69 /*                                                                        */
70 /*    Application Code                                                    */
71 /*                                                                        */
72 /*  RELEASE HISTORY                                                       */
73 /*                                                                        */
74 /*    DATE              NAME                      DESCRIPTION             */
75 /*                                                                        */
76 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
77 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
78 /*                                            resulting in version 6.1    */
79 /*                                                                        */
80 /**************************************************************************/
_gxe_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,UINT control_block_size)81 UINT  _gxe_menu_create(GX_MENU *menu, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
82                        GX_RESOURCE_ID text_id, GX_RESOURCE_ID fill_id,
83                        ULONG style, USHORT menu_id, GX_CONST GX_RECTANGLE *size, UINT control_block_size)
84 {
85 UINT status;
86 
87     /* Check for appropriate caller.  */
88     GX_INIT_AND_THREADS_CALLER_CHECKING
89 
90     /* Check for invalid input pointers.  */
91     if ((!menu) || (!size))
92     {
93         return(GX_PTR_ERROR);
94     }
95 
96     /* Check for widget already created.  */
97     if (menu -> gx_widget_type != 0)
98     {
99         return(GX_ALREADY_CREATED);
100     }
101 
102     /* Check for invalid control block size. */
103     if (control_block_size != sizeof(GX_MENU))
104     {
105         return(GX_INVALID_SIZE);
106     }
107 
108     /* Call actual menu create function. */
109     status = _gx_menu_create(menu, name, parent, text_id, fill_id, style, menu_id, size);
110 
111     return(status);
112 }
113 
114