1 | /* $Id: scroll.cpp,v 1.20 1999-11-10 17:11:30 cbratschi Exp $ */
|
---|
2 | /*
|
---|
3 | * Scrollbar control
|
---|
4 | *
|
---|
5 | * Copyright 1999 Christoph Bratschi
|
---|
6 | *
|
---|
7 | * Copyright 1993 Martin Ayotte
|
---|
8 | * Copyright 1994, 1996 Alexandre Julliard
|
---|
9 | *
|
---|
10 | * WINE version: 990923
|
---|
11 | *
|
---|
12 | * Status: complete
|
---|
13 | * Version: 5.00
|
---|
14 | */
|
---|
15 |
|
---|
16 | #include <stdlib.h>
|
---|
17 | #include <os2win.h>
|
---|
18 | #include "controls.h"
|
---|
19 | #include "scroll.h"
|
---|
20 | #include "win32wbase.h"
|
---|
21 | #include "oslibwin.h"
|
---|
22 | #include "initterm.h"
|
---|
23 | #include "pmframe.h"
|
---|
24 |
|
---|
25 | #define SCROLL_MIN_RECT 4 /* Minimum size of the rectangle between the arrows */
|
---|
26 | #define SCROLL_MIN_THUMB 6 /* Minimum size of the thumb in pixels */
|
---|
27 |
|
---|
28 | #define SCROLL_ARROW_THUMB_OVERLAP 0 /* Overlap between arrows and thumb */
|
---|
29 |
|
---|
30 | #define SCROLL_FIRST_DELAY 200 /* Delay (in ms) before first repetition when holding the button down */
|
---|
31 | #define SCROLL_REPEAT_DELAY 50 /* Delay (in ms) between scroll repetitions */
|
---|
32 | #define SCROLL_BLINK_DELAY 1000
|
---|
33 |
|
---|
34 | #define SCROLL_TIMER 0 /* Scroll timer id */
|
---|
35 | #define BLINK_TIMER 1
|
---|
36 |
|
---|
37 | /* Scroll-bar hit testing */
|
---|
38 | enum SCROLL_HITTEST
|
---|
39 | {
|
---|
40 | SCROLL_NOWHERE, /* Outside the scroll bar */
|
---|
41 | SCROLL_TOP_ARROW, /* Top or left arrow */
|
---|
42 | SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */
|
---|
43 | SCROLL_THUMB, /* Thumb rectangle */
|
---|
44 | SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */
|
---|
45 | SCROLL_BOTTOM_ARROW /* Bottom or right arrow */
|
---|
46 | };
|
---|
47 |
|
---|
48 | /* What to do in SetScrollInfo() */
|
---|
49 | #define SA_SSI_HIDE 0x0001
|
---|
50 | #define SA_SSI_SHOW 0x0002
|
---|
51 | #define SA_SSI_REPAINT_INTERIOR 0x0004
|
---|
52 | #define SA_SSI_REPAINT_ARROWS 0x0008
|
---|
53 | #define SA_SSI_MOVE_THUMB 0x0010
|
---|
54 | #define SA_SSI_REFRESH 0x0020
|
---|
55 |
|
---|
56 | /* Thumb-tracking info */
|
---|
57 | static HWND SCROLL_TrackingWin = 0;
|
---|
58 | static INT SCROLL_TrackingBar = 0;
|
---|
59 | static INT SCROLL_TrackingPos = 0;
|
---|
60 | static INT SCROLL_TrackingVal = 0;
|
---|
61 | /* Focus info */
|
---|
62 | static HWND SCROLL_FocusWin = 0;
|
---|
63 | static BOOL SCROLL_HasFocus = FALSE;
|
---|
64 | static BOOL SCROLL_Highlighted = FALSE;
|
---|
65 | static BOOL SCROLL_Scrolling = FALSE;
|
---|
66 |
|
---|
67 | /* Hit test code of the last button-down event */
|
---|
68 | static enum SCROLL_HITTEST SCROLL_trackHitTest;
|
---|
69 | static enum SCROLL_HITTEST SCROLL_lastHitTest;
|
---|
70 | static BOOL SCROLL_trackVertical;
|
---|
71 |
|
---|
72 | /* Is the moving thumb being displayed? */
|
---|
73 | static BOOL SCROLL_MovingThumb = FALSE;
|
---|
74 |
|
---|
75 | // Get the scrollbar handle: works only with frame/control handles
|
---|
76 |
|
---|
77 | static HWND SCROLL_GetScrollHandle(HWND hwnd,INT nBar)
|
---|
78 | {
|
---|
79 | switch(nBar)
|
---|
80 | {
|
---|
81 | case SB_HORZ:
|
---|
82 | case SB_VERT:
|
---|
83 | {
|
---|
84 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
85 | if (!win32wnd) return 0;
|
---|
86 | if (nBar == SB_HORZ) return Win32BaseWindow::OS2ToWin32Handle(win32wnd->getHorzScrollHandle());
|
---|
87 | else return Win32BaseWindow::OS2ToWin32Handle(win32wnd->getVertScrollHandle());
|
---|
88 | }
|
---|
89 | case SB_CTL:
|
---|
90 | return hwnd;
|
---|
91 |
|
---|
92 | default:
|
---|
93 | return 0;
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|
97 | static HWND SCROLL_GetFrameHandle(HWND hwnd)
|
---|
98 | {
|
---|
99 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
100 |
|
---|
101 | if (!win32wnd) return 0;
|
---|
102 | return Win32BaseWindow::GetWindowFromOS2FrameHandle(OSLibWinQueryWindow(win32wnd->getOS2WindowHandle(),QWOS_OWNER))->getWindowHandle();
|
---|
103 | }
|
---|
104 |
|
---|
105 | // Get the infoPtr: works only with scrollbar handles
|
---|
106 |
|
---|
107 | static SCROLLBAR_INFO *SCROLL_GetInfoPtr( HWND hwnd, INT nBar )
|
---|
108 | {
|
---|
109 | Win32BaseWindow *win32wnd;
|
---|
110 | HWND hwndFrame;
|
---|
111 |
|
---|
112 | switch(nBar)
|
---|
113 | {
|
---|
114 | case SB_HORZ:
|
---|
115 | case SB_VERT:
|
---|
116 | win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
117 | if (!win32wnd) return NULL;
|
---|
118 | hwndFrame = OSLibWinQueryWindow(win32wnd->getOS2WindowHandle(),QWOS_OWNER);
|
---|
119 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndFrame);
|
---|
120 | if (!win32wnd) return NULL;
|
---|
121 | return win32wnd->getScrollInfo(nBar);
|
---|
122 |
|
---|
123 | case SB_CTL:
|
---|
124 | return (SCROLLBAR_INFO*)GetInfoPtr(hwnd);
|
---|
125 | }
|
---|
126 |
|
---|
127 | return NULL;
|
---|
128 | }
|
---|
129 |
|
---|
130 | /* Scrollbar Functions */
|
---|
131 |
|
---|
132 | /***********************************************************************
|
---|
133 | * SCROLL_GetScrollBarRect
|
---|
134 | *
|
---|
135 | * Compute the scroll bar rectangle, in drawing coordinates (i.e. client
|
---|
136 | * coords for SB_CTL, window coords for SB_VERT and SB_HORZ).
|
---|
137 | * 'arrowSize' returns the width or height of an arrow (depending on
|
---|
138 | * the orientation of the scrollbar), 'thumbSize' returns the size of
|
---|
139 | * the thumb, and 'thumbPos' returns the position of the thumb
|
---|
140 | * relative to the left or to the top.
|
---|
141 | * Return TRUE if the scrollbar is vertical, FALSE if horizontal.
|
---|
142 | */
|
---|
143 | static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect,
|
---|
144 | INT *arrowSize, INT *thumbSize,
|
---|
145 | INT *thumbPos )
|
---|
146 | {
|
---|
147 | INT pixels;
|
---|
148 | BOOL vertical;
|
---|
149 | RECT rectClient;
|
---|
150 |
|
---|
151 | switch(nBar)
|
---|
152 | {
|
---|
153 | case SB_HORZ:
|
---|
154 | case SB_VERT:
|
---|
155 | GetClientRect( hwnd, lprect );
|
---|
156 | vertical = (nBar == SB_VERT);
|
---|
157 | break;
|
---|
158 |
|
---|
159 | case SB_CTL:
|
---|
160 | {
|
---|
161 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
162 |
|
---|
163 | GetClientRect( hwnd, lprect );
|
---|
164 | vertical = ((dwStyle & SBS_VERT) != 0);
|
---|
165 | break;
|
---|
166 | }
|
---|
167 |
|
---|
168 | default:
|
---|
169 | return FALSE;
|
---|
170 | }
|
---|
171 |
|
---|
172 | if (vertical) pixels = lprect->bottom - lprect->top;
|
---|
173 | else pixels = lprect->right - lprect->left;
|
---|
174 |
|
---|
175 | if (pixels <= 2*GetSystemMetrics(SM_CXVSCROLL) + SCROLL_MIN_RECT)
|
---|
176 | {
|
---|
177 | if (pixels > SCROLL_MIN_RECT)
|
---|
178 | *arrowSize = (pixels - SCROLL_MIN_RECT) / 2;
|
---|
179 | else
|
---|
180 | *arrowSize = 0;
|
---|
181 | *thumbPos = *thumbSize = 0;
|
---|
182 | }
|
---|
183 | else
|
---|
184 | {
|
---|
185 | SCROLLBAR_INFO *info = SCROLL_GetInfoPtr( hwnd, nBar );
|
---|
186 |
|
---|
187 | *arrowSize = GetSystemMetrics(SM_CXVSCROLL);
|
---|
188 | pixels -= (2 * (GetSystemMetrics(SM_CXVSCROLL) - SCROLL_ARROW_THUMB_OVERLAP));
|
---|
189 |
|
---|
190 | if (info->Page)
|
---|
191 | {
|
---|
192 | *thumbSize = pixels * info->Page / (info->MaxVal-info->MinVal+1);
|
---|
193 | if (*thumbSize < SCROLL_MIN_THUMB) *thumbSize = SCROLL_MIN_THUMB;
|
---|
194 | }
|
---|
195 | else *thumbSize = GetSystemMetrics(SM_CXVSCROLL);
|
---|
196 |
|
---|
197 | if (((pixels -= *thumbSize ) < 0) ||
|
---|
198 | ((info->flags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH))
|
---|
199 | {
|
---|
200 | /* Rectangle too small or scrollbar disabled -> no thumb */
|
---|
201 | *thumbPos = *thumbSize = 0;
|
---|
202 | }
|
---|
203 | else
|
---|
204 | {
|
---|
205 | INT max = info->MaxVal - MAX( info->Page-1, 0 );
|
---|
206 | if (info->MinVal >= max)
|
---|
207 | *thumbPos = *arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
|
---|
208 | else
|
---|
209 | *thumbPos = *arrowSize - SCROLL_ARROW_THUMB_OVERLAP
|
---|
210 | + pixels * (info->CurVal-info->MinVal) / (max - info->MinVal);
|
---|
211 | }
|
---|
212 | }
|
---|
213 | return vertical;
|
---|
214 | }
|
---|
215 |
|
---|
216 | /***********************************************************************
|
---|
217 | * SCROLL_PtInRectEx
|
---|
218 | */
|
---|
219 | static BOOL SCROLL_PtInRectEx( LPRECT lpRect, POINT pt, BOOL vertical )
|
---|
220 | {
|
---|
221 | RECT rect = *lpRect;
|
---|
222 |
|
---|
223 | if (vertical)
|
---|
224 | {
|
---|
225 | INT w = lpRect->right-lpRect->left;
|
---|
226 |
|
---|
227 | rect.left -= w;
|
---|
228 | rect.right += w;
|
---|
229 | rect.top -= w;
|
---|
230 | rect.bottom += w;
|
---|
231 | } else
|
---|
232 | {
|
---|
233 | INT h = lpRect->bottom-lpRect->top;
|
---|
234 |
|
---|
235 | rect.top -= h;
|
---|
236 | rect.bottom += h;
|
---|
237 | rect.left -= h;
|
---|
238 | rect.right += h;
|
---|
239 | }
|
---|
240 |
|
---|
241 | return PtInRect( &rect, pt );
|
---|
242 | }
|
---|
243 |
|
---|
244 | /***********************************************************************
|
---|
245 | * SCROLL_HitTest
|
---|
246 | *
|
---|
247 | * Scroll-bar hit testing (don't confuse this with WM_NCHITTEST!).
|
---|
248 | */
|
---|
249 | static enum SCROLL_HITTEST SCROLL_HitTest( HWND hwnd, INT nBar,
|
---|
250 | POINT pt, BOOL bDragging )
|
---|
251 | {
|
---|
252 | INT arrowSize, thumbSize, thumbPos;
|
---|
253 | RECT rect;
|
---|
254 | SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr(hwnd,nBar);
|
---|
255 |
|
---|
256 | if (!infoPtr) return SCROLL_NOWHERE;
|
---|
257 |
|
---|
258 | BOOL vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
|
---|
259 | &arrowSize, &thumbSize, &thumbPos );
|
---|
260 |
|
---|
261 | if ( (bDragging && !SCROLL_PtInRectEx( &rect, pt, vertical )) ||
|
---|
262 | (!PtInRect( &rect, pt )) ) return SCROLL_NOWHERE;
|
---|
263 |
|
---|
264 | if (vertical)
|
---|
265 | {
|
---|
266 | if (pt.y < rect.top + arrowSize) return (infoPtr->flags & ESB_DISABLE_LTUP) ? SCROLL_NOWHERE:SCROLL_TOP_ARROW;
|
---|
267 | if (pt.y >= rect.bottom - arrowSize) return (infoPtr->flags & ESB_DISABLE_RTDN) ? SCROLL_NOWHERE:SCROLL_BOTTOM_ARROW;
|
---|
268 | if (!thumbPos) return SCROLL_TOP_RECT;
|
---|
269 | pt.y -= rect.top;
|
---|
270 | if (pt.y < thumbPos) return SCROLL_TOP_RECT;
|
---|
271 | if (pt.y >= thumbPos + thumbSize) return SCROLL_BOTTOM_RECT;
|
---|
272 | }
|
---|
273 | else /* horizontal */
|
---|
274 | {
|
---|
275 | if (pt.x < rect.left + arrowSize) return (infoPtr->flags & ESB_DISABLE_LTUP) ? SCROLL_NOWHERE:SCROLL_TOP_ARROW;
|
---|
276 | if (pt.x >= rect.right - arrowSize) return (infoPtr->flags & ESB_DISABLE_RTDN) ? SCROLL_NOWHERE:SCROLL_BOTTOM_ARROW;
|
---|
277 | if (!thumbPos) return SCROLL_TOP_RECT;
|
---|
278 | pt.x -= rect.left;
|
---|
279 | if (pt.x < thumbPos) return SCROLL_TOP_RECT;
|
---|
280 | if (pt.x >= thumbPos + thumbSize) return SCROLL_BOTTOM_RECT;
|
---|
281 | }
|
---|
282 | return SCROLL_THUMB;
|
---|
283 | }
|
---|
284 |
|
---|
285 | static void SCROLL_DrawTopArrow(HDC hdc,SCROLLBAR_INFO *infoPtr,RECT *rect,INT arrowSize,BOOL vertical,BOOL top_pressed)
|
---|
286 | {
|
---|
287 | RECT r;
|
---|
288 |
|
---|
289 | r = *rect;
|
---|
290 | if( vertical )
|
---|
291 | r.bottom = r.top + arrowSize;
|
---|
292 | else
|
---|
293 | r.right = r.left + arrowSize;
|
---|
294 |
|
---|
295 | DrawFrameControl( hdc, &r, DFC_SCROLL,
|
---|
296 | (vertical ? DFCS_SCROLLUP : DFCS_SCROLLLEFT)
|
---|
297 | | (top_pressed ? (DFCS_PUSHED | DFCS_FLAT) : 0 )
|
---|
298 | | (infoPtr->flags&ESB_DISABLE_LTUP ? DFCS_INACTIVE : 0 ) );
|
---|
299 | }
|
---|
300 |
|
---|
301 | static void SCROLL_DrawBottomArrow(HDC hdc,SCROLLBAR_INFO *infoPtr,RECT *rect,INT arrowSize,BOOL vertical,BOOL bottom_pressed)
|
---|
302 | {
|
---|
303 | RECT r;
|
---|
304 |
|
---|
305 | r = *rect;
|
---|
306 | if( vertical )
|
---|
307 | r.top = r.bottom-arrowSize;
|
---|
308 | else
|
---|
309 | r.left = r.right-arrowSize;
|
---|
310 |
|
---|
311 | DrawFrameControl( hdc, &r, DFC_SCROLL,
|
---|
312 | (vertical ? DFCS_SCROLLDOWN : DFCS_SCROLLRIGHT)
|
---|
313 | | (bottom_pressed ? (DFCS_PUSHED | DFCS_FLAT) : 0 )
|
---|
314 | | (infoPtr->flags&ESB_DISABLE_RTDN ? DFCS_INACTIVE : 0) );
|
---|
315 | }
|
---|
316 |
|
---|
317 | /***********************************************************************
|
---|
318 | * SCROLL_DrawArrows
|
---|
319 | *
|
---|
320 | * Draw the scroll bar arrows.
|
---|
321 | */
|
---|
322 | static void SCROLL_DrawArrows( HDC hdc, SCROLLBAR_INFO *infoPtr,
|
---|
323 | RECT *rect, INT arrowSize, BOOL vertical,
|
---|
324 | BOOL top_pressed, BOOL bottom_pressed )
|
---|
325 | {
|
---|
326 | SCROLL_DrawTopArrow(hdc,infoPtr,rect,arrowSize,vertical,top_pressed);
|
---|
327 | SCROLL_DrawBottomArrow(hdc,infoPtr,rect,arrowSize,vertical,bottom_pressed);
|
---|
328 | }
|
---|
329 |
|
---|
330 | static void SCROLL_DrawInterior( HWND hwnd, HDC hdc, INT nBar,
|
---|
331 | RECT *rect, INT arrowSize,
|
---|
332 | INT thumbSize, INT thumbPos,
|
---|
333 | UINT flags, BOOL vertical,
|
---|
334 | BOOL top_selected, BOOL bottom_selected )
|
---|
335 | {
|
---|
336 | RECT r;
|
---|
337 | HPEN hSavePen;
|
---|
338 | HBRUSH hSaveBrush,hBrush;
|
---|
339 |
|
---|
340 | /* Select the correct brush and pen */
|
---|
341 |
|
---|
342 | /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
|
---|
343 | * The window-owned scrollbars need to call DEFWND_ControlColor
|
---|
344 | * to correctly setup default scrollbar colors
|
---|
345 | */
|
---|
346 | if (nBar == SB_CTL) {
|
---|
347 | hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR,
|
---|
348 | (WPARAM)hdc,(LPARAM)hwnd);
|
---|
349 | } else {
|
---|
350 | hBrush = (HBRUSH)SendMessageA( hwnd, WM_CTLCOLORSCROLLBAR,
|
---|
351 | (WPARAM)hdc,(LPARAM)hwnd);
|
---|
352 |
|
---|
353 | }
|
---|
354 |
|
---|
355 | hSavePen = SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
|
---|
356 | hSaveBrush = SelectObject( hdc, hBrush );
|
---|
357 |
|
---|
358 | /* Calculate the scroll rectangle */
|
---|
359 |
|
---|
360 | r = *rect;
|
---|
361 | if (vertical)
|
---|
362 | {
|
---|
363 | r.top += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
|
---|
364 | r.bottom -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
---|
365 | }
|
---|
366 | else
|
---|
367 | {
|
---|
368 | r.left += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
|
---|
369 | r.right -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
---|
370 | }
|
---|
371 |
|
---|
372 | /* Draw the scroll rectangles and thumb */
|
---|
373 | if (!thumbPos) /* No thumb to draw */
|
---|
374 | {
|
---|
375 | PatBlt( hdc, r.left, r.top,
|
---|
376 | r.right - r.left, r.bottom - r.top,
|
---|
377 | PATCOPY );
|
---|
378 |
|
---|
379 | /* cleanup and return */
|
---|
380 | SelectObject( hdc, hSavePen );
|
---|
381 | SelectObject( hdc, hSaveBrush );
|
---|
382 | return;
|
---|
383 | }
|
---|
384 |
|
---|
385 | if (vertical)
|
---|
386 | {
|
---|
387 | PatBlt( hdc, r.left, r.top,
|
---|
388 | r.right - r.left,
|
---|
389 | thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
|
---|
390 | top_selected ? 0x0f0000 : PATCOPY );
|
---|
391 | r.top += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
---|
392 | PatBlt( hdc, r.left, r.top + thumbSize,
|
---|
393 | r.right - r.left,
|
---|
394 | r.bottom - r.top - thumbSize,
|
---|
395 | bottom_selected ? 0x0f0000 : PATCOPY );
|
---|
396 | r.bottom = r.top + thumbSize;
|
---|
397 | }
|
---|
398 | else /* horizontal */
|
---|
399 | {
|
---|
400 | PatBlt( hdc, r.left, r.top,
|
---|
401 | thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
|
---|
402 | r.bottom - r.top,
|
---|
403 | top_selected ? 0x0f0000 : PATCOPY );
|
---|
404 | r.left += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
---|
405 | PatBlt( hdc, r.left + thumbSize, r.top,
|
---|
406 | r.right - r.left - thumbSize,
|
---|
407 | r.bottom - r.top,
|
---|
408 | bottom_selected ? 0x0f0000 : PATCOPY );
|
---|
409 | r.right = r.left + thumbSize;
|
---|
410 | }
|
---|
411 |
|
---|
412 | /* Draw the thumb */
|
---|
413 |
|
---|
414 | DrawEdge(hdc,&r,EDGE_RAISED,BF_RECT | BF_ADJUST);
|
---|
415 | FillRect(hdc,&r,(SCROLL_FocusWin == hwnd && SCROLL_Highlighted && !SCROLL_Scrolling) ? GetSysColorBrush(COLOR_3DSHADOW):GetSysColorBrush(COLOR_BTNFACE));
|
---|
416 |
|
---|
417 | /* cleanup */
|
---|
418 | SelectObject( hdc, hSavePen );
|
---|
419 | SelectObject( hdc, hSaveBrush );
|
---|
420 | }
|
---|
421 |
|
---|
422 | /***********************************************************************
|
---|
423 | * SCROLL_DrawMovingThumb
|
---|
424 | *
|
---|
425 | * Draw the moving thumb rectangle.
|
---|
426 | */
|
---|
427 | static void SCROLL_DrawMovingThumb( HDC hdc, RECT *rect, BOOL vertical,
|
---|
428 | INT arrowSize, INT thumbSize )
|
---|
429 | {
|
---|
430 | INT pos = SCROLL_TrackingPos;
|
---|
431 | INT max_size;
|
---|
432 |
|
---|
433 | if( vertical )
|
---|
434 | max_size = rect->bottom - rect->top;
|
---|
435 | else
|
---|
436 | max_size = rect->right - rect->left;
|
---|
437 |
|
---|
438 | max_size -= (arrowSize-SCROLL_ARROW_THUMB_OVERLAP) + thumbSize;
|
---|
439 |
|
---|
440 | if( pos < (arrowSize-SCROLL_ARROW_THUMB_OVERLAP) )
|
---|
441 | pos = (arrowSize-SCROLL_ARROW_THUMB_OVERLAP);
|
---|
442 | else if( pos > max_size )
|
---|
443 | pos = max_size;
|
---|
444 |
|
---|
445 | SCROLL_DrawInterior( SCROLL_TrackingWin, hdc, SCROLL_TrackingBar,
|
---|
446 | rect, arrowSize, thumbSize, pos,
|
---|
447 | 0, vertical, FALSE, FALSE );
|
---|
448 | }
|
---|
449 |
|
---|
450 | /***********************************************************************
|
---|
451 | * SCROLL_ClipPos
|
---|
452 | */
|
---|
453 | static POINT SCROLL_ClipPos( LPRECT lpRect, POINT pt )
|
---|
454 | {
|
---|
455 | if( pt.x < lpRect->left )
|
---|
456 | pt.x = lpRect->left;
|
---|
457 | else
|
---|
458 | if( pt.x >= lpRect->right )
|
---|
459 | pt.x = lpRect->right-1;
|
---|
460 |
|
---|
461 | if( pt.y < lpRect->top )
|
---|
462 | pt.y = lpRect->top;
|
---|
463 | else
|
---|
464 | if( pt.y >= lpRect->bottom )
|
---|
465 | pt.y = lpRect->bottom-1;
|
---|
466 |
|
---|
467 | return pt;
|
---|
468 | }
|
---|
469 |
|
---|
470 | /***********************************************************************
|
---|
471 | * SCROLL_GetThumbVal
|
---|
472 | *
|
---|
473 | * Compute the current scroll position based on the thumb position in pixels
|
---|
474 | * from the top of the scroll-bar.
|
---|
475 | */
|
---|
476 | static UINT SCROLL_GetThumbVal( SCROLLBAR_INFO *infoPtr, RECT *rect,
|
---|
477 | BOOL vertical, INT pos )
|
---|
478 | {
|
---|
479 | INT thumbSize;
|
---|
480 | INT pixels = vertical ? rect->bottom-rect->top : rect->right-rect->left;
|
---|
481 |
|
---|
482 | if ((pixels -= 2*(GetSystemMetrics(SM_CXVSCROLL) - SCROLL_ARROW_THUMB_OVERLAP)) <= 0)
|
---|
483 | return infoPtr->MinVal;
|
---|
484 |
|
---|
485 | if (infoPtr->Page)
|
---|
486 | {
|
---|
487 | thumbSize = pixels * infoPtr->Page/(infoPtr->MaxVal-infoPtr->MinVal+1);
|
---|
488 | if (thumbSize < SCROLL_MIN_THUMB) thumbSize = SCROLL_MIN_THUMB;
|
---|
489 | }
|
---|
490 | else thumbSize = GetSystemMetrics(SM_CXVSCROLL);
|
---|
491 |
|
---|
492 | if ((pixels -= thumbSize) <= 0) return infoPtr->MinVal;
|
---|
493 |
|
---|
494 | pos = MAX( 0, pos - (GetSystemMetrics(SM_CXVSCROLL) - SCROLL_ARROW_THUMB_OVERLAP) );
|
---|
495 | if (pos > pixels) pos = pixels;
|
---|
496 |
|
---|
497 | if (!infoPtr->Page) pos *= infoPtr->MaxVal - infoPtr->MinVal;
|
---|
498 | else pos *= infoPtr->MaxVal - infoPtr->MinVal - infoPtr->Page + 1;
|
---|
499 | return infoPtr->MinVal + ((pos + pixels / 2) / pixels);
|
---|
500 | }
|
---|
501 |
|
---|
502 | void SCROLL_GetSizeBox(HWND hwnd,DWORD dwStyle,PRECT rect)
|
---|
503 | {
|
---|
504 | RECT clientRect;
|
---|
505 | INT cx = GetSystemMetrics(SM_CXVSCROLL);
|
---|
506 | INT cy = GetSystemMetrics(SM_CYHSCROLL);
|
---|
507 |
|
---|
508 | GetClientRect(hwnd,&clientRect);
|
---|
509 |
|
---|
510 | if (dwStyle & SBS_SIZEBOXTOPLEFTALIGN)
|
---|
511 | {
|
---|
512 | rect->left = 0;
|
---|
513 | rect->right = cx;
|
---|
514 | rect->bottom = cy;
|
---|
515 | rect->top = 0;
|
---|
516 | } else
|
---|
517 | {
|
---|
518 | rect->left = clientRect.right-cx;
|
---|
519 | rect->right = clientRect.right;
|
---|
520 | rect->bottom = clientRect.bottom;
|
---|
521 | rect->top = clientRect.bottom-cy;
|
---|
522 | }
|
---|
523 | }
|
---|
524 |
|
---|
525 | void SCROLL_DrawSizeBox(HDC hdc,RECT rect)
|
---|
526 | {
|
---|
527 | POINT p1,p2;
|
---|
528 | HPEN penDark = GetSysColorPen(COLOR_3DSHADOW);
|
---|
529 | HPEN penWhite = GetSysColorPen(COLOR_3DHILIGHT);
|
---|
530 | HPEN oldPen = SelectObject(hdc,penDark);
|
---|
531 | INT x;
|
---|
532 |
|
---|
533 | p1.x = rect.right-1;
|
---|
534 | p1.y = rect.bottom;
|
---|
535 | p2.x = rect.right;
|
---|
536 | p2.y = rect.bottom-1;
|
---|
537 | for (x = 0;x < 3;x++)
|
---|
538 | {
|
---|
539 | SelectObject(hdc,penDark);
|
---|
540 | MoveToEx(hdc,p1.x,p1.y,NULL);
|
---|
541 | LineTo(hdc,p2.x,p2.y);
|
---|
542 | p1.x--;
|
---|
543 | p2.y--;
|
---|
544 | MoveToEx(hdc,p1.x,p1.y,NULL);
|
---|
545 | LineTo(hdc,p2.x,p2.y);
|
---|
546 | SelectObject(hdc,penWhite);
|
---|
547 | p1.x--;
|
---|
548 | p2.y--;
|
---|
549 | MoveToEx(hdc,p1.x,p1.y,NULL);
|
---|
550 | LineTo(hdc,p2.x,p2.y);
|
---|
551 | p1.x -= 2;
|
---|
552 | p2.y -= 2;
|
---|
553 | }
|
---|
554 |
|
---|
555 | SelectObject(hdc,oldPen);
|
---|
556 | }
|
---|
557 |
|
---|
558 | /***********************************************************************
|
---|
559 | * SCROLL_DrawScrollBar
|
---|
560 | *
|
---|
561 | * Redraw the whole scrollbar.
|
---|
562 | */
|
---|
563 | void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar,
|
---|
564 | BOOL arrows, BOOL interior )
|
---|
565 | {
|
---|
566 | INT arrowSize, thumbSize, thumbPos;
|
---|
567 | RECT rect;
|
---|
568 | BOOL vertical;
|
---|
569 | SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr( hwnd, nBar );
|
---|
570 |
|
---|
571 | if (!infoPtr) return;
|
---|
572 | if (nBar == SB_CTL)
|
---|
573 | {
|
---|
574 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
575 |
|
---|
576 | if (dwStyle & (SBS_SIZEBOX | SBS_SIZEGRIP))
|
---|
577 | {
|
---|
578 | RECT rect;
|
---|
579 | HBRUSH hBrush;
|
---|
580 |
|
---|
581 | hdc = GetDC(hwnd);
|
---|
582 | hBrush = GetSysColorBrush(COLOR_3DFACE);
|
---|
583 | GetClientRect(hwnd,&rect);
|
---|
584 | FillRect(hdc,&rect,hBrush);
|
---|
585 |
|
---|
586 | if (dwStyle & SBS_SIZEGRIP)
|
---|
587 | {
|
---|
588 | SCROLL_GetSizeBox(hwnd,dwStyle,&rect);
|
---|
589 | SCROLL_DrawSizeBox(hdc,rect);
|
---|
590 | }
|
---|
591 |
|
---|
592 | ReleaseDC(hwnd,hdc);
|
---|
593 |
|
---|
594 | return;
|
---|
595 | }
|
---|
596 | }
|
---|
597 |
|
---|
598 | vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
|
---|
599 | &arrowSize, &thumbSize, &thumbPos );
|
---|
600 |
|
---|
601 | /* Draw the arrows */
|
---|
602 |
|
---|
603 | if (arrows && arrowSize)
|
---|
604 | {
|
---|
605 | if( vertical == SCROLL_trackVertical && GetCapture() == hwnd )
|
---|
606 | SCROLL_DrawArrows( hdc, infoPtr, &rect, arrowSize, vertical,
|
---|
607 | (SCROLL_trackHitTest == SCROLL_TOP_ARROW),
|
---|
608 | (SCROLL_trackHitTest == SCROLL_BOTTOM_ARROW) );
|
---|
609 | else
|
---|
610 | SCROLL_DrawArrows( hdc, infoPtr, &rect, arrowSize, vertical,
|
---|
611 | FALSE, FALSE );
|
---|
612 | }
|
---|
613 |
|
---|
614 | if (SCROLL_MovingThumb &&
|
---|
615 | (SCROLL_TrackingWin == hwnd) &&
|
---|
616 | (SCROLL_TrackingBar == nBar))
|
---|
617 | SCROLL_DrawMovingThumb( hdc, &rect, vertical, arrowSize, thumbSize );
|
---|
618 | else if( interior )
|
---|
619 | SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
|
---|
620 | thumbPos, infoPtr->flags, vertical, SCROLL_trackHitTest == SCROLL_TOP_RECT && SCROLL_lastHitTest == SCROLL_TOP_RECT,SCROLL_trackHitTest == SCROLL_BOTTOM_RECT && SCROLL_lastHitTest == SCROLL_BOTTOM_RECT);
|
---|
621 | }
|
---|
622 |
|
---|
623 | /***********************************************************************
|
---|
624 | * SCROLL_RefreshScrollBar
|
---|
625 | *
|
---|
626 | * Repaint the scroll bar interior after a SetScrollRange() or
|
---|
627 | * SetScrollPos() call.
|
---|
628 | */
|
---|
629 | static void SCROLL_RefreshScrollBar( HWND hwnd, INT nBar,
|
---|
630 | BOOL arrows, BOOL interior )
|
---|
631 | {
|
---|
632 | Win32BaseWindow *window;
|
---|
633 | HDC hdc;
|
---|
634 |
|
---|
635 | hdc = GetDCEx( hwnd, 0, DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW));
|
---|
636 |
|
---|
637 | if (!hdc) return;
|
---|
638 |
|
---|
639 | SCROLL_DrawScrollBar( hwnd, hdc, nBar, arrows, interior );
|
---|
640 | ReleaseDC( hwnd, hdc );
|
---|
641 | }
|
---|
642 |
|
---|
643 | /* Message Handler */
|
---|
644 |
|
---|
645 | LRESULT SCROLL_NCCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
646 | {
|
---|
647 | SCROLLBAR_INFO *infoPtr = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
---|
648 |
|
---|
649 | infoPtr->MinVal = infoPtr->CurVal = infoPtr->Page = 0;
|
---|
650 | infoPtr->MaxVal = 100;
|
---|
651 | infoPtr->flags = ESB_ENABLE_BOTH;
|
---|
652 |
|
---|
653 | SetInfoPtr(hwnd,(DWORD)infoPtr);
|
---|
654 |
|
---|
655 | return TRUE;
|
---|
656 | }
|
---|
657 |
|
---|
658 | LRESULT SCROLL_Create(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
659 | {
|
---|
660 | CREATESTRUCTA *lpCreat = (CREATESTRUCTA *)lParam;
|
---|
661 |
|
---|
662 | if (!(lpCreat->style & (SBS_SIZEBOX | SBS_SIZEGRIP)) && lpCreat->style & (SBS_LEFTALIGN | SBS_RIGHTALIGN))
|
---|
663 | {
|
---|
664 | if (lpCreat->style & SBS_VERT)
|
---|
665 | {
|
---|
666 | INT w,h;
|
---|
667 |
|
---|
668 | w = GetSystemMetrics(SM_CXVSCROLL);
|
---|
669 | h = lpCreat->cy;
|
---|
670 |
|
---|
671 | if (lpCreat->style & SBS_LEFTALIGN)
|
---|
672 | MoveWindow(hwnd,lpCreat->x,lpCreat->y,w,h,FALSE);
|
---|
673 | else if (lpCreat->style & SBS_RIGHTALIGN)
|
---|
674 | MoveWindow(hwnd,lpCreat->x+lpCreat->cx-w,lpCreat->y,w,h,FALSE);
|
---|
675 | } else /* SBS_HORZ */
|
---|
676 | {
|
---|
677 | INT w,h;
|
---|
678 |
|
---|
679 | w = lpCreat->cx;
|
---|
680 | h = GetSystemMetrics(SM_CYHSCROLL);
|
---|
681 |
|
---|
682 | if (lpCreat->style & SBS_TOPALIGN)
|
---|
683 | MoveWindow(hwnd,lpCreat->x,lpCreat->y,w,h,FALSE);
|
---|
684 | else if (lpCreat->style & SBS_BOTTOMALIGN)
|
---|
685 | MoveWindow(hwnd,lpCreat->x,lpCreat->y+lpCreat->cy-h,w,h,FALSE);
|
---|
686 | }
|
---|
687 | }
|
---|
688 |
|
---|
689 | return 0;
|
---|
690 | }
|
---|
691 |
|
---|
692 | /***********************************************************************
|
---|
693 | * SCROLL_HandleScrollEvent
|
---|
694 | *
|
---|
695 | * Handle a mouse or timer event for the scrollbar.
|
---|
696 | * 'pt' is the location of the mouse event in client (for SB_CTL) or
|
---|
697 | * windows coordinates.
|
---|
698 | */
|
---|
699 | LRESULT SCROLL_HandleScrollEvent(HWND hwnd,WPARAM wParam,LPARAM lParam,INT nBar,UINT msg)
|
---|
700 | {
|
---|
701 | static POINT prevPt; /* Previous mouse position for timer events */
|
---|
702 | static UINT trackThumbPos; /* Thumb position when tracking started. */
|
---|
703 | static INT lastClickPos; /* Position in the scroll-bar of the last button-down event. */
|
---|
704 | static INT lastMousePos; /* Position in the scroll-bar of the last mouse event. */
|
---|
705 | static BOOL timerRunning;
|
---|
706 |
|
---|
707 | enum SCROLL_HITTEST hittest;
|
---|
708 | HWND hwndOwner, hwndCtl;
|
---|
709 | BOOL vertical;
|
---|
710 | INT arrowSize, thumbSize, thumbPos;
|
---|
711 | RECT rect;
|
---|
712 | HDC hdc;
|
---|
713 | POINT pt;
|
---|
714 | LRESULT res = (msg == WM_MOUSEMOVE) ? 1:0;
|
---|
715 |
|
---|
716 | SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr(hwnd,nBar);
|
---|
717 | if (!infoPtr) return res;
|
---|
718 |
|
---|
719 | if (nBar == SB_CTL)
|
---|
720 | {
|
---|
721 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
722 |
|
---|
723 | if ((dwStyle & (SBS_SIZEBOX | SBS_SIZEGRIP)))
|
---|
724 | {
|
---|
725 | if (!(dwStyle & SBS_SIZEGRIP)) return res;
|
---|
726 |
|
---|
727 | if (msg == WM_MOUSEMOVE)
|
---|
728 | {
|
---|
729 | RECT rect;
|
---|
730 |
|
---|
731 | SCROLL_GetSizeBox(hwnd,dwStyle,&rect);
|
---|
732 | pt.x = (SHORT)LOWORD(lParam);
|
---|
733 | pt.y = (SHORT)HIWORD(lParam);
|
---|
734 |
|
---|
735 | if (PtInRect(&rect,pt))
|
---|
736 | {
|
---|
737 | SetCursor(LoadCursorA(0,IDC_SIZENWSEA));
|
---|
738 | return 0;
|
---|
739 | }
|
---|
740 | } else if (msg == WM_LBUTTONDOWN)
|
---|
741 | {
|
---|
742 | if (dwStyle & SBS_SIZEGRIP)
|
---|
743 | {
|
---|
744 | RECT rect;
|
---|
745 |
|
---|
746 | pt.x = (SHORT)LOWORD(lParam);
|
---|
747 | pt.y = (SHORT)HIWORD(lParam);
|
---|
748 | SCROLL_GetSizeBox(hwnd,dwStyle,&rect);
|
---|
749 | if (PtInRect(&rect,pt))
|
---|
750 | {
|
---|
751 | HWND hwndFrame;
|
---|
752 |
|
---|
753 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
754 | if (!win32wnd) return res;
|
---|
755 | hwndFrame = OSLibWinQueryWindow(win32wnd->getOS2WindowHandle(),QWOS_OWNER);
|
---|
756 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndFrame);
|
---|
757 | if (!win32wnd) return res;
|
---|
758 | FrameTrackFrame(win32wnd,dwStyle & SBS_SIZEBOXTOPLEFTALIGN);
|
---|
759 | }
|
---|
760 | }
|
---|
761 | }
|
---|
762 |
|
---|
763 | return res;
|
---|
764 | }
|
---|
765 | }
|
---|
766 |
|
---|
767 | if (!SCROLL_Scrolling && msg != WM_LBUTTONDOWN) return res;
|
---|
768 |
|
---|
769 | vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
|
---|
770 | &arrowSize, &thumbSize, &thumbPos );
|
---|
771 | if (nBar == SB_CTL) hwndOwner = GetParent(hwnd); else
|
---|
772 | {
|
---|
773 | Win32BaseWindow *win32wnd;
|
---|
774 | HWND hwndFrame;
|
---|
775 |
|
---|
776 | win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
777 | if (!win32wnd) return res;
|
---|
778 | hwndFrame = OSLibWinQueryWindow(win32wnd->getOS2WindowHandle(),QWOS_OWNER);
|
---|
779 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndFrame);
|
---|
780 | if (!win32wnd) return res;
|
---|
781 | hwndOwner = win32wnd->getWindowHandle();
|
---|
782 | }
|
---|
783 |
|
---|
784 | hwndCtl = (nBar == SB_CTL) ? hwnd : 0;
|
---|
785 |
|
---|
786 | switch (msg)
|
---|
787 | {
|
---|
788 | case WM_LBUTTONDOWN: /* Initialise mouse tracking */
|
---|
789 | pt.x = (SHORT)LOWORD(lParam);
|
---|
790 | pt.y = (SHORT)HIWORD(lParam);
|
---|
791 | SCROLL_trackVertical = vertical;
|
---|
792 | SCROLL_trackHitTest = hittest = SCROLL_HitTest( hwnd, nBar, pt, FALSE );
|
---|
793 | if (SCROLL_trackHitTest == SCROLL_NOWHERE) return res;
|
---|
794 | SCROLL_Scrolling = TRUE;
|
---|
795 | timerRunning = FALSE;
|
---|
796 | if (SCROLL_FocusWin == hwnd && SCROLL_Highlighted)
|
---|
797 | {
|
---|
798 | hdc = GetDCEx(hwnd,0,DCX_CACHE);
|
---|
799 | SCROLL_DrawScrollBar(hwnd,hdc,nBar,FALSE,TRUE);
|
---|
800 | ReleaseDC(hwnd,hdc);
|
---|
801 | }
|
---|
802 | lastClickPos = vertical ? pt.y:pt.x;
|
---|
803 | lastMousePos = lastClickPos;
|
---|
804 | trackThumbPos = thumbPos;
|
---|
805 | prevPt = pt;
|
---|
806 | SetCapture( hwnd );
|
---|
807 | if (nBar == SB_CTL) SetFocus( hwnd );
|
---|
808 | break;
|
---|
809 |
|
---|
810 | case WM_MOUSEMOVE:
|
---|
811 | pt.x = (SHORT)LOWORD(lParam);
|
---|
812 | pt.y = (SHORT)HIWORD(lParam);
|
---|
813 | hittest = SCROLL_HitTest( hwnd, nBar, pt, TRUE );
|
---|
814 | prevPt = pt;
|
---|
815 | break;
|
---|
816 |
|
---|
817 | case WM_LBUTTONUP:
|
---|
818 | if (SCROLL_Scrolling)
|
---|
819 | {
|
---|
820 | pt.x = (SHORT)LOWORD(lParam);
|
---|
821 | pt.y = (SHORT)HIWORD(lParam);
|
---|
822 | hittest = SCROLL_NOWHERE;
|
---|
823 | ReleaseCapture();
|
---|
824 | SCROLL_Scrolling = FALSE;
|
---|
825 | } else return res;
|
---|
826 | break;
|
---|
827 |
|
---|
828 | case WM_CAPTURECHANGED:
|
---|
829 | if (SCROLL_Scrolling)
|
---|
830 | {
|
---|
831 | hittest = SCROLL_NOWHERE;
|
---|
832 | SCROLL_Scrolling = FALSE;
|
---|
833 | } else return res;
|
---|
834 | break;
|
---|
835 |
|
---|
836 | case WM_SETFOCUS:
|
---|
837 | if (nBar == SB_CTL)
|
---|
838 | {
|
---|
839 | SCROLL_FocusWin = hwnd;
|
---|
840 | SCROLL_HasFocus = TRUE;
|
---|
841 | SCROLL_Highlighted = FALSE;
|
---|
842 | SetSystemTimer(hwnd,BLINK_TIMER,SCROLL_BLINK_DELAY,(TIMERPROC)0);
|
---|
843 | }
|
---|
844 | return res;
|
---|
845 |
|
---|
846 | case WM_KILLFOCUS:
|
---|
847 | if (SCROLL_FocusWin == hwnd)
|
---|
848 | {
|
---|
849 | SCROLL_FocusWin = 0;
|
---|
850 | SCROLL_HasFocus = FALSE;
|
---|
851 | if (SCROLL_Highlighted)
|
---|
852 | {
|
---|
853 | SCROLL_Highlighted = FALSE;
|
---|
854 | hdc = GetDCEx(hwnd,0,DCX_CACHE);
|
---|
855 | SCROLL_DrawScrollBar(hwnd,hdc,nBar,FALSE,TRUE);
|
---|
856 | ReleaseDC(hwnd,hdc);
|
---|
857 | }
|
---|
858 | KillSystemTimer(hwnd,BLINK_TIMER);
|
---|
859 | }
|
---|
860 | return res;
|
---|
861 |
|
---|
862 | case WM_SYSTIMER:
|
---|
863 | if (wParam == SCROLL_TIMER)
|
---|
864 | {
|
---|
865 | pt = prevPt;
|
---|
866 | hittest = SCROLL_HitTest( hwnd, nBar, pt, FALSE );
|
---|
867 | break;
|
---|
868 | } else if (wParam == BLINK_TIMER)
|
---|
869 | {
|
---|
870 | SCROLL_Highlighted = ~SCROLL_Highlighted;
|
---|
871 | if (!SCROLL_Scrolling)
|
---|
872 | {
|
---|
873 | hdc = GetDCEx(hwnd,0,DCX_CACHE);
|
---|
874 | SCROLL_DrawScrollBar(hwnd,hdc,nBar,FALSE,TRUE);
|
---|
875 | ReleaseDC(hwnd,hdc);
|
---|
876 | }
|
---|
877 | return res;
|
---|
878 | } else return res;
|
---|
879 |
|
---|
880 | default:
|
---|
881 | return res; /* Should never happen */
|
---|
882 | }
|
---|
883 |
|
---|
884 | hdc = GetDCEx(hwnd,0,DCX_CACHE | ((nBar == SB_CTL) ? 0:DCX_WINDOW));
|
---|
885 |
|
---|
886 | switch(SCROLL_trackHitTest)
|
---|
887 | {
|
---|
888 | case SCROLL_NOWHERE: /* No tracking in progress */
|
---|
889 | break;
|
---|
890 |
|
---|
891 | case SCROLL_TOP_ARROW:
|
---|
892 | if (msg == WM_LBUTTONUP || msg == WM_CAPTURECHANGED)
|
---|
893 | KillSystemTimer(hwnd,SCROLL_TIMER);
|
---|
894 | else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER))
|
---|
895 | {
|
---|
896 | SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
|
---|
897 | SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
|
---|
898 | (TIMERPROC)0 );
|
---|
899 | if (msg != WM_LBUTTONDOWN) timerRunning = TRUE;
|
---|
900 | }
|
---|
901 |
|
---|
902 | if (msg == WM_LBUTTONDOWN || SCROLL_lastHitTest != hittest)
|
---|
903 | {
|
---|
904 | SCROLL_DrawTopArrow(hdc,infoPtr,&rect,arrowSize,vertical,(hittest == SCROLL_trackHitTest));
|
---|
905 | SCROLL_lastHitTest = hittest;
|
---|
906 | }
|
---|
907 | if (hittest == SCROLL_trackHitTest && (msg == WM_LBUTTONDOWN || msg == WM_SYSTIMER))
|
---|
908 | SendMessageA(hwndOwner,vertical ? WM_VSCROLL:WM_HSCROLL,SB_LINEUP,hwndCtl);
|
---|
909 |
|
---|
910 | break;
|
---|
911 |
|
---|
912 | case SCROLL_TOP_RECT:
|
---|
913 | if (msg == WM_LBUTTONUP || msg == WM_CAPTURECHANGED)
|
---|
914 | KillSystemTimer(hwnd,SCROLL_TIMER);
|
---|
915 | else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER))
|
---|
916 | {
|
---|
917 | SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
|
---|
918 | SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
|
---|
919 | (TIMERPROC)0 );
|
---|
920 | if (msg != WM_LBUTTONDOWN) timerRunning = TRUE;
|
---|
921 | }
|
---|
922 |
|
---|
923 | if (msg == WM_LBUTTONDOWN || SCROLL_lastHitTest != hittest)
|
---|
924 | {
|
---|
925 | SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
|
---|
926 | thumbPos, infoPtr->flags, vertical,
|
---|
927 | (hittest == SCROLL_trackHitTest), FALSE );
|
---|
928 | SCROLL_lastHitTest = hittest;
|
---|
929 | }
|
---|
930 |
|
---|
931 | if (hittest == SCROLL_trackHitTest && (msg == WM_LBUTTONDOWN || msg == WM_SYSTIMER))
|
---|
932 | SendMessageA(hwndOwner,vertical ? WM_VSCROLL:WM_HSCROLL,SB_PAGEUP,hwndCtl);
|
---|
933 |
|
---|
934 | break;
|
---|
935 |
|
---|
936 | case SCROLL_THUMB:
|
---|
937 | if (msg == WM_LBUTTONDOWN)
|
---|
938 | {
|
---|
939 | SCROLL_TrackingWin = hwnd;
|
---|
940 | SCROLL_TrackingBar = nBar;
|
---|
941 | SCROLL_TrackingPos = trackThumbPos + lastMousePos - lastClickPos;
|
---|
942 | SCROLL_TrackingVal = infoPtr->CurVal;
|
---|
943 | SCROLL_MovingThumb = TRUE;
|
---|
944 | SCROLL_DrawMovingThumb(hdc, &rect, vertical, arrowSize, thumbSize);
|
---|
945 | } else if (msg == WM_LBUTTONUP || msg == WM_CAPTURECHANGED)
|
---|
946 | {
|
---|
947 | UINT val;
|
---|
948 | INT oldPos = infoPtr->CurVal;
|
---|
949 |
|
---|
950 | SCROLL_MovingThumb = FALSE;
|
---|
951 | SCROLL_TrackingWin = 0;
|
---|
952 | SCROLL_trackHitTest = SCROLL_NOWHERE; /* Terminate tracking */
|
---|
953 | val = SCROLL_GetThumbVal( infoPtr, &rect, vertical,
|
---|
954 | trackThumbPos + lastMousePos - lastClickPos );
|
---|
955 |
|
---|
956 | if (val != infoPtr->CurVal)
|
---|
957 | SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
|
---|
958 | MAKEWPARAM( SB_THUMBPOSITION, val ), hwndCtl );
|
---|
959 |
|
---|
960 | if (oldPos == infoPtr->CurVal)
|
---|
961 | {
|
---|
962 | vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
|
---|
963 | &arrowSize, &thumbSize, &thumbPos );
|
---|
964 | SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
|
---|
965 | thumbPos, infoPtr->flags, vertical,
|
---|
966 | FALSE, FALSE );
|
---|
967 | }
|
---|
968 |
|
---|
969 | ReleaseDC(hwnd,hdc);
|
---|
970 | return res;
|
---|
971 | } else if (msg == WM_MOUSEMOVE)
|
---|
972 | {
|
---|
973 | UINT pos;
|
---|
974 |
|
---|
975 | if (!SCROLL_PtInRectEx( &rect, pt, vertical )) pos = lastClickPos;
|
---|
976 | else
|
---|
977 | {
|
---|
978 | pt = SCROLL_ClipPos( &rect, pt );
|
---|
979 | pos = vertical ? pt.y:pt.x;
|
---|
980 | }
|
---|
981 | if (pos != lastMousePos)
|
---|
982 | {
|
---|
983 | lastMousePos = pos;
|
---|
984 | SCROLL_TrackingPos = trackThumbPos + pos - lastClickPos;
|
---|
985 | SCROLL_TrackingVal = SCROLL_GetThumbVal( infoPtr, &rect,
|
---|
986 | vertical,
|
---|
987 | SCROLL_TrackingPos );
|
---|
988 | SCROLL_DrawMovingThumb( hdc, &rect, vertical,
|
---|
989 | arrowSize, thumbSize );
|
---|
990 | SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
|
---|
991 | MAKEWPARAM( SB_THUMBTRACK, SCROLL_TrackingVal),
|
---|
992 | hwndCtl );
|
---|
993 | }
|
---|
994 | }
|
---|
995 | break;
|
---|
996 |
|
---|
997 | case SCROLL_BOTTOM_RECT:
|
---|
998 | if (msg == WM_LBUTTONUP || msg == WM_CAPTURECHANGED)
|
---|
999 | KillSystemTimer(hwnd,SCROLL_TIMER);
|
---|
1000 | else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER))
|
---|
1001 | {
|
---|
1002 | SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
|
---|
1003 | SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
|
---|
1004 | (TIMERPROC)0 );
|
---|
1005 | if (msg != WM_LBUTTONDOWN) timerRunning = TRUE;
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | if (msg == WM_LBUTTONDOWN || SCROLL_lastHitTest != hittest)
|
---|
1009 | {
|
---|
1010 | SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
|
---|
1011 | thumbPos, infoPtr->flags, vertical,
|
---|
1012 | FALSE, (hittest == SCROLL_trackHitTest) );
|
---|
1013 | SCROLL_lastHitTest = hittest;
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 | if (hittest == SCROLL_trackHitTest && (msg == WM_LBUTTONDOWN || msg == WM_SYSTIMER))
|
---|
1017 | SendMessageA(hwndOwner,vertical ? WM_VSCROLL:WM_HSCROLL,SB_PAGEDOWN,hwndCtl);
|
---|
1018 |
|
---|
1019 | break;
|
---|
1020 |
|
---|
1021 | case SCROLL_BOTTOM_ARROW:
|
---|
1022 | if (msg == WM_LBUTTONUP || msg == WM_CAPTURECHANGED)
|
---|
1023 | KillSystemTimer(hwnd,SCROLL_TIMER);
|
---|
1024 | else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER))
|
---|
1025 | {
|
---|
1026 | SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
|
---|
1027 | SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
|
---|
1028 | (TIMERPROC)0 );
|
---|
1029 | if (msg != WM_LBUTTONDOWN) timerRunning = TRUE;
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 | if (msg == WM_LBUTTONDOWN || SCROLL_lastHitTest != hittest)
|
---|
1033 | {
|
---|
1034 | SCROLL_DrawBottomArrow(hdc,infoPtr,&rect,arrowSize,vertical,(hittest == SCROLL_trackHitTest));
|
---|
1035 | SCROLL_lastHitTest = hittest;
|
---|
1036 | }
|
---|
1037 | if (hittest == SCROLL_trackHitTest && (msg == WM_LBUTTONDOWN || msg == WM_SYSTIMER))
|
---|
1038 | SendMessageA(hwndOwner,vertical ? WM_VSCROLL:WM_HSCROLL,SB_LINEDOWN,hwndCtl);
|
---|
1039 |
|
---|
1040 | break;
|
---|
1041 | }
|
---|
1042 |
|
---|
1043 | if (msg == WM_LBUTTONUP || msg == WM_CAPTURECHANGED)
|
---|
1044 | {
|
---|
1045 | SCROLL_trackHitTest = SCROLL_NOWHERE; /* Terminate tracking */
|
---|
1046 |
|
---|
1047 | SendMessageA(hwndOwner,vertical ? WM_VSCROLL:WM_HSCROLL,SB_ENDSCROLL,hwndCtl);
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 | ReleaseDC( hwnd, hdc );
|
---|
1051 |
|
---|
1052 | return res;
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 | /***********************************************************************
|
---|
1056 | * SCROLL_HandleKbdEvent
|
---|
1057 | *
|
---|
1058 | * Handle a keyboard event (only for SB_CTL scrollbars).
|
---|
1059 | */
|
---|
1060 | LRESULT SCROLL_KeyDown(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1061 | {
|
---|
1062 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
1063 | UINT msg;
|
---|
1064 |
|
---|
1065 | if (dwStyle & (SBS_SIZEBOX | SBS_SIZEGRIP)) return 0;
|
---|
1066 |
|
---|
1067 | switch(wParam)
|
---|
1068 | {
|
---|
1069 | case VK_PRIOR: msg = SB_PAGEUP; break;
|
---|
1070 | case VK_NEXT: msg = SB_PAGEDOWN; break;
|
---|
1071 | case VK_HOME: msg = SB_TOP; break;
|
---|
1072 | case VK_END: msg = SB_BOTTOM; break;
|
---|
1073 | case VK_UP: msg = SB_LINEUP; break;
|
---|
1074 | case VK_DOWN: msg = SB_LINEDOWN; break;
|
---|
1075 | default:
|
---|
1076 | return 0;
|
---|
1077 | }
|
---|
1078 | SendMessageA( GetParent(hwnd),
|
---|
1079 | (dwStyle & SBS_VERT) ? WM_VSCROLL : WM_HSCROLL,
|
---|
1080 | msg, hwnd );
|
---|
1081 |
|
---|
1082 | return 0;
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 | LRESULT SCROLL_Paint(HWND hwnd,WPARAM wParam,LPARAM lParam,INT nBar)
|
---|
1086 | {
|
---|
1087 | PAINTSTRUCT ps;
|
---|
1088 | HDC hdc = wParam ? (HDC)wParam:BeginPaint( hwnd, &ps );
|
---|
1089 |
|
---|
1090 | SCROLL_DrawScrollBar( hwnd, hdc, nBar, TRUE, TRUE );
|
---|
1091 | if (!wParam) EndPaint( hwnd, &ps );
|
---|
1092 |
|
---|
1093 | return 0;
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 | LRESULT SCROLL_SetRange(HWND hwnd,WPARAM wParam,LPARAM lParam,INT nBar,BOOL redraw)
|
---|
1097 | {
|
---|
1098 | SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr(hwnd,nBar);
|
---|
1099 | INT oldPos = infoPtr->CurVal;
|
---|
1100 |
|
---|
1101 | SetScrollRange((nBar == SB_CTL) ? hwnd:SCROLL_GetFrameHandle(hwnd),nBar,wParam,lParam,redraw);
|
---|
1102 | return (oldPos != infoPtr->CurVal) ? infoPtr->CurVal:0;
|
---|
1103 | }
|
---|
1104 |
|
---|
1105 | /* Window Procedures */
|
---|
1106 |
|
---|
1107 | /***********************************************************************
|
---|
1108 | * ScrollBarWndProc
|
---|
1109 | */
|
---|
1110 | LRESULT WINAPI ScrollBarWndProc( HWND hwnd, UINT message, WPARAM wParam,
|
---|
1111 | LPARAM lParam )
|
---|
1112 | {
|
---|
1113 | switch(message)
|
---|
1114 | {
|
---|
1115 | case WM_NCCREATE:
|
---|
1116 | return SCROLL_NCCreate(hwnd,wParam,lParam);
|
---|
1117 |
|
---|
1118 | case WM_CREATE:
|
---|
1119 | return SCROLL_Create(hwnd,wParam,lParam);
|
---|
1120 |
|
---|
1121 | case WM_LBUTTONDOWN:
|
---|
1122 | case WM_LBUTTONUP:
|
---|
1123 | case WM_CAPTURECHANGED:
|
---|
1124 | case WM_MOUSEMOVE:
|
---|
1125 | case WM_SYSTIMER:
|
---|
1126 | case WM_SETFOCUS:
|
---|
1127 | case WM_KILLFOCUS:
|
---|
1128 | return SCROLL_HandleScrollEvent(hwnd,wParam,lParam,SB_CTL,message);
|
---|
1129 |
|
---|
1130 | case WM_KEYDOWN:
|
---|
1131 | return SCROLL_KeyDown(hwnd,wParam,lParam);
|
---|
1132 |
|
---|
1133 | case WM_ERASEBKGND:
|
---|
1134 | return 1;
|
---|
1135 |
|
---|
1136 | case WM_GETDLGCODE:
|
---|
1137 | return DLGC_WANTARROWS; /* Windows returns this value */
|
---|
1138 |
|
---|
1139 | case WM_PAINT:
|
---|
1140 | return SCROLL_Paint(hwnd,wParam,lParam,SB_CTL);
|
---|
1141 |
|
---|
1142 | case SBM_SETPOS:
|
---|
1143 | return SetScrollPos( hwnd, SB_CTL, wParam, (BOOL)lParam );
|
---|
1144 |
|
---|
1145 | case SBM_GETPOS:
|
---|
1146 | return GetScrollPos( hwnd, SB_CTL );
|
---|
1147 |
|
---|
1148 | case SBM_SETRANGE:
|
---|
1149 | return SCROLL_SetRange(hwnd,wParam,lParam,SB_CTL,FALSE);
|
---|
1150 |
|
---|
1151 | case SBM_GETRANGE:
|
---|
1152 | GetScrollRange( hwnd, SB_CTL, (LPINT)wParam, (LPINT)lParam );
|
---|
1153 | return 0;
|
---|
1154 |
|
---|
1155 | case SBM_ENABLE_ARROWS:
|
---|
1156 | return EnableScrollBar( hwnd, SB_CTL, wParam );
|
---|
1157 |
|
---|
1158 | case SBM_SETRANGEREDRAW:
|
---|
1159 | return SCROLL_SetRange(hwnd,wParam,lParam,SB_CTL,TRUE);
|
---|
1160 |
|
---|
1161 | case SBM_SETSCROLLINFO:
|
---|
1162 | return SetScrollInfo(hwnd,SB_CTL,(SCROLLINFO*)lParam,wParam);
|
---|
1163 |
|
---|
1164 | case SBM_GETSCROLLINFO:
|
---|
1165 | return GetScrollInfo( hwnd, SB_CTL, (SCROLLINFO *)lParam );
|
---|
1166 |
|
---|
1167 | case 0x00e5:
|
---|
1168 | case 0x00e7:
|
---|
1169 | case 0x00e8:
|
---|
1170 | case 0x00eb:
|
---|
1171 | case 0x00ec:
|
---|
1172 | case 0x00ed:
|
---|
1173 | case 0x00ee:
|
---|
1174 | case 0x00ef:
|
---|
1175 | //ERR("unknown Win32 msg %04x wp=%08x lp=%08lx\n",
|
---|
1176 | // message, wParam, lParam );
|
---|
1177 | break;
|
---|
1178 |
|
---|
1179 | default:
|
---|
1180 | return DefWindowProcA( hwnd, message, wParam, lParam );
|
---|
1181 | }
|
---|
1182 |
|
---|
1183 | return 0;
|
---|
1184 | }
|
---|
1185 |
|
---|
1186 | /* frame handlers */
|
---|
1187 |
|
---|
1188 | VOID SCROLL_SubclassScrollBars(HWND hwndHorz,HWND hwndVert)
|
---|
1189 | {
|
---|
1190 | if (hwndHorz) SetWindowLongA(hwndHorz,GWL_WNDPROC,(ULONG)HorzScrollBarWndProc);
|
---|
1191 | if (hwndVert) SetWindowLongA(hwndVert,GWL_WNDPROC,(ULONG)VertScrollBarWndProc);
|
---|
1192 | }
|
---|
1193 |
|
---|
1194 | LRESULT WINAPI HorzScrollBarWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam )
|
---|
1195 | {
|
---|
1196 | switch (message)
|
---|
1197 | {
|
---|
1198 | case WM_LBUTTONDOWN:
|
---|
1199 | case WM_LBUTTONUP:
|
---|
1200 | case WM_CAPTURECHANGED:
|
---|
1201 | case WM_MOUSEMOVE:
|
---|
1202 | case WM_SYSTIMER:
|
---|
1203 | case WM_SETFOCUS:
|
---|
1204 | case WM_KILLFOCUS:
|
---|
1205 | return SCROLL_HandleScrollEvent(hwnd,wParam,lParam,SB_HORZ,message);
|
---|
1206 |
|
---|
1207 | case WM_ERASEBKGND:
|
---|
1208 | return 1;
|
---|
1209 |
|
---|
1210 | case WM_GETDLGCODE:
|
---|
1211 | return DLGC_WANTARROWS; /* Windows returns this value */
|
---|
1212 |
|
---|
1213 | case WM_PAINT:
|
---|
1214 | return SCROLL_Paint(hwnd,wParam,lParam,SB_HORZ);
|
---|
1215 |
|
---|
1216 | case SBM_SETPOS:
|
---|
1217 | return SetScrollPos(SCROLL_GetFrameHandle(hwnd),SB_HORZ,wParam,(BOOL)lParam);
|
---|
1218 |
|
---|
1219 | case SBM_GETPOS:
|
---|
1220 | return GetScrollPos(SCROLL_GetFrameHandle(hwnd),SB_HORZ);
|
---|
1221 |
|
---|
1222 | case SBM_SETRANGE:
|
---|
1223 | return SCROLL_SetRange(hwnd,wParam,lParam,SB_HORZ,FALSE);
|
---|
1224 |
|
---|
1225 | case SBM_GETRANGE:
|
---|
1226 | GetScrollRange(SCROLL_GetFrameHandle(hwnd),SB_HORZ,(LPINT)wParam,(LPINT)lParam);
|
---|
1227 | return 0;
|
---|
1228 |
|
---|
1229 | case SBM_ENABLE_ARROWS:
|
---|
1230 | return EnableScrollBar(SCROLL_GetFrameHandle(hwnd),SB_HORZ,wParam);
|
---|
1231 |
|
---|
1232 | case SBM_SETRANGEREDRAW:
|
---|
1233 | return SCROLL_SetRange(hwnd,wParam,lParam,SB_HORZ,TRUE);
|
---|
1234 |
|
---|
1235 | case SBM_SETSCROLLINFO:
|
---|
1236 | return SetScrollInfo(SCROLL_GetFrameHandle(hwnd),SB_HORZ,(SCROLLINFO*)lParam,wParam);
|
---|
1237 |
|
---|
1238 | case SBM_GETSCROLLINFO:
|
---|
1239 | return GetScrollInfo(SCROLL_GetFrameHandle(hwnd),SB_HORZ,(SCROLLINFO*)lParam);
|
---|
1240 |
|
---|
1241 | default:
|
---|
1242 | return DefWindowProcA(hwnd,message,wParam,lParam);
|
---|
1243 | }
|
---|
1244 |
|
---|
1245 | return 0;
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 | LRESULT WINAPI VertScrollBarWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam )
|
---|
1249 | {
|
---|
1250 | switch (message)
|
---|
1251 | {
|
---|
1252 | case WM_LBUTTONDOWN:
|
---|
1253 | case WM_LBUTTONUP:
|
---|
1254 | case WM_CAPTURECHANGED:
|
---|
1255 | case WM_MOUSEMOVE:
|
---|
1256 | case WM_SYSTIMER:
|
---|
1257 | case WM_SETFOCUS:
|
---|
1258 | case WM_KILLFOCUS:
|
---|
1259 | return SCROLL_HandleScrollEvent(hwnd,wParam,lParam,SB_VERT,message);
|
---|
1260 |
|
---|
1261 | case WM_ERASEBKGND:
|
---|
1262 | return 1;
|
---|
1263 |
|
---|
1264 | case WM_GETDLGCODE:
|
---|
1265 | return DLGC_WANTARROWS; /* Windows returns this value */
|
---|
1266 |
|
---|
1267 | case WM_PAINT:
|
---|
1268 | return SCROLL_Paint(hwnd,wParam,lParam,SB_VERT);
|
---|
1269 |
|
---|
1270 | case SBM_SETPOS:
|
---|
1271 | return SetScrollPos(SCROLL_GetFrameHandle(hwnd),SB_VERT,wParam,(BOOL)lParam);
|
---|
1272 |
|
---|
1273 | case SBM_GETPOS:
|
---|
1274 | return GetScrollPos(SCROLL_GetFrameHandle(hwnd),SB_VERT);
|
---|
1275 |
|
---|
1276 | case SBM_SETRANGE:
|
---|
1277 | return SCROLL_SetRange(hwnd,wParam,lParam,SB_VERT,FALSE);
|
---|
1278 |
|
---|
1279 | case SBM_GETRANGE:
|
---|
1280 | GetScrollRange(SCROLL_GetFrameHandle(hwnd),SB_VERT,(LPINT)wParam,(LPINT)lParam);
|
---|
1281 | return 0;
|
---|
1282 |
|
---|
1283 | case SBM_ENABLE_ARROWS:
|
---|
1284 | return EnableScrollBar(SCROLL_GetFrameHandle(hwnd),SB_VERT,wParam);
|
---|
1285 |
|
---|
1286 | case SBM_SETRANGEREDRAW:
|
---|
1287 | return SCROLL_SetRange(hwnd,wParam,lParam,SB_VERT,TRUE);
|
---|
1288 |
|
---|
1289 | case SBM_SETSCROLLINFO:
|
---|
1290 | return SetScrollInfo(SCROLL_GetFrameHandle(hwnd),SB_VERT,(SCROLLINFO*)lParam,wParam);
|
---|
1291 |
|
---|
1292 | case SBM_GETSCROLLINFO:
|
---|
1293 | return GetScrollInfo(SCROLL_GetFrameHandle(hwnd),SB_VERT,(SCROLLINFO*)lParam);
|
---|
1294 |
|
---|
1295 | default:
|
---|
1296 | return DefWindowProcA(hwnd,message,wParam,lParam);
|
---|
1297 | }
|
---|
1298 |
|
---|
1299 | return 0;
|
---|
1300 | }
|
---|
1301 |
|
---|
1302 | /* Scrollbar API */
|
---|
1303 |
|
---|
1304 | /*************************************************************************
|
---|
1305 | * SetScrollInfo (USER32.501)
|
---|
1306 | * SetScrollInfo32 can be used to set the position, upper bound,
|
---|
1307 | * lower bound, and page size of a scrollbar control.
|
---|
1308 | *
|
---|
1309 | * RETURNS
|
---|
1310 | * Scrollbar position
|
---|
1311 | *
|
---|
1312 | * NOTE
|
---|
1313 | * For 100 lines of text to be displayed in a window of 25 lines,
|
---|
1314 | * one would for instance use info->nMin=0, info->nMax=75
|
---|
1315 | * (corresponding to the 76 different positions of the window on
|
---|
1316 | * the text), and info->nPage=25.
|
---|
1317 | */
|
---|
1318 | INT WINAPI SetScrollInfo(HWND hwnd,INT nBar,const SCROLLINFO *info,BOOL bRedraw)
|
---|
1319 | {
|
---|
1320 | /* Update the scrollbar state and set action flags according to
|
---|
1321 | * what has to be done graphics wise. */
|
---|
1322 |
|
---|
1323 | SCROLLBAR_INFO *infoPtr;
|
---|
1324 | UINT new_flags;
|
---|
1325 | INT action = 0;
|
---|
1326 | HWND hwndScroll = SCROLL_GetScrollHandle(hwnd,nBar);
|
---|
1327 |
|
---|
1328 | dprintf(("USER32: SetScrollInfo"));
|
---|
1329 |
|
---|
1330 | if (!hwndScroll) return 0;
|
---|
1331 | if (!(infoPtr = SCROLL_GetInfoPtr(hwndScroll,nBar))) return 0;
|
---|
1332 | if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return 0;
|
---|
1333 | if ((info->cbSize != sizeof(*info)) &&
|
---|
1334 | (info->cbSize != sizeof(*info)-sizeof(info->nTrackPos))) return 0;
|
---|
1335 |
|
---|
1336 | /* Set the page size */
|
---|
1337 | if (info->fMask & SIF_PAGE)
|
---|
1338 | {
|
---|
1339 | if( infoPtr->Page != info->nPage )
|
---|
1340 | {
|
---|
1341 | infoPtr->Page = info->nPage;
|
---|
1342 | action |= SA_SSI_REPAINT_INTERIOR;
|
---|
1343 | }
|
---|
1344 | }
|
---|
1345 |
|
---|
1346 | /* Set the scroll pos */
|
---|
1347 | if (info->fMask & SIF_POS)
|
---|
1348 | {
|
---|
1349 | //dsprintf(scroll, " pos=%d", info->nPos );
|
---|
1350 | if( infoPtr->CurVal != info->nPos )
|
---|
1351 | {
|
---|
1352 | infoPtr->CurVal = info->nPos;
|
---|
1353 | action |= SA_SSI_MOVE_THUMB;
|
---|
1354 | }
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | /* Set the scroll range */
|
---|
1358 | if (info->fMask & SIF_RANGE)
|
---|
1359 | {
|
---|
1360 | /* Invalid range -> range is set to (0,0) */
|
---|
1361 | if ((info->nMin > info->nMax) ||
|
---|
1362 | ((UINT)(info->nMax - info->nMin) >= 0x80000000))
|
---|
1363 | {
|
---|
1364 | infoPtr->MinVal = 0;
|
---|
1365 | infoPtr->MaxVal = 0;
|
---|
1366 | }
|
---|
1367 | else
|
---|
1368 | {
|
---|
1369 | if( infoPtr->MinVal != info->nMin ||
|
---|
1370 | infoPtr->MaxVal != info->nMax )
|
---|
1371 | {
|
---|
1372 | action |= SA_SSI_REPAINT_INTERIOR;
|
---|
1373 | infoPtr->MinVal = info->nMin;
|
---|
1374 | infoPtr->MaxVal = info->nMax;
|
---|
1375 | }
|
---|
1376 | }
|
---|
1377 | }
|
---|
1378 |
|
---|
1379 | /* Make sure the page size is valid */
|
---|
1380 |
|
---|
1381 | if (infoPtr->Page < 0) infoPtr->Page = 0;
|
---|
1382 | else if (infoPtr->Page > infoPtr->MaxVal - infoPtr->MinVal + 1 )
|
---|
1383 | infoPtr->Page = infoPtr->MaxVal - infoPtr->MinVal + 1;
|
---|
1384 |
|
---|
1385 | /* Make sure the pos is inside the range */
|
---|
1386 |
|
---|
1387 | if (infoPtr->CurVal < infoPtr->MinVal)
|
---|
1388 | infoPtr->CurVal = infoPtr->MinVal;
|
---|
1389 | else if (infoPtr->CurVal > infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 ))
|
---|
1390 | infoPtr->CurVal = infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 );
|
---|
1391 |
|
---|
1392 | //TRACE(" new values: page=%d pos=%d min=%d max=%d\n",
|
---|
1393 | // infoPtr->Page, infoPtr->CurVal,
|
---|
1394 | // infoPtr->MinVal, infoPtr->MaxVal );
|
---|
1395 |
|
---|
1396 | /* Check if the scrollbar should be hidden or disabled */
|
---|
1397 | if (info->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL))
|
---|
1398 | {
|
---|
1399 | new_flags = infoPtr->flags;
|
---|
1400 | if (infoPtr->MinVal >= infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 ))
|
---|
1401 | {
|
---|
1402 | /* Hide or disable scroll-bar */
|
---|
1403 | if (info->fMask & SIF_DISABLENOSCROLL)
|
---|
1404 | {
|
---|
1405 | new_flags = ESB_DISABLE_BOTH;
|
---|
1406 | action |= SA_SSI_REFRESH;
|
---|
1407 | }
|
---|
1408 | else if (nBar != SB_CTL)
|
---|
1409 | {
|
---|
1410 | action = SA_SSI_HIDE;
|
---|
1411 | goto done;
|
---|
1412 | }
|
---|
1413 | }
|
---|
1414 | else /* Show and enable scroll-bar */
|
---|
1415 | {
|
---|
1416 | new_flags = 0;
|
---|
1417 | if (nBar != SB_CTL)
|
---|
1418 | action |= SA_SSI_SHOW;
|
---|
1419 | }
|
---|
1420 |
|
---|
1421 | if (infoPtr->flags != new_flags) /* check arrow flags */
|
---|
1422 | {
|
---|
1423 | infoPtr->flags = new_flags;
|
---|
1424 | action |= SA_SSI_REPAINT_ARROWS;
|
---|
1425 | }
|
---|
1426 | }
|
---|
1427 |
|
---|
1428 | done:
|
---|
1429 | /* Update scrollbar */
|
---|
1430 |
|
---|
1431 | if( action & SA_SSI_HIDE )
|
---|
1432 | ShowScrollBar(hwnd,nBar,FALSE);
|
---|
1433 | else
|
---|
1434 | {
|
---|
1435 | if(action & SA_SSI_SHOW)
|
---|
1436 | ShowScrollBar(hwnd,nBar,TRUE);
|
---|
1437 |
|
---|
1438 | if(bRedraw && (action & SA_SSI_REFRESH))
|
---|
1439 | SCROLL_RefreshScrollBar(hwndScroll,nBar,TRUE,TRUE);
|
---|
1440 | else
|
---|
1441 | {
|
---|
1442 | if (action & SA_SSI_REPAINT_INTERIOR || action & SA_SSI_MOVE_THUMB)
|
---|
1443 | SCROLL_RefreshScrollBar(hwndScroll,nBar,FALSE,TRUE);
|
---|
1444 | if (action & SA_SSI_REPAINT_ARROWS )
|
---|
1445 | SCROLL_RefreshScrollBar(hwndScroll,nBar,TRUE,FALSE);
|
---|
1446 | }
|
---|
1447 | }
|
---|
1448 |
|
---|
1449 | /* Return current position */
|
---|
1450 |
|
---|
1451 | return infoPtr->CurVal;
|
---|
1452 | }
|
---|
1453 | /*************************************************************************
|
---|
1454 | * GetScrollInfo (USER32.284)
|
---|
1455 | * GetScrollInfo32 can be used to retrieve the position, upper bound,
|
---|
1456 | * lower bound, and page size of a scrollbar control.
|
---|
1457 | *
|
---|
1458 | * RETURNS STD
|
---|
1459 | */
|
---|
1460 | BOOL WINAPI GetScrollInfo(
|
---|
1461 | HWND hwnd /* [I] Handle of window */ ,
|
---|
1462 | INT nBar /* [I] One of SB_HORZ, SB_VERT, or SB_CTL */,
|
---|
1463 | LPSCROLLINFO info /* [IO] (info.fMask [I] specifies which values are to retrieve) */)
|
---|
1464 | {
|
---|
1465 | SCROLLBAR_INFO *infoPtr;
|
---|
1466 |
|
---|
1467 | dprintf(("USER32: GetScrollInfo"));
|
---|
1468 |
|
---|
1469 | if (!(infoPtr = SCROLL_GetInfoPtr(SCROLL_GetScrollHandle(hwnd,nBar),nBar))) return FALSE;
|
---|
1470 | if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return FALSE;
|
---|
1471 | if ((info->cbSize != sizeof(*info)) &&
|
---|
1472 | (info->cbSize != sizeof(*info)-sizeof(info->nTrackPos))) return FALSE;
|
---|
1473 |
|
---|
1474 | if (info->fMask & SIF_PAGE) info->nPage = infoPtr->Page;
|
---|
1475 | if (info->fMask & SIF_POS) info->nPos = infoPtr->CurVal;
|
---|
1476 | if ((info->fMask & SIF_TRACKPOS) && (info->cbSize == sizeof(*info)))
|
---|
1477 | info->nTrackPos = (SCROLL_TrackingWin==hwnd) ? SCROLL_TrackingVal : infoPtr->CurVal;
|
---|
1478 | if (info->fMask & SIF_RANGE)
|
---|
1479 | {
|
---|
1480 | info->nMin = infoPtr->MinVal;
|
---|
1481 | info->nMax = infoPtr->MaxVal;
|
---|
1482 | }
|
---|
1483 | return (info->fMask & SIF_ALL) != 0;
|
---|
1484 | }
|
---|
1485 | /*************************************************************************
|
---|
1486 | * SetScrollPos (USER32.502)
|
---|
1487 | *
|
---|
1488 | * RETURNS
|
---|
1489 | * Success: Scrollbar position
|
---|
1490 | * Failure: 0
|
---|
1491 | *
|
---|
1492 | * REMARKS
|
---|
1493 | * Note the ambiguity when 0 is returned. Use GetLastError
|
---|
1494 | * to make sure there was an error (and to know which one).
|
---|
1495 | */
|
---|
1496 | INT WINAPI SetScrollPos(
|
---|
1497 | HWND hwnd /* [I] Handle of window whose scrollbar will be affected */,
|
---|
1498 | INT nBar /* [I] One of SB_HORZ, SB_VERT, or SB_CTL */,
|
---|
1499 | INT nPos /* [I] New value */,
|
---|
1500 | BOOL bRedraw /* [I] Should scrollbar be redrawn afterwards ? */ )
|
---|
1501 | {
|
---|
1502 | SCROLLINFO info;
|
---|
1503 | SCROLLBAR_INFO *infoPtr;
|
---|
1504 | INT oldPos;
|
---|
1505 |
|
---|
1506 | dprintf(("SetScrollPos %x %d %d %d", hwnd, nBar, nPos, bRedraw));
|
---|
1507 | if (!(infoPtr = SCROLL_GetInfoPtr(SCROLL_GetScrollHandle(hwnd,nBar),nBar))) return 0;
|
---|
1508 | oldPos = infoPtr->CurVal;
|
---|
1509 | info.cbSize = sizeof(info);
|
---|
1510 | info.nPos = nPos;
|
---|
1511 | info.fMask = SIF_POS;
|
---|
1512 | SetScrollInfo( hwnd, nBar, &info, bRedraw );
|
---|
1513 | return oldPos;
|
---|
1514 | }
|
---|
1515 | /*************************************************************************
|
---|
1516 | * GetScrollPos (USER32.285)
|
---|
1517 | *
|
---|
1518 | * RETURNS
|
---|
1519 | * Success: Current position
|
---|
1520 | * Failure: 0
|
---|
1521 | *
|
---|
1522 | * REMARKS
|
---|
1523 | * Note the ambiguity when 0 is returned. Use GetLastError
|
---|
1524 | * to make sure there was an error (and to know which one).
|
---|
1525 | */
|
---|
1526 | INT WINAPI GetScrollPos(
|
---|
1527 | HWND hwnd, /* [I] Handle of window */
|
---|
1528 | INT nBar /* [I] One of SB_HORZ, SB_VERT, or SB_CTL */)
|
---|
1529 | {
|
---|
1530 | SCROLLBAR_INFO *infoPtr;
|
---|
1531 |
|
---|
1532 | dprintf(("GetScrollPos %x %d", hwnd, nBar));
|
---|
1533 |
|
---|
1534 | infoPtr = SCROLL_GetInfoPtr(SCROLL_GetScrollHandle(hwnd,nBar),nBar);
|
---|
1535 | if (!infoPtr) return 0;
|
---|
1536 |
|
---|
1537 | return infoPtr->CurVal;
|
---|
1538 | }
|
---|
1539 | /*************************************************************************
|
---|
1540 | * SetScrollRange (USER32.503)
|
---|
1541 | *
|
---|
1542 | * RETURNS STD
|
---|
1543 | */
|
---|
1544 | BOOL WINAPI SetScrollRange(
|
---|
1545 | HWND hwnd, /* [I] Handle of window whose scrollbar will be affected */
|
---|
1546 | INT nBar, /* [I] One of SB_HORZ, SB_VERT, or SB_CTL */
|
---|
1547 | INT MinVal, /* [I] New minimum value */
|
---|
1548 | INT MaxVal, /* [I] New maximum value */
|
---|
1549 | BOOL bRedraw /* [I] Should scrollbar be redrawn afterwards ? */)
|
---|
1550 | {
|
---|
1551 | SCROLLINFO info;
|
---|
1552 |
|
---|
1553 | dprintf(("SetScrollRange %x %x %d %d %d", hwnd, nBar, MinVal, MaxVal, bRedraw));
|
---|
1554 | info.cbSize = sizeof(info);
|
---|
1555 | info.nMin = MinVal;
|
---|
1556 | info.nMax = MaxVal;
|
---|
1557 | info.fMask = SIF_RANGE;
|
---|
1558 | SetScrollInfo( hwnd, nBar, &info, bRedraw );
|
---|
1559 | return TRUE;
|
---|
1560 | }
|
---|
1561 |
|
---|
1562 | /*************************************************************************
|
---|
1563 | * GetScrollRange (USER32.286)
|
---|
1564 | *
|
---|
1565 | * RETURNS STD
|
---|
1566 | */
|
---|
1567 | BOOL WINAPI GetScrollRange(
|
---|
1568 | HWND hwnd, /* [I] Handle of window */
|
---|
1569 | INT nBar, /* [I] One of SB_HORZ, SB_VERT, or SB_CTL */
|
---|
1570 | LPINT lpMin, /* [O] Where to store minimum value */
|
---|
1571 | LPINT lpMax /* [O] Where to store maximum value */)
|
---|
1572 | {
|
---|
1573 | SCROLLBAR_INFO *infoPtr;
|
---|
1574 |
|
---|
1575 | infoPtr = SCROLL_GetInfoPtr(SCROLL_GetScrollHandle(hwnd,nBar),nBar);
|
---|
1576 | if (!infoPtr)
|
---|
1577 | {
|
---|
1578 | if (lpMin) lpMin = 0;
|
---|
1579 | if (lpMax) lpMax = 0;
|
---|
1580 | return FALSE;
|
---|
1581 | }
|
---|
1582 | if (lpMin) *lpMin = infoPtr->MinVal;
|
---|
1583 | if (lpMax) *lpMax = infoPtr->MaxVal;
|
---|
1584 | return TRUE;
|
---|
1585 | }
|
---|
1586 |
|
---|
1587 | /*************************************************************************
|
---|
1588 | * ShowScrollBar (USER32.532)
|
---|
1589 | *
|
---|
1590 | * RETURNS STD
|
---|
1591 | */
|
---|
1592 | BOOL WINAPI ShowScrollBar(
|
---|
1593 | HWND hwnd, /* [I] Handle of window whose scrollbar(s) will be affected */
|
---|
1594 | INT nBar, /* [I] One of SB_HORZ, SB_VERT, SB_BOTH or SB_CTL */
|
---|
1595 | BOOL fShow /* [I] TRUE = show, FALSE = hide */)
|
---|
1596 | {
|
---|
1597 | dprintf(("ShowScrollBar %04x %d %d\n", hwnd, nBar, fShow));
|
---|
1598 |
|
---|
1599 | if (nBar == SB_CTL)
|
---|
1600 | {
|
---|
1601 | ShowWindow(hwnd,fShow ? SW_SHOW:SW_HIDE);
|
---|
1602 |
|
---|
1603 | return TRUE;
|
---|
1604 | } else
|
---|
1605 | {
|
---|
1606 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1607 | BOOL createHorz = FALSE,createVert = FALSE;
|
---|
1608 |
|
---|
1609 | if (!window)
|
---|
1610 | {
|
---|
1611 | dprintf(("ShowScrollBar window not found!"));
|
---|
1612 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1613 | return 0;
|
---|
1614 | }
|
---|
1615 |
|
---|
1616 | return window->showScrollBars(nBar == SB_HORZ || nBar == SB_BOTH,nBar == SB_VERT || nBar == SB_BOTH,fShow);
|
---|
1617 | }
|
---|
1618 |
|
---|
1619 | return TRUE;
|
---|
1620 | }
|
---|
1621 |
|
---|
1622 | /*************************************************************************
|
---|
1623 | * EnableScrollBar (USER32.171)
|
---|
1624 | */
|
---|
1625 | BOOL WINAPI EnableScrollBar( HWND hwnd, INT nBar, UINT flags)
|
---|
1626 | {
|
---|
1627 | Win32BaseWindow *window;
|
---|
1628 | SCROLLBAR_INFO *infoPtr;
|
---|
1629 |
|
---|
1630 | dprintf(("EnableScrollBar %04x %d %d\n", hwnd, nBar, flags));
|
---|
1631 |
|
---|
1632 | if (nBar == SB_CTL)
|
---|
1633 | {
|
---|
1634 | if (!(infoPtr = SCROLL_GetInfoPtr(hwnd,nBar))) return FALSE;
|
---|
1635 |
|
---|
1636 | if (infoPtr->flags != flags)
|
---|
1637 | {
|
---|
1638 | infoPtr->flags = flags;
|
---|
1639 | SCROLL_RefreshScrollBar(hwnd,nBar,TRUE,TRUE);
|
---|
1640 | }
|
---|
1641 |
|
---|
1642 | return TRUE;
|
---|
1643 | } else
|
---|
1644 | {
|
---|
1645 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1646 | if(!window)
|
---|
1647 | {
|
---|
1648 | dprintf(("EnableScrollBar window not found!"));
|
---|
1649 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1650 | return FALSE;
|
---|
1651 | }
|
---|
1652 |
|
---|
1653 | if(window->getStyle() & (WS_HSCROLL | WS_VSCROLL))
|
---|
1654 | {
|
---|
1655 | BOOL rc = FALSE;
|
---|
1656 |
|
---|
1657 | if (nBar == SB_VERT || nBar == SB_BOTH)
|
---|
1658 | {
|
---|
1659 | HWND hwndScroll = Win32BaseWindow::OS2ToWin32Handle(window->getVertScrollHandle());
|
---|
1660 |
|
---|
1661 | infoPtr = SCROLL_GetInfoPtr(hwndScroll,SB_VERT);
|
---|
1662 | if (infoPtr)
|
---|
1663 | {
|
---|
1664 | if (infoPtr->flags != flags)
|
---|
1665 | {
|
---|
1666 | infoPtr->flags = flags;
|
---|
1667 | SCROLL_RefreshScrollBar(hwndScroll,nBar,TRUE,TRUE);
|
---|
1668 | }
|
---|
1669 |
|
---|
1670 | rc = TRUE;
|
---|
1671 | }
|
---|
1672 | }
|
---|
1673 | if (nBar == SB_HORZ || (rc && nBar == SB_BOTH))
|
---|
1674 | {
|
---|
1675 | HWND hwndScroll = Win32BaseWindow::OS2ToWin32Handle(window->getVertScrollHandle());
|
---|
1676 |
|
---|
1677 | infoPtr = SCROLL_GetInfoPtr(hwndScroll,SB_VERT);
|
---|
1678 | if (infoPtr)
|
---|
1679 | {
|
---|
1680 | if (infoPtr->flags != flags)
|
---|
1681 | {
|
---|
1682 | infoPtr->flags = flags;
|
---|
1683 | SCROLL_RefreshScrollBar(hwndScroll,nBar,TRUE,TRUE);
|
---|
1684 | }
|
---|
1685 |
|
---|
1686 | rc = TRUE;
|
---|
1687 | }
|
---|
1688 | }
|
---|
1689 |
|
---|
1690 | return rc;
|
---|
1691 | }
|
---|
1692 | }
|
---|
1693 |
|
---|
1694 | return TRUE;
|
---|
1695 | }
|
---|
1696 |
|
---|
1697 | //CB: not listed in user32.exp -> don't know the id!
|
---|
1698 |
|
---|
1699 | BOOL WINAPI GetScrollBarInfo(HWND hwnd,LONG idObject,PSCROLLBARINFO psbi)
|
---|
1700 | {
|
---|
1701 | if (!psbi || psbi->cbSize != sizeof(SCROLLBARINFO))
|
---|
1702 | {
|
---|
1703 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1704 |
|
---|
1705 | return FALSE;
|
---|
1706 | }
|
---|
1707 |
|
---|
1708 | HWND hwndScroll;
|
---|
1709 | INT nBar,arrowSize;
|
---|
1710 |
|
---|
1711 | switch (idObject)
|
---|
1712 | {
|
---|
1713 | case OBJID_CLIENT:
|
---|
1714 | nBar = SB_CTL;
|
---|
1715 | hwndScroll = hwnd;
|
---|
1716 | break;
|
---|
1717 |
|
---|
1718 | case OBJID_HSCROLL:
|
---|
1719 | nBar = SB_HORZ;
|
---|
1720 | hwndScroll = SCROLL_GetScrollHandle(hwnd,SB_HORZ);
|
---|
1721 | break;
|
---|
1722 |
|
---|
1723 | case OBJID_VSCROLL:
|
---|
1724 | nBar = SB_VERT;
|
---|
1725 | hwndScroll = SCROLL_GetScrollHandle(hwnd,SB_VERT);
|
---|
1726 | break;
|
---|
1727 |
|
---|
1728 | default:
|
---|
1729 | return FALSE;
|
---|
1730 | }
|
---|
1731 |
|
---|
1732 | if (!hwndScroll) return FALSE;
|
---|
1733 |
|
---|
1734 | SCROLL_GetScrollBarRect(hwndScroll,nBar,&psbi->rcScrollBar,&arrowSize,&psbi->dxyLineButton,&psbi->xyThumbTop);
|
---|
1735 | psbi->xyThumbBottom = psbi->xyThumbTop+psbi->dxyLineButton;
|
---|
1736 | psbi->bogus = 0; //CB: undocumented!
|
---|
1737 | psbi->rgstate[0] = IsWindowVisible(hwndScroll) ? STATE_SYSTEM_INVISIBLE:0;
|
---|
1738 | psbi->rgstate[1] = psbi->rgstate[2] = psbi->rgstate[3] = psbi->rgstate[4] = psbi->rgstate[5] = psbi->rgstate[0]; //CB: todo
|
---|
1739 |
|
---|
1740 | return TRUE;
|
---|
1741 | }
|
---|
1742 | //******************************************************************************
|
---|
1743 | //******************************************************************************
|
---|
1744 | BOOL SCROLLBAR_Register()
|
---|
1745 | {
|
---|
1746 | WNDCLASSA wndClass;
|
---|
1747 |
|
---|
1748 | //SvL: Don't check this now
|
---|
1749 | // if (GlobalFindAtomA(SCROLLBARCLASSNAME)) return FALSE;
|
---|
1750 |
|
---|
1751 | ZeroMemory(&wndClass,sizeof(WNDCLASSA));
|
---|
1752 | wndClass.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW | CS_PARENTDC;
|
---|
1753 | wndClass.lpfnWndProc = (WNDPROC)ScrollBarWndProc;
|
---|
1754 | wndClass.cbClsExtra = 0;
|
---|
1755 | wndClass.cbWndExtra = sizeof(SCROLLBAR_INFO);
|
---|
1756 | wndClass.hCursor = LoadCursorA(0,IDC_ARROWA);
|
---|
1757 | wndClass.hbrBackground = (HBRUSH)0;
|
---|
1758 | wndClass.lpszClassName = SCROLLBARCLASSNAME;
|
---|
1759 |
|
---|
1760 | return RegisterClassA(&wndClass);
|
---|
1761 | }
|
---|
1762 | //******************************************************************************
|
---|
1763 | //******************************************************************************
|
---|
1764 | BOOL SCROLLBAR_Unregister()
|
---|
1765 | {
|
---|
1766 | if (GlobalFindAtomA(SCROLLBARCLASSNAME))
|
---|
1767 | return UnregisterClassA(SCROLLBARCLASSNAME,(HINSTANCE)NULL);
|
---|
1768 | else return FALSE;
|
---|
1769 | }
|
---|
1770 | //******************************************************************************
|
---|
1771 | //******************************************************************************
|
---|
1772 |
|
---|