Removed all non-standard common control headers from the include
[wine/hacks.git] / dlls / comctl32 / pager.c
blob94d40862e4ba574641e08c5e15f062b382050e48
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 "debugtools.h"
20 DEFAULT_DEBUG_CHANNEL(pager);
22 typedef struct
24 HWND hwndChild;
25 COLORREF clrBk;
26 INT nBorder;
27 INT nButtonSize;
28 INT nPos;
29 BOOL bForward;
31 INT nChildSize;
33 } PAGER_INFO;
35 #define PAGER_GetInfoPtr(hwnd) ((PAGER_INFO *)GetWindowLongA(hwnd, 0))
38 static inline LRESULT
39 PAGER_ForwardMouse (HWND hwnd, WPARAM wParam)
41 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
43 infoPtr->bForward = (BOOL)wParam;
45 return 0;
49 static inline LRESULT
50 PAGER_GetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
52 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
54 return (LRESULT)infoPtr->clrBk;
58 static inline LRESULT
59 PAGER_GetBorder (HWND hwnd, WPARAM wParam, LPARAM lParam)
61 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
63 return (LRESULT)infoPtr->nBorder;
67 static inline LRESULT
68 PAGER_GetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
70 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
72 return (LRESULT)infoPtr->nButtonSize;
76 static LRESULT
77 PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam)
79 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); */
81 FIXME("empty stub!\n");
83 return PGF_INVISIBLE;
87 /* << PAGER_GetDropTarget >> */
90 static inline LRESULT
91 PAGER_GetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
93 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
95 return infoPtr->nPos;
99 static LRESULT
100 PAGER_RecalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
102 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
103 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
104 NMPGCALCSIZE nmpgcs;
106 if (infoPtr->hwndChild) {
107 ZeroMemory (&nmpgcs, sizeof (NMPGCALCSIZE));
108 nmpgcs.hdr.hwndFrom = hwnd;
109 nmpgcs.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
110 nmpgcs.hdr.code = PGN_CALCSIZE;
111 nmpgcs.dwFlag = (dwStyle & PGS_HORZ) ? PGF_CALCWIDTH : PGF_CALCHEIGHT;
112 SendMessageA (GetParent (hwnd), WM_NOTIFY,
113 (WPARAM)nmpgcs.hdr.idFrom, (LPARAM)&nmpgcs);
115 infoPtr->nChildSize = (dwStyle & PGS_HORZ) ? nmpgcs.iWidth : nmpgcs.iHeight;
118 FIXME("Child size %d\n", infoPtr->nChildSize);
123 return 0;
127 static inline LRESULT
128 PAGER_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
130 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
131 COLORREF clrTemp = infoPtr->clrBk;
133 infoPtr->clrBk = (COLORREF)lParam;
135 /* FIXME: redraw */
137 return (LRESULT)clrTemp;
141 static inline LRESULT
142 PAGER_SetBorder (HWND hwnd, WPARAM wParam, LPARAM lParam)
144 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
145 INT nTemp = infoPtr->nBorder;
147 infoPtr->nBorder = (INT)lParam;
149 /* FIXME: redraw */
151 return (LRESULT)nTemp;
155 static inline LRESULT
156 PAGER_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
158 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
159 INT nTemp = infoPtr->nButtonSize;
161 infoPtr->nButtonSize = (INT)lParam;
163 FIXME("size=%d\n", infoPtr->nButtonSize);
165 /* FIXME: redraw */
167 return (LRESULT)nTemp;
171 static inline LRESULT
172 PAGER_SetChild (HWND hwnd, WPARAM wParam, LPARAM lParam)
174 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
176 infoPtr->hwndChild = IsWindow ((HWND)lParam) ? (HWND)lParam : 0;
178 FIXME("hwnd=%x\n", infoPtr->hwndChild);
180 /* FIXME: redraw */
181 if (infoPtr->hwndChild) {
182 RECT rect;
184 GetClientRect (hwnd, &rect);
185 SetParent (infoPtr->hwndChild, hwnd);
186 SetWindowPos (infoPtr->hwndChild, HWND_TOP,
187 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
189 MoveWindow (infoPtr->hwndChild, 0, 0, rect.right, rect.bottom, TRUE);
192 return 0;
196 static inline LRESULT
197 PAGER_SetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
199 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
201 infoPtr->nPos = (INT)lParam;
203 FIXME("pos=%d\n", infoPtr->nPos);
205 /* FIXME: redraw */
206 SetWindowPos (infoPtr->hwndChild, HWND_TOP,
207 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
209 return 0;
213 static LRESULT
214 PAGER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
216 PAGER_INFO *infoPtr;
218 /* allocate memory for info structure */
219 infoPtr = (PAGER_INFO *)COMCTL32_Alloc (sizeof(PAGER_INFO));
220 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
222 /* set default settings */
223 infoPtr->hwndChild = (HWND)NULL;
224 infoPtr->clrBk = GetSysColor (COLOR_BTNFACE);
225 infoPtr->nBorder = 0;
226 infoPtr->nButtonSize = 0;
227 infoPtr->nPos = 0;
230 return 0;
234 static LRESULT
235 PAGER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
237 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
242 /* free pager info data */
243 COMCTL32_Free (infoPtr);
244 SetWindowLongA (hwnd, 0, 0);
245 return 0;
249 static LRESULT
250 PAGER_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
252 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
253 HBRUSH hBrush = CreateSolidBrush (infoPtr->clrBk);
254 RECT rect;
256 GetClientRect (hwnd, &rect);
257 FillRect ((HDC)wParam, &rect, hBrush);
258 DeleteObject (hBrush);
260 /* return TRUE; */
261 return FALSE;
265 static LRESULT
266 PAGER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
268 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); */
270 TRACE("stub!\n");
272 return 0;
276 /* << PAGER_Paint >> */
279 static LRESULT
280 PAGER_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
282 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
283 RECT rect;
285 GetClientRect (hwnd, &rect);
286 if (infoPtr->hwndChild) {
287 SetWindowPos (infoPtr->hwndChild, HWND_TOP, rect.left, rect.top,
288 rect.right - rect.left, rect.bottom - rect.top,
289 SWP_SHOWWINDOW);
290 /* MoveWindow (infoPtr->hwndChild, 1, 1, rect.right - 2, rect.bottom-2, TRUE); */
291 /* UpdateWindow (infoPtr->hwndChild); */
294 /* FillRect ((HDC)wParam, &rect, hBrush); */
295 /* DeleteObject (hBrush); */
296 return TRUE;
301 static LRESULT WINAPI
302 PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
304 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
305 if (!PAGER_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
306 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
307 switch (uMsg)
309 case PGM_FORWARDMOUSE:
310 return PAGER_ForwardMouse (hwnd, wParam);
312 case PGM_GETBKCOLOR:
313 return PAGER_GetBkColor (hwnd, wParam, lParam);
315 case PGM_GETBORDER:
316 return PAGER_GetBorder (hwnd, wParam, lParam);
318 case PGM_GETBUTTONSIZE:
319 return PAGER_GetButtonSize (hwnd, wParam, lParam);
321 case PGM_GETBUTTONSTATE:
322 return PAGER_GetButtonState (hwnd, wParam, lParam);
324 /* case PGM_GETDROPTARGET: */
326 case PGM_GETPOS:
327 return PAGER_SetPos (hwnd, wParam, lParam);
329 case PGM_RECALCSIZE:
330 return PAGER_RecalcSize (hwnd, wParam, lParam);
332 case PGM_SETBKCOLOR:
333 return PAGER_SetBkColor (hwnd, wParam, lParam);
335 case PGM_SETBORDER:
336 return PAGER_SetBorder (hwnd, wParam, lParam);
338 case PGM_SETBUTTONSIZE:
339 return PAGER_SetButtonSize (hwnd, wParam, lParam);
341 case PGM_SETCHILD:
342 return PAGER_SetChild (hwnd, wParam, lParam);
344 case PGM_SETPOS:
345 return PAGER_SetPos (hwnd, wParam, lParam);
347 case WM_CREATE:
348 return PAGER_Create (hwnd, wParam, lParam);
350 case WM_DESTROY:
351 return PAGER_Destroy (hwnd, wParam, lParam);
353 case WM_ERASEBKGND:
354 return PAGER_EraseBackground (hwnd, wParam, lParam);
356 case WM_MOUSEMOVE:
357 return PAGER_MouseMove (hwnd, wParam, lParam);
359 case WM_NOTIFY:
360 case WM_COMMAND:
361 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
363 /* case WM_PAINT: */
364 /* return PAGER_Paint (hwnd, wParam); */
366 case WM_SIZE:
367 return PAGER_Size (hwnd, wParam, lParam);
369 default:
370 if (uMsg >= WM_USER)
371 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
372 uMsg, wParam, lParam);
373 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
375 return 0;
379 VOID
380 PAGER_Register (void)
382 WNDCLASSA wndClass;
384 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
385 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS;
386 wndClass.lpfnWndProc = (WNDPROC)PAGER_WindowProc;
387 wndClass.cbClsExtra = 0;
388 wndClass.cbWndExtra = sizeof(PAGER_INFO *);
389 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
390 wndClass.hbrBackground = 0;
391 wndClass.lpszClassName = WC_PAGESCROLLERA;
393 RegisterClassA (&wndClass);
397 VOID
398 PAGER_Unregister (void)
400 UnregisterClassA (WC_PAGESCROLLERA, (HINSTANCE)NULL);