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 |
|
|
/** 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 |
|
|
/**************************************************************************/ |
71 |
|
76 |
UINT _gx_window_client_scroll(GX_WINDOW *window, GX_VALUE x_scroll, GX_VALUE y_scroll) |
72 |
|
|
{ |
73 |
|
|
GX_SCROLLBAR *scroll; |
74 |
|
|
INT scroll_value; |
75 |
|
|
|
76 |
|
|
/* This function is designed to be called by the application, i.e. not driven |
77 |
|
|
by the user operating a scrollbar. However if the window does have scrollbars, |
78 |
|
|
we will satisfy the scrolling request by assigning the scroll bar value. |
79 |
|
|
*/ |
80 |
|
76 |
scroll = GX_NULL; |
81 |
|
|
|
82 |
✓✓ |
76 |
if (x_scroll) |
83 |
|
|
{ |
84 |
|
63 |
_gx_window_scrollbar_find(window, (USHORT)GX_TYPE_HORIZONTAL_SCROLL, &scroll); |
85 |
|
|
|
86 |
✓✓ |
63 |
if (scroll) |
87 |
|
|
{ |
88 |
|
59 |
scroll_value = scroll -> gx_scrollbar_info.gx_scroll_value; |
89 |
|
59 |
scroll_value = scroll_value - x_scroll; |
90 |
|
|
|
91 |
|
|
/* this function will generate a scroll event, which will cause |
92 |
|
|
the parent window to scroll |
93 |
|
|
*/ |
94 |
|
59 |
_gx_scrollbar_value_set(scroll, scroll_value); |
95 |
|
59 |
x_scroll = 0; |
96 |
|
|
} |
97 |
|
|
} |
98 |
|
|
|
99 |
✓✓ |
76 |
if (y_scroll) |
100 |
|
|
{ |
101 |
|
75 |
_gx_window_scrollbar_find(window, GX_TYPE_VERTICAL_SCROLL, &scroll); |
102 |
|
|
|
103 |
✓✓ |
75 |
if (scroll) |
104 |
|
|
{ |
105 |
|
71 |
scroll_value = scroll -> gx_scrollbar_info.gx_scroll_value; |
106 |
|
71 |
scroll_value = scroll_value - y_scroll; |
107 |
|
71 |
_gx_scrollbar_value_set(scroll, scroll_value); |
108 |
|
71 |
y_scroll = 0; |
109 |
|
|
} |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
/* If we get to here with non-zero scroll values, the window is being |
113 |
|
|
scrolled with no scrollbars. |
114 |
|
|
Manually invoke the _gx_window_scroll functions to accomplish |
115 |
|
|
the requested scrolling |
116 |
|
|
*/ |
117 |
|
|
|
118 |
✓✓ |
76 |
if (x_scroll) |
119 |
|
|
{ |
120 |
✓✓ |
4 |
if (y_scroll) |
121 |
|
|
{ |
122 |
|
|
/* If we are scrolling both x and y, we need to do two |
123 |
|
|
operations for the block-move to work correctly |
124 |
|
|
*/ |
125 |
|
1 |
_gx_window_scroll(window, x_scroll, 0); |
126 |
|
1 |
_gx_window_scroll(window, 0, y_scroll); |
127 |
|
|
} |
128 |
|
|
else |
129 |
|
|
{ |
130 |
|
|
/* just scrolling in x */ |
131 |
|
3 |
_gx_window_scroll(window, x_scroll, 0); |
132 |
|
|
} |
133 |
|
|
} |
134 |
|
|
else |
135 |
|
|
{ |
136 |
|
|
/* just scrolling in y */ |
137 |
|
72 |
_gx_window_scroll(window, 0, y_scroll); |
138 |
|
|
} |
139 |
|
|
|
140 |
|
76 |
return GX_SUCCESS; |
141 |
|
|
} |
142 |
|
|
|