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 /** Drop List (List) */
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_system.h"
29 #include "gx_drop_list.h"
30 #include "gx_window.h"
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _gx_drop_list_create PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Kenneth Maxwell, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This service creates a drop list. */
45 /* */
46 /* INPUT */
47 /* */
48 /* drop_list Drop list control block */
49 /* name Name of drop list */
50 /* parent Pointer to parent widget */
51 /* total_rows Total number of rows in */
52 /* drop list */
53 /* open_height Height of the vertical list */
54 /* callback function called to create */
55 /* new widgets when the list */
56 /* is scrolled. */
57 /* style Style of drop list */
58 /* drop_list_id Application-defined ID of */
59 /* the drop list */
60 /* size Dimensions of the drop list */
61 /* */
62 /* OUTPUT */
63 /* */
64 /* status Completion status */
65 /* */
66 /* CALLS */
67 /* */
68 /* _gx_widget_create Create the underlying widget */
69 /* memset Clear the memory block */
70 /* _gx_vertical_list_create Create the underlying */
71 /* vertical list */
72 /* _gx_widget_link Link the widget to its parent */
73 /* */
74 /* CALLED BY */
75 /* */
76 /* Application Code */
77 /* */
78 /* RELEASE HISTORY */
79 /* */
80 /* DATE NAME DESCRIPTION */
81 /* */
82 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
83 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
84 /* resulting in version 6.1 */
85 /* */
86 /**************************************************************************/
_gx_drop_list_create(GX_DROP_LIST * drop_list,GX_CONST GX_CHAR * name,GX_WIDGET * parent,INT total_rows,INT open_height,VOID (* callback)(GX_VERTICAL_LIST *,GX_WIDGET *,INT),ULONG style,USHORT drop_list_id,GX_CONST GX_RECTANGLE * size)87 UINT _gx_drop_list_create(GX_DROP_LIST *drop_list, GX_CONST GX_CHAR *name,
88 GX_WIDGET *parent, INT total_rows, INT open_height,
89 VOID (*callback)(GX_VERTICAL_LIST *, GX_WIDGET *, INT),
90 ULONG style, USHORT drop_list_id,
91 GX_CONST GX_RECTANGLE *size)
92 {
93 GX_VERTICAL_LIST *list;
94
95 /* the drop list should not have enabled style */
96 style &= ~GX_STYLE_ENABLED;
97
98 /* Call the widget create function. */
99 _gx_widget_create((GX_WIDGET *)drop_list, name, GX_NULL, style, drop_list_id, size);
100
101 drop_list -> gx_widget_type = GX_TYPE_DROP_LIST;
102 drop_list -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_drop_list_event_process;
103 drop_list -> gx_drop_list_open_height = open_height;
104 drop_list -> gx_drop_list_pixelmap = 0;
105 drop_list -> gx_drop_list_popup_open = GX_FALSE;
106 drop_list -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_drop_list_draw;
107 drop_list -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_drop_list_event_process;
108 drop_list -> gx_widget_disabled_fill_color = drop_list -> gx_widget_normal_fill_color;
109
110 /* create the drop-down list, which is a modified vertical list */
111 list = &drop_list -> gx_drop_list_popup.gx_popup_list_list;
112
113 _gx_vertical_list_create(list, name, GX_NULL, total_rows, callback, style, drop_list_id, size);
114 list -> gx_widget_type = GX_TYPE_POPUP_LIST;
115 list -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_popup_list_event_process;
116 drop_list -> gx_drop_list_popup.gx_popup_list_owner = (GX_WIDGET *)drop_list;
117
118 /* Determine if a parent widget was provided. */
119 if (parent)
120 {
121 _gx_widget_link(parent, (GX_WIDGET *)drop_list);
122 }
123
124 /* Return completion status. */
125 return(GX_SUCCESS);
126 }
127
128