GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_hide.c Lines: 24 24 100.0 %
Date: 2026-03-06 19:21:09 Branches: 16 16 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
/**   Widget Management (Widget)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_widget.h"
30
#include "gx_window.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_widget_hide                                     PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function hides the widget.                                     */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    widget                                Pointer to widget             */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    None                                                                */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    [gx_widget_event_process_function]    Call widget event processing  */
57
/*    _gx_system_dirty_partial_add          Mark the parent dirty         */
58
/*    _gx_window_view_update_detect         Update viewports if needed    */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    Application Code                                                    */
63
/*                                                                        */
64
/**************************************************************************/
65
4435
UINT _gx_widget_hide(GX_WIDGET *widget)
66
{
67
GX_EVENT   hide_event;
68
GX_WINDOW *win;
69
GX_WIDGET *next;
70
71
4435
    widget -> gx_widget_status |= GX_STATUS_HIDDEN;
72
73
4435
    if (widget -> gx_widget_status & GX_STATUS_VISIBLE)
74
    {
75
        /* Send a GX_EVENT_HIDE event to widget and all children of the widget.  */
76
3358
        hide_event.gx_event_type = GX_EVENT_HIDE;
77
3358
        hide_event.gx_event_target = GX_NULL;
78
3358
        hide_event.gx_event_sender = 0;
79
80
        /* Call widget's event processing.  */
81
3358
        widget -> gx_widget_event_process_function(widget, &hide_event);
82
83
3358
        if (widget -> gx_widget_status & GX_STATUS_HAS_FOCUS)
84
        {
85
434
            if(widget -> gx_widget_nav_next == widget)
86
            {
87
                /* Current widget is the last widget in navigation order, move focus to its parent. */
88
121
                next = widget -> gx_widget_parent;
89
            }
90
            else
91
            {
92
                /* Move focus to the next widget in navigation order. */
93
313
                next  = widget -> gx_widget_nav_next;
94
            }
95
96
434
            if (next)
97
            {
98
395
                _gx_system_focus_claim(next);
99
            }
100
        }
101
102
3358
        if (widget -> gx_widget_parent)
103
        {
104
3300
            _gx_system_dirty_partial_add(widget -> gx_widget_parent, &widget -> gx_widget_size);
105
106
            /* if this widget was part of navigation order, re-create nav order list */
107
3300
            if (widget -> gx_widget_status & GX_STATUS_ACCEPTS_FOCUS)
108
            {
109
1123
                _gx_widget_nav_order_initialize(widget -> gx_widget_parent);
110
            }
111
        }
112
113
3358
        if (widget -> gx_widget_type >= GX_TYPE_WINDOW)
114
        {
115
1098
            win = (GX_WINDOW *)widget;
116
1098
            if (win -> gx_window_views)
117
            {
118
697
                _gx_system_views_free(win -> gx_window_views);
119
697
                win -> gx_window_views = GX_NULL;
120
            }
121
1098
            _gx_window_view_update_detect((GX_WINDOW *)widget);
122
        }
123
124
    }
125
126
127
4435
    return(GX_SUCCESS);
128
}
129