1 | /*
|
---|
2 | * Toolbar control
|
---|
3 | *
|
---|
4 | * Copyright 1998,1999 Eric Kohl
|
---|
5 | * Copyright 2000 Eric Kohl for CodeWeavers
|
---|
6 | *
|
---|
7 | * Differences between MSDN and actual native control operation:
|
---|
8 | * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
|
---|
9 | * to the right of the bitmap. Otherwise, this style is
|
---|
10 | * identical to TBSTYLE_FLAT."
|
---|
11 | * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL
|
---|
12 | * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result
|
---|
13 | * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does
|
---|
14 | * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001)
|
---|
15 | *
|
---|
16 | *
|
---|
17 | * TODO:
|
---|
18 | * - A little bug in TOOLBAR_DrawMasked()
|
---|
19 | * - Button wrapping (under construction).
|
---|
20 | * - Messages.
|
---|
21 | * - Notifications (under construction).
|
---|
22 | * - Fix TB_SETROWS.
|
---|
23 | * - Tooltip support (almost complete).
|
---|
24 | * - Unicode suppport (under construction).
|
---|
25 | * - Fix TOOLBAR_SetButtonInfo32A/W.
|
---|
26 | * - TBSTYLE_AUTOSIZE for toolbar and buttons.
|
---|
27 | * - I_IMAGECALLBACK support.
|
---|
28 | * - iString of -1 is undocumented
|
---|
29 | * - Customization dialog:
|
---|
30 | * - Add flat look.
|
---|
31 | * - Minor buglet in 'available buttons' list:
|
---|
32 | * Buttons are not listed in M$-like order. M$ seems to use a single
|
---|
33 | * internal list to store the button information of both listboxes.
|
---|
34 | * - Drag list support.
|
---|
35 | * - Help and Reset button support.
|
---|
36 | *
|
---|
37 | * Testing:
|
---|
38 | * - Run tests using Waite Group Windows95 API Bible Volume 2.
|
---|
39 | * The second cdrom contains executables addstr.exe, btncount.exe,
|
---|
40 | * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
|
---|
41 | * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
|
---|
42 | * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
|
---|
43 | * setparnt.exe, setrows.exe, toolwnd.exe.
|
---|
44 | * - Microsofts controlspy examples.
|
---|
45 | * - Charles Petzold's 'Programming Windows': gadgets.exe
|
---|
46 | */
|
---|
47 |
|
---|
48 | #include <string.h>
|
---|
49 |
|
---|
50 | #include "winbase.h"
|
---|
51 | #include "windef.h"
|
---|
52 | #include "wingdi.h"
|
---|
53 | #include "winuser.h"
|
---|
54 | #include "wine/unicode.h"
|
---|
55 | #include "commctrl.h"
|
---|
56 | #include "imagelist.h"
|
---|
57 | #include "comctl32.h"
|
---|
58 | #include "debugtools.h"
|
---|
59 |
|
---|
60 | DEFAULT_DEBUG_CHANNEL(toolbar);
|
---|
61 |
|
---|
62 | #ifdef __WIN32OS2__
|
---|
63 | #undef inline
|
---|
64 | #define inline
|
---|
65 | #define COMCTL32_hPattern55AABrush GetPattern55AABrush()
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | typedef struct
|
---|
69 | {
|
---|
70 | INT iBitmap;
|
---|
71 | INT idCommand;
|
---|
72 | BYTE fsState;
|
---|
73 | BYTE fsStyle;
|
---|
74 | DWORD dwData;
|
---|
75 | INT iString;
|
---|
76 |
|
---|
77 | BOOL bHot;
|
---|
78 | INT nRow;
|
---|
79 | RECT rect;
|
---|
80 | } TBUTTON_INFO;
|
---|
81 |
|
---|
82 | typedef struct
|
---|
83 | {
|
---|
84 | DWORD dwStructSize; /* size of TBBUTTON struct */
|
---|
85 | INT nHeight; /* height of the toolbar */
|
---|
86 | INT nWidth; /* width of the toolbar */
|
---|
87 | INT nButtonHeight;
|
---|
88 | INT nButtonWidth;
|
---|
89 | INT nBitmapHeight;
|
---|
90 | INT nBitmapWidth;
|
---|
91 | INT nIndent;
|
---|
92 | INT nRows; /* number of button rows */
|
---|
93 | INT nMaxTextRows; /* maximum number of text rows */
|
---|
94 | INT cxMin; /* minimum button width */
|
---|
95 | INT cxMax; /* maximum button width */
|
---|
96 | INT nNumButtons; /* number of buttons */
|
---|
97 | INT nNumBitmaps; /* number of bitmaps */
|
---|
98 | INT nNumStrings; /* number of strings */
|
---|
99 | BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */
|
---|
100 | BOOL bCaptured; /* mouse captured? */
|
---|
101 | INT nButtonDown;
|
---|
102 | INT nOldHit;
|
---|
103 | INT nHotItem; /* index of the "hot" item */
|
---|
104 | HFONT hFont; /* text font */
|
---|
105 | HIMAGELIST himlInt; /* image list created internally */
|
---|
106 | HIMAGELIST himlDef; /* default image list */
|
---|
107 | HIMAGELIST himlHot; /* hot image list */
|
---|
108 | HIMAGELIST himlDis; /* disabled image list */
|
---|
109 | HWND hwndToolTip; /* handle to tool tip control */
|
---|
110 | HWND hwndNotify; /* handle to the window that gets notifications */
|
---|
111 | HWND hwndSelf; /* my own handle */
|
---|
112 | BOOL bTransparent; /* background transparency flag */
|
---|
113 | BOOL bBtnTranspnt; /* button transparency flag */
|
---|
114 | BOOL bAutoSize; /* auto size deadlock indicator */
|
---|
115 | BOOL bAnchor; /* anchor highlight enabled */
|
---|
116 | BOOL bNtfUnicode; /* TRUE if NOTIFYs use {W} */
|
---|
117 | DWORD dwExStyle; /* extended toolbar style */
|
---|
118 | DWORD dwDTFlags; /* DrawText flags */
|
---|
119 |
|
---|
120 | COLORREF clrInsertMark; /* insert mark color */
|
---|
121 | RECT rcBound; /* bounding rectangle */
|
---|
122 | INT iVersion;
|
---|
123 |
|
---|
124 | TBUTTON_INFO *buttons; /* pointer to button array */
|
---|
125 | LPWSTR *strings; /* pointer to string array */
|
---|
126 | } TOOLBAR_INFO, *PTOOLBAR_INFO;
|
---|
127 |
|
---|
128 |
|
---|
129 | /* used by customization dialog */
|
---|
130 | typedef struct
|
---|
131 | {
|
---|
132 | PTOOLBAR_INFO tbInfo;
|
---|
133 | HWND tbHwnd;
|
---|
134 | } CUSTDLG_INFO, *PCUSTDLG_INFO;
|
---|
135 |
|
---|
136 | typedef struct
|
---|
137 | {
|
---|
138 | TBBUTTON btn;
|
---|
139 | BOOL bVirtual;
|
---|
140 | BOOL bRemovable;
|
---|
141 | CHAR text[64];
|
---|
142 | } CUSTOMBUTTON, *PCUSTOMBUTTON;
|
---|
143 |
|
---|
144 |
|
---|
145 | #define SEPARATOR_WIDTH 8
|
---|
146 | #define TOP_BORDER 2
|
---|
147 | #define BOTTOM_BORDER 2
|
---|
148 | #define DDARROW_WIDTH 11
|
---|
149 |
|
---|
150 | #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
|
---|
151 | #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
|
---|
152 | #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
|
---|
153 |
|
---|
154 |
|
---|
155 | static void
|
---|
156 | TOOLBAR_DumpButton(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *bP, INT btn_num, BOOL internal)
|
---|
157 | {
|
---|
158 | if (TRACE_ON(toolbar)){
|
---|
159 | TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, string=%d\n",
|
---|
160 | btn_num, bP->idCommand,
|
---|
161 | bP->iBitmap, bP->fsState, bP->fsStyle, bP->dwData, bP->iString);
|
---|
162 | if (internal)
|
---|
163 | TRACE("button %d id %d, hot=%s, row=%d, rect=(%d,%d)-(%d,%d)\n",
|
---|
164 | btn_num, bP->idCommand,
|
---|
165 | (bP->bHot) ? "TRUE":"FALSE", bP->nRow,
|
---|
166 | bP->rect.left, bP->rect.top,
|
---|
167 | bP->rect.right, bP->rect.bottom);
|
---|
168 | }
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 | static void
|
---|
173 | TOOLBAR_DumpToolbar(TOOLBAR_INFO *iP, INT line)
|
---|
174 | {
|
---|
175 | if (TRACE_ON(toolbar)) {
|
---|
176 | INT i;
|
---|
177 | DWORD dwStyle;
|
---|
178 |
|
---|
179 | dwStyle = GetWindowLongA (iP->hwndSelf, GWL_STYLE);
|
---|
180 | TRACE("toolbar %08x at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
|
---|
181 | iP->hwndSelf, line,
|
---|
182 | iP->dwExStyle, iP->nNumButtons, iP->nNumBitmaps,
|
---|
183 | iP->nNumStrings, dwStyle);
|
---|
184 | TRACE("toolbar %08x at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p\n",
|
---|
185 | iP->hwndSelf, line,
|
---|
186 | iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis);
|
---|
187 | for(i=0; i<iP->nNumButtons; i++) {
|
---|
188 | TOOLBAR_DumpButton(iP, &iP->buttons[i], i, TRUE);
|
---|
189 | }
|
---|
190 | }
|
---|
191 | }
|
---|
192 |
|
---|
193 |
|
---|
194 | /***********************************************************************
|
---|
195 | * TOOLBAR_CheckStyle
|
---|
196 | *
|
---|
197 | * This function validates that the styles set are implemented and
|
---|
198 | * issues FIXME's warning of possible problems. In a perfect world this
|
---|
199 | * function should be null.
|
---|
200 | */
|
---|
201 | static void
|
---|
202 | TOOLBAR_CheckStyle (HWND hwnd, DWORD dwStyle)
|
---|
203 | {
|
---|
204 | if (dwStyle & TBSTYLE_ALTDRAG)
|
---|
205 | FIXME("[%04x] TBSTYLE_ALTDRAG not implemented\n", hwnd);
|
---|
206 | if (dwStyle & TBSTYLE_REGISTERDROP)
|
---|
207 | FIXME("[%04x] TBSTYLE_REGISTERDROP not implemented\n", hwnd);
|
---|
208 | }
|
---|
209 |
|
---|
210 |
|
---|
211 | static INT
|
---|
212 | TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code)
|
---|
213 | {
|
---|
214 | nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
|
---|
215 | nmhdr->hwndFrom = infoPtr->hwndSelf;
|
---|
216 | nmhdr->code = code;
|
---|
217 |
|
---|
218 | TRACE("to window %04x, code=%08x, %s\n", infoPtr->hwndNotify, code,
|
---|
219 | (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI");
|
---|
220 |
|
---|
221 | if (infoPtr->bNtfUnicode)
|
---|
222 | return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
|
---|
223 | (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
|
---|
224 | else
|
---|
225 | return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
|
---|
226 | (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
|
---|
227 | }
|
---|
228 |
|
---|
229 | static LPWSTR
|
---|
230 | TOOLBAR_GetText(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
|
---|
231 | {
|
---|
232 | LPWSTR lpText = NULL;
|
---|
233 |
|
---|
234 | /* FIXME: iString == -1 is undocumented */
|
---|
235 | if ((HIWORD(btnPtr->iString) != 0) && (btnPtr->iString != -1))
|
---|
236 | lpText = (LPWSTR)btnPtr->iString;
|
---|
237 | else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
|
---|
238 | lpText = infoPtr->strings[btnPtr->iString];
|
---|
239 |
|
---|
240 | return lpText;
|
---|
241 | }
|
---|
242 |
|
---|
243 | /***********************************************************************
|
---|
244 | * TOOLBAR_GetBitmapIndex
|
---|
245 | *
|
---|
246 | * This function returns the bitmap index associated with a button.
|
---|
247 | * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
|
---|
248 | * is issued to retrieve the index.
|
---|
249 | */
|
---|
250 | static INT
|
---|
251 | TOOLBAR_GetBitmapIndex(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
|
---|
252 | {
|
---|
253 | INT ret = btnPtr->iBitmap;
|
---|
254 |
|
---|
255 | if (ret == I_IMAGECALLBACK) {
|
---|
256 | /* issue TBN_GETDISPINFO */
|
---|
257 | NMTBDISPINFOA nmgd;
|
---|
258 |
|
---|
259 | nmgd.idCommand = btnPtr->idCommand;
|
---|
260 | nmgd.lParam = btnPtr->dwData;
|
---|
261 | nmgd.dwMask = TBNF_IMAGE;
|
---|
262 | TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr,
|
---|
263 | (infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW :
|
---|
264 | TBN_GETDISPINFOA);
|
---|
265 | if (nmgd.dwMask & TBNF_DI_SETITEM) {
|
---|
266 | btnPtr->iBitmap = nmgd.iImage;
|
---|
267 | }
|
---|
268 | ret = nmgd.iImage;
|
---|
269 | TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
|
---|
270 | ret, nmgd.dwMask, infoPtr->nNumBitmaps);
|
---|
271 | }
|
---|
272 | return ret;
|
---|
273 | }
|
---|
274 |
|
---|
275 |
|
---|
276 | static BOOL
|
---|
277 | TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index)
|
---|
278 | {
|
---|
279 | if (((index>=0) && (index <= infoPtr->nNumBitmaps)) ||
|
---|
280 | (index == I_IMAGECALLBACK))
|
---|
281 | return TRUE;
|
---|
282 | else
|
---|
283 | return FALSE;
|
---|
284 | }
|
---|
285 |
|
---|
286 |
|
---|
287 | /***********************************************************************
|
---|
288 | * TOOLBAR_DrawImageList
|
---|
289 | *
|
---|
290 | * This function validates the bitmap index (including I_IMAGECALLBACK
|
---|
291 | * functionality). It then draws the image via the ImageList_Draw
|
---|
292 | * function. It returns TRUE if the image was drawn, FALSE otherwise.
|
---|
293 | */
|
---|
294 | static BOOL
|
---|
295 | TOOLBAR_DrawImageList (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl,
|
---|
296 | HDC hdc, UINT left, UINT top, UINT draw_flags)
|
---|
297 | {
|
---|
298 | INT index;
|
---|
299 |
|
---|
300 | if (!himl) return FALSE;
|
---|
301 |
|
---|
302 | if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
|
---|
303 | ERR("index %d is not valid, max %d\n",
|
---|
304 | btnPtr->iBitmap, infoPtr->nNumBitmaps);
|
---|
305 | return FALSE;
|
---|
306 | }
|
---|
307 |
|
---|
308 | if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
|
---|
309 | if (index == -1) return FALSE;
|
---|
310 | ERR("TBN_GETDISPINFO returned invalid index %d\n",
|
---|
311 | index);
|
---|
312 | return FALSE;
|
---|
313 | }
|
---|
314 | TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n",
|
---|
315 | index, himl, left, top, draw_flags);
|
---|
316 |
|
---|
317 | ImageList_Draw (himl, index, hdc, left, top, draw_flags);
|
---|
318 | return TRUE;
|
---|
319 | }
|
---|
320 |
|
---|
321 |
|
---|
322 | /***********************************************************************
|
---|
323 | * TOOLBAR_TestImageExist
|
---|
324 | *
|
---|
325 | * This function is similar to TOOLBAR_DrawImageList, except it does not
|
---|
326 | * draw the image. The I_IMAGECALLBACK functionality is implemented.
|
---|
327 | */
|
---|
328 | static BOOL
|
---|
329 | TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
|
---|
330 | {
|
---|
331 | INT index;
|
---|
332 |
|
---|
333 | if (!himl) return FALSE;
|
---|
334 |
|
---|
335 | if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
|
---|
336 | ERR("index %d is not valid, max %d\n",
|
---|
337 | btnPtr->iBitmap, infoPtr->nNumBitmaps);
|
---|
338 | return FALSE;
|
---|
339 | }
|
---|
340 |
|
---|
341 | if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
|
---|
342 | if (index == -1) return FALSE;
|
---|
343 | ERR("TBN_GETDISPINFO returned invalid index %d\n",
|
---|
344 | index);
|
---|
345 | return FALSE;
|
---|
346 | }
|
---|
347 | return TRUE;
|
---|
348 | }
|
---|
349 |
|
---|
350 |
|
---|
351 | static void
|
---|
352 | TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
|
---|
353 | {
|
---|
354 | INT x = (lpRect->left + lpRect->right) / 2 - 1;
|
---|
355 | INT yBottom = lpRect->bottom - 3;
|
---|
356 | INT yTop = lpRect->top + 1;
|
---|
357 |
|
---|
358 | SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
|
---|
359 | MoveToEx (hdc, x, yBottom, NULL);
|
---|
360 | LineTo (hdc, x, yTop);
|
---|
361 | x++;
|
---|
362 | SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
|
---|
363 | MoveToEx (hdc, x, yBottom, NULL);
|
---|
364 | LineTo (hdc, x, yTop);
|
---|
365 | }
|
---|
366 |
|
---|
367 |
|
---|
368 | /***********************************************************************
|
---|
369 | * TOOLBAR_DrawDDFlatSeparator
|
---|
370 | *
|
---|
371 | * This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
|
---|
372 | * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
|
---|
373 | * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
|
---|
374 | * are horizontal as opposed to the vertical separators for not dropdown
|
---|
375 | * type.
|
---|
376 | *
|
---|
377 | * FIXME: It is possible that the height of each line is really SM_CYBORDER.
|
---|
378 | */
|
---|
379 | static void
|
---|
380 | TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr)
|
---|
381 | {
|
---|
382 | RECT myrect;
|
---|
383 | COLORREF oldcolor, newcolor;
|
---|
384 |
|
---|
385 | myrect.left = lpRect->left;
|
---|
386 | myrect.right = lpRect->right;
|
---|
387 | myrect.top = lpRect->top + (lpRect->bottom - lpRect->top - 2)/2;
|
---|
388 | myrect.bottom = myrect.top + 1;
|
---|
389 |
|
---|
390 | InflateRect (&myrect, -2, 0);
|
---|
391 |
|
---|
392 | TRACE("rect=(%d,%d)-(%d,%d)\n",
|
---|
393 | myrect.left, myrect.top, myrect.right, myrect.bottom);
|
---|
394 |
|
---|
395 | newcolor = GetSysColor (COLOR_BTNSHADOW);
|
---|
396 | oldcolor = SetBkColor (hdc, newcolor);
|
---|
397 | ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
|
---|
398 |
|
---|
399 | myrect.top = myrect.bottom;
|
---|
400 | myrect.bottom = myrect.top + 1;
|
---|
401 |
|
---|
402 | newcolor = GetSysColor (COLOR_BTNHIGHLIGHT);
|
---|
403 | SetBkColor (hdc, newcolor);
|
---|
404 | ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
|
---|
405 |
|
---|
406 | SetBkColor (hdc, oldcolor);
|
---|
407 | }
|
---|
408 |
|
---|
409 |
|
---|
410 | static void
|
---|
411 | TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, INT colorRef)
|
---|
412 | {
|
---|
413 | INT x, y;
|
---|
414 | SelectObject ( hdc, GetSysColorPen (colorRef));
|
---|
415 | x = left + 2;
|
---|
416 | y = top + 8;
|
---|
417 | MoveToEx (hdc, x, y, NULL);
|
---|
418 | LineTo (hdc, x+5, y++); x++;
|
---|
419 | MoveToEx (hdc, x, y, NULL);
|
---|
420 | LineTo (hdc, x+3, y++); x++;
|
---|
421 | MoveToEx (hdc, x, y, NULL);
|
---|
422 | LineTo (hdc, x+1, y++);
|
---|
423 | }
|
---|
424 |
|
---|
425 | /*
|
---|
426 | * Draw the text string for this button.
|
---|
427 | * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
|
---|
428 | * is non-zero, so we can simply check himlDef to see if we have
|
---|
429 | * an image list
|
---|
430 | */
|
---|
431 | static void
|
---|
432 | TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
---|
433 | HDC hdc, INT nState, DWORD dwStyle)
|
---|
434 | {
|
---|
435 | RECT rcText = btnPtr->rect;
|
---|
436 | HFONT hOldFont;
|
---|
437 | COLORREF clrOld;
|
---|
438 | LPWSTR lpText = NULL;
|
---|
439 | HIMAGELIST himl = infoPtr->himlDef;
|
---|
440 |
|
---|
441 | TRACE ("iString: %x\n", btnPtr->iString);
|
---|
442 |
|
---|
443 | /* get a pointer to the text */
|
---|
444 | lpText = TOOLBAR_GetText(infoPtr, btnPtr);
|
---|
445 |
|
---|
446 | TRACE ("lpText: %s\n", debugstr_w(lpText));
|
---|
447 |
|
---|
448 | /* draw text */
|
---|
449 | if (lpText) {
|
---|
450 |
|
---|
451 | InflateRect (&rcText, -3, -3);
|
---|
452 |
|
---|
453 | if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
|
---|
454 | /* The following test looked like this before
|
---|
455 | * I changed it. IE4 "Links" toolbar would not
|
---|
456 | * draw correctly with the original code. - GA 8/01
|
---|
457 | * ((dwStyle & TBSTYLE_LIST) &&
|
---|
458 | * ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
|
---|
459 | * (btnPtr->iBitmap != I_IMAGENONE))
|
---|
460 | */
|
---|
461 | if (dwStyle & TBSTYLE_LIST) {
|
---|
462 | /* LIST style w/ ICON offset is by matching native. */
|
---|
463 | /* Matches IE4 "Links" bar. - GA 8/01 */
|
---|
464 | rcText.left += (infoPtr->nBitmapWidth + 2);
|
---|
465 | }
|
---|
466 | else {
|
---|
467 | rcText.top += infoPtr->nBitmapHeight + 1;
|
---|
468 | }
|
---|
469 | }
|
---|
470 | else {
|
---|
471 | if (dwStyle & TBSTYLE_LIST) {
|
---|
472 | /* LIST style w/o ICON offset is by matching native. */
|
---|
473 | /* Matches IE4 "menu" bar. - GA 8/01 */
|
---|
474 | rcText.left += 4;
|
---|
475 | }
|
---|
476 | }
|
---|
477 |
|
---|
478 | if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
|
---|
479 | OffsetRect (&rcText, 1, 1);
|
---|
480 |
|
---|
481 | TRACE("string rect=(%d,%d)-(%d,%d)\n",
|
---|
482 | rcText.left, rcText.top, rcText.right, rcText.bottom);
|
---|
483 |
|
---|
484 | hOldFont = SelectObject (hdc, infoPtr->hFont);
|
---|
485 | if (!(nState & TBSTATE_ENABLED)) {
|
---|
486 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
|
---|
487 | OffsetRect (&rcText, 1, 1);
|
---|
488 | DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
|
---|
489 | SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
|
---|
490 | OffsetRect (&rcText, -1, -1);
|
---|
491 | DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
|
---|
492 | }
|
---|
493 | else if (nState & TBSTATE_INDETERMINATE) {
|
---|
494 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
|
---|
495 | DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
|
---|
496 | }
|
---|
497 | else {
|
---|
498 | clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
|
---|
499 | DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
|
---|
500 | }
|
---|
501 |
|
---|
502 | SetTextColor (hdc, clrOld);
|
---|
503 | SelectObject (hdc, hOldFont);
|
---|
504 | }
|
---|
505 | }
|
---|
506 |
|
---|
507 |
|
---|
508 | static void
|
---|
509 | TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
|
---|
510 | {
|
---|
511 | HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
|
---|
512 | INT cx = lpRect->right - lpRect->left;
|
---|
513 | INT cy = lpRect->bottom - lpRect->top;
|
---|
514 | PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
|
---|
515 | SelectObject (hdc, hbr);
|
---|
516 | }
|
---|
517 |
|
---|
518 |
|
---|
519 | static void
|
---|
520 | TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
---|
521 | HDC hdc, INT x, INT y)
|
---|
522 | {
|
---|
523 | /* FIXME: this function is a hack since it uses image list
|
---|
524 | internals directly */
|
---|
525 |
|
---|
526 | HIMAGELIST himl = infoPtr->himlDef;
|
---|
527 | HBITMAP hbmMask;
|
---|
528 | HDC hdcImageList;
|
---|
529 | HDC hdcMask;
|
---|
530 |
|
---|
531 | if (!himl)
|
---|
532 | return;
|
---|
533 |
|
---|
534 | /* create new dc's */
|
---|
535 | hdcImageList = CreateCompatibleDC (0);
|
---|
536 | hdcMask = CreateCompatibleDC (0);
|
---|
537 |
|
---|
538 | /* create new bitmap */
|
---|
539 | hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
|
---|
540 | SelectObject (hdcMask, hbmMask);
|
---|
541 |
|
---|
542 | /* copy the mask bitmap */
|
---|
543 | SelectObject (hdcImageList, himl->hbmMask);
|
---|
544 | SetBkColor (hdcImageList, RGB(255, 255, 255));
|
---|
545 | SetTextColor (hdcImageList, RGB(0, 0, 0));
|
---|
546 | BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
|
---|
547 | hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
|
---|
548 |
|
---|
549 | /* draw the new mask */
|
---|
550 | SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
|
---|
551 | BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
|
---|
552 | hdcMask, 0, 0, 0xB8074A);
|
---|
553 |
|
---|
554 | SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
|
---|
555 | BitBlt (hdc, x, y, himl->cx, himl->cy,
|
---|
556 | hdcMask, 0, 0, 0xB8074A);
|
---|
557 |
|
---|
558 | DeleteObject (hbmMask);
|
---|
559 | DeleteDC (hdcMask);
|
---|
560 | DeleteDC (hdcImageList);
|
---|
561 | }
|
---|
562 |
|
---|
563 |
|
---|
564 | static void
|
---|
565 | TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
|
---|
566 | {
|
---|
567 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
568 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
569 | BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
|
---|
570 | (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
|
---|
571 | RECT rc, rcArrow, rcBitmap;
|
---|
572 |
|
---|
573 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
574 | return;
|
---|
575 |
|
---|
576 | rc = btnPtr->rect;
|
---|
577 | CopyRect (&rcArrow, &rc);
|
---|
578 | CopyRect(&rcBitmap, &rc);
|
---|
579 |
|
---|
580 | if (!infoPtr->bBtnTranspnt)
|
---|
581 | FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
|
---|
582 |
|
---|
583 | if (hasDropDownArrow)
|
---|
584 | {
|
---|
585 | if (dwStyle & TBSTYLE_FLAT)
|
---|
586 | rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
|
---|
587 | else
|
---|
588 | rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
|
---|
589 | rcArrow.left = rc.right;
|
---|
590 | }
|
---|
591 |
|
---|
592 | /* Center the bitmap horizontally and vertically */
|
---|
593 | if (dwStyle & TBSTYLE_LIST)
|
---|
594 | rcBitmap.left += 3;
|
---|
595 | else
|
---|
596 | rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
|
---|
597 |
|
---|
598 | if(TOOLBAR_HasText(infoPtr, btnPtr))
|
---|
599 | rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
|
---|
600 | else
|
---|
601 | rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
|
---|
602 |
|
---|
603 | TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n",
|
---|
604 | btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
|
---|
605 | infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
|
---|
606 |
|
---|
607 | /* separator */
|
---|
608 | if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
---|
609 | /* with the FLAT style, iBitmap is the width and has already */
|
---|
610 | /* been taken into consideration in calculating the width */
|
---|
611 | /* so now we need to draw the vertical separator */
|
---|
612 | /* empirical tests show that iBitmap can/will be non-zero */
|
---|
613 | /* when drawing the vertical bar... */
|
---|
614 | if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
|
---|
615 | if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
|
---|
616 | TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr);
|
---|
617 | else
|
---|
618 | TOOLBAR_DrawFlatSeparator (&rc, hdc);
|
---|
619 | }
|
---|
620 | return;
|
---|
621 | }
|
---|
622 |
|
---|
623 | /* disabled */
|
---|
624 | if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
|
---|
625 | if (!(dwStyle & TBSTYLE_FLAT))
|
---|
626 | {
|
---|
627 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
---|
628 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
629 | if (hasDropDownArrow)
|
---|
630 | DrawEdge (hdc, &rcArrow, EDGE_RAISED,
|
---|
631 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
632 | }
|
---|
633 |
|
---|
634 | if (hasDropDownArrow)
|
---|
635 | {
|
---|
636 | TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
|
---|
637 | TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
|
---|
638 | }
|
---|
639 |
|
---|
640 | if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDis,
|
---|
641 | hdc, rcBitmap.left, rcBitmap.top,
|
---|
642 | ILD_NORMAL))
|
---|
643 | TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
|
---|
644 |
|
---|
645 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
|
---|
646 | return;
|
---|
647 | }
|
---|
648 |
|
---|
649 | /* pressed TBSTYLE_BUTTON */
|
---|
650 | if (btnPtr->fsState & TBSTATE_PRESSED) {
|
---|
651 | if (dwStyle & TBSTYLE_FLAT)
|
---|
652 | {
|
---|
653 | DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
|
---|
654 | if (hasDropDownArrow)
|
---|
655 | DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
|
---|
656 | }
|
---|
657 | else
|
---|
658 | {
|
---|
659 | DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
660 | if (hasDropDownArrow)
|
---|
661 | DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
662 | }
|
---|
663 |
|
---|
664 | if (hasDropDownArrow)
|
---|
665 | TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
|
---|
666 |
|
---|
667 | TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
|
---|
668 | hdc, rcBitmap.left+1, rcBitmap.top+1,
|
---|
669 | ILD_NORMAL);
|
---|
670 |
|
---|
671 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
|
---|
672 | return;
|
---|
673 | }
|
---|
674 |
|
---|
675 | /* checked TBSTYLE_CHECK */
|
---|
676 | if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
|
---|
677 | (btnPtr->fsState & TBSTATE_CHECKED)) {
|
---|
678 | if (dwStyle & TBSTYLE_FLAT)
|
---|
679 | DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
|
---|
680 | BF_RECT | BF_ADJUST);
|
---|
681 | else
|
---|
682 | DrawEdge (hdc, &rc, EDGE_SUNKEN,
|
---|
683 | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
684 |
|
---|
685 | TOOLBAR_DrawPattern (hdc, &rc);
|
---|
686 |
|
---|
687 | TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
|
---|
688 | hdc, rcBitmap.left+1, rcBitmap.top+1,
|
---|
689 | ILD_NORMAL);
|
---|
690 |
|
---|
691 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
|
---|
692 | return;
|
---|
693 | }
|
---|
694 |
|
---|
695 | /* indeterminate */
|
---|
696 | if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
|
---|
697 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
---|
698 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
699 |
|
---|
700 | TOOLBAR_DrawPattern (hdc, &rc);
|
---|
701 | TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
|
---|
702 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
|
---|
703 | return;
|
---|
704 | }
|
---|
705 |
|
---|
706 | /* normal state */
|
---|
707 | if (dwStyle & TBSTYLE_FLAT)
|
---|
708 | {
|
---|
709 | if (btnPtr->bHot)
|
---|
710 | {
|
---|
711 | DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
|
---|
712 | if (hasDropDownArrow)
|
---|
713 | DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
|
---|
714 | }
|
---|
715 | #if 1
|
---|
716 | else /* The following code needs to be removed after
|
---|
717 | * "hot item" support has been implemented for the
|
---|
718 | * case where it is being de-selected.
|
---|
719 | */
|
---|
720 | {
|
---|
721 | FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
|
---|
722 | if (hasDropDownArrow)
|
---|
723 | FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE));
|
---|
724 | }
|
---|
725 | #endif
|
---|
726 |
|
---|
727 | if (hasDropDownArrow)
|
---|
728 | TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
|
---|
729 |
|
---|
730 | if (btnPtr->bHot) {
|
---|
731 | /* if hot, attempt to draw with himlHot, if fails, use himlDef */
|
---|
732 | if (!TOOLBAR_DrawImageList (infoPtr, btnPtr,
|
---|
733 | infoPtr->himlHot,
|
---|
734 | hdc, rcBitmap.left,
|
---|
735 | rcBitmap.top, ILD_NORMAL))
|
---|
736 | TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
|
---|
737 | hdc, rcBitmap.left, rcBitmap.top,
|
---|
738 | ILD_NORMAL);
|
---|
739 | }
|
---|
740 | else
|
---|
741 | TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
|
---|
742 | hdc, rcBitmap.left, rcBitmap.top,
|
---|
743 | ILD_NORMAL);
|
---|
744 | }
|
---|
745 | else
|
---|
746 | {
|
---|
747 | DrawEdge (hdc, &rc, EDGE_RAISED,
|
---|
748 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
749 |
|
---|
750 | if (hasDropDownArrow)
|
---|
751 | {
|
---|
752 | DrawEdge (hdc, &rcArrow, EDGE_RAISED,
|
---|
753 | BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
---|
754 | TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
|
---|
755 | }
|
---|
756 |
|
---|
757 | TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
|
---|
758 | hdc, rcBitmap.left, rcBitmap.top,
|
---|
759 | ILD_NORMAL);
|
---|
760 | }
|
---|
761 |
|
---|
762 | TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
|
---|
763 | }
|
---|
764 |
|
---|
765 |
|
---|
766 | static void
|
---|
767 | TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
|
---|
768 | {
|
---|
769 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
770 | TBUTTON_INFO *btnPtr;
|
---|
771 | INT i, oldBKmode = 0;
|
---|
772 | RECT rcTemp;
|
---|
773 |
|
---|
774 | /* if imagelist belongs to the app, it can be changed
|
---|
775 | by the app after setting it */
|
---|
776 | if (infoPtr->himlDef != infoPtr->himlInt)
|
---|
777 | infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
|
---|
778 |
|
---|
779 | TOOLBAR_DumpToolbar (infoPtr, __LINE__);
|
---|
780 |
|
---|
781 | if (infoPtr->bBtnTranspnt)
|
---|
782 | oldBKmode = SetBkMode (hdc, TRANSPARENT);
|
---|
783 |
|
---|
784 | /* redraw necessary buttons */
|
---|
785 | btnPtr = infoPtr->buttons;
|
---|
786 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
|
---|
787 | {
|
---|
788 | if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect)))
|
---|
789 | TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
|
---|
790 | }
|
---|
791 |
|
---|
792 | if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT))
|
---|
793 | SetBkMode (hdc, oldBKmode);
|
---|
794 | }
|
---|
795 |
|
---|
796 | /***********************************************************************
|
---|
797 | * TOOLBAR_MeasureString
|
---|
798 | *
|
---|
799 | * This function gets the width and height of a string in pixels. This
|
---|
800 | * is done first by using GetTextExtentPoint to get the basic width
|
---|
801 | * and height. The DrawText is called with DT_CALCRECT to get the exact
|
---|
802 | * width. The reason is because the text may have more than one "&" (or
|
---|
803 | * prefix characters as M$ likes to call them). The prefix character
|
---|
804 | * indicates where the underline goes, except for the string "&&" which
|
---|
805 | * is reduced to a single "&". GetTextExtentPoint does not process these
|
---|
806 | * only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
|
---|
807 | */
|
---|
808 | static void
|
---|
809 | TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
---|
810 | HDC hdc, LPSIZE lpSize)
|
---|
811 | {
|
---|
812 | RECT myrect;
|
---|
813 |
|
---|
814 | lpSize->cx = 0;
|
---|
815 | lpSize->cy = 0;
|
---|
816 |
|
---|
817 | if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
|
---|
818 | (btnPtr->iString > -1) &&
|
---|
819 | (btnPtr->iString < infoPtr->nNumStrings))
|
---|
820 | {
|
---|
821 | LPWSTR lpText = infoPtr->strings[btnPtr->iString];
|
---|
822 |
|
---|
823 | /* first get size of all the text */
|
---|
824 | GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize);
|
---|
825 |
|
---|
826 | /* feed above size into the rectangle for DrawText */
|
---|
827 | myrect.left = myrect.top = 0;
|
---|
828 | myrect.right = lpSize->cx;
|
---|
829 | myrect.bottom = lpSize->cy;
|
---|
830 |
|
---|
831 | /* Use DrawText to get true size as drawn (less pesky "&") */
|
---|
832 | DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
|
---|
833 | DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
|
---|
834 | DT_NOPREFIX : 0));
|
---|
835 |
|
---|
836 | /* feed back to caller */
|
---|
837 | lpSize->cx = myrect.right;
|
---|
838 | lpSize->cy = myrect.bottom;
|
---|
839 | }
|
---|
840 |
|
---|
841 | TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
|
---|
842 | }
|
---|
843 |
|
---|
844 | /***********************************************************************
|
---|
845 | * TOOLBAR_CalcStrings
|
---|
846 | *
|
---|
847 | * This function walks through each string and measures it and returns
|
---|
848 | * the largest height and width to caller.
|
---|
849 | */
|
---|
850 | static void
|
---|
851 | TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
|
---|
852 | {
|
---|
853 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
854 | TBUTTON_INFO *btnPtr;
|
---|
855 | INT i;
|
---|
856 | SIZE sz;
|
---|
857 | HDC hdc;
|
---|
858 | HFONT hOldFont;
|
---|
859 |
|
---|
860 | lpSize->cx = 0;
|
---|
861 | lpSize->cy = 0;
|
---|
862 |
|
---|
863 | hdc = GetDC (hwnd);
|
---|
864 | hOldFont = SelectObject (hdc, infoPtr->hFont);
|
---|
865 |
|
---|
866 | btnPtr = infoPtr->buttons;
|
---|
867 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
---|
868 | if(TOOLBAR_HasText(infoPtr, btnPtr))
|
---|
869 | {
|
---|
870 | TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
|
---|
871 | if (sz.cx > lpSize->cx)
|
---|
872 | lpSize->cx = sz.cx;
|
---|
873 | if (sz.cy > lpSize->cy)
|
---|
874 | lpSize->cy = sz.cy;
|
---|
875 | }
|
---|
876 | }
|
---|
877 |
|
---|
878 | SelectObject (hdc, hOldFont);
|
---|
879 | ReleaseDC (hwnd, hdc);
|
---|
880 |
|
---|
881 | TRACE("max string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
|
---|
882 | }
|
---|
883 |
|
---|
884 | /***********************************************************************
|
---|
885 | * TOOLBAR_WrapToolbar
|
---|
886 | *
|
---|
887 | * This function walks through the buttons and seperators in the
|
---|
888 | * toolbar, and sets the TBSTATE_WRAP flag only on those items where
|
---|
889 | * wrapping should occur based on the width of the toolbar window.
|
---|
890 | * It does *not* calculate button placement itself. That task
|
---|
891 | * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
|
---|
892 | * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
|
---|
893 | * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
|
---|
894 | */
|
---|
895 |
|
---|
896 | static void
|
---|
897 | TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle )
|
---|
898 | {
|
---|
899 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
900 | TBUTTON_INFO *btnPtr;
|
---|
901 | INT x, cx, i, j;
|
---|
902 | RECT rc;
|
---|
903 | BOOL bWrap, bButtonWrap;
|
---|
904 |
|
---|
905 | /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
|
---|
906 | /* no layout is necessary. Applications may use this style */
|
---|
907 | /* to perform their own layout on the toolbar. */
|
---|
908 | if( !(dwStyle & TBSTYLE_WRAPABLE) )
|
---|
909 | return;
|
---|
910 |
|
---|
911 | btnPtr = infoPtr->buttons;
|
---|
912 | x = infoPtr->nIndent;
|
---|
913 |
|
---|
914 | /* this can get the parents width, to know how far we can extend
|
---|
915 | * this toolbar. We cannot use its height, as there may be multiple
|
---|
916 | * toolbars in a rebar control
|
---|
917 | */
|
---|
918 | GetClientRect( GetParent(hwnd), &rc );
|
---|
919 | infoPtr->nWidth = rc.right - rc.left;
|
---|
920 | bButtonWrap = FALSE;
|
---|
921 |
|
---|
922 | TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
|
---|
923 | infoPtr->nButtonWidth, infoPtr->nBitmapWidth, infoPtr->nWidth,
|
---|
924 | infoPtr->nIndent);
|
---|
925 |
|
---|
926 | for (i = 0; i < infoPtr->nNumButtons; i++ )
|
---|
927 | {
|
---|
928 | bWrap = FALSE;
|
---|
929 | btnPtr[i].fsState &= ~TBSTATE_WRAP;
|
---|
930 |
|
---|
931 | if (btnPtr[i].fsState & TBSTATE_HIDDEN)
|
---|
932 | continue;
|
---|
933 |
|
---|
934 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
---|
935 | /* it is the actual width of the separator. This is used for */
|
---|
936 | /* custom controls in toolbars. */
|
---|
937 | /* */
|
---|
938 | /* TBSTYLE_DROPDOWN separators are treated as buttons for */
|
---|
939 | /* width. - GA 8/01 */
|
---|
940 | if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
|
---|
941 | !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
|
---|
942 | cx = (btnPtr[i].iBitmap > 0) ?
|
---|
943 | btnPtr[i].iBitmap : SEPARATOR_WIDTH;
|
---|
944 | else
|
---|
945 | cx = infoPtr->nButtonWidth;
|
---|
946 |
|
---|
947 | /* Two or more adjacent separators form a separator group. */
|
---|
948 | /* The first separator in a group should be wrapped to the */
|
---|
949 | /* next row if the previous wrapping is on a button. */
|
---|
950 | if( bButtonWrap &&
|
---|
951 | (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
|
---|
952 | (i + 1 < infoPtr->nNumButtons ) &&
|
---|
953 | (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
|
---|
954 | {
|
---|
955 | TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
|
---|
956 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
---|
957 | x = infoPtr->nIndent;
|
---|
958 | i++;
|
---|
959 | bButtonWrap = FALSE;
|
---|
960 | continue;
|
---|
961 | }
|
---|
962 |
|
---|
963 | /* The layout makes sure the bitmap is visible, but not the button. */
|
---|
964 | /* Test added to also wrap after a button that starts a row but */
|
---|
965 | /* is bigger than the area. - GA 8/01 */
|
---|
966 | if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
|
---|
967 | > infoPtr->nWidth ) ||
|
---|
968 | ((x == infoPtr->nIndent) && (cx > infoPtr->nWidth)))
|
---|
969 | {
|
---|
970 | BOOL bFound = FALSE;
|
---|
971 |
|
---|
972 | /* If the current button is a separator and not hidden, */
|
---|
973 | /* go to the next until it reaches a non separator. */
|
---|
974 | /* Wrap the last separator if it is before a button. */
|
---|
975 | while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
|
---|
976 | (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
|
---|
977 | i < infoPtr->nNumButtons )
|
---|
978 | {
|
---|
979 | i++;
|
---|
980 | bFound = TRUE;
|
---|
981 | }
|
---|
982 |
|
---|
983 | if( bFound && i < infoPtr->nNumButtons )
|
---|
984 | {
|
---|
985 | i--;
|
---|
986 | TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
|
---|
987 | i, btnPtr[i].fsStyle, x, cx);
|
---|
988 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
---|
989 | x = infoPtr->nIndent;
|
---|
990 | bButtonWrap = FALSE;
|
---|
991 | continue;
|
---|
992 | }
|
---|
993 | else if ( i >= infoPtr->nNumButtons)
|
---|
994 | break;
|
---|
995 |
|
---|
996 | /* If the current button is not a separator, find the last */
|
---|
997 | /* separator and wrap it. */
|
---|
998 | for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
|
---|
999 | {
|
---|
1000 | if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
|
---|
1001 | !(btnPtr[j].fsState & TBSTATE_HIDDEN))
|
---|
1002 | {
|
---|
1003 | bFound = TRUE;
|
---|
1004 | i = j;
|
---|
1005 | TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
|
---|
1006 | i, btnPtr[i].fsStyle, x, cx);
|
---|
1007 | x = infoPtr->nIndent;
|
---|
1008 | btnPtr[j].fsState |= TBSTATE_WRAP;
|
---|
1009 | bButtonWrap = FALSE;
|
---|
1010 | break;
|
---|
1011 | }
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 | /* If no separator available for wrapping, wrap one of */
|
---|
1015 | /* non-hidden previous button. */
|
---|
1016 | if (!bFound)
|
---|
1017 | {
|
---|
1018 | for ( j = i - 1;
|
---|
1019 | j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
|
---|
1020 | {
|
---|
1021 | if (btnPtr[j].fsState & TBSTATE_HIDDEN)
|
---|
1022 | continue;
|
---|
1023 |
|
---|
1024 | bFound = TRUE;
|
---|
1025 | i = j;
|
---|
1026 | TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
|
---|
1027 | i, btnPtr[i].fsStyle, x, cx);
|
---|
1028 | x = infoPtr->nIndent;
|
---|
1029 | btnPtr[j].fsState |= TBSTATE_WRAP;
|
---|
1030 | bButtonWrap = TRUE;
|
---|
1031 | break;
|
---|
1032 | }
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 | /* If all above failed, wrap the current button. */
|
---|
1036 | if (!bFound)
|
---|
1037 | {
|
---|
1038 | TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
|
---|
1039 | i, btnPtr[i].fsStyle, x, cx);
|
---|
1040 | btnPtr[i].fsState |= TBSTATE_WRAP;
|
---|
1041 | bFound = TRUE;
|
---|
1042 | x = infoPtr->nIndent;
|
---|
1043 | if (btnPtr[i].fsStyle & TBSTYLE_SEP )
|
---|
1044 | bButtonWrap = FALSE;
|
---|
1045 | else
|
---|
1046 | bButtonWrap = TRUE;
|
---|
1047 | }
|
---|
1048 | }
|
---|
1049 | else {
|
---|
1050 | TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
|
---|
1051 | i, btnPtr[i].fsStyle, x, cx);
|
---|
1052 | x += cx;
|
---|
1053 | }
|
---|
1054 | }
|
---|
1055 | }
|
---|
1056 |
|
---|
1057 |
|
---|
1058 | /***********************************************************************
|
---|
1059 | * TOOLBAR_CalcToolbar
|
---|
1060 | *
|
---|
1061 | * This function calculates button and separator placement. It first
|
---|
1062 | * calculates the button sizes, gets the toolbar window width and then
|
---|
1063 | * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
|
---|
1064 | * on. It assigns a new location to each item and sends this location to
|
---|
1065 | * the tooltip window if appropriate. Finally, it updates the rcBound
|
---|
1066 | * rect and calculates the new required toolbar window height.
|
---|
1067 | */
|
---|
1068 |
|
---|
1069 | static void
|
---|
1070 | TOOLBAR_CalcToolbar (HWND hwnd)
|
---|
1071 | {
|
---|
1072 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
---|
1073 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
1074 | TBUTTON_INFO *btnPtr;
|
---|
1075 | INT i, nRows, nSepRows;
|
---|
1076 | INT x, y, cx, cy;
|
---|
1077 | SIZE sizeString;
|
---|
1078 | BOOL bWrap;
|
---|
1079 | BOOL usesBitmaps = FALSE;
|
---|
1080 | BOOL hasDropDownArrows = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle);
|
---|
1081 |
|
---|
1082 | TOOLBAR_CalcStrings (hwnd, &sizeString);
|
---|
1083 |
|
---|
1084 | if (dwStyle & TBSTYLE_LIST)
|
---|
1085 | {
|
---|
1086 | for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
|
---|
1087 | {
|
---|
1088 | if (infoPtr->buttons[i].iBitmap >= 0)
|
---|
1089 | usesBitmaps = TRUE;
|
---|
1090 | }
|
---|
1091 | infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight :
|
---|
1092 | 0, sizeString.cy) + 6;
|
---|
1093 | infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
|
---|
1094 | 0) + sizeString.cx + 6;
|
---|
1095 | TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
|
---|
1096 | infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps,
|
---|
1097 | infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
|
---|
1098 | TOOLBAR_DumpToolbar (infoPtr, __LINE__);
|
---|
1099 | }
|
---|
1100 | else {
|
---|
1101 | for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
|
---|
1102 | {
|
---|
1103 | if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
|
---|
1104 | usesBitmaps = TRUE;
|
---|
1105 | }
|
---|
1106 |
|
---|
1107 | if (sizeString.cy > 0)
|
---|
1108 | {
|
---|
1109 | if (usesBitmaps)
|
---|
1110 | infoPtr->nButtonHeight = sizeString.cy +
|
---|
1111 | 2 + /* this is the space to separate text from bitmap */
|
---|
1112 | infoPtr->nBitmapHeight + 6;
|
---|
1113 | else
|
---|
1114 | infoPtr->nButtonHeight = sizeString.cy + 6;
|
---|
1115 | }
|
---|
1116 | else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
|
---|
1117 | infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
|
---|
1118 |
|
---|
1119 | if (sizeString.cx > infoPtr->nBitmapWidth)
|
---|
1120 | infoPtr->nButtonWidth = sizeString.cx + 6;
|
---|
1121 | else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
|
---|
1122 | infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
|
---|
1123 | }
|
---|
1124 |
|
---|
1125 | if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin )
|
---|
1126 | infoPtr->nButtonWidth = infoPtr->cxMin;
|
---|
1127 | if ( infoPtr->cxMax > 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
|
---|
1128 | infoPtr->nButtonWidth = infoPtr->cxMax;
|
---|
1129 |
|
---|
1130 | TOOLBAR_WrapToolbar( hwnd, dwStyle );
|
---|
1131 |
|
---|
1132 | x = infoPtr->nIndent;
|
---|
1133 | y = 0;
|
---|
1134 |
|
---|
1135 | /*
|
---|
1136 | * We will set the height below, and we set the width on entry
|
---|
1137 | * so we do not reset them here..
|
---|
1138 | */
|
---|
1139 | #if 0
|
---|
1140 | GetClientRect( hwnd, &rc );
|
---|
1141 | /* get initial values for toolbar */
|
---|
1142 | infoPtr->nWidth = rc.right - rc.left;
|
---|
1143 | infoPtr->nHeight = rc.bottom - rc.top;
|
---|
1144 | #endif
|
---|
1145 |
|
---|
1146 | /* from above, minimum is a button, and possible text */
|
---|
1147 | cx = infoPtr->nButtonWidth;
|
---|
1148 |
|
---|
1149 | /* cannot use just ButtonHeight, we may have no buttons! */
|
---|
1150 | if (infoPtr->nNumButtons > 0)
|
---|
1151 | infoPtr->nHeight = infoPtr->nButtonHeight;
|
---|
1152 |
|
---|
1153 | cy = infoPtr->nHeight;
|
---|
1154 |
|
---|
1155 | nRows = nSepRows = 0;
|
---|
1156 |
|
---|
1157 | infoPtr->rcBound.top = y;
|
---|
1158 | infoPtr->rcBound.left = x;
|
---|
1159 | infoPtr->rcBound.bottom = y + cy;
|
---|
1160 | infoPtr->rcBound.right = x;
|
---|
1161 |
|
---|
1162 | btnPtr = infoPtr->buttons;
|
---|
1163 |
|
---|
1164 | /* do not base height/width on parent, if the parent is a */
|
---|
1165 | /* rebar control it could have multiple rows of toolbars */
|
---|
1166 | /* GetClientRect( GetParent(hwnd), &rc ); */
|
---|
1167 | /* cx = rc.right - rc.left; */
|
---|
1168 | /* cy = rc.bottom - rc.top; */
|
---|
1169 |
|
---|
1170 | TRACE("cy=%d\n", cy);
|
---|
1171 |
|
---|
1172 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
|
---|
1173 | {
|
---|
1174 | bWrap = FALSE;
|
---|
1175 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
1176 | {
|
---|
1177 | SetRectEmpty (&btnPtr->rect);
|
---|
1178 | continue;
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 | cy = infoPtr->nHeight;
|
---|
1182 |
|
---|
1183 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
---|
1184 | /* it is the actual width of the separator. This is used for */
|
---|
1185 | /* custom controls in toolbars. */
|
---|
1186 | if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
---|
1187 | if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
|
---|
1188 | cy = (btnPtr->iBitmap > 0) ?
|
---|
1189 | btnPtr->iBitmap : SEPARATOR_WIDTH;
|
---|
1190 | cx = infoPtr->nButtonWidth;
|
---|
1191 | }
|
---|
1192 | else
|
---|
1193 | cx = (btnPtr->iBitmap > 0) ?
|
---|
1194 | btnPtr->iBitmap : SEPARATOR_WIDTH;
|
---|
1195 | }
|
---|
1196 | else
|
---|
1197 | {
|
---|
1198 | if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
|
---|
1199 | {
|
---|
1200 | SIZE sz;
|
---|
1201 | HDC hdc;
|
---|
1202 | HFONT hOldFont;
|
---|
1203 |
|
---|
1204 | hdc = GetDC (hwnd);
|
---|
1205 | hOldFont = SelectObject (hdc, infoPtr->hFont);
|
---|
1206 |
|
---|
1207 | TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
|
---|
1208 |
|
---|
1209 | SelectObject (hdc, hOldFont);
|
---|
1210 | ReleaseDC (hwnd, hdc);
|
---|
1211 |
|
---|
1212 | /* Fudge amount measured against IE4 "menu" and "Links" */
|
---|
1213 | /* toolbars with native control (v4.71). - GA 8/01 */
|
---|
1214 | cx = sz.cx + 6 + 5 + 5;
|
---|
1215 | if ((dwStyle & TBSTYLE_LIST) &&
|
---|
1216 | (TOOLBAR_TestImageExist (infoPtr, btnPtr, infoPtr->himlDef)))
|
---|
1217 | cx += infoPtr->nBitmapWidth;
|
---|
1218 | }
|
---|
1219 | else
|
---|
1220 | cx = infoPtr->nButtonWidth;
|
---|
1221 |
|
---|
1222 | if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
|
---|
1223 | cx += DDARROW_WIDTH;
|
---|
1224 | }
|
---|
1225 | if (btnPtr->fsState & TBSTATE_WRAP )
|
---|
1226 | bWrap = TRUE;
|
---|
1227 |
|
---|
1228 | SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
|
---|
1229 |
|
---|
1230 | if (infoPtr->rcBound.left > x)
|
---|
1231 | infoPtr->rcBound.left = x;
|
---|
1232 | if (infoPtr->rcBound.right < x + cx)
|
---|
1233 | infoPtr->rcBound.right = x + cx;
|
---|
1234 | if (infoPtr->rcBound.bottom < y + cy)
|
---|
1235 | infoPtr->rcBound.bottom = y + cy;
|
---|
1236 |
|
---|
1237 | /* Set the toolTip only for non-hidden, non-separator button */
|
---|
1238 | if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
|
---|
1239 | {
|
---|
1240 | TTTOOLINFOA ti;
|
---|
1241 |
|
---|
1242 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
1243 | ti.cbSize = sizeof(TTTOOLINFOA);
|
---|
1244 | ti.hwnd = hwnd;
|
---|
1245 | ti.uId = btnPtr->idCommand;
|
---|
1246 | ti.rect = btnPtr->rect;
|
---|
1247 | SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
|
---|
1248 | 0, (LPARAM)&ti);
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 | /* btnPtr->nRow is zero based. The space between the rows is */
|
---|
1252 | /* also considered as a row. */
|
---|
1253 | btnPtr->nRow = nRows + nSepRows;
|
---|
1254 |
|
---|
1255 | TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d\n",
|
---|
1256 | i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow);
|
---|
1257 |
|
---|
1258 | if( bWrap )
|
---|
1259 | {
|
---|
1260 | if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
|
---|
1261 | y += cy;
|
---|
1262 | else
|
---|
1263 | {
|
---|
1264 | /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
---|
1265 | /* it is the actual width of the separator. This is used for */
|
---|
1266 | /* custom controls in toolbars. */
|
---|
1267 | if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
|
---|
1268 | y += cy + ( (btnPtr->iBitmap > 0 ) ?
|
---|
1269 | btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
|
---|
1270 | else
|
---|
1271 | y += cy;
|
---|
1272 |
|
---|
1273 | /* nSepRows is used to calculate the extra height follwoing */
|
---|
1274 | /* the last row. */
|
---|
1275 | nSepRows++;
|
---|
1276 | }
|
---|
1277 | x = infoPtr->nIndent;
|
---|
1278 | nRows++;
|
---|
1279 | }
|
---|
1280 | else
|
---|
1281 | x += cx;
|
---|
1282 | }
|
---|
1283 |
|
---|
1284 | /* infoPtr->nRows is the number of rows on the toolbar */
|
---|
1285 | infoPtr->nRows = nRows + nSepRows + 1;
|
---|
1286 |
|
---|
1287 | /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
|
---|
1288 | /* the last row. */
|
---|
1289 | infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
|
---|
1290 | nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
|
---|
1291 | nSepRows * (infoPtr->nBitmapHeight + 1) +
|
---|
1292 | BOTTOM_BORDER;
|
---|
1293 | TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
|
---|
1294 | }
|
---|
1295 |
|
---|
1296 |
|
---|
1297 | static INT
|
---|
1298 | TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
|
---|
1299 | {
|
---|
1300 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1301 | TBUTTON_INFO *btnPtr;
|
---|
1302 | INT i;
|
---|
1303 |
|
---|
1304 | btnPtr = infoPtr->buttons;
|
---|
1305 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
---|
1306 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
1307 | continue;
|
---|
1308 |
|
---|
1309 | if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
---|
1310 | if (PtInRect (&btnPtr->rect, *lpPt)) {
|
---|
1311 | TRACE(" ON SEPARATOR %d!\n", i);
|
---|
1312 | return -i;
|
---|
1313 | }
|
---|
1314 | }
|
---|
1315 | else {
|
---|
1316 | if (PtInRect (&btnPtr->rect, *lpPt)) {
|
---|
1317 | TRACE(" ON BUTTON %d!\n", i);
|
---|
1318 | return i;
|
---|
1319 | }
|
---|
1320 | }
|
---|
1321 | }
|
---|
1322 |
|
---|
1323 | TRACE(" NOWHERE!\n");
|
---|
1324 | return -1;
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 |
|
---|
1328 | static INT
|
---|
1329 | TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand)
|
---|
1330 | {
|
---|
1331 | TBUTTON_INFO *btnPtr;
|
---|
1332 | INT i;
|
---|
1333 |
|
---|
1334 | btnPtr = infoPtr->buttons;
|
---|
1335 | for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
---|
1336 | if (btnPtr->idCommand == idCommand) {
|
---|
1337 | TRACE("command=%d index=%d\n", idCommand, i);
|
---|
1338 | return i;
|
---|
1339 | }
|
---|
1340 | }
|
---|
1341 | TRACE("no index found for command=%d\n", idCommand);
|
---|
1342 | return -1;
|
---|
1343 | }
|
---|
1344 |
|
---|
1345 |
|
---|
1346 | static INT
|
---|
1347 | TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
|
---|
1348 | {
|
---|
1349 | TBUTTON_INFO *btnPtr;
|
---|
1350 | INT nRunIndex;
|
---|
1351 |
|
---|
1352 | if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
|
---|
1353 | return -1;
|
---|
1354 |
|
---|
1355 | /* check index button */
|
---|
1356 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
1357 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
---|
1358 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
1359 | return nIndex;
|
---|
1360 | }
|
---|
1361 |
|
---|
1362 | /* check previous buttons */
|
---|
1363 | nRunIndex = nIndex - 1;
|
---|
1364 | while (nRunIndex >= 0) {
|
---|
1365 | btnPtr = &infoPtr->buttons[nRunIndex];
|
---|
1366 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
---|
1367 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
1368 | return nRunIndex;
|
---|
1369 | }
|
---|
1370 | else
|
---|
1371 | break;
|
---|
1372 | nRunIndex--;
|
---|
1373 | }
|
---|
1374 |
|
---|
1375 | /* check next buttons */
|
---|
1376 | nRunIndex = nIndex + 1;
|
---|
1377 | while (nRunIndex < infoPtr->nNumButtons) {
|
---|
1378 | btnPtr = &infoPtr->buttons[nRunIndex];
|
---|
1379 | if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
---|
1380 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
1381 | return nRunIndex;
|
---|
1382 | }
|
---|
1383 | else
|
---|
1384 | break;
|
---|
1385 | nRunIndex++;
|
---|
1386 | }
|
---|
1387 |
|
---|
1388 | return -1;
|
---|
1389 | }
|
---|
1390 |
|
---|
1391 |
|
---|
1392 | static VOID
|
---|
1393 | TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
|
---|
1394 | WPARAM wParam, LPARAM lParam)
|
---|
1395 | {
|
---|
1396 | MSG msg;
|
---|
1397 |
|
---|
1398 | msg.hwnd = hwndMsg;
|
---|
1399 | msg.message = uMsg;
|
---|
1400 | msg.wParam = wParam;
|
---|
1401 | msg.lParam = lParam;
|
---|
1402 | msg.time = GetMessageTime ();
|
---|
1403 | msg.pt.x = LOWORD(GetMessagePos ());
|
---|
1404 | msg.pt.y = HIWORD(GetMessagePos ());
|
---|
1405 |
|
---|
1406 | SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
|
---|
1407 | }
|
---|
1408 |
|
---|
1409 |
|
---|
1410 | /***********************************************************************
|
---|
1411 | * TOOLBAR_CustomizeDialogProc
|
---|
1412 | * This function implements the toolbar customization dialog.
|
---|
1413 | */
|
---|
1414 | static BOOL WINAPI
|
---|
1415 | TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
1416 | {
|
---|
1417 | PCUSTDLG_INFO custInfo = (PCUSTDLG_INFO)GetWindowLongA (hwnd, DWL_USER);
|
---|
1418 | PCUSTOMBUTTON btnInfo;
|
---|
1419 | NMTOOLBARA nmtb;
|
---|
1420 | TOOLBAR_INFO *infoPtr = custInfo->tbInfo;
|
---|
1421 |
|
---|
1422 | switch (uMsg)
|
---|
1423 | {
|
---|
1424 | case WM_INITDIALOG:
|
---|
1425 | custInfo = (PCUSTDLG_INFO)lParam;
|
---|
1426 | SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
|
---|
1427 |
|
---|
1428 | if (custInfo)
|
---|
1429 | {
|
---|
1430 | char Buffer[256];
|
---|
1431 | int i = 0;
|
---|
1432 | int index;
|
---|
1433 |
|
---|
1434 | /* send TBN_QUERYINSERT notification */
|
---|
1435 | nmtb.iItem = custInfo->tbInfo->nNumButtons;
|
---|
1436 |
|
---|
1437 | if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT))
|
---|
1438 | return FALSE;
|
---|
1439 |
|
---|
1440 | /* add items to 'toolbar buttons' list and check if removable */
|
---|
1441 | for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
|
---|
1442 | {
|
---|
1443 | btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
|
---|
1444 | memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
|
---|
1445 | btnInfo->btn.fsStyle = TBSTYLE_SEP;
|
---|
1446 | btnInfo->bVirtual = FALSE;
|
---|
1447 | LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
|
---|
1448 |
|
---|
1449 | /* send TBN_QUERYDELETE notification */
|
---|
1450 | nmtb.iItem = i;
|
---|
1451 | btnInfo->bRemovable = TOOLBAR_SendNotify ((NMHDR *) &nmtb,
|
---|
1452 | infoPtr,
|
---|
1453 | TBN_QUERYDELETE);
|
---|
1454 |
|
---|
1455 | index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
|
---|
1456 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
---|
1457 | }
|
---|
1458 |
|
---|
1459 | /* insert separator button into 'available buttons' list */
|
---|
1460 | btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
|
---|
1461 | memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
|
---|
1462 | btnInfo->btn.fsStyle = TBSTYLE_SEP;
|
---|
1463 | btnInfo->bVirtual = FALSE;
|
---|
1464 | btnInfo->bRemovable = TRUE;
|
---|
1465 | LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
|
---|
1466 | index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
|
---|
1467 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
---|
1468 |
|
---|
1469 | /* insert all buttons into dsa */
|
---|
1470 | for (i = 0;; i++)
|
---|
1471 | {
|
---|
1472 | /* send TBN_GETBUTTONINFO notification */
|
---|
1473 | nmtb.iItem = i;
|
---|
1474 | nmtb.pszText = Buffer;
|
---|
1475 | nmtb.cchText = 256;
|
---|
1476 |
|
---|
1477 | if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_GETBUTTONINFOA))
|
---|
1478 | break;
|
---|
1479 |
|
---|
1480 | TRACE("style: %x\n", nmtb.tbButton.fsStyle);
|
---|
1481 |
|
---|
1482 | /* insert button into the apropriate list */
|
---|
1483 | index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand);
|
---|
1484 | if (index == -1)
|
---|
1485 | {
|
---|
1486 | btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
|
---|
1487 | memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
|
---|
1488 | btnInfo->bVirtual = FALSE;
|
---|
1489 | btnInfo->bRemovable = TRUE;
|
---|
1490 | if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
|
---|
1491 | strcpy (btnInfo->text, nmtb.pszText);
|
---|
1492 |
|
---|
1493 | index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
|
---|
1494 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
---|
1495 | }
|
---|
1496 | else
|
---|
1497 | {
|
---|
1498 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
|
---|
1499 | memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
|
---|
1500 | if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
|
---|
1501 | strcpy (btnInfo->text, nmtb.pszText);
|
---|
1502 |
|
---|
1503 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
---|
1504 | }
|
---|
1505 | }
|
---|
1506 |
|
---|
1507 | /* select first item in the 'available' list */
|
---|
1508 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
|
---|
1509 |
|
---|
1510 | /* append 'virtual' separator button to the 'toolbar buttons' list */
|
---|
1511 | btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
|
---|
1512 | memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
|
---|
1513 | btnInfo->btn.fsStyle = TBSTYLE_SEP;
|
---|
1514 | btnInfo->bVirtual = TRUE;
|
---|
1515 | btnInfo->bRemovable = FALSE;
|
---|
1516 | LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
|
---|
1517 | index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
|
---|
1518 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
---|
1519 |
|
---|
1520 | /* select last item in the 'toolbar' list */
|
---|
1521 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
|
---|
1522 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
|
---|
1523 |
|
---|
1524 | /* set focus and disable buttons */
|
---|
1525 | PostMessageA (hwnd, WM_USER, 0, 0);
|
---|
1526 | }
|
---|
1527 | return TRUE;
|
---|
1528 |
|
---|
1529 | case WM_USER:
|
---|
1530 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
|
---|
1531 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
|
---|
1532 | EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
|
---|
1533 | SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
|
---|
1534 | return TRUE;
|
---|
1535 |
|
---|
1536 | case WM_CLOSE:
|
---|
1537 | EndDialog(hwnd, FALSE);
|
---|
1538 | return TRUE;
|
---|
1539 |
|
---|
1540 | case WM_COMMAND:
|
---|
1541 | switch (LOWORD(wParam))
|
---|
1542 | {
|
---|
1543 | case IDC_TOOLBARBTN_LBOX:
|
---|
1544 | if (HIWORD(wParam) == LBN_SELCHANGE)
|
---|
1545 | {
|
---|
1546 | PCUSTOMBUTTON btnInfo;
|
---|
1547 | NMTOOLBARA nmtb;
|
---|
1548 | int count;
|
---|
1549 | int index;
|
---|
1550 |
|
---|
1551 | count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
|
---|
1552 | index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
|
---|
1553 |
|
---|
1554 | /* send TBN_QUERYINSERT notification */
|
---|
1555 | nmtb.iItem = index;
|
---|
1556 | TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
---|
1557 | TBN_QUERYINSERT);
|
---|
1558 |
|
---|
1559 | /* get list box item */
|
---|
1560 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
|
---|
1561 |
|
---|
1562 | if (index == (count - 1))
|
---|
1563 | {
|
---|
1564 | /* last item (virtual separator) */
|
---|
1565 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
|
---|
1566 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
|
---|
1567 | }
|
---|
1568 | else if (index == (count - 2))
|
---|
1569 | {
|
---|
1570 | /* second last item (last non-virtual item) */
|
---|
1571 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
|
---|
1572 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
|
---|
1573 | }
|
---|
1574 | else if (index == 0)
|
---|
1575 | {
|
---|
1576 | /* first item */
|
---|
1577 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
|
---|
1578 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
|
---|
1579 | }
|
---|
1580 | else
|
---|
1581 | {
|
---|
1582 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
|
---|
1583 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
|
---|
1584 | }
|
---|
1585 |
|
---|
1586 | EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
|
---|
1587 | }
|
---|
1588 | break;
|
---|
1589 |
|
---|
1590 | case IDC_MOVEUP_BTN:
|
---|
1591 | {
|
---|
1592 | PCUSTOMBUTTON btnInfo;
|
---|
1593 | int index;
|
---|
1594 | int count;
|
---|
1595 |
|
---|
1596 | count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
|
---|
1597 | index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
|
---|
1598 | TRACE("Move up: index %d\n", index);
|
---|
1599 |
|
---|
1600 | /* send TBN_QUERYINSERT notification */
|
---|
1601 | nmtb.iItem = index;
|
---|
1602 |
|
---|
1603 | if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
---|
1604 | TBN_QUERYINSERT))
|
---|
1605 | {
|
---|
1606 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
|
---|
1607 |
|
---|
1608 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
|
---|
1609 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
|
---|
1610 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
|
---|
1611 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
|
---|
1612 |
|
---|
1613 | if (index <= 1)
|
---|
1614 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
|
---|
1615 | else if (index >= (count - 3))
|
---|
1616 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
|
---|
1617 |
|
---|
1618 | SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
|
---|
1619 | SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
|
---|
1620 | }
|
---|
1621 | }
|
---|
1622 | break;
|
---|
1623 |
|
---|
1624 | case IDC_MOVEDN_BTN: /* move down */
|
---|
1625 | {
|
---|
1626 | PCUSTOMBUTTON btnInfo;
|
---|
1627 | int index;
|
---|
1628 | int count;
|
---|
1629 |
|
---|
1630 | count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
|
---|
1631 | index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
|
---|
1632 | TRACE("Move up: index %d\n", index);
|
---|
1633 |
|
---|
1634 | /* send TBN_QUERYINSERT notification */
|
---|
1635 | nmtb.iItem = index;
|
---|
1636 | if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
---|
1637 | TBN_QUERYINSERT))
|
---|
1638 | {
|
---|
1639 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
|
---|
1640 |
|
---|
1641 | /* move button down */
|
---|
1642 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
|
---|
1643 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
|
---|
1644 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
|
---|
1645 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
|
---|
1646 |
|
---|
1647 | if (index == 0)
|
---|
1648 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
|
---|
1649 | else if (index >= (count - 3))
|
---|
1650 | EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
|
---|
1651 |
|
---|
1652 | SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
|
---|
1653 | SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
|
---|
1654 | }
|
---|
1655 | }
|
---|
1656 | break;
|
---|
1657 |
|
---|
1658 | case IDC_REMOVE_BTN: /* remove button */
|
---|
1659 | {
|
---|
1660 | PCUSTOMBUTTON btnInfo;
|
---|
1661 | int index;
|
---|
1662 |
|
---|
1663 | index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
|
---|
1664 | TRACE("Remove: index %d\n", index);
|
---|
1665 |
|
---|
1666 | /* send TBN_QUERYDELETE notification */
|
---|
1667 | nmtb.iItem = index;
|
---|
1668 | if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
---|
1669 | TBN_QUERYDELETE))
|
---|
1670 | {
|
---|
1671 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
|
---|
1672 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
|
---|
1673 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
|
---|
1674 |
|
---|
1675 | SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
|
---|
1676 |
|
---|
1677 | /* insert into 'available button' list */
|
---|
1678 | if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
|
---|
1679 | {
|
---|
1680 | index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
|
---|
1681 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
---|
1682 | }
|
---|
1683 | else
|
---|
1684 | COMCTL32_Free (btnInfo);
|
---|
1685 | }
|
---|
1686 | }
|
---|
1687 | break;
|
---|
1688 |
|
---|
1689 | case IDOK: /* Add button */
|
---|
1690 | {
|
---|
1691 | int index;
|
---|
1692 | int count;
|
---|
1693 |
|
---|
1694 | count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
|
---|
1695 | index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
|
---|
1696 | TRACE("Add: index %d\n", index);
|
---|
1697 |
|
---|
1698 | /* send TBN_QUERYINSERT notification */
|
---|
1699 | nmtb.iItem = index;
|
---|
1700 | if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
---|
1701 | TBN_QUERYINSERT))
|
---|
1702 | {
|
---|
1703 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
|
---|
1704 |
|
---|
1705 | if (index != 0)
|
---|
1706 | {
|
---|
1707 | /* remove from 'available buttons' list */
|
---|
1708 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
|
---|
1709 | if (index == count-1)
|
---|
1710 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
|
---|
1711 | else
|
---|
1712 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
|
---|
1713 | }
|
---|
1714 | else
|
---|
1715 | {
|
---|
1716 | PCUSTOMBUTTON btnNew;
|
---|
1717 |
|
---|
1718 | /* duplicate 'separator' button */
|
---|
1719 | btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
|
---|
1720 | memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
|
---|
1721 | btnInfo = btnNew;
|
---|
1722 | }
|
---|
1723 |
|
---|
1724 | /* insert into 'toolbar button' list */
|
---|
1725 | index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
|
---|
1726 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
|
---|
1727 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
|
---|
1728 |
|
---|
1729 | SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
|
---|
1730 | }
|
---|
1731 | }
|
---|
1732 | break;
|
---|
1733 |
|
---|
1734 | case IDCANCEL:
|
---|
1735 | EndDialog(hwnd, FALSE);
|
---|
1736 | break;
|
---|
1737 | }
|
---|
1738 | return TRUE;
|
---|
1739 |
|
---|
1740 | case WM_DESTROY:
|
---|
1741 | {
|
---|
1742 | int count;
|
---|
1743 | int i;
|
---|
1744 |
|
---|
1745 | /* delete items from 'toolbar buttons' listbox*/
|
---|
1746 | count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
|
---|
1747 | for (i = 0; i < count; i++)
|
---|
1748 | {
|
---|
1749 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
|
---|
1750 | COMCTL32_Free(btnInfo);
|
---|
1751 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
|
---|
1752 | }
|
---|
1753 | SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
|
---|
1754 |
|
---|
1755 |
|
---|
1756 | /* delete items from 'available buttons' listbox*/
|
---|
1757 | count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
|
---|
1758 | for (i = 0; i < count; i++)
|
---|
1759 | {
|
---|
1760 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
|
---|
1761 | COMCTL32_Free(btnInfo);
|
---|
1762 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
|
---|
1763 | }
|
---|
1764 | SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
|
---|
1765 | }
|
---|
1766 | return TRUE;
|
---|
1767 |
|
---|
1768 | case WM_DRAWITEM:
|
---|
1769 | if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
|
---|
1770 | {
|
---|
1771 | LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
|
---|
1772 | RECT rcButton;
|
---|
1773 | RECT rcText;
|
---|
1774 | HPEN hOldPen;
|
---|
1775 | HBRUSH hOldBrush;
|
---|
1776 | COLORREF oldText = 0;
|
---|
1777 | COLORREF oldBk = 0;
|
---|
1778 |
|
---|
1779 | /* get item data */
|
---|
1780 | btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
|
---|
1781 | if (btnInfo == NULL)
|
---|
1782 | {
|
---|
1783 | FIXME("btnInfo invalid!\n");
|
---|
1784 | return TRUE;
|
---|
1785 | }
|
---|
1786 |
|
---|
1787 | /* set colors and select objects */
|
---|
1788 | oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
|
---|
1789 | if (btnInfo->bVirtual)
|
---|
1790 | oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
|
---|
1791 | else
|
---|
1792 | oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
|
---|
1793 | hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
|
---|
1794 | hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
|
---|
1795 |
|
---|
1796 | /* fill background rectangle */
|
---|
1797 | Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
|
---|
1798 | lpdis->rcItem.right, lpdis->rcItem.bottom);
|
---|
1799 |
|
---|
1800 | /* calculate button and text rectangles */
|
---|
1801 | CopyRect (&rcButton, &lpdis->rcItem);
|
---|
1802 | InflateRect (&rcButton, -1, -1);
|
---|
1803 | CopyRect (&rcText, &rcButton);
|
---|
1804 | rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
|
---|
1805 | rcText.left = rcButton.right + 2;
|
---|
1806 |
|
---|
1807 | /* draw focus rectangle */
|
---|
1808 | if (lpdis->itemState & ODS_FOCUS)
|
---|
1809 | DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
|
---|
1810 |
|
---|
1811 | /* draw button */
|
---|
1812 | DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
|
---|
1813 |
|
---|
1814 | /* draw image and text */
|
---|
1815 | if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
|
---|
1816 | ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
|
---|
1817 | rcButton.left+3, rcButton.top+3, ILD_NORMAL);
|
---|
1818 | DrawTextA (lpdis->hDC, btnInfo->text, -1, &rcText,
|
---|
1819 | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
---|
1820 |
|
---|
1821 | /* delete objects and reset colors */
|
---|
1822 | SelectObject (lpdis->hDC, hOldBrush);
|
---|
1823 | SelectObject (lpdis->hDC, hOldPen);
|
---|
1824 | SetBkColor (lpdis->hDC, oldBk);
|
---|
1825 | SetTextColor (lpdis->hDC, oldText);
|
---|
1826 |
|
---|
1827 | return TRUE;
|
---|
1828 | }
|
---|
1829 | return FALSE;
|
---|
1830 |
|
---|
1831 | case WM_MEASUREITEM:
|
---|
1832 | if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
|
---|
1833 | {
|
---|
1834 | MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
|
---|
1835 |
|
---|
1836 | if (custInfo && custInfo->tbInfo)
|
---|
1837 | lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
|
---|
1838 | else
|
---|
1839 | lpmis->itemHeight = 15 + 8; /* default height */
|
---|
1840 |
|
---|
1841 | return TRUE;
|
---|
1842 | }
|
---|
1843 | return FALSE;
|
---|
1844 |
|
---|
1845 | default:
|
---|
1846 | return FALSE;
|
---|
1847 | }
|
---|
1848 | }
|
---|
1849 |
|
---|
1850 |
|
---|
1851 | /***********************************************************************
|
---|
1852 | * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
|
---|
1853 | *
|
---|
1854 | */
|
---|
1855 | static LRESULT
|
---|
1856 | TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1857 | {
|
---|
1858 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
1859 | LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
|
---|
1860 | INT nIndex = 0, nButtons, nCount;
|
---|
1861 | HBITMAP hbmLoad;
|
---|
1862 |
|
---|
1863 | TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
|
---|
1864 | if (!lpAddBmp)
|
---|
1865 | return -1;
|
---|
1866 |
|
---|
1867 | if (lpAddBmp->hInst == HINST_COMMCTRL)
|
---|
1868 | {
|
---|
1869 | if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
|
---|
1870 | nButtons = 15;
|
---|
1871 | else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
|
---|
1872 | nButtons = 13;
|
---|
1873 | else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
|
---|
1874 | nButtons = 5;
|
---|
1875 | else
|
---|
1876 | return -1;
|
---|
1877 |
|
---|
1878 | TRACE ("adding %d internal bitmaps!\n", nButtons);
|
---|
1879 |
|
---|
1880 | /* Windows resize all the buttons to the size of a newly added standard image */
|
---|
1881 | if (lpAddBmp->nID & 1)
|
---|
1882 | {
|
---|
1883 | /* large icons */
|
---|
1884 | /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
|
---|
1885 | * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
|
---|
1886 | */
|
---|
1887 | SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
|
---|
1888 | MAKELPARAM((WORD)24, (WORD)24));
|
---|
1889 | SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
|
---|
1890 | MAKELPARAM((WORD)31, (WORD)30));
|
---|
1891 | }
|
---|
1892 | else
|
---|
1893 | {
|
---|
1894 | /* small icons */
|
---|
1895 | SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
|
---|
1896 | MAKELPARAM((WORD)16, (WORD)16));
|
---|
1897 | SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
|
---|
1898 | MAKELPARAM((WORD)22, (WORD)22));
|
---|
1899 | }
|
---|
1900 |
|
---|
1901 | TOOLBAR_CalcToolbar (hwnd);
|
---|
1902 | }
|
---|
1903 | else
|
---|
1904 | {
|
---|
1905 | nButtons = (INT)wParam;
|
---|
1906 | if (nButtons <= 0)
|
---|
1907 | return -1;
|
---|
1908 |
|
---|
1909 | TRACE ("adding %d bitmaps!\n", nButtons);
|
---|
1910 | }
|
---|
1911 |
|
---|
1912 | if (!(infoPtr->himlDef)) {
|
---|
1913 | /* create new default image list */
|
---|
1914 | TRACE ("creating default image list!\n");
|
---|
1915 |
|
---|
1916 | infoPtr->himlDef =
|
---|
1917 | ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
|
---|
1918 | ILC_COLOR | ILC_MASK, nButtons, 2);
|
---|
1919 | infoPtr->himlInt = infoPtr->himlDef;
|
---|
1920 | }
|
---|
1921 |
|
---|
1922 | nCount = ImageList_GetImageCount(infoPtr->himlDef);
|
---|
1923 |
|
---|
1924 | /* Add bitmaps to the default image list */
|
---|
1925 | if (lpAddBmp->hInst == (HINSTANCE)0)
|
---|
1926 | {
|
---|
1927 | nIndex =
|
---|
1928 | ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
|
---|
1929 | CLR_DEFAULT);
|
---|
1930 | }
|
---|
1931 | else if (lpAddBmp->hInst == HINST_COMMCTRL)
|
---|
1932 | {
|
---|
1933 | /* Add system bitmaps */
|
---|
1934 | switch (lpAddBmp->nID)
|
---|
1935 | {
|
---|
1936 | case IDB_STD_SMALL_COLOR:
|
---|
1937 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1938 | MAKEINTRESOURCEA(IDB_STD_SMALL));
|
---|
1939 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1940 | hbmLoad, CLR_DEFAULT);
|
---|
1941 | DeleteObject (hbmLoad);
|
---|
1942 | break;
|
---|
1943 |
|
---|
1944 | case IDB_STD_LARGE_COLOR:
|
---|
1945 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1946 | MAKEINTRESOURCEA(IDB_STD_LARGE));
|
---|
1947 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1948 | hbmLoad, CLR_DEFAULT);
|
---|
1949 | DeleteObject (hbmLoad);
|
---|
1950 | break;
|
---|
1951 |
|
---|
1952 | case IDB_VIEW_SMALL_COLOR:
|
---|
1953 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1954 | MAKEINTRESOURCEA(IDB_VIEW_SMALL));
|
---|
1955 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1956 | hbmLoad, CLR_DEFAULT);
|
---|
1957 | DeleteObject (hbmLoad);
|
---|
1958 | break;
|
---|
1959 |
|
---|
1960 | case IDB_VIEW_LARGE_COLOR:
|
---|
1961 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1962 | MAKEINTRESOURCEA(IDB_VIEW_LARGE));
|
---|
1963 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1964 | hbmLoad, CLR_DEFAULT);
|
---|
1965 | DeleteObject (hbmLoad);
|
---|
1966 | break;
|
---|
1967 |
|
---|
1968 | case IDB_HIST_SMALL_COLOR:
|
---|
1969 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1970 | MAKEINTRESOURCEA(IDB_HIST_SMALL));
|
---|
1971 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1972 | hbmLoad, CLR_DEFAULT);
|
---|
1973 | DeleteObject (hbmLoad);
|
---|
1974 | break;
|
---|
1975 |
|
---|
1976 | case IDB_HIST_LARGE_COLOR:
|
---|
1977 | hbmLoad = LoadBitmapA (COMCTL32_hModule,
|
---|
1978 | MAKEINTRESOURCEA(IDB_HIST_LARGE));
|
---|
1979 | nIndex = ImageList_AddMasked (infoPtr->himlDef,
|
---|
1980 | hbmLoad, CLR_DEFAULT);
|
---|
1981 | DeleteObject (hbmLoad);
|
---|
1982 | break;
|
---|
1983 |
|
---|
1984 | default:
|
---|
1985 | nIndex = ImageList_GetImageCount (infoPtr->himlDef);
|
---|
1986 | ERR ("invalid imagelist!\n");
|
---|
1987 | break;
|
---|
1988 | }
|
---|
1989 | }
|
---|
1990 | else
|
---|
1991 | {
|
---|
1992 | hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
|
---|
1993 | nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
|
---|
1994 | DeleteObject (hbmLoad);
|
---|
1995 | }
|
---|
1996 |
|
---|
1997 | if (nIndex != -1)
|
---|
1998 | {
|
---|
1999 | INT imagecount = ImageList_GetImageCount(infoPtr->himlDef);
|
---|
2000 |
|
---|
2001 | if (infoPtr->nNumBitmaps + nButtons != imagecount)
|
---|
2002 | {
|
---|
2003 | WARN("Desired images do not match received images : Previous image number %i Previous images in list %i added %i expecting total %i, Images in list %i\n",
|
---|
2004 | infoPtr->nNumBitmaps, nCount, imagecount - nCount,
|
---|
2005 | infoPtr->nNumBitmaps+nButtons,imagecount);
|
---|
2006 |
|
---|
2007 | infoPtr->nNumBitmaps = imagecount;
|
---|
2008 | }
|
---|
2009 | else
|
---|
2010 | infoPtr->nNumBitmaps += nButtons;
|
---|
2011 | }
|
---|
2012 |
|
---|
2013 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
2014 |
|
---|
2015 | return nIndex;
|
---|
2016 | }
|
---|
2017 |
|
---|
2018 |
|
---|
2019 | static LRESULT
|
---|
2020 | TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2021 | {
|
---|
2022 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2023 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
2024 | INT nOldButtons, nNewButtons, nAddButtons, nCount;
|
---|
2025 |
|
---|
2026 | TRACE("adding %d buttons!\n", wParam);
|
---|
2027 |
|
---|
2028 | nAddButtons = (UINT)wParam;
|
---|
2029 | nOldButtons = infoPtr->nNumButtons;
|
---|
2030 | nNewButtons = nOldButtons + nAddButtons;
|
---|
2031 |
|
---|
2032 | if (infoPtr->nNumButtons == 0) {
|
---|
2033 | infoPtr->buttons =
|
---|
2034 | COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
|
---|
2035 | }
|
---|
2036 | else {
|
---|
2037 | TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
---|
2038 | infoPtr->buttons =
|
---|
2039 | COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
|
---|
2040 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
2041 | nOldButtons * sizeof(TBUTTON_INFO));
|
---|
2042 | COMCTL32_Free (oldButtons);
|
---|
2043 | }
|
---|
2044 |
|
---|
2045 | infoPtr->nNumButtons = nNewButtons;
|
---|
2046 |
|
---|
2047 | /* insert new button data */
|
---|
2048 | for (nCount = 0; nCount < nAddButtons; nCount++) {
|
---|
2049 | TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
|
---|
2050 | btnPtr->iBitmap = lpTbb[nCount].iBitmap;
|
---|
2051 | btnPtr->idCommand = lpTbb[nCount].idCommand;
|
---|
2052 | btnPtr->fsState = lpTbb[nCount].fsState;
|
---|
2053 | btnPtr->fsStyle = lpTbb[nCount].fsStyle;
|
---|
2054 | btnPtr->dwData = lpTbb[nCount].dwData;
|
---|
2055 | btnPtr->iString = lpTbb[nCount].iString;
|
---|
2056 | btnPtr->bHot = FALSE;
|
---|
2057 |
|
---|
2058 | if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
|
---|
2059 | TTTOOLINFOA ti;
|
---|
2060 |
|
---|
2061 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
2062 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
2063 | ti.hwnd = hwnd;
|
---|
2064 | ti.uId = btnPtr->idCommand;
|
---|
2065 | ti.hinst = 0;
|
---|
2066 | ti.lpszText = LPSTR_TEXTCALLBACKA;
|
---|
2067 |
|
---|
2068 | SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
|
---|
2069 | 0, (LPARAM)&ti);
|
---|
2070 | }
|
---|
2071 | }
|
---|
2072 |
|
---|
2073 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2074 |
|
---|
2075 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
2076 |
|
---|
2077 | return TRUE;
|
---|
2078 | }
|
---|
2079 |
|
---|
2080 |
|
---|
2081 | static LRESULT
|
---|
2082 | TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2083 | {
|
---|
2084 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2085 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
2086 | INT nOldButtons, nNewButtons, nAddButtons, nCount;
|
---|
2087 |
|
---|
2088 | TRACE("adding %d buttons!\n", wParam);
|
---|
2089 |
|
---|
2090 | nAddButtons = (UINT)wParam;
|
---|
2091 | nOldButtons = infoPtr->nNumButtons;
|
---|
2092 | nNewButtons = nOldButtons + nAddButtons;
|
---|
2093 |
|
---|
2094 | if (infoPtr->nNumButtons == 0) {
|
---|
2095 | infoPtr->buttons =
|
---|
2096 | COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
|
---|
2097 | }
|
---|
2098 | else {
|
---|
2099 | TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
---|
2100 | infoPtr->buttons =
|
---|
2101 | COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
|
---|
2102 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
2103 | nOldButtons * sizeof(TBUTTON_INFO));
|
---|
2104 | COMCTL32_Free (oldButtons);
|
---|
2105 | }
|
---|
2106 |
|
---|
2107 | infoPtr->nNumButtons = nNewButtons;
|
---|
2108 |
|
---|
2109 | /* insert new button data */
|
---|
2110 | for (nCount = 0; nCount < nAddButtons; nCount++) {
|
---|
2111 | TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
|
---|
2112 | btnPtr->iBitmap = lpTbb[nCount].iBitmap;
|
---|
2113 | btnPtr->idCommand = lpTbb[nCount].idCommand;
|
---|
2114 | btnPtr->fsState = lpTbb[nCount].fsState;
|
---|
2115 | btnPtr->fsStyle = lpTbb[nCount].fsStyle;
|
---|
2116 | btnPtr->dwData = lpTbb[nCount].dwData;
|
---|
2117 | btnPtr->iString = lpTbb[nCount].iString;
|
---|
2118 | btnPtr->bHot = FALSE;
|
---|
2119 |
|
---|
2120 | if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
|
---|
2121 | TTTOOLINFOW ti;
|
---|
2122 |
|
---|
2123 | ZeroMemory (&ti, sizeof(TTTOOLINFOW));
|
---|
2124 | ti.cbSize = sizeof (TTTOOLINFOW);
|
---|
2125 | ti.hwnd = hwnd;
|
---|
2126 | ti.uId = btnPtr->idCommand;
|
---|
2127 | ti.hinst = 0;
|
---|
2128 | ti.lpszText = LPSTR_TEXTCALLBACKW;
|
---|
2129 |
|
---|
2130 | SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
|
---|
2131 | 0, (LPARAM)&ti);
|
---|
2132 | }
|
---|
2133 | }
|
---|
2134 |
|
---|
2135 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2136 |
|
---|
2137 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
2138 |
|
---|
2139 | return TRUE;
|
---|
2140 | }
|
---|
2141 |
|
---|
2142 |
|
---|
2143 | static LRESULT
|
---|
2144 | TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2145 | {
|
---|
2146 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2147 | INT nIndex;
|
---|
2148 |
|
---|
2149 | if ((wParam) && (HIWORD(lParam) == 0)) {
|
---|
2150 | char szString[256];
|
---|
2151 | INT len, lenW;
|
---|
2152 | TRACE("adding string from resource!\n");
|
---|
2153 |
|
---|
2154 | len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
|
---|
2155 | szString, 256);
|
---|
2156 |
|
---|
2157 | TRACE("len=%d \"%s\"\n", len, szString);
|
---|
2158 | nIndex = infoPtr->nNumStrings;
|
---|
2159 | if (infoPtr->nNumStrings == 0) {
|
---|
2160 | infoPtr->strings =
|
---|
2161 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
2162 | }
|
---|
2163 | else {
|
---|
2164 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
2165 | infoPtr->strings =
|
---|
2166 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
2167 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
2168 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
2169 | COMCTL32_Free (oldStrings);
|
---|
2170 | }
|
---|
2171 |
|
---|
2172 | lenW = MultiByteToWideChar( CP_ACP, 0, szString, -1, NULL, 0 );
|
---|
2173 | infoPtr->strings[infoPtr->nNumStrings] = COMCTL32_Alloc (sizeof(WCHAR)*lenW);
|
---|
2174 | MultiByteToWideChar( CP_ACP, 0, szString, -1,
|
---|
2175 | infoPtr->strings[infoPtr->nNumStrings], lenW );
|
---|
2176 | infoPtr->nNumStrings++;
|
---|
2177 | }
|
---|
2178 | else {
|
---|
2179 | LPSTR p = (LPSTR)lParam;
|
---|
2180 | INT len, lenW;
|
---|
2181 |
|
---|
2182 | if (p == NULL)
|
---|
2183 | return -1;
|
---|
2184 | TRACE("adding string(s) from array!\n");
|
---|
2185 |
|
---|
2186 | nIndex = infoPtr->nNumStrings;
|
---|
2187 | while (*p) {
|
---|
2188 | len = strlen (p);
|
---|
2189 | TRACE("len=%d \"%s\"\n", len, p);
|
---|
2190 |
|
---|
2191 | if (infoPtr->nNumStrings == 0) {
|
---|
2192 | infoPtr->strings =
|
---|
2193 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
2194 | }
|
---|
2195 | else {
|
---|
2196 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
2197 | infoPtr->strings =
|
---|
2198 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
2199 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
2200 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
2201 | COMCTL32_Free (oldStrings);
|
---|
2202 | }
|
---|
2203 |
|
---|
2204 | lenW = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 );
|
---|
2205 | infoPtr->strings[infoPtr->nNumStrings] = COMCTL32_Alloc (sizeof(WCHAR)*lenW);
|
---|
2206 | MultiByteToWideChar( CP_ACP, 0, p, -1,
|
---|
2207 | infoPtr->strings[infoPtr->nNumStrings], lenW );
|
---|
2208 | infoPtr->nNumStrings++;
|
---|
2209 |
|
---|
2210 | p += (len+1);
|
---|
2211 | }
|
---|
2212 | }
|
---|
2213 |
|
---|
2214 | return nIndex;
|
---|
2215 | }
|
---|
2216 |
|
---|
2217 |
|
---|
2218 | static LRESULT
|
---|
2219 | TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2220 | {
|
---|
2221 | #define MAX_RESOURCE_STRING_LENGTH 512
|
---|
2222 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2223 | INT nIndex;
|
---|
2224 |
|
---|
2225 | if ((wParam) && (HIWORD(lParam) == 0)) {
|
---|
2226 | WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
|
---|
2227 | INT len;
|
---|
2228 | TRACE("adding string from resource!\n");
|
---|
2229 |
|
---|
2230 | len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
|
---|
2231 | szString, MAX_RESOURCE_STRING_LENGTH);
|
---|
2232 |
|
---|
2233 | TRACE("len=%d %s\n", len, debugstr_w(szString));
|
---|
2234 | TRACE("First char: 0x%x\n", *szString);
|
---|
2235 | if (szString[0] == L'|')
|
---|
2236 | {
|
---|
2237 | PWSTR p = szString + 1;
|
---|
2238 |
|
---|
2239 | nIndex = infoPtr->nNumStrings;
|
---|
2240 | while (*p != L'|') {
|
---|
2241 |
|
---|
2242 | if (infoPtr->nNumStrings == 0) {
|
---|
2243 | infoPtr->strings =
|
---|
2244 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
2245 | }
|
---|
2246 | else {
|
---|
2247 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
2248 | infoPtr->strings =
|
---|
2249 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
2250 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
2251 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
2252 | COMCTL32_Free (oldStrings);
|
---|
2253 | }
|
---|
2254 |
|
---|
2255 | len = COMCTL32_StrChrW (p, L'|') - p;
|
---|
2256 | TRACE("len=%d %s\n", len, debugstr_w(p));
|
---|
2257 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
2258 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
2259 | lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len);
|
---|
2260 | infoPtr->nNumStrings++;
|
---|
2261 |
|
---|
2262 | p += (len+1);
|
---|
2263 | }
|
---|
2264 | }
|
---|
2265 | else
|
---|
2266 | {
|
---|
2267 | nIndex = infoPtr->nNumStrings;
|
---|
2268 | if (infoPtr->nNumStrings == 0) {
|
---|
2269 | infoPtr->strings =
|
---|
2270 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
2271 | }
|
---|
2272 | else {
|
---|
2273 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
2274 | infoPtr->strings =
|
---|
2275 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
2276 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
2277 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
2278 | COMCTL32_Free (oldStrings);
|
---|
2279 | }
|
---|
2280 |
|
---|
2281 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
2282 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
2283 | strcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
|
---|
2284 | infoPtr->nNumStrings++;
|
---|
2285 | }
|
---|
2286 | }
|
---|
2287 | else {
|
---|
2288 | LPWSTR p = (LPWSTR)lParam;
|
---|
2289 | INT len;
|
---|
2290 |
|
---|
2291 | if (p == NULL)
|
---|
2292 | return -1;
|
---|
2293 | TRACE("adding string(s) from array!\n");
|
---|
2294 | nIndex = infoPtr->nNumStrings;
|
---|
2295 | while (*p) {
|
---|
2296 | len = strlenW (p);
|
---|
2297 |
|
---|
2298 | TRACE("len=%d %s\n", len, debugstr_w(p));
|
---|
2299 | if (infoPtr->nNumStrings == 0) {
|
---|
2300 | infoPtr->strings =
|
---|
2301 | COMCTL32_Alloc (sizeof(LPWSTR));
|
---|
2302 | }
|
---|
2303 | else {
|
---|
2304 | LPWSTR *oldStrings = infoPtr->strings;
|
---|
2305 | infoPtr->strings =
|
---|
2306 | COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
|
---|
2307 | memcpy (&infoPtr->strings[0], &oldStrings[0],
|
---|
2308 | sizeof(LPWSTR) * infoPtr->nNumStrings);
|
---|
2309 | COMCTL32_Free (oldStrings);
|
---|
2310 | }
|
---|
2311 |
|
---|
2312 | infoPtr->strings[infoPtr->nNumStrings] =
|
---|
2313 | COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
|
---|
2314 | strcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
|
---|
2315 | infoPtr->nNumStrings++;
|
---|
2316 |
|
---|
2317 | p += (len+1);
|
---|
2318 | }
|
---|
2319 | }
|
---|
2320 |
|
---|
2321 | return nIndex;
|
---|
2322 | }
|
---|
2323 |
|
---|
2324 |
|
---|
2325 | static LRESULT
|
---|
2326 | TOOLBAR_AutoSize (HWND hwnd)
|
---|
2327 | {
|
---|
2328 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2329 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
2330 | RECT parent_rect;
|
---|
2331 | RECT window_rect;
|
---|
2332 | HWND parent;
|
---|
2333 | INT x, y;
|
---|
2334 | INT cx, cy;
|
---|
2335 | UINT uPosFlags = SWP_NOZORDER;
|
---|
2336 |
|
---|
2337 | TRACE("resize forced, style=%lx!\n", dwStyle);
|
---|
2338 |
|
---|
2339 | parent = GetParent (hwnd);
|
---|
2340 | GetClientRect(parent, &parent_rect);
|
---|
2341 |
|
---|
2342 | x = parent_rect.left;
|
---|
2343 | y = parent_rect.top;
|
---|
2344 |
|
---|
2345 | /* FIXME: we should be able to early out if nothing */
|
---|
2346 | /* has changed with nWidth != parent_rect width */
|
---|
2347 |
|
---|
2348 | if (dwStyle & CCS_NORESIZE) {
|
---|
2349 | uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
---|
2350 | cx = 0;
|
---|
2351 | cy = 0;
|
---|
2352 | }
|
---|
2353 | else {
|
---|
2354 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
---|
2355 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2356 | InvalidateRect( hwnd, NULL, TRUE );
|
---|
2357 | cy = infoPtr->nHeight;
|
---|
2358 | cx = infoPtr->nWidth;
|
---|
2359 |
|
---|
2360 | if (dwStyle & CCS_NOMOVEY) {
|
---|
2361 | GetWindowRect(hwnd, &window_rect);
|
---|
2362 | ScreenToClient(parent, (LPPOINT)&window_rect.left);
|
---|
2363 | y = window_rect.top;
|
---|
2364 | }
|
---|
2365 | }
|
---|
2366 |
|
---|
2367 | if (dwStyle & CCS_NOPARENTALIGN)
|
---|
2368 | uPosFlags |= SWP_NOMOVE;
|
---|
2369 |
|
---|
2370 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
2371 | cy += GetSystemMetrics(SM_CYEDGE);
|
---|
2372 |
|
---|
2373 | if (dwStyle & WS_BORDER)
|
---|
2374 | {
|
---|
2375 | x = y = 1;
|
---|
2376 | cy += GetSystemMetrics(SM_CYEDGE);
|
---|
2377 | cx += GetSystemMetrics(SM_CYEDGE);
|
---|
2378 | }
|
---|
2379 |
|
---|
2380 | infoPtr->bAutoSize = TRUE;
|
---|
2381 | SetWindowPos (hwnd, HWND_TOP, parent_rect.left - x, parent_rect.top - y,
|
---|
2382 | cx, cy, uPosFlags);
|
---|
2383 | /* The following line makes sure that the infoPtr->bAutoSize is turned off after
|
---|
2384 | * the setwindowpos calls */
|
---|
2385 | infoPtr->bAutoSize = FALSE;
|
---|
2386 |
|
---|
2387 | return 0;
|
---|
2388 | }
|
---|
2389 |
|
---|
2390 |
|
---|
2391 | static LRESULT
|
---|
2392 | TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2393 | {
|
---|
2394 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2395 |
|
---|
2396 | return infoPtr->nNumButtons;
|
---|
2397 | }
|
---|
2398 |
|
---|
2399 |
|
---|
2400 | static LRESULT
|
---|
2401 | TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2402 | {
|
---|
2403 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2404 |
|
---|
2405 | if (infoPtr == NULL) {
|
---|
2406 | ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
|
---|
2407 | ERR("infoPtr == NULL!\n");
|
---|
2408 | return 0;
|
---|
2409 | }
|
---|
2410 |
|
---|
2411 | infoPtr->dwStructSize = (DWORD)wParam;
|
---|
2412 |
|
---|
2413 | return 0;
|
---|
2414 | }
|
---|
2415 |
|
---|
2416 |
|
---|
2417 | static LRESULT
|
---|
2418 | TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2419 | {
|
---|
2420 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2421 | TBUTTON_INFO *btnPtr;
|
---|
2422 | INT nIndex;
|
---|
2423 |
|
---|
2424 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2425 | if (nIndex == -1)
|
---|
2426 | return FALSE;
|
---|
2427 |
|
---|
2428 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2429 | btnPtr->iBitmap = LOWORD(lParam);
|
---|
2430 |
|
---|
2431 | /* we HAVE to erase the background, the new bitmap could be */
|
---|
2432 | /* transparent */
|
---|
2433 | InvalidateRect(hwnd, &btnPtr->rect, TRUE);
|
---|
2434 |
|
---|
2435 | return TRUE;
|
---|
2436 | }
|
---|
2437 |
|
---|
2438 |
|
---|
2439 | static LRESULT
|
---|
2440 | TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2441 | {
|
---|
2442 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2443 | TBUTTON_INFO *btnPtr;
|
---|
2444 | INT nIndex;
|
---|
2445 | INT nOldIndex = -1;
|
---|
2446 | BOOL bChecked = FALSE;
|
---|
2447 |
|
---|
2448 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2449 | if (nIndex == -1)
|
---|
2450 | return FALSE;
|
---|
2451 |
|
---|
2452 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2453 |
|
---|
2454 | if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
|
---|
2455 | return FALSE;
|
---|
2456 |
|
---|
2457 | bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
|
---|
2458 |
|
---|
2459 | if (LOWORD(lParam) == FALSE)
|
---|
2460 | btnPtr->fsState &= ~TBSTATE_CHECKED;
|
---|
2461 | else {
|
---|
2462 | if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
---|
2463 | nOldIndex =
|
---|
2464 | TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
|
---|
2465 | if (nOldIndex == nIndex)
|
---|
2466 | return 0;
|
---|
2467 | if (nOldIndex != -1)
|
---|
2468 | infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
---|
2469 | }
|
---|
2470 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
2471 | }
|
---|
2472 |
|
---|
2473 | if( bChecked != LOWORD(lParam) )
|
---|
2474 | {
|
---|
2475 | if (nOldIndex != -1)
|
---|
2476 | {
|
---|
2477 | InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
|
---|
2478 | TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
|
---|
2479 | }
|
---|
2480 | InvalidateRect(hwnd, &btnPtr->rect, TRUE);
|
---|
2481 | }
|
---|
2482 |
|
---|
2483 | /* FIXME: Send a WM_NOTIFY?? */
|
---|
2484 |
|
---|
2485 | return TRUE;
|
---|
2486 | }
|
---|
2487 |
|
---|
2488 |
|
---|
2489 | static LRESULT
|
---|
2490 | TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2491 | {
|
---|
2492 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2493 |
|
---|
2494 | return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2495 | }
|
---|
2496 |
|
---|
2497 |
|
---|
2498 | static LRESULT
|
---|
2499 | TOOLBAR_Customize (HWND hwnd)
|
---|
2500 | {
|
---|
2501 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2502 | CUSTDLG_INFO custInfo;
|
---|
2503 | LRESULT ret;
|
---|
2504 | LPCVOID template;
|
---|
2505 | HRSRC hRes;
|
---|
2506 | NMHDR nmhdr;
|
---|
2507 |
|
---|
2508 | custInfo.tbInfo = infoPtr;
|
---|
2509 | custInfo.tbHwnd = hwnd;
|
---|
2510 |
|
---|
2511 | /* send TBN_BEGINADJUST notification */
|
---|
2512 | TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
|
---|
2513 | TBN_BEGINADJUST);
|
---|
2514 |
|
---|
2515 | if (!(hRes = FindResourceA (COMCTL32_hModule,
|
---|
2516 | MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
|
---|
2517 | RT_DIALOGA)))
|
---|
2518 | return FALSE;
|
---|
2519 |
|
---|
2520 | if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
|
---|
2521 | return FALSE;
|
---|
2522 |
|
---|
2523 | ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
|
---|
2524 | (LPDLGTEMPLATEA)template,
|
---|
2525 | hwnd,
|
---|
2526 | (DLGPROC)TOOLBAR_CustomizeDialogProc,
|
---|
2527 | (LPARAM)&custInfo);
|
---|
2528 |
|
---|
2529 | /* send TBN_ENDADJUST notification */
|
---|
2530 | TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
|
---|
2531 | TBN_ENDADJUST);
|
---|
2532 |
|
---|
2533 | return ret;
|
---|
2534 | }
|
---|
2535 |
|
---|
2536 |
|
---|
2537 | static LRESULT
|
---|
2538 | TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2539 | {
|
---|
2540 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2541 | INT nIndex = (INT)wParam;
|
---|
2542 |
|
---|
2543 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
2544 | return FALSE;
|
---|
2545 |
|
---|
2546 | if ((infoPtr->hwndToolTip) &&
|
---|
2547 | !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
|
---|
2548 | TTTOOLINFOA ti;
|
---|
2549 |
|
---|
2550 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
2551 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
2552 | ti.hwnd = hwnd;
|
---|
2553 | ti.uId = infoPtr->buttons[nIndex].idCommand;
|
---|
2554 |
|
---|
2555 | SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
|
---|
2556 | }
|
---|
2557 |
|
---|
2558 | if (infoPtr->nNumButtons == 1) {
|
---|
2559 | TRACE(" simple delete!\n");
|
---|
2560 | COMCTL32_Free (infoPtr->buttons);
|
---|
2561 | infoPtr->buttons = NULL;
|
---|
2562 | infoPtr->nNumButtons = 0;
|
---|
2563 | }
|
---|
2564 | else {
|
---|
2565 | TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
---|
2566 | TRACE("complex delete! [nIndex=%d]\n", nIndex);
|
---|
2567 |
|
---|
2568 | infoPtr->nNumButtons--;
|
---|
2569 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
---|
2570 | if (nIndex > 0) {
|
---|
2571 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
2572 | nIndex * sizeof(TBUTTON_INFO));
|
---|
2573 | }
|
---|
2574 |
|
---|
2575 | if (nIndex < infoPtr->nNumButtons) {
|
---|
2576 | memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
|
---|
2577 | (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
|
---|
2578 | }
|
---|
2579 |
|
---|
2580 | COMCTL32_Free (oldButtons);
|
---|
2581 | }
|
---|
2582 |
|
---|
2583 | TOOLBAR_CalcToolbar (hwnd);
|
---|
2584 |
|
---|
2585 | InvalidateRect (hwnd, NULL, TRUE);
|
---|
2586 |
|
---|
2587 | return TRUE;
|
---|
2588 | }
|
---|
2589 |
|
---|
2590 |
|
---|
2591 | static LRESULT
|
---|
2592 | TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2593 | {
|
---|
2594 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2595 | TBUTTON_INFO *btnPtr;
|
---|
2596 | INT nIndex;
|
---|
2597 | DWORD bState;
|
---|
2598 |
|
---|
2599 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2600 | if (nIndex == -1)
|
---|
2601 | return FALSE;
|
---|
2602 |
|
---|
2603 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2604 |
|
---|
2605 | bState = btnPtr->fsState & TBSTATE_ENABLED;
|
---|
2606 |
|
---|
2607 | /* update the toolbar button state */
|
---|
2608 | if(LOWORD(lParam) == FALSE) {
|
---|
2609 | btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
|
---|
2610 | } else {
|
---|
2611 | btnPtr->fsState |= TBSTATE_ENABLED;
|
---|
2612 | }
|
---|
2613 |
|
---|
2614 | /* redraw the button only if the state of the button changed */
|
---|
2615 | if(bState != (btnPtr->fsState & TBSTATE_ENABLED))
|
---|
2616 | {
|
---|
2617 | InvalidateRect(hwnd, &btnPtr->rect,
|
---|
2618 | TOOLBAR_HasText(infoPtr, btnPtr));
|
---|
2619 | }
|
---|
2620 |
|
---|
2621 | return TRUE;
|
---|
2622 | }
|
---|
2623 |
|
---|
2624 |
|
---|
2625 | static inline LRESULT
|
---|
2626 | TOOLBAR_GetAnchorHighlight (HWND hwnd)
|
---|
2627 | {
|
---|
2628 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2629 |
|
---|
2630 | return infoPtr->bAnchor;
|
---|
2631 | }
|
---|
2632 |
|
---|
2633 |
|
---|
2634 | static LRESULT
|
---|
2635 | TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2636 | {
|
---|
2637 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2638 | INT nIndex;
|
---|
2639 |
|
---|
2640 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2641 | if (nIndex == -1)
|
---|
2642 | return -1;
|
---|
2643 |
|
---|
2644 | return infoPtr->buttons[nIndex].iBitmap;
|
---|
2645 | }
|
---|
2646 |
|
---|
2647 |
|
---|
2648 | static inline LRESULT
|
---|
2649 | TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2650 | {
|
---|
2651 | return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
|
---|
2652 | }
|
---|
2653 |
|
---|
2654 |
|
---|
2655 | static LRESULT
|
---|
2656 | TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2657 | {
|
---|
2658 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2659 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
2660 | INT nIndex = (INT)wParam;
|
---|
2661 | TBUTTON_INFO *btnPtr;
|
---|
2662 |
|
---|
2663 | if (infoPtr == NULL)
|
---|
2664 | return FALSE;
|
---|
2665 |
|
---|
2666 | if (lpTbb == NULL)
|
---|
2667 | return FALSE;
|
---|
2668 |
|
---|
2669 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
2670 | return FALSE;
|
---|
2671 |
|
---|
2672 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2673 | lpTbb->iBitmap = btnPtr->iBitmap;
|
---|
2674 | lpTbb->idCommand = btnPtr->idCommand;
|
---|
2675 | lpTbb->fsState = btnPtr->fsState;
|
---|
2676 | lpTbb->fsStyle = btnPtr->fsStyle;
|
---|
2677 | lpTbb->dwData = btnPtr->dwData;
|
---|
2678 | lpTbb->iString = btnPtr->iString;
|
---|
2679 |
|
---|
2680 | return TRUE;
|
---|
2681 | }
|
---|
2682 |
|
---|
2683 |
|
---|
2684 | static LRESULT
|
---|
2685 | TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2686 | {
|
---|
2687 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2688 | LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
|
---|
2689 | TBUTTON_INFO *btnPtr;
|
---|
2690 | INT nIndex;
|
---|
2691 |
|
---|
2692 | if (infoPtr == NULL)
|
---|
2693 | return -1;
|
---|
2694 | if (lpTbInfo == NULL)
|
---|
2695 | return -1;
|
---|
2696 | if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
|
---|
2697 | return -1;
|
---|
2698 |
|
---|
2699 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2700 | if (nIndex == -1)
|
---|
2701 | return -1;
|
---|
2702 |
|
---|
2703 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2704 |
|
---|
2705 | if (lpTbInfo->dwMask & TBIF_COMMAND)
|
---|
2706 | lpTbInfo->idCommand = btnPtr->idCommand;
|
---|
2707 | if (lpTbInfo->dwMask & TBIF_IMAGE)
|
---|
2708 | lpTbInfo->iImage = btnPtr->iBitmap;
|
---|
2709 | if (lpTbInfo->dwMask & TBIF_LPARAM)
|
---|
2710 | lpTbInfo->lParam = btnPtr->dwData;
|
---|
2711 | if (lpTbInfo->dwMask & TBIF_SIZE)
|
---|
2712 | lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
|
---|
2713 | if (lpTbInfo->dwMask & TBIF_STATE)
|
---|
2714 | lpTbInfo->fsState = btnPtr->fsState;
|
---|
2715 | if (lpTbInfo->dwMask & TBIF_STYLE)
|
---|
2716 | lpTbInfo->fsStyle = btnPtr->fsStyle;
|
---|
2717 | if (lpTbInfo->dwMask & TBIF_TEXT) {
|
---|
2718 | if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
|
---|
2719 | {
|
---|
2720 | if (!WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[btnPtr->iString], -1,
|
---|
2721 | lpTbInfo->pszText, lpTbInfo->cchText, NULL, NULL ))
|
---|
2722 | lpTbInfo->pszText[lpTbInfo->cchText-1] = 0;
|
---|
2723 | }
|
---|
2724 | else lpTbInfo->pszText[0]=0;
|
---|
2725 | }
|
---|
2726 | return nIndex;
|
---|
2727 | }
|
---|
2728 |
|
---|
2729 |
|
---|
2730 | static LRESULT
|
---|
2731 | TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2732 | {
|
---|
2733 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2734 | LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
|
---|
2735 | TBUTTON_INFO *btnPtr;
|
---|
2736 | INT nIndex;
|
---|
2737 |
|
---|
2738 | if (infoPtr == NULL)
|
---|
2739 | return -1;
|
---|
2740 | if (lpTbInfo == NULL)
|
---|
2741 | return -1;
|
---|
2742 | if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
|
---|
2743 | return -1;
|
---|
2744 |
|
---|
2745 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2746 | if (nIndex == -1)
|
---|
2747 | return -1;
|
---|
2748 |
|
---|
2749 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2750 |
|
---|
2751 | if (lpTbInfo->dwMask & TBIF_COMMAND)
|
---|
2752 | lpTbInfo->idCommand = btnPtr->idCommand;
|
---|
2753 | if (lpTbInfo->dwMask & TBIF_IMAGE)
|
---|
2754 | lpTbInfo->iImage = btnPtr->iBitmap;
|
---|
2755 | if (lpTbInfo->dwMask & TBIF_LPARAM)
|
---|
2756 | lpTbInfo->lParam = btnPtr->dwData;
|
---|
2757 | if (lpTbInfo->dwMask & TBIF_SIZE)
|
---|
2758 | lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
|
---|
2759 | if (lpTbInfo->dwMask & TBIF_STATE)
|
---|
2760 | lpTbInfo->fsState = btnPtr->fsState;
|
---|
2761 | if (lpTbInfo->dwMask & TBIF_STYLE)
|
---|
2762 | lpTbInfo->fsStyle = btnPtr->fsStyle;
|
---|
2763 | if (lpTbInfo->dwMask & TBIF_TEXT) {
|
---|
2764 | if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
|
---|
2765 | lstrcpynW (lpTbInfo->pszText,
|
---|
2766 | (LPWSTR)infoPtr->strings[btnPtr->iString],
|
---|
2767 | lpTbInfo->cchText);
|
---|
2768 | }
|
---|
2769 |
|
---|
2770 | return nIndex;
|
---|
2771 | }
|
---|
2772 |
|
---|
2773 |
|
---|
2774 | static LRESULT
|
---|
2775 | TOOLBAR_GetButtonSize (HWND hwnd)
|
---|
2776 | {
|
---|
2777 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2778 |
|
---|
2779 | if (infoPtr->nNumButtons > 0)
|
---|
2780 | return MAKELONG((WORD)infoPtr->nButtonWidth,
|
---|
2781 | (WORD)infoPtr->nButtonHeight);
|
---|
2782 | else
|
---|
2783 | return MAKELONG(8,7);
|
---|
2784 | }
|
---|
2785 |
|
---|
2786 |
|
---|
2787 | static LRESULT
|
---|
2788 | TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2789 | {
|
---|
2790 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2791 | INT nIndex, nStringIndex;
|
---|
2792 |
|
---|
2793 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2794 | if (nIndex == -1)
|
---|
2795 | return -1;
|
---|
2796 |
|
---|
2797 | nStringIndex = infoPtr->buttons[nIndex].iString;
|
---|
2798 |
|
---|
2799 | TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
|
---|
2800 |
|
---|
2801 | if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
|
---|
2802 | return -1;
|
---|
2803 |
|
---|
2804 | if (lParam == 0)
|
---|
2805 | return -1;
|
---|
2806 |
|
---|
2807 | return WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[nStringIndex], -1,
|
---|
2808 | (LPSTR)lParam, 0x7fffffff, NULL, NULL ) - 1;
|
---|
2809 | }
|
---|
2810 |
|
---|
2811 |
|
---|
2812 | static LRESULT
|
---|
2813 | TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2814 | {
|
---|
2815 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2816 | INT nIndex, nStringIndex;
|
---|
2817 |
|
---|
2818 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2819 | if (nIndex == -1)
|
---|
2820 | return -1;
|
---|
2821 |
|
---|
2822 | nStringIndex = infoPtr->buttons[nIndex].iString;
|
---|
2823 |
|
---|
2824 | TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
|
---|
2825 |
|
---|
2826 | if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
|
---|
2827 | return -1;
|
---|
2828 |
|
---|
2829 | if (lParam == 0)
|
---|
2830 | return -1;
|
---|
2831 |
|
---|
2832 | strcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
|
---|
2833 |
|
---|
2834 | return strlenW ((LPWSTR)infoPtr->strings[nStringIndex]);
|
---|
2835 | }
|
---|
2836 |
|
---|
2837 |
|
---|
2838 | /* << TOOLBAR_GetColorScheme >> */
|
---|
2839 |
|
---|
2840 |
|
---|
2841 | static LRESULT
|
---|
2842 | TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2843 | {
|
---|
2844 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2845 |
|
---|
2846 | return (LRESULT)infoPtr->himlDis;
|
---|
2847 | }
|
---|
2848 |
|
---|
2849 |
|
---|
2850 | inline static LRESULT
|
---|
2851 | TOOLBAR_GetExtendedStyle (HWND hwnd)
|
---|
2852 | {
|
---|
2853 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2854 |
|
---|
2855 | return infoPtr->dwExStyle;
|
---|
2856 | }
|
---|
2857 |
|
---|
2858 |
|
---|
2859 | static LRESULT
|
---|
2860 | TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2861 | {
|
---|
2862 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2863 |
|
---|
2864 | return (LRESULT)infoPtr->himlHot;
|
---|
2865 | }
|
---|
2866 |
|
---|
2867 |
|
---|
2868 | static LRESULT
|
---|
2869 | TOOLBAR_GetHotItem (HWND hwnd)
|
---|
2870 | {
|
---|
2871 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2872 |
|
---|
2873 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
|
---|
2874 | return -1;
|
---|
2875 |
|
---|
2876 | if (infoPtr->nHotItem < 0)
|
---|
2877 | return -1;
|
---|
2878 |
|
---|
2879 | return (LRESULT)infoPtr->nHotItem;
|
---|
2880 | }
|
---|
2881 |
|
---|
2882 |
|
---|
2883 | static LRESULT
|
---|
2884 | TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2885 | {
|
---|
2886 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2887 |
|
---|
2888 | return (LRESULT)infoPtr->himlDef;
|
---|
2889 | }
|
---|
2890 |
|
---|
2891 |
|
---|
2892 | /* << TOOLBAR_GetInsertMark >> */
|
---|
2893 | /* << TOOLBAR_GetInsertMarkColor >> */
|
---|
2894 |
|
---|
2895 |
|
---|
2896 | static LRESULT
|
---|
2897 | TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2898 | {
|
---|
2899 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2900 | TBUTTON_INFO *btnPtr;
|
---|
2901 | LPRECT lpRect;
|
---|
2902 | INT nIndex;
|
---|
2903 |
|
---|
2904 | if (infoPtr == NULL)
|
---|
2905 | return FALSE;
|
---|
2906 | nIndex = (INT)wParam;
|
---|
2907 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2908 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
2909 | return FALSE;
|
---|
2910 | lpRect = (LPRECT)lParam;
|
---|
2911 | if (lpRect == NULL)
|
---|
2912 | return FALSE;
|
---|
2913 | if (btnPtr->fsState & TBSTATE_HIDDEN)
|
---|
2914 | return FALSE;
|
---|
2915 |
|
---|
2916 | lpRect->left = btnPtr->rect.left;
|
---|
2917 | lpRect->right = btnPtr->rect.right;
|
---|
2918 | lpRect->bottom = btnPtr->rect.bottom;
|
---|
2919 | lpRect->top = btnPtr->rect.top;
|
---|
2920 |
|
---|
2921 | return TRUE;
|
---|
2922 | }
|
---|
2923 |
|
---|
2924 |
|
---|
2925 | static LRESULT
|
---|
2926 | TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2927 | {
|
---|
2928 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2929 | LPSIZE lpSize = (LPSIZE)lParam;
|
---|
2930 |
|
---|
2931 | if (lpSize == NULL)
|
---|
2932 | return FALSE;
|
---|
2933 |
|
---|
2934 | lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
|
---|
2935 | lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
|
---|
2936 |
|
---|
2937 | TRACE("maximum size %d x %d\n",
|
---|
2938 | infoPtr->rcBound.right - infoPtr->rcBound.left,
|
---|
2939 | infoPtr->rcBound.bottom - infoPtr->rcBound.top);
|
---|
2940 |
|
---|
2941 | return TRUE;
|
---|
2942 | }
|
---|
2943 |
|
---|
2944 |
|
---|
2945 | /* << TOOLBAR_GetObject >> */
|
---|
2946 | /* << TOOLBAR_GetPadding >> */
|
---|
2947 |
|
---|
2948 |
|
---|
2949 | static LRESULT
|
---|
2950 | TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2951 | {
|
---|
2952 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2953 | TBUTTON_INFO *btnPtr;
|
---|
2954 | LPRECT lpRect;
|
---|
2955 | INT nIndex;
|
---|
2956 |
|
---|
2957 | if (infoPtr == NULL)
|
---|
2958 | return FALSE;
|
---|
2959 | nIndex = (INT)wParam;
|
---|
2960 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
2961 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
2962 | return FALSE;
|
---|
2963 | lpRect = (LPRECT)lParam;
|
---|
2964 | if (lpRect == NULL)
|
---|
2965 | return FALSE;
|
---|
2966 |
|
---|
2967 | lpRect->left = btnPtr->rect.left;
|
---|
2968 | lpRect->right = btnPtr->rect.right;
|
---|
2969 | lpRect->bottom = btnPtr->rect.bottom;
|
---|
2970 | lpRect->top = btnPtr->rect.top;
|
---|
2971 |
|
---|
2972 | return TRUE;
|
---|
2973 | }
|
---|
2974 |
|
---|
2975 |
|
---|
2976 | static LRESULT
|
---|
2977 | TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2978 | {
|
---|
2979 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2980 |
|
---|
2981 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
|
---|
2982 | return infoPtr->nRows;
|
---|
2983 | else
|
---|
2984 | return 1;
|
---|
2985 | }
|
---|
2986 |
|
---|
2987 |
|
---|
2988 | static LRESULT
|
---|
2989 | TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
2990 | {
|
---|
2991 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
2992 | INT nIndex;
|
---|
2993 |
|
---|
2994 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
2995 | if (nIndex == -1)
|
---|
2996 | return -1;
|
---|
2997 |
|
---|
2998 | return infoPtr->buttons[nIndex].fsState;
|
---|
2999 | }
|
---|
3000 |
|
---|
3001 |
|
---|
3002 | static LRESULT
|
---|
3003 | TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3004 | {
|
---|
3005 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3006 | INT nIndex;
|
---|
3007 |
|
---|
3008 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3009 | if (nIndex == -1)
|
---|
3010 | return -1;
|
---|
3011 |
|
---|
3012 | return infoPtr->buttons[nIndex].fsStyle;
|
---|
3013 | }
|
---|
3014 |
|
---|
3015 |
|
---|
3016 | static LRESULT
|
---|
3017 | TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3018 | {
|
---|
3019 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3020 |
|
---|
3021 | if (infoPtr == NULL)
|
---|
3022 | return 0;
|
---|
3023 |
|
---|
3024 | return infoPtr->nMaxTextRows;
|
---|
3025 | }
|
---|
3026 |
|
---|
3027 |
|
---|
3028 | static LRESULT
|
---|
3029 | TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3030 | {
|
---|
3031 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3032 |
|
---|
3033 | if (infoPtr == NULL)
|
---|
3034 | return 0;
|
---|
3035 | return infoPtr->hwndToolTip;
|
---|
3036 | }
|
---|
3037 |
|
---|
3038 |
|
---|
3039 | static LRESULT
|
---|
3040 | TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3041 | {
|
---|
3042 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3043 |
|
---|
3044 | TRACE("%s hwnd=0x%x stub!\n",
|
---|
3045 | infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
|
---|
3046 |
|
---|
3047 | return infoPtr->bUnicode;
|
---|
3048 | }
|
---|
3049 |
|
---|
3050 |
|
---|
3051 | inline static LRESULT
|
---|
3052 | TOOLBAR_GetVersion (HWND hwnd)
|
---|
3053 | {
|
---|
3054 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3055 | return infoPtr->iVersion;
|
---|
3056 | }
|
---|
3057 |
|
---|
3058 |
|
---|
3059 | static LRESULT
|
---|
3060 | TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3061 | {
|
---|
3062 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3063 | TBUTTON_INFO *btnPtr;
|
---|
3064 | INT nIndex;
|
---|
3065 |
|
---|
3066 | TRACE("\n");
|
---|
3067 |
|
---|
3068 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3069 | if (nIndex == -1)
|
---|
3070 | return FALSE;
|
---|
3071 |
|
---|
3072 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
3073 | if (LOWORD(lParam) == FALSE)
|
---|
3074 | btnPtr->fsState &= ~TBSTATE_HIDDEN;
|
---|
3075 | else
|
---|
3076 | btnPtr->fsState |= TBSTATE_HIDDEN;
|
---|
3077 |
|
---|
3078 | TOOLBAR_CalcToolbar (hwnd);
|
---|
3079 |
|
---|
3080 | InvalidateRect (hwnd, NULL, TRUE);
|
---|
3081 |
|
---|
3082 | return TRUE;
|
---|
3083 | }
|
---|
3084 |
|
---|
3085 |
|
---|
3086 | inline static LRESULT
|
---|
3087 | TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3088 | {
|
---|
3089 | return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
|
---|
3090 | }
|
---|
3091 |
|
---|
3092 |
|
---|
3093 | static LRESULT
|
---|
3094 | TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3095 | {
|
---|
3096 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3097 | TBUTTON_INFO *btnPtr;
|
---|
3098 | INT nIndex;
|
---|
3099 |
|
---|
3100 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3101 | if (nIndex == -1)
|
---|
3102 | return FALSE;
|
---|
3103 |
|
---|
3104 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
3105 | if (LOWORD(lParam) == FALSE)
|
---|
3106 | btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
|
---|
3107 | else
|
---|
3108 | btnPtr->fsState |= TBSTATE_INDETERMINATE;
|
---|
3109 |
|
---|
3110 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
|
---|
3111 |
|
---|
3112 | return TRUE;
|
---|
3113 | }
|
---|
3114 |
|
---|
3115 |
|
---|
3116 | static LRESULT
|
---|
3117 | TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3118 | {
|
---|
3119 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3120 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
3121 | INT nIndex = (INT)wParam;
|
---|
3122 | TBUTTON_INFO *oldButtons;
|
---|
3123 |
|
---|
3124 | if (lpTbb == NULL)
|
---|
3125 | return FALSE;
|
---|
3126 |
|
---|
3127 | TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
|
---|
3128 |
|
---|
3129 | if (nIndex == -1) {
|
---|
3130 | /* EPP: this seems to be an undocumented call (from my IE4)
|
---|
3131 | * I assume in that case that:
|
---|
3132 | * - lpTbb->iString is a string pointer (not a string index in strings[] table
|
---|
3133 | * - index of insertion is at the end of existing buttons
|
---|
3134 | * I only see this happen with nIndex == -1, but it could have a special
|
---|
3135 | * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
|
---|
3136 | */
|
---|
3137 | int len;
|
---|
3138 | LPSTR ptr;
|
---|
3139 |
|
---|
3140 | /* FIXME: iString == -1 is undocumented */
|
---|
3141 | if(lpTbb->iString && lpTbb->iString!=-1) {
|
---|
3142 | len = strlen((char*)lpTbb->iString) + 2;
|
---|
3143 | ptr = COMCTL32_Alloc(len);
|
---|
3144 | nIndex = infoPtr->nNumButtons;
|
---|
3145 | strcpy(ptr, (char*)lpTbb->iString);
|
---|
3146 | ptr[len - 1] = 0; /* ended by two '\0' */
|
---|
3147 | lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
|
---|
3148 | COMCTL32_Free(ptr);
|
---|
3149 | }
|
---|
3150 | else {
|
---|
3151 | ERR("lpTbb->iString is NULL\n");
|
---|
3152 | return FALSE;
|
---|
3153 | }
|
---|
3154 |
|
---|
3155 | } else if (nIndex < 0)
|
---|
3156 | return FALSE;
|
---|
3157 |
|
---|
3158 | TRACE("inserting button index=%d\n", nIndex);
|
---|
3159 | if (nIndex > infoPtr->nNumButtons) {
|
---|
3160 | nIndex = infoPtr->nNumButtons;
|
---|
3161 | TRACE("adjust index=%d\n", nIndex);
|
---|
3162 | }
|
---|
3163 |
|
---|
3164 | oldButtons = infoPtr->buttons;
|
---|
3165 | infoPtr->nNumButtons++;
|
---|
3166 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
---|
3167 | /* pre insert copy */
|
---|
3168 | if (nIndex > 0) {
|
---|
3169 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
3170 | nIndex * sizeof(TBUTTON_INFO));
|
---|
3171 | }
|
---|
3172 |
|
---|
3173 | /* insert new button */
|
---|
3174 | infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
|
---|
3175 | infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
|
---|
3176 | infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
|
---|
3177 | infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
|
---|
3178 | infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
|
---|
3179 | infoPtr->buttons[nIndex].iString = lpTbb->iString;
|
---|
3180 |
|
---|
3181 | if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
|
---|
3182 | TTTOOLINFOA ti;
|
---|
3183 |
|
---|
3184 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
3185 | ti.cbSize = sizeof (TTTOOLINFOA);
|
---|
3186 | ti.hwnd = hwnd;
|
---|
3187 | ti.uId = lpTbb->idCommand;
|
---|
3188 | ti.hinst = 0;
|
---|
3189 | ti.lpszText = LPSTR_TEXTCALLBACKA;
|
---|
3190 |
|
---|
3191 | SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
|
---|
3192 | 0, (LPARAM)&ti);
|
---|
3193 | }
|
---|
3194 |
|
---|
3195 | /* post insert copy */
|
---|
3196 | if (nIndex < infoPtr->nNumButtons - 1) {
|
---|
3197 | memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
|
---|
3198 | (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
|
---|
3199 | }
|
---|
3200 |
|
---|
3201 | COMCTL32_Free (oldButtons);
|
---|
3202 |
|
---|
3203 | TOOLBAR_CalcToolbar (hwnd);
|
---|
3204 |
|
---|
3205 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
3206 |
|
---|
3207 | return TRUE;
|
---|
3208 | }
|
---|
3209 |
|
---|
3210 |
|
---|
3211 | static LRESULT
|
---|
3212 | TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3213 | {
|
---|
3214 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3215 | LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
---|
3216 | INT nIndex = (INT)wParam;
|
---|
3217 | TBUTTON_INFO *oldButtons;
|
---|
3218 |
|
---|
3219 | if (lpTbb == NULL)
|
---|
3220 | return FALSE;
|
---|
3221 | if (nIndex < 0)
|
---|
3222 | return FALSE;
|
---|
3223 |
|
---|
3224 | TRACE("inserting button index=%d\n", nIndex);
|
---|
3225 | if (nIndex > infoPtr->nNumButtons) {
|
---|
3226 | nIndex = infoPtr->nNumButtons;
|
---|
3227 | TRACE("adjust index=%d\n", nIndex);
|
---|
3228 | }
|
---|
3229 |
|
---|
3230 | oldButtons = infoPtr->buttons;
|
---|
3231 | infoPtr->nNumButtons++;
|
---|
3232 | infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
---|
3233 | /* pre insert copy */
|
---|
3234 | if (nIndex > 0) {
|
---|
3235 | memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
---|
3236 | nIndex * sizeof(TBUTTON_INFO));
|
---|
3237 | }
|
---|
3238 |
|
---|
3239 | /* insert new button */
|
---|
3240 | infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
|
---|
3241 | infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
|
---|
3242 | infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
|
---|
3243 | infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
|
---|
3244 | infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
|
---|
3245 | infoPtr->buttons[nIndex].iString = lpTbb->iString;
|
---|
3246 |
|
---|
3247 | if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
|
---|
3248 | TTTOOLINFOW ti;
|
---|
3249 |
|
---|
3250 | ZeroMemory (&ti, sizeof(TTTOOLINFOW));
|
---|
3251 | ti.cbSize = sizeof (TTTOOLINFOW);
|
---|
3252 | ti.hwnd = hwnd;
|
---|
3253 | ti.uId = lpTbb->idCommand;
|
---|
3254 | ti.hinst = 0;
|
---|
3255 | ti.lpszText = LPSTR_TEXTCALLBACKW;
|
---|
3256 |
|
---|
3257 | SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
|
---|
3258 | 0, (LPARAM)&ti);
|
---|
3259 | }
|
---|
3260 |
|
---|
3261 | /* post insert copy */
|
---|
3262 | if (nIndex < infoPtr->nNumButtons - 1) {
|
---|
3263 | memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
|
---|
3264 | (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
|
---|
3265 | }
|
---|
3266 |
|
---|
3267 | COMCTL32_Free (oldButtons);
|
---|
3268 |
|
---|
3269 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
3270 |
|
---|
3271 | return TRUE;
|
---|
3272 | }
|
---|
3273 |
|
---|
3274 |
|
---|
3275 | /* << TOOLBAR_InsertMarkHitTest >> */
|
---|
3276 |
|
---|
3277 |
|
---|
3278 | static LRESULT
|
---|
3279 | TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3280 | {
|
---|
3281 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3282 | INT nIndex;
|
---|
3283 |
|
---|
3284 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3285 | if (nIndex == -1)
|
---|
3286 | return FALSE;
|
---|
3287 |
|
---|
3288 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
|
---|
3289 | }
|
---|
3290 |
|
---|
3291 |
|
---|
3292 | static LRESULT
|
---|
3293 | TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3294 | {
|
---|
3295 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3296 | INT nIndex;
|
---|
3297 |
|
---|
3298 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3299 | if (nIndex == -1)
|
---|
3300 | return FALSE;
|
---|
3301 |
|
---|
3302 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
|
---|
3303 | }
|
---|
3304 |
|
---|
3305 |
|
---|
3306 | static LRESULT
|
---|
3307 | TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3308 | {
|
---|
3309 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3310 | INT nIndex;
|
---|
3311 |
|
---|
3312 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3313 | if (nIndex == -1)
|
---|
3314 | return TRUE;
|
---|
3315 |
|
---|
3316 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
|
---|
3317 | }
|
---|
3318 |
|
---|
3319 |
|
---|
3320 | static LRESULT
|
---|
3321 | TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3322 | {
|
---|
3323 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3324 | INT nIndex;
|
---|
3325 |
|
---|
3326 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3327 | if (nIndex == -1)
|
---|
3328 | return FALSE;
|
---|
3329 |
|
---|
3330 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
|
---|
3331 | }
|
---|
3332 |
|
---|
3333 |
|
---|
3334 | static LRESULT
|
---|
3335 | TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3336 | {
|
---|
3337 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3338 | INT nIndex;
|
---|
3339 |
|
---|
3340 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3341 | if (nIndex == -1)
|
---|
3342 | return FALSE;
|
---|
3343 |
|
---|
3344 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
|
---|
3345 | }
|
---|
3346 |
|
---|
3347 |
|
---|
3348 | static LRESULT
|
---|
3349 | TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3350 | {
|
---|
3351 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3352 | INT nIndex;
|
---|
3353 |
|
---|
3354 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3355 | if (nIndex == -1)
|
---|
3356 | return FALSE;
|
---|
3357 |
|
---|
3358 | return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
|
---|
3359 | }
|
---|
3360 |
|
---|
3361 |
|
---|
3362 | /* << TOOLBAR_LoadImages >> */
|
---|
3363 | /* << TOOLBAR_MapAccelerator >> */
|
---|
3364 | /* << TOOLBAR_MarkButton >> */
|
---|
3365 | /* << TOOLBAR_MoveButton >> */
|
---|
3366 |
|
---|
3367 |
|
---|
3368 | static LRESULT
|
---|
3369 | TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3370 | {
|
---|
3371 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3372 | TBUTTON_INFO *btnPtr;
|
---|
3373 | INT nIndex;
|
---|
3374 |
|
---|
3375 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3376 | if (nIndex == -1)
|
---|
3377 | return FALSE;
|
---|
3378 |
|
---|
3379 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
3380 | if (LOWORD(lParam) == FALSE)
|
---|
3381 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
3382 | else
|
---|
3383 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
3384 |
|
---|
3385 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
|
---|
3386 |
|
---|
3387 | return TRUE;
|
---|
3388 | }
|
---|
3389 |
|
---|
3390 |
|
---|
3391 | /* << TOOLBAR_ReplaceBitmap >> */
|
---|
3392 |
|
---|
3393 |
|
---|
3394 | static LRESULT
|
---|
3395 | TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3396 | {
|
---|
3397 | #if 0
|
---|
3398 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3399 | LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
|
---|
3400 |
|
---|
3401 | if (lpSave == NULL) return 0;
|
---|
3402 |
|
---|
3403 | if ((BOOL)wParam) {
|
---|
3404 | /* save toolbar information */
|
---|
3405 | FIXME("save to \"%s\" \"%s\"\n",
|
---|
3406 | lpSave->pszSubKey, lpSave->pszValueName);
|
---|
3407 |
|
---|
3408 |
|
---|
3409 | }
|
---|
3410 | else {
|
---|
3411 | /* restore toolbar information */
|
---|
3412 |
|
---|
3413 | FIXME("restore from \"%s\" \"%s\"\n",
|
---|
3414 | lpSave->pszSubKey, lpSave->pszValueName);
|
---|
3415 |
|
---|
3416 |
|
---|
3417 | }
|
---|
3418 | #endif
|
---|
3419 |
|
---|
3420 | return 0;
|
---|
3421 | }
|
---|
3422 |
|
---|
3423 |
|
---|
3424 | static LRESULT
|
---|
3425 | TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3426 | {
|
---|
3427 | #if 0
|
---|
3428 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3429 | LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
|
---|
3430 |
|
---|
3431 | if (lpSave == NULL)
|
---|
3432 | return 0;
|
---|
3433 |
|
---|
3434 | if ((BOOL)wParam) {
|
---|
3435 | /* save toolbar information */
|
---|
3436 | FIXME("save to \"%s\" \"%s\"\n",
|
---|
3437 | lpSave->pszSubKey, lpSave->pszValueName);
|
---|
3438 |
|
---|
3439 |
|
---|
3440 | }
|
---|
3441 | else {
|
---|
3442 | /* restore toolbar information */
|
---|
3443 |
|
---|
3444 | FIXME("restore from \"%s\" \"%s\"\n",
|
---|
3445 | lpSave->pszSubKey, lpSave->pszValueName);
|
---|
3446 |
|
---|
3447 |
|
---|
3448 | }
|
---|
3449 | #endif
|
---|
3450 |
|
---|
3451 | return 0;
|
---|
3452 | }
|
---|
3453 |
|
---|
3454 |
|
---|
3455 | static LRESULT
|
---|
3456 | TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
|
---|
3457 | {
|
---|
3458 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3459 | BOOL bOldAnchor = infoPtr->bAnchor;
|
---|
3460 |
|
---|
3461 | infoPtr->bAnchor = (BOOL)wParam;
|
---|
3462 |
|
---|
3463 | return (LRESULT)bOldAnchor;
|
---|
3464 | }
|
---|
3465 |
|
---|
3466 |
|
---|
3467 | static LRESULT
|
---|
3468 | TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3469 | {
|
---|
3470 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3471 |
|
---|
3472 | if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
|
---|
3473 | return FALSE;
|
---|
3474 |
|
---|
3475 | if (infoPtr->nNumButtons > 0)
|
---|
3476 | WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
|
---|
3477 | infoPtr->nNumButtons,
|
---|
3478 | infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
|
---|
3479 | LOWORD(lParam), HIWORD(lParam));
|
---|
3480 |
|
---|
3481 | infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
|
---|
3482 | infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
|
---|
3483 |
|
---|
3484 | /* uses image list internals directly */
|
---|
3485 | if (infoPtr->himlDef) {
|
---|
3486 | infoPtr->himlDef->cx = infoPtr->nBitmapWidth;
|
---|
3487 | infoPtr->himlDef->cy = infoPtr->nBitmapHeight;
|
---|
3488 | }
|
---|
3489 |
|
---|
3490 | return TRUE;
|
---|
3491 | }
|
---|
3492 |
|
---|
3493 |
|
---|
3494 | static LRESULT
|
---|
3495 | TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3496 | {
|
---|
3497 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3498 | LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
|
---|
3499 | TBUTTON_INFO *btnPtr;
|
---|
3500 | INT nIndex;
|
---|
3501 |
|
---|
3502 | if (lptbbi == NULL)
|
---|
3503 | return FALSE;
|
---|
3504 | if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
|
---|
3505 | return FALSE;
|
---|
3506 |
|
---|
3507 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3508 | if (nIndex == -1)
|
---|
3509 | return FALSE;
|
---|
3510 |
|
---|
3511 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
3512 | if (lptbbi->dwMask & TBIF_COMMAND)
|
---|
3513 | btnPtr->idCommand = lptbbi->idCommand;
|
---|
3514 | if (lptbbi->dwMask & TBIF_IMAGE)
|
---|
3515 | btnPtr->iBitmap = lptbbi->iImage;
|
---|
3516 | if (lptbbi->dwMask & TBIF_LPARAM)
|
---|
3517 | btnPtr->dwData = lptbbi->lParam;
|
---|
3518 | /* if (lptbbi->dwMask & TBIF_SIZE) */
|
---|
3519 | /* btnPtr->cx = lptbbi->cx; */
|
---|
3520 | if (lptbbi->dwMask & TBIF_STATE)
|
---|
3521 | btnPtr->fsState = lptbbi->fsState;
|
---|
3522 | if (lptbbi->dwMask & TBIF_STYLE)
|
---|
3523 | btnPtr->fsStyle = lptbbi->fsStyle;
|
---|
3524 |
|
---|
3525 | if (lptbbi->dwMask & TBIF_TEXT) {
|
---|
3526 | if ((btnPtr->iString >= 0) ||
|
---|
3527 | (btnPtr->iString < infoPtr->nNumStrings)) {
|
---|
3528 | TRACE("Ooooooch\n");
|
---|
3529 | #if 0
|
---|
3530 | WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
|
---|
3531 | INT len = lstrlenA (lptbbi->pszText);
|
---|
3532 | *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
|
---|
3533 | #endif
|
---|
3534 |
|
---|
3535 | /* this is the ultimate sollution */
|
---|
3536 | /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
|
---|
3537 | }
|
---|
3538 | }
|
---|
3539 |
|
---|
3540 | return TRUE;
|
---|
3541 | }
|
---|
3542 |
|
---|
3543 |
|
---|
3544 | static LRESULT
|
---|
3545 | TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3546 | {
|
---|
3547 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3548 | LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
|
---|
3549 | TBUTTON_INFO *btnPtr;
|
---|
3550 | INT nIndex;
|
---|
3551 |
|
---|
3552 | if (lptbbi == NULL)
|
---|
3553 | return FALSE;
|
---|
3554 | if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
|
---|
3555 | return FALSE;
|
---|
3556 |
|
---|
3557 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3558 | if (nIndex == -1)
|
---|
3559 | return FALSE;
|
---|
3560 |
|
---|
3561 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
3562 | if (lptbbi->dwMask & TBIF_COMMAND)
|
---|
3563 | btnPtr->idCommand = lptbbi->idCommand;
|
---|
3564 | if (lptbbi->dwMask & TBIF_IMAGE)
|
---|
3565 | btnPtr->iBitmap = lptbbi->iImage;
|
---|
3566 | if (lptbbi->dwMask & TBIF_LPARAM)
|
---|
3567 | btnPtr->dwData = lptbbi->lParam;
|
---|
3568 | /* if (lptbbi->dwMask & TBIF_SIZE) */
|
---|
3569 | /* btnPtr->cx = lptbbi->cx; */
|
---|
3570 | if (lptbbi->dwMask & TBIF_STATE)
|
---|
3571 | btnPtr->fsState = lptbbi->fsState;
|
---|
3572 | if (lptbbi->dwMask & TBIF_STYLE)
|
---|
3573 | btnPtr->fsStyle = lptbbi->fsStyle;
|
---|
3574 |
|
---|
3575 | if (lptbbi->dwMask & TBIF_TEXT) {
|
---|
3576 | if ((btnPtr->iString >= 0) ||
|
---|
3577 | (btnPtr->iString < infoPtr->nNumStrings)) {
|
---|
3578 | #if 0
|
---|
3579 | WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
|
---|
3580 | INT len = lstrlenW (lptbbi->pszText);
|
---|
3581 | *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
|
---|
3582 | #endif
|
---|
3583 |
|
---|
3584 | /* this is the ultimate solution */
|
---|
3585 | /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
|
---|
3586 | }
|
---|
3587 | }
|
---|
3588 |
|
---|
3589 | return TRUE;
|
---|
3590 | }
|
---|
3591 |
|
---|
3592 |
|
---|
3593 | static LRESULT
|
---|
3594 | TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3595 | {
|
---|
3596 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3597 |
|
---|
3598 | if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
|
---|
3599 | {
|
---|
3600 | ERR("invalid parameter\n");
|
---|
3601 | return FALSE;
|
---|
3602 | }
|
---|
3603 |
|
---|
3604 | /* The documentation claims you can only change the button size before
|
---|
3605 | * any button has been added. But this is wrong.
|
---|
3606 | * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
|
---|
3607 | * it to the toolbar, and it checks that the return value is nonzero - mjm
|
---|
3608 | * Further testing shows that we must actually perform the change too.
|
---|
3609 | */
|
---|
3610 | infoPtr->nButtonWidth = (INT)LOWORD(lParam);
|
---|
3611 | infoPtr->nButtonHeight = (INT)HIWORD(lParam);
|
---|
3612 | return TRUE;
|
---|
3613 | }
|
---|
3614 |
|
---|
3615 |
|
---|
3616 | static LRESULT
|
---|
3617 | TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3618 | {
|
---|
3619 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3620 |
|
---|
3621 | if (infoPtr == NULL) {
|
---|
3622 | TRACE("Toolbar not initialized yet?????\n");
|
---|
3623 | return FALSE;
|
---|
3624 | }
|
---|
3625 |
|
---|
3626 | /* if setting to current values, ignore */
|
---|
3627 | if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
|
---|
3628 | (infoPtr->cxMax == (INT)HIWORD(lParam))) {
|
---|
3629 | TRACE("matches current width, min=%d, max=%d, no recalc\n",
|
---|
3630 | infoPtr->cxMin, infoPtr->cxMax);
|
---|
3631 | return TRUE;
|
---|
3632 | }
|
---|
3633 |
|
---|
3634 | /* save new values */
|
---|
3635 | infoPtr->cxMin = (INT)LOWORD(lParam);
|
---|
3636 | infoPtr->cxMax = (INT)HIWORD(lParam);
|
---|
3637 |
|
---|
3638 | /* if both values are 0 then we are done */
|
---|
3639 | if (lParam == 0) {
|
---|
3640 | TRACE("setting both min and max to 0, norecalc\n");
|
---|
3641 | return TRUE;
|
---|
3642 | }
|
---|
3643 |
|
---|
3644 | /* otherwise we need to recalc the toolbar and in some cases
|
---|
3645 | recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
|
---|
3646 | which doesn't actually draw - GA). */
|
---|
3647 | TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
|
---|
3648 | infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
|
---|
3649 |
|
---|
3650 | TOOLBAR_CalcToolbar (hwnd);
|
---|
3651 |
|
---|
3652 | InvalidateRect (hwnd, NULL, TRUE);
|
---|
3653 |
|
---|
3654 | return TRUE;
|
---|
3655 | }
|
---|
3656 |
|
---|
3657 |
|
---|
3658 | static LRESULT
|
---|
3659 | TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3660 | {
|
---|
3661 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3662 | INT nIndex = (INT)wParam;
|
---|
3663 |
|
---|
3664 | if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
---|
3665 | return FALSE;
|
---|
3666 |
|
---|
3667 | infoPtr->buttons[nIndex].idCommand = (INT)lParam;
|
---|
3668 |
|
---|
3669 | if (infoPtr->hwndToolTip) {
|
---|
3670 |
|
---|
3671 | FIXME("change tool tip!\n");
|
---|
3672 |
|
---|
3673 | }
|
---|
3674 |
|
---|
3675 | return TRUE;
|
---|
3676 | }
|
---|
3677 |
|
---|
3678 |
|
---|
3679 | /* << TOOLBAR_SetColorScheme >> */
|
---|
3680 |
|
---|
3681 |
|
---|
3682 | static LRESULT
|
---|
3683 | TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3684 | {
|
---|
3685 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3686 | HIMAGELIST himlTemp;
|
---|
3687 |
|
---|
3688 |
|
---|
3689 | himlTemp = infoPtr->himlDis;
|
---|
3690 | infoPtr->himlDis = (HIMAGELIST)lParam;
|
---|
3691 |
|
---|
3692 | /* FIXME: redraw ? */
|
---|
3693 |
|
---|
3694 | return (LRESULT)himlTemp;
|
---|
3695 | }
|
---|
3696 |
|
---|
3697 |
|
---|
3698 | static LRESULT
|
---|
3699 | TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3700 | {
|
---|
3701 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3702 | DWORD dwTemp;
|
---|
3703 |
|
---|
3704 | dwTemp = infoPtr->dwDTFlags;
|
---|
3705 | infoPtr->dwDTFlags =
|
---|
3706 | (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
|
---|
3707 |
|
---|
3708 | return (LRESULT)dwTemp;
|
---|
3709 | }
|
---|
3710 |
|
---|
3711 |
|
---|
3712 | static LRESULT
|
---|
3713 | TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3714 | {
|
---|
3715 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3716 | DWORD dwTemp;
|
---|
3717 |
|
---|
3718 | dwTemp = infoPtr->dwExStyle;
|
---|
3719 | infoPtr->dwExStyle = (DWORD)lParam;
|
---|
3720 |
|
---|
3721 | return (LRESULT)dwTemp;
|
---|
3722 | }
|
---|
3723 |
|
---|
3724 |
|
---|
3725 | static LRESULT
|
---|
3726 | TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3727 | {
|
---|
3728 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
---|
3729 | HIMAGELIST himlTemp;
|
---|
3730 |
|
---|
3731 | himlTemp = infoPtr->himlHot;
|
---|
3732 | infoPtr->himlHot = (HIMAGELIST)lParam;
|
---|
3733 |
|
---|
3734 | /* FIXME: redraw ? */
|
---|
3735 |
|
---|
3736 | return (LRESULT)himlTemp;
|
---|
3737 | }
|
---|
3738 |
|
---|
3739 |
|
---|
3740 | static LRESULT
|
---|
3741 | TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
|
---|
3742 | {
|
---|
3743 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
---|
3744 | INT nOldHotItem = infoPtr->nHotItem;
|
---|
3745 | TBUTTON_INFO *btnPtr;
|
---|
3746 |
|
---|
3747 | if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
|
---|
3748 | wParam = -2;
|
---|
3749 |
|
---|
3750 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
|
---|
3751 | {
|
---|
3752 |
|
---|
3753 | infoPtr->nHotItem = (INT)wParam;
|
---|
3754 | if ((INT)wParam >=0)
|
---|
3755 | {
|
---|
3756 | btnPtr = &infoPtr->buttons[(INT)wParam];
|
---|
3757 | btnPtr->bHot = TRUE;
|
---|
3758 | InvalidateRect (hwnd, &btnPtr->rect,
|
---|
3759 | TOOLBAR_HasText(infoPtr, btnPtr));
|
---|
3760 | }
|
---|
3761 | if (nOldHotItem>=0)
|
---|
3762 | {
|
---|
3763 | btnPtr = &infoPtr->buttons[nOldHotItem];
|
---|
3764 | btnPtr->bHot = FALSE;
|
---|
3765 | InvalidateRect (hwnd, &btnPtr->rect,
|
---|
3766 | TOOLBAR_HasText(infoPtr, btnPtr));
|
---|
3767 | }
|
---|
3768 | }
|
---|
3769 |
|
---|
3770 | if (nOldHotItem < 0)
|
---|
3771 | return -1;
|
---|
3772 |
|
---|
3773 | return (LRESULT)nOldHotItem;
|
---|
3774 | }
|
---|
3775 |
|
---|
3776 |
|
---|
3777 | static LRESULT
|
---|
3778 | TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3779 | {
|
---|
3780 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3781 | HIMAGELIST himlTemp;
|
---|
3782 |
|
---|
3783 | himlTemp = infoPtr->himlDef;
|
---|
3784 | infoPtr->himlDef = (HIMAGELIST)lParam;
|
---|
3785 |
|
---|
3786 | infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
|
---|
3787 |
|
---|
3788 | ImageList_GetIconSize(infoPtr->himlDef, &infoPtr->nBitmapWidth,
|
---|
3789 | &infoPtr->nBitmapHeight);
|
---|
3790 | TRACE("hwnd %08x, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
|
---|
3791 | hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
|
---|
3792 | infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
|
---|
3793 |
|
---|
3794 | /* FIXME: redraw ? */
|
---|
3795 |
|
---|
3796 | return (LRESULT)himlTemp;
|
---|
3797 | }
|
---|
3798 |
|
---|
3799 |
|
---|
3800 | static LRESULT
|
---|
3801 | TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3802 | {
|
---|
3803 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3804 |
|
---|
3805 | infoPtr->nIndent = (INT)wParam;
|
---|
3806 |
|
---|
3807 | TRACE("\n");
|
---|
3808 |
|
---|
3809 | /* process only on indent changing */
|
---|
3810 | if(infoPtr->nIndent != (INT)wParam)
|
---|
3811 | {
|
---|
3812 | infoPtr->nIndent = (INT)wParam;
|
---|
3813 | TOOLBAR_CalcToolbar (hwnd);
|
---|
3814 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
3815 | }
|
---|
3816 |
|
---|
3817 | return TRUE;
|
---|
3818 | }
|
---|
3819 |
|
---|
3820 |
|
---|
3821 | /* << TOOLBAR_SetInsertMark >> */
|
---|
3822 |
|
---|
3823 |
|
---|
3824 | static LRESULT
|
---|
3825 | TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3826 | {
|
---|
3827 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3828 |
|
---|
3829 | infoPtr->clrInsertMark = (COLORREF)lParam;
|
---|
3830 |
|
---|
3831 | /* FIXME : redraw ??*/
|
---|
3832 |
|
---|
3833 | return 0;
|
---|
3834 | }
|
---|
3835 |
|
---|
3836 |
|
---|
3837 | static LRESULT
|
---|
3838 | TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3839 | {
|
---|
3840 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3841 |
|
---|
3842 | if (infoPtr == NULL)
|
---|
3843 | return FALSE;
|
---|
3844 |
|
---|
3845 | infoPtr->nMaxTextRows = (INT)wParam;
|
---|
3846 |
|
---|
3847 | return TRUE;
|
---|
3848 | }
|
---|
3849 |
|
---|
3850 |
|
---|
3851 | /* << TOOLBAR_SetPadding >> */
|
---|
3852 |
|
---|
3853 |
|
---|
3854 | static LRESULT
|
---|
3855 | TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3856 | {
|
---|
3857 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3858 | HWND hwndOldNotify;
|
---|
3859 |
|
---|
3860 | TRACE("\n");
|
---|
3861 |
|
---|
3862 | if (infoPtr == NULL)
|
---|
3863 | return 0;
|
---|
3864 | hwndOldNotify = infoPtr->hwndNotify;
|
---|
3865 | infoPtr->hwndNotify = (HWND)wParam;
|
---|
3866 |
|
---|
3867 | return hwndOldNotify;
|
---|
3868 | }
|
---|
3869 |
|
---|
3870 |
|
---|
3871 | static LRESULT
|
---|
3872 | TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3873 | {
|
---|
3874 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3875 | LPRECT lprc = (LPRECT)lParam;
|
---|
3876 |
|
---|
3877 | TRACE("\n");
|
---|
3878 |
|
---|
3879 | if (LOWORD(wParam) > 1) {
|
---|
3880 | FIXME("multiple rows not supported!\n");
|
---|
3881 | }
|
---|
3882 |
|
---|
3883 | if(infoPtr->nRows != LOWORD(wParam))
|
---|
3884 | {
|
---|
3885 | infoPtr->nRows = LOWORD(wParam);
|
---|
3886 |
|
---|
3887 | /* recalculate toolbar */
|
---|
3888 | TOOLBAR_CalcToolbar (hwnd);
|
---|
3889 |
|
---|
3890 | /* repaint toolbar */
|
---|
3891 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
3892 | }
|
---|
3893 |
|
---|
3894 | /* return bounding rectangle */
|
---|
3895 | if (lprc) {
|
---|
3896 | lprc->left = infoPtr->rcBound.left;
|
---|
3897 | lprc->right = infoPtr->rcBound.right;
|
---|
3898 | lprc->top = infoPtr->rcBound.top;
|
---|
3899 | lprc->bottom = infoPtr->rcBound.bottom;
|
---|
3900 | }
|
---|
3901 |
|
---|
3902 | return 0;
|
---|
3903 | }
|
---|
3904 |
|
---|
3905 |
|
---|
3906 | static LRESULT
|
---|
3907 | TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3908 | {
|
---|
3909 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3910 | TBUTTON_INFO *btnPtr;
|
---|
3911 | INT nIndex;
|
---|
3912 |
|
---|
3913 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3914 | if (nIndex == -1)
|
---|
3915 | return FALSE;
|
---|
3916 |
|
---|
3917 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
3918 |
|
---|
3919 | /* if hidden state has changed the invalidate entire window and recalc */
|
---|
3920 | if ((btnPtr->fsState & TBSTATE_HIDDEN) != (LOWORD(lParam) & TBSTATE_HIDDEN)) {
|
---|
3921 | btnPtr->fsState = LOWORD(lParam);
|
---|
3922 | TOOLBAR_CalcToolbar (hwnd);
|
---|
3923 | InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
|
---|
3924 | return TRUE;
|
---|
3925 | }
|
---|
3926 |
|
---|
3927 | /* process state changing if current state doesn't match new state */
|
---|
3928 | if(btnPtr->fsState != LOWORD(lParam))
|
---|
3929 | {
|
---|
3930 | btnPtr->fsState = LOWORD(lParam);
|
---|
3931 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
|
---|
3932 | btnPtr));
|
---|
3933 | }
|
---|
3934 |
|
---|
3935 | return TRUE;
|
---|
3936 | }
|
---|
3937 |
|
---|
3938 |
|
---|
3939 | static LRESULT
|
---|
3940 | TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3941 | {
|
---|
3942 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3943 | TBUTTON_INFO *btnPtr;
|
---|
3944 | INT nIndex;
|
---|
3945 |
|
---|
3946 | nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
|
---|
3947 | if (nIndex == -1)
|
---|
3948 | return FALSE;
|
---|
3949 |
|
---|
3950 | btnPtr = &infoPtr->buttons[nIndex];
|
---|
3951 |
|
---|
3952 | /* process style change if current style doesn't match new style */
|
---|
3953 | if(btnPtr->fsStyle != LOWORD(lParam))
|
---|
3954 | {
|
---|
3955 | btnPtr->fsStyle = LOWORD(lParam);
|
---|
3956 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
|
---|
3957 | btnPtr));
|
---|
3958 |
|
---|
3959 | if (infoPtr->hwndToolTip) {
|
---|
3960 | FIXME("change tool tip!\n");
|
---|
3961 | }
|
---|
3962 | }
|
---|
3963 |
|
---|
3964 | return TRUE;
|
---|
3965 | }
|
---|
3966 |
|
---|
3967 |
|
---|
3968 | inline static LRESULT
|
---|
3969 | TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3970 | {
|
---|
3971 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3972 |
|
---|
3973 | if (infoPtr == NULL)
|
---|
3974 | return 0;
|
---|
3975 | infoPtr->hwndToolTip = (HWND)wParam;
|
---|
3976 | return 0;
|
---|
3977 | }
|
---|
3978 |
|
---|
3979 |
|
---|
3980 | static LRESULT
|
---|
3981 | TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
3982 | {
|
---|
3983 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
3984 | BOOL bTemp;
|
---|
3985 |
|
---|
3986 | TRACE("%s hwnd=0x%04x stub!\n",
|
---|
3987 | ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
|
---|
3988 |
|
---|
3989 | bTemp = infoPtr->bUnicode;
|
---|
3990 | infoPtr->bUnicode = (BOOL)wParam;
|
---|
3991 |
|
---|
3992 | return bTemp;
|
---|
3993 | }
|
---|
3994 |
|
---|
3995 |
|
---|
3996 | static LRESULT
|
---|
3997 | TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
|
---|
3998 | {
|
---|
3999 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4000 | INT iOldVersion = infoPtr->iVersion;
|
---|
4001 |
|
---|
4002 | infoPtr->iVersion = iVersion;
|
---|
4003 |
|
---|
4004 | return iOldVersion;
|
---|
4005 | }
|
---|
4006 |
|
---|
4007 |
|
---|
4008 | static LRESULT
|
---|
4009 | TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4010 | {
|
---|
4011 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4012 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
4013 | LOGFONTA logFont;
|
---|
4014 |
|
---|
4015 | /* initialize info structure */
|
---|
4016 | infoPtr->nButtonHeight = 22;
|
---|
4017 | infoPtr->nButtonWidth = 24;
|
---|
4018 | infoPtr->nBitmapHeight = 15;
|
---|
4019 | infoPtr->nBitmapWidth = 16;
|
---|
4020 |
|
---|
4021 | infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
|
---|
4022 | infoPtr->nRows = 1;
|
---|
4023 | infoPtr->nMaxTextRows = 1;
|
---|
4024 | infoPtr->cxMin = -1;
|
---|
4025 | infoPtr->cxMax = -1;
|
---|
4026 | infoPtr->nNumBitmaps = 0;
|
---|
4027 | infoPtr->nNumStrings = 0;
|
---|
4028 |
|
---|
4029 | infoPtr->bCaptured = FALSE;
|
---|
4030 | infoPtr->bUnicode = IsWindowUnicode (hwnd);
|
---|
4031 | infoPtr->nButtonDown = -1;
|
---|
4032 | infoPtr->nOldHit = -1;
|
---|
4033 | infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
|
---|
4034 | infoPtr->hwndNotify = GetParent (hwnd);
|
---|
4035 | infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
|
---|
4036 | infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
|
---|
4037 | infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
|
---|
4038 | infoPtr->bAnchor = FALSE; /* no anchor highlighting */
|
---|
4039 | infoPtr->iVersion = 0;
|
---|
4040 | infoPtr->bNtfUnicode = FALSE;
|
---|
4041 | infoPtr->hwndSelf = hwnd;
|
---|
4042 |
|
---|
4043 | SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
|
---|
4044 | infoPtr->hFont = CreateFontIndirectA (&logFont);
|
---|
4045 |
|
---|
4046 | if (dwStyle & TBSTYLE_TOOLTIPS) {
|
---|
4047 | /* Create tooltip control */
|
---|
4048 | infoPtr->hwndToolTip =
|
---|
4049 | CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
|
---|
4050 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
4051 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
4052 | hwnd, 0, 0, 0);
|
---|
4053 |
|
---|
4054 | /* Send NM_TOOLTIPSCREATED notification */
|
---|
4055 | if (infoPtr->hwndToolTip) {
|
---|
4056 | NMTOOLTIPSCREATED nmttc;
|
---|
4057 |
|
---|
4058 | nmttc.hwndToolTips = infoPtr->hwndToolTip;
|
---|
4059 |
|
---|
4060 | TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
|
---|
4061 | NM_TOOLTIPSCREATED);
|
---|
4062 | }
|
---|
4063 | }
|
---|
4064 |
|
---|
4065 | TOOLBAR_CheckStyle (hwnd, dwStyle);
|
---|
4066 |
|
---|
4067 | TOOLBAR_CalcToolbar(hwnd);
|
---|
4068 |
|
---|
4069 | return 0;
|
---|
4070 | }
|
---|
4071 |
|
---|
4072 |
|
---|
4073 | static LRESULT
|
---|
4074 | TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4075 | {
|
---|
4076 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4077 |
|
---|
4078 | /* delete tooltip control */
|
---|
4079 | if (infoPtr->hwndToolTip)
|
---|
4080 | DestroyWindow (infoPtr->hwndToolTip);
|
---|
4081 |
|
---|
4082 | /* delete button data */
|
---|
4083 | if (infoPtr->buttons)
|
---|
4084 | COMCTL32_Free (infoPtr->buttons);
|
---|
4085 |
|
---|
4086 | /* delete strings */
|
---|
4087 | if (infoPtr->strings) {
|
---|
4088 | INT i;
|
---|
4089 | for (i = 0; i < infoPtr->nNumStrings; i++)
|
---|
4090 | if (infoPtr->strings[i])
|
---|
4091 | COMCTL32_Free (infoPtr->strings[i]);
|
---|
4092 |
|
---|
4093 | COMCTL32_Free (infoPtr->strings);
|
---|
4094 | }
|
---|
4095 |
|
---|
4096 | /* destroy internal image list */
|
---|
4097 | if (infoPtr->himlInt)
|
---|
4098 | ImageList_Destroy (infoPtr->himlInt);
|
---|
4099 |
|
---|
4100 | /* delete default font */
|
---|
4101 | if (infoPtr->hFont)
|
---|
4102 | DeleteObject (infoPtr->hFont);
|
---|
4103 |
|
---|
4104 | /* free toolbar info data */
|
---|
4105 | COMCTL32_Free (infoPtr);
|
---|
4106 | SetWindowLongA (hwnd, 0, 0);
|
---|
4107 |
|
---|
4108 | return 0;
|
---|
4109 | }
|
---|
4110 |
|
---|
4111 |
|
---|
4112 | static LRESULT
|
---|
4113 | TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4114 | {
|
---|
4115 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4116 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
4117 | NMTBCUSTOMDRAW tbcd;
|
---|
4118 | INT ret, ntfret;
|
---|
4119 |
|
---|
4120 | if (dwStyle & TBSTYLE_CUSTOMERASE) {
|
---|
4121 | ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
|
---|
4122 | tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
|
---|
4123 | tbcd.nmcd.hdc = (HDC)wParam;
|
---|
4124 | ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
|
---|
4125 | /* FIXME: in general the return flags *can* be or'ed together */
|
---|
4126 | switch (ntfret)
|
---|
4127 | {
|
---|
4128 | case CDRF_DODEFAULT:
|
---|
4129 | break;
|
---|
4130 | case CDRF_SKIPDEFAULT:
|
---|
4131 | return TRUE;
|
---|
4132 | default:
|
---|
4133 | FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
|
---|
4134 | hwnd, ntfret);
|
---|
4135 | }
|
---|
4136 | }
|
---|
4137 |
|
---|
4138 | /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
|
---|
4139 | * to my parent for processing.
|
---|
4140 | */
|
---|
4141 | if (infoPtr->bTransparent) {
|
---|
4142 | POINT pt, ptorig;
|
---|
4143 | HDC hdc = (HDC)wParam;
|
---|
4144 | HWND parent;
|
---|
4145 |
|
---|
4146 | pt.x = 0;
|
---|
4147 | pt.y = 0;
|
---|
4148 | parent = GetParent(hwnd);
|
---|
4149 | MapWindowPoints(hwnd, parent, &pt, 1);
|
---|
4150 | OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
|
---|
4151 | SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
|
---|
4152 | SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
|
---|
4153 | return TRUE;
|
---|
4154 | }
|
---|
4155 | ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
|
---|
4156 |
|
---|
4157 | if (dwStyle & TBSTYLE_CUSTOMERASE) {
|
---|
4158 | ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
|
---|
4159 | tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
|
---|
4160 | tbcd.nmcd.hdc = (HDC)wParam;
|
---|
4161 | ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
|
---|
4162 | switch (ntfret)
|
---|
4163 | {
|
---|
4164 | case CDRF_DODEFAULT:
|
---|
4165 | break;
|
---|
4166 | case CDRF_SKIPDEFAULT:
|
---|
4167 | return TRUE;
|
---|
4168 | default:
|
---|
4169 | FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
|
---|
4170 | hwnd, ntfret);
|
---|
4171 | }
|
---|
4172 | }
|
---|
4173 | return ret;
|
---|
4174 | }
|
---|
4175 |
|
---|
4176 |
|
---|
4177 | static LRESULT
|
---|
4178 | TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4179 | {
|
---|
4180 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4181 |
|
---|
4182 | return infoPtr->hFont;
|
---|
4183 | }
|
---|
4184 |
|
---|
4185 |
|
---|
4186 | static LRESULT
|
---|
4187 | TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4188 | {
|
---|
4189 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4190 | TBUTTON_INFO *btnPtr;
|
---|
4191 | POINT pt;
|
---|
4192 | INT nHit;
|
---|
4193 |
|
---|
4194 | pt.x = (INT)LOWORD(lParam);
|
---|
4195 | pt.y = (INT)HIWORD(lParam);
|
---|
4196 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
4197 |
|
---|
4198 | if (nHit >= 0) {
|
---|
4199 | btnPtr = &infoPtr->buttons[nHit];
|
---|
4200 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
---|
4201 | return 0;
|
---|
4202 | SetCapture (hwnd);
|
---|
4203 | infoPtr->bCaptured = TRUE;
|
---|
4204 | infoPtr->nButtonDown = nHit;
|
---|
4205 |
|
---|
4206 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
4207 |
|
---|
4208 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
|
---|
4209 | btnPtr));
|
---|
4210 | }
|
---|
4211 | else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
|
---|
4212 | TOOLBAR_Customize (hwnd);
|
---|
4213 |
|
---|
4214 | return 0;
|
---|
4215 | }
|
---|
4216 |
|
---|
4217 |
|
---|
4218 | static LRESULT
|
---|
4219 | TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4220 | {
|
---|
4221 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4222 | TBUTTON_INFO *btnPtr;
|
---|
4223 | POINT pt;
|
---|
4224 | INT nHit;
|
---|
4225 | NMTOOLBARA nmtb;
|
---|
4226 |
|
---|
4227 | if (infoPtr->hwndToolTip)
|
---|
4228 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
---|
4229 | WM_LBUTTONDOWN, wParam, lParam);
|
---|
4230 |
|
---|
4231 | pt.x = (INT)LOWORD(lParam);
|
---|
4232 | pt.y = (INT)HIWORD(lParam);
|
---|
4233 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
4234 |
|
---|
4235 | if (nHit >= 0) {
|
---|
4236 | RECT arrowRect;
|
---|
4237 | btnPtr = &infoPtr->buttons[nHit];
|
---|
4238 | if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
---|
4239 | return 0;
|
---|
4240 |
|
---|
4241 | infoPtr->nOldHit = nHit;
|
---|
4242 |
|
---|
4243 | CopyRect(&arrowRect, &btnPtr->rect);
|
---|
4244 | arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
|
---|
4245 |
|
---|
4246 | /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
|
---|
4247 | if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
|
---|
4248 | ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
|
---|
4249 | (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
|
---|
4250 | {
|
---|
4251 | LRESULT res;
|
---|
4252 | /*
|
---|
4253 | * this time we must force a Redraw, so the btn is
|
---|
4254 | * painted down before CaptureChanged repaints it up
|
---|
4255 | */
|
---|
4256 | RedrawWindow(hwnd,&btnPtr->rect,0,
|
---|
4257 | RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
|
---|
4258 |
|
---|
4259 | nmtb.iItem = btnPtr->idCommand;
|
---|
4260 | memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
|
---|
4261 | nmtb.cchText = 0;
|
---|
4262 | nmtb.pszText = 0;
|
---|
4263 | memset(&nmtb.rcButton, 0, sizeof(RECT));
|
---|
4264 | res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
---|
4265 | TBN_DROPDOWN);
|
---|
4266 | if (res != TBDDRET_TREATPRESSED)
|
---|
4267 | /* ??? guess (GA) */
|
---|
4268 | return 0;
|
---|
4269 | /* otherwise drop through and process as pushed */
|
---|
4270 | }
|
---|
4271 | /* SetCapture (hwnd); */
|
---|
4272 | infoPtr->bCaptured = TRUE;
|
---|
4273 | infoPtr->nButtonDown = nHit;
|
---|
4274 |
|
---|
4275 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
4276 | btnPtr->bHot = FALSE;
|
---|
4277 |
|
---|
4278 | InvalidateRect(hwnd, &btnPtr->rect,
|
---|
4279 | TOOLBAR_HasText(infoPtr, btnPtr));
|
---|
4280 | UpdateWindow(hwnd);
|
---|
4281 | SetCapture (hwnd);
|
---|
4282 |
|
---|
4283 | /* native issues the TBN_BEGINDRAG here */
|
---|
4284 | nmtb.iItem = btnPtr->idCommand;
|
---|
4285 | nmtb.tbButton.iBitmap = btnPtr->iBitmap;
|
---|
4286 | nmtb.tbButton.idCommand = btnPtr->idCommand;
|
---|
4287 | nmtb.tbButton.fsState = btnPtr->fsState;
|
---|
4288 | nmtb.tbButton.fsStyle = btnPtr->fsStyle;
|
---|
4289 | nmtb.tbButton.dwData = btnPtr->dwData;
|
---|
4290 | nmtb.tbButton.iString = btnPtr->iString;
|
---|
4291 | nmtb.cchText = 0; /* !!! not correct */
|
---|
4292 | nmtb.pszText = 0; /* !!! not correct */
|
---|
4293 | TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
---|
4294 | TBN_BEGINDRAG);
|
---|
4295 | }
|
---|
4296 |
|
---|
4297 | return 0;
|
---|
4298 | }
|
---|
4299 |
|
---|
4300 | static LRESULT
|
---|
4301 | TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4302 | {
|
---|
4303 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4304 | TBUTTON_INFO *btnPtr;
|
---|
4305 | POINT pt;
|
---|
4306 | INT nHit;
|
---|
4307 | INT nOldIndex = -1;
|
---|
4308 | BOOL bSendMessage = TRUE;
|
---|
4309 | NMHDR hdr;
|
---|
4310 | NMMOUSE nmmouse;
|
---|
4311 | NMTOOLBARA nmtb;
|
---|
4312 |
|
---|
4313 | if (infoPtr->hwndToolTip)
|
---|
4314 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
---|
4315 | WM_LBUTTONUP, wParam, lParam);
|
---|
4316 |
|
---|
4317 | pt.x = (INT)LOWORD(lParam);
|
---|
4318 | pt.y = (INT)HIWORD(lParam);
|
---|
4319 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
4320 |
|
---|
4321 | /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */
|
---|
4322 | /* if the cursor is still inside of the toolbar */
|
---|
4323 | if((infoPtr->nHotItem >= 0) && (nHit != -1))
|
---|
4324 | infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
|
---|
4325 |
|
---|
4326 | if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
|
---|
4327 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
---|
4328 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
4329 |
|
---|
4330 | if (nHit == infoPtr->nButtonDown) {
|
---|
4331 | if (btnPtr->fsStyle & TBSTYLE_CHECK) {
|
---|
4332 | if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
---|
4333 | nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
|
---|
4334 | infoPtr->nButtonDown);
|
---|
4335 | if (nOldIndex == infoPtr->nButtonDown)
|
---|
4336 | bSendMessage = FALSE;
|
---|
4337 | if ((nOldIndex != infoPtr->nButtonDown) &&
|
---|
4338 | (nOldIndex != -1))
|
---|
4339 | infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
---|
4340 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
4341 | }
|
---|
4342 | else {
|
---|
4343 | if (btnPtr->fsState & TBSTATE_CHECKED)
|
---|
4344 | btnPtr->fsState &= ~TBSTATE_CHECKED;
|
---|
4345 | else
|
---|
4346 | btnPtr->fsState |= TBSTATE_CHECKED;
|
---|
4347 | }
|
---|
4348 | }
|
---|
4349 | }
|
---|
4350 | else
|
---|
4351 | bSendMessage = FALSE;
|
---|
4352 |
|
---|
4353 | if (nOldIndex != -1)
|
---|
4354 | {
|
---|
4355 | InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
|
---|
4356 | TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
|
---|
4357 | }
|
---|
4358 |
|
---|
4359 | /*
|
---|
4360 | * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
|
---|
4361 | * that resets bCaptured and btn TBSTATE_PRESSED flags,
|
---|
4362 | * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
|
---|
4363 | */
|
---|
4364 | ReleaseCapture ();
|
---|
4365 |
|
---|
4366 | /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
|
---|
4367 | TOOLBAR_SendNotify ((NMHDR *) &hdr, infoPtr,
|
---|
4368 | NM_RELEASEDCAPTURE);
|
---|
4369 |
|
---|
4370 | /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
|
---|
4371 | * TBN_BEGINDRAG
|
---|
4372 | */
|
---|
4373 | nmtb.iItem = btnPtr->idCommand;
|
---|
4374 | nmtb.tbButton.iBitmap = btnPtr->iBitmap;
|
---|
4375 | nmtb.tbButton.idCommand = btnPtr->idCommand;
|
---|
4376 | nmtb.tbButton.fsState = btnPtr->fsState;
|
---|
4377 | nmtb.tbButton.fsStyle = btnPtr->fsStyle;
|
---|
4378 | nmtb.tbButton.dwData = btnPtr->dwData;
|
---|
4379 | nmtb.tbButton.iString = btnPtr->iString;
|
---|
4380 | nmtb.cchText = 0; /* !!! not correct */
|
---|
4381 | nmtb.pszText = 0; /* !!! not correct */
|
---|
4382 | TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
|
---|
4383 | TBN_ENDDRAG);
|
---|
4384 |
|
---|
4385 | if (bSendMessage)
|
---|
4386 | SendMessageA (GetParent(hwnd), WM_COMMAND,
|
---|
4387 | MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
|
---|
4388 |
|
---|
4389 | /* !!! Undocumented - toolbar at 4.71 level and above sends
|
---|
4390 | * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
|
---|
4391 | * Only NM_RCLICK is documented.
|
---|
4392 | */
|
---|
4393 | nmmouse.dwItemSpec = btnPtr->idCommand;
|
---|
4394 | nmmouse.dwItemData = btnPtr->dwData;
|
---|
4395 | TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr,
|
---|
4396 | NM_CLICK);
|
---|
4397 | }
|
---|
4398 |
|
---|
4399 | return 0;
|
---|
4400 | }
|
---|
4401 |
|
---|
4402 | static LRESULT
|
---|
4403 | TOOLBAR_CaptureChanged(HWND hwnd)
|
---|
4404 | {
|
---|
4405 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4406 | TBUTTON_INFO *btnPtr;
|
---|
4407 |
|
---|
4408 | infoPtr->bCaptured = FALSE;
|
---|
4409 |
|
---|
4410 | if (infoPtr->nButtonDown >= 0)
|
---|
4411 | {
|
---|
4412 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
---|
4413 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
4414 |
|
---|
4415 | infoPtr->nButtonDown = -1;
|
---|
4416 | infoPtr->nOldHit = -1;
|
---|
4417 |
|
---|
4418 | InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
|
---|
4419 | btnPtr));
|
---|
4420 | }
|
---|
4421 | return 0;
|
---|
4422 | }
|
---|
4423 |
|
---|
4424 | static LRESULT
|
---|
4425 | TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4426 | {
|
---|
4427 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4428 | TBUTTON_INFO *hotBtnPtr, *btnPtr;
|
---|
4429 | RECT rc1;
|
---|
4430 |
|
---|
4431 | if (infoPtr->nOldHit < 0)
|
---|
4432 | return TRUE;
|
---|
4433 |
|
---|
4434 | hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
|
---|
4435 |
|
---|
4436 | /* Redraw the button if the last button we were over is the hot button and it
|
---|
4437 | is enabled */
|
---|
4438 | if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
|
---|
4439 | {
|
---|
4440 | hotBtnPtr->bHot = FALSE;
|
---|
4441 | rc1 = hotBtnPtr->rect;
|
---|
4442 | InflateRect (&rc1, 1, 1);
|
---|
4443 | InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
|
---|
4444 | hotBtnPtr));
|
---|
4445 | }
|
---|
4446 |
|
---|
4447 | /* If the last button we were over is depressed then make it not */
|
---|
4448 | /* depressed and redraw it */
|
---|
4449 | if(infoPtr->nOldHit == infoPtr->nButtonDown)
|
---|
4450 | {
|
---|
4451 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
---|
4452 |
|
---|
4453 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
4454 |
|
---|
4455 | rc1 = hotBtnPtr->rect;
|
---|
4456 | InflateRect (&rc1, 1, 1);
|
---|
4457 | InvalidateRect (hwnd, &rc1, TRUE);
|
---|
4458 | }
|
---|
4459 |
|
---|
4460 | infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */
|
---|
4461 | infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
|
---|
4462 |
|
---|
4463 | return TRUE;
|
---|
4464 | }
|
---|
4465 |
|
---|
4466 | static LRESULT
|
---|
4467 | TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4468 | {
|
---|
4469 | TBUTTON_INFO *btnPtr, *oldBtnPtr;
|
---|
4470 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4471 | POINT pt;
|
---|
4472 | INT nHit;
|
---|
4473 | TRACKMOUSEEVENT trackinfo;
|
---|
4474 |
|
---|
4475 | /* fill in the TRACKMOUSEEVENT struct */
|
---|
4476 | trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
|
---|
4477 | trackinfo.dwFlags = TME_QUERY;
|
---|
4478 | trackinfo.hwndTrack = hwnd;
|
---|
4479 | trackinfo.dwHoverTime = HOVER_DEFAULT;
|
---|
4480 |
|
---|
4481 | /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
|
---|
4482 | _TrackMouseEvent(&trackinfo);
|
---|
4483 |
|
---|
4484 | /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
|
---|
4485 | if(!(trackinfo.dwFlags & TME_LEAVE)) {
|
---|
4486 | trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
|
---|
4487 |
|
---|
4488 | /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
|
---|
4489 | /* and can properly deactivate the hot toolbar button */
|
---|
4490 | _TrackMouseEvent(&trackinfo);
|
---|
4491 | }
|
---|
4492 |
|
---|
4493 | if (infoPtr->hwndToolTip)
|
---|
4494 | TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
|
---|
4495 | WM_MOUSEMOVE, wParam, lParam);
|
---|
4496 |
|
---|
4497 | pt.x = (INT)LOWORD(lParam);
|
---|
4498 | pt.y = (INT)HIWORD(lParam);
|
---|
4499 |
|
---|
4500 | nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
|
---|
4501 |
|
---|
4502 | if (infoPtr->nOldHit != nHit)
|
---|
4503 | {
|
---|
4504 | /* Remove the effect of an old hot button if the button was enabled and was
|
---|
4505 | drawn with the hot button effect */
|
---|
4506 | if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
|
---|
4507 | (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
|
---|
4508 | {
|
---|
4509 | oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
|
---|
4510 | oldBtnPtr->bHot = FALSE;
|
---|
4511 |
|
---|
4512 | InvalidateRect (hwnd, &oldBtnPtr->rect,
|
---|
4513 | TOOLBAR_HasText(infoPtr, oldBtnPtr));
|
---|
4514 | }
|
---|
4515 |
|
---|
4516 | /* It's not a separator or in nowhere. It's a hot button. */
|
---|
4517 | if (nHit >= 0)
|
---|
4518 | {
|
---|
4519 | btnPtr = &infoPtr->buttons[nHit];
|
---|
4520 |
|
---|
4521 | infoPtr->nHotItem = nHit;
|
---|
4522 |
|
---|
4523 | /* only enabled buttons show hot effect */
|
---|
4524 | if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
|
---|
4525 | {
|
---|
4526 | btnPtr->bHot = TRUE;
|
---|
4527 | InvalidateRect(hwnd, &btnPtr->rect,
|
---|
4528 | TOOLBAR_HasText(infoPtr, btnPtr));
|
---|
4529 | }
|
---|
4530 |
|
---|
4531 | }
|
---|
4532 |
|
---|
4533 | if (infoPtr->bCaptured) {
|
---|
4534 | btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
---|
4535 | if (infoPtr->nOldHit == infoPtr->nButtonDown) {
|
---|
4536 | btnPtr->fsState &= ~TBSTATE_PRESSED;
|
---|
4537 | InvalidateRect(hwnd, &btnPtr->rect, TRUE);
|
---|
4538 | }
|
---|
4539 | else if (nHit == infoPtr->nButtonDown) {
|
---|
4540 | btnPtr->fsState |= TBSTATE_PRESSED;
|
---|
4541 | InvalidateRect(hwnd, &btnPtr->rect, TRUE);
|
---|
4542 | }
|
---|
4543 | }
|
---|
4544 | infoPtr->nOldHit = nHit;
|
---|
4545 | }
|
---|
4546 | return 0;
|
---|
4547 | }
|
---|
4548 |
|
---|
4549 |
|
---|
4550 | inline static LRESULT
|
---|
4551 | TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4552 | {
|
---|
4553 | /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
|
---|
4554 | return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
|
---|
4555 | /* else */
|
---|
4556 | /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
|
---|
4557 | }
|
---|
4558 |
|
---|
4559 |
|
---|
4560 | inline static LRESULT
|
---|
4561 | TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4562 | {
|
---|
4563 | if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
|
---|
4564 | ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
|
---|
4565 |
|
---|
4566 | return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
|
---|
4567 | }
|
---|
4568 |
|
---|
4569 |
|
---|
4570 | static LRESULT
|
---|
4571 | TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4572 | {
|
---|
4573 | TOOLBAR_INFO *infoPtr;
|
---|
4574 | LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
|
---|
4575 | DWORD styleadd = 0;
|
---|
4576 |
|
---|
4577 | /* allocate memory for info structure */
|
---|
4578 | infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
|
---|
4579 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
---|
4580 |
|
---|
4581 | /* paranoid!! */
|
---|
4582 | infoPtr->dwStructSize = sizeof(TBBUTTON);
|
---|
4583 |
|
---|
4584 | /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
|
---|
4585 | if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
|
---|
4586 | HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
|
---|
4587 | SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
|
---|
4588 | }
|
---|
4589 |
|
---|
4590 | /* native control does:
|
---|
4591 | * Get a lot of colors and brushes
|
---|
4592 | * WM_NOTIFYFORMAT
|
---|
4593 | * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
|
---|
4594 | * CreateFontIndirectA(adr1)
|
---|
4595 | * CreateBitmap(0x27, 0x24, 1, 1, 0)
|
---|
4596 | * hdc = GetDC(toolbar)
|
---|
4597 | * GetSystemMetrics(0x48)
|
---|
4598 | * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
|
---|
4599 | * 0, 0, 0, 0, "MARLETT")
|
---|
4600 | * oldfnt = SelectObject(hdc, fnt2)
|
---|
4601 | * GetCharWidthA(hdc, 0x36, 0x36, adr2)
|
---|
4602 | * GetTextMetricsA(hdc, adr3)
|
---|
4603 | * SelectObject(hdc, oldfnt)
|
---|
4604 | * DeleteObject(fnt2)
|
---|
4605 | * ReleaseDC(hdc)
|
---|
4606 | * InvalidateRect(toolbar, 0, 1)
|
---|
4607 | * SetWindowLongA(toolbar, 0, addr)
|
---|
4608 | * SetWindowLongA(toolbar, -16, xxx) **sometimes**
|
---|
4609 | * WM_STYLECHANGING
|
---|
4610 | * CallWinEx old new
|
---|
4611 | * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
|
---|
4612 | * ie 2 0x4600094c 0x4600094c 0x4600894d
|
---|
4613 | * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
|
---|
4614 | * rebar 0x50008844 0x40008844 0x50008845
|
---|
4615 | * pager 0x50000844 0x40000844 0x50008845
|
---|
4616 | * IC35mgr 0x5400084e **nochange**
|
---|
4617 | * on entry to _NCCREATE 0x5400084e
|
---|
4618 | * rowlist 0x5400004e **nochange**
|
---|
4619 | * on entry to _NCCREATE 0x5400004e
|
---|
4620 | *
|
---|
4621 | */
|
---|
4622 |
|
---|
4623 | /* I think the code below is a bug, but it is the way that the native
|
---|
4624 | * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
|
---|
4625 | * forgets to specify TBSTYLE_TRANSPARENT but does specify either
|
---|
4626 | * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
|
---|
4627 | * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
|
---|
4628 | * Some how, the only cases of this seem to be MFC programs.
|
---|
4629 | *
|
---|
4630 | * Note also that the addition of _TRANSPARENT occurs *only* here. It
|
---|
4631 | * does not occur in the WM_STYLECHANGING routine.
|
---|
4632 | * (Guy Albertelli 9/2001)
|
---|
4633 | *
|
---|
4634 | */
|
---|
4635 | if ((cs->style & TBSTYLE_FLAT) && !(cs->style & TBSTYLE_TRANSPARENT))
|
---|
4636 | styleadd |= TBSTYLE_TRANSPARENT;
|
---|
4637 | if (!(cs->style & (CCS_TOP | CCS_NOMOVEY))) {
|
---|
4638 | styleadd |= CCS_TOP; /* default to top */
|
---|
4639 | SetWindowLongA (hwnd, GWL_STYLE, cs->style | styleadd);
|
---|
4640 | }
|
---|
4641 |
|
---|
4642 | return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
|
---|
4643 | }
|
---|
4644 |
|
---|
4645 |
|
---|
4646 | static LRESULT
|
---|
4647 | TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4648 | {
|
---|
4649 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
4650 | RECT rcWindow;
|
---|
4651 | HDC hdc;
|
---|
4652 |
|
---|
4653 | if (dwStyle & WS_MINIMIZE)
|
---|
4654 | return 0; /* Nothing to do */
|
---|
4655 |
|
---|
4656 | DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
|
---|
4657 |
|
---|
4658 | if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
|
---|
4659 | return 0;
|
---|
4660 |
|
---|
4661 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
4662 | {
|
---|
4663 | GetWindowRect (hwnd, &rcWindow);
|
---|
4664 | OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
|
---|
4665 | if( dwStyle & WS_BORDER )
|
---|
4666 | OffsetRect (&rcWindow, 1, 1);
|
---|
4667 | DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
|
---|
4668 | }
|
---|
4669 |
|
---|
4670 | ReleaseDC( hwnd, hdc );
|
---|
4671 |
|
---|
4672 | return 0;
|
---|
4673 | }
|
---|
4674 |
|
---|
4675 |
|
---|
4676 | inline static LRESULT
|
---|
4677 | TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4678 | {
|
---|
4679 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4680 | LPNMHDR lpnmh = (LPNMHDR)lParam;
|
---|
4681 |
|
---|
4682 | if (lpnmh->code == PGN_CALCSIZE) {
|
---|
4683 | LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
|
---|
4684 |
|
---|
4685 | if (lppgc->dwFlag == PGF_CALCWIDTH) {
|
---|
4686 | lppgc->iWidth = infoPtr->nWidth;
|
---|
4687 | TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
|
---|
4688 | infoPtr->nWidth);
|
---|
4689 | }
|
---|
4690 | else {
|
---|
4691 | lppgc->iHeight = infoPtr->nHeight;
|
---|
4692 | TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
|
---|
4693 | infoPtr->nHeight);
|
---|
4694 | }
|
---|
4695 | return 0;
|
---|
4696 | }
|
---|
4697 |
|
---|
4698 |
|
---|
4699 | TRACE("passing WM_NOTIFY!\n");
|
---|
4700 |
|
---|
4701 | if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
|
---|
4702 | SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
|
---|
4703 |
|
---|
4704 | #if 0
|
---|
4705 | if (lpnmh->code == TTN_GETDISPINFOA) {
|
---|
4706 | LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
|
---|
4707 |
|
---|
4708 | FIXME("retrieving ASCII string\n");
|
---|
4709 |
|
---|
4710 | }
|
---|
4711 | else if (lpnmh->code == TTN_GETDISPINFOW) {
|
---|
4712 | LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
|
---|
4713 |
|
---|
4714 | FIXME("retrieving UNICODE string\n");
|
---|
4715 |
|
---|
4716 | }
|
---|
4717 | #endif
|
---|
4718 | }
|
---|
4719 |
|
---|
4720 | return 0;
|
---|
4721 | }
|
---|
4722 |
|
---|
4723 |
|
---|
4724 | static LRESULT
|
---|
4725 | TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
|
---|
4726 | {
|
---|
4727 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
|
---|
4728 | HDC hdc;
|
---|
4729 | PAINTSTRUCT ps;
|
---|
4730 |
|
---|
4731 | /* fill ps.rcPaint with a default rect */
|
---|
4732 | memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
|
---|
4733 |
|
---|
4734 | hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
|
---|
4735 |
|
---|
4736 | TRACE("psrect=(%d,%d)-(%d,%d)\n",
|
---|
4737 | ps.rcPaint.left, ps.rcPaint.top,
|
---|
4738 | ps.rcPaint.right, ps.rcPaint.bottom);
|
---|
4739 |
|
---|
4740 | TOOLBAR_Refresh (hwnd, hdc, &ps);
|
---|
4741 | if (!wParam) EndPaint (hwnd, &ps);
|
---|
4742 |
|
---|
4743 | return 0;
|
---|
4744 | }
|
---|
4745 |
|
---|
4746 |
|
---|
4747 | static LRESULT
|
---|
4748 | TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
4749 | {
|
---|
4750 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4751 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
4752 | RECT parent_rect;
|
---|
4753 | RECT window_rect;
|
---|
4754 | HWND parent;
|
---|
4755 | INT x, y;
|
---|
4756 | INT cx, cy;
|
---|
4757 | INT flags;
|
---|
4758 | UINT uPosFlags = 0;
|
---|
4759 |
|
---|
4760 | /* Resize deadlock check */
|
---|
4761 | if (infoPtr->bAutoSize) {
|
---|
4762 | infoPtr->bAutoSize = FALSE;
|
---|
4763 | return 0;
|
---|
4764 | }
|
---|
4765 |
|
---|
4766 | /* FIXME: optimize to only update size if the new size doesn't */
|
---|
4767 | /* match the current size */
|
---|
4768 |
|
---|
4769 | flags = (INT) wParam;
|
---|
4770 |
|
---|
4771 | /* FIXME for flags =
|
---|
4772 | * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
|
---|
4773 | */
|
---|
4774 |
|
---|
4775 | TRACE("sizing toolbar!\n");
|
---|
4776 |
|
---|
4777 | if (flags == SIZE_RESTORED) {
|
---|
4778 | /* width and height don't apply */
|
---|
4779 | parent = GetParent (hwnd);
|
---|
4780 | GetClientRect(parent, &parent_rect);
|
---|
4781 | x = parent_rect.left;
|
---|
4782 | y = parent_rect.top;
|
---|
4783 |
|
---|
4784 | if (dwStyle & CCS_NORESIZE) {
|
---|
4785 | uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
---|
4786 |
|
---|
4787 | /*
|
---|
4788 | * this sets the working width of the toolbar, and
|
---|
4789 | * Calc Toolbar will not adjust it, only the height
|
---|
4790 | */
|
---|
4791 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
---|
4792 | cy = infoPtr->nHeight;
|
---|
4793 | cx = infoPtr->nWidth;
|
---|
4794 | TOOLBAR_CalcToolbar (hwnd);
|
---|
4795 | infoPtr->nWidth = cx;
|
---|
4796 | infoPtr->nHeight = cy;
|
---|
4797 | }
|
---|
4798 | else {
|
---|
4799 | infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
---|
4800 | TOOLBAR_CalcToolbar (hwnd);
|
---|
4801 | cy = infoPtr->nHeight;
|
---|
4802 | cx = infoPtr->nWidth;
|
---|
4803 |
|
---|
4804 | if (dwStyle & CCS_NOMOVEY) {
|
---|
4805 | GetWindowRect(hwnd, &window_rect);
|
---|
4806 | ScreenToClient(parent, (LPPOINT)&window_rect.left);
|
---|
4807 | y = window_rect.top;
|
---|
4808 | }
|
---|
4809 | }
|
---|
4810 |
|
---|
4811 | if (dwStyle & CCS_NOPARENTALIGN) {
|
---|
4812 | uPosFlags |= SWP_NOMOVE;
|
---|
4813 | cy = infoPtr->nHeight;
|
---|
4814 | cx = infoPtr->nWidth;
|
---|
4815 | }
|
---|
4816 |
|
---|
4817 | if (!(dwStyle & CCS_NODIVIDER))
|
---|
4818 | cy += GetSystemMetrics(SM_CYEDGE);
|
---|
4819 |
|
---|
4820 | if (dwStyle & WS_BORDER)
|
---|
4821 | {
|
---|
4822 | x = y = 1;
|
---|
4823 | cy += GetSystemMetrics(SM_CYEDGE);
|
---|
4824 | cx += GetSystemMetrics(SM_CYEDGE);
|
---|
4825 | }
|
---|
4826 |
|
---|
4827 | SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
|
---|
4828 | cx, cy, uPosFlags | SWP_NOZORDER);
|
---|
4829 | }
|
---|
4830 | return 0;
|
---|
4831 | }
|
---|
4832 |
|
---|
4833 |
|
---|
4834 | static LRESULT
|
---|
4835 | TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
|
---|
4836 | {
|
---|
4837 | TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
|
---|
4838 |
|
---|
4839 | if (nType == GWL_STYLE) {
|
---|
4840 | if (lpStyle->styleNew & TBSTYLE_LIST) {
|
---|
4841 | infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
|
---|
4842 | }
|
---|
4843 | else {
|
---|
4844 | infoPtr->dwDTFlags = DT_CENTER;
|
---|
4845 | }
|
---|
4846 | infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT);
|
---|
4847 | infoPtr->bBtnTranspnt = (lpStyle->styleNew &
|
---|
4848 | (TBSTYLE_FLAT | TBSTYLE_LIST));
|
---|
4849 | TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
|
---|
4850 | }
|
---|
4851 |
|
---|
4852 | TOOLBAR_AutoSize (hwnd);
|
---|
4853 |
|
---|
4854 | InvalidateRect(hwnd, NULL, FALSE);
|
---|
4855 |
|
---|
4856 | return 0;
|
---|
4857 | }
|
---|
4858 |
|
---|
4859 |
|
---|
4860 |
|
---|
4861 | static LRESULT WINAPI
|
---|
4862 | ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
4863 | {
|
---|
4864 | TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
|
---|
4865 | hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
|
---|
4866 |
|
---|
4867 | if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
|
---|
4868 | return DefWindowProcA( hwnd, uMsg, wParam, lParam );
|
---|
4869 |
|
---|
4870 | switch (uMsg)
|
---|
4871 | {
|
---|
4872 | case TB_ADDBITMAP:
|
---|
4873 | return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
|
---|
4874 |
|
---|
4875 | case TB_ADDBUTTONSA:
|
---|
4876 | return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
|
---|
4877 |
|
---|
4878 | case TB_ADDBUTTONSW:
|
---|
4879 | return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
|
---|
4880 |
|
---|
4881 | case TB_ADDSTRINGA:
|
---|
4882 | return TOOLBAR_AddStringA (hwnd, wParam, lParam);
|
---|
4883 |
|
---|
4884 | case TB_ADDSTRINGW:
|
---|
4885 | return TOOLBAR_AddStringW (hwnd, wParam, lParam);
|
---|
4886 |
|
---|
4887 | case TB_AUTOSIZE:
|
---|
4888 | return TOOLBAR_AutoSize (hwnd);
|
---|
4889 |
|
---|
4890 | case TB_BUTTONCOUNT:
|
---|
4891 | return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
|
---|
4892 |
|
---|
4893 | case TB_BUTTONSTRUCTSIZE:
|
---|
4894 | return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
|
---|
4895 |
|
---|
4896 | case TB_CHANGEBITMAP:
|
---|
4897 | return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
|
---|
4898 |
|
---|
4899 | case TB_CHECKBUTTON:
|
---|
4900 | return TOOLBAR_CheckButton (hwnd, wParam, lParam);
|
---|
4901 |
|
---|
4902 | case TB_COMMANDTOINDEX:
|
---|
4903 | return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
|
---|
4904 |
|
---|
4905 | case TB_CUSTOMIZE:
|
---|
4906 | return TOOLBAR_Customize (hwnd);
|
---|
4907 |
|
---|
4908 | case TB_DELETEBUTTON:
|
---|
4909 | return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
|
---|
4910 |
|
---|
4911 | case TB_ENABLEBUTTON:
|
---|
4912 | return TOOLBAR_EnableButton (hwnd, wParam, lParam);
|
---|
4913 |
|
---|
4914 | case TB_GETANCHORHIGHLIGHT:
|
---|
4915 | return TOOLBAR_GetAnchorHighlight (hwnd);
|
---|
4916 |
|
---|
4917 | case TB_GETBITMAP:
|
---|
4918 | return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
|
---|
4919 |
|
---|
4920 | case TB_GETBITMAPFLAGS:
|
---|
4921 | return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
|
---|
4922 |
|
---|
4923 | case TB_GETBUTTON:
|
---|
4924 | return TOOLBAR_GetButton (hwnd, wParam, lParam);
|
---|
4925 |
|
---|
4926 | case TB_GETBUTTONINFOA:
|
---|
4927 | return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
|
---|
4928 |
|
---|
4929 | case TB_GETBUTTONINFOW:
|
---|
4930 | return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
|
---|
4931 |
|
---|
4932 | case TB_GETBUTTONSIZE:
|
---|
4933 | return TOOLBAR_GetButtonSize (hwnd);
|
---|
4934 |
|
---|
4935 | case TB_GETBUTTONTEXTA:
|
---|
4936 | return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
|
---|
4937 |
|
---|
4938 | case TB_GETBUTTONTEXTW:
|
---|
4939 | return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
|
---|
4940 |
|
---|
4941 | /* case TB_GETCOLORSCHEME: */ /* 4.71 */
|
---|
4942 |
|
---|
4943 | case TB_GETDISABLEDIMAGELIST:
|
---|
4944 | return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
|
---|
4945 |
|
---|
4946 | case TB_GETEXTENDEDSTYLE:
|
---|
4947 | return TOOLBAR_GetExtendedStyle (hwnd);
|
---|
4948 |
|
---|
4949 | case TB_GETHOTIMAGELIST:
|
---|
4950 | return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
|
---|
4951 |
|
---|
4952 | case TB_GETHOTITEM:
|
---|
4953 | return TOOLBAR_GetHotItem (hwnd);
|
---|
4954 |
|
---|
4955 | case TB_GETIMAGELIST:
|
---|
4956 | return TOOLBAR_GetImageList (hwnd, wParam, lParam);
|
---|
4957 |
|
---|
4958 | /* case TB_GETINSERTMARK: */ /* 4.71 */
|
---|
4959 | /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
|
---|
4960 |
|
---|
4961 | case TB_GETITEMRECT:
|
---|
4962 | return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
|
---|
4963 |
|
---|
4964 | case TB_GETMAXSIZE:
|
---|
4965 | return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
|
---|
4966 |
|
---|
4967 | /* case TB_GETOBJECT: */ /* 4.71 */
|
---|
4968 | /* case TB_GETPADDING: */ /* 4.71 */
|
---|
4969 |
|
---|
4970 | case TB_GETRECT:
|
---|
4971 | return TOOLBAR_GetRect (hwnd, wParam, lParam);
|
---|
4972 |
|
---|
4973 | case TB_GETROWS:
|
---|
4974 | return TOOLBAR_GetRows (hwnd, wParam, lParam);
|
---|
4975 |
|
---|
4976 | case TB_GETSTATE:
|
---|
4977 | return TOOLBAR_GetState (hwnd, wParam, lParam);
|
---|
4978 |
|
---|
4979 | case TB_GETSTYLE:
|
---|
4980 | return TOOLBAR_GetStyle (hwnd, wParam, lParam);
|
---|
4981 |
|
---|
4982 | case TB_GETTEXTROWS:
|
---|
4983 | return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
|
---|
4984 |
|
---|
4985 | case TB_GETTOOLTIPS:
|
---|
4986 | return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
|
---|
4987 |
|
---|
4988 | case TB_GETUNICODEFORMAT:
|
---|
4989 | return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
|
---|
4990 |
|
---|
4991 | case CCM_GETVERSION:
|
---|
4992 | return TOOLBAR_GetVersion (hwnd);
|
---|
4993 |
|
---|
4994 | case TB_HIDEBUTTON:
|
---|
4995 | return TOOLBAR_HideButton (hwnd, wParam, lParam);
|
---|
4996 |
|
---|
4997 | case TB_HITTEST:
|
---|
4998 | return TOOLBAR_HitTest (hwnd, wParam, lParam);
|
---|
4999 |
|
---|
5000 | case TB_INDETERMINATE:
|
---|
5001 | return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
|
---|
5002 |
|
---|
5003 | case TB_INSERTBUTTONA:
|
---|
5004 | return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
|
---|
5005 |
|
---|
5006 | case TB_INSERTBUTTONW:
|
---|
5007 | return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
|
---|
5008 |
|
---|
5009 | /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
|
---|
5010 |
|
---|
5011 | case TB_ISBUTTONCHECKED:
|
---|
5012 | return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
|
---|
5013 |
|
---|
5014 | case TB_ISBUTTONENABLED:
|
---|
5015 | return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
|
---|
5016 |
|
---|
5017 | case TB_ISBUTTONHIDDEN:
|
---|
5018 | return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
|
---|
5019 |
|
---|
5020 | case TB_ISBUTTONHIGHLIGHTED:
|
---|
5021 | return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
|
---|
5022 |
|
---|
5023 | case TB_ISBUTTONINDETERMINATE:
|
---|
5024 | return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
|
---|
5025 |
|
---|
5026 | case TB_ISBUTTONPRESSED:
|
---|
5027 | return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
|
---|
5028 |
|
---|
5029 | case TB_LOADIMAGES: /* 4.70 */
|
---|
5030 | FIXME("missing standard imagelists\n");
|
---|
5031 | return 0;
|
---|
5032 |
|
---|
5033 | /* case TB_MAPACCELERATORA: */ /* 4.71 */
|
---|
5034 | /* case TB_MAPACCELERATORW: */ /* 4.71 */
|
---|
5035 | /* case TB_MARKBUTTON: */ /* 4.71 */
|
---|
5036 | /* case TB_MOVEBUTTON: */ /* 4.71 */
|
---|
5037 |
|
---|
5038 | case TB_PRESSBUTTON:
|
---|
5039 | return TOOLBAR_PressButton (hwnd, wParam, lParam);
|
---|
5040 |
|
---|
5041 | /* case TB_REPLACEBITMAP: */
|
---|
5042 |
|
---|
5043 | case TB_SAVERESTOREA:
|
---|
5044 | return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
|
---|
5045 |
|
---|
5046 | case TB_SAVERESTOREW:
|
---|
5047 | return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
|
---|
5048 |
|
---|
5049 | case TB_SETANCHORHIGHLIGHT:
|
---|
5050 | return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
|
---|
5051 |
|
---|
5052 | case TB_SETBITMAPSIZE:
|
---|
5053 | return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
|
---|
5054 |
|
---|
5055 | case TB_SETBUTTONINFOA:
|
---|
5056 | return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
|
---|
5057 |
|
---|
5058 | case TB_SETBUTTONINFOW:
|
---|
5059 | return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
|
---|
5060 |
|
---|
5061 | case TB_SETBUTTONSIZE:
|
---|
5062 | return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
|
---|
5063 |
|
---|
5064 | case TB_SETBUTTONWIDTH:
|
---|
5065 | return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
|
---|
5066 |
|
---|
5067 | case TB_SETCMDID:
|
---|
5068 | return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
|
---|
5069 |
|
---|
5070 | /* case TB_SETCOLORSCHEME: */ /* 4.71 */
|
---|
5071 |
|
---|
5072 | case TB_SETDISABLEDIMAGELIST:
|
---|
5073 | return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
|
---|
5074 |
|
---|
5075 | case TB_SETDRAWTEXTFLAGS:
|
---|
5076 | return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
|
---|
5077 |
|
---|
5078 | case TB_SETEXTENDEDSTYLE:
|
---|
5079 | return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
|
---|
5080 |
|
---|
5081 | case TB_SETHOTIMAGELIST:
|
---|
5082 | return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
|
---|
5083 |
|
---|
5084 | case TB_SETHOTITEM:
|
---|
5085 | return TOOLBAR_SetHotItem (hwnd, wParam);
|
---|
5086 |
|
---|
5087 | case TB_SETIMAGELIST:
|
---|
5088 | return TOOLBAR_SetImageList (hwnd, wParam, lParam);
|
---|
5089 |
|
---|
5090 | case TB_SETINDENT:
|
---|
5091 | return TOOLBAR_SetIndent (hwnd, wParam, lParam);
|
---|
5092 |
|
---|
5093 | /* case TB_SETINSERTMARK: */ /* 4.71 */
|
---|
5094 |
|
---|
5095 | case TB_SETINSERTMARKCOLOR:
|
---|
5096 | return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
|
---|
5097 |
|
---|
5098 | case TB_SETMAXTEXTROWS:
|
---|
5099 | return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
|
---|
5100 |
|
---|
5101 | /* case TB_SETPADDING: */ /* 4.71 */
|
---|
5102 |
|
---|
5103 | case TB_SETPARENT:
|
---|
5104 | return TOOLBAR_SetParent (hwnd, wParam, lParam);
|
---|
5105 |
|
---|
5106 | case TB_SETROWS:
|
---|
5107 | return TOOLBAR_SetRows (hwnd, wParam, lParam);
|
---|
5108 |
|
---|
5109 | case TB_SETSTATE:
|
---|
5110 | return TOOLBAR_SetState (hwnd, wParam, lParam);
|
---|
5111 |
|
---|
5112 | case TB_SETSTYLE:
|
---|
5113 | return TOOLBAR_SetStyle (hwnd, wParam, lParam);
|
---|
5114 |
|
---|
5115 | case TB_SETTOOLTIPS:
|
---|
5116 | return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
|
---|
5117 |
|
---|
5118 | case TB_SETUNICODEFORMAT:
|
---|
5119 | return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
|
---|
5120 |
|
---|
5121 | case CCM_SETVERSION:
|
---|
5122 | return TOOLBAR_SetVersion (hwnd, (INT)wParam);
|
---|
5123 |
|
---|
5124 |
|
---|
5125 | /* case WM_CHAR: */
|
---|
5126 |
|
---|
5127 | case WM_CREATE:
|
---|
5128 | return TOOLBAR_Create (hwnd, wParam, lParam);
|
---|
5129 |
|
---|
5130 | case WM_DESTROY:
|
---|
5131 | return TOOLBAR_Destroy (hwnd, wParam, lParam);
|
---|
5132 |
|
---|
5133 | case WM_ERASEBKGND:
|
---|
5134 | return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
|
---|
5135 |
|
---|
5136 | case WM_GETFONT:
|
---|
5137 | return TOOLBAR_GetFont (hwnd, wParam, lParam);
|
---|
5138 |
|
---|
5139 | /* case WM_KEYDOWN: */
|
---|
5140 | /* case WM_KILLFOCUS: */
|
---|
5141 |
|
---|
5142 | case WM_LBUTTONDBLCLK:
|
---|
5143 | return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
|
---|
5144 |
|
---|
5145 | case WM_LBUTTONDOWN:
|
---|
5146 | return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
|
---|
5147 |
|
---|
5148 | case WM_LBUTTONUP:
|
---|
5149 | return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
|
---|
5150 |
|
---|
5151 | case WM_MOUSEMOVE:
|
---|
5152 | return TOOLBAR_MouseMove (hwnd, wParam, lParam);
|
---|
5153 |
|
---|
5154 | case WM_MOUSELEAVE:
|
---|
5155 | return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
|
---|
5156 |
|
---|
5157 | case WM_CAPTURECHANGED:
|
---|
5158 | return TOOLBAR_CaptureChanged(hwnd);
|
---|
5159 |
|
---|
5160 | case WM_NCACTIVATE:
|
---|
5161 | return TOOLBAR_NCActivate (hwnd, wParam, lParam);
|
---|
5162 |
|
---|
5163 | case WM_NCCALCSIZE:
|
---|
5164 | return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
|
---|
5165 |
|
---|
5166 | case WM_NCCREATE:
|
---|
5167 | return TOOLBAR_NCCreate (hwnd, wParam, lParam);
|
---|
5168 |
|
---|
5169 | case WM_NCPAINT:
|
---|
5170 | return TOOLBAR_NCPaint (hwnd, wParam, lParam);
|
---|
5171 |
|
---|
5172 | case WM_NOTIFY:
|
---|
5173 | return TOOLBAR_Notify (hwnd, wParam, lParam);
|
---|
5174 |
|
---|
5175 | /* case WM_NOTIFYFORMAT: */
|
---|
5176 |
|
---|
5177 | case WM_PAINT:
|
---|
5178 | return TOOLBAR_Paint (hwnd, wParam);
|
---|
5179 |
|
---|
5180 | case WM_SIZE:
|
---|
5181 | return TOOLBAR_Size (hwnd, wParam, lParam);
|
---|
5182 |
|
---|
5183 | case WM_STYLECHANGED:
|
---|
5184 | return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
|
---|
5185 |
|
---|
5186 | /* case WM_SYSCOLORCHANGE: */
|
---|
5187 |
|
---|
5188 | /* case WM_WININICHANGE: */
|
---|
5189 |
|
---|
5190 | case WM_CHARTOITEM:
|
---|
5191 | case WM_COMMAND:
|
---|
5192 | case WM_DRAWITEM:
|
---|
5193 | case WM_MEASUREITEM:
|
---|
5194 | case WM_VKEYTOITEM:
|
---|
5195 | return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
|
---|
5196 |
|
---|
5197 | default:
|
---|
5198 | if (uMsg >= WM_USER)
|
---|
5199 | ERR("unknown msg %04x wp=%08x lp=%08lx\n",
|
---|
5200 | uMsg, wParam, lParam);
|
---|
5201 | return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
---|
5202 | }
|
---|
5203 | return 0;
|
---|
5204 | }
|
---|
5205 |
|
---|
5206 |
|
---|
5207 | VOID
|
---|
5208 | TOOLBAR_Register (void)
|
---|
5209 | {
|
---|
5210 | WNDCLASSA wndClass;
|
---|
5211 |
|
---|
5212 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
---|
5213 | wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
|
---|
5214 | wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
|
---|
5215 | wndClass.cbClsExtra = 0;
|
---|
5216 | wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
|
---|
5217 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
---|
5218 | wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
---|
5219 | wndClass.lpszClassName = TOOLBARCLASSNAMEA;
|
---|
5220 |
|
---|
5221 | RegisterClassA (&wndClass);
|
---|
5222 | }
|
---|
5223 |
|
---|
5224 |
|
---|
5225 | VOID
|
---|
5226 | TOOLBAR_Unregister (void)
|
---|
5227 | {
|
---|
5228 | UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
|
---|
5229 | }
|
---|