GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_find.c Lines: 20 20 100.0 %
Date: 2024-12-05 08:52:37 Branches: 16 16 100.0 %

Line Branch Exec Source
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
/**   Widget Management (Widget)                                          */
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
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_widget_find                                     PORTABLE C      */
35
/*                                                           6.1          */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Kenneth Maxwell, Microsoft Corporation                              */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    This service searches for the specified widget.                     */
43
/*                                                                        */
44
/*  INPUT                                                                 */
45
/*                                                                        */
46
/*    parent                                Pointer to parent widget to   */
47
/*                                          start search from             */
48
/*    widget_id                             Widget ID                     */
49
/*    search_depth                          how many generations to search*/
50
/*    return_widget                         Pointer to destination for    */
51
/*                                            found widget                */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_widget_find                       Find the specified widget     */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    Application Code                                                    */
64
/*    GUIX Internal Code                                                  */
65
/*                                                                        */
66
/*  RELEASE HISTORY                                                       */
67
/*                                                                        */
68
/*    DATE              NAME                      DESCRIPTION             */
69
/*                                                                        */
70
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
71
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
72
/*                                            resulting in version 6.1    */
73
/*                                                                        */
74
/**************************************************************************/
75
250
UINT _gx_widget_find(GX_WIDGET *parent, USHORT widget_id, INT search_depth, GX_WIDGET **return_widget)
76
{
77
GX_WIDGET *child;
78
79
250
    *return_widget = GX_NULL;
80
81
    /* Is there a widget?  */
82
250
    if (parent)
83
    {
84
249
        child = parent -> gx_widget_first_child;
85
86
1904
        while (child)
87
        {
88
1900
            if (child -> gx_widget_id == widget_id)
89
            {
90
231
                *return_widget = child;
91
231
                return(GX_SUCCESS);
92
            }
93
1669
            if (search_depth > 0)
94
            {
95
1380
                if (child -> gx_widget_first_child)
96
                {
97
218
                    child = child -> gx_widget_first_child;
98
218
                    search_depth--;
99
218
                    continue;
100
                }
101
            }
102
103

1644
            while ((child -> gx_widget_next == GX_NULL) && (child != parent))
104
            {
105
193
                search_depth++;
106
193
                child = child -> gx_widget_parent;
107
            }
108
109
1451
            if (child == parent)
110
            {
111
14
                break;
112
            }
113
114
1437
            child = child -> gx_widget_next;
115
        }
116
    }
117
19
    return(GX_NOT_FOUND);
118
}
119