3 // Copyright (c) 2001-2005 David Ward
5 #ifndef __DasherView_h_
6 #define __DasherView_h_
12 class CDasherComponent
;
16 #include "DasherTypes.h"
17 #include "DasherComponent.h"
20 // CDasherView is an abstract view class
21 // See the CDasherViewSquare class for an example
23 // DJW 200504 - at the moment its quite hard work to plug in a new view
25 ////// \brief View base class.
26 ////// Dasher views represent the visualisation of a Dasher model on the screen.
27 ////// Note that we really should aim to avoid having to try and keep
28 /// multiple pointers to the same object (model etc.) up-to-date at
29 /// once. We should be able to avoid the need for this just by being
30 /// sane about passing pointers as arguments to the relevant
31 /// functions, for example we could pass a pointer to the canvas every
32 /// time we call the render routine, rather than worrying about
33 /// notifying this object every time it changes. The same logic can be
34 /// applied in several other places.
36 /// We should also attempt to try and remove the need for this class
37 /// to know about the model. When we call render we should just pass a
38 /// pointer to the root node, which we can obtain elsewhere, and make
39 /// sure that the data structure contains all the info we need to do
40 /// the rendering (eg make sure it contains strings as well as symbol
42 ////// There are really three roles played by CDasherView: providing high
43 /// level drawing functions, providing a mapping between Dasher
44 /// co-ordinates and screen co-ordinates and providing a mapping
45 /// between true and effective Dasher co-ordinates (eg for eyetracking
46 /// mode). We should probably consider creating separate classes for
49 class Dasher::CDasherView
:public CDasherComponent
54 /// \param pEventHandler Pointer to the event handler
55 /// \param pSettingsStore Pointer to the settings store
56 /// \param DasherScreen Pointer to the CDasherScreen object used to do rendering
57 /// \param DasherModel Reference to the CDasherModel which is to be represented
59 CDasherView(CEventHandler
* pEventHandler
, CSettingsStore
* pSettingsStore
, CDasherScreen
* DasherScreen
, CDasherModel
* DasherModel
);
60 virtual ~ CDasherView() {
63 /// \param pEvent Pointer to incoming event
64 virtual void HandleEvent(Dasher::CEvent
* pEvent
);
66 /// \deprecated Use parameter interface instead
68 void ChangeOrientation(Dasher::Opts::ScreenOrientations Orientation
);
70 virtual bool CheckForNewRoot() {};
72 //void SetDrawKeyboard(bool bDrawKeyboard);
74 // 0 - no box, 1 - upper box, 2 - lower box
75 //void SetDrawMousePosBox(int MousePosBox);
77 /// Render the display
79 virtual void Render();
81 /// Renders Dasher with mouse-dependent items
82 /// \todo Clarify relationship between Render functions and probably only expose one
84 virtual bool Render(int iMouseX
, int iMouseY
, bool bRedrawDisplay
);
86 /// Renders the Dasher node structure
87 /// \todo Shouldn't be public?
89 virtual void RenderNodes() = 0;
91 /// Translates the screen coordinates to Dasher coordinates and calls
92 /// dashermodel.TapOnDisplay
94 virtual void TapOnDisplay(screenint mousex
, screenint mousey
, unsigned long Time
, VECTOR_SYMBOL_PROB
* pAdded
= NULL
, int* pNumDeleted
= NULL
)=0;
98 virtual void ClickTo(int x
, int y
, int width
, int height
) = 0;
100 /// Handles start-on-mouse behaviour - check whether we are in the box, and change box or start on timer,.
101 /// \param iTime Current time in ms.
103 virtual bool HandleStartOnMouse(int iTime
) = 0;
105 /// translates the screen coordinates to Dasher coordinates and calls
108 virtual void GoTo(screenint mousex
, screenint mousey
) = 0;
110 /// Change the screen - must be called if the Screen is replaced or resized
111 /// \param NewScreen Pointer to the new CDasherScreen.
113 virtual void ChangeScreen(CDasherScreen
* NewScreen
);
115 /// Get autocallibration offset
116 /// \retval Current offset
118 virtual int GetAutoOffset() const {
121 ////// \todo Document this
122 virtual void DrawGoTo(screenint mousex
, screenint mousey
) = 0;
124 /// Draw the mouse cursor
125 /// \todo Probably shouldn't be public
127 virtual void DrawMouse(screenint mousex
, screenint mousey
) = 0;
129 /// Draw the mouse line
130 /// \todo Probably shouldn't be public
132 virtual void DrawMouseLine(screenint mousex
, screenint mousey
) = 0;
134 /// \todo Document this
136 virtual void DrawKeyboard() = 0;
138 /// \todo Document this
140 virtual void DrawMousePosBox();
142 /// Draw the game mode pointer
144 virtual void DrawGameModePointer() = 0;
147 /// Return a reference to the model
149 CDasherModel
* DasherModel() {
150 return m_pDasherModel
;
155 const CDasherModel
* DasherModel() const {
156 return m_pDasherModel
;
158 ////// Return a reference to the screen
160 CDasherScreen
* Screen() {
164 /// Request the Screen to copy its buffer to the Display
165 /// \todo Shouldn't be public?
169 /// \todo Document this
171 virtual void ResetSum() {
174 /// \todo Document this
176 virtual void ResetSumCounter() {
179 /// \todo Document this
181 virtual void ResetYAutoOffset() {
184 /// Set the input device class. Note that this class will now assume ownership of the pointer, ie it will delete the object when it's done with it.
185 /// \param _pInput Pointer to the new CDasherInput.
187 void SetInput(CDasherInput
* _pInput
);
189 /// Get the co-ordinates from the input device
190 /// \todo This shouldn't be public?
192 int GetCoordinates(int iN
, myint
* pCoordinates
);
194 /// Get the co-ordinate count from the input device
196 int GetCoordinateCount();
199 // Orientation of Dasher Screen
200 inline void MapScreen(screenint
* DrawX
, screenint
* DrawY
);
201 inline void UnMapScreen(screenint
* DrawX
, screenint
* DrawY
);
204 CDasherScreen
* m_pScreen
; // provides the graphics (text, lines, rectangles):
205 CDasherModel
* m_pDasherModel
; // Model view represents
206 CDasherInput
*m_pInput
; // Input device abstraction
208 // Pure virtuals to implement
209 virtual void Crosshair(myint sx
) = 0; // Tells m_Screen to draw a crosshair - or other static decoration
212 #include "DasherView.inl"
214 #endif /* #ifndef __DasherView_h_ */