diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-09-16 10:14:06 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-16 11:33:20 +0100 |
commit | 363446eb61de141deb1364805e0d7cd0e1f6d7fe (patch) | |
tree | ee1d0e11a8c3b99fe3ebf3b9ec2e85c6be1a6d6e /vcl | |
parent | Set URE_INTERNAL_JAVA_DIR for unorc to allow jvm in unit tests. (diff) | |
download | core-363446eb61de141deb1364805e0d7cd0e1f6d7fe.tar.gz core-363446eb61de141deb1364805e0d7cd0e1f6d7fe.zip |
Resolves: fdo#69236 route size request to layout widget, not hard-coded value
a) For the sidebar the sidebars automatically handle scrolling, but for the
older panel the widgets has to do the scrolling so add scrolling parents to the
.ui
b) Fold the DialogListBox scrolling widget implementation into
VclScrolledWindow and remove the duplication.
Change-Id: Ife9ccd8c501e5dee7bf3102a92c8261d979cd834
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/control/scrbar.cxx | 3 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 24 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 129 |
3 files changed, 136 insertions, 20 deletions
diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx index fcb92e2a8a19..3ff834d4c9d3 100644 --- a/vcl/source/control/scrbar.cxx +++ b/vcl/source/control/scrbar.cxx @@ -145,8 +145,7 @@ ScrollBar::ScrollBar( Window* pParent, const ResId& rResId ) : ScrollBar::~ScrollBar() { - if( mpData ) - delete mpData; + delete mpData; } diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 1baf1c04135b..77762b50e68b 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -731,7 +731,7 @@ namespace Button* extractStockAndBuildPushButton(Window *pParent, VclBuilder::stringmap &rMap) { - WinBits nBits = WB_CENTER|WB_VCENTER; + WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER; nBits |= extractRelief(rMap); @@ -764,7 +764,7 @@ namespace Button * extractStockAndBuildMenuButton(Window *pParent, VclBuilder::stringmap &rMap) { - WinBits nBits = WB_CENTER|WB_VCENTER|WB_3DLOOK; + WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK; nBits |= extractRelief(rMap); @@ -1105,7 +1105,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri } } - if (bIsPlaceHolder || name == "GtkTreeSelection") + if (bIsPlaceHolder || name == "GtkTreeSelection" || name == "GtkViewport") return NULL; extractButtonImage(id, rMap, name == "GtkRadioButton"); @@ -1113,14 +1113,14 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri Window *pWindow = NULL; if (name == "GtkDialog") { - WinBits nBits = WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE; + WinBits nBits = WB_CLIPCHILDREN|WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE; if (extractResizable(rMap)) nBits |= WB_SIZEABLE; pWindow = new Dialog(pParent, nBits); } else if (name == "GtkMessageDialog") { - WinBits nBits = WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE; + WinBits nBits = WB_CLIPCHILDREN|WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE; if (extractResizable(rMap)) nBits |= WB_SIZEABLE; pWindow = new MessageDialog(pParent, nBits); @@ -1178,7 +1178,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri else if (name == "GtkRadioButton") { extractGroup(id, rMap); - WinBits nBits = WB_CENTER|WB_VCENTER|WB_3DLOOK; + WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK; OString sWrap = extractCustomProperty(rMap); if (!sWrap.isEmpty()) nBits |= WB_WORDBREAK; @@ -1188,7 +1188,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri } else if (name == "GtkCheckButton") { - WinBits nBits = WB_CENTER|WB_VCENTER|WB_3DLOOK; + WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK; OString sWrap = extractCustomProperty(rMap); if (!sWrap.isEmpty()) nBits |= WB_WORDBREAK; @@ -1208,7 +1208,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri OString sPattern = extractCustomProperty(rMap); OString sUnit = extractUnit(sPattern); - WinBits nBits = WB_LEFT|WB_BORDER|WB_3DLOOK; + WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_BORDER|WB_3DLOOK; if (!id.endsWith("-nospin")) nBits |= WB_SPIN | WB_REPEAT; @@ -1254,7 +1254,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri OString sPattern = extractCustomProperty(rMap); extractModel(id, rMap); - WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK; + WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK; bool bDropdown = VclBuilder::extractDropdown(rMap); @@ -1312,7 +1312,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri OString sAdjustment = extractAdjustment(rMap); extractModel(id, rMap); - WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK; + WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK; bool bDropdown = VclBuilder::extractDropdown(rMap); @@ -1352,7 +1352,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri // everything over to SvTreeViewBox //d) remove the users of makeSvTreeViewBox extractModel(id, rMap); - WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE; + WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE; OString sBorder = extractCustomProperty(rMap); if (!sBorder.isEmpty()) nWinStyle |= WB_BORDER; @@ -1433,7 +1433,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri { extractBuffer(id, rMap); - WinBits nWinStyle = WB_LEFT; + WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT; OString sBorder = extractCustomProperty(rMap); if (!sBorder.isEmpty()) nWinStyle |= WB_BORDER; diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 7bfcb8cd1caa..977aee810800 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1573,9 +1573,46 @@ IMPL_LINK( VclExpander, ClickHdl, DisclosureButton*, pBtn ) return 0; } +VclScrolledWindow::VclScrolledWindow(Window *pParent, WinBits nStyle) + : VclBin(pParent, nStyle) + , m_bUserManagedScrolling(false) + , m_aVScroll(this, WB_HIDE | WB_VERT) + , m_aHScroll(this, WB_HIDE | WB_HORZ) + , m_aScrollBarBox(this, WB_HIDE) +{ + SetType(WINDOW_SCROLLWINDOW); + + Link aLink( LINK( this, VclScrolledWindow, ScrollBarHdl ) ); + m_aVScroll.SetScrollHdl(aLink); + m_aHScroll.SetScrollHdl(aLink); +} + +IMPL_LINK_NOARG(VclScrolledWindow, ScrollBarHdl) +{ + Window *pChild = get_child(); + if (!pChild) + return 1; + + Point aWinPos; + + if (m_aHScroll.IsVisible()) + { + aWinPos.X() = -m_aHScroll.GetThumbPos(); + } + + if (m_aVScroll.IsVisible()) + { + aWinPos.Y() = -m_aVScroll.GetThumbPos(); + } + + pChild->SetPosPixel(aWinPos); + + return 1; +} + const Window *VclScrolledWindow::get_child() const { - assert(GetChildCount() == 3); + assert(GetChildCount() == 4); const WindowImpl* pWindowImpl = ImplGetWindowImpl(); return pWindowImpl->mpLastChild; } @@ -1593,15 +1630,38 @@ Size VclScrolledWindow::calculateRequisition() const if (pChild && pChild->IsVisible()) aRet = getLayoutRequisition(*pChild); - if (m_aVScroll.IsVisible()) + if (GetStyle() & WB_VSCROLL) aRet.Width() += getLayoutRequisition(m_aVScroll).Width(); - if (m_aHScroll.IsVisible()) + if (GetStyle() & WB_HSCROLL) aRet.Height() += getLayoutRequisition(m_aHScroll).Height(); return aRet; } +void VclScrolledWindow::InitScrollBars(const Size &rRequest) +{ + const Window *pChild = get_child(); + if (!pChild || !pChild->IsVisible()) + return; + + Size aOutSize(getVisibleChildSize()); + + if (m_aVScroll.IsVisible()) + { + m_aVScroll.SetRangeMax(rRequest.Height()); + m_aVScroll.SetVisibleSize(aOutSize.Height()); + m_aVScroll.SetPageSize(16); + } + + if (m_aHScroll.IsVisible()) + { + m_aHScroll.SetRangeMax(rRequest.Width()); + m_aHScroll.SetVisibleSize(aOutSize.Width()); + m_aHScroll.SetPageSize(16); + } +} + void VclScrolledWindow::setAllocation(const Size &rAllocation) { Size aChildAllocation(rAllocation); @@ -1611,26 +1671,61 @@ void VclScrolledWindow::setAllocation(const Size &rAllocation) if (pChild && pChild->IsVisible()) aChildReq = getLayoutRequisition(*pChild); + long nAvailHeight = rAllocation.Width(); + 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(); + + // horz. ScrollBar + if (GetStyle() & WB_AUTOHSCROLL) { - long nScrollBarWidth = getLayoutRequisition(m_aVScroll).Width(); + m_aHScroll.Show(nAvailWidth < aChildReq.Width()); + nAvailHeight -= getLayoutRequisition(m_aHScroll).Height(); + + if (GetStyle() & WB_AUTOVSCROLL) + m_aVScroll.Show(nAvailHeight < aChildReq.Height()); + } + + Size aInnerSize(aChildAllocation); + long nScrollBarWidth, nScrollBarHeight; + + if (m_aVScroll.IsVisible()) + { + nScrollBarWidth = getLayoutRequisition(m_aVScroll).Width(); Point aScrollPos(rAllocation.Width() - nScrollBarWidth, 0); Size aScrollSize(nScrollBarWidth, rAllocation.Height()); setLayoutAllocation(m_aVScroll, aScrollPos, aScrollSize); aChildAllocation.Width() -= nScrollBarWidth; + aInnerSize.Width() -= nScrollBarWidth; aChildAllocation.Height() = aChildReq.Height(); } if (m_aHScroll.IsVisible()) { - long nScrollBarHeight = getLayoutRequisition(m_aHScroll).Height(); + nScrollBarHeight = getLayoutRequisition(m_aHScroll).Height(); Point aScrollPos(0, rAllocation.Height() - nScrollBarHeight); Size aScrollSize(rAllocation.Width(), nScrollBarHeight); setLayoutAllocation(m_aHScroll, aScrollPos, aScrollSize); aChildAllocation.Height() -= nScrollBarHeight; + aInnerSize.Height() -= nScrollBarHeight; aChildAllocation.Width() = aChildReq.Width(); } + if (m_aVScroll.IsVisible() && m_aHScroll.IsVisible()) + { + Point aBoxPos(aInnerSize.Width(), aInnerSize.Height()); + m_aScrollBarBox.SetPosSizePixel(aBoxPos, Size(nScrollBarWidth, nScrollBarHeight)); + m_aScrollBarBox.Show(); + } + else + { + m_aScrollBarBox.Hide(); + } + if (pChild && pChild->IsVisible()) { Point aChildPos(pChild->GetPosPixel()); @@ -1640,6 +1735,9 @@ void VclScrolledWindow::setAllocation(const Size &rAllocation) aChildPos.Y() = 0; setLayoutAllocation(*pChild, aChildPos, aChildAllocation); } + + if (!m_bUserManagedScrolling) + InitScrollBars(aChildReq); } Size VclScrolledWindow::getVisibleChildSize() const @@ -1660,6 +1758,25 @@ bool VclScrolledWindow::set_property(const OString &rKey, const OString &rValue) return bRet; } +long VclScrolledWindow::Notify(NotifyEvent& rNEvt) +{ + long nDone = 0; + if ( rNEvt.GetType() == EVENT_COMMAND ) + { + const CommandEvent& rCEvt = *rNEvt.GetCommandEvent(); + if ( rCEvt.GetCommand() == COMMAND_WHEEL ) + { + const CommandWheelData* pData = rCEvt.GetWheelData(); + if( !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) ) + { + nDone = HandleScrollCommand(rCEvt, &m_aHScroll, &m_aVScroll); + } + } + } + + return nDone ? nDone : VclBin::Notify( rNEvt ); +} + const Window *VclEventBox::get_child() const { const WindowImpl* pWindowImpl = ImplGetWindowImpl(); @@ -1919,7 +2036,7 @@ short MessageDialog::Execute() m_pImage->set_valign(VCL_ALIGN_START); m_pImage->Show(); - WinBits nWinStyle = WB_LEFT | WB_VCENTER | WB_WORDBREAK | WB_NOLABEL | WB_NOTABSTOP; + WinBits nWinStyle = WB_CLIPCHILDREN | WB_LEFT | WB_VCENTER | WB_WORDBREAK | WB_NOLABEL | WB_NOTABSTOP; bool bHasSecondaryText = !m_sSecondaryString.isEmpty(); |