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 /**   Popup 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 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_popup_list_event_process                        PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This service processes an event for the vertical list.              */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    popup_list                            Popup List widget control     */
48 /*                                            block                       */
49 /*    event_ptr                             Pointer to event to process   */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _gx_vertical_list_event_process       Process vertical list events  */
58 /*    [gx_widget_event_process_function]    Widget-specified event        */
59 /*                                            process routine             */
60 /*    _gx_system_dirty_mark                 Mark the widget dirty         */
61 /*                                                                        */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    Application Code                                                    */
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 /**************************************************************************/
76 
_gx_popup_list_event_process(GX_POPUP_LIST * popup_list,GX_EVENT * event_ptr)77 UINT  _gx_popup_list_event_process(GX_POPUP_LIST *popup_list, GX_EVENT *event_ptr)
78 {
79 GX_WIDGET        *owner;
80 GX_EVENT          send_event;
81 
82 GX_VERTICAL_LIST *list = &popup_list -> gx_popup_list_list;
83 
84     owner = popup_list -> gx_popup_list_owner;
85 
86     memset(&send_event, 0, sizeof(GX_EVENT));
87 
88     switch (event_ptr -> gx_event_type)
89     {
90     case GX_EVENT_FOCUS_LOST:
91         send_event.gx_event_type = GX_EVENT_CLOSE_POPUP;
92         owner -> gx_widget_event_process_function(owner, &send_event);
93         break;
94 
95     case GX_EVENT_PEN_UP:
96         /*Only close popup list after click event. If PEN_UP event is following PEN_DRAG, pen index is -1, and list should not be closed.*/
97         if (list -> gx_vertical_list_pen_index >= 0)
98         {
99             send_event.gx_event_type = GX_EVENT_CLOSE_POPUP;
100         }
101         _gx_vertical_list_event_process(list, event_ptr);
102         if (send_event.gx_event_type)
103         {
104             owner->gx_widget_event_process_function(owner, &send_event);
105             _gx_system_dirty_mark(owner);
106         }
107         break;
108 
109     default:
110         _gx_vertical_list_event_process(list, event_ptr);
111     }
112 
113     return 0;
114 }
115 
116