Updated German translation
[dasher.git] / Src / DasherCore / AlternatingDirectMode.cpp
blobd4740de35df42e21f52419f95eaddcad7af3b92a
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"
11 #include <valarray>
12 #include <iostream>
14 // Track memory leaks on Windows to the line that new'd the memory
15 #ifdef _WIN32
16 #ifdef _DEBUG_MEMLEAKS
17 #define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ )
18 #define new DEBUG_NEW
19 #undef THIS_FILE
20 static char THIS_FILE[] = __FILE__;
21 #endif
22 #endif
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];
40 // Fast boxes
42 m_pBoxes[0].iTop = 0;
43 m_pBoxes[0].iBottom = 1000;
44 m_pBoxes[1].iTop = 3096;
45 m_pBoxes[1].iBottom = 4096;
47 // Slow boxes
49 m_pBoxes[2].iTop = 0;
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);
69 m_iLastBox = -1;
72 bool CAlternatingDirectMode::DecorateView(CDasherView *pView, CDasherInput *pInput) {
74 if(m_iLastBox == 1) {
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);
79 else {
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;
87 return bRV;
91 void CAlternatingDirectMode::DirectKeyDown(unsigned long iTime, int iId, CDasherView *pView, CDasherModel *pModel) {
92 int iTargetBox;
93 switch(iId) {
94 case 2:
95 iTargetBox = (m_iLastBox == 1) ? 2 : 0;
96 m_iLastBox = 1;
97 break;
98 case 3:
99 case 4:
100 iTargetBox = (m_iLastBox==2) ? 3 : 1;
101 m_iLastBox = 2;
102 break;
103 case 1:
104 iTargetBox = 4;
105 break;
106 default:
107 //unknown button...do nothing (?)
108 return;
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);
118 return true;