[dasher: 2/11] Rename Pause() to Stop(); remove CStop/StartEvent and EV_START/EV_STOP



commit 61a53471cff4059eaedd7cb376c43999a50ab805
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Wed May 12 11:02:08 2010 +0100

    Rename Pause() to Stop(); remove CStop/StartEvent and EV_START/EV_STOP
    
    For now subclasses can intercept Stop() by overriding (virtual method).
    Also renamed BP_PAUSE_OUTSIDE to BP_STOP_OUTSIDE.
    
    Gtk2: removed DASHER_START signal, but preserving DASHER_STOP (Stop() emits)

 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/dashermaemofullscreen.ui            |    1 -
 Src/DasherCore/CircleStartHandler.cpp        |    2 +-
 Src/DasherCore/DasherGameMode.cpp            |   31 +++++++++++++------------
 Src/DasherCore/DasherInterfaceBase.cpp       |   14 +----------
 Src/DasherCore/DasherInterfaceBase.h         |   21 ++++-------------
 Src/DasherCore/DasherModel.h                 |    2 +-
 Src/DasherCore/DefaultFilter.cpp             |    8 +++---
 Src/DasherCore/DynamicFilter.cpp             |    4 +-
 Src/DasherCore/Event.h                       |   18 +--------------
 Src/DasherCore/Parameters.h                  |    4 +-
 Src/DasherCore/StylusFilter.cpp              |    2 +-
 Src/Gtk2/DasherControl.cpp                   |   12 +++++-----
 Src/Gtk2/DasherControl.h                     |    3 ++
 Src/Gtk2/GtkDasherControl.cpp                |    6 +----
 Src/Gtk2/GtkDasherControl.h                  |    1 -
 Src/Gtk2/Preferences.cpp                     |    2 +-
 Src/MacOSX/COSXDasherControl.mm              |    6 -----
 Src/MacOSX/DasherApp.mm                      |    2 +-
 Src/MacOSX/DasherEdit.mm                     |    3 +-
 Src/Qt/QtDasherScreen.cc                     |    2 +-
 Src/Win32/Dasher.cpp                         |    7 ++++++
 Src/Win32/Dasher.h                           |    5 ++-
 Src/Win32/Widgets/AdvancedPage.cpp           |    2 +-
 Src/Win32/Widgets/Edit.cpp                   |    3 --
 Src/iPhone/Classes/CDasherInterfaceBridge.mm |    6 -----
 Src/iPhone/Classes/DasherAppDelegate.mm      |    2 +-
 Src/iPhone/Classes/IPhoneFilters.cpp         |    2 +-
 Src/iPhone/Classes/PlainDragFilter.cpp       |    2 +-
 33 files changed, 64 insertions(+), 114 deletions(-)
---
diff --git a/Data/GUI/dasher.compose.ui b/Data/GUI/dasher.compose.ui
index 247baa4..eacc7bc 100644
--- a/Data/GUI/dasher.compose.ui
+++ b/Data/GUI/dasher.compose.ui
@@ -458,7 +458,6 @@
                             <property name="int1">0</property>
                             <property name="int2">0</property>
                             <signal handler="parameter_notification" name="dasher_changed"/>
-                            <signal handler="handle_start_event" name="dasher_start"/>
                             <signal handler="handle_stop_event" name="dasher_stop"/>
                             <signal handler="handle_control_event" name="dasher_control"/>
                             <signal handler="gtk2_edit_output_callback" name="dasher_edit_insert"/>
diff --git a/Data/GUI/dasher.direct.ui b/Data/GUI/dasher.direct.ui
index abd0903..88c9b83 100644
--- a/Data/GUI/dasher.direct.ui
+++ b/Data/GUI/dasher.direct.ui
@@ -55,7 +55,6 @@
                 <property name="can_focus">True</property>
                 <property name="has_focus">True</property>
                 <signal handler="parameter_notification" name="dasher_changed"/>
-                <signal handler="handle_start_event" name="dasher_start"/>
                 <signal handler="handle_stop_event" name="dasher_stop"/>
                 <signal handler="handle_control_event" name="dasher_control"/>
                 <signal handler="gtk2_edit_output_callback" name="dasher_edit_insert"/>
diff --git a/Data/GUI/dasher.fullscreen.ui b/Data/GUI/dasher.fullscreen.ui
index 75f2546..f83a315 100644
--- a/Data/GUI/dasher.fullscreen.ui
+++ b/Data/GUI/dasher.fullscreen.ui
@@ -171,7 +171,6 @@
                     <property name="int2">0</property>
                     <property name="last_modification_time">Sun, 05 Mar 2006 19:33:03 GMT</property>
                     <signal handler="parameter_notification" last_modification_time="Sun, 05 Mar 2006 19:45:23 GMT" name="dasher_changed"/>
-                    <signal handler="handle_start_event" last_modification_time="Sun, 05 Mar 2006 19:45:35 GMT" name="dasher_start"/>
                     <signal handler="handle_stop_event" last_modification_time="Sun, 05 Mar 2006 19:45:43 GMT" name="dasher_stop"/>
                     <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"/>
diff --git a/Data/GUI/dasher.gameWIP.ui b/Data/GUI/dasher.gameWIP.ui
index a7a1340..64ee4c0 100644
--- a/Data/GUI/dasher.gameWIP.ui
+++ b/Data/GUI/dasher.gameWIP.ui
@@ -646,7 +646,6 @@
                 <property name="int2">0</property>
                 <property name="last_modification_time">Sun, 05 Mar 2006 19:33:03 GMT</property>
                 <signal handler="parameter_notification" last_modification_time="Sun, 05 Mar 2006 19:45:23 GMT" name="dasher_changed"/>
-                <signal handler="handle_start_event" last_modification_time="Sun, 05 Mar 2006 19:45:35 GMT" name="dasher_start"/>
                 <signal handler="handle_stop_event" last_modification_time="Sun, 05 Mar 2006 19:45:43 GMT" name="dasher_stop"/>
                 <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"/>
diff --git a/Data/GUI/dasher.traditional.ui b/Data/GUI/dasher.traditional.ui
index 58ec38b..eff79d0 100644
--- a/Data/GUI/dasher.traditional.ui
+++ b/Data/GUI/dasher.traditional.ui
@@ -243,7 +243,6 @@
                 <property name="height_request">200</property>
                 <property name="visible">True</property>
                 <signal handler="parameter_notification" name="dasher_changed"/>
-                <signal handler="handle_start_event" name="dasher_start"/>
                 <signal handler="handle_stop_event" name="dasher_stop"/>
                 <signal handler="handle_control_event" name="dasher_control"/>
                 <signal handler="gtk2_edit_output_callback" name="dasher_edit_insert"/>
diff --git a/Data/GUI/dashermaemofullscreen.ui b/Data/GUI/dashermaemofullscreen.ui
index 1427a3d..96fc49b 100644
--- a/Data/GUI/dashermaemofullscreen.ui
+++ b/Data/GUI/dashermaemofullscreen.ui
@@ -216,7 +216,6 @@
                 <property name="int2">0</property>
                 <property name="last_modification_time">Wed, 29 Mar 2006 17:31:58 GMT</property>
                 <signal handler="parameter_notification" last_modification_time="Sun, 05 Mar 2006 19:45:23 GMT" name="dasher_changed"/>
-                <signal handler="handle_start_event" last_modification_time="Sun, 05 Mar 2006 19:45:35 GMT" name="dasher_start"/>
                 <signal handler="handle_stop_event" last_modification_time="Sun, 05 Mar 2006 19:45:43 GMT" name="dasher_stop"/>
                 <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"/>
diff --git a/Src/DasherCore/CircleStartHandler.cpp b/Src/DasherCore/CircleStartHandler.cpp
index b3d5020..a8495ad 100644
--- a/Src/DasherCore/CircleStartHandler.cpp
+++ b/Src/DasherCore/CircleStartHandler.cpp
@@ -151,7 +151,7 @@ void CCircleStartHandler::Timer(int iTime, CDasherView *m_pDasherView, CDasherMo
   if(iTime - m_iChangeTime > 1000) {
     if(iNewStatus == 4) {
       iNewStatus = 2;
-      m_pInterface->Pause();
+      m_pInterface->Stop();
     } 
     else if(iNewStatus == 5) {
       iNewStatus = 3;
diff --git a/Src/DasherCore/DasherGameMode.cpp b/Src/DasherCore/DasherGameMode.cpp
index 53b3847..40e0793 100644
--- a/Src/DasherCore/DasherGameMode.cpp
+++ b/Src/DasherCore/DasherGameMode.cpp
@@ -134,7 +134,7 @@ void CDasherGameMode::NotifyGameCooperators(bool bGameOn)
   m_pView->SetGameMode(bGameOn);
   m_pDasherInterface->SetContext(std::string(""));
   m_pDasherInterface->SetBuffer(0);
-  m_pDasherInterface->Pause();
+  m_pDasherInterface->Stop();
 
 }
 
@@ -184,7 +184,7 @@ void CDasherGameMode::DemoModeStart(bool bFullDemo)
 void CDasherGameMode::DemoModeStop()
 {
   // Close down external first...
-  m_pDasherInterface->Pause();
+  m_pDasherInterface->Stop();
   m_pView->SetDemoMode(false);
 
   // ... then internal.
@@ -238,18 +238,19 @@ void CDasherGameMode::HandleEvent(Dasher::CEvent * pEvent)
 	    case LP_MAX_BITRATE: 
 	      CalculateDemoParameters();
 	      break;
+      case BP_DASHER_PAUSED:
+          if (GetBoolParameter(BP_DASHER_PAUSED)) {
+            //just stopped
+            if(m_pScorer)
+              m_pScorer->Stop();
+          } else {
+            if(m_pDemo)
+              CalculateDemoParameters();
+            if(m_pScorer)
+              m_pScorer->Start();            
+          }
 	    }
 	  break;
-	case EV_STOP:
-	  if(m_pScorer)
-	    m_pScorer->Stop();
-	  break;
-	case EV_START:
-	  if(m_pDemo)
-	    CalculateDemoParameters();
-	  if(m_pScorer)
-	    m_pScorer->Start();
-	  break;
 	case EV_EDIT:
 	  if(m_bSentenceFinished) break;
 	  CEditEvent *pEditEvent(static_cast < CEditEvent * >(pEvent));
@@ -298,7 +299,7 @@ void CDasherGameMode::GameNext()
   m_pDasherInterface->GameMessageOut(GAME_MESSAGE_CLEAR_BUFFER, NULL);
   m_pDasherInterface->SetContext(std::string(""));
   m_pDasherInterface->SetBuffer(0);
-  m_pDasherInterface->Pause();
+  m_pDasherInterface->Stop();
  
   RunningScoreUpdates();
 }
@@ -336,7 +337,7 @@ void CDasherGameMode::FullDemoNext()
   m_pDasherInterface->GameMessageOut(GAME_MESSAGE_CLEAR_BUFFER, NULL);
   m_pDasherInterface->SetContext(std::string(""));
   m_pDasherInterface->SetBuffer(0);
-  m_pDasherInterface->Pause();
+  m_pDasherInterface->Stop();
 
   // We start in 3 seconds.
   Callback(&CDasherGameMode::DemoGo,3000);
@@ -654,7 +655,7 @@ void CDasherGameMode::PrivateSentenceFinished()
   m_bDrawHelperArrow=false;
   m_bDrawTargetArrow=false;
   m_bSentenceFinished=true;
-  m_pDasherInterface->Pause();
+  m_pDasherInterface->Stop();
   if(!m_pDemo) {
     string msg = m_pLevel->m_strPerformance.str();
     m_pDasherInterface->GameMessageOut(GAME_MESSAGE_HELP_MESSAGE, &msg);
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index e72aee2..cdc0a5a 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -356,7 +356,7 @@ void CDasherInterfaceBase::InterfaceEventHandler(Dasher::CEvent *pEvent) {
 
     switch(pControlEvent->m_iID) {
     case CControlManager::CTL_STOP:
-      Pause();
+      Stop();
       break;
     case CControlManager::CTL_PAUSE:
   //Halt Dasher - without a stop event, so does not result in speech etc.
@@ -433,16 +433,13 @@ void CDasherInterfaceBase::CreateNCManager() {
     CreateModel(iOffset);
 }
 
-void CDasherInterfaceBase::Pause() {
+void CDasherInterfaceBase::Stop() {
   if (GetBoolParameter(BP_DASHER_PAUSED)) return; //already paused, no need to do anything.
   SetBoolParameter(BP_DASHER_PAUSED, true);
 
   // Request a full redraw at the next time step.
   SetBoolParameter(BP_REDRAW, true);
 
-  Dasher::CStopEvent oEvent;
-  m_pEventHandler->InsertEvent(&oEvent);
-
 #ifndef _WIN32_WCE
   if (m_pUserLog != NULL)
     m_pUserLog->StopWriting((float) GetNats());
@@ -460,13 +457,6 @@ void CDasherInterfaceBase::Unpause(unsigned long Time) {
   if(m_pDasherModel != 0)
     m_pDasherModel->Reset_framerate(Time);
 
-  Dasher::CStartEvent oEvent;
-  m_pEventHandler->InsertEvent(&oEvent);
-
-  // Commenting this out, can't see a good reason to ResetNats,
-  // just because we are not paused anymore - pconlon
-  // ResetNats();
-
 #ifndef _WIN32_WCE
   if (m_pUserLog != NULL)
     m_pUserLog->StartWriting();
diff --git a/Src/DasherCore/DasherInterfaceBase.h b/Src/DasherCore/DasherInterfaceBase.h
index 638705a..3a72144 100644
--- a/Src/DasherCore/DasherInterfaceBase.h
+++ b/Src/DasherCore/DasherInterfaceBase.h
@@ -63,12 +63,6 @@ class CNodeCreationManager;
 /// @{
 
 
-struct Dasher::SLockData {
-  std::string strDisplay;
-  int iPercent;
-};
-
-
 /// The central class in the core of Dasher. Ties together the rest of
 /// the platform independent stuff and provides a single interface for
 /// the UI to use.
@@ -215,19 +209,14 @@ public:
   /// Methods used to instruct dynamic motion of Dasher to start or stop
   /// @{ 
 
-  /// Resets the Dasher model. Doesn't actually unpause Dasher.
-  /// \deprecated Use InvalidateContext() instead
-
-  //  void Start();
-
-  /// Pause Dasher. Sets BP_DASHER_PAUSED and broadcasts a StopEvent.
+  /// Stop Dasher - Sets BP_DASHER_PAUSED; subclasses may override to do more
   /// (But does nothing if BP_DASHER_PAUSED is not set)
-  void Pause(); // are required to make
+  virtual void Stop();
 
-  /// Unpause Dasher. Clears BP_DASHER_PAUSED, broadcasts a StartEvent.
+  /// Unpause Dasher. Clears BP_DASHER_PAUSED.
   /// (But does nothing if BP_DASHER_PAUSED is currently set).
   /// \param Time Time in ms, used to keep a constant frame rate
-  void Unpause(unsigned long Time);     // Dasher run at the
+  void Unpause(unsigned long Time);
 
   /// @}
 
@@ -340,7 +329,7 @@ public:
 
   void AddGameModeString(const std::string &strText) {
     m_deGameModeStrings.push_back(strText);
-    Pause();
+    Stop();
     //    CreateDasherModel();
     CreateNCManager();
     //    Start();
diff --git a/Src/DasherCore/DasherModel.h b/Src/DasherCore/DasherModel.h
index d8c050b..075da35 100644
--- a/Src/DasherCore/DasherModel.h
+++ b/Src/DasherCore/DasherModel.h
@@ -192,7 +192,7 @@ class Dasher::CDasherModel:public Dasher::CFrameRate, private NoClones
   ///
 
   int GetOffset() {
-    return m_pLastOutput->offset()+1;
+    return m_pLastOutput ? m_pLastOutput->offset()+1 : 0;
   };
 
   /// Create the children of a Dasher node
diff --git a/Src/DasherCore/DefaultFilter.cpp b/Src/DasherCore/DefaultFilter.cpp
index 8b767cc..a66336d 100644
--- a/Src/DasherCore/DefaultFilter.cpp
+++ b/Src/DasherCore/DefaultFilter.cpp
@@ -54,7 +54,7 @@ bool CDefaultFilter::Timer(int Time, CDasherView *m_pDasherView, CDasherModel *m
     ApplyAutoCalibration(iDasherX, iDasherY, true);
     ApplyTransform(iDasherX, iDasherY);
 
-    if(GetBoolParameter(BP_PAUSE_OUTSIDE)) {
+    if(GetBoolParameter(BP_STOP_OUTSIDE)) {
       myint iDasherMinX;
       myint iDasherMinY;
       myint iDasherMaxX;
@@ -62,7 +62,7 @@ bool CDefaultFilter::Timer(int Time, CDasherView *m_pDasherView, CDasherModel *m
       m_pDasherView->VisibleRegion(iDasherMinX, iDasherMinY, iDasherMaxX, iDasherMaxY);
   
       if((iDasherX > iDasherMaxX) || (iDasherX < iDasherMinX) || (iDasherY > iDasherMaxY) || (iDasherY < iDasherMinY)) {
-        m_pInterface->Pause();
+        m_pInterface->Stop();
         return false;
       }
     }
@@ -88,7 +88,7 @@ void CDefaultFilter::KeyDown(int iTime, int iId, CDasherView *pDasherView, CDash
       if(GetBoolParameter(BP_DASHER_PAUSED))
 	m_pInterface->Unpause(iTime);
       else
-	m_pInterface->Pause();
+	m_pInterface->Stop();
     }
     break; 
   case 100: // Start on mouse
@@ -96,7 +96,7 @@ void CDefaultFilter::KeyDown(int iTime, int iId, CDasherView *pDasherView, CDash
       if(GetBoolParameter(BP_DASHER_PAUSED))
 	m_pInterface->Unpause(iTime);
       else
-	m_pInterface->Pause();
+	m_pInterface->Stop();
     }
     break;
   default:
diff --git a/Src/DasherCore/DynamicFilter.cpp b/Src/DasherCore/DynamicFilter.cpp
index e4ddabc..af6229f 100644
--- a/Src/DasherCore/DynamicFilter.cpp
+++ b/Src/DasherCore/DynamicFilter.cpp
@@ -105,7 +105,7 @@ void CDynamicFilter::Event(int iTime, int iButton, int iType, CDasherModel *pMod
       pUserLog->KeyDown(iButton, iType, 2);
     
     pause();
-    m_pInterface->Pause();
+    m_pInterface->Stop();
   } else {
     //running; examine event/button-press type
     switch(iType) {
@@ -115,7 +115,7 @@ void CDynamicFilter::Event(int iTime, int iButton, int iType, CDasherModel *pMod
         if(pUserLog)
           pUserLog->KeyDown(iButton, iType, 2);
         pause();
-        m_pInterface->Pause();
+        m_pInterface->Stop();
         break;
       }
       else if(iButton == 1) {
diff --git a/Src/DasherCore/Event.h b/Src/DasherCore/Event.h
index 542972a..e171c10 100644
--- a/Src/DasherCore/Event.h
+++ b/Src/DasherCore/Event.h
@@ -11,8 +11,6 @@ namespace Dasher {
   class CParameterNotificationEvent;
   class CEditEvent;
   class CEditContextEvent;
-  class CStartEvent;
-  class CStopEvent;
   class CControlEvent;
   class CLockEvent;
   class CMessageEvent;
@@ -20,7 +18,7 @@ namespace Dasher {
 }
 
 enum {
-  EV_PARAM_NOTIFY = 1, EV_EDIT, EV_EDIT_CONTEXT, EV_START, EV_STOP, EV_CONTROL, EV_LOCK, EV_MESSAGE, EV_COMMAND
+  EV_PARAM_NOTIFY = 1, EV_EDIT, EV_EDIT_CONTEXT, EV_CONTROL, EV_LOCK, EV_MESSAGE, EV_COMMAND
 };
 
 /// \ingroup Core
@@ -69,20 +67,6 @@ public:
   int m_iLength;
 };
 
-class Dasher::CStartEvent:public Dasher::CEvent {
-public:
-  CStartEvent() {
-    m_iEventType = EV_START;
-  };
-};
-
-class Dasher::CStopEvent:public Dasher::CEvent {
-public:
-  CStopEvent() {
-    m_iEventType = EV_STOP;
-  };
-};
-
 class Dasher::CControlEvent:public Dasher::CEvent {
 public:
   CControlEvent(int iID) {
diff --git a/Src/DasherCore/Parameters.h b/Src/DasherCore/Parameters.h
index 3de96ba..2e4b37e 100644
--- a/Src/DasherCore/Parameters.h
+++ b/Src/DasherCore/Parameters.h
@@ -40,7 +40,7 @@ enum {
   BP_LM_LETTER_EXCLUSION, BP_AUTO_SPEEDCONTROL,
   BP_LM_ADAPTIVE, BP_SOCKET_INPUT_ENABLE, BP_SOCKET_DEBUG, 
   BP_CIRCLE_START, BP_GLOBAL_KEYBOARD, BP_NONLINEAR_Y,
-  BP_SMOOTH_OFFSET, BP_CONVERSION_MODE, BP_PAUSE_OUTSIDE, BP_BACKOFF_BUTTON,
+  BP_SMOOTH_OFFSET, BP_CONVERSION_MODE, BP_STOP_OUTSIDE, BP_BACKOFF_BUTTON,
   BP_TWOBUTTON_REVERSE, BP_2B_INVERT_DOUBLE, BP_SLOW_START,
 #ifdef TARGET_OS_IPHONE
   BP_CUSTOM_TILT, BP_DOUBLE_X,
@@ -158,7 +158,7 @@ static bp_table boolparamtable[] = {
 #endif
   {BP_SMOOTH_OFFSET, "DelayView", !PERS, false, "Smooth dynamic-button-mode jumps over several frames"},
   {BP_CONVERSION_MODE, "ConversionMode", !PERS, false, "Whether Dasher is operating in conversion (eg Japanese) mode"},
-  {BP_PAUSE_OUTSIDE, "PauseOutside", PERS, false, "Whether to pause when pointer leaves canvas area"},
+  {BP_STOP_OUTSIDE, "PauseOutside", PERS, false, "Whether to stop when pointer leaves canvas area"},
 #ifdef TARGET_OS_IPHONE
   {BP_BACKOFF_BUTTON, "BackoffButton", PERS, false, "Whether to enable the extra backoff button in dynamic mode"},
 #else
diff --git a/Src/DasherCore/StylusFilter.cpp b/Src/DasherCore/StylusFilter.cpp
index aa83b1a..4267b8d 100644
--- a/Src/DasherCore/StylusFilter.cpp
+++ b/Src/DasherCore/StylusFilter.cpp
@@ -36,7 +36,7 @@ void CStylusFilter::KeyUp(int iTime, int iId, CDasherView *pView, CDasherModel *
       pView->GetCoordinates(iDasherX, iDasherY);
       pModel->ScheduleZoom(iTime, iDasherX, iDasherY, GetLongParameter(LP_MAXZOOM));
     } else {
-      m_pInterface->Pause();
+      m_pInterface->Stop();
     }
   }
 }
diff --git a/Src/Gtk2/DasherControl.cpp b/Src/Gtk2/DasherControl.cpp
index e743238..260fcf5 100644
--- a/Src/Gtk2/DasherControl.cpp
+++ b/Src/Gtk2/DasherControl.cpp
@@ -329,12 +329,6 @@ void CDasherControl::ExternalEventHandler(Dasher::CEvent *pEvent) {
     CEditContextEvent *pEditContextEvent(static_cast < CEditContextEvent * >(pEvent));
     g_signal_emit_by_name(GTK_OBJECT(m_pDasherControl), "dasher_context_request", pEditContextEvent->m_iOffset, pEditContextEvent->m_iLength);
   }
-  else if(pEvent->m_iEventType == EV_START) {
-    g_signal_emit_by_name(GTK_OBJECT(m_pDasherControl), "dasher_start");
-  }
-  else if(pEvent->m_iEventType == EV_STOP) {
-    g_signal_emit_by_name(GTK_OBJECT(m_pDasherControl), "dasher_stop");
-  }
   else if(pEvent->m_iEventType == EV_CONTROL) {
     CControlEvent *pControlEvent(static_cast < CControlEvent * >(pEvent));
     g_signal_emit_by_name(GTK_OBJECT(m_pDasherControl), "dasher_control", pControlEvent->m_iID);
@@ -488,6 +482,12 @@ gboolean CDasherControl::ExposeEvent() {
   return 0;
 }
 
+void CDasherControl::Stop() {
+  if (GetBoolParameter(BP_DASHER_PAUSED)) return;
+  CDasherInterfaceBase::Stop();
+  g_signal_emit_by_name(GTK_OBJECT(m_pDasherControl), "dasher_stop");
+}
+
 gboolean CDasherControl::ButtonPressEvent(GdkEventButton *event) {
 
   // Take the focus if we click on the canvas
diff --git a/Src/Gtk2/DasherControl.h b/Src/Gtk2/DasherControl.h
index 7a3ab37..a3ef525 100644
--- a/Src/Gtk2/DasherControl.h
+++ b/Src/Gtk2/DasherControl.h
@@ -128,6 +128,9 @@ public:
   
   gboolean ExposeEvent();
 
+  ///Override to broadcast signal...
+  virtual void Stop();
+
 private:
   //  virtual void CreateSettingsStore();
   virtual void ScanAlphabetFiles(std::vector<std::string> &vFileList);
diff --git a/Src/Gtk2/GtkDasherControl.cpp b/Src/Gtk2/GtkDasherControl.cpp
index 9e3c0d0..7e2c70c 100644
--- a/Src/Gtk2/GtkDasherControl.cpp
+++ b/Src/Gtk2/GtkDasherControl.cpp
@@ -38,7 +38,6 @@ typedef struct _GtkDasherControlPrivate GtkDasherControlPrivate;
 
 enum {
   DASHER_CHANGED,
-  DASHER_START,
   DASHER_STOP,
   DASHER_EDIT_INSERT,
   DASHER_EDIT_DELETE,
@@ -71,8 +70,6 @@ gtk_dasher_control_class_init(GtkDasherControlClass *pClass) {
    
   gtk_dasher_control_signals[DASHER_CHANGED] = g_signal_new("dasher_changed", G_TYPE_FROM_CLASS(pClass), static_cast < GSignalFlags > (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), G_STRUCT_OFFSET(GtkDasherControlClass, dasher_changed), NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
 
-  gtk_dasher_control_signals[DASHER_START] = g_signal_new("dasher_start", G_TYPE_FROM_CLASS(pClass), static_cast < GSignalFlags > (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), G_STRUCT_OFFSET(GtkDasherControlClass, dasher_start), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
   gtk_dasher_control_signals[DASHER_STOP] = g_signal_new("dasher_stop", G_TYPE_FROM_CLASS(pClass), static_cast < GSignalFlags > (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), G_STRUCT_OFFSET(GtkDasherControlClass, dasher_stop), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
   gtk_dasher_control_signals[DASHER_EDIT_INSERT] = g_signal_new("dasher_edit_insert", G_TYPE_FROM_CLASS(pClass), static_cast < GSignalFlags > (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), G_STRUCT_OFFSET(GtkDasherControlClass, dasher_edit_insert), NULL, NULL, g_cclosure_user_marshal_VOID__STRING_INT, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_INT);
@@ -100,7 +97,6 @@ gtk_dasher_control_class_init(GtkDasherControlClass *pClass) {
    gtk_dasher_control_signals[DASHER_COMMAND] = g_signal_new("dasher_command", G_TYPE_FROM_CLASS(pClass), static_cast < GSignalFlags > (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), G_STRUCT_OFFSET(GtkDasherControlClass, dasher_command), NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
 
   pClass->dasher_changed = NULL;
-  pClass->dasher_start = NULL;
   pClass->dasher_stop = NULL;
   pClass->dasher_edit_insert = NULL;
   pClass->dasher_edit_delete = NULL;
@@ -314,7 +310,7 @@ gtk_dasher_control_game_messageout(GtkDasherControl *pControl, int message, cons
 void 
 gtk_dasher_control_force_pause(GtkDasherControl *pControl) {
   GtkDasherControlPrivate *pPrivate = GTK_DASHER_CONTROL_GET_PRIVATE(pControl);
-  pPrivate->pControl->Pause();
+  pPrivate->pControl->Stop();
 }
 
 double 
diff --git a/Src/Gtk2/GtkDasherControl.h b/Src/Gtk2/GtkDasherControl.h
index 2980421..9cfcff0 100644
--- a/Src/Gtk2/GtkDasherControl.h
+++ b/Src/Gtk2/GtkDasherControl.h
@@ -44,7 +44,6 @@ struct _GtkDasherControlClass {
   // Signal handlers
 
   void (*dasher_changed) (GtkDasherControl * pDasherControl, gint iParameter, gpointer data);
-  void (*dasher_start) (GtkDasherControl * pDasherControl, gpointer data);
   void (*dasher_stop) (GtkDasherControl * pDasherControl, gpointer data);
   void (*dasher_edit_insert) (GtkDasherControl * pDasherControl, const gchar * szText, int iOffset, gpointer data);
   void (*dasher_edit_delete) (GtkDasherControl * pDasherControl, const gchar * szText, int iOffset, gpointer data);
diff --git a/Src/Gtk2/Preferences.cpp b/Src/Gtk2/Preferences.cpp
index a198180..8b5badc 100644
--- a/Src/Gtk2/Preferences.cpp
+++ b/Src/Gtk2/Preferences.cpp
@@ -45,7 +45,7 @@ BoolTranslation sBoolTranslationTable[] = {
   {APP_BP_DOCK, "dockbutton", NULL},
   {BP_START_MOUSE, "leftbutton", NULL},  
   {BP_START_SPACE, "spacebutton", NULL},
-  {BP_PAUSE_OUTSIDE, "winpausebutton", NULL},
+  {BP_STOP_OUTSIDE, "winpausebutton", NULL},
   {BP_AUTO_SPEEDCONTROL, "adaptivebutton", NULL},
   {BP_LM_ADAPTIVE, "cb_adaptive", NULL}
 };
diff --git a/Src/MacOSX/COSXDasherControl.mm b/Src/MacOSX/COSXDasherControl.mm
index 6f9a227..72450da 100644
--- a/Src/MacOSX/COSXDasherControl.mm
+++ b/Src/MacOSX/COSXDasherControl.mm
@@ -191,12 +191,6 @@ void COSXDasherControl::ExternalEventHandler(Dasher::CEvent *pEvent) {
       SetContext(StdStringFromNSString([dasherEdit textAtOffset:ecvt->m_iOffset Length:ecvt->m_iLength]));
       break;
     }
-    case EV_START:
-      NSLog(@"ExternalEventHandler, m_iEventType = EV_START");
-      break;
-    case EV_STOP:
-      NSLog(@"ExternalEventHandler, m_iEventType = EV_STOP");
-      break;
     case EV_CONTROL:
       NSLog(@"ExternalEventHandler, m_iEventType = EV_CONTROL");
       break;
diff --git a/Src/MacOSX/DasherApp.mm b/Src/MacOSX/DasherApp.mm
index 55e1ae5..66a3273 100644
--- a/Src/MacOSX/DasherApp.mm
+++ b/Src/MacOSX/DasherApp.mm
@@ -36,7 +36,7 @@
 }
 
 - (void)pause {
-  aquaDasherControl->Pause();
+  aquaDasherControl->Stop();
 }
 
 - (void)unpause:(unsigned long int)time {
diff --git a/Src/MacOSX/DasherEdit.mm b/Src/MacOSX/DasherEdit.mm
index a4742d7..64cbc8c 100644
--- a/Src/MacOSX/DasherEdit.mm
+++ b/Src/MacOSX/DasherEdit.mm
@@ -10,7 +10,7 @@
 #import "PreferencesController.h"
 #import "UnicharGenerator.h"
 #import "Chatter.h"
-
+#import "../Common/Common.h"
 #import <Carbon/Carbon.h>
 
 @implementation DasherEdit
@@ -58,6 +58,7 @@
 }
 
 -(NSString *)textAtOffset:(int)iOffset Length:(int)iLength {
+  DASHER_ASSERT(iOffset+iLength <= [allTextEntered length]);
   return [allTextEntered substringWithRange:NSMakeRange(iOffset,iLength)];
 }
 
diff --git a/Src/Qt/QtDasherScreen.cc b/Src/Qt/QtDasherScreen.cc
index cf95794..d77912c 100644
--- a/Src/Qt/QtDasherScreen.cc
+++ b/Src/Qt/QtDasherScreen.cc
@@ -157,7 +157,7 @@ void QtDasherScreen::mousePressEvent(QMouseEvent *e) {
 }
 
 void QtDasherScreen::mouseReleaseEvent(QMouseEvent *e) {
-  interface->Pause();
+  interface->Stop();
   paused = true;
 }
 
diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp
index 8a80f23..dcd4ce8 100644
--- a/Src/Win32/Dasher.cpp
+++ b/Src/Win32/Dasher.cpp
@@ -59,6 +59,13 @@ void CDasher::CreateModules() {
   RegisterModule(new CDasherMouseInput(m_pEventHandler, m_pSettingsStore, m_pCanvas->getwindow()));
 }
 
+void CDasher::Stop() {
+  if (!GetBoolParameter(BP_DASHER_PAUSED)) {
+    CDasherInterfaceBase::Stop();
+    if (m_pEdit) m_pEdit->HandleStop();
+  }
+}
+
 void CDasher::Main() {
   if(m_pCanvas) {
 		m_pCanvas->DoFrame();
diff --git a/Src/Win32/Dasher.h b/Src/Win32/Dasher.h
index d8100a9..4d15c09 100644
--- a/Src/Win32/Dasher.h
+++ b/Src/Win32/Dasher.h
@@ -46,7 +46,8 @@ public:
   void GameMessageOut(int message, const void* messagedata);
   
   virtual void WriteTrainFile(const std::string &strNewText);
-
+  ///Override to implement copy/speak-on-stop
+  void Stop();
   void Main(); 
 
 
@@ -71,4 +72,4 @@ private:
  
   HWND m_hParent;
 };
-}
\ No newline at end of file
+}
diff --git a/Src/Win32/Widgets/AdvancedPage.cpp b/Src/Win32/Widgets/AdvancedPage.cpp
index 74d0447..5ae21b6 100644
--- a/Src/Win32/Widgets/AdvancedPage.cpp
+++ b/Src/Win32/Widgets/AdvancedPage.cpp
@@ -158,4 +158,4 @@ LRESULT CAdvancedPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM
   }
 
   return CPrefsPageBase::WndProc(Window, message, wParam, lParam);
-}
\ No newline at end of file
+}
diff --git a/Src/Win32/Widgets/Edit.cpp b/Src/Win32/Widgets/Edit.cpp
index 3cc332d..db0ca3f 100644
--- a/Src/Win32/Widgets/Edit.cpp
+++ b/Src/Win32/Widgets/Edit.cpp
@@ -971,9 +971,6 @@ void CEdit::HandleEvent(Dasher::CEvent *pEvent) {
   case EV_EDIT:
     HandleEditEvent(pEvent);
     break;
-  case EV_STOP:
-    HandleStop();
-    break;
   case EV_EDIT_CONTEXT:
     // TODO: Make this return the context properly. cf Linux 
     //m_pDasherInterface->SetContext("");
diff --git a/Src/iPhone/Classes/CDasherInterfaceBridge.mm b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
index 65b1ee4..c7f8c55 100644
--- a/Src/iPhone/Classes/CDasherInterfaceBridge.mm
+++ b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
@@ -199,12 +199,6 @@ void CDasherInterfaceBridge::ExternalEventHandler(Dasher::CEvent *pEvent) {
       SetContext(StdStringFromNSString([dasherApp textAtOffset:ecvt->m_iOffset Length:ecvt->m_iLength]));
       break;
 	}
-    case EV_START:
-      NSLog(@"ExternalEventHandler, m_iEventType = EV_START");
-      break;
-    case EV_STOP:
-      NSLog(@"ExternalEventHandler, m_iEventType = EV_STOP");
-      break;
     case EV_CONTROL:
       NSLog(@"ExternalEventHandler, m_iEventType = EV_CONTROL");
       break;
diff --git a/Src/iPhone/Classes/DasherAppDelegate.mm b/Src/iPhone/Classes/DasherAppDelegate.mm
index 04c7e66..1e0fe2f 100644
--- a/Src/iPhone/Classes/DasherAppDelegate.mm
+++ b/Src/iPhone/Classes/DasherAppDelegate.mm
@@ -280,7 +280,7 @@
 	
 - (void)settings {
   //avoid awful muddle if we change out of tap-to-start mode whilst running.... 
-  _dasherInterface->Pause();
+  _dasherInterface->Stop();
   [glView stopAnimation];
 	
   UITabBarController *tabs = [[[UITabBarController alloc] init] autorelease];
diff --git a/Src/iPhone/Classes/IPhoneFilters.cpp b/Src/iPhone/Classes/IPhoneFilters.cpp
index 7205586..e829e60 100644
--- a/Src/iPhone/Classes/IPhoneFilters.cpp
+++ b/Src/iPhone/Classes/IPhoneFilters.cpp
@@ -77,5 +77,5 @@ void CIPhonePolarFilter::KeyDown(int iTime, int iId, CDasherView *pView, CDasher
 
 void CIPhonePolarFilter::KeyUp(int iTime, int iId, CDasherView *pView, CDasherModel *pModel) {
 	if(iId == 100)
-		m_pInterface->Pause();
+		m_pInterface->Stop();
 }
\ No newline at end of file
diff --git a/Src/iPhone/Classes/PlainDragFilter.cpp b/Src/iPhone/Classes/PlainDragFilter.cpp
index dd7331c..085945f 100644
--- a/Src/iPhone/Classes/PlainDragFilter.cpp
+++ b/Src/iPhone/Classes/PlainDragFilter.cpp
@@ -33,6 +33,6 @@ void CPlainDragFilter::KeyUp(int iTime, int iId, CDasherView *pDasherView, CDash
 	if(iId == 100)
 	{
     DASHER_ASSERT(!GetBoolParameter(BP_DASHER_PAUSED));
-    m_pInterface->Pause();
+    m_pInterface->Stop();
   }
 }
\ No newline at end of file



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