tagging release
[dasher.git] / Src / Win32 / Widgets / Canvas.h
blobcc30162c12c82615b4ec134e2ac2775f0afe8da7
1 // Canvas.h
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge.
6 //
7 /////////////////////////////////////////////////////////////////////////////
9 #ifndef __Canvas_h__
10 #define __Canvas_h__
12 #include "../TabletPC/CursorInRange.h"
13 #include "../../DasherCore/DasherComponent.h"
14 #include "../../DasherCore/DasherTypes.h"
15 #include "../KeyboardHelper.h"
17 namespace Dasher {
18 class CDasherMouseInput;
19 class CSocketInput;
20 class CDasher;
21 class CDasherInterfaceBase;
24 class CEdit;
25 class CScreen;
27 class CCanvas:
28 public ATL::CWindowImpl<CCanvas>,
29 public Dasher::CDasherComponent
31 public:
33 static ATL::CWndClassInfo& GetWndClassInfo()
35 static ATL::CWndClassInfo wc = \
36 { \
37 { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, StartWindowProc, \
38 0, 0, NULL, NULL, NULL, NULL, NULL, _T("CANVAS"), NULL }, \
39 NULL, NULL, MAKEINTRESOURCE(IDC_CROSS), TRUE, 0, _T("") \
40 }; \
41 return wc;
44 BEGIN_MSG_MAP( CCanvas )
45 MESSAGE_HANDLER(WM_PAINT, OnPaint)
46 MESSAGE_HANDLER(WM_CREATE, OnCreate)
47 MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
48 MESSAGE_HANDLER(WM_TIMER, OnTimer)
49 MESSAGE_HANDLER(WM_COMMAND, OnCommand)
50 MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
51 MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
52 MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
53 MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
54 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
55 MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
56 MESSAGE_HANDLER(WM_CURSOR_IN_RANGE, OnCursorInRange)
57 MESSAGE_HANDLER(WM_CURSOR_OUT_OF_RANGE, OnCursorOutOfRange)
58 MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
59 MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp)
60 MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
61 MESSAGE_HANDLER(WM_SIZE, OnSize)
63 END_MSG_MAP()
65 CCanvas(Dasher::CDasher *DI, Dasher::CEventHandler *pEventHandler, CSettingsStore *pSettingsStore);
66 ~CCanvas();
68 HWND Create(HWND hParent);
70 void DoFrame();
72 LRESULT OnSize(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
73 LRESULT OnMouseMove(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
74 LRESULT OnRButtonUp(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
75 LRESULT OnRButtonDown(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
76 LRESULT OnCursorInRange(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
77 LRESULT OnCursorOutOfRange(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
78 LRESULT OnLButtonDblClk(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
79 LRESULT OnLButtonDown(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
80 LRESULT OnLButtonUp(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
81 LRESULT OnPaint(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
82 LRESULT OnCreate(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
83 LRESULT OnDestroy(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
84 LRESULT OnTimer(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
85 LRESULT OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
86 LRESULT OnSetFocus(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
87 LRESULT OnKeyUp(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
88 LRESULT OnKeyDown(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
90 void Move(int x, int y, int Width, int Height);
91 void Paint();
95 HWND getwindow() {
96 return m_hWnd;
98 void StartOnLeftClick(bool Value) {
99 startonleft = Value;
103 void MousePosStart(bool Value);
104 void setkeycoords(int coords[18]) {
105 for(int i = 0; i < 18; i++) {
106 keycoords[i] = coords[i];
109 int *getkeycoords() {
110 return keycoords;
113 void setforward(bool value) {
114 forward = value;
116 void setbackward(bool value) {
117 backward = value;
119 void setselect(bool value) {
120 select = value;
122 bool getforward() {
123 return forward;
125 bool getbackward() {
126 return backward;
128 bool getselect() {
129 return select;
132 void centrecursor();
133 void StartStop();
135 void Pause() {
136 running = 0;
138 bool Running() {
139 return running;
141 void SetScreenInterface(Dasher::CDasherInterfaceBase * dasherinterface);
143 int OnTimer();
145 bool GetCanvasSize(int& pTop, int& pLeft, int& pBottom, int& pRight);
147 void HandleEvent(Dasher::CEvent *pEvent);
149 private:
151 HDC m_hdc;
152 int keycoords[18], buttonnum, yscaling;
153 bool forward, backward, select;
154 CScreen *m_pScreen;
155 Dasher::CDasher * m_pDasherInterface;
157 // Input devices:
159 //Dasher::CDasherMouseInput * m_pMouseInput;
160 //Dasher::CSocketInput * m_pSocketInput;
162 Dasher::screenint imousex, imousey;
163 UINT MY_TIMER;
164 bool startonleft;
165 bool direction;
166 bool running;
167 bool firstwindow;
168 bool secondwindow;
169 bool lbuttonheld;
170 bool inturbo;
171 bool enabletime;
172 DWORD startturbo;
173 DWORD endturbo;
174 DWORD lastlbutton;
175 DWORD mousepostime;
176 DWORD previoustime;
177 RECT coords;
179 // Indicates that a button is depressed, so we dont stop on idle
180 bool m_bButtonDown;
181 // Ticks as last event, for stop on idle
182 DWORD m_dwTicksLastEvent;
184 // Enables tablet pc events
185 CCursorInRange m_CursorInRange;
187 CKeyboardHelper *m_pKeyboardHelper;
191 #endif /* #ifndef __Canvas_h__ */