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.
23 #define PAGER_GetInfoPtr(wndPtr) ((PAGER_INFO *)wndPtr->wExtra[0])
26 static __inline__ LRESULT
27 PAGER_ForwardMouse (WND
*wndPtr
, WPARAM32 wParam
)
29 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
31 infoPtr
->bForward
= (BOOL32
)wParam
;
37 static __inline__ LRESULT
38 PAGER_GetBkColor (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
40 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
42 return (LRESULT
)infoPtr
->clrBk
;
46 static __inline__ LRESULT
47 PAGER_GetBorder (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
49 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
51 return (LRESULT
)infoPtr
->nBorder
;
55 static __inline__ LRESULT
56 PAGER_GetButtonSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
58 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
60 return (LRESULT
)infoPtr
->nButtonSize
;
65 PAGER_GetButtonState (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
67 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
69 FIXME (pager
, "empty stub!\n");
75 // << PAGER_GetDropTarget >>
78 static __inline__ LRESULT
79 PAGER_GetPos (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
81 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
88 PAGER_RecalcSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
90 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
93 if (infoPtr
->hwndChild
) {
94 ZeroMemory (&nmpgcs
, sizeof (NMPGCALCSIZE
));
95 nmpgcs
.hdr
.hwndFrom
= wndPtr
->hwndSelf
;
96 nmpgcs
.hdr
.idFrom
= wndPtr
->wIDmenu
;
97 nmpgcs
.hdr
.code
= PGN_CALCSIZE
;
99 (wndPtr
->dwStyle
& PGS_HORZ
) ? PGF_CALCWIDTH
: PGF_CALCHEIGHT
;
100 SendMessage32A (GetParent32 (wndPtr
->hwndSelf
), WM_NOTIFY
,
101 (WPARAM32
)wndPtr
->wIDmenu
, (LPARAM
)&nmpgcs
);
103 infoPtr
->nChildSize
=
104 (wndPtr
->dwStyle
& PGS_HORZ
) ? nmpgcs
.iWidth
: nmpgcs
.iHeight
;
107 FIXME (pager
, "Child size %d\n", infoPtr
->nChildSize
);
116 static __inline__ LRESULT
117 PAGER_SetBkColor (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
119 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
120 COLORREF clrTemp
= infoPtr
->clrBk
;
122 infoPtr
->clrBk
= (COLORREF
)lParam
;
126 return (LRESULT
)clrTemp
;
130 static __inline__ LRESULT
131 PAGER_SetBorder (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
133 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
134 INT32 nTemp
= infoPtr
->nBorder
;
136 infoPtr
->nBorder
= (INT32
)lParam
;
140 return (LRESULT
)nTemp
;
144 static __inline__ LRESULT
145 PAGER_SetButtonSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
147 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
148 INT32 nTemp
= infoPtr
->nButtonSize
;
150 infoPtr
->nButtonSize
= (INT32
)lParam
;
152 FIXME (pager
, "size=%d\n", infoPtr
->nButtonSize
);
156 return (LRESULT
)nTemp
;
160 static __inline__ LRESULT
161 PAGER_SetChild (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
163 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
165 infoPtr
->hwndChild
= IsWindow32 ((HWND32
)lParam
) ? (HWND32
)lParam
: 0;
167 FIXME (pager
, "hwnd=%x\n", infoPtr
->hwndChild
);
170 if (infoPtr
->hwndChild
) {
171 SetParent32 (infoPtr
->hwndChild
, wndPtr
->hwndSelf
);
172 SetWindowPos32 (infoPtr
->hwndChild
, HWND_TOP
,
173 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOSIZE
);
180 static __inline__ LRESULT
181 PAGER_SetPos (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
183 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
185 infoPtr
->nPos
= (INT32
)lParam
;
187 FIXME (pager
, "pos=%d\n", infoPtr
->nPos
);
190 SetWindowPos32 (infoPtr
->hwndChild
, HWND_TOP
,
191 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOSIZE
);
198 PAGER_Create (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
202 /* allocate memory for info structure */
203 infoPtr
= (PAGER_INFO
*)COMCTL32_Alloc (sizeof(PAGER_INFO
));
204 wndPtr
->wExtra
[0] = (DWORD
)infoPtr
;
206 if (infoPtr
== NULL
) {
207 ERR (pager
, "could not allocate info memory!\n");
211 if ((PAGER_INFO
*)wndPtr
->wExtra
[0] != infoPtr
) {
212 ERR (pager
, "pointer assignment error!\n");
216 /* set default settings */
217 infoPtr
->hwndChild
= (HWND32
)NULL
;
218 infoPtr
->clrBk
= GetSysColor32 (COLOR_BTNFACE
);
219 infoPtr
->nBorder
= 0;
220 infoPtr
->nButtonSize
= 0;
229 PAGER_Destroy (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
231 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
236 /* free pager info data */
237 COMCTL32_Free (infoPtr
);
244 PAGER_EraseBackground (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
246 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
247 HBRUSH32 hBrush
= CreateSolidBrush32 (infoPtr
->clrBk
);
250 GetClientRect32 (wndPtr
->hwndSelf
, &rect
);
251 FillRect32 ((HDC32
)wParam
, &rect
, hBrush
);
252 DeleteObject32 (hBrush
);
260 PAGER_MouseMove (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
262 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
264 TRACE (pager
, "stub!\n");
274 PAGER_Size (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
276 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr(wndPtr
);
279 GetClientRect32 (wndPtr
->hwndSelf
, &rect
);
280 if (infoPtr
->hwndChild
) {
281 SetWindowPos32 (infoPtr
->hwndChild
, HWND_TOP
, rect
.left
, rect
.top
,
282 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
284 // MoveWindow32 (infoPtr->hwndChild, 1, 1, rect.right - 2, rect.bottom-2, TRUE);
285 // UpdateWindow32 (infoPtr->hwndChild);
288 // FillRect32 ((HDC32)wParam, &rect, hBrush);
289 // DeleteObject32 (hBrush);
296 PAGER_WindowProc (HWND32 hwnd
, UINT32 uMsg
, WPARAM32 wParam
, LPARAM lParam
)
298 WND
*wndPtr
= WIN_FindWndPtr(hwnd
);
302 case PGM_FORWARDMOUSE
:
303 return PAGER_ForwardMouse (wndPtr
, wParam
);
306 return PAGER_GetBkColor (wndPtr
, wParam
, lParam
);
309 return PAGER_GetBorder (wndPtr
, wParam
, lParam
);
311 case PGM_GETBUTTONSIZE
:
312 return PAGER_GetButtonSize (wndPtr
, wParam
, lParam
);
314 case PGM_GETBUTTONSTATE
:
315 return PAGER_GetButtonState (wndPtr
, wParam
, lParam
);
317 // case PGM_GETDROPTARGET:
320 return PAGER_SetPos (wndPtr
, wParam
, lParam
);
323 return PAGER_RecalcSize (wndPtr
, wParam
, lParam
);
326 return PAGER_SetBkColor (wndPtr
, wParam
, lParam
);
329 return PAGER_SetBorder (wndPtr
, wParam
, lParam
);
331 case PGM_SETBUTTONSIZE
:
332 return PAGER_SetButtonSize (wndPtr
, wParam
, lParam
);
335 return PAGER_SetChild (wndPtr
, wParam
, lParam
);
338 return PAGER_SetPos (wndPtr
, wParam
, lParam
);
341 return PAGER_Create (wndPtr
, wParam
, lParam
);
344 return PAGER_Destroy (wndPtr
, wParam
, lParam
);
347 return PAGER_EraseBackground (wndPtr
, wParam
, lParam
);
350 return PAGER_MouseMove (wndPtr
, wParam
, lParam
);
353 // return PAGER_Paint (wndPtr, wParam);
356 return PAGER_Size (wndPtr
, wParam
, lParam
);
360 ERR (pager
, "unknown msg %04x wp=%08x lp=%08lx\n",
361 uMsg
, wParam
, lParam
);
362 return DefWindowProc32A (hwnd
, uMsg
, wParam
, lParam
);
369 PAGER_Register (VOID
)
371 WNDCLASS32A wndClass
;
373 if (GlobalFindAtom32A (WC_PAGESCROLLER32A
)) return;
375 ZeroMemory (&wndClass
, sizeof(WNDCLASS32A
));
376 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
| CS_SAVEBITS
;
377 wndClass
.lpfnWndProc
= (WNDPROC32
)PAGER_WindowProc
;
378 wndClass
.cbClsExtra
= 0;
379 wndClass
.cbWndExtra
= sizeof(PAGER_INFO
*);
380 wndClass
.hCursor
= LoadCursor32A (0, IDC_ARROW32A
);
381 wndClass
.hbrBackground
= 0;
382 wndClass
.lpszClassName
= WC_PAGESCROLLER32A
;
384 RegisterClass32A (&wndClass
);
389 PAGER_Unregister (VOID
)
391 if (GlobalFindAtom32A (WC_PAGESCROLLER32A
))
392 UnregisterClass32A (WC_PAGESCROLLER32A
, (HINSTANCE32
)NULL
);