Hi,
please find attached a patch that takes advantage of previous patch
to cleanup the code calling ImplDraw2ColorFrame.
The attached patch is contributed under LGPL3+/MPL1.1 license.
Matteo
From e0167dc0598f011f22728fb77e5b23be2f273781 Mon Sep 17 00:00:00 2001
From: Matteo Casalin <matteo.casalin@poste.it>
Date: Sun, 4 Dec 2011 16:09:21 +0100
Subject: [PATCH 4/4] DecoView cleanup - ImplDraw2ColorFrame also resizes its
rectangle
---
vcl/source/window/decoview.cxx | 64 +++++++++++----------------------------
1 files changed, 18 insertions(+), 46 deletions(-)
diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx
index 58f425c..ec46b89 100644
--- a/vcl/source/window/decoview.cxx
+++ b/vcl/source/window/decoview.cxx
@@ -481,15 +481,21 @@ void ImplDrawDPILineRect( OutputDevice *const pDev, Rectangle& rRect,
}
-void ImplDraw2ColorFrame( OutputDevice *const pDev, const Rectangle& rRect,
+void ImplDraw2ColorFrame( OutputDevice *const pDev, Rectangle& rRect,
const Color& rLeftTopColor, const Color& rRightBottomColor )
{
- pDev->SetFillColor( rLeftTopColor );
- pDev->DrawRect( Rectangle( rRect.TopLeft(), Point( rRect.Left(), rRect.Bottom()-1 ) ) );
- pDev->DrawRect( Rectangle( rRect.TopLeft(), Point( rRect.Right()-1, rRect.Top() ) ) );
- pDev->SetFillColor( rRightBottomColor );
- pDev->DrawRect( Rectangle( rRect.BottomLeft(), rRect.BottomRight() ) );
- pDev->DrawRect( Rectangle( rRect.TopRight(), rRect.BottomRight() ) );
+ pDev->SetLineColor( rLeftTopColor );
+ pDev->DrawLine( rRect.TopLeft(), rRect.BottomLeft() );
+ pDev->DrawLine( rRect.TopLeft(), rRect.TopRight() );
+ pDev->SetLineColor( rRightBottomColor );
+ pDev->DrawLine( rRect.BottomLeft(), rRect.BottomRight() );
+ pDev->DrawLine( rRect.TopRight(), rRect.BottomRight() );
+
+ // reduce drawing area
+ ++rRect.Left();
+ ++rRect.Top();
+ --rRect.Right();
+ --rRect.Bottom();
}
@@ -609,13 +615,7 @@ void ImplDrawButton( OutputDevice *const pDev, Rectangle aFillRect,
aColor2 = rStyleSettings.GetDarkShadowColor();
}
- pDev->SetLineColor();
-
ImplDraw2ColorFrame( pDev, aFillRect, aColor1, aColor2 );
- ++aFillRect.Left();
- ++aFillRect.Top();
- --aFillRect.Right();
- --aFillRect.Bottom();
if ( !((nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT) )
{
@@ -633,14 +633,11 @@ void ImplDrawButton( OutputDevice *const pDev, Rectangle aFillRect,
aColor2 = rStyleSettings.GetShadowColor();
}
ImplDraw2ColorFrame( pDev, aFillRect, aColor1, aColor2 );
- ++aFillRect.Left();
- ++aFillRect.Top();
- --aFillRect.Right();
- --aFillRect.Bottom();
}
if ( !(nStyle & BUTTON_DRAW_NOFILL) )
{
+ pDev->SetLineColor();
if ( nStyle & (BUTTON_DRAW_CHECKED | BUTTON_DRAW_DONTKNOW) )
pDev->SetFillColor( rStyleSettings.GetCheckedColor() );
else
@@ -704,15 +701,12 @@ void DecorationView::DrawFrame( const Rectangle& rRect,
const Color& rLeftTopColor,
const Color& rRightBottomColor )
{
- Rectangle aRect = mpOutDev->LogicToPixel( rRect );
- Color aOldLineColor = mpOutDev->GetLineColor();
- Color aOldFillColor = mpOutDev->GetFillColor();
- sal_Bool bOldMapMode = mpOutDev->IsMapModeEnabled();
- mpOutDev->EnableMapMode( sal_False );
- mpOutDev->SetLineColor();
+ Rectangle aRect = mpOutDev->LogicToPixel( rRect );
+ const Color aOldLineColor = mpOutDev->GetLineColor();
+ const bool bOldMapMode = mpOutDev->IsMapModeEnabled();
+ mpOutDev->EnableMapMode( false );
ImplDraw2ColorFrame( mpOutDev, aRect, rLeftTopColor, rRightBottomColor );
mpOutDev->SetLineColor( aOldLineColor );
- mpOutDev->SetFillColor( aOldFillColor );
mpOutDev->EnableMapMode( bOldMapMode );
}
@@ -908,8 +902,6 @@ static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect,
}
else
{
- pDev->SetLineColor();
-
if ( (nFrameStyle == FRAME_DRAW_IN) ||
(nFrameStyle == FRAME_DRAW_OUT) )
{
@@ -925,11 +917,6 @@ static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect,
rStyleSettings.GetLightColor(),
rStyleSettings.GetShadowColor() );
}
-
- rRect.Left()++;
- rRect.Top()++;
- rRect.Right()--;
- rRect.Bottom()--;
}
else // FRAME_DRAW_DOUBLEIN || FRAME_DRAW_DOUBLEOUT
{
@@ -959,12 +946,6 @@ static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect,
}
- rRect.Left()++;
- rRect.Top()++;
- rRect.Right()--;
- rRect.Bottom()--;
-
- sal_Bool bDrawn = sal_True;
if ( nFrameStyle == FRAME_DRAW_DOUBLEIN )
{
if( bFlatBorders ) // no 3d effect
@@ -983,15 +964,6 @@ static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect,
ImplDraw2ColorFrame( pDev, rRect,
rStyleSettings.GetLightColor(),
rStyleSettings.GetShadowColor() );
- else
- bDrawn = sal_False;
- }
- if( bDrawn )
- {
- rRect.Left()++;
- rRect.Top()++;
- rRect.Right()--;
- rRect.Bottom()--;
}
}
}
--
1.7.5.4
Context
- [Libreoffice] [PATCH] Decoview cleanup #6 - take advantage of cleanup #5 for more cleanups · Matteo Casalin
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.