MSDN: "WM_NCHITTEST - Returns HTCLIENT if the control style is
[wine.git] / dlls / comctl32 / pager.c
blobc1161aa09a391b2ae38fd3cea5ee4577013062de
1 /*
2 * Pager control
4 * Copyright 1998, 1999 Eric Kohl
6 * NOTES
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>
11 * TODO:
12 * - All messages.
13 * - All notifications.
16 #include "winbase.h"
17 #include "commctrl.h"
18 #include "pager.h"
19 #include "debugtools.h"
21 DEFAULT_DEBUG_CHANNEL(pager)
24 #define PAGER_GetInfoPtr(hwnd) ((PAGER_INFO *)GetWindowLongA(hwnd, 0))
27 static inline LRESULT
28 PAGER_ForwardMouse (HWND hwnd, WPARAM wParam)
30 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
32 infoPtr->bForward = (BOOL)wParam;
34 return 0;
38 static inline LRESULT
39 PAGER_GetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
41 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
43 return (LRESULT)infoPtr->clrBk;
47 static inline LRESULT
48 PAGER_GetBorder (HWND hwnd, WPARAM wParam, LPARAM lParam)
50 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
52 return (LRESULT)infoPtr->nBorder;
56 static inline LRESULT
57 PAGER_GetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
59 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
61 return (LRESULT)infoPtr->nButtonSize;
65 static LRESULT
66 PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam)
68 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); */
70 FIXME("empty stub!\n");
72 return PGF_INVISIBLE;
76 /* << PAGER_GetDropTarget >> */
79 static inline LRESULT
80 PAGER_GetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
82 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
84 return infoPtr->nPos;
88 static LRESULT
89 PAGER_RecalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
91 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
92 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
93 NMPGCALCSIZE nmpgcs;
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);
112 return 0;
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;
124 /* FIXME: redraw */
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;
138 /* FIXME: redraw */
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);
154 /* FIXME: redraw */
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);
169 /* FIXME: redraw */
170 if (infoPtr->hwndChild) {
171 RECT rect;
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);
181 return 0;
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);
194 /* FIXME: redraw */
195 SetWindowPos (infoPtr->hwndChild, HWND_TOP,
196 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
198 return 0;
202 static LRESULT
203 PAGER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
205 PAGER_INFO *infoPtr;
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;
216 infoPtr->nPos = 0;
219 return 0;
223 static LRESULT
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);
233 SetWindowLongA (hwnd, 0, 0);
234 return 0;
238 static LRESULT
239 PAGER_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
241 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
242 HBRUSH hBrush = CreateSolidBrush (infoPtr->clrBk);
243 RECT rect;
245 GetClientRect (hwnd, &rect);
246 FillRect ((HDC)wParam, &rect, hBrush);
247 DeleteObject (hBrush);
249 /* return TRUE; */
250 return FALSE;
254 static LRESULT
255 PAGER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
257 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); */
259 TRACE("stub!\n");
261 return 0;
265 /* << PAGER_Paint >> */
268 static LRESULT
269 PAGER_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
271 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
272 RECT rect;
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,
278 SWP_SHOWWINDOW);
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); */
285 return TRUE;
290 static LRESULT WINAPI
291 PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
293 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
294 if (!PAGER_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
295 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
296 switch (uMsg)
298 case PGM_FORWARDMOUSE:
299 return PAGER_ForwardMouse (hwnd, wParam);
301 case PGM_GETBKCOLOR:
302 return PAGER_GetBkColor (hwnd, wParam, lParam);
304 case PGM_GETBORDER:
305 return PAGER_GetBorder (hwnd, wParam, lParam);
307 case PGM_GETBUTTONSIZE:
308 return PAGER_GetButtonSize (hwnd, wParam, lParam);
310 case PGM_GETBUTTONSTATE:
311 return PAGER_GetButtonState (hwnd, wParam, lParam);
313 /* case PGM_GETDROPTARGET: */
315 case PGM_GETPOS:
316 return PAGER_SetPos (hwnd, wParam, lParam);
318 case PGM_RECALCSIZE:
319 return PAGER_RecalcSize (hwnd, wParam, lParam);
321 case PGM_SETBKCOLOR:
322 return PAGER_SetBkColor (hwnd, wParam, lParam);
324 case PGM_SETBORDER:
325 return PAGER_SetBorder (hwnd, wParam, lParam);
327 case PGM_SETBUTTONSIZE:
328 return PAGER_SetButtonSize (hwnd, wParam, lParam);
330 case PGM_SETCHILD:
331 return PAGER_SetChild (hwnd, wParam, lParam);
333 case PGM_SETPOS:
334 return PAGER_SetPos (hwnd, wParam, lParam);
336 case WM_CREATE:
337 return PAGER_Create (hwnd, wParam, lParam);
339 case WM_DESTROY:
340 return PAGER_Destroy (hwnd, wParam, lParam);
342 case WM_ERASEBKGND:
343 return PAGER_EraseBackground (hwnd, wParam, lParam);
345 case WM_MOUSEMOVE:
346 return PAGER_MouseMove (hwnd, wParam, lParam);
348 case WM_NOTIFY:
349 case WM_COMMAND:
350 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
352 /* case WM_PAINT: */
353 /* return PAGER_Paint (hwnd, wParam); */
355 case WM_SIZE:
356 return PAGER_Size (hwnd, wParam, lParam);
358 default:
359 if (uMsg >= WM_USER)
360 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
361 uMsg, wParam, lParam);
362 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
364 return 0;
368 VOID
369 PAGER_Register (void)
371 WNDCLASSA wndClass;
373 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
374 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS;
375 wndClass.lpfnWndProc = (WNDPROC)PAGER_WindowProc;
376 wndClass.cbClsExtra = 0;
377 wndClass.cbWndExtra = sizeof(PAGER_INFO *);
378 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
379 wndClass.hbrBackground = 0;
380 wndClass.lpszClassName = WC_PAGESCROLLERA;
382 RegisterClassA (&wndClass);
386 VOID
387 PAGER_Unregister (void)
389 UnregisterClassA (WC_PAGESCROLLERA, (HINSTANCE)NULL);