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

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

comctl32 wine conversion bugs fixed
trackbar: TRACKBAR_Draw prototype

File size: 89.3 KB
Line 
1/* $Id: toolbar.c,v 1.5 1999-06-16 20:25:43 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.
13 * - Notifications.
14 * - Fix TB_SETROWS.
15 * - Tooltip support (almost complete).
16 * - Unicode suppport.
17 * - Internal COMMCTL32 bitmaps.
18 * - Fix TOOLBAR_SetButtonInfo32A.
19 * - Customize dialog (under construction).
20 *
21 * Testing:
22 * - Run tests using Waite Group Windows95 API Bible Volume 2.
23 * The second cdrom contains executables addstr.exe, btncount.exe,
24 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
25 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
26 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
27 * setparnt.exe, setrows.exe, toolwnd.exe.
28 * - Microsofts controlspy examples.
29 */
30
31#include <string.h>
32
33#include "winbase.h"
34#include "winuser.h"
35#include "wingdi.h"
36#include "commctrl.h"
37#include "cache.h"
38#include "comctl32.h"
39#include "toolbar.h"
40
41
42#define SEPARATOR_WIDTH 8
43#define TOP_BORDER 2
44#define BOTTOM_BORDER 2
45
46#define TOOLBAR_GetInfoPtr(wndPtr) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
47
48
49static void
50TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
51{
52 INT x = (lpRect->left + lpRect->right) / 2 - 1;
53 INT yBottom = lpRect->bottom - 3;
54 INT yTop = lpRect->top + 1;
55
56 SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
57 MoveToEx (hdc, x, yBottom, NULL);
58 LineTo (hdc, x, yTop);
59 x++;
60 SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
61 MoveToEx (hdc, x, yBottom, NULL);
62 LineTo (hdc, x, yTop);
63}
64
65
66static void
67TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
68 HDC hdc, INT nState)
69{
70 RECT rcText = btnPtr->rect;
71 HFONT hOldFont;
72 INT nOldBkMode;
73 COLORREF clrOld;
74
75 /* draw text */
76 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
77 InflateRect (&rcText, -3, -3);
78 rcText.top += infoPtr->nBitmapHeight;
79 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
80 OffsetRect (&rcText, 1, 1);
81
82 hOldFont = SelectObject (hdc, infoPtr->hFont);
83 nOldBkMode = SetBkMode (hdc, TRANSPARENT);
84 if (!(nState & TBSTATE_ENABLED)) {
85 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
86 OffsetRect (&rcText, 1, 1);
87 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
88 &rcText, infoPtr->dwDTFlags);
89 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
90 OffsetRect (&rcText, -1, -1);
91 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
92 &rcText, infoPtr->dwDTFlags);
93 }
94 else if (nState & TBSTATE_INDETERMINATE) {
95 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
96 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
97 &rcText, infoPtr->dwDTFlags);
98 }
99 else {
100 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
101 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
102 &rcText, infoPtr->dwDTFlags);
103 }
104
105 SetTextColor (hdc, clrOld);
106 SelectObject (hdc, hOldFont);
107 if (nOldBkMode != TRANSPARENT)
108 SetBkMode (hdc, nOldBkMode);
109 }
110}
111
112
113static void
114TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
115{
116 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
117 INT cx = lpRect->right - lpRect->left;
118 INT cy = lpRect->bottom - lpRect->top;
119 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
120 SelectObject (hdc, hbr);
121}
122
123
124static void
125TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
126 HDC hdc, INT x, INT y)
127{
128 /* FIXME: this function is a hack since it uses image list
129 internals directly */
130
131 HDC hdcImageList = CreateCompatibleDC (0);
132 HDC hdcMask = CreateCompatibleDC (0);
133 HIMAGELIST himl = infoPtr->himlStd;
134 HBITMAP hbmMask;
135
136 /* create new bitmap */
137 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
138 SelectObject (hdcMask, hbmMask);
139
140 /* copy the mask bitmap */
141 SelectObject (hdcImageList, himl->hbmMask);
142 SetBkColor (hdcImageList, RGB(255, 255, 255));
143 SetTextColor (hdcImageList, RGB(0, 0, 0));
144 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
145 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
146
147#if 0
148 /* add white mask from image */
149 SelectObject (hdcImageList, himl->hbmImage);
150 SetBkColor (hdcImageList, RGB(0, 0, 0));
151 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
152 hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
153#endif
154
155 /* draw the new mask */
156 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
157 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
158 hdcMask, 0, 0, 0xB8074A);
159
160 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
161 BitBlt (hdc, x, y, himl->cx, himl->cy,
162 hdcMask, 0, 0, 0xB8074A);
163
164 DeleteObject (hbmMask);
165 DeleteDC (hdcMask);
166 DeleteDC (hdcImageList);
167}
168
169
170static void
171TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
172{
173 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
174 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
175 RECT rc;
176
177 if (btnPtr->fsState & TBSTATE_HIDDEN)
178 return;
179
180 rc = btnPtr->rect;
181 if (btnPtr->fsStyle & TBSTYLE_SEP) {
182 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0))
183 TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc);
184 return;
185 }
186
187 /* disabled */
188 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
189 DrawEdge (hdc, &rc, EDGE_RAISED,
190 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
191
192 if (dwStyle & TBSTYLE_FLAT) {
193/* if (infoPtr->himlDis) */
194 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
195 rc.left+1, rc.top+1, ILD_NORMAL);
196/* else */
197/* TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */
198 }
199 else
200 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
201
202 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
203 return;
204 }
205
206 /* pressed TBSTYLE_BUTTON */
207 if (btnPtr->fsState & TBSTATE_PRESSED) {
208 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
209 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
210 rc.left+2, rc.top+2, ILD_NORMAL);
211 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
212 return;
213 }
214
215 /* checked TBSTYLE_CHECK*/
216 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
217 (btnPtr->fsState & TBSTATE_CHECKED)) {
218 if (dwStyle & TBSTYLE_FLAT)
219 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
220 BF_RECT | BF_MIDDLE | BF_ADJUST);
221 else
222 DrawEdge (hdc, &rc, EDGE_SUNKEN,
223 BF_RECT | BF_MIDDLE | BF_ADJUST);
224
225 TOOLBAR_DrawPattern (hdc, &rc);
226 if (dwStyle & TBSTYLE_FLAT)
227 {
228 if (infoPtr->himlDef != NULL)
229 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
230 rc.left+2, rc.top+2, ILD_NORMAL);
231 else
232 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
233 rc.left+2, rc.top+2, ILD_NORMAL);
234 }
235 else
236 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
237 rc.left+2, rc.top+2, ILD_NORMAL);
238 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
239 return;
240 }
241
242 /* indeterminate */
243 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
244 DrawEdge (hdc, &rc, EDGE_RAISED,
245 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
246
247 TOOLBAR_DrawPattern (hdc, &rc);
248 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
249 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
250 return;
251 }
252
253 if (dwStyle & TBSTYLE_FLAT)
254 {
255 if(btnPtr->bHot)
256 DrawEdge (hdc, &rc, BDR_RAISEDINNER,
257 BF_RECT | BF_MIDDLE | BF_SOFT);
258
259 if(infoPtr->himlDef != NULL)
260 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
261 rc.left +2, rc.top +2, ILD_NORMAL);
262 else
263 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
264 rc.left +2, rc.top +2, ILD_NORMAL);
265 }
266 else{
267 /* normal state */
268 DrawEdge (hdc, &rc, EDGE_RAISED,
269 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
270
271 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
272 rc.left+1, rc.top+1, ILD_NORMAL);
273 }
274
275 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
276}
277
278
279static void
280TOOLBAR_Refresh (HWND hwnd, HDC hdc)
281{
282 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
283 TBUTTON_INFO *btnPtr;
284 INT i;
285
286 /* draw buttons */
287 btnPtr = infoPtr->buttons;
288 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
289 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
290}
291
292
293static void
294TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
295{
296 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
297 TBUTTON_INFO *btnPtr;
298 INT i;
299 HDC hdc;
300 HFONT hOldFont;
301 SIZE sz;
302
303 lpSize->cx = 0;
304 lpSize->cy = 0;
305 hdc = GetDC (0);
306 hOldFont = SelectObject (hdc, infoPtr->hFont);
307
308 btnPtr = infoPtr->buttons;
309 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
310 if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
311 (btnPtr->iString > -1) &&
312 (btnPtr->iString < infoPtr->nNumStrings)) {
313 LPWSTR lpText = infoPtr->strings[btnPtr->iString];
314 GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
315 if (sz.cx > lpSize->cx)
316 lpSize->cx = sz.cx;
317 if (sz.cy > lpSize->cy)
318 lpSize->cy = sz.cy;
319 }
320 }
321
322 SelectObject (hdc, hOldFont);
323 ReleaseDC (0, hdc);
324
325// TRACE (toolbar, "string size %d x %d!\n", lpSize->cx, lpSize->cy);
326}
327
328/***********************************************************************
329* TOOLBAR_WrapToolbar
330*
331* This function walks through the buttons and seperators in the
332* toolbar, and sets the TBSTATE_WRAP flag only on those items where
333* wrapping should occur based on the width of the toolbar window.
334* It does *not* calculate button placement itself. That task
335* takes place in TOOLBAR_CalcToolbar. If the program wants to manage
336* the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
337* flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
338*/
339
340static void
341TOOLBAR_WrapToolbar( HWND hwnd )
342{
343 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
344 TBUTTON_INFO *btnPtr;
345 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
346 INT x, cx, i, j;
347 RECT rc;
348 BOOL bWrap, bButtonWrap;
349
350 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
351 /* no layout is necessary. Applications may use this style */
352 /* to perform their own layout on the toolbar. */
353 if( !(dwStyle & TBSTYLE_WRAPABLE) )
354 return;
355
356 btnPtr = infoPtr->buttons;
357 x = infoPtr->nIndent;
358
359 GetClientRect( GetParent(hwnd), &rc );
360 infoPtr->nWidth = rc.right - rc.left;
361 bButtonWrap = FALSE;
362
363 for (i = 0; i < infoPtr->nNumButtons; i++ )
364 {
365 bWrap = FALSE;
366 btnPtr[i].fsState &= ~TBSTATE_WRAP;
367
368 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
369 continue;
370
371 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
372 /* it is the actual width of the separator. This is used for */
373 /* custom controls in toolbars. */
374 if (btnPtr[i].fsStyle & TBSTYLE_SEP)
375 cx = (btnPtr[i].iBitmap > 0) ?
376 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
377 else
378 cx = infoPtr->nButtonWidth;
379
380 /* Two or more adjacent separators form a separator group. */
381 /* The first separator in a group should be wrapped to the */
382 /* next row if the previous wrapping is on a button. */
383 if( bButtonWrap &&
384 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
385 (i + 1 < infoPtr->nNumButtons ) &&
386 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
387 {
388 btnPtr[i].fsState |= TBSTATE_WRAP;
389 x = infoPtr->nIndent;
390 i++;
391 bButtonWrap = FALSE;
392 continue;
393 }
394
395 /* The layout makes sure the bitmap is visible, but not the button. */
396 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
397 > infoPtr->nWidth )
398 {
399 BOOL bFound = FALSE;
400
401 /* If the current button is a separator and not hidden, */
402 /* go to the next until it reaches a non separator. */
403 /* Wrap the last separator if it is before a button. */
404 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
405 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
406 i < infoPtr->nNumButtons )
407 {
408 i++;
409 bFound = TRUE;
410 }
411
412 if( bFound && i < infoPtr->nNumButtons )
413 {
414 i--;
415 btnPtr[i].fsState |= TBSTATE_WRAP;
416 x = infoPtr->nIndent;
417 bButtonWrap = FALSE;
418 continue;
419 }
420 else if ( i >= infoPtr->nNumButtons)
421 break;
422
423 /* If the current button is not a separator, find the last */
424 /* separator and wrap it. */
425 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
426 {
427 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
428 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
429 {
430 bFound = TRUE;
431 i = j;
432 x = infoPtr->nIndent;
433 btnPtr[j].fsState |= TBSTATE_WRAP;
434 bButtonWrap = FALSE;
435 break;
436 }
437 }
438
439 /* If no separator available for wrapping, wrap one of */
440 /* non-hidden previous button. */
441 if (!bFound)
442 {
443 for ( j = i - 1;
444 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
445 {
446 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
447 continue;
448
449 bFound = TRUE;
450 i = j;
451 x = infoPtr->nIndent;
452 btnPtr[j].fsState |= TBSTATE_WRAP;
453 bButtonWrap = TRUE;
454 break;
455 }
456 }
457
458 /* If all above failed, wrap the current button. */
459 if (!bFound)
460 {
461 btnPtr[i].fsState |= TBSTATE_WRAP;
462 bFound = TRUE;
463 x = infoPtr->nIndent;
464 if (btnPtr[i].fsState & TBSTYLE_SEP )
465 bButtonWrap = FALSE;
466 else
467 bButtonWrap = TRUE;
468 }
469 }
470 else
471 x += cx;
472 }
473}
474
475/***********************************************************************
476* TOOLBAR_CalcToolbar
477*
478* This function calculates button and separator placement. It first
479* calculates the button sizes, gets the toolbar window width and then
480* calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
481* on. It assigns a new location to each item and sends this location to
482* the tooltip window if appropriate. Finally, it updates the rcBound
483* rect and calculates the new required toolbar window height.
484*/
485
486static void
487TOOLBAR_CalcToolbar (HWND hwnd)
488{
489 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
490 TBUTTON_INFO *btnPtr;
491 INT i, nRows, nSepRows;
492 INT x, y, cx, cy;
493 SIZE sizeString;
494 RECT rc;
495 BOOL bWrap;
496
497 TOOLBAR_CalcStrings (hwnd, &sizeString);
498
499 if (sizeString.cy > 0)
500 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
501 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
502 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
503
504 if (sizeString.cx > infoPtr->nBitmapWidth)
505 infoPtr->nButtonWidth = sizeString.cx + 6;
506 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
507 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
508
509 TOOLBAR_WrapToolbar( hwnd );
510
511 x = infoPtr->nIndent;
512 y = TOP_BORDER;
513 cx = infoPtr->nButtonWidth;
514 cy = infoPtr->nButtonHeight;
515 nRows = nSepRows = 0;
516
517 infoPtr->rcBound.top = y;
518 infoPtr->rcBound.left = x;
519 infoPtr->rcBound.bottom = y + cy;
520 infoPtr->rcBound.right = x;
521
522 btnPtr = infoPtr->buttons;
523 GetClientRect( GetParent(hwnd), &rc );
524 infoPtr->nWidth = rc.right - rc.left;
525
526 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
527 {
528 bWrap = FALSE;
529 if (btnPtr->fsState & TBSTATE_HIDDEN)
530 {
531 SetRectEmpty (&btnPtr->rect);
532 continue;
533 }
534
535 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
536 /* it is the actual width of the separator. This is used for */
537 /* custom controls in toolbars. */
538 if (btnPtr->fsStyle & TBSTYLE_SEP)
539 cx = (btnPtr->iBitmap > 0) ?
540 btnPtr->iBitmap : SEPARATOR_WIDTH;
541 else
542 cx = infoPtr->nButtonWidth;
543
544 if (btnPtr->fsState & TBSTATE_WRAP )
545 bWrap = TRUE;
546
547 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
548
549 if (infoPtr->rcBound.left > x)
550 infoPtr->rcBound.left = x;
551 if (infoPtr->rcBound.right < x + cx)
552 infoPtr->rcBound.right = x + cx;
553 if (infoPtr->rcBound.bottom < y + cy)
554 infoPtr->rcBound.bottom = y + cy;
555
556 /* Set the toolTip only for non-hidden, non-separator button */
557 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
558 {
559 TTTOOLINFOA ti;
560
561 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
562 ti.cbSize = sizeof(TTTOOLINFOA);
563 ti.hwnd = hwnd;
564 ti.uId = btnPtr->idCommand;
565 ti.rect = btnPtr->rect;
566 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
567 0, (LPARAM)&ti);
568 }
569
570 /* btnPtr->nRow is zero based. The space between the rows is */
571 /* also considered as a row. */
572 btnPtr->nRow = nRows + nSepRows;
573 if( bWrap )
574 {
575 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
576 y += cy;
577 else
578 {
579 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
580 /* it is the actual width of the separator. This is used for */
581 /* custom controls in toolbars. */
582 y += cy + ( (btnPtr->iBitmap > 0 ) ?
583 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
584
585 /* nSepRows is used to calculate the extra height follwoing */
586 /* the last row. */
587 nSepRows++;
588 }
589 x = infoPtr->nIndent;
590 nRows++;
591 }
592 else
593 x += cx;
594 }
595
596 /* infoPtr->nRows is the number of rows on the toolbar */
597 infoPtr->nRows = nRows + nSepRows + 1;
598
599 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
600 /* the last row. */
601 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
602 nSepRows * SEPARATOR_WIDTH * 2 / 3 +
603 nSepRows * (infoPtr->nBitmapHeight + 1) +
604 BOTTOM_BORDER;
605// TRACE (toolbar, "toolbar height %d\n", infoPtr->nHeight);
606}
607
608
609static INT
610TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
611{
612 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
613 TBUTTON_INFO *btnPtr;
614 INT i;
615
616 btnPtr = infoPtr->buttons;
617 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
618 if (btnPtr->fsState & TBSTATE_HIDDEN)
619 continue;
620
621 if (btnPtr->fsStyle & TBSTYLE_SEP) {
622 if (PtInRect (&btnPtr->rect, *lpPt)) {
623// TRACE (toolbar, " ON SEPARATOR %d!\n", i);
624 return -i;
625 }
626 }
627 else {
628 if (PtInRect (&btnPtr->rect, *lpPt)) {
629// TRACE (toolbar, " ON BUTTON %d!\n", i);
630 return i;
631 }
632 }
633 }
634
635// TRACE (toolbar, " NOWHERE!\n");
636 return -1;
637}
638
639
640static INT
641TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand)
642{
643 TBUTTON_INFO *btnPtr;
644 INT i;
645
646 btnPtr = infoPtr->buttons;
647 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
648 if (btnPtr->idCommand == idCommand) {
649// TRACE (toolbar, "command=%d index=%d\n", idCommand, i);
650 return i;
651 }
652 }
653// TRACE (toolbar, "no index found for command=%d\n", idCommand);
654 return -1;
655}
656
657
658static INT
659TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
660{
661 TBUTTON_INFO *btnPtr;
662 INT nRunIndex;
663
664 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
665 return -1;
666
667 /* check index button */
668 btnPtr = &infoPtr->buttons[nIndex];
669 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
670 if (btnPtr->fsState & TBSTATE_CHECKED)
671 return nIndex;
672 }
673
674 /* check previous buttons */
675 nRunIndex = nIndex - 1;
676 while (nRunIndex >= 0) {
677 btnPtr = &infoPtr->buttons[nRunIndex];
678 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
679 if (btnPtr->fsState & TBSTATE_CHECKED)
680 return nRunIndex;
681 }
682 else
683 break;
684 nRunIndex--;
685 }
686
687 /* check next buttons */
688 nRunIndex = nIndex + 1;
689 while (nRunIndex < infoPtr->nNumButtons) {
690 btnPtr = &infoPtr->buttons[nRunIndex];
691 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
692 if (btnPtr->fsState & TBSTATE_CHECKED)
693 return nRunIndex;
694 }
695 else
696 break;
697 nRunIndex++;
698 }
699
700 return -1;
701}
702
703
704static VOID
705TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
706 WPARAM wParam, LPARAM lParam)
707{
708 MSG msg;
709
710 msg.hwnd = hwndMsg;
711 msg.message = uMsg;
712 msg.wParam = wParam;
713 msg.lParam = lParam;
714 msg.time = GetMessageTime ();
715 msg.pt.x = LOWORD(GetMessagePos ());
716 msg.pt.y = HIWORD(GetMessagePos ());
717
718 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
719}
720
721
722/***********************************************************************
723 * TOOLBAR_CustomizeDialogProc
724 * This function implements the toolbar customization dialog.
725 */
726BOOL WINAPI
727TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
728{
729 TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER);
730 static HDSA hDsa = NULL;
731
732 switch (uMsg)
733 {
734 case WM_INITDIALOG:
735 infoPtr = (TOOLBAR_INFO *)lParam;
736 SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr);
737
738 hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5);
739
740 if (infoPtr)
741 {
742 TBUTTON_INFO *btnPtr;
743 INT i;
744
745 /* insert 'virtual' separator button into 'available buttons' list */
746 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
747
748 /* copy all buttons and append them to the right listbox */
749 btnPtr = infoPtr->buttons;
750 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
751 {
752 DSA_InsertItem (hDsa, i, btnPtr);
753
754 if (btnPtr->fsState & TBSTATE_HIDDEN)
755 {
756 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
757 }
758 else
759 {
760 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
761 }
762 }
763
764 /* append 'virtual' sepatator button to the 'toolbar buttons' list */
765 /* TODO */
766 }
767 return TRUE;
768
769 case WM_CLOSE:
770 EndDialog(hwnd, FALSE);
771 return TRUE;
772
773 case WM_COMMAND:
774 switch (LOWORD(wParam))
775 {
776 case IDCANCEL:
777 EndDialog(hwnd, FALSE);
778 break;
779 }
780 return TRUE;
781
782 case WM_DESTROY:
783 if (hDsa)
784 DSA_Destroy (hDsa);
785 return TRUE;
786
787 case WM_DRAWITEM:
788 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
789 {
790 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
791 RECT rcButton;
792 RECT rcText;
793 HPEN hOldPen;
794 HBRUSH hOldBrush;
795 COLORREF oldText = 0;
796 COLORREF oldBk = 0;
797
798// FIXME(toolbar, "action: %x itemState: %x\n",
799// lpdis->itemAction, lpdis->itemState);
800
801 if (lpdis->itemState & ODS_FOCUS)
802 {
803 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
804 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
805 }
806
807 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
808 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
809
810 /* fill background rectangle */
811 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
812 lpdis->rcItem.right, lpdis->rcItem.bottom);
813
814 /* calculate button and text rectangles */
815 CopyRect (&rcButton, &lpdis->rcItem);
816 InflateRect (&rcButton, -1, -1);
817 CopyRect (&rcText, &rcButton);
818 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6;
819 rcText.left = rcButton.right + 2;
820
821 /* draw focus rectangle */
822 if (lpdis->itemState & ODS_FOCUS)
823 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
824
825 /* draw button */
826 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
827
828 /* draw text */
829 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0)
830 DrawTextA (lpdis->hDC, "Separator", -1, &rcText,
831 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
832
833 if (lpdis->itemState & ODS_FOCUS)
834 {
835 SetBkColor (lpdis->hDC, oldBk);
836 SetTextColor (lpdis->hDC, oldText);
837 }
838
839 SelectObject (lpdis->hDC, hOldBrush);
840 SelectObject (lpdis->hDC, hOldPen);
841
842 return TRUE;
843 }
844 return FALSE;
845
846 case WM_MEASUREITEM:
847 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
848 {
849 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
850
851 if (infoPtr)
852 lpmis->itemHeight = infoPtr->nBitmapHeight + 8;
853 else
854 lpmis->itemHeight = 16 + 8; /* default height */
855
856 return TRUE;
857 }
858 return FALSE;
859
860 default:
861 return FALSE;
862 }
863}
864
865
866/***********************************************************************
867 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
868 *
869 */
870static LRESULT
871TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
872{
873 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
874 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
875 INT nIndex = 0;
876
877 if ((!lpAddBmp) || ((INT)wParam <= 0))
878 return -1;
879
880// TRACE (toolbar, "adding %d bitmaps!\n", wParam);
881
882 if (!(infoPtr->himlStd)) {
883 /* create new standard image list */
884
885// TRACE (toolbar, "creating standard image list!\n");
886
887
888 /* Windows resize all the buttons to the size of a newly added STandard Image*/
889 /* TODO: The resizing should be done each time a standard image is added*/
890 if (lpAddBmp->hInst == HINST_COMMCTRL)
891 {
892
893 if (lpAddBmp->nID & 1)
894 {
895 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
896 MAKELPARAM((WORD)26, (WORD)26));
897 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
898 MAKELPARAM((WORD)33, (WORD)33));
899 }
900 else
901 {
902 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
903 MAKELPARAM((WORD)16, (WORD)16));
904
905 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
906 MAKELPARAM((WORD)22, (WORD)22));
907 }
908
909 TOOLBAR_CalcToolbar (hwnd);
910 }
911
912 infoPtr->himlStd =
913 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
914 ILC_COLOR | ILC_MASK, (INT)wParam, 2);
915 }
916
917 /* Add bitmaps to the standard image list */
918 if (lpAddBmp->hInst == (HINSTANCE)0) {
919 nIndex =
920 ImageList_AddMasked (infoPtr->himlStd, (HBITMAP)lpAddBmp->nID,
921 CLR_DEFAULT);
922 }
923 else if (lpAddBmp->hInst == HINST_COMMCTRL) {
924 /* add internal bitmaps */
925
926// FIXME (toolbar, "internal bitmaps not supported!\n");
927 /* TODO: Resize all the buttons when a new standard image is added */
928
929 /* Hack to "add" some reserved images within the image list
930 to get the right image indices */
931 nIndex = ImageList_GetImageCount (infoPtr->himlStd);
932 ImageList_SetImageCount (infoPtr->himlStd, nIndex + (INT)wParam);
933
934 }
935 else {
936 HBITMAP hBmp =
937 LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
938 nIndex = ImageList_AddMasked (infoPtr->himlStd, hBmp, CLR_DEFAULT);
939
940 DeleteObject (hBmp);
941 }
942
943 infoPtr->nNumBitmaps += (INT)wParam;
944
945 return nIndex;
946}
947
948
949static LRESULT
950TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
951{
952 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
953 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
954 INT nOldButtons, nNewButtons, nAddButtons, nCount;
955
956// TRACE (toolbar, "adding %d buttons!\n", wParam);
957
958 nAddButtons = (UINT)wParam;
959 nOldButtons = infoPtr->nNumButtons;
960 nNewButtons = nOldButtons + nAddButtons;
961
962 if (infoPtr->nNumButtons == 0) {
963 infoPtr->buttons =
964 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
965 }
966 else {
967 TBUTTON_INFO *oldButtons = infoPtr->buttons;
968 infoPtr->buttons =
969 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
970 memcpy (&infoPtr->buttons[0], &oldButtons[0],
971 nOldButtons * sizeof(TBUTTON_INFO));
972 COMCTL32_Free (oldButtons);
973 }
974
975 infoPtr->nNumButtons = nNewButtons;
976
977 /* insert new button data */
978 for (nCount = 0; nCount < nAddButtons; nCount++) {
979 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
980 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
981 btnPtr->idCommand = lpTbb[nCount].idCommand;
982 btnPtr->fsState = lpTbb[nCount].fsState;
983 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
984 btnPtr->dwData = lpTbb[nCount].dwData;
985 btnPtr->iString = lpTbb[nCount].iString;
986 btnPtr->bHot = FALSE;
987
988 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
989 TTTOOLINFOA ti;
990
991 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
992 ti.cbSize = sizeof (TTTOOLINFOA);
993 ti.hwnd = hwnd;
994 ti.uId = btnPtr->idCommand;
995 ti.hinst = 0;
996 ti.lpszText = LPSTR_TEXTCALLBACKA;
997
998 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
999 0, (LPARAM)&ti);
1000 }
1001 }
1002
1003 TOOLBAR_CalcToolbar (hwnd);
1004
1005 InvalidateRect(hwnd, NULL, FALSE);
1006
1007 return TRUE;
1008}
1009
1010
1011/* << TOOLBAR_AddButtons32W >> */
1012
1013
1014static LRESULT
1015TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1016{
1017 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1018 INT nIndex;
1019
1020 if ((wParam) && (HIWORD(lParam) == 0)) {
1021 char szString[256];
1022 INT len;
1023// TRACE (toolbar, "adding string from resource!\n");
1024
1025 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
1026 szString, 256);
1027
1028// TRACE (toolbar, "len=%d \"%s\"\n", len, szString);
1029 nIndex = infoPtr->nNumStrings;
1030 if (infoPtr->nNumStrings == 0) {
1031 infoPtr->strings =
1032 COMCTL32_Alloc (sizeof(LPWSTR));
1033 }
1034 else {
1035 LPWSTR *oldStrings = infoPtr->strings;
1036 infoPtr->strings =
1037 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1038 memcpy (&infoPtr->strings[0], &oldStrings[0],
1039 sizeof(LPWSTR) * infoPtr->nNumStrings);
1040 COMCTL32_Free (oldStrings);
1041 }
1042
1043 infoPtr->strings[infoPtr->nNumStrings] =
1044 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1045 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
1046 infoPtr->nNumStrings++;
1047 }
1048 else {
1049 LPSTR p = (LPSTR)lParam;
1050 INT len;
1051
1052 if (p == NULL)
1053 return -1;
1054// TRACE (toolbar, "adding string(s) from array!\n");
1055 nIndex = infoPtr->nNumStrings;
1056 while (*p) {
1057 len = lstrlenA (p);
1058// TRACE (toolbar, "len=%d \"%s\"\n", len, p);
1059
1060 if (infoPtr->nNumStrings == 0) {
1061 infoPtr->strings =
1062 COMCTL32_Alloc (sizeof(LPWSTR));
1063 }
1064 else {
1065 LPWSTR *oldStrings = infoPtr->strings;
1066 infoPtr->strings =
1067 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1068 memcpy (&infoPtr->strings[0], &oldStrings[0],
1069 sizeof(LPWSTR) * infoPtr->nNumStrings);
1070 COMCTL32_Free (oldStrings);
1071 }
1072
1073 infoPtr->strings[infoPtr->nNumStrings] =
1074 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1075 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
1076 infoPtr->nNumStrings++;
1077
1078 p += (len+1);
1079 }
1080 }
1081
1082 return nIndex;
1083}
1084
1085
1086static LRESULT
1087TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1088{
1089 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1090 INT nIndex;
1091
1092 if ((wParam) && (HIWORD(lParam) == 0)) {
1093 WCHAR szString[256];
1094 INT len;
1095// TRACE (toolbar, "adding string from resource!\n");
1096
1097 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
1098 szString, 256);
1099
1100// TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(szString));
1101 nIndex = infoPtr->nNumStrings;
1102 if (infoPtr->nNumStrings == 0) {
1103 infoPtr->strings =
1104 COMCTL32_Alloc (sizeof(LPWSTR));
1105 }
1106 else {
1107 LPWSTR *oldStrings = infoPtr->strings;
1108 infoPtr->strings =
1109 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1110 memcpy (&infoPtr->strings[0], &oldStrings[0],
1111 sizeof(LPWSTR) * infoPtr->nNumStrings);
1112 COMCTL32_Free (oldStrings);
1113 }
1114
1115 infoPtr->strings[infoPtr->nNumStrings] =
1116 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1117 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
1118 infoPtr->nNumStrings++;
1119 }
1120 else {
1121 LPWSTR p = (LPWSTR)lParam;
1122 INT len;
1123
1124 if (p == NULL)
1125 return -1;
1126// TRACE (toolbar, "adding string(s) from array!\n");
1127 nIndex = infoPtr->nNumStrings;
1128 while (*p) {
1129 len = lstrlenW (p);
1130// TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(p));
1131
1132 if (infoPtr->nNumStrings == 0) {
1133 infoPtr->strings =
1134 COMCTL32_Alloc (sizeof(LPWSTR));
1135 }
1136 else {
1137 LPWSTR *oldStrings = infoPtr->strings;
1138 infoPtr->strings =
1139 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1140 memcpy (&infoPtr->strings[0], &oldStrings[0],
1141 sizeof(LPWSTR) * infoPtr->nNumStrings);
1142 COMCTL32_Free (oldStrings);
1143 }
1144
1145 infoPtr->strings[infoPtr->nNumStrings] =
1146 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1147 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
1148 infoPtr->nNumStrings++;
1149
1150 p += (len+1);
1151 }
1152 }
1153
1154 return nIndex;
1155}
1156
1157
1158static LRESULT
1159TOOLBAR_AutoSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1160{
1161 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1162 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1163 RECT parent_rect;
1164 HWND parent;
1165 /* INT32 x, y; */
1166 INT cx, cy;
1167 UINT uPosFlags = 0;
1168
1169// TRACE (toolbar, "resize forced!\n");
1170
1171 parent = GetParent (hwnd);
1172 GetClientRect(parent, &parent_rect);
1173
1174 if (dwStyle & CCS_NORESIZE) {
1175 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
1176 cx = 0;
1177 cy = 0;
1178 }
1179 else {
1180 infoPtr->nWidth = parent_rect.right - parent_rect.left;
1181 TOOLBAR_CalcToolbar (hwnd);
1182 InvalidateRect( hwnd, NULL, TRUE );
1183 cy = infoPtr->nHeight;
1184 cx = infoPtr->nWidth;
1185 }
1186
1187 if (dwStyle & CCS_NOPARENTALIGN)
1188 uPosFlags |= SWP_NOMOVE;
1189
1190 if (!(dwStyle & CCS_NODIVIDER))
1191 cy += GetSystemMetrics(SM_CYEDGE);
1192
1193 infoPtr->bAutoSize = TRUE;
1194 SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
1195 cx, cy, uPosFlags);
1196
1197 return 0;
1198}
1199
1200
1201static LRESULT
1202TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1203{
1204 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1205
1206 return infoPtr->nNumButtons;
1207}
1208
1209
1210static LRESULT
1211TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1212{
1213 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1214
1215 if (infoPtr == NULL) {
1216// ERR (toolbar, "(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
1217// ERR (toolbar, "infoPtr == NULL!\n");
1218 return 0;
1219 }
1220
1221 infoPtr->dwStructSize = (DWORD)wParam;
1222
1223 return 0;
1224}
1225
1226
1227static LRESULT
1228TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1229{
1230 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1231 TBUTTON_INFO *btnPtr;
1232 HDC hdc;
1233 INT nIndex;
1234
1235 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1236 if (nIndex == -1)
1237 return FALSE;
1238
1239 btnPtr = &infoPtr->buttons[nIndex];
1240 btnPtr->iBitmap = LOWORD(lParam);
1241
1242 hdc = GetDC (hwnd);
1243 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1244 ReleaseDC (hwnd, hdc);
1245
1246 return TRUE;
1247}
1248
1249
1250static LRESULT
1251TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1252{
1253 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1254 TBUTTON_INFO *btnPtr;
1255 HDC hdc;
1256 INT nIndex;
1257 INT nOldIndex = -1;
1258
1259 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1260 if (nIndex == -1)
1261 return FALSE;
1262
1263 btnPtr = &infoPtr->buttons[nIndex];
1264
1265 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
1266 return FALSE;
1267
1268 if (LOWORD(lParam) == FALSE)
1269 btnPtr->fsState &= ~TBSTATE_CHECKED;
1270 else {
1271 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
1272 nOldIndex =
1273 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
1274 if (nOldIndex == nIndex)
1275 return 0;
1276 if (nOldIndex != -1)
1277 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
1278 }
1279 btnPtr->fsState |= TBSTATE_CHECKED;
1280 }
1281
1282 hdc = GetDC (hwnd);
1283 if (nOldIndex != -1)
1284 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
1285 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1286 ReleaseDC (hwnd, hdc);
1287
1288 /* FIXME: Send a WM_NOTIFY?? */
1289
1290 return TRUE;
1291}
1292
1293
1294static LRESULT
1295TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
1296{
1297 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1298
1299 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1300}
1301
1302
1303static LRESULT
1304TOOLBAR_Customize (HWND hwnd)
1305{
1306 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1307 LRESULT ret;
1308 LPCVOID template;
1309 HRSRC hRes;
1310 NMHDR nmhdr;
1311
1312 /* send TBN_BEGINADJUST notification */
1313 nmhdr.hwndFrom = hwnd;
1314 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1315 nmhdr.code = TBN_BEGINADJUST;
1316
1317 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1318 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1319
1320 if (!(hRes = FindResourceA (COMCTL32_hModule,
1321 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
1322 RT_DIALOGA)))
1323 return FALSE;
1324
1325 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
1326 return FALSE;
1327
1328 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
1329 (LPDLGTEMPLATEA)template,
1330 hwnd,
1331 (DLGPROC)TOOLBAR_CustomizeDialogProc,
1332 (LPARAM)infoPtr);
1333
1334 /* send TBN_ENDADJUST notification */
1335 nmhdr.code = TBN_ENDADJUST;
1336
1337 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1338 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1339
1340 return ret;
1341}
1342
1343
1344static LRESULT
1345TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1346{
1347 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1348 INT nIndex = (INT)wParam;
1349
1350 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1351 return FALSE;
1352
1353 if ((infoPtr->hwndToolTip) &&
1354 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
1355 TTTOOLINFOA ti;
1356
1357 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1358 ti.cbSize = sizeof (TTTOOLINFOA);
1359 ti.hwnd = hwnd;
1360 ti.uId = infoPtr->buttons[nIndex].idCommand;
1361
1362 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
1363 }
1364
1365 if (infoPtr->nNumButtons == 1) {
1366// TRACE (toolbar, " simple delete!\n");
1367 COMCTL32_Free (infoPtr->buttons);
1368 infoPtr->buttons = NULL;
1369 infoPtr->nNumButtons = 0;
1370 }
1371 else {
1372 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1373// TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex);
1374
1375 infoPtr->nNumButtons--;
1376 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1377 if (nIndex > 0) {
1378 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1379 nIndex * sizeof(TBUTTON_INFO));
1380 }
1381
1382 if (nIndex < infoPtr->nNumButtons) {
1383 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
1384 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
1385 }
1386
1387 COMCTL32_Free (oldButtons);
1388 }
1389
1390 TOOLBAR_CalcToolbar (hwnd);
1391
1392 InvalidateRect (hwnd, NULL, TRUE);
1393
1394 return TRUE;
1395}
1396
1397
1398static LRESULT
1399TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1400{
1401 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1402 TBUTTON_INFO *btnPtr;
1403 HDC hdc;
1404 INT nIndex;
1405
1406 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1407 if (nIndex == -1)
1408 return FALSE;
1409
1410 btnPtr = &infoPtr->buttons[nIndex];
1411 if (LOWORD(lParam) == FALSE)
1412 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
1413 else
1414 btnPtr->fsState |= TBSTATE_ENABLED;
1415
1416 hdc = GetDC (hwnd);
1417 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1418 ReleaseDC (hwnd, hdc);
1419
1420 return TRUE;
1421}
1422
1423
1424/* << TOOLBAR_GetAnchorHighlight >> */
1425
1426
1427static LRESULT
1428TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1429{
1430 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1431 INT nIndex;
1432
1433 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1434 if (nIndex == -1)
1435 return -1;
1436
1437 return infoPtr->buttons[nIndex].iBitmap;
1438}
1439
1440
1441static LRESULT
1442TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
1443{
1444 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
1445}
1446
1447
1448static LRESULT
1449TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1450{
1451 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1452 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1453 INT nIndex = (INT)wParam;
1454 TBUTTON_INFO *btnPtr;
1455
1456 if (infoPtr == NULL)
1457 return FALSE;
1458
1459 if (lpTbb == NULL)
1460 return FALSE;
1461
1462 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1463 return FALSE;
1464
1465 btnPtr = &infoPtr->buttons[nIndex];
1466 lpTbb->iBitmap = btnPtr->iBitmap;
1467 lpTbb->idCommand = btnPtr->idCommand;
1468 lpTbb->fsState = btnPtr->fsState;
1469 lpTbb->fsStyle = btnPtr->fsStyle;
1470 lpTbb->dwData = btnPtr->dwData;
1471 lpTbb->iString = btnPtr->iString;
1472
1473 return TRUE;
1474}
1475
1476
1477static LRESULT
1478TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1479{
1480 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1481 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
1482 TBUTTON_INFO *btnPtr;
1483 INT nIndex;
1484
1485 if (infoPtr == NULL)
1486 return -1;
1487 if (lpTbInfo == NULL)
1488 return -1;
1489 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
1490 return -1;
1491
1492 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1493 if (nIndex == -1)
1494 return -1;
1495
1496 btnPtr = &infoPtr->buttons[nIndex];
1497
1498 if (lpTbInfo->dwMask & TBIF_COMMAND)
1499 lpTbInfo->idCommand = btnPtr->idCommand;
1500 if (lpTbInfo->dwMask & TBIF_IMAGE)
1501 lpTbInfo->iImage = btnPtr->iBitmap;
1502 if (lpTbInfo->dwMask & TBIF_LPARAM)
1503 lpTbInfo->lParam = btnPtr->dwData;
1504 if (lpTbInfo->dwMask & TBIF_SIZE)
1505 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1506 if (lpTbInfo->dwMask & TBIF_STATE)
1507 lpTbInfo->fsState = btnPtr->fsState;
1508 if (lpTbInfo->dwMask & TBIF_STYLE)
1509 lpTbInfo->fsStyle = btnPtr->fsStyle;
1510 if (lpTbInfo->dwMask & TBIF_TEXT) {
1511 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1512 lstrcpynA (lpTbInfo->pszText,
1513 (LPSTR)infoPtr->strings[btnPtr->iString],
1514 lpTbInfo->cchText);
1515 }
1516
1517 return nIndex;
1518}
1519
1520
1521/* << TOOLBAR_GetButtonInfo32W >> */
1522
1523
1524static LRESULT
1525TOOLBAR_GetButtonSize (HWND hwnd)
1526{
1527 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1528
1529 return MAKELONG((WORD)infoPtr->nButtonWidth,
1530 (WORD)infoPtr->nButtonHeight);
1531}
1532
1533
1534static LRESULT
1535TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1536{
1537 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1538 INT nIndex, nStringIndex;
1539
1540 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1541 if (nIndex == -1)
1542 return -1;
1543
1544 nStringIndex = infoPtr->buttons[nIndex].iString;
1545
1546// TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex);
1547
1548 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1549 return -1;
1550
1551 if (lParam == 0) return -1;
1552
1553 lstrcpyA ((LPSTR)lParam, (LPSTR)infoPtr->strings[nStringIndex]);
1554
1555 return lstrlenA ((LPSTR)infoPtr->strings[nStringIndex]);
1556}
1557
1558
1559/* << TOOLBAR_GetButtonText32W >> */
1560/* << TOOLBAR_GetColorScheme >> */
1561
1562
1563static LRESULT
1564TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1565{
1566 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1567
1568 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
1569 return (LRESULT)infoPtr->himlDis;
1570 else
1571 return 0;
1572}
1573
1574
1575static LRESULT
1576TOOLBAR_GetExtendedStyle (HWND hwnd)
1577{
1578 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1579
1580 return infoPtr->dwExStyle;
1581}
1582
1583
1584static LRESULT
1585TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1586{
1587 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1588
1589 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
1590 return (LRESULT)infoPtr->himlHot;
1591 else
1592 return 0;
1593}
1594
1595
1596/* << TOOLBAR_GetHotItem >> */
1597
1598
1599static LRESULT
1600TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1601{
1602 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1603
1604 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
1605 return (LRESULT)infoPtr->himlDef;
1606 else
1607 return 0;
1608}
1609
1610
1611/* << TOOLBAR_GetInsertMark >> */
1612/* << TOOLBAR_GetInsertMarkColor >> */
1613
1614
1615static LRESULT
1616TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1617{
1618 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1619 TBUTTON_INFO *btnPtr;
1620 LPRECT lpRect;
1621 INT nIndex;
1622
1623 if (infoPtr == NULL)
1624 return FALSE;
1625 nIndex = (INT)wParam;
1626 btnPtr = &infoPtr->buttons[nIndex];
1627 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1628 return FALSE;
1629 lpRect = (LPRECT)lParam;
1630 if (lpRect == NULL)
1631 return FALSE;
1632 if (btnPtr->fsState & TBSTATE_HIDDEN)
1633 return FALSE;
1634
1635 TOOLBAR_CalcToolbar( hwnd );
1636
1637 lpRect->left = btnPtr->rect.left;
1638 lpRect->right = btnPtr->rect.right;
1639 lpRect->bottom = btnPtr->rect.bottom;
1640 lpRect->top = btnPtr->rect.top;
1641
1642 return TRUE;
1643}
1644
1645
1646static LRESULT
1647TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1648{
1649 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1650 LPSIZE lpSize = (LPSIZE)lParam;
1651
1652 if (lpSize == NULL)
1653 return FALSE;
1654
1655 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
1656 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1657
1658// TRACE (toolbar, "maximum size %d x %d\n",
1659// infoPtr->rcBound.right - infoPtr->rcBound.left,
1660// infoPtr->rcBound.bottom - infoPtr->rcBound.top);
1661
1662 return TRUE;
1663}
1664
1665
1666/* << TOOLBAR_GetObject >> */
1667/* << TOOLBAR_GetPadding >> */
1668
1669
1670static LRESULT
1671TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1672{
1673 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1674 TBUTTON_INFO *btnPtr;
1675 LPRECT lpRect;
1676 INT nIndex;
1677
1678 if (infoPtr == NULL)
1679 return FALSE;
1680 nIndex = (INT)wParam;
1681 btnPtr = &infoPtr->buttons[nIndex];
1682 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1683 return FALSE;
1684 lpRect = (LPRECT)lParam;
1685 if (lpRect == NULL)
1686 return FALSE;
1687
1688 lpRect->left = btnPtr->rect.left;
1689 lpRect->right = btnPtr->rect.right;
1690 lpRect->bottom = btnPtr->rect.bottom;
1691 lpRect->top = btnPtr->rect.top;
1692
1693 return TRUE;
1694}
1695
1696
1697static LRESULT
1698TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1699{
1700 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1701
1702 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
1703 return infoPtr->nRows;
1704 else
1705 return 1;
1706}
1707
1708
1709static LRESULT
1710TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
1711{
1712 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1713 INT nIndex;
1714
1715 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1716 if (nIndex == -1)
1717 return -1;
1718
1719 return infoPtr->buttons[nIndex].fsState;
1720}
1721
1722
1723static LRESULT
1724TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
1725{
1726 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1727 INT nIndex;
1728
1729 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1730 if (nIndex == -1)
1731 return -1;
1732
1733 return infoPtr->buttons[nIndex].fsStyle;
1734}
1735
1736
1737static LRESULT
1738TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1739{
1740 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1741
1742 if (infoPtr == NULL)
1743 return 0;
1744
1745 return infoPtr->nMaxTextRows;
1746}
1747
1748
1749static LRESULT
1750TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
1751{
1752 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1753
1754 if (infoPtr == NULL)
1755 return 0;
1756 return infoPtr->hwndToolTip;
1757}
1758
1759
1760static LRESULT
1761TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
1762{
1763 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1764
1765// TRACE (toolbar, "%s hwnd=0x%x stub!\n",
1766// infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
1767
1768 return infoPtr->bUnicode;
1769}
1770
1771
1772static LRESULT
1773TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1774{
1775 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1776 TBUTTON_INFO *btnPtr;
1777 INT nIndex;
1778
1779 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1780 if (nIndex == -1)
1781 return FALSE;
1782
1783 btnPtr = &infoPtr->buttons[nIndex];
1784 if (LOWORD(lParam) == FALSE)
1785 btnPtr->fsState &= ~TBSTATE_HIDDEN;
1786 else
1787 btnPtr->fsState |= TBSTATE_HIDDEN;
1788
1789 TOOLBAR_CalcToolbar (hwnd);
1790
1791 InvalidateRect (hwnd, NULL, TRUE);
1792
1793 return TRUE;
1794}
1795
1796
1797static LRESULT
1798TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
1799{
1800 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
1801}
1802
1803
1804static LRESULT
1805TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1806{
1807 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1808 TBUTTON_INFO *btnPtr;
1809 HDC hdc;
1810 INT nIndex;
1811
1812 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1813 if (nIndex == -1)
1814 return FALSE;
1815
1816 btnPtr = &infoPtr->buttons[nIndex];
1817 if (LOWORD(lParam) == FALSE)
1818 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
1819 else
1820 btnPtr->fsState |= TBSTATE_INDETERMINATE;
1821
1822 hdc = GetDC (hwnd);
1823 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1824 ReleaseDC (hwnd, hdc);
1825
1826 return TRUE;
1827}
1828
1829
1830static LRESULT
1831TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1832{
1833 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1834 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1835 INT nIndex = (INT)wParam;
1836 TBUTTON_INFO *oldButtons;
1837
1838 if (lpTbb == NULL)
1839 return FALSE;
1840 if (nIndex < 0)
1841 return FALSE;
1842
1843// TRACE (toolbar, "inserting button index=%d\n", nIndex);
1844 if (nIndex > infoPtr->nNumButtons) {
1845 nIndex = infoPtr->nNumButtons;
1846// TRACE (toolbar, "adjust index=%d\n", nIndex);
1847 }
1848
1849 oldButtons = infoPtr->buttons;
1850 infoPtr->nNumButtons++;
1851 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1852 /* pre insert copy */
1853 if (nIndex > 0) {
1854 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1855 nIndex * sizeof(TBUTTON_INFO));
1856 }
1857
1858 /* insert new button */
1859 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
1860 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
1861 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
1862 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
1863 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
1864 infoPtr->buttons[nIndex].iString = lpTbb->iString;
1865
1866 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
1867 TTTOOLINFOA ti;
1868
1869 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1870 ti.cbSize = sizeof (TTTOOLINFOA);
1871 ti.hwnd = hwnd;
1872 ti.uId = lpTbb->idCommand;
1873 ti.hinst = 0;
1874 ti.lpszText = LPSTR_TEXTCALLBACKA;
1875
1876 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
1877 0, (LPARAM)&ti);
1878 }
1879
1880 /* post insert copy */
1881 if (nIndex < infoPtr->nNumButtons - 1) {
1882 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
1883 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
1884 }
1885
1886 COMCTL32_Free (oldButtons);
1887
1888 TOOLBAR_CalcToolbar (hwnd);
1889
1890 InvalidateRect (hwnd, NULL, FALSE);
1891
1892 return TRUE;
1893}
1894
1895
1896/* << TOOLBAR_InsertButton32W >> */
1897/* << TOOLBAR_InsertMarkHitTest >> */
1898
1899
1900static LRESULT
1901TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
1902{
1903 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1904 INT nIndex;
1905
1906 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1907 if (nIndex == -1)
1908 return FALSE;
1909
1910 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
1911}
1912
1913
1914static LRESULT
1915TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
1916{
1917 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1918 INT nIndex;
1919
1920 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1921 if (nIndex == -1)
1922 return FALSE;
1923
1924 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
1925}
1926
1927
1928static LRESULT
1929TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
1930{
1931 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1932 INT nIndex;
1933
1934 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1935 if (nIndex == -1)
1936 return FALSE;
1937
1938 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
1939}
1940
1941
1942static LRESULT
1943TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
1944{
1945 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1946 INT nIndex;
1947
1948 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1949 if (nIndex == -1)
1950 return FALSE;
1951
1952 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
1953}
1954
1955
1956static LRESULT
1957TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1958{
1959 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1960 INT nIndex;
1961
1962 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1963 if (nIndex == -1)
1964 return FALSE;
1965
1966 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
1967}
1968
1969
1970static LRESULT
1971TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
1972{
1973 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1974 INT nIndex;
1975
1976 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1977 if (nIndex == -1)
1978 return FALSE;
1979
1980 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
1981}
1982
1983
1984/* << TOOLBAR_LoadImages >> */
1985/* << TOOLBAR_MapAccelerator >> */
1986/* << TOOLBAR_MarkButton >> */
1987/* << TOOLBAR_MoveButton >> */
1988
1989
1990static LRESULT
1991TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1992{
1993 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1994 TBUTTON_INFO *btnPtr;
1995 HDC hdc;
1996 INT nIndex;
1997
1998 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1999 if (nIndex == -1)
2000 return FALSE;
2001
2002 btnPtr = &infoPtr->buttons[nIndex];
2003 if (LOWORD(lParam) == FALSE)
2004 btnPtr->fsState &= ~TBSTATE_PRESSED;
2005 else
2006 btnPtr->fsState |= TBSTATE_PRESSED;
2007
2008 hdc = GetDC (hwnd);
2009 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2010 ReleaseDC (hwnd, hdc);
2011
2012 return TRUE;
2013}
2014
2015
2016/* << TOOLBAR_ReplaceBitmap >> */
2017
2018
2019static LRESULT
2020TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2021{
2022#if 0
2023 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2024 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
2025
2026 if (lpSave == NULL) return 0;
2027
2028 if ((BOOL)wParam) {
2029 /* save toolbar information */
2030// FIXME (toolbar, "save to \"%s\" \"%s\"\n",
2031// lpSave->pszSubKey, lpSave->pszValueName);
2032
2033
2034 }
2035 else {
2036 /* restore toolbar information */
2037
2038// FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
2039// lpSave->pszSubKey, lpSave->pszValueName);
2040
2041
2042 }
2043#endif
2044
2045 return 0;
2046}
2047
2048
2049/* << TOOLBAR_SaveRestore32W >> */
2050/* << TOOLBAR_SetAnchorHighlight >> */
2051
2052
2053static LRESULT
2054TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2055{
2056 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2057
2058 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2059 return FALSE;
2060
2061 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
2062 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
2063
2064 return TRUE;
2065}
2066
2067
2068static LRESULT
2069TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2070{
2071 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2072 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
2073 TBUTTON_INFO *btnPtr;
2074 INT nIndex;
2075
2076 if (lptbbi == NULL)
2077 return FALSE;
2078 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
2079 return FALSE;
2080
2081 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2082 if (nIndex == -1)
2083 return FALSE;
2084
2085 btnPtr = &infoPtr->buttons[nIndex];
2086 if (lptbbi->dwMask & TBIF_COMMAND)
2087 btnPtr->idCommand = lptbbi->idCommand;
2088 if (lptbbi->dwMask & TBIF_IMAGE)
2089 btnPtr->iBitmap = lptbbi->iImage;
2090 if (lptbbi->dwMask & TBIF_LPARAM)
2091 btnPtr->dwData = lptbbi->lParam;
2092/* if (lptbbi->dwMask & TBIF_SIZE) */
2093/* btnPtr->cx = lptbbi->cx; */
2094 if (lptbbi->dwMask & TBIF_STATE)
2095 btnPtr->fsState = lptbbi->fsState;
2096 if (lptbbi->dwMask & TBIF_STYLE)
2097 btnPtr->fsStyle = lptbbi->fsStyle;
2098
2099 if (lptbbi->dwMask & TBIF_TEXT) {
2100 if ((btnPtr->iString >= 0) ||
2101 (btnPtr->iString < infoPtr->nNumStrings)) {
2102#if 0
2103 CHAR **lpString = &infoPtr->strings[btnPtr->iString];
2104 INT len = lstrlenA (lptbbi->pszText);
2105 *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1));
2106#endif
2107
2108 /* this is the ultimate sollution */
2109/* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2110 }
2111 }
2112
2113 return TRUE;
2114}
2115
2116
2117/* << TOOLBAR_SetButtonInfo32W >> */
2118
2119
2120static LRESULT
2121TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2122{
2123 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2124
2125 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2126 return FALSE;
2127
2128 infoPtr->nButtonWidth = (INT)LOWORD(lParam);
2129 infoPtr->nButtonHeight = (INT)HIWORD(lParam);
2130
2131 return TRUE;
2132}
2133
2134
2135static LRESULT
2136TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
2137{
2138 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2139
2140 if (infoPtr == NULL)
2141 return FALSE;
2142
2143 infoPtr->cxMin = (INT)LOWORD(lParam);
2144 infoPtr->cxMax = (INT)HIWORD(lParam);
2145
2146 return TRUE;
2147}
2148
2149
2150static LRESULT
2151TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
2152{
2153 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2154 INT nIndex = (INT)wParam;
2155
2156 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2157 return FALSE;
2158
2159 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
2160
2161 if (infoPtr->hwndToolTip) {
2162
2163// FIXME (toolbar, "change tool tip!\n");
2164
2165 }
2166
2167 return TRUE;
2168}
2169
2170
2171/* << TOOLBAR_SetColorScheme >> */
2172
2173
2174static LRESULT
2175TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2176{
2177 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2178 HIMAGELIST himlTemp;
2179
2180 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2181 return 0;
2182
2183 himlTemp = infoPtr->himlDis;
2184 infoPtr->himlDis = (HIMAGELIST)lParam;
2185
2186 /* FIXME: redraw ? */
2187
2188 return (LRESULT)himlTemp;
2189}
2190
2191
2192static LRESULT
2193TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2194{
2195 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2196 DWORD dwTemp;
2197
2198 dwTemp = infoPtr->dwDTFlags;
2199 infoPtr->dwDTFlags =
2200 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
2201
2202 return (LRESULT)dwTemp;
2203}
2204
2205
2206static LRESULT
2207TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2208{
2209 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2210 DWORD dwTemp;
2211
2212 dwTemp = infoPtr->dwExStyle;
2213 infoPtr->dwExStyle = (DWORD)lParam;
2214
2215 return (LRESULT)dwTemp;
2216}
2217
2218
2219static LRESULT
2220TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2221{
2222 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2223 HIMAGELIST himlTemp;
2224
2225 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2226 return 0;
2227
2228 himlTemp = infoPtr->himlHot;
2229 infoPtr->himlHot = (HIMAGELIST)lParam;
2230
2231 /* FIXME: redraw ? */
2232
2233 return (LRESULT)himlTemp;
2234}
2235
2236
2237/* << TOOLBAR_SetHotItem >> */
2238
2239
2240static LRESULT
2241TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2242{
2243 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2244 HIMAGELIST himlTemp;
2245
2246 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2247 return 0;
2248
2249 himlTemp = infoPtr->himlDef;
2250 infoPtr->himlDef = (HIMAGELIST)lParam;
2251
2252 /* FIXME: redraw ? */
2253
2254 return (LRESULT)himlTemp;
2255}
2256
2257
2258static LRESULT
2259TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2260{
2261 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2262
2263 infoPtr->nIndent = (INT)wParam;
2264
2265 TOOLBAR_CalcToolbar (hwnd);
2266
2267 InvalidateRect(hwnd, NULL, FALSE);
2268
2269 return TRUE;
2270}
2271
2272
2273/* << TOOLBAR_SetInsertMark >> */
2274
2275
2276static LRESULT
2277TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
2278{
2279 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2280
2281 infoPtr->clrInsertMark = (COLORREF)lParam;
2282
2283 /* FIXME : redraw ??*/
2284
2285 return 0;
2286}
2287
2288
2289static LRESULT
2290TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2291{
2292 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2293
2294 if (infoPtr == NULL)
2295 return FALSE;
2296
2297 infoPtr->nMaxTextRows = (INT)wParam;
2298
2299 return TRUE;
2300}
2301
2302
2303/* << TOOLBAR_SetPadding >> */
2304
2305
2306static LRESULT
2307TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2308{
2309 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2310 HWND hwndOldNotify;
2311
2312 if (infoPtr == NULL)
2313 return 0;
2314 hwndOldNotify = infoPtr->hwndNotify;
2315 infoPtr->hwndNotify = (HWND)wParam;
2316
2317 return hwndOldNotify;
2318}
2319
2320
2321static LRESULT
2322TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2323{
2324 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2325 LPRECT lprc = (LPRECT)lParam;
2326
2327 if (LOWORD(wParam) > 1) {
2328
2329// FIXME (toolbar, "multiple rows not supported!\n");
2330
2331 }
2332
2333 /* recalculate toolbar */
2334 TOOLBAR_CalcToolbar (hwnd);
2335
2336 /* return bounding rectangle */
2337 if (lprc) {
2338 lprc->left = infoPtr->rcBound.left;
2339 lprc->right = infoPtr->rcBound.right;
2340 lprc->top = infoPtr->rcBound.top;
2341 lprc->bottom = infoPtr->rcBound.bottom;
2342 }
2343
2344 /* repaint toolbar */
2345 InvalidateRect(hwnd, NULL, FALSE);
2346
2347 return 0;
2348}
2349
2350
2351static LRESULT
2352TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
2353{
2354 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2355 TBUTTON_INFO *btnPtr;
2356 HDC hdc;
2357 INT nIndex;
2358
2359 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2360 if (nIndex == -1)
2361 return FALSE;
2362
2363 btnPtr = &infoPtr->buttons[nIndex];
2364 btnPtr->fsState = LOWORD(lParam);
2365
2366 hdc = GetDC (hwnd);
2367 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2368 ReleaseDC (hwnd, hdc);
2369
2370 return TRUE;
2371}
2372
2373
2374static LRESULT
2375TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2376{
2377 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2378 TBUTTON_INFO *btnPtr;
2379 HDC hdc;
2380 INT nIndex;
2381
2382 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2383 if (nIndex == -1)
2384 return FALSE;
2385
2386 btnPtr = &infoPtr->buttons[nIndex];
2387 btnPtr->fsStyle = LOWORD(lParam);
2388
2389 hdc = GetDC (hwnd);
2390 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2391 ReleaseDC (hwnd, hdc);
2392
2393 if (infoPtr->hwndToolTip) {
2394
2395// FIXME (toolbar, "change tool tip!\n");
2396
2397 }
2398
2399 return TRUE;
2400}
2401
2402
2403static LRESULT
2404TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
2405{
2406 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2407
2408 if (infoPtr == NULL)
2409 return 0;
2410 infoPtr->hwndToolTip = (HWND)wParam;
2411 return 0;
2412}
2413
2414
2415static LRESULT
2416TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2417{
2418 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2419 BOOL bTemp;
2420
2421// TRACE (toolbar, "%s hwnd=0x%04x stub!\n",
2422// ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
2423
2424 bTemp = infoPtr->bUnicode;
2425 infoPtr->bUnicode = (BOOL)wParam;
2426
2427 return bTemp;
2428}
2429
2430
2431static LRESULT
2432TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
2433{
2434 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2435 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2436 LOGFONTA logFont;
2437
2438 /* initialize info structure */
2439 infoPtr->nButtonHeight = 22;
2440 infoPtr->nButtonWidth = 23;
2441 infoPtr->nBitmapHeight = 15;
2442 infoPtr->nBitmapWidth = 16;
2443
2444 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
2445 infoPtr->nRows = 1;
2446 infoPtr->nMaxTextRows = 1;
2447 infoPtr->cxMin = -1;
2448 infoPtr->cxMax = -1;
2449
2450 infoPtr->bCaptured = FALSE;
2451 infoPtr->bUnicode = IsWindowUnicode (hwnd);
2452 infoPtr->nButtonDown = -1;
2453 infoPtr->nOldHit = -1;
2454 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
2455 infoPtr->hwndNotify = GetParent (hwnd);
2456 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
2457 infoPtr->dwDTFlags = DT_CENTER;
2458
2459 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
2460 infoPtr->hFont = CreateFontIndirectA (&logFont);
2461
2462 if (dwStyle & TBSTYLE_TOOLTIPS) {
2463 /* Create tooltip control */
2464 infoPtr->hwndToolTip =
2465 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
2466 CW_USEDEFAULT, CW_USEDEFAULT,
2467 CW_USEDEFAULT, CW_USEDEFAULT,
2468 hwnd, 0, 0, 0);
2469
2470 /* Send NM_TOOLTIPSCREATED notification */
2471 if (infoPtr->hwndToolTip) {
2472 NMTOOLTIPSCREATED nmttc;
2473
2474 nmttc.hdr.hwndFrom = hwnd;
2475 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
2476 nmttc.hdr.code = NM_TOOLTIPSCREATED;
2477 nmttc.hwndToolTips = infoPtr->hwndToolTip;
2478
2479 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
2480 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
2481 }
2482 }
2483
2484 return 0;
2485}
2486
2487
2488static LRESULT
2489TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
2490{
2491 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2492
2493 /* delete tooltip control */
2494 if (infoPtr->hwndToolTip)
2495 DestroyWindow (infoPtr->hwndToolTip);
2496
2497 /* delete button data */
2498 if (infoPtr->buttons)
2499 COMCTL32_Free (infoPtr->buttons);
2500
2501 /* delete strings */
2502 if (infoPtr->strings) {
2503 INT i;
2504 for (i = 0; i < infoPtr->nNumStrings; i++)
2505 if (infoPtr->strings[i])
2506 COMCTL32_Free (infoPtr->strings[i]);
2507
2508 COMCTL32_Free (infoPtr->strings);
2509 }
2510
2511 /* destroy default image list */
2512 if (infoPtr->himlDef)
2513 ImageList_Destroy (infoPtr->himlDef);
2514
2515 /* destroy disabled image list */
2516 if (infoPtr->himlDis)
2517 ImageList_Destroy (infoPtr->himlDis);
2518
2519 /* destroy hot image list */
2520 if (infoPtr->himlHot)
2521 ImageList_Destroy (infoPtr->himlHot);
2522
2523 /* delete default font */
2524 if (infoPtr->hFont)
2525 DeleteObject (infoPtr->hFont);
2526
2527 /* free toolbar info data */
2528 COMCTL32_Free (infoPtr);
2529
2530 return 0;
2531}
2532
2533
2534static LRESULT
2535TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
2536{
2537 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2538
2539 if (infoPtr->bTransparent)
2540 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
2541
2542 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
2543}
2544
2545
2546static LRESULT
2547TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
2548{
2549 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2550 TBUTTON_INFO *btnPtr;
2551 POINT pt;
2552 INT nHit;
2553 HDC hdc;
2554
2555 pt.x = (INT)LOWORD(lParam);
2556 pt.y = (INT)HIWORD(lParam);
2557 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2558
2559 if (nHit >= 0) {
2560 btnPtr = &infoPtr->buttons[nHit];
2561 if (!(btnPtr->fsState & TBSTATE_ENABLED))
2562 return 0;
2563 SetCapture (hwnd);
2564 infoPtr->bCaptured = TRUE;
2565 infoPtr->nButtonDown = nHit;
2566
2567 btnPtr->fsState |= TBSTATE_PRESSED;
2568
2569 hdc = GetDC (hwnd);
2570 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2571 ReleaseDC (hwnd, hdc);
2572 }
2573 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
2574 TOOLBAR_Customize (hwnd);
2575
2576 return 0;
2577}
2578
2579
2580static LRESULT
2581TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
2582{
2583 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2584 TBUTTON_INFO *btnPtr;
2585 POINT pt;
2586 INT nHit;
2587 HDC hdc;
2588
2589 if (infoPtr->hwndToolTip)
2590 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2591 WM_LBUTTONDOWN, wParam, lParam);
2592
2593 pt.x = (INT)LOWORD(lParam);
2594 pt.y = (INT)HIWORD(lParam);
2595 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2596
2597 if (nHit >= 0) {
2598 btnPtr = &infoPtr->buttons[nHit];
2599 if (!(btnPtr->fsState & TBSTATE_ENABLED))
2600 return 0;
2601
2602 SetCapture (hwnd);
2603 infoPtr->bCaptured = TRUE;
2604 infoPtr->nButtonDown = nHit;
2605 infoPtr->nOldHit = nHit;
2606
2607 btnPtr->fsState |= TBSTATE_PRESSED;
2608
2609 hdc = GetDC (hwnd);
2610 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2611 ReleaseDC (hwnd, hdc);
2612 }
2613
2614 return 0;
2615}
2616
2617
2618static LRESULT
2619TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
2620{
2621 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2622 TBUTTON_INFO *btnPtr;
2623 POINT pt;
2624 INT nHit;
2625 INT nOldIndex = -1;
2626 HDC hdc;
2627 BOOL bSendMessage = TRUE;
2628
2629 if (infoPtr->hwndToolTip)
2630 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2631 WM_LBUTTONUP, wParam, lParam);
2632
2633 pt.x = (INT)LOWORD(lParam);
2634 pt.y = (INT)HIWORD(lParam);
2635 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2636
2637 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
2638 infoPtr->bCaptured = FALSE;
2639 ReleaseCapture ();
2640 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
2641 btnPtr->fsState &= ~TBSTATE_PRESSED;
2642
2643 if (nHit == infoPtr->nButtonDown) {
2644 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
2645 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
2646 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
2647 infoPtr->nButtonDown);
2648 if (nOldIndex == infoPtr->nButtonDown)
2649 bSendMessage = FALSE;
2650 if ((nOldIndex != infoPtr->nButtonDown) &&
2651 (nOldIndex != -1))
2652 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
2653 btnPtr->fsState |= TBSTATE_CHECKED;
2654 }
2655 else {
2656 if (btnPtr->fsState & TBSTATE_CHECKED)
2657 btnPtr->fsState &= ~TBSTATE_CHECKED;
2658 else
2659 btnPtr->fsState |= TBSTATE_CHECKED;
2660 }
2661 }
2662 }
2663 else
2664 bSendMessage = FALSE;
2665
2666 hdc = GetDC (hwnd);
2667 if (nOldIndex != -1)
2668 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
2669 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2670 ReleaseDC (hwnd, hdc);
2671
2672 if (bSendMessage)
2673 SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
2674 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
2675
2676 infoPtr->nButtonDown = -1;
2677 infoPtr->nOldHit = -1;
2678 }
2679
2680 return 0;
2681}
2682
2683
2684static LRESULT
2685TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
2686{
2687 TBUTTON_INFO *btnPtr, *oldBtnPtr;
2688 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2689 POINT pt;
2690 INT nHit;
2691 HDC hdc;
2692
2693 if (infoPtr->hwndToolTip)
2694 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2695 WM_MOUSEMOVE, wParam, lParam);
2696
2697 pt.x = (INT)LOWORD(lParam);
2698 pt.y = (INT)HIWORD(lParam);
2699
2700 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2701
2702 if (infoPtr->nOldHit != nHit)
2703 {
2704 /* Remove the effect of an old hot button */
2705 if(infoPtr->nOldHit == infoPtr->nHotItem)
2706 {
2707 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
2708 oldBtnPtr->bHot = FALSE;
2709
2710 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
2711 }
2712
2713 /* It's not a separator or in nowhere. It's a hot button. */
2714 if (nHit >= 0)
2715 {
2716 btnPtr = &infoPtr->buttons[nHit];
2717 btnPtr->bHot = TRUE;
2718
2719 hdc = GetDC (hwnd);
2720 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2721 ReleaseDC (hwnd, hdc);
2722
2723 infoPtr->nHotItem = nHit;
2724 }
2725
2726 if (infoPtr->bCaptured) {
2727 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
2728 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
2729 btnPtr->fsState &= ~TBSTATE_PRESSED;
2730 hdc = GetDC (hwnd);
2731 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2732 ReleaseDC (hwnd, hdc);
2733 }
2734 else if (nHit == infoPtr->nButtonDown) {
2735 btnPtr->fsState |= TBSTATE_PRESSED;
2736 hdc = GetDC (hwnd);
2737 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2738 ReleaseDC (hwnd, hdc);
2739 }
2740 }
2741 infoPtr->nOldHit = nHit;
2742 }
2743 return 0;
2744}
2745
2746
2747static LRESULT
2748TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2749{
2750/* if (wndPtr->dwStyle & CCS_NODIVIDER) */
2751 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
2752/* else */
2753/* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
2754}
2755
2756
2757static LRESULT
2758TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2759{
2760 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
2761 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
2762
2763 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
2764}
2765
2766
2767static LRESULT
2768TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2769{
2770 TOOLBAR_INFO *infoPtr;
2771
2772 /* allocate memory for info structure */
2773 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
2774 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
2775
2776 /* paranoid!! */
2777 infoPtr->dwStructSize = sizeof(TBBUTTON);
2778
2779 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
2780 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
2781 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
2782 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
2783 }
2784
2785 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
2786}
2787
2788
2789static LRESULT
2790TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
2791{
2792 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2793 RECT rcWindow;
2794 HDC hdc;
2795
2796 if (dwStyle & WS_MINIMIZE)
2797 return 0; /* Nothing to do */
2798
2799 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
2800
2801 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
2802 return 0;
2803
2804 if (!(dwStyle & CCS_NODIVIDER))
2805 {
2806 GetWindowRect (hwnd, &rcWindow);
2807 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
2808 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
2809 }
2810
2811 ReleaseDC( hwnd, hdc );
2812
2813 return 0;
2814}
2815
2816
2817static LRESULT
2818TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
2819{
2820 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2821 LPNMHDR lpnmh = (LPNMHDR)lParam;
2822
2823// TRACE (toolbar, "passing WM_NOTIFY!\n");
2824
2825 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
2826 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
2827
2828#if 0
2829 if (lpnmh->code == TTN_GETDISPINFOA) {
2830 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
2831
2832// FIXME (toolbar, "retrieving ASCII string\n");
2833
2834 }
2835 else if (lpnmh->code == TTN_GETDISPINFOW) {
2836 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
2837
2838// FIXME (toolbar, "retrieving UNICODE string\n");
2839
2840 }
2841#endif
2842 }
2843
2844 return 0;
2845}
2846
2847
2848static LRESULT
2849TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
2850{
2851 HDC hdc;
2852 PAINTSTRUCT ps;
2853
2854 TOOLBAR_CalcToolbar( hwnd );
2855 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
2856 TOOLBAR_Refresh (hwnd, hdc);
2857 if (!wParam)
2858 EndPaint (hwnd, &ps);
2859 return 0;
2860}
2861
2862
2863static LRESULT
2864TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
2865{
2866 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2867 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2868 RECT parent_rect;
2869 HWND parent;
2870 /* INT32 x, y; */
2871 INT cx, cy;
2872 INT flags;
2873 UINT uPosFlags = 0;
2874
2875 /* Resize deadlock check */
2876 if (infoPtr->bAutoSize) {
2877 infoPtr->bAutoSize = FALSE;
2878 return 0;
2879 }
2880
2881 flags = (INT) wParam;
2882
2883 /* FIXME for flags =
2884 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
2885 */
2886
2887// TRACE (toolbar, "sizing toolbar!\n");
2888
2889 if (flags == SIZE_RESTORED) {
2890 /* width and height don't apply */
2891 parent = GetParent (hwnd);
2892 GetClientRect(parent, &parent_rect);
2893
2894 if (dwStyle & CCS_NORESIZE) {
2895 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
2896
2897 /* FIXME */
2898/* infoPtr->nWidth = parent_rect.right - parent_rect.left; */
2899 cy = infoPtr->nHeight;
2900 cx = infoPtr->nWidth;
2901 TOOLBAR_CalcToolbar (hwnd);
2902 infoPtr->nWidth = cx;
2903 infoPtr->nHeight = cy;
2904 }
2905 else {
2906 infoPtr->nWidth = parent_rect.right - parent_rect.left;
2907 TOOLBAR_CalcToolbar (hwnd);
2908 cy = infoPtr->nHeight;
2909 cx = infoPtr->nWidth;
2910 }
2911
2912 if (dwStyle & CCS_NOPARENTALIGN) {
2913 uPosFlags |= SWP_NOMOVE;
2914 cy = infoPtr->nHeight;
2915 cx = infoPtr->nWidth;
2916 }
2917
2918 if (!(dwStyle & CCS_NODIVIDER))
2919 cy += GetSystemMetrics(SM_CYEDGE);
2920
2921 SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
2922 cx, cy, uPosFlags | SWP_NOZORDER);
2923 }
2924 return 0;
2925}
2926
2927
2928static LRESULT
2929TOOLBAR_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
2930{
2931 TOOLBAR_AutoSize (hwnd, wParam, lParam);
2932
2933 InvalidateRect(hwnd, NULL, FALSE);
2934
2935 return 0;
2936}
2937
2938
2939
2940LRESULT WINAPI
2941ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2942{
2943 switch (uMsg)
2944 {
2945 case TB_ADDBITMAP:
2946 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
2947
2948 case TB_ADDBUTTONSA:
2949 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
2950
2951/* case TB_ADDBUTTONSW: */
2952
2953 case TB_ADDSTRINGA:
2954 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
2955
2956 case TB_ADDSTRINGW:
2957 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
2958
2959 case TB_AUTOSIZE:
2960 return TOOLBAR_AutoSize (hwnd, wParam, lParam);
2961
2962 case TB_BUTTONCOUNT:
2963 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
2964
2965 case TB_BUTTONSTRUCTSIZE:
2966 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
2967
2968 case TB_CHANGEBITMAP:
2969 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
2970
2971 case TB_CHECKBUTTON:
2972 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
2973
2974 case TB_COMMANDTOINDEX:
2975 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
2976
2977 case TB_CUSTOMIZE:
2978 return TOOLBAR_Customize (hwnd);
2979
2980 case TB_DELETEBUTTON:
2981 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
2982
2983 case TB_ENABLEBUTTON:
2984 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
2985
2986/* case TB_GETANCHORHIGHLIGHT: */ /* 4.71 */
2987
2988 case TB_GETBITMAP:
2989 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
2990
2991 case TB_GETBITMAPFLAGS:
2992 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
2993
2994 case TB_GETBUTTON:
2995 return TOOLBAR_GetButton (hwnd, wParam, lParam);
2996
2997 case TB_GETBUTTONINFOA:
2998 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
2999
3000/* case TB_GETBUTTONINFOW: */ /* 4.71 */
3001
3002 case TB_GETBUTTONSIZE:
3003 return TOOLBAR_GetButtonSize (hwnd);
3004
3005 case TB_GETBUTTONTEXTA:
3006 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
3007
3008/* case TB_GETBUTTONTEXTW: */
3009/* case TB_GETCOLORSCHEME: */ /* 4.71 */
3010
3011 case TB_GETDISABLEDIMAGELIST:
3012 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
3013
3014 case TB_GETEXTENDEDSTYLE:
3015 return TOOLBAR_GetExtendedStyle (hwnd);
3016
3017 case TB_GETHOTIMAGELIST:
3018 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
3019
3020/* case TB_GETHOTITEM: */ /* 4.71 */
3021
3022 case TB_GETIMAGELIST:
3023 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
3024
3025/* case TB_GETINSERTMARK: */ /* 4.71 */
3026/* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
3027
3028 case TB_GETITEMRECT:
3029 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
3030
3031 case TB_GETMAXSIZE:
3032 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
3033
3034/* case TB_GETOBJECT: */ /* 4.71 */
3035/* case TB_GETPADDING: */ /* 4.71 */
3036
3037 case TB_GETRECT:
3038 return TOOLBAR_GetRect (hwnd, wParam, lParam);
3039
3040 case TB_GETROWS:
3041 return TOOLBAR_GetRows (hwnd, wParam, lParam);
3042
3043 case TB_GETSTATE:
3044 return TOOLBAR_GetState (hwnd, wParam, lParam);
3045
3046 case TB_GETSTYLE:
3047 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
3048
3049 case TB_GETTEXTROWS:
3050 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
3051
3052 case TB_GETTOOLTIPS:
3053 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
3054
3055 case TB_GETUNICODEFORMAT:
3056 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
3057
3058 case TB_HIDEBUTTON:
3059 return TOOLBAR_HideButton (hwnd, wParam, lParam);
3060
3061 case TB_HITTEST:
3062 return TOOLBAR_HitTest (hwnd, wParam, lParam);
3063
3064 case TB_INDETERMINATE:
3065 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
3066
3067 case TB_INSERTBUTTONA:
3068 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
3069
3070/* case TB_INSERTBUTTONW: */
3071/* case TB_INSERTMARKHITTEST: */ /* 4.71 */
3072
3073 case TB_ISBUTTONCHECKED:
3074 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
3075
3076 case TB_ISBUTTONENABLED:
3077 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
3078
3079 case TB_ISBUTTONHIDDEN:
3080 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
3081
3082 case TB_ISBUTTONHIGHLIGHTED:
3083 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
3084
3085 case TB_ISBUTTONINDETERMINATE:
3086 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
3087
3088 case TB_ISBUTTONPRESSED:
3089 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
3090
3091/* case TB_LOADIMAGES: */ /* 4.70 */
3092/* case TB_MAPACCELERATORA: */ /* 4.71 */
3093/* case TB_MAPACCELERATORW: */ /* 4.71 */
3094/* case TB_MARKBUTTON: */ /* 4.71 */
3095/* case TB_MOVEBUTTON: */ /* 4.71 */
3096
3097 case TB_PRESSBUTTON:
3098 return TOOLBAR_PressButton (hwnd, wParam, lParam);
3099
3100/* case TB_REPLACEBITMAP: */
3101
3102 case TB_SAVERESTOREA:
3103 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
3104
3105/* case TB_SAVERESTOREW: */
3106/* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */
3107
3108 case TB_SETBITMAPSIZE:
3109 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
3110
3111 case TB_SETBUTTONINFOA:
3112 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
3113
3114/* case TB_SETBUTTONINFOW: */ /* 4.71 */
3115
3116 case TB_SETBUTTONSIZE:
3117 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
3118
3119 case TB_SETBUTTONWIDTH:
3120 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
3121
3122 case TB_SETCMDID:
3123 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
3124
3125/* case TB_SETCOLORSCHEME: */ /* 4.71 */
3126
3127 case TB_SETDISABLEDIMAGELIST:
3128 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
3129
3130 case TB_SETDRAWTEXTFLAGS:
3131 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
3132
3133 case TB_SETEXTENDEDSTYLE:
3134 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
3135
3136 case TB_SETHOTIMAGELIST:
3137 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
3138
3139/* case TB_SETHOTITEM: */ /* 4.71 */
3140
3141 case TB_SETIMAGELIST:
3142 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
3143
3144 case TB_SETINDENT:
3145 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
3146
3147/* case TB_SETINSERTMARK: */ /* 4.71 */
3148
3149 case TB_SETINSERTMARKCOLOR:
3150 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
3151
3152 case TB_SETMAXTEXTROWS:
3153 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
3154
3155/* case TB_SETPADDING: */ /* 4.71 */
3156
3157 case TB_SETPARENT:
3158 return TOOLBAR_SetParent (hwnd, wParam, lParam);
3159
3160 case TB_SETROWS:
3161 return TOOLBAR_SetRows (hwnd, wParam, lParam);
3162
3163 case TB_SETSTATE:
3164 return TOOLBAR_SetState (hwnd, wParam, lParam);
3165
3166 case TB_SETSTYLE:
3167 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
3168
3169 case TB_SETTOOLTIPS:
3170 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
3171
3172 case TB_SETUNICODEFORMAT:
3173 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
3174
3175
3176/* case WM_CHAR: */
3177
3178 case WM_CREATE:
3179 return TOOLBAR_Create (hwnd, wParam, lParam);
3180
3181 case WM_DESTROY:
3182 return TOOLBAR_Destroy (hwnd, wParam, lParam);
3183
3184 case WM_ERASEBKGND:
3185 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
3186
3187/* case WM_GETFONT: */
3188/* case WM_KEYDOWN: */
3189/* case WM_KILLFOCUS: */
3190
3191 case WM_LBUTTONDBLCLK:
3192 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
3193
3194 case WM_LBUTTONDOWN:
3195 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
3196
3197 case WM_LBUTTONUP:
3198 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
3199
3200 case WM_MOUSEMOVE:
3201 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
3202
3203 case WM_NCACTIVATE:
3204 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
3205
3206 case WM_NCCALCSIZE:
3207 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
3208
3209 case WM_NCCREATE:
3210 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
3211
3212 case WM_NCPAINT:
3213 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
3214
3215 case WM_NOTIFY:
3216 return TOOLBAR_Notify (hwnd, wParam, lParam);
3217
3218/* case WM_NOTIFYFORMAT: */
3219
3220 case WM_PAINT:
3221 return TOOLBAR_Paint (hwnd, wParam);
3222
3223 case WM_SIZE:
3224 return TOOLBAR_Size (hwnd, wParam, lParam);
3225
3226 case WM_STYLECHANGED:
3227 return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
3228
3229/* case WM_SYSCOLORCHANGE: */
3230
3231/* case WM_WININICHANGE: */
3232
3233 case WM_CHARTOITEM:
3234 case WM_COMMAND:
3235 case WM_DRAWITEM:
3236 case WM_MEASUREITEM:
3237 case WM_VKEYTOITEM:
3238 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
3239
3240 default:
3241// if (uMsg >= WM_USER)
3242// ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n",
3243// uMsg, wParam, lParam);
3244 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3245 }
3246 return 0;
3247}
3248
3249
3250VOID
3251TOOLBAR_Register (VOID)
3252{
3253 WNDCLASSA wndClass;
3254
3255 if (GlobalFindAtomA (TOOLBARCLASSNAMEA)) return;
3256
3257 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
3258 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3259 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
3260 wndClass.cbClsExtra = 0;
3261 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
3262 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
3263 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
3264 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
3265
3266 RegisterClassA (&wndClass);
3267}
3268
3269
3270VOID
3271TOOLBAR_Unregister (VOID)
3272{
3273 if (GlobalFindAtomA (TOOLBARCLASSNAMEA))
3274 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
3275}
3276
Note: See TracBrowser for help on using the repository browser.