Use control current, not best, size in wxMSW wxToolBar layout code
Avoid allocating too much space to the control in the toolbar, it may have been made smaller than its best size on purpose and, in any case, we don't resize the control, so it's useless to allocate more space to it than it's going to use. See #18294.
This commit is contained in:
@@ -443,7 +443,7 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar)
|
|||||||
wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO, wxEmptyString, wxDefaultPosition, wxSize(100,-1) );
|
wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO, wxEmptyString, wxDefaultPosition, wxSize(100,-1) );
|
||||||
combo->Append("This");
|
combo->Append("This");
|
||||||
combo->Append("is a");
|
combo->Append("is a");
|
||||||
combo->Append("combobox");
|
combo->Append("combobox with extremely, extremely, extremely, extremely long label");
|
||||||
combo->Append("in a");
|
combo->Append("in a");
|
||||||
combo->Append("toolbar");
|
combo->Append("toolbar");
|
||||||
toolBar->AddControl(combo, "Combo Label");
|
toolBar->AddControl(combo, "Combo Label");
|
||||||
|
@@ -548,7 +548,10 @@ wxToolBar::~wxToolBar()
|
|||||||
|
|
||||||
wxSize wxToolBar::MSWGetFittingtSizeForControl(wxToolBarTool* tool) const
|
wxSize wxToolBar::MSWGetFittingtSizeForControl(wxToolBarTool* tool) const
|
||||||
{
|
{
|
||||||
wxSize size = tool->GetControl()->GetBestSize();
|
// Note that we intentionally use GetSize() and not GetBestSize() here as
|
||||||
|
// the control could have been added to the toolbar with the size less than
|
||||||
|
// its best size in order to avoid taking too much space.
|
||||||
|
wxSize size = tool->GetControl()->GetSize();
|
||||||
|
|
||||||
// This is arbitrary, but we want to leave at least 1px around the control
|
// This is arbitrary, but we want to leave at least 1px around the control
|
||||||
// vertically, otherwise it really looks too cramped.
|
// vertically, otherwise it really looks too cramped.
|
||||||
|
Reference in New Issue
Block a user