summaryrefslogtreecommitdiff
authorwimpie <wimpie>2004-04-09 18:04:30 (UTC)
committer wimpie <wimpie>2004-04-09 18:04:30 (UTC)
commit028717962deec0c2ff0e382221cbc2242393b79e (patch) (side-by-side diff)
treea5f00a3b3d229f838b6e40e34ca12f248b317813
parentd17b9f7b64e004dcc301866f8122171218553b42 (diff)
downloadopie-028717962deec0c2ff0e382221cbc2242393b79e.zip
opie-028717962deec0c2ff0e382221cbc2242393b79e.tar.gz
opie-028717962deec0c2ff0e382221cbc2242393b79e.tar.bz2
Removed warnings about initialization sequence in constructores
and unused variables and arguments
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/dasher/AlphIO.cpp8
-rw-r--r--inputmethods/dasher/Alphabet.cpp4
-rw-r--r--inputmethods/dasher/AlphabetMap.cpp2
-rw-r--r--inputmethods/dasher/AlphabetMap.h2
-rw-r--r--inputmethods/dasher/DashEdit.h14
-rw-r--r--inputmethods/dasher/DasherInterface.cpp27
-rw-r--r--inputmethods/dasher/DasherInterface.h2
-rw-r--r--inputmethods/dasher/DasherModel.cpp8
-rw-r--r--inputmethods/dasher/DasherNode.cpp2
-rw-r--r--inputmethods/dasher/DasherNode.h20
-rw-r--r--inputmethods/dasher/DasherSettingsInterface.h48
-rw-r--r--inputmethods/dasher/DasherView.cpp4
-rw-r--r--inputmethods/dasher/DasherView.h2
-rw-r--r--inputmethods/dasher/PPMLanguageModel.cpp8
-rw-r--r--inputmethods/dasher/PPMLanguageModel.h7
-rw-r--r--inputmethods/dasher/QtDasherImpl.cc2
-rw-r--r--inputmethods/dasher/QtDasherPlugin.cc2
-rw-r--r--inputmethods/dasher/QtDasherPlugin.h2
-rw-r--r--inputmethods/dasher/QtDasherScreen.cc17
-rw-r--r--inputmethods/dasher/QtDasherScreen.h4
-rw-r--r--inputmethods/dasher/SettingsStore.cpp12
21 files changed, 118 insertions, 79 deletions
diff --git a/inputmethods/dasher/AlphIO.cpp b/inputmethods/dasher/AlphIO.cpp
index 41b1b23..96ca14a 100644
--- a/inputmethods/dasher/AlphIO.cpp
+++ b/inputmethods/dasher/AlphIO.cpp
@@ -1,73 +1,75 @@
// AlphIO.cpp
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Iain Murray
//
/////////////////////////////////////////////////////////////////////////////
#include "AlphIO.h"
using namespace Dasher;
using namespace std;
CAlphIO::CAlphIO(string SystemLocation, string UserLocation)
- : SystemLocation(SystemLocation), UserLocation(UserLocation),
- BlankInfo(), CData("")
+ : BlankInfo(),
+ SystemLocation(SystemLocation),
+ UserLocation(UserLocation),
+ CData("")
{
CreateDefault();
}
void CAlphIO::GetAlphabets(std::vector< std::string > * AlphabetList) const
{
AlphabetList->clear();
typedef std::map<std::string, AlphInfo>::const_iterator CI;
CI End = Alphabets.end();
for (CI Cur=Alphabets.begin(); Cur!=End; Cur++)
AlphabetList->push_back( (*Cur).second.AlphID);
}
const CAlphIO::AlphInfo& CAlphIO::GetInfo(const std::string& AlphID)
{
if (AlphID=="")
return Alphabets["Default"];
else {
- AlphInfo& CurInfo = Alphabets[AlphID];
+ // AlphInfo& CurInfo = Alphabets[AlphID];
Alphabets[AlphID].AlphID = AlphID; // Ensure consistency
return Alphabets[AlphID];
}
}
void CAlphIO::SetInfo(const AlphInfo& NewInfo)
{
Alphabets[NewInfo.AlphID] = NewInfo;
}
void CAlphIO::Delete(const std::string& AlphID)
{
if (Alphabets.find(AlphID)!=Alphabets.end()) {
Alphabets.erase(AlphID);
}
}
void CAlphIO::CreateDefault()
{
// TODO I appreciate these strings should probably be in a resource file.
// Not urgent though as this is not intended to be used. It's just a
// last ditch effort in case file I/O totally fails.
AlphInfo& Default = Alphabets["Default"];
Default.AlphID = "Default";
Default.Type = Opts::Western;
Default.Mutable = false;
Default.Orientation = Opts::LeftToRight;
Default.SpaceCharacter.Display = "_";
Default.SpaceCharacter.Text = " ";
diff --git a/inputmethods/dasher/Alphabet.cpp b/inputmethods/dasher/Alphabet.cpp
index dc58b35..6327d8a 100644
--- a/inputmethods/dasher/Alphabet.cpp
+++ b/inputmethods/dasher/Alphabet.cpp
@@ -1,66 +1,66 @@
// Alphabet.cpp
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2001-2002 David Ward
//
/////////////////////////////////////////////////////////////////////////////
#include "Alphabet.h"
#include "AlphabetMap.h"
//#include <iostream>
//WinCE doesn't have iostream!
using namespace Dasher;
using namespace std;
-CAlphabet::CAlphabet() : m_Groups(0), m_DefaultEncoding(Opts::Western), m_Orientation(Opts::LeftToRight)
+CAlphabet::CAlphabet() : m_DefaultEncoding(Opts::Western), m_Orientation(Opts::LeftToRight), m_Groups(0)
{
m_Characters.push_back("");
m_Display.push_back("");
m_Colours.push_back("");
m_Foreground.push_back("");
m_Group.push_back(0);
}
void CAlphabet::GetSymbols(vector<symbol>* Symbols, string* Input, bool IsMore)
{
string Tmp;
symbol CurSymbol=0, TmpSymbol=0;
bool KeyIsPrefix;
- int z= Input->size();
+ // int z= Input->size();
int extras;
unsigned int bit;
for (unsigned int i=0; i<Input->size(); i++) {
Tmp = (*Input)[i];
/* The string we've been given is in UTF-8. The symbols are
also in UTF-8, so we need to pass the entire UTF-8 character
which may be several bytes long. RFC 2279 describes this
encoding */
if ((*Input)[i] & 0x80) { // Character is more than 1 byte long
extras = 1;
for (bit = 0x20; ((*Input)[i] & bit) != 0; bit >>= 1)
extras++;
if (extras > 5) {
} // Malformed character
while (extras-->0) {
Tmp += (*Input)[++i];
}
}
CurSymbol = TextMap.Get(Tmp, &KeyIsPrefix);
if (KeyIsPrefix) {
CurSymbol = 0;
for (; i<Input->size(); i++) {
Tmp += (*Input)[i];
TmpSymbol = TextMap.Get(Tmp, &KeyIsPrefix);
diff --git a/inputmethods/dasher/AlphabetMap.cpp b/inputmethods/dasher/AlphabetMap.cpp
index 09e2c72..c687e45 100644
--- a/inputmethods/dasher/AlphabetMap.cpp
+++ b/inputmethods/dasher/AlphabetMap.cpp
@@ -1,47 +1,47 @@
// AlphabetMap.cpp
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Iain Murray
//
/////////////////////////////////////////////////////////////////////////////
#include "AlphabetMap.h"
using namespace Dasher;
using namespace std;
alphabet_map::alphabet_map(unsigned int InitialTableSize)
- : Undefined(0), HashTable(InitialTableSize<<1)
+ : HashTable(InitialTableSize<<1), Undefined(0)
{
Entries.reserve(InitialTableSize);
}
void alphabet_map::Add(const string& Key, symbol Value)
{
RecursiveAdd(Key, Value, false);
}
void alphabet_map::RecursiveAdd(const string& Key, symbol Value, bool PrefixFlag)
{
Entry*& HashEntry = HashTable[Hash(Key)];
// Loop through Entries with the correct Hash value.
for (Entry* i = HashEntry; i; i=i->Next) {
if (i->Key==Key) {
if (PrefixFlag) {
// Just tagging - don't change symbol. Recurse if necessary
i->KeyIsPrefix = true;
if (Key.size()>1)
RecursiveAdd(Key.substr(Key.size()-1), Undefined, true);
} else {
// Add symbol and leave
i->Symbol = Value;
}
return;
}
}
// When hash table gets 1/2 full...
diff --git a/inputmethods/dasher/AlphabetMap.h b/inputmethods/dasher/AlphabetMap.h
index 3aac1f5..62f20d9 100644
--- a/inputmethods/dasher/AlphabetMap.h
+++ b/inputmethods/dasher/AlphabetMap.h
@@ -39,65 +39,65 @@ Usage:
alphabet_map MyMap(NumberOfEntriesWeExpect); // Can omit NumberOfEntriesWeExpect
MyMap.add("asdf", 15);
symbol i = MyMap.get("asdf") // i=15
symbol j = MyMap.get("fdsa") // j=0
You can't remove items once they are added as Dasher has no need for that.
IAM 08/2002
*/
#ifndef __AlphabetMap_h__
#define __AlphabetMap_h__
#include "MSVC_Unannoy.h"
#include <vector>
#include <string>
#include "DasherTypes.h"
namespace Dasher {class alphabet_map;}
class Dasher::alphabet_map
{
public:
alphabet_map(uint InitialTableSize=255);
void Add(const std::string& Key, symbol Value);
symbol Get(const std::string& Key, bool* KeyIsPrefix=0) const;
private:
class Entry
{
public:
Entry(std::string Key, symbol Symbol, Entry* Next)
- : Key(Key), Symbol(Symbol), Next(Next), KeyIsPrefix(false) {}
+ : Key(Key), KeyIsPrefix(false), Symbol(Symbol), Next(Next) {}
std::string Key;
bool KeyIsPrefix;
symbol Symbol;
Entry* Next;
};
void RecursiveAdd(const std::string& Key, symbol Value, bool PrefixFlag);
// A standard hash -- could try and research something specific.
inline uint Hash(const std::string& Input) const {
uint Result = 0;
typedef std::string::const_iterator CI;
CI Cur = Input.begin();
CI end = Input.end();
while (Cur!=end) Result = (Result<<1)^*Cur++;
Result %= HashTable.size();
return Result;
/*
if (Input.size()==1) // Speedup for ASCII text
return Input[0];
for (int i=0; i<Input.size(); i++)
Result = (Result<<1)^Input[i];
return Result%HashTable.size();
*/
}
diff --git a/inputmethods/dasher/DashEdit.h b/inputmethods/dasher/DashEdit.h
index dc14d15..0baeec9 100644
--- a/inputmethods/dasher/DashEdit.h
+++ b/inputmethods/dasher/DashEdit.h
@@ -1,131 +1,131 @@
//! Class definition for an edit box
// DashEdit.h
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Iain Murray
//
/////////////////////////////////////////////////////////////////////////////
/*
An abstract DashEditbox class is described here.
An implementation will handle interaction between Dasher and an actual Edit control.
e.g. - output characters to the edit control
- tapping on the edit box updates the Dasher display
*/
#ifndef __DashEdit_h__
#define __DashEdit_h__
#include "DasherWidgetInterface.h"
namespace Dasher {class CDashEditbox;}
class Dasher::CDashEditbox
{
public:
- CDashEditbox() : m_iFlushed(0), m_DasherInterface(0), m_dirty(false) {}
+ CDashEditbox() : m_dirty(false),m_iFlushed(0), m_DasherInterface(0) {}
//! Provide the Editbox with a widget interface
virtual void SetInterface(CDasherWidgetInterface* DasherInterface) {m_DasherInterface = DasherInterface;}
//! Write some buffered output to a file
virtual void write_to_file()=0;
//! Set the number of flushed characters
//
//! Set the number of flushed characters to an arbitrary number.
//! Usually used to reset it to 0 after unflushing
void set_flushed(int i) {m_iFlushed=i;}
//! Provide context from the editbox for the core
//
//! Provide the context at the current position within the editbox to
//! the core. Set str to up to max characters before
//! the cursor position within the editbox.
virtual void get_new_context(std::string& str, int max)=0;
//! Delete flushed text from the editbox
- virtual inline void unflush()=0;
+ virtual void unflush()=0;
//! Enter a the character Symbol into the text box
virtual void output(symbol Symbol)=0;
//! Delete the previous symbol from the text box
virtual void deletetext()=0;
//! Enter a character into the text box and remember that it is flushed
//
//! Output the character and increment m_iFlushed. When unflush is
//! called, remove the previous m_iFlushed characters
virtual void flush(symbol Symbol)=0;
// File I/O (optional)
//! If Value is true, timestamp all new files (optional)
//
//! If switched on, all new files should be timestamped, either in the
//! filename or in file metadata
- virtual void TimeStampNewFiles(bool Value) {}
+ virtual void TimeStampNewFiles(bool ) {}
//! Return true if any text has been modified since the last save (optional)
bool IsDirty() {return m_dirty;}
//! Generate a new file (optional)
//
//! New file - provide a file save dialogue and return the filename in
//! filename, or provide a blank filename and present a file
//! save dialogue when Save() is called
- virtual void New(const std::string& filename) {}; // filename can be "", but you cannot call Save() without having set a filename.
+ virtual void New(const std::string& ) {}; // filename can be "", but you cannot call Save() without having set a filename.
//! Open a file (optional)
//
//! Provide a file open dialogue and set filename to the
//! filename. Return true if a file is chosen and opened successfully,
//! false otherwise
- virtual bool Open(const std::string& filename) {return false;};
+ virtual bool Open(const std::string& ) {return false;};
//! Open a file and append to it (optional)
//
//! Provide a file open dialogue and set filename to the
//! filename. The file will then have any new text appended to it.
//! Return true if a file is chosen and opened successfully, false
//! otherwise
- virtual bool OpenAppendMode(const std::string& filename) {return false;};
+ virtual bool OpenAppendMode(const std::string& ) {return false;};
//! Save a file as a provided filename (optional)
//
//! Provide a file save dialogue and set filename to the
//! filename. Return true if a file is chosen and saved successfully,
//! false otherwise
- virtual bool SaveAs(const std::string& filename) {return false;};
+ virtual bool SaveAs(const std::string& ) {return false;};
//! Save the current file (optional)
//
//! Save file to the current filename. If there is no current filename,
//! or if saving fails, return false
virtual bool Save() {return false;}; // returns false if there is no filename set, or if saving fails
// Clipboard (optional)
//! Cut selected text (optional)
//
//! Copy the selected text to the clipboard and remove it from the
//! editbox
virtual void Cut() {};
//! Copy selected text (optional)
//
//! Copy the selected text to the clipboard
virtual void Copy() {};
//! Copy all text (optional)
//
//! Copy all text in the editbox to the clipboard
virtual void CopyAll() {};
//! Paste text from clipboard (optional)
//
//! Paste text from the clipboard into the editbox at the current
//! position
virtual void Paste() {};
//! Select all text in the editbox (optional)
virtual void SelectAll() {};
diff --git a/inputmethods/dasher/DasherInterface.cpp b/inputmethods/dasher/DasherInterface.cpp
index bb5b85e..4699687 100644
--- a/inputmethods/dasher/DasherInterface.cpp
+++ b/inputmethods/dasher/DasherInterface.cpp
@@ -1,64 +1,81 @@
// DasherInterface.cpp
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Iain Murray
//
/////////////////////////////////////////////////////////////////////////////
#include "DasherInterface.h"
//#include "EnglishAlphabet.h"
#include "CustomAlphabet.h"
#include "DasherViewSquare.h"
#include "PPMLanguageModel.h"
#include <iostream>
namespace {
#include "stdio.h"
}
using namespace Dasher;
using namespace std;
const string CDasherInterface::EmptyString = "";
CDasherInterface::CDasherInterface()
- : m_DashEditbox(0), m_DasherScreen(0), m_LanguageModel(0), TrainContext(0), m_Alphabet(0),
- m_DasherModel(0), m_DasherView(0), AlphabetID(""), LanguageModelID(-1), ViewID(-1),
- m_MaxBitRate(-1), m_Orientation(Opts::LeftToRight), m_SettingsStore(0), m_SettingsUI(0),
- m_UserLocation("usr_"), m_SystemLocation("sys_"), m_AlphIO(0), m_TrainFile(""),
- m_DasherFont(""), m_EditFont(""), m_EditFontSize(0), m_DrawKeyboard(false)
+ : m_Alphabet(0),
+ m_LanguageModel(0),
+ m_DasherModel(0),
+ m_DashEditbox(0),
+ m_DasherScreen(0),
+ m_DasherView(0),
+ m_SettingsStore(0),
+ m_SettingsUI(0),
+ m_AlphIO(0),
+ TrainContext(0),
+ AlphabetID(""),
+ LanguageModelID(-1),
+ ViewID(-1),
+ m_MaxBitRate(-1),
+ m_DrawKeyboard(false),
+ m_Orientation(Opts::LeftToRight),
+ m_UserLocation("usr_"),
+ m_SystemLocation("sys_"),
+ m_TrainFile(""),
+ m_DasherFont(""),
+ m_EditFont(""),
+ m_EditFontSize(0)
{
}
CDasherInterface::~CDasherInterface()
{
if (m_LanguageModel)
m_LanguageModel->ReleaseNodeContext(TrainContext);
delete m_DasherModel; // The order of some of these deletions matters
delete m_LanguageModel; // eg DasherModel has a pointer to LanguageModel.
delete m_Alphabet; // DM baulks if LM is deleted before it is.
delete m_DasherView;
// Do NOT delete Edit box or Screen. This class did not create them.
}
void CDasherInterface::SetSettingsStore(CSettingsStore* SettingsStore)
{
delete m_SettingsStore;
m_SettingsStore = SettingsStore;
this->SettingsDefaults(m_SettingsStore);
}
void CDasherInterface::SetSettingsUI(CDasherSettingsInterface* SettingsUI)
{
delete m_SettingsUI;
m_SettingsUI = SettingsUI;
//this->SettingsDefaults(m_SettingsStore);
m_SettingsUI->SettingsDefaults(m_SettingsStore);
}
diff --git a/inputmethods/dasher/DasherInterface.h b/inputmethods/dasher/DasherInterface.h
index 6338801..7c4496f 100644
--- a/inputmethods/dasher/DasherInterface.h
+++ b/inputmethods/dasher/DasherInterface.h
@@ -9,65 +9,65 @@
#ifndef __DasherInterface_h__
#define __DasherInterface_h__
// TODO - there is a list of things to be configurable in my notes
// Check that everything that is not self-contained within the GUI is covered.
#include "MSVC_Unannoy.h"
#include "NoClones.h"
#include "DasherWidgetInterface.h"
#include "DasherAppInterface.h"
#include "DasherSettingsInterface.h"
#include "DasherScreen.h"
#include "Alphabet.h"
#include "AlphIO.h"
#include "LanguageModel.h"
#include "DasherModel.h"
#include "DashEdit.h"
#include "DasherView.h"
#include "MSVC_Unannoy.h"
#include <map>
namespace Dasher {class CDasherInterface;}
class Dasher::CDasherInterface : private NoClones,
public CDasherWidgetInterface, public CDasherAppInterface, public CDasherSettingsInterface
{
public:
CDasherInterface();
- ~CDasherInterface();
+ virtual ~CDasherInterface();
//! Tell the core which CSettingsStore should be used
void SetSettingsStore(CSettingsStore* SettingsStore);
//! Tell the core which CDasherSettingsInterface should be used
//
//! Provide a pointer to an instance of CDasherSettingsInterface in
//! order to allow for platform dependent configuration of certain
//! options
void SetSettingsUI(CDasherSettingsInterface* SettingsUI);
//! Set the path for user specific configuration and files
void SetUserLocation(std::string UserLocation);
//! Set the path for system-wide configuration and files
void SetSystemLocation(std::string SystemLocation);
// Widget Interface
// -----------------------------------------------------
void Start();
void TapOn(int MouseX, int MouseY, unsigned long Time); // Times in milliseconds
void PauseAt(int MouseX, int MouseY); // are required to make
void Unpause(unsigned long Time); // Dasher run at the
void Redraw(); // correct speed.
void ChangeScreen(); // The widgets need to tell the engine when they have been
void ChangeEdit(); // affected by external interaction
unsigned int GetNumberSymbols(); // These are needed so widgets know
const std::string& GetDisplayText(symbol Symbol); // how to render the alphabet. All
const std::string& GetEditText(symbol Symbol); // strings are encoded in UTF-8
diff --git a/inputmethods/dasher/DasherModel.cpp b/inputmethods/dasher/DasherModel.cpp
index 0450d66..f15fa49 100644
--- a/inputmethods/dasher/DasherModel.cpp
+++ b/inputmethods/dasher/DasherModel.cpp
@@ -1,52 +1,52 @@
// DasherModel.h
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2001-2002 David Ward
//
/////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include "DasherModel.h"
using namespace Dasher;
using namespace std;
//////////////////////////////////////////////////////////////////////
// CDasherModel
//////////////////////////////////////////////////////////////////////
CDasherModel::CDasherModel(CDashEditbox* Editbox, CLanguageModel* LanguageModel, bool Dimensions)
- : m_editbox(Editbox), m_languagemodel(LanguageModel), m_Root(0), m_Dimensions(Dimensions)
+ : m_Dimensions(Dimensions), m_editbox(Editbox), m_languagemodel(LanguageModel), m_Root(0)
{
LearnContext = m_languagemodel->GetRootNodeContext();
// various settings
int iShift = 12;
m_DasherY = 1<<iShift;
m_DasherOY = m_DasherY/2;
m_DasherOX = m_DasherY/2;
m_dAddProb = 0.003;
}
CDasherModel::~CDasherModel()
{
m_languagemodel->ReleaseNodeContext(LearnContext);
delete m_Root; // which will also delete all the whole structure
}
void CDasherModel::Make_root(int whichchild)
// find a new root node
{
symbol t=m_Root->Symbol();
if (t) {
m_editbox->output(t);
m_languagemodel->LearnNodeSymbol(LearnContext, t);
}
CDasherNode * oldroot=m_Root;
CDasherNode **children=m_Root->Children();
m_Root=children[whichchild];
@@ -76,65 +76,65 @@ void CDasherModel::Reparent_root(int lower, int upper)
m_Root=oldroots.back();
oldroots.pop_back();
}
/////////////////////////////////////////////////////////////////////////////
CDasherNode * CDasherModel::Get_node_under_crosshair()
{
return m_Root->Get_node_under(Normalization(),m_Rootmin,m_Rootmax,m_DasherOX,m_DasherOY);
}
/////////////////////////////////////////////////////////////////////////////
CDasherNode * CDasherModel::Get_node_under_mouse(myint Mousex,myint Mousey)
{
return m_Root->Get_node_under(Normalization(),m_Rootmin,m_Rootmax,Mousex,Mousey);
}
/////////////////////////////////////////////////////////////////////////////
void CDasherModel::Get_string_under_mouse(const myint Mousex,const myint Mousey, vector<symbol> &str)
{
m_Root->Get_string_under(Normalization(),m_Rootmin,m_Rootmax,Mousex,Mousey,str);
return;
}
/////////////////////////////////////////////////////////////////////////////
-void CDasherModel::Flush(const myint Mousex,const myint Mousey)
+void CDasherModel::Flush(const myint ,const myint )
{
vector<symbol> vtUnder;
Get_string_under_mouse(m_DasherOX,m_DasherOY,vtUnder);
unsigned int i;
for (i=0;i<vtUnder.size();i++) {
if (vtUnder[i]==0)
continue;
m_editbox->flush(vtUnder[i]);
}
}
/////////////////////////////////////////////////////////////////////////////
void CDasherModel::Update(CDasherNode *node,CDasherNode *under_mouse,int iSafe)
// go through the Dasher nodes, delete ones who have expired
// decrease the time left for nodes which arent safe
// safe nodes are those which are under the mouse or offspring of this node
{
// if (node->pushme )
// node->push_node();
if (node==under_mouse)
iSafe=1;
if (!iSafe)
node->Age();
// dchar debug[256];
// wsprintf(debug,TEXT("node->Age %d %f\n"),node->Age, fr.framerate());
// OutputDebugString(debug);
if (node->Age() > Framerate())
node->Kill();
@@ -155,124 +155,124 @@ void CDasherModel::Update(CDasherNode *node,CDasherNode *under_mouse,int iSafe)
void CDasherModel::Start()
{
m_Rootmin=0;
m_Rootmax=m_DasherY;
delete m_Root;
CLanguageModel::CNodeContext* therootcontext=m_languagemodel->GetRootNodeContext();
//Rootparent=new DasherNode(0,0,0,therootcontext,0,0,0,Normalization(),languagemodel);
if (m_editbox) {
m_editbox->set_flushed(0);
string ContextString;
m_editbox->get_new_context(ContextString,5);
if (ContextString.size() != 0) {
m_languagemodel->EnterText(therootcontext, ContextString);
}
m_languagemodel->ReleaseNodeContext(LearnContext);
LearnContext = m_languagemodel->CloneNodeContext(therootcontext);
}
m_Root=new CDasherNode(0,0,0,0,Opts::Nodes1,0,Normalization(),m_languagemodel);
m_Root->Push_Node(therootcontext);
m_languagemodel->ReleaseNodeContext(therootcontext);
// ppmmodel->dump();
// dump();
}
/////////////////////////////////////////////////////////////////////////////
void CDasherModel::Get_new_root_coords(myint Mousex,myint Mousey)
{
- int cappedrate=0;
+ // int cappedrate=0;
double dRx=1.0,dRxnew=1.0;
double dRxnew2;
int iSteps=m_fr.Steps();
if (Mousex<m_DasherOX) {
// rx=1.0001*Ixmap[mx]/Ixmap[cx];
if (Mousex<=0)
Mousex=1;
dRx=1.0*m_DasherOX/Mousex;
dRxnew=pow(dRx,1.0/iSteps); // or exp(log(rx)/steps) - i think the replacement is faster
dRxnew2=1+(dRx-1)/iSteps;
//+(rx-1)*(rx-1)*(1.0/fr.steps()-1.0)/2/fr.steps();
const double dRxmax=m_fr.Rxmax();
if (dRxnew>dRxmax)
dRxnew=dRxmax;
// cappedrate=1;
} else {
if (Mousex==m_DasherOX)
Mousex++;
// OutputDebugString(TEXT("zoom out\n"));
dRx=1.0001*m_DasherOX/Mousex;
dRxnew=exp(log(dRx)/iSteps);
// get_coords(root->lbnd,root->hbnd,&x1,&y1,&y2);
//if (x1>0 || y1>0 || y2<CanvasY)
//go_back_a_char();
if (m_Rootmax<m_DasherY && m_Rootmin>0)
return;
}
// dchar debug[256];
// _stprintf(debug,TEXT("rx %f rxnew %f approx %f\n"),rx,rxnew,rxnew2);
// OutputDebugString(debug);
//wsprintf(debug,TEXT("rx %f rxnew %f\n"),rx,rxnew);
//OutputDebugString(debug);
myint above=(Mousey-m_Rootmin);//*(1-rxnew)/(1-rx);
myint below=(m_Rootmax-Mousey);//*(1-rxnew)/(1-rx);
// wsprintf(debug,TEXT("above %I64d below %I64d \n"),above,below);
// OutputDebugString(debug);
myint miDistance=m_DasherY/2-Mousey;
miDistance=myint(miDistance*(dRxnew-1)/(dRx-1));
myint miNewrootzoom=Mousey+miDistance;
myint newRootmax=miNewrootzoom+myint(below*dRxnew);
myint newRootmin=miNewrootzoom-myint(above*dRxnew);
if (newRootmin<m_DasherY/2 && newRootmax>m_DasherY/2 && newRootmax<LLONG_MAX && newRootmin>LLONG_MIN) {
m_Rootmax=newRootmax;
m_Rootmin=newRootmin;
}
}
/////////////////////////////////////////////////////////////////////////////
-void CDasherModel::Tap_on_display(myint miMousex,myint miMousey, unsigned long Time)
+void CDasherModel::Tap_on_display(myint miMousex,myint miMousey, unsigned long )
// work out the next viewpoint, opens some new nodes
{
// works out next viewpoint
Get_new_root_coords(miMousex,miMousey);
// opens up new nodes
// push node under mouse
CDasherNode *under_mouse=Get_node_under_mouse(miMousex,miMousey);
under_mouse->Push_Node();
if (Framerate() > 4) {
// push node under mouse but with x coord on RHS
CDasherNode *right=Get_node_under_mouse(50,miMousey);
right->Push_Node();
}
if (Framerate() > 8) {
// push node under the crosshair
CDasherNode *under_cross=Get_node_under_crosshair();
under_cross->Push_Node();
}
unsigned int iRandom;
#if defined(_WIN32_WCE)
iRandom=Random();
#else
iRandom=rand();
#endif
if (Framerate() > 8) {
// add some noise and push another node
diff --git a/inputmethods/dasher/DasherNode.cpp b/inputmethods/dasher/DasherNode.cpp
index 26af10f..3a984ef 100644
--- a/inputmethods/dasher/DasherNode.cpp
+++ b/inputmethods/dasher/DasherNode.cpp
@@ -3,65 +3,65 @@
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2001-2002 David Ward
//
/////////////////////////////////////////////////////////////////////////////
#include "DasherNode.h"
using namespace Dasher;
using namespace Opts;
using namespace std;
/////////////////////////////////////////////////////////////////////////////
void CDasherNode::Dump_node () const
{
/* TODO sort out
dchar out[256];
if (m_Symbol)
wsprintf(out,TEXT("%7x %3c %7x %5d %7x %5d %8x %8x \n"),this,m_Symbol,m_iGroup,m_context,m_Children,m_Cscheme,m_iLbnd,m_iHbnd);
else
wsprintf(out,TEXT("%7x %7x %5d %7x %5d %8x %8x \n"),this,m_iGroup,m_context,m_Children,m_Cscheme,m_iLbnd,m_iHbnd);
OutputDebugString(out);
if (m_Children) {
unsigned int i;
for (i=1;i<m_iChars;i++)
m_Children[i]->Dump_node();
}
*/
}
-void CDasherNode::Generic_Push_Node(CLanguageModel::CNodeContext *context) {
+void CDasherNode::Generic_Push_Node(CLanguageModel::CNodeContext *) {
m_iAge=0;
m_bAlive=true;
if (m_Symbol && !m_iChars) // make sure it's a valid symbol and don't enter if already done
m_languagemodel->EnterNodeSymbol(m_context,m_Symbol);
vector<symbol> newchars; // place to put this list of characters
vector<unsigned int> cum,groups; // for the probability list
m_languagemodel->GetNodeProbs(m_context,newchars,groups,cum,0.003);
m_iChars=newchars.size();
// work out cumulative probs
unsigned int i;
for (i=1;i<m_iChars;i++)
cum[i]+=cum[i-1];
m_Children =new CDasherNode *[m_iChars];
// create the children
ColorSchemes NormalScheme, SpecialScheme;
if ((m_ColorScheme==Nodes1) || (m_ColorScheme==Special1)) {
NormalScheme = Nodes2;
SpecialScheme = Special2;
} else {
NormalScheme = Nodes1;
SpecialScheme = Special1;
}
ColorSchemes ChildScheme;
for (i=1;i<m_iChars;i++) {
if (newchars[i]==this->m_languagemodel->GetSpaceSymbol())
ChildScheme = SpecialScheme;
diff --git a/inputmethods/dasher/DasherNode.h b/inputmethods/dasher/DasherNode.h
index 705a9d4..fb00d47 100644
--- a/inputmethods/dasher/DasherNode.h
+++ b/inputmethods/dasher/DasherNode.h
@@ -45,67 +45,81 @@ public:
CDasherNode ** const Children() const {return m_Children;}
unsigned int Lbnd() const {return m_iLbnd;}
bool Alive() {return m_bAlive;}
bool Control() {return m_bControlChild;}
void Kill() {m_bAlive=0;m_iAge=0;}
unsigned int Hbnd() const {return m_iHbnd;}
unsigned int Group() const {return m_iGroup;}
unsigned int Age() const {return m_iAge;}
symbol Symbol() const {return m_Symbol;}
unsigned int Chars() const {return m_iChars;}
int Phase() const {return m_iPhase;}
Opts::ColorSchemes Cscheme() const {return m_ColorScheme;}
int Colour() const {return m_iColour;}
CDasherNode* const Get_node_under(int,myint y1,myint y2,myint smousex,myint smousey); // find node under given co-ords
void Get_string_under(const int,const myint y1,const myint y2,const myint smousex,const myint smousey,std::vector<symbol>&) const; // get string under given co-ords
void Generic_Push_Node(CLanguageModel::CNodeContext *context);
void Push_Node(); // give birth to children
void Push_Node(CLanguageModel::CNodeContext *context); // give birth to children with this context
void Delete_children();
void Dump_node() const; // diagnostic
};
/////////////////////////////////////////////////////////////////////////////
// Inline functions
/////////////////////////////////////////////////////////////////////////////
using namespace Dasher;
using namespace Opts;
/////////////////////////////////////////////////////////////////////////////
-inline CDasherNode::CDasherNode(CDasherNode *parent,symbol Symbol, unsigned int igroup, int iphase, ColorSchemes ColorScheme,int ilbnd,int ihbnd,CLanguageModel *lm, int Colour=0)
- : m_parent(parent),m_Symbol(Symbol),m_iGroup(igroup),m_iLbnd(ilbnd),m_iHbnd(ihbnd),m_languagemodel(lm),m_iPhase(iphase),
- m_context(0), m_iAge(0), m_bAlive(1), m_Children(0), m_bForce(false), m_iChars(0), m_ColorScheme(ColorScheme), m_bControlChild(false), m_iColour(Colour)
+inline CDasherNode::CDasherNode(CDasherNode *parent,symbol Symbol, unsigned int igroup, int iphase, ColorSchemes ColorScheme,int ilbnd,int ihbnd,CLanguageModel *lm, int Colour=0) :
+ m_iLbnd(ilbnd),
+ m_iHbnd(ihbnd),
+ m_iGroup(igroup),
+ m_iChars(0),
+ m_iAge(0),
+ m_bAlive(1),
+ m_bControlChild(false),
+ m_ColorScheme(ColorScheme),
+ m_iPhase(iphase),
+ m_iColour(Colour),
+ m_Symbol(Symbol),
+ m_languagemodel(lm),
+ m_Children(0),
+ m_parent(parent),
+ m_context(0),
+ m_bForce(false)
{
/*
switch (ColorScheme) {
case Nodes1:
m_ColorScheme = Nodes2;
break;
case Nodes2:
m_ColorScheme = Nodes1;
break;
case Special1:
m_ColorScheme = Special2;
break;
case Special2:
m_ColorScheme = Special1;
break;
case default:
m_ColorScheme = ColorScheme;
break;
}
*/
}
/////////////////////////////////////////////////////////////////////////////
inline void CDasherNode::Delete_children()
{
if (m_Children) {
unsigned int i;
for (i=1;i<m_iChars;i++)
delete m_Children[i];
delete [] m_Children;
}
diff --git a/inputmethods/dasher/DasherSettingsInterface.h b/inputmethods/dasher/DasherSettingsInterface.h
index 9d03eba..34b55d4 100644
--- a/inputmethods/dasher/DasherSettingsInterface.h
+++ b/inputmethods/dasher/DasherSettingsInterface.h
@@ -1,130 +1,130 @@
// DasherSettingsInterface.h
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Iain Murray
//
/////////////////////////////////////////////////////////////////////////////
#ifndef __DasherSettingsInterface_h__
#define __DasherSettingsInterface_h__
#include "DasherTypes.h"
#include "SettingsStore.h"
namespace Dasher {class CDasherSettingsInterface;}
class Dasher::CDasherSettingsInterface
{
public:
void SettingsDefaults(CSettingsStore* Store);
// These actually affect the way Dasher works
//! Change the alphabet in use to NewAlphabetID
- virtual void ChangeAlphabet(const std::string& NewAlphabetID) {};
+ virtual void ChangeAlphabet(const std::string& ) {};
//! Change the maximum bitrate (effectively the speed) of Dasher
- virtual void ChangeMaxBitRate(double NewMaxBitRate) {};
+ virtual void ChangeMaxBitRate(double ) {};
//! Generate a new langage model. Not usually needed
- virtual void ChangeLanguageModel(unsigned int NewLanguageModelID) {};
+ virtual void ChangeLanguageModel(unsigned int ) {};
//! Generate a new view of the model. Call it with 0 when starting up
- virtual void ChangeView(unsigned int NewViewID) {};
+ virtual void ChangeView(unsigned int ) {};
//! Change the orientation (l->r, r->l, so on) of the model
- virtual void ChangeOrientation(Opts::ScreenOrientations Orientation) {};
+ virtual void ChangeOrientation(Opts::ScreenOrientations ) {};
//! Set the file encoding of output files to Encoding
- virtual void SetFileEncoding(Opts::FileEncodingFormats Encoding) {};
+ virtual void SetFileEncoding(Opts::FileEncodingFormats ) {};
//! Inform the core that the screen has this size
- virtual void SetScreenSize(long Width, long Height) {};
+ virtual void SetScreenSize(long , long ) {};
//! Set the size of the font used in the Dasher canvas
- virtual void SetDasherFontSize(Dasher::Opts::FontSize fontsize) {};
+ virtual void SetDasherFontSize(Dasher::Opts::FontSize ) {};
//! Set the number of dimensions of input (either 1 or 2)
- virtual void SetDasherDimensions(bool Value) {};
+ virtual void SetDasherDimensions(bool ) {};
// These are recommended options for the Dasher GUI. {{{ They don't actually
// change the way Dasher works. They are part of the Dasher interface
// anyway so that it can handle option saving for you, and to make it
// easy for the Dasher engine to control the GUI later on. }}}
//! True if toolbar should be shown, false otherwise
- virtual void ShowToolbar(bool Value) {};
+ virtual void ShowToolbar(bool ) {};
//! True if toolbar should show text, false otherwse
- virtual void ShowToolbarText(bool Value) {};
+ virtual void ShowToolbarText(bool ) {};
//! True if toolbar should have large icons, false otherwise
- virtual void ShowToolbarLargeIcons(bool Value) {};
+ virtual void ShowToolbarLargeIcons(bool ) {};
//! True if the speed slider should be shown, false otherwise
- virtual void ShowSpeedSlider(bool Value) {};
+ virtual void ShowSpeedSlider(bool ) {};
//! True if the window layout should be fixed, false otherwise
- virtual void FixLayout(bool Value) {};
+ virtual void FixLayout(bool ) {};
//! True if new files should be timestamped, false otherwise
- virtual void TimeStampNewFiles(bool Value) {};
+ virtual void TimeStampNewFiles(bool ) {};
//! True if all text should be copied to clipboard when Dasher is stopped, false otherwise
- virtual void CopyAllOnStop(bool Value) {};
+ virtual void CopyAllOnStop(bool ) {};
//! True if a box should be drawn to represent the logical position of the mouse
- virtual void DrawMouse(bool Value) {};
+ virtual void DrawMouse(bool ) {};
//! Set the editbox font
- virtual void SetEditFont(std::string Name, long Size) {};
+ virtual void SetEditFont(std::string , long ) {};
//! Set the canvas font
- virtual void SetDasherFont(std::string Name) {};
+ virtual void SetDasherFont(std::string ) {};
//! Set the height of the edit box
- virtual void SetEditHeight(long Value) {};
+ virtual void SetEditHeight(long ) {};
//! Should Dasher start and stop on space bar?
- virtual void StartOnSpace(bool Value) {};
+ virtual void StartOnSpace(bool ) {};
//! Should Dasher start and stop on left mouse button?
- virtual void StartOnLeft(bool Value) {};
+ virtual void StartOnLeft(bool ) {};
//! Should Dasher be keyboard controlled?
- virtual void KeyControl(bool Value) {};
+ virtual void KeyControl(bool ) {};
//! Should Dasher pause when the pointer leaves the window?
- virtual void WindowPause(bool Value) {};
+ virtual void WindowPause(bool ) {};
};
#include <string>
namespace Dasher
{
namespace Keys
{
// Standard Option strings. You are encouraged to use these constants.
// -------------------------------------------------------------------
// bool options
extern const std::string TIME_STAMP;
extern const std::string SHOW_TOOLBAR;
extern const std::string SHOW_TOOLBAR_TEXT;
extern const std::string SHOW_LARGE_ICONS;
extern const std::string FIX_LAYOUT;
extern const std::string SHOW_SLIDER;
extern const std::string COPY_ALL_ON_STOP;
extern const std::string DRAW_MOUSE;
extern const std::string START_SPACE;
extern const std::string START_MOUSE;
extern const std::string KEY_CONTROL;
extern const std::string WINDOW_PAUSE;
// long options
extern const std::string FILE_ENCODING;
extern const std::string MAX_BITRATE_TIMES100;
extern const std::string SCREEN_ORIENTATION;
extern const std::string VIEW_ID;
extern const std::string LANGUAGE_MODEL_ID;
extern const std::string EDIT_FONT_SIZE;
diff --git a/inputmethods/dasher/DasherView.cpp b/inputmethods/dasher/DasherView.cpp
index 3b8cb64..8e32cf1 100644
--- a/inputmethods/dasher/DasherView.cpp
+++ b/inputmethods/dasher/DasherView.cpp
@@ -1,66 +1,66 @@
// DasherView.cpp
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2001-2002 David Ward
//
/////////////////////////////////////////////////////////////////////////////
#include "DasherView.h"
using namespace Dasher;
CDasherView::CDasherView(CDasherScreen* DasherScreen, CDasherModel& DasherModel, Opts::ScreenOrientations Orientation)
: m_Screen(DasherScreen), m_DasherModel(DasherModel), ScreenOrientation(Orientation), ColourMode(false)
{
// XYScale = (double)m_Screen->GetHeight() / m_Screen->GetWidth();
}
void CDasherView::ChangeOrientation(Dasher::Opts::ScreenOrientations Orientation)
{
ScreenOrientation = Orientation;
Render();
}
-void CDasherView::FlushAt(int mousex,int mousey)
+void CDasherView::FlushAt(int ,int )
{
m_DasherModel.Flush(0,0);
}
int CDasherView::RecursiveRender(CDasherNode* Render, myint y1,myint y2,int mostleft, bool text)
{
- symbol CurChar = Render->Symbol();
+ // symbol CurChar = Render->Symbol();
int Color;
if (ColourMode==true) {
Color = Render->Colour();
} else {
Color = Render->Phase()%3;
}
if (RenderNode(Render->Symbol(), Color, Render->Cscheme(), y1, y2, mostleft, Render->m_bForce, text))
RenderGroups(Render, y1, y2, text);
else
Render->Kill();
CDasherNode** const Children=Render->Children();
if (!Children)
return 0;
int norm=DasherModel().Normalization();
for (unsigned int i=1; i<Render->Chars(); i++) {
if (Children[i]->Alive()) {
myint Range=y2-y1;
myint newy1=y1+(Range*Children[i]->Lbnd())/norm;
myint newy2=y1+(Range*Children[i]->Hbnd())/norm;
RecursiveRender(Children[i], newy1, newy2, mostleft, text);
}
}
return 1;
}
void CDasherView::RenderGroups(CDasherNode* Render, myint y1, myint y2, bool text)
diff --git a/inputmethods/dasher/DasherView.h b/inputmethods/dasher/DasherView.h
index 81cc24e..6257c03 100644
--- a/inputmethods/dasher/DasherView.h
+++ b/inputmethods/dasher/DasherView.h
@@ -1,63 +1,63 @@
// DasherView.h
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2001-2002 David Ward
//
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// DasherView.h: interface for the DasherView class.
// Copyright 2002 David Ward
//////////////////////////////////////////////////////////////////////
#ifndef __DasherView_h_
#define __DasherView_h_
#include "MSVC_Unannoy.h"
#include "DasherScreen.h"
#include "DasherModel.h"
// CDasherView is an abstract view class
// The implentation must provide several functions - defined here as pure virtual functions
// See the CDasherViewSquare class for an example
namespace Dasher {class CDasherView;}
class Dasher::CDasherView
{
public:
CDasherView(CDasherScreen* DasherScreen, CDasherModel& DasherModel, Dasher::Opts::ScreenOrientations Orientation=Dasher::Opts::LeftToRight);
- ~CDasherView() {}
+ virtual ~CDasherView() {}
void ChangeOrientation(Dasher::Opts::ScreenOrientations Orientation);
// TODO Sort this out
void FlushAt(int mousex,int mousey);
// renders Dasher
inline void Render();
// translates the screen coordinates to Dasher coordinates and calls
// dashermodel.TapOnDisplay
virtual void TapOnDisplay(int mousex, int mousey, unsigned long Time)=0;
virtual void ChangeScreen(CDasherScreen* NewScreen)
{
m_Screen=NewScreen;
// DJW - removed floating point stuff
//XYScale = (double)m_Screen->GetHeight() / m_Screen->GetWidth();
}
virtual void DrawMouse(int mousex, int mousey)=0;
virtual void DrawKeyboard()=0;
// Return references to the model and the screen:
CDasherModel& DasherModel() {return m_DasherModel;}
CDasherScreen& Screen() {return *m_Screen;}
void Display() {m_Screen->Display();}
// Toggle advanced colour mode
void SetColourMode(bool colourmode) {ColourMode=colourmode;}
diff --git a/inputmethods/dasher/PPMLanguageModel.cpp b/inputmethods/dasher/PPMLanguageModel.cpp
index b725a2b..137b07f 100644
--- a/inputmethods/dasher/PPMLanguageModel.cpp
+++ b/inputmethods/dasher/PPMLanguageModel.cpp
@@ -43,78 +43,78 @@ CPPMLanguageModel::CPPMnode * CPPMLanguageModel::CPPMnode::add_symbol_to_node(in
child=born;
// node->count=1;
return born;
} else {
if (*update) { // perform update exclusions
search->count++;
*update=0;
}
return search;
}
}
/////////////////////////////////////////////////////////////////////
// CPPMLanguageModel defs
/////////////////////////////////////////////////////////////////////
CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization)
: CLanguageModel(_alphabet,_normalization)
{
root=new CPPMnode(-1);
m_rootcontext=new CPPMContext(root,0);
}
CPPMLanguageModel::~CPPMLanguageModel()
{
delete root;
}
-bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double addprob)
+bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double )
// get the probability distribution at the context
{
// seems like we have to have this hack for VC++
CPPMContext *ppmcontext=static_cast<CPPMContext *> (context);
int modelchars=GetNumberModelChars();
int norm=CLanguageModel::normalization();
probs.resize(modelchars);
CPPMnode *temp,*s;
int loop,total;
int sym;
- ulong spent=0;
+ // ulong spent=0;
ulong size_of_slice;
bool *exclusions=new bool [modelchars];
ulong uniform=modelchars;
ulong tospend=norm-uniform;
temp=ppmcontext->head;
for (loop=0; loop <modelchars; loop++) { /* set up the exclusions array */
probs[loop]=0;
exclusions[loop]=0;
}
while (temp!=0) {
// Usprintf(debug,TEXT("tospend %u\n"),tospend);
// DebugOutput(TEXT("round\n"));
total=0;
s=temp->child;
while (s) {
sym=s->symbol;
if (!exclusions[s->symbol])
total=total+s->count;
s=s->next;
}
if (total) {
// Usprintf(debug,TEXT"escape %u\n"),tospend*
size_of_slice=tospend;
s=temp->child;
while (s) {
if (!exclusions[s->symbol]) {
exclusions[s->symbol]=1;
ulong p=size_of_slice*(2*s->count-1)/2/ulong(total);
probs[s->symbol]+=p;
tospend-=p;
}
// Usprintf(debug,TEXT("sym %u counts %d p %u tospend %u \n"),sym,s->count,p,tospend);
@@ -163,119 +163,119 @@ void CPPMLanguageModel::AddSymbol(CPPMLanguageModel::CPPMContext &context,int sy
{
// sanity check
if (symbol==0 || symbol>=GetNumberModelChars())
return;
CPPMnode *vineptr,*temp;
int updatecnt=1;
temp=context.head->vine;
context.head=context.head->add_symbol_to_node(symbol,&updatecnt);
vineptr=context.head;
context.order++;
while (temp!=0) {
vineptr->vine=temp->add_symbol_to_node(symbol,&updatecnt);
vineptr=vineptr->vine;
temp=temp->vine;
}
vineptr->vine=root;
if (context.order>MAX_ORDER){
context.head=context.head->vine;
context.order--;
}
}
// update context with symbol 'Symbol'
void CPPMLanguageModel::EnterSymbol(CContext* Context, modelchar Symbol)
{
CPPMLanguageModel::CPPMContext& context = * static_cast<CPPMContext *> (Context);
CPPMnode *find;
- CPPMnode *temp=context.head;
+ // CPPMnode *temp=context.head;
while (context.head) {
find =context.head->find_symbol(Symbol);
if (find) {
context.order++;
context.head=find;
// Usprintf(debug,TEXT("found context %x order %d\n"),head,order);
// DebugOutput(debug);
return;
}
context.order--;
context.head=context.head->vine;
}
if (context.head==0) {
context.head=root;
context.order=0;
}
}
void CPPMLanguageModel::LearnSymbol(CContext* Context, modelchar Symbol)
{
CPPMLanguageModel::CPPMContext& context = * static_cast<CPPMContext *> (Context);
AddSymbol(context, Symbol);
}
void CPPMLanguageModel::dumpSymbol(int symbol)
{
if ((symbol <= 32) || (symbol >= 127))
printf( "<%d>", symbol );
else
printf( "%c", symbol );
}
void CPPMLanguageModel::dumpString( char *str, int pos, int len )
// Dump the string STR starting at position POS
{
char cc;
int p;
for (p = pos; p<pos+len; p++) {
cc = str [p];
if ((cc <= 31) || (cc >= 127))
printf( "<%d>", cc );
else
printf( "%c", cc );
}
}
-void CPPMLanguageModel::dumpTrie( CPPMLanguageModel::CPPMnode *t, int d )
+void CPPMLanguageModel::dumpTrie( CPPMLanguageModel::CPPMnode *, int )
// diagnostic display of the PPM trie from node t and deeper
{
//TODO
/*
dchar debug[256];
int sym;
CPPMnode *s;
Usprintf( debug,TEXT("%5d %7x "), d, t );
//TODO: Uncomment this when headers sort out
//DebugOutput(debug);
if (t < 0) // pointer to input
printf( " <" );
else {
Usprintf(debug,TEXT( " %3d %5d %7x %7x %7x <"), t->symbol,t->count, t->vine, t->child, t->next );
//TODO: Uncomment this when headers sort out
//DebugOutput(debug);
}
dumpString( dumpTrieStr, 0, d );
Usprintf( debug,TEXT(">\n") );
//TODO: Uncomment this when headers sort out
//DebugOutput(debug);
if (t != 0) {
s = t->child;
while (s != 0) {
sym =s->symbol;
dumpTrieStr [d] = sym;
dumpTrie( s, d+1 );
s = s->next;
}
}
diff --git a/inputmethods/dasher/PPMLanguageModel.h b/inputmethods/dasher/PPMLanguageModel.h
index bd860b8..7025a0a 100644
--- a/inputmethods/dasher/PPMLanguageModel.h
+++ b/inputmethods/dasher/PPMLanguageModel.h
@@ -1,76 +1,77 @@
// PPMLanguageModel.h
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 1999-2002 David Ward
//
/////////////////////////////////////////////////////////////////////////////
#ifndef __PPMLanguageModel_h__
#define __PPMLanguageModel_h__
#include "NoClones.h"
#include "MSVC_Unannoy.h"
#include <vector>
#include <stdio.h>
#include "LanguageModel.h"
-static char dumpTrieStr[40000];
+// static char dumpTrieStr[40000];
const int MAX_ORDER = 5;
const int maxcont =200;
namespace Dasher {class CPPMLanguageModel;}
class Dasher::CPPMLanguageModel : public Dasher::CLanguageModel, private NoClones
{
public:
CPPMLanguageModel(CAlphabet *_alphabet, int _normalization);
- ~CPPMLanguageModel();
+ virtual ~CPPMLanguageModel();
class CPPMnode {
public:
CPPMnode* find_symbol(int sym);
CPPMnode* add_symbol_to_node(int sym,int *update);
CPPMnode* child;
CPPMnode* next;
CPPMnode* vine;
short int count;
const short int symbol;
CPPMnode(int sym);
};
class CPPMContext : public CContext {
public:
- CPPMContext(CPPMContext const &input) {head = input.head; order= input.order;}
+ CPPMContext(CPPMContext const &input) : CContext(input)
+ { head = input.head;order= input.order;}
CPPMContext(CPPMnode* _head=0, int _order=0) : head(_head),order(_order) {};
~CPPMContext() {};
void dump();
CPPMnode* head;
int order;
};
void ReleaseContext(CContext*);
CContext* GetRootContext();
inline CContext* CloneContext(CContext*);
void EnterSymbol(CContext* context, modelchar Symbol);
//inline bool GetProbs(CContext*,std::vector<symbol> &newchars,std::vector<unsigned int> &groups,std::vector<unsigned int> &probs,double addprob);
bool GetProbs(CContext*, std::vector<unsigned int> &Probs, double AddProb);
void LearnSymbol(CContext* Context, modelchar Symbol);
void dump();
private:
CPPMContext *m_rootcontext;
CPPMnode *root;
void AddSymbol(CPPMContext& context,int symbol);
void dumpSymbol(int symbol);
void dumpString( char *str, int pos, int len );
void dumpTrie( CPPMnode *t, int d );
};
////////////////////////////////////////////////////////////////////////
// Inline functions
////////////////////////////////////////////////////////////////////////
diff --git a/inputmethods/dasher/QtDasherImpl.cc b/inputmethods/dasher/QtDasherImpl.cc
index d72f6d9..f4a70dd 100644
--- a/inputmethods/dasher/QtDasherImpl.cc
+++ b/inputmethods/dasher/QtDasherImpl.cc
@@ -1,56 +1,56 @@
#include <iostream>
#include <qapplication.h>
#include <qobject.h>
#include <qpixmap.h>
#include "DasherInterface.h"
#include "QtDasherScreen.h"
#include "QtDasherImpl.h"
/* XPM */
static const char * qtdasher_xpm[]={
"28 7 2 1",
"# c #303030",
" c None",
" ########################## ",
" ",
" # # ",
" # # # # ",
" # # # # ",
" # # # ",
" ########################## "};
QtDasherImpl::QtDasherImpl()
- : qtdasherwidget(0), icn(0), qtdasherinterface(0)
+ : qtdasherinterface(0), qtdasherwidget(0), icn(0)
{
}
QtDasherImpl::~QtDasherImpl()
{
delete qtdasherwidget;
delete icn;
}
QWidget *QtDasherImpl::inputMethod( QWidget *parent, Qt::WFlags f )
{
if ( !qtdasherwidget ) {
qtdasherwidget = new QtDasherPlugin( parent, "Dasher", f );
}
return qtdasherwidget;
}
void QtDasherImpl::resetState()
{
if ( qtdasherwidget )
qtdasherwidget->resetState();
}
QPixmap *QtDasherImpl::icon()
{
if ( !icn )
icn = new QPixmap( (const char **)qtdasher_xpm );
return icn;
}
QString QtDasherImpl::name()
{
diff --git a/inputmethods/dasher/QtDasherPlugin.cc b/inputmethods/dasher/QtDasherPlugin.cc
index cf4fc2c..f491769 100644
--- a/inputmethods/dasher/QtDasherPlugin.cc
+++ b/inputmethods/dasher/QtDasherPlugin.cc
@@ -20,60 +20,60 @@ QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QF
(new QHBoxLayout(this))->setAutoAdd(TRUE);
interface = new CDasherInterface;
interface->SetSystemLocation("/opt/QtPalmtop/share/dasher/");
interface->Unpause(0);
interface->Start();
d = new QtDasherScreen(240,100,interface,this,this);
interface->ChangeMaxBitRate(2.5);
d->show();
utf8_codec = new QUtf8Codec;
}
QSize QtDasherPlugin::sizeHint() const
{
return QSize(240,100);
}
QtDasherPlugin::~QtDasherPlugin()
{
delete d;
}
void QtDasherPlugin::resetState()
{
flushcount=0;
interface->Start();
interface->Redraw();
}
void QtDasherPlugin::unflush()
{
if (flushcount==0)
return;
- for (flushcount; flushcount>0; flushcount--) {
+ for (; flushcount>0; flushcount--) {
deletetext();
}
}
void QtDasherPlugin::output(int Symbol)
{
std::string label = interface->GetEditText(Symbol);
QString unicodestring = utf8_codec->toUnicode(label.c_str());
for (int i=0; i<int(unicodestring.length()); i++) {
emit key( unicodestring[i].unicode(), 0, 0, true, false );
emit key( unicodestring[i].unicode(), 0, 0, false, false );
}
}
void QtDasherPlugin::deletetext()
{
emit key( 0, Qt::Key_Backspace, 0, true, false);
emit key( 0, Qt::Key_Backspace, 0, false, false);
}
void QtDasherPlugin::flush(int Symbol)
{
if (Symbol==0)
return;
output(Symbol);
flushcount++;
}
diff --git a/inputmethods/dasher/QtDasherPlugin.h b/inputmethods/dasher/QtDasherPlugin.h
index 5f70acf..c979a2f 100644
--- a/inputmethods/dasher/QtDasherPlugin.h
+++ b/inputmethods/dasher/QtDasherPlugin.h
@@ -1,42 +1,42 @@
#include <qutfcodec.h>
#include <qframe.h>
#include "QtDasherScreen.h"
#include "DasherInterface.h"
#include "DashEdit.h"
class QtDasherPlugin : public QFrame, public CDashEditbox
{
Q_OBJECT
public:
QtDasherPlugin(QWidget* parent=0, const char* name=0, WFlags f=0);
~QtDasherPlugin();
void resetState();
QSize sizeHint() const;
void write_to_file() {};
void get_new_context(std::string&, int) {};
void unflush();
void output(int);
void deletetext();
void flush(int);
void Clear() {};
void SetEncoding(Dasher::Opts::FileEncodingFormats) {};
- void SetFont(std::string Name, long Size) {};
+ void SetFont(std::string , long ) {};
signals:
void key( ushort, ushort, ushort, bool, bool);
private:
QtDasherScreen *d;
CDasherInterface *interface;
int flushcount;
QUtf8Codec *utf8_codec;
};
diff --git a/inputmethods/dasher/QtDasherScreen.cc b/inputmethods/dasher/QtDasherScreen.cc
index 747b705..2179cfb 100644
--- a/inputmethods/dasher/QtDasherScreen.cc
+++ b/inputmethods/dasher/QtDasherScreen.cc
@@ -1,67 +1,72 @@
// QtDasherScreen.cc
// (c) 2003 Yann Dirson
// Derived from GtkDasherCanvas.cc
// (c) 2002 Philip Cowans
#include <iostream>
#include <string>
#include <qpointarray.h>
#include <qpoint.h>
#include "QtDasherScreen.h"
#include "DasherScreen.h"
#include "SettingsStore.h"
#define MAXFONTSIZE 25
#define MINFONTSIZE 8
QtDasherScreen::QtDasherScreen (int _width, int _height,
CDasherInterface *_interface,
- QWidget * _parent, Dasher::CDashEditbox *edit):
- QWidget(_parent), interface( _interface ),
- fontname( "fixed" ), fontsize(12),
- Dasher::CDasherScreen(_width, _height)
+ QWidget * _parent,
+ Dasher::CDashEditbox *_edit):
+ QWidget(_parent),
+ Dasher::CDasherScreen(_width, _height),
+ fontsize(12),
+ interface( _interface ),
+ fontname( "fixed" )
{
font = QFont (fontname.c_str(), fontsize);
painter = new QPainter ();
pixmap = new QPixmap (_width, _height);
pixmap->setOptimization(QPixmap::BestOptim);
interface->SetSettingsStore(new CSettingsStore);
interface->ChangeLanguageModel(0);
interface->ChangeView(0);
- interface->ChangeEdit(edit);
+ interface->ChangeEdit(_edit);
+ edit = _edit;
+
/* interface->GetFontSizes(&FontSizes);
for (int i=0; i<FontSizes.size(); i++) {
if (FontSizes[i]>Fonts.size())
Fonts.resize((FontSizes[i])+1);
Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]);
// Fonts[FontSizes[i]].setPixelSize(FontSizes[i]);
}
*/
interface->ChangeScreen(this);
paused=true;
QTimer *tmr = new QTimer(this);
connect (tmr, SIGNAL(timeout()), SLOT(timer()));
tmr->start(200);
}
long QtDasherScreen::get_time()
{
long s_now;
long ms_now;
struct timeval tv;
struct timezone tz;
gettimeofday( &tv, &tz );
s_now = tv.tv_sec-1054487600;
@@ -114,64 +119,64 @@ void QtDasherScreen::DrawRectangle(int x1, int y1, int x2, int y2,
{
painter->setBrush (getColor (Color, ColorScheme));
painter->drawRect (x1, y1, x2-x1, y2-y1);
}
static void Points_to_QPointArray(const Dasher::CDasherScreen::point* const points,
int number,
QPointArray &qpa)
{
for (int i = 0; i < number; i++) {
qpa.setPoint (i, points[i].x, points[i].y);
}
}
void QtDasherScreen::Polyline(point* Points, int Number) const
{
QPointArray qpa(Number);
Points_to_QPointArray (Points, Number, qpa);
painter->setPen (SolidLine);
painter->drawPolyline (qpa);
painter->setPen (NoPen);
}
void QtDasherScreen::DrawPolygon(point* Points, int Number, int Color,
Opts::ColorSchemes ColorScheme) const
{
painter->setBrush (getColor (Color, ColorScheme));
QPointArray qpa(Number);
Points_to_QPointArray (Points, Number, qpa);
painter->drawPolygon (qpa);
}
-void QtDasherScreen::mousePressEvent (QMouseEvent *e)
+void QtDasherScreen::mousePressEvent (QMouseEvent *)
{
paused=false;
interface->Unpause(get_time());
}
void QtDasherScreen::mouseReleaseEvent(QMouseEvent *e)
{
QPoint p = e->pos();
interface->PauseAt(p.x(), p.y());
paused=true;
}
void QtDasherScreen::timer()
{
if (paused==false) {
QPoint cursorpos;
cursorpos=this->cursor().pos();
cursorpos=mapFromGlobal(cursorpos);
interface->TapOn(cursorpos.x(), cursorpos.y(), get_time());
}
}
diff --git a/inputmethods/dasher/QtDasherScreen.h b/inputmethods/dasher/QtDasherScreen.h
index 06689d6..d3d67cb 100644
--- a/inputmethods/dasher/QtDasherScreen.h
+++ b/inputmethods/dasher/QtDasherScreen.h
@@ -7,75 +7,75 @@
#define QT_DASHER_SCREEN_H
#include <string>
#include <sys/time.h>
#include <qwidget.h>
#include <qpainter.h>
#include <qfont.h>
#include <qstring.h>
#include <qpixmap.h>
#include <qtimer.h>
#include <qcursor.h>
#include "DasherScreen.h"
#include "DashEdit.h"
#include "DasherInterface.h"
using namespace Dasher;
class QtDasherScreen : public QWidget, public Dasher::CDasherScreen
{
Q_OBJECT
public:
QtDasherScreen (int _width, int _height,
CDasherInterface *_interface,
QWidget * _parent=0, Dasher::CDashEditbox* edit=0);
QtDasherScreen::~QtDasherScreen();
void SetFont(std::string Name)
{ fontname = Name; /* set_the_font(); */ }
- void SetFontSize(Dasher::Opts::FontSize fontsize)
+ void SetFontSize(Dasher::Opts::FontSize )
{
#warning QtDasherScreen::SetFontSize() not implemented
}
Dasher::Opts::FontSize GetFontSize()
{
#warning QtDasherScreen::GetFontSize() not implemented
return (Dasher::Opts::Normal);
}
- void TextSize(symbol Character, int* Width, int* Height, int Size) const
+ void TextSize(symbol , int* Width, int* Height, int ) const
{
// should probably use QPainter::boundingRect()
*Width = *Height = font.pixelSize();
}
void DrawText(symbol Character, int x1, int y1, int Size) const
{
// QFont font = QFont (fontname.c_str(), Size);
// font.setPixelSize(Size);
QPoint point = QPoint(x1, y1+Size/2);
painter->setFont (font);
painter->drawText (point,
QString(interface->GetDisplayText(Character).c_str()));
}
void DrawRectangle(int x1, int y1, int x2, int y2,
int Color, Opts::ColorSchemes ColorScheme) const;
void Polyline(point* Points, int Number) const;
void DrawPolygon(point* Points, int Number, int Color,
Opts::ColorSchemes ColorScheme) const;
std::vector<int> FontSizes;
std::vector<QFont> Fonts;
QFont font;
int fontsize;
void Blank() const {
painter->begin(pixmap);
painter->setPen (NoPen);
painter->fillRect(0, 0, m_iWidth, m_iHeight,
QColor(255,255,255));
}
diff --git a/inputmethods/dasher/SettingsStore.cpp b/inputmethods/dasher/SettingsStore.cpp
index c5bbfea..f7661bd 100644
--- a/inputmethods/dasher/SettingsStore.cpp
+++ b/inputmethods/dasher/SettingsStore.cpp
@@ -73,63 +73,63 @@ void CSettingsStore::SetStringOption(const string& Key, const string& Value)
}
void CSettingsStore::SetBoolDefault(const string& Key, bool Value)
{
bool TmpValue;
if ( (BoolMap.find(Key)==BoolMap.end()) && (!LoadSetting(Key, &TmpValue)) )
SetBoolOption(Key, Value);
}
void CSettingsStore::SetLongDefault(const string& Key, long Value)
{
long TmpValue;
if ( (LongMap.find(Key)==LongMap.end()) && (!LoadSetting(Key, &TmpValue)) )
SetLongOption(Key, Value);
}
void CSettingsStore::SetStringDefault(const string& Key, const string& Value)
{
string TmpValue;
if ( (StringMap.find(Key)==StringMap.end()) && (!LoadSetting(Key, &TmpValue)) )
SetStringOption(Key, Value);
}
/* Private functions -- Settings are not saved between sessions unless these
functions are over-ridden.
--------------------------------------------------------------------------*/
-bool CSettingsStore::LoadSetting(const string& Key, bool* Value)
+bool CSettingsStore::LoadSetting(const string& , bool* )
{
return false;
}
-bool CSettingsStore::LoadSetting(const string& Key, long* Value)
+bool CSettingsStore::LoadSetting(const string& , long* )
{
return false;
}
-bool CSettingsStore::LoadSetting(const string& Key, string* Value)
+bool CSettingsStore::LoadSetting(const string& , string* )
{
return false;
}
-void CSettingsStore::SaveSetting(const string& Key, bool Value)
+void CSettingsStore::SaveSetting(const string& , bool )
{
}
-void CSettingsStore::SaveSetting(const string& Key, long Value)
+void CSettingsStore::SaveSetting(const string& , long )
{
}
-void CSettingsStore::SaveSetting(const string& Key, const string& Value)
+void CSettingsStore::SaveSetting(const string& , const string& )
{
}