[dasher] Remove CEditContextEvent by making DashIntf::GetContext (pure) virtual
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher] Remove CEditContextEvent by making DashIntf::GetContext (pure) virtual
- Date: Tue, 22 Mar 2011 21:23:08 +0000 (UTC)
commit 6661a4c13d6440e9dc7f09c14eaadfaa77b63174
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Tue Mar 15 11:52:01 2011 +0000
Remove CEditContextEvent by making DashIntf::GetContext (pure) virtual
=> Subclasses override.
Gtk2: remove dasher_context_request signal, implement directly in DasherControl.
Data/GUI/dasher.compose.ui | 1 -
Data/GUI/dasher.direct.ui | 1 -
Data/GUI/dasher.fullscreen.ui | 1 -
Data/GUI/dasher.gameWIP.ui | 1 -
Data/GUI/dasher.traditional.ui | 1 -
Data/GUI/dashermaemo.ui | 1 -
Data/GUI/dashermaemofullscreen.ui | 1 -
Src/DasherCore/DasherGameMode.cpp | 3 ---
Src/DasherCore/DasherInterfaceBase.cpp | 15 ---------------
Src/DasherCore/DasherInterfaceBase.h | 5 ++---
Src/DasherCore/Event.h | 12 +-----------
Src/Gtk2/DasherControl.cpp | 9 +++++----
Src/Gtk2/DasherControl.h | 1 +
Src/Gtk2/GtkDasherControl.cpp | 10 +++-------
Src/Gtk2/GtkDasherControl.h | 3 +--
Src/Gtk2/dasher_main.cpp | 14 --------------
Src/MacOSX/COSXDasherControl.h | 2 +-
Src/MacOSX/COSXDasherControl.mm | 10 ++++------
Src/MacOSX/DasherEdit.h | 2 +-
Src/MacOSX/DasherEdit.mm | 2 +-
Src/Win32/Dasher.cpp | 4 ++++
Src/Win32/Dasher.h | 1 +
Src/Win32/DasherWindow.cpp | 6 ------
Src/iPhone/Classes/CDasherInterfaceBridge.h | 1 +
Src/iPhone/Classes/CDasherInterfaceBridge.mm | 10 ++++------
25 files changed, 30 insertions(+), 87 deletions(-)
---
diff --git a/Data/GUI/dasher.compose.ui b/Data/GUI/dasher.compose.ui
index eacc7bc..6d769d2 100644
--- a/Data/GUI/dasher.compose.ui
+++ b/Data/GUI/dasher.compose.ui
@@ -462,7 +462,6 @@
<signal handler="handle_control_event" name="dasher_control"/>
<signal handler="gtk2_edit_output_callback" name="dasher_edit_insert"/>
<signal handler="gtk2_edit_delete_callback" name="dasher_edit_delete"/>
- <signal handler="handle_context_request" name="dasher_context_request"/>
<signal handler="handle_request_settings" name="dasher_request_settings"/>
<signal handler="focus_in_event" name="focus_in_event"/>
<signal handler="on_lock_info" name="dasher_lock_info"/>
diff --git a/Data/GUI/dasher.direct.ui b/Data/GUI/dasher.direct.ui
index 88c9b83..917620f 100644
--- a/Data/GUI/dasher.direct.ui
+++ b/Data/GUI/dasher.direct.ui
@@ -59,7 +59,6 @@
<signal handler="handle_control_event" name="dasher_control"/>
<signal handler="gtk2_edit_output_callback" name="dasher_edit_insert"/>
<signal handler="gtk2_edit_delete_callback" name="dasher_edit_delete"/>
- <signal handler="handle_context_request" name="dasher_context_request"/>
<signal handler="handle_request_settings" name="dasher_request_settings"/>
<signal handler="focus_in_event" name="focus_in_event"/>
<signal handler="on_lock_info" name="dasher_lock_info"/>
diff --git a/Data/GUI/dasher.fullscreen.ui b/Data/GUI/dasher.fullscreen.ui
index f83a315..9d9b703 100644
--- a/Data/GUI/dasher.fullscreen.ui
+++ b/Data/GUI/dasher.fullscreen.ui
@@ -175,7 +175,6 @@
<signal handler="handle_control_event" last_modification_time="Sun, 05 Mar 2006 19:45:53 GMT" name="dasher_control"/>
<signal handler="gtk2_edit_output_callback" last_modification_time="Sun, 05 Mar 2006 19:46:13 GMT" name="dasher_edit_insert"/>
<signal handler="gtk2_edit_delete_callback" last_modification_time="Sun, 05 Mar 2006 19:46:32 GMT" name="dasher_edit_delete"/>
- <signal handler="handle_context_request" last_modification_time="Sun, 05 Mar 2006 19:46:54 GMT" name="dasher_context_request"/>
<signal handler="handle_request_settings" last_modification_time="Sun, 05 Mar 2006 19:47:12 GMT" name="dasher_request_settings"/>
<signal handler="focus_in_event" last_modification_time="Sun, 05 Mar 2006 19:47:28 GMT" name="focus_in_event"/>
<signal handler="on_lock_info" last_modification_time="Wed, 22 Mar 2006 10:38:44 GMT" name="dasher_lock_info"/>
diff --git a/Data/GUI/dasher.gameWIP.ui b/Data/GUI/dasher.gameWIP.ui
index 64ee4c0..4a9945d 100644
--- a/Data/GUI/dasher.gameWIP.ui
+++ b/Data/GUI/dasher.gameWIP.ui
@@ -650,7 +650,6 @@
<signal handler="handle_control_event" last_modification_time="Sun, 05 Mar 2006 19:45:53 GMT" name="dasher_control"/>
<signal handler="gtk2_edit_output_callback" last_modification_time="Sun, 05 Mar 2006 19:46:13 GMT" name="dasher_edit_insert"/>
<signal handler="gtk2_edit_delete_callback" last_modification_time="Sun, 05 Mar 2006 19:46:32 GMT" name="dasher_edit_delete"/>
- <signal handler="handle_context_request" last_modification_time="Sun, 05 Mar 2006 19:46:54 GMT" name="dasher_context_request"/>
<signal handler="handle_request_settings" last_modification_time="Sun, 05 Mar 2006 19:47:12 GMT" name="dasher_request_settings"/>
<signal handler="focus_in_event" last_modification_time="Sun, 05 Mar 2006 19:47:28 GMT" name="focus_in_event"/>
<signal handler="on_lock_info" last_modification_time="Wed, 22 Mar 2006 10:38:44 GMT" name="dasher_lock_info"/>
diff --git a/Data/GUI/dasher.traditional.ui b/Data/GUI/dasher.traditional.ui
index c8e1085..b24015a 100644
--- a/Data/GUI/dasher.traditional.ui
+++ b/Data/GUI/dasher.traditional.ui
@@ -246,7 +246,6 @@
<signal handler="handle_control_event" name="dasher_control"/>
<signal handler="gtk2_edit_output_callback" name="dasher_edit_insert"/>
<signal handler="gtk2_edit_delete_callback" name="dasher_edit_delete"/>
- <signal handler="handle_context_request" name="dasher_context_request"/>
<signal handler="handle_request_settings" name="dasher_request_settings"/>
<signal handler="focus_in_event" name="focus_in_event"/>
<signal handler="on_lock_info" name="dasher_lock_info"/>
diff --git a/Data/GUI/dashermaemo.ui b/Data/GUI/dashermaemo.ui
index 5a17075..898c211 100644
--- a/Data/GUI/dashermaemo.ui
+++ b/Data/GUI/dashermaemo.ui
@@ -93,7 +93,6 @@
<signal handler="handle_control_event" name="dasher_control"/>
<signal handler="gtk2_edit_output_callback" name="dasher_edit_insert"/>
<signal handler="gtk2_edit_delete_callback" name="dasher_edit_delete"/>
- <signal handler="handle_context_request" name="dasher_context_request"/>
<signal handler="handle_request_settings" name="dasher_request_settings"/>
<signal handler="focus_in_event" name="focus_in_event"/>
<signal handler="on_lock_info" name="dasher_lock_info"/>
diff --git a/Data/GUI/dashermaemofullscreen.ui b/Data/GUI/dashermaemofullscreen.ui
index 96fc49b..c16dd17 100644
--- a/Data/GUI/dashermaemofullscreen.ui
+++ b/Data/GUI/dashermaemofullscreen.ui
@@ -220,7 +220,6 @@
<signal handler="handle_control_event" last_modification_time="Sun, 05 Mar 2006 19:45:53 GMT" name="dasher_control"/>
<signal handler="gtk2_edit_output_callback" last_modification_time="Sun, 05 Mar 2006 19:46:13 GMT" name="dasher_edit_insert"/>
<signal handler="gtk2_edit_delete_callback" last_modification_time="Sun, 05 Mar 2006 19:46:32 GMT" name="dasher_edit_delete"/>
- <signal handler="handle_context_request" last_modification_time="Sun, 05 Mar 2006 19:46:54 GMT" name="dasher_context_request"/>
<signal handler="handle_request_settings" last_modification_time="Sun, 05 Mar 2006 19:47:12 GMT" name="dasher_request_settings"/>
<signal handler="focus_in_event" last_modification_time="Sun, 05 Mar 2006 19:47:28 GMT" name="focus_in_event"/>
<signal handler="on_lock_info" last_modification_time="Wed, 22 Mar 2006 10:38:44 GMT" name="dasher_lock_info"/>
diff --git a/Src/DasherCore/DasherGameMode.cpp b/Src/DasherCore/DasherGameMode.cpp
index aa9bcd9..c6ccb95 100644
--- a/Src/DasherCore/DasherGameMode.cpp
+++ b/Src/DasherCore/DasherGameMode.cpp
@@ -132,7 +132,6 @@ void CDasherGameMode::NotifyGameCooperators(bool bGameOn)
{
SetBoolParameter(BP_GAME_MODE, bGameOn);
m_pView->SetGameMode(bGameOn);
- m_pDasherInterface->SetContext(std::string(""));
m_pDasherInterface->SetBuffer(0);
m_pDasherInterface->Stop();
@@ -297,7 +296,6 @@ void CDasherGameMode::GameNext()
// ...then reset the external state, and leave them at the start ready to go.
m_pDasherInterface->GameMessageOut(GAME_MESSAGE_CLEAR_BUFFER, NULL);
- m_pDasherInterface->SetContext(std::string(""));
m_pDasherInterface->SetBuffer(0);
m_pDasherInterface->Stop();
@@ -335,7 +333,6 @@ void CDasherGameMode::FullDemoNext()
// ...then reset the external state, and leave the demo at the start ready to go.
m_pDasherInterface->GameMessageOut(GAME_MESSAGE_CLEAR_BUFFER, NULL);
- m_pDasherInterface->SetContext(std::string(""));
m_pDasherInterface->SetBuffer(0);
m_pDasherInterface->Stop();
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 68ee06e..f91f0b9 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -685,25 +685,10 @@ void CDasherInterfaceBase::ResetNats() {
m_pDasherModel->ResetNats();
}
-// TODO: Fix this
-
-std::string CDasherInterfaceBase::GetContext(int iStart, int iLength) {
- m_strContext = "";
-
- CEditContextEvent oEvent(iStart, iLength);
- m_pEventHandler->InsertEvent(&oEvent);
-
- return m_strContext;
-}
-
void CDasherInterfaceBase::ClearAllContext() {
SetBuffer(0);
}
-void CDasherInterfaceBase::SetContext(std::string strNewContext) {
- m_strContext = strNewContext;
-}
-
void CDasherInterfaceBase::SetBoolParameter(int iParameter, bool bValue) {
m_pSettingsStore->SetBoolParameter(iParameter, bValue);
}
diff --git a/Src/DasherCore/DasherInterfaceBase.h b/Src/DasherCore/DasherInterfaceBase.h
index dfd9f64..aa25183 100644
--- a/Src/DasherCore/DasherInterfaceBase.h
+++ b/Src/DasherCore/DasherInterfaceBase.h
@@ -392,7 +392,8 @@ public:
m_bRedrawScheduled = true;
};
- std::string GetContext(int iStart, int iLength);
+ ///Subclasses should return the contents of (the specified subrange of) the edit buffer
+ virtual std::string GetContext(unsigned int iStart, unsigned int iLength)=0;
///Subclasses should override to clear text edit box, etc., etc., but then
/// call this (superclass) implementation as well to rebuild the model...
@@ -593,8 +594,6 @@ protected:
///builds up the word currently being entered for speech.
std::string m_strCurrentWord;
- std::string m_strContext;
-
/// @name State variables
/// Represent the current overall state of the core
/// @{
diff --git a/Src/DasherCore/Event.h b/Src/DasherCore/Event.h
index 2c2de66..a65fa5c 100644
--- a/Src/DasherCore/Event.h
+++ b/Src/DasherCore/Event.h
@@ -10,7 +10,6 @@ namespace Dasher {
class CEvent;
class CParameterNotificationEvent;
class CEditEvent;
- class CEditContextEvent;
class CControlEvent;
class CLockEvent;
class CMessageEvent;
@@ -18,7 +17,7 @@ namespace Dasher {
}
enum {
- EV_PARAM_NOTIFY = 1, EV_EDIT, EV_EDIT_CONTEXT, EV_CONTROL, EV_LOCK, EV_MESSAGE, EV_SCREEN_GEOM
+ EV_PARAM_NOTIFY = 1, EV_EDIT, EV_CONTROL, EV_LOCK, EV_MESSAGE, EV_SCREEN_GEOM
};
/// \ingroup Core
@@ -52,15 +51,6 @@ public:
const int m_iOffset;
};
-class Dasher::CEditContextEvent:public Dasher::CEvent {
-public:
- CEditContextEvent(int iOffset, int iLength) : CEvent(EV_EDIT_CONTEXT), m_iOffset(iOffset), m_iLength(iLength) {
- };
-
- const int m_iOffset;
- const int m_iLength;
-};
-
class Dasher::CControlEvent:public Dasher::CEvent {
public:
CControlEvent(int iID) : CEvent(EV_CONTROL), m_iID(iID) {
diff --git a/Src/Gtk2/DasherControl.cpp b/Src/Gtk2/DasherControl.cpp
index f22e778..fde7212 100644
--- a/Src/Gtk2/DasherControl.cpp
+++ b/Src/Gtk2/DasherControl.cpp
@@ -196,6 +196,11 @@ std::string CDasherControl::GetAllContext() {
return text;
}
+std::string CDasherControl::GetContext(unsigned int iStart, unsigned int iLength) {
+ const gchar *text = gtk_dasher_control_get_context(m_pDasherControl, iStart, iLength);
+ return text;
+}
+
bool CDasherControl::SupportsClipboard() {
return true;
}
@@ -349,10 +354,6 @@ void CDasherControl::ExternalEventHandler(Dasher::CEvent *pEvent) {
g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_edit_protect");
}
}
- else if(pEvent->m_iEventType == EV_EDIT_CONTEXT) {
- CEditContextEvent *pEditContextEvent(static_cast < CEditContextEvent * >(pEvent));
- g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_context_request", pEditContextEvent->m_iOffset, pEditContextEvent->m_iLength);
- }
else if(pEvent->m_iEventType == EV_CONTROL) {
CControlEvent *pControlEvent(static_cast < CControlEvent * >(pEvent));
g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_control", pControlEvent->m_iID);
diff --git a/Src/Gtk2/DasherControl.h b/Src/Gtk2/DasherControl.h
index 28e9ab9..8b8a929 100644
--- a/Src/Gtk2/DasherControl.h
+++ b/Src/Gtk2/DasherControl.h
@@ -138,6 +138,7 @@ public:
virtual void WriteTrainFile(const std::string &filename, const std::string &strNewText);
virtual std::string GetAllContext();
+ std::string GetContext(unsigned int iStart, unsigned int iLength);
virtual bool SupportsClipboard();
virtual void CopyToClipboard(const std::string &strText);
diff --git a/Src/Gtk2/GtkDasherControl.cpp b/Src/Gtk2/GtkDasherControl.cpp
index 266538d..8b92c48 100644
--- a/Src/Gtk2/GtkDasherControl.cpp
+++ b/Src/Gtk2/GtkDasherControl.cpp
@@ -45,7 +45,6 @@ enum {
DASHER_EDIT_CONVERT,
DASHER_EDIT_PROTECT,
DASHER_CONTROL,
- DASHER_CONTEXT_REQUEST,
DASHER_REQUEST_SETTINGS,
DASHER_LOCK_INFO,
DASHER_MESSAGE,
@@ -83,8 +82,6 @@ gtk_dasher_control_class_init(GtkDasherControlClass *pClass) {
gtk_dasher_control_signals[DASHER_CONTROL] = g_signal_new("dasher_control", G_TYPE_FROM_CLASS(pClass), static_cast < GSignalFlags > (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), G_STRUCT_OFFSET(GtkDasherControlClass, dasher_control), NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
- gtk_dasher_control_signals[DASHER_CHANGED] = g_signal_new("dasher_context_request", G_TYPE_FROM_CLASS(pClass), static_cast < GSignalFlags > (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), G_STRUCT_OFFSET(GtkDasherControlClass, dasher_context_request), NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-
// gtk_dasher_control_signals[DASHER_CONTROL] = g_signal_new("key_press_event", G_TYPE_FROM_CLASS(pClass), static_cast < GSignalFlags > (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), G_STRUCT_OFFSET(GtkDasherControlClass, key_press_event), NULL, NULL, gtk_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
// gtk_dasher_control_signals[DASHER_CONTROL] = g_signal_new("key_release_event", G_TYPE_FROM_CLASS(pClass), static_cast < GSignalFlags > (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), G_STRUCT_OFFSET(GtkDasherControlClass, key_release_event), NULL, NULL, gtk_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
@@ -104,7 +101,6 @@ gtk_dasher_control_class_init(GtkDasherControlClass *pClass) {
pClass->dasher_edit_convert = NULL;
pClass->dasher_edit_protect = NULL;
pClass->dasher_control = NULL;
- pClass->dasher_context_request = NULL;
pClass->dasher_request_settings = NULL;
pClass->dasher_lock = NULL;
pClass->dasher_message = NULL;
@@ -206,10 +202,10 @@ gtk_dasher_control_train(GtkDasherControl *pControl, const gchar *szFilename) {
pPrivate->pControl->ImportTrainingText(szFilename);
};
-void
-gtk_dasher_control_set_context(GtkDasherControl *pControl, const gchar *szContext) {
+const gchar *
+gtk_dasher_control_get_context(GtkDasherControl *pControl, unsigned int iStart, unsigned int iLength) {
GtkDasherControlPrivate *pPrivate = GTK_DASHER_CONTROL_GET_PRIVATE(pControl);
- pPrivate->pControl->SetContext(szContext);
+ return dasher_editor_get_context(pPrivate->pEditor, iStart, iLength);
}
const gchar *
diff --git a/Src/Gtk2/GtkDasherControl.h b/Src/Gtk2/GtkDasherControl.h
index 40224b2..06541f5 100644
--- a/Src/Gtk2/GtkDasherControl.h
+++ b/Src/Gtk2/GtkDasherControl.h
@@ -56,7 +56,6 @@ struct _GtkDasherControlClass {
void (*dasher_control) (GtkDasherControl * pDasherControl, gint iEvent, gpointer data);
gboolean (*key_press_event) (GtkDasherControl *pDasherControl, GdkEventKey *pEvent, gpointer data);
gboolean (*key_release_event) (GtkDasherControl *pDasherControl, GdkEventKey *pEvent, gpointer data);
- void (*dasher_context_request) (GtkDasherControl * pDasherControl, gint iOffset, gint iLength, gpointer data);
void (*dasher_request_settings) (GtkDasherControl * pDasherControl, gpointer data);
void (*dasher_lock) (GtkDasherControl * pDasherControl, gpointer pLockInfo, gpointer data);
void (*dasher_message) (GtkDasherControl * pDasherControl, gpointer pLockInfo, gpointer data);
@@ -78,9 +77,9 @@ void gtk_dasher_control_reset_parameter(GtkDasherControl * pControl, int iParame
const char *gtk_dasher_control_get_parameter_string(GtkDasherControl * pControl, int iParameter);
GArray *gtk_dasher_control_get_allowed_values(GtkDasherControl * pControl, int iParameter);
void gtk_dasher_control_train(GtkDasherControl * pControl, const gchar * szFilename);
-void gtk_dasher_control_set_context(GtkDasherControl *pControl, const gchar *szContext);
void gtk_dasher_control_set_editor(GtkDasherControl *pControl, DasherEditor *pEditor);
const gchar* gtk_dasher_control_get_all_text(GtkDasherControl *pControl);
+const gchar* gtk_dasher_control_get_context(GtkDasherControl *pControl, unsigned int iOffset, unsigned int iLength);
//void gtk_dasher_control_invalidate_context(GtkDasherControl *pControl, bool bForceStart);
void gtk_dasher_control_set_buffer(GtkDasherControl *pControl, int iOffset);
void gtk_dasher_control_set_offset(GtkDasherControl *pControl, int iOffset);
diff --git a/Src/Gtk2/dasher_main.cpp b/Src/Gtk2/dasher_main.cpp
index 4c66541..0852e01 100644
--- a/Src/Gtk2/dasher_main.cpp
+++ b/Src/Gtk2/dasher_main.cpp
@@ -152,7 +152,6 @@ extern "C" gboolean edit_key_release(GtkWidget *widget, GdkEventKey *event, gpoi
/* ... Temporary test/debug functions */
extern "C" gboolean test_focus_handler(GtkWidget *pWidget, GtkDirectionType iDirection, gpointer *pUserData);
-extern "C" void handle_context_request(GtkDasherControl * pDasherControl, gint iOffset, gint iLength, gpointer data);
extern "C" void handle_control_event(GtkDasherControl *pDasherControl, gint iEvent, gpointer data);
extern "C" void handle_start_event(GtkDasherControl *pDasherControl, gpointer data);
extern "C" gint dasher_main_key_snooper(GtkWidget *pWidget, GdkEventKey *pEvent, gpointer pUserData);
@@ -1312,19 +1311,6 @@ test_focus_handler(GtkWidget *pWidget, GtkDirectionType iDirection, gpointer *pU
}
extern "C" void
-handle_context_request(GtkDasherControl * pDasherControl, gint iOffset, gint iLength, gpointer data) {
- if(!g_pDasherMain)
- return;
-
- DasherMainPrivate *pPrivate = DASHER_MAIN_GET_PRIVATE(g_pDasherMain);
-
- if(!pPrivate->pEditor || !pPrivate->pDasherWidget)
- return;
-
- gtk_dasher_control_set_context(GTK_DASHER_CONTROL(pPrivate->pDasherWidget), dasher_editor_get_context(pPrivate->pEditor, iOffset, iLength));
-}
-
-extern "C" void
handle_control_event(GtkDasherControl *pDasherControl, gint iEvent, gpointer data) {
if(!g_pDasherMain)
return;
diff --git a/Src/MacOSX/COSXDasherControl.h b/Src/MacOSX/COSXDasherControl.h
index b2a8e65..76101bd 100644
--- a/Src/MacOSX/COSXDasherControl.h
+++ b/Src/MacOSX/COSXDasherControl.h
@@ -48,7 +48,7 @@ public:
virtual void WriteTrainFile(const std::string &filename, const std::string &strNewText);
std::string GetAllContext();
void ClearAllContext();
-
+ std::string GetContext(unsigned int iOffset, unsigned int iLength);
private:
virtual void ScanAlphabetFiles(std::vector<std::string> &vFileList);
virtual void ScanColourFiles(std::vector<std::string> &vFileList);
diff --git a/Src/MacOSX/COSXDasherControl.mm b/Src/MacOSX/COSXDasherControl.mm
index 96f1ea3..cb51ccd 100644
--- a/Src/MacOSX/COSXDasherControl.mm
+++ b/Src/MacOSX/COSXDasherControl.mm
@@ -182,12 +182,6 @@ void COSXDasherControl::ExternalEventHandler(Dasher::CEvent *pEvent) {
}
break;
}
- case EV_EDIT_CONTEXT: {
- //NSLog(@"ExternalEventHandler, m_iEventType = EV_EDIT_CONTEXT");
- CEditContextEvent *ecvt((CEditContextEvent *)pEvent);
- SetContext(StdStringFromNSString([dasherEdit textAtOffset:ecvt->m_iOffset Length:ecvt->m_iLength]));
- break;
- }
case EV_CONTROL:
NSLog(@"ExternalEventHandler, m_iEventType = EV_CONTROL");
break;
@@ -294,6 +288,10 @@ void COSXDasherControl::CopyToClipboard(const std::string &strText) {
[dasherApp copyToClipboard:NSStringFromStdString(strText)];
}
+std::string COSXDasherControl::GetContext(unsigned int iOffset, unsigned int iLength) {
+ return StdStringFromNSString([dasherEdit textAtOffset:iOffset Length:iLength]);
+}
+
std::string COSXDasherControl::GetAllContext() {
return StdStringFromNSString([dasherEdit allContext]);
}
diff --git a/Src/MacOSX/DasherEdit.h b/Src/MacOSX/DasherEdit.h
index 2618510..b6bc7d0 100644
--- a/Src/MacOSX/DasherEdit.h
+++ b/Src/MacOSX/DasherEdit.h
@@ -18,7 +18,7 @@
- (void)sendString:(NSString *)aString toTargetApp:(AXUIElementRef)aTargetApp;
- (void)outputCallback:(NSString *)aString targetApp:(AXUIElementRef)aTargetApp;
- (void)deleteCallback:(NSString *)s targetApp:(AXUIElementRef)aTargetApp;
-- (NSString *)textAtOffset:(int)iOffset Length:(int)iLength;
+- (NSString *)textAtOffset:(unsigned int)iOffset Length:(unsigned int)iLength;
- (NSString *)allContext;
- (void)clearContext;
diff --git a/Src/MacOSX/DasherEdit.mm b/Src/MacOSX/DasherEdit.mm
index 966ae2a..1d54244 100644
--- a/Src/MacOSX/DasherEdit.mm
+++ b/Src/MacOSX/DasherEdit.mm
@@ -53,7 +53,7 @@
[allTextEntered deleteCharactersInRange:NSMakeRange([allTextEntered length]-len, len)];
}
--(NSString *)textAtOffset:(int)iOffset Length:(int)iLength {
+-(NSString *)textAtOffset:(unsigned int)iOffset Length:(unsigned int)iLength {
DASHER_ASSERT(iOffset+iLength <= [allTextEntered length]);
return [allTextEntered substringWithRange:NSMakeRange(iOffset,iLength)];
}
diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp
index 31e127d..342463c 100644
--- a/Src/Win32/Dasher.cpp
+++ b/Src/Win32/Dasher.cpp
@@ -361,3 +361,7 @@ std::string CDasher::GetAllContext() {
m_pEdit->GetWindowText(allspeech, speechlength + 1);
return allspeech;
}
+
+std::string CDasher::GetContext(unsigned int iStart, unsigned int iLength) {
+ return m_pEdit->get_context(iStart, iLength);
+}
diff --git a/Src/Win32/Dasher.h b/Src/Win32/Dasher.h
index 7659972..df69899 100644
--- a/Src/Win32/Dasher.h
+++ b/Src/Win32/Dasher.h
@@ -50,6 +50,7 @@ public:
void Main();
virtual std::string GetAllContext();
+ std::string GetContext(unsigned int iStart, unsigned int iLength);
#ifndef _WIN32_WCE
//on WinCE, do not support speech - so use defaults from CDasherInterfaceBase
diff --git a/Src/Win32/DasherWindow.cpp b/Src/Win32/DasherWindow.cpp
index ca19489..1e8e2ee 100644
--- a/Src/Win32/DasherWindow.cpp
+++ b/Src/Win32/DasherWindow.cpp
@@ -431,12 +431,6 @@ LRESULT CDasherWindow::OnDasherEvent(UINT message, WPARAM wParam, LPARAM lParam,
}
}
break;
- case EV_EDIT_CONTEXT:
- {
- Dasher::CEditContextEvent *pEvt = static_cast< Dasher::CEditContextEvent * >(pEvent);
- m_pDasher->SetContext(m_pEdit->get_context(pEvt->m_iOffset, pEvt->m_iLength));
- }
- break;
default:
break;
}
diff --git a/Src/iPhone/Classes/CDasherInterfaceBridge.h b/Src/iPhone/Classes/CDasherInterfaceBridge.h
index e1ca468..39d568a 100644
--- a/Src/iPhone/Classes/CDasherInterfaceBridge.h
+++ b/Src/iPhone/Classes/CDasherInterfaceBridge.h
@@ -49,6 +49,7 @@ public:
bool SupportsSpeech();
void Speak(const std::string &strText, bool bInterrupt);
std::string GetAllContext();
+ std::string GetContext(unsigned int iStart, unsigned int iLength);
private:
virtual void ScanAlphabetFiles(std::vector<std::string> &vFileList);
virtual void ScanColourFiles(std::vector<std::string> &vFileList);
diff --git a/Src/iPhone/Classes/CDasherInterfaceBridge.mm b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
index b7f2c2a..779633e 100644
--- a/Src/iPhone/Classes/CDasherInterfaceBridge.mm
+++ b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
@@ -180,12 +180,6 @@ void CDasherInterfaceBridge::ExternalEventHandler(Dasher::CEvent *pEvent) {
}
}
break;
- case EV_EDIT_CONTEXT:
- {
- CEditContextEvent *ecvt((CEditContextEvent *)pEvent);
- SetContext(StdStringFromNSString([dasherApp textAtOffset:ecvt->m_iOffset Length:ecvt->m_iLength]));
- break;
- }
case EV_CONTROL:
switch (static_cast<CControlEvent *>(pEvent)->m_iID) {
case CControlManager::CTL_MOVE_FORWARD_CHAR:
@@ -263,6 +257,10 @@ string CDasherInterfaceBridge::GetAllContext() {
return StdStringFromNSString([dasherApp allText]);
}
+string CDasherInterfaceBridge::GetContext(unsigned int iOffset, unsigned int iLength) {
+ return StdStringFromNSString([dasherApp textAtOffset:iOffset Length:iLength]);
+}
+
int CDasherInterfaceBridge::GetFileSize(const std::string &strFileName) {
struct stat sStatInfo;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]