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_window.h"
29 #include "gx_system.h"
30 #include "gx_drop_list.h"
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_drop_list_open                                  PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This service opens a drop list.                                     */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    drop_list                             Drop list control block       */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    status                                Completion status             */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    _gx_window_root_find                  Find the root window          */
57 /*    _gx_widget_resize                     Resize a widget               */
58 /*    _gx_vertical_list_children_position   Position the children for     */
59 /*                                          the vertical list             */
60 /*    _gx_widget_link                       Link the widget to its root   */
61 /*    _gx_system_focus_claim                Claim the input focus         */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    _gx_drop_list_event_process                                         */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
72 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
73 /*                                            resulting in version 6.1    */
74 /*                                                                        */
75 /**************************************************************************/
_gx_drop_list_open(GX_DROP_LIST * drop_list)76 UINT _gx_drop_list_open(GX_DROP_LIST *drop_list)
77 {
78 GX_WINDOW_ROOT   *root;
79 GX_WIDGET        *child;
80 GX_RECTANGLE      size;
81 GX_VERTICAL_LIST *list = &drop_list -> gx_drop_list_popup.gx_popup_list_list;
82 
83     if (list -> gx_widget_status & GX_STATUS_VISIBLE)
84     {
85         drop_list -> gx_drop_list_popup_open = GX_TRUE;
86         return(GX_SUCCESS);
87     }
88     _gx_window_root_find((GX_WIDGET *)drop_list, &root);
89 
90     size = drop_list -> gx_widget_size;
91     size.gx_rectangle_top = (GX_VALUE)(size.gx_rectangle_bottom + 1);
92     size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_top + drop_list -> gx_drop_list_open_height);
93     _gx_widget_resize((GX_WIDGET *)list, &size);
94     _gx_vertical_list_children_position(list);
95     _gx_widget_link((GX_WIDGET *)drop_list -> gx_widget_parent, (GX_WIDGET *)list);
96 
97     _gx_vertical_list_selected_widget_get(list, &child);
98     if (child)
99     {
100         child -> gx_widget_style |= GX_STYLE_DRAW_SELECTED;
101     }
102 
103     drop_list -> gx_drop_list_popup_open = GX_TRUE;
104     _gx_system_focus_claim((GX_WIDGET *)list);
105 
106     return(GX_SUCCESS);
107 }
108 
109