GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_accordion_menu_event_process.c Lines: 157 157 100.0 %
Date: 2026-03-06 19:21:09 Branches: 76 76 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
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
/**************************************************************************/
69
620
static VOID _gx_accordion_menu_shift_helper(GX_ACCORDION_MENU *accordion, GX_WIDGET *animation_target, INT shift)
70
{
71
GX_WIDGET   *child;
72
GX_MENU     *menu;
73
620
GX_BOOL      shift_start = GX_FALSE;
74
GX_RECTANGLE size;
75
76
620
    child = accordion -> gx_widget_first_child;
77
3150
    while (child)
78
    {
79
2530
        switch (child -> gx_widget_type)
80
        {
81
1525
        case GX_TYPE_MENU:
82
1525
            if (shift_start)
83
            {
84
                /* Shift the menu item. */
85
547
                _gx_widget_scroll_shift(child, 0, shift, GX_TRUE);
86
87
547
                menu = (GX_MENU *)child;
88
89
                /* Shift the menu list which is a member of menu item. */
90
547
                _gx_widget_scroll_shift((GX_WIDGET *)&menu -> gx_menu_list, 0, shift, GX_TRUE);
91
            }
92
1525
            break;
93
94
838
        case GX_TYPE_MENU_LIST:
95
            /* The shift work has done by the menu list owner. */
96
838
            break;
97
98
167
        default:
99
167
            if (shift_start)
100
            {
101
                /* Shift other types of menu item. */
102
88
                _gx_widget_scroll_shift(child, 0, shift, GX_TRUE);
103
            }
104
167
            break;
105
        }
106
107
2530
        if (child == animation_target)
108
        {
109
620
            shift_start = GX_TRUE;
110
        }
111
112
2530
        child = child -> gx_widget_next;
113
    }
114
115
    /* Resize accordion menu. */
116
620
    size = accordion -> gx_widget_size;
117
620
    size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom + shift);
118
620
    _gx_widget_resize((GX_WIDGET *)accordion, &size);
119
620
}
120
121
/**************************************************************************/
122
/*                                                                        */
123
/*  FUNCTION                                               RELEASE        */
124
/*                                                                        */
125
/*    _gx_accordion_menu_shift                            PORTABLE C      */
126
/*                                                           6.1          */
127
/*  AUTHOR                                                                */
128
/*                                                                        */
129
/*    Kenneth Maxwell, Microsoft Corporation                              */
130
/*                                                                        */
131
/*  DESCRIPTION                                                           */
132
/*                                                                        */
133
/*    Internal helper function to shift menu items for an accordion menu. */
134
/*                                                                        */
135
/*  INPUT                                                                 */
136
/*                                                                        */
137
/*    accordion                             Pointer to accordion menu     */
138
/*                                            control block               */
139
/*    animation_target                      Animation target              */
140
/*    shift                                 Shift value                   */
141
/*                                                                        */
142
/*  OUTPUT                                                                */
143
/*                                                                        */
144
/*    status                                Completion status             */
145
/*                                                                        */
146
/*  CALLS                                                                 */
147
/*                                                                        */
148
/*    _gx_widget_resize                     Resize the widget             */
149
/*    _gx_accordion_menu_shift_heloer       Change the accordion menu     */
150
/*                                            position                    */
151
/*                                                                        */
152
/*  CALLED BY                                                             */
153
/*                                                                        */
154
/*    _gx_accordion_menu_close_animation_update                           */
155
/*    _gx_accordion_menu_open_animation_update                            */
156
/*                                                                        */
157
/**************************************************************************/
158
367
static UINT _gx_accordion_menu_shift(GX_ACCORDION_MENU *accordion, GX_WIDGET *animation_target, INT shift)
159
{
160
GX_WIDGET   *temp_target;
161
GX_WIDGET   *parent;
162
GX_RECTANGLE size;
163
GX_WIDGET   *child;
164
165
367
    _gx_accordion_menu_shift_helper(accordion, animation_target, shift);
166
167
367
    temp_target = (GX_WIDGET *)accordion;
168
367
    parent = accordion -> gx_widget_parent;
169
170
620
    while (parent)
171
    {
172
173
619
        if (parent -> gx_widget_type == GX_TYPE_MENU_LIST)
174
        {
175
            /* If the accordion menu is the child of a menu list,
176
               Resize the menu list.*/
177
216
            size = parent -> gx_widget_size;
178
216
            size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom + shift);
179
216
            _gx_widget_resize(parent, &size);
180
181
            /* Get the menu that owns the menu list. */
182
216
            child = ((GX_MENU_LIST *)parent) -> gx_menu_list_owner;
183
184
            /* Get the parent of the menu*/
185
216
            if (child)
186
            {
187
215
                parent = child -> gx_widget_parent;
188
189
                /* Check if the menu parent is an accordion menu. */
190

215
                if (parent && parent -> gx_widget_type == GX_TYPE_ACCORDION_MENU)
191
                {
192
213
                    _gx_accordion_menu_shift_helper((GX_ACCORDION_MENU *)parent, child, shift);
193
                }
194
                else
195
                {
196
                    break; /* Break out of the "while(parent)" loop and return. */
197
                }
198
            }
199
            else
200
            {
201
1
                break; /* Break out of the "while(parent)" loop and return. */
202
            }
203
        }
204
403
        else if (parent -> gx_widget_type == GX_TYPE_ACCORDION_MENU)
205
        {
206
40
            _gx_accordion_menu_shift_helper((GX_ACCORDION_MENU *)parent, temp_target, shift);
207
        }
208
        else
209
        {
210
363
            break;
211
        }
212
213
253
        temp_target = parent;
214
253
        parent = parent -> gx_widget_parent;
215
    }
216
217
367
    return GX_SUCCESS;
218
}
219
220
/**************************************************************************/
221
/*                                                                        */
222
/*  FUNCTION                                               RELEASE        */
223
/*                                                                        */
224
/*    _gx_accordion_menu_close_animation_update           PORTABLE C      */
225
/*                                                           6.3.0        */
226
/*  AUTHOR                                                                */
227
/*                                                                        */
228
/*    Kenneth Maxwell, Microsoft Corporation                              */
229
/*                                                                        */
230
/*  DESCRIPTION                                                           */
231
/*                                                                        */
232
/*    Internal helper function to execute one step in menu close          */
233
/*    animation.                                                          */
234
/*                                                                        */
235
/*  INPUT                                                                 */
236
/*                                                                        */
237
/*    accordion                             Pointer to accordin menu      */
238
/*                                            control block               */
239
/*                                                                        */
240
/*  OUTPUT                                                                */
241
/*                                                                        */
242
/*    status                                Completion status             */
243
/*                                                                        */
244
/*  CALLS                                                                 */
245
/*                                                                        */
246
/*    _gx_widget_height_get                 Get widget height             */
247
/*    _gx_system_timer_stop                 Stop a timer for widget       */
248
/*    _gx_widget_detach                     Detach widget from its parent */
249
/*    _gx_widget_resize                     Resize a widget               */
250
/*    _gx_accordion_menu_shift              Change accordion menu position*/
251
/*                                                                        */
252
/*  CALLED BY                                                             */
253
/*                                                                        */
254
/*    _gx_accordion_menu_event_process                                    */
255
/*                                                                        */
256
/**************************************************************************/
257
141
static UINT _gx_accordion_menu_close_animation_update(GX_ACCORDION_MENU *accordion)
258
{
259
141
GX_MENU     *deselected = (GX_MENU *)accordion -> gx_accordion_menu_collapse_item;
260
141
GX_VALUE     list_children_height = 0;
261
GX_VALUE     height;
262
GX_VALUE     shift;
263
GX_RECTANGLE size;
264
GX_WIDGET   *child;
265
266
141
    if (!deselected)
267
    {
268
1
        return GX_SUCCESS;
269
    }
270
271
140
    child = deselected -> gx_menu_list.gx_widget_first_child;
272
273
    /* Calcualte total height of list children. */
274
298
    while (child)
275
    {
276
158
        _gx_widget_height_get(child, &height);
277
158
        list_children_height = (GX_VALUE)(list_children_height + height);
278
279
158
        child = child -> gx_widget_next;
280
    }
281
282
    /* Calcualte shift value for each animation step. */
283
140
    shift = (GX_VALUE)(list_children_height / 10);
284
140
    if (shift == 0)
285
    {
286
4
        shift = list_children_height;
287
    }
288
289
    /* Get menu list height. */
290
140
    _gx_widget_height_get((GX_WIDGET *)&deselected -> gx_menu_list, &height);
291
292
140
    if (shift > height)
293
    {
294
13
        shift = height;
295
13
        _gx_system_timer_stop((GX_WIDGET *)accordion, GX_MENU_CLOSE_TIMER);
296
13
        deselected -> gx_widget_style &= (ULONG)(~GX_STYLE_MENU_EXPANDED);
297
13
        accordion -> gx_accordion_menu_animation_status &= (GX_UBYTE)(~GX_MENU_ANIMATION_CLOSE);
298
13
        accordion -> gx_accordion_menu_collapse_item = GX_NULL;
299
13
        _gx_widget_detach((GX_WIDGET *)&deselected -> gx_menu_list);
300
    }
301
302
    /* Resize menu list. */
303
140
    size = deselected -> gx_menu_list.gx_widget_size;
304
140
    size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom - shift);
305
140
    _gx_widget_resize((GX_WIDGET *)&deselected -> gx_menu_list, &size);
306
307
    /* Shift menus that follow the opening menu. */
308
140
    _gx_accordion_menu_shift(accordion, (GX_WIDGET *)deselected, -shift);
309
310
140
    return GX_SUCCESS;
311
}
312
313
/**************************************************************************/
314
/*                                                                        */
315
/*  FUNCTION                                               RELEASE        */
316
/*                                                                        */
317
/*    _gx_accordion_menu_open_animation_update            PORTABLE C      */
318
/*                                                           6.3.0        */
319
/*  AUTHOR                                                                */
320
/*                                                                        */
321
/*    Kenneth Maxwell, Microsoft Corporation                              */
322
/*                                                                        */
323
/*  DESCRIPTION                                                           */
324
/*                                                                        */
325
/*    Internal helper function to execute one step in menu open animation.*/
326
/*                                                                        */
327
/*  INPUT                                                                 */
328
/*                                                                        */
329
/*    accordion                             Pointer to accordin menu      */
330
/*                                            control block               */
331
/*                                                                        */
332
/*  OUTPUT                                                                */
333
/*                                                                        */
334
/*    status                                Completion status             */
335
/*                                                                        */
336
/*  CALLS                                                                 */
337
/*                                                                        */
338
/*    _gx_widget_height_get                 Get widget height             */
339
/*    _gx_system_timer_stop                 Stop a timer for widget       */
340
/*    _gx_widget_resize                     Resize widget                 */
341
/*    _gx_accordion_menu_shift              Change accordin menu position */
342
/*                                                                        */
343
/*  CALLED BY                                                             */
344
/*                                                                        */
345
/*    _gx_accordion_menu_event_process                                    */
346
/*                                                                        */
347
/**************************************************************************/
348
228
static UINT _gx_accordion_menu_open_animation_update(GX_ACCORDION_MENU *accordion)
349
{
350
228
GX_MENU     *selected = (GX_MENU *)accordion -> gx_accordion_menu_expand_item;
351
GX_VALUE     shift;
352
GX_RECTANGLE size;
353
228
GX_VALUE     list_children_height = 0;
354
228
GX_VALUE     height = 0;
355
GX_WIDGET   *child;
356
357
228
    if (!selected)
358
    {
359
1
        return GX_SUCCESS;
360
    }
361
362
227
    child = selected -> gx_menu_list.gx_widget_first_child;
363
364
    /* Calcualte total height of list children. */
365
492
    while (child)
366
    {
367
265
        _gx_widget_height_get(child, &height);
368
265
        list_children_height = (GX_VALUE)(list_children_height + height);
369
370
265
        child = child -> gx_widget_next;
371
    }
372
373
    /* Calcualte shift value for each animation step. */
374
227
    shift = (GX_VALUE)(list_children_height / 10);
375
227
    if (shift == 0)
376
    {
377
2
        shift = list_children_height;
378
    }
379
380
    /* Get menu list height. */
381
227
    _gx_widget_height_get((GX_WIDGET *)&selected -> gx_menu_list, &height);
382
383
227
    if (height + shift >= list_children_height)
384
    {
385
21
        shift = (GX_VALUE)(list_children_height - height);
386
21
        _gx_system_timer_stop((GX_WIDGET *)accordion, GX_MENU_OPEN_TIMER);
387
21
        accordion -> gx_accordion_menu_animation_status &= (GX_UBYTE)(~GX_MENU_ANIMATION_OPEN);
388
21
        selected -> gx_widget_style |= GX_STYLE_MENU_EXPANDED;
389
    }
390
391
    /* Resize menu list. */
392
227
    size = selected -> gx_menu_list.gx_widget_size;
393
227
    size.gx_rectangle_bottom = (GX_VALUE)(size.gx_rectangle_bottom + shift);
394
227
    _gx_widget_resize((GX_WIDGET *)&selected -> gx_menu_list, &size);
395
396
    /* Shift menus that follow the opening menu. */
397
227
    _gx_accordion_menu_shift(accordion, (GX_WIDGET *)selected, shift);
398
399
227
    return GX_SUCCESS;
400
}
401
402
/**************************************************************************/
403
/*                                                                        */
404
/*  FUNCTION                                               RELEASE        */
405
/*                                                                        */
406
/*    _gx_accordion_menu_pen_down_event_process           PORTABLE C      */
407
/*                                                           6.1          */
408
/*  AUTHOR                                                                */
409
/*                                                                        */
410
/*    Kenneth Maxwell, Microsoft Corporation                              */
411
/*                                                                        */
412
/*  DESCRIPTION                                                           */
413
/*                                                                        */
414
/*    Internal helper function to process pen down event for an accordion */
415
/*    menu.                                                               */
416
/*                                                                        */
417
/*  INPUT                                                                 */
418
/*                                                                        */
419
/*    accordion                             Pointer to accordion menu     */
420
/*                                            control block               */
421
/*    event_ptr                             Pointer to event to process   */
422
/*                                                                        */
423
/*  OUTPUT                                                                */
424
/*                                                                        */
425
/*    status                                Completion status             */
426
/*                                                                        */
427
/*  CALLS                                                                 */
428
/*                                                                        */
429
/*    _gx_system_top_widget_find            Find toppest widget that      */
430
/*                                            contain test point          */
431
/*    _gx_system_input_capture              Temporarily direct all inputs */
432
/*                                            to specified widget         */
433
/*    _gx_widget_event_process              Default widget event procses  */
434
/*                                                                        */
435
/*  CALLED BY                                                             */
436
/*                                                                        */
437
/*    Application Code                                                    */
438
/*                                                                        */
439
/**************************************************************************/
440
30
static UINT _gx_accordion_menu_pen_down_event_process(GX_ACCORDION_MENU *accordion, GX_EVENT *event_ptr)
441
{
442
30
GX_WIDGET *widget = (GX_WIDGET *)accordion;
443
30
GX_WIDGET *child = GX_NULL;
444
445
30
    child = _gx_system_top_widget_find(widget, event_ptr -> gx_event_payload.gx_event_pointdata, GX_STATUS_SELECTABLE);
446
447

30
    if (child && (child -> gx_widget_type == GX_TYPE_MENU) &&
448
28
        ((GX_MENU *)child) -> gx_menu_list.gx_widget_first_child)
449
    {
450
27
        if ((accordion -> gx_accordion_menu_animation_status & GX_MENU_ANIMATION_CLOSE) ||
451
26
            (accordion -> gx_accordion_menu_animation_status & GX_MENU_ANIMATION_OPEN))
452
        {
453
            /* Animation is going on. */
454
2
            return GX_SUCCESS;
455
        }
456
457
        /* Set expand and collapse menu items. */
458
25
        if (child -> gx_widget_style & GX_STYLE_MENU_EXPANDED)
459
        {
460
3
            accordion -> gx_accordion_menu_collapse_item = child;
461
3
            accordion -> gx_accordion_menu_expand_item = GX_NULL;
462
        }
463
        else
464
        {
465
22
            if (accordion -> gx_accordion_menu_expand_item != child)
466
            {
467
21
                accordion -> gx_accordion_menu_collapse_item = accordion -> gx_accordion_menu_expand_item;
468
            }
469
22
            accordion -> gx_accordion_menu_expand_item = child;
470
        }
471
472
25
        _gx_system_input_capture(widget);
473
    }
474
    else
475
    {
476
3
        _gx_widget_event_process(widget, event_ptr);
477
    }
478
479
28
    return GX_SUCCESS;
480
}
481
482
/**************************************************************************/
483
/*                                                                        */
484
/*  FUNCTION                                               RELEASE        */
485
/*                                                                        */
486
/*    _gx_accordion_menu_pen_up_event_process             PORTABLE C      */
487
/*                                                           6.1          */
488
/*  AUTHOR                                                                */
489
/*                                                                        */
490
/*    Kenneth Maxwell, Microsoft Corporation                              */
491
/*                                                                        */
492
/*  DESCRIPTION                                                           */
493
/*                                                                        */
494
/*    Internal helper function to process pen up event for an accordion   */
495
/*    menu.                                                               */
496
/*                                                                        */
497
/*  INPUT                                                                 */
498
/*                                                                        */
499
/*    accordion                             Pointer to accordion menu     */
500
/*                                            control block               */
501
/*    event_ptr                             Pointer to event to process   */
502
/*                                                                        */
503
/*  OUTPUT                                                                */
504
/*                                                                        */
505
/*    status                                Completion status             */
506
/*                                                                        */
507
/*  CALLS                                                                 */
508
/*                                                                        */
509
/*    _gx_system_input_release              Release event capture         */
510
/*    _gx_system_timer_start                Start a timer for widget      */
511
/*    _gx_widget_link                       Link a widget to its parent   */
512
/*    _gx_widget_shift                      Change a widget's position    */
513
/*    _gx_widget_event_process              Default widget event process  */
514
/*                                                                        */
515
/*  CALLED BY                                                             */
516
/*                                                                        */
517
/*    Application Code                                                    */
518
/*                                                                        */
519
/**************************************************************************/
520
29
static UINT _gx_accordion_menu_pen_up_event_process(GX_ACCORDION_MENU *accordion, GX_EVENT *event_ptr)
521
{
522
29
GX_WIDGET    *widget = (GX_WIDGET *)accordion;
523
29
GX_WIDGET    *child = GX_NULL;
524
GX_MENU_LIST *menu_list;
525
GX_VALUE      x_shift;
526
GX_VALUE      y_shift;
527
528
29
    if (accordion -> gx_widget_status & GX_STATUS_OWNS_INPUT)
529
    {
530
24
        _gx_system_input_release(widget);
531
532
24
        if (accordion -> gx_accordion_menu_collapse_item)
533
        {
534
            /* Start a timer to collapse a menu. */
535
13
            _gx_system_timer_start((GX_WIDGET *)accordion, GX_MENU_CLOSE_TIMER, 1, 1);
536
13
            accordion -> gx_accordion_menu_animation_status |= GX_MENU_ANIMATION_CLOSE;
537
        }
538
539
24
        if (accordion -> gx_accordion_menu_expand_item)
540
        {
541
542
            /* Start a timer to expand a menu. */
543
21
            _gx_system_timer_start((GX_WIDGET *)accordion, GX_MENU_OPEN_TIMER, 1, 1);
544
21
            accordion -> gx_accordion_menu_animation_status |= GX_MENU_ANIMATION_OPEN;
545
546
21
            child = accordion -> gx_accordion_menu_expand_item;
547
21
            menu_list = &((GX_MENU *)child) -> gx_menu_list;
548
549
            /* Link menu list to menu's parent. */
550
21
            _gx_widget_link(child -> gx_widget_parent, (GX_WIDGET *)menu_list);
551
552
21
            x_shift = (GX_VALUE)(child -> gx_widget_size.gx_rectangle_left - menu_list -> gx_widget_size.gx_rectangle_left);
553
21
            y_shift = (GX_VALUE)(child -> gx_widget_size.gx_rectangle_bottom + 1 - menu_list -> gx_widget_size.gx_rectangle_top);
554
555
            /* Shift menu list to the bottom of the menu. */
556

21
            if (x_shift || y_shift)
557
            {
558
7
                _gx_widget_shift((GX_WIDGET *)menu_list, x_shift, y_shift, GX_FALSE);
559
            }
560
        }
561
    }
562
    else
563
    {
564
5
        _gx_widget_event_process(widget, event_ptr);
565
    }
566
567
29
    return GX_SUCCESS;
568
}
569
570
/**************************************************************************/
571
/*                                                                        */
572
/*  FUNCTION                                               RELEASE        */
573
/*                                                                        */
574
/*    _gx_accordion_menu_event_process                    PORTABLE C      */
575
/*                                                           6.1          */
576
/*  AUTHOR                                                                */
577
/*                                                                        */
578
/*    Kenneth Maxwell, Microsoft Corporation                              */
579
/*                                                                        */
580
/*  DESCRIPTION                                                           */
581
/*                                                                        */
582
/*    This service processes an event for the accordion menu.             */
583
/*                                                                        */
584
/*  INPUT                                                                 */
585
/*                                                                        */
586
/*    accordion                             Pointer to accordion menu     */
587
/*                                            control block               */
588
/*    event_ptr                             Pointer to event to process   */
589
/*                                                                        */
590
/*  OUTPUT                                                                */
591
/*                                                                        */
592
/*    status                                Completion status             */
593
/*                                                                        */
594
/*  CALLS                                                                 */
595
/*                                                                        */
596
/*    _gx_widget_event_process              Default widget event process  */
597
/*    _gx_accordion_menu_position           Position an accordion menu    */
598
/*    _gx_accordion_menu_open_animation_update                            */
599
/*                                          Execute one step menu open    */
600
/*                                            animation                   */
601
/*    _gx_accordion_menu_close_animation_update                           */
602
/*                                          Execute one step menu close   */
603
/*                                            animation                   */
604
/*    _gx_accordion_menu_pen_down_event_process                           */
605
/*                                          Handle pen down event         */
606
/*    _gx_accordion_menu_pen_up_event_process                             */
607
/*                                          Handle pen up event           */
608
/*                                                                        */
609
/*  CALLED BY                                                             */
610
/*                                                                        */
611
/*    Application Code                                                    */
612
/*                                                                        */
613
/**************************************************************************/
614
662
UINT _gx_accordion_menu_event_process(GX_ACCORDION_MENU *accordion, GX_EVENT *event_ptr)
615
{
616
UINT timer_id;
617
618

662
    switch (event_ptr -> gx_event_type)
619
    {
620
115
    case GX_EVENT_SHOW:
621
115
        _gx_widget_event_process((GX_WIDGET *)accordion, event_ptr);
622
623
        /* Check if the accordion parent is a menu list, if so, this is not a top level accordion,
624
           Do not call accordion menu position here. We should only call menu position for a top level accordion menu. */
625

115
        if (!(accordion -> gx_widget_parent && accordion -> gx_widget_parent -> gx_widget_type == GX_TYPE_MENU_LIST))
626
        {
627
111
            _gx_accordion_menu_position(accordion);
628
        }
629
115
        break;
630
631
30
    case GX_EVENT_PEN_DOWN:
632
30
        _gx_accordion_menu_pen_down_event_process(accordion, event_ptr);
633
30
        break;
634
635
29
    case GX_EVENT_PEN_UP:
636
29
        _gx_accordion_menu_pen_up_event_process(accordion, event_ptr);
637
29
        break;
638
639
393
    case GX_EVENT_TIMER:
640
393
        timer_id = event_ptr -> gx_event_payload.gx_event_timer_id;
641
393
        if (timer_id == GX_MENU_CLOSE_TIMER)
642
        {
643
141
            _gx_accordion_menu_close_animation_update(accordion);
644
        }
645
252
        else if (timer_id == GX_MENU_OPEN_TIMER)
646
        {
647
228
            _gx_accordion_menu_open_animation_update(accordion);
648
        }
649
393
        break;
650
651
95
    default:
652
95
        return _gx_widget_event_process((GX_WIDGET *)accordion, event_ptr);
653
    }
654
655
567
    return(GX_SUCCESS);
656
}
657