4 * Copyright 1998 Eric Kohl
7 * This is just a dummy control. An author is needed! Any volunteers?
8 * I will only improve this control once in a while.
9 * Eric <ekohl@abo.rhein-zeitung.de>
13 * - All notifications.
22 #define PAGER_GetInfoPtr(wndPtr) ((PAGER_INFO *)wndPtr->wExtra[0])
25 static __inline__ LRESULT
26 PAGER_ForwardMouse (WND
*wndPtr
, WPARAM32 wParam
)
28 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
30 infoPtr
->bForward
= (BOOL32
)wParam
;
36 static __inline__ LRESULT
37 PAGER_GetBkColor (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
39 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
41 return (LRESULT
)infoPtr
->clrBk
;
45 static __inline__ LRESULT
46 PAGER_GetBorder (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
48 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
50 return (LRESULT
)infoPtr
->nBorder
;
54 static __inline__ LRESULT
55 PAGER_GetButtonSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
57 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
59 return (LRESULT
)infoPtr
->nButtonSize
;
64 PAGER_GetButtonState (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
66 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr(wndPtr); */
68 FIXME (pager
, "empty stub!\n");
74 /* << PAGER_GetDropTarget >> */
77 static __inline__ LRESULT
78 PAGER_GetPos (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
80 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
87 PAGER_RecalcSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
89 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
92 if (infoPtr
->hwndChild
) {
93 ZeroMemory (&nmpgcs
, sizeof (NMPGCALCSIZE
));
94 nmpgcs
.hdr
.hwndFrom
= wndPtr
->hwndSelf
;
95 nmpgcs
.hdr
.idFrom
= wndPtr
->wIDmenu
;
96 nmpgcs
.hdr
.code
= PGN_CALCSIZE
;
98 (wndPtr
->dwStyle
& PGS_HORZ
) ? PGF_CALCWIDTH
: PGF_CALCHEIGHT
;
99 SendMessage32A (GetParent32 (wndPtr
->hwndSelf
), WM_NOTIFY
,
100 (WPARAM32
)wndPtr
->wIDmenu
, (LPARAM
)&nmpgcs
);
102 infoPtr
->nChildSize
=
103 (wndPtr
->dwStyle
& PGS_HORZ
) ? nmpgcs
.iWidth
: nmpgcs
.iHeight
;
106 FIXME (pager
, "Child size %d\n", infoPtr
->nChildSize
);
115 static __inline__ LRESULT
116 PAGER_SetBkColor (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
118 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
119 COLORREF clrTemp
= infoPtr
->clrBk
;
121 infoPtr
->clrBk
= (COLORREF
)lParam
;
125 return (LRESULT
)clrTemp
;
129 static __inline__ LRESULT
130 PAGER_SetBorder (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
132 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
133 INT32 nTemp
= infoPtr
->nBorder
;
135 infoPtr
->nBorder
= (INT32
)lParam
;
139 return (LRESULT
)nTemp
;
143 static __inline__ LRESULT
144 PAGER_SetButtonSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
146 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
147 INT32 nTemp
= infoPtr
->nButtonSize
;
149 infoPtr
->nButtonSize
= (INT32
)lParam
;
151 FIXME (pager
, "size=%d\n", infoPtr
->nButtonSize
);
155 return (LRESULT
)nTemp
;
159 static __inline__ LRESULT
160 PAGER_SetChild (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
162 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
164 infoPtr
->hwndChild
= IsWindow32 ((HWND32
)lParam
) ? (HWND32
)lParam
: 0;
166 FIXME (pager
, "hwnd=%x\n", infoPtr
->hwndChild
);
169 if (infoPtr
->hwndChild
) {
170 SetParent32 (infoPtr
->hwndChild
, wndPtr
->hwndSelf
);
171 SetWindowPos32 (infoPtr
->hwndChild
, HWND_TOP
,
172 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOSIZE
);
179 static __inline__ LRESULT
180 PAGER_SetPos (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
182 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
184 infoPtr
->nPos
= (INT32
)lParam
;
186 FIXME (pager
, "pos=%d\n", infoPtr
->nPos
);
189 SetWindowPos32 (infoPtr
->hwndChild
, HWND_TOP
,
190 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOSIZE
);
197 PAGER_Create (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
201 /* allocate memory for info structure */
202 infoPtr
= (PAGER_INFO
*)COMCTL32_Alloc (sizeof(PAGER_INFO
));
203 wndPtr
->wExtra
[0] = (DWORD
)infoPtr
;
205 if (infoPtr
== NULL
) {
206 ERR (pager
, "could not allocate info memory!\n");
210 if ((PAGER_INFO
*)wndPtr
->wExtra
[0] != infoPtr
) {
211 ERR (pager
, "pointer assignment error!\n");
215 /* set default settings */
216 infoPtr
->hwndChild
= (HWND32
)NULL
;
217 infoPtr
->clrBk
= GetSysColor32 (COLOR_BTNFACE
);
218 infoPtr
->nBorder
= 0;
219 infoPtr
->nButtonSize
= 0;
228 PAGER_Destroy (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
230 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
235 /* free pager info data */
236 COMCTL32_Free (infoPtr
);
243 PAGER_EraseBackground (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
245 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
246 HBRUSH32 hBrush
= CreateSolidBrush32 (infoPtr
->clrBk
);
249 GetClientRect32 (wndPtr
->hwndSelf
, &rect
);
250 FillRect32 ((HDC32
)wParam
, &rect
, hBrush
);
251 DeleteObject32 (hBrush
);
259 PAGER_MouseMove (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
261 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr(wndPtr); */
263 TRACE (pager
, "stub!\n");
269 /* << PAGER_Paint >> */
273 PAGER_Size (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
275 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
278 GetClientRect32 (wndPtr
->hwndSelf
, &rect
);
279 if (infoPtr
->hwndChild
) {
280 SetWindowPos32 (infoPtr
->hwndChild
, HWND_TOP
, rect
.left
, rect
.top
,
281 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
283 /* MoveWindow32 (infoPtr->hwndChild, 1, 1, rect.right - 2, rect.bottom-2, TRUE); */
284 /* UpdateWindow32 (infoPtr->hwndChild); */
287 /* FillRect32 ((HDC32)wParam, &rect, hBrush); */
288 /* DeleteObject32 (hBrush); */
295 PAGER_WindowProc (HWND32 hwnd
, UINT32 uMsg
, WPARAM32 wParam
, LPARAM lParam
)
297 WND
*wndPtr
= WIN_FindWndPtr(hwnd
);
301 case PGM_FORWARDMOUSE
:
302 return PAGER_ForwardMouse (wndPtr
, wParam
);
305 return PAGER_GetBkColor (wndPtr
, wParam
, lParam
);
308 return PAGER_GetBorder (wndPtr
, wParam
, lParam
);
310 case PGM_GETBUTTONSIZE
:
311 return PAGER_GetButtonSize (wndPtr
, wParam
, lParam
);
313 case PGM_GETBUTTONSTATE
:
314 return PAGER_GetButtonState (wndPtr
, wParam
, lParam
);
316 /* case PGM_GETDROPTARGET: */
319 return PAGER_SetPos (wndPtr
, wParam
, lParam
);
322 return PAGER_RecalcSize (wndPtr
, wParam
, lParam
);
325 return PAGER_SetBkColor (wndPtr
, wParam
, lParam
);
328 return PAGER_SetBorder (wndPtr
, wParam
, lParam
);
330 case PGM_SETBUTTONSIZE
:
331 return PAGER_SetButtonSize (wndPtr
, wParam
, lParam
);
334 return PAGER_SetChild (wndPtr
, wParam
, lParam
);
337 return PAGER_SetPos (wndPtr
, wParam
, lParam
);
340 return PAGER_Create (wndPtr
, wParam
, lParam
);
343 return PAGER_Destroy (wndPtr
, wParam
, lParam
);
346 return PAGER_EraseBackground (wndPtr
, wParam
, lParam
);
349 return PAGER_MouseMove (wndPtr
, wParam
, lParam
);
353 return SendMessage32A (wndPtr
->parent
->hwndSelf
, uMsg
, wParam
, lParam
);
356 /* return PAGER_Paint (wndPtr, wParam); */
359 return PAGER_Size (wndPtr
, wParam
, lParam
);
363 ERR (pager
, "unknown msg %04x wp=%08x lp=%08lx\n",
364 uMsg
, wParam
, lParam
);
365 return DefWindowProc32A (hwnd
, uMsg
, wParam
, lParam
);
372 PAGER_Register (VOID
)
374 WNDCLASS32A wndClass
;
376 if (GlobalFindAtom32A (WC_PAGESCROLLER32A
)) return;
378 ZeroMemory (&wndClass
, sizeof(WNDCLASS32A
));
379 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
| CS_SAVEBITS
;
380 wndClass
.lpfnWndProc
= (WNDPROC32
)PAGER_WindowProc
;
381 wndClass
.cbClsExtra
= 0;
382 wndClass
.cbWndExtra
= sizeof(PAGER_INFO
*);
383 wndClass
.hCursor
= LoadCursor32A (0, IDC_ARROW32A
);
384 wndClass
.hbrBackground
= 0;
385 wndClass
.lpszClassName
= WC_PAGESCROLLER32A
;
387 RegisterClass32A (&wndClass
);
392 PAGER_Unregister (VOID
)
394 if (GlobalFindAtom32A (WC_PAGESCROLLER32A
))
395 UnregisterClass32A (WC_PAGESCROLLER32A
, (HINSTANCE32
)NULL
);