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.
18 #include "debugtools.h"
20 DEFAULT_DEBUG_CHANNEL(pager
);
35 #define PAGER_GetInfoPtr(hwnd) ((PAGER_INFO *)GetWindowLongA(hwnd, 0))
39 PAGER_ForwardMouse (HWND hwnd
, WPARAM wParam
)
41 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr (hwnd
);
43 infoPtr
->bForward
= (BOOL
)wParam
;
50 PAGER_GetBkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
52 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr (hwnd
);
54 return (LRESULT
)infoPtr
->clrBk
;
59 PAGER_GetBorder (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
61 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr (hwnd
);
63 return (LRESULT
)infoPtr
->nBorder
;
68 PAGER_GetButtonSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
70 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr (hwnd
);
72 return (LRESULT
)infoPtr
->nButtonSize
;
77 PAGER_GetButtonState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
79 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); */
81 FIXME("empty stub!\n");
87 /* << PAGER_GetDropTarget >> */
91 PAGER_GetPos (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
93 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr (hwnd
);
100 PAGER_RecalcSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
102 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr (hwnd
);
103 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
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
);
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
;
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
;
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
);
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
);
181 if (infoPtr
->hwndChild
) {
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
);
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
);
206 SetWindowPos (infoPtr
->hwndChild
, HWND_TOP
,
207 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOSIZE
);
214 PAGER_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
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;
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);
250 PAGER_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
252 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr (hwnd
);
253 HBRUSH hBrush
= CreateSolidBrush (infoPtr
->clrBk
);
256 GetClientRect (hwnd
, &rect
);
257 FillRect ((HDC
)wParam
, &rect
, hBrush
);
258 DeleteObject (hBrush
);
266 PAGER_MouseMove (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
268 /* PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); */
276 /* << PAGER_Paint >> */
280 PAGER_Size (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
282 PAGER_INFO
*infoPtr
= PAGER_GetInfoPtr (hwnd
);
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
,
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); */
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
);
309 case PGM_FORWARDMOUSE
:
310 return PAGER_ForwardMouse (hwnd
, wParam
);
313 return PAGER_GetBkColor (hwnd
, wParam
, lParam
);
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: */
327 return PAGER_SetPos (hwnd
, wParam
, lParam
);
330 return PAGER_RecalcSize (hwnd
, wParam
, lParam
);
333 return PAGER_SetBkColor (hwnd
, wParam
, lParam
);
336 return PAGER_SetBorder (hwnd
, wParam
, lParam
);
338 case PGM_SETBUTTONSIZE
:
339 return PAGER_SetButtonSize (hwnd
, wParam
, lParam
);
342 return PAGER_SetChild (hwnd
, wParam
, lParam
);
345 return PAGER_SetPos (hwnd
, wParam
, lParam
);
348 return PAGER_Create (hwnd
, wParam
, lParam
);
351 return PAGER_Destroy (hwnd
, wParam
, lParam
);
354 return PAGER_EraseBackground (hwnd
, wParam
, lParam
);
357 return PAGER_MouseMove (hwnd
, wParam
, lParam
);
361 return SendMessageA (GetParent (hwnd
), uMsg
, wParam
, lParam
);
364 /* return PAGER_Paint (hwnd, wParam); */
367 return PAGER_Size (hwnd
, wParam
, lParam
);
371 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
372 uMsg
, wParam
, lParam
);
373 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
380 PAGER_Register (void)
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
);
398 PAGER_Unregister (void)
400 UnregisterClassA (WC_PAGESCROLLERA
, (HINSTANCE
)NULL
);