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