diff options
-rw-r--r-- | include/svtools/valueset.hxx | 8 | ||||
-rw-r--r-- | svtools/source/control/valueset.cxx | 162 |
2 files changed, 49 insertions, 121 deletions
diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx index 0f70c177ee1b..6d67061c79b9 100644 --- a/include/svtools/valueset.hxx +++ b/include/svtools/valueset.hxx @@ -194,8 +194,6 @@ typedef std::vector<ValueSetItem*> ValueItemList; class SVT_DLLPUBLIC ValueSet : public Control { private: - - ScopedVclPtr<VirtualDevice> maVirDev; Timer maTimer; ValueItemList mItemList; std::unique_ptr<ValueSetItem> mpNoneItem; @@ -245,11 +243,10 @@ private: SVT_DLLPRIVATE void ImplInitScrollBar(); SVT_DLLPRIVATE void ImplDeleteItems(); - SVT_DLLPRIVATE void ImplFormatItem(vcl::RenderContext const & rRenderContext, ValueSetItem* pItem, tools::Rectangle aRect); + SVT_DLLPRIVATE void ImplFormatItem(vcl::RenderContext& rRenderContext, ValueSetItem* pItem, tools::Rectangle aRect); SVT_DLLPRIVATE void ImplDrawItemText(vcl::RenderContext& rRenderContext, const OUString& rStr); SVT_DLLPRIVATE void ImplDrawSelect(vcl::RenderContext& rRenderContext, sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel); SVT_DLLPRIVATE void ImplDrawSelect(vcl::RenderContext& rRenderContext); - SVT_DLLPRIVATE void ImplHideSelect(sal_uInt16 nItemId); SVT_DLLPRIVATE void ImplHighlightItem(sal_uInt16 nItemId, bool bIsSelection = true); SVT_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext); using Window::ImplScroll; @@ -270,6 +267,8 @@ private: ValueSet (const ValueSet &) = delete; ValueSet & operator= (const ValueSet &) = delete; + SVT_DLLPRIVATE void Format(vcl::RenderContext& rRenderContext); + protected: void StartDrag( const CommandEvent& rCEvt, vcl::Region& rRegion ); @@ -375,7 +374,6 @@ public: void SetExtraSpacing( sal_uInt16 nNewSpacing ); - void Format(vcl::RenderContext const & rRenderContext); void SetFormat(); void StartSelection(); diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 0502bbe4017c..7efb94313d09 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -57,7 +57,6 @@ enum ValueSet::ValueSet( vcl::Window* pParent, WinBits nWinStyle ) : Control( pParent, nWinStyle ), - maVirDev( VclPtr<VirtualDevice>::Create(*this) ), maColor( COL_TRANSPARENT ) { mpNoneItem.reset(nullptr); @@ -91,9 +90,6 @@ ValueSet::ValueSet( vcl::Window* pParent, WinBits nWinStyle ) : mbEdgeBlending = false; mbHasVisibleItems = false; - // #106446#, #106601# force mirroring of virtual device - maVirDev->EnableRTL( GetParent()->IsRTLEnabled() ); - ImplInitSettings( true, true, true ); } @@ -201,7 +197,7 @@ void ValueSet::ImplInitScrollBar() } } -void ValueSet::ImplFormatItem(vcl::RenderContext const & rRenderContext, ValueSetItem* pItem, tools::Rectangle aRect) +void ValueSet::ImplFormatItem(vcl::RenderContext& rRenderContext, ValueSetItem* pItem, tools::Rectangle aRect) { WinBits nStyle = GetStyle(); if (nStyle & WB_ITEMBORDER) @@ -222,7 +218,7 @@ void ValueSet::ImplFormatItem(vcl::RenderContext const & rRenderContext, ValueSe } else { - DecorationView aView(maVirDev.get()); + DecorationView aView(&rRenderContext); aRect = aView.DrawFrame(aRect, mnFrameStyle); } } @@ -237,42 +233,45 @@ void ValueSet::ImplFormatItem(vcl::RenderContext const & rRenderContext, ValueSe if (pItem == mpNoneItem.get()) { - maVirDev->SetFont(rRenderContext.GetFont()); - maVirDev->SetTextColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor()); - maVirDev->SetTextFillColor(); - maVirDev->SetFillColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor()); - maVirDev->DrawRect(aRect); + rRenderContext.SetTextColor((nStyle & WB_MENUSTYLEVALUESET) + ? rStyleSettings.GetMenuTextColor() + : rStyleSettings.GetWindowTextColor()); + rRenderContext.SetTextFillColor(); + rRenderContext.SetFillColor((nStyle & WB_MENUSTYLEVALUESET) + ? rStyleSettings.GetMenuColor() + : rStyleSettings.GetWindowColor()); + rRenderContext.DrawRect(aRect); Point aTxtPos(aRect.Left() + 2, aRect.Top()); long nTxtWidth = rRenderContext.GetTextWidth(pItem->maText); if ((aTxtPos.X() + nTxtWidth) > aRect.Right()) { - maVirDev->SetClipRegion(vcl::Region(aRect)); - maVirDev->DrawText(aTxtPos, pItem->maText); - maVirDev->SetClipRegion(); + rRenderContext.SetClipRegion(vcl::Region(aRect)); + rRenderContext.DrawText(aTxtPos, pItem->maText); + rRenderContext.SetClipRegion(); } else - maVirDev->DrawText(aTxtPos, pItem->maText); + rRenderContext.DrawText(aTxtPos, pItem->maText); } else if (pItem->meType == VALUESETITEM_COLOR) { - maVirDev->SetFillColor(pItem->maColor); - maVirDev->DrawRect(aRect); + rRenderContext.SetFillColor(pItem->maColor); + rRenderContext.DrawRect(aRect); } else { if (IsColor()) - maVirDev->SetFillColor(maColor); + rRenderContext.SetFillColor(maColor); else if (nStyle & WB_MENUSTYLEVALUESET) - maVirDev->SetFillColor(rStyleSettings.GetMenuColor()); + rRenderContext.SetFillColor(rStyleSettings.GetMenuColor()); else if (IsEnabled()) - maVirDev->SetFillColor(rStyleSettings.GetWindowColor()); + rRenderContext.SetFillColor(rStyleSettings.GetWindowColor()); else - maVirDev->SetFillColor(rStyleSettings.GetFaceColor()); - maVirDev->DrawRect(aRect); + rRenderContext.SetFillColor(rStyleSettings.GetFaceColor()); + rRenderContext.DrawRect(aRect); if (pItem->meType == VALUESETITEM_USERDRAW) { - UserDrawEvent aUDEvt(this, maVirDev.get(), aRect, pItem->mnId); + UserDrawEvent aUDEvt(this, &rRenderContext, aRect, pItem->mnId); UserDraw(aUDEvt); } else @@ -292,31 +291,30 @@ void ValueSet::ImplFormatItem(vcl::RenderContext const & rRenderContext, ValueSe if (aImageSize.Width() > aRectSize.Width() || aImageSize.Height() > aRectSize.Height()) { - maVirDev->SetClipRegion(vcl::Region(aRect)); - maVirDev->DrawImage(aPos, pItem->maImage, nImageStyle); - maVirDev->SetClipRegion(); + rRenderContext.SetClipRegion(vcl::Region(aRect)); + rRenderContext.DrawImage(aPos, pItem->maImage, nImageStyle); + rRenderContext.SetClipRegion(); } else - maVirDev->DrawImage(aPos, pItem->maImage, nImageStyle); + rRenderContext.DrawImage(aPos, pItem->maImage, nImageStyle); if (pItem->meType == VALUESETITEM_IMAGE_AND_TEXT) { - maVirDev->SetFont(rRenderContext.GetFont()); - maVirDev->SetTextColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor()); - maVirDev->SetTextFillColor(); + rRenderContext.SetFont(rRenderContext.GetFont()); + rRenderContext.SetTextColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor()); + rRenderContext.SetTextFillColor(); - long nTxtWidth = maVirDev->GetTextWidth(pItem->maText); + long nTxtWidth = rRenderContext.GetTextWidth(pItem->maText); if (nTxtWidth > aRect.GetWidth()) - maVirDev->SetClipRegion(vcl::Region(aRect)); + rRenderContext.SetClipRegion(vcl::Region(aRect)); - maVirDev->DrawText(Point(aRect.Left() + - (aRect.GetWidth() - nTxtWidth) / 2, - aRect.Bottom() - maVirDev->GetTextHeight()), - pItem->maText); + rRenderContext.DrawText(Point(aRect.Left() + (aRect.GetWidth() - nTxtWidth) / 2, + aRect.Bottom() - rRenderContext.GetTextHeight()), + pItem->maText); if (nTxtWidth > aRect.GetWidth()) - maVirDev->SetClipRegion(); + rRenderContext.SetClipRegion(); } } } @@ -332,7 +330,7 @@ void ValueSet::ImplFormatItem(vcl::RenderContext const & rRenderContext, ValueSe if (!aBlendFrame.IsEmpty()) { - maVirDev->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); + rRenderContext.DrawBitmapEx(aRect.TopLeft(), aBlendFrame); } } } @@ -342,7 +340,7 @@ Reference<XAccessible> ValueSet::CreateAccessible() return new ValueSetAcc( this ); } -void ValueSet::Format(vcl::RenderContext const & rRenderContext) +void ValueSet::Format(vcl::RenderContext& rRenderContext) { Size aWinSize(GetOutputSizePixel()); size_t nItemCount = mItemList.size(); @@ -487,11 +485,6 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) mnItemHeight = nCalcHeight / mnVisLines; } - // Init VirDev - maVirDev->SetSettings(rRenderContext.GetSettings()); - maVirDev->SetBackground(rRenderContext.GetBackground()); - maVirDev->SetOutputSizePixel(aWinSize); - // nothing is changed in case of too small items if ((mnItemWidth <= 0) || (mnItemHeight <= ((nStyle & WB_ITEMBORDER) ? 4 : 2)) || @@ -570,7 +563,7 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) } // calculate and draw items - maVirDev->SetLineColor(); + rRenderContext.SetLineColor(); long x = nStartX; long y = nStartY; @@ -850,41 +843,11 @@ void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext, sal_uInt16 nIt ImplDrawItemText(rRenderContext, pItem->maText); } -void ValueSet::ImplHideSelect( sal_uInt16 nItemId ) -{ - tools::Rectangle aRect; - - const size_t nItemPos = GetItemPos( nItemId ); - if ( nItemPos != VALUESET_ITEM_NOTFOUND ) - { - if ( !mItemList[nItemPos]->mbVisible ) - { - return; - } - aRect = ImplGetItemRect(nItemPos); - } - else - { - if (mpNoneItem.get() == nullptr) - { - return; - } - aRect = maNoneItemRect; - } - - HideFocus(); - const Point aPos = aRect.TopLeft(); - const Size aSize = aRect.GetSize(); - DrawOutDev( aPos, aSize, aPos, aSize, *maVirDev.get() ); -} - void ValueSet::ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection ) { if ( mnHighItemId == nItemId ) return; - // remember the old item to delete the previous selection - sal_uInt16 nOldItem = mnHighItemId; mnHighItemId = nItemId; // don't draw the selection if nothing is selected @@ -892,40 +855,15 @@ void ValueSet::ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection ) mbDrawSelection = false; // remove the old selection and draw the new one - ImplHideSelect( nOldItem ); Invalidate(); mbDrawSelection = true; } void ValueSet::ImplDraw(vcl::RenderContext& rRenderContext) { - if (mbFormat) - Format(rRenderContext); - + Format(rRenderContext); HideFocus(); - Point aDefPos; - Size aSize = maVirDev->GetOutputSizePixel(); - - if (mxScrollBar.get() && mxScrollBar->IsVisible()) - { - Point aScrPos = mxScrollBar->GetPosPixel(); - Size aScrSize = mxScrollBar->GetSizePixel(); - Point aTempPos(0, aScrPos.Y()); - Size aTempSize(aSize.Width(), aScrPos.Y()); - - rRenderContext.DrawOutDev(aDefPos, aTempSize, aDefPos, aTempSize, *maVirDev.get()); - aTempSize.Width() = aScrPos.X() - 1; - aTempSize.Height() = aScrSize.Height(); - rRenderContext.DrawOutDev(aTempPos, aTempSize, aTempPos, aTempSize, *maVirDev.get()); - aTempPos.Y() = aScrPos.Y() + aScrSize.Height(); - aTempSize.Width() = aSize.Width(); - aTempSize.Height() = aSize.Height() - aTempPos.Y(); - rRenderContext.DrawOutDev(aTempPos, aTempSize, aTempPos, aTempSize, *maVirDev.get()); - } - else - rRenderContext.DrawOutDev(aDefPos, aSize, aDefPos, aSize, *maVirDev.get()); - // draw parting line to the Namefield if (GetStyle() & WB_NAMEFIELD) { @@ -1381,9 +1319,6 @@ void ValueSet::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); rRenderContext.SetLineColor(); rRenderContext.SetFillColor(rStyleSettings.GetFaceColor()); - long nOffY = maVirDev->GetOutputSizePixel().Height(); - Size aWinSize(GetOutputSizePixel()); - rRenderContext.DrawRect(tools::Rectangle(Point(0, nOffY ), Point( aWinSize.Width(), aWinSize.Height()))); } ImplDraw(rRenderContext); @@ -1404,9 +1339,7 @@ void ValueSet::GetFocus() void ValueSet::LoseFocus() { SAL_INFO("svtools", "value set losing focus"); - if ( mbNoSelection && mnSelItemId ) - ImplHideSelect( mnSelItemId ); - else + if (!mbNoSelection || !mnSelItemId) HideFocus(); Control::LoseFocus(); @@ -1818,7 +1751,6 @@ void ValueSet::SelectItem( sal_uInt16 nItemId ) else { // remove old selection and draw the new one - ImplHideSelect( nOldItem ); Invalidate(); } } @@ -1983,16 +1915,15 @@ void ValueSet::SetItemText(sal_uInt16 nItemId, const OUString& rText) if ( nPos == VALUESET_ITEM_NOTFOUND ) return; - ValueSetItem* pItem = mItemList[nPos]; + if (pItem->maText == rText) + return; // Remember old and new name for accessibility event. Any aOldName; Any aNewName; - OUString sString (pItem->maText); - aOldName <<= sString; - sString = rText; - aNewName <<= sString; + aOldName <<= pItem->maText; + aNewName <<= rText; pItem->maText = rText; @@ -2242,10 +2173,9 @@ Size ValueSet::GetLargestItemSize() Size aSize = pItem->maImage.GetSizePixel(); if (pItem->meType == VALUESETITEM_IMAGE_AND_TEXT) { - aSize.Height() += 3 * NAME_LINE_HEIGHT + - maVirDev->GetTextHeight(); + aSize.Height() += 3 * NAME_LINE_HEIGHT + GetTextHeight(); aSize.Width() = std::max(aSize.Width(), - maVirDev->GetTextWidth(pItem->maText) + NAME_OFFSET); + GetTextWidth(pItem->maText) + NAME_OFFSET); } aLargestItem.Width() = std::max(aLargestItem.Width(), aSize.Width()); |