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 ...@@ -182,7 +182,7 @@ class SwSidebarWin : public vcl::Window
protected: protected:
virtual void DataChanged( const DataChangedEvent& aEvent) SAL_OVERRIDE; virtual void DataChanged( const DataChangedEvent& aEvent) SAL_OVERRIDE;
virtual void LoseFocus() 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 void GetFocus() SAL_OVERRIDE;
virtual VclPtr<MenuButton> CreateMenuButton() = 0; virtual VclPtr<MenuButton> CreateMenuButton() = 0;
......
...@@ -36,24 +36,22 @@ ...@@ -36,24 +36,22 @@
namespace sw { namespace annotation { namespace sw { namespace annotation {
Color ColorFromAlphaColor( const sal_uInt8 aTransparency, Color ColorFromAlphaColor(const sal_uInt8 aTransparency, const Color& aFront, const Color& aBack)
const Color &aFront,
const Color &aBack )
{ {
return Color((sal_uInt8)(aFront.GetRed() * aTransparency/(double)255 + aBack.GetRed() * (1-aTransparency/(double)255)), return Color(sal_uInt8(aFront.GetRed() * aTransparency / 255.0 + aBack.GetRed() * (1 - aTransparency / 255.0)),
(sal_uInt8)(aFront.GetGreen() * aTransparency/(double)255 + aBack.GetGreen() * (1-aTransparency/(double)255)), sal_uInt8(aFront.GetGreen() * aTransparency / 255.0 + aBack.GetGreen() * (1 - aTransparency / 255.0)),
(sal_uInt8)(aFront.GetBlue() * aTransparency/(double)255 + aBack.GetBlue() * (1-aTransparency/(double)255))); sal_uInt8(aFront.GetBlue() * aTransparency / 255.0 + aBack.GetBlue() * (1 - aTransparency / 255.0)));
} }
AnnotationMenuButton::AnnotationMenuButton( sw::sidebarwindows::SwSidebarWin& rSidebarWin ) AnnotationMenuButton::AnnotationMenuButton(sw::sidebarwindows::SwSidebarWin& rSidebarWin)
: MenuButton( &rSidebarWin ) : MenuButton(&rSidebarWin)
, mrSidebarWin( rSidebarWin ) , mrSidebarWin(rSidebarWin)
{ {
AddEventListener( LINK( &mrSidebarWin, sw::sidebarwindows::SwSidebarWin, WindowEventListener ) ); AddEventListener(LINK(&mrSidebarWin, sw::sidebarwindows::SwSidebarWin, WindowEventListener));
SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_BUTTON_NAME ) ); SetAccessibleName(SW_RES(STR_ACCESS_ANNOTATION_BUTTON_NAME));
SetAccessibleDescription( SW_RES( STR_ACCESS_ANNOTATION_BUTTON_DESC ) ); SetAccessibleDescription(SW_RES(STR_ACCESS_ANNOTATION_BUTTON_DESC));
SetQuickHelpText( GetAccessibleDescription() ); SetQuickHelpText(GetAccessibleDescription());
} }
AnnotationMenuButton::~AnnotationMenuButton() AnnotationMenuButton::~AnnotationMenuButton()
...@@ -63,7 +61,7 @@ AnnotationMenuButton::~AnnotationMenuButton() ...@@ -63,7 +61,7 @@ AnnotationMenuButton::~AnnotationMenuButton()
void AnnotationMenuButton::dispose() void AnnotationMenuButton::dispose()
{ {
RemoveEventListener( LINK( &mrSidebarWin, sw::sidebarwindows::SwSidebarWin, WindowEventListener ) ); RemoveEventListener(LINK(&mrSidebarWin, sw::sidebarwindows::SwSidebarWin, WindowEventListener));
MenuButton::dispose(); MenuButton::dispose();
} }
...@@ -74,138 +72,135 @@ void AnnotationMenuButton::Select() ...@@ -74,138 +72,135 @@ void AnnotationMenuButton::Select()
void AnnotationMenuButton::MouseButtonDown( const MouseEvent& rMEvt ) void AnnotationMenuButton::MouseButtonDown( const MouseEvent& rMEvt )
{ {
PopupMenu* pButtonPopup( GetPopupMenu() ); PopupMenu* pButtonPopup(GetPopupMenu());
if ( mrSidebarWin.IsReadOnly() ) if (mrSidebarWin.IsReadOnly())
{ {
pButtonPopup->EnableItem( FN_REPLY, false ); pButtonPopup->EnableItem(FN_REPLY, false );
pButtonPopup->EnableItem( FN_DELETE_COMMENT, false ); pButtonPopup->EnableItem(FN_DELETE_COMMENT, false );
pButtonPopup->EnableItem( FN_DELETE_NOTE_AUTHOR, false ); pButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR, false );
pButtonPopup->EnableItem( FN_DELETE_ALL_NOTES, false ); pButtonPopup->EnableItem(FN_DELETE_ALL_NOTES, false );
pButtonPopup->EnableItem( FN_FORMAT_ALL_NOTES, false ); pButtonPopup->EnableItem(FN_FORMAT_ALL_NOTES, false );
} }
else else
{ {
pButtonPopup->EnableItem( FN_DELETE_COMMENT, !mrSidebarWin.IsProtected() ); pButtonPopup->EnableItem(FN_DELETE_COMMENT, !mrSidebarWin.IsProtected() );
pButtonPopup->EnableItem( FN_DELETE_NOTE_AUTHOR, true ); pButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR, true );
pButtonPopup->EnableItem( FN_DELETE_ALL_NOTES, true ); pButtonPopup->EnableItem(FN_DELETE_ALL_NOTES, true );
pButtonPopup->EnableItem( FN_FORMAT_ALL_NOTES, true ); pButtonPopup->EnableItem(FN_FORMAT_ALL_NOTES, true );
} }
if ( mrSidebarWin.IsProtected() ) if (mrSidebarWin.IsProtected())
{ {
pButtonPopup->EnableItem( FN_REPLY, false ); pButtonPopup->EnableItem(FN_REPLY, false);
} }
else else
{ {
SvtUserOptions aUserOpt; SvtUserOptions aUserOpt;
OUString sAuthor; OUString sAuthor;
if ( (sAuthor = aUserOpt.GetFullName()).isEmpty() ) if ((sAuthor = aUserOpt.GetFullName()).isEmpty())
{ {
if ( (sAuthor = aUserOpt.GetID()).isEmpty() ) if ((sAuthor = aUserOpt.GetID()).isEmpty())
{ {
sAuthor = SW_RES( STR_REDLINE_UNKNOWN_AUTHOR ); sAuthor = SW_RES(STR_REDLINE_UNKNOWN_AUTHOR);
} }
} }
// do not allow to reply to ourself and no answer possible if this note is in a protected section // do not allow to reply to ourself and no answer possible if this note is in a protected section
if ( sAuthor == mrSidebarWin.GetAuthor() ) if (sAuthor == mrSidebarWin.GetAuthor())
{ {
pButtonPopup->EnableItem( FN_REPLY, false ); pButtonPopup->EnableItem(FN_REPLY, false);
} }
else else
{ {
pButtonPopup->EnableItem( FN_REPLY, true ); pButtonPopup->EnableItem(FN_REPLY, true);
} }
} }
MenuButton::MouseButtonDown( rMEvt ); MenuButton::MouseButtonDown(rMEvt);
} }
void AnnotationMenuButton::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& /*rRect*/ ) void AnnotationMenuButton::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
{ {
if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) bool bHighContrast = rRenderContext.GetSettings().GetStyleSettings().GetHighContrastMode();
SetFillColor(COL_BLACK);
if (bHighContrast)
rRenderContext.SetFillColor(COL_BLACK);
else else
SetFillColor( mrSidebarWin.ColorDark() ); rRenderContext.SetFillColor(mrSidebarWin.ColorDark());
SetLineColor(); rRenderContext.SetLineColor();
const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) ); const Rectangle aRect(Rectangle(Point(0, 0), rRenderContext.PixelToLogic(GetSizePixel())));
DrawRect( aRect ); rRenderContext.DrawRect(aRect);
if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode()) if (bHighContrast)
{ {
//draw rect around button //draw rect around button
SetFillColor(COL_BLACK); rRenderContext.SetFillColor(COL_BLACK);
SetLineColor(COL_WHITE); rRenderContext.SetLineColor(COL_WHITE);
} }
else else
{ {
//draw button //draw button
Gradient aGradient; Gradient aGradient;
if ( IsMouseOver() ) if (IsMouseOver())
aGradient = Gradient( GradientStyle_LINEAR, aGradient = Gradient(GradientStyle_LINEAR,
ColorFromAlphaColor( 80, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ), ColorFromAlphaColor(80, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark()),
ColorFromAlphaColor( 15, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() )); ColorFromAlphaColor(15, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark()));
else else
aGradient = Gradient( GradientStyle_LINEAR, aGradient = Gradient(GradientStyle_LINEAR,
ColorFromAlphaColor( 15, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() ), ColorFromAlphaColor(15, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark()),
ColorFromAlphaColor( 80, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() )); ColorFromAlphaColor(80, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark()));
DrawGradient( aRect, aGradient ); rRenderContext.DrawGradient(aRect, aGradient);
//draw rect around button //draw rect around button
SetFillColor(); rRenderContext.SetFillColor();
SetLineColor( ColorFromAlphaColor( 90, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark() )); rRenderContext.SetLineColor(ColorFromAlphaColor(90, mrSidebarWin.ColorAnchor(), mrSidebarWin.ColorDark()));
} }
DrawRect( aRect ); rRenderContext.DrawRect(aRect);
if ( mrSidebarWin.IsPreview() ) if (mrSidebarWin.IsPreview())
{ {
vcl::Font aOldFont( mrSidebarWin.GetFont() ); vcl::Font aOldFont(mrSidebarWin.GetFont());
vcl::Font aFont(aOldFont); vcl::Font aFont(aOldFont);
Color aCol( COL_BLACK); Color aCol(COL_BLACK);
aFont.SetColor( aCol ); aFont.SetColor(aCol);
aFont.SetHeight(200); aFont.SetHeight(200);
aFont.SetWeight(WEIGHT_MEDIUM); aFont.SetWeight(WEIGHT_MEDIUM);
SetFont( aFont ); rRenderContext.SetFont(aFont);
DrawText( aRect , rRenderContext.DrawText(aRect, OUString("Edit Note"), TEXT_DRAW_CENTER);
OUString("Edit Note"), rRenderContext.SetFont(aOldFont);
TEXT_DRAW_CENTER );
SetFont( aOldFont );
} }
else else
{ {
Rectangle aSymbolRect( aRect ); Rectangle aSymbolRect(aRect);
// 25% distance to the left and right button border // 25% distance to the left and right button border
const long nBorderDistanceLeftAndRight = ((aSymbolRect.GetWidth()*250)+500)/1000; const long nBorderDistanceLeftAndRight = ((aSymbolRect.GetWidth() * 250) + 500) / 1000;
aSymbolRect.Left()+=nBorderDistanceLeftAndRight; aSymbolRect.Left() += nBorderDistanceLeftAndRight;
aSymbolRect.Right()-=nBorderDistanceLeftAndRight; aSymbolRect.Right() -= nBorderDistanceLeftAndRight;
// 40% distance to the top button border // 40% distance to the top button border
const long nBorderDistanceTop = ((aSymbolRect.GetHeight()*400)+500)/1000; const long nBorderDistanceTop = ((aSymbolRect.GetHeight() * 400) + 500) / 1000;
aSymbolRect.Top()+=nBorderDistanceTop; aSymbolRect.Top()+=nBorderDistanceTop;
// 15% distance to the bottom button border // 15% distance to the bottom button border
const long nBorderDistanceBottom = ((aSymbolRect.GetHeight()*150)+500)/1000; const long nBorderDistanceBottom = ((aSymbolRect.GetHeight() * 150) + 500) / 1000;
aSymbolRect.Bottom()-=nBorderDistanceBottom; aSymbolRect.Bottom() -= nBorderDistanceBottom;
DecorationView aDecoView( this ); DecorationView aDecoView(&rRenderContext);
aDecoView.DrawSymbol( aSymbolRect, SymbolType::SPIN_DOWN, aDecoView.DrawSymbol(aSymbolRect, SymbolType::SPIN_DOWN, (bHighContrast ? Color(COL_WHITE) : Color(COL_BLACK)));
( Application::GetSettings().GetStyleSettings().GetHighContrastMode()
? Color( COL_WHITE )
: Color( COL_BLACK ) ) );
} }
} }
void AnnotationMenuButton::KeyInput( const KeyEvent& rKeyEvt ) void AnnotationMenuButton::KeyInput(const KeyEvent& rKeyEvt)
{ {
const vcl::KeyCode& rKeyCode = rKeyEvt.GetKeyCode(); const vcl::KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
const sal_uInt16 nKey = rKeyCode.GetCode(); const sal_uInt16 nKey = rKeyCode.GetCode();
if ( nKey == KEY_TAB ) if (nKey == KEY_TAB)
{ {
mrSidebarWin.ActivatePostIt(); mrSidebarWin.ActivatePostIt();
mrSidebarWin.GrabFocus(); mrSidebarWin.GrabFocus();
} }
else else
{ {
MenuButton::KeyInput( rKeyEvt ); MenuButton::KeyInput(rKeyEvt);
} }
} }
} } // end of namespace sw::annotation }} // end of namespace sw::annotation
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -29,31 +29,30 @@ SwDashedLine::~SwDashedLine( ) ...@@ -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; const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor( boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor(
drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice( drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(rRenderContext, aNewViewInfos));
*this, aNewViewInfos ));
// Compute the start and end points // Compute the start and end points
const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) ); const Rectangle aRect(Rectangle(Point(0, 0), rRenderContext.PixelToLogic(GetSizePixel())));
double nHalfWidth = double( aRect.Top() + aRect.Bottom() ) / 2.0; double nHalfWidth = double(aRect.Top() + aRect.Bottom()) / 2.0;
basegfx::B2DPoint aStart( double( aRect.Left() ), nHalfWidth ); basegfx::B2DPoint aStart(double(aRect.Left()), nHalfWidth);
basegfx::B2DPoint aEnd( double( aRect.Right() ), nHalfWidth ); basegfx::B2DPoint aEnd(double(aRect.Right()), nHalfWidth);
basegfx::B2DPolygon aPolygon; basegfx::B2DPolygon aPolygon;
aPolygon.append( aStart ); aPolygon.append(aStart);
aPolygon.append( aEnd ); aPolygon.append(aEnd);
drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 ); drawinglayer::primitive2d::Primitive2DSequence aSeq(1);
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
std::vector< double > aStrokePattern; std::vector<double> aStrokePattern;
basegfx::BColor aColor = m_pColorFn().getBColor(); basegfx::BColor aColor = m_pColorFn().getBColor();
if ( rSettings.GetHighContrastMode( ) ) if (rSettings.GetHighContrastMode())
{ {
// Only a solid line in high contrast mode // Only a solid line in high contrast mode
aColor = rSettings.GetDialogTextColor().getBColor(); aColor = rSettings.GetDialogTextColor().getBColor();
...@@ -61,37 +60,36 @@ void SwDashedLine::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangl ...@@ -61,37 +60,36 @@ void SwDashedLine::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangl
else else
{ {
// Get a color for the contrast // Get a color for the contrast
basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aColor ); basegfx::BColor aHslLine = basegfx::tools::rgb2hsl(aColor);
double nLuminance = aHslLine.getZ(); double nLuminance = aHslLine.getZ();
nLuminance += ( 1.0 - nLuminance ) * 0.75; nLuminance += (1.0 - nLuminance) * 0.75;
if ( aHslLine.getZ() > 0.7 ) if (aHslLine.getZ() > 0.7)
nLuminance = aHslLine.getZ() * 0.7; nLuminance = aHslLine.getZ() * 0.7;
aHslLine.setZ( nLuminance ); aHslLine.setZ(nLuminance);
const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb( aHslLine ); const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb(aHslLine);
// Compute the plain line // Compute the plain line
drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pPlainLine = drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pPlainLine =
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPolygon, aOtherColor);
aPolygon, aOtherColor );
aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pPlainLine ); aSeq[0] = drawinglayer::primitive2d::Primitive2DReference(pPlainLine);
// Dashed line in twips // 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 // Compute the dashed line primitive
drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine = drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D ( new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(
basegfx::B2DPolyPolygon( aPolygon ), basegfx::B2DPolyPolygon(aPolygon),
drawinglayer::attribute::LineAttribute( m_pColorFn().getBColor() ), drawinglayer::attribute::LineAttribute(m_pColorFn().getBColor()),
drawinglayer::attribute::StrokeAttribute( aStrokePattern ) ); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -136,35 +136,32 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag ...@@ -136,35 +136,32 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
m_aFadeTimer( ) m_aFadeTimer( )
{ {
// Get the font and configure it // Get the font and configure it
vcl::Font aFont = GetSettings().GetStyleSettings().GetToolFont(); vcl::Font aFont = Application::GetSettings().GetStyleSettings().GetToolFont();
SetZoomedPointFont( aFont ); SetZoomedPointFont(aFont);
// Use pixels for the rest of the drawing
SetMapMode( MapMode ( MAP_PIXEL ) );
// Create the line control // Create the line control
m_pLine = VclPtr<SwDashedLine>::Create( GetEditWin(), &SwViewOption::GetHeaderFooterMarkColor ); m_pLine = VclPtr<SwDashedLine>::Create(GetEditWin(), &SwViewOption::GetHeaderFooterMarkColor);
m_pLine->SetZOrder( this, WINDOW_ZORDER_BEFOR ); m_pLine->SetZOrder(this, WINDOW_ZORDER_BEFOR);
// Create and set the PopupMenu // Create and set the PopupMenu
m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) ); m_pPopupMenu = new PopupMenu(SW_RES(MN_HEADERFOOTER_BUTTON));
// Rewrite the menu entries' text // Rewrite the menu entries' text
if ( m_bIsHeader ) if (m_bIsHeader)
{ {
m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, SW_RESSTR( STR_FORMAT_HEADER ) ); m_pPopupMenu->SetItemText(FN_HEADERFOOTER_EDIT, SW_RESSTR(STR_FORMAT_HEADER));
m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, SW_RESSTR( STR_DELETE_HEADER ) ); m_pPopupMenu->SetItemText(FN_HEADERFOOTER_DELETE, SW_RESSTR(STR_DELETE_HEADER));
} }
else else
{ {
m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, SW_RESSTR( STR_FORMAT_FOOTER ) ); m_pPopupMenu->SetItemText(FN_HEADERFOOTER_EDIT, SW_RESSTR(STR_FORMAT_FOOTER));
m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, SW_RESSTR( STR_DELETE_FOOTER ) ); m_pPopupMenu->SetItemText(FN_HEADERFOOTER_DELETE, SW_RESSTR(STR_DELETE_FOOTER));
} }
SetPopupMenu( m_pPopupMenu ); SetPopupMenu(m_pPopupMenu);
m_aFadeTimer.SetTimeout( 50 ); m_aFadeTimer.SetTimeout(50);
m_aFadeTimer.SetTimeoutHdl( LINK( this, SwHeaderFooterWin, FadeHandler ) ); m_aFadeTimer.SetTimeoutHdl(LINK(this, SwHeaderFooterWin, FadeHandler));
} }
SwHeaderFooterWin::~SwHeaderFooterWin( ) SwHeaderFooterWin::~SwHeaderFooterWin( )
...@@ -184,148 +181,146 @@ const SwPageFrm* SwHeaderFooterWin::GetPageFrame( ) ...@@ -184,148 +181,146 @@ const SwPageFrm* SwHeaderFooterWin::GetPageFrame( )
return static_cast< const SwPageFrm * >( GetFrame( ) ); return static_cast< const SwPageFrm * >( GetFrame( ) );
} }
void SwHeaderFooterWin::SetOffset( Point aOffset, long nXLineStart, long nXLineEnd ) void SwHeaderFooterWin::SetOffset(Point aOffset, long nXLineStart, long nXLineEnd)
{ {
// Compute the text to show // Compute the text to show
const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc(); const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
bool bIsFirst = !pDesc->IsFirstShared() && GetPageFrame()->OnFirstPage(); bool bIsFirst = !pDesc->IsFirstShared() && GetPageFrame()->OnFirstPage();
bool bIsLeft = !pDesc->IsHeaderShared() && !GetPageFrame()->OnRightPage(); bool bIsLeft = !pDesc->IsHeaderShared() && !GetPageFrame()->OnRightPage();
bool bIsRight = !pDesc->IsHeaderShared() && GetPageFrame()->OnRightPage(); bool bIsRight = !pDesc->IsHeaderShared() && GetPageFrame()->OnRightPage();
m_sLabel = SW_RESSTR( STR_HEADER_TITLE ); m_sLabel = SW_RESSTR(STR_HEADER_TITLE);
if ( !m_bIsHeader ) if (!m_bIsHeader)
m_sLabel = bIsFirst ? SW_RESSTR( STR_FIRST_FOOTER_TITLE ) m_sLabel = bIsFirst ? SW_RESSTR(STR_FIRST_FOOTER_TITLE)
: bIsLeft ? SW_RESSTR( STR_LEFT_FOOTER_TITLE ) : bIsLeft ? SW_RESSTR(STR_LEFT_FOOTER_TITLE)
: bIsRight ? SW_RESSTR( STR_RIGHT_FOOTER_TITLE ) : bIsRight ? SW_RESSTR(STR_RIGHT_FOOTER_TITLE)
: SW_RESSTR( STR_FOOTER_TITLE ); : SW_RESSTR(STR_FOOTER_TITLE );
else else
m_sLabel = bIsFirst ? SW_RESSTR( STR_FIRST_HEADER_TITLE ) m_sLabel = bIsFirst ? SW_RESSTR(STR_FIRST_HEADER_TITLE)
: bIsLeft ? SW_RESSTR( STR_LEFT_HEADER_TITLE ) : bIsLeft ? SW_RESSTR(STR_LEFT_HEADER_TITLE)
: bIsRight ? SW_RESSTR( STR_RIGHT_HEADER_TITLE ) : bIsRight ? SW_RESSTR(STR_RIGHT_HEADER_TITLE)
: SW_RESSTR( STR_HEADER_TITLE ); : SW_RESSTR(STR_HEADER_TITLE);
sal_Int32 nPos = m_sLabel.lastIndexOf( "%1" ); sal_Int32 nPos = m_sLabel.lastIndexOf("%1");
m_sLabel = m_sLabel.replaceAt( nPos, 2, pDesc->GetName() ); m_sLabel = m_sLabel.replaceAt(nPos, 2, pDesc->GetName());
// Compute the text size and get the box position & size from it // Compute the text size and get the box position & size from it
Rectangle aTextRect; Rectangle aTextRect;
GetTextBoundRect( aTextRect, OUString( m_sLabel ) ); GetTextBoundRect(aTextRect, OUString(m_sLabel));
Rectangle aTextPxRect = LogicToPixel( aTextRect ); Rectangle aTextPxRect = LogicToPixel(aTextRect);
FontMetric aFontMetric = GetFontMetric( GetFont() ); FontMetric aFontMetric = GetFontMetric(GetFont());
Size aBoxSize ( aTextPxRect.GetWidth() + BUTTON_WIDTH + TEXT_PADDING * 2, Size aBoxSize (aTextPxRect.GetWidth() + BUTTON_WIDTH + TEXT_PADDING * 2,
aFontMetric.GetLineHeight() + TEXT_PADDING * 2 ); aFontMetric.GetLineHeight() + TEXT_PADDING * 2 );
long nYFooterOff = 0; long nYFooterOff = 0;
if ( !m_bIsHeader ) if (!m_bIsHeader)
nYFooterOff = aBoxSize.Height(); nYFooterOff = aBoxSize.Height();
Point aBoxPos( aOffset.X() - aBoxSize.Width() - BOX_DISTANCE, Point aBoxPos(aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
aOffset.Y() - nYFooterOff ); aOffset.Y() - nYFooterOff);
if ( AllSettings::GetLayoutRTL() ) if (AllSettings::GetLayoutRTL())
{ {
aBoxPos.setX( aOffset.X() + BOX_DISTANCE ); aBoxPos.setX( aOffset.X() + BOX_DISTANCE );
} }
// Set the position & Size of the window // Set the position & Size of the window
SetPosSizePixel( aBoxPos, aBoxSize ); SetPosSizePixel(aBoxPos, aBoxSize);
double nYLinePos = aBoxPos.Y(); double nYLinePos = aBoxPos.Y();
if ( !m_bIsHeader ) if (!m_bIsHeader)
nYLinePos += aBoxSize.Height(); nYLinePos += aBoxSize.Height();
Point aLinePos( nXLineStart, nYLinePos ); Point aLinePos(nXLineStart, nYLinePos);
Size aLineSize( nXLineEnd - nXLineStart, 1 ); Size aLineSize(nXLineEnd - nXLineStart, 1);
m_pLine->SetPosSizePixel( aLinePos, aLineSize ); m_pLine->SetPosSizePixel(aLinePos, aLineSize);
} }
void SwHeaderFooterWin::ShowAll( bool bShow ) void SwHeaderFooterWin::ShowAll(bool bShow)
{ {
if ( !PopupMenu::IsInExecute() ) if (!PopupMenu::IsInExecute())
{ {
m_bIsAppearing = bShow; m_bIsAppearing = bShow;
if ( m_aFadeTimer.IsActive( ) ) if (m_aFadeTimer.IsActive())
m_aFadeTimer.Stop(); m_aFadeTimer.Stop();
m_aFadeTimer.Start( ); m_aFadeTimer.Start();
} }
} }
bool SwHeaderFooterWin::Contains( const Point &rDocPt ) const bool SwHeaderFooterWin::Contains( const Point &rDocPt ) const
{ {
Rectangle aRect( GetPosPixel(), GetSizePixel() ); Rectangle aRect(GetPosPixel(), GetSizePixel());
if ( aRect.IsInside( rDocPt ) ) if (aRect.IsInside(rDocPt))
return true; return true;
Rectangle aLineRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() ); Rectangle aLineRect(m_pLine->GetPosPixel(), m_pLine->GetSizePixel());
if ( aLineRect.IsInside( rDocPt ) ) if (aLineRect.IsInside(rDocPt))
return true; return true;
return false; return false;
} }
void SwHeaderFooterWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& ) void SwHeaderFooterWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{ {
const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) ); // Use pixels for the rest of the drawing
drawinglayer::primitive2d::Primitive2DSequence aSeq( 3 ); SetMapMode(MapMode(MAP_PIXEL));
B2DPolygon aPolygon = lcl_GetPolygon( aRect, m_bIsHeader ); const Rectangle aRect(Rectangle(Point(0, 0), rRenderContext.PixelToLogic(GetSizePixel())));
drawinglayer::primitive2d::Primitive2DSequence aSeq(3);
B2DPolygon aPolygon = lcl_GetPolygon(aRect, m_bIsHeader);
// Colors // Colors
basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor(); basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor ); basegfx::BColor aFillColor = lcl_GetFillColor(aLineColor);
basegfx::BColor aLighterColor = lcl_GetLighterGradientColor( aFillColor ); basegfx::BColor aLighterColor = lcl_GetLighterGradientColor(aFillColor);
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
if ( rSettings.GetHighContrastMode() ) if (rSettings.GetHighContrastMode())
{ {
aFillColor = rSettings.GetDialogColor( ).getBColor(); aFillColor = rSettings.GetDialogColor().getBColor();
aLineColor = rSettings.GetDialogTextColor( ).getBColor(); aLineColor = rSettings.GetDialogTextColor().getBColor();
aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( aSeq[0] = drawinglayer::primitive2d::Primitive2DReference(
B2DPolyPolygon( aPolygon ), aFillColor ) ); new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), aFillColor));
} }
else else
{ {
B2DRectangle aGradientRect( aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom() ); B2DRectangle aGradientRect(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom());
double nAngle = M_PI; double nAngle = M_PI;
if ( m_bIsHeader ) if (m_bIsHeader)
nAngle = 0; nAngle = 0;
FillGradientAttribute aFillAttrs( GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, nAngle, FillGradientAttribute aFillAttrs(GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, nAngle, aLighterColor, aFillColor, 10);
aLighterColor, aFillColor, 10 ); aSeq[0] = drawinglayer::primitive2d::Primitive2DReference(
aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::FillGradientPrimitive2D( new drawinglayer::primitive2d::FillGradientPrimitive2D(aGradientRect, aFillAttrs));
aGradientRect, aFillAttrs ) );
} }
// Create the border lines primitive // Create the border lines primitive
aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( aSeq[1] = drawinglayer::primitive2d::Primitive2DReference(
aPolygon, aLineColor ) ); new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPolygon, aLineColor));
// Create the text primitive // Create the text primitive
B2DVector aFontSize; B2DVector aFontSize;
FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont( FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(aFontSize, rRenderContext.GetFont(), false, false);
aFontSize, GetFont(), false, false );
FontMetric aFontMetric = GetFontMetric( GetFont() ); FontMetric aFontMetric = rRenderContext.GetFontMetric(rRenderContext.GetFont());
double nTextOffsetY = aFontMetric.GetAscent() + TEXT_PADDING; double nTextOffsetY = aFontMetric.GetAscent() + TEXT_PADDING;
Point aTextPos( TEXT_PADDING, nTextOffsetY ); Point aTextPos(TEXT_PADDING, nTextOffsetY);
basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix( basegfx::B2DHomMatrix aTextMatrix(createScaleTranslateB2DHomMatrix(
aFontSize.getX(), aFontSize.getY(), aFontSize.getX(), aFontSize.getY(),
double( aTextPos.X() ), double( aTextPos.Y() ) ) ); double(aTextPos.X()), double(aTextPos.Y())));
aSeq[2] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( aSeq[2] = drawinglayer::primitive2d::Primitive2DReference(
aTextMatrix, new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
OUString( m_sLabel ), 0, m_sLabel.getLength(), aTextMatrix, OUString(m_sLabel), 0, m_sLabel.getLength(),
std::vector< double >( ), std::vector<double>(), aFontAttr, css::lang::Locale(), aLineColor));
aFontAttr,
com::sun::star::lang::Locale(),
aLineColor ) );
// Create the 'plus' or 'arrow' primitive // Create the 'plus' or 'arrow' primitive
B2DRectangle aSignArea( B2DPoint( aRect.Right() - BUTTON_WIDTH, 0.0 ), B2DRectangle aSignArea(B2DPoint(aRect.Right() - BUTTON_WIDTH, 0.0),
B2DSize( aRect.Right(), aRect.getHeight() ) ); B2DSize(aRect.Right(), aRect.getHeight()));
B2DPolygon aSign; B2DPolygon aSign;
if ( IsEmptyHeaderFooter( ) ) if (IsEmptyHeaderFooter())
{ {
// Create the + polygon // Create the + polygon
double nLeft = aSignArea.getMinX() + TEXT_PADDING; double nLeft = aSignArea.getMinX() + TEXT_PADDING;
...@@ -335,57 +330,58 @@ void SwHeaderFooterWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rec ...@@ -335,57 +330,58 @@ void SwHeaderFooterWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rec
double nTop = aSignArea.getCenterY() - nHalfW; double nTop = aSignArea.getCenterY() - nHalfW;
double nBottom = aSignArea.getCenterY() + nHalfW; double nBottom = aSignArea.getCenterY() + nHalfW;
aSign.append( B2DPoint( nLeft, aSignArea.getCenterY() - 1.0 ) ); aSign.append(B2DPoint(nLeft, aSignArea.getCenterY() - 1.0));
aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() - 1.0 ) ); aSign.append(B2DPoint(aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() - 1.0));
aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, nTop ) ); aSign.append(B2DPoint(aSignArea.getCenterX() - 1.0, nTop));
aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, nTop ) ); aSign.append(B2DPoint(aSignArea.getCenterX() + 1.0, nTop));
aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() - 1.0 ) ); aSign.append(B2DPoint(aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() - 1.0));
aSign.append( B2DPoint( nRight, aSignArea.getCenterY() - 1.0 ) ); aSign.append(B2DPoint(nRight, aSignArea.getCenterY() - 1.0));
aSign.append( B2DPoint( nRight, aSignArea.getCenterY() + 1.0 ) ); aSign.append(B2DPoint(nRight, aSignArea.getCenterY() + 1.0));
aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() + 1.0 ) ); aSign.append(B2DPoint(aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() + 1.0));
aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, nBottom ) ); aSign.append(B2DPoint(aSignArea.getCenterX() + 1.0, nBottom));
aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, nBottom ) ); aSign.append(B2DPoint(aSignArea.getCenterX() - 1.0, nBottom));
aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() + 1.0 ) ); aSign.append(B2DPoint(aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() + 1.0));
aSign.append( B2DPoint( nLeft, aSignArea.getCenterY() + 1.0 ) ); aSign.append(B2DPoint(nLeft, aSignArea.getCenterY() + 1.0));
aSign.setClosed( true ); aSign.setClosed(true);
} }
else else
{ {
// Create the v polygon // Create the v polygon
B2DPoint aLeft( aSignArea.getMinX() + TEXT_PADDING, aSignArea.getCenterY() ); B2DPoint aLeft(aSignArea.getMinX() + TEXT_PADDING, aSignArea.getCenterY());
B2DPoint aRight( aSignArea.getMaxX() - TEXT_PADDING, aSignArea.getCenterY() ); B2DPoint aRight(aSignArea.getMaxX() - TEXT_PADDING, aSignArea.getCenterY());
B2DPoint aBottom( ( aLeft.getX() + aRight.getX() ) / 2.0, aLeft.getY() + 4.0 ); B2DPoint aBottom((aLeft.getX() + aRight.getX()) / 2.0, aLeft.getY() + 4.0);
aSign.append( aLeft ); aSign.append(aLeft);
aSign.append( aRight ); aSign.append(aRight);
aSign.append( aBottom ); aSign.append(aBottom);
aSign.setClosed( true ); aSign.setClosed(true);
} }
BColor aSignColor = Color( COL_BLACK ).getBColor( ); BColor aSignColor = Color(COL_BLACK).getBColor();
if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) if (Application::GetSettings().GetStyleSettings().GetHighContrastMode())
aSignColor = Color( COL_WHITE ).getBColor( ); aSignColor = Color(COL_WHITE).getBColor();
aSeq.realloc( aSeq.getLength() + 1 ); aSeq.realloc(aSeq.getLength() + 1);
aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( aSeq[aSeq.getLength() - 1] = drawinglayer::primitive2d::Primitive2DReference(
B2DPolyPolygon( aSign ), aSignColor ) ); new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
B2DPolyPolygon(aSign), aSignColor));
// Create the processor and process the primitives // Create the processor and process the primitives
const drawinglayer::geometry::ViewInformation2D aNewViewInfos; const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor( boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor(
drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice( drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(rRenderContext, aNewViewInfos));
*this, aNewViewInfos ));
// TODO Ghost it all if needed // TODO Ghost it all if needed
drawinglayer::primitive2d::Primitive2DSequence aGhostedSeq( 1 ); drawinglayer::primitive2d::Primitive2DSequence aGhostedSeq(1);
double nFadeRate = double( m_nFadeRate ) / 100.0; double nFadeRate = double(m_nFadeRate) / 100.0;
const basegfx::BColorModifierSharedPtr aBColorModifier( const basegfx::BColorModifierSharedPtr aBColorModifier(
new basegfx::BColorModifier_interpolate( new basegfx::BColorModifier_interpolate(Color(COL_WHITE).getBColor(),
Color( COL_WHITE ).getBColor(), 1.0 - nFadeRate));
1.0 - nFadeRate));
aGhostedSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
aSeq, aBColorModifier ) );
pProcessor->process( aGhostedSeq ); aGhostedSeq[0] = drawinglayer::primitive2d::Primitive2DReference(
new drawinglayer::primitive2d::ModifiedColorPrimitive2D(aSeq, aBColorModifier));
pProcessor->process(aGhostedSeq);
} }
bool SwHeaderFooterWin::IsEmptyHeaderFooter( ) bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
...@@ -420,11 +416,11 @@ void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot ) ...@@ -420,11 +416,11 @@ void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
switch ( nSlot ) switch ( nSlot )
{ {
case FN_HEADERFOOTER_EDIT: case FN_HEADERFOOTER_EDIT:
{ {
OString sPageId = m_bIsHeader ? OString("header") : OString("footer"); OString sPageId = m_bIsHeader ? OString("header") : OString("footer");
rView.GetDocShell()->FormatPage(rStyleName, sPageId, rSh); rView.GetDocShell()->FormatPage(rStyleName, sPageId, rSh);
} }
break; break;
case FN_HEADERFOOTER_BORDERBACK: case FN_HEADERFOOTER_BORDERBACK:
{ {
const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc(); const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
...@@ -440,47 +436,47 @@ void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot ) ...@@ -440,47 +436,47 @@ void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
RES_SHADOW, RES_SHADOW, 0 ); RES_SHADOW, RES_SHADOW, 0 );
aSet.Put( pHFFmt->GetAttrSet() ); aSet.Put( pHFFmt->GetAttrSet() );
// Create a box info item... needed by the dialog // Create a box info item... needed by the dialog
SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
const SfxPoolItem *pBoxInfo; const SfxPoolItem *pBoxInfo;
if ( SfxItemState::SET == pHFFmt->GetAttrSet().GetItemState( SID_ATTR_BORDER_INNER, if ( SfxItemState::SET == pHFFmt->GetAttrSet().GetItemState( SID_ATTR_BORDER_INNER,
true, &pBoxInfo) ) true, &pBoxInfo) )
aBoxInfo = *static_cast<const SvxBoxInfoItem*>(pBoxInfo); aBoxInfo = *static_cast<const SvxBoxInfoItem*>(pBoxInfo);
aBoxInfo.SetTable( false ); aBoxInfo.SetTable( false );
aBoxInfo.SetDist( true); aBoxInfo.SetDist( true);
aBoxInfo.SetMinDist( false ); aBoxInfo.SetMinDist( false );
aBoxInfo.SetDefDist( MIN_BORDER_DIST ); aBoxInfo.SetDefDist( MIN_BORDER_DIST );
aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE ); aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE );
aSet.Put( aBoxInfo ); aSet.Put( aBoxInfo );
if ( svx::ShowBorderBackgroundDlg( this, &aSet, true ) ) if ( svx::ShowBorderBackgroundDlg( this, &aSet, true ) )
{ {
const SfxPoolItem* pItem; const SfxPoolItem* pItem;
if ( SfxItemState::SET == aSet.GetItemState( RES_BACKGROUND, false, &pItem ) ) { if ( SfxItemState::SET == aSet.GetItemState( RES_BACKGROUND, false, &pItem ) ) {
pHFFmt->SetFmtAttr( *pItem ); pHFFmt->SetFmtAttr( *pItem );
rView.GetDocShell()->SetModified(true); rView.GetDocShell()->SetModified(true);
} }
if ( SfxItemState::SET == aSet.GetItemState( RES_BOX, false, &pItem ) ) { if ( SfxItemState::SET == aSet.GetItemState( RES_BOX, false, &pItem ) ) {
pHFFmt->SetFmtAttr( *pItem ); pHFFmt->SetFmtAttr( *pItem );
rView.GetDocShell()->SetModified(true); rView.GetDocShell()->SetModified(true);
} }
if ( SfxItemState::SET == aSet.GetItemState( RES_SHADOW, false, &pItem ) ) { if ( SfxItemState::SET == aSet.GetItemState( RES_SHADOW, false, &pItem ) ) {
pHFFmt->SetFmtAttr( *pItem ); pHFFmt->SetFmtAttr( *pItem );
rView.GetDocShell()->SetModified(true); rView.GetDocShell()->SetModified(true);
}
} }
} }
break; }
break;
case FN_HEADERFOOTER_DELETE: case FN_HEADERFOOTER_DELETE:
{ {
rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, false, true ); rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, false, true );
} }
break; break;
default: default:
break; break;
} }
...@@ -493,7 +489,7 @@ void SwHeaderFooterWin::SetReadonly( bool bReadonly ) ...@@ -493,7 +489,7 @@ void SwHeaderFooterWin::SetReadonly( bool bReadonly )
void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt ) void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt )
{ {
if ( IsEmptyHeaderFooter( ) ) if (IsEmptyHeaderFooter())
{ {
SwView& rView = GetEditWin()->GetView(); SwView& rView = GetEditWin()->GetView();
SwWrtShell& rSh = rView.GetWrtShell(); SwWrtShell& rSh = rView.GetWrtShell();
...@@ -505,32 +501,32 @@ void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -505,32 +501,32 @@ void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt )
MenuButton::MouseButtonDown( rMEvt ); MenuButton::MouseButtonDown( rMEvt );
} }
void SwHeaderFooterWin::Select( ) void SwHeaderFooterWin::Select()
{ {
ExecuteCommand( GetCurItemId() ); ExecuteCommand(GetCurItemId());
} }
IMPL_LINK_NOARG_TYPED(SwHeaderFooterWin, FadeHandler, Timer *, void) IMPL_LINK_NOARG_TYPED(SwHeaderFooterWin, FadeHandler, Timer *, void)
{ {
if ( m_bIsAppearing && m_nFadeRate > 0 ) if (m_bIsAppearing && m_nFadeRate > 0)
m_nFadeRate -= 25; m_nFadeRate -= 25;
else if ( !m_bIsAppearing && m_nFadeRate < 100 ) else if (!m_bIsAppearing && m_nFadeRate < 100)
m_nFadeRate += 25; m_nFadeRate += 25;
if ( m_nFadeRate != 100 && !IsVisible() ) if (m_nFadeRate != 100 && !IsVisible())
{ {
Show( true ); Show(true);
m_pLine->Show( true ); m_pLine->Show(true);
} }
else if ( m_nFadeRate == 100 && IsVisible( ) ) else if (m_nFadeRate == 100 && IsVisible())
{ {
Show( false ); Show(false);
m_pLine->Show( false ); m_pLine->Show(false);
} }
else else
Invalidate(); Invalidate();
if ( IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100 ) if (IsVisible() && m_nFadeRate > 0 && m_nFadeRate < 100)
m_aFadeTimer.Start(); m_aFadeTimer.Start();
} }
......
...@@ -135,86 +135,86 @@ void SwPageBreakWin::dispose() ...@@ -135,86 +135,86 @@ void SwPageBreakWin::dispose()
MenuButton::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 // Properly paint the control
BColor aColor = SwViewOption::GetPageBreakColor().getBColor(); BColor aColor = SwViewOption::GetPageBreakColor().getBColor();
BColor aHslLine = rgb2hsl( aColor ); BColor aHslLine = rgb2hsl(aColor);
double nLuminance = aHslLine.getZ(); double nLuminance = aHslLine.getZ();
nLuminance += ( 1.0 - nLuminance ) * 0.75; nLuminance += (1.0 - nLuminance) * 0.75;
if ( aHslLine.getZ() > 0.7 ) if ( aHslLine.getZ() > 0.7 )
nLuminance = aHslLine.getZ() * 0.7; nLuminance = aHslLine.getZ() * 0.7;
aHslLine.setZ( nLuminance ); aHslLine.setZ(nLuminance);
BColor aOtherColor = hsl2rgb( aHslLine ); BColor aOtherColor = hsl2rgb(aHslLine);
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
if ( rSettings.GetHighContrastMode( ) ) if (rSettings.GetHighContrastMode())
{ {
aColor = rSettings.GetDialogTextColor().getBColor(); aColor = rSettings.GetDialogTextColor().getBColor();
aOtherColor = rSettings.GetDialogColor( ).getBColor(); aOtherColor = rSettings.GetDialogColor().getBColor();
} }
bool bRtl = AllSettings::GetLayoutRTL(); bool bRtl = AllSettings::GetLayoutRTL();
drawinglayer::primitive2d::Primitive2DSequence aSeq( 3 ); drawinglayer::primitive2d::Primitive2DSequence aSeq(3);
B2DRectangle aBRect( double( aRect.Left() ), double( aRect.Top( ) ), B2DRectangle aBRect(double(aRect.Left()), double(aRect.Top()),
double( aRect.Right() ), double( aRect.Bottom( ) ) ); double(aRect.Right()), double(aRect.Bottom()));
B2DPolygon aPolygon = createPolygonFromRect( aBRect, 3.0 / BUTTON_WIDTH, 3.0 / BUTTON_HEIGHT ); B2DPolygon aPolygon = createPolygonFromRect(aBRect, 3.0 / BUTTON_WIDTH, 3.0 / BUTTON_HEIGHT);
// Create the polygon primitives // Create the polygon primitives
aSeq[0] = Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( aSeq[0] = Primitive2DReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
B2DPolyPolygon( aPolygon ), aOtherColor ) ); B2DPolyPolygon(aPolygon), aOtherColor));
aSeq[1] = Primitive2DReference( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( aSeq[1] = Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
aPolygon, aColor ) ); aPolygon, aColor));
// Create the primitive for the image // Create the primitive for the image
Image aImg( SW_RES( IMG_PAGE_BREAK ) ); Image aImg(SW_RES(IMG_PAGE_BREAK));
double nImgOfstX = 3.0; double nImgOfstX = 3.0;
if ( bRtl ) if (bRtl)
nImgOfstX = aRect.Right() - aImg.GetSizePixel().Width() - 3.0; nImgOfstX = aRect.Right() - aImg.GetSizePixel().Width() - 3.0;
aSeq[2] = Primitive2DReference( new drawinglayer::primitive2d::DiscreteBitmapPrimitive2D( aSeq[2] = Primitive2DReference(new drawinglayer::primitive2d::DiscreteBitmapPrimitive2D(
aImg.GetBitmapEx(), B2DPoint( nImgOfstX, 1.0 ) ) ); 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 nBottom = nTop + 4.0;
double nLeft = aRect.getWidth( ) - ARROW_WIDTH - 6.0; double nLeft = aRect.getWidth() - ARROW_WIDTH - 6.0;
if ( bRtl ) if (bRtl)
nLeft = ARROW_WIDTH - 2.0; nLeft = ARROW_WIDTH - 2.0;
double nRight = nLeft + 8.0; double nRight = nLeft + 8.0;
B2DPolygon aTriangle; B2DPolygon aTriangle;
aTriangle.append( B2DPoint( nLeft, nTop ) ); aTriangle.append(B2DPoint(nLeft, nTop));
aTriangle.append( B2DPoint( nRight, nTop ) ); aTriangle.append(B2DPoint(nRight, nTop));
aTriangle.append( B2DPoint( ( nLeft + nRight ) / 2.0, nBottom ) ); aTriangle.append(B2DPoint((nLeft + nRight) / 2.0, nBottom));
aTriangle.setClosed( true ); aTriangle.setClosed(true);
BColor aTriangleColor = Color( COL_BLACK ).getBColor( ); BColor aTriangleColor = Color(COL_BLACK).getBColor();
if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) if (Application::GetSettings().GetStyleSettings().GetHighContrastMode())
aTriangleColor = Color( COL_WHITE ).getBColor( ); aTriangleColor = Color(COL_WHITE).getBColor();
aSeq.realloc( aSeq.getLength() + 1 ); aSeq.realloc(aSeq.getLength() + 1);
aSeq[ aSeq.getLength() - 1 ] = Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( aSeq[aSeq.getLength() - 1] = Primitive2DReference(
B2DPolyPolygon( aTriangle ), aTriangleColor ) ); new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
B2DPolyPolygon(aTriangle), aTriangleColor));
Primitive2DSequence aGhostedSeq( 1 );
double nFadeRate = double( m_nFadeRate ) / 100.0; Primitive2DSequence aGhostedSeq(1);
double nFadeRate = double(m_nFadeRate) / 100.0;
const basegfx::BColorModifierSharedPtr aBColorModifier( const basegfx::BColorModifierSharedPtr aBColorModifier(
new basegfx::BColorModifier_interpolate( new basegfx::BColorModifier_interpolate(Color(COL_WHITE).getBColor(),
Color( COL_WHITE ).getBColor(), 1.0 - nFadeRate));
1.0 - nFadeRate)); aGhostedSeq[0] = Primitive2DReference(
aGhostedSeq[0] = Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
aSeq, aBColorModifier ) ); aSeq, aBColorModifier));
// Create the processor and process the primitives // Create the processor and process the primitives
const drawinglayer::geometry::ViewInformation2D aNewViewInfos; const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor( boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor(
drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice( drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(rRenderContext, aNewViewInfos));
*this, aNewViewInfos ));
pProcessor->process( aGhostedSeq ); pProcessor->process(aGhostedSeq);
} }
void SwPageBreakWin::Select( ) void SwPageBreakWin::Select( )
...@@ -466,7 +466,7 @@ IMPL_LINK_NOARG_TYPED(SwPageBreakWin, FadeHandler, Timer *, void) ...@@ -466,7 +466,7 @@ IMPL_LINK_NOARG_TYPED(SwPageBreakWin, FadeHandler, Timer *, void)
Invalidate(); Invalidate();
} }
if ( IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100 ) if (IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100)
m_aFadeTimer.Start(); m_aFadeTimer.Start();
} }
......
...@@ -151,43 +151,37 @@ void SidebarTxtControl::Draw(OutputDevice* pDev, const Point& rPt, const Size& r ...@@ -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() || if (mrSidebarWin.IsMouseOverSidebarWin() || HasFocus())
HasFocus() )
{ {
DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ), rRenderContext.DrawGradient(Rectangle(Point(0,0), rRenderContext.PixelToLogic(GetSizePixel())),
Gradient( GradientStyle_LINEAR, Gradient(GradientStyle_LINEAR, mrSidebarWin.ColorDark(), mrSidebarWin.ColorDark()));
mrSidebarWin.ColorDark(),
mrSidebarWin.ColorDark() ) );
} }
else else
{ {
DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ), rRenderContext.DrawGradient(Rectangle(Point(0,0), rRenderContext.PixelToLogic(GetSizePixel())),
Gradient( GradientStyle_LINEAR, Gradient(GradientStyle_LINEAR, mrSidebarWin.ColorLight(), mrSidebarWin.ColorDark()));
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()); rRenderContext.SetLineColor(mrSidebarWin.GetChangeColor());
DrawLine( PixelToLogic( GetPosPixel() ), rRenderContext.DrawLine(rRenderContext.PixelToLogic(GetPosPixel()),
PixelToLogic( GetPosPixel() + rRenderContext.PixelToLogic(GetPosPixel() + Point(GetSizePixel().Width(),
Point( GetSizePixel().Width(), GetSizePixel().Height())));
GetSizePixel().Height() ) ) ); rRenderContext.DrawLine(rRenderContext.PixelToLogic(GetPosPixel() + Point(GetSizePixel().Width(),
DrawLine( PixelToLogic( GetPosPixel() + 0)),
Point( GetSizePixel().Width(),0) ), rRenderContext.PixelToLogic(GetPosPixel() + Point(0,
PixelToLogic( GetPosPixel() + GetSizePixel().Height())));
Point( 0, GetSizePixel().Height() ) ) );
} }
} }
......
...@@ -89,14 +89,14 @@ namespace sw { namespace sidebarwindows { ...@@ -89,14 +89,14 @@ namespace sw { namespace sidebarwindows {
#define POSTIT_META_HEIGHT (sal_Int32) 30 #define POSTIT_META_HEIGHT (sal_Int32) 30
#define POSTIT_MINIMUMSIZE_WITHOUT_META 50 #define POSTIT_MINIMUMSIZE_WITHOUT_META 50
SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin, SwSidebarWin::SwSidebarWin(SwEditWin& rEditWin,
WinBits nBits, WinBits nBits,
SwPostItMgr& aMgr, SwPostItMgr& aMgr,
SwPostItBits aBits, SwPostItBits aBits,
SwSidebarItem& rSidebarItem ) SwSidebarItem& rSidebarItem)
: Window(&rEditWin, nBits) : Window(&rEditWin, nBits)
, mrMgr(aMgr) , mrMgr(aMgr)
, mrView( rEditWin.GetView() ) , mrView(rEditWin.GetView())
, nFlags(aBits) , nFlags(aBits)
, mnEventId(0) , mnEventId(0)
, mpOutlinerView(0) , mpOutlinerView(0)
...@@ -106,23 +106,23 @@ SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin, ...@@ -106,23 +106,23 @@ SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin,
, mpMetadataAuthor(0) , mpMetadataAuthor(0)
, mpMetadataDate(0) , mpMetadataDate(0)
, mpMenuButton(0) , mpMenuButton(0)
, mpAnchor( NULL ) , mpAnchor(NULL)
, mpShadow( NULL ) , mpShadow(NULL)
, mpTextRangeOverlay( NULL ) , mpTextRangeOverlay(NULL)
, mColorAnchor() , mColorAnchor()
, mColorDark() , mColorDark()
, mColorLight() , mColorLight()
, mChangeColor() , mChangeColor()
, meSidebarPosition( sw::sidebarwindows::SidebarPosition::NONE ) , meSidebarPosition(sw::sidebarwindows::SidebarPosition::NONE)
, mPosSize() , mPosSize()
, mAnchorRect() , mAnchorRect()
, mPageBorder( 0 ) , mPageBorder(0)
, mbMouseOver( false ) , mbMouseOver(false)
, mLayoutStatus( SwPostItHelper::INVISIBLE ) , mLayoutStatus(SwPostItHelper::INVISIBLE)
, mbReadonly( false ) , mbReadonly(false)
, mbIsFollow( false ) , mbIsFollow(false)
, mrSidebarItem( rSidebarItem ) , mrSidebarItem(rSidebarItem)
, mpAnchorFrm( rSidebarItem.maLayoutInfo.mpAnchorFrm ) , mpAnchorFrm(rSidebarItem.maLayoutInfo.mpAnchorFrm)
{ {
mpShadow = ShadowOverlayObject::CreateShadowOverlayObject( mrView ); mpShadow = ShadowOverlayObject::CreateShadowOverlayObject( mrView );
if ( mpShadow ) if ( mpShadow )
...@@ -208,29 +208,29 @@ void SwSidebarWin::dispose() ...@@ -208,29 +208,29 @@ void SwSidebarWin::dispose()
vcl::Window::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); Window::Paint(rRenderContext, rRect);
if (mpMetadataAuthor->IsVisible() ) if (mpMetadataAuthor->IsVisible())
{ {
//draw left over space //draw left over space
if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) if (Application::GetSettings().GetStyleSettings().GetHighContrastMode())
{ {
SetFillColor(COL_BLACK); rRenderContext.SetFillColor(COL_BLACK);
} }
else else
{ {
SetFillColor(mColorDark); rRenderContext.SetFillColor(mColorDark);
} }
SetLineColor();
DrawRect( PixelToLogic( rRenderContext.SetLineColor();
Rectangle( Point( mpMetadataAuthor->GetPosPixel().X() + Rectangle aRectangle(Point(mpMetadataAuthor->GetPosPixel().X() + mpMetadataAuthor->GetSizePixel().Width(),
mpMetadataAuthor->GetSizePixel().Width(), mpMetadataAuthor->GetPosPixel().Y()),
mpMetadataAuthor->GetPosPixel().Y() ), Size(GetMetaButtonAreaWidth(),
Size( GetMetaButtonAreaWidth(), mpMetadataAuthor->GetSizePixel().Height() + mpMetadataDate->GetSizePixel().Height()));
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 ...@@ -302,12 +302,8 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, s
} }
} }
void SwSidebarWin::SetPosSizePixelRect( long nX, void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight,
long nY, const SwRect& aAnchorRect, const long aPageBorder)
long nWidth,
long nHeight,
const SwRect& aAnchorRect,
const long aPageBorder)
{ {
mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight)); mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight));
mAnchorRect = aAnchorRect; 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