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