diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-06-18 21:30:10 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-06-20 12:41:53 +0200 |
commit | 1f8d45c276760a173c3e30c78b8b740414a5b05f (patch) | |
tree | 4e22f39b8515a1839c9dc64146725ca02ec9b6f9 /svtools | |
parent | 6e5e83025c948b699bb65839ef810a45a98ba014 (diff) |
weld SvxColorTabPage
Change-Id: I5dc6f949edcb34aa110dfa9415e2ac886d0dfa4c
Reviewed-on: https://gerrit.libreoffice.org/56111
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/valueset.cxx | 123 |
1 files changed, 122 insertions, 1 deletions
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 457ffaba83cb..281bbe5b8a19 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -2275,8 +2275,9 @@ void ValueSet::SetEdgeBlending(bool bNew) } } -SvtValueSet::SvtValueSet() +SvtValueSet::SvtValueSet(weld::ScrolledWindow* pScrolledWindow) : maVirDev( VclPtr<VirtualDevice>::Create()) + , mxScrolledWindow(pScrolledWindow) , maColor(COL_TRANSPARENT) , mnStyle(0) , mbFormat(true) @@ -2307,6 +2308,12 @@ SvtValueSet::SvtValueSet() mbFullMode = true; mbEdgeBlending = false; mbHasVisibleItems = false; + + if (mxScrolledWindow) + { + mxScrolledWindow->set_user_managed_scrolling(); + mxScrolledWindow->connect_vadjustment_changed(LINK(this, SvtValueSet, ImplScrollHdl)); + } } void SvtValueSet::SetDrawingArea(weld::DrawingArea* pDrawingArea) @@ -2354,6 +2361,11 @@ void SvtValueSet::ImplDeleteItems() mItemList.clear(); } +void SvtValueSet::Select() +{ + maSelectHdl.Call( this ); +} + size_t SvtValueSet::ImplGetItem( const Point& rPos ) const { if (!mbHasVisibleItems) @@ -2432,6 +2444,17 @@ bool SvtValueSet::ImplHasAccessibleListeners() return( pAcc && pAcc->HasAccessibleListeners() ); } +IMPL_LINK(SvtValueSet, ImplScrollHdl, weld::ScrolledWindow&, rScrollWin, void) +{ + auto nNewFirstLine = rScrollWin.vadjustment_get_value(); + if ( nNewFirstLine != mnFirstLine ) + { + mnFirstLine = nNewFirstLine; + mbFormat = true; + Invalidate(); + } +} + void SvtValueSet::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { if (GetStyle() & WB_FLATVALUESET) @@ -2598,6 +2621,7 @@ bool SvtValueSet::KeyInput( const KeyEvent& rKeyEvent ) case KEY_RETURN: if (GetStyle() & WB_NO_DIRECTSELECT) { + Select(); break; } SAL_FALLTHROUGH; @@ -2618,6 +2642,11 @@ bool SvtValueSet::KeyInput( const KeyEvent& rKeyEvent ) if ( nItemId != mnSelItemId ) { SelectItem( nItemId ); + if (!(GetStyle() & WB_NO_DIRECTSELECT)) + { + // select only if WB_NO_DIRECTSELECT is not set + Select(); + } } return true; @@ -2635,6 +2664,7 @@ void SvtValueSet::MouseButtonDown( const MouseEvent& rMouseEvent ) SelectItem( pItem->mnId ); if (!(GetStyle() & WB_NOPOINTERFOCUS)) GrabFocus(); + Select(); } else if ( rMouseEvent.GetClicks() == 2 ) maDoubleClickHdl.Call( this ); @@ -2646,6 +2676,50 @@ void SvtValueSet::MouseButtonDown( const MouseEvent& rMouseEvent ) CustomWidgetController::MouseButtonDown( rMouseEvent ); } +void SvtValueSet::RemoveItem( sal_uInt16 nItemId ) +{ + size_t nPos = GetItemPos( nItemId ); + + if ( nPos == VALUESET_ITEM_NOTFOUND ) + return; + + if ( nPos < mItemList.size() ) { + SvtValueItemList::iterator it = mItemList.begin(); + ::std::advance( it, nPos ); + delete *it; + mItemList.erase( it ); + } + + // reset variables + if (mnSelItemId == nItemId) + { + mnCurCol = 0; + mnSelItemId = 0; + mbNoSelection = true; + } + + queue_resize(); + + mbFormat = true; + if ( IsReallyVisible() && IsUpdateMode() ) + Invalidate(); +} + +void SvtValueSet::Clear() +{ + ImplDeleteItems(); + + // reset variables + mnFirstLine = 0; + mnCurCol = 0; + mnSelItemId = 0; + mbNoSelection = true; + + mbFormat = true; + if (IsReallyVisible() && IsUpdateMode()) + Invalidate(); +} + size_t SvtValueSet::GetItemCount() const { return mItemList.size(); @@ -2846,6 +2920,16 @@ void SvtValueSet::SetNoSelection() Invalidate(); } +void SvtValueSet::SetStyle(WinBits nStyle) +{ + if (nStyle != mnStyle) + { + mnStyle = nStyle; + mbFormat = false; + Invalidate(); + } +} + void SvtValueSet::Format(vcl::RenderContext const & rRenderContext) { Size aWinSize(GetOutputSizePixel()); @@ -2856,6 +2940,13 @@ void SvtValueSet::Format(vcl::RenderContext const & rRenderContext) long nNoneHeight; long nNoneSpace; + if (mxScrolledWindow && !(nStyle & WB_VSCROLL) && mxScrolledWindow->get_vpolicy() != VclPolicyType::NEVER) + { + mxScrolledWindow->set_vpolicy(VclPolicyType::NEVER); + Size aPrefSize(GetDrawingArea()->get_preferred_size()); + GetDrawingArea()->set_size_request(aPrefSize.Width() + GetScrollWidth(), aPrefSize.Height()); + } + // calculate item offset if (nStyle & WB_ITEMBORDER) { @@ -3000,6 +3091,13 @@ void SvtValueSet::Format(vcl::RenderContext const & rRenderContext) { mItemList[i]->mbVisible = false; } + + if (mxScrolledWindow && mxScrolledWindow->get_vpolicy() != VclPolicyType::NEVER) + { + mxScrolledWindow->set_vpolicy(VclPolicyType::NEVER); + Size aPrefSize(GetDrawingArea()->get_preferred_size()); + GetDrawingArea()->set_size_request(aPrefSize.Width() + GetScrollWidth(), aPrefSize.Height()); + } } else { @@ -3136,6 +3234,19 @@ void SvtValueSet::Format(vcl::RenderContext const & rRenderContext) pItem->mbVisible = false; } } + + // arrange ScrollBar, set values and show it + if (mxScrolledWindow && (nStyle & WB_VSCROLL) && mxScrolledWindow->get_vpolicy() != VclPolicyType::ALWAYS) + { + long nPageSize = mnVisLines; + if (nPageSize < 1) + nPageSize = 1; + mxScrolledWindow->vadjustment_configure(mnFirstLine, 0, mnLines, 1, + mnVisLines, nPageSize); + mxScrolledWindow->set_vpolicy(VclPolicyType::ALWAYS); + Size aPrefSize(GetDrawingArea()->get_preferred_size()); + GetDrawingArea()->set_size_request(aPrefSize.Width() - GetScrollWidth(), aPrefSize.Height()); + } } // waiting for the next since the formatting is finished @@ -3523,6 +3634,9 @@ Size SvtValueSet::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesire aSize.AdjustHeight(nTxtHeight + n + mnSpacing ); } + // sum possible ScrollBar width + aSize.AdjustWidth(GetScrollWidth()); + return aSize; } @@ -3558,6 +3672,13 @@ void SvtValueSet::ImplInsertItem( SvtValueSetItem *const pItem, const size_t nPo Invalidate(); } +int SvtValueSet::GetScrollWidth() const +{ + if (mxScrolledWindow) + return mxScrolledWindow->get_vscroll_width(); + return 0; +} + void SvtValueSet::SetEdgeBlending(bool bNew) { if(mbEdgeBlending != bNew) |