~ubuntu-branches/ubuntu/oneiric/dasher/oneiric

« back to all changes in this revision

Viewing changes to Src/DasherCore/ButtonMultiPress.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2010-04-23 07:56:20 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100423075620-qpr1ousiruyxs1fb
Tags: 4.11-1
* New upstream release:
  + debian/control.in:
    - Update build dependencies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ButtonMultiPress.cpp
 
2
//
 
3
// Copyright (c) 2007 The Dasher Team
 
4
//
 
5
// This file is part of Dasher.
 
6
//
 
7
// Dasher is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or
 
10
// (at your option) any later version.
 
11
//
 
12
// Dasher is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
// GNU General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with Dasher; if not, write to the Free Software 
 
19
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 
 
21
#include "DasherInterfaceBase.h"
 
22
#include "ButtonMultiPress.h"
 
23
 
 
24
using namespace Dasher;
 
25
 
 
26
CButtonMultiPress::CButtonMultiPress(Dasher::CEventHandler * pEventHandler, CSettingsStore *pSettingsStore, CDasherInterfaceBase *pInterface, ModuleID_t iID, int iType, const char *szName)
 
27
  : CDynamicFilter(pEventHandler, pSettingsStore, pInterface, iID, iType, szName) {
 
28
}
 
29
 
 
30
void CButtonMultiPress::KeyDown(int iTime, int iId, CDasherView *pView, CDasherModel *pModel, CUserLogBase *pUserLog) {
 
31
 
 
32
  if (m_bKeyDown) return;
 
33
      
 
34
  // Check for multiple clicks
 
35
  if(iId == m_iQueueId && m_deQueueTimes.size()) {
 
36
    if ( (iTime - m_deQueueTimes.back()) > GetLongParameter(LP_MULTIPRESS_TIME) )
 
37
      m_deQueueTimes.clear(); //and fall through to record+process normally, below
 
38
    else
 
39
    {
 
40
      //previous presses should not be treated as such....
 
41
      RevertPresses(m_deQueueTimes.size());
 
42
      //...but should be combined with this one into a new event (type = #presses)
 
43
      Event(iTime, iId, m_deQueueTimes.size()+1, pModel, pUserLog);
 
44
      if (m_deQueueTimes.size() >= maxClickCount() - 1)
 
45
        m_deQueueTimes.clear(); //final press
 
46
      else //may still be more presses to come
 
47
        m_deQueueTimes.push_back(iTime);
 
48
      return; //we've called Event ourselves, so finished.
 
49
    }
 
50
  }
 
51
  else
 
52
  {
 
53
    m_deQueueTimes.clear(); //clear record of previous, different, button
 
54
    m_iQueueId = iId;
 
55
  }
 
56
 
 
57
  // Record press...
 
58
  m_deQueueTimes.push_back(iTime);
 
59
  // ... and process normally; if it changes the state, pause()/reverse()'ll clear the queue
 
60
  CDynamicFilter::KeyDown(iTime, iId, pView, pModel, pUserLog);
 
61
}
 
62
 
 
63
void CButtonMultiPress::pause()
 
64
{
 
65
  CDynamicFilter::pause();
 
66
  m_deQueueTimes.clear();
 
67
}
 
68
 
 
69
void CButtonMultiPress::reverse()
 
70
{
 
71
  CDynamicFilter::reverse();
 
72
  m_deQueueTimes.clear();
 
73
}
 
74
 
 
75
void CButtonMultiPress::run()
 
76
{
 
77
  if (!isRunning()) m_deQueueTimes.clear();
 
78
  CDynamicFilter::run();
 
79
}