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

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Wed May 6 20:18:31 PDT 2015


 include/vcl/scrbar.hxx         |    4 
 include/vcl/status.hxx         |   10 -
 vcl/source/control/imgctrl.cxx |   28 ++--
 vcl/source/control/prgsbar.cxx |   32 ++---
 vcl/source/control/scrbar.cxx  |  255 ++++++++++++++++++++---------------------
 vcl/source/window/status.cxx   |  118 +++++++++---------
 6 files changed, 223 insertions(+), 224 deletions(-)

New commits:
commit 9daf1821167332a4a2fb2120e09592e3cb1607b6
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu May 7 12:17:25 2015 +0900

    refactor ImageControl to use RenderContext
    
    Change-Id: I1290757fa5d6b61b68bf6c985b657253dca83586

diff --git a/vcl/source/control/imgctrl.cxx b/vcl/source/control/imgctrl.cxx
index baaaa20..9050a9b 100644
--- a/vcl/source/control/imgctrl.cxx
+++ b/vcl/source/control/imgctrl.cxx
@@ -23,7 +23,7 @@
 
 #include <com/sun/star/awt/ImageScaleMode.hpp>
 
-namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
+namespace ImageScaleMode = css::awt::ImageScaleMode;
 
 ImageControl::ImageControl( vcl::Window* pParent, WinBits nStyle )
     :FixedImage( pParent, nStyle )
@@ -67,7 +67,7 @@ namespace
     }
 }
 
-void ImageControl::ImplDraw( OutputDevice& rDev, sal_uLong nDrawFlags, const Point& rPos, const Size& rSize ) const
+void ImageControl::ImplDraw(OutputDevice& rDev, sal_uLong nDrawFlags, const Point& rPos, const Size& rSize) const
 {
     sal_uInt16 nStyle = 0;
     if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) )
@@ -135,25 +135,25 @@ void ImageControl::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*
 {
     ImplDraw(rRenderContext, 0, Point(), GetOutputSizePixel());
 
-    if( HasFocus() )
+    if (HasFocus())
     {
-        vcl::Window *pWin = GetWindow( WINDOW_BORDER );
+        vcl::Window* pBorderWindow = GetWindow(WINDOW_BORDER);
 
         bool bFlat = (GetBorderStyle() == WindowBorderStyle::MONO);
-        Rectangle aRect( Point(0,0), pWin->GetOutputSizePixel() );
-        Color oldLineCol = pWin->GetLineColor();
-        Color oldFillCol = pWin->GetFillColor();
-        pWin->SetFillColor();
-        pWin->SetLineColor( bFlat ? COL_WHITE : COL_BLACK );
-        pWin->DrawRect( aRect );
+        Rectangle aRect(Point(0,0), pBorderWindow->GetOutputSizePixel());
+        Color oldLineCol = pBorderWindow->GetLineColor();
+        Color oldFillCol = pBorderWindow->GetFillColor();
+        pBorderWindow->SetFillColor();
+        pBorderWindow->SetLineColor(bFlat ? COL_WHITE : COL_BLACK);
+        pBorderWindow->DrawRect(aRect);
         ++aRect.Left();
         --aRect.Right();
         ++aRect.Top();
         --aRect.Bottom();
-        pWin->SetLineColor( bFlat ? COL_BLACK : COL_WHITE );
-        pWin->DrawRect( aRect );
-        pWin->SetLineColor( oldLineCol );
-        pWin->SetFillColor( oldFillCol );
+        pBorderWindow->SetLineColor(bFlat ? COL_BLACK : COL_WHITE);
+        pBorderWindow->DrawRect(aRect);
+        pBorderWindow->SetLineColor(oldLineCol);
+        pBorderWindow->SetFillColor(oldFillCol);
     }
 }
 
commit 7dec505a5a78603c591566dad6f80f52ca0ebe9d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu May 7 12:12:34 2015 +0900

    refactor ScrollBar to use RenderContext
    
    Change-Id: I8707fa934d729d96e019ad5d0688299bf88954c4

diff --git a/include/vcl/scrbar.hxx b/include/vcl/scrbar.hxx
index 3a16f9e..20eeceb 100644
--- a/include/vcl/scrbar.hxx
+++ b/include/vcl/scrbar.hxx
@@ -76,13 +76,13 @@ 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, OutputDevice* pOutDev  );
+    SAL_DLLPRIVATE void         ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags);
     using Window::ImplScroll;
     SAL_DLLPRIVATE long         ImplScroll( long nNewPos, bool bCallEndScroll );
     SAL_DLLPRIVATE long         ImplDoAction( bool bCallEndScroll );
     SAL_DLLPRIVATE void         ImplDoMouseAction( const Point& rPos, bool bCallAction = true );
     SAL_DLLPRIVATE void         ImplInvert();
-    SAL_DLLPRIVATE bool     ImplDrawNative( sal_uInt16 nDrawFlags );
+    SAL_DLLPRIVATE bool         ImplDrawNative(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags);
     SAL_DLLPRIVATE void         ImplDragThumb( const Point& rMousePos );
     SAL_DLLPRIVATE Size         getCurrentCalcSize() const;
     DECL_DLLPRIVATE_LINK(       ImplTimerHdl, Timer* );
diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx
index 0d71783..f72407c 100644
--- a/vcl/source/control/scrbar.cxx
+++ b/vcl/source/control/scrbar.cxx
@@ -231,7 +231,7 @@ void ScrollBar::ImplUpdateRects( bool bUpdate )
             nDraw |= SCRBAR_DRAW_PAGE2;
         if ( aOldThumbRect != maThumbRect )
             nDraw |= SCRBAR_DRAW_THUMB;
-        ImplDraw( nDraw, this );
+        Invalidate();
     }
 }
 
@@ -448,26 +448,27 @@ void ScrollBar::Draw( OutputDevice* pDev, const Point& rPos, const Size& /* rSiz
     maPage1Rect+=aPos;
     maPage2Rect+=aPos;
 
-    ImplDraw( SCRBAR_DRAW_ALL, pDev );
+    ImplDraw(*pDev, SCRBAR_DRAW_ALL);
     pDev->Pop();
 
     mbCalcSize = true;
 }
 
-bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags )
+bool ScrollBar::ImplDrawNative(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags)
 {
     ScrollbarValue scrValue;
 
-    bool bNativeOK = IsNativeControlSupported(CTRL_SCROLLBAR, PART_ENTIRE_CONTROL);
-    if( !bNativeOK )
+    bool bNativeOK = rRenderContext.IsNativeControlSupported(CTRL_SCROLLBAR, PART_ENTIRE_CONTROL);
+    if (!bNativeOK)
         return false;
 
     bool bHorz = (GetStyle() & WB_HORZ) != 0;
 
     // Draw the entire background if the control supports it
-    if( IsNativeControlSupported(CTRL_SCROLLBAR, bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT) )
+    if (rRenderContext.IsNativeControlSupported(CTRL_SCROLLBAR, bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT))
     {
-        ControlState        nState = ( IsEnabled() ? ControlState::ENABLED : ControlState::NONE ) | ( HasFocus() ? ControlState::FOCUSED : ControlState::NONE );
+        ControlState nState = (IsEnabled() ? ControlState::ENABLED : ControlState::NONE)
+                            | (HasFocus() ? ControlState::FOCUSED : ControlState::NONE);
 
         scrValue.mnMin = mnMinRange;
         scrValue.mnMax = mnMaxRange;
@@ -484,91 +485,90 @@ bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags )
         scrValue.mnPage1State = nState | ((mnStateFlags & SCRBAR_STATE_PAGE1_DOWN) ? ControlState::PRESSED : ControlState::NONE);
         scrValue.mnPage2State = nState | ((mnStateFlags & SCRBAR_STATE_PAGE2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
 
-        if( IsMouseOver() )
+        if (IsMouseOver())
         {
-            Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
-            if( pRect )
+            Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
+            if (pRect)
             {
-                if( pRect == &maThumbRect )
+                if (pRect == &maThumbRect)
                     scrValue.mnThumbState |= ControlState::ROLLOVER;
-                else if( pRect == &maBtn1Rect )
+                else if (pRect == &maBtn1Rect)
                     scrValue.mnButton1State |= ControlState::ROLLOVER;
-                else if( pRect == &maBtn2Rect )
+                else if (pRect == &maBtn2Rect)
                     scrValue.mnButton2State |= ControlState::ROLLOVER;
-                else if( pRect == &maPage1Rect )
+                else if (pRect == &maPage1Rect)
                     scrValue.mnPage1State |= ControlState::ROLLOVER;
-                else if( pRect == &maPage2Rect )
+                else if (pRect == &maPage2Rect)
                     scrValue.mnPage2State |= ControlState::ROLLOVER;
             }
         }
 
         Rectangle aCtrlRegion;
-        aCtrlRegion.Union( maBtn1Rect );
-        aCtrlRegion.Union( maBtn2Rect );
-        aCtrlRegion.Union( maPage1Rect );
-        aCtrlRegion.Union( maPage2Rect );
-        aCtrlRegion.Union( maThumbRect );
+        aCtrlRegion.Union(maBtn1Rect);
+        aCtrlRegion.Union(maBtn2Rect);
+        aCtrlRegion.Union(maPage1Rect);
+        aCtrlRegion.Union(maPage2Rect);
+        aCtrlRegion.Union(maThumbRect);
 
-        Rectangle aRequestedRegion(Point(0,0), GetOutputSizePixel());
+        Rectangle aRequestedRegion(Point(0,0), rRenderContext.GetOutputSizePixel());
         // if the actual native control region is smaller then the region that
         // we requested the control to draw in, then draw a background rectangle
         // to avoid drawing artifacts in the uncovered region
         if (aCtrlRegion.GetWidth() < aRequestedRegion.GetWidth() ||
             aCtrlRegion.GetHeight() < aRequestedRegion.GetHeight())
         {
-            Color aFaceColor = GetSettings().GetStyleSettings().GetFaceColor();
-            SetFillColor(aFaceColor);
-            SetLineColor(aFaceColor);
-            DrawRect(aRequestedRegion);
+            Color aFaceColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor();
+            rRenderContext.SetFillColor(aFaceColor);
+            rRenderContext.SetLineColor(aFaceColor);
+            rRenderContext.DrawRect(aRequestedRegion);
         }
 
-        bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, (bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT),
-                        aCtrlRegion, nState, scrValue, OUString() );
+        bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, (bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT),
+                                                    aCtrlRegion, nState, scrValue, OUString());
     }
     else
     {
-        if ( (nDrawFlags & SCRBAR_DRAW_PAGE1) || (nDrawFlags & SCRBAR_DRAW_PAGE2) )
+        if ((nDrawFlags & SCRBAR_DRAW_PAGE1) || (nDrawFlags & SCRBAR_DRAW_PAGE2))
         {
-            sal_uInt32  part1 = bHorz ? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER;
-            sal_uInt32  part2 = bHorz ? PART_TRACK_HORZ_RIGHT : PART_TRACK_VERT_LOWER;
-            Rectangle   aCtrlRegion1( maPage1Rect );
-            Rectangle   aCtrlRegion2( maPage2Rect );
-            ControlState nState1 = (IsEnabled() ? ControlState::ENABLED : ControlState::NONE) | (HasFocus() ? ControlState::FOCUSED : ControlState::NONE);
+            sal_uInt32 part1 = bHorz ? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER;
+            sal_uInt32 part2 = bHorz ? PART_TRACK_HORZ_RIGHT : PART_TRACK_VERT_LOWER;
+            Rectangle aCtrlRegion1(maPage1Rect);
+            Rectangle aCtrlRegion2(maPage2Rect);
+            ControlState nState1 = (IsEnabled() ? ControlState::ENABLED : ControlState::NONE)
+                                 | (HasFocus() ? ControlState::FOCUSED : ControlState::NONE);
             ControlState nState2 = nState1;
 
             nState1 |= ((mnStateFlags & SCRBAR_STATE_PAGE1_DOWN) ? ControlState::PRESSED : ControlState::NONE);
             nState2 |= ((mnStateFlags & SCRBAR_STATE_PAGE2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
 
-            if( IsMouseOver() )
+            if (IsMouseOver())
             {
-                Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
-                if( pRect )
+                Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
+                if (pRect)
                 {
-                    if( pRect == &maPage1Rect )
+                    if (pRect == &maPage1Rect)
                         nState1 |= ControlState::ROLLOVER;
-                    else if( pRect == &maPage2Rect )
+                    else if (pRect == &maPage2Rect)
                         nState2 |= ControlState::ROLLOVER;
                 }
             }
 
-            if ( nDrawFlags & SCRBAR_DRAW_PAGE1 )
-                bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1,
-                                scrValue, OUString() );
+            if (nDrawFlags & SCRBAR_DRAW_PAGE1)
+                bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1, scrValue, OUString());
 
-            if ( nDrawFlags & SCRBAR_DRAW_PAGE2 )
-                bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2,
-                                scrValue, OUString() );
+            if (nDrawFlags & SCRBAR_DRAW_PAGE2)
+                bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2, scrValue, OUString());
         }
-        if ( (nDrawFlags & SCRBAR_DRAW_BTN1) || (nDrawFlags & SCRBAR_DRAW_BTN2) )
+        if ((nDrawFlags & SCRBAR_DRAW_BTN1) || (nDrawFlags & SCRBAR_DRAW_BTN2))
         {
-            sal_uInt32  part1 = bHorz ? PART_BUTTON_LEFT : PART_BUTTON_UP;
-            sal_uInt32  part2 = bHorz ? PART_BUTTON_RIGHT : PART_BUTTON_DOWN;
-            Rectangle   aCtrlRegion1( maBtn1Rect );
-            Rectangle   aCtrlRegion2( maBtn2Rect );
+            sal_uInt32 part1 = bHorz ? PART_BUTTON_LEFT : PART_BUTTON_UP;
+            sal_uInt32 part2 = bHorz ? PART_BUTTON_RIGHT : PART_BUTTON_DOWN;
+            Rectangle aCtrlRegion1(maBtn1Rect);
+            Rectangle aCtrlRegion2(maBtn2Rect);
             ControlState nState1 = HasFocus() ? ControlState::FOCUSED : ControlState::NONE;
             ControlState nState2 = nState1;
 
-            if ( !Window::IsEnabled() || !IsEnabled() )
+            if (!Window::IsEnabled() || !IsEnabled())
                 nState1 = (nState2 &= ~ControlState::ENABLED);
             else
                 nState1 = (nState2 |= ControlState::ENABLED);
@@ -576,171 +576,169 @@ bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags )
             nState1 |= ((mnStateFlags & SCRBAR_STATE_BTN1_DOWN) ? ControlState::PRESSED : ControlState::NONE);
             nState2 |= ((mnStateFlags & SCRBAR_STATE_BTN2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
 
-            if(mnStateFlags & SCRBAR_STATE_BTN1_DISABLE)
+            if (mnStateFlags & SCRBAR_STATE_BTN1_DISABLE)
                 nState1 &= ~ControlState::ENABLED;
-            if(mnStateFlags & SCRBAR_STATE_BTN2_DISABLE)
+            if (mnStateFlags & SCRBAR_STATE_BTN2_DISABLE)
                 nState2 &= ~ControlState::ENABLED;
 
-            if( IsMouseOver() )
+            if (IsMouseOver())
             {
-                Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
-                if( pRect )
+                Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
+                if (pRect)
                 {
-                    if( pRect == &maBtn1Rect )
+                    if (pRect == &maBtn1Rect)
                         nState1 |= ControlState::ROLLOVER;
-                    else if( pRect == &maBtn2Rect )
+                    else if (pRect == &maBtn2Rect)
                         nState2 |= ControlState::ROLLOVER;
                 }
             }
 
-            if ( nDrawFlags & SCRBAR_DRAW_BTN1 )
-                bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1,
-                                scrValue, OUString() );
+            if (nDrawFlags & SCRBAR_DRAW_BTN1)
+                bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1, scrValue, OUString());
 
-            if ( nDrawFlags & SCRBAR_DRAW_BTN2 )
-                bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2,
-                                scrValue, OUString() );
+            if (nDrawFlags & SCRBAR_DRAW_BTN2)
+                bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2, scrValue, OUString());
         }
-        if ( (nDrawFlags & SCRBAR_DRAW_THUMB) && !maThumbRect.IsEmpty() )
+        if ((nDrawFlags & SCRBAR_DRAW_THUMB) && !maThumbRect.IsEmpty())
         {
-            ControlState    nState = IsEnabled() ? ControlState::ENABLED : ControlState::NONE;
-            Rectangle       aCtrlRegion( maThumbRect );
+            ControlState nState = IsEnabled() ? ControlState::ENABLED : ControlState::NONE;
+            Rectangle aCtrlRegion(maThumbRect);
 
-            if ( mnStateFlags & SCRBAR_STATE_THUMB_DOWN )
+            if (mnStateFlags & SCRBAR_STATE_THUMB_DOWN)
                 nState |= ControlState::PRESSED;
 
-            if ( HasFocus() )
+            if (HasFocus())
                 nState |= ControlState::FOCUSED;
 
-            if( IsMouseOver() )
+            if (IsMouseOver())
             {
-                Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
-                if( pRect )
+                Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
+                if (pRect)
                 {
-                    if( pRect == &maThumbRect )
+                    if (pRect == &maThumbRect)
                         nState |= ControlState::ROLLOVER;
                 }
             }
 
-            bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, (bHorz ? PART_THUMB_HORZ : PART_THUMB_VERT),
-                    aCtrlRegion, nState, scrValue, OUString() );
+            bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, (bHorz ? PART_THUMB_HORZ : PART_THUMB_VERT),
+                                                         aCtrlRegion, nState, scrValue, OUString());
         }
     }
     return bNativeOK;
 }
 
-void ScrollBar::ImplDraw( sal_uInt16 nDrawFlags, OutputDevice* pOutDev )
+void ScrollBar::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags)
 {
-    DecorationView          aDecoView( pOutDev );
-    Rectangle               aTempRect;
-    sal_uInt16              nStyle;
-    const StyleSettings&    rStyleSettings = pOutDev->GetSettings().GetStyleSettings();
-    SymbolType              eSymbolType;
-    bool                    bEnabled = IsEnabled();
+    DecorationView aDecoView(&rRenderContext);
+    Rectangle aTempRect;
+    sal_uInt16 nStyle;
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+    SymbolType eSymbolType;
+    bool bEnabled = IsEnabled();
 
     // Finish some open calculations (if any)
-    if ( mbCalcSize )
-        ImplCalc( false );
+    if (mbCalcSize)
+        ImplCalc(false);
 
     vcl::Window *pWin = NULL;
-    if( pOutDev->GetOutDevType() == OUTDEV_WINDOW )
-        pWin = static_cast<vcl::Window*>(pOutDev);
+    if (rRenderContext.GetOutDevType() == OUTDEV_WINDOW)
+        pWin = static_cast<vcl::Window*>(&rRenderContext);
 
     // Draw the entire control if the native theme engine needs it
-    if ( nDrawFlags && pWin && pWin->IsNativeControlSupported(CTRL_SCROLLBAR, PART_DRAW_BACKGROUND_HORZ) )
+    if (nDrawFlags && pWin && rRenderContext.IsNativeControlSupported(CTRL_SCROLLBAR, PART_DRAW_BACKGROUND_HORZ))
     {
-        ImplDrawNative( SCRBAR_DRAW_BACKGROUND );
+        ImplDrawNative(rRenderContext, SCRBAR_DRAW_BACKGROUND);
         return;
     }
 
-    if( (nDrawFlags & SCRBAR_DRAW_BTN1) && (!pWin || !ImplDrawNative( SCRBAR_DRAW_BTN1 ) ) )
+    if ((nDrawFlags & SCRBAR_DRAW_BTN1) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_BTN1)))
     {
         nStyle = BUTTON_DRAW_NOLIGHTBORDER;
-        if ( mnStateFlags & SCRBAR_STATE_BTN1_DOWN )
+        if (mnStateFlags & SCRBAR_STATE_BTN1_DOWN)
             nStyle |= BUTTON_DRAW_PRESSED;
         aTempRect = aDecoView.DrawButton( maBtn1Rect, nStyle );
         ImplCalcSymbolRect( aTempRect );
         nStyle = 0;
-        if ( (mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) || !bEnabled )
+        if ((mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) || !bEnabled)
             nStyle |= SYMBOL_DRAW_DISABLE;
-        if ( rStyleSettings.GetOptions() & STYLE_OPTION_SCROLLARROW )
+        if (rStyleSettings.GetOptions() & STYLE_OPTION_SCROLLARROW)
         {
-            if ( GetStyle() & WB_HORZ )
+            if (GetStyle() & WB_HORZ)
                 eSymbolType = SymbolType::ARROW_LEFT;
             else
                 eSymbolType = SymbolType::ARROW_UP;
         }
         else
         {
-            if ( GetStyle() & WB_HORZ )
+            if (GetStyle() & WB_HORZ)
                 eSymbolType = SymbolType::SPIN_LEFT;
             else
                 eSymbolType = SymbolType::SPIN_UP;
         }
-        aDecoView.DrawSymbol( aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nStyle );
+        aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nStyle);
     }
 
-    if ( (nDrawFlags & SCRBAR_DRAW_BTN2) && (!pWin || !ImplDrawNative( SCRBAR_DRAW_BTN2 ) ) )
+    if ((nDrawFlags & SCRBAR_DRAW_BTN2) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_BTN2)))
     {
         nStyle = BUTTON_DRAW_NOLIGHTBORDER;
-        if ( mnStateFlags & SCRBAR_STATE_BTN2_DOWN )
+        if (mnStateFlags & SCRBAR_STATE_BTN2_DOWN)
             nStyle |= BUTTON_DRAW_PRESSED;
-        aTempRect = aDecoView.DrawButton(  maBtn2Rect, nStyle );
-        ImplCalcSymbolRect( aTempRect );
+        aTempRect = aDecoView.DrawButton(maBtn2Rect, nStyle);
+        ImplCalcSymbolRect(aTempRect);
         nStyle = 0;
-        if ( (mnStateFlags & SCRBAR_STATE_BTN2_DISABLE) || !bEnabled )
+        if ((mnStateFlags & SCRBAR_STATE_BTN2_DISABLE) || !bEnabled)
             nStyle |= SYMBOL_DRAW_DISABLE;
-        if ( rStyleSettings.GetOptions() & STYLE_OPTION_SCROLLARROW )
+        if (rStyleSettings.GetOptions() & STYLE_OPTION_SCROLLARROW)
         {
-            if ( GetStyle() & WB_HORZ )
+            if (GetStyle() & WB_HORZ)
                 eSymbolType = SymbolType::ARROW_RIGHT;
             else
                 eSymbolType = SymbolType::ARROW_DOWN;
         }
         else
         {
-            if ( GetStyle() & WB_HORZ )
+            if (GetStyle() & WB_HORZ)
                 eSymbolType = SymbolType::SPIN_RIGHT;
             else
                 eSymbolType = SymbolType::SPIN_DOWN;
         }
-        aDecoView.DrawSymbol( aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nStyle );
+        aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nStyle);
     }
 
-    pOutDev->SetLineColor();
+    rRenderContext.SetLineColor();
 
-    if ( (nDrawFlags & SCRBAR_DRAW_THUMB) && (!pWin || !ImplDrawNative( SCRBAR_DRAW_THUMB ) ) )
+    if ((nDrawFlags & SCRBAR_DRAW_THUMB) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_THUMB)))
     {
-        if ( !maThumbRect.IsEmpty() )
+        if (!maThumbRect.IsEmpty())
         {
-            if ( bEnabled )
+            if (bEnabled)
             {
                 nStyle = BUTTON_DRAW_NOLIGHTBORDER;
-                aTempRect = aDecoView.DrawButton( maThumbRect, nStyle );
+                aTempRect = aDecoView.DrawButton(maThumbRect, nStyle);
             }
             else
             {
-                pOutDev->SetFillColor( rStyleSettings.GetCheckedColor() );
-                pOutDev->DrawRect( maThumbRect );
+                rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
+                rRenderContext.DrawRect(maThumbRect);
             }
         }
     }
 
-    if ( (nDrawFlags & SCRBAR_DRAW_PAGE1) && (!pWin || !ImplDrawNative( SCRBAR_DRAW_PAGE1 ) ) )
+    if ((nDrawFlags & SCRBAR_DRAW_PAGE1) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_PAGE1)))
     {
-        if ( mnStateFlags & SCRBAR_STATE_PAGE1_DOWN )
-            pOutDev->SetFillColor( rStyleSettings.GetShadowColor() );
+        if (mnStateFlags & SCRBAR_STATE_PAGE1_DOWN)
+            rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
         else
-            pOutDev->SetFillColor( rStyleSettings.GetCheckedColor() );
-        pOutDev->DrawRect( maPage1Rect );
+            rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
+        rRenderContext.DrawRect(maPage1Rect);
     }
-    if ( (nDrawFlags & SCRBAR_DRAW_PAGE2) && (!pWin || !ImplDrawNative( SCRBAR_DRAW_PAGE2 ) ) )
+    if ((nDrawFlags & SCRBAR_DRAW_PAGE2) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_PAGE2)))
     {
-        if ( mnStateFlags & SCRBAR_STATE_PAGE2_DOWN )
-            pOutDev->SetFillColor( rStyleSettings.GetShadowColor() );
+        if (mnStateFlags & SCRBAR_STATE_PAGE2_DOWN)
+            rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
         else
-            pOutDev->SetFillColor( rStyleSettings.GetCheckedColor() );
-        pOutDev->DrawRect( maPage2Rect );
+            rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
+        rRenderContext.DrawRect(maPage2Rect);
     }
 }
 
@@ -858,7 +856,7 @@ void ScrollBar::ImplDoMouseAction( const Point& rMousePos, bool bCallAction )
     }
 
     if ( nOldStateFlags != mnStateFlags )
-        ImplDraw( mnDragDraw, this );
+        Invalidate();
     if ( bAction )
         ImplDoAction( false );
 }
@@ -947,8 +945,11 @@ void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt )
                 if( mpData )
                 {
                     mpData->mbHide = true; // disable focus blinking
-                    if( HasFocus() )
-                        ImplDraw( SCRBAR_DRAW_THUMB, this ); // paint without focus
+                    if (HasFocus())
+                    {
+                        mnStateFlags |= SCRBAR_DRAW_THUMB; // paint without focus
+                        Invalidate();
+                    }
                 }
 
                 if ( mnVisibleSize < mnMaxRange-mnMinRange )
@@ -975,7 +976,7 @@ void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt )
                     }
 
                     mnStateFlags |= SCRBAR_STATE_THUMB_DOWN;
-                    ImplDraw( mnDragDraw, this );
+                    Invalidate();
                 }
             }
             else if(bPage && (!HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_TRACK_HORZ_AREA : PART_TRACK_VERT_AREA,
@@ -1028,7 +1029,7 @@ void ScrollBar::Tracking( const TrackingEvent& rTEvt )
                           SCRBAR_STATE_PAGE1_DOWN | SCRBAR_STATE_PAGE2_DOWN |
                           SCRBAR_STATE_THUMB_DOWN);
         if ( nOldStateFlags != mnStateFlags )
-            ImplDraw( mnDragDraw, this );
+            Invalidate();
         mnDragDraw = 0;
 
         // Restore the old ThumbPosition when canceled
@@ -1122,7 +1123,7 @@ void ScrollBar::KeyInput( const KeyEvent& rKEvt )
 
 void ScrollBar::Paint( vcl::RenderContext& rRenderContext, const Rectangle& )
 {
-    ImplDraw(SCRBAR_DRAW_ALL, &rRenderContext);
+    ImplDraw(rRenderContext, SCRBAR_DRAW_ALL);
 }
 
 void ScrollBar::Resize()
@@ -1177,7 +1178,7 @@ void ScrollBar::LoseFocus()
 {
     if( mpData )
         mpData->maTimer.Stop();
-    ImplDraw( SCRBAR_DRAW_THUMB, this );
+    Invalidate();
 
     Control::LoseFocus();
 }
commit 48cea2a7f23d98b704de7de8065e63df5c345322
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu May 7 12:11:49 2015 +0900

    refactor ProgressBar to use RenderContext
    
    Change-Id: Idf33332a207736f70809820853dee5ce1e0a3cb1

diff --git a/include/vcl/status.hxx b/include/vcl/status.hxx
index 782316b..0d8344e 100644
--- a/include/vcl/status.hxx
+++ b/include/vcl/status.hxx
@@ -31,12 +31,10 @@ typedef ::std::vector< ImplStatusItem* > ImplStatusItemList;
 
 // - Progress-Ausgabe -
 
-
-void VCL_DLLPUBLIC DrawProgress( vcl::Window* pWindow, const Point& rPos,
-                                 long nOffset, long nPrgsWidth, long nPrgsHeight,
-                                 sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
-                                 const Rectangle& rFramePosSize
-                                 );
+void VCL_DLLPUBLIC DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRenderContext, const Point& rPos,
+                                long nOffset, long nPrgsWidth, long nPrgsHeight,
+                                sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
+                                const Rectangle& rFramePosSize);
 
 
 // - StatusBarItemBits -
diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx
index 609911c..74d2bc6 100644
--- a/vcl/source/control/prgsbar.cxx
+++ b/vcl/source/control/prgsbar.cxx
@@ -117,33 +117,37 @@ void ProgressBar::ImplInitSettings( bool bFont,
     }
 }
 
-void ProgressBar::ImplDrawProgress(vcl::RenderContext& /*rRenderContext*/, sal_uInt16 nOldPerc, sal_uInt16 nNewPerc)
+void ProgressBar::ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt16 nOldPerc, sal_uInt16 nNewPerc)
 {
-    if ( mbCalcNew )
+    if (mbCalcNew)
     {
         mbCalcNew = false;
 
-        Size aSize = GetOutputSizePixel();
-        mnPrgsHeight = aSize.Height()-(PROGRESSBAR_WIN_OFFSET*2);
-        mnPrgsWidth = (mnPrgsHeight*2)/3;
+        Size aSize = rRenderContext.GetOutputSizePixel();
+        mnPrgsHeight = aSize.Height() - (PROGRESSBAR_WIN_OFFSET * 2);
+        mnPrgsWidth = (mnPrgsHeight * 2) / 3;
         maPos.Y() = PROGRESSBAR_WIN_OFFSET;
-        long nMaxWidth = (aSize.Width()-(PROGRESSBAR_WIN_OFFSET*2)+PROGRESSBAR_OFFSET);
+        long nMaxWidth = (aSize.Width() - (PROGRESSBAR_WIN_OFFSET * 2) + PROGRESSBAR_OFFSET);
         sal_uInt16 nMaxCount = (sal_uInt16)(nMaxWidth / (mnPrgsWidth+PROGRESSBAR_OFFSET));
-        if ( nMaxCount <= 1 )
+        if (nMaxCount <= 1)
+        {
             nMaxCount = 1;
+        }
         else
         {
-            while ( ((10000/(10000/nMaxCount))*(mnPrgsWidth+PROGRESSBAR_OFFSET)) > nMaxWidth )
+            while (((10000 / (10000 / nMaxCount)) * (mnPrgsWidth + PROGRESSBAR_OFFSET)) > nMaxWidth)
+            {
                 nMaxCount--;
+            }
         }
-        mnPercentCount = 10000/nMaxCount;
-        nMaxWidth = ((10000/(10000/nMaxCount))*(mnPrgsWidth+PROGRESSBAR_OFFSET))-PROGRESSBAR_OFFSET;
-        maPos.X() = (aSize.Width()-nMaxWidth)/2;
+        mnPercentCount = 10000 / nMaxCount;
+        nMaxWidth = ((10000 / (10000 / nMaxCount)) * (mnPrgsWidth + PROGRESSBAR_OFFSET)) - PROGRESSBAR_OFFSET;
+        maPos.X() = (aSize.Width() - nMaxWidth) / 2;
     }
 
-    ::DrawProgress( this, maPos, PROGRESSBAR_OFFSET, mnPrgsWidth, mnPrgsHeight,
-                    nOldPerc*100, nNewPerc*100, mnPercentCount,
-                    Rectangle( Point(), GetSizePixel() ) );
+    ::DrawProgress(this, rRenderContext, maPos, PROGRESSBAR_OFFSET, mnPrgsWidth, mnPrgsHeight,
+                   nOldPerc * 100, nNewPerc * 100, mnPercentCount,
+                   Rectangle(Point(), GetSizePixel()));
 }
 
 void ProgressBar::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 53d48b9..e54564c 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -468,147 +468,143 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& /*rRenderContext*/, bool bOffSc
         CallEventListeners( VCLEVENT_STATUSBAR_DRAWITEM, reinterpret_cast<void*>(pItem->mnId) );
 }
 
-void DrawProgress( vcl::Window* pWindow, const Point& rPos,
-                   long nOffset, long nPrgsWidth, long nPrgsHeight,
-                   sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
-                   const Rectangle& rFramePosSize
-                   )
+void DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRenderContext, const Point& rPos,
+                  long nOffset, long nPrgsWidth, long nPrgsHeight,
+                  sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
+                  const Rectangle& rFramePosSize)
 {
-    if( pWindow->IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
+    if (rRenderContext.IsNativeControlSupported(CTRL_PROGRESS, PART_ENTIRE_CONTROL))
     {
         bool bNeedErase = ImplGetSVData()->maNWFData.mbProgressNeedsErase;
 
         long nFullWidth = (nPrgsWidth + nOffset) * (10000 / nPercentCount);
         long nPerc = (nPercent2 > 10000) ? 10000 : nPercent2;
-        ImplControlValue aValue( nFullWidth * (long)nPerc / 10000 );
-        Rectangle aDrawRect( rPos, Size( nFullWidth, nPrgsHeight ) );
-        Rectangle aControlRegion( aDrawRect );
-        if( bNeedErase )
+        ImplControlValue aValue(nFullWidth * long(nPerc) / 10000);
+        Rectangle aDrawRect(rPos, Size(nFullWidth, nPrgsHeight));
+        Rectangle aControlRegion(aDrawRect);
+
+        if(bNeedErase)
         {
             vcl::Window* pEraseWindow = pWindow;
-            while( pEraseWindow->IsPaintTransparent()                         &&
-                   ! pEraseWindow->ImplGetWindowImpl()->mbFrame )
+            while (pEraseWindow->IsPaintTransparent() && !pEraseWindow->ImplGetWindowImpl()->mbFrame)
             {
                 pEraseWindow = pEraseWindow->ImplGetWindowImpl()->mpParent;
             }
-            if( pEraseWindow == pWindow )
+
+            if (pEraseWindow == pWindow)
+            {
                 // restore background of pWindow
-                pEraseWindow->Erase( rFramePosSize );
+                rRenderContext.Erase(rFramePosSize);
+            }
             else
             {
                 // restore transparent background
-                Point aTL( pWindow->OutputToAbsoluteScreenPixel( rFramePosSize.TopLeft() ) );
-                aTL = pEraseWindow->AbsoluteScreenToOutputPixel( aTL );
-                Rectangle aRect( aTL, rFramePosSize.GetSize() );
-                pEraseWindow->Invalidate( aRect, INVALIDATE_NOCHILDREN     |
-                                                 INVALIDATE_NOCLIPCHILDREN |
-                                                 INVALIDATE_TRANSPARENT );
+                Point aTL(pWindow->OutputToAbsoluteScreenPixel(rFramePosSize.TopLeft()));
+                aTL = pEraseWindow->AbsoluteScreenToOutputPixel(aTL);
+                Rectangle aRect(aTL, rFramePosSize.GetSize());
+                pEraseWindow->Invalidate(aRect, INVALIDATE_NOCHILDREN     |
+                                                INVALIDATE_NOCLIPCHILDREN |
+                                                INVALIDATE_TRANSPARENT);
                 pEraseWindow->Update();
             }
-            pWindow->Push( PushFlags::CLIPREGION );
-            pWindow->IntersectClipRegion( rFramePosSize );
+            rRenderContext.Push(PushFlags::CLIPREGION);
+            rRenderContext.IntersectClipRegion(rFramePosSize);
         }
-        bool bNativeOK = pWindow->DrawNativeControl( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
-                                                     ControlState::ENABLED, aValue, OUString() );
-        if( bNeedErase )
-            pWindow->Pop();
-        if( bNativeOK )
-        {
-            pWindow->Flush();
+
+        bool bNativeOK = rRenderContext.DrawNativeControl(CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
+                                                          ControlState::ENABLED, aValue, OUString());
+        if (bNeedErase)
+            rRenderContext.Pop();
+        if (bNativeOK)
             return;
-        }
     }
 
     // precompute values
     sal_uInt16 nPerc1 = nPercent1 / nPercentCount;
     sal_uInt16 nPerc2 = nPercent2 / nPercentCount;
 
-    if ( nPerc1 > nPerc2 )
+    if (nPerc1 > nPerc2)
     {
         // support progress that can also decrease
 
         // compute rectangle
-        long        nDX = nPrgsWidth + nOffset;
-        long        nLeft = rPos.X()+((nPerc1-1)*nDX);
-        Rectangle   aRect( nLeft, rPos.Y(), nLeft+nPrgsWidth, rPos.Y()+nPrgsHeight );
+        long nDX = nPrgsWidth + nOffset;
+        long nLeft = rPos.X() + ((nPerc1 - 1) * nDX);
+        Rectangle aRect(nLeft, rPos.Y(), nLeft + nPrgsWidth, rPos.Y() + nPrgsHeight);
 
         do
         {
-            pWindow->Erase( aRect );
+            rRenderContext.Erase(aRect);
             aRect.Left()  -= nDX;
             aRect.Right() -= nDX;
             nPerc1--;
         }
-        while ( nPerc1 > nPerc2 );
-
-        pWindow->Flush();
+        while (nPerc1 > nPerc2);
     }
-    else if ( nPerc1 < nPerc2 )
+    else if (nPerc1 < nPerc2)
     {
         // draw Percent rectangle
         // if Percent2 greater than 100%, adapt values
-        if ( nPercent2 > 10000 )
+        if (nPercent2 > 10000)
         {
             nPerc2 = 10000 / nPercentCount;
-            if ( nPerc1 >= nPerc2 )
-                nPerc1 = nPerc2-1;
+            if (nPerc1 >= nPerc2)
+                nPerc1 = nPerc2 - 1;
         }
 
         // compute rectangle
-        long        nDX = nPrgsWidth + nOffset;
-        long        nLeft = rPos.X()+(nPerc1*nDX);
-        Rectangle   aRect( nLeft, rPos.Y(), nLeft+nPrgsWidth, rPos.Y()+nPrgsHeight );
+        long nDX = nPrgsWidth + nOffset;
+        long nLeft = rPos.X() + (nPerc1 * nDX);
+        Rectangle aRect(nLeft, rPos.Y(), nLeft + nPrgsWidth, rPos.Y() + nPrgsHeight);
 
         do
         {
-            pWindow->DrawRect( aRect );
+            rRenderContext.DrawRect(aRect);
             aRect.Left()  += nDX;
             aRect.Right() += nDX;
             nPerc1++;
         }
-        while ( nPerc1 < nPerc2 );
+        while (nPerc1 < nPerc2);
 
         // if greater than 100%, set rectangle to blink
-        if ( nPercent2 > 10000 )
+        if (nPercent2 > 10000)
         {
             // define on/off status
-            if ( ((nPercent2 / nPercentCount) & 0x01) == (nPercentCount & 0x01) )
+            if (((nPercent2 / nPercentCount) & 0x01) == (nPercentCount & 0x01))
             {
                 aRect.Left()  -= nDX;
                 aRect.Right() -= nDX;
-                pWindow->Erase( aRect );
+                rRenderContext.Erase(aRect);
             }
         }
-
-        pWindow->Flush();
     }
 }
 
 void StatusBar::ImplDrawProgress(vcl::RenderContext& rRenderContext, bool bPaint,
                                  sal_uInt16 nPercent1, sal_uInt16 nPercent2)
 {
-    bool bNative = IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL );
+    bool bNative = rRenderContext.IsNativeControlSupported(CTRL_PROGRESS, PART_ENTIRE_CONTROL);
     // bPaint: draw text also, else only update progress
     if (bPaint)
     {
-        DrawText( maPrgsTxtPos, maPrgsTxt );
-        if( ! bNative )
+        rRenderContext.DrawText(maPrgsTxtPos, maPrgsTxt);
+        if (!bNative)
         {
             DecorationView aDecoView(&rRenderContext);
-            aDecoView.DrawFrame( maPrgsFrameRect, FRAME_DRAW_IN );
+            aDecoView.DrawFrame(maPrgsFrameRect, FRAME_DRAW_IN);
         }
     }
 
-    Point aPos( maPrgsFrameRect.Left()+STATUSBAR_PRGS_OFFSET,
-                maPrgsFrameRect.Top()+STATUSBAR_PRGS_OFFSET );
+    Point aPos(maPrgsFrameRect.Left() + STATUSBAR_PRGS_OFFSET,
+               maPrgsFrameRect.Top()  + STATUSBAR_PRGS_OFFSET);
     long nPrgsHeight = mnPrgsSize;
-    if( bNative )
+    if (bNative)
     {
         aPos = maPrgsFrameRect.TopLeft();
         nPrgsHeight = maPrgsFrameRect.GetHeight();
     }
-    DrawProgress( this, aPos, mnPrgsSize / 2, mnPrgsSize, nPrgsHeight,
-                  nPercent1 * 100, nPercent2 * 100, mnPercentCount, maPrgsFrameRect );
+    DrawProgress(this, rRenderContext, aPos, mnPrgsSize / 2, mnPrgsSize, nPrgsHeight,
+                 nPercent1 * 100, nPercent2 * 100, mnPercentCount, maPrgsFrameRect);
 }
 
 void StatusBar::ImplCalcProgressRect()


More information about the Libreoffice-commits mailing list