1 #ifndef __dashercontrol_h__
2 #define __dashercontrol_h__
4 #include "../../config.h"
6 #include "PangoCache.h"
8 #include "../DasherCore/SocketInput.h"
11 #include "joystick_input.h"
14 #include "mouse_input.h"
16 #include "GtkDasherControl.h"
17 //#include "KeyboardHelper.h"
19 //#include "../DasherCore/DasherSettingsInterface.h"
20 #include "../DasherCore/DasherInterfaceBase.h"
21 #include "../DasherCore/GnomeSettingsStore.h"
22 #include "../DasherCore/UserLog.h"
25 /// \brief C++ core of the Dasher GTK UI component.
27 /// Class representing the Dasher UI component (ie the canvas and speed slider)
28 /// \todo It would really be more sensible for CDasherControl to inheret from CDasherInterface rather than contain a pointer to it
31 class CDasherControl
: public CDasherInterfaceBase
{
36 /// \param pVBox GTK VBox to populate with the DasherControl
37 /// component widgets. This needs to be created externally by the
38 /// GObject wrapper and passed to the C++ class rather than being
39 /// created internally.
40 /// \param pDasherControl Pointer to the GObject wrapper. This is
41 /// needed so that we can emit signals from the GObject.
44 CDasherControl(GtkVBox
* pVbox
, GtkDasherControl
* pDasherControl
);
48 // FIXME - we should probably pass all parameters to these from the "C" callbacks
53 /// GTK Signal handler for the canvas getting the focus (which it gives away to the edit box)
56 bool FocusEvent(GtkWidget
*pWidget
, GdkEventFocus
*pEvent
);
60 /// Called when the canvas gets realized (ie when internal resources have been allocated), so we can finalise setup.
63 void RealizeCanvas(GtkWidget
*pWidget
);
66 /// Called periodically by a timer. Used to prompt the interface to perform a redraw
67 /// \todo There's rather a lot which happens in this
68 /// function. Ideally it should just be a simple call to the core
69 /// which then figures out whether we're paused or not etc.
77 /// Mouse button pressed on the canvas
80 gboolean
ButtonPressEvent(GdkEventButton
* event
);
83 /// Called when the canvas has been resized, prompts the (re)creation of the CCanvas object.
86 int CanvasConfigureEvent();
89 /// Speed slider has been moved.
95 /// Called when the canvas GTK widget is destroyed, so we can free any references to it.
98 void CanvasDestroyEvent();
101 /// Key press event on the canvas
104 gint
KeyReleaseEvent(GdkEventKey
* event
);
105 gint
KeyPressEvent(GdkEventKey
* event
);
108 /// Return an array of allowed values for a string parameter.
109 /// \param iParameter The parameter to query.
110 /// \return A GArray of gchar* pointers to strings containing permitted values
113 GArray
*GetAllowedValues(int iParameter
);
116 /// Load a file and use to train the language model
117 /// \param filename The file to load.
120 void Train(const gchar
* filename
) {
121 // TODO: Shouldn't call this directly - need a wrapper function which stats for filesize etc.
122 // Better - allow user to pass a vector of filenames
123 TrainFile(filename
,0,0);
127 /// Called by UI needs to signal a new user trial is starting.
129 void UserLogNewTrial();
131 void ExternalKeyDown(int iKeyVal
);
132 void ExternalKeyUp(int iKeyVal
);
134 gboolean
ExposeEvent();
137 // virtual void CreateSettingsStore();
138 virtual void ScanAlphabetFiles(std::vector
<std::string
> &vFileList
);
139 virtual void ScanColourFiles(std::vector
<std::string
> &vFileList
);
140 virtual void SetupPaths();
141 virtual void CreateLocalFactories();
142 virtual void SetupUI();
143 virtual void CreateSettingsStore();
144 virtual int GetFileSize(const std::string
&strFileName
);
145 virtual void WriteTrainFile(const std::string
&strNewText
);
146 virtual void StartTimer();
147 virtual void ShutdownTimer();
150 /// Pass events coming from the core to the appropriate handler.
153 void ExternalEventHandler(Dasher::CEvent
*pEvent
);
156 /// Notification from CDasherInterface that a parameter has changed
157 /// \param iParameter The parameter which has changed
160 void HandleParameterNotification(int iParameter
);
163 GtkWidget
*m_pCanvas
;
166 /// Abstracted input device object for mouse input.
169 CDasherMouseInput
*m_pMouseInput
;
170 CDasher1DMouseInput
*m_p1DMouseInput
;
173 /// Cache of Pango layouts
176 CPangoCache
*m_pPangoCache
;
179 /// The CCanvas object
185 /// The GObject which is wrapping this class
188 GtkDasherControl
*m_pDasherControl
;
191 /// Keyboard helper class
194 // CKeyboardHelper *m_pKeyboardHelper;