GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_back_link.c Lines: 15 15 100.0 %
Date: 2026-03-06 19:21:09 Branches: 8 8 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_utility.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_widget_back_link                                PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function links a widget to the back of the parent child list   */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    parent                                Parent widget control block   */
50
/*    widget                                Widget control block          */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    status                                Completion status             */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_widget_unlink                     Unlink the widget             */
59
/*    _gx_widget_show                       Show the widget               */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    GUIX Internal Code                                                  */
64
/*                                                                        */
65
/**************************************************************************/
66
561
VOID _gx_widget_back_link(GX_WIDGET *parent, GX_WIDGET *widget)
67
{
68
GX_WIDGET *sibling;
69
70
    /* Determine if a parent widget was provided.  */
71
561
    if (parent)
72
    {
73
        /* Yes, is there already a child for this parent?  */
74
559
        if (parent -> gx_widget_first_child)
75
        {
76
            /* Yes, find the last child.  */
77
557
            sibling =  parent -> gx_widget_first_child;
78
557
            widget -> gx_widget_next = sibling;
79
557
            sibling -> gx_widget_previous = widget;
80
        }
81
        else
82
        {
83
2
            widget -> gx_widget_next = NULL;
84
2
            parent -> gx_widget_last_child = widget;
85
        }
86
87
559
        parent -> gx_widget_first_child =  widget;
88
89
        /* Setup the last child pointer and remember the parent widget.  */
90
559
        widget -> gx_widget_parent = parent;
91
92
559
        if (parent -> gx_widget_status & GX_STATUS_VISIBLE)
93
        {
94
556
            _gx_widget_show(widget);
95
556
            if (widget -> gx_widget_status & GX_STATUS_ACCEPTS_FOCUS)
96
            {
97
8
                _gx_widget_nav_order_initialize(parent);
98
            }
99
        }
100
    }
101
561
}
102