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 /**   Vertical 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_window.h"
29 #include "gx_system.h"
30 #include "gx_scrollbar.h"
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_vetical_list_create                             PORTABLE C      */
37 /*                                                           6.1.10       */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This service creates a vertical list.                               */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    vertical_list                         Vertical list control block   */
49 /*    name                                  Name of vertical list         */
50 /*    parent                                Pointer to parent widget      */
51 /*    total_rows                            Total number of rows in       */
52 /*                                            vertical list               */
53 /*    callback                              User-specified Callback       */
54 /*                                            function                    */
55 /*    style                                 Style of scrollbar widget     */
56 /*    vertical_list_id                      Application-defined ID of     */
57 /*                                            vertical list               */
58 /*    size                                  Dimensions of vertical list   */
59 /*                                                                        */
60 /*  OUTPUT                                                                */
61 /*                                                                        */
62 /*    status                                Completion status             */
63 /*                                                                        */
64 /*  CALLS                                                                 */
65 /*                                                                        */
66 /*    _gx_window_create                     Create the underlying window  */
67 /*    _gx_widget_link                       Link the widget to its parent */
68 /*                                                                        */
69 /*  CALLED BY                                                             */
70 /*                                                                        */
71 /*    Application Code                                                    */
72 /*                                                                        */
73 /*  RELEASE HISTORY                                                       */
74 /*                                                                        */
75 /*    DATE              NAME                      DESCRIPTION             */
76 /*                                                                        */
77 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
78 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
79 /*                                            resulting in version 6.1    */
80 /*  01-31-2022     Ting Zhu                 Modified comment(s),          */
81 /*                                            initialized new vertical    */
82 /*                                            list control block member,  */
83 /*                                            resulting in version 6.1.10 */
84 /*                                                                        */
85 /**************************************************************************/
_gx_vertical_list_create(GX_VERTICAL_LIST * vertical_list,GX_CONST GX_CHAR * name,GX_WIDGET * parent,INT total_rows,VOID (* callback)(GX_VERTICAL_LIST *,GX_WIDGET *,INT),ULONG style,USHORT vertical_list_id,GX_CONST GX_RECTANGLE * size)86 UINT  _gx_vertical_list_create(GX_VERTICAL_LIST *vertical_list,
87                                GX_CONST GX_CHAR *name,
88                                GX_WIDGET *parent, INT total_rows,
89                                VOID (*callback)(GX_VERTICAL_LIST *, GX_WIDGET *, INT),
90                                ULONG style, USHORT vertical_list_id,
91                                GX_CONST GX_RECTANGLE *size)
92 {
93 
94     /* Call the widget create function.  */
95     _gx_window_create((GX_WINDOW *)vertical_list, name, GX_NULL, style, vertical_list_id, size);
96 
97     vertical_list -> gx_widget_type =       GX_TYPE_VERTICAL_LIST;
98     vertical_list -> gx_widget_status |=    GX_STATUS_NAV_PARENT;
99     vertical_list -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_vertical_list_event_process;
100 
101     vertical_list -> gx_vertical_list_total_rows = total_rows;
102     vertical_list -> gx_vertical_list_top_index = 0;
103     vertical_list -> gx_vertical_list_pen_index = -1;
104     vertical_list -> gx_vertical_list_child_height = 1;
105     vertical_list -> gx_vertical_list_selected = 0;
106     vertical_list -> gx_vertical_list_callback = callback;
107     vertical_list -> gx_vertical_list_visible_rows = 0;
108     vertical_list -> gx_vertical_list_child_count = 0;
109     vertical_list -> gx_window_scroll_info_get = (VOID (*)(struct GX_WINDOW_STRUCT *, ULONG, GX_SCROLL_INFO *))_gx_vertical_list_scroll_info_get;
110     vertical_list -> gx_vertical_list_idle_child_list = GX_NULL;
111 
112     /* Determine if a parent widget was provided.  */
113     if (parent)
114     {
115         _gx_widget_link((GX_WIDGET *)parent, (GX_WIDGET *)vertical_list);
116     }
117 
118     /* Return completion status.  */
119     return(GX_SUCCESS);
120 }
121 
122