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 /** Prompt Management (Prompt) */
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_utility.h"
29 #include "gx_prompt.h"
30 #include "gx_system.h"
31 #include "gx_icon.h"
32
33
34 /**************************************************************************/
35 /* */
36 /* FUNCTION RELEASE */
37 /* */
38 /* _gx_icon_create PORTABLE C */
39 /* 6.1 */
40 /* AUTHOR */
41 /* */
42 /* Kenneth Maxwell, Microsoft Corporation */
43 /* */
44 /* DESCRIPTION */
45 /* */
46 /* This function creates a bitmap prompt, which is a special type of */
47 /* widget. */
48 /* */
49 /* INPUT */
50 /* */
51 /* icon Pointer to icon control block */
52 /* name Logical name of icon widget */
53 /* parent Pointer to the parent widget */
54 /* pixelmap_id Resource ID of pixelmap */
55 /* style Style of icon */
56 /* icon_id Application-definedID of icon */
57 /* x Starting x-coordinate position*/
58 /* y Starting y-coordinate position*/
59 /* */
60 /* OUTPUT */
61 /* */
62 /* status Completion status */
63 /* */
64 /* CALLS */
65 /* */
66 /* _gx_utility_rectangle_define Define the icon area */
67 /* _gx_widget_create Create the underlying widget */
68 /* _gx_widget_status_add Set widget status */
69 /* _gx_widget_link Link the widget to its parent */
70 /* */
71 /* CALLED BY */
72 /* */
73 /* Application Code */
74 /* */
75 /* RELEASE HISTORY */
76 /* */
77 /* DATE NAME DESCRIPTION */
78 /* */
79 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
80 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
81 /* resulting in version 6.1 */
82 /* */
83 /**************************************************************************/
_gx_icon_create(GX_ICON * icon,GX_CONST GX_CHAR * name,GX_WIDGET * parent,GX_RESOURCE_ID pixelmap_id,ULONG style,USHORT icon_id,GX_VALUE x,GX_VALUE y)84 UINT _gx_icon_create(GX_ICON *icon, GX_CONST GX_CHAR *name, GX_WIDGET *parent,
85 GX_RESOURCE_ID pixelmap_id, ULONG style, USHORT icon_id,
86 GX_VALUE x, GX_VALUE y)
87 {
88
89 GX_RECTANGLE size;
90
91 _gx_utility_rectangle_define(&size, x, y, (GX_VALUE)(x + 1), (GX_VALUE)(y + 1));
92
93 /* Call the base prompt create function. */
94 _gx_widget_create((GX_WIDGET *)icon, name, GX_NULL, style, icon_id, &size);
95
96 /* Populate the rest of icon control block - overriding as necessary. */
97 icon -> gx_widget_type = GX_TYPE_ICON;
98 icon -> gx_icon_normal_pixelmap = pixelmap_id;
99 icon -> gx_icon_selected_pixelmap = 0;
100 icon -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_icon_event_process;
101 icon -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_icon_draw;
102
103 if (icon_id > 0)
104 {
105 _gx_widget_status_add((GX_WIDGET *)icon, GX_STATUS_SELECTABLE);
106 }
107
108 /* Determine if a parent widget was provided. */
109 if (parent)
110 {
111 _gx_widget_link(parent, (GX_WIDGET *)icon);
112 }
113
114 return(GX_SUCCESS);
115 }
116