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_system.h"
28 #include "gx_utility.h"
29 #include "gx_widget.h"
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _gx_widget_scroll_shift_helper PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Kenneth Maxwell, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* Internal helper function to change the position of a widget. */
44 /* It also adds a dirty entry if required. */
45 /* */
46 /* INPUT */
47 /* */
48 /* widget Widget control block */
49 /* xShift The x-axis shift amount */
50 /* yShift The y-axis shift amount */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* status Completion status */
55 /* */
56 /* CALLS */
57 /* */
58 /* _gx_utility_rectangle_shift Shift a rectangle */
59 /* _gx_system_dirty_entry_shift Mark partial widget area dirty*/
60 /* */
61 /* CALLED BY */
62 /* */
63 /* _gx_widget_scroll_shift */
64 /* */
65 /* RELEASE HISTORY */
66 /* */
67 /* DATE NAME DESCRIPTION */
68 /* */
69 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
70 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
71 /* resulting in version 6.1 */
72 /* */
73 /**************************************************************************/
_gx_widget_scroll_shift_helper(GX_WIDGET * widget,INT xShift,INT yShift)74 static VOID _gx_widget_scroll_shift_helper(GX_WIDGET *widget, INT xShift, INT yShift)
75 {
76 GX_WINDOW *win;
77
78 _gx_utility_rectangle_shift(&widget -> gx_widget_size, (GX_VALUE)xShift, (GX_VALUE)yShift);
79
80 if (widget -> gx_widget_type >= GX_TYPE_WINDOW)
81 {
82 win = (GX_WINDOW *)widget;
83 _gx_utility_rectangle_shift(&win -> gx_window_client, (GX_VALUE)xShift, (GX_VALUE)yShift);
84 }
85
86 if (widget -> gx_widget_status & GX_STATUS_DIRTY)
87 {
88 /* mark it dirty again so that the new position is recorded */
89 _gx_system_dirty_entry_shift(widget, xShift, yShift);
90 }
91 }
92
93 /**************************************************************************/
94 /* */
95 /* FUNCTION RELEASE */
96 /* */
97 /* _gx_widget_scroll_shift PORTABLE C */
98 /* 6.1 */
99 /* AUTHOR */
100 /* */
101 /* Kenneth Maxwell, Microsoft Corporation */
102 /* */
103 /* DESCRIPTION */
104 /* */
105 /* This function changes the position of a widget. It also adds */
106 /* a dirty entry if required */
107 /* */
108 /* INPUT */
109 /* */
110 /* widget Widget control block */
111 /* xShift The x-axis shift amount */
112 /* yShift The y-axis shift amount */
113 /* clip Flag, should we update child */
114 /* widget clipping areas. */
115 /* */
116 /* */
117 /* OUTPUT */
118 /* */
119 /* status Completion status */
120 /* */
121 /* CALLS */
122 /* */
123 /* _gx_widget_scroll_shift_helper Scroll a widget */
124 /* _gx_widget_clipping_update Update the clipping area */
125 /* */
126 /* CALLED BY */
127 /* */
128 /* Application Code */
129 /* GUIX Internal Code */
130 /* */
131 /* RELEASE HISTORY */
132 /* */
133 /* DATE NAME DESCRIPTION */
134 /* */
135 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
136 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
137 /* resulting in version 6.1 */
138 /* */
139 /**************************************************************************/
_gx_widget_scroll_shift(GX_WIDGET * widget,INT xShift,INT yShift,GX_BOOL clip)140 UINT _gx_widget_scroll_shift(GX_WIDGET *widget, INT xShift, INT yShift, GX_BOOL clip)
141 {
142 GX_WIDGET *child;
143
144 /* first, check to see if the old and new size are the same */
145
146 if (xShift == 0 && yShift == 0)
147 {
148 return GX_SUCCESS;
149 }
150
151 _gx_widget_scroll_shift_helper(widget, xShift, yShift);
152
153 /* pick up pointer to first child widget */
154 child = widget -> gx_widget_first_child;
155
156 /* loop through and shift all my child widgets */
157 while (child)
158 {
159 _gx_widget_scroll_shift_helper(child, xShift, yShift);
160
161 if (child -> gx_widget_first_child)
162 {
163 child = child -> gx_widget_first_child;
164 continue;
165 }
166
167 while ((child -> gx_widget_next == GX_NULL) && (child != widget))
168 {
169 child = child -> gx_widget_parent;
170 }
171
172 if (child == widget)
173 {
174 break;
175 }
176
177 child = child -> gx_widget_next;
178 }
179
180 if (clip && (widget -> gx_widget_status & GX_STATUS_VISIBLE))
181 {
182 _gx_widget_clipping_update(widget);
183 }
184
185 return(GX_SUCCESS);
186 }
187
188