Update Turkish translation
[dasher.git] / Src / DasherCore / DasherInput.h
blobb5998ec4aa2724943070be3d2f3ee276a8859ec3
1 // DasherInput.h
2 //
3 // Copyright (c) 2005 Phil Cowans
5 #ifndef __DasherInput_h__
6 #define __DasherInput_h__
8 #include "DasherTypes.h"
9 #include "DasherModule.h"
10 #include "ModuleManager.h"
11 #include "DasherView.h"
13 namespace Dasher {
14 class CDasherInput;
15 class CDasherCoordInput;
16 class CScreenCoordInput;
17 class CDasherInterfaceBase;
19 /// \defgroup Input Input devices
20 /// \{
21 class Dasher::CDasherInput : public CDasherModule {
23 public:
25 CDasherInput(ModuleID_t iID, const char *szName)
26 : CDasherModule(iID, InputDevice, szName) {};
28 /// Get the position of the input in Dasher coordinates.
29 /// \param iDasherX X-coordinate; if only one coordinate (axis) is available, this should be 0.
30 /// \param iDasherY Y-coordinate; if only one coordinate (axis) is available, this should be it.
31 /// \param pView view to use to convert Screen2Dasher, if necessary
32 /// \return true if coordinates were obtained; false if they could not be.
33 virtual bool GetDasherCoords(myint &iDasherX, myint &iDasherY, CDasherView *pView)=0;
35 /// Get the position of the input in screen coordinates. If only one coordinate (axis) is available,
36 /// it should be returned in Y for left-to-right / right-to-left orientations, X for top-to-bottom/
37 /// bottom-to-top. (As would happen if performing Dasher2Screen on values obtained from GetDasherCoords!)
38 /// \param iX Screen X-coordinate
39 /// \param iY Screen Y-coordinate
40 /// \param pView view to use to convert Dasher2Screen, if necessary
41 /// \return true if coordinates were obtained; false if they could not be.
42 virtual bool GetScreenCoords(screenint &iX, screenint &iY, CDasherView *pView)=0;
44 /// Activate the device. If a helper thread needs to be started in
45 /// order to listen for input then do it here.
46 virtual void Activate() {};
48 /// Deactivate the device. Please don't hold on to any significant
49 /// resources (eg helper threads) after deactivation.
50 virtual void Deactivate() {};
52 /// Handle key down events
53 ///
54 virtual void KeyDown(unsigned long iTime, int iId) {};
56 ///
57 /// Handle key up events
58 virtual void KeyUp(unsigned long iTime, int iId) {};
60 ///Abstract superclasses for CDasherInputs which natively provide screen coordinates;
61 /// thus, when dasher-coordinates are requested, they will be converted
62 /// via the views Screen2Dasher. (=>Subclasses must implement GetScreenCoords)
63 class Dasher::CScreenCoordInput : public CDasherInput {
64 public:
65 CScreenCoordInput(ModuleID_t iId, const char *szName)
66 : CDasherInput(iId, szName) {
68 virtual bool GetDasherCoords(myint &iDasherX, myint &iDasherY, CDasherView *pView) {
69 screenint iX, iY;
70 if (!GetScreenCoords(iX, iY, pView)) return false;
71 pView->Screen2Dasher(iX, iY, iDasherX, iDasherY);
72 return true;
76 ///Abstract superclasses for CDasherInputs which natively provide dasher coordinates;
77 /// thus, when screen-coordinates are requested, they will be converted
78 /// via the views Dasher2Screen. (=>Subclasses must implement GetDasherCoords)
79 class Dasher::CDasherCoordInput : public CDasherInput {
80 public:
81 CDasherCoordInput(ModuleID_t iId, const char *szName)
82 : CDasherInput(iId, szName) {
85 virtual bool GetScreenCoords(screenint &iX, screenint &iY, CDasherView *pView) {
86 myint iDasherX, iDasherY;
87 if (!GetDasherCoords(iDasherX, iDasherY, pView)) return false;
88 pView->Dasher2Screen(iDasherX, iDasherY, iX, iY);
89 return true;
94 /// \}
95 #endif