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