Optimized include/*.h: (recursively) include all headers needed by
[wine/testsucceed.git] / dlls / comctl32 / pager.c
blobcae056c8ece8703837821a06e019cb80077fa744
1 /*
2 * Pager control
4 * Copyright 1998 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 "commctrl.h"
17 #include "pager.h"
18 #include "win.h"
19 #include "debug.h"
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;
32 return 0;
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;
63 static LRESULT
64 PAGER_GetButtonState (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
66 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr(wndPtr); */
68 FIXME (pager, "empty stub!\n");
70 return PGF_INVISIBLE;
74 /* << PAGER_GetDropTarget >> */
77 static __inline__ LRESULT
78 PAGER_GetPos (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
80 PAGER_INFO *infoPtr = PAGER_GetInfoPtr(wndPtr);
82 return infoPtr->nPos;
86 static LRESULT
87 PAGER_RecalcSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
89 PAGER_INFO *infoPtr = PAGER_GetInfoPtr(wndPtr);
90 NMPGCALCSIZE nmpgcs;
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;
97 nmpgcs.dwFlag =
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);
111 return 0;
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;
123 /* FIXME: redraw */
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;
137 /* FIXME: redraw */
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);
153 /* FIXME: redraw */
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);
168 /* FIXME: redraw */
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);
175 return 0;
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);
188 /* FIXME: redraw */
189 SetWindowPos32 (infoPtr->hwndChild, HWND_TOP,
190 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
192 return 0;
196 static LRESULT
197 PAGER_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
199 PAGER_INFO *infoPtr;
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");
207 return 0;
210 if ((PAGER_INFO*)wndPtr->wExtra[0] != infoPtr) {
211 ERR (pager, "pointer assignment error!\n");
212 return 0;
215 /* set default settings */
216 infoPtr->hwndChild = (HWND32)NULL;
217 infoPtr->clrBk = GetSysColor32 (COLOR_BTNFACE);
218 infoPtr->nBorder = 0;
219 infoPtr->nButtonSize = 0;
220 infoPtr->nPos = 0;
223 return 0;
227 static LRESULT
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);
238 return 0;
242 static LRESULT
243 PAGER_EraseBackground (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
245 PAGER_INFO *infoPtr = PAGER_GetInfoPtr(wndPtr);
246 HBRUSH32 hBrush = CreateSolidBrush32 (infoPtr->clrBk);
247 RECT32 rect;
249 GetClientRect32 (wndPtr->hwndSelf, &rect);
250 FillRect32 ((HDC32)wParam, &rect, hBrush);
251 DeleteObject32 (hBrush);
253 /* return TRUE; */
254 return FALSE;
258 static LRESULT
259 PAGER_MouseMove (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
261 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr(wndPtr); */
263 TRACE (pager, "stub!\n");
265 return 0;
269 /* << PAGER_Paint >> */
272 static LRESULT
273 PAGER_Size (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
275 PAGER_INFO *infoPtr = PAGER_GetInfoPtr(wndPtr);
276 RECT32 rect;
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,
282 SWP_SHOWWINDOW);
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); */
289 return TRUE;
294 LRESULT WINAPI
295 PAGER_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
297 WND *wndPtr = WIN_FindWndPtr(hwnd);
299 switch (uMsg)
301 case PGM_FORWARDMOUSE:
302 return PAGER_ForwardMouse (wndPtr, wParam);
304 case PGM_GETBKCOLOR:
305 return PAGER_GetBkColor (wndPtr, wParam, lParam);
307 case PGM_GETBORDER:
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: */
318 case PGM_GETPOS:
319 return PAGER_SetPos (wndPtr, wParam, lParam);
321 case PGM_RECALCSIZE:
322 return PAGER_RecalcSize (wndPtr, wParam, lParam);
324 case PGM_SETBKCOLOR:
325 return PAGER_SetBkColor (wndPtr, wParam, lParam);
327 case PGM_SETBORDER:
328 return PAGER_SetBorder (wndPtr, wParam, lParam);
330 case PGM_SETBUTTONSIZE:
331 return PAGER_SetButtonSize (wndPtr, wParam, lParam);
333 case PGM_SETCHILD:
334 return PAGER_SetChild (wndPtr, wParam, lParam);
336 case PGM_SETPOS:
337 return PAGER_SetPos (wndPtr, wParam, lParam);
339 case WM_CREATE:
340 return PAGER_Create (wndPtr, wParam, lParam);
342 case WM_DESTROY:
343 return PAGER_Destroy (wndPtr, wParam, lParam);
345 case WM_ERASEBKGND:
346 return PAGER_EraseBackground (wndPtr, wParam, lParam);
348 case WM_MOUSEMOVE:
349 return PAGER_MouseMove (wndPtr, wParam, lParam);
351 case WM_NOTIFY:
352 case WM_COMMAND:
353 return SendMessage32A (wndPtr->parent->hwndSelf, uMsg, wParam, lParam);
355 /* case WM_PAINT: */
356 /* return PAGER_Paint (wndPtr, wParam); */
358 case WM_SIZE:
359 return PAGER_Size (wndPtr, wParam, lParam);
361 default:
362 if (uMsg >= WM_USER)
363 ERR (pager, "unknown msg %04x wp=%08x lp=%08lx\n",
364 uMsg, wParam, lParam);
365 return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
367 return 0;
371 VOID
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);
391 VOID
392 PAGER_Unregister (VOID)
394 if (GlobalFindAtom32A (WC_PAGESCROLLER32A))
395 UnregisterClass32A (WC_PAGESCROLLER32A, (HINSTANCE32)NULL);