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