diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-06-16 16:43:25 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-28 08:48:31 +0100 |
commit | 15eb1c02601d8c7fa135930a3eb3787a24e8b92a (patch) | |
tree | fdae634092c3b53effcf22bab35388e50b18ade3 | |
parent | 43713eb40f464dfb457efa7659f85c4b60b7c611 (diff) |
improve queue_resize
-rw-r--r-- | vcl/inc/vcl/dialog.hxx | 2 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 32 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 11 |
3 files changed, 24 insertions, 21 deletions
diff --git a/vcl/inc/vcl/dialog.hxx b/vcl/inc/vcl/dialog.hxx index 621f73b199ba..13a5520bbc23 100644 --- a/vcl/inc/vcl/dialog.hxx +++ b/vcl/inc/vcl/dialog.hxx @@ -44,6 +44,7 @@ // ---------- struct DialogImpl; class VclBuilder; +class VclBox; class VCL_DLLPUBLIC Dialog : public SystemWindow @@ -77,6 +78,7 @@ protected: SAL_DLLPRIVATE void ImplDialogRes( const ResId& rResId ); SAL_DLLPRIVATE WinBits init(Window *pParent, const ResId& rResId); + SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, VclBox &rBox); public: SAL_DLLPRIVATE sal_Bool IsInClose() const { return mbInClose; } SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); } diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 3fca7b2b9670..ff284fcfcb47 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -672,21 +672,16 @@ void Dialog::StateChanged( StateChangedType nType ) Size aSize = get_preferred_size(); - fprintf(stderr, "100 dialog sized to %d %d\n", aSize.Width(), - aSize.Height()); - 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); - - aSize = GetSizePixel(); + setPosSizeOnContainee(aSize, *pBox); fprintf(stderr, "101 dialog sized to %d %d\n", aSize.Width(), aSize.Height()); - } if ( GetSettings().GetStyleSettings().GetAutoMnemonic() ) @@ -1190,6 +1185,19 @@ Size Dialog::GetOptimalSize(WindowSizeType eType) const return Window::CalcWindowSize(aSize); } +void Dialog::setPosSizeOnContainee(Size aSize, VclBox &rBox) +{ + aSize.Width() -= mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder + + 2 * m_nBorderWidth; + aSize.Height() -= mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder + + 2 * m_nBorderWidth; + + Point aPos(mpWindowImpl->mnLeftBorder + m_nBorderWidth, + mpWindowImpl->mnTopBorder + m_nBorderWidth); + + rBox.SetPosSizePixel(aPos, aSize); +} + IMPL_LINK( Dialog, ImplHandleLayoutTimerHdl, void*, EMPTYARG ) { fprintf(stderr, "ImplHandleLayoutTimerHdl\n"); @@ -1200,17 +1208,7 @@ IMPL_LINK( Dialog, ImplHandleLayoutTimerHdl, void*, EMPTYARG ) fprintf(stderr, "WTF!\n"); return 0; } - Size aSize = GetSizePixel(); - - aSize.Width() -= mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder - + 2 * m_nBorderWidth; - aSize.Height() -= mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder - + 2 * m_nBorderWidth; - - Point aPos(mpWindowImpl->mnLeftBorder + m_nBorderWidth, - mpWindowImpl->mnTopBorder + m_nBorderWidth); - - pBox->SetPosSizePixel(aPos, aSize); + setPosSizeOnContainee(GetSizePixel(), *pBox); return 0; } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index f651041e1f5c..ade0df0d6e0b 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -4935,6 +4935,7 @@ void Window::StateChanged( StateChangedType eType ) case STATE_CHANGE_ENABLE: case STATE_CHANGE_STATE: case STATE_CHANGE_DATA: + case STATE_CHANGE_INITSHOW: break; //stuff that does invalidate the layout default: @@ -9667,14 +9668,16 @@ Selection Window::GetSurroundingTextSelection() const return Selection( 0, 0 ); } -//Poor man's equivalent, when widget wants to renegotiate -//size, get parent dialog and call resize on it +//When a widget wants to renegotiate size, get toplevel parent dialog and call +//resize on it. Maybe better to just find direct parent and if its a container +//chain it upwards one step at a time until a dialog is found. void Window::queue_resize() { Dialog *pParent = GetParentDialog(); - if (!pParent) + if (!pParent || pParent == this) return; - pParent->Resize(); + if (pParent->isLayoutEnabled()) + pParent->Resize(); } void Window::setChildAnyProperty(const rtl::OString &rString, const Any &rValue) |