diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-08-30 16:58:59 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-08-30 17:22:37 +0100 |
commit | e8fb86134c6f6052ab6748698039760827fbcd37 (patch) | |
tree | c5d2cfe5aab6685ab4464dc46c6f29a0aa62bf7a /vcl/source/window/dialog.cxx | |
parent | 0d5cc8ce2976b8a69cc4ef1091b0dfe72c15fba2 (diff) |
move layout from dialog to systemwindow
*distant sounds of hammering in basement*
so we can get Floating Windows layout aware
as well without duplicate of dialog layout logic
Change-Id: I063375f2f7d4e5c3bfbfedf55649078d4dbe4139
Diffstat (limited to 'vcl/source/window/dialog.cxx')
-rw-r--r-- | vcl/source/window/dialog.cxx | 151 |
1 files changed, 24 insertions, 127 deletions
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index f8afa9f8ae8c..1fa6f40c9994 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -347,13 +347,8 @@ void Dialog::ImplInitDialogData() mbModalMode = false; mpContentArea = NULL; mpActionArea = NULL; - mbIsCalculatingInitialLayoutSize = false; mnMousePositioned = 0; mpDialogImpl = new DialogImpl; - - //To-Do, reuse maResizeTimer - maLayoutTimer.SetTimeout(50); - maLayoutTimer.SetTimeoutHdl( LINK( this, Dialog, ImplHandleLayoutTimerHdl ) ); } void Dialog::ImplInit( Window* pParent, WinBits nStyle ) @@ -531,9 +526,24 @@ void Dialog::set_content_area(VclBox* pContentArea) mpContentArea = pContentArea; } +void Dialog::settingOptimalLayoutSize(VclBox *pBox) +{ + const DialogStyle& rDialogStyle = + GetSettings().GetStyleSettings().GetDialogStyle(); + pBox->set_border_width(rDialogStyle.content_area_border); + pBox->set_spacing(pBox->get_spacing() + + rDialogStyle.content_area_spacing); + + VclButtonBox *pActionArea = getActionArea(this); + if (pActionArea) + { + pActionArea->set_border_width(rDialogStyle.action_area_border); + pActionArea->set_spacing(rDialogStyle.button_spacing); + } +} + Dialog::~Dialog() { - maLayoutTimer.Stop(); delete mpDialogImpl; mpDialogImpl = NULL; } @@ -614,54 +624,14 @@ Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize) return Size(w, h); } -void Dialog::setOptimalLayoutSize() -{ - maLayoutTimer.Stop(); - - //resize dialog to fit requisition on initial show - VclBox *pBox = static_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD)); - - const DialogStyle& rDialogStyle = - GetSettings().GetStyleSettings().GetDialogStyle(); - pBox->set_border_width(rDialogStyle.content_area_border); - pBox->set_spacing(pBox->get_spacing() + - rDialogStyle.content_area_spacing); - - VclButtonBox *pActionArea = getActionArea(this); - if (pActionArea) - { - pActionArea->set_border_width(rDialogStyle.action_area_border); - pActionArea->set_spacing(rDialogStyle.button_spacing); - } - - Size aSize = get_preferred_size(); - - Size aMax(bestmaxFrameSizeForScreenSize(GetDesktopRectPixel().GetSize())); - - aSize.Width() = std::min(aMax.Width(), aSize.Width()); - aSize.Height() = std::min(aMax.Height(), aSize.Height()); - - SetMinOutputSizePixel(aSize); - SetSizePixel(aSize); - setPosSizeOnContainee(aSize, *pBox); -} - void Dialog::StateChanged( StateChangedType nType ) { - SystemWindow::StateChanged( nType ); - - if ( nType == STATE_CHANGE_INITSHOW ) + if (nType == STATE_CHANGE_INITSHOW) { if ( GetSettings().GetStyleSettings().GetAutoMnemonic() ) ImplWindowAutoMnemonic( this ); - if (isLayoutEnabled()) - { - mbIsCalculatingInitialLayoutSize = true; - setDeferredProperties(); - setOptimalLayoutSize(); - mbIsCalculatingInitialLayoutSize = false; - } + DoInitialLayout(); if ( !HasChildPathFocus() || HasFocus() ) GrabFocusToFirstControl(); @@ -676,7 +646,10 @@ void Dialog::StateChanged( StateChangedType nType ) ImplMouseAutoPos( this ); } - else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) + + SystemWindow::StateChanged( nType ); + + if (nType == STATE_CHANGE_CONTROLBACKGROUND) { ImplInitSettings(); Invalidate(); @@ -1166,75 +1139,11 @@ void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal pDev->Pop(); } -bool Dialog::isLayoutEnabled() const -{ - //pre dtor called, and single child is a container => we're layout enabled - return mpDialogImpl && ::isLayoutEnabled(this); -} - -Size Dialog::GetOptimalSize() const -{ - if (!isLayoutEnabled()) - return SystemWindow::GetOptimalSize(); - - Size aSize = VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD)); - - sal_Int32 nBorderWidth = get_border_width(); - - aSize.Height() += mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder - + 2*nBorderWidth; - aSize.Width() += mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder - + 2*nBorderWidth; - - return Window::CalcWindowSize(aSize); -} - -void Dialog::setPosSizeOnContainee(Size aSize, VclContainer &rBox) -{ - sal_Int32 nBorderWidth = get_border_width(); - - aSize.Width() -= mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder - + 2 * nBorderWidth; - aSize.Height() -= mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder - + 2 * nBorderWidth; - - Point aPos(mpWindowImpl->mnLeftBorder + nBorderWidth, - mpWindowImpl->mnTopBorder + nBorderWidth); - - VclContainer::setLayoutAllocation(rBox, aPos, aSize); -} - -IMPL_LINK( Dialog, ImplHandleLayoutTimerHdl, void*, EMPTYARG ) +void Dialog::queue_resize(StateChangedType eReason) { - if (!isLayoutEnabled()) - { - SAL_WARN("vcl.layout", "Dialog has become non-layout because extra children have been added directly to it."); - return 0; - } - - VclBox *pBox = static_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD)); - assert(pBox); - setPosSizeOnContainee(GetSizePixel(), *pBox); - return 0; -} - -void Dialog::queue_resize(StateChangedType /*eReason*/) -{ - if (hasPendingLayout() || isCalculatingInitialLayoutSize()) - return; if (IsInClose()) return; - if (!isLayoutEnabled()) - return; - WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; - pWindowImpl->mnOptimalWidthCache = -1; - pWindowImpl->mnOptimalHeightCache = -1; - maLayoutTimer.Start(); -} - -void Dialog::Resize() -{ - queue_resize(); + SystemWindow::queue_resize(eReason); } bool Dialog::set_property(const OString &rKey, const OString &rValue) @@ -1246,18 +1155,6 @@ bool Dialog::set_property(const OString &rKey, const OString &rValue) return true; } -void Dialog::SetText(const OUString& rStr) -{ - setDeferredProperties(); - SystemWindow::SetText(rStr); -} - -OUString Dialog::GetText() const -{ - const_cast<Dialog*>(this)->setDeferredProperties(); - return SystemWindow::GetText(); -} - VclBuilderContainer::VclBuilderContainer() : m_pUIBuilder(NULL) { |