1 | /* $Id: header.c,v 1.12 1999-10-04 16:02:07 cbratschi Exp $ */
|
---|
2 | /*
|
---|
3 | * Header control
|
---|
4 | *
|
---|
5 | * Copyright 1998 Eric Kohl
|
---|
6 | * Copyright 1999 Achim Hasenmueller
|
---|
7 | * Copyright 1999 Christoph Bratschi
|
---|
8 | *
|
---|
9 | * TODO:
|
---|
10 | * - Imagelist support (partially).
|
---|
11 | * - Callback items (under construction).
|
---|
12 | * - Order list support.
|
---|
13 | * - Control specific cursors (over dividers).
|
---|
14 | * - Hottrack support (partially).
|
---|
15 | * - Custom draw support (including Notifications).
|
---|
16 | * - Drag and Drop support (including Notifications).
|
---|
17 | * - Unicode support.
|
---|
18 | *
|
---|
19 | *
|
---|
20 | * Status: Development in progress, a lot to do :)
|
---|
21 | * Version: 5.00 (target)
|
---|
22 | */
|
---|
23 |
|
---|
24 | #include <string.h>
|
---|
25 |
|
---|
26 | #include "winbase.h"
|
---|
27 | #include "commctrl.h"
|
---|
28 | #include "header.h"
|
---|
29 | #include "comctl32.h"
|
---|
30 |
|
---|
31 |
|
---|
32 | #define __HDM_LAYOUT_HACK__
|
---|
33 |
|
---|
34 |
|
---|
35 | #define VERT_BORDER 4
|
---|
36 | #define DIVIDER_WIDTH 10
|
---|
37 | #define MIN_ITEMWIDTH 0
|
---|
38 | #define ITEM_FRAMESIZE 2
|
---|
39 | #define TEXT_MARGIN 3
|
---|
40 |
|
---|
41 | #define HEADER_GetInfoPtr(hwnd) ((HEADER_INFO *)GetWindowLongA(hwnd,0))
|
---|
42 |
|
---|
43 | static VOID
|
---|
44 | HEADER_DrawItemImage(HWND hwnd,HDC hdc,HEADER_INFO* infoPtr,HEADER_ITEM* phdi,RECT* r,INT iItem)
|
---|
45 | {
|
---|
46 | if (phdi->fmt & HDF_IMAGE)
|
---|
47 | {
|
---|
48 | INT iImage;
|
---|
49 | IMAGEINFO info;
|
---|
50 | INT x,y,cx,cy,w,h,rx,ry;
|
---|
51 |
|
---|
52 | if (phdi->iImage == I_IMAGECALLBACK)
|
---|
53 | {
|
---|
54 | if (IsWindowUnicode(GetParent(hwnd)))
|
---|
55 | {
|
---|
56 | NMHDDISPINFOW nmhdr;
|
---|
57 |
|
---|
58 | nmhdr.hdr.hwndFrom = hwnd;
|
---|
59 | nmhdr.hdr.idFrom = GetWindowLongW(hwnd,GWL_ID);
|
---|
60 | nmhdr.hdr.code = HDN_GETDISPINFOW;
|
---|
61 | nmhdr.iItem = iItem;
|
---|
62 | nmhdr.mask = HDI_IMAGE;
|
---|
63 | nmhdr.iImage = 0;
|
---|
64 | nmhdr.lParam = phdi->lParam;
|
---|
65 |
|
---|
66 | SendMessageW(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
|
---|
67 |
|
---|
68 | iImage = nmhdr.iImage;
|
---|
69 | if (nmhdr.mask & HDI_DI_SETITEM) phdi->iImage = iImage;
|
---|
70 | } else
|
---|
71 | {
|
---|
72 | NMHDDISPINFOA nmhdr;
|
---|
73 |
|
---|
74 | nmhdr.hdr.hwndFrom = hwnd;
|
---|
75 | nmhdr.hdr.idFrom = GetWindowLongA(hwnd,GWL_ID);
|
---|
76 | nmhdr.hdr.code = HDN_GETDISPINFOA;
|
---|
77 | nmhdr.iItem = iItem;
|
---|
78 | nmhdr.mask = HDI_IMAGE;
|
---|
79 | nmhdr.iImage = 0;
|
---|
80 | nmhdr.lParam = phdi->lParam;
|
---|
81 |
|
---|
82 | SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
|
---|
83 |
|
---|
84 | iImage = nmhdr.iImage;
|
---|
85 | if (nmhdr.mask & HDI_DI_SETITEM) phdi->iImage = iImage;
|
---|
86 | }
|
---|
87 | } else iImage = phdi->iImage;
|
---|
88 |
|
---|
89 | if (!ImageList_GetImageInfo(infoPtr->himl,phdi->iImage,&info)) return;
|
---|
90 | w = info.rcImage.right-info.rcImage.left;
|
---|
91 | h = info.rcImage.bottom-info.rcImage.top;
|
---|
92 |
|
---|
93 | ry = r->bottom-r->top;
|
---|
94 | rx = r->right-r->left;
|
---|
95 |
|
---|
96 | if (ry >= h)
|
---|
97 | {
|
---|
98 | cy = h;
|
---|
99 | y = r->top+(ry-h)/2;
|
---|
100 | } else
|
---|
101 | {
|
---|
102 | cy = ry;
|
---|
103 | y = r->top;
|
---|
104 | }
|
---|
105 |
|
---|
106 | if (rx >= w+infoPtr->xBmpMargin)
|
---|
107 | cx = w;
|
---|
108 | else
|
---|
109 | cx = MAX(0,rx-w-infoPtr->xBmpMargin);
|
---|
110 |
|
---|
111 | if (ImageList_DrawEx(infoPtr->himl,phdi->iImage,hdc,x,y,cx,cy,CLR_NONE,CLR_NONE,ILD_TRANSPARENT))
|
---|
112 | {
|
---|
113 | r->left += w+2*infoPtr->xBmpMargin;
|
---|
114 | }
|
---|
115 | }
|
---|
116 | }
|
---|
117 |
|
---|
118 | static VOID
|
---|
119 | HEADER_DrawItemBitmap(HDC hdc,HEADER_INFO* infoPtr,HEADER_ITEM* phdi,RECT* r,WCHAR* pszText,UINT uTextJustify)
|
---|
120 | {
|
---|
121 | if ((phdi->fmt & HDF_BITMAP) && !(phdi->fmt & HDF_BITMAP_ON_RIGHT) && (phdi->hbm))
|
---|
122 | {
|
---|
123 | BITMAP bmp;
|
---|
124 | HDC hdcBitmap;
|
---|
125 | INT yD,yS,cx,cy,rx,ry;
|
---|
126 |
|
---|
127 | GetObjectA (phdi->hbm,sizeof(BITMAP),(LPVOID)&bmp);
|
---|
128 |
|
---|
129 | ry = r->bottom-r->top;
|
---|
130 | rx = r->right-r->left;
|
---|
131 |
|
---|
132 | if (ry >= bmp.bmHeight)
|
---|
133 | {
|
---|
134 | cy = bmp.bmHeight;
|
---|
135 | yD = r->top + (ry - bmp.bmHeight) / 2;
|
---|
136 | yS = 0;
|
---|
137 | } else
|
---|
138 | {
|
---|
139 | cy = ry;
|
---|
140 | yD = r->top;
|
---|
141 | yS = (bmp.bmHeight - ry) / 2;
|
---|
142 | }
|
---|
143 |
|
---|
144 | if (rx >= bmp.bmWidth+infoPtr->xBmpMargin)
|
---|
145 | cx = bmp.bmWidth;
|
---|
146 | else
|
---|
147 | cx = MAX(0,rx-bmp.bmWidth-infoPtr->xBmpMargin);
|
---|
148 |
|
---|
149 | hdcBitmap = CreateCompatibleDC (hdc);
|
---|
150 | SelectObject(hdcBitmap,phdi->hbm);
|
---|
151 | BitBlt (hdc,r->left+infoPtr->xBmpMargin,yD,cx,cy,hdcBitmap,0,yS,SRCCOPY);
|
---|
152 | DeleteDC (hdcBitmap);
|
---|
153 |
|
---|
154 | r->left += bmp.bmWidth+2*infoPtr->xBmpMargin;
|
---|
155 | } else if ((phdi->fmt & HDF_BITMAP_ON_RIGHT) && (phdi->hbm))
|
---|
156 | {
|
---|
157 | BITMAP bmp;
|
---|
158 | HDC hdcBitmap;
|
---|
159 | INT xD,yD,yS,cx,cy,rx,ry,tx;
|
---|
160 | RECT textRect;
|
---|
161 |
|
---|
162 | GetObjectA (phdi->hbm,sizeof(BITMAP),(LPVOID)&bmp);
|
---|
163 |
|
---|
164 | textRect = *r;
|
---|
165 | DrawTextExW(hdc,pszText,lstrlenW(pszText),&textRect,DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_CALCRECT|DT_END_ELLIPSIS,NULL);
|
---|
166 | tx = textRect.right - textRect.left;
|
---|
167 | ry = r->bottom-r->top;
|
---|
168 | rx = r->right-r->left;
|
---|
169 |
|
---|
170 | if (ry >= bmp.bmHeight)
|
---|
171 | {
|
---|
172 | cy = bmp.bmHeight;
|
---|
173 | yD = r->top + (ry - bmp.bmHeight) / 2;
|
---|
174 | yS = 0;
|
---|
175 | } else
|
---|
176 | {
|
---|
177 | cy = ry;
|
---|
178 | yD = r->top;
|
---|
179 | yS = (bmp.bmHeight - ry) / 2;
|
---|
180 | }
|
---|
181 |
|
---|
182 | if (r->left+tx+bmp.bmWidth+2*infoPtr->xBmpMargin <= r->right)
|
---|
183 | {
|
---|
184 | cx = bmp.bmWidth;
|
---|
185 | if (uTextJustify & DT_LEFT)
|
---|
186 | xD = r->left+tx+infoPtr->xBmpMargin;
|
---|
187 | else
|
---|
188 | {
|
---|
189 | xD = r->right-infoPtr->xBmpMargin-bmp.bmWidth;
|
---|
190 | r->right = xD;
|
---|
191 | }
|
---|
192 | } else
|
---|
193 | {
|
---|
194 | if (rx >= bmp.bmWidth+2*infoPtr->xBmpMargin)
|
---|
195 | {
|
---|
196 | cx = bmp.bmWidth;
|
---|
197 | xD = r->right-bmp.bmWidth-infoPtr->xBmpMargin;
|
---|
198 | r->right = xD-infoPtr->xBmpMargin;
|
---|
199 | } else
|
---|
200 | {
|
---|
201 | cx = MAX(0,rx-infoPtr->xBmpMargin);
|
---|
202 | xD = r->left;
|
---|
203 | r->right = r->left;
|
---|
204 | }
|
---|
205 | }
|
---|
206 |
|
---|
207 | hdcBitmap = CreateCompatibleDC(hdc);
|
---|
208 | SelectObject(hdcBitmap,phdi->hbm);
|
---|
209 | BitBlt(hdc,xD,yD,cx,cy,hdcBitmap,0,yS,SRCCOPY);
|
---|
210 | DeleteDC (hdcBitmap);
|
---|
211 | }
|
---|
212 | }
|
---|
213 |
|
---|
214 | static VOID
|
---|
215 | HEADER_DrawItemText(HDC hdc,HEADER_INFO* infoPtr,HEADER_ITEM* phdi,RECT* r,WCHAR* pszText,UINT uTextJustify,BOOL bEraseTextBkgnd,BOOL bHotTrack)
|
---|
216 | {
|
---|
217 | if ((phdi->fmt & HDF_STRING) && (phdi->pszText))
|
---|
218 | {
|
---|
219 | INT oldBkMode = SetBkMode(hdc,TRANSPARENT);
|
---|
220 |
|
---|
221 | if ((phdi->fmt & HDF_BITMAP_ON_RIGHT) || !(phdi->fmt & HDF_IMAGE)) r->left += TEXT_MARGIN;
|
---|
222 | if (!(phdi->fmt & HDF_BITMAP_ON_RIGHT)) r->right -= TEXT_MARGIN;
|
---|
223 | if (r->left >= r->right) return;
|
---|
224 |
|
---|
225 | SetTextColor (hdc,GetSysColor(bHotTrack ? COLOR_HIGHLIGHT:COLOR_BTNTEXT)); //CB: not right color: COLOR_HOTLIGHT? (blue in Win95)
|
---|
226 | if (bEraseTextBkgnd)
|
---|
227 | {
|
---|
228 | HBRUSH hbrBk = GetSysColorBrush(COLOR_3DFACE);
|
---|
229 |
|
---|
230 | FillRect(hdc,r,hbrBk);
|
---|
231 | }
|
---|
232 |
|
---|
233 | DrawTextExW(hdc,pszText,lstrlenW(pszText),r,uTextJustify|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS,NULL);
|
---|
234 | if (oldBkMode != TRANSPARENT) SetBkMode(hdc,oldBkMode);
|
---|
235 | }
|
---|
236 | }
|
---|
237 |
|
---|
238 | static INT
|
---|
239 | HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack,BOOL bEraseTextBkgnd)
|
---|
240 | {
|
---|
241 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
242 | HEADER_ITEM *phdi = &infoPtr->items[iItem];
|
---|
243 | RECT r;
|
---|
244 |
|
---|
245 | r = phdi->rect;
|
---|
246 | if (r.right - r.left == 0) return phdi->rect.right;
|
---|
247 |
|
---|
248 | if (GetWindowLongA (hwnd, GWL_STYLE) & HDS_BUTTONS)
|
---|
249 | {
|
---|
250 | if (phdi->bDown)
|
---|
251 | {
|
---|
252 | DrawEdge (hdc,&r,BDR_RAISEDOUTER,BF_RECT | BF_FLAT | BF_MIDDLE | BF_ADJUST);
|
---|
253 | r.left += 2;
|
---|
254 | r.top += 2;
|
---|
255 | } else
|
---|
256 | DrawEdge(hdc,&r,EDGE_RAISED,BF_RECT | BF_SOFT | BF_MIDDLE | BF_ADJUST);
|
---|
257 | } else
|
---|
258 | DrawEdge(hdc,&r,EDGE_ETCHED, BF_BOTTOM | BF_RIGHT | BF_ADJUST);
|
---|
259 |
|
---|
260 | if (r.left >= r.right) return phdi->rect.right;
|
---|
261 |
|
---|
262 | if (phdi->fmt & HDF_OWNERDRAW)
|
---|
263 | {
|
---|
264 | DRAWITEMSTRUCT dis;
|
---|
265 | dis.CtlType = ODT_HEADER;
|
---|
266 | dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
|
---|
267 | dis.itemID = iItem;
|
---|
268 | dis.itemAction = ODA_DRAWENTIRE;
|
---|
269 | dis.itemState = phdi->bDown ? ODS_SELECTED : 0;
|
---|
270 | dis.hwndItem = hwnd;
|
---|
271 | dis.hDC = hdc;
|
---|
272 | dis.rcItem = r;
|
---|
273 | dis.itemData = phdi->lParam;
|
---|
274 | SendMessageA (GetParent(hwnd),WM_DRAWITEM,(WPARAM)dis.CtlID,(LPARAM)&dis);
|
---|
275 | } else
|
---|
276 | {
|
---|
277 | UINT uTextJustify;
|
---|
278 | WCHAR* pszText = phdi->pszText;
|
---|
279 |
|
---|
280 | if ((phdi->fmt & HDF_JUSTIFYMASK) == HDF_CENTER)
|
---|
281 | uTextJustify = DT_CENTER;
|
---|
282 | else if ((phdi->fmt & HDF_JUSTIFYMASK) == HDF_RIGHT)
|
---|
283 | uTextJustify = DT_RIGHT;
|
---|
284 | else uTextJustify = DT_LEFT;
|
---|
285 |
|
---|
286 | if (phdi->pszText == LPSTR_TEXTCALLBACKW)
|
---|
287 | {
|
---|
288 | if (IsWindowUnicode(GetParent(hwnd)))
|
---|
289 | {
|
---|
290 | NMHDDISPINFOW nmhdr;
|
---|
291 |
|
---|
292 | nmhdr.hdr.hwndFrom = hwnd;
|
---|
293 | nmhdr.hdr.idFrom = GetWindowLongW(hwnd,GWL_ID);
|
---|
294 | nmhdr.hdr.code = HDN_GETDISPINFOW;
|
---|
295 | nmhdr.iItem = iItem;
|
---|
296 | nmhdr.mask = HDI_TEXT;
|
---|
297 | nmhdr.cchTextMax = phdi->cchTextMax;
|
---|
298 | nmhdr.pszText = COMCTL32_Alloc(phdi->cchTextMax*sizeof(WCHAR));
|
---|
299 | if (nmhdr.pszText) nmhdr.pszText[0] = 0;
|
---|
300 | nmhdr.lParam = phdi->lParam;
|
---|
301 |
|
---|
302 | SendMessageW(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
|
---|
303 |
|
---|
304 | pszText = nmhdr.pszText;
|
---|
305 | if (nmhdr.mask & HDI_DI_SETITEM)
|
---|
306 | {
|
---|
307 | INT len = pszText ? lstrlenW(pszText):0;
|
---|
308 |
|
---|
309 | if (len)
|
---|
310 | {
|
---|
311 | phdi->pszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
|
---|
312 | lstrcpyW(phdi->pszText,pszText);
|
---|
313 | } else phdi->pszText = NULL;
|
---|
314 | COMCTL32_Free(pszText);
|
---|
315 | pszText = phdi->pszText;
|
---|
316 | }
|
---|
317 | } else
|
---|
318 | {
|
---|
319 | NMHDDISPINFOA nmhdr;
|
---|
320 | INT len;
|
---|
321 |
|
---|
322 | nmhdr.hdr.hwndFrom = hwnd;
|
---|
323 | nmhdr.hdr.idFrom = GetWindowLongA(hwnd,GWL_ID);
|
---|
324 | nmhdr.hdr.code = HDN_GETDISPINFOA;
|
---|
325 | nmhdr.iItem = iItem;
|
---|
326 | nmhdr.mask = HDI_TEXT;
|
---|
327 | nmhdr.cchTextMax = phdi->cchTextMax;
|
---|
328 | nmhdr.pszText = COMCTL32_Alloc(phdi->cchTextMax);
|
---|
329 | if (nmhdr.pszText) nmhdr.pszText[0] = 0;
|
---|
330 | nmhdr.lParam = phdi->lParam;
|
---|
331 |
|
---|
332 | SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
|
---|
333 |
|
---|
334 | len = nmhdr.pszText ? lstrlenA(nmhdr.pszText):0;
|
---|
335 |
|
---|
336 | if (len)
|
---|
337 | {
|
---|
338 | pszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
|
---|
339 | lstrcpyAtoW(pszText,nmhdr.pszText);
|
---|
340 | } else pszText = NULL;
|
---|
341 | COMCTL32_Free(nmhdr.pszText);
|
---|
342 |
|
---|
343 | if (nmhdr.mask & HDI_DI_SETITEM)
|
---|
344 | phdi->pszText = pszText;
|
---|
345 | }
|
---|
346 | }
|
---|
347 |
|
---|
348 | if (!(phdi->fmt & HDI_ORDER) || (phdi->iOrder & (HDF_LEFT | HDF_CENTER)))
|
---|
349 | {
|
---|
350 | HEADER_DrawItemImage(hwnd,hdc,infoPtr,phdi,&r,iItem);
|
---|
351 | if (r.left < r.right)
|
---|
352 | {
|
---|
353 | HEADER_DrawItemBitmap(hdc,infoPtr,phdi,&r,pszText,uTextJustify);
|
---|
354 | if (r.left < r.right)
|
---|
355 | HEADER_DrawItemText(hdc,infoPtr,phdi,&r,pszText,uTextJustify,bEraseTextBkgnd,bHotTrack);
|
---|
356 | }
|
---|
357 | } else
|
---|
358 | {
|
---|
359 | HEADER_DrawItemBitmap(hdc,infoPtr,phdi,&r,pszText,uTextJustify);
|
---|
360 | if (r.left < r.right)
|
---|
361 | {
|
---|
362 | HEADER_DrawItemImage(hwnd,hdc,infoPtr,phdi,&r,iItem);
|
---|
363 | if (r.left < r.right)
|
---|
364 | HEADER_DrawItemText(hdc,infoPtr,phdi,&r,pszText,uTextJustify,bEraseTextBkgnd,bHotTrack);
|
---|
365 | }
|
---|
366 | }
|
---|
367 | if (phdi->pszText == LPSTR_TEXTCALLBACKW) COMCTL32_Free(pszText);
|
---|
368 | }
|
---|
369 |
|
---|
370 | return phdi->rect.right;
|
---|
371 | }
|
---|
372 |
|
---|
373 |
|
---|
374 | static void
|
---|
375 | HEADER_Draw(HWND hwnd,HDC hdc)
|
---|
376 | {
|
---|
377 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
378 | HFONT hFont, hOldFont;
|
---|
379 | RECT rect;
|
---|
380 | HBRUSH hbrBk;
|
---|
381 | INT i, x;
|
---|
382 |
|
---|
383 | /* get rect for the bar, adjusted for the border */
|
---|
384 | GetClientRect (hwnd, &rect);
|
---|
385 |
|
---|
386 | hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
|
---|
387 | hOldFont = SelectObject (hdc, hFont);
|
---|
388 |
|
---|
389 | /* draw Background */
|
---|
390 | hbrBk = GetSysColorBrush(COLOR_3DFACE);
|
---|
391 | FillRect(hdc, &rect, hbrBk);
|
---|
392 |
|
---|
393 | x = rect.left;
|
---|
394 | for (i = 0; i < infoPtr->uNumItem; i++)
|
---|
395 | {
|
---|
396 | x = HEADER_DrawItem(hwnd,hdc,i,infoPtr->iHotItem == i,FALSE);
|
---|
397 | if (x > rect.right)
|
---|
398 | {
|
---|
399 | x = -1;
|
---|
400 | break;
|
---|
401 | }
|
---|
402 | }
|
---|
403 |
|
---|
404 | if (x != -1 && (x <= rect.right) && (infoPtr->uNumItem > 0))
|
---|
405 | {
|
---|
406 | rect.left = x;
|
---|
407 | if (GetWindowLongA (hwnd, GWL_STYLE) & HDS_BUTTONS)
|
---|
408 | DrawEdge (hdc, &rect, EDGE_RAISED, BF_TOP|BF_LEFT|BF_BOTTOM|BF_SOFT);
|
---|
409 | else
|
---|
410 | DrawEdge (hdc, &rect, EDGE_ETCHED, BF_BOTTOM);
|
---|
411 | }
|
---|
412 |
|
---|
413 | SelectObject (hdc, hOldFont);
|
---|
414 | }
|
---|
415 |
|
---|
416 |
|
---|
417 | static void
|
---|
418 | HEADER_RefreshItem (HWND hwnd, HDC hdc, INT iItem)
|
---|
419 | {
|
---|
420 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
421 | HFONT hFont, hOldFont;
|
---|
422 |
|
---|
423 | hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
|
---|
424 | hOldFont = SelectObject (hdc, hFont);
|
---|
425 | HEADER_DrawItem(hwnd,hdc,iItem,infoPtr->iHotItem == iItem,TRUE);
|
---|
426 | SelectObject (hdc, hOldFont);
|
---|
427 | }
|
---|
428 |
|
---|
429 | static void
|
---|
430 | HEADER_Refresh(HWND hwnd)
|
---|
431 | {
|
---|
432 | HDC hdc,hdcCompatible;
|
---|
433 | HBITMAP bitmap,oldbmp;
|
---|
434 | RECT rect;
|
---|
435 |
|
---|
436 | GetClientRect(hwnd,&rect);
|
---|
437 | hdc = GetDC(hwnd);
|
---|
438 | hdcCompatible = CreateCompatibleDC(hdc);
|
---|
439 | bitmap = CreateCompatibleBitmap(hdc,rect.right,rect.bottom);
|
---|
440 | oldbmp = SelectObject(hdcCompatible,bitmap);
|
---|
441 | HEADER_Draw(hwnd,hdcCompatible);
|
---|
442 | BitBlt(hdc,0,0,rect.right,rect.bottom,hdcCompatible,0,0,SRCCOPY);
|
---|
443 | SelectObject(hdcCompatible,oldbmp);
|
---|
444 | DeleteObject(bitmap);
|
---|
445 | DeleteDC(hdcCompatible);
|
---|
446 | ReleaseDC(hwnd,hdc);
|
---|
447 | }
|
---|
448 |
|
---|
449 | static void
|
---|
450 | HEADER_SetItemBounds(HWND hwnd,INT start)
|
---|
451 | {
|
---|
452 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
453 | HEADER_ITEM *phdi;
|
---|
454 | RECT rect;
|
---|
455 | int i, x;
|
---|
456 |
|
---|
457 | if (infoPtr->uNumItem == 0) return;
|
---|
458 |
|
---|
459 | GetClientRect(hwnd,&rect);
|
---|
460 |
|
---|
461 | x = (start > 0) ? infoPtr->items[start-1].rect.right:rect.left;
|
---|
462 | for (i = start;i < infoPtr->uNumItem;i++)
|
---|
463 | {
|
---|
464 | phdi = &infoPtr->items[i];
|
---|
465 | phdi->rect.top = rect.top;
|
---|
466 | phdi->rect.bottom = rect.bottom;
|
---|
467 | phdi->rect.left = x;
|
---|
468 | phdi->rect.right = phdi->rect.left + phdi->cxy;
|
---|
469 | x = phdi->rect.right;
|
---|
470 | }
|
---|
471 | }
|
---|
472 |
|
---|
473 |
|
---|
474 | static void
|
---|
475 | HEADER_ForceItemBounds (HWND hwnd, INT cy)
|
---|
476 | {
|
---|
477 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
478 | HEADER_ITEM *phdi;
|
---|
479 | int i, x;
|
---|
480 |
|
---|
481 | if (infoPtr->uNumItem == 0)
|
---|
482 | return;
|
---|
483 |
|
---|
484 | x = 0;
|
---|
485 | for (i = 0; i < infoPtr->uNumItem; i++) {
|
---|
486 | phdi = &infoPtr->items[i];
|
---|
487 | phdi->rect.top = 0;
|
---|
488 | phdi->rect.bottom = cy;
|
---|
489 | phdi->rect.left = x;
|
---|
490 | phdi->rect.right = phdi->rect.left + phdi->cxy;
|
---|
491 | x = phdi->rect.right;
|
---|
492 | }
|
---|
493 | }
|
---|
494 |
|
---|
495 |
|
---|
496 | static void
|
---|
497 | HEADER_InternalHitTest (HWND hwnd, LPPOINT lpPt, UINT *pFlags, INT *pItem)
|
---|
498 | {
|
---|
499 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
500 | RECT rect, rcTest;
|
---|
501 | INT iCount, width;
|
---|
502 | BOOL bNoWidth;
|
---|
503 |
|
---|
504 | GetClientRect (hwnd, &rect);
|
---|
505 |
|
---|
506 | *pFlags = 0;
|
---|
507 | bNoWidth = FALSE;
|
---|
508 | if (PtInRect (&rect, *lpPt))
|
---|
509 | {
|
---|
510 | if (infoPtr->uNumItem == 0) {
|
---|
511 | *pFlags |= HHT_NOWHERE;
|
---|
512 | *pItem = 1;
|
---|
513 | // TRACE (header, "NOWHERE\n");
|
---|
514 | return;
|
---|
515 | }
|
---|
516 | else {
|
---|
517 | /* somewhere inside */
|
---|
518 | for (iCount = 0; iCount < infoPtr->uNumItem; iCount++) {
|
---|
519 | rect = infoPtr->items[iCount].rect;
|
---|
520 | width = rect.right - rect.left;
|
---|
521 | if (width == 0) {
|
---|
522 | bNoWidth = TRUE;
|
---|
523 | continue;
|
---|
524 | }
|
---|
525 | if (PtInRect (&rect, *lpPt)) {
|
---|
526 | if (width <= 2 * DIVIDER_WIDTH) {
|
---|
527 | *pFlags |= HHT_ONHEADER;
|
---|
528 | *pItem = iCount;
|
---|
529 | // TRACE (header, "ON HEADER %d\n", iCount);
|
---|
530 | return;
|
---|
531 | }
|
---|
532 | if (iCount > 0) {
|
---|
533 | rcTest = rect;
|
---|
534 | rcTest.right = rcTest.left + DIVIDER_WIDTH;
|
---|
535 | if (PtInRect (&rcTest, *lpPt)) {
|
---|
536 | if (bNoWidth) {
|
---|
537 | *pFlags |= HHT_ONDIVOPEN;
|
---|
538 | *pItem = iCount - 1;
|
---|
539 | // TRACE (header, "ON DIVOPEN %d\n", *pItem);
|
---|
540 | return;
|
---|
541 | }
|
---|
542 | else {
|
---|
543 | *pFlags |= HHT_ONDIVIDER;
|
---|
544 | *pItem = iCount - 1;
|
---|
545 | // TRACE (header, "ON DIVIDER %d\n", *pItem);
|
---|
546 | return;
|
---|
547 | }
|
---|
548 | }
|
---|
549 | }
|
---|
550 | rcTest = rect;
|
---|
551 | rcTest.left = rcTest.right - DIVIDER_WIDTH;
|
---|
552 | if (PtInRect (&rcTest, *lpPt)) {
|
---|
553 | *pFlags |= HHT_ONDIVIDER;
|
---|
554 | *pItem = iCount;
|
---|
555 | // TRACE (header, "ON DIVIDER %d\n", *pItem);
|
---|
556 | return;
|
---|
557 | }
|
---|
558 |
|
---|
559 | *pFlags |= HHT_ONHEADER;
|
---|
560 | *pItem = iCount;
|
---|
561 | // TRACE (header, "ON HEADER %d\n", iCount);
|
---|
562 | return;
|
---|
563 | }
|
---|
564 | }
|
---|
565 |
|
---|
566 | /* check for last divider part (on nowhere) */
|
---|
567 | rect = infoPtr->items[infoPtr->uNumItem-1].rect;
|
---|
568 | rect.left = rect.right;
|
---|
569 | rect.right += DIVIDER_WIDTH;
|
---|
570 | if (PtInRect (&rect, *lpPt)) {
|
---|
571 | if (bNoWidth) {
|
---|
572 | *pFlags |= HHT_ONDIVOPEN;
|
---|
573 | *pItem = infoPtr->uNumItem - 1;
|
---|
574 | // TRACE (header, "ON DIVOPEN %d\n", *pItem);
|
---|
575 | return;
|
---|
576 | }
|
---|
577 | else {
|
---|
578 | *pFlags |= HHT_ONDIVIDER;
|
---|
579 | *pItem = infoPtr->uNumItem-1;
|
---|
580 | // TRACE (header, "ON DIVIDER %d\n", *pItem);
|
---|
581 | return;
|
---|
582 | }
|
---|
583 | }
|
---|
584 |
|
---|
585 | *pFlags |= HHT_NOWHERE;
|
---|
586 | *pItem = 1;
|
---|
587 | // TRACE (header, "NOWHERE\n");
|
---|
588 | return;
|
---|
589 | }
|
---|
590 | }
|
---|
591 | else {
|
---|
592 | if (lpPt->x < rect.left) {
|
---|
593 | // TRACE (header, "TO LEFT\n");
|
---|
594 | *pFlags |= HHT_TOLEFT;
|
---|
595 | }
|
---|
596 | else if (lpPt->x > rect.right) {
|
---|
597 | // TRACE (header, "TO LEFT\n");
|
---|
598 | *pFlags |= HHT_TORIGHT;
|
---|
599 | }
|
---|
600 |
|
---|
601 | if (lpPt->y < rect.top) {
|
---|
602 | // TRACE (header, "ABOVE\n");
|
---|
603 | *pFlags |= HHT_ABOVE;
|
---|
604 | }
|
---|
605 | else if (lpPt->y > rect.bottom) {
|
---|
606 | // TRACE (header, "BELOW\n");
|
---|
607 | *pFlags |= HHT_BELOW;
|
---|
608 | }
|
---|
609 | }
|
---|
610 |
|
---|
611 | *pItem = 1;
|
---|
612 | // TRACE (header, "flags=0x%X\n", *pFlags);
|
---|
613 | return;
|
---|
614 | }
|
---|
615 |
|
---|
616 |
|
---|
617 | static void
|
---|
618 | HEADER_DrawTrackLine (HWND hwnd, HDC hdc, INT x)
|
---|
619 | {
|
---|
620 | RECT rect;
|
---|
621 | HPEN hOldPen;
|
---|
622 | INT oldRop;
|
---|
623 |
|
---|
624 | GetClientRect (hwnd, &rect);
|
---|
625 |
|
---|
626 | rect.left = x;
|
---|
627 | rect.right = x+1;
|
---|
628 | InvertRect(hdc,&rect);
|
---|
629 | /* //CB: Odin bug!!! This code doesn't work:
|
---|
630 | hOldPen = SelectObject (hdc, GetStockObject (BLACK_PEN));
|
---|
631 | oldRop = SetROP2 (hdc, R2_XORPEN);
|
---|
632 | MoveToEx (hdc, x, rect.top, NULL);
|
---|
633 | LineTo (hdc, x, rect.bottom);
|
---|
634 | SetROP2 (hdc, oldRop);
|
---|
635 | SelectObject (hdc, hOldPen);
|
---|
636 | */
|
---|
637 | }
|
---|
638 |
|
---|
639 | static BOOL
|
---|
640 | HEADER_SendSimpleNotify (HWND hwnd, UINT code)
|
---|
641 | {
|
---|
642 | NMHDR nmhdr;
|
---|
643 |
|
---|
644 | nmhdr.hwndFrom = hwnd;
|
---|
645 | nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
|
---|
646 | nmhdr.code = code;
|
---|
647 |
|
---|
648 | return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
|
---|
649 | (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
|
---|
650 | }
|
---|
651 |
|
---|
652 |
|
---|
653 | static BOOL
|
---|
654 | HEADER_SendHeaderNotify (HWND hwnd, UINT code, INT iItem)
|
---|
655 | {
|
---|
656 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
657 | NMHEADERA nmhdr;
|
---|
658 | HDITEMA nmitem;
|
---|
659 |
|
---|
660 | nmhdr.hdr.hwndFrom = hwnd;
|
---|
661 | nmhdr.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
|
---|
662 | nmhdr.hdr.code = code;
|
---|
663 | nmhdr.iItem = iItem;
|
---|
664 | nmhdr.iButton = 0;
|
---|
665 | nmhdr.pitem = &nmitem;
|
---|
666 | nmitem.mask = 0;
|
---|
667 | nmitem.cxy = infoPtr->items[iItem].cxy;
|
---|
668 | nmitem.hbm = infoPtr->items[iItem].hbm;
|
---|
669 | nmitem.pszText = NULL;
|
---|
670 | nmitem.cchTextMax = 0;
|
---|
671 | /* nmitem.pszText = infoPtr->items[iItem].pszText; */
|
---|
672 | /* nmitem.cchTextMax = infoPtr->items[iItem].cchTextMax; */
|
---|
673 | nmitem.fmt = infoPtr->items[iItem].fmt;
|
---|
674 | nmitem.lParam = infoPtr->items[iItem].lParam;
|
---|
675 | nmitem.iOrder = infoPtr->items[iItem].iOrder;
|
---|
676 | nmitem.iImage = infoPtr->items[iItem].iImage;
|
---|
677 |
|
---|
678 | return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
|
---|
679 | (WPARAM)nmhdr.hdr.idFrom, (LPARAM)&nmhdr);
|
---|
680 | }
|
---|
681 |
|
---|
682 |
|
---|
683 | static BOOL
|
---|
684 | HEADER_SendClickNotify (HWND hwnd, UINT code, INT iItem)
|
---|
685 | {
|
---|
686 | NMHEADERA nmhdr;
|
---|
687 |
|
---|
688 | nmhdr.hdr.hwndFrom = hwnd;
|
---|
689 | nmhdr.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
|
---|
690 | nmhdr.hdr.code = code;
|
---|
691 | nmhdr.iItem = iItem;
|
---|
692 | nmhdr.iButton = 0;
|
---|
693 | nmhdr.pitem = NULL;
|
---|
694 |
|
---|
695 | return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
|
---|
696 | (WPARAM)nmhdr.hdr.idFrom, (LPARAM)&nmhdr);
|
---|
697 | }
|
---|
698 |
|
---|
699 | static LRESULT
|
---|
700 | HEADER_ClearFilter(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
701 | {
|
---|
702 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
|
---|
703 |
|
---|
704 | //CB:todo
|
---|
705 | //HDN_FILTERCHANGE
|
---|
706 |
|
---|
707 | return 0;
|
---|
708 | }
|
---|
709 |
|
---|
710 | static LRESULT
|
---|
711 | HEADER_EditFilter(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
712 | {
|
---|
713 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
|
---|
714 | INT iItem = (INT)wParam;
|
---|
715 |
|
---|
716 | if ((iItem < 0) || (iItem >= (INT)infoPtr->uNumItem)) return 0;
|
---|
717 |
|
---|
718 | //CB: todo
|
---|
719 |
|
---|
720 | return iItem;
|
---|
721 | }
|
---|
722 |
|
---|
723 | static LRESULT
|
---|
724 | HEADER_SetFilterChangeTimeout(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
725 | {
|
---|
726 | //CB: todo
|
---|
727 |
|
---|
728 | return 0;
|
---|
729 | }
|
---|
730 |
|
---|
731 | static LRESULT
|
---|
732 | HEADER_CreateDragImage (HWND hwnd, WPARAM wParam)
|
---|
733 | {
|
---|
734 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
|
---|
735 | INT iItem = (INT)wParam;
|
---|
736 | HEADER_ITEM *phdi;
|
---|
737 | HICON hicon;
|
---|
738 | HIMAGELIST himl;
|
---|
739 |
|
---|
740 | if (!infoPtr->himl || (iItem < 0) || (iItem >= (INT)infoPtr->uNumItem)) return 0;
|
---|
741 | phdi = &infoPtr->items[iItem];
|
---|
742 | /*
|
---|
743 | hicon = ImageList_GetIcon(infoPtr->himl,phdi->iImage,ILD_BLEND | ILD_TRANSPARENT);
|
---|
744 | if (!hicon) return 0;
|
---|
745 |
|
---|
746 | himl = ImageList_Create();
|
---|
747 | */
|
---|
748 | //CB: create and return new imagelist
|
---|
749 |
|
---|
750 | return 0;
|
---|
751 | }
|
---|
752 |
|
---|
753 | static LRESULT
|
---|
754 | HEADER_SetHotDivider(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
755 | {
|
---|
756 | //CB:todo
|
---|
757 |
|
---|
758 | return 0;
|
---|
759 | }
|
---|
760 |
|
---|
761 | static LRESULT
|
---|
762 | HEADER_DeleteItem (HWND hwnd, WPARAM wParam)
|
---|
763 | {
|
---|
764 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
|
---|
765 | INT iItem = (INT)wParam;
|
---|
766 | HDC hdc;
|
---|
767 |
|
---|
768 | // TRACE(header, "[iItem=%d]\n", iItem);
|
---|
769 |
|
---|
770 | if ((iItem < 0) || (iItem >= (INT)infoPtr->uNumItem)) return FALSE;
|
---|
771 |
|
---|
772 | if (infoPtr->uNumItem == 1)
|
---|
773 | {
|
---|
774 | //clear
|
---|
775 | if (infoPtr->items[0].pszText) COMCTL32_Free(infoPtr->items[0].pszText);
|
---|
776 | COMCTL32_Free (infoPtr->items);
|
---|
777 | infoPtr->items = 0;
|
---|
778 | infoPtr->uNumItem = 0;
|
---|
779 |
|
---|
780 | InvalidateRect(hwnd,NULL,FALSE);
|
---|
781 | } else
|
---|
782 | {
|
---|
783 | HEADER_ITEM *oldItems = infoPtr->items;
|
---|
784 | // TRACE(header, "Complex delete! [iItem=%d]\n", iItem);
|
---|
785 |
|
---|
786 | if (infoPtr->items[iItem].pszText) COMCTL32_Free(infoPtr->items[iItem].pszText);
|
---|
787 |
|
---|
788 | infoPtr->uNumItem--;
|
---|
789 | infoPtr->items = COMCTL32_Alloc (sizeof (HEADER_ITEM) * infoPtr->uNumItem);
|
---|
790 | /* pre delete copy */
|
---|
791 | if (iItem > 0)
|
---|
792 | memcpy (&infoPtr->items[0], &oldItems[0],iItem*sizeof(HEADER_ITEM));
|
---|
793 |
|
---|
794 | /* post delete copy */
|
---|
795 | if (iItem < infoPtr->uNumItem)
|
---|
796 | memcpy (&infoPtr->items[iItem],&oldItems[iItem+1],(infoPtr->uNumItem-iItem)*sizeof(HEADER_ITEM));
|
---|
797 |
|
---|
798 | COMCTL32_Free(oldItems);
|
---|
799 |
|
---|
800 | if (iItem < infoPtr->uNumItem) HEADER_SetItemBounds(hwnd,iItem);
|
---|
801 |
|
---|
802 | HEADER_Refresh(hwnd);
|
---|
803 |
|
---|
804 | }
|
---|
805 |
|
---|
806 | return TRUE;
|
---|
807 | }
|
---|
808 |
|
---|
809 | static LRESULT
|
---|
810 | HEADER_GetBitmapMargin(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
811 | {
|
---|
812 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
813 |
|
---|
814 | return infoPtr->xBmpMargin;
|
---|
815 | }
|
---|
816 |
|
---|
817 | static LRESULT
|
---|
818 | HEADER_SetBitmapMargin(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
819 | {
|
---|
820 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
821 | INT oldMargin = infoPtr->xBmpMargin;
|
---|
822 |
|
---|
823 | if (infoPtr->xBmpMargin != (INT)wParam)
|
---|
824 | {
|
---|
825 | infoPtr->xBmpMargin = (INT)wParam;
|
---|
826 | HEADER_Refresh(hwnd);
|
---|
827 | }
|
---|
828 |
|
---|
829 | return oldMargin;
|
---|
830 | }
|
---|
831 |
|
---|
832 | static LRESULT
|
---|
833 | HEADER_GetImageList (HWND hwnd)
|
---|
834 | {
|
---|
835 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
836 |
|
---|
837 | return (LRESULT)infoPtr->himl;
|
---|
838 | }
|
---|
839 |
|
---|
840 |
|
---|
841 | static LRESULT
|
---|
842 | HEADER_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
843 | {
|
---|
844 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
|
---|
845 | HDITEMA *phdi = (HDITEMA*)lParam;
|
---|
846 | INT nItem = (INT)wParam;
|
---|
847 | HEADER_ITEM *lpItem;
|
---|
848 |
|
---|
849 | if (!phdi) return FALSE;
|
---|
850 | if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) return FALSE;
|
---|
851 |
|
---|
852 | // TRACE (header, "[nItem=%d]\n", nItem);
|
---|
853 |
|
---|
854 | if (phdi->mask == 0) return TRUE;
|
---|
855 |
|
---|
856 | lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
|
---|
857 |
|
---|
858 | if (phdi->mask & HDI_BITMAP) phdi->hbm = lpItem->hbm;
|
---|
859 |
|
---|
860 | if (phdi->mask & HDI_FORMAT) phdi->fmt = lpItem->fmt;
|
---|
861 |
|
---|
862 | if (phdi->mask & HDI_FILTER)
|
---|
863 | {
|
---|
864 | phdi->type = lpItem->type;
|
---|
865 | phdi->pvFilter = lpItem->pvFilter;
|
---|
866 | }
|
---|
867 |
|
---|
868 | if (phdi->mask & (HDI_WIDTH | HDI_HEIGHT)) phdi->cxy = lpItem->cxy;
|
---|
869 |
|
---|
870 | if (phdi->mask & HDI_IMAGE) phdi->iImage = lpItem->iImage;
|
---|
871 |
|
---|
872 | if (phdi->mask & HDI_LPARAM) phdi->lParam = lpItem->lParam;
|
---|
873 |
|
---|
874 | if (phdi->mask & HDI_ORDER) phdi->iOrder = lpItem->iOrder;
|
---|
875 |
|
---|
876 | if (phdi->mask & HDI_TEXT)
|
---|
877 | {
|
---|
878 | if (lpItem->pszText != LPSTR_TEXTCALLBACKW)
|
---|
879 | {
|
---|
880 | if (lpItem->pszText)
|
---|
881 | lstrcpynWtoA (phdi->pszText,lpItem->pszText,phdi->cchTextMax);
|
---|
882 | else
|
---|
883 | phdi->pszText = NULL;
|
---|
884 | } else phdi->pszText = LPSTR_TEXTCALLBACKA;
|
---|
885 | }
|
---|
886 |
|
---|
887 | return TRUE;
|
---|
888 | }
|
---|
889 |
|
---|
890 | static LRESULT
|
---|
891 | HEADER_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
892 | {
|
---|
893 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
|
---|
894 | HDITEMW *phdi = (HDITEMW*)lParam;
|
---|
895 | INT nItem = (INT)wParam;
|
---|
896 | HEADER_ITEM *lpItem;
|
---|
897 |
|
---|
898 | if (!phdi) return FALSE;
|
---|
899 | if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) return FALSE;
|
---|
900 |
|
---|
901 | // TRACE (header, "[nItem=%d]\n", nItem);
|
---|
902 |
|
---|
903 | if (phdi->mask == 0) return TRUE;
|
---|
904 |
|
---|
905 | lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
|
---|
906 |
|
---|
907 | if (phdi->mask & HDI_BITMAP) phdi->hbm = lpItem->hbm;
|
---|
908 |
|
---|
909 | if (phdi->mask & HDI_FORMAT) phdi->fmt = lpItem->fmt;
|
---|
910 |
|
---|
911 | if (phdi->mask & HDI_FILTER)
|
---|
912 | {
|
---|
913 | phdi->type = lpItem->type;
|
---|
914 | phdi->pvFilter = lpItem->pvFilter;
|
---|
915 | }
|
---|
916 |
|
---|
917 | if (phdi->mask & (HDI_WIDTH | HDI_HEIGHT)) phdi->cxy = lpItem->cxy;
|
---|
918 |
|
---|
919 | if (phdi->mask & HDI_IMAGE) phdi->iImage = lpItem->iImage;
|
---|
920 |
|
---|
921 | if (phdi->mask & HDI_LPARAM) phdi->lParam = lpItem->lParam;
|
---|
922 |
|
---|
923 | if (phdi->mask & HDI_ORDER) phdi->iOrder = lpItem->iOrder;
|
---|
924 |
|
---|
925 | if (phdi->mask & HDI_TEXT)
|
---|
926 | {
|
---|
927 | if (lpItem->pszText != LPSTR_TEXTCALLBACKW)
|
---|
928 | {
|
---|
929 | if (lpItem->pszText)
|
---|
930 | lstrcpynW (phdi->pszText,lpItem->pszText,phdi->cchTextMax);
|
---|
931 | else
|
---|
932 | phdi->pszText = NULL;
|
---|
933 | } else phdi->pszText = LPSTR_TEXTCALLBACKW;
|
---|
934 | }
|
---|
935 |
|
---|
936 | return TRUE;
|
---|
937 | }
|
---|
938 |
|
---|
939 |
|
---|
940 | static LRESULT
|
---|
941 | HEADER_GetItemCount (HWND hwnd)
|
---|
942 | {
|
---|
943 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
944 |
|
---|
945 | return infoPtr->uNumItem;
|
---|
946 | }
|
---|
947 |
|
---|
948 |
|
---|
949 | static LRESULT
|
---|
950 | HEADER_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
951 | {
|
---|
952 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
953 | INT iItem = (INT)wParam;
|
---|
954 | LPRECT lpRect = (LPRECT)lParam;
|
---|
955 |
|
---|
956 | if (!lpRect || (iItem < 0) || (iItem >= (INT)infoPtr->uNumItem)) return FALSE;
|
---|
957 |
|
---|
958 | lpRect->left = infoPtr->items[iItem].rect.left;
|
---|
959 | lpRect->right = infoPtr->items[iItem].rect.right;
|
---|
960 | lpRect->top = infoPtr->items[iItem].rect.top;
|
---|
961 | lpRect->bottom = infoPtr->items[iItem].rect.bottom;
|
---|
962 |
|
---|
963 | return TRUE;
|
---|
964 | }
|
---|
965 |
|
---|
966 | static LRESULT
|
---|
967 | HEADER_GetOrderArray(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
968 | {
|
---|
969 | //CB: todo
|
---|
970 |
|
---|
971 | return 0;
|
---|
972 | }
|
---|
973 |
|
---|
974 | static LRESULT
|
---|
975 | HEADER_SetOrderArray(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
976 | {
|
---|
977 | //CB: todo
|
---|
978 | HEADER_SetItemBounds(hwnd,0);
|
---|
979 | HEADER_Refresh(hwnd);
|
---|
980 |
|
---|
981 | return 0;
|
---|
982 | }
|
---|
983 |
|
---|
984 | static LRESULT
|
---|
985 | HEADER_OrderToIndex(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
986 | {
|
---|
987 | //CB:todo
|
---|
988 |
|
---|
989 | return 0;
|
---|
990 | }
|
---|
991 |
|
---|
992 | static LRESULT
|
---|
993 | HEADER_GetUnicodeFormat (HWND hwnd)
|
---|
994 | {
|
---|
995 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
|
---|
996 |
|
---|
997 | return infoPtr->bUnicode;
|
---|
998 | }
|
---|
999 |
|
---|
1000 |
|
---|
1001 | static LRESULT
|
---|
1002 | HEADER_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1003 | {
|
---|
1004 | LPHDHITTESTINFO phti = (LPHDHITTESTINFO)lParam;
|
---|
1005 |
|
---|
1006 | HEADER_InternalHitTest (hwnd, &phti->pt, &phti->flags, &phti->iItem);
|
---|
1007 |
|
---|
1008 | return phti->iItem;
|
---|
1009 | }
|
---|
1010 |
|
---|
1011 |
|
---|
1012 | static LRESULT
|
---|
1013 | HEADER_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1014 | {
|
---|
1015 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1016 | HDITEMA *phdi = (HDITEMA*)lParam;
|
---|
1017 | INT nItem = (INT)wParam;
|
---|
1018 | HEADER_ITEM *lpItem;
|
---|
1019 |
|
---|
1020 | if ((phdi == NULL) || (nItem < 0)) return -1;
|
---|
1021 |
|
---|
1022 | if (nItem > infoPtr->uNumItem) nItem = infoPtr->uNumItem;
|
---|
1023 |
|
---|
1024 | if (infoPtr->uNumItem == 0)
|
---|
1025 | {
|
---|
1026 | infoPtr->items = COMCTL32_Alloc(sizeof(HEADER_ITEM));
|
---|
1027 | infoPtr->uNumItem++;
|
---|
1028 | } else
|
---|
1029 | {
|
---|
1030 | HEADER_ITEM *oldItems = infoPtr->items;
|
---|
1031 |
|
---|
1032 | infoPtr->uNumItem++;
|
---|
1033 | infoPtr->items = COMCTL32_Alloc(sizeof(HEADER_ITEM)*infoPtr->uNumItem);
|
---|
1034 | if (nItem == 0)
|
---|
1035 | memcpy (&infoPtr->items[1],&oldItems[0],(infoPtr->uNumItem-1)*sizeof(HEADER_ITEM));
|
---|
1036 | else
|
---|
1037 | {
|
---|
1038 | /* pre insert copy */
|
---|
1039 | memcpy (&infoPtr->items[0],&oldItems[0],nItem*sizeof(HEADER_ITEM));
|
---|
1040 |
|
---|
1041 | /* post insert copy */
|
---|
1042 | if (nItem < infoPtr->uNumItem-1)
|
---|
1043 | memcpy (&infoPtr->items[nItem+1],&oldItems[nItem],(infoPtr->uNumItem - nItem)*sizeof(HEADER_ITEM));
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 | COMCTL32_Free (oldItems);
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 | lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
|
---|
1050 | lpItem->bDown = FALSE;
|
---|
1051 |
|
---|
1052 | lpItem->cxy = (phdi->mask & HDI_WIDTH || phdi->mask & HDI_HEIGHT) ? phdi->cxy:0;
|
---|
1053 |
|
---|
1054 | if (phdi->mask & HDI_TEXT)
|
---|
1055 | {
|
---|
1056 | if (!phdi->pszText) lpItem->pszText = NULL;
|
---|
1057 | else if (phdi->pszText != LPSTR_TEXTCALLBACKA)
|
---|
1058 | {
|
---|
1059 | INT len;
|
---|
1060 |
|
---|
1061 | len = lstrlenA(phdi->pszText);
|
---|
1062 | if (len == 0) lpItem->pszText = NULL; else
|
---|
1063 | {
|
---|
1064 | lpItem->pszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
|
---|
1065 | lstrcpyAtoW(lpItem->pszText,phdi->pszText);
|
---|
1066 | }
|
---|
1067 | } else lpItem->pszText = LPSTR_TEXTCALLBACKW;
|
---|
1068 | lpItem->cchTextMax = phdi->cchTextMax;
|
---|
1069 | } else
|
---|
1070 | {
|
---|
1071 | lpItem->pszText = NULL;
|
---|
1072 | lpItem->cchTextMax = 0;
|
---|
1073 | }
|
---|
1074 |
|
---|
1075 | lpItem->fmt = (phdi->mask & HDI_FORMAT) ? phdi->fmt:HDF_LEFT;
|
---|
1076 | if (lpItem->fmt == 0) lpItem->fmt = HDF_LEFT;
|
---|
1077 |
|
---|
1078 | lpItem->lParam = (phdi->mask & HDI_LPARAM) ? phdi->lParam:0;
|
---|
1079 |
|
---|
1080 | lpItem->iImage = (phdi->mask & HDI_IMAGE) ? phdi->iImage:0;
|
---|
1081 |
|
---|
1082 | lpItem->iOrder = (phdi->mask & HDI_ORDER) ? phdi->iOrder:HDF_LEFT;
|
---|
1083 |
|
---|
1084 | lpItem->hbm = (phdi->mask & HDI_BITMAP) ? phdi->hbm:0;
|
---|
1085 |
|
---|
1086 | if (phdi->mask & HDI_FILTER)
|
---|
1087 | {
|
---|
1088 | lpItem->type = phdi->type;
|
---|
1089 | lpItem->pvFilter = phdi->pvFilter;
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 | HEADER_SetItemBounds (hwnd,nItem);
|
---|
1093 | HEADER_Refresh(hwnd);
|
---|
1094 |
|
---|
1095 | return nItem;
|
---|
1096 | }
|
---|
1097 |
|
---|
1098 | static LRESULT
|
---|
1099 | HEADER_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1100 | {
|
---|
1101 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1102 | HDITEMW *phdi = (HDITEMW*)lParam;
|
---|
1103 | INT nItem = (INT)wParam;
|
---|
1104 | HEADER_ITEM *lpItem;
|
---|
1105 |
|
---|
1106 | if ((phdi == NULL) || (nItem < 0)) return -1;
|
---|
1107 |
|
---|
1108 | if (nItem > infoPtr->uNumItem) nItem = infoPtr->uNumItem;
|
---|
1109 |
|
---|
1110 | if (infoPtr->uNumItem == 0)
|
---|
1111 | {
|
---|
1112 | infoPtr->items = COMCTL32_Alloc(sizeof(HEADER_ITEM));
|
---|
1113 | infoPtr->uNumItem++;
|
---|
1114 | } else
|
---|
1115 | {
|
---|
1116 | HEADER_ITEM *oldItems = infoPtr->items;
|
---|
1117 |
|
---|
1118 | infoPtr->uNumItem++;
|
---|
1119 | infoPtr->items = COMCTL32_Alloc(sizeof(HEADER_ITEM)*infoPtr->uNumItem);
|
---|
1120 | if (nItem == 0)
|
---|
1121 | memcpy (&infoPtr->items[1],&oldItems[0],(infoPtr->uNumItem-1)*sizeof(HEADER_ITEM));
|
---|
1122 | else
|
---|
1123 | {
|
---|
1124 | /* pre insert copy */
|
---|
1125 | memcpy (&infoPtr->items[0],&oldItems[0],nItem*sizeof(HEADER_ITEM));
|
---|
1126 |
|
---|
1127 | /* post insert copy */
|
---|
1128 | if (nItem < infoPtr->uNumItem-1)
|
---|
1129 | memcpy (&infoPtr->items[nItem+1],&oldItems[nItem],(infoPtr->uNumItem - nItem)*sizeof(HEADER_ITEM));
|
---|
1130 | }
|
---|
1131 |
|
---|
1132 | COMCTL32_Free (oldItems);
|
---|
1133 | }
|
---|
1134 |
|
---|
1135 | lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
|
---|
1136 | lpItem->bDown = FALSE;
|
---|
1137 |
|
---|
1138 | lpItem->cxy = (phdi->mask & HDI_WIDTH || phdi->mask & HDI_HEIGHT) ? phdi->cxy:0;
|
---|
1139 |
|
---|
1140 | if (phdi->mask & HDI_TEXT)
|
---|
1141 | {
|
---|
1142 | if (!phdi->pszText) lpItem->pszText = NULL;
|
---|
1143 | else if (phdi->pszText != LPSTR_TEXTCALLBACKW)
|
---|
1144 | {
|
---|
1145 | INT len;
|
---|
1146 |
|
---|
1147 | len = lstrlenW(phdi->pszText);
|
---|
1148 | if (len == 0) lpItem->pszText = NULL; else
|
---|
1149 | {
|
---|
1150 | lpItem->pszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
|
---|
1151 | lstrcpyW(lpItem->pszText,phdi->pszText);
|
---|
1152 | }
|
---|
1153 | } else lpItem->pszText = LPSTR_TEXTCALLBACKW;
|
---|
1154 | lpItem->cchTextMax = phdi->cchTextMax;
|
---|
1155 | } else
|
---|
1156 | {
|
---|
1157 | lpItem->pszText = NULL;
|
---|
1158 | lpItem->cchTextMax = 0;
|
---|
1159 | }
|
---|
1160 |
|
---|
1161 | lpItem->fmt = (phdi->mask & HDI_FORMAT) ? phdi->fmt:HDF_LEFT;
|
---|
1162 | if (lpItem->fmt == 0) lpItem->fmt = HDF_LEFT;
|
---|
1163 |
|
---|
1164 | lpItem->lParam = (phdi->mask & HDI_LPARAM) ? phdi->lParam:0;
|
---|
1165 |
|
---|
1166 | lpItem->iImage = (phdi->mask & HDI_IMAGE) ? phdi->iImage:0;
|
---|
1167 |
|
---|
1168 | lpItem->iOrder = (phdi->mask & HDI_ORDER) ? phdi->iOrder:HDF_LEFT;
|
---|
1169 |
|
---|
1170 | lpItem->hbm = (phdi->mask & HDI_BITMAP) ? phdi->hbm:0;
|
---|
1171 |
|
---|
1172 | if (phdi->mask & HDI_FILTER)
|
---|
1173 | {
|
---|
1174 | lpItem->type = phdi->type;
|
---|
1175 | lpItem->pvFilter = phdi->pvFilter;
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | HEADER_SetItemBounds (hwnd,nItem);
|
---|
1179 | HEADER_Refresh(hwnd);
|
---|
1180 |
|
---|
1181 | return nItem;
|
---|
1182 | }
|
---|
1183 |
|
---|
1184 |
|
---|
1185 | static LRESULT
|
---|
1186 | HEADER_Layout (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1187 | {
|
---|
1188 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1189 | LPHDLAYOUT lpLayout = (LPHDLAYOUT)lParam;
|
---|
1190 |
|
---|
1191 | lpLayout->pwpos->hwnd = hwnd;
|
---|
1192 | lpLayout->pwpos->hwndInsertAfter = 0;
|
---|
1193 | lpLayout->pwpos->x = lpLayout->prc->left;
|
---|
1194 | lpLayout->pwpos->y = lpLayout->prc->top;
|
---|
1195 | lpLayout->pwpos->cx = lpLayout->prc->right - lpLayout->prc->left;
|
---|
1196 | if (GetWindowLongA (hwnd, GWL_STYLE) & HDS_HIDDEN)
|
---|
1197 | lpLayout->pwpos->cy = 0;
|
---|
1198 | else
|
---|
1199 | lpLayout->pwpos->cy = infoPtr->nHeight;
|
---|
1200 | lpLayout->pwpos->flags = SWP_NOZORDER;
|
---|
1201 |
|
---|
1202 | // TRACE (header, "Layout x=%d y=%d cx=%d cy=%d\n",
|
---|
1203 | // lpLayout->pwpos->x, lpLayout->pwpos->y,
|
---|
1204 | // lpLayout->pwpos->cx, lpLayout->pwpos->cy);
|
---|
1205 |
|
---|
1206 | HEADER_ForceItemBounds (hwnd, lpLayout->pwpos->cy);
|
---|
1207 |
|
---|
1208 | /* hack */
|
---|
1209 | #ifdef __HDM_LAYOUT_HACK__
|
---|
1210 | MoveWindow (lpLayout->pwpos->hwnd, lpLayout->pwpos->x, lpLayout->pwpos->y,
|
---|
1211 | lpLayout->pwpos->cx, lpLayout->pwpos->cy, TRUE);
|
---|
1212 | #endif
|
---|
1213 |
|
---|
1214 | return TRUE;
|
---|
1215 | }
|
---|
1216 |
|
---|
1217 |
|
---|
1218 | static LRESULT
|
---|
1219 | HEADER_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1220 | {
|
---|
1221 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1222 | HIMAGELIST himlOld;
|
---|
1223 |
|
---|
1224 | himlOld = infoPtr->himl;
|
---|
1225 | infoPtr->himl = (HIMAGELIST)lParam;
|
---|
1226 |
|
---|
1227 | HEADER_Refresh(hwnd);
|
---|
1228 |
|
---|
1229 | return (LRESULT)himlOld;
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 |
|
---|
1233 | static LRESULT
|
---|
1234 | HEADER_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1235 | {
|
---|
1236 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1237 | HDITEMA *phdi = (HDITEMA*)lParam;
|
---|
1238 | INT nItem = (INT)wParam;
|
---|
1239 | HEADER_ITEM *lpItem;
|
---|
1240 | HDC hdc;
|
---|
1241 |
|
---|
1242 | if (phdi == NULL) return FALSE;
|
---|
1243 | if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) return FALSE;
|
---|
1244 | if (phdi->mask == 0) return TRUE;
|
---|
1245 |
|
---|
1246 | // TRACE (header, "[nItem=%d]\n", nItem);
|
---|
1247 |
|
---|
1248 | if (HEADER_SendHeaderNotify(hwnd,HDN_ITEMCHANGINGA,nItem)) return FALSE;
|
---|
1249 |
|
---|
1250 | lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
|
---|
1251 |
|
---|
1252 | if (phdi->mask & HDI_BITMAP) lpItem->hbm = phdi->hbm;
|
---|
1253 |
|
---|
1254 | if (phdi->mask & HDI_FORMAT) lpItem->fmt = phdi->fmt;
|
---|
1255 |
|
---|
1256 | if (phdi->mask & HDI_FILTER)
|
---|
1257 | {
|
---|
1258 | lpItem->type = lpItem->type;
|
---|
1259 | lpItem->pvFilter = lpItem->pvFilter;
|
---|
1260 | }
|
---|
1261 |
|
---|
1262 | if (phdi->mask & (HDI_WIDTH | HDI_WIDTH)) lpItem->cxy = phdi->cxy;
|
---|
1263 |
|
---|
1264 | if (phdi->mask & HDI_IMAGE) lpItem->iImage = phdi->iImage;
|
---|
1265 |
|
---|
1266 | if (phdi->mask & HDI_LPARAM) lpItem->lParam = phdi->lParam;
|
---|
1267 |
|
---|
1268 | if (phdi->mask & HDI_ORDER) lpItem->iOrder = phdi->iOrder;
|
---|
1269 |
|
---|
1270 | if (phdi->mask & HDI_TEXT)
|
---|
1271 | {
|
---|
1272 | if (phdi->pszText != LPSTR_TEXTCALLBACKA)
|
---|
1273 | {
|
---|
1274 | if (lpItem->pszText)
|
---|
1275 | {
|
---|
1276 | COMCTL32_Free (lpItem->pszText);
|
---|
1277 | lpItem->pszText = NULL;
|
---|
1278 | }
|
---|
1279 | if (phdi->pszText)
|
---|
1280 | {
|
---|
1281 | INT len = lstrlenA (phdi->pszText);
|
---|
1282 |
|
---|
1283 | if (len)
|
---|
1284 | {
|
---|
1285 | lpItem->pszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
|
---|
1286 | lstrcpyAtoW(lpItem->pszText,phdi->pszText);
|
---|
1287 | }
|
---|
1288 | }
|
---|
1289 | } else
|
---|
1290 | {
|
---|
1291 | if (lpItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(lpItem->pszText);
|
---|
1292 | lpItem->pszText = LPSTR_TEXTCALLBACKW;
|
---|
1293 | }
|
---|
1294 | }
|
---|
1295 |
|
---|
1296 | HEADER_SendHeaderNotify(hwnd,HDN_ITEMCHANGEDA,nItem);
|
---|
1297 |
|
---|
1298 | HEADER_SetItemBounds(hwnd,0);
|
---|
1299 | HEADER_Refresh(hwnd);
|
---|
1300 |
|
---|
1301 | return TRUE;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 |
|
---|
1305 | static LRESULT
|
---|
1306 | HEADER_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1307 | {
|
---|
1308 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1309 | HDITEMW *phdi = (HDITEMW*)lParam;
|
---|
1310 | INT nItem = (INT)wParam;
|
---|
1311 | HEADER_ITEM *lpItem;
|
---|
1312 | HDC hdc;
|
---|
1313 |
|
---|
1314 | if (phdi == NULL) return FALSE;
|
---|
1315 | if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) return FALSE;
|
---|
1316 | if (phdi->mask == 0) return TRUE;
|
---|
1317 |
|
---|
1318 | // TRACE (header, "[nItem=%d]\n", nItem);
|
---|
1319 |
|
---|
1320 | if (HEADER_SendHeaderNotify(hwnd,HDN_ITEMCHANGINGW,nItem)) return FALSE;
|
---|
1321 |
|
---|
1322 | lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
|
---|
1323 |
|
---|
1324 | if (phdi->mask & HDI_BITMAP) lpItem->hbm = phdi->hbm;
|
---|
1325 |
|
---|
1326 | if (phdi->mask & HDI_FORMAT) lpItem->fmt = phdi->fmt;
|
---|
1327 |
|
---|
1328 | if (phdi->mask & HDI_FILTER)
|
---|
1329 | {
|
---|
1330 | lpItem->type = lpItem->type;
|
---|
1331 | lpItem->pvFilter = lpItem->pvFilter;
|
---|
1332 | }
|
---|
1333 |
|
---|
1334 | if (phdi->mask & (HDI_WIDTH | HDI_WIDTH)) lpItem->cxy = phdi->cxy;
|
---|
1335 |
|
---|
1336 | if (phdi->mask & HDI_IMAGE) lpItem->iImage = phdi->iImage;
|
---|
1337 |
|
---|
1338 | if (phdi->mask & HDI_LPARAM) lpItem->lParam = phdi->lParam;
|
---|
1339 |
|
---|
1340 | if (phdi->mask & HDI_ORDER) lpItem->iOrder = phdi->iOrder;
|
---|
1341 |
|
---|
1342 | if (phdi->mask & HDI_TEXT)
|
---|
1343 | {
|
---|
1344 | if (phdi->pszText != LPSTR_TEXTCALLBACKW)
|
---|
1345 | {
|
---|
1346 | if (lpItem->pszText)
|
---|
1347 | {
|
---|
1348 | COMCTL32_Free(lpItem->pszText);
|
---|
1349 | lpItem->pszText = NULL;
|
---|
1350 | }
|
---|
1351 | if (phdi->pszText)
|
---|
1352 | {
|
---|
1353 | INT len = lstrlenW(phdi->pszText);
|
---|
1354 |
|
---|
1355 | if (len)
|
---|
1356 | {
|
---|
1357 | lpItem->pszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
|
---|
1358 | lstrcpyW(lpItem->pszText,phdi->pszText);
|
---|
1359 | }
|
---|
1360 | }
|
---|
1361 | } else
|
---|
1362 | {
|
---|
1363 | if (lpItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(lpItem->pszText);
|
---|
1364 | lpItem->pszText = LPSTR_TEXTCALLBACKW;
|
---|
1365 | }
|
---|
1366 | }
|
---|
1367 |
|
---|
1368 | HEADER_SendHeaderNotify(hwnd,HDN_ITEMCHANGEDW,nItem);
|
---|
1369 |
|
---|
1370 | HEADER_SetItemBounds(hwnd,0);
|
---|
1371 | HEADER_Refresh(hwnd);
|
---|
1372 |
|
---|
1373 | return TRUE;
|
---|
1374 | }
|
---|
1375 |
|
---|
1376 | static LRESULT
|
---|
1377 | HEADER_SetUnicodeFormat (HWND hwnd, WPARAM wParam)
|
---|
1378 | {
|
---|
1379 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
|
---|
1380 | BOOL bTemp = infoPtr->bUnicode;
|
---|
1381 |
|
---|
1382 | infoPtr->bUnicode = (BOOL)wParam;
|
---|
1383 |
|
---|
1384 | return bTemp;
|
---|
1385 | }
|
---|
1386 |
|
---|
1387 |
|
---|
1388 | static LRESULT
|
---|
1389 | HEADER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1390 | {
|
---|
1391 | HEADER_INFO *infoPtr;
|
---|
1392 | TEXTMETRICA tm;
|
---|
1393 | HFONT hOldFont;
|
---|
1394 | HDC hdc;
|
---|
1395 |
|
---|
1396 | infoPtr = (HEADER_INFO *)COMCTL32_Alloc (sizeof(HEADER_INFO));
|
---|
1397 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
---|
1398 |
|
---|
1399 | infoPtr->uNumItem = 0;
|
---|
1400 | infoPtr->hFont = 0;
|
---|
1401 | infoPtr->items = 0;
|
---|
1402 | infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
|
---|
1403 | infoPtr->hcurDivider = LoadCursorA (0, IDC_SIZEWEA);
|
---|
1404 | infoPtr->hcurDivopen = LoadCursorA (0, IDC_SIZENSA);
|
---|
1405 | infoPtr->bPressed = FALSE;
|
---|
1406 | infoPtr->bTracking = FALSE;
|
---|
1407 | infoPtr->iMoveItem = 0;
|
---|
1408 | infoPtr->himl = 0;
|
---|
1409 | infoPtr->iHotItem = -1;
|
---|
1410 | infoPtr->xBmpMargin = 3*GetSystemMetrics(SM_CXEDGE);
|
---|
1411 | infoPtr->bUnicode = IsWindowUnicode (hwnd);
|
---|
1412 |
|
---|
1413 | hdc = GetDC (0);
|
---|
1414 | hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT));
|
---|
1415 | GetTextMetricsA (hdc, &tm);
|
---|
1416 | infoPtr->nHeight = tm.tmHeight + VERT_BORDER;
|
---|
1417 | SelectObject (hdc, hOldFont);
|
---|
1418 | ReleaseDC (0, hdc);
|
---|
1419 |
|
---|
1420 | return 0;
|
---|
1421 | }
|
---|
1422 |
|
---|
1423 |
|
---|
1424 | static LRESULT
|
---|
1425 | HEADER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1426 | {
|
---|
1427 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1428 | HEADER_ITEM *lpItem;
|
---|
1429 | INT nItem;
|
---|
1430 |
|
---|
1431 | if (infoPtr->items) {
|
---|
1432 | lpItem = (HEADER_ITEM*)infoPtr->items;
|
---|
1433 | for (nItem = 0; nItem < infoPtr->uNumItem; nItem++, lpItem++) {
|
---|
1434 | if ((lpItem->pszText) && (lpItem->pszText != LPSTR_TEXTCALLBACKW))
|
---|
1435 | COMCTL32_Free (lpItem->pszText);
|
---|
1436 | }
|
---|
1437 | COMCTL32_Free (infoPtr->items);
|
---|
1438 | }
|
---|
1439 |
|
---|
1440 | if (infoPtr->himl)
|
---|
1441 | ImageList_Destroy (infoPtr->himl);
|
---|
1442 |
|
---|
1443 | COMCTL32_Free (infoPtr);
|
---|
1444 |
|
---|
1445 | return 0;
|
---|
1446 | }
|
---|
1447 |
|
---|
1448 | static LRESULT
|
---|
1449 | HEADER_EraseBackground(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1450 | {
|
---|
1451 | return TRUE;
|
---|
1452 | }
|
---|
1453 |
|
---|
1454 | static LRESULT
|
---|
1455 | HEADER_GetDlgCode(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1456 | {
|
---|
1457 | return DLGC_WANTTAB | DLGC_WANTARROWS;
|
---|
1458 | }
|
---|
1459 |
|
---|
1460 | static LRESULT
|
---|
1461 | HEADER_GetFont (HWND hwnd)
|
---|
1462 | {
|
---|
1463 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1464 |
|
---|
1465 | return (LRESULT)infoPtr->hFont;
|
---|
1466 | }
|
---|
1467 |
|
---|
1468 |
|
---|
1469 | static LRESULT
|
---|
1470 | HEADER_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1471 | {
|
---|
1472 | POINT pt;
|
---|
1473 | UINT flags;
|
---|
1474 | INT nItem;
|
---|
1475 |
|
---|
1476 | pt.x = (INT)LOWORD(lParam);
|
---|
1477 | pt.y = (INT)HIWORD(lParam);
|
---|
1478 | HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem);
|
---|
1479 |
|
---|
1480 | if ((GetWindowLongA (hwnd, GWL_STYLE) & HDS_BUTTONS) && (flags == HHT_ONHEADER))
|
---|
1481 | HEADER_SendHeaderNotify (hwnd, HDN_ITEMDBLCLICKA, nItem);
|
---|
1482 | else if ((flags == HHT_ONDIVIDER) || (flags == HHT_ONDIVOPEN))
|
---|
1483 | HEADER_SendHeaderNotify (hwnd, HDN_DIVIDERDBLCLICKA, nItem);
|
---|
1484 |
|
---|
1485 | return 0;
|
---|
1486 | }
|
---|
1487 |
|
---|
1488 |
|
---|
1489 | static LRESULT
|
---|
1490 | HEADER_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1491 | {
|
---|
1492 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1493 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
1494 | POINT pt;
|
---|
1495 | UINT flags;
|
---|
1496 | INT nItem;
|
---|
1497 | HDC hdc;
|
---|
1498 |
|
---|
1499 | pt.x = (INT)LOWORD(lParam);
|
---|
1500 | pt.y = (INT)HIWORD(lParam);
|
---|
1501 | HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem);
|
---|
1502 |
|
---|
1503 | if ((dwStyle & HDS_BUTTONS) && (flags == HHT_ONHEADER))
|
---|
1504 | {
|
---|
1505 | SetCapture (hwnd);
|
---|
1506 | infoPtr->bCaptured = TRUE;
|
---|
1507 | infoPtr->bPressed = TRUE;
|
---|
1508 | infoPtr->iMoveItem = nItem;
|
---|
1509 |
|
---|
1510 | infoPtr->items[nItem].bDown = TRUE;
|
---|
1511 |
|
---|
1512 | /* Send WM_CUSTOMDRAW */
|
---|
1513 | hdc = GetDC (hwnd);
|
---|
1514 | HEADER_RefreshItem (hwnd, hdc, nItem);
|
---|
1515 | ReleaseDC (hwnd, hdc);
|
---|
1516 |
|
---|
1517 | // TRACE (header, "Pressed item %d!\n", nItem);
|
---|
1518 | }
|
---|
1519 | else if ((flags == HHT_ONDIVIDER) || (flags == HHT_ONDIVOPEN))
|
---|
1520 | {
|
---|
1521 | if (!(HEADER_SendHeaderNotify (hwnd, HDN_BEGINTRACKA, nItem)))
|
---|
1522 | {
|
---|
1523 | SetCapture (hwnd);
|
---|
1524 | infoPtr->bCaptured = TRUE;
|
---|
1525 | infoPtr->bTracking = TRUE;
|
---|
1526 | infoPtr->iMoveItem = nItem;
|
---|
1527 | infoPtr->nOldWidth = infoPtr->items[nItem].cxy;
|
---|
1528 | infoPtr->xTrackOffset = infoPtr->items[nItem].rect.right - pt.x;
|
---|
1529 |
|
---|
1530 | if (!(dwStyle & HDS_FULLDRAG))
|
---|
1531 | {
|
---|
1532 | infoPtr->xOldTrack = infoPtr->items[nItem].rect.right;
|
---|
1533 | hdc = GetDC (hwnd);
|
---|
1534 | HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
|
---|
1535 | ReleaseDC (hwnd, hdc);
|
---|
1536 | }
|
---|
1537 |
|
---|
1538 | // TRACE (header, "Begin tracking item %d!\n", nItem);
|
---|
1539 | }
|
---|
1540 | }
|
---|
1541 |
|
---|
1542 | return 0;
|
---|
1543 | }
|
---|
1544 |
|
---|
1545 |
|
---|
1546 | static LRESULT
|
---|
1547 | HEADER_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1548 | {
|
---|
1549 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1550 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
1551 | POINT pt;
|
---|
1552 | UINT flags;
|
---|
1553 | INT nItem, nWidth;
|
---|
1554 | HDC hdc;
|
---|
1555 |
|
---|
1556 | pt.x = (INT)LOWORD(lParam);
|
---|
1557 | pt.y = (INT)HIWORD(lParam);
|
---|
1558 | HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem);
|
---|
1559 |
|
---|
1560 | if (infoPtr->bPressed)
|
---|
1561 | {
|
---|
1562 | if ((nItem == infoPtr->iMoveItem) && (flags == HHT_ONHEADER))
|
---|
1563 | {
|
---|
1564 | infoPtr->items[infoPtr->iMoveItem].bDown = FALSE;
|
---|
1565 | hdc = GetDC (hwnd);
|
---|
1566 | HEADER_RefreshItem (hwnd, hdc, infoPtr->iMoveItem);
|
---|
1567 | ReleaseDC (hwnd, hdc);
|
---|
1568 |
|
---|
1569 | HEADER_SendClickNotify (hwnd, HDN_ITEMCLICKA, infoPtr->iMoveItem);
|
---|
1570 | }
|
---|
1571 | // TRACE (header, "Released item %d!\n", infoPtr->iMoveItem);
|
---|
1572 | infoPtr->bPressed = FALSE;
|
---|
1573 | }
|
---|
1574 | else if (infoPtr->bTracking)
|
---|
1575 | {
|
---|
1576 | // TRACE (header, "End tracking item %d!\n", infoPtr->iMoveItem);
|
---|
1577 | infoPtr->bTracking = FALSE;
|
---|
1578 |
|
---|
1579 | HEADER_SendHeaderNotify (hwnd, HDN_ENDTRACKA, infoPtr->iMoveItem);
|
---|
1580 |
|
---|
1581 | if (!(dwStyle & HDS_FULLDRAG))
|
---|
1582 | {
|
---|
1583 | hdc = GetDC (hwnd);
|
---|
1584 | HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
|
---|
1585 | ReleaseDC (hwnd, hdc);
|
---|
1586 | if (HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGINGA, infoPtr->iMoveItem))
|
---|
1587 | infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth;
|
---|
1588 | else
|
---|
1589 | {
|
---|
1590 | nWidth = pt.x - infoPtr->items[infoPtr->iMoveItem].rect.left + infoPtr->xTrackOffset;
|
---|
1591 | if (nWidth < MIN_ITEMWIDTH) nWidth = MIN_ITEMWIDTH;
|
---|
1592 |
|
---|
1593 | if (infoPtr->nOldWidth != nWidth)
|
---|
1594 | {
|
---|
1595 | infoPtr->items[infoPtr->iMoveItem].cxy = nWidth;
|
---|
1596 | HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGEDA, infoPtr->iMoveItem);
|
---|
1597 |
|
---|
1598 | HEADER_SetItemBounds (hwnd,infoPtr->iMoveItem);
|
---|
1599 |
|
---|
1600 | HEADER_Refresh(hwnd);
|
---|
1601 | }
|
---|
1602 | }
|
---|
1603 | }
|
---|
1604 | }
|
---|
1605 |
|
---|
1606 | if (infoPtr->bCaptured) {
|
---|
1607 | infoPtr->bCaptured = FALSE;
|
---|
1608 | ReleaseCapture ();
|
---|
1609 | HEADER_SendSimpleNotify (hwnd, NM_RELEASEDCAPTURE);
|
---|
1610 | }
|
---|
1611 |
|
---|
1612 | return 0;
|
---|
1613 | }
|
---|
1614 |
|
---|
1615 |
|
---|
1616 | static LRESULT
|
---|
1617 | HEADER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1618 | {
|
---|
1619 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1620 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
1621 | POINT pt;
|
---|
1622 | UINT flags;
|
---|
1623 | INT nItem, nWidth;
|
---|
1624 | HDC hdc;
|
---|
1625 |
|
---|
1626 | pt.x = (INT)LOWORD(lParam);
|
---|
1627 | pt.y = (INT)HIWORD(lParam);
|
---|
1628 | HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem);
|
---|
1629 |
|
---|
1630 | if ((dwStyle & HDS_BUTTONS) && (dwStyle & HDS_HOTTRACK))
|
---|
1631 | {
|
---|
1632 | INT newItem;
|
---|
1633 |
|
---|
1634 | if (flags & (HHT_ONHEADER | HHT_ONDIVIDER | HHT_ONDIVOPEN))
|
---|
1635 | newItem = nItem;
|
---|
1636 | else
|
---|
1637 | newItem = -1;
|
---|
1638 | if (newItem != infoPtr->iHotItem)
|
---|
1639 | {
|
---|
1640 | INT oldItem = infoPtr->iHotItem;
|
---|
1641 |
|
---|
1642 | infoPtr->iHotItem = newItem;
|
---|
1643 | HEADER_Refresh(hwnd);
|
---|
1644 | }
|
---|
1645 | }
|
---|
1646 |
|
---|
1647 | if (infoPtr->bCaptured)
|
---|
1648 | {
|
---|
1649 | if (infoPtr->bPressed)
|
---|
1650 | {
|
---|
1651 | BOOL newDown;
|
---|
1652 |
|
---|
1653 | if ((nItem == infoPtr->iMoveItem) && (flags == HHT_ONHEADER))
|
---|
1654 | newDown = TRUE;
|
---|
1655 | else
|
---|
1656 | newDown = FALSE;
|
---|
1657 |
|
---|
1658 | if (newDown != infoPtr->items[infoPtr->iMoveItem].bDown)
|
---|
1659 | {
|
---|
1660 | infoPtr->items[infoPtr->iMoveItem].bDown = newDown;
|
---|
1661 | hdc = GetDC (hwnd);
|
---|
1662 | HEADER_RefreshItem (hwnd, hdc, infoPtr->iMoveItem);
|
---|
1663 | ReleaseDC (hwnd, hdc);
|
---|
1664 | }
|
---|
1665 | // TRACE (header, "Moving pressed item %d!\n", infoPtr->iMoveItem);
|
---|
1666 | } else if (infoPtr->bTracking)
|
---|
1667 | {
|
---|
1668 | if (dwStyle & HDS_FULLDRAG)
|
---|
1669 | {
|
---|
1670 | if (HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGINGA, infoPtr->iMoveItem))
|
---|
1671 | infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth;
|
---|
1672 | else {
|
---|
1673 | nWidth = pt.x - infoPtr->items[infoPtr->iMoveItem].rect.left + infoPtr->xTrackOffset;
|
---|
1674 | if (nWidth < MIN_ITEMWIDTH)
|
---|
1675 | nWidth = MIN_ITEMWIDTH;
|
---|
1676 | infoPtr->items[infoPtr->iMoveItem].cxy = nWidth;
|
---|
1677 | HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGEDA,
|
---|
1678 | infoPtr->iMoveItem);
|
---|
1679 | }
|
---|
1680 | HEADER_SetItemBounds (hwnd,infoPtr->iMoveItem);
|
---|
1681 | HEADER_Refresh(hwnd);
|
---|
1682 | }
|
---|
1683 | else {
|
---|
1684 | hdc = GetDC (hwnd);
|
---|
1685 | HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
|
---|
1686 | infoPtr->xOldTrack = pt.x + infoPtr->xTrackOffset;
|
---|
1687 | if (infoPtr->xOldTrack < infoPtr->items[infoPtr->iMoveItem].rect.left)
|
---|
1688 | infoPtr->xOldTrack = infoPtr->items[infoPtr->iMoveItem].rect.left;
|
---|
1689 | infoPtr->items[infoPtr->iMoveItem].cxy =
|
---|
1690 | infoPtr->xOldTrack - infoPtr->items[infoPtr->iMoveItem].rect.left;
|
---|
1691 | HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
|
---|
1692 | ReleaseDC (hwnd, hdc);
|
---|
1693 | }
|
---|
1694 |
|
---|
1695 | HEADER_SendHeaderNotify (hwnd, HDN_TRACKA, infoPtr->iMoveItem);
|
---|
1696 | // TRACE (header, "Tracking item %d!\n", infoPtr->iMoveItem);
|
---|
1697 | }
|
---|
1698 | }
|
---|
1699 |
|
---|
1700 | return 0;
|
---|
1701 | }
|
---|
1702 |
|
---|
1703 |
|
---|
1704 | static LRESULT
|
---|
1705 | HEADER_Paint (HWND hwnd, WPARAM wParam)
|
---|
1706 | {
|
---|
1707 | HDC hdc;
|
---|
1708 | PAINTSTRUCT ps;
|
---|
1709 |
|
---|
1710 | hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
|
---|
1711 | HEADER_Draw (hwnd, hdc);
|
---|
1712 | if(!wParam)
|
---|
1713 | EndPaint (hwnd, &ps);
|
---|
1714 |
|
---|
1715 | return 0;
|
---|
1716 | }
|
---|
1717 |
|
---|
1718 |
|
---|
1719 | static LRESULT
|
---|
1720 | HEADER_RButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1721 | {
|
---|
1722 | return HEADER_SendSimpleNotify (hwnd, NM_RCLICK);
|
---|
1723 | }
|
---|
1724 |
|
---|
1725 |
|
---|
1726 | static LRESULT
|
---|
1727 | HEADER_SetCursor (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1728 | {
|
---|
1729 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1730 | POINT pt;
|
---|
1731 | UINT flags;
|
---|
1732 | INT nItem;
|
---|
1733 |
|
---|
1734 | // TRACE (header, "code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
|
---|
1735 |
|
---|
1736 | GetCursorPos (&pt);
|
---|
1737 | ScreenToClient (hwnd, &pt);
|
---|
1738 |
|
---|
1739 | HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem);
|
---|
1740 |
|
---|
1741 | if (flags == HHT_ONDIVIDER)
|
---|
1742 | SetCursor (infoPtr->hcurDivider);
|
---|
1743 | else if (flags == HHT_ONDIVOPEN)
|
---|
1744 | SetCursor (infoPtr->hcurDivopen);
|
---|
1745 | else
|
---|
1746 | SetCursor (infoPtr->hcurArrow);
|
---|
1747 |
|
---|
1748 | return 0;
|
---|
1749 | }
|
---|
1750 |
|
---|
1751 |
|
---|
1752 | static LRESULT
|
---|
1753 | HEADER_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1754 | {
|
---|
1755 | HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
|
---|
1756 | TEXTMETRICA tm;
|
---|
1757 | HFONT hFont, hOldFont;
|
---|
1758 | HDC hdc;
|
---|
1759 |
|
---|
1760 | infoPtr->hFont = (HFONT)wParam;
|
---|
1761 |
|
---|
1762 | hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
|
---|
1763 |
|
---|
1764 | hdc = GetDC (0);
|
---|
1765 | hOldFont = SelectObject (hdc, hFont);
|
---|
1766 | GetTextMetricsA (hdc, &tm);
|
---|
1767 | infoPtr->nHeight = tm.tmHeight + VERT_BORDER;
|
---|
1768 | SelectObject (hdc, hOldFont);
|
---|
1769 | ReleaseDC (0, hdc);
|
---|
1770 |
|
---|
1771 | if (lParam) {
|
---|
1772 | HEADER_ForceItemBounds (hwnd, infoPtr->nHeight);
|
---|
1773 | HEADER_Refresh(hwnd);
|
---|
1774 | }
|
---|
1775 |
|
---|
1776 | return 0;
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 |
|
---|
1780 | static LRESULT WINAPI
|
---|
1781 | HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
1782 | {
|
---|
1783 | switch (msg)
|
---|
1784 | {
|
---|
1785 | case HDM_CLEARFILTER:
|
---|
1786 | return HEADER_ClearFilter(hwnd,wParam,lParam);
|
---|
1787 |
|
---|
1788 | case HDM_CREATEDRAGIMAGE:
|
---|
1789 | return HEADER_CreateDragImage (hwnd, wParam);
|
---|
1790 |
|
---|
1791 | case HDM_DELETEITEM:
|
---|
1792 | return HEADER_DeleteItem (hwnd, wParam);
|
---|
1793 |
|
---|
1794 | case HDM_EDITFILTER:
|
---|
1795 | return HEADER_EditFilter(hwnd,wParam,lParam);
|
---|
1796 |
|
---|
1797 | case HDM_GETBITMAPMARGIN:
|
---|
1798 | return HEADER_GetBitmapMargin(hwnd,wParam,lParam);
|
---|
1799 |
|
---|
1800 | case HDM_GETIMAGELIST:
|
---|
1801 | return HEADER_GetImageList (hwnd);
|
---|
1802 |
|
---|
1803 | case HDM_GETITEMA:
|
---|
1804 | return HEADER_GetItemA (hwnd, wParam, lParam);
|
---|
1805 |
|
---|
1806 | case HDM_GETITEMW:
|
---|
1807 | return HEADER_GetItemW (hwnd, wParam, lParam);
|
---|
1808 |
|
---|
1809 | case HDM_GETITEMCOUNT:
|
---|
1810 | return HEADER_GetItemCount (hwnd);
|
---|
1811 |
|
---|
1812 | case HDM_GETITEMRECT:
|
---|
1813 | return HEADER_GetItemRect (hwnd, wParam, lParam);
|
---|
1814 |
|
---|
1815 | case HDM_GETORDERARRAY:
|
---|
1816 | return HEADER_GetOrderArray(hwnd,wParam,lParam);
|
---|
1817 |
|
---|
1818 | case HDM_GETUNICODEFORMAT:
|
---|
1819 | return HEADER_GetUnicodeFormat (hwnd);
|
---|
1820 |
|
---|
1821 | case HDM_HITTEST:
|
---|
1822 | return HEADER_HitTest (hwnd, wParam, lParam);
|
---|
1823 |
|
---|
1824 | case HDM_INSERTITEMA:
|
---|
1825 | return HEADER_InsertItemA (hwnd, wParam, lParam);
|
---|
1826 |
|
---|
1827 | case HDM_INSERTITEMW:
|
---|
1828 | return HEADER_InsertItemW (hwnd, wParam, lParam);
|
---|
1829 |
|
---|
1830 | case HDM_LAYOUT:
|
---|
1831 | return HEADER_Layout (hwnd, wParam, lParam);
|
---|
1832 |
|
---|
1833 | case HDM_ORDERTOINDEX:
|
---|
1834 | return HEADER_OrderToIndex(hwnd,wParam,lParam);
|
---|
1835 |
|
---|
1836 | case HDM_SETBITMAPMARGIN:
|
---|
1837 | return HEADER_SetBitmapMargin(hwnd,wParam,lParam);
|
---|
1838 |
|
---|
1839 | case HDM_SETFILTERCHANGETIMEOUT:
|
---|
1840 | return HEADER_SetFilterChangeTimeout(hwnd,wParam,lParam);
|
---|
1841 |
|
---|
1842 | case HDM_SETHOTDIVIDER:
|
---|
1843 | return HEADER_SetHotDivider(hwnd,wParam,lParam);
|
---|
1844 |
|
---|
1845 | case HDM_SETIMAGELIST:
|
---|
1846 | return HEADER_SetImageList (hwnd, wParam, lParam);
|
---|
1847 |
|
---|
1848 | case HDM_SETITEMA:
|
---|
1849 | return HEADER_SetItemA (hwnd, wParam, lParam);
|
---|
1850 |
|
---|
1851 | case HDM_SETITEMW:
|
---|
1852 | return HEADER_SetItemW (hwnd, wParam, lParam);
|
---|
1853 |
|
---|
1854 | case HDM_SETORDERARRAY:
|
---|
1855 | return HEADER_SetOrderArray(hwnd,wParam,lParam);
|
---|
1856 |
|
---|
1857 | case HDM_SETUNICODEFORMAT:
|
---|
1858 | return HEADER_SetUnicodeFormat (hwnd, wParam);
|
---|
1859 |
|
---|
1860 | case WM_CREATE:
|
---|
1861 | return HEADER_Create (hwnd, wParam, lParam);
|
---|
1862 |
|
---|
1863 | case WM_DESTROY:
|
---|
1864 | return HEADER_Destroy (hwnd, wParam, lParam);
|
---|
1865 |
|
---|
1866 | case WM_ERASEBKGND:
|
---|
1867 | return HEADER_EraseBackground(hwnd,wParam,lParam);
|
---|
1868 |
|
---|
1869 | case WM_GETDLGCODE:
|
---|
1870 | return HEADER_GetDlgCode(hwnd,wParam,lParam);
|
---|
1871 |
|
---|
1872 | case WM_GETFONT:
|
---|
1873 | return HEADER_GetFont (hwnd);
|
---|
1874 |
|
---|
1875 | case WM_LBUTTONDBLCLK:
|
---|
1876 | return HEADER_LButtonDblClk (hwnd, wParam, lParam);
|
---|
1877 |
|
---|
1878 | case WM_LBUTTONDOWN:
|
---|
1879 | return HEADER_LButtonDown (hwnd, wParam, lParam);
|
---|
1880 |
|
---|
1881 | case WM_LBUTTONUP:
|
---|
1882 | return HEADER_LButtonUp (hwnd, wParam, lParam);
|
---|
1883 |
|
---|
1884 | case WM_MOUSEMOVE:
|
---|
1885 | return HEADER_MouseMove (hwnd, wParam, lParam);
|
---|
1886 |
|
---|
1887 | /* case WM_NOTIFYFORMAT: */
|
---|
1888 |
|
---|
1889 | case WM_PAINT:
|
---|
1890 | return HEADER_Paint(hwnd,wParam);
|
---|
1891 |
|
---|
1892 | case WM_RBUTTONUP:
|
---|
1893 | return HEADER_RButtonUp (hwnd, wParam, lParam);
|
---|
1894 |
|
---|
1895 | case WM_SETCURSOR:
|
---|
1896 | return HEADER_SetCursor (hwnd, wParam, lParam);
|
---|
1897 |
|
---|
1898 | case WM_SETFONT:
|
---|
1899 | return HEADER_SetFont (hwnd, wParam, lParam);
|
---|
1900 |
|
---|
1901 | default:
|
---|
1902 | // if (msg >= WM_USER)
|
---|
1903 | // ERR (header, "unknown msg %04x wp=%04x lp=%08lx\n",
|
---|
1904 | // msg, wParam, lParam );
|
---|
1905 | return DefWindowProcA (hwnd, msg, wParam, lParam);
|
---|
1906 | }
|
---|
1907 | return 0;
|
---|
1908 | }
|
---|
1909 |
|
---|
1910 |
|
---|
1911 | VOID
|
---|
1912 | HEADER_Register (VOID)
|
---|
1913 | {
|
---|
1914 | WNDCLASSA wndClass;
|
---|
1915 |
|
---|
1916 | if (GlobalFindAtomA (WC_HEADERA)) return;
|
---|
1917 |
|
---|
1918 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
---|
1919 | wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
|
---|
1920 | wndClass.lpfnWndProc = (WNDPROC)HEADER_WindowProc;
|
---|
1921 | wndClass.cbClsExtra = 0;
|
---|
1922 | wndClass.cbWndExtra = sizeof(HEADER_INFO *);
|
---|
1923 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
---|
1924 | wndClass.lpszClassName = WC_HEADERA;
|
---|
1925 |
|
---|
1926 | RegisterClassA (&wndClass);
|
---|
1927 | }
|
---|
1928 |
|
---|
1929 |
|
---|
1930 | VOID
|
---|
1931 | HEADER_Unregister (VOID)
|
---|
1932 | {
|
---|
1933 | if (GlobalFindAtomA (WC_HEADERA))
|
---|
1934 | UnregisterClassA (WC_HEADERA, (HINSTANCE)NULL);
|
---|
1935 | }
|
---|
1936 |
|
---|