source: trunk/src/comctl32/toolbar.c@ 2164

Last change on this file since 2164 was 2164, checked in by cbratschi, 26 years ago

separator fix for customize dialog

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