| 531 | |
| 532 | |
| 533 | void ToolBar::ReCreateButtons() |
| 534 | { |
| 535 | wxSize sz3 = GetSize(); |
| 536 | //wxLogDebug( "x:%i y:%i",sz3.x, sz3.y); |
| 537 | |
| 538 | // SetSizer(NULL) detaches mHSizer and deletes it. |
| 539 | // Do not use Detach() here, as that attempts to detach mHSizer from itself! |
| 540 | SetSizer( NULL ); |
| 541 | |
| 542 | // Get rid of any children we may have |
| 543 | DestroyChildren(); |
| 544 | mGrabber = NULL; |
| 545 | mResizer = NULL; |
| 546 | SetLayoutDirection(wxLayout_LeftToRight); |
| 547 | |
| 548 | // Refresh the background before populating |
| 549 | if (!IsDocked()) |
| 550 | { |
| 551 | GetParent()->Refresh(); |
| 552 | } |
| 553 | |
| 554 | { |
| 555 | // Create the main sizer |
| 556 | auto ms = std::make_unique<wxBoxSizer>(wxHORIZONTAL); |
| 557 | |
| 558 | // Create the grabber and add it to the main sizer |
| 559 | mGrabber = safenew Grabber(this, GetSection()); |
| 560 | ms->Add(mGrabber, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxRIGHT, 1); |
| 561 | |
| 562 | // Use a box sizer for laying out controls |
| 563 | ms->Add((mHSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND); |
| 564 | |
| 565 | // Go add all the rest of the gadgets |
| 566 | Populate(); |
| 567 | |
| 568 | // Add some space for the resize border |
| 569 | if (IsResizable()) |
| 570 | { |
| 571 | // Create the resizer and add it to the main sizer |
| 572 | mResizer = safenew ToolBarResizer(this); |
| 573 | ms->Add(mResizer, 0, wxEXPAND | wxALIGN_TOP | wxLEFT, 1); |
| 574 | mResizer->SetToolTip(_("Click and drag to resize toolbar")); |
| 575 | } |
| 576 | |
| 577 | // Set dock after possibly creating resizer. |
| 578 | // (Re)Establish dock state |
| 579 | SetDocked(GetDock(), false); |
| 580 | |
| 581 | // Set the sizer |
| 582 | SetSizerAndFit(ms.release()); |
| 583 | } |
| 584 | |
| 585 | // Recalculate the height to be a multiple of toolbarSingle |
| 586 | const int tbs = toolbarSingle + toolbarGap; |
| 587 | wxSize sz = GetSize(); |
| 588 | sz.y = ( ( ( sz.y + tbs -1) / tbs ) * tbs ) - 1; |
| 589 | |
| 590 | // Set the true AND minimum sizes and do final layout |
no test coverage detected