4 * Copyright 1998, 1999 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.
19 #include "debugtools.h"
21 DEFAULT_DEBUG_CHANNEL(pager)
24 #define PAGER_GetInfoPtr(hwnd) ((PAGER_INFO *)GetWindowLongA(hwnd, 0))
28 PAGER_ForwardMouse (HWND hwnd, WPARAM wParam)
30 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
32 infoPtr->bForward = (BOOL)wParam;
39 PAGER_GetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
41 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
43 return (LRESULT)infoPtr->clrBk;
48 PAGER_GetBorder (HWND hwnd, WPARAM wParam, LPARAM lParam)
50 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
52 return (LRESULT)infoPtr->nBorder;
57 PAGER_GetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
59 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
61 return (LRESULT)infoPtr->nButtonSize;
66 PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam)
68 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); */
70 FIXME("empty stub!\n");
76 /* << PAGER_GetDropTarget >> */
80 PAGER_GetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
82 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
89 PAGER_RecalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
91 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
92 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
95 if (infoPtr->hwndChild) {
96 ZeroMemory (&nmpgcs, sizeof (NMPGCALCSIZE));
97 nmpgcs.hdr.hwndFrom = hwnd;
98 nmpgcs.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
99 nmpgcs.hdr.code = PGN_CALCSIZE;
100 nmpgcs.dwFlag = (dwStyle & PGS_HORZ) ? PGF_CALCWIDTH : PGF_CALCHEIGHT;
101 SendMessageA (GetParent (hwnd), WM_NOTIFY,
102 (WPARAM)nmpgcs.hdr.idFrom, (LPARAM)&nmpgcs);
104 infoPtr->nChildSize = (dwStyle & PGS_HORZ) ? nmpgcs.iWidth : nmpgcs.iHeight;
107 FIXME("Child size %d\n", infoPtr->nChildSize);
116 static inline LRESULT
117 PAGER_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
119 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
120 COLORREF clrTemp = infoPtr->clrBk;
122 infoPtr->clrBk = (COLORREF)lParam;
126 return (LRESULT)clrTemp;
130 static inline LRESULT
131 PAGER_SetBorder (HWND hwnd, WPARAM wParam, LPARAM lParam)
133 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
134 INT nTemp = infoPtr->nBorder;
136 infoPtr->nBorder = (INT)lParam;
140 return (LRESULT)nTemp;
144 static inline LRESULT
145 PAGER_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
147 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
148 INT nTemp = infoPtr->nButtonSize;
150 infoPtr->nButtonSize = (INT)lParam;
152 FIXME("size=%d\n", infoPtr->nButtonSize);
156 return (LRESULT)nTemp;
160 static inline LRESULT
161 PAGER_SetChild (HWND hwnd, WPARAM wParam, LPARAM lParam)
163 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
165 infoPtr->hwndChild = IsWindow ((HWND)lParam) ? (HWND)lParam : 0;
167 FIXME("hwnd=%x\n", infoPtr->hwndChild);
170 if (infoPtr->hwndChild) {
173 GetClientRect (hwnd, &rect);
174 SetParent (infoPtr->hwndChild, hwnd);
175 SetWindowPos (infoPtr->hwndChild, HWND_TOP,
176 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
178 MoveWindow (infoPtr->hwndChild, 0, 0, rect.right, rect.bottom, TRUE);
185 static inline LRESULT
186 PAGER_SetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
188 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
190 infoPtr->nPos = (INT)lParam;
192 FIXME("pos=%d\n", infoPtr->nPos);
195 SetWindowPos (infoPtr->hwndChild, HWND_TOP,
196 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
203 PAGER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
207 /* allocate memory for info structure */
208 infoPtr = (PAGER_INFO *)COMCTL32_Alloc (sizeof(PAGER_INFO));
209 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
211 /* set default settings */
212 infoPtr->hwndChild = (HWND)NULL;
213 infoPtr->clrBk = GetSysColor (COLOR_BTNFACE);
214 infoPtr->nBorder = 0;
215 infoPtr->nButtonSize = 0;
224 PAGER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
226 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
231 /* free pager info data */
232 COMCTL32_Free (infoPtr);
239 PAGER_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
241 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
242 HBRUSH hBrush = CreateSolidBrush (infoPtr->clrBk);
245 GetClientRect (hwnd, &rect);
246 FillRect ((HDC)wParam, &rect, hBrush);
247 DeleteObject (hBrush);
255 PAGER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
257 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); */
265 /* << PAGER_Paint >> */
269 PAGER_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
271 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
274 GetClientRect (hwnd, &rect);
275 if (infoPtr->hwndChild) {
276 SetWindowPos (infoPtr->hwndChild, HWND_TOP, rect.left, rect.top,
277 rect.right - rect.left, rect.bottom - rect.top,
279 /* MoveWindow (infoPtr->hwndChild, 1, 1, rect.right - 2, rect.bottom-2, TRUE); */
280 /* UpdateWindow (infoPtr->hwndChild); */
283 /* FillRect ((HDC)wParam, &rect, hBrush); */
284 /* DeleteObject (hBrush); */
290 static LRESULT WINAPI
291 PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
295 case PGM_FORWARDMOUSE:
296 return PAGER_ForwardMouse (hwnd, wParam);
299 return PAGER_GetBkColor (hwnd, wParam, lParam);
302 return PAGER_GetBorder (hwnd, wParam, lParam);
304 case PGM_GETBUTTONSIZE:
305 return PAGER_GetButtonSize (hwnd, wParam, lParam);
307 case PGM_GETBUTTONSTATE:
308 return PAGER_GetButtonState (hwnd, wParam, lParam);
310 /* case PGM_GETDROPTARGET: */
313 return PAGER_SetPos (hwnd, wParam, lParam);
316 return PAGER_RecalcSize (hwnd, wParam, lParam);
319 return PAGER_SetBkColor (hwnd, wParam, lParam);
322 return PAGER_SetBorder (hwnd, wParam, lParam);
324 case PGM_SETBUTTONSIZE:
325 return PAGER_SetButtonSize (hwnd, wParam, lParam);
328 return PAGER_SetChild (hwnd, wParam, lParam);
331 return PAGER_SetPos (hwnd, wParam, lParam);
334 return PAGER_Create (hwnd, wParam, lParam);
337 return PAGER_Destroy (hwnd, wParam, lParam);
340 return PAGER_EraseBackground (hwnd, wParam, lParam);
343 return PAGER_MouseMove (hwnd, wParam, lParam);
347 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
350 /* return PAGER_Paint (hwnd, wParam); */
353 return PAGER_Size (hwnd, wParam, lParam);
357 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
358 uMsg, wParam, lParam);
359 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
366 PAGER_Register (void)
370 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
371 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS;
372 wndClass.lpfnWndProc = (WNDPROC)PAGER_WindowProc;
373 wndClass.cbClsExtra = 0;
374 wndClass.cbWndExtra = sizeof(PAGER_INFO *);
375 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
376 wndClass.hbrBackground = 0;
377 wndClass.lpszClassName = WC_PAGESCROLLERA;
379 RegisterClassA (&wndClass);
384 PAGER_Unregister (void)
386 UnregisterClassA (WC_PAGESCROLLERA, (HINSTANCE)NULL);