diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-02-25 14:39:42 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-03-02 11:38:17 +0900 |
commit | 8127b06fa4661bb743bfc432bcae4c089c72c76a (patch) | |
tree | 60718e79b3fc10c214c48de5db42dfac796f3b8b /svtools | |
parent | 05de5c9bf3bc989c72f081d8415c079f4b2ecf36 (diff) |
tabbar buttons next/previous act as last/first if MOD1 is pressed
If user presses MOD1 (ctrl) key, the next / previous will act
as last / first button. This support removes the need for last /
first button.
Change-Id: I53c9cf0b4963ed4f4c99eb47c21e643e1c6f9110
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/tabbar.cxx | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index e80af1e53a8a..d09675f4468b 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -93,9 +93,12 @@ struct ImplTabBarItem class ImplTabButton : public PushButton { + bool mbModKey : 1; + public: ImplTabButton(TabBar* pParent, WinBits nWinStyle = 0) : PushButton(pParent, nWinStyle | WB_FLATBUTTON | WB_RECTSTYLE | WB_SMALLSTYLE | WB_NOLIGHTBORDER | WB_NOPOINTERFOCUS) + , mbModKey(false) {} TabBar* GetParent() const @@ -103,16 +106,28 @@ public: return static_cast<TabBar*>(Window::GetParent()); } + bool isModKeyPressed() + { + return mbModKey; + } + virtual bool PreNotify(NotifyEvent& rNotifyEvent) SAL_OVERRIDE; virtual void MouseButtonDown(const MouseEvent& rMouseEvent) SAL_OVERRIDE; + virtual void MouseButtonUp(const MouseEvent& rMouseEvent) SAL_OVERRIDE; virtual void Command(const CommandEvent& rCommandEvent) SAL_OVERRIDE; }; void ImplTabButton::MouseButtonDown(const MouseEvent& rMouseEvent) { + mbModKey = rMouseEvent.IsMod1(); PushButton::MouseButtonDown(rMouseEvent); } +void ImplTabButton::MouseButtonUp(const MouseEvent& rMouseEvent) +{ + mbModKey = false; + PushButton::MouseButtonUp(rMouseEvent); +} void ImplTabButton::Command(const CommandEvent& rCommandEvent) { @@ -818,28 +833,35 @@ IMPL_LINK( TabBar, ImplClickHdl, ImplTabButton*, pBtn ) sal_uInt16 nNewPos = mnFirstPos; - if ( pBtn == mpFirstBtn ) + if (pBtn == mpFirstBtn || (pBtn == mpPrevBtn && pBtn->isModKeyPressed())) + { nNewPos = 0; - else if ( pBtn == mpPrevBtn ) + } + else if (pBtn == mpLastBtn || (pBtn == mpNextBtn && pBtn->isModKeyPressed())) { - if ( mnFirstPos ) - nNewPos = mnFirstPos-1; + sal_uInt16 nCount = GetPageCount(); + if (nCount) + nNewPos = nCount - 1; + } + else if (pBtn == mpPrevBtn) + { + if (mnFirstPos) + nNewPos = mnFirstPos - 1; } - else if ( pBtn == mpNextBtn ) + else if (pBtn == mpNextBtn) { sal_uInt16 nCount = GetPageCount(); - if ( mnFirstPos < nCount ) + if (mnFirstPos < nCount) nNewPos = mnFirstPos+1; } else { - sal_uInt16 nCount = GetPageCount(); - if ( nCount ) - nNewPos = nCount-1; + return 0; } - if ( nNewPos != mnFirstPos ) - SetFirstPageId( GetPageId( nNewPos ) ); + if (nNewPos != mnFirstPos) + SetFirstPageId(GetPageId(nNewPos)); + return 0; } |