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 /** Window Management (Window) */
19 /** */
20 /**************************************************************************/
21
22 #define GX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "gx_api.h"
28 #include "gx_widget.h"
29 #include "gx_window.h"
30 #include "gx_system.h"
31 #include "gx_display.h"
32 #include "gx_canvas.h"
33 #include "gx_utility.h"
34 #include "gx_scrollbar.h"
35
36 /**************************************************************************/
37 /* */
38 /* FUNCTION RELEASE */
39 /* */
40 /* _gx_window_client_scroll PORTABLE C */
41 /* 6.1 */
42 /* AUTHOR */
43 /* */
44 /* Kenneth Maxwell, Microsoft Corporation */
45 /* */
46 /* DESCRIPTION */
47 /* */
48 /* This service scrolls the window client area by the specified amount */
49 /* */
50 /* */
51 /* INPUT */
52 /* */
53 /* window Pointer to window */
54 /* x_scroll Amount to scroll on x-axis */
55 /* y_scroll Amount to scroll on y-axis */
56 /* */
57 /* OUTPUT */
58 /* */
59 /* status Completion status */
60 /* */
61 /* CALLS */
62 /* */
63 /* _gx_widget_scroll main scroll function */
64 /* _gx_scrollbar_value_set reset scrollbar thumb pos */
65 /* */
66 /* CALLED BY */
67 /* */
68 /* Application Code */
69 /* */
70 /* RELEASE HISTORY */
71 /* */
72 /* DATE NAME DESCRIPTION */
73 /* */
74 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
75 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
76 /* resulting in version 6.1 */
77 /* */
78 /**************************************************************************/
_gx_window_client_scroll(GX_WINDOW * window,GX_VALUE x_scroll,GX_VALUE y_scroll)79 UINT _gx_window_client_scroll(GX_WINDOW *window, GX_VALUE x_scroll, GX_VALUE y_scroll)
80 {
81 GX_SCROLLBAR *scroll;
82 INT scroll_value;
83
84 /* This function is designed to be called by the application, i.e. not driven
85 by the user operating a scrollbar. However if the window does have scrollbars,
86 we will satisfy the scrolling request by assigning the scroll bar value.
87 */
88 scroll = GX_NULL;
89
90 if (x_scroll)
91 {
92 _gx_window_scrollbar_find(window, (USHORT)GX_TYPE_HORIZONTAL_SCROLL, &scroll);
93
94 if (scroll)
95 {
96 scroll_value = scroll -> gx_scrollbar_info.gx_scroll_value;
97 scroll_value = scroll_value - x_scroll;
98
99 /* this function will generate a scroll event, which will cause
100 the parent window to scroll
101 */
102 _gx_scrollbar_value_set(scroll, scroll_value);
103 x_scroll = 0;
104 }
105 }
106
107 if (y_scroll)
108 {
109 _gx_window_scrollbar_find(window, GX_TYPE_VERTICAL_SCROLL, &scroll);
110
111 if (scroll)
112 {
113 scroll_value = scroll -> gx_scrollbar_info.gx_scroll_value;
114 scroll_value = scroll_value - y_scroll;
115 _gx_scrollbar_value_set(scroll, scroll_value);
116 y_scroll = 0;
117 }
118 }
119
120 /* If we get to here with non-zero scroll values, the window is being
121 scrolled with no scrollbars.
122 Manually invoke the _gx_window_scroll functions to accomplish
123 the requested scrolling
124 */
125
126 if (x_scroll)
127 {
128 if (y_scroll)
129 {
130 /* If we are scrolling both x and y, we need to do two
131 operations for the block-move to work correctly
132 */
133 _gx_window_scroll(window, x_scroll, 0);
134 _gx_window_scroll(window, 0, y_scroll);
135 }
136 else
137 {
138 /* just scrolling in x */
139 _gx_window_scroll(window, x_scroll, 0);
140 }
141 }
142 else
143 {
144 /* just scrolling in y */
145 _gx_window_scroll(window, 0, y_scroll);
146 }
147
148 return GX_SUCCESS;
149 }
150
151