GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_find.c Lines: 20 20 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_widget.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_widget_find                                     PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This service searches for the specified widget.                     */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    parent                                Pointer to parent widget to   */
48
/*                                          start search from             */
49
/*    widget_id                             Widget ID                     */
50
/*    search_depth                          how many generations to search*/
51
/*    return_widget                         Pointer to destination for    */
52
/*                                            found widget                */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    status                                Completion status             */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _gx_widget_find                       Find the specified widget     */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    Application Code                                                    */
65
/*    GUIX Internal Code                                                  */
66
/*                                                                        */
67
/**************************************************************************/
68
250
UINT _gx_widget_find(GX_WIDGET *parent, USHORT widget_id, INT search_depth, GX_WIDGET **return_widget)
69
{
70
GX_WIDGET *child;
71
72
250
    *return_widget = GX_NULL;
73
74
    /* Is there a widget?  */
75
250
    if (parent)
76
    {
77
249
        child = parent -> gx_widget_first_child;
78
79
1904
        while (child)
80
        {
81
1900
            if (child -> gx_widget_id == widget_id)
82
            {
83
231
                *return_widget = child;
84
231
                return(GX_SUCCESS);
85
            }
86
1669
            if (search_depth > 0)
87
            {
88
1380
                if (child -> gx_widget_first_child)
89
                {
90
218
                    child = child -> gx_widget_first_child;
91
218
                    search_depth--;
92
218
                    continue;
93
                }
94
            }
95
96

1644
            while ((child -> gx_widget_next == GX_NULL) && (child != parent))
97
            {
98
193
                search_depth++;
99
193
                child = child -> gx_widget_parent;
100
            }
101
102
1451
            if (child == parent)
103
            {
104
14
                break;
105
            }
106
107
1437
            child = child -> gx_widget_next;
108
        }
109
    }
110
19
    return(GX_NOT_FOUND);
111
}
112