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 /**   Accordion Menu Management (Menu)                                    */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_menu.h"
29 #include "gx_widget.h"
30 #include "gx_window.h"
31 #include "gx_system.h"
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _gx_accordion_menu_shift_helper                     PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Kenneth Maxwell, Microsoft Corporation                              */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    Internal helper function to shift one accordion menu.               */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    accordion                             Pointer to accordion menu     */
50 /*                                            control block               */
51 /*    animation_target                      Animation target              */
52 /*    shift                                 Shift value                   */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    status                                Completion status             */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    _gx_widget_scroll_shift               Change the widget position    */
61 /*    _gx_widget_resize                     Resize the widget             */
62 /*    _gx_menu_list_shift                   Change the menu list position */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    _gx_accordion_menu_shift_helper                                     */
67 /*                                                                        */
68 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
73 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*                                                                        */
76 /**************************************************************************/
_gx_accordion_menu_shift_helper(GX_ACCORDION_MENU * accordion,GX_WIDGET * animation_target,INT shift)77 static VOID _gx_accordion_menu_shift_helper(GX_ACCORDION_MENU *accordion, GX_WIDGET *animation_target, INT shift)
78 {
79 GX_WIDGET   *child;
80 GX_MENU     *menu;
81 GX_BOOL      shift_start = GX_FALSE;
82 GX_RECTANGLE size;
83 
84     child = accordion -> gx_widget_first_child;
85     while (child)
86     {
87         switch (child -> gx_widget_type)
88         {
89         case GX_TYPE_MENU:
90             if (shift_start)
91             {
92                 /* Shift the menu item. */
93                 _gx_widget_scroll_shift(child, 0, shift, GX_TRUE);
94 
95                 menu = (GX_MENU *)child;
96 
97                 /* Shift the menu list which is a member of menu item. */
98                 _gx_widget_scroll_shift((GX_WIDGET *)&menu -> gx_menu_list, 0, shift, GX_TRUE);
99             }
100             break;
101 
102         case GX_TYPE_MENU_LIST:
103             /* The shift work has done by the menu list owner. */
104             break;
105 
106         default:
107             if (shift_start)
108             {
109                 /* Shift other types of menu item. */
110                 _gx_widget_scroll_shift(child, 0, shift, GX_TRUE);
111             }
112             break;
113         }
114 
115         if (child == animation_target)
116         {
117             shift_start = GX_TRUE;
118         }
119 
120         child = child -> gx_widget_next;
121     }
122 
123     /* Resize accordion menu. */
124     size = accordion -> gx_widget_size;
125     size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom + shift);
126     _gx_widget_resize((GX_WIDGET *)accordion, &size);
127 }
128 
129 /**************************************************************************/
130 /*                                                                        */
131 /*  FUNCTION                                               RELEASE        */
132 /*                                                                        */
133 /*    _gx_accordion_menu_shift                            PORTABLE C      */
134 /*                                                           6.1          */
135 /*  AUTHOR                                                                */
136 /*                                                                        */
137 /*    Kenneth Maxwell, Microsoft Corporation                              */
138 /*                                                                        */
139 /*  DESCRIPTION                                                           */
140 /*                                                                        */
141 /*    Internal helper function to shift menu items for an accordion menu. */
142 /*                                                                        */
143 /*  INPUT                                                                 */
144 /*                                                                        */
145 /*    accordion                             Pointer to accordion menu     */
146 /*                                            control block               */
147 /*    animation_target                      Animation target              */
148 /*    shift                                 Shift value                   */
149 /*                                                                        */
150 /*  OUTPUT                                                                */
151 /*                                                                        */
152 /*    status                                Completion status             */
153 /*                                                                        */
154 /*  CALLS                                                                 */
155 /*                                                                        */
156 /*    _gx_widget_resize                     Resize the widget             */
157 /*    _gx_accordion_menu_shift_heloer       Change the accordion menu     */
158 /*                                            position                    */
159 /*                                                                        */
160 /*  CALLED BY                                                             */
161 /*                                                                        */
162 /*    _gx_accordion_menu_close_animation_update                           */
163 /*    _gx_accordion_menu_open_animation_update                            */
164 /*                                                                        */
165 /*  RELEASE HISTORY                                                       */
166 /*                                                                        */
167 /*    DATE              NAME                      DESCRIPTION             */
168 /*                                                                        */
169 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
170 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
171 /*                                            resulting in version 6.1    */
172 /*                                                                        */
173 /**************************************************************************/
_gx_accordion_menu_shift(GX_ACCORDION_MENU * accordion,GX_WIDGET * animation_target,INT shift)174 static UINT _gx_accordion_menu_shift(GX_ACCORDION_MENU *accordion, GX_WIDGET *animation_target, INT shift)
175 {
176 GX_WIDGET   *temp_target;
177 GX_WIDGET   *parent;
178 GX_RECTANGLE size;
179 GX_WIDGET   *child;
180 
181     _gx_accordion_menu_shift_helper(accordion, animation_target, shift);
182 
183     temp_target = (GX_WIDGET *)accordion;
184     parent = accordion -> gx_widget_parent;
185 
186     while (parent)
187     {
188 
189         if (parent -> gx_widget_type == GX_TYPE_MENU_LIST)
190         {
191             /* If the accordion menu is the child of a menu list,
192                Resize the menu list.*/
193             size = parent -> gx_widget_size;
194             size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom + shift);
195             _gx_widget_resize(parent, &size);
196 
197             /* Get the menu that owns the menu list. */
198             child = ((GX_MENU_LIST *)parent) -> gx_menu_list_owner;
199 
200             /* Get the parent of the menu*/
201             if (child)
202             {
203                 parent = child -> gx_widget_parent;
204 
205                 /* Check if the menu parent is an accordion menu. */
206                 if (parent && parent -> gx_widget_type == GX_TYPE_ACCORDION_MENU)
207                 {
208                     _gx_accordion_menu_shift_helper((GX_ACCORDION_MENU *)parent, child, shift);
209                 }
210                 else
211                 {
212                     break; /* Break out of the "while(parent)" loop and return. */
213                 }
214             }
215             else
216             {
217                 break; /* Break out of the "while(parent)" loop and return. */
218             }
219         }
220         else if (parent -> gx_widget_type == GX_TYPE_ACCORDION_MENU)
221         {
222             _gx_accordion_menu_shift_helper((GX_ACCORDION_MENU *)parent, temp_target, shift);
223         }
224         else
225         {
226             break;
227         }
228 
229         temp_target = parent;
230         parent = parent -> gx_widget_parent;
231     }
232 
233     return GX_SUCCESS;
234 }
235 
236 /**************************************************************************/
237 /*                                                                        */
238 /*  FUNCTION                                               RELEASE        */
239 /*                                                                        */
240 /*    _gx_accordion_menu_close_animation_update           PORTABLE C      */
241 /*                                                           6.1          */
242 /*  AUTHOR                                                                */
243 /*                                                                        */
244 /*    Kenneth Maxwell, Microsoft Corporation                              */
245 /*                                                                        */
246 /*  DESCRIPTION                                                           */
247 /*                                                                        */
248 /*    Internal helper function to execute one step in menu close          */
249 /*    animation.                                                          */
250 /*                                                                        */
251 /*  INPUT                                                                 */
252 /*                                                                        */
253 /*    accordion                             Pointer to accordin menu      */
254 /*                                            control block               */
255 /*                                                                        */
256 /*  OUTPUT                                                                */
257 /*                                                                        */
258 /*    status                                Completion status             */
259 /*                                                                        */
260 /*  CALLS                                                                 */
261 /*                                                                        */
262 /*    _gx_widget_height_get                 Get widget height             */
263 /*    _gx_system_timer_stop                 Stop a timer for widget       */
264 /*    _gx_widget_detach                     Detach widget from its parent */
265 /*    _gx_widget_resize                     Resize a widget               */
266 /*    _gx_accordion_menu_shift              Change accordion menu position*/
267 /*                                                                        */
268 /*  CALLED BY                                                             */
269 /*                                                                        */
270 /*    _gx_accordion_menu_event_process                                    */
271 /*                                                                        */
272 /*  RELEASE HISTORY                                                       */
273 /*                                                                        */
274 /*    DATE              NAME                      DESCRIPTION             */
275 /*                                                                        */
276 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
277 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
278 /*                                            resulting in version 6.1    */
279 /*                                                                        */
280 /**************************************************************************/
_gx_accordion_menu_close_animation_update(GX_ACCORDION_MENU * accordion)281 static UINT _gx_accordion_menu_close_animation_update(GX_ACCORDION_MENU *accordion)
282 {
283 GX_MENU     *deselected = (GX_MENU *)accordion -> gx_accordion_menu_collapse_item;
284 GX_VALUE     list_children_height = 0;
285 GX_VALUE     height;
286 GX_VALUE     shift;
287 GX_RECTANGLE size;
288 GX_WIDGET   *child;
289 
290     child = deselected -> gx_menu_list.gx_widget_first_child;
291 
292     /* Calcualte total height of list children. */
293     while (child)
294     {
295         _gx_widget_height_get(child, &height);
296         list_children_height = (GX_VALUE)(list_children_height + height);
297 
298         child = child -> gx_widget_next;
299     }
300 
301     /* Calcualte shift value for each animation step. */
302     shift = (GX_VALUE)(list_children_height / 10);
303     if (shift == 0)
304     {
305         shift = list_children_height;
306     }
307 
308     /* Get menu list height. */
309     _gx_widget_height_get((GX_WIDGET *)&deselected -> gx_menu_list, &height);
310 
311     if (shift > height)
312     {
313         shift = height;
314         _gx_system_timer_stop((GX_WIDGET *)accordion, GX_MENU_CLOSE_TIMER);
315         deselected -> gx_widget_style &= (ULONG)(~GX_STYLE_MENU_EXPANDED);
316         accordion -> gx_accordion_menu_animation_status &= (GX_UBYTE)(~GX_MENU_ANIMATION_CLOSE);
317         accordion -> gx_accordion_menu_collapse_item = GX_NULL;
318         _gx_widget_detach((GX_WIDGET *)&deselected -> gx_menu_list);
319     }
320 
321     /* Resize menu list. */
322     size = deselected -> gx_menu_list.gx_widget_size;
323     size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom - shift);
324     _gx_widget_resize((GX_WIDGET *)&deselected -> gx_menu_list, &size);
325 
326     /* Shift menus that follow the opening menu. */
327     _gx_accordion_menu_shift(accordion, (GX_WIDGET *)deselected, -shift);
328 
329     return GX_SUCCESS;
330 }
331 
332 /**************************************************************************/
333 /*                                                                        */
334 /*  FUNCTION                                               RELEASE        */
335 /*                                                                        */
336 /*    _gx_accordion_menu_open_animation_update            PORTABLE C      */
337 /*                                                           6.1          */
338 /*  AUTHOR                                                                */
339 /*                                                                        */
340 /*    Kenneth Maxwell, Microsoft Corporation                              */
341 /*                                                                        */
342 /*  DESCRIPTION                                                           */
343 /*                                                                        */
344 /*    Internal helper function to execute one step in menu open animation.*/
345 /*                                                                        */
346 /*  INPUT                                                                 */
347 /*                                                                        */
348 /*    accordion                             Pointer to accordin menu      */
349 /*                                            control block               */
350 /*                                                                        */
351 /*  OUTPUT                                                                */
352 /*                                                                        */
353 /*    status                                Completion status             */
354 /*                                                                        */
355 /*  CALLS                                                                 */
356 /*                                                                        */
357 /*    _gx_widget_height_get                 Get widget height             */
358 /*    _gx_system_timer_stop                 Stop a timer for widget       */
359 /*    _gx_widget_resize                     Resize widget                 */
360 /*    _gx_accordion_menu_shift              Change accordin menu position */
361 /*                                                                        */
362 /*  CALLED BY                                                             */
363 /*                                                                        */
364 /*    _gx_accordion_menu_event_process                                    */
365 /*                                                                        */
366 /*  RELEASE HISTORY                                                       */
367 /*                                                                        */
368 /*    DATE              NAME                      DESCRIPTION             */
369 /*                                                                        */
370 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
371 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
372 /*                                            resulting in version 6.1    */
373 /*                                                                        */
374 /**************************************************************************/
_gx_accordion_menu_open_animation_update(GX_ACCORDION_MENU * accordion)375 static UINT _gx_accordion_menu_open_animation_update(GX_ACCORDION_MENU *accordion)
376 {
377 GX_MENU     *selected = (GX_MENU *)accordion -> gx_accordion_menu_expand_item;
378 GX_VALUE     shift;
379 GX_RECTANGLE size;
380 GX_VALUE     list_children_height = 0;
381 GX_VALUE     height = 0;
382 GX_WIDGET   *child;
383 
384     child = selected -> gx_menu_list.gx_widget_first_child;
385 
386     /* Calcualte total height of list children. */
387     while (child)
388     {
389         _gx_widget_height_get(child, &height);
390         list_children_height = (GX_VALUE)(list_children_height + height);
391 
392         child = child -> gx_widget_next;
393     }
394 
395     /* Calcualte shift value for each animation step. */
396     shift = (GX_VALUE)(list_children_height / 10);
397     if (shift == 0)
398     {
399         shift = list_children_height;
400     }
401 
402     /* Get menu list height. */
403     _gx_widget_height_get((GX_WIDGET *)&selected -> gx_menu_list, &height);
404 
405     if (height + shift >= list_children_height)
406     {
407         shift = (GX_VALUE)(list_children_height - height);
408         _gx_system_timer_stop((GX_WIDGET *)accordion, GX_MENU_OPEN_TIMER);
409         accordion -> gx_accordion_menu_animation_status &= (GX_UBYTE)(~GX_MENU_ANIMATION_OPEN);
410         selected -> gx_widget_style |= GX_STYLE_MENU_EXPANDED;
411     }
412 
413     /* Resize menu list. */
414     size = selected -> gx_menu_list.gx_widget_size;
415     size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom + shift);
416     _gx_widget_resize((GX_WIDGET *)&selected -> gx_menu_list, &size);
417 
418     /* Shift menus that follow the opening menu. */
419     _gx_accordion_menu_shift(accordion, (GX_WIDGET *)selected, shift);
420 
421     return GX_SUCCESS;
422 }
423 
424 /**************************************************************************/
425 /*                                                                        */
426 /*  FUNCTION                                               RELEASE        */
427 /*                                                                        */
428 /*    _gx_accordion_menu_pen_down_event_process           PORTABLE C      */
429 /*                                                           6.1          */
430 /*  AUTHOR                                                                */
431 /*                                                                        */
432 /*    Kenneth Maxwell, Microsoft Corporation                              */
433 /*                                                                        */
434 /*  DESCRIPTION                                                           */
435 /*                                                                        */
436 /*    Internal helper function to process pen down event for an accordion */
437 /*    menu.                                                               */
438 /*                                                                        */
439 /*  INPUT                                                                 */
440 /*                                                                        */
441 /*    accordion                             Pointer to accordion menu     */
442 /*                                            control block               */
443 /*    event_ptr                             Pointer to event to process   */
444 /*                                                                        */
445 /*  OUTPUT                                                                */
446 /*                                                                        */
447 /*    status                                Completion status             */
448 /*                                                                        */
449 /*  CALLS                                                                 */
450 /*                                                                        */
451 /*    _gx_system_top_widget_find            Find toppest widget that      */
452 /*                                            contain test point          */
453 /*    _gx_system_input_capture              Temporarily direct all inputs */
454 /*                                            to specified widget         */
455 /*    _gx_widget_event_process              Default widget event procses  */
456 /*                                                                        */
457 /*  CALLED BY                                                             */
458 /*                                                                        */
459 /*    Application Code                                                    */
460 /*                                                                        */
461 /*  RELEASE HISTORY                                                       */
462 /*                                                                        */
463 /*    DATE              NAME                      DESCRIPTION             */
464 /*                                                                        */
465 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
466 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
467 /*                                            resulting in version 6.1    */
468 /*                                                                        */
469 /**************************************************************************/
_gx_accordion_menu_pen_down_event_process(GX_ACCORDION_MENU * accordion,GX_EVENT * event_ptr)470 static UINT _gx_accordion_menu_pen_down_event_process(GX_ACCORDION_MENU *accordion, GX_EVENT *event_ptr)
471 {
472 GX_WIDGET *widget = (GX_WIDGET *)accordion;
473 GX_WIDGET *child = GX_NULL;
474 
475     child = _gx_system_top_widget_find(widget, event_ptr -> gx_event_payload.gx_event_pointdata, GX_STATUS_SELECTABLE);
476 
477     if (child && (child -> gx_widget_type == GX_TYPE_MENU) &&
478         ((GX_MENU *)child) -> gx_menu_list.gx_widget_first_child)
479     {
480         if ((accordion -> gx_accordion_menu_animation_status & GX_MENU_ANIMATION_CLOSE) ||
481             (accordion -> gx_accordion_menu_animation_status & GX_MENU_ANIMATION_OPEN))
482         {
483             /* Animation is going on. */
484             return GX_SUCCESS;
485         }
486 
487         /* Set expand and collapse menu items. */
488         if (child -> gx_widget_style & GX_STYLE_MENU_EXPANDED)
489         {
490             accordion -> gx_accordion_menu_collapse_item = child;
491             accordion -> gx_accordion_menu_expand_item = GX_NULL;
492         }
493         else
494         {
495             if (accordion -> gx_accordion_menu_expand_item != child)
496             {
497                 accordion -> gx_accordion_menu_collapse_item = accordion -> gx_accordion_menu_expand_item;
498             }
499             accordion -> gx_accordion_menu_expand_item = child;
500         }
501 
502         _gx_system_input_capture(widget);
503     }
504     else
505     {
506         _gx_widget_event_process(widget, event_ptr);
507     }
508 
509     return GX_SUCCESS;
510 }
511 
512 /**************************************************************************/
513 /*                                                                        */
514 /*  FUNCTION                                               RELEASE        */
515 /*                                                                        */
516 /*    _gx_accordion_menu_pen_up_event_process             PORTABLE C      */
517 /*                                                           6.1          */
518 /*  AUTHOR                                                                */
519 /*                                                                        */
520 /*    Kenneth Maxwell, Microsoft Corporation                              */
521 /*                                                                        */
522 /*  DESCRIPTION                                                           */
523 /*                                                                        */
524 /*    Internal helper function to process pen up event for an accordion   */
525 /*    menu.                                                               */
526 /*                                                                        */
527 /*  INPUT                                                                 */
528 /*                                                                        */
529 /*    accordion                             Pointer to accordion menu     */
530 /*                                            control block               */
531 /*    event_ptr                             Pointer to event to process   */
532 /*                                                                        */
533 /*  OUTPUT                                                                */
534 /*                                                                        */
535 /*    status                                Completion status             */
536 /*                                                                        */
537 /*  CALLS                                                                 */
538 /*                                                                        */
539 /*    _gx_system_input_release              Release event capture         */
540 /*    _gx_system_timer_start                Start a timer for widget      */
541 /*    _gx_widget_link                       Link a widget to its parent   */
542 /*    _gx_widget_shift                      Change a widget's position    */
543 /*    _gx_widget_event_process              Default widget event process  */
544 /*                                                                        */
545 /*  CALLED BY                                                             */
546 /*                                                                        */
547 /*    Application Code                                                    */
548 /*                                                                        */
549 /*  RELEASE HISTORY                                                       */
550 /*                                                                        */
551 /*    DATE              NAME                      DESCRIPTION             */
552 /*                                                                        */
553 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
554 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
555 /*                                            resulting in version 6.1    */
556 /*                                                                        */
557 /**************************************************************************/
_gx_accordion_menu_pen_up_event_process(GX_ACCORDION_MENU * accordion,GX_EVENT * event_ptr)558 static UINT _gx_accordion_menu_pen_up_event_process(GX_ACCORDION_MENU *accordion, GX_EVENT *event_ptr)
559 {
560 GX_WIDGET    *widget = (GX_WIDGET *)accordion;
561 GX_WIDGET    *child = GX_NULL;
562 GX_MENU_LIST *menu_list;
563 GX_VALUE      x_shift;
564 GX_VALUE      y_shift;
565 
566     if (accordion -> gx_widget_status & GX_STATUS_OWNS_INPUT)
567     {
568         _gx_system_input_release(widget);
569 
570         if (accordion -> gx_accordion_menu_collapse_item)
571         {
572             /* Start a timer to collapse a menu. */
573             _gx_system_timer_start((GX_WIDGET *)accordion, GX_MENU_CLOSE_TIMER, 1, 1);
574             accordion -> gx_accordion_menu_animation_status |= GX_MENU_ANIMATION_CLOSE;
575         }
576 
577         if (accordion -> gx_accordion_menu_expand_item)
578         {
579 
580             /* Start a timer to expand a menu. */
581             _gx_system_timer_start((GX_WIDGET *)accordion, GX_MENU_OPEN_TIMER, 1, 1);
582             accordion -> gx_accordion_menu_animation_status |= GX_MENU_ANIMATION_OPEN;
583 
584             child = accordion -> gx_accordion_menu_expand_item;
585             menu_list = &((GX_MENU *)child) -> gx_menu_list;
586 
587             /* Link menu list to menu's parent. */
588             _gx_widget_link(child -> gx_widget_parent, (GX_WIDGET *)menu_list);
589 
590             x_shift = (GX_VALUE)(child -> gx_widget_size.gx_rectangle_left - menu_list -> gx_widget_size.gx_rectangle_left);
591             y_shift = (GX_VALUE)(child -> gx_widget_size.gx_rectangle_bottom + 1 - menu_list -> gx_widget_size.gx_rectangle_top);
592 
593             /* Shift menu list to the bottom of the menu. */
594             if (x_shift || y_shift)
595             {
596                 _gx_widget_shift((GX_WIDGET *)menu_list, x_shift, y_shift, GX_FALSE);
597             }
598         }
599     }
600     else
601     {
602         _gx_widget_event_process(widget, event_ptr);
603     }
604 
605     return GX_SUCCESS;
606 }
607 
608 /**************************************************************************/
609 /*                                                                        */
610 /*  FUNCTION                                               RELEASE        */
611 /*                                                                        */
612 /*    _gx_accordion_menu_event_process                    PORTABLE C      */
613 /*                                                           6.1          */
614 /*  AUTHOR                                                                */
615 /*                                                                        */
616 /*    Kenneth Maxwell, Microsoft Corporation                              */
617 /*                                                                        */
618 /*  DESCRIPTION                                                           */
619 /*                                                                        */
620 /*    This service processes an event for the accordion menu.             */
621 /*                                                                        */
622 /*  INPUT                                                                 */
623 /*                                                                        */
624 /*    accordion                             Pointer to accordion menu     */
625 /*                                            control block               */
626 /*    event_ptr                             Pointer to event to process   */
627 /*                                                                        */
628 /*  OUTPUT                                                                */
629 /*                                                                        */
630 /*    status                                Completion status             */
631 /*                                                                        */
632 /*  CALLS                                                                 */
633 /*                                                                        */
634 /*    _gx_widget_event_process              Default widget event process  */
635 /*    _gx_accordion_menu_position           Position an accordion menu    */
636 /*    _gx_accordion_menu_open_animation_update                            */
637 /*                                          Execute one step menu open    */
638 /*                                            animation                   */
639 /*    _gx_accordion_menu_close_animation_update                           */
640 /*                                          Execute one step menu close   */
641 /*                                            animation                   */
642 /*    _gx_accordion_menu_pen_down_event_process                           */
643 /*                                          Handle pen down event         */
644 /*    _gx_accordion_menu_pen_up_event_process                             */
645 /*                                          Handle pen up event           */
646 /*                                                                        */
647 /*  CALLED BY                                                             */
648 /*                                                                        */
649 /*    Application Code                                                    */
650 /*                                                                        */
651 /*  RELEASE HISTORY                                                       */
652 /*                                                                        */
653 /*    DATE              NAME                      DESCRIPTION             */
654 /*                                                                        */
655 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
656 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
657 /*                                            resulting in version 6.1    */
658 /*                                                                        */
659 /**************************************************************************/
_gx_accordion_menu_event_process(GX_ACCORDION_MENU * accordion,GX_EVENT * event_ptr)660 UINT _gx_accordion_menu_event_process(GX_ACCORDION_MENU *accordion, GX_EVENT *event_ptr)
661 {
662 UINT timer_id;
663 
664     switch (event_ptr -> gx_event_type)
665     {
666     case GX_EVENT_SHOW:
667         _gx_widget_event_process((GX_WIDGET *)accordion, event_ptr);
668 
669         /* Check if the accordion parent is a menu list, if so, this is not a top level accordion,
670            Do not call accordion menu position here. We should only call menu position for a top level accordion menu. */
671         if (!(accordion -> gx_widget_parent && accordion -> gx_widget_parent -> gx_widget_type == GX_TYPE_MENU_LIST))
672         {
673             _gx_accordion_menu_position(accordion);
674         }
675         break;
676 
677     case GX_EVENT_PEN_DOWN:
678         _gx_accordion_menu_pen_down_event_process(accordion, event_ptr);
679         break;
680 
681     case GX_EVENT_PEN_UP:
682         _gx_accordion_menu_pen_up_event_process(accordion, event_ptr);
683         break;
684 
685     case GX_EVENT_TIMER:
686         timer_id = event_ptr -> gx_event_payload.gx_event_timer_id;
687         if (timer_id == GX_MENU_CLOSE_TIMER)
688         {
689             _gx_accordion_menu_close_animation_update(accordion);
690         }
691         else if (timer_id == GX_MENU_OPEN_TIMER)
692         {
693             _gx_accordion_menu_open_animation_update(accordion);
694         }
695         break;
696 
697     default:
698         return _gx_widget_event_process((GX_WIDGET *)accordion, event_ptr);
699     }
700 
701     return(GX_SUCCESS);
702 }
703 
704