summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-11-25 12:13:14 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-11-26 15:06:35 +0100
commit952242a20cdc4a0248a95c1e1d61b1c213ae270a (patch)
tree7599ba314f80cfb188ae8e42fbe0b1c8f3dd4d70 /svx
parent59fec754a1523eede0f19a59e4eeeff593a4d688 (diff)
factor out as a standalone "ButtonPressRepeater" class
Change-Id: Id89d5655c2428cecdaf9faa224133302c6448a87 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106600 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/fmcomp/gridctrl.cxx62
1 files changed, 4 insertions, 58 deletions
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index c5eb6ba50ac6..b004aed7d7d9 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -317,6 +317,8 @@ NavigationBar::NavigationBar(vcl::Window* pParent)
, m_xNextBtn(m_xBuilder->weld_button("next"))
, m_xLastBtn(m_xBuilder->weld_button("last"))
, m_xNewBtn(m_xBuilder->weld_button("new"))
+ , m_aPrevRepeater(*m_xPrevBtn, LINK(this,NavigationBar,OnClick))
+ , m_aNextRepeater(*m_xNextBtn, LINK(this,NavigationBar,OnClick))
, m_nCurrentPos(-1)
, m_bPositioning(false)
{
@@ -340,19 +342,6 @@ NavigationBar::NavigationBar(vcl::Window* pParent)
m_xLastBtn->connect_clicked(LINK(this,NavigationBar,OnClick));
m_xNewBtn->connect_clicked(LINK(this,NavigationBar,OnClick));
- // instead of connect_clicked because we want a button held down to
- // repeat the next/prev
- m_xPrevBtn->connect_mouse_press(LINK(this, NavigationBar, PrevMousePressHdl));
- m_xNextBtn->connect_mouse_press(LINK(this, NavigationBar, NextMousePressHdl));
- m_xPrevBtn->connect_mouse_release(LINK(this, NavigationBar, PrevMouseReleaseHdl));
- m_xNextBtn->connect_mouse_release(LINK(this, NavigationBar, NextMouseReleaseHdl));
-
- auto nRepeatTime = Application::GetSettings().GetMouseSettings().GetButtonRepeat();
- m_aNextRepeat.SetTimeout(nRepeatTime);
- m_aNextRepeat.SetInvokeHandler(LINK(this, NavigationBar, NextRepeatTimerHdl));
- m_aPrevRepeat.SetTimeout(nRepeatTime);
- m_aPrevRepeat.SetInvokeHandler(LINK(this, NavigationBar, PrevRepeatTimerHdl));
-
m_xRecordText->set_label(SvxResId(RID_STR_REC_TEXT));
m_xRecordOf->set_label(SvxResId(RID_STR_REC_FROM_TEXT));
m_xRecordCount->set_label(OUString('?'));
@@ -386,49 +375,6 @@ sal_uInt16 NavigationBar::ArrangeControls()
return m_xContainer->get_preferred_size().Width();
}
-IMPL_LINK_NOARG(NavigationBar, PrevRepeatTimerHdl, Timer*, void)
-{
- OnClick(*m_xPrevBtn);
-}
-
-IMPL_LINK_NOARG(NavigationBar, NextRepeatTimerHdl, Timer*, void)
-{
- OnClick(*m_xNextBtn);
-}
-
-IMPL_LINK_NOARG(NavigationBar, PrevMousePressHdl, const MouseEvent&, bool)
-{
- if (!m_xPrevBtn->get_sensitive())
- return false;
- PrevRepeatTimerHdl(nullptr);
- if (!m_xPrevBtn->get_sensitive())
- return false;
- m_aPrevRepeat.Start();
- return false;
-}
-
-IMPL_LINK_NOARG(NavigationBar, PrevMouseReleaseHdl, const MouseEvent&, bool)
-{
- m_aPrevRepeat.Stop();
- return false;
-}
-
-IMPL_LINK_NOARG(NavigationBar, NextMousePressHdl, const MouseEvent&, bool)
-{
- if (m_xNextBtn->get_sensitive())
- {
- NextRepeatTimerHdl(nullptr);
- m_aNextRepeat.Start();
- }
- return false;
-}
-
-IMPL_LINK_NOARG(NavigationBar, NextMouseReleaseHdl, const MouseEvent&, bool)
-{
- m_aNextRepeat.Stop();
- return false;
-}
-
IMPL_LINK(NavigationBar, OnClick, weld::Button&, rButton, void)
{
DbGridControl* pParent = static_cast<DbGridControl*>(GetParent());
@@ -631,9 +577,9 @@ void NavigationBar::SetState(DbGridControlNavigationBarState nWhich)
if (!bAvailable)
{
if (pWnd == m_xNextBtn.get())
- m_aNextRepeat.Stop();
+ m_aNextRepeater.Stop();
else if (pWnd == m_xPrevBtn.get())
- m_aPrevRepeat.Stop();
+ m_aPrevRepeater.Stop();
}
}