1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
#ifndef __dashercontrol_h__
#define __dashercontrol_h__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "Canvas.h"
#include "../DasherCore/SocketInput.h"
#ifdef JOYSTICK
#include "joystick_input.h"
#endif
#ifdef TILT
#include "tilt_input.h"
#endif
#ifdef WITH_SPEECH
#include "Speech.h"
#endif
#include "mouse_input.h"
#include "GtkDasherControl.h"
//#include "KeyboardHelper.h"
//#include "../DasherCore/DasherSettingsInterface.h"
#include "../DasherCore/DashIntfScreenMsgs.h"
#include "../DasherCore/UserLog.h"
#include "FileUtils.h"
///
/// \brief C++ core of the Dasher GTK UI component.
///
/// Class representing the Dasher UI component (ie the canvas and speed slider)
///
class CDasherControl : public CDashIntfScreenMsgs {
public:
///
/// \param pVBox GTK VBox to populate with the DasherControl
/// component widgets. This needs to be created externally by the
/// GObject wrapper and passed to the C++ class rather than being
/// created internally.
/// \param pDasherControl Pointer to the GObject wrapper. This is
/// needed so that we can emit signals from the GObject.
///
// The CDasherControl object takes ownership of 'settings'.
CDasherControl(GtkVBox * pVbox, GtkDasherControl * pDasherControl,
CSettingsStore* settings);
~CDasherControl();
// Event handlers
// FIXME - we should probably pass all parameters to these from the "C" callbacks
void SetFocus();
///
/// GTK Signal handler for the canvas getting the focus (which it gives away to the edit box)
///
bool FocusEvent(GtkWidget *pWidget, GdkEventFocus *pEvent);
///
/// Called when the canvas gets realized (ie when internal resources have been allocated), so we can finalise setup.
///
void RealizeCanvas(GtkWidget *pWidget);
///
/// Called periodically by a timer. Used to prompt the interface to perform a redraw
/// \todo There's rather a lot which happens in this
/// function. Ideally it should just be a simple call to the core
/// which then figures out whether we're paused or not etc.
///
int TimerEvent();
int LongTimerEvent();
///
/// Mouse button pressed on the canvas
///
gboolean ButtonPressEvent(GdkEventButton * event);
///
/// Called when the canvas has been resized, prompts the (re)creation of the CCanvas object.
///
int CanvasConfigureEvent();
///
/// Speed slider has been moved.
///
void SliderEvent();
///
/// Called when the canvas GTK widget is destroyed, so we can free any references to it.
///
void CanvasDestroyEvent();
///
/// Key press event on the canvas
///
gint KeyReleaseEvent(GdkEventKey * event);
gint KeyPressEvent(GdkEventKey * event);
///
/// Return an array of allowed values for a string parameter.
/// \param iParameter The parameter to query.
/// \return A GArray of gchar* pointers to strings containing permitted values
///
GArray *GetAllowedValues(int iParameter);
///
/// Called by UI needs to signal a new user trial is starting.
///
void UserLogNewTrial();
void ExternalKeyDown(int iKeyVal);
void ExternalKeyUp(int iKeyVal);
gboolean ExposeEvent();
///Override to broadcast dasher_stop signal...
void Done() override;
void ClearAllContext() override ;
std::string GetAllContext() override;
int GetAllContextLenght() override;
std::string GetTextAroundCursor(CControlManager::EditDistance dist) override;
std::string GetContext(unsigned int iStart, unsigned int iLength) override;
bool SupportsClipboard() override;
void CopyToClipboard(const std::string &strText) override;
unsigned int ctrlMove(bool bForwards, CControlManager::EditDistance dist) override;
unsigned int ctrlDelete(bool bForwards, CControlManager::EditDistance dist) override;
#ifdef WITH_SPEECH
///override default non-implementation if compiling with speech...
bool SupportsSpeech() override;
void Speak(const std::string &strText, bool bInterrupt) override;
#endif
///
/// Pass events coming from the core to the appropriate handler.
///
void HandleEvent(int iParameter) override;
///Override to emit Gtk2 signal
void editOutput(const std::string &strText, CDasherNode *pNode) override;
void editDelete(const std::string &strText, CDasherNode *pNode) override;
void editConvert(CDasherNode *pNode) override;
void editProtect(CDasherNode *pNode) override;
///Override to emit Gtk2 signal
void SetLockStatus(const string &strText, int iPercent) override;
CGameModule *CreateGameModule() override;
private:
virtual void CreateModules() override;
GtkWidget *m_pVBox;
GtkWidget *m_pCanvas;
///
/// Abstracted input device object for mouse input.
///
CDasherMouseInput *m_pMouseInput;
CDasher1DMouseInput *m_p1DMouseInput;
///
/// The CCanvas object
///
CCanvas *m_pScreen;
///
/// The GObject which is wrapping this class
///
GtkDasherControl *m_pDasherControl;
//full path of user data directory, including trailing /
const char *m_user_data_dir;
///
/// Keyboard helper class
///
// CKeyboardHelper *m_pKeyboardHelper;
//Cache the clipboard object...
GtkClipboard *pClipboard;
FileUtils file_utils_;
#ifdef WITH_SPEECH
CSpeech m_Speech;
#endif
};
#endif
|