tagging release
[dasher.git] / trunk / Src / Gtk2 / mouse_input.h
blob4bb66219ca673a2efb29a3620d5d3ddf10eb8939
1 #ifndef __mouse_input_h__
2 #define __mouse_input_h__
4 #include "../Common/Common.h"
5 #include "../DasherCore/DasherInput.h"
6 #include "../DasherCore/DasherTypes.h"
8 #include <iostream>
10 using namespace Dasher;
12 class CDasherMouseInput : public CDasherInput {
13 public:
14 CDasherMouseInput(CEventHandler * pEventHandler, CSettingsStore * pSettingsStore)
15 : CDasherInput(pEventHandler, pSettingsStore, 0, 0, _("Mouse Input")) {
17 m_iX = 0;
18 m_iY = 0;
21 // Fill pCoordinates with iN coordinate values, return 0 if the
22 // values were in screen coordinates or 1 if the values were in
23 // Dasher coordinates.
25 virtual int GetCoordinates(int iN, myint * pCoordinates) {
27 pCoordinates[0] = m_iX;
28 pCoordinates[1] = m_iY;
30 return 0;
33 // Get the number of co-ordinates that this device supplies
35 virtual int GetCoordinateCount() {
36 return 2;
39 void SetCoordinates(myint _iX, myint _iY) {
40 m_iX = _iX;
41 m_iY = _iY;
44 private:
45 myint m_iX;
46 myint m_iY;
50 static SModuleSettings sSettings[] = {
51 {LP_YSCALE, T_LONG, 10, 2000, 1, 1, "Pixels covering Y range:"}
54 class CDasher1DMouseInput:public CDasherInput {
55 public:
56 CDasher1DMouseInput(CEventHandler * pEventHandler, CSettingsStore * pSettingsStore)
57 : CDasherInput(pEventHandler, pSettingsStore, 2, 0, _("One Dimensional Mouse Input")) {
59 m_iOffset = 0;
61 m_iY = 0;
62 m_iRealY = 0;
65 // Fill pCoordinates with iN coordinate values, return 0 if the
66 // values were in screen coordinates or 1 if the values were in
67 // Dasher coordinates.
69 virtual int GetCoordinates(int iN, myint * pCoordinates) {
70 pCoordinates[0] = m_iY;
71 return 1;
74 // Get the number of co-ordinates that this device supplies
76 virtual int GetCoordinateCount() {
77 return 1;
80 virtual void SetMaxCoordinates(int iN, myint * iDasherMax) {
81 // FIXME - need to cope with the more general case here
83 m_iDasherMaxX = iDasherMax[0];
84 m_iDasherMaxY = iDasherMax[1];
87 void SetCoordinates(myint iY, myint iScale) {
88 m_iRealY = iY;
89 m_iY = (iY - m_iOffset) * 4096 / iScale + 2048;
92 void KeyDown(int iTime, int iId) {
93 if(iId == 10) {
94 m_iOffset = m_iRealY;
98 bool GetSettings(SModuleSettings **pSettings, int *iCount) {
99 *pSettings = sSettings;
100 *iCount = sizeof(sSettings) / sizeof(SModuleSettings);
102 return true;
105 private:
107 myint m_iDasherMaxX;
108 myint m_iDasherMaxY;
110 myint m_iY;
112 myint m_iRealY;
114 myint m_iOffset;
117 #endif