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

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Wed May 6 23:19:34 PDT 2015


 vcl/source/window/dockingarea.cxx |   90 +++++++++++++-------------
 vcl/source/window/dockmgr.cxx     |  131 +++++++++++++++++++-------------------
 2 files changed, 111 insertions(+), 110 deletions(-)

New commits:
commit 6ea7a051b699ea8d1afa6a4f61d966454942f67b
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu May 7 15:18:41 2015 +0900

    refactor PopupFloatWin to use RenderContext
    
    Change-Id: Ib3f74c89c9a930deb0c153bf456f9c84095e237e

diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 7d0f826..15b0e0c 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -487,7 +487,7 @@ public:
     virtual void dispose() SAL_OVERRIDE;
 
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() 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        MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     virtual void        MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     virtual void        MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
@@ -498,8 +498,8 @@ public:
     Rectangle           GetDragRect() const;
     Point               GetToolboxPosition() const;
     Point               GetTearOffPosition() const;
-    void                DrawGrip();
-    void                DrawBorder();
+    void                DrawGrip(vcl::RenderContext& rRenderContext);
+    void                DrawBorder(vcl::RenderContext& rRenderContext);
 
     bool                hasGrip() const { return mbHasGrip; }
 };
@@ -600,9 +600,9 @@ Point ImplPopupFloatWin::GetTearOffPosition() const
     return aPt;
 }
 
-void ImplPopupFloatWin::DrawBorder()
+void ImplPopupFloatWin::DrawBorder(vcl::RenderContext& rRenderContext)
 {
-    SetFillColor();
+    rRenderContext.SetFillColor();
     Point aPt;
     Rectangle aRect( aPt, GetOutputSizePixel() );
 
@@ -614,113 +614,114 @@ void ImplPopupFloatWin::DrawBorder()
         aItemClipRect.SetPos( AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
 
         // draw the excluded border part with the background color of a toolbox
-        SetClipRegion( vcl::Region( aItemClipRect ) );
-        SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
-        DrawRect( aRect );
+        rRenderContext.SetClipRegion( vcl::Region( aItemClipRect ) );
+        rRenderContext.SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
+        rRenderContext.DrawRect( aRect );
 
         aClipRgn.Exclude( aItemClipRect );
         SetClipRegion( aClipRgn );
     }
-    SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
-    DrawRect( aRect );
-    SetClipRegion( oldClipRgn );
+    rRenderContext.SetLineColor( rRenderContext.GetSettings().GetStyleSettings().GetShadowColor() );
+    rRenderContext.DrawRect( aRect );
+    rRenderContext.SetClipRegion( oldClipRgn );
 }
 
-void ImplPopupFloatWin::DrawGrip()
+void ImplPopupFloatWin::DrawGrip(vcl::RenderContext& rRenderContext)
 {
-    bool bLinecolor     = IsLineColor();
-    Color aLinecolor    = GetLineColor();
-    bool bFillcolor     = IsFillColor();
-    Color aFillcolor    = GetFillColor();
+    bool bLinecolor     = rRenderContext.IsLineColor();
+    Color aLinecolor    = rRenderContext.GetLineColor();
+    bool bFillcolor     = rRenderContext.IsFillColor();
+    Color aFillcolor    = rRenderContext.GetFillColor();
 
     // draw background
-    Rectangle aRect( GetDragRect() );
-    aRect.Top()      += POPUP_DRAGBORDER;
-    aRect.Bottom()   -= POPUP_DRAGBORDER;
-    aRect.Left()+=3;
-    aRect.Right()-=3;
+    Rectangle aRect(GetDragRect());
+    aRect.Top() += POPUP_DRAGBORDER;
+    aRect.Bottom() -= POPUP_DRAGBORDER;
+    aRect.Left() += 3;
+    aRect.Right() -= 3;
 
-    if( mbHighlight )
+    if (mbHighlight)
     {
-        Erase( aRect );
-        DrawSelectionBackground( aRect, 2, false, true, false );
+        rRenderContext.Erase(aRect);
+        DrawSelectionBackground(aRect, 2, false, true, false);
     }
     else
     {
-        SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
-        SetLineColor();
-        DrawRect( aRect );
+        rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetFaceColor());
+        rRenderContext.SetLineColor();
+        rRenderContext.DrawRect(aRect);
     }
 
-    if( !ToolBox::AlwaysLocked() )  // no grip if toolboxes are locked
+    if (!ToolBox::AlwaysLocked())  // no grip if toolboxes are locked
     {
 #ifdef TEAROFF_DASHED
         // draw single dashed line
-        LineInfo aLineInfo( LINE_DASH );
-        aLineInfo.SetDistance( 4 );
-        aLineInfo.SetDashLen( 12 );
-        aLineInfo.SetDashCount( 1 );
+        LineInfo aLineInfo(LINE_DASH);
+        aLineInfo.SetDistance(4);
+        aLineInfo.SetDashLen(12);
+        aLineInfo.SetDashCount(1);
 
-        aRect.Left()+=2;
-        aRect.Right()-=2;
+        aRect.Left() += 2;
+        aRect.Right()-= 2;
 
-        aRect.Top()+=2;
+        aRect.Top()   += 2;
         aRect.Bottom() = aRect.Top();
-        SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
-        DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
+        rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetDarkShadowColor());
+        rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight(), aLineInfo);
 
-        if( !mbHighlight )
+        if (!mbHighlight)
         {
             ++aRect.Top();
             ++aRect.Bottom();
-            SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
-            DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
+            rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetLightColor());
+            rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight(), aLineInfo);
         }
 
 #else
         // draw several grip lines
-        SetFillColor( GetSettings().GetStyleSettings().GetShadowColor() );
+        rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetShadowColor());
         aRect.Top()++;
         aRect.Bottom() = aRect.Top();
 
         int width = POPUP_DRAGWIDTH;
-        while( width >= aRect.getWidth() )
+        while(width >= aRect.getWidth())
+        {
             width -= 4;
-        if( width <= 0 )
+        }
+        if (width <= 0)
             width = aRect.getWidth();
         //aRect.nLeft = aRect.nLeft + (aRect.getWidth() - width) / 2;
         aRect.Left() = (aRect.Left() + aRect.Right() - width) / 2;
         aRect.Right() = aRect.Left() + width;
 
-        int i=0;
-        while( i< POPUP_DRAGGRIP )
+        int i = 0;
+        while (i < POPUP_DRAGGRIP)
         {
-            DrawRect( aRect );
-            aRect.Top()+=2;
-            aRect.Bottom()+=2;
-            i+=2;
+            rRenderContext.DrawRect(aRect);
+            aRect.Top() += 2;
+            aRect.Bottom() += 2;
+            i += 2;
         }
 #endif
     }
 
-    if( bLinecolor )
-        SetLineColor( aLinecolor );
+    if (bLinecolor)
+        rRenderContext.SetLineColor(aLinecolor);
     else
-        SetLineColor();
-    if( bFillcolor )
-        SetFillColor( aFillcolor );
+        rRenderContext.SetLineColor();
+    if (bFillcolor)
+        rRenderContext.SetFillColor(aFillcolor);
     else
-        SetFillColor();
+        rRenderContext.SetFillColor();
 }
 
-void ImplPopupFloatWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void ImplPopupFloatWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
 {
-    Point aPt;
-    Rectangle aRect( aPt, GetOutputSizePixel() );
-    DrawWallpaper( aRect, Wallpaper( GetSettings().GetStyleSettings().GetFaceGradientColor() ) );
-    DrawBorder();
-    if( hasGrip() )
-        DrawGrip();
+    Rectangle aRect(Point(), rRenderContext.GetOutputSizePixel());
+    rRenderContext.DrawWallpaper(aRect, Wallpaper(rRenderContext.GetSettings().GetStyleSettings().GetFaceGradientColor()));
+    DrawBorder(rRenderContext);
+    if (hasGrip())
+        DrawGrip(rRenderContext);
 }
 
 void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
@@ -739,12 +740,12 @@ void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
         if( !mbHighlight && GetDragRect().IsInside( aMousePos ) )
         {
             mbHighlight = true;
-            DrawGrip();
+            Invalidate();
         }
-        if( mbHighlight && ( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) )
+        if (mbHighlight && ( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) )
         {
             mbHighlight = false;
-            DrawGrip();
+            Invalidate();
         }
     }
 }
commit 235ce69e49f1c6eb58d1cbfa5739dacabfb3c3d4
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu May 7 15:12:42 2015 +0900

    refactor DockingAreaWindow to use RenderContext
    
    Change-Id: Iacd4fb271dcf006c2eb81017d364f1c2d452b915

diff --git a/vcl/source/window/dockingarea.cxx b/vcl/source/window/dockingarea.cxx
index e94d607..e1d16e9 100644
--- a/vcl/source/window/dockingarea.cxx
+++ b/vcl/source/window/dockingarea.cxx
@@ -159,55 +159,54 @@ WindowAlign DockingAreaWindow::GetAlign() const
     return mpImplData->meAlign;
 }
 
-void DockingAreaWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void DockingAreaWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
 {
-    EnableNativeWidget( true ); // only required because the toolkit currently switches this flag off
-    if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
+    EnableNativeWidget(true); // only required because the toolkit currently switches this flag off
+    if (rRenderContext.IsNativeControlSupported(CTRL_TOOLBAR, PART_ENTIRE_CONTROL))
     {
-        ToolbarValue        aControlValue;
-        const StyleSettings rSetting = Application::GetSettings().GetStyleSettings();
+        ToolbarValue aControlValue;
+        const StyleSettings rSetting = rRenderContext.GetSettings().GetStyleSettings();
 
-        if( GetAlign() == WINDOWALIGN_TOP && ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG )
+        if (GetAlign() == WINDOWALIGN_TOP && ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG)
         {
             // give NWF a hint that this dockingarea is adjacent to the menubar
             // useful for special gradient effects that should cover both windows
             aControlValue.mbIsTopDockingArea = true;
         }
 
-        ControlState        nState = ControlState::ENABLED;
+        ControlState nState = ControlState::ENABLED;
         const bool isFooter = GetAlign() == WINDOWALIGN_BOTTOM && !rSetting.GetPersonaFooter().IsEmpty();
 
-        if (( GetAlign() == WINDOWALIGN_TOP && !rSetting.GetPersonaHeader().IsEmpty() ) || isFooter  )
-            Erase();
-        else if ( !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB )
+        if ((GetAlign() == WINDOWALIGN_TOP && !rSetting.GetPersonaHeader().IsEmpty() ) || isFooter)
+            rRenderContext.Erase();
+        else if (!ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB)
         {
             // draw a single toolbar background covering the whole docking area
-            Point tmp;
-            Rectangle aCtrlRegion( tmp, GetOutputSizePixel() );
+            Rectangle aCtrlRegion(Point(), GetOutputSizePixel());
 
-            DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
-                               aCtrlRegion, nState, aControlValue, OUString() );
+            rRenderContext.DrawNativeControl(CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
+                                             aCtrlRegion, nState, aControlValue, OUString() );
 
-            if( !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames )
+            if (!ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames)
             {
                 // each toolbar gets a thin border to better recognize its borders on the homogeneous docking area
                 sal_uInt16 nChildren = GetChildCount();
-                for( sal_uInt16 n = 0; n < nChildren; n++ )
+                for (sal_uInt16 n = 0; n < nChildren; n++)
                 {
-                    vcl::Window* pChild = GetChild( n );
-                    if ( pChild->IsVisible() )
+                    vcl::Window* pChild = GetChild(n);
+                    if (pChild->IsVisible())
                     {
                         Point aPos = pChild->GetPosPixel();
                         Size aSize = pChild->GetSizePixel();
-                        Rectangle aRect( aPos, aSize );
+                        Rectangle aRect(aPos, aSize);
 
-                        SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
-                        DrawLine( aRect.TopLeft(), aRect.TopRight() );
-                        DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
+                        rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetLightColor());
+                        rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight());
+                        rRenderContext.DrawLine(aRect.TopLeft(), aRect.BottomLeft());
 
-                        SetLineColor( GetSettings().GetStyleSettings().GetSeparatorColor() );
-                        DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
-                        DrawLine( aRect.TopRight(), aRect.BottomRight() );
+                        rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetSeparatorColor());
+                        rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
+                        rRenderContext.DrawLine(aRect.TopRight(), aRect.BottomRight());
                     }
                 }
             }
@@ -215,40 +214,41 @@ void DockingAreaWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rec
         else
         {
             // create map to find toolbar lines
-            Size aOutSz = GetOutputSizePixel();
-            std::map< int, int > ranges;
+            Size aOutSz = rRenderContext.GetOutputSizePixel();
+            std::map<int, int> ranges;
             sal_uInt16 nChildren = GetChildCount();
-            for( sal_uInt16 n = 0; n < nChildren; n++ )
+            for (sal_uInt16 n = 0; n < nChildren; n++)
             {
-                vcl::Window* pChild = GetChild( n );
+                vcl::Window* pChild = GetChild(n);
                 Point aPos = pChild->GetPosPixel();
                 Size aSize = pChild->GetSizePixel();
-                if( IsHorizontal() )
-                    ranges[ aPos.Y() ] = aSize.Height();
+                if (IsHorizontal())
+                    ranges[aPos.Y()] = aSize.Height();
                 else
-                    ranges[ aPos.X() ] = aSize.Width();
+                    ranges[aPos.X()] = aSize.Width();
             }
 
             // draw multiple toolbar backgrounds, i.e., one for each toolbar line
-            for( std::map<int,int>::const_iterator it = ranges.begin(); it != ranges.end(); ++it )
+            std::map<int, int>::const_iterator it;
+            for (it = ranges.begin(); it != ranges.end(); ++it)
             {
                 Rectangle aTBRect;
-                if( IsHorizontal() )
+                if (IsHorizontal())
                 {
-                    aTBRect.Left()      = 0;
-                    aTBRect.Right()     = aOutSz.Width() - 1;
-                    aTBRect.Top()       = it->first;
-                    aTBRect.Bottom()    = it->first + it->second - 1;
+                    aTBRect.Left()   = 0;
+                    aTBRect.Right()  = aOutSz.Width() - 1;
+                    aTBRect.Top()    = it->first;
+                    aTBRect.Bottom() = it->first + it->second - 1;
                 }
                 else
                 {
-                    aTBRect.Left()      = it->first;
-                    aTBRect.Right()     = it->first + it->second - 1;
-                    aTBRect.Top()       = 0;
-                    aTBRect.Bottom()    = aOutSz.Height() - 1;
+                    aTBRect.Left()   = it->first;
+                    aTBRect.Right()  = it->first + it->second - 1;
+                    aTBRect.Top()    = 0;
+                    aTBRect.Bottom() = aOutSz.Height() - 1;
                 }
-                DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
-                                   aTBRect, nState, aControlValue, OUString() );
+                rRenderContext.DrawNativeControl(CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
+                                                 aTBRect, nState, aControlValue, OUString());
             }
         }
     }
@@ -258,7 +258,7 @@ void DockingAreaWindow::Resize()
 {
     ImplInitBackground( this );
     ImplInvalidateMenubar( this );
-    if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
+    if (IsNativeControlSupported(CTRL_TOOLBAR, PART_ENTIRE_CONTROL))
         Invalidate();
 }
 


More information about the Libreoffice-commits mailing list