Kaydet (Commit) 41df7db9 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor sw Sidebar classes to use RenderContext

Change-Id: I09a4abd8fb34470c4c365aa1f604accd80631ab3
üst 7587cf88
......@@ -182,7 +182,7 @@ class SwSidebarWin : public vcl::Window
protected:
virtual void DataChanged( const DataChangedEvent& aEvent) SAL_OVERRIDE;
virtual void LoseFocus() 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 GetFocus() SAL_OVERRIDE;
virtual VclPtr<MenuButton> CreateMenuButton() = 0;
......
......@@ -29,31 +29,30 @@ SwDashedLine::~SwDashedLine( )
{
}
void SwDashedLine::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
void SwDashedLine::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{
const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor(
drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
*this, aNewViewInfos ));
drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(rRenderContext, aNewViewInfos));
// Compute the start and end points
const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
double nHalfWidth = double( aRect.Top() + aRect.Bottom() ) / 2.0;
const Rectangle aRect(Rectangle(Point(0, 0), rRenderContext.PixelToLogic(GetSizePixel())));
double nHalfWidth = double(aRect.Top() + aRect.Bottom()) / 2.0;
basegfx::B2DPoint aStart( double( aRect.Left() ), nHalfWidth );
basegfx::B2DPoint aEnd( double( aRect.Right() ), nHalfWidth );
basegfx::B2DPoint aStart(double(aRect.Left()), nHalfWidth);
basegfx::B2DPoint aEnd(double(aRect.Right()), nHalfWidth);
basegfx::B2DPolygon aPolygon;
aPolygon.append( aStart );
aPolygon.append( aEnd );
aPolygon.append(aStart);
aPolygon.append(aEnd);
drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 );
drawinglayer::primitive2d::Primitive2DSequence aSeq(1);
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
std::vector< double > aStrokePattern;
std::vector<double> aStrokePattern;
basegfx::BColor aColor = m_pColorFn().getBColor();
if ( rSettings.GetHighContrastMode( ) )
if (rSettings.GetHighContrastMode())
{
// Only a solid line in high contrast mode
aColor = rSettings.GetDialogTextColor().getBColor();
......@@ -61,37 +60,36 @@ void SwDashedLine::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangl
else
{
// Get a color for the contrast
basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aColor );
basegfx::BColor aHslLine = basegfx::tools::rgb2hsl(aColor);
double nLuminance = aHslLine.getZ();
nLuminance += ( 1.0 - nLuminance ) * 0.75;
if ( aHslLine.getZ() > 0.7 )
nLuminance += (1.0 - nLuminance) * 0.75;
if (aHslLine.getZ() > 0.7)
nLuminance = aHslLine.getZ() * 0.7;
aHslLine.setZ( nLuminance );
const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb( aHslLine );
aHslLine.setZ(nLuminance);
const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb(aHslLine);
// Compute the plain line
drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pPlainLine =
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
aPolygon, aOtherColor );
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPolygon, aOtherColor);
aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pPlainLine );
aSeq[0] = drawinglayer::primitive2d::Primitive2DReference(pPlainLine);
// Dashed line in twips
aStrokePattern.push_back( 3 );
aStrokePattern.push_back( 3 );
aStrokePattern.push_back(3);
aStrokePattern.push_back(3);
aSeq.realloc( 2 );
aSeq.realloc(2);
}
// Compute the dashed line primitive
drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
basegfx::B2DPolyPolygon( aPolygon ),
drawinglayer::attribute::LineAttribute( m_pColorFn().getBColor() ),
drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(
basegfx::B2DPolyPolygon(aPolygon),
drawinglayer::attribute::LineAttribute(m_pColorFn().getBColor()),
drawinglayer::attribute::StrokeAttribute(aStrokePattern));
aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( pLine );
aSeq[aSeq.getLength() - 1] = drawinglayer::primitive2d::Primitive2DReference(pLine);
pProcessor->process( aSeq );
pProcessor->process(aSeq);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -135,86 +135,86 @@ void SwPageBreakWin::dispose()
MenuButton::dispose();
}
void SwPageBreakWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
void SwPageBreakWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{
const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
const Rectangle aRect(Rectangle(Point(0, 0), rRenderContext.PixelToLogic(GetSizePixel())));
// Properly paint the control
BColor aColor = SwViewOption::GetPageBreakColor().getBColor();
BColor aHslLine = rgb2hsl( aColor );
BColor aHslLine = rgb2hsl(aColor);
double nLuminance = aHslLine.getZ();
nLuminance += ( 1.0 - nLuminance ) * 0.75;
nLuminance += (1.0 - nLuminance) * 0.75;
if ( aHslLine.getZ() > 0.7 )
nLuminance = aHslLine.getZ() * 0.7;
aHslLine.setZ( nLuminance );
BColor aOtherColor = hsl2rgb( aHslLine );
aHslLine.setZ(nLuminance);
BColor aOtherColor = hsl2rgb(aHslLine);
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
if ( rSettings.GetHighContrastMode( ) )
if (rSettings.GetHighContrastMode())
{
aColor = rSettings.GetDialogTextColor().getBColor();
aOtherColor = rSettings.GetDialogColor( ).getBColor();
aOtherColor = rSettings.GetDialogColor().getBColor();
}
bool bRtl = AllSettings::GetLayoutRTL();
drawinglayer::primitive2d::Primitive2DSequence aSeq( 3 );
B2DRectangle aBRect( double( aRect.Left() ), double( aRect.Top( ) ),
double( aRect.Right() ), double( aRect.Bottom( ) ) );
B2DPolygon aPolygon = createPolygonFromRect( aBRect, 3.0 / BUTTON_WIDTH, 3.0 / BUTTON_HEIGHT );
drawinglayer::primitive2d::Primitive2DSequence aSeq(3);
B2DRectangle aBRect(double(aRect.Left()), double(aRect.Top()),
double(aRect.Right()), double(aRect.Bottom()));
B2DPolygon aPolygon = createPolygonFromRect(aBRect, 3.0 / BUTTON_WIDTH, 3.0 / BUTTON_HEIGHT);
// Create the polygon primitives
aSeq[0] = Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
B2DPolyPolygon( aPolygon ), aOtherColor ) );
aSeq[1] = Primitive2DReference( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
aPolygon, aColor ) );
aSeq[0] = Primitive2DReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
B2DPolyPolygon(aPolygon), aOtherColor));
aSeq[1] = Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
aPolygon, aColor));
// Create the primitive for the image
Image aImg( SW_RES( IMG_PAGE_BREAK ) );
Image aImg(SW_RES(IMG_PAGE_BREAK));
double nImgOfstX = 3.0;
if ( bRtl )
if (bRtl)
nImgOfstX = aRect.Right() - aImg.GetSizePixel().Width() - 3.0;
aSeq[2] = Primitive2DReference( new drawinglayer::primitive2d::DiscreteBitmapPrimitive2D(
aImg.GetBitmapEx(), B2DPoint( nImgOfstX, 1.0 ) ) );
aSeq[2] = Primitive2DReference(new drawinglayer::primitive2d::DiscreteBitmapPrimitive2D(
aImg.GetBitmapEx(), B2DPoint(nImgOfstX, 1.0)));
double nTop = double( aRect.getHeight() ) / 2.0;
double nTop = double(aRect.getHeight()) / 2.0;
double nBottom = nTop + 4.0;
double nLeft = aRect.getWidth( ) - ARROW_WIDTH - 6.0;
if ( bRtl )
double nLeft = aRect.getWidth() - ARROW_WIDTH - 6.0;
if (bRtl)
nLeft = ARROW_WIDTH - 2.0;
double nRight = nLeft + 8.0;
B2DPolygon aTriangle;
aTriangle.append( B2DPoint( nLeft, nTop ) );
aTriangle.append( B2DPoint( nRight, nTop ) );
aTriangle.append( B2DPoint( ( nLeft + nRight ) / 2.0, nBottom ) );
aTriangle.setClosed( true );
BColor aTriangleColor = Color( COL_BLACK ).getBColor( );
if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
aTriangleColor = Color( COL_WHITE ).getBColor( );
aSeq.realloc( aSeq.getLength() + 1 );
aSeq[ aSeq.getLength() - 1 ] = Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
B2DPolyPolygon( aTriangle ), aTriangleColor ) );
Primitive2DSequence aGhostedSeq( 1 );
double nFadeRate = double( m_nFadeRate ) / 100.0;
aTriangle.append(B2DPoint(nLeft, nTop));
aTriangle.append(B2DPoint(nRight, nTop));
aTriangle.append(B2DPoint((nLeft + nRight) / 2.0, nBottom));
aTriangle.setClosed(true);
BColor aTriangleColor = Color(COL_BLACK).getBColor();
if (Application::GetSettings().GetStyleSettings().GetHighContrastMode())
aTriangleColor = Color(COL_WHITE).getBColor();
aSeq.realloc(aSeq.getLength() + 1);
aSeq[aSeq.getLength() - 1] = Primitive2DReference(
new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
B2DPolyPolygon(aTriangle), aTriangleColor));
Primitive2DSequence aGhostedSeq(1);
double nFadeRate = double(m_nFadeRate) / 100.0;
const basegfx::BColorModifierSharedPtr aBColorModifier(
new basegfx::BColorModifier_interpolate(
Color( COL_WHITE ).getBColor(),
1.0 - nFadeRate));
aGhostedSeq[0] = Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
aSeq, aBColorModifier ) );
new basegfx::BColorModifier_interpolate(Color(COL_WHITE).getBColor(),
1.0 - nFadeRate));
aGhostedSeq[0] = Primitive2DReference(
new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
aSeq, aBColorModifier));
// Create the processor and process the primitives
const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor(
drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
*this, aNewViewInfos ));
drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(rRenderContext, aNewViewInfos));
pProcessor->process( aGhostedSeq );
pProcessor->process(aGhostedSeq);
}
void SwPageBreakWin::Select( )
......@@ -466,7 +466,7 @@ IMPL_LINK_NOARG_TYPED(SwPageBreakWin, FadeHandler, Timer *, void)
Invalidate();
}
if ( IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100 )
if (IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100)
m_aFadeTimer.Start();
}
......
......@@ -151,43 +151,37 @@ void SidebarTxtControl::Draw(OutputDevice* pDev, const Point& rPt, const Size& r
}
}
void SidebarTxtControl::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect)
void SidebarTxtControl::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
{
if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
if (!rRenderContext.GetSettings().GetStyleSettings().GetHighContrastMode())
{
if ( mrSidebarWin.IsMouseOverSidebarWin() ||
HasFocus() )
if (mrSidebarWin.IsMouseOverSidebarWin() || HasFocus())
{
DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ),
Gradient( GradientStyle_LINEAR,
mrSidebarWin.ColorDark(),
mrSidebarWin.ColorDark() ) );
rRenderContext.DrawGradient(Rectangle(Point(0,0), rRenderContext.PixelToLogic(GetSizePixel())),
Gradient(GradientStyle_LINEAR, mrSidebarWin.ColorDark(), mrSidebarWin.ColorDark()));
}
else
{
DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ),
Gradient( GradientStyle_LINEAR,
mrSidebarWin.ColorLight(),
mrSidebarWin.ColorDark()));
rRenderContext.DrawGradient(Rectangle(Point(0,0), rRenderContext.PixelToLogic(GetSizePixel())),
Gradient(GradientStyle_LINEAR, mrSidebarWin.ColorLight(), mrSidebarWin.ColorDark()));
}
}
if ( GetTextView() )
if (GetTextView())
{
GetTextView()->Paint( rRect );
GetTextView()->Paint(rRect, &rRenderContext);
}
if ( mrSidebarWin.GetLayoutStatus()==SwPostItHelper::DELETED )
if (mrSidebarWin.GetLayoutStatus() == SwPostItHelper::DELETED)
{
SetLineColor(mrSidebarWin.GetChangeColor());
DrawLine( PixelToLogic( GetPosPixel() ),
PixelToLogic( GetPosPixel() +
Point( GetSizePixel().Width(),
GetSizePixel().Height() ) ) );
DrawLine( PixelToLogic( GetPosPixel() +
Point( GetSizePixel().Width(),0) ),
PixelToLogic( GetPosPixel() +
Point( 0, GetSizePixel().Height() ) ) );
rRenderContext.SetLineColor(mrSidebarWin.GetChangeColor());
rRenderContext.DrawLine(rRenderContext.PixelToLogic(GetPosPixel()),
rRenderContext.PixelToLogic(GetPosPixel() + Point(GetSizePixel().Width(),
GetSizePixel().Height())));
rRenderContext.DrawLine(rRenderContext.PixelToLogic(GetPosPixel() + Point(GetSizePixel().Width(),
0)),
rRenderContext.PixelToLogic(GetPosPixel() + Point(0,
GetSizePixel().Height())));
}
}
......
......@@ -89,14 +89,14 @@ namespace sw { namespace sidebarwindows {
#define POSTIT_META_HEIGHT (sal_Int32) 30
#define POSTIT_MINIMUMSIZE_WITHOUT_META 50
SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin,
WinBits nBits,
SwPostItMgr& aMgr,
SwPostItBits aBits,
SwSidebarItem& rSidebarItem )
SwSidebarWin::SwSidebarWin(SwEditWin& rEditWin,
WinBits nBits,
SwPostItMgr& aMgr,
SwPostItBits aBits,
SwSidebarItem& rSidebarItem)
: Window(&rEditWin, nBits)
, mrMgr(aMgr)
, mrView( rEditWin.GetView() )
, mrView(rEditWin.GetView())
, nFlags(aBits)
, mnEventId(0)
, mpOutlinerView(0)
......@@ -106,23 +106,23 @@ SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin,
, mpMetadataAuthor(0)
, mpMetadataDate(0)
, mpMenuButton(0)
, mpAnchor( NULL )
, mpShadow( NULL )
, mpTextRangeOverlay( NULL )
, mpAnchor(NULL)
, mpShadow(NULL)
, mpTextRangeOverlay(NULL)
, mColorAnchor()
, mColorDark()
, mColorLight()
, mChangeColor()
, meSidebarPosition( sw::sidebarwindows::SidebarPosition::NONE )
, meSidebarPosition(sw::sidebarwindows::SidebarPosition::NONE)
, mPosSize()
, mAnchorRect()
, mPageBorder( 0 )
, mbMouseOver( false )
, mLayoutStatus( SwPostItHelper::INVISIBLE )
, mbReadonly( false )
, mbIsFollow( false )
, mrSidebarItem( rSidebarItem )
, mpAnchorFrm( rSidebarItem.maLayoutInfo.mpAnchorFrm )
, mPageBorder(0)
, mbMouseOver(false)
, mLayoutStatus(SwPostItHelper::INVISIBLE)
, mbReadonly(false)
, mbIsFollow(false)
, mrSidebarItem(rSidebarItem)
, mpAnchorFrm(rSidebarItem.maLayoutInfo.mpAnchorFrm)
{
mpShadow = ShadowOverlayObject::CreateShadowOverlayObject( mrView );
if ( mpShadow )
......@@ -208,29 +208,29 @@ void SwSidebarWin::dispose()
vcl::Window::dispose();
}
void SwSidebarWin::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect)
void SwSidebarWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
{
Window::Paint(rRenderContext, rRect);
if (mpMetadataAuthor->IsVisible() )
if (mpMetadataAuthor->IsVisible())
{
//draw left over space
if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
if (Application::GetSettings().GetStyleSettings().GetHighContrastMode())
{
SetFillColor(COL_BLACK);
rRenderContext.SetFillColor(COL_BLACK);
}
else
{
SetFillColor(mColorDark);
rRenderContext.SetFillColor(mColorDark);
}
SetLineColor();
DrawRect( PixelToLogic(
Rectangle( Point( mpMetadataAuthor->GetPosPixel().X() +
mpMetadataAuthor->GetSizePixel().Width(),
mpMetadataAuthor->GetPosPixel().Y() ),
Size( GetMetaButtonAreaWidth(),
mpMetadataAuthor->GetSizePixel().Height() +
mpMetadataDate->GetSizePixel().Height() ) ) ) );
rRenderContext.SetLineColor();
Rectangle aRectangle(Point(mpMetadataAuthor->GetPosPixel().X() + mpMetadataAuthor->GetSizePixel().Width(),
mpMetadataAuthor->GetPosPixel().Y()),
Size(GetMetaButtonAreaWidth(),
mpMetadataAuthor->GetSizePixel().Height() + mpMetadataDate->GetSizePixel().Height()));
rRenderContext.DrawRect(PixelToLogic(aRectangle));
}
}
......@@ -302,12 +302,8 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, s
}
}
void SwSidebarWin::SetPosSizePixelRect( long nX,
long nY,
long nWidth,
long nHeight,
const SwRect& aAnchorRect,
const long aPageBorder)
void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight,
const SwRect& aAnchorRect, const long aPageBorder)
{
mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight));
mAnchorRect = aAnchorRect;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment