configure: Changes from running autconf after previous patch.
[wine/hacks.git] / dlls / comctl32 / pager.c
blobf3461fde88d3ef6d2ef60c93f2848b3016108920
1 /*
2 * Pager control
4 * Copyright 1998, 1999 Eric Kohl
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * NOTES
22 * This code was audited for completeness against the documented features
23 * of Comctl32.dll version 6.0 on Sep. 18, 2004, by Robert Shearman.
25 * Unless otherwise noted, we believe this code to be complete, as per
26 * the specification mentioned above.
27 * If you discover missing features or bugs please note them below.
29 * TODO:
30 * Implement repetitive button press.
31 * Adjust arrow size relative to size of button.
32 * Allow border size changes.
33 * Styles:
34 * PGS_DRAGNDROP
35 * Notifications:
36 * PGN_HOTITEMCHANGE
37 * Messages:
38 * WM_PRINT and/or WM_PRINTCLIENT
40 * TESTING:
41 * Tested primarily with the controlspy Pager application.
42 * Susan Farley (susan@codeweavers.com)
44 * IMPLEMENTATION NOTES:
45 * This control uses WM_NCPAINT instead of WM_PAINT to paint itself
46 * as we need to scroll a child window. In order to do this we move
47 * the child window in the control's client area, using the clipping
48 * region that is automatically set around the client area. As the
49 * entire client area now consists of the child window, we must
50 * allocate space (WM_NCCALCSIZE) for the buttons and draw them as
51 * a non-client area (WM_NCPAINT).
52 * Robert Shearman <rob@codeweavers.com>
55 #include <stdarg.h>
56 #include <string.h>
57 #include "windef.h"
58 #include "winbase.h"
59 #include "wingdi.h"
60 #include "winuser.h"
61 #include "winnls.h"
62 #include "commctrl.h"
63 #include "comctl32.h"
64 #include "wine/debug.h"
66 WINE_DEFAULT_DEBUG_CHANNEL(pager);
68 typedef struct
70 HWND hwndSelf; /* handle of the control wnd */
71 HWND hwndChild; /* handle of the contained wnd */
72 HWND hwndNotify; /* handle of the parent wnd */
73 DWORD dwStyle; /* styles for this control */
74 COLORREF clrBk; /* background color */
75 INT nBorder; /* border size for the control */
76 INT nButtonSize;/* size of the pager btns */
77 INT nPos; /* scroll position */
78 INT nWidth; /* from child wnd's response to PGN_CALCSIZE */
79 INT nHeight; /* from child wnd's response to PGN_CALCSIZE */
80 BOOL bForward; /* forward WM_MOUSEMOVE msgs to the contained wnd */
81 BOOL bCapture; /* we have captured the mouse */
82 INT TLbtnState; /* state of top or left btn */
83 INT BRbtnState; /* state of bottom or right btn */
84 INT direction; /* direction of the scroll, (e.g. PGF_SCROLLUP) */
85 } PAGER_INFO;
87 #define MIN_ARROW_WIDTH 8
88 #define MIN_ARROW_HEIGHT 5
90 #define TIMERID1 1
91 #define TIMERID2 2
92 #define INITIAL_DELAY 500
93 #define REPEAT_DELAY 50
95 static void
96 PAGER_GetButtonRects(const PAGER_INFO* infoPtr, RECT* prcTopLeft, RECT* prcBottomRight, BOOL bClientCoords)
98 RECT rcWindow;
99 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
101 if (bClientCoords)
103 POINT pt = {rcWindow.left, rcWindow.top};
104 ScreenToClient(infoPtr->hwndSelf, &pt);
105 OffsetRect(&rcWindow, -(rcWindow.left-pt.x), -(rcWindow.top-pt.y));
107 else
108 OffsetRect(&rcWindow, -rcWindow.left, -rcWindow.top);
110 *prcTopLeft = *prcBottomRight = rcWindow;
111 if (infoPtr->dwStyle & PGS_HORZ)
113 prcTopLeft->right = prcTopLeft->left + infoPtr->nButtonSize;
114 prcBottomRight->left = prcBottomRight->right - infoPtr->nButtonSize;
116 else
118 prcTopLeft->bottom = prcTopLeft->top + infoPtr->nButtonSize;
119 prcBottomRight->top = prcBottomRight->bottom - infoPtr->nButtonSize;
123 /* the horizontal arrows are:
125 * 01234 01234
126 * 1 * *
127 * 2 ** **
128 * 3*** ***
129 * 4*** ***
130 * 5 ** **
131 * 6 * *
135 static void
136 PAGER_DrawHorzArrow (HDC hdc, RECT r, INT colorRef, BOOL left)
138 INT x, y, w, h;
139 HPEN hPen, hOldPen;
141 w = r.right - r.left + 1;
142 h = r.bottom - r.top + 1;
143 if ((h < MIN_ARROW_WIDTH) || (w < MIN_ARROW_HEIGHT))
144 return; /* refuse to draw partial arrow */
146 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
147 hOldPen = SelectObject ( hdc, hPen );
148 if (left)
150 x = r.left + ((w - MIN_ARROW_HEIGHT) / 2) + 3;
151 y = r.top + ((h - MIN_ARROW_WIDTH) / 2) + 1;
152 MoveToEx (hdc, x, y, NULL);
153 LineTo (hdc, x--, y+5); y++;
154 MoveToEx (hdc, x, y, NULL);
155 LineTo (hdc, x--, y+3); y++;
156 MoveToEx (hdc, x, y, NULL);
157 LineTo (hdc, x, y+1);
159 else
161 x = r.left + ((w - MIN_ARROW_HEIGHT) / 2) + 1;
162 y = r.top + ((h - MIN_ARROW_WIDTH) / 2) + 1;
163 MoveToEx (hdc, x, y, NULL);
164 LineTo (hdc, x++, y+5); y++;
165 MoveToEx (hdc, x, y, NULL);
166 LineTo (hdc, x++, y+3); y++;
167 MoveToEx (hdc, x, y, NULL);
168 LineTo (hdc, x, y+1);
171 SelectObject( hdc, hOldPen );
172 DeleteObject( hPen );
175 /* the vertical arrows are:
177 * 01234567 01234567
178 * 1****** **
179 * 2 **** ****
180 * 3 ** ******
184 static void
185 PAGER_DrawVertArrow (HDC hdc, RECT r, INT colorRef, BOOL up)
187 INT x, y, w, h;
188 HPEN hPen, hOldPen;
190 w = r.right - r.left + 1;
191 h = r.bottom - r.top + 1;
192 if ((h < MIN_ARROW_WIDTH) || (w < MIN_ARROW_HEIGHT))
193 return; /* refuse to draw partial arrow */
195 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
196 hOldPen = SelectObject ( hdc, hPen );
197 if (up)
199 x = r.left + ((w - MIN_ARROW_HEIGHT) / 2) + 1;
200 y = r.top + ((h - MIN_ARROW_WIDTH) / 2) + 3;
201 MoveToEx (hdc, x, y, NULL);
202 LineTo (hdc, x+5, y--); x++;
203 MoveToEx (hdc, x, y, NULL);
204 LineTo (hdc, x+3, y--); x++;
205 MoveToEx (hdc, x, y, NULL);
206 LineTo (hdc, x+1, y);
208 else
210 x = r.left + ((w - MIN_ARROW_HEIGHT) / 2) + 1;
211 y = r.top + ((h - MIN_ARROW_WIDTH) / 2) + 1;
212 MoveToEx (hdc, x, y, NULL);
213 LineTo (hdc, x+5, y++); x++;
214 MoveToEx (hdc, x, y, NULL);
215 LineTo (hdc, x+3, y++); x++;
216 MoveToEx (hdc, x, y, NULL);
217 LineTo (hdc, x+1, y);
220 SelectObject( hdc, hOldPen );
221 DeleteObject( hPen );
224 static void
225 PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT arrowRect,
226 BOOL horz, BOOL topLeft, INT btnState)
228 HBRUSH hBrush, hOldBrush;
229 RECT rc = arrowRect;
231 TRACE("arrowRect = %s, btnState = %d\n", wine_dbgstr_rect(&arrowRect), btnState);
233 if (btnState == PGF_INVISIBLE)
234 return;
236 if ((rc.right - rc.left <= 0) || (rc.bottom - rc.top <= 0))
237 return;
239 hBrush = CreateSolidBrush(clrBk);
240 hOldBrush = SelectObject(hdc, hBrush);
242 FillRect(hdc, &rc, hBrush);
244 if (btnState == PGF_HOT)
246 DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT);
247 if (horz)
248 PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
249 else
250 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
252 else if (btnState == PGF_NORMAL)
254 DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
255 if (horz)
256 PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
257 else
258 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
260 else if (btnState == PGF_DEPRESSED)
262 DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
263 if (horz)
264 PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
265 else
266 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
268 else if (btnState == PGF_GRAYED)
270 DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
271 if (horz)
273 PAGER_DrawHorzArrow(hdc, rc, COLOR_3DHIGHLIGHT, topLeft);
274 rc.left++, rc.top++; rc.right++, rc.bottom++;
275 PAGER_DrawHorzArrow(hdc, rc, COLOR_3DSHADOW, topLeft);
277 else
279 PAGER_DrawVertArrow(hdc, rc, COLOR_3DHIGHLIGHT, topLeft);
280 rc.left++, rc.top++; rc.right++, rc.bottom++;
281 PAGER_DrawVertArrow(hdc, rc, COLOR_3DSHADOW, topLeft);
285 SelectObject( hdc, hOldBrush );
286 DeleteObject(hBrush);
289 /* << PAGER_GetDropTarget >> */
291 static inline LRESULT
292 PAGER_ForwardMouse (PAGER_INFO* infoPtr, BOOL bFwd)
294 TRACE("[%p]\n", infoPtr->hwndSelf);
296 infoPtr->bForward = bFwd;
298 return 0;
301 static inline LRESULT
302 PAGER_GetButtonState (const PAGER_INFO* infoPtr, INT btn)
304 LRESULT btnState = PGF_INVISIBLE;
305 TRACE("[%p]\n", infoPtr->hwndSelf);
307 if (btn == PGB_TOPORLEFT)
308 btnState = infoPtr->TLbtnState;
309 else if (btn == PGB_BOTTOMORRIGHT)
310 btnState = infoPtr->BRbtnState;
312 return btnState;
316 static inline INT
317 PAGER_GetPos(const PAGER_INFO *infoPtr)
319 TRACE("[%p] returns %d\n", infoPtr->hwndSelf, infoPtr->nPos);
320 return infoPtr->nPos;
323 static inline INT
324 PAGER_GetButtonSize(const PAGER_INFO *infoPtr)
326 TRACE("[%p] returns %d\n", infoPtr->hwndSelf, infoPtr->nButtonSize);
327 return infoPtr->nButtonSize;
330 static inline INT
331 PAGER_GetBorder(const PAGER_INFO *infoPtr)
333 TRACE("[%p] returns %d\n", infoPtr->hwndSelf, infoPtr->nBorder);
334 return infoPtr->nBorder;
337 static inline COLORREF
338 PAGER_GetBkColor(const PAGER_INFO *infoPtr)
340 TRACE("[%p] returns %06x\n", infoPtr->hwndSelf, infoPtr->clrBk);
341 return infoPtr->clrBk;
344 static void
345 PAGER_CalcSize (const PAGER_INFO *infoPtr, INT* size, BOOL getWidth)
347 NMPGCALCSIZE nmpgcs;
348 ZeroMemory (&nmpgcs, sizeof (NMPGCALCSIZE));
349 nmpgcs.hdr.hwndFrom = infoPtr->hwndSelf;
350 nmpgcs.hdr.idFrom = GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_ID);
351 nmpgcs.hdr.code = PGN_CALCSIZE;
352 nmpgcs.dwFlag = getWidth ? PGF_CALCWIDTH : PGF_CALCHEIGHT;
353 nmpgcs.iWidth = getWidth ? *size : 0;
354 nmpgcs.iHeight = getWidth ? 0 : *size;
355 SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, nmpgcs.hdr.idFrom, (LPARAM)&nmpgcs);
357 *size = getWidth ? nmpgcs.iWidth : nmpgcs.iHeight;
359 TRACE("[%p] PGN_CALCSIZE returns %s=%d\n", infoPtr->hwndSelf,
360 getWidth ? "width" : "height", *size);
363 static void
364 PAGER_PositionChildWnd(PAGER_INFO* infoPtr)
366 if (infoPtr->hwndChild)
368 RECT rcClient;
369 int nPos = infoPtr->nPos;
371 /* compensate for a grayed btn, which will soon become invisible */
372 if (infoPtr->TLbtnState == PGF_GRAYED)
373 nPos += infoPtr->nButtonSize;
375 GetClientRect(infoPtr->hwndSelf, &rcClient);
377 if (infoPtr->dwStyle & PGS_HORZ)
379 int wndSize = max(0, rcClient.right - rcClient.left);
380 if (infoPtr->nWidth < wndSize)
381 infoPtr->nWidth = wndSize;
383 TRACE("[%p] SWP %dx%d at (%d,%d)\n", infoPtr->hwndSelf,
384 infoPtr->nWidth, infoPtr->nHeight,
385 -nPos, 0);
386 SetWindowPos(infoPtr->hwndChild, 0,
387 -nPos, 0,
388 infoPtr->nWidth, infoPtr->nHeight,
389 SWP_NOZORDER);
391 else
393 int wndSize = max(0, rcClient.bottom - rcClient.top);
394 if (infoPtr->nHeight < wndSize)
395 infoPtr->nHeight = wndSize;
397 TRACE("[%p] SWP %dx%d at (%d,%d)\n", infoPtr->hwndSelf,
398 infoPtr->nWidth, infoPtr->nHeight,
399 0, -nPos);
400 SetWindowPos(infoPtr->hwndChild, 0,
401 0, -nPos,
402 infoPtr->nWidth, infoPtr->nHeight,
403 SWP_NOZORDER);
406 InvalidateRect(infoPtr->hwndChild, NULL, TRUE);
410 static INT
411 PAGER_GetScrollRange(PAGER_INFO* infoPtr)
413 INT scrollRange = 0;
415 if (infoPtr->hwndChild)
417 INT wndSize, childSize;
418 RECT wndRect;
419 GetWindowRect(infoPtr->hwndSelf, &wndRect);
421 if (infoPtr->dwStyle & PGS_HORZ)
423 wndSize = wndRect.right - wndRect.left;
424 PAGER_CalcSize(infoPtr, &infoPtr->nWidth, TRUE);
425 childSize = infoPtr->nWidth;
427 else
429 wndSize = wndRect.bottom - wndRect.top;
430 PAGER_CalcSize(infoPtr, &infoPtr->nHeight, FALSE);
431 childSize = infoPtr->nHeight;
434 TRACE("childSize = %d, wndSize = %d\n", childSize, wndSize);
435 if (childSize > wndSize)
436 scrollRange = childSize - wndSize + infoPtr->nButtonSize;
439 TRACE("[%p] returns %d\n", infoPtr->hwndSelf, scrollRange);
440 return scrollRange;
443 static void
444 PAGER_UpdateBtns(PAGER_INFO *infoPtr, INT scrollRange, BOOL hideGrayBtns)
446 BOOL resizeClient;
447 BOOL repaintBtns;
448 INT oldTLbtnState = infoPtr->TLbtnState;
449 INT oldBRbtnState = infoPtr->BRbtnState;
450 POINT pt;
451 RECT rcTopLeft, rcBottomRight;
453 /* get button rects */
454 PAGER_GetButtonRects(infoPtr, &rcTopLeft, &rcBottomRight, FALSE);
456 GetCursorPos(&pt);
458 /* update states based on scroll position */
459 if (infoPtr->nPos > 0)
461 if (infoPtr->TLbtnState == PGF_INVISIBLE || infoPtr->TLbtnState == PGF_GRAYED)
462 infoPtr->TLbtnState = PGF_NORMAL;
464 else if (PtInRect(&rcTopLeft, pt))
465 infoPtr->TLbtnState = PGF_GRAYED;
466 else
467 infoPtr->TLbtnState = PGF_INVISIBLE;
469 if (scrollRange <= 0)
471 infoPtr->TLbtnState = PGF_INVISIBLE;
472 infoPtr->BRbtnState = PGF_INVISIBLE;
474 else if (infoPtr->nPos < scrollRange)
476 if (infoPtr->BRbtnState == PGF_INVISIBLE || infoPtr->BRbtnState == PGF_GRAYED)
477 infoPtr->BRbtnState = PGF_NORMAL;
479 else if (PtInRect(&rcBottomRight, pt))
480 infoPtr->BRbtnState = PGF_GRAYED;
481 else
482 infoPtr->BRbtnState = PGF_INVISIBLE;
484 /* only need to resize when entering or leaving PGF_INVISIBLE state */
485 resizeClient =
486 ((oldTLbtnState == PGF_INVISIBLE) != (infoPtr->TLbtnState == PGF_INVISIBLE)) ||
487 ((oldBRbtnState == PGF_INVISIBLE) != (infoPtr->BRbtnState == PGF_INVISIBLE));
488 /* initiate NCCalcSize to resize client wnd if necessary */
489 if (resizeClient)
490 SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
491 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
492 SWP_NOZORDER | SWP_NOACTIVATE);
494 /* repaint when changing any state */
495 repaintBtns = (oldTLbtnState != infoPtr->TLbtnState) ||
496 (oldBRbtnState != infoPtr->BRbtnState);
497 if (repaintBtns)
498 SendMessageW(infoPtr->hwndSelf, WM_NCPAINT, 0, 0);
501 static LRESULT
502 PAGER_SetPos(PAGER_INFO* infoPtr, INT newPos, BOOL fromBtnPress)
504 INT scrollRange = PAGER_GetScrollRange(infoPtr);
505 INT oldPos = infoPtr->nPos;
507 if ((scrollRange <= 0) || (newPos < 0))
508 infoPtr->nPos = 0;
509 else if (newPos > scrollRange)
510 infoPtr->nPos = scrollRange;
511 else
512 infoPtr->nPos = newPos;
514 TRACE("[%p] pos=%d, oldpos=%d\n", infoPtr->hwndSelf, infoPtr->nPos, oldPos);
516 if (infoPtr->nPos != oldPos)
518 /* gray and restore btns, and if from WM_SETPOS, hide the gray btns */
519 PAGER_UpdateBtns(infoPtr, scrollRange, !fromBtnPress);
520 PAGER_PositionChildWnd(infoPtr);
523 return 0;
526 static LRESULT
527 PAGER_WindowPosChanging(PAGER_INFO* infoPtr, WINDOWPOS *winpos)
529 if ((infoPtr->dwStyle & CCS_NORESIZE) && !(winpos->flags & SWP_NOSIZE))
531 /* don't let the app resize the nonscrollable dimension of a control
532 * that was created with CCS_NORESIZE style
533 * (i.e. height for a horizontal pager, or width for a vertical one) */
535 /* except if the current dimension is 0 and app is setting for
536 * first time, then save amount as dimension. - GA 8/01 */
538 if (infoPtr->dwStyle & PGS_HORZ)
539 if (!infoPtr->nHeight && winpos->cy)
540 infoPtr->nHeight = winpos->cy;
541 else
542 winpos->cy = infoPtr->nHeight;
543 else
544 if (!infoPtr->nWidth && winpos->cx)
545 infoPtr->nWidth = winpos->cx;
546 else
547 winpos->cx = infoPtr->nWidth;
548 return 0;
551 return DefWindowProcW (infoPtr->hwndSelf, WM_WINDOWPOSCHANGING, 0, (LPARAM)winpos);
554 static INT
555 PAGER_SetFixedWidth(PAGER_INFO* infoPtr)
557 /* Must set the non-scrollable dimension to be less than the full height/width
558 * so that NCCalcSize is called. The Microsoft docs mention 3/4 factor for button
559 * size, and experimentation shows that the effect is almost right. */
561 RECT wndRect;
562 INT delta, h;
563 GetWindowRect(infoPtr->hwndSelf, &wndRect);
565 /* see what the app says for btn width */
566 PAGER_CalcSize(infoPtr, &infoPtr->nWidth, TRUE);
568 if (infoPtr->dwStyle & CCS_NORESIZE)
570 delta = wndRect.right - wndRect.left - infoPtr->nWidth;
571 if (delta > infoPtr->nButtonSize)
572 infoPtr->nWidth += 4 * infoPtr->nButtonSize / 3;
573 else if (delta > 0)
574 infoPtr->nWidth += infoPtr->nButtonSize / 3;
577 h = wndRect.bottom - wndRect.top + infoPtr->nButtonSize;
579 TRACE("[%p] infoPtr->nWidth set to %d\n",
580 infoPtr->hwndSelf, infoPtr->nWidth);
582 return h;
585 static INT
586 PAGER_SetFixedHeight(PAGER_INFO* infoPtr)
588 /* Must set the non-scrollable dimension to be less than the full height/width
589 * so that NCCalcSize is called. The Microsoft docs mention 3/4 factor for button
590 * size, and experimentation shows that the effect is almost right. */
592 RECT wndRect;
593 INT delta, w;
594 GetWindowRect(infoPtr->hwndSelf, &wndRect);
596 /* see what the app says for btn height */
597 PAGER_CalcSize(infoPtr, &infoPtr->nHeight, FALSE);
599 if (infoPtr->dwStyle & CCS_NORESIZE)
601 delta = wndRect.bottom - wndRect.top - infoPtr->nHeight;
602 if (delta > infoPtr->nButtonSize)
603 infoPtr->nHeight += infoPtr->nButtonSize;
604 else if (delta > 0)
605 infoPtr->nHeight += infoPtr->nButtonSize / 3;
608 w = wndRect.right - wndRect.left + infoPtr->nButtonSize;
610 TRACE("[%p] infoPtr->nHeight set to %d\n",
611 infoPtr->hwndSelf, infoPtr->nHeight);
613 return w;
616 /******************************************************************
617 * For the PGM_RECALCSIZE message (but not the other uses in *
618 * this module), the native control does only the following: *
620 * if (some condition) *
621 * PostMessageW(hwnd, EM_FMTLINES, 0, 0); *
622 * return DefWindowProcW(hwnd, PGM_RECALCSIZE, 0, 0); *
624 * When we figure out what the "some condition" is we will *
625 * implement that for the message processing. *
626 ******************************************************************/
628 static LRESULT
629 PAGER_RecalcSize(PAGER_INFO *infoPtr)
631 TRACE("[%p]\n", infoPtr->hwndSelf);
633 if (infoPtr->hwndChild)
635 INT scrollRange = PAGER_GetScrollRange(infoPtr);
637 if (scrollRange <= 0)
639 infoPtr->nPos = -1;
640 PAGER_SetPos(infoPtr, 0, FALSE);
642 else
643 PAGER_PositionChildWnd(infoPtr);
646 return 1;
650 static COLORREF
651 PAGER_SetBkColor (PAGER_INFO* infoPtr, COLORREF clrBk)
653 COLORREF clrTemp = infoPtr->clrBk;
655 infoPtr->clrBk = clrBk;
656 TRACE("[%p] %06x\n", infoPtr->hwndSelf, infoPtr->clrBk);
658 /* the native control seems to do things this way */
659 SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
660 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
661 SWP_NOZORDER | SWP_NOACTIVATE);
663 RedrawWindow(infoPtr->hwndSelf, 0, 0, RDW_ERASE | RDW_INVALIDATE);
665 return clrTemp;
669 static INT
670 PAGER_SetBorder (PAGER_INFO* infoPtr, INT iBorder)
672 INT nTemp = infoPtr->nBorder;
674 infoPtr->nBorder = iBorder;
675 TRACE("[%p] %d\n", infoPtr->hwndSelf, infoPtr->nBorder);
677 PAGER_RecalcSize(infoPtr);
679 return nTemp;
683 static INT
684 PAGER_SetButtonSize (PAGER_INFO* infoPtr, INT iButtonSize)
686 INT nTemp = infoPtr->nButtonSize;
688 infoPtr->nButtonSize = iButtonSize;
689 TRACE("[%p] %d\n", infoPtr->hwndSelf, infoPtr->nButtonSize);
691 PAGER_RecalcSize(infoPtr);
693 return nTemp;
697 static LRESULT
698 PAGER_SetChild (PAGER_INFO* infoPtr, HWND hwndChild)
700 INT hw;
702 infoPtr->hwndChild = IsWindow (hwndChild) ? hwndChild : 0;
704 if (infoPtr->hwndChild)
706 TRACE("[%p] hwndChild=%p\n", infoPtr->hwndSelf, infoPtr->hwndChild);
708 if (infoPtr->dwStyle & PGS_HORZ) {
709 hw = PAGER_SetFixedHeight(infoPtr);
710 /* adjust non-scrollable dimension to fit the child */
711 SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, hw, infoPtr->nHeight,
712 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER |
713 SWP_NOSIZE | SWP_NOACTIVATE);
715 else {
716 hw = PAGER_SetFixedWidth(infoPtr);
717 /* adjust non-scrollable dimension to fit the child */
718 SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, infoPtr->nWidth, hw,
719 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER |
720 SWP_NOSIZE | SWP_NOACTIVATE);
723 /* position child within the page scroller */
724 SetWindowPos(infoPtr->hwndChild, HWND_TOP,
725 0,0,0,0,
726 SWP_SHOWWINDOW | SWP_NOSIZE); /* native is 0 */
728 infoPtr->nPos = -1;
729 PAGER_SetPos(infoPtr, 0, FALSE);
732 return 0;
735 static void
736 PAGER_Scroll(PAGER_INFO* infoPtr, INT dir)
738 NMPGSCROLL nmpgScroll;
739 RECT rcWnd;
741 if (infoPtr->hwndChild)
743 ZeroMemory (&nmpgScroll, sizeof (NMPGSCROLL));
744 nmpgScroll.hdr.hwndFrom = infoPtr->hwndSelf;
745 nmpgScroll.hdr.idFrom = GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_ID);
746 nmpgScroll.hdr.code = PGN_SCROLL;
748 GetWindowRect(infoPtr->hwndSelf, &rcWnd);
749 GetClientRect(infoPtr->hwndSelf, &nmpgScroll.rcParent);
750 nmpgScroll.iXpos = nmpgScroll.iYpos = 0;
751 nmpgScroll.iDir = dir;
753 if (infoPtr->dwStyle & PGS_HORZ)
755 nmpgScroll.iScroll = rcWnd.right - rcWnd.left;
756 nmpgScroll.iXpos = infoPtr->nPos;
758 else
760 nmpgScroll.iScroll = rcWnd.bottom - rcWnd.top;
761 nmpgScroll.iYpos = infoPtr->nPos;
763 nmpgScroll.iScroll -= 2*infoPtr->nButtonSize;
765 SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, nmpgScroll.hdr.idFrom, (LPARAM)&nmpgScroll);
767 TRACE("[%p] PGN_SCROLL returns iScroll=%d\n", infoPtr->hwndSelf, nmpgScroll.iScroll);
769 if (nmpgScroll.iScroll > 0)
771 infoPtr->direction = dir;
773 if (dir == PGF_SCROLLLEFT || dir == PGF_SCROLLUP)
774 PAGER_SetPos(infoPtr, infoPtr->nPos - nmpgScroll.iScroll, TRUE);
775 else
776 PAGER_SetPos(infoPtr, infoPtr->nPos + nmpgScroll.iScroll, TRUE);
778 else
779 infoPtr->direction = -1;
783 static LRESULT
784 PAGER_FmtLines(const PAGER_INFO *infoPtr)
786 /* initiate NCCalcSize to resize client wnd and get size */
787 SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
788 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
789 SWP_NOZORDER | SWP_NOACTIVATE);
791 SetWindowPos(infoPtr->hwndChild, 0,
792 0,0,infoPtr->nWidth,infoPtr->nHeight,
795 return DefWindowProcW (infoPtr->hwndSelf, EM_FMTLINES, 0, 0);
798 static LRESULT
799 PAGER_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
801 PAGER_INFO *infoPtr;
803 /* allocate memory for info structure */
804 infoPtr = Alloc (sizeof(PAGER_INFO));
805 if (!infoPtr) return -1;
806 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
808 /* set default settings */
809 infoPtr->hwndSelf = hwnd;
810 infoPtr->hwndChild = NULL;
811 infoPtr->hwndNotify = lpcs->hwndParent;
812 infoPtr->dwStyle = lpcs->style;
813 infoPtr->clrBk = GetSysColor(COLOR_BTNFACE);
814 infoPtr->nBorder = 0;
815 infoPtr->nButtonSize = 12;
816 infoPtr->nPos = 0;
817 infoPtr->nWidth = 0;
818 infoPtr->nHeight = 0;
819 infoPtr->bForward = FALSE;
820 infoPtr->bCapture = FALSE;
821 infoPtr->TLbtnState = PGF_INVISIBLE;
822 infoPtr->BRbtnState = PGF_INVISIBLE;
823 infoPtr->direction = -1;
825 if (infoPtr->dwStyle & PGS_DRAGNDROP)
826 FIXME("[%p] Drag and Drop style is not implemented yet.\n", infoPtr->hwndSelf);
828 return 0;
832 static LRESULT
833 PAGER_Destroy (PAGER_INFO *infoPtr)
835 SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
836 Free (infoPtr); /* free pager info data */
837 return 0;
840 static LRESULT
841 PAGER_NCCalcSize(PAGER_INFO* infoPtr, WPARAM wParam, LPRECT lpRect)
843 RECT rcChild, rcWindow;
846 * lpRect points to a RECT struct. On entry, the struct
847 * contains the proposed wnd rectangle for the window.
848 * On exit, the struct should contain the screen
849 * coordinates of the corresponding window's client area.
852 DefWindowProcW (infoPtr->hwndSelf, WM_NCCALCSIZE, wParam, (LPARAM)lpRect);
854 TRACE("orig rect=%s\n", wine_dbgstr_rect(lpRect));
856 GetWindowRect (infoPtr->hwndChild, &rcChild);
857 MapWindowPoints (0, infoPtr->hwndSelf, (LPPOINT)&rcChild, 2); /* FIXME: RECT != 2 POINTS */
858 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
860 if (infoPtr->dwStyle & PGS_HORZ)
862 infoPtr->nWidth = lpRect->right - lpRect->left;
863 PAGER_CalcSize (infoPtr, &infoPtr->nWidth, TRUE);
865 if (infoPtr->TLbtnState && (lpRect->left + infoPtr->nButtonSize < lpRect->right))
866 lpRect->left += infoPtr->nButtonSize;
867 if (infoPtr->BRbtnState && (lpRect->right - infoPtr->nButtonSize > lpRect->left))
868 lpRect->right -= infoPtr->nButtonSize;
870 else
872 infoPtr->nHeight = lpRect->bottom - lpRect->top;
873 PAGER_CalcSize (infoPtr, &infoPtr->nHeight, FALSE);
875 if (infoPtr->TLbtnState && (lpRect->top + infoPtr->nButtonSize < lpRect->bottom))
876 lpRect->top += infoPtr->nButtonSize;
877 if (infoPtr->BRbtnState && (lpRect->bottom - infoPtr->nButtonSize > lpRect->top))
878 lpRect->bottom -= infoPtr->nButtonSize;
881 TRACE("nPos=%d, nHeight=%d, window=%s\n",
882 infoPtr->nPos, infoPtr->nHeight,
883 wine_dbgstr_rect(&rcWindow));
885 TRACE("[%p] client rect set to %dx%d at (%d,%d) BtnState[%d,%d]\n",
886 infoPtr->hwndSelf, lpRect->right-lpRect->left, lpRect->bottom-lpRect->top,
887 lpRect->left, lpRect->top,
888 infoPtr->TLbtnState, infoPtr->BRbtnState);
890 return 0;
893 static LRESULT
894 PAGER_NCPaint (const PAGER_INFO* infoPtr, HRGN hRgn)
896 RECT rcBottomRight, rcTopLeft;
897 HDC hdc;
899 if (infoPtr->dwStyle & WS_MINIMIZE)
900 return 0;
902 DefWindowProcW (infoPtr->hwndSelf, WM_NCPAINT, (WPARAM)hRgn, 0);
904 if (!(hdc = GetDCEx (infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW)))
905 return 0;
907 PAGER_GetButtonRects(infoPtr, &rcTopLeft, &rcBottomRight, FALSE);
909 PAGER_DrawButton(hdc, infoPtr->clrBk, rcTopLeft,
910 infoPtr->dwStyle & PGS_HORZ, TRUE, infoPtr->TLbtnState);
911 PAGER_DrawButton(hdc, infoPtr->clrBk, rcBottomRight,
912 infoPtr->dwStyle & PGS_HORZ, FALSE, infoPtr->BRbtnState);
914 ReleaseDC( infoPtr->hwndSelf, hdc );
915 return 0;
918 static INT
919 PAGER_HitTest (const PAGER_INFO* infoPtr, const POINT * pt)
921 RECT clientRect, rcTopLeft, rcBottomRight;
922 POINT ptWindow;
924 GetClientRect (infoPtr->hwndSelf, &clientRect);
926 if (PtInRect(&clientRect, *pt))
928 TRACE("child\n");
929 return -1;
932 ptWindow = *pt;
933 PAGER_GetButtonRects(infoPtr, &rcTopLeft, &rcBottomRight, TRUE);
935 if ((infoPtr->TLbtnState != PGF_INVISIBLE) && PtInRect(&rcTopLeft, ptWindow))
937 TRACE("PGB_TOPORLEFT\n");
938 return PGB_TOPORLEFT;
940 else if ((infoPtr->BRbtnState != PGF_INVISIBLE) && PtInRect(&rcBottomRight, ptWindow))
942 TRACE("PGB_BOTTOMORRIGHT\n");
943 return PGB_BOTTOMORRIGHT;
946 TRACE("nowhere\n");
947 return -1;
950 static LRESULT
951 PAGER_NCHitTest (const PAGER_INFO* infoPtr, INT x, INT y)
953 POINT pt;
954 INT nHit;
956 pt.x = x;
957 pt.y = y;
959 ScreenToClient (infoPtr->hwndSelf, &pt);
960 nHit = PAGER_HitTest(infoPtr, &pt);
962 return (nHit < 0) ? HTTRANSPARENT : HTCLIENT;
965 static LRESULT
966 PAGER_MouseMove (PAGER_INFO* infoPtr, INT keys, INT x, INT y)
968 POINT clpt, pt;
969 RECT wnrect, *btnrect = NULL;
970 BOOL topLeft = FALSE;
971 INT btnstate = 0;
972 INT hit;
973 HDC hdc;
975 pt.x = x;
976 pt.y = y;
978 TRACE("[%p] to (%d,%d)\n", infoPtr->hwndSelf, x, y);
979 ClientToScreen(infoPtr->hwndSelf, &pt);
980 GetWindowRect(infoPtr->hwndSelf, &wnrect);
981 if (PtInRect(&wnrect, pt)) {
982 RECT TLbtnrect, BRbtnrect;
983 PAGER_GetButtonRects(infoPtr, &TLbtnrect, &BRbtnrect, FALSE);
985 clpt = pt;
986 MapWindowPoints(0, infoPtr->hwndSelf, &clpt, 1);
987 hit = PAGER_HitTest(infoPtr, &clpt);
988 if ((hit == PGB_TOPORLEFT) && (infoPtr->TLbtnState == PGF_NORMAL))
990 topLeft = TRUE;
991 btnrect = &TLbtnrect;
992 infoPtr->TLbtnState = PGF_HOT;
993 btnstate = infoPtr->TLbtnState;
995 else if ((hit == PGB_BOTTOMORRIGHT) && (infoPtr->BRbtnState == PGF_NORMAL))
997 topLeft = FALSE;
998 btnrect = &BRbtnrect;
999 infoPtr->BRbtnState = PGF_HOT;
1000 btnstate = infoPtr->BRbtnState;
1003 /* If in one of the buttons the capture and draw buttons */
1004 if (btnrect)
1006 TRACE("[%p] draw btn (%s), Capture %s, style %08x\n",
1007 infoPtr->hwndSelf, wine_dbgstr_rect(btnrect),
1008 (infoPtr->bCapture) ? "TRUE" : "FALSE",
1009 infoPtr->dwStyle);
1010 if (!infoPtr->bCapture)
1012 TRACE("[%p] SetCapture\n", infoPtr->hwndSelf);
1013 SetCapture(infoPtr->hwndSelf);
1014 infoPtr->bCapture = TRUE;
1016 if (infoPtr->dwStyle & PGS_AUTOSCROLL)
1017 SetTimer(infoPtr->hwndSelf, TIMERID1, 0x3e, 0);
1018 hdc = GetWindowDC(infoPtr->hwndSelf);
1019 /* OffsetRect(wnrect, 0 | 1, 0 | 1) */
1020 PAGER_DrawButton(hdc, infoPtr->clrBk, *btnrect,
1021 infoPtr->dwStyle & PGS_HORZ, topLeft, btnstate);
1022 ReleaseDC(infoPtr->hwndSelf, hdc);
1023 return 0;
1027 /* If we think we are captured, then do release */
1028 if (infoPtr->bCapture && (WindowFromPoint(pt) != infoPtr->hwndSelf))
1030 NMHDR nmhdr;
1032 infoPtr->bCapture = FALSE;
1034 if (GetCapture() == infoPtr->hwndSelf)
1036 ReleaseCapture();
1038 if (infoPtr->TLbtnState == PGF_GRAYED)
1040 infoPtr->TLbtnState = PGF_INVISIBLE;
1041 SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
1042 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
1043 SWP_NOZORDER | SWP_NOACTIVATE);
1045 else if (infoPtr->TLbtnState == PGF_HOT)
1047 infoPtr->TLbtnState = PGF_NORMAL;
1048 /* FIXME: just invalidate button rect */
1049 RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
1052 if (infoPtr->BRbtnState == PGF_GRAYED)
1054 infoPtr->BRbtnState = PGF_INVISIBLE;
1055 SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
1056 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
1057 SWP_NOZORDER | SWP_NOACTIVATE);
1059 else if (infoPtr->BRbtnState == PGF_HOT)
1061 infoPtr->BRbtnState = PGF_NORMAL;
1062 /* FIXME: just invalidate button rect */
1063 RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
1066 /* Notify parent of released mouse capture */
1067 memset(&nmhdr, 0, sizeof(NMHDR));
1068 nmhdr.hwndFrom = infoPtr->hwndSelf;
1069 nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
1070 nmhdr.code = NM_RELEASEDCAPTURE;
1071 SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
1073 if (IsWindow(infoPtr->hwndSelf))
1074 KillTimer(infoPtr->hwndSelf, TIMERID1);
1076 return 0;
1079 static LRESULT
1080 PAGER_LButtonDown (PAGER_INFO* infoPtr, INT keys, INT x, INT y)
1082 BOOL repaintBtns = FALSE;
1083 POINT pt;
1084 INT hit;
1086 pt.x = x;
1087 pt.y = y;
1089 TRACE("[%p] at (%d,%d)\n", infoPtr->hwndSelf, x, y);
1091 hit = PAGER_HitTest(infoPtr, &pt);
1093 /* put btn in DEPRESSED state */
1094 if (hit == PGB_TOPORLEFT)
1096 repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED;
1097 infoPtr->TLbtnState = PGF_DEPRESSED;
1098 SetTimer(infoPtr->hwndSelf, TIMERID1, INITIAL_DELAY, 0);
1100 else if (hit == PGB_BOTTOMORRIGHT)
1102 repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED;
1103 infoPtr->BRbtnState = PGF_DEPRESSED;
1104 SetTimer(infoPtr->hwndSelf, TIMERID1, INITIAL_DELAY, 0);
1107 if (repaintBtns)
1108 SendMessageW(infoPtr->hwndSelf, WM_NCPAINT, 0, 0);
1110 switch(hit)
1112 case PGB_TOPORLEFT:
1113 if (infoPtr->dwStyle & PGS_HORZ)
1115 TRACE("[%p] PGF_SCROLLLEFT\n", infoPtr->hwndSelf);
1116 PAGER_Scroll(infoPtr, PGF_SCROLLLEFT);
1118 else
1120 TRACE("[%p] PGF_SCROLLUP\n", infoPtr->hwndSelf);
1121 PAGER_Scroll(infoPtr, PGF_SCROLLUP);
1123 break;
1124 case PGB_BOTTOMORRIGHT:
1125 if (infoPtr->dwStyle & PGS_HORZ)
1127 TRACE("[%p] PGF_SCROLLRIGHT\n", infoPtr->hwndSelf);
1128 PAGER_Scroll(infoPtr, PGF_SCROLLRIGHT);
1130 else
1132 TRACE("[%p] PGF_SCROLLDOWN\n", infoPtr->hwndSelf);
1133 PAGER_Scroll(infoPtr, PGF_SCROLLDOWN);
1135 break;
1136 default:
1137 break;
1140 return 0;
1143 static LRESULT
1144 PAGER_LButtonUp (PAGER_INFO* infoPtr, INT keys, INT x, INT y)
1146 TRACE("[%p]\n", infoPtr->hwndSelf);
1148 KillTimer (infoPtr->hwndSelf, TIMERID1);
1149 KillTimer (infoPtr->hwndSelf, TIMERID2);
1151 /* make PRESSED btns NORMAL but don't hide gray btns */
1152 if (infoPtr->TLbtnState & (PGF_HOT | PGF_DEPRESSED))
1153 infoPtr->TLbtnState = PGF_NORMAL;
1154 if (infoPtr->BRbtnState & (PGF_HOT | PGF_DEPRESSED))
1155 infoPtr->BRbtnState = PGF_NORMAL;
1157 return 0;
1160 static LRESULT
1161 PAGER_Timer (PAGER_INFO* infoPtr, INT nTimerId)
1163 INT dir;
1165 /* if initial timer, kill it and start the repeat timer */
1166 if (nTimerId == TIMERID1) {
1167 if (infoPtr->TLbtnState == PGF_HOT)
1168 dir = (infoPtr->dwStyle & PGS_HORZ) ?
1169 PGF_SCROLLLEFT : PGF_SCROLLUP;
1170 else
1171 dir = (infoPtr->dwStyle & PGS_HORZ) ?
1172 PGF_SCROLLRIGHT : PGF_SCROLLDOWN;
1173 TRACE("[%p] TIMERID1: style=%08x, dir=%d\n",
1174 infoPtr->hwndSelf, infoPtr->dwStyle, dir);
1175 KillTimer(infoPtr->hwndSelf, TIMERID1);
1176 SetTimer(infoPtr->hwndSelf, TIMERID1, REPEAT_DELAY, 0);
1177 if (infoPtr->dwStyle & PGS_AUTOSCROLL) {
1178 PAGER_Scroll(infoPtr, dir);
1179 SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
1180 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
1181 SWP_NOZORDER | SWP_NOACTIVATE);
1183 return 0;
1187 TRACE("[%p] TIMERID2: dir=%d\n", infoPtr->hwndSelf, infoPtr->direction);
1188 KillTimer(infoPtr->hwndSelf, TIMERID2);
1189 if (infoPtr->direction > 0) {
1190 PAGER_Scroll(infoPtr, infoPtr->direction);
1191 SetTimer(infoPtr->hwndSelf, TIMERID2, REPEAT_DELAY, 0);
1193 return 0;
1196 static LRESULT
1197 PAGER_EraseBackground (const PAGER_INFO* infoPtr, HDC hdc)
1199 POINT pt, ptorig;
1200 HWND parent;
1202 pt.x = 0;
1203 pt.y = 0;
1204 parent = GetParent(infoPtr->hwndSelf);
1205 MapWindowPoints(infoPtr->hwndSelf, parent, &pt, 1);
1206 OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
1207 SendMessageW (parent, WM_ERASEBKGND, (WPARAM)hdc, 0);
1208 SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
1210 return 0;
1214 static LRESULT
1215 PAGER_Size (PAGER_INFO* infoPtr, INT type, INT x, INT y)
1217 /* note that WM_SIZE is sent whenever NCCalcSize resizes the client wnd */
1219 TRACE("[%p] %d,%d\n", infoPtr->hwndSelf, x, y);
1221 if (infoPtr->dwStyle & PGS_HORZ)
1222 infoPtr->nHeight = y;
1223 else
1224 infoPtr->nWidth = x;
1226 return PAGER_RecalcSize(infoPtr);
1230 static LRESULT
1231 PAGER_StyleChanged(PAGER_INFO *infoPtr, WPARAM wStyleType, const STYLESTRUCT *lpss)
1233 DWORD oldStyle = infoPtr->dwStyle;
1235 TRACE("(styletype=%lx, styleOld=0x%08x, styleNew=0x%08x)\n",
1236 wStyleType, lpss->styleOld, lpss->styleNew);
1238 if (wStyleType != GWL_STYLE) return 0;
1240 infoPtr->dwStyle = lpss->styleNew;
1242 if ((oldStyle ^ lpss->styleNew) & (PGS_HORZ | PGS_VERT))
1244 PAGER_RecalcSize(infoPtr);
1247 return 0;
1250 static LRESULT WINAPI
1251 PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1253 PAGER_INFO *infoPtr = (PAGER_INFO *)GetWindowLongPtrW(hwnd, 0);
1255 if (!infoPtr && (uMsg != WM_CREATE))
1256 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
1258 switch (uMsg)
1260 case EM_FMTLINES:
1261 return PAGER_FmtLines(infoPtr);
1263 case PGM_FORWARDMOUSE:
1264 return PAGER_ForwardMouse (infoPtr, (BOOL)wParam);
1266 case PGM_GETBKCOLOR:
1267 return PAGER_GetBkColor(infoPtr);
1269 case PGM_GETBORDER:
1270 return PAGER_GetBorder(infoPtr);
1272 case PGM_GETBUTTONSIZE:
1273 return PAGER_GetButtonSize(infoPtr);
1275 case PGM_GETPOS:
1276 return PAGER_GetPos(infoPtr);
1278 case PGM_GETBUTTONSTATE:
1279 return PAGER_GetButtonState (infoPtr, (INT)lParam);
1281 /* case PGM_GETDROPTARGET: */
1283 case PGM_RECALCSIZE:
1284 return PAGER_RecalcSize(infoPtr);
1286 case PGM_SETBKCOLOR:
1287 return PAGER_SetBkColor (infoPtr, (COLORREF)lParam);
1289 case PGM_SETBORDER:
1290 return PAGER_SetBorder (infoPtr, (INT)lParam);
1292 case PGM_SETBUTTONSIZE:
1293 return PAGER_SetButtonSize (infoPtr, (INT)lParam);
1295 case PGM_SETCHILD:
1296 return PAGER_SetChild (infoPtr, (HWND)lParam);
1298 case PGM_SETPOS:
1299 return PAGER_SetPos(infoPtr, (INT)lParam, FALSE);
1301 case WM_CREATE:
1302 return PAGER_Create (hwnd, (LPCREATESTRUCTW)lParam);
1304 case WM_DESTROY:
1305 return PAGER_Destroy (infoPtr);
1307 case WM_SIZE:
1308 return PAGER_Size (infoPtr, (INT)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
1310 case WM_NCPAINT:
1311 return PAGER_NCPaint (infoPtr, (HRGN)wParam);
1313 case WM_WINDOWPOSCHANGING:
1314 return PAGER_WindowPosChanging (infoPtr, (WINDOWPOS*)lParam);
1316 case WM_STYLECHANGED:
1317 return PAGER_StyleChanged(infoPtr, wParam, (LPSTYLESTRUCT)lParam);
1319 case WM_NCCALCSIZE:
1320 return PAGER_NCCalcSize (infoPtr, wParam, (LPRECT)lParam);
1322 case WM_NCHITTEST:
1323 return PAGER_NCHitTest (infoPtr, (short)LOWORD(lParam), (short)HIWORD(lParam));
1325 case WM_MOUSEMOVE:
1326 if (infoPtr->bForward && infoPtr->hwndChild)
1327 PostMessageW(infoPtr->hwndChild, WM_MOUSEMOVE, wParam, lParam);
1328 return PAGER_MouseMove (infoPtr, (INT)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
1330 case WM_LBUTTONDOWN:
1331 return PAGER_LButtonDown (infoPtr, (INT)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
1333 case WM_LBUTTONUP:
1334 return PAGER_LButtonUp (infoPtr, (INT)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
1336 case WM_ERASEBKGND:
1337 return PAGER_EraseBackground (infoPtr, (HDC)wParam);
1339 case WM_TIMER:
1340 return PAGER_Timer (infoPtr, (INT)wParam);
1342 case WM_NOTIFY:
1343 case WM_COMMAND:
1344 return SendMessageW (infoPtr->hwndNotify, uMsg, wParam, lParam);
1346 default:
1347 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
1352 VOID
1353 PAGER_Register (void)
1355 WNDCLASSW wndClass;
1357 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
1358 wndClass.style = CS_GLOBALCLASS;
1359 wndClass.lpfnWndProc = PAGER_WindowProc;
1360 wndClass.cbClsExtra = 0;
1361 wndClass.cbWndExtra = sizeof(PAGER_INFO *);
1362 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
1363 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
1364 wndClass.lpszClassName = WC_PAGESCROLLERW;
1366 RegisterClassW (&wndClass);
1370 VOID
1371 PAGER_Unregister (void)
1373 UnregisterClassW (WC_PAGESCROLLERW, NULL);