1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
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 /* 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 /**************************************************************************/
_gx_widget_scroll_shift_helper(GX_WIDGET * widget,INT xShift,INT yShift)75 static VOID _gx_widget_scroll_shift_helper(GX_WIDGET *widget, INT xShift, INT yShift)
76 {
77 GX_WINDOW *win;
78
79 _gx_utility_rectangle_shift(&widget -> gx_widget_size, (GX_VALUE)xShift, (GX_VALUE)yShift);
80
81 if (widget -> gx_widget_type >= GX_TYPE_WINDOW)
82 {
83 win = (GX_WINDOW *)widget;
84 _gx_utility_rectangle_shift(&win -> gx_window_client, (GX_VALUE)xShift, (GX_VALUE)yShift);
85 }
86
87 if (widget -> gx_widget_status & GX_STATUS_DIRTY)
88 {
89 /* mark it dirty again so that the new position is recorded */
90 _gx_system_dirty_entry_shift(widget, xShift, yShift);
91 }
92 }
93
94 /**************************************************************************/
95 /* */
96 /* FUNCTION RELEASE */
97 /* */
98 /* _gx_widget_scroll_shift PORTABLE C */
99 /* 6.1 */
100 /* AUTHOR */
101 /* */
102 /* Kenneth Maxwell, Microsoft Corporation */
103 /* */
104 /* DESCRIPTION */
105 /* */
106 /* This function changes the position of a widget. It also adds */
107 /* a dirty entry if required */
108 /* */
109 /* INPUT */
110 /* */
111 /* widget Widget control block */
112 /* xShift The x-axis shift amount */
113 /* yShift The y-axis shift amount */
114 /* clip Flag, should we update child */
115 /* widget clipping areas. */
116 /* */
117 /* */
118 /* OUTPUT */
119 /* */
120 /* status Completion status */
121 /* */
122 /* CALLS */
123 /* */
124 /* _gx_widget_scroll_shift_helper Scroll a widget */
125 /* _gx_widget_clipping_update Update the clipping area */
126 /* */
127 /* CALLED BY */
128 /* */
129 /* Application Code */
130 /* GUIX Internal Code */
131 /* */
132 /* RELEASE HISTORY */
133 /* */
134 /* DATE NAME DESCRIPTION */
135 /* */
136 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
137 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
138 /* resulting in version 6.1 */
139 /* */
140 /**************************************************************************/
_gx_widget_scroll_shift(GX_WIDGET * widget,INT xShift,INT yShift,GX_BOOL clip)141 UINT _gx_widget_scroll_shift(GX_WIDGET *widget, INT xShift, INT yShift, GX_BOOL clip)
142 {
143 GX_WIDGET *child;
144
145 /* first, check to see if the old and new size are the same */
146
147 if (xShift == 0 && yShift == 0)
148 {
149 return GX_SUCCESS;
150 }
151
152 _gx_widget_scroll_shift_helper(widget, xShift, yShift);
153
154 /* pick up pointer to first child widget */
155 child = widget -> gx_widget_first_child;
156
157 /* loop through and shift all my child widgets */
158 while (child)
159 {
160 _gx_widget_scroll_shift_helper(child, xShift, yShift);
161
162 if (child -> gx_widget_first_child)
163 {
164 child = child -> gx_widget_first_child;
165 continue;
166 }
167
168 while ((child -> gx_widget_next == GX_NULL) && (child != widget))
169 {
170 child = child -> gx_widget_parent;
171 }
172
173 if (child == widget)
174 {
175 break;
176 }
177
178 child = child -> gx_widget_next;
179 }
180
181 if (clip && (widget -> gx_widget_status & GX_STATUS_VISIBLE))
182 {
183 _gx_widget_clipping_update(widget);
184 }
185
186 return(GX_SUCCESS);
187 }
188
189