[Libreoffice-commits] core.git: Branch 'feature/rendercontext' - 6 commits - basctl/source include/vcl sw/source vcl/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Tue May 5 23:50:21 PDT 2015


 basctl/source/basicide/baside2b.cxx |    6 -
 include/vcl/slider.hxx              |    9 +
 include/vcl/spin.h                  |   14 +-
 include/vcl/tabctrl.hxx             |    6 -
 include/vcl/textview.hxx            |   17 +--
 include/vcl/toolbox.hxx             |   10 +-
 sw/source/uibase/docvw/srcedtw.cxx  |    4 
 vcl/source/app/help.cxx             |   36 +++----
 vcl/source/control/slider.cxx       |  166 +++++++++++++++++++--------------
 vcl/source/control/spinbtn.cxx      |   18 +--
 vcl/source/control/spinfld.cxx      |  154 +++++++++++++++---------------
 vcl/source/control/tabctrl.cxx      |  179 ++++++++++++++++++------------------
 vcl/source/edit/texteng.cxx         |    5 -
 vcl/source/edit/textview.cxx        |   86 ++++++++---------
 vcl/source/edit/vclmedit.cxx        |    6 -
 vcl/source/window/toolbox.cxx       |    2 
 16 files changed, 368 insertions(+), 350 deletions(-)

New commits:
commit 4d69a3fec28a4d35d9c09b6e0feee80dfbc2aaaf
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed May 6 15:49:16 2015 +0900

    refactor "TextEdit" & co. to use RenderContext
    
    Change-Id: Ib26ecb9640d23714acec73304f26e2fd6af90ed4

diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 6cbaaf5..d805646 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -915,12 +915,12 @@ void EditorWindow::SetupAndShowCodeCompleteWnd( const std::vector< OUString >& a
     pEditView->GetWindow()->GrabFocus();
 }
 
-void EditorWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect )
+void EditorWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
 {
-    if ( !pEditEngine )     // We need it now at latest
+    if (!pEditEngine)     // We need it now at latest
         CreateEditEngine();
 
-    pEditView->Paint( rRect );
+    pEditView->Paint(rRenderContext, rRect);
 }
 
 void EditorWindow::LoseFocus()
diff --git a/include/vcl/textview.hxx b/include/vcl/textview.hxx
index baf97a9..721c0c0 100644
--- a/include/vcl/textview.hxx
+++ b/include/vcl/textview.hxx
@@ -25,10 +25,11 @@
 #include <vcl/dllapi.h>
 #include <vcl/dndhelp.hxx>
 #include <vcl/textdata.hxx>
+#include <vcl/window.hxx>
 
 class TextEngine;
 class OutputDevice;
-namespace vcl { class Window; }
+
 class KeyEvent;
 class MouseEvent;
 class CommandEvent;
@@ -37,11 +38,7 @@ class SelectionEngine;
 class VirtualDevice;
 struct TextDDInfo;
 
-namespace com {
-namespace sun {
-namespace star {
-namespace datatransfer {
-namespace clipboard {
+namespace com { namespace sun { namespace star { namespace datatransfer { namespace clipboard {
     class XClipboard;
 }}}}}
 
@@ -72,8 +69,8 @@ protected:
     void                ImpSetSelection( const TextSelection& rNewSel, bool bUI );
     bool                IsInSelection( const TextPaM& rPaM );
 
-    void                ImpPaint( OutputDevice* pOut, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange = 0, TextSelection const* pSelection = 0 );
-    void                ImpPaint( const Rectangle& rRect, bool bUseVirtDev );
+    void                ImpPaint(vcl::RenderContext& rRenderContext, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange = 0, TextSelection const* pSelection = 0);
+    void                ImpPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect, bool bUseVirtDev);
     void                ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bEndKey );
     void                ImpHighlight( const TextSelection& rSel );
     void                ImpSetSelection( const TextSelection& rSelection );
@@ -127,8 +124,8 @@ public:
 
     void                InsertText( const OUString& rNew, bool bSelect = false );
 
-    bool            KeyInput( const KeyEvent& rKeyEvent );
-    void                Paint( const Rectangle& rRect );
+    bool                KeyInput( const KeyEvent& rKeyEvent );
+    void                Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
     void                MouseButtonUp( const MouseEvent& rMouseEvent );
     void                MouseButtonDown( const MouseEvent& rMouseEvent );
     void                MouseMove( const MouseEvent& rMouseEvent );
diff --git a/sw/source/uibase/docvw/srcedtw.cxx b/sw/source/uibase/docvw/srcedtw.cxx
index cd66ace..2e42082 100644
--- a/sw/source/uibase/docvw/srcedtw.cxx
+++ b/sw/source/uibase/docvw/srcedtw.cxx
@@ -479,9 +479,9 @@ void  TextViewOutWin::KeyInput( const KeyEvent& rKEvt )
     }
 }
 
-void  TextViewOutWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect )
+void TextViewOutWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
 {
-    pTextView->Paint( rRect );
+    pTextView->Paint(rRenderContext, rRect);
 }
 
 void SwSrcEditWindow::CreateTextEngine()
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index 235dd13..86a7173 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -1499,10 +1499,7 @@ void TextEngine::UpdateViews( TextView* pCurView )
                 aNewPos.X() -= aOutSz.Width() - 1;
             aClipRect.SetPos( aNewPos );
 
-            if ( pView == pCurView )
-                pView->ImpPaint( aClipRect, !pView->GetWindow()->IsPaintTransparent() );
-            else
-                pView->GetWindow()->Invalidate( aClipRect );
+            pView->GetWindow()->Invalidate( aClipRect );
         }
     }
 
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index 2dd8da9..bd0ccc9 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -293,99 +293,97 @@ void TextView::DeleteSelected()
     ShowCursor();
 }
 
-void TextView::ImpPaint( OutputDevice* pOut, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange, TextSelection const* pSelection )
+void TextView::ImpPaint(vcl::RenderContext& rRenderContext, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange, TextSelection const* pSelection)
 {
-    if ( !mpImpl->mbPaintSelection )
+    if (!mpImpl->mbPaintSelection)
+    {
         pSelection = NULL;
+    }
     else
     {
         // set correct background color;
         // unfortunately we cannot detect if it has changed
         vcl::Font aFont = mpImpl->mpTextEngine->GetFont();
-        Color aColor = pOut->GetBackground().GetColor();
-        aColor.SetTransparency( 0 );
-        if ( aColor != aFont.GetFillColor() )
+        Color aColor = rRenderContext.GetBackground().GetColor();
+        aColor.SetTransparency(0);
+        if (aColor != aFont.GetFillColor())
         {
-            if( aFont.IsTransparent() )
-                aColor = Color( COL_TRANSPARENT );
-            aFont.SetFillColor( aColor );
+            if (aFont.IsTransparent())
+                aColor = Color(COL_TRANSPARENT);
+            aFont.SetFillColor(aColor);
             mpImpl->mpTextEngine->maFont = aFont;
         }
     }
 
-    mpImpl->mpTextEngine->ImpPaint( pOut, rStartPos, pPaintArea, pPaintRange, pSelection );
+    mpImpl->mpTextEngine->ImpPaint(&rRenderContext, rStartPos, pPaintArea, pPaintRange, pSelection);
 }
 
-void TextView::Paint( const Rectangle& rRect )
+void TextView::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
 {
-    ImpPaint( rRect, false );
+    ImpPaint(rRenderContext, rRect, false);
 }
 
-void TextView::ImpPaint( const Rectangle& rRect, bool bUseVirtDev )
+void TextView::ImpPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect, bool bUseVirtDev)
 {
     if ( !mpImpl->mpTextEngine->GetUpdateMode() || mpImpl->mpTextEngine->IsInUndo() )
         return;
 
     TextSelection *pDrawSelection = NULL;
-    if ( !mpImpl->mbHighlightSelection && mpImpl->maSelection.HasRange() )
+    if (!mpImpl->mbHighlightSelection && mpImpl->maSelection.HasRange())
         pDrawSelection = &mpImpl->maSelection;
 
-    if ( bUseVirtDev )
+    if (bUseVirtDev)
     {
         VirtualDevice* pVDev = GetVirtualDevice();
 
         const Color& rBackgroundColor = mpImpl->mpWindow->GetBackground().GetColor();
-        if ( pVDev->GetFillColor() != rBackgroundColor )
+        if (pVDev->GetFillColor() != rBackgroundColor)
             pVDev->SetFillColor( rBackgroundColor );
-        if ( pVDev->GetBackground().GetColor() != rBackgroundColor )
+        if (pVDev->GetBackground().GetColor() != rBackgroundColor)
             pVDev->SetBackground( rBackgroundColor );
 
         bool bVDevValid = true;
-        Size aOutSz( pVDev->GetOutputSizePixel() );
-        if ( (  aOutSz.Width() < rRect.GetWidth() ) ||
-             (  aOutSz.Height() < rRect.GetHeight() ) )
+        Size aOutSz(pVDev->GetOutputSizePixel());
+        if ((aOutSz.Width() < rRect.GetWidth()) ||
+            (aOutSz.Height() < rRect.GetHeight()))
         {
-            bVDevValid = pVDev->SetOutputSizePixel( rRect.GetSize() );
+            bVDevValid = pVDev->SetOutputSizePixel(rRect.GetSize());
         }
         else
         {
             // the VirtDev can get very large on Resize =>
             // shrink now and then
-            if ( ( aOutSz.Height() > ( rRect.GetHeight() + 20 ) ) ||
-                 ( aOutSz.Width() > ( rRect.GetWidth() + 20 ) ) )
+            if ((aOutSz.Height() > (rRect.GetHeight() + 20)) ||
+                (aOutSz.Width() > (rRect.GetWidth() + 20)))
             {
-                bVDevValid = pVDev->SetOutputSizePixel( rRect.GetSize() );
+                bVDevValid = pVDev->SetOutputSizePixel(rRect.GetSize());
             }
             else
             {
                 pVDev->Erase();
             }
         }
-        if ( !bVDevValid )
+        if (!bVDevValid)
         {
-            ImpPaint( rRect, false /* without VDev */ );
+            ImpPaint(rRenderContext, rRect, false);
             return;
         }
 
-        Rectangle aTmpRect( Point( 0, 0 ), rRect.GetSize() );
+        Rectangle aTmpRect(Point(0, 0), rRect.GetSize());
 
-        Point aDocPos( mpImpl->maStartDocPos.X(), mpImpl->maStartDocPos.Y() + rRect.Top() );
-        Point aStartPos = ImpGetOutputStartPos( aDocPos );
-        ImpPaint( pVDev, aStartPos, &aTmpRect, NULL, pDrawSelection );
-        mpImpl->mpWindow->DrawOutDev( rRect.TopLeft(), rRect.GetSize(),
-                                Point(0,0), rRect.GetSize(), *pVDev );
-//      ShowSelection();
-        if ( mpImpl->mbHighlightSelection )
-            ImpHighlight( mpImpl->maSelection );
+        Point aDocPos(mpImpl->maStartDocPos.X(), mpImpl->maStartDocPos.Y() + rRect.Top());
+        Point aStartPos = ImpGetOutputStartPos(aDocPos);
+        ImpPaint(*pVDev, aStartPos, &aTmpRect, NULL, pDrawSelection);
+        rRenderContext.DrawOutDev(rRect.TopLeft(), rRect.GetSize(), Point(0,0), rRect.GetSize(), *pVDev);
+        if (mpImpl->mbHighlightSelection)
+            ImpHighlight(mpImpl->maSelection);
     }
     else
     {
-        Point aStartPos = ImpGetOutputStartPos( mpImpl->maStartDocPos );
-        ImpPaint( mpImpl->mpWindow, aStartPos, &rRect, NULL, pDrawSelection );
-
-//      ShowSelection();
-        if ( mpImpl->mbHighlightSelection )
-            ImpHighlight( mpImpl->maSelection );
+        Point aStartPos = ImpGetOutputStartPos(mpImpl->maStartDocPos);
+        ImpPaint(rRenderContext, aStartPos, &rRect, NULL, pDrawSelection);
+        if (mpImpl->mbHighlightSelection)
+            ImpHighlight(mpImpl->maSelection);
     }
 }
 
@@ -499,7 +497,7 @@ void TextView::ShowSelection( const TextSelection& rRange )
     ImpShowHideSelection( true, &rRange );
 }
 
-void TextView::ImpShowHideSelection( bool bShow, const TextSelection* pRange )
+void TextView::ImpShowHideSelection(bool /*bShow*/, const TextSelection* pRange)
 {
     const TextSelection* pRangeOrSelection = pRange ? pRange : &mpImpl->maSelection;
 
@@ -515,14 +513,12 @@ void TextView::ImpShowHideSelection( bool bShow, const TextSelection* pRange )
                 mpImpl->mpWindow->Invalidate();
             else
             {
-                Rectangle aOutArea( Point( 0, 0 ), mpImpl->mpWindow->GetOutputSizePixel() );
-                Point aStartPos( ImpGetOutputStartPos( mpImpl->maStartDocPos ) );
                 TextSelection aRange( *pRangeOrSelection );
                 aRange.Justify();
                 bool bVisCursor = mpImpl->mpCursor->IsVisible();
                 mpImpl->mpCursor->Hide();
-                ImpPaint( mpImpl->mpWindow, aStartPos, &aOutArea, &aRange, bShow ? &mpImpl->maSelection : NULL );
-                if ( bVisCursor )
+                Invalidate();
+                if (bVisCursor)
                     mpImpl->mpCursor->Show();
             }
         }
diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx
index a631380..0e7e91c 100644
--- a/vcl/source/edit/vclmedit.cxx
+++ b/vcl/source/edit/vclmedit.cxx
@@ -60,7 +60,7 @@ public:
 
     virtual void    Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
 
-    virtual void    Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) SAL_OVERRIDE;
+    virtual void    Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
     virtual void    Resize() SAL_OVERRIDE;
 
     virtual void    GetFocus() SAL_OVERRIDE;
@@ -805,9 +805,9 @@ void TextWindow::KeyInput( const KeyEvent& rKEvent )
         Window::KeyInput( rKEvent );
 }
 
-void TextWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect )
+void TextWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
 {
-    mpExtTextView->Paint( rRect );
+    mpExtTextView->Paint(rRenderContext, rRect);
 }
 
 void TextWindow::Resize()
commit c29e6edce8465aeab69024a979d617431b841dd0
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed May 6 13:01:10 2015 +0900

    refactor "HelpTextWindow" - use RenderContext
    
    Change-Id: I6cfcd86fabb2f568b577bb060cccabfe1aebc537

diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index 68bb91e..a970baa 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -352,49 +352,49 @@ void HelpTextWindow::ImplShow()
     Update();
 }
 
-void HelpTextWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void HelpTextWindow::Paint( vcl::RenderContext& rRenderContext, const Rectangle& )
 {
     // paint native background
     bool bNativeOK = false;
-    if ( IsNativeControlSupported( CTRL_TOOLTIP, PART_ENTIRE_CONTROL ) )
+    if (rRenderContext.IsNativeControlSupported(CTRL_TOOLTIP, PART_ENTIRE_CONTROL))
     {
         // #i46472# workaround gcc3.3 temporary problem
-        Rectangle aCtrlRegion( Point( 0, 0 ), GetOutputSizePixel() );
-        ImplControlValue    aControlValue;
-        bNativeOK = DrawNativeControl( CTRL_TOOLTIP, PART_ENTIRE_CONTROL, aCtrlRegion,
-                                        ControlState::NONE, aControlValue, OUString() );
+        Rectangle aCtrlRegion(Point(0, 0), GetOutputSizePixel());
+        ImplControlValue aControlValue;
+        bNativeOK = rRenderContext.DrawNativeControl(CTRL_TOOLTIP, PART_ENTIRE_CONTROL, aCtrlRegion,
+                                                     ControlState::NONE, aControlValue, OUString());
     }
 
     // paint text
-    if ( mnHelpWinStyle == HELPWINSTYLE_QUICK && maHelpText.getLength() < HELPTEXTMAXLEN)
+    if (mnHelpWinStyle == HELPWINSTYLE_QUICK && maHelpText.getLength() < HELPTEXTMAXLEN)
     {
         if ( mnStyle & QUICKHELP_CTRLTEXT )
-            DrawCtrlText( maTextRect.TopLeft(), maHelpText );
+            rRenderContext.DrawCtrlText(maTextRect.TopLeft(), maHelpText);
         else
-            DrawText( maTextRect.TopLeft(), maHelpText );
+            rRenderContext.DrawText(maTextRect.TopLeft(), maHelpText);
     }
     else // HELPWINSTYLE_BALLOON
     {
         sal_uInt16 nDrawFlags = TEXT_DRAW_MULTILINE|TEXT_DRAW_WORDBREAK|
                                 TEXT_DRAW_LEFT|TEXT_DRAW_TOP;
-        if ( mnStyle & QUICKHELP_CTRLTEXT )
+        if (mnStyle & QUICKHELP_CTRLTEXT)
             nDrawFlags |= TEXT_DRAW_MNEMONIC;
-        DrawText( maTextRect, maHelpText, nDrawFlags );
+        rRenderContext.DrawText(maTextRect, maHelpText, nDrawFlags);
     }
 
     // border
-    if( ! bNativeOK )
+    if (!bNativeOK)
     {
         Size aSz = GetOutputSizePixel();
-        DrawRect( Rectangle( Point(), aSz ) );
-        if ( mnHelpWinStyle == HELPWINSTYLE_BALLOON )
+        rRenderContext.DrawRect(Rectangle(Point(), aSz));
+        if (mnHelpWinStyle == HELPWINSTYLE_BALLOON)
         {
             aSz.Width() -= 2;
             aSz.Height() -= 2;
-            Color aColor( GetLineColor() );
-            SetLineColor( ( COL_GRAY ) );
-            DrawRect( Rectangle( Point( 1, 1 ), aSz ) );
-            SetLineColor( aColor );
+            Color aColor(rRenderContext.GetLineColor());
+            rRenderContext.SetLineColor(COL_GRAY);
+            rRenderContext.DrawRect(Rectangle(Point(1, 1), aSz));
+            rRenderContext.SetLineColor(aColor);
         }
     }
 }
commit 4ba62ef90e8e426d151bf34eb3453be7f4b2e6ef
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed May 6 13:00:13 2015 +0900

    refactor "TabControl" to use RenderContext
    
    Change-Id: Iac6703bb9cf42e18c658b560a10baa6af6fa1df3

diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx
index 05fd48e..33e003c 100644
--- a/include/vcl/tabctrl.hxx
+++ b/include/vcl/tabctrl.hxx
@@ -61,8 +61,10 @@ private:
     SAL_DLLPRIVATE bool         ImplPosCurTabPage();
     SAL_DLLPRIVATE void         ImplActivateTabPage( bool bNext );
     SAL_DLLPRIVATE void         ImplShowFocus();
-    SAL_DLLPRIVATE void         ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bool bLayout = false, bool bFirstInGroup = false, bool bLastInGroup = false, bool bIsCurrentItem = false );
-    SAL_DLLPRIVATE void         ImplPaint( const Rectangle& rRect, bool bLayout = false );
+    SAL_DLLPRIVATE void         ImplDrawItem(vcl::RenderContext& rRenderContext, ImplTabItem* pItem,
+                                             const Rectangle& rCurRect, bool bLayout = false, bool bFirstInGroup = false,
+                                             bool bLastInGroup = false, bool bIsCurrentItem = false);
+    SAL_DLLPRIVATE void         ImplPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect, bool bLayout = false);
     SAL_DLLPRIVATE void         ImplFreeLayoutData();
     SAL_DLLPRIVATE bool         ImplHandleKeyEvent( const KeyEvent& rKeyEvent );
 
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 72c1357..22bb6d6 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -763,7 +763,8 @@ void TabControl::ImplShowFocus()
     ShowFocus( aRect );
 }
 
-void TabControl::ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bool bLayout, bool bFirstInGroup, bool bLastInGroup, bool /* bIsCurrentItem */ )
+void TabControl::ImplDrawItem(vcl::RenderContext& /*rRenderContext*/, ImplTabItem* pItem, const Rectangle& rCurRect,
+                              bool bLayout, bool bFirstInGroup, bool bLastInGroup, bool /* bIsCurrentItem */ )
 {
     if ( pItem->maRect.IsEmpty() )
         return;
@@ -1048,26 +1049,26 @@ void TabControl::KeyInput( const KeyEvent& rKEvt )
     Control::KeyInput( rKEvt );
 }
 
-void TabControl::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect )
+void TabControl::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect)
 {
-    if (  !( GetStyle() & WB_NOBORDER ) )
-        ImplPaint( rRect, false );
+    if (!(GetStyle() & WB_NOBORDER))
+        ImplPaint(rRenderContext, rRect, false);
 }
 
-void TabControl::ImplPaint( const Rectangle& rRect, bool bLayout )
+void TabControl::ImplPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect, bool bLayout)
 {
-    if( ! bLayout )
+    if (!bLayout)
         HideFocus();
 
     // reformat if needed
-    Rectangle aRect = ImplGetTabRect( TAB_PAGERECT );
+    Rectangle aRect = ImplGetTabRect(TAB_PAGERECT);
 
     // find current item
     ImplTabItem* pCurItem = NULL;
-    for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
+    for (std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
          it != mpTabCtrlData->maItemList.end(); ++it )
     {
-        if ( it->mnId == mnCurPageId )
+        if (it->mnId == mnCurPageId)
         {
             pCurItem = &(*it);
             break;
@@ -1075,8 +1076,8 @@ void TabControl::ImplPaint( const Rectangle& rRect, bool bLayout )
     }
 
     // Draw the TabPage border
-    const StyleSettings&    rStyleSettings  = GetSettings().GetStyleSettings();
-    Rectangle               aCurRect;
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+    Rectangle aCurRect;
     aRect.Left()   -= TAB_OFFSET;
     aRect.Top()    -= TAB_OFFSET;
     aRect.Right()  += TAB_OFFSET;
@@ -1088,123 +1089,121 @@ void TabControl::ImplPaint( const Rectangle& rRect, bool bLayout )
     // standalone (eg impress)
     bool bNoTabPage = false;
     TabPage* pCurPage = pCurItem ? pCurItem->mpTabPage.get() : NULL;
-    if( !pCurPage || !pCurPage->IsVisible() )
+    if (!pCurPage || !pCurPage->IsVisible())
     {
         bNoTabPage = true;
-        aRect.Left()-=10;
-        aRect.Right()+=10;
+        aRect.Left() -= 10;
+        aRect.Right() += 10;
     }
 
-    if (!bLayout && IsNativeControlSupported(CTRL_TAB_PANE, PART_ENTIRE_CONTROL))
+    if (!bLayout && rRenderContext.IsNativeControlSupported(CTRL_TAB_PANE, PART_ENTIRE_CONTROL))
     {
         const ImplControlValue aControlValue;
 
         ControlState nState = ControlState::ENABLED;
-        if ( !IsEnabled() )
+        if (!IsEnabled())
             nState &= ~ControlState::ENABLED;
-        if ( HasFocus() )
+        if (HasFocus())
             nState |= ControlState::FOCUSED;
 
-        vcl::Region aClipRgn( GetActiveClipRegion() );
-        aClipRgn.Intersect( aRect );
-        if( !rRect.IsEmpty() )
-            aClipRgn.Intersect( rRect );
+        vcl::Region aClipRgn(rRenderContext.GetActiveClipRegion());
+        aClipRgn.Intersect(aRect);
+        if (!rRect.IsEmpty())
+            aClipRgn.Intersect(rRect);
 
-        if( !aClipRgn.IsEmpty() )
+        if (!aClipRgn.IsEmpty())
         {
-            DrawNativeControl(CTRL_TAB_PANE, PART_ENTIRE_CONTROL, aRect, nState,
-                aControlValue, OUString());
+            rRenderContext.DrawNativeControl(CTRL_TAB_PANE, PART_ENTIRE_CONTROL,
+                                             aRect, nState, aControlValue, OUString());
         }
 
-        if (IsNativeControlSupported(CTRL_TAB_HEADER, PART_ENTIRE_CONTROL))
+        if (rRenderContext.IsNativeControlSupported(CTRL_TAB_HEADER, PART_ENTIRE_CONTROL))
         {
             Rectangle aHeaderRect(aRect.Left(), 0, aRect.Right(), aRect.Top());
 
-            aClipRgn = GetActiveClipRegion();
-            aClipRgn.Intersect( aHeaderRect );
-            if( !rRect.IsEmpty() )
-                aClipRgn.Intersect( rRect );
+            aClipRgn = rRenderContext.GetActiveClipRegion();
+            aClipRgn.Intersect(aHeaderRect);
+            if (!rRect.IsEmpty())
+                aClipRgn.Intersect(rRect);
 
-            if( !aClipRgn.IsEmpty() )
+            if (!aClipRgn.IsEmpty())
             {
-                DrawNativeControl(CTRL_TAB_HEADER, PART_ENTIRE_CONTROL, aHeaderRect, nState,
-                    aControlValue, OUString());
+                rRenderContext.DrawNativeControl(CTRL_TAB_HEADER, PART_ENTIRE_CONTROL,
+                                                 aHeaderRect, nState, aControlValue, OUString());
             }
         }
     }
     else
     {
         long nTopOff = 1;
-        if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
-            SetLineColor( rStyleSettings.GetLightColor() );
+        if (!(rStyleSettings.GetOptions() & STYLE_OPTION_MONO))
+            rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
         else
-            SetLineColor( Color( COL_BLACK ) );
-        if ( pCurItem && !pCurItem->maRect.IsEmpty() )
+            rRenderContext.SetLineColor(Color(COL_BLACK));
+        if (pCurItem && !pCurItem->maRect.IsEmpty())
         {
             aCurRect = pCurItem->maRect;
-            if( ! bLayout )
-                DrawLine( aRect.TopLeft(), Point( aCurRect.Left()-2, aRect.Top() ) );
-            if ( aCurRect.Right()+1 < aRect.Right() )
+            if (!bLayout)
+                rRenderContext.DrawLine(aRect.TopLeft(), Point(aCurRect.Left() - 2, aRect.Top()));
+            if (aCurRect.Right() + 1 < aRect.Right())
             {
-                if( ! bLayout )
-                    DrawLine( Point( aCurRect.Right(), aRect.Top() ), aRect.TopRight() );
+                if (!bLayout)
+                    rRenderContext.DrawLine(Point(aCurRect.Right(), aRect.Top()), aRect.TopRight());
             }
             else
+            {
                 nTopOff = 0;
+            }
         }
         else
-            if( ! bLayout )
-                DrawLine( aRect.TopLeft(), aRect.TopRight() );
+            if (!bLayout)
+                rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight());
 
-        if( ! bLayout )
+        if (!bLayout)
         {
-            DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
+            rRenderContext.DrawLine(aRect.TopLeft(), aRect.BottomLeft());
 
-            if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
+            if (!(rStyleSettings.GetOptions() & STYLE_OPTION_MONO))
             {
                 // if we have not tab page the bottom line of the tab page
                 // directly touches the tab items, so choose a color that fits seamlessly
-                if( bNoTabPage )
-                    SetLineColor( rStyleSettings.GetDialogColor() );
+                if (bNoTabPage)
+                    rRenderContext.SetLineColor(rStyleSettings.GetDialogColor());
                 else
-                    SetLineColor( rStyleSettings.GetShadowColor() );
-                DrawLine( Point( 1, aRect.Bottom()-1 ),
-                        Point( aRect.Right()-1, aRect.Bottom()-1 ) );
-                DrawLine( Point( aRect.Right()-1, aRect.Top()+nTopOff ),
-                        Point( aRect.Right()-1, aRect.Bottom()-1 ) );
-                if( bNoTabPage )
-                    SetLineColor( rStyleSettings.GetDialogColor() );
+                    rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
+                rRenderContext.DrawLine(Point(1, aRect.Bottom() - 1), Point(aRect.Right() - 1, aRect.Bottom() - 1));
+                rRenderContext.DrawLine(Point(aRect.Right() - 1, aRect.Top() + nTopOff), Point(aRect.Right() - 1, aRect.Bottom() - 1));
+                if (bNoTabPage)
+                    rRenderContext.SetLineColor(rStyleSettings.GetDialogColor());
                 else
-                    SetLineColor( rStyleSettings.GetDarkShadowColor() );
-                DrawLine( Point( 0, aRect.Bottom() ),
-                        Point( aRect.Right(), aRect.Bottom() ) );
-                DrawLine( Point( aRect.Right(), aRect.Top()+nTopOff ),
-                        Point( aRect.Right(), aRect.Bottom() ) );
+                    rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
+                rRenderContext.DrawLine(Point(0, aRect.Bottom()), Point(aRect.Right(), aRect.Bottom()));
+                rRenderContext.DrawLine(Point(aRect.Right(), aRect.Top() + nTopOff), Point(aRect.Right(), aRect.Bottom()));
             }
             else
             {
-                DrawLine( aRect.TopRight(), aRect.BottomRight() );
-                DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
+                rRenderContext.DrawLine(aRect.TopRight(), aRect.BottomRight());
+                rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
             }
         }
     }
 
-    if ( !mpTabCtrlData->maItemList.empty() && mpTabCtrlData->mpListBox == nullptr )
+    if (!mpTabCtrlData->maItemList.empty() && mpTabCtrlData->mpListBox == nullptr)
     {
         // Some native toolkits (GTK+) draw tabs right-to-left, with an
         // overlap between adjacent tabs
-        bool            bDrawTabsRTL = IsNativeControlSupported( CTRL_TAB_ITEM, PART_TABS_DRAW_RTL );
-        ImplTabItem *   pFirstTab = NULL;
-        ImplTabItem *   pLastTab = NULL;
+        bool bDrawTabsRTL = rRenderContext.IsNativeControlSupported(CTRL_TAB_ITEM, PART_TABS_DRAW_RTL);
+        ImplTabItem* pFirstTab = NULL;
+        ImplTabItem* pLastTab = NULL;
         size_t idx;
 
         // Event though there is a tab overlap with GTK+, the first tab is not
         // overlapped on the left side.  Other tookits ignore this option.
-        if ( bDrawTabsRTL )
+        if (bDrawTabsRTL)
         {
             pFirstTab = &mpTabCtrlData->maItemList.front();
             pLastTab = &mpTabCtrlData->maItemList.back();
-            idx = mpTabCtrlData->maItemList.size()-1;
+            idx = mpTabCtrlData->maItemList.size() - 1;
         }
         else
         {
@@ -1213,40 +1212,46 @@ void TabControl::ImplPaint( const Rectangle& rRect, bool bLayout )
             idx = 0;
         }
 
-        while ( idx < mpTabCtrlData->maItemList.size() )
+        while (idx < mpTabCtrlData->maItemList.size())
         {
             ImplTabItem* pItem = &mpTabCtrlData->maItemList[idx];
-            if ( pItem != pCurItem )
+            if (pItem != pCurItem)
             {
-                vcl::Region aClipRgn( GetActiveClipRegion() );
-                aClipRgn.Intersect( pItem->maRect );
-                if( !rRect.IsEmpty() )
-                    aClipRgn.Intersect( rRect );
-                if( bLayout || !aClipRgn.IsEmpty() )
-                    ImplDrawItem( pItem, aCurRect, bLayout, (pItem==pFirstTab), (pItem==pLastTab), false );
+                vcl::Region aClipRgn(rRenderContext.GetActiveClipRegion());
+                aClipRgn.Intersect(pItem->maRect);
+                if (!rRect.IsEmpty())
+                    aClipRgn.Intersect(rRect);
+                if (bLayout || !aClipRgn.IsEmpty())
+                {
+                    ImplDrawItem(rRenderContext, pItem, aCurRect, bLayout,
+                                 pItem == pFirstTab, pItem == pLastTab, false);
+                }
             }
 
-            if ( bDrawTabsRTL )
+            if (bDrawTabsRTL)
                 idx--;
             else
                 idx++;
         }
 
-        if ( pCurItem )
+        if (pCurItem)
         {
-            vcl::Region aClipRgn( GetActiveClipRegion() );
-            aClipRgn.Intersect( pCurItem->maRect );
-            if( !rRect.IsEmpty() )
-                aClipRgn.Intersect( rRect );
-            if( bLayout || !aClipRgn.IsEmpty() )
-                ImplDrawItem( pCurItem, aCurRect, bLayout, (pCurItem==pFirstTab), (pCurItem==pLastTab), true );
+            vcl::Region aClipRgn(rRenderContext.GetActiveClipRegion());
+            aClipRgn.Intersect(pCurItem->maRect);
+            if (!rRect.IsEmpty())
+                aClipRgn.Intersect(rRect);
+            if (bLayout || !aClipRgn.IsEmpty())
+            {
+                ImplDrawItem(rRenderContext, pCurItem, aCurRect, bLayout,
+                             pCurItem == pFirstTab, pCurItem == pLastTab, true);
+            }
         }
     }
 
-    if ( !bLayout && HasFocus() )
+    if (!bLayout && HasFocus())
         ImplShowFocus();
 
-    if( ! bLayout )
+    if (!bLayout)
         mbSmallInvalidate = true;
 }
 
@@ -2092,7 +2097,7 @@ void TabControl::FillLayoutData() const
 {
     mpTabCtrlData->maLayoutLineToPageId.clear();
     mpTabCtrlData->maLayoutPageIdToLine.clear();
-    const_cast<TabControl*>(this)->ImplPaint( Rectangle(), true );
+    const_cast<TabControl*>(this)->Invalidate();
 }
 
 Rectangle TabControl::GetTabBounds( sal_uInt16 nPageId ) const
commit a2c830eb63ec5b44824c15e7baa461ba4ab1bbfe
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed May 6 12:51:15 2015 +0900

    Refactor "SpinField" & "SpinButton" - use RenderContext
    
    Change-Id: I589f49179b446ae24037546075070641de5cb927

diff --git a/include/vcl/spin.h b/include/vcl/spin.h
index 98ac18b..e4ce463 100644
--- a/include/vcl/spin.h
+++ b/include/vcl/spin.h
@@ -20,16 +20,14 @@
 #ifndef INCLUDED_VCL_SPIN_H
 #define INCLUDED_VCL_SPIN_H
 
+#include <vcl/window.hxx>
+
 class Rectangle;
-class OutputDevice;
 
-void ImplDrawSpinButton( OutputDevice* pOutDev,
-                         const Rectangle& rUpperRect,
-                         const Rectangle& rLowerRect,
-                         bool bUpperIn, bool bLowerIn,
-                         bool bUpperEnabled = sal_True,
-                         bool bLowerEnabled = sal_True,
-                         bool bHorz = sal_False, bool bMirrorHorz = sal_False );
+void ImplDrawSpinButton(vcl::RenderContext& rRenderContext, vcl::Window* pWindow,
+                        const Rectangle& rUpperRect, const Rectangle& rLowerRect,
+                        bool bUpperIn, bool bLowerIn, bool bUpperEnabled = true, bool bLowerEnabled = true,
+                        bool bHorz = false, bool bMirrorHorz = false);
 
 #endif // INCLUDED_VCL_SPIN_H
 
diff --git a/vcl/source/control/spinbtn.cxx b/vcl/source/control/spinbtn.cxx
index 4689ee8..e218f25 100644
--- a/vcl/source/control/spinbtn.cxx
+++ b/vcl/source/control/spinbtn.cxx
@@ -159,23 +159,23 @@ void SpinButton::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
     aUpperRect += aPos;
     aLowerRect += aPos;
 
-    ImplDrawSpinButton( pDev, aUpperRect, aLowerRect, false, false,
-                        IsEnabled() && ImplIsUpperEnabled(),
-                        IsEnabled() && ImplIsLowerEnabled(), mbHorz, true );
+    ImplDrawSpinButton(*pDev, this, aUpperRect, aLowerRect, false, false,
+                       IsEnabled() && ImplIsUpperEnabled(),
+                       IsEnabled() && ImplIsLowerEnabled(), mbHorz, true);
     pDev->Pop();
 }
 
-void SpinButton::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void SpinButton::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
 {
     HideFocus();
 
     bool bEnable = IsEnabled();
-    ImplDrawSpinButton( this, maUpperRect, maLowerRect, mbUpperIn, mbLowerIn,
-                        bEnable && ImplIsUpperEnabled(),
-                        bEnable && ImplIsLowerEnabled(), mbHorz, true );
+    ImplDrawSpinButton(rRenderContext, this, maUpperRect, maLowerRect, mbUpperIn, mbLowerIn,
+                       bEnable && ImplIsUpperEnabled(),
+                       bEnable && ImplIsLowerEnabled(), mbHorz, true);
 
-    if ( HasFocus() )
-        ShowFocus( maFocusRect );
+    if (HasFocus())
+        ShowFocus(maFocusRect);
 }
 
 void SpinButton::MouseButtonDown( const MouseEvent& rMEvt )
diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx
index c9131b7..28b43f5 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -30,11 +30,10 @@
 
 namespace {
 
-void ImplGetSpinbuttonValue( vcl::Window *pWin, const Rectangle& rUpperRect,
-                            const Rectangle& rLowerRect,
-                            bool bUpperIn, bool bLowerIn,
-                            bool bUpperEnabled, bool bLowerEnabled, bool bHorz,
-                            SpinbuttonValue& rValue )
+void ImplGetSpinbuttonValue(vcl::Window* pWin,
+                            const Rectangle& rUpperRect, const Rectangle& rLowerRect,
+                            bool bUpperIn, bool bLowerIn, bool bUpperEnabled, bool bLowerEnabled,
+                            bool bHorz, SpinbuttonValue& rValue )
 {
     // convert spinbutton data to a SpinbuttonValue structure for native painting
 
@@ -44,26 +43,25 @@ void ImplGetSpinbuttonValue( vcl::Window *pWin, const Rectangle& rUpperRect,
     Point aPointerPos = pWin->GetPointerPosPixel();
 
     ControlState nState = ControlState::ENABLED;
-    if ( bUpperIn )
+    if (bUpperIn)
         nState |= ControlState::PRESSED;
-    if ( !pWin->IsEnabled() || !bUpperEnabled )
+    if (!pWin->IsEnabled() || !bUpperEnabled)
         nState &= ~ControlState::ENABLED;
-    if ( pWin->HasFocus() )
+    if (pWin->HasFocus())
         nState |= ControlState::FOCUSED;
-    if( pWin->IsMouseOver() && rUpperRect.IsInside( aPointerPos ) )
+    if (pWin->IsMouseOver() && rUpperRect.IsInside(aPointerPos))
         nState |= ControlState::ROLLOVER;
     rValue.mnUpperState = nState;
 
     nState = ControlState::ENABLED;
-    if ( bLowerIn )
+    if (bLowerIn)
         nState |= ControlState::PRESSED;
-    if ( !pWin->IsEnabled() || !bLowerEnabled )
+    if (!pWin->IsEnabled() || !bLowerEnabled)
         nState &= ~ControlState::ENABLED;
-    if ( pWin->HasFocus() )
+    if (pWin->HasFocus())
         nState |= ControlState::FOCUSED;
     // for overlapping spins: highlight only one
-    if( pWin->IsMouseOver() && rLowerRect.IsInside( aPointerPos ) &&
-                              !rUpperRect.IsInside( aPointerPos ) )
+    if (pWin->IsMouseOver() && rLowerRect.IsInside(aPointerPos) && !rUpperRect.IsInside(aPointerPos))
         nState |= ControlState::ROLLOVER;
     rValue.mnLowerState = nState;
 
@@ -71,50 +69,51 @@ void ImplGetSpinbuttonValue( vcl::Window *pWin, const Rectangle& rUpperRect,
     rValue.mnLowerPart = bHorz ? PART_BUTTON_RIGHT : PART_BUTTON_DOWN;
 }
 
-bool ImplDrawNativeSpinfield( vcl::Window *pWin, const SpinbuttonValue& rSpinbuttonValue )
+bool ImplDrawNativeSpinfield(vcl::RenderContext& rRenderContext, vcl::Window* pWin, const SpinbuttonValue& rSpinbuttonValue)
 {
     bool bNativeOK = false;
 
-    if( pWin->IsNativeControlSupported(CTRL_SPINBOX, PART_ENTIRE_CONTROL) &&
+    if (rRenderContext.IsNativeControlSupported(CTRL_SPINBOX, PART_ENTIRE_CONTROL) &&
         // there is just no useful native support for spinfields with dropdown
-        !(pWin->GetStyle() & WB_DROPDOWN) )
+        !(pWin->GetStyle() & WB_DROPDOWN))
     {
-        if( pWin->IsNativeControlSupported(CTRL_SPINBOX, rSpinbuttonValue.mnUpperPart) &&
-            pWin->IsNativeControlSupported(CTRL_SPINBOX, rSpinbuttonValue.mnLowerPart) )
+        if (rRenderContext.IsNativeControlSupported(CTRL_SPINBOX, rSpinbuttonValue.mnUpperPart) &&
+            rRenderContext.IsNativeControlSupported(CTRL_SPINBOX, rSpinbuttonValue.mnLowerPart))
         {
             // only paint the embedded spin buttons, all buttons are painted at once
-            bNativeOK = pWin->DrawNativeControl( CTRL_SPINBOX, PART_ALL_BUTTONS, Rectangle(), ControlState::ENABLED,
-                        rSpinbuttonValue, OUString() );
+            bNativeOK = rRenderContext.DrawNativeControl(CTRL_SPINBOX, PART_ALL_BUTTONS, Rectangle(),
+                                                         ControlState::ENABLED, rSpinbuttonValue, OUString());
         }
         else
         {
             // paint the spinbox as a whole, use borderwindow to have proper clipping
-            vcl::Window *pBorder = pWin->GetWindow( WINDOW_BORDER );
+            vcl::Window* pBorder = pWin->GetWindow(WINDOW_BORDER);
 
             // to not overwrite everything, set the button region as clipregion to the border window
             Rectangle aClipRect( rSpinbuttonValue.maLowerRect );
             aClipRect.Union( rSpinbuttonValue.maUpperRect );
 
             // convert from screen space to borderwin space
-            aClipRect.SetPos( pBorder->ScreenToOutputPixel(pWin->OutputToScreenPixel(aClipRect.TopLeft())) );
+            aClipRect.SetPos(pBorder->ScreenToOutputPixel(pWin->OutputToScreenPixel(aClipRect.TopLeft())));
 
-            vcl::Region oldRgn( pBorder->GetClipRegion() );
+            vcl::Region oldRgn(pBorder->GetClipRegion());
             pBorder->SetClipRegion( vcl::Region( aClipRect ) );
 
             Point aPt;
-            Size aSize( pBorder->GetOutputSizePixel() );    // the size of the border window, i.e., the whole control
+            Size aSize(pBorder->GetOutputSizePixel());    // the size of the border window, i.e., the whole control
             Rectangle aBound, aContent;
-            Rectangle aNatRgn( aPt, aSize );
-            if( ! ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize &&
-                pBorder->GetNativeControlRegion( CTRL_SPINBOX, PART_ENTIRE_CONTROL,
-                                                 aNatRgn, ControlState::NONE, rSpinbuttonValue, OUString(), aBound, aContent) )
+            Rectangle aNatRgn(aPt, aSize);
+            if (!ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize &&
+                pBorder->GetNativeControlRegion(CTRL_SPINBOX, PART_ENTIRE_CONTROL,
+                                                aNatRgn, ControlState::NONE, rSpinbuttonValue,
+                                                OUString(), aBound, aContent))
             {
                 aSize = aContent.GetSize();
             }
 
-            Rectangle aRgn( aPt, aSize );
-            bNativeOK = pBorder->DrawNativeControl( CTRL_SPINBOX, PART_ENTIRE_CONTROL, aRgn, ControlState::ENABLED,
-                        rSpinbuttonValue, OUString() );
+            Rectangle aRgn(aPt, aSize);
+            bNativeOK = pBorder->DrawNativeControl(CTRL_SPINBOX, PART_ENTIRE_CONTROL, aRgn,
+                                                   ControlState::ENABLED, rSpinbuttonValue, OUString());
 
             pBorder->SetClipRegion(vcl::Region(oldRgn));
         }
@@ -122,35 +121,34 @@ bool ImplDrawNativeSpinfield( vcl::Window *pWin, const SpinbuttonValue& rSpinbut
     return bNativeOK;
 }
 
-bool ImplDrawNativeSpinbuttons( vcl::Window *pWin, const SpinbuttonValue& rSpinbuttonValue )
+bool ImplDrawNativeSpinbuttons(vcl::RenderContext& rRenderContext, const SpinbuttonValue& rSpinbuttonValue)
 {
     bool bNativeOK = false;
 
-    if( pWin->IsNativeControlSupported(CTRL_SPINBUTTONS, PART_ENTIRE_CONTROL) )
+    if (rRenderContext.IsNativeControlSupported(CTRL_SPINBUTTONS, PART_ENTIRE_CONTROL))
     {
         // only paint the standalone spin buttons, all buttons are painted at once
-        bNativeOK = pWin->DrawNativeControl( CTRL_SPINBUTTONS, PART_ALL_BUTTONS, Rectangle(), ControlState::ENABLED,
-                    rSpinbuttonValue, OUString() );
+        bNativeOK = rRenderContext.DrawNativeControl(CTRL_SPINBUTTONS, PART_ALL_BUTTONS, Rectangle(),
+                                                     ControlState::ENABLED, rSpinbuttonValue, OUString());
     }
     return bNativeOK;
 }
 
 }
 
-void ImplDrawSpinButton( OutputDevice* pOutDev,
-                         const Rectangle& rUpperRect,
-                         const Rectangle& rLowerRect,
-                         bool bUpperIn, bool bLowerIn,
-                         bool bUpperEnabled, bool bLowerEnabled, bool bHorz, bool bMirrorHorz )
+void ImplDrawSpinButton(vcl::RenderContext& rRenderContext, vcl::Window* pWindow,
+                        const Rectangle& rUpperRect, const Rectangle& rLowerRect,
+                        bool bUpperIn, bool bLowerIn, bool bUpperEnabled, bool bLowerEnabled,
+                        bool bHorz, bool bMirrorHorz)
 {
-    DecorationView aDecoView( pOutDev );
+    DecorationView aDecoView(&rRenderContext);
 
     sal_uInt16 nStyle = BUTTON_DRAW_NOLEFTLIGHTBORDER;
     sal_uInt16 nSymStyle = 0;
 
     SymbolType eType1, eType2;
 
-    const StyleSettings& rStyleSettings = pOutDev->GetSettings().GetStyleSettings();
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
     if ( rStyleSettings.GetOptions() & STYLE_OPTION_SPINARROW )
     {
         // arrows are only use in OS/2 look
@@ -187,13 +185,11 @@ void ImplDrawSpinButton( OutputDevice* pOutDev,
     bool bNativeOK = false;
     Rectangle aUpRect;
 
-    if( pOutDev->GetOutDevType() == OUTDEV_WINDOW )
+    if (pWindow)
     {
-        vcl::Window *pWin = static_cast<vcl::Window*>(pOutDev);
-
         // are we drawing standalone spin buttons or members of a spinfield ?
         ControlType aControl = CTRL_SPINBUTTONS;
-        switch( pWin->GetType() )
+        switch (pWindow->GetType())
         {
             case WINDOW_EDIT:
             case WINDOW_MULTILINEEDIT:
@@ -213,25 +209,25 @@ void ImplDrawSpinButton( OutputDevice* pOutDev,
         }
 
         SpinbuttonValue aValue;
-        ImplGetSpinbuttonValue( pWin, rUpperRect, rLowerRect,
-                                bUpperIn, bLowerIn, bUpperEnabled, bLowerEnabled,
-                                bHorz, aValue );
+        ImplGetSpinbuttonValue(pWindow, rUpperRect, rLowerRect,
+                               bUpperIn, bLowerIn, bUpperEnabled, bLowerEnabled,
+                               bHorz, aValue);
 
         if( aControl == CTRL_SPINBOX )
-            bNativeOK = ImplDrawNativeSpinfield( pWin, aValue );
+            bNativeOK = ImplDrawNativeSpinfield(rRenderContext, pWindow, aValue);
         else if( aControl == CTRL_SPINBUTTONS )
-            bNativeOK = ImplDrawNativeSpinbuttons( pWin, aValue );
+            bNativeOK = ImplDrawNativeSpinbuttons(rRenderContext, aValue);
     }
 
-    if( !bNativeOK )
-        aUpRect = aDecoView.DrawButton( rUpperRect, nTempStyle );
+    if (!bNativeOK)
+        aUpRect = aDecoView.DrawButton(rUpperRect, nTempStyle);
 
     // draw lower/right Button
-    if ( bLowerIn )
+    if (bLowerIn)
         nStyle |= BUTTON_DRAW_PRESSED;
     Rectangle aLowRect;
-    if( !bNativeOK )
-        aLowRect = aDecoView.DrawButton( rLowerRect, nStyle );
+    if(!bNativeOK)
+        aLowRect = aDecoView.DrawButton(rLowerRect, nStyle);
 
      // make use of additional default edge
     aUpRect.Left()--;
@@ -244,7 +240,7 @@ void ImplDrawSpinButton( OutputDevice* pOutDev,
     aLowRect.Bottom()++;
 
     // draw into the edge, so that something is visible if the rectangle is too small
-    if ( aUpRect.GetHeight() < 4 )
+    if (aUpRect.GetHeight() < 4)
     {
         aUpRect.Right()++;
         aUpRect.Bottom()++;
@@ -255,33 +251,33 @@ void ImplDrawSpinButton( OutputDevice* pOutDev,
     // calculate Symbol size
     long nTempSize1 = aUpRect.GetWidth();
     long nTempSize2 = aLowRect.GetWidth();
-    if ( std::abs( nTempSize1-nTempSize2 ) == 1 )
+    if (std::abs( nTempSize1-nTempSize2 ) == 1)
     {
-        if ( nTempSize1 > nTempSize2 )
+        if (nTempSize1 > nTempSize2)
             aUpRect.Left()++;
         else
             aLowRect.Left()++;
     }
     nTempSize1 = aUpRect.GetHeight();
     nTempSize2 = aLowRect.GetHeight();
-    if ( std::abs( nTempSize1-nTempSize2 ) == 1 )
+    if (std::abs(nTempSize1 - nTempSize2) == 1)
     {
-        if ( nTempSize1 > nTempSize2 )
+        if (nTempSize1 > nTempSize2)
             aUpRect.Top()++;
         else
             aLowRect.Top()++;
     }
 
     nTempStyle = nSymStyle;
-    if ( !bUpperEnabled )
+    if (!bUpperEnabled)
         nTempStyle |= SYMBOL_DRAW_DISABLE;
-    if( !bNativeOK )
-        aDecoView.DrawSymbol( aUpRect, eType1, rStyleSettings.GetButtonTextColor(), nTempStyle );
+    if (!bNativeOK)
+        aDecoView.DrawSymbol(aUpRect, eType1, rStyleSettings.GetButtonTextColor(), nTempStyle);
 
-    if ( !bLowerEnabled )
+    if (!bLowerEnabled)
         nSymStyle |= SYMBOL_DRAW_DISABLE;
-    if( !bNativeOK )
-        aDecoView.DrawSymbol( aLowRect, eType2, rStyleSettings.GetButtonTextColor(), nSymStyle );
+    if (!bNativeOK)
+        aDecoView.DrawSymbol(aLowRect, eType2, rStyleSettings.GetButtonTextColor(), nSymStyle);
 }
 
 void SpinField::ImplInitSpinFieldData()
@@ -606,28 +602,28 @@ void SpinField::FillLayoutData() const
 
 void SpinField::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect )
 {
-    if ( mbSpin )
+    if (mbSpin)
     {
-        bool    bEnable = IsEnabled();
-        ImplDrawSpinButton( this, maUpperRect, maLowerRect,
-                            mbUpperIn, mbLowerIn, bEnable, bEnable );
+        bool bEnable = IsEnabled();
+        ImplDrawSpinButton(rRenderContext, this, maUpperRect, maLowerRect,
+                           mbUpperIn, mbLowerIn, bEnable, bEnable);
     }
 
-    if ( GetStyle() & WB_DROPDOWN )
+    if (GetStyle() & WB_DROPDOWN)
     {
-        DecorationView aView( this );
+        DecorationView aView(&rRenderContext);
 
         sal_uInt16 nStyle = BUTTON_DRAW_NOLIGHTBORDER;
-        if ( mbInDropDown )
+        if (mbInDropDown)
             nStyle |= BUTTON_DRAW_PRESSED;
-        Rectangle aInnerRect = aView.DrawButton( maDropDownRect, nStyle );
+        Rectangle aInnerRect = aView.DrawButton(maDropDownRect, nStyle);
 
         SymbolType eSymbol = SymbolType::SPIN_DOWN;
-        if ( GetSettings().GetStyleSettings().GetOptions() & STYLE_OPTION_SPINUPDOWN )
+        if (rRenderContext.GetSettings().GetStyleSettings().GetOptions() & STYLE_OPTION_SPINUPDOWN)
             eSymbol = SymbolType::SPIN_UPDOWN;
 
         nStyle = IsEnabled() ? 0 : SYMBOL_DRAW_DISABLE;
-        aView.DrawSymbol( aInnerRect, eSymbol, GetSettings().GetStyleSettings().GetButtonTextColor(), nStyle );
+        aView.DrawSymbol(aInnerRect, eSymbol, rRenderContext.GetSettings().GetStyleSettings().GetButtonTextColor(), nStyle);
     }
 
     Edit::Paint(rRenderContext, rRect);
@@ -1040,7 +1036,7 @@ void SpinField::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
 
         if ( GetStyle() & WB_SPIN )
         {
-            ImplDrawSpinButton( pDev, aUp, aDown, false, false, true, true );
+            ImplDrawSpinButton(*pDev, this, aUp, aDown, false, false, true, true );
         }
 
         pDev->Pop();
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 5d4d837..1e946e3 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -2852,7 +2852,7 @@ void ToolBox::ImplDrawSpin(vcl::RenderContext& rRenderContext, bool bUpperIn, bo
         bTmpLower = false;
     }
 
-    ImplDrawSpinButton(&rRenderContext, maUpperRect, maLowerRect,
+    ImplDrawSpinButton(rRenderContext, this, maUpperRect, maLowerRect,
                        bUpperIn, bLowerIn, bTmpUpper, bTmpLower, !mbHorz);
 }
 
commit 417c0dafd4348ee6024ec18fbffa35b4940cb614
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed May 6 12:14:52 2015 +0900

    missing ToolBox include changes
    
    Change-Id: I13252ac17fd4fca96992bf48c8dbdebd01c479dc

diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index c475aa0..2a4e723 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -199,6 +199,8 @@ public:
     using Window::ImplInit;
 private:
     SAL_DLLPRIVATE void InvalidateItem(sal_uInt16 nPosition, sal_uInt16 nHighlight = 0, bool bPaint = false, bool bLayout = false);
+    SAL_DLLPRIVATE void InvalidateSpin(bool bUpperIn, bool bLowerIn);
+    SAL_DLLPRIVATE void InvalidateMenuButton(bool bHighlight);
 
     SAL_DLLPRIVATE void            ImplInit( vcl::Window* pParent, WinBits nStyle );
     using DockingWindow::ImplInitSettings;
@@ -208,8 +210,8 @@ private:
     SAL_DLLPRIVATE bool            ImplCalcItem();
     SAL_DLLPRIVATE sal_uInt16          ImplCalcBreaks( long nWidth, long* pMaxLineWidth, bool bCalcHorz );
     SAL_DLLPRIVATE void            ImplFormat( bool bResize = false );
-    SAL_DLLPRIVATE void            ImplDrawSpin( bool bUpperIn, bool bLowerIn );
-    SAL_DLLPRIVATE void            ImplDrawSeparator(sal_uInt16 nPos, const Rectangle& rRect);
+    SAL_DLLPRIVATE void            ImplDrawSpin(vcl::RenderContext& rRenderContext, bool bUpperIn, bool bLowerIn);
+    SAL_DLLPRIVATE void            ImplDrawSeparator(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, const Rectangle& rRect);
     SAL_DLLPRIVATE void            ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, sal_uInt16 nHighlight = 0, bool bPaint = false, bool bLayout = false );
     using Window::ImplInvalidate;
     SAL_DLLPRIVATE void            ImplInvalidate( bool bNewCalc = false, bool bFullPaint = false );
@@ -235,7 +237,7 @@ private:
     SAL_DLLPRIVATE const OUString& ImplGetHelpText( sal_uInt16 nItemId ) const;
     SAL_DLLPRIVATE Size            ImplGetOptimalFloatingSize();
     SAL_DLLPRIVATE bool            ImplHasExternalMenubutton();
-    SAL_DLLPRIVATE void            ImplDrawFloatwinBorder( ImplToolItem* pItem );
+    SAL_DLLPRIVATE void            ImplDrawFloatwinBorder(vcl::RenderContext& rRenderContext, ImplToolItem* pItem );
 
     DECL_DLLPRIVATE_LINK(          ImplCallExecuteCustomMenu, void* );
     DECL_DLLPRIVATE_LINK(          ImplUpdateHdl, void* );
@@ -276,7 +278,7 @@ public:
     static SAL_DLLPRIVATE void ImplLineSizing( ToolBox* pThis, const Point& rPos, Rectangle& rRect, sal_uInt16 nLineMode );
     static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( ToolBox* pBox, const Point& rPos );
     static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( const ImplToolItem* pItem, const std::vector< ImplToolItem >& rList );
-    SAL_DLLPRIVATE void ImplDrawMenubutton(vcl::RenderContext& rRenderContext, bool bHighlight);
+    SAL_DLLPRIVATE void ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight);
     SAL_DLLPRIVATE void ImplDrawButton(vcl::RenderContext& rRenderContext, const Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow);
     static SAL_DLLPRIVATE sal_uInt16 ImplCountLineBreaks( const ToolBox *pThis );
     SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData; }
commit 943f13afe0b9edf5f63f7aec3f096a2a36408d7d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed May 6 11:57:31 2015 +0900

    Refactor "Slider" - use RenderContext & Invalidate
    
    Change-Id: I3c733ac46b89b0a6b413eadf2796b80ec033c2c9

diff --git a/include/vcl/slider.hxx b/include/vcl/slider.hxx
index a290030..51fa7b6 100644
--- a/include/vcl/slider.hxx
+++ b/include/vcl/slider.hxx
@@ -45,8 +45,9 @@ private:
     long            mnLineSize;
     long            mnPageSize;
     long            mnDelta;
-    sal_uInt16          mnDragDraw;
-    sal_uInt16          mnStateFlags;
+    sal_uInt16      mnDragDraw;
+    sal_uInt16      mnDrawFlags;
+    sal_uInt16      mnStateFlags;
     ScrollType      meScrollType;
     bool            mbCalcSize;
     bool            mbFullDrag;
@@ -61,7 +62,7 @@ private:
     SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos );
     SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos );
     SAL_DLLPRIVATE void ImplCalc( bool bUpdate = true );
-    SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags );
+    SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags);
     SAL_DLLPRIVATE bool ImplIsPageUp( const Point& rPos );
     SAL_DLLPRIVATE bool ImplIsPageDown( const Point& rPos );
     SAL_DLLPRIVATE long ImplSlide( long nNewPos, bool bCallEndSlide );
@@ -77,7 +78,7 @@ public:
     virtual void    MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     virtual void    Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     virtual void    KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
-    virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
+    virtual void    Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
     virtual void    Resize() SAL_OVERRIDE;
     virtual void    RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
     virtual void    StateChanged( StateChangedType nType ) SAL_OVERRIDE;
diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx
index e85ce80..f369344 100644
--- a/vcl/source/control/slider.cxx
+++ b/vcl/source/control/slider.cxx
@@ -62,6 +62,7 @@ void Slider::ImplInit( vcl::Window* pParent, WinBits nStyle )
     mnPageSize          = 1;
     mnDelta             = 0;
     mnDragDraw          = 0;
+    mnDrawFlags         = SLIDER_DRAW_ALL;
     mnStateFlags        = 0;
     meScrollType        = SCROLL_DONTKNOW;
     mbCalcSize          = true;
@@ -189,6 +190,7 @@ void Slider::ImplUpdateRects( bool bUpdate )
     {
         if ( aOldThumbRect != maThumbRect )
         {
+            mnDrawFlags = SLIDER_DRAW_ALL;
             if( bInvalidateAll )
                 Invalidate();
             else
@@ -296,145 +298,146 @@ void Slider::ImplCalc( bool bUpdate )
 
     if ( bUpdate && bInvalidateAll )
     {
+        mnDrawFlags = SLIDER_DRAW_ALL;
         Invalidate();
         bUpdate = false;
     }
     ImplUpdateRects( bUpdate );
 }
 
-void Slider::ImplDraw( sal_uInt16 nDrawFlags )
+void Slider::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags)
 {
-    DecorationView          aDecoView( this );
-    sal_uInt16                  nStyle;
-    const StyleSettings&    rStyleSettings = GetSettings().GetStyleSettings();
-    bool                    bEnabled = IsEnabled();
+    DecorationView aDecoView(&rRenderContext);
+    sal_uInt16 nStyle;
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+    bool bEnabled = IsEnabled();
 
     // do missing calculations
-    if ( mbCalcSize )
-        ImplCalc( false );
+    if (mbCalcSize)
+        ImplCalc(false);
 
     ControlPart nPart = (GetStyle() & WB_HORZ) ? PART_TRACK_HORZ_AREA : PART_TRACK_VERT_AREA;
-    ControlState   nState = ( IsEnabled() ? ControlState::ENABLED : ControlState::NONE ) | ( HasFocus() ? ControlState::FOCUSED : ControlState::NONE );
-    SliderValue    sldValue;
+    ControlState nState = (IsEnabled() ? ControlState::ENABLED : ControlState::NONE);
+    nState |= (HasFocus() ? ControlState::FOCUSED : ControlState::NONE);
+    SliderValue sldValue;
 
-    sldValue.mnMin       = mnMinRange;
-    sldValue.mnMax       = mnMaxRange;
-    sldValue.mnCur       = mnThumbPos;
+    sldValue.mnMin = mnMinRange;
+    sldValue.mnMax = mnMaxRange;
+    sldValue.mnCur = mnThumbPos;
     sldValue.maThumbRect = maThumbRect;
 
-    if( IsMouseOver() )
+    if (IsMouseOver())
     {
-        if( maThumbRect.IsInside( GetPointerPosPixel() ) )
+        if (maThumbRect.IsInside(GetPointerPosPixel()))
             sldValue.mnThumbState |= ControlState::ROLLOVER;
     }
 
-    const Rectangle aCtrlRegion( Point(0,0), GetOutputSizePixel() );
-    bool bNativeOK = DrawNativeControl( CTRL_SLIDER, nPart,
-                                        aCtrlRegion, nState, sldValue, OUString() );
-    if( bNativeOK )
+    const Rectangle aCtrlRegion(Point(0,0), rRenderContext.GetOutputSizePixel());
+    bool bNativeOK = rRenderContext.DrawNativeControl(CTRL_SLIDER, nPart, aCtrlRegion, nState, sldValue, OUString());
+    if (bNativeOK)
         return;
 
-    if ( (nDrawFlags & SLIDER_DRAW_CHANNEL1) && !maChannel1Rect.IsEmpty() )
+    if ((nDrawFlags & SLIDER_DRAW_CHANNEL1) && !maChannel1Rect.IsEmpty())
     {
         long        nRectSize;
         Rectangle   aRect = maChannel1Rect;
-        SetLineColor( rStyleSettings.GetShadowColor() );
-        if ( GetStyle() & WB_HORZ )
+        rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
+        if (GetStyle() & WB_HORZ)
         {
-            DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom()-1 ) );
-            DrawLine( aRect.TopLeft(), aRect.TopRight() );
+            rRenderContext.DrawLine(aRect.TopLeft(), Point(aRect.Left(), aRect.Bottom() - 1));
+            rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight());
         }
         else
         {
-            DrawLine( aRect.TopLeft(), Point( aRect.Right()-1, aRect.Top() ) );
-            DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
+            rRenderContext.DrawLine(aRect.TopLeft(), Point(aRect.Right() - 1, aRect.Top()));
+            rRenderContext.DrawLine(aRect.TopLeft(), aRect.BottomLeft());
         }
-        SetLineColor( rStyleSettings.GetLightColor() );
-        if ( GetStyle() & WB_HORZ )
+        rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
+        if (GetStyle() & WB_HORZ)
         {
-            DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
+            rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
             nRectSize = aRect.GetWidth();
         }
         else
         {
-            DrawLine( aRect.TopRight(), aRect.BottomRight() );
+            rRenderContext.DrawLine(aRect.TopRight(), aRect.BottomRight());
             nRectSize = aRect.GetHeight();
         }
 
-        if ( nRectSize > 1 )
+        if (nRectSize > 1)
         {
             aRect.Left()++;
             aRect.Top()++;
-            if ( GetStyle() & WB_HORZ )
+            if (GetStyle() & WB_HORZ)
                 aRect.Bottom()--;
             else
                 aRect.Right()--;
-            SetLineColor();
-            if ( mnStateFlags & SLIDER_STATE_CHANNEL1_DOWN )
-                SetFillColor( rStyleSettings.GetShadowColor() );
+            rRenderContext.SetLineColor();
+            if (mnStateFlags & SLIDER_STATE_CHANNEL1_DOWN)
+                rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
             else
-                SetFillColor( rStyleSettings.GetCheckedColor() );
-            DrawRect( aRect );
+                rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
+            rRenderContext.DrawRect(aRect);
         }
     }
 
-    if ( (nDrawFlags & SLIDER_DRAW_CHANNEL2) && !maChannel2Rect.IsEmpty() )
+    if ((nDrawFlags & SLIDER_DRAW_CHANNEL2) && !maChannel2Rect.IsEmpty())
     {
-        long        nRectSize;
-        Rectangle   aRect = maChannel2Rect;
-        SetLineColor( rStyleSettings.GetLightColor() );
-        if ( GetStyle() & WB_HORZ )
+        long nRectSize;
+        Rectangle aRect = maChannel2Rect;
+        rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
+        if (GetStyle() & WB_HORZ)
         {
-            DrawLine( aRect.TopRight(), aRect.BottomRight() );
-            DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
+            rRenderContext.DrawLine(aRect.TopRight(), aRect.BottomRight());
+            rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
             nRectSize = aRect.GetWidth();
         }
         else
         {
-            DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
-            DrawLine( aRect.TopRight(), aRect.BottomRight() );
+            rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
+            rRenderContext.DrawLine(aRect.TopRight(), aRect.BottomRight());
             nRectSize = aRect.GetHeight();
         }
 
-        if ( nRectSize > 1 )
+        if (nRectSize > 1)
         {
-            SetLineColor( rStyleSettings.GetShadowColor() );
-            if ( GetStyle() & WB_HORZ )
-                DrawLine( aRect.TopLeft(), Point( aRect.Right()-1, aRect.Top() ) );
+            rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
+            if (GetStyle() & WB_HORZ)
+                rRenderContext.DrawLine(aRect.TopLeft(), Point(aRect.Right() - 1, aRect.Top()));
             else
-                DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom()-1 ) );
+                rRenderContext.DrawLine(aRect.TopLeft(), Point(aRect.Left(), aRect.Bottom() - 1));
 
             aRect.Right()--;
             aRect.Bottom()--;
-            if ( GetStyle() & WB_HORZ )
+            if (GetStyle() & WB_HORZ)
                 aRect.Top()++;
             else
                 aRect.Left()++;
-            SetLineColor();
-            if ( mnStateFlags & SLIDER_STATE_CHANNEL2_DOWN )
-                SetFillColor( rStyleSettings.GetShadowColor() );
+            rRenderContext.SetLineColor();
+            if (mnStateFlags & SLIDER_STATE_CHANNEL2_DOWN)
+                rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
             else
-                SetFillColor( rStyleSettings.GetCheckedColor() );
-            DrawRect( aRect );
+                rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
+            rRenderContext.DrawRect(aRect);
         }
     }
 
-    if ( nDrawFlags & SLIDER_DRAW_THUMB )
+    if (nDrawFlags & SLIDER_DRAW_THUMB)
     {
-        if ( !maThumbRect.IsEmpty() )
+        if (!maThumbRect.IsEmpty())
         {
-            if ( bEnabled )
+            if (bEnabled)
             {
                 nStyle = 0;
-                if ( mnStateFlags & SLIDER_STATE_THUMB_DOWN )
+                if (mnStateFlags & SLIDER_STATE_THUMB_DOWN)
                     nStyle |= BUTTON_DRAW_PRESSED;
-                aDecoView.DrawButton( maThumbRect, nStyle );
+                aDecoView.DrawButton(maThumbRect, nStyle);
             }
             else
             {
-                SetLineColor( rStyleSettings.GetShadowColor() );
-                SetFillColor( rStyleSettings.GetCheckedColor() );
-                DrawRect( maThumbRect );
+                rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
+                rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
+                rRenderContext.DrawRect(maThumbRect);
             }
         }
     }
@@ -574,12 +577,16 @@ void Slider::ImplDoMouseAction( const Point& rMousePos, bool bCallAction )
             if ( mnDragDraw & SLIDER_DRAW_CHANNEL )
             {
                 Update();
-                ImplDraw( mnDragDraw );
+                mnDrawFlags = mnDragDraw;
+                Invalidate();
             }
         }
     }
     else if ( nOldStateFlags != mnStateFlags )
-        ImplDraw( mnDragDraw );
+    {
+        mnDrawFlags = mnDragDraw;
+        Invalidate();
+    }
 }
 
 long Slider::ImplDoSlide( long nNewPos )
@@ -675,8 +682,10 @@ void Slider::MouseButtonUp( const MouseEvent& )
         mnStateFlags &= ~( SLIDER_STATE_CHANNEL1_DOWN | SLIDER_STATE_CHANNEL2_DOWN | SLIDER_STATE_THUMB_DOWN );
 
         if ( nOldStateFlags != mnStateFlags )
-            ImplDraw( mnDragDraw );
-
+        {
+            mnDrawFlags = mnDragDraw;
+            Invalidate();
+        }
         mnDragDraw = 0;
         ImplDoAction( true );
         meScrollType = SCROLL_DONTKNOW;
@@ -692,7 +701,10 @@ void Slider::Tracking( const TrackingEvent& rTEvt )
         mnStateFlags &= ~(SLIDER_STATE_CHANNEL1_DOWN | SLIDER_STATE_CHANNEL2_DOWN |
                           SLIDER_STATE_THUMB_DOWN);
         if ( nOldStateFlags != mnStateFlags )
-            ImplDraw( mnDragDraw );
+        {
+            mnDrawFlags = mnDragDraw;
+            Invalidate();
+        }
         mnDragDraw = 0;
 
         // on cancel, reset the previous Thumb position
@@ -808,9 +820,13 @@ void Slider::KeyInput( const KeyEvent& rKEvt )
         Control::KeyInput( rKEvt );
 }
 
-void Slider::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void Slider::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
 {
-    ImplDraw( SLIDER_DRAW_ALL );
+    if (mnDrawFlags)
+    {
+        ImplDraw(rRenderContext, mnDrawFlags);
+        mnDrawFlags = 0;
+    }
 }
 
 void Slider::Resize()
@@ -819,6 +835,7 @@ void Slider::Resize()
     mbCalcSize = true;
     if ( IsReallyVisible() )
         ImplCalc( false );
+    mnDrawFlags = SLIDER_DRAW_ALL;
     Invalidate();
 }
 
@@ -843,13 +860,17 @@ void Slider::StateChanged( StateChangedType nType )
         if ( IsReallyVisible() && IsUpdateMode() )
         {
             ImplCalc( false );
+            mnDrawFlags = SLIDER_DRAW_ALL;
             Invalidate();
         }
     }
     else if ( nType == StateChangedType::ENABLE )
     {
         if ( IsReallyVisible() && IsUpdateMode() )
+        {
+            mnDrawFlags = SLIDER_DRAW_ALL;
             Invalidate();
+        }
     }
     else if ( nType == StateChangedType::STYLE )
     {
@@ -860,6 +881,7 @@ void Slider::StateChanged( StateChangedType nType )
             {
                 mbCalcSize = true;
                 ImplCalc( false );
+                mnDrawFlags = SLIDER_DRAW_ALL;
                 Invalidate();
             }
         }
@@ -867,6 +889,7 @@ void Slider::StateChanged( StateChangedType nType )
     else if ( nType == StateChangedType::CONTROLBACKGROUND )
     {
         ImplInitSettings();
+        mnDrawFlags = SLIDER_DRAW_ALL;
         Invalidate();
     }
 }
@@ -879,6 +902,7 @@ void Slider::DataChanged( const DataChangedEvent& rDCEvt )
          (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
     {
         ImplInitSettings();
+        mnDrawFlags = SLIDER_DRAW_ALL;
         Invalidate();
     }
 }


More information about the Libreoffice-commits mailing list