[dasher: 13/43] Remove CLockEvent, replace with virtual CDashInterfaceBase::SetLockStatus
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 13/43] Remove CLockEvent, replace with virtual CDashInterfaceBase::SetLockStatus
- Date: Thu, 23 Jun 2011 18:56:51 +0000 (UTC)
commit 844737e93b970cc6d8b149caf20f8fc55a5439e2
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Wed Mar 30 15:23:03 2011 +0100
Remove CLockEvent, replace with virtual CDashInterfaceBase::SetLockStatus
Subclasses override: Gtk2 (emits signal => dialog), iPhone (lock-screen caption)
Win32 TODO: couldn't find any code handling old CLockEvent?
Also rm BP_TRAINING, replace with isLocked(); and reorganise NewFrame to render
any lock message in place of DasherView. But both of these are only applicable
if we've got multithreading, and we have no thread synchronization/safety
(or efficiency, e.g. DasherGameMode's busy-wait!)...
Add LP_MESSAGE_FONTSIZE = font size in points of lock message
Src/DasherCore/DasherGameMode.cpp | 10 ++-
Src/DasherCore/DasherInterfaceBase.cpp | 141 +++++++++++++++-----------
Src/DasherCore/DasherInterfaceBase.h | 25 +++++-
Src/DasherCore/Event.h | 18 +---
Src/DasherCore/NodeCreationManager.cpp | 9 +-
Src/DasherCore/Parameters.h | 6 +-
Src/Gtk2/DasherControl.cpp | 21 ++--
Src/Gtk2/DasherControl.h | 4 +-
Src/MacOSX/COSXDasherControl.mm | 4 -
Src/iPhone/Classes/CDasherInterfaceBridge.h | 1 +
Src/iPhone/Classes/CDasherInterfaceBridge.mm | 30 ++----
11 files changed, 150 insertions(+), 119 deletions(-)
---
diff --git a/Src/DasherCore/DasherGameMode.cpp b/Src/DasherCore/DasherGameMode.cpp
index c6ccb95..66de33c 100644
--- a/Src/DasherCore/DasherGameMode.cpp
+++ b/Src/DasherCore/DasherGameMode.cpp
@@ -313,7 +313,10 @@ void CDasherGameMode::FullDemoNext()
m_pDasherInterface->GetPermittedValues(SP_ALPHABET_ID, vAlphabets);
do{
- while(GetBoolParameter(BP_TRAINING)) {}
+ //TODO I think SetStringParam(SP_ALPHABET_ID) blocks until done;
+ // if not, a busy-wait is hardly going to help training finish
+ // any faster, and I'm not sure this is threadsafe either!
+ while(m_pDasherInterface->isLocked()) {}
int randomAlph = rand() % vAlphabets.size();
std::cout << "Setting: " << vAlphabets[randomAlph] << std::endl;
SetStringParameter(SP_ALPHABET_ID, vAlphabets[randomAlph]);
@@ -327,7 +330,10 @@ void CDasherGameMode::FullDemoNext()
NextString(true);
}
- while(GetBoolParameter(BP_TRAINING)) {}
+ //TODO I think SetStringParam(SP_ALPHABET_ID) blocks until done;
+ // if not, a busy-wait is hardly going to help training finish
+ // any faster, and I'm not sure this is threadsafe either!
+ while(m_pDasherInterface->isLocked()) {}
m_bSentenceFinished = false;
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 517f7c7..9bee70e 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -56,6 +56,7 @@
#include <cstdio>
#include <iostream>
#include <memory>
+#include <sstream>
// Declare our global file logging object
#include "../DasherCore/FileLogger.h"
@@ -84,7 +85,7 @@ static char THIS_FILE[] = __FILE__;
#endif
#endif
-CDasherInterfaceBase::CDasherInterfaceBase() {
+CDasherInterfaceBase::CDasherInterfaceBase() : m_pLockLabel(NULL) {
// Ensure that pointers to 'owned' objects are set to NULL.
m_pDasherModel = NULL;
@@ -360,6 +361,24 @@ void CDasherInterfaceBase::InterfaceEventHandler(Dasher::CEvent *pEvent) {
}
}
+void CDasherInterfaceBase::SetLockStatus(const string &strText, int iPercent) {
+ string newMessage; //empty - what we want if iPercent==-1 (unlock)
+ if (iPercent!=-1) {
+ ostringstream os;
+ os << (strText.empty() ? "Training Dasher" : strText);
+ if (iPercent) os << " " << iPercent << "%";
+ newMessage = os.str();
+ }
+ if (newMessage != m_strLockMessage) {
+ ScheduleRedraw();
+ if (m_pLockLabel) {
+ delete m_pLockLabel;
+ m_pLockLabel = NULL;
+ }
+ m_strLockMessage = newMessage;
+ }
+}
+
void CDasherInterfaceBase::WriteTrainFileFull() {
m_pNCManager->GetAlphabetManager()->WriteTrainFileFull(this);
}
@@ -492,59 +511,71 @@ void CDasherInterfaceBase::NewFrame(unsigned long iTime, bool bForceRedraw) {
bool bChanged(false), bWasPaused(GetBoolParameter(BP_DASHER_PAUSED));
CExpansionPolicy *pol=m_defaultPolicy;
if(m_pDasherView != 0) {
- if(!GetBoolParameter(BP_TRAINING)) {
+ if (isLocked()) {
+ //Hmmm. If we're locked, NewFrame is never actually called - the thread
+ // that would be rendering frames, is the same one doing the training.
+ // So the following is never actually executed atm, but may be a simple
+ // template if/when we ever implement multithreading widely/properly...
+ m_DasherScreen->SendMarker(0); //this replaces the nodes...
+ const screenint iSW = m_DasherScreen->GetWidth(), iSH = m_DasherScreen->GetHeight();
+ m_DasherScreen->DrawRectangle(0,0,iSW,iSH,0,0,0); //fill in colour 0 = white
+ unsigned int iSize(GetLongParameter(LP_MESSAGE_FONTSIZE));
+ if (!m_pLockLabel) m_pLockLabel = m_DasherScreen->MakeLabel(m_strLockMessage, iSize);
+ pair<screenint,screenint> dims = m_DasherScreen->TextSize(m_pLockLabel, iSize);
+ m_DasherScreen->DrawString(m_pLockLabel, (iSW-dims.first)/2, (iSH-dims.second)/2, iSize, 4);
+ m_DasherScreen->SendMarker(1); //decorations - don't draw any
+ m_DasherScreen->Display();
+ } else {
if (m_pUserLog != NULL) {
- //ACL note that as of 15/5/09, splitting UpdatePosition into two,
- //DasherModel no longer guarantees to empty these two if it didn't do anything.
- //So initialise appropriately...
- Dasher::VECTOR_SYMBOL_PROB vAdded;
- int iNumDeleted = 0;
-
- if(m_pInputFilter) {
- bChanged = m_pInputFilter->Timer(iTime, m_pDasherView, m_pInput, m_pDasherModel, &vAdded, &iNumDeleted, &pol);
- }
+ //ACL note that as of 15/5/09, splitting UpdatePosition into two,
+ //DasherModel no longer guarantees to empty these two if it didn't do anything.
+ //So initialise appropriately...
+ Dasher::VECTOR_SYMBOL_PROB vAdded;
+ int iNumDeleted = 0;
+
+ if(m_pInputFilter) {
+ bChanged = m_pInputFilter->Timer(iTime, m_pDasherView, m_pInput, m_pDasherModel, &vAdded, &iNumDeleted, &pol);
+ }
-#ifndef _WIN32_WCE
- if (iNumDeleted > 0)
- m_pUserLog->DeleteSymbols(iNumDeleted);
- if (vAdded.size() > 0)
- m_pUserLog->AddSymbols(&vAdded);
-#endif
+ #ifndef _WIN32_WCE
+ if (iNumDeleted > 0)
+ m_pUserLog->DeleteSymbols(iNumDeleted);
+ if (vAdded.size() > 0)
+ m_pUserLog->AddSymbols(&vAdded);
+ #endif
+ } else {
+ if(m_pInputFilter) {
+ bChanged = m_pInputFilter->Timer(iTime, m_pDasherView, m_pInput, m_pDasherModel, 0, 0, &pol);
+ }
}
- else {
- if(m_pInputFilter) {
- bChanged = m_pInputFilter->Timer(iTime, m_pDasherView, m_pInput, m_pDasherModel, 0, 0, &pol);
- }
- }
+ //check: if we were paused before, and the input filter didn't unpause,
+ // then nothing can have changed:
+ DASHER_ASSERT(!bWasPaused || !GetBoolParameter(BP_DASHER_PAUSED) || !bChanged);
+
+ // Flags at this stage:
+ //
+ // - bChanged = the display was updated, so needs to be rendered to the display
+ // - m_bLastChanged = bChanged was true last time around
+ // - m_bRedrawScheduled = Display invalidated internally
+ // - bForceRedraw = Display invalidated externally
+
+ // TODO: Would be good to sort out / check through the redraw logic properly
+
+ bForceRedraw |= m_bLastChanged || bChanged || m_bRedrawScheduled;
+ m_bLastChanged = bChanged; //will also be set in Redraw if any nodes were expanded.
+
+ Redraw(bForceRedraw, *pol);
+
+ m_bRedrawScheduled = false;
+
+ // This just passes the time through to the framerate tracker, so we
+ // know how often new frames are being drawn.
+ if(m_pDasherModel != 0)
+ m_pDasherModel->RecordFrame(iTime);
}
}
- //check: if we were paused before, and the input filter didn't unpause,
- // then nothing can have changed:
- DASHER_ASSERT(!bWasPaused || !GetBoolParameter(BP_DASHER_PAUSED) || !bChanged);
-
- // Flags at this stage:
- //
- // - bChanged = the display was updated, so needs to be rendered to the display
- // - m_bLastChanged = bChanged was true last time around
- // - m_bRedrawScheduled = Display invalidated internally
- // - bForceRedraw = Display invalidated externally
-
- // TODO: Would be good to sort out / check through the redraw logic properly
-
- bForceRedraw |= m_bLastChanged;
- m_bLastChanged = bChanged; //will also be set in Redraw if any nodes were expanded.
-
- Redraw(bChanged || m_bRedrawScheduled || bForceRedraw, *pol);
-
- m_bRedrawScheduled = false;
-
- // This just passes the time through to the framerate tracker, so we
- // know how often new frames are being drawn.
- if(m_pDasherModel != 0)
- m_pDasherModel->RecordFrame(iTime);
-
bReentered=false;
}
@@ -598,14 +629,10 @@ void CDasherInterfaceBase::ChangeAlphabet() {
// Lock Dasher to prevent changes from happening while we're training.
- SetBoolParameter( BP_TRAINING, true );
-
CreateNCManager();
// Apply options from alphabet
- SetBoolParameter( BP_TRAINING, false );
-
//}
}
@@ -749,27 +776,27 @@ CUserLogBase* CDasherInterfaceBase::GetUserLogPtr() {
}
void CDasherInterfaceBase::KeyDown(int iTime, int iId, bool bPos, int iX, int iY) {
- if(m_iCurrentState != ST_NORMAL)
+ if(m_iCurrentState != ST_NORMAL || isLocked())
return;
- if(m_pInputFilter && !GetBoolParameter(BP_TRAINING)) {
+ if(m_pInputFilter) {
m_pInputFilter->KeyDown(iTime, iId, m_pDasherView, m_pInput, m_pDasherModel, m_pUserLog, bPos, iX, iY);
}
- if(m_pInput && !GetBoolParameter(BP_TRAINING)) {
+ if(m_pInput) {
m_pInput->KeyDown(iTime, iId);
}
}
void CDasherInterfaceBase::KeyUp(int iTime, int iId, bool bPos, int iX, int iY) {
- if(m_iCurrentState != ST_NORMAL)
+ if(m_iCurrentState != ST_NORMAL || isLocked())
return;
- if(m_pInputFilter && !GetBoolParameter(BP_TRAINING)) {
+ if(m_pInputFilter) {
m_pInputFilter->KeyUp(iTime, iId, m_pDasherView, m_pInput, m_pDasherModel, bPos, iX, iY);
}
- if(m_pInput && !GetBoolParameter(BP_TRAINING)) {
+ if(m_pInput) {
m_pInput->KeyUp(iTime, iId);
}
}
diff --git a/Src/DasherCore/DasherInterfaceBase.h b/Src/DasherCore/DasherInterfaceBase.h
index a2485ba..5e7df51 100644
--- a/Src/DasherCore/DasherInterfaceBase.h
+++ b/Src/DasherCore/DasherInterfaceBase.h
@@ -201,6 +201,24 @@ public:
void PreSetNotify(int iParameter, const std::string &sValue);
+ ///Locks/unlocks Dasher. The default here stores the lock message and percentage
+ /// in m_strLockMessage, such that NewFrame renders this instead of the canvas
+ /// if we are locked. Subclasses may override to implement better (GUI)
+ /// notifications/dialogues, but should call through to this method to ensure
+ /// isLocked() returns the correct value.
+ /// Note that we do not support multiple/concurrent locks; each call to SetLockStatus
+ /// overrides any/all previous ones.
+ /// \param strText text of message to display, excluding %age, _if_ locked;
+ /// ignored, if unlocked.
+ /// \param iPercent -1 unlocks Dasher; anything else locks it, and indicates
+ /// %progress.
+ virtual void SetLockStatus(const std::string &strText, int iPercent);
+
+ /// Tells us whether Dasher is locked (i.e. for training).
+ /// TODO This just replaces the old BP_TRAINING; however, I'd think that _if_ we
+ /// do actually need a global function to tell whether Dasher's locked, it probably
+ /// needs to be threadsafe, which neither this nor BP_TRAINING is (I don't think!)...
+ inline bool isLocked() {return !m_strLockMessage.empty();}
///Does this subclass support speech (i.e. the speak(string) method?)
/// Default is just to return false.
@@ -625,10 +643,15 @@ protected:
///builds up the word currently being entered for speech.
std::string m_strCurrentWord;
+ ///If non-empty, Dasher is locked, and this is the message that should be displayed.
+ std::string m_strLockMessage;
+ /// (Cache) renderable version of previous; created only to render
+ /// (so may still be NULL even if locked)
+ CDasherScreen::Label *m_pLockLabel;
+
/// @name State variables
/// Represent the current overall state of the core
/// @{
- // bool m_bGlobalLock; // The big lock
bool m_bRedrawScheduled;
EState m_iCurrentState;
bool m_bOldVisible;
diff --git a/Src/DasherCore/Event.h b/Src/DasherCore/Event.h
index d15758e..fabcac1 100644
--- a/Src/DasherCore/Event.h
+++ b/Src/DasherCore/Event.h
@@ -10,13 +10,12 @@ namespace Dasher {
class CEvent;
class CParameterNotificationEvent;
class CEditEvent;
- class CLockEvent;
class CMessageEvent;
class CScreenGeomEvent;
}
enum {
- EV_PARAM_NOTIFY = 1, EV_EDIT, EV_LOCK, EV_MESSAGE, EV_SCREEN_GEOM
+ EV_PARAM_NOTIFY = 1, EV_EDIT, EV_MESSAGE, EV_SCREEN_GEOM
};
/// \ingroup Core
@@ -50,21 +49,6 @@ public:
const int m_iOffset;
};
-class Dasher::CLockEvent : public Dasher::CEvent {
-public:
- CLockEvent(const std::string &strMessage, bool bLock, int iPercent) : CEvent(EV_LOCK) {
- m_strMessage = strMessage;
- m_bLock = bLock;
- m_iPercent = iPercent;
- };
-
- ///Unlike other events, fields are mutable: CLockEvents may be
- /// reused at the start, end, and during, the task requiring locking.
- std::string m_strMessage;
- bool m_bLock;
- int m_iPercent;
-};
-
class Dasher::CMessageEvent : public Dasher::CEvent {
public:
CMessageEvent(const std::string &strMessage, int iID, int iType)
diff --git a/Src/DasherCore/NodeCreationManager.cpp b/Src/DasherCore/NodeCreationManager.cpp
index 9efeb9f..47e20bd 100644
--- a/Src/DasherCore/NodeCreationManager.cpp
+++ b/Src/DasherCore/NodeCreationManager.cpp
@@ -57,15 +57,12 @@ CNodeCreationManager::CNodeCreationManager(Dasher::CDasherInterfaceBase *pInterf
if (!pAlphInfo->GetTrainingFile().empty()) {
//1. Look for system training text...
- CLockEvent oEvent("Training on System Text", true, 0);
- pEventHandler->InsertEvent(&oEvent);
+ pInterface->SetLockStatus("Training on System Text", 0);
m_pTrainer->LoadFile(GetStringParameter(SP_SYSTEM_LOC) + pAlphInfo->GetTrainingFile());
//Now add in any user-provided individual training text...
- oEvent.m_strMessage = "Training on User Text"; oEvent.m_bLock=true; oEvent.m_iPercent = 0;
- pEventHandler->InsertEvent(&oEvent);
+ pInterface->SetLockStatus("Training on User Text", 0);
m_pTrainer->LoadFile(GetStringParameter(SP_USER_LOC) + pAlphInfo->GetTrainingFile());
- oEvent.m_bLock = false;
- pEventHandler->InsertEvent(&oEvent);
+ pInterface->SetLockStatus("",-1);
}
#ifdef DEBUG
else {
diff --git a/Src/DasherCore/Parameters.h b/Src/DasherCore/Parameters.h
index 303636d..39609af 100644
--- a/Src/DasherCore/Parameters.h
+++ b/Src/DasherCore/Parameters.h
@@ -36,7 +36,7 @@ enum {
BP_COLOUR_MODE, BP_MOUSEPOS_MODE,
BP_PALETTE_CHANGE,
BP_AUTOCALIBRATE, BP_REMAP_XTREME, BP_DASHER_PAUSED,
- BP_GAME_MODE, BP_TRAINING, BP_REDRAW, BP_LM_DICTIONARY,
+ BP_GAME_MODE, BP_REDRAW, BP_LM_DICTIONARY,
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,
@@ -52,7 +52,7 @@ enum {
enum {
LP_ORIENTATION = END_OF_BPS, LP_REAL_ORIENTATION, LP_MAX_BITRATE, LP_FRAMERATE,
- LP_VIEW_ID, LP_LANGUAGE_MODEL_ID, LP_DASHER_FONTSIZE, LP_SHAPE_TYPE,
+ LP_VIEW_ID, LP_LANGUAGE_MODEL_ID, LP_DASHER_FONTSIZE, LP_MESSAGE_FONTSIZE, LP_SHAPE_TYPE,
LP_UNIFORM, LP_YSCALE, LP_MOUSEPOSDIST, LP_STOP_IDLETIME,
LP_LM_MAX_ORDER, LP_LM_EXCLUSION,
LP_LM_UPDATE_EXCLUSION, LP_LM_ALPHA, LP_LM_BETA,
@@ -143,7 +143,6 @@ static bp_table boolparamtable[] = {
{BP_REMAP_XTREME, "RemapXtreme", PERS, false, "Pointer at extreme Y translates more and zooms less"},
{BP_DASHER_PAUSED, "DasherPaused", !PERS, true, "Dasher Paused"},
{BP_GAME_MODE, "GameMode", !PERS, false, "Dasher Game Mode"},
- {BP_TRAINING, "Training", !PERS, false, "Provides locking during training"},
{BP_REDRAW, "Redraw", !PERS, false, "Force a full redraw at the next timer event"},
{BP_LM_DICTIONARY, "Dictionary", PERS, true, "Whether the word-based language model uses a dictionary"},
{BP_LM_LETTER_EXCLUSION, "LetterExclusion", PERS, true, "Whether to do letter exclusion in the word-based model"},
@@ -194,6 +193,7 @@ static lp_table longparamtable[] = {
{LP_VIEW_ID, "ViewID", PERS, 1, "ViewID"},
{LP_LANGUAGE_MODEL_ID, "LanguageModelID", PERS, 0, "LanguageModelID"},
{LP_DASHER_FONTSIZE, "DasherFontSize", PERS, 2, "DasherFontSize"},
+ {LP_MESSAGE_FONTSIZE, "MessageFontSize", PERS, 14, "Size of font for messages (in points)"},
{LP_SHAPE_TYPE, "RenderStyle", PERS, 1, "Shapes to render in (0/1=disjoint/overlapping rects, 2/3=triangles/truncated, 4=quadrics, 5=circles)"},
{LP_UNIFORM, "UniformTimes1000", PERS, 50, "UniformTimes1000"},
{LP_YSCALE, "YScaling", PERS, 0, "YScaling"},
diff --git a/Src/Gtk2/DasherControl.cpp b/Src/Gtk2/DasherControl.cpp
index 3a51857..58c3895 100644
--- a/Src/Gtk2/DasherControl.cpp
+++ b/Src/Gtk2/DasherControl.cpp
@@ -359,15 +359,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_LOCK) {
- CLockEvent *pLockEvent(static_cast<CLockEvent *>(pEvent));
- DasherLockInfo sInfo;
- sInfo.szMessage = pLockEvent->m_strMessage.c_str();
- sInfo.bLock = pLockEvent->m_bLock;
- sInfo.iPercent = pLockEvent->m_iPercent;
-
- g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_lock_info", &sInfo);
- }
else if(pEvent->m_iEventType == EV_MESSAGE) {
CMessageEvent *pMessageEvent(static_cast<CMessageEvent *>(pEvent));
DasherMessageInfo sInfo;
@@ -379,6 +370,18 @@ void CDasherControl::ExternalEventHandler(Dasher::CEvent *pEvent) {
}
};
+void CDasherControl::SetLockStatus(const string &strText, int iPercent) {
+ DasherLockInfo sInfo;
+ sInfo.szMessage = strText.c_str();
+ sInfo.bLock = (iPercent!=-1);
+ sInfo.iPercent = iPercent;
+
+ g_signal_emit_by_name(GTK_WIDGET(m_pDasherControl), "dasher_lock_info", &sInfo);
+ //No frames seem to be rendered, so this is probably unnecessary.
+ // But call through to superclass anyway:
+ CDasherInterfaceBase::SetLockStatus(strText,iPercent);
+}
+
unsigned int CDasherControl::ctrlMove(bool bForwards, CControlManager::EditDistance dist) {
return gtk_dasher_control_ctrl_move(m_pDasherControl,bForwards,dist);
}
diff --git a/Src/Gtk2/DasherControl.h b/Src/Gtk2/DasherControl.h
index 85a2a34..3524d60 100644
--- a/Src/Gtk2/DasherControl.h
+++ b/Src/Gtk2/DasherControl.h
@@ -156,6 +156,9 @@ public:
///
virtual void ExternalEventHandler(Dasher::CEvent *pEvent);
+ ///Override to emit Gtk2 signal
+ virtual void SetLockStatus(const string &strText, int iPercent);
+
private:
// virtual void CreateSettingsStore();
virtual void ScanAlphabetFiles(std::vector<std::string> &vFileList);
@@ -168,7 +171,6 @@ private:
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.mm b/Src/MacOSX/COSXDasherControl.mm
index 4a51408..01fc71e 100644
--- a/Src/MacOSX/COSXDasherControl.mm
+++ b/Src/MacOSX/COSXDasherControl.mm
@@ -182,10 +182,6 @@ void COSXDasherControl::ExternalEventHandler(Dasher::CEvent *pEvent) {
}
break;
}
- case EV_LOCK:
-// CLockEvent *lockEvent(static_cast < CLockEvent * >(pEvent));
-// NSLog(@"ExternalEventHandler, m_iEventType = EV_LOCK, mess: %@, bLock = %d, pct = %d", NSStringFromStdString(lockEvent->m_strMessage), lockEvent->m_bLock, lockEvent->m_iPercent);
- break;
case EV_MESSAGE: {
CMessageEvent *messageEvent(static_cast < CMessageEvent * >(pEvent));
NSLog(@"ExternalEventHandler, m_iEventType = EV_MESSAGE, mess: %@, id = %d, type = %d", NSStringFromStdString(messageEvent->m_strMessage), messageEvent->m_iID, messageEvent->m_iType);
diff --git a/Src/iPhone/Classes/CDasherInterfaceBridge.h b/Src/iPhone/Classes/CDasherInterfaceBridge.h
index a274464..1cc52d2 100644
--- a/Src/iPhone/Classes/CDasherInterfaceBridge.h
+++ b/Src/iPhone/Classes/CDasherInterfaceBridge.h
@@ -53,6 +53,7 @@ public:
std::string GetContext(unsigned int iStart, unsigned int iLength);
unsigned int ctrlMove(bool bForwards, CControlManager::EditDistance dist);
unsigned int ctrlDelete(bool bForwards, CControlManager::EditDistance dist);
+ void SetLockStatus(const string &strText, int iPercent);
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 f197cfb..9537645 100644
--- a/Src/iPhone/Classes/CDasherInterfaceBridge.mm
+++ b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
@@ -182,18 +182,6 @@ void CDasherInterfaceBridge::ExternalEventHandler(Dasher::CEvent *pEvent) {
}
}
break;
- case EV_LOCK:
- {
- CLockEvent *evt(static_cast<CLockEvent *>(pEvent));
- NSString *dispMsg = nil;
- if (evt->m_bLock) {
- dispMsg = NSStringFromStdString(evt->m_strMessage);
- if (evt->m_iPercent) dispMsg = [NSString stringWithFormat:@"%@ (%i%%)",
- dispMsg,evt->m_iPercent];
- }
- [dasherApp setLockText:dispMsg];
- break;
- }
case EV_MESSAGE:
{
CMessageEvent *messageEvent(static_cast < CMessageEvent * >(pEvent));
@@ -207,6 +195,17 @@ void CDasherInterfaceBridge::ExternalEventHandler(Dasher::CEvent *pEvent) {
}
+void CDasherInterfaceBridge::SetLockStatus(const string &strText, int iPercent) {
+ NSString *dispMsg = nil;
+ if (iPercent != -1) {
+ dispMsg = NSStringFromStdString(strText);
+ if (iPercent) dispMsg = [NSString stringWithFormat:@"%@ (%i%%)", dispMsg, iPercent];
+ }
+ [dasherApp setLockText:dispMsg];
+ //Call superclass too. Probably unnecessary, as no frames'll be rendered..!
+ CDasherInterfaceBase::SetLockStatus(strText, iPercent);
+}
+
void CDasherInterfaceBridge::CopyToClipboard(const std::string &strText) {
[dasherApp copy:NSStringFromStdString(strText)];
}
@@ -248,13 +247,6 @@ int CDasherInterfaceBridge::GetFileSize(const std::string &strFileName) {
return 0;
}
-/*void CDasherInterfaceBridge::Train(NSString *fileName) {
- std::string f = StdStringFromNSString(fileName);
- NSLog(@"Read train file: %s", f.c_str());
- NSLog(@"method disappeared!! doing nuffink");
-// CDasherInterfaceBase::TrainFile(f, GetFileSize(f), 0);
-}*/
-
void CDasherInterfaceBridge::WriteTrainFile(const std::string &filename,const std::string &strNewText) {
if(strNewText.length() == 0)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]