wxWidgets docs recommend: don't SetSizeHints on non-top-level windows

This commit is contained in:
Paul Licameli 2018-01-30 01:06:23 -05:00
parent c67a47e3e6
commit 7ccd35d219
9 changed files with 29 additions and 22 deletions

View File

@ -671,7 +671,8 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S)
// Keep dialog from getting too wide
int w = r.GetWidth() - (GetClientSize().GetWidth() - mEffects->GetSize().GetWidth());
mEffects->SetSizeHints(wxSize(wxMin(maxW, w), 200), wxSize(w, -1));
mEffects->SetMinSize({ std::min(maxW, w), 200 });
mEffects->SetMaxSize({ w, -1 });
RegenerateEffectsList(ID_ShowAll);

View File

@ -397,7 +397,7 @@ wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt,
choices,
Style( 0 ) );
pChoice->SetSizeHints( 180,-1);// Use -1 for 'default size' - Platform specific.
pChoice->SetMinSize( { 180, -1 } );// Use -1 for 'default size' - Platform specific.
#ifdef __WXMAC__
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
@ -2347,7 +2347,7 @@ void ShuttleGuiBase::SetSizeHints( wxWindow *window, const wxArrayStringEx & ite
maxw += 50;
#endif
window->SetSizeHints( maxw, -1 );
window->SetMinSize( { maxw, -1 } );
}
void ShuttleGuiBase::SetSizeHints( const wxArrayStringEx & items )

View File

@ -1104,14 +1104,15 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
//S.GetParent()->Layout();
wxSize sz = szrV->GetMinSize();
sz += wxSize( 30, 0);
mUIParent->SetSizeHints(sz);
mUIParent->SetMinSize(sz);
}
else{
mPanel->Show( true );
szrV->Show(szr1, true);
mUIParent->SetSizeHints(mUIParent->GetBestSize());
mUIParent->SetMinSize(mUIParent->GetBestSize());
}
ForceRecalc();
return;
}
@ -2304,7 +2305,7 @@ void EffectEqualization::UpdateCurves()
// Allow the control to resize
if( mCurve )
mCurve->SetSizeHints(-1, -1);
mCurve->SetMinSize({-1, -1});
// Set initial curve
setCurve( mCurveName );

View File

@ -1500,10 +1500,10 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
// Try to give the window a sensible default/minimum size
wxSize sz1 = marginSizer->GetMinSize();
wxSize sz2 = mParent->GetMinSize();
w->SetSizeHints(wxSize(wxMin(sz1.x, sz2.x), wxMin(sz1.y, sz2.y)));
w->SetMinSize( { std::min(sz1.x, sz2.x), std::min(sz1.y, sz2.y) } );
// And let the parent reduce to the NEW minimum if possible
mParent->SetSizeHints(-1, -1);
mParent->SetMinSize({ -1, -1 });
return true;
}

View File

@ -1829,10 +1829,10 @@ bool LV2Effect::BuildPlain()
// Try to give the window a sensible default/minimum size
wxSize sz1 = innerSizer->GetMinSize();
wxSize sz2 = mParent->GetMinSize();
w->SetSizeHints(wxSize(-1, wxMin(sz1.y, sz2.y)));
w->SetMinSize( { -1, std::min(sz1.y, sz2.y) } );
// And let the parent reduce to the NEW minimum if possible
mParent->SetSizeHints(w->GetMinSize());
mParent->SetMinSize(w->GetMinSize());
TransferDataToWindow();

View File

@ -630,7 +630,7 @@ PrefsDialog::PrefsDialog
mCategories->GetTreeCtrl()->EnsureVisible(mCategories->GetTreeCtrl()->GetRootItem());
#endif
// mCategories->SetSizeHints(-1, -1, 790, 600); // 790 = 800 - (border * 2)
// mCategories->SetMaxSize({ 790, 600 }); // 790 = 800 - (border * 2)
Layout();
Fit();
wxSize sz = GetSize();

View File

@ -271,8 +271,8 @@ void AButton::Init(wxWindow * parent,
mFocusRect = GetClientRect().Deflate( 3, 3 );
mForceFocusRect = false;
SetSizeHints(mImages[0].mArr[0].GetMinSize(),
mImages[0].mArr[0].GetMaxSize());
SetMinSize(mImages[0].mArr[0].GetMinSize());
SetMaxSize(mImages[0].mArr[0].GetMaxSize());
#if wxUSE_ACCESSIBILITY
SetName( wxT("") );

View File

@ -380,7 +380,8 @@ void ExpandingToolBar::Fit()
mCurrentDrawerSize = wxSize(mExtraSize.x, 0);
mCurrentTotalSize = baseWindowSize;
SetSizeHints(mCurrentTotalSize, mCurrentTotalSize);
SetMinSize(mCurrentTotalSize);
SetMaxSize(mCurrentTotalSize);
SetSize(mCurrentTotalSize);
}
@ -434,7 +435,8 @@ void ExpandingToolBar::MoveDrawer(wxSize prevSize)
if (mFrameParent) {
// If we're in a tool window
SetSizeHints(mCurrentTotalSize, mCurrentTotalSize);
SetMinSize(mCurrentTotalSize);
SetMaxSize(mCurrentTotalSize);
SetSize(mCurrentTotalSize);
GetParent()->Fit();
@ -443,7 +445,8 @@ void ExpandingToolBar::MoveDrawer(wxSize prevSize)
if (mDialogParent) {
// If we're in a dialog
SetSizeHints(mCurrentTotalSize, mCurrentTotalSize);
SetMinSize(mCurrentTotalSize);
SetMaxSize(mCurrentTotalSize);
SetSize(mCurrentTotalSize);
GetParent()->Fit();
@ -457,7 +460,8 @@ void ExpandingToolBar::MoveDrawer(wxSize prevSize)
mExtraPanel->Show();
}
mExtraPanel->SetSizeHints(mCurrentDrawerSize, mCurrentDrawerSize);
mExtraPanel->SetMinSize(mCurrentDrawerSize);
mExtraPanel->SetMaxSize(mCurrentDrawerSize);
mExtraPanel->SetSize(mCurrentDrawerSize);
if (mCurrentDrawerSize.y == 0)
@ -680,8 +684,8 @@ ToolBarGrabber::ToolBarGrabber(wxWindow *parent,
images[1],
magicColor);
SetSizeHints(mImageRoll[0].GetMinSize(),
mImageRoll[1].GetMaxSize());
SetMinSize(mImageRoll[0].GetMinSize());
SetMaxSize(mImageRoll[1].GetMaxSize());
#endif
mState = 0;
}
@ -1094,7 +1098,8 @@ void ToolBarArea::Fit(bool horizontal, bool vertical)
maxSize != mMaxSize) {
mMinSize = minSize;
mMaxSize = maxSize;
SetSizeHints(mMinSize, mMaxSize);
SetMinSize(mMinSize);
SetMaxSize(mMaxSize);
}
if (actualSize != mActualSize) {
mActualSize = actualSize;

View File

@ -435,8 +435,8 @@ ImageRollPanel::ImageRollPanel(wxWindow *parent,
//mImageRoll(imgRoll),
mLogicalFunction(wxCOPY)
{
// SetSizeHints(mImageRoll.GetMinSize(),
// mImageRoll.GetMaxSize());
// SetMinSize(mImageRoll.GetMinSize());
// SetMaxSize(mImageRoll.GetMaxSize());
}
void ImageRollPanel::SetLogicalFunction(int /*wxRasterOperationMode*/ func)