summaryrefslogtreecommitdiff
path: root/vcl/source/window/dialog.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-04-16 15:14:42 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-09-28 08:48:16 +0100
commite432b5e60ceba0206cfcbd6466fa8ef468c04531 (patch)
treea07d3647f0936304a1fa049e85980345d329fbe0 /vcl/source/window/dialog.cxx
parent394bc02eea5e52276c2c188ca520a63a98a0bb6a (diff)
basic optimization pass
Diffstat (limited to 'vcl/source/window/dialog.cxx')
-rw-r--r--vcl/source/window/dialog.cxx30
1 files changed, 25 insertions, 5 deletions
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 3dd5ff149e0d..d1e36edc31c9 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -511,6 +511,22 @@ void Dialog::StateChanged( StateChangedType nType )
if ( nType == STATE_CHANGE_INITSHOW )
{
+ if (isLayoutEnabled())
+ {
+ maLayoutTimer.Stop();
+
+ //resize dialog to fit requisition on initial show
+ const Window *pContainer = GetWindow(WINDOW_FIRSTCHILD);
+ Size aSize = pContainer->get_preferred_size();
+
+ Size aMax = GetOptimalSize(WINDOWSIZE_MAXIMUM);
+ aSize.Width() = std::min(aMax.Width(), aSize.Width());
+ aSize.Height() = std::min(aMax.Height(), aSize.Height());
+
+ SetMinOutputSizePixel(aSize);
+ SetSizePixel(aSize);
+ }
+
if ( GetSettings().GetStyleSettings().GetAutoMnemonic() )
ImplWindowAutoMnemonic( this );
@@ -993,8 +1009,8 @@ void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal
bool Dialog::isLayoutEnabled() const
{
- //Has one child, and that child is a container => we're layout enabled
- return (GetChildCount() == 1 && dynamic_cast<const VclContainer*>(GetChild(0)));
+ //Child is a container => we're layout enabled
+ return dynamic_cast<const VclContainer*>(GetWindow(WINDOW_FIRSTCHILD));
}
Size Dialog::GetOptimalSize(WindowSizeType eType) const
@@ -1002,7 +1018,7 @@ Size Dialog::GetOptimalSize(WindowSizeType eType) const
if (eType == WINDOWSIZE_MAXIMUM || !isLayoutEnabled())
return SystemWindow::GetOptimalSize(eType);
- Size aSize = GetChild(0)->GetOptimalSize(eType);
+ Size aSize = GetWindow(WINDOW_FIRSTCHILD)->GetOptimalSize(eType);
return Window::CalcWindowSize(aSize);
}
@@ -1013,13 +1029,17 @@ IMPL_LINK( Dialog, ImplHandleLayoutTimerHdl, void*, EMPTYARG )
aSize.Width() -= mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder;
aSize.Height() -= mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder;
Point aPos(mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder);
- GetChild(0)->SetPosSizePixel(aPos, aSize);
+ GetWindow(WINDOW_FIRSTCHILD)->SetPosSizePixel(aPos, aSize);
return 0;
}
void Dialog::Resize()
{
- if (hasPendingLayout() || !isLayoutEnabled())
+ if (hasPendingLayout())
+ return;
+ if (IsInClose())
+ return;
+ if (!isLayoutEnabled())
return;
maLayoutTimer.Start();
}