[dasher: 23/43] Refactor CEditEvents, adding CDashIntf::edit{Output, Delete, Convert, Protect}



commit 5c7a4052d084bf17fc3b6ec17c5a1f5371d9a7dd
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Fri Apr 8 22:43:22 2011 +0100

    Refactor CEditEvents, adding CDashIntf::edit{Output,Delete,Convert,Protect}
    
    Following general principle that an event should be a notification of something
     that has happened, rather than a request for it to happen: hence, only
     CDasherInterfaceBase can construct EditEvents, but clients instead call
     editOutput, etc. Default implementation broadcasts event, but subclasses
     of DasherInterface override editOutput etc. to actually perform work.

 Src/DasherCore/AlphabetManager.cpp           |    6 +--
 Src/DasherCore/ConversionHelper.cpp          |    4 +-
 Src/DasherCore/ConversionHelper.h            |    4 +-
 Src/DasherCore/ConversionManager.cpp         |   35 ++++------------
 Src/DasherCore/ConversionManager.h           |    5 +-
 Src/DasherCore/DasherInterfaceBase.cpp       |   20 +++++++++
 Src/DasherCore/DasherInterfaceBase.h         |    5 ++
 Src/DasherCore/Event.h                       |    7 ++-
 Src/Gtk2/DasherControl.cpp                   |   40 ++++++++++---------
 Src/Gtk2/DasherControl.h                     |    8 +++-
 Src/MacOSX/COSXDasherControl.h               |    8 ++++
 Src/MacOSX/COSXDasherControl.mm              |   46 ++++++++++-----------
 Src/Win32/Dasher.cpp                         |   42 ++++++++-----------
 Src/Win32/Dasher.h                           |    2 +
 Src/Win32/Widgets/Edit.cpp                   |   11 -----
 Src/Win32/Widgets/Edit.h                     |    5 +-
 Src/iPhone/Classes/CDasherInterfaceBridge.h  |    4 ++
 Src/iPhone/Classes/CDasherInterfaceBridge.mm |   55 ++++++++++++-------------
 18 files changed, 157 insertions(+), 150 deletions(-)
---
diff --git a/Src/DasherCore/AlphabetManager.cpp b/Src/DasherCore/AlphabetManager.cpp
index f776383..d599eb5 100644
--- a/Src/DasherCore/AlphabetManager.cpp
+++ b/Src/DasherCore/AlphabetManager.cpp
@@ -568,8 +568,7 @@ void CAlphabetManager::CSymbolNode::Output() {
   }
   //std::cout << this << " " << Parent() << ": Output at offset " << m_iOffset << " *" << m_pMgr->m_pAlphabet->GetText(t) << "* " << std::endl;
 
-  Dasher::CEditEvent oEvent(1, outputText(), this);
-  m_pMgr->m_pNCManager->InsertEvent(&oEvent);
+  m_pMgr->m_pInterface->editOutput(outputText(), this);
 }
 
 SymbolProb CAlphabetManager::CSymbolNode::GetSymbolProb(int iNormalization) const {
@@ -591,8 +590,7 @@ void CAlphabetManager::CSymbolNode::Undo() {
       }
     }
   } else CAlphBase::Undo();
-  Dasher::CEditEvent oEvent(2, outputText(), this);
-  m_pMgr->m_pNCManager->InsertEvent(&oEvent);
+  m_pMgr->m_pInterface->editDelete(outputText(), this);
 }
 
 CDasherNode *CAlphabetManager::CGroupNode::RebuildParent() {
diff --git a/Src/DasherCore/ConversionHelper.cpp b/Src/DasherCore/ConversionHelper.cpp
index e453063..a391d75 100644
--- a/Src/DasherCore/ConversionHelper.cpp
+++ b/Src/DasherCore/ConversionHelper.cpp
@@ -40,8 +40,8 @@
 using namespace Dasher;
 using namespace std;
 
-CConversionHelper::CConversionHelper(CNodeCreationManager *pNCManager, const CAlphInfo *pAlphabet, CLanguageModel *pLanguageModel) :
-  CConversionManager(pNCManager, pAlphabet), m_pLanguageModel(pLanguageModel) {
+CConversionHelper::CConversionHelper(CDasherInterfaceBase *pInterface, CNodeCreationManager *pNCManager, const CAlphInfo *pAlphabet, CLanguageModel *pLanguageModel) :
+  CConversionManager(pInterface, pNCManager, pAlphabet), m_pLanguageModel(pLanguageModel) {
 	  colourStore[0][0]=66;//light blue
 	  colourStore[0][1]=64;//very light green
 	  colourStore[0][2]=62;//light yellow
diff --git a/Src/DasherCore/ConversionHelper.h b/Src/DasherCore/ConversionHelper.h
index b3c39cd..65a25fe 100644
--- a/Src/DasherCore/ConversionHelper.h
+++ b/Src/DasherCore/ConversionHelper.h
@@ -42,8 +42,8 @@ namespace Dasher{
 ///
   class CConversionHelper : public CConversionManager {
   public:
-	CConversionHelper(CNodeCreationManager *pNCManager, const CAlphInfo *pAlphabet, CLanguageModel *pLanguageModel);
-    
+	CConversionHelper(CDasherInterfaceBase *pInterface, CNodeCreationManager *pNCManager, const CAlphInfo *pAlphabet, CLanguageModel *pLanguageModel);
+
 	/// Convert a given string to a lattice of candidates. Sizes for
 	/// candidates aren't assigned at this point. The input string
 	/// should be UTF-8 encoded.
diff --git a/Src/DasherCore/ConversionManager.cpp b/Src/DasherCore/ConversionManager.cpp
index f475f0e..b3b7f37 100644
--- a/Src/DasherCore/ConversionManager.cpp
+++ b/Src/DasherCore/ConversionManager.cpp
@@ -27,6 +27,7 @@
 #include "EventHandler.h"
 #include "NodeCreationManager.h"
 #include "DasherModel.h"
+#include "DasherInterfaceBase.h"
 
 #include <iostream>
 #include <cstring>
@@ -40,8 +41,8 @@
 using namespace Dasher;
 using namespace std;
 
-CConversionManager::CConversionManager(CNodeCreationManager *pNCManager, const CAlphInfo *pAlphabet) {
-
+CConversionManager::CConversionManager(CDasherInterfaceBase *pInterface, CNodeCreationManager *pNCManager, const CAlphInfo *pAlphabet) {
+  m_pInterface = pInterface;
   m_pNCManager = pNCManager;
   m_pAlphabet = pAlphabet;
 
@@ -161,28 +162,18 @@ void CConversionManager::CConvNode::Output() {
   SCENode *pCurrentSCENode(pSCENode);
 
   if(pCurrentSCENode){
-    Dasher::CEditEvent oEvent(1, pCurrentSCENode->pszConversion, this);
-    m_pMgr->m_pNCManager->InsertEvent(&oEvent);
+    m_pMgr->m_pInterface->editOutput(pCurrentSCENode->pszConversion, this);
 
     if((GetChildren())[0]->mgr() == m_pMgr) {
       if (static_cast<CConvNode *>(GetChildren()[0])->m_pMgr == m_pMgr) {
-        Dasher::CEditEvent oEvent(11, "", 0);
-        m_pMgr->m_pNCManager->InsertEvent(&oEvent);
+        m_pMgr->m_pInterface->editProtect(this); //TODO used to pass in offset 0, will now get this node's offset...
       }
     }
   }
   else {
-    if(!bisRoot) {
-      Dasher::CEditEvent oOPEvent(1, "|", this);
-      m_pMgr->m_pNCManager->InsertEvent(&oOPEvent);
-    }
-    else {
-      Dasher::CEditEvent oOPEvent(1, ">", this);
-      m_pMgr->m_pNCManager->InsertEvent(&oOPEvent);
-    }
+    m_pMgr->m_pInterface->editOutput(bisRoot ? ">" : "|", this);
 
-    Dasher::CEditEvent oEvent(10, "", this); //TODO this used to pass in offset 0, now we'll get the node's offset...
-    m_pMgr->m_pNCManager->InsertEvent(&oEvent);
+    m_pMgr->m_pInterface->editConvert(this); //TODO used to pass in offset 0, will now get this node's offset...
   }
 }
 
@@ -191,18 +182,10 @@ void CConversionManager::CConvNode::Undo() {
 
   if(pCurrentSCENode) {
     if(pCurrentSCENode->pszConversion && (strlen(pCurrentSCENode->pszConversion) > 0)) {
-      Dasher::CEditEvent oEvent(2, pCurrentSCENode->pszConversion, this);
-      m_pMgr->m_pNCManager->InsertEvent(&oEvent);
+      m_pMgr->m_pInterface->editDelete(pCurrentSCENode->pszConversion, this);
     }
   }
   else {
-    if(!bisRoot) {
-      Dasher::CEditEvent oOPEvent(2, "|", this);
-      m_pMgr->m_pNCManager->InsertEvent(&oOPEvent);
-    }
-    else {
-      Dasher::CEditEvent oOPEvent(2, ">", this);
-      m_pMgr->m_pNCManager->InsertEvent(&oOPEvent);
-    }
+    m_pMgr->m_pInterface->editDelete(bisRoot ? ">" : "|", this);
   }
 }
diff --git a/Src/DasherCore/ConversionManager.h b/Src/DasherCore/ConversionManager.h
index 6c4e490..7964765 100644
--- a/Src/DasherCore/ConversionManager.h
+++ b/Src/DasherCore/ConversionManager.h
@@ -33,6 +33,7 @@
 class CNodeCreationManager;
 
 namespace Dasher {
+  class CDasherInterfaceBase;
   /// \ingroup Model
   /// @{
 
@@ -61,7 +62,7 @@ namespace Dasher {
   class CConversionManager : public CNodeManager {
   public:
     // TODO: We shouldn't need to know about this stuff, but the code is somewhat in knots at the moment
-    CConversionManager(CNodeCreationManager *pNCManager, const CAlphInfo *pAlphabet);
+    CConversionManager(CDasherInterfaceBase *pInterface, CNodeCreationManager *pNCManager, const CAlphInfo *pAlphabet);
 
     ///Tells us to use the specified screen to create node labels.
     /// (note we cache the screen and create labels lazily)
@@ -137,7 +138,7 @@ namespace Dasher {
 
     virtual CConvNode *makeNode(CDasherNode *pParent, int iOffset, unsigned int iLbnd, unsigned int iHbnd, int iColour, CDasherScreen::Label *pLabel);
 
-
+  CDasherInterfaceBase *m_pInterface;
 	CNodeCreationManager *m_pNCManager;
 	const CAlphInfo *m_pAlphabet;
 	
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 77a23e5..557abc5 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -377,6 +377,26 @@ void CDasherInterfaceBase::SetLockStatus(const string &strText, int iPercent) {
   }
 }
 
+void CDasherInterfaceBase::editOutput(const std::string &strText, CDasherNode *pCause) {
+  CEditEvent evt(CEditEvent::EDIT_OUTPUT, strText, pCause);
+  m_pEventHandler->InsertEvent(&evt);
+}
+
+void CDasherInterfaceBase::editDelete(const std::string &strText, CDasherNode *pCause) {
+  CEditEvent evt(CEditEvent::EDIT_DELETE, strText, pCause);
+  m_pEventHandler->InsertEvent(&evt);
+}
+
+void CDasherInterfaceBase::editConvert(CDasherNode *pCause) {
+  CEditEvent evt(CEditEvent::EDIT_CONVERT, "", pCause);
+  m_pEventHandler->InsertEvent(&evt);
+}
+
+void CDasherInterfaceBase::editProtect(CDasherNode *pCause) {
+  CEditEvent evt(CEditEvent::EDIT_PROTECT, "", pCause);
+  m_pEventHandler->InsertEvent(&evt);
+}
+
 void CDasherInterfaceBase::WriteTrainFileFull() {
   m_pNCManager->GetAlphabetManager()->WriteTrainFileFull(this);
 }
diff --git a/Src/DasherCore/DasherInterfaceBase.h b/Src/DasherCore/DasherInterfaceBase.h
index 441cd6f..e9d7f03 100644
--- a/Src/DasherCore/DasherInterfaceBase.h
+++ b/Src/DasherCore/DasherInterfaceBase.h
@@ -236,6 +236,11 @@ public:
   /// (for forwards deletion, this will be the same as the offset *before*)
   virtual unsigned int ctrlDelete(bool bForwards, CControlManager::EditDistance dist)=0;
 
+  virtual void editOutput(const std::string &strText, CDasherNode *pCause);
+  virtual void editDelete(const std::string &strText, CDasherNode *pCause);
+  virtual void editConvert(CDasherNode *pCause);
+  virtual void editProtect(CDasherNode *pCause);
+
   class TextAction {
   public:
     TextAction(CDasherInterfaceBase *pMgr);
diff --git a/Src/DasherCore/Event.h b/Src/DasherCore/Event.h
index 24b11ab..0e517fb 100644
--- a/Src/DasherCore/Event.h
+++ b/Src/DasherCore/Event.h
@@ -39,11 +39,12 @@ public:
 };
 
 class Dasher::CEditEvent:public Dasher::CEvent {
-public:
+  friend class CDasherInterfaceBase;
   CEditEvent(int iEditType, const std::string & sText, CDasherNode *pNode)
   : CEvent(EV_EDIT), m_iEditType(iEditType), m_sText(sText), m_pNode(pNode) {
-  };
-
+  };  
+public:
+  static const int EDIT_OUTPUT=1, EDIT_DELETE=2, EDIT_CONVERT=10, EDIT_PROTECT=11;
   const int m_iEditType;
   const std::string m_sText;
   /// Node causing the event - allows calling GetSymbolProb, offset(), etc.
diff --git a/Src/Gtk2/DasherControl.cpp b/Src/Gtk2/DasherControl.cpp
index 51aa93f..a226681 100644
--- a/Src/Gtk2/DasherControl.cpp
+++ b/Src/Gtk2/DasherControl.cpp
@@ -341,25 +341,27 @@ void CDasherControl::ExternalEventHandler(Dasher::CEvent *pEvent) {
     HandleParameterNotification(pEvt->m_iParameter);
     g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_changed", pEvt->m_iParameter);
   }
-  else if(pEvent->m_iEventType == EV_EDIT) {
-    CEditEvent *pEditEvent(static_cast < CEditEvent * >(pEvent));
-    
-    if(pEditEvent->m_iEditType == 1) {
-      // Insert event
-      g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_edit_insert", pEditEvent->m_sText.c_str(), pEditEvent->m_pNode->offset());
-    }
-    else if(pEditEvent->m_iEditType == 2) {
-      // Delete event
-      g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_edit_delete", pEditEvent->m_sText.c_str(), pEditEvent->m_pNode->offset());
-    }
-    else if(pEditEvent->m_iEditType == 10) {
-      g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_edit_convert");
-    }
-    else if(pEditEvent->m_iEditType == 11) {
-      g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_edit_protect");
-    }
-  }
-};
+}
+
+void CDasherControl::editOutput(const std::string &strText, CDasherNode *pNode) {
+  g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_edit_insert", strText.c_str(), pNode->offset());
+  CDasherInterfaceBase::editOutput(strText, pNode);
+}
+
+void CDasherControl::editDelete(const std::string &strText, CDasherNode *pNode) {
+  g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_edit_delete", strText.c_str(), pNode->offset());
+  CDasherInterfaceBase::editDelete(strText, pNode);
+}
+
+void CDasherControl::editConvert(CDasherNode *pNode) {
+  g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_edit_convert");
+  CDasherInterfaceBase::editConvert(pNode);
+}
+
+void CDasherControl::editProtect(CDasherNode *pNode) {
+  g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_edit_protect");
+  CDasherInterfaceBase::editProtect(pNode);
+}
 
 void CDasherControl::SetLockStatus(const string &strText, int iPercent) {
     DasherLockInfo sInfo;
diff --git a/Src/Gtk2/DasherControl.h b/Src/Gtk2/DasherControl.h
index 55fbad0..e1af50a 100644
--- a/Src/Gtk2/DasherControl.h
+++ b/Src/Gtk2/DasherControl.h
@@ -157,6 +157,12 @@ public:
   virtual void ExternalEventHandler(Dasher::CEvent *pEvent);
 
   ///Override to emit Gtk2 signal
+  virtual void editOutput(const std::string &strText, CDasherNode *pNode);
+  virtual void editDelete(const std::string &strText, CDasherNode *pNode);
+  virtual void editConvert(CDasherNode *pNode);
+  virtual void editProtect(CDasherNode *pNode);
+
+  ///Override to emit Gtk2 signal
   virtual void SetLockStatus(const string &strText, int iPercent);
 
 private:
@@ -169,7 +175,7 @@ private:
   virtual void CreateSettingsStore();
   virtual void StartTimer();
   virtual void ShutdownTimer();
-
+  
   /// Override to emit Gtk2 signals (previously in response to CCommandEvent)
   void ExecuteCommand(const std::string &strName);
 
diff --git a/Src/MacOSX/COSXDasherControl.h b/Src/MacOSX/COSXDasherControl.h
index 15807c2..b209d20 100644
--- a/Src/MacOSX/COSXDasherControl.h
+++ b/Src/MacOSX/COSXDasherControl.h
@@ -86,6 +86,14 @@ private:
   ///
   
   void ExternalEventHandler(Dasher::CEvent *pEvent);
+
+  ///Override to perform output/deletion via DasherEdit
+  void editOutput(const std::string &strText, CDasherNode *pSource);
+  void editDelete(const std::string &strText, CDasherNode *pSource);
+  ///Just log (and call superclass)
+  void editConvert(CDasherNode *pSource);
+  void editProtect(CDasherNode *pSource);
+
   void GameMessageOut(int message, const void* messagedata);
   
   DasherApp *dasherApp;   // objc counterpart
diff --git a/Src/MacOSX/COSXDasherControl.mm b/Src/MacOSX/COSXDasherControl.mm
index 51dd2e7..528e6ef 100644
--- a/Src/MacOSX/COSXDasherControl.mm
+++ b/Src/MacOSX/COSXDasherControl.mm
@@ -159,29 +159,6 @@ void COSXDasherControl::ExternalEventHandler(Dasher::CEvent *pEvent) {
 //      CParameterNotificationEvent *parameterEvent(static_cast < CParameterNotificationEvent * >(pEvent));
 //      NSLog(@"CParameterNotificationEvent, m_iParameter: %d", parameterEvent->m_iParameter);
       break;
-    case EV_EDIT: {
-//      NSLog(@"ExternalEventHandler, m_iEventType = EV_EDIT");
-      CEditEvent *editEvent(static_cast < CEditEvent * >(pEvent));
-      switch (editEvent->m_iEditType) {
-        case 1:
-          //NSLog(@"ExternalEventHandler edit insert");
-          [dasherEdit outputCallback:NSStringFromStdString(editEvent->m_sText) targetApp:[dasherApp targetAppUIElementRef]];
-          break;
-        case 2:
-         // NSLog(@"ExternalEventHandler edit delete");
-          [dasherEdit deleteCallback:NSStringFromStdString(editEvent->m_sText) targetApp:[dasherApp targetAppUIElementRef]];
-          break;
-        case 10:
-          NSLog(@"ExternalEventHandler edit convert");
-          break;
-        case 11:
-          NSLog(@"ExternalEventHandler edit protect");
-          break;
-        default:
-          break;
-      }
-      break;
-    }
     case EV_SCREEN_GEOM:
       //no need to do anything, so avoid log message
       break;
@@ -189,7 +166,28 @@ void COSXDasherControl::ExternalEventHandler(Dasher::CEvent *pEvent) {
       NSLog(@"ExternalEventHandler, UNKNOWN m_iEventType = %d", pEvent->m_iEventType);
       break;
   }
-  
+}
+
+void COSXDasherControl::editOutput(const string &strText, CDasherNode *pNode) {
+//NSLog(@"ExternalEventHandler edit insert");
+  [dasherEdit outputCallback:NSStringFromStdString(strText) targetApp:[dasherApp targetAppUIElementRef]];
+  CDasherInterfaceBase::editOutput(strText,pNode);
+}
+
+void COSXDasherControl::editDelete(const string &strText, CDasherNode *pNode) {
+// NSLog(@"ExternalEventHandler edit delete");
+  [dasherEdit deleteCallback:NSStringFromStdString(strText) targetApp:[dasherApp targetAppUIElementRef]];
+  CDasherInterfaceBase::editDelete(strText, pNode);
+}
+
+void COSXDasherControl::editConvert(CDasherNode *pSource) {
+  NSLog(@"ExternalEventHandler edit convert");
+  CDasherInterfaceBase::editConvert(pSource);
+}
+
+void COSXDasherControl::editProtect(CDasherNode *pSource) {
+  NSLog(@"ExternalEventHandler edit protect");
+  CDasherInterfaceBase::editProtect(pSource);
 }
 
 unsigned int COSXDasherControl::ctrlMove(bool bForwards, CControlManager::EditDistance dist) {
diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp
index a893856..2f8c72b 100644
--- a/Src/Win32/Dasher.cpp
+++ b/Src/Win32/Dasher.cpp
@@ -111,33 +111,27 @@ void CDasher::Log() {
 }
 
 void Dasher::CDasher::ExternalEventHandler(CEvent* pEvent) {  
-  switch(pEvent->m_iEventType) {
-    case EV_PARAM_NOTIFY: {
-      int iParam(static_cast<CParameterNotificationEvent *> (pEvent)->m_iParameter);
-      m_pWindow->HandleParameterChange(iParam);
-      m_pEdit->HandleParameterChange(iParam);
-      break;
-    }
-    case EV_EDIT:  {
-      CEditEvent *pEvt(static_cast<CEditEvent *> (pEvent));
-      if(m_pWindow->m_pGameModeHelper) {
-        switch (pEvt->m_iEditType) {
-          case 1:
-            m_pWindow->m_pGameModeHelper->Output(pEvt->m_sText);
-            break;
-          case 2:
-            m_pWindow->m_pGameModeHelper->Delete(pEvt->m_sText.size());
-            break;
-        }
-      }
-      m_pEdit->HandleEditEvent(pEvt);
-      break;
-    }
-    default:
-      break;
+  if (pEvent->m_iEventType==EV_PARAM_NOTIFY) {
+    int iParam(static_cast<CParameterNotificationEvent *> (pEvent)->m_iParameter);
+    m_pWindow->HandleParameterChange(iParam);
+    m_pEdit->HandleParameterChange(iParam);
   }
 }
 
+void Dasher::CDasher::editOutput(const string &strText, CDasherNode *pSource) {
+  if(m_pWindow->m_pGameModeHelper)
+    m_pWindow->m_pGameModeHelper->Output(strText);
+  m_pEdit->output(strText);
+  CDasherInterfaceBase::editOutput(strText, pSource);
+}
+
+void Dasher::CDasher::editDelete(const string &strText, CDasherNode *pSource) {
+  if (m_pWindow->m_pGameModeHelper)
+    m_pWindow->m_pGameModeHelper->Delete(strText.size());
+  m_pEdit->deletetext(strText);
+  CDasherInterfaceBase::editDelete(strText, pSource);
+}
+
 unsigned int Dasher::CDasher::ctrlMove(bool bForwards, CControlManager::EditDistance iDist) {
   return m_pEdit->Move(bForwards, iDist);
 }
diff --git a/Src/Win32/Dasher.h b/Src/Win32/Dasher.h
index b56a38c..7b0551d 100644
--- a/Src/Win32/Dasher.h
+++ b/Src/Win32/Dasher.h
@@ -48,6 +48,8 @@ public:
   void TakeFocus();
 
   void ExternalEventHandler(Dasher::CEvent *pEvent);
+  void editOutput(const std::string &strText, CDasherNode *pSource);
+  void editDelete(const std::string &strText, CDasherNode *pSource);
   unsigned int ctrlMove(bool bForwards, CControlManager::EditDistance iDist);
   unsigned int ctrlDelete(bool bForwards, CControlManager::EditDistance iDist);
   
diff --git a/Src/Win32/Widgets/Edit.cpp b/Src/Win32/Widgets/Edit.cpp
index 09c7ebc..c3f8140 100644
--- a/Src/Win32/Widgets/Edit.cpp
+++ b/Src/Win32/Widgets/Edit.cpp
@@ -875,15 +875,4 @@ void CEdit::HandleParameterChange(int iParameter) {
   default:
     break;
   }
-}
-
-void CEdit::HandleEditEvent(Dasher::CEditEvent *pEvt) {
-  switch (pEvt->m_iEditType) {
-    case 1:
-      output(pEvt->m_sText);
-      break;
-    case 2:
-      deletetext(pEvt->m_sText);
-      break;
-  }
 }
\ No newline at end of file
diff --git a/Src/Win32/Widgets/Edit.h b/Src/Win32/Widgets/Edit.h
index 5c75b51..740b505 100644
--- a/Src/Win32/Widgets/Edit.h
+++ b/Src/Win32/Widgets/Edit.h
@@ -117,17 +117,16 @@ class CEdit : public ATL::CWindowImpl<CEdit> {
   // Get context (new version)
   std::string get_context(int iOffset, int iLength);
 
-  // called when characters fall of the LHS of the screen
+  // called when a new character falls under the crosshair
   void output(const std::string & sText);
     
-  // remove the previous character
+  // remove the previous character: called when we steer/reverse the crosshair out of a node
   void deletetext(const std::string & sText);
   
   void SetNewWithDate(bool bNewWithDate);
 
   //ACL Making these public so can be called directly from CDasher
   void HandleParameterChange(int iParameter);
-  void HandleEditEvent(Dasher::CEditEvent *pEvent);
 
  protected:
   bool m_dirty;
diff --git a/Src/iPhone/Classes/CDasherInterfaceBridge.h b/Src/iPhone/Classes/CDasherInterfaceBridge.h
index 869c4cc..f16e4e4 100644
--- a/Src/iPhone/Classes/CDasherInterfaceBridge.h
+++ b/Src/iPhone/Classes/CDasherInterfaceBridge.h
@@ -55,6 +55,10 @@ public:
   unsigned int ctrlMove(bool bForwards, CControlManager::EditDistance dist);
   unsigned int ctrlDelete(bool bForwards, CControlManager::EditDistance dist);
   void SetLockStatus(const string &strText, int iPercent);
+  void editOutput(const string &strText, CDasherNode *pNode);
+  void editDelete(const string &strText, CDasherNode *pNode);
+  void editConvert(CDasherNode *pNode);
+  void editProtect(CDasherNode *pNode);
   void Message(const string &strText);
 private:
   virtual void ScanAlphabetFiles(std::vector<std::string> &vFileList);
diff --git a/Src/iPhone/Classes/CDasherInterfaceBridge.mm b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
index 4ad74d1..c927a05 100644
--- a/Src/iPhone/Classes/CDasherInterfaceBridge.mm
+++ b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
@@ -158,38 +158,35 @@ void CDasherInterfaceBridge::ExternalEventHandler(Dasher::CEvent *pEvent) {
       [dasherApp setAlphabet:GetActiveAlphabet()];
     }
       break;
-    case EV_EDIT:
-	  {
-//      NSLog(@"ExternalEventHandler, m_iEventType = EV_EDIT");
-		  CEditEvent *editEvent((CEditEvent *)pEvent);
-      switch (editEvent->m_iEditType) {
-        case 1:
-          //NSLog(@"ExternalEventHandler edit insert");
-          [dasherApp outputCallback:NSStringFromStdString(editEvent->m_sText)];
-          break;
-        case 2:
-          //NSLog(@"ExternalEventHandler edit delete");
-          [dasherApp deleteCallback:NSStringFromStdString(editEvent->m_sText)];
-          break;
-        case 10:
-          NSLog(@"ExternalEventHandler edit convert");
-          break;
-        case 11:
-          NSLog(@"ExternalEventHandler edit protect");
-          break;
-        default:
-          break;
-      }
-	  }
-        break;
    case EV_SCREEN_GEOM:
      //no need to do anything
      break;
-    default:
-      NSLog(@"ExternalEventHandler, UNKNOWN m_iEventType = %d", pEvent->m_iEventType);
-      break;
-  }
-  
+   default:
+     NSLog(@"ExternalEventHandler, UNKNOWN m_iEventType = %d", pEvent->m_iEventType);
+     break;
+   }
+}
+
+void CDasherInterfaceBridge::editOutput(const string &strText, CDasherNode *pNode) {
+//NSLog(@"ExternalEventHandler edit insert");
+  [dasherApp outputCallback:NSStringFromStdString(strText)];
+  CDasherInterfaceBase::editOutput(strText,pNode);
+}
+
+void CDasherInterfaceBridge::editDelete(const string &strText, CDasherNode *pNode) {
+// NSLog(@"ExternalEventHandler edit delete");
+  [dasherApp deleteCallback:NSStringFromStdString(strText)];
+  CDasherInterfaceBase::editDelete(strText, pNode);
+}
+
+void CDasherInterfaceBridge::editConvert(CDasherNode *pSource) {
+  NSLog(@"ExternalEventHandler edit convert");
+  CDasherInterfaceBase::editConvert(pSource);
+}
+
+void CDasherInterfaceBridge::editProtect(CDasherNode *pSource) {
+  NSLog(@"ExternalEventHandler edit protect");
+  CDasherInterfaceBase::editProtect(pSource);
 }
 
 void CDasherInterfaceBridge::Message(const string &strMessage) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]