1 // DasherButtons.cpp, build a set of boxes for Button Dasher.
2 // Copyright 2005, Chris Ball and David MacKay. GPL.
4 // Idea - should back off button always just undo the previous 'forwards' button?
6 #include "../Common/Common.h"
8 #include "AlternatingDirectMode.h"
9 #include "DasherScreen.h"
10 #include "DasherInterfaceBase.h"
14 // Track memory leaks on Windows to the line that new'd the memory
16 #ifdef _DEBUG_MEMLEAKS
17 #define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ )
20 static char THIS_FILE
[] = __FILE__
;
24 using namespace Dasher
;
26 static SModuleSettings sSettings
[] = {
27 /* TRANSLATORS: The number of time steps over which to perform the zooming motion in button mode. */
28 {LP_ZOOMSTEPS
, T_LONG
, 1, 63, 1, 1, _("Frames over which to perform zoom")},
29 /* TRANSLATORS: Intercept keyboard events for 'special' keys even when the Dasher window doesn't have keyboard focus.*/
30 {BP_GLOBAL_KEYBOARD
, T_BOOL
, -1, -1, -1, -1, _("Global keyboard grab")}
33 CAlternatingDirectMode::CAlternatingDirectMode(CSettingsUser
*pCreator
, CDasherInterfaceBase
*pInterface
)
34 : CDasherButtons(pCreator
, pInterface
, false/*menu*/, 12, _("Alternating Direct Mode")) {}
36 void CAlternatingDirectMode::SetupBoxes()
38 m_pBoxes
= new SBoxInfo
[m_iNumBoxes
= 5];
43 m_pBoxes
[0].iBottom
= 1000;
44 m_pBoxes
[1].iTop
= 3096;
45 m_pBoxes
[1].iBottom
= 4096;
50 m_pBoxes
[2].iBottom
= 3096;
51 m_pBoxes
[3].iTop
= 1000;
52 m_pBoxes
[3].iBottom
= 4096;
54 m_pBoxes
[0].iDisplayTop
= m_pBoxes
[0].iTop
;
55 m_pBoxes
[0].iDisplayBottom
= m_pBoxes
[0].iBottom
;
56 m_pBoxes
[1].iDisplayTop
= m_pBoxes
[1].iTop
;
57 m_pBoxes
[1].iDisplayBottom
= m_pBoxes
[1].iBottom
;
58 m_pBoxes
[2].iDisplayTop
= m_pBoxes
[2].iTop
;
59 m_pBoxes
[2].iDisplayBottom
= m_pBoxes
[2].iBottom
;
60 m_pBoxes
[3].iDisplayTop
= m_pBoxes
[3].iTop
;
61 m_pBoxes
[3].iDisplayBottom
= m_pBoxes
[3].iBottom
;
63 m_pBoxes
[m_iNumBoxes
-1].iDisplayTop
= 0;
64 m_pBoxes
[m_iNumBoxes
-1].iDisplayBottom
= CDasherModel::MAX_Y
;
66 m_pBoxes
[m_iNumBoxes
-1].iTop
= int(- CDasherModel::MAX_Y
/ 2);
67 m_pBoxes
[m_iNumBoxes
-1].iBottom
= int(CDasherModel::MAX_Y
* 1.5);
72 bool CAlternatingDirectMode::DecorateView(CDasherView
*pView
, CDasherInput
*pInput
) {
75 NewDrawGoTo(pView
, m_pBoxes
[2].iDisplayTop
, m_pBoxes
[2].iDisplayBottom
, false);
76 NewDrawGoTo(pView
, m_pBoxes
[1].iDisplayTop
, m_pBoxes
[3].iDisplayBottom
, false);
77 NewDrawGoTo(pView
, m_pBoxes
[4].iDisplayTop
, m_pBoxes
[4].iDisplayBottom
, false);
80 NewDrawGoTo(pView
, m_pBoxes
[0].iDisplayTop
, m_pBoxes
[0].iDisplayBottom
, false);
81 NewDrawGoTo(pView
, m_pBoxes
[3].iDisplayTop
, m_pBoxes
[1].iDisplayBottom
, false);
82 NewDrawGoTo(pView
, m_pBoxes
[4].iDisplayTop
, m_pBoxes
[4].iDisplayBottom
, false);
85 bool bRV(m_bDecorationChanged
);
86 m_bDecorationChanged
= false;
91 void CAlternatingDirectMode::DirectKeyDown(unsigned long iTime
, int iId
, CDasherView
*pView
, CDasherModel
*pModel
) {
95 iTargetBox
= (m_iLastBox
== 1) ? 2 : 0;
100 iTargetBox
= (m_iLastBox
==2) ? 3 : 1;
107 //unknown button...do nothing (?)
110 //iTargetBox now indicates the box into which to zoom
111 ScheduleZoom(pModel
, m_pBoxes
[iTargetBox
].iTop
, m_pBoxes
[iTargetBox
].iBottom
);
114 bool CAlternatingDirectMode::GetSettings(SModuleSettings
**pSettings
, int *iCount
) {
115 *pSettings
= sSettings
;
116 *iCount
= sizeof(sSettings
) / sizeof(SModuleSettings
);