From 4b339818bb036b409dd5dc00d645c62063e63de5 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 20 Aug 2014 12:01:14 +0100 Subject: add a VclViewport like GtkViewport so that the scrolled region will be clipped, which also has the side-effect of stopping glade clobbering the non view-port scrolled .ui files on editing Change-Id: Ic64174b3a35b77f068e0085cdc7721aeb33f1d82 --- .../source/deployment/gui/dp_gui_updatedialog.hxx | 2 +- desktop/uiconfig/ui/updatedialog.ui | 7 +++++- include/vcl/layout.hxx | 11 ++++++++ reportdesign/source/ui/dlg/CondFormat.cxx | 2 +- .../uiconfig/dbreport/ui/condformatdialog.ui | 5 ++++ sc/uiconfig/scalc/ui/retypepassdialog.ui | 19 ++++++++------ sc/uiconfig/scalc/ui/sortcriteriapage.ui | 17 ++++++++++--- sfx2/uiconfig/ui/cmisinfopage.ui | 25 +++++++++++-------- svtools/uiconfig/ui/addresstemplatedialog.ui | 5 ++++ svx/uiconfig/ui/asianphoneticguidedialog.ui | 5 ++++ vcl/source/window/builder.cxx | 6 ++++- vcl/source/window/layout.cxx | 29 +++++++++++++++++----- 12 files changed, 102 insertions(+), 31 deletions(-) diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx index adcc1895154a..e5365498b635 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx @@ -172,7 +172,7 @@ private: FixedText* m_pchecking; Throbber* m_pthrobber; FixedText* m_pUpdate; - VclScrolledWindow* m_pContainer; + VclViewport* m_pContainer; UpdateDialog::CheckListBox* m_pUpdates; CheckBox* m_pAll; FixedText* m_pDescription; diff --git a/desktop/uiconfig/ui/updatedialog.ui b/desktop/uiconfig/ui/updatedialog.ui index 940b104edafc..e3856326c385 100644 --- a/desktop/uiconfig/ui/updatedialog.ui +++ b/desktop/uiconfig/ui/updatedialog.ui @@ -144,10 +144,15 @@ - + True True in + + + True + + True diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx index a68103802e06..6c4ce283d12d 100644 --- a/include/vcl/layout.hxx +++ b/include/vcl/layout.hxx @@ -576,6 +576,17 @@ private: ScrollBarBox m_aScrollBarBox; }; +class VCL_DLLPUBLIC VclViewport : public VclBin +{ +public: + VclViewport(Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN) + : VclBin(pParent, nStyle) + { + } +protected: + virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE; +}; + //Enforces that its children are always the same size as itself. //Intercepts any Commands intended for its children. // diff --git a/reportdesign/source/ui/dlg/CondFormat.cxx b/reportdesign/source/ui/dlg/CondFormat.cxx index 82fb0fdf225d..7390352cb0fe 100644 --- a/reportdesign/source/ui/dlg/CondFormat.cxx +++ b/reportdesign/source/ui/dlg/CondFormat.cxx @@ -321,7 +321,7 @@ namespace rptui return; long nConditionHeight = m_aConditions[0]->get_preferred_size().Height(); Point aConditionPos(0, -1 * nConditionHeight * impl_getFirstVisibleConditionIndex()); - m_pScrollWindow->get_child()->SetPosPixel(aConditionPos); + m_pConditionPlayground->SetPosPixel(aConditionPos); } void ConditionalFormattingDialog::impl_layoutAll() diff --git a/reportdesign/uiconfig/dbreport/ui/condformatdialog.ui b/reportdesign/uiconfig/dbreport/ui/condformatdialog.ui index 741ce749bdc0..a3ff67b406c6 100644 --- a/reportdesign/uiconfig/dbreport/ui/condformatdialog.ui +++ b/reportdesign/uiconfig/dbreport/ui/condformatdialog.ui @@ -92,6 +92,9 @@ always in + + True + True False @@ -102,6 +105,8 @@ + + diff --git a/sc/uiconfig/scalc/ui/retypepassdialog.ui b/sc/uiconfig/scalc/ui/retypepassdialog.ui index 95459f275264..88d32498661c 100644 --- a/sc/uiconfig/scalc/ui/retypepassdialog.ui +++ b/sc/uiconfig/scalc/ui/retypepassdialog.ui @@ -188,15 +188,20 @@ True always - + True - False - True - True - vertical - 6 - + + True + False + True + True + vertical + 6 + + + + diff --git a/sc/uiconfig/scalc/ui/sortcriteriapage.ui b/sc/uiconfig/scalc/ui/sortcriteriapage.ui index 6b9202125d0a..c7347ef18510 100644 --- a/sc/uiconfig/scalc/ui/sortcriteriapage.ui +++ b/sc/uiconfig/scalc/ui/sortcriteriapage.ui @@ -1,6 +1,7 @@ + - + True True @@ -9,14 +10,22 @@ never in - + True False True True - vertical - + + True + False + True + True + vertical + + + + diff --git a/sfx2/uiconfig/ui/cmisinfopage.ui b/sfx2/uiconfig/ui/cmisinfopage.ui index 6fad6832d5ac..dafcb96495e0 100644 --- a/sfx2/uiconfig/ui/cmisinfopage.ui +++ b/sfx2/uiconfig/ui/cmisinfopage.ui @@ -25,14 +25,17 @@ - True - True - True - True - never - in - - + True + True + True + True + never + in + + + True + + True False True @@ -41,8 +44,10 @@ - - + + + + 0 diff --git a/svtools/uiconfig/ui/addresstemplatedialog.ui b/svtools/uiconfig/ui/addresstemplatedialog.ui index 65e708c09fdb..50b38245322b 100644 --- a/svtools/uiconfig/ui/addresstemplatedialog.ui +++ b/svtools/uiconfig/ui/addresstemplatedialog.ui @@ -231,6 +231,9 @@ True always in + + + True True @@ -582,6 +585,8 @@ + + diff --git a/svx/uiconfig/ui/asianphoneticguidedialog.ui b/svx/uiconfig/ui/asianphoneticguidedialog.ui index aa1cf2c5b59a..46f38e0d0df8 100644 --- a/svx/uiconfig/ui/asianphoneticguidedialog.ui +++ b/svx/uiconfig/ui/asianphoneticguidedialog.ui @@ -122,6 +122,9 @@ never always in + + + True True @@ -230,6 +233,8 @@ + + False diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index e336a052b5db..ff88496af8a7 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -1159,7 +1159,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri } } - if (bIsPlaceHolder || name == "GtkTreeSelection" || name == "GtkViewport") + if (bIsPlaceHolder || name == "GtkTreeSelection") return NULL; extractButtonImage(id, rMap, name == "GtkRadioButton"); @@ -1473,6 +1473,10 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri { pWindow = new VclScrolledWindow(pParent); } + else if (name == "GtkViewport") + { + pWindow = new VclViewport(pParent); + } else if (name == "GtkEventBox") { pWindow = new VclEventBox(pParent); diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 88823f17db6a..0795ee89fd65 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1613,6 +1613,13 @@ VclScrolledWindow::VclScrolledWindow(Window *pParent, WinBits nStyle) IMPL_LINK_NOARG(VclScrolledWindow, ScrollBarHdl) { Window *pChild = get_child(); + if (!pChild) + return 1; + + assert(dynamic_cast(pChild) && "scrolledwindow child should be a Viewport"); + + pChild = pChild->GetWindow(WINDOW_FIRSTCHILD); + if (!pChild) return 1; @@ -1698,7 +1705,9 @@ void VclScrolledWindow::setAllocation(const Size &rAllocation) long nAvailWidth = rAllocation.Width(); // vert. ScrollBar if (GetStyle() & WB_AUTOVSCROLL) + { m_aVScroll.Show(nAvailHeight < aChildReq.Height()); + } if (m_aVScroll.IsVisible()) nAvailWidth -= getLayoutRequisition(m_aVScroll).Width(); @@ -1754,12 +1763,8 @@ void VclScrolledWindow::setAllocation(const Size &rAllocation) if (pChild && pChild->IsVisible()) { - Point aChildPos(pChild->GetPosPixel()); - if (!m_aHScroll.IsVisible()) - aChildPos.X() = 0; - if (!m_aVScroll.IsVisible()) - aChildPos.Y() = 0; - setLayoutAllocation(*pChild, aChildPos, aChildAllocation); + assert(dynamic_cast(pChild) && "scrolledwindow child should be a Viewport"); + setLayoutAllocation(*pChild, Point(0, 0), aInnerSize); } if (!m_bUserManagedScrolling) @@ -1803,6 +1808,18 @@ bool VclScrolledWindow::Notify(NotifyEvent& rNEvt) return nDone || VclBin::Notify( rNEvt ); } +void VclViewport::setAllocation(const Size &rAllocation) +{ + Window *pChild = get_child(); + if (pChild && pChild->IsVisible()) + { + Size aReq(getLayoutRequisition(*pChild)); + aReq.Width() = std::max(aReq.Width(), rAllocation.Width()); + aReq.Height() = std::max(aReq.Height(), rAllocation.Height()); + setLayoutAllocation(*pChild, Point(0, 0), aReq); + } +} + const Window *VclEventBox::get_child() const { const WindowImpl* pWindowImpl = ImplGetWindowImpl(); -- cgit v1.2.3