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