summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-09-07 16:02:01 +0200
committerCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-09-08 15:42:57 +0200
commit4115a81bea06eb9cb3ea7b6d8819a35a8a8de52b (patch)
tree210f029c275a9c945ce2dc49f5edfbf418d14729 /sw
parent2fe52eded60106062dd5736885c5537155cb03f7 (diff)
Header/Footer: Use a Window with WB_DIALOGCONTROL to fix loads of bugs
Bugs fixed by this change: * The Header/footer window is now moving with the parent window * The Window rectangle is adapted to the parent area and doesn't go over the scrollbar * The windows are shown properly in all cases
Diffstat (limited to 'sw')
-rwxr-xr-xsw/source/core/layout/paintfrm.cxx2
-rw-r--r--sw/source/ui/docvw/HeaderFooterWin.cxx118
-rw-r--r--sw/source/ui/inc/HeaderFooterWin.hxx4
3 files changed, 51 insertions, 73 deletions
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index e3146afbb7ff..4a67bb27508c 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3414,7 +3414,6 @@ void SwPageFrm::PaintDecorators( ) const
const SwRect& rVisArea = pGlobalShell->VisArea();
long nXOff = std::min( aBodyRect.Right(), rVisArea.Right() );
- // FIXME there are cases where the label isn't show but should be
long nHeaderYOff = aBodyRect.Top();
if ( rVisArea.IsInside( Point( rVisArea.Left(), nHeaderYOff ) ) )
{
@@ -3434,7 +3433,6 @@ void SwPageFrm::PaintDecorators( ) const
pFtnContFrm = pFtnContFrm->GetNext();
}
- // FIXME there are cases where the label isn't show but should be
long nFooterYOff = aBodyRect.Bottom();
if ( rVisArea.IsInside( Point( rVisArea.Left(), nFooterYOff ) ) )
{
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 271a7d7cbfda..9ba49fcb0994 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -58,6 +58,38 @@ namespace
aHslLine.setZ( nLuminance );
return basegfx::tools::hsl2rgb( aHslLine );
}
+
+ void lcl_DrawBackground( OutputDevice* pOut, const Rectangle& rRect, bool bHeader )
+ {
+ // Colors
+ basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
+ basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor );
+
+ // Draw the background rect
+ pOut->SetFillColor( Color ( aFillColor ) );
+ pOut->SetLineColor( Color ( aFillColor ) );
+ pOut->DrawRect( rRect );
+
+ // Draw the lines around the rect
+ pOut->SetLineColor( Color( aLineColor ) );
+ basegfx::B2DPolygon aPolygon;
+ aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Top() ) );
+ aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Bottom() ) );
+ pOut->DrawPolyLine( aPolygon, 1.0 );
+
+ aPolygon.clear();
+ aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Top() ) );
+ aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Bottom() ) );
+ pOut->DrawPolyLine( aPolygon, 1.0 );
+
+ long nYLine = rRect.Bottom();
+ if ( !bHeader )
+ nYLine = rRect.Top();
+ aPolygon.clear();
+ aPolygon.append( basegfx::B2DPoint( rRect.Left(), nYLine ) );
+ aPolygon.append( basegfx::B2DPoint( rRect.Right(), nYLine ) );
+ pOut->DrawPolyLine( aPolygon, 1.0 );
+ }
}
class SwHeaderFooterButton : public MenuButton
@@ -76,7 +108,7 @@ class SwHeaderFooterButton : public MenuButton
// and the WB_OWNERDRAWDECORATION prevents the system to draw the window decorations.
//
SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader, Point aOffset ) :
- FloatingWindow( pEditWin, WB_SYSTEMWINDOW | WB_NOBORDER | WB_NOSHADOW | WB_MOVEABLE | WB_OWNERDRAWDECORATION ),
+ Window( pEditWin, WB_DIALOGCONTROL ),
m_pEditWin( pEditWin ),
m_sLabel( ),
m_pPageFrm( pPageFrm ),
@@ -110,9 +142,8 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
if ( !bHeader )
nYFooterOff = aBoxSize.Height();
- Size aPosOffset ( pEditWin->GetOutOffXPixel(), pEditWin->GetOutOffYPixel() );
- Point aBoxPos( aPosOffset.Width() + aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
- aPosOffset.Height() + aOffset.Y() - nYFooterOff );
+ Point aBoxPos( aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
+ aOffset.Y() - nYFooterOff );
// Set the position & Size of the window
SetPosSizePixel( aBoxPos, aBoxSize );
@@ -131,40 +162,15 @@ SwHeaderFooterWin::~SwHeaderFooterWin( )
delete m_pButton;
}
-void SwHeaderFooterWin::Paint( const Rectangle& rRect )
+void SwHeaderFooterWin::Paint( const Rectangle& )
{
- // Colors
- basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
- basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor );
-
- // Draw the background rect
- SetFillColor( Color ( aFillColor ) );
- SetLineColor( Color ( aFillColor ) );
- DrawRect( rRect );
-
- // Draw the lines around the rect
- SetLineColor( Color( aLineColor ) );
- basegfx::B2DPolygon aPolygon;
- aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Top() ) );
- aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Bottom() ) );
- DrawPolyLine( aPolygon, 1.0 );
-
- aPolygon.clear();
- aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Top() ) );
- aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Bottom() ) );
- DrawPolyLine( aPolygon, 1.0 );
-
- long nYLine = rRect.Bottom();
- if ( !m_bIsHeader )
- nYLine = rRect.Top();
- aPolygon.clear();
- aPolygon.append( basegfx::B2DPoint( rRect.Left(), nYLine ) );
- aPolygon.append( basegfx::B2DPoint( rRect.Right(), nYLine ) );
- DrawPolyLine( aPolygon, 1.0 );
+ const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+ lcl_DrawBackground( this, aRect, m_bIsHeader );
// Draw the text
+ basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
SetTextColor( Color( aLineColor ) );
- DrawText( Point( rRect.Left() + TEXT_PADDING, rRect.Top() + TEXT_PADDING ),
+ DrawText( Point( aRect.Left() + TEXT_PADDING, aRect.Top() + TEXT_PADDING ),
String( m_sLabel ) );
}
@@ -200,39 +206,13 @@ SwHeaderFooterButton::~SwHeaderFooterButton( )
{
}
-void SwHeaderFooterButton::Paint( const Rectangle& rRect )
+void SwHeaderFooterButton::Paint( const Rectangle& )
{
- // Colors
- basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
- basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor );
-
- // Draw the background rect
- SetFillColor( Color ( aFillColor ) );
- SetLineColor( Color ( aFillColor ) );
- DrawRect( rRect );
-
- // Draw the lines around the rect
- SetLineColor( Color( aLineColor ) );
- basegfx::B2DPolygon aPolygon;
- aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Top() ) );
- aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Bottom() ) );
- DrawPolyLine( aPolygon, 1.0 );
-
- aPolygon.clear();
- aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Top() ) );
- aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Bottom() ) );
- DrawPolyLine( aPolygon, 1.0 );
-
- long nYLine = rRect.Bottom();
- if ( !m_pWindow->IsHeader() )
- nYLine = rRect.Top();
- aPolygon.clear();
- aPolygon.append( basegfx::B2DPoint( rRect.Left(), nYLine ) );
- aPolygon.append( basegfx::B2DPoint( rRect.Right(), nYLine ) );
- DrawPolyLine( aPolygon, 1.0 );
-
-
- Rectangle aSymbolRect( rRect );
+ const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+
+ lcl_DrawBackground( this, aRect, m_pWindow->IsHeader() );
+
+ Rectangle aSymbolRect( aRect );
// 25% distance to the left and right button border
const long nBorderDistanceLeftAndRight = ((aSymbolRect.GetWidth()*250)+500)/1000;
aSymbolRect.Left()+=nBorderDistanceLeftAndRight;
@@ -249,9 +229,9 @@ void SwHeaderFooterButton::Paint( const Rectangle& rRect )
SvtResId id( BMP_LIST_ADD );
Image aPlusImg( id );
Size aSize = aPlusImg.GetSizePixel();
- Point aPt = rRect.TopLeft();
- long nXOffset = ( rRect.GetWidth() - aSize.Width() ) / 2;
- long nYOffset = ( rRect.GetHeight() - aSize.Height() ) / 2;
+ Point aPt = aRect.TopLeft();
+ long nXOffset = ( aRect.GetWidth() - aSize.Width() ) / 2;
+ long nYOffset = ( aRect.GetHeight() - aSize.Height() ) / 2;
aPt += Point( nXOffset, nYOffset );
DrawImage(aPt, aPlusImg);
}
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index e35bc9a42802..42b80a1c28ed 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -30,7 +30,7 @@
#include <pagedesc.hxx>
-#include <vcl/floatwin.hxx>
+#include <vcl/window.hxx>
class SwHeaderFooterButton;
@@ -39,7 +39,7 @@ class SwHeaderFooterButton;
This control is showing the header / footer style name and provides
a few useful actions to the user.
*/
-class SwHeaderFooterWin : public FloatingWindow
+class SwHeaderFooterWin : public Window
{
SwEditWin* m_pEditWin;
rtl::OUString m_sLabel;