tagging release
[dasher.git] / trunk / Src / Gtk2 / DasherControl.h
blobce942b1c635422676264bb2de1e41b1cae1b09c4
1 #ifndef __dashercontrol_h__
2 #define __dashercontrol_h__
4 #include "../../config.h"
6 #include "PangoCache.h"
7 #include "Canvas.h"
8 #include "../DasherCore/SocketInput.h"
10 #ifdef JOYSTICK
11 #include "joystick_input.h"
12 #endif
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"
24 ///
25 /// \brief C++ core of the Dasher GTK UI component.
26 ///
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
29 ///
31 class CDasherControl : public CDasherInterfaceBase {
33 public:
35 ///
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.
42 ///
44 CDasherControl(GtkVBox * pVbox, GtkDasherControl * pDasherControl);
45 ~CDasherControl();
47 // Event handlers
48 // FIXME - we should probably pass all parameters to these from the "C" callbacks
49 void SetFocus();
52 ///
53 /// GTK Signal handler for the canvas getting the focus (which it gives away to the edit box)
54 ///
56 bool FocusEvent(GtkWidget *pWidget, GdkEventFocus *pEvent);
59 ///
60 /// Called when the canvas gets realized (ie when internal resources have been allocated), so we can finalise setup.
61 ///
63 void RealizeCanvas(GtkWidget *pWidget);
65 ///
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.
70 ///
72 int TimerEvent();
73 int LongTimerEvent();
76 ///
77 /// Mouse button pressed on the canvas
78 ///
80 gboolean ButtonPressEvent(GdkEventButton * event);
82 ///
83 /// Called when the canvas has been resized, prompts the (re)creation of the CCanvas object.
84 ///
86 int CanvasConfigureEvent();
88 ///
89 /// Speed slider has been moved.
90 ///
92 void SliderEvent();
94 ///
95 /// Called when the canvas GTK widget is destroyed, so we can free any references to it.
96 ///
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);
115 ///
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();
136 private:
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);
162 GtkWidget *m_pVBox;
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
182 CCanvas *m_pScreen;
185 /// The GObject which is wrapping this class
188 GtkDasherControl *m_pDasherControl;
191 /// Keyboard helper class
194 // CKeyboardHelper *m_pKeyboardHelper;
197 #endif