summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-12-28 20:01:57 +0100
committerJan Holesovsky <kendy@suse.cz>2011-12-29 13:46:20 +0100
commit64e08fd3c5980b74bb958dc566c229d92db18726 (patch)
treec70e96ad9bf59547d1a80a3500c9700fd285af7c /sw/source
parent4e41996b5693414c0887c2c4d929cd16f4eb4577 (diff)
Header/Footer: Show / hide the control immediately.
- When the mouse pointer enters or leaves the headers / footers, show or hide the header / footer control immediately. Waiting for that to appear is annoying; and similarly for disappearing - one usually ended up clicking the header / footer area to speed that up, and had a feeling of misbehaving. - Few related re-paint improvements
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/crsr/crsrsh.cxx6
-rw-r--r--sw/source/core/view/viewsh.cxx9
-rw-r--r--sw/source/ui/docvw/FrameControlsManager.cxx5
-rw-r--r--sw/source/ui/docvw/HeaderFooterWin.cxx19
-rw-r--r--sw/source/ui/docvw/PageBreakWin.cxx19
-rw-r--r--sw/source/ui/docvw/edtwin.cxx106
-rw-r--r--sw/source/ui/inc/FrameControl.hxx4
-rw-r--r--sw/source/ui/inc/FrameControlsManager.hxx5
-rw-r--r--sw/source/ui/inc/HeaderFooterWin.hxx3
-rw-r--r--sw/source/ui/inc/PageBreakWin.hxx3
-rw-r--r--sw/source/ui/inc/edtwin.hxx14
-rw-r--r--sw/source/ui/inc/wrtsh.hxx2
-rw-r--r--sw/source/ui/wrtsh/wrtsh1.cxx7
13 files changed, 112 insertions, 90 deletions
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 561766564eca..bb55f6b57a06 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -674,7 +674,7 @@ int SwCrsrShell::SetCrsr( const Point &rLPt, sal_Bool bOnlyText, bool bBlock )
// Toggle the Header/Footer mode if needed
bool bInHeaderFooter = pFrm && ( pFrm->IsHeaderFrm() || pFrm->IsFooterFrm() );
- if ( bInHeaderFooter ^ (bool) IsHeaderFooterEdit() )
+ if ( bInHeaderFooter != IsHeaderFooterEdit() )
ToggleHeaderFooterEdit();
if( pBlockCrsr && bBlock )
@@ -1315,9 +1315,7 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, sal_Bool bIdleEnd )
return; // wenn nicht, dann kein Update !!
}
- bool bInHeaderFooter = IsInHeaderFooter( );
- if ( ( bInHeaderFooter && !IsHeaderFooterEdit( ) ) ||
- ( !bInHeaderFooter && IsHeaderFooterEdit( ) ) )
+ if ( IsInHeaderFooter() != IsHeaderFooterEdit() )
ToggleHeaderFooterEdit( );
// #i27301#
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 41f1443ed612..9e3bb9bd9295 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -94,11 +94,14 @@ TYPEINIT0(ViewShell);
using namespace ::com::sun::star;
-void ViewShell::ToggleHeaderFooterEdit( ) {
+void ViewShell::ToggleHeaderFooterEdit()
+{
bHeaderFooterEdit = !bHeaderFooterEdit;
- SetShowHeaderFooterSeparator( bHeaderFooterEdit );
+ if ( bHeaderFooterEdit != IsShowHeaderFooterSeparator() )
+ SetShowHeaderFooterSeparator( bHeaderFooterEdit );
+
// Repaint everything to update the colors of the selected area
- Paint( VisArea().SVRect() );
+ GetWin()->Invalidate();
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/sw/source/ui/docvw/FrameControlsManager.cxx b/sw/source/ui/docvw/FrameControlsManager.cxx
index 2ee48869403f..72671049bbc5 100644
--- a/sw/source/ui/docvw/FrameControlsManager.cxx
+++ b/sw/source/ui/docvw/FrameControlsManager.cxx
@@ -153,8 +153,9 @@ void SwFrameControlsManager::SetHeaderFooterControl( const SwPageFrm* pPageFrm,
{
// Check if we already have the control
SwFrameControlPtr pControl;
+ FrameControlType eType = bHeader? Header: Footer;
- vector< SwFrameControlPtr >& aControls = m_aControls[HeaderFooter];
+ vector< SwFrameControlPtr >& aControls = m_aControls[eType];
vector< SwFrameControlPtr >::iterator pIt = aControls.begin();
while ( pIt != aControls.end() && !pControl.get() )
@@ -171,7 +172,7 @@ void SwFrameControlsManager::SetHeaderFooterControl( const SwPageFrm* pPageFrm,
SwFrameControlPtr pNewControl( new SwHeaderFooterWin( m_pEditWin, pPageFrm, bHeader ) );
const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions();
pNewControl->SetReadonly( pViewOpt->IsReadonly() );
- AddControl( HeaderFooter, pNewControl );
+ AddControl( eType, pNewControl );
pControl.swap( pNewControl );
}
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 64e75e456d41..b5a3c7045af9 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -78,7 +78,7 @@ using namespace drawinglayer::primitive2d;
namespace
{
- basegfx::BColor lcl_GetFillColor( basegfx::BColor aLineColor )
+ static basegfx::BColor lcl_GetFillColor( basegfx::BColor aLineColor )
{
basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor );
double nLuminance = aHslLine.getZ() * 2.5;
@@ -90,7 +90,7 @@ namespace
return basegfx::tools::hsl2rgb( aHslLine );
}
- basegfx::BColor lcl_GetLighterGradientColor( basegfx::BColor aDarkColor )
+ static basegfx::BColor lcl_GetLighterGradientColor( basegfx::BColor aDarkColor )
{
basegfx::BColor aHslDark = basegfx::tools::rgb2hsl( aDarkColor );
double nLuminance = aHslDark.getZ() * 255 + 20;
@@ -98,7 +98,7 @@ namespace
return basegfx::tools::hsl2rgb( aHslDark );
}
- B2DPolygon lcl_GetPolygon( const Rectangle& rRect, bool bHeader )
+ static B2DPolygon lcl_GetPolygon( const Rectangle& rRect, bool bHeader )
{
const double nRadius = 3;
const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0);
@@ -250,6 +250,19 @@ void SwHeaderFooterWin::ShowAll( bool bShow )
}
}
+bool SwHeaderFooterWin::Contains( const Point &rDocPt ) const
+{
+ Rectangle aRect( GetPosPixel(), GetSizePixel() );
+ if ( aRect.IsInside( rDocPt ) )
+ return true;
+
+ Rectangle aLineRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() );
+ if ( aLineRect.IsInside( rDocPt ) )
+ return true;
+
+ return false;
+}
+
void SwHeaderFooterWin::Paint( const Rectangle& )
{
const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx
index 7c1f00ef977d..7e6232d85371 100644
--- a/sw/source/ui/docvw/PageBreakWin.cxx
+++ b/sw/source/ui/docvw/PageBreakWin.cxx
@@ -173,9 +173,8 @@ namespace
if ( rMEvt.IsLeaveWindow() )
{
// don't fade if we just move to the 'button'
- Rectangle aRect( m_pWin->GetPosPixel(), m_pWin->GetSizePixel() );
Point aEventPos( GetPosPixel() + rMEvt.GetPosPixel() );
- if ( !aRect.IsInside( aEventPos ) )
+ if ( !m_pWin->Contains( aEventPos ) )
m_pWin->Fade( false );
}
else if ( !m_pWin->IsVisible() )
@@ -402,9 +401,8 @@ void SwPageBreakWin::MouseMove( const MouseEvent& rMEvt )
if ( rMEvt.IsLeaveWindow() )
{
// don't fade if we just move to the 'line', or the popup menu is open
- Rectangle aRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() );
Point aEventPos( GetPosPixel() + rMEvt.GetPosPixel() );
- if ( !aRect.IsInside( aEventPos ) && !PopupMenu::IsInExecute() )
+ if ( !Contains( aEventPos ) && !PopupMenu::IsInExecute() )
Fade( false );
}
else if ( !IsVisible() )
@@ -504,6 +502,19 @@ void SwPageBreakWin::ShowAll( bool bShow )
m_pLine->Show( bShow );
}
+bool SwPageBreakWin::Contains( const Point &rDocPt ) const
+{
+ Rectangle aRect( GetPosPixel(), GetSizePixel() );
+ if ( aRect.IsInside( rDocPt ) )
+ return true;
+
+ Rectangle aLineRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() );
+ if ( aLineRect.IsInside( rDocPt ) )
+ return true;
+
+ return false;
+}
+
const SwPageFrm* SwPageBreakWin::GetPageFrame( )
{
return static_cast< const SwPageFrm * >( GetFrame( ) );
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 78d18fabd4c8..729c4c8bd6ee 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -188,17 +188,17 @@ DBG_NAME(edithdl)
namespace
{
- bool lcl_CheckHeaderFooterClick( SwWrtShell& rSh, const Point aDocPos, sal_uInt16 nClicks )
+ static bool lcl_CheckHeaderFooterClick( SwWrtShell& rSh, const Point &rDocPos, sal_uInt16 nClicks )
{
bool bRet = false;
- sal_Bool bOverHdrFtr = rSh.IsOverHeaderFooterPos( aDocPos );
+ sal_Bool bOverHdrFtr = rSh.IsOverHeaderFooterPos( rDocPos );
if ( ( rSh.IsHeaderFooterEdit( ) && !bOverHdrFtr ) ||
( !rSh.IsHeaderFooterEdit() && bOverHdrFtr ) )
{
bRet = true;
// Check if there we are in a FlyFrm
- Point aPt( aDocPos );
+ Point aPt( rDocPos );
SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() );
rSh.GetLayout()->GetCrsrOfst( aPam.GetPoint(), aPt );
@@ -209,7 +209,7 @@ namespace
if ( nClicks == nNbClicks )
{
- rSh.SwCrsrShell::SetCrsr( aDocPos );
+ rSh.SwCrsrShell::SetCrsr( rDocPos );
bRet = false;
}
}
@@ -1289,13 +1289,6 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
{
SwWrtShell &rSh = rView.GetWrtShell();
- // Hide the header/footer separator if not editing a header of footer
- if ( rSh.IsShowHeaderFooterSeparator( ) && !rSh.IsHeaderFooterEdit() )
- {
- rSh.SetShowHeaderFooterSeparator( sal_False );
- aOverHeaderFooterTimer.Stop();
- }
-
if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
pApplyTempl && pApplyTempl->pFormatClipboard )
{
@@ -2624,23 +2617,6 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
{
SwWrtShell &rSh = rView.GetWrtShell();
- // Hide the header/footer separator if not editing a header of footer
- if ( rSh.IsShowHeaderFooterSeparator( ) && !rSh.IsHeaderFooterEdit() )
- {
- const Point aDocPt( PixelToLogic( _rMEvt.GetPosPixel() ) );
- const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( aDocPt );
- if ( pPageFrm )
- {
- bool bOverHeadFoot = pPageFrm->IsOverHeaderFooterArea( aDocPt );
-
- if ( !bOverHeadFoot )
- {
- rSh.SetShowHeaderFooterSeparator( sal_False );
- aOverHeaderFooterTimer.Stop();
- }
- }
- }
-
// We have to check if a context menu is shown and we have an UI
// active inplace client. In that case we have to ignore the mouse
// button down event. Otherwise we would crash (context menu has been
@@ -3436,10 +3412,6 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
{
MouseEvent rMEvt(_rMEvt);
- // Mouse went out of the edit window: don't show the header/footer marker
- if ( rMEvt.IsLeaveWindow() )
- aOverHeaderFooterTimer.Stop();
-
//ignore key modifiers for format paintbrush
{
sal_Bool bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard
@@ -3832,23 +3804,16 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
}
else
rView.GetPostItMgr()->SetShadowState(0,false);
- // no break;
- // Are we over a header or footer area?
- const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( aDocPt );
- if ( pPageFrm )
+ // Are we moving from or to header / footer area?
+ if ( !rSh.IsHeaderFooterEdit() )
{
- bool bOverHeadFoot = pPageFrm->IsOverHeaderFooterArea( aDocPt );
- if ( bOverHeadFoot )
- aOverHeaderFooterTimer.Start();
- else
- {
- aOverHeaderFooterTimer.Stop();
- if ( !rSh.IsHeaderFooterEdit() && rSh.IsShowHeaderFooterSeparator() )
- aOverHeaderFooterTimer.Start();
- }
+ bool bIsInHF = IsInHeaderFooter( aDocPt );
+ if ( rSh.IsShowHeaderFooterSeparator() != bIsInHF )
+ ShowHeaderFooterSeparator( bIsInHF );
}
}
+ // no break;
case KEY_SHIFT:
case KEY_MOD2:
case KEY_MOD1:
@@ -4608,9 +4573,6 @@ SwEditWin::SwEditWin(Window *pParent, SwView &rMyView):
aKeyInputFlushTimer.SetTimeout( 200 );
aKeyInputFlushTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputFlushHandler));
- aOverHeaderFooterTimer.SetTimeout( 1000 );
- aOverHeaderFooterTimer.SetTimeoutHdl(LINK(this, SwEditWin, OverHeaderFooterHandler));
-
// TemplatePointer for colors should be resetted without
// selection after single click
aTemplateTimer.SetTimeout(400);
@@ -5431,18 +5393,6 @@ IMPL_LINK( SwEditWin, KeyInputTimerHandler, Timer *, EMPTYARG )
return 0;
}
-IMPL_LINK( SwEditWin, OverHeaderFooterHandler, Timer *, EMPTYARG )
-{
- if ( !GetView().GetWrtShell().IsHeaderFooterEdit() && IsMouseOver() )
- {
- // Toggle the Header/Footer separator
- sal_Bool bShown = GetView().GetWrtShell().IsShowHeaderFooterSeparator( );
- GetView().GetWrtShell().SetShowHeaderFooterSeparator( !bShown );
- Invalidate();
- }
- return 0;
-}
-
void SwEditWin::_InitStaticData()
{
pQuickHlpData = new QuickHelpData();
@@ -5697,6 +5647,42 @@ void SwEditWin::ShowAutoTextCorrectQuickHelp(
pQuickHlpData->Start( rSh, rWord.Len() );
}
+void SwEditWin::ShowHeaderFooterSeparator( bool bShow )
+{
+ SwWrtShell& rSh = rView.GetWrtShell();
+
+ if ( rSh.IsShowHeaderFooterSeparator() != bShow )
+ {
+ rSh.SetShowHeaderFooterSeparator( bShow );
+ Invalidate();
+ }
+}
+
+bool SwEditWin::IsInHeaderFooter( const Point &rDocPt ) const
+{
+ SwWrtShell &rSh = rView.GetWrtShell();
+ const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( rDocPt );
+
+ if ( pPageFrm && pPageFrm->IsOverHeaderFooterArea( rDocPt ) )
+ return true;
+
+ if ( rSh.IsShowHeaderFooterSeparator() )
+ {
+ SwFrameControlsManager &rMgr = rSh.GetView().GetEditWin().GetFrameControlsManager();
+ Point aPoint( LogicToPixel( rDocPt ) );
+
+ SwFrameControlPtr pControl = rMgr.GetControl( Header, pPageFrm );
+ if ( pControl.get() && pControl->Contains( aPoint ) )
+ return true;
+
+ pControl = rMgr.GetControl( Footer, pPageFrm );
+ if ( pControl.get() && pControl->Contains( aPoint ) )
+ return true;
+ }
+
+ return false;
+}
+
void SwEditWin::SetUseInputLanguage( sal_Bool bNew )
{
if ( bNew || bUseInputLanguage )
diff --git a/sw/source/ui/inc/FrameControl.hxx b/sw/source/ui/inc/FrameControl.hxx
index 4e52918c06b6..cf887a98cefc 100644
--- a/sw/source/ui/inc/FrameControl.hxx
+++ b/sw/source/ui/inc/FrameControl.hxx
@@ -30,6 +30,7 @@
class SwEditWin;
class SwFrm;
+struct Point;
/** Class representing a control linked to a SwFrm.
*/
@@ -61,6 +62,9 @@ public:
virtual void SetReadonly( bool bReadonly ) = 0;
virtual void ShowAll( bool bShow ) = 0;
+
+ /// Returns true if the point is inside the control.
+ virtual bool Contains( const Point &rDocPt ) const = 0;
};
#endif
diff --git a/sw/source/ui/inc/FrameControlsManager.hxx b/sw/source/ui/inc/FrameControlsManager.hxx
index 453466ec9cd0..ddfaaa00a2db 100644
--- a/sw/source/ui/inc/FrameControlsManager.hxx
+++ b/sw/source/ui/inc/FrameControlsManager.hxx
@@ -42,11 +42,14 @@ class SwEditWin;
enum FrameControlType
{
PageBreak,
- HeaderFooter
+ Header,
+ Footer
};
typedef boost::shared_ptr< SwFrameControl > SwFrameControlPtr;
+/** A container for the Header/Footer, or PageBreak controls.
+*/
class SwFrameControlsManager
{
private:
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index 247678ea75ae..c895b534846a 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -58,7 +58,8 @@ public:
virtual void MouseButtonDown( const MouseEvent& rMEvt );
virtual void Select( );
- void ShowAll( bool bShow );
+ virtual void ShowAll( bool bShow );
+ virtual bool Contains( const Point &rDocPt ) const;
bool IsHeader() { return m_bIsHeader; };
bool IsEmptyHeaderFooter( );
diff --git a/sw/source/ui/inc/PageBreakWin.hxx b/sw/source/ui/inc/PageBreakWin.hxx
index fa2631c787b4..e1967f3c2c94 100644
--- a/sw/source/ui/inc/PageBreakWin.hxx
+++ b/sw/source/ui/inc/PageBreakWin.hxx
@@ -59,7 +59,8 @@ public:
void UpdatePosition( );
- void ShowAll( bool bShow );
+ virtual void ShowAll( bool bShow );
+ virtual bool Contains( const Point &rDocPt ) const;
const SwPageFrm* GetPageFrame( );
diff --git a/sw/source/ui/inc/edtwin.hxx b/sw/source/ui/inc/edtwin.hxx
index 8cdcb1b1aec3..ca87b8988912 100644
--- a/sw/source/ui/inc/edtwin.hxx
+++ b/sw/source/ui/inc/edtwin.hxx
@@ -100,11 +100,6 @@ friend void PageNumNotify( ViewShell* pVwSh,
Timer aKeyInputTimer;
// timer for ANY-KeyInut question without a following KeyInputEvent
Timer aKeyInputFlushTimer;
- /*
- * timer for showing the Header/Footer separators when the mouse
- * stays over a header or footer area for several seconds.
- */
- Timer aOverHeaderFooterTimer;
String aInBuffer;
LanguageType eBufferLanguage;
@@ -199,9 +194,6 @@ friend void PageNumNotify( ViewShell* pVwSh,
// timer for overlapping KeyInputs (e.g. for tables)
DECL_LINK( KeyInputTimerHandler, Timer * );
- // timer for hovering header/footer areas
- DECL_LINK( OverHeaderFooterHandler, Timer * );
-
// timer for ApplyTemplates via mouse (in disguise Drag&Drop)
DECL_LINK( TemplateTimerHdl, Timer* );
@@ -235,6 +227,12 @@ protected:
void ShowAutoTextCorrectQuickHelp( const String& rWord, SvxAutoCorrCfg* pACfg,
SvxAutoCorrect* pACorr, sal_Bool bFromIME = sal_False );
+
+ /// Shows or hides the header & footer separators; only if there is a change.
+ void ShowHeaderFooterSeparator( bool bShow );
+
+ /// Returns true if in header/footer area, or in the header/footer control.
+ bool IsInHeaderFooter( const Point &rDocPt ) const;
public:
void UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx
index 879ccbed8b41..408da88351cb 100644
--- a/sw/source/ui/inc/wrtsh.hxx
+++ b/sw/source/ui/inc/wrtsh.hxx
@@ -491,7 +491,7 @@ typedef sal_Bool (SwWrtShell:: *FNSimpleMove)();
const SwRedline* GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect = sal_False);
void ChangeHeaderOrFooter(const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning);
- virtual void SetShowHeaderFooterSeparator( sal_Bool bShow );
+ virtual void SetShowHeaderFooterSeparator( bool bShow );
private:
diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx
index 9dcda67fd704..b67e43350d93 100644
--- a/sw/source/ui/wrtsh/wrtsh1.cxx
+++ b/sw/source/ui/wrtsh/wrtsh1.cxx
@@ -1889,11 +1889,14 @@ void SwWrtShell::ChangeHeaderOrFooter(
EndAllAction();
}
-void SwWrtShell::SetShowHeaderFooterSeparator( sal_Bool bShow )
+void SwWrtShell::SetShowHeaderFooterSeparator( bool bShow )
{
ViewShell::SetShowHeaderFooterSeparator( bShow );
if ( !bShow )
- GetView().GetEditWin().GetFrameControlsManager().HideControls( HeaderFooter );
+ {
+ GetView().GetEditWin().GetFrameControlsManager().HideControls( Header );
+ GetView().GetEditWin().GetFrameControlsManager().HideControls( Footer );
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */