GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_back_move.c Lines: 19 19 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_utility.h"
30
#include "gx_widget.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_widget_back_move                                PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function moves a widget to the back in the Z order.            */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    widget                                Widget control block          */
50
/*    widget_moved                          Return flag indicate widget   */
51
/*                                            moved                       */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_system_dirty_partial_add          Add dirty area                */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    Application Code                                                    */
64
/*    GUIX Internal Code                                                  */
65
/*                                                                        */
66
/**************************************************************************/
67
14
UINT  _gx_widget_back_move(GX_WIDGET *widget, GX_BOOL *widget_moved)
68
{
69
GX_WIDGET *parent;
70
71
    /* Pickup parent widget.  */
72
14
    parent = widget -> gx_widget_parent;
73
74
    /* Check for invalid parent.  */
75
14
    if (!parent)
76
    {
77
1
        return(GX_PTR_ERROR);
78
    }
79
80
    /* First check to see if the widget is already in back.  */
81
13
    if (parent -> gx_widget_first_child == widget)
82
    {
83
        /* Yes, widget is already in back, so nothing to do.  */
84
85
        /* Return no change.  */
86
2
        return(GX_NO_CHANGE);
87
    }
88
89
    /* Relink widget to the end
90
        2) unlink and stitch linked list
91
        3) relink to the end
92
        4) call dirty so that we will get redraw
93
     */
94
11
    _gx_system_dirty_partial_add(parent, &widget -> gx_widget_size);
95
96
    /* Is the widget last (front) child of parent?  */
97
11
    if (parent -> gx_widget_last_child == widget)
98
    {
99
        /* Yes, the first child, easy remove the first child.  */
100
10
        parent -> gx_widget_last_child =  widget -> gx_widget_previous;
101
10
        widget -> gx_widget_previous -> gx_widget_next =  NULL;
102
    }
103
    else
104
    {
105
        /* No, not the first child. Remove from the middle.  */
106
1
        widget -> gx_widget_previous -> gx_widget_next =  widget -> gx_widget_next;
107
1
        widget -> gx_widget_next -> gx_widget_previous =  widget -> gx_widget_previous;
108
    }
109
110
    /* Link the widget to the back (head) of the list.  */
111
11
    widget -> gx_widget_next = parent -> gx_widget_first_child;
112
11
    parent -> gx_widget_first_child -> gx_widget_previous = widget;
113
11
    widget -> gx_widget_previous = GX_NULL;
114
11
    parent -> gx_widget_first_child = widget;
115
116
    /* Indicate the widget was moved.  */
117
118
11
    if (widget_moved)
119
    {
120
7
        *widget_moved =  GX_TRUE;
121
    }
122
123
    /* Return successful completion.  */
124
11
    return(GX_SUCCESS);
125
}
126