File: mouse_input.h

package info (click to toggle)
dasher 5.0.0~beta~repack2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 70,872 kB
  • sloc: xml: 181,314; cpp: 70,860; java: 8,020; python: 3,579; makefile: 939; sh: 324; ansic: 223; perl: 71
file content (106 lines) | stat: -rw-r--r-- 2,282 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef __mouse_input_h__
#define __mouse_input_h__

#include "../Common/Common.h"
#include "../DasherCore/DasherInput.h"
#include "../DasherCore/DasherTypes.h"

#include <iostream>

using namespace Dasher;

class CDasherMouseInput : public CScreenCoordInput {
public:
  CDasherMouseInput() : CScreenCoordInput(0, _("Mouse Input")) {

    m_iX = 0;
    m_iY = 0;
  };

  // Fill pCoordinates with iN coordinate values, return 0 if the
  // values were in screen coordinates or 1 if the values were in
  // Dasher coordinates.

  virtual bool GetScreenCoords(screenint &iX, screenint &iY, CDasherView *pView) {

    iX = m_iX;
    iY = m_iY;

    return true;
  };

  void SetCoordinates(myint _iX, myint _iY) {
    m_iX = _iX;
    m_iY = _iY;
  };

private:
  myint m_iX;
  myint m_iY;

};

static SModuleSettings sSettings[] = {
  {LP_YSCALE, T_LONG, 10, 2000, 1, 1, _("Pixels covering Y range")}
};

class CDasher1DMouseInput : public CDasherCoordInput {
public:
  CDasher1DMouseInput() 
    /* TRANSLATORS: Only use the vertical mouse coordinate - this is prefered for some disabled users. */
    : CDasherCoordInput(2, _("One Dimensional Mouse Input")) {

    m_iOffset = 0;

    m_iY = 0;
    m_iRealY = 0;
  };

  // Fill pCoordinates with iN coordinate values, return 0 if the
  // values were in screen coordinates or 1 if the values were in
  // Dasher coordinates.

  virtual bool GetDasherCoords(myint &iDasherX, myint &iDasherY, CDasherView *pView) override {
    iDasherX=0;
    iDasherY = m_iY; 
    return true;
  };

  virtual void SetMaxCoordinates(int iN, myint * iDasherMax) {
    // FIXME - need to cope with the more general case here

    m_iDasherMaxX = iDasherMax[0];
    m_iDasherMaxY = iDasherMax[1];
  };

  void SetCoordinates(myint iY, myint iScale) {
    m_iRealY = iY;
    m_iY = (iY - m_iOffset) * 4096 / iScale + 2048;
  };

  void KeyDown(unsigned long iTime, int iId) override {
    if(iId == 10) {
      m_iOffset = m_iRealY;
    }
  };

  bool GetSettings(SModuleSettings **pSettings, int *iCount) override {
    *pSettings = sSettings;
    *iCount = sizeof(sSettings) / sizeof(SModuleSettings);
    
    return true;
  };

private:

  myint m_iDasherMaxX;
  myint m_iDasherMaxY;

  myint m_iY;

  myint m_iRealY;

  myint m_iOffset;
};

#endif