Kaydet (Commit) 61ae8caa authored tarafından Cédric Bosdonnat's avatar Cédric Bosdonnat

Page Break: show the button on the right for book mode view

üst eb09adaa
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <wrtsh.hxx> #include <wrtsh.hxx>
#include <basegfx/color/bcolortools.hxx> #include <basegfx/color/bcolortools.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/range/b2drectangle.hxx> #include <basegfx/range/b2drectangle.hxx>
...@@ -65,7 +66,7 @@ using namespace drawinglayer::primitive2d; ...@@ -65,7 +66,7 @@ using namespace drawinglayer::primitive2d;
namespace namespace
{ {
B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds ) B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds, bool bShowOnRight )
{ {
B2DPolygon aRetval; B2DPolygon aRetval;
const double nRadius = 1; const double nRadius = 1;
...@@ -140,6 +141,14 @@ namespace ...@@ -140,6 +141,14 @@ namespace
} }
aRetval.setClosed( true ); aRetval.setClosed( true );
if ( bShowOnRight )
{
B2DHomMatrix bRotMatrix = createRotateAroundPoint(
aBounds.getCenterX(), aBounds.getCenterY(), M_PI );
aRetval.transform( bRotMatrix );
}
return aRetval; return aRetval;
} }
} }
...@@ -190,10 +199,12 @@ void SwPageBreakWin::Paint( const Rectangle& ) ...@@ -190,10 +199,12 @@ void SwPageBreakWin::Paint( const Rectangle& )
aOtherColor = rSettings.GetDialogColor( ).getBColor(); aOtherColor = rSettings.GetDialogColor( ).getBColor();
} }
bool bShowOnRight = ShowOnRight( );
Primitive2DSequence aSeq( 2 ); Primitive2DSequence aSeq( 2 );
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 = lcl_CreatePolygon( aBRect ); B2DPolygon aPolygon = lcl_CreatePolygon( aBRect, bShowOnRight );
// Create the polygon primitives // Create the polygon primitives
aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D( aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
...@@ -213,7 +224,9 @@ void SwPageBreakWin::Paint( const Rectangle& ) ...@@ -213,7 +224,9 @@ void SwPageBreakWin::Paint( const Rectangle& )
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;
double nRight = aRect.getWidth( ) - ARROW_WIDTH + 2.0; if ( bShowOnRight )
nLeft = ARROW_WIDTH - 2.0;
double nRight = nLeft + 8.0;
B2DPolygon aTriangle; B2DPolygon aTriangle;
aTriangle.append( B2DPoint( nLeft, nTop ) ); aTriangle.append( B2DPoint( nLeft, nTop ) );
...@@ -234,7 +247,10 @@ void SwPageBreakWin::Paint( const Rectangle& ) ...@@ -234,7 +247,10 @@ void SwPageBreakWin::Paint( const Rectangle& )
// Paint the picture // Paint the picture
Image aImg( SW_RES( IMG_PAGE_BREAK ) ); Image aImg( SW_RES( IMG_PAGE_BREAK ) );
DrawImage( Point( 3, 1 ), aImg ); long nImgOfstX = 3;
if ( bShowOnRight )
nImgOfstX = aRect.Right() - aImg.GetSizePixel().Width() - 3;
DrawImage( Point( nImgOfstX, 1 ), aImg );
} }
void SwPageBreakWin::Select( ) void SwPageBreakWin::Select( )
...@@ -306,33 +322,81 @@ void SwPageBreakWin::Select( ) ...@@ -306,33 +322,81 @@ void SwPageBreakWin::Select( )
} }
} }
void SwPageBreakWin::UpdatePosition( ) bool SwPageBreakWin::ShowOnRight( )
{ {
const SwPageFrm* pPrevPage = static_cast< const SwPageFrm* >( GetPageFrame()->GetPrev() ); bool bOnRight = false;
Rectangle aPrevFrmRect = GetEditWin()->LogicToPixel( pPrevPage->Frm().SVRect() );
Rectangle aBoundRect = GetEditWin()->LogicToPixel( GetPageFrame()->GetBoundRect().SVRect() );
Rectangle aFrmRect = GetEditWin()->LogicToPixel( GetPageFrame()->Frm().SVRect() );
long nYLineOffset = ( aPrevFrmRect.Bottom() + aFrmRect.Top() ) / 2; // Handle the book mode / columns view case
if ( aFrmRect.Top() == aPrevFrmRect.Top() ) const SwViewOption* pViewOpt = GetEditWin()->GetView().GetWrtShell().GetViewOptions();
nYLineOffset = ( aBoundRect.Top() + aFrmRect.Top() ) / 2; bool bBookMode = pViewOpt->IsViewLayoutBookMode();
Rectangle aVisArea = GetEditWin()->LogicToPixel( GetEditWin()->GetView().GetVisArea() ); if ( bBookMode )
bOnRight = GetPageFrame()->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_RIGHT;
Size aBtnSize( BUTTON_WIDTH + ARROW_WIDTH, BUTTON_HEIGHT ); // TODO Handle the RTL case
long nLeft = std::max( aFrmRect.Left() - aBtnSize.Width(), aVisArea.Left() );
Point aBtnPos( nLeft + ARROW_WIDTH / 2,
nYLineOffset - aBtnSize.Height() / 2 );
SetPosSizePixel( aBtnPos, aBtnSize ); return bOnRight;
}
void SwPageBreakWin::UpdatePosition( )
{
const SwPageFrm* pPageFrm = GetPageFrame();
const SwFrm* pPrevPage = pPageFrm->GetPrev();
while ( pPrevPage && ( pPrevPage->Frm().Top( ) == pPageFrm->Frm().Top( ) ) )
pPrevPage = pPrevPage->GetPrev();
Rectangle aBoundRect = GetEditWin()->LogicToPixel( pPageFrm->GetBoundRect().SVRect() );
Rectangle aFrmRect = GetEditWin()->LogicToPixel( pPageFrm->Frm().SVRect() );
long nYLineOffset = ( aBoundRect.Top() + aFrmRect.Top() ) / 2;
if ( pPrevPage )
{
Rectangle aPrevFrmRect = GetEditWin()->LogicToPixel( pPrevPage->Frm().SVRect() );
nYLineOffset = ( aPrevFrmRect.Bottom() + aFrmRect.Top() ) / 2;
}
// Get the page + sidebar coords
long nPgLeft = aFrmRect.Left();
long nPgRight = aFrmRect.Right();
// Update the line position
Point aLinePos( nLeft + ARROW_WIDTH / 2, nYLineOffset );
unsigned long nSidebarWidth = 0; unsigned long nSidebarWidth = 0;
const SwPostItMgr* pPostItMngr = GetEditWin()->GetView().GetWrtShell().GetPostItMgr(); const SwPostItMgr* pPostItMngr = GetEditWin()->GetView().GetWrtShell().GetPostItMgr();
if ( pPostItMngr && pPostItMngr->HasNotes() && pPostItMngr->ShowNotes() ) if ( pPostItMngr && pPostItMngr->HasNotes() && pPostItMngr->ShowNotes() )
nSidebarWidth = pPostItMngr->GetSidebarBorderWidth( true ) + pPostItMngr->GetSidebarWidth( true ); nSidebarWidth = pPostItMngr->GetSidebarBorderWidth( true ) + pPostItMngr->GetSidebarWidth( true );
Size aLineSize( aFrmRect.Right() + nSidebarWidth - nLeft, 1 );
if ( pPageFrm->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_LEFT )
nPgLeft -= nSidebarWidth;
else if ( pPageFrm->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_RIGHT )
nPgRight += nSidebarWidth;
Size aBtnSize( BUTTON_WIDTH + ARROW_WIDTH, BUTTON_HEIGHT );
// Place the button on the left or right?
Rectangle aVisArea = GetEditWin()->LogicToPixel( GetEditWin()->GetView().GetVisArea() );
long nLineLeft = nPgLeft;
long nLineRight = nPgRight;
long nBtnLeft = nPgLeft;
if ( ShowOnRight( ) )
{
long nRight = std::min( nPgRight + aBtnSize.getWidth() - ARROW_WIDTH / 2, aVisArea.Right() );
nBtnLeft = nRight - aBtnSize.getWidth();
nLineRight = nBtnLeft - ARROW_WIDTH / 2;
}
else
{
nBtnLeft = std::max( nPgLeft - aBtnSize.Width() + ARROW_WIDTH / 2, aVisArea.Left() );
nLineLeft = nBtnLeft + aBtnSize.Width( ) + ARROW_WIDTH / 2;
}
// Set the button position
Point aBtnPos( nBtnLeft, nYLineOffset - aBtnSize.Height() / 2 );
SetPosSizePixel( aBtnPos, aBtnSize );
// Set the line position
Point aLinePos( nLineLeft, nYLineOffset );
Size aLineSize( nLineRight - nLineLeft, 1 );
m_pLine->SetPosSizePixel( aLinePos, aLineSize ); m_pLine->SetPosSizePixel( aLinePos, aLineSize );
} }
......
...@@ -58,6 +58,9 @@ public: ...@@ -58,6 +58,9 @@ public:
const SwPageFrm* GetPageFrame( ); const SwPageFrm* GetPageFrame( );
void SetReadonly( bool bReadonly ); void SetReadonly( bool bReadonly );
private:
bool ShowOnRight();
}; };
#endif #endif
......
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