GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_scroll_shift.c Lines: 26 26 100.0 %
Date: 2026-03-06 19:21:09 Branches: 22 22 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
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_widget_scroll_shift_helper                      PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    Internal helper function to change the position of a widget.        */
45
/*    It also adds a dirty entry if required.                             */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    widget                                Widget control block          */
50
/*    xShift                                The x-axis shift amount       */
51
/*    yShift                                The y-axis shift amount       */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_utility_rectangle_shift           Shift a rectangle             */
60
/*    _gx_system_dirty_entry_shift          Mark partial widget area dirty*/
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    _gx_widget_scroll_shift                                             */
65
/*                                                                        */
66
/**************************************************************************/
67
20741
static VOID _gx_widget_scroll_shift_helper(GX_WIDGET *widget, INT xShift, INT yShift)
68
{
69
GX_WINDOW *win;
70
71
20741
    _gx_utility_rectangle_shift(&widget -> gx_widget_size, (GX_VALUE)xShift, (GX_VALUE)yShift);
72
73
20741
    if (widget -> gx_widget_type >= GX_TYPE_WINDOW)
74
    {
75
2309
        win = (GX_WINDOW *)widget;
76
2309
        _gx_utility_rectangle_shift(&win -> gx_window_client, (GX_VALUE)xShift, (GX_VALUE)yShift);
77
    }
78
79
20741
    if (widget -> gx_widget_status & GX_STATUS_DIRTY)
80
    {
81
        /* mark it dirty again so that the new position is recorded */
82
6378
        _gx_system_dirty_entry_shift(widget, xShift, yShift);
83
    }
84
20741
}
85
86
/**************************************************************************/
87
/*                                                                        */
88
/*  FUNCTION                                               RELEASE        */
89
/*                                                                        */
90
/*    _gx_widget_scroll_shift                             PORTABLE C      */
91
/*                                                           6.1          */
92
/*  AUTHOR                                                                */
93
/*                                                                        */
94
/*    Kenneth Maxwell, Microsoft Corporation                              */
95
/*                                                                        */
96
/*  DESCRIPTION                                                           */
97
/*                                                                        */
98
/*    This function changes the position of a widget. It also adds        */
99
/*    a dirty entry if required                                           */
100
/*                                                                        */
101
/*  INPUT                                                                 */
102
/*                                                                        */
103
/*    widget                                Widget control block          */
104
/*    xShift                                The x-axis shift amount       */
105
/*    yShift                                The y-axis shift amount       */
106
/*    clip                                  Flag, should we update child  */
107
/*                                          widget clipping areas.        */
108
/*                                                                        */
109
/*                                                                        */
110
/*  OUTPUT                                                                */
111
/*                                                                        */
112
/*    status                                Completion status             */
113
/*                                                                        */
114
/*  CALLS                                                                 */
115
/*                                                                        */
116
/*    _gx_widget_scroll_shift_helper        Scroll a widget               */
117
/*    _gx_widget_clipping_update            Update the clipping area      */
118
/*                                                                        */
119
/*  CALLED BY                                                             */
120
/*                                                                        */
121
/*    Application Code                                                    */
122
/*    GUIX Internal Code                                                  */
123
/*                                                                        */
124
/**************************************************************************/
125
15479
UINT  _gx_widget_scroll_shift(GX_WIDGET *widget, INT xShift, INT yShift, GX_BOOL clip)
126
{
127
GX_WIDGET *child;
128
129
    /* first, check to see if the old and new size are the same */
130
131

15479
    if (xShift == 0 && yShift == 0)
132
    {
133
90
        return GX_SUCCESS;
134
    }
135
136
15389
    _gx_widget_scroll_shift_helper(widget, xShift, yShift);
137
138
    /* pick up pointer to first child widget */
139
15389
    child = widget -> gx_widget_first_child;
140
141
    /* loop through and shift all my child widgets */
142
17876
    while (child)
143
    {
144
5352
        _gx_widget_scroll_shift_helper(child, xShift, yShift);
145
146
5352
        if (child -> gx_widget_first_child)
147
        {
148
162
            child = child -> gx_widget_first_child;
149
162
            continue;
150
        }
151
152

8217
        while ((child -> gx_widget_next == GX_NULL) && (child != widget))
153
        {
154
3027
            child = child -> gx_widget_parent;
155
        }
156
157
5190
        if (child == widget)
158
        {
159
2865
            break;
160
        }
161
162
2325
        child = child -> gx_widget_next;
163
    }
164
165

15389
    if (clip && (widget -> gx_widget_status & GX_STATUS_VISIBLE))
166
    {
167
14848
        _gx_widget_clipping_update(widget);
168
    }
169
170
15389
    return(GX_SUCCESS);
171
}
172