diff options
author | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2011-09-13 15:29:57 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2011-09-13 17:29:04 +0200 |
commit | e88eb733eda4fe3284d366a4cc0d20d3b1c80e85 (patch) | |
tree | 317c2d8b4b13c6e42febe80aa422092dea3a6fc9 | |
parent | 883991e8470075be1ade56595a90040d1ad64f6c (diff) |
Header/Footer: handle high contrast mode in Paint method
-rwxr-xr-x | sw/source/core/layout/paintfrm.cxx | 54 | ||||
-rw-r--r-- | sw/source/ui/docvw/HeaderFooterWin.cxx | 45 |
2 files changed, 63 insertions, 36 deletions
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index eee5966ea889..544d02b2d16d 100755 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -3279,39 +3279,50 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr const SwPageFrm* pPageFrm, double nLineY ) { // Adjust the Y-coordinate of the line to the header/footer box - drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 ); + drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 ); basegfx::B2DPoint aLeft ( pPageFrm->Frm().Left(), nLineY ); basegfx::B2DPoint aRight( pPageFrm->Frm().Right(), nLineY ); basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor(); - // Get a color for the contrast - basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor ); - double nLuminance = aHslLine.getZ() * 2.5; - if ( nLuminance == 0 ) - nLuminance = 0.5; - else if ( nLuminance >= 1.0 ) - nLuminance = aHslLine.getZ() * 0.4; - aHslLine.setZ( nLuminance ); - const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb( aHslLine ); - - // Compute the plain line + std::vector< double > aStrokePattern; basegfx::B2DPolygon aLinePolygon; aLinePolygon.append( aLeft ); aLinePolygon.append( aRight ); - drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pPlainLine = - new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( - aLinePolygon, aOtherColor ); + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + if ( rSettings.GetHighContrastMode( ) ) + { + // Only a solid line in high contrast mode + aLineColor = rSettings.GetDialogTextColor().getBColor(); + } + else + { + // Get a color for the contrast + basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor ); + double nLuminance = aHslLine.getZ() * 2.5; + if ( nLuminance == 0 ) + nLuminance = 0.5; + else if ( nLuminance >= 1.0 ) + nLuminance = aHslLine.getZ() * 0.4; + aHslLine.setZ( nLuminance ); + const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb( aHslLine ); + + // Compute the plain line + drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pPlainLine = + new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( + aLinePolygon, aOtherColor ); + + aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pPlainLine ); - aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pPlainLine ); + // Dashed line in twips + aStrokePattern.push_back( 40 ); + aStrokePattern.push_back( 40 ); - // Dashed line in twips - std::vector< double > aStrokePattern; - aStrokePattern.push_back( 40 ); - aStrokePattern.push_back( 40 ); + aSeq.realloc( 2 ); + } // Compute the dashed line primitive drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine = @@ -3320,7 +3331,8 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr drawinglayer::attribute::LineAttribute( aLineColor ), drawinglayer::attribute::StrokeAttribute( aStrokePattern ) ); - aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pLine ); + aSeq[ aSeq.getLength( ) - 1 ] = drawinglayer::primitive2d::Primitive2DReference( pLine ); + return aSeq; } diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx index edc09d880ffa..1f7bbaefb54b 100644 --- a/sw/source/ui/docvw/HeaderFooterWin.cxx +++ b/sw/source/ui/docvw/HeaderFooterWin.cxx @@ -79,25 +79,37 @@ namespace void lcl_DrawBackground( OutputDevice* pOut, const Rectangle& rRect, bool bHeader ) { - // Colors basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor(); - basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor ); - basegfx::BColor aLighterColor = lcl_GetLighterGradientColor( aFillColor ); - - // Draw the background gradient - Gradient aGradient; - if ( bHeader ) - aGradient = Gradient( GRADIENT_LINEAR, - Color( aLighterColor ), Color( aFillColor ) ); - else - aGradient = Gradient( GRADIENT_LINEAR, - Color( aFillColor ), Color( aLighterColor ) ); - pOut->DrawGradient( rRect, aGradient ); + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + if ( rSettings.GetHighContrastMode() ) + { + aLineColor = rSettings.GetDialogTextColor().getBColor(); - pOut->SetFillColor( Color ( aFillColor ) ); - pOut->SetLineColor( Color ( aFillColor ) ); + pOut->SetFillColor( rSettings.GetDialogColor( ) ); + pOut->SetLineColor( rSettings.GetDialogTextColor( ) ); + pOut->DrawRect( rRect ); + } + else + { + // Colors + basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor ); + basegfx::BColor aLighterColor = lcl_GetLighterGradientColor( aFillColor ); + // Draw the background gradient + Gradient aGradient; + if ( bHeader ) + aGradient = Gradient( GRADIENT_LINEAR, + Color( aLighterColor ), Color( aFillColor ) ); + else + aGradient = Gradient( GRADIENT_LINEAR, + Color( aFillColor ), Color( aLighterColor ) ); + + pOut->DrawGradient( rRect, aGradient ); + + pOut->SetFillColor( Color ( aFillColor ) ); + pOut->SetLineColor( Color ( aFillColor ) ); + } // Draw the lines around the rect pOut->SetLineColor( Color( aLineColor ) ); @@ -203,7 +215,10 @@ void SwHeaderFooterWin::Paint( const Rectangle& ) GetTextBoundRect( aTextRect, String( m_sLabel ) ); Point aTextPos = aTextRect.TopLeft() + Point( TEXT_PADDING, 0 ); + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor(); + if ( rSettings.GetHighContrastMode( ) ) + aLineColor = rSettings.GetDialogTextColor().getBColor(); SetTextColor( Color( aLineColor ) ); DrawText( aTextPos, String( m_sLabel ) ); |