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