diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-08-20 12:01:14 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-08-20 14:00:58 +0100 |
commit | 4b339818bb036b409dd5dc00d645c62063e63de5 (patch) | |
tree | cd27d4fc5a75930cb6565d362a1cfc2261c404e1 /vcl | |
parent | eba5e5b6b6577cc2d0bbd1ff66eefd0e2024fc4e (diff) |
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
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/builder.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 29 |
2 files changed, 28 insertions, 7 deletions
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 @@ -1616,6 +1616,13 @@ IMPL_LINK_NOARG(VclScrolledWindow, ScrollBarHdl) if (!pChild) return 1; + assert(dynamic_cast<VclViewport*>(pChild) && "scrolledwindow child should be a Viewport"); + + pChild = pChild->GetWindow(WINDOW_FIRSTCHILD); + + if (!pChild) + return 1; + Point aWinPos; if (m_aHScroll.IsVisible()) @@ -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<VclViewport*>(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(); |