summaryrefslogtreecommitdiff
Unidiff
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,83 +1,85 @@
1// AlphIO.cpp 1// AlphIO.cpp
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10 10
11#include "AlphIO.h" 11#include "AlphIO.h"
12 12
13using namespace Dasher; 13using namespace Dasher;
14using namespace std; 14using namespace std;
15 15
16CAlphIO::CAlphIO(string SystemLocation, string UserLocation) 16CAlphIO::CAlphIO(string SystemLocation, string UserLocation)
17 : SystemLocation(SystemLocation), UserLocation(UserLocation), 17 : BlankInfo(),
18 BlankInfo(), CData("") 18 SystemLocation(SystemLocation),
19 UserLocation(UserLocation),
20 CData("")
19{ 21{
20 CreateDefault(); 22 CreateDefault();
21} 23}
22 24
23 25
24void CAlphIO::GetAlphabets(std::vector< std::string > * AlphabetList) const 26void CAlphIO::GetAlphabets(std::vector< std::string > * AlphabetList) const
25{ 27{
26 AlphabetList->clear(); 28 AlphabetList->clear();
27 29
28 typedef std::map<std::string, AlphInfo>::const_iterator CI; 30 typedef std::map<std::string, AlphInfo>::const_iterator CI;
29 CI End = Alphabets.end(); 31 CI End = Alphabets.end();
30 32
31 for (CI Cur=Alphabets.begin(); Cur!=End; Cur++) 33 for (CI Cur=Alphabets.begin(); Cur!=End; Cur++)
32 AlphabetList->push_back( (*Cur).second.AlphID); 34 AlphabetList->push_back( (*Cur).second.AlphID);
33} 35}
34 36
35 37
36const CAlphIO::AlphInfo& CAlphIO::GetInfo(const std::string& AlphID) 38const CAlphIO::AlphInfo& CAlphIO::GetInfo(const std::string& AlphID)
37{ 39{
38 if (AlphID=="") 40 if (AlphID=="")
39 return Alphabets["Default"]; 41 return Alphabets["Default"];
40 else { 42 else {
41 AlphInfo& CurInfo = Alphabets[AlphID]; 43 // AlphInfo& CurInfo = Alphabets[AlphID];
42 Alphabets[AlphID].AlphID = AlphID; // Ensure consistency 44 Alphabets[AlphID].AlphID = AlphID; // Ensure consistency
43 return Alphabets[AlphID]; 45 return Alphabets[AlphID];
44 } 46 }
45} 47}
46 48
47 49
48void CAlphIO::SetInfo(const AlphInfo& NewInfo) 50void CAlphIO::SetInfo(const AlphInfo& NewInfo)
49{ 51{
50 Alphabets[NewInfo.AlphID] = NewInfo; 52 Alphabets[NewInfo.AlphID] = NewInfo;
51} 53}
52 54
53 55
54void CAlphIO::Delete(const std::string& AlphID) 56void CAlphIO::Delete(const std::string& AlphID)
55{ 57{
56 if (Alphabets.find(AlphID)!=Alphabets.end()) { 58 if (Alphabets.find(AlphID)!=Alphabets.end()) {
57 Alphabets.erase(AlphID); 59 Alphabets.erase(AlphID);
58 } 60 }
59} 61}
60 62
61 63
62void CAlphIO::CreateDefault() 64void CAlphIO::CreateDefault()
63{ 65{
64 // TODO I appreciate these strings should probably be in a resource file. 66 // TODO I appreciate these strings should probably be in a resource file.
65 // Not urgent though as this is not intended to be used. It's just a 67 // Not urgent though as this is not intended to be used. It's just a
66 // last ditch effort in case file I/O totally fails. 68 // last ditch effort in case file I/O totally fails.
67 AlphInfo& Default = Alphabets["Default"]; 69 AlphInfo& Default = Alphabets["Default"];
68 Default.AlphID = "Default"; 70 Default.AlphID = "Default";
69 Default.Type = Opts::Western; 71 Default.Type = Opts::Western;
70 Default.Mutable = false; 72 Default.Mutable = false;
71 Default.Orientation = Opts::LeftToRight; 73 Default.Orientation = Opts::LeftToRight;
72 Default.SpaceCharacter.Display = "_"; 74 Default.SpaceCharacter.Display = "_";
73 Default.SpaceCharacter.Text = " "; 75 Default.SpaceCharacter.Text = " ";
74 Default.TrainingFile = "training_english_GB.txt"; 76 Default.TrainingFile = "training_english_GB.txt";
75 string Chars = "abcdefghijklmnopqrstuvwxyz"; 77 string Chars = "abcdefghijklmnopqrstuvwxyz";
76 Default.Groups.resize(1); 78 Default.Groups.resize(1);
77 Default.Groups[0].Description = "Lower case Latin letters"; 79 Default.Groups[0].Description = "Lower case Latin letters";
78 Default.Groups[0].Characters.resize(Chars.size()); 80 Default.Groups[0].Characters.resize(Chars.size());
79 for (unsigned int i=0; i<Chars.size(); i++) { 81 for (unsigned int i=0; i<Chars.size(); i++) {
80 Default.Groups[0].Characters[i].Text = Chars[i]; 82 Default.Groups[0].Characters[i].Text = Chars[i];
81 Default.Groups[0].Characters[i].Display = Chars[i]; 83 Default.Groups[0].Characters[i].Display = Chars[i];
82 } 84 }
83} 85}
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,140 +1,140 @@
1// Alphabet.cpp 1// Alphabet.cpp
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2001-2002 David Ward 5// Copyright (c) 2001-2002 David Ward
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9#include "Alphabet.h" 9#include "Alphabet.h"
10#include "AlphabetMap.h" 10#include "AlphabetMap.h"
11 11
12//#include <iostream> 12//#include <iostream>
13//WinCE doesn't have iostream! 13//WinCE doesn't have iostream!
14 14
15using namespace Dasher; 15using namespace Dasher;
16using namespace std; 16using namespace std;
17 17
18 18
19CAlphabet::CAlphabet() : m_Groups(0), m_DefaultEncoding(Opts::Western), m_Orientation(Opts::LeftToRight) 19CAlphabet::CAlphabet() : m_DefaultEncoding(Opts::Western), m_Orientation(Opts::LeftToRight), m_Groups(0)
20{ 20{
21 m_Characters.push_back(""); 21 m_Characters.push_back("");
22 m_Display.push_back(""); 22 m_Display.push_back("");
23 m_Colours.push_back(""); 23 m_Colours.push_back("");
24 m_Foreground.push_back(""); 24 m_Foreground.push_back("");
25 m_Group.push_back(0); 25 m_Group.push_back(0);
26} 26}
27 27
28 28
29void CAlphabet::GetSymbols(vector<symbol>* Symbols, string* Input, bool IsMore) 29void CAlphabet::GetSymbols(vector<symbol>* Symbols, string* Input, bool IsMore)
30{ 30{
31 string Tmp; 31 string Tmp;
32 symbol CurSymbol=0, TmpSymbol=0; 32 symbol CurSymbol=0, TmpSymbol=0;
33 bool KeyIsPrefix; 33 bool KeyIsPrefix;
34 int z= Input->size(); 34 // int z= Input->size();
35 int extras; 35 int extras;
36 unsigned int bit; 36 unsigned int bit;
37 37
38 for (unsigned int i=0; i<Input->size(); i++) { 38 for (unsigned int i=0; i<Input->size(); i++) {
39 39
40 Tmp = (*Input)[i]; 40 Tmp = (*Input)[i];
41 41
42 /* The string we've been given is in UTF-8. The symbols are 42 /* The string we've been given is in UTF-8. The symbols are
43 also in UTF-8, so we need to pass the entire UTF-8 character 43 also in UTF-8, so we need to pass the entire UTF-8 character
44 which may be several bytes long. RFC 2279 describes this 44 which may be several bytes long. RFC 2279 describes this
45 encoding */ 45 encoding */
46 46
47 if ((*Input)[i] & 0x80) { // Character is more than 1 byte long 47 if ((*Input)[i] & 0x80) { // Character is more than 1 byte long
48 extras = 1; 48 extras = 1;
49 for (bit = 0x20; ((*Input)[i] & bit) != 0; bit >>= 1) 49 for (bit = 0x20; ((*Input)[i] & bit) != 0; bit >>= 1)
50 extras++; 50 extras++;
51 if (extras > 5) { 51 if (extras > 5) {
52 } // Malformed character 52 } // Malformed character
53 while (extras-->0) { 53 while (extras-->0) {
54 Tmp += (*Input)[++i]; 54 Tmp += (*Input)[++i];
55 } 55 }
56 } 56 }
57 57
58 CurSymbol = TextMap.Get(Tmp, &KeyIsPrefix); 58 CurSymbol = TextMap.Get(Tmp, &KeyIsPrefix);
59 59
60 if (KeyIsPrefix) { 60 if (KeyIsPrefix) {
61 CurSymbol = 0; 61 CurSymbol = 0;
62 for (; i<Input->size(); i++) { 62 for (; i<Input->size(); i++) {
63 63
64 Tmp += (*Input)[i]; 64 Tmp += (*Input)[i];
65 65
66 TmpSymbol = TextMap.Get(Tmp, &KeyIsPrefix); 66 TmpSymbol = TextMap.Get(Tmp, &KeyIsPrefix);
67 if (TmpSymbol>0) { 67 if (TmpSymbol>0) {
68 CurSymbol = TmpSymbol; 68 CurSymbol = TmpSymbol;
69 } 69 }
70 if (!KeyIsPrefix) { 70 if (!KeyIsPrefix) {
71 if (CurSymbol!=0) { 71 if (CurSymbol!=0) {
72 Symbols->push_back(CurSymbol); 72 Symbols->push_back(CurSymbol);
73 } else { 73 } else {
74 i -= Tmp.size()-1; 74 i -= Tmp.size()-1;
75 //Tmp.erase(Tmp.begin(), Tmp.end()); 75 //Tmp.erase(Tmp.begin(), Tmp.end());
76 Tmp = ""; 76 Tmp = "";
77 } 77 }
78 break; 78 break;
79 } 79 }
80 } 80 }
81 } else { 81 } else {
82 if (CurSymbol!=0) 82 if (CurSymbol!=0)
83 Symbols->push_back(CurSymbol); 83 Symbols->push_back(CurSymbol);
84 } 84 }
85 } 85 }
86 86
87 if (IsMore) 87 if (IsMore)
88 if (KeyIsPrefix) 88 if (KeyIsPrefix)
89 *Input = Tmp; 89 *Input = Tmp;
90 else 90 else
91 *Input = ""; 91 *Input = "";
92 else 92 else
93 if (KeyIsPrefix) 93 if (KeyIsPrefix)
94 Symbols->push_back(CurSymbol); 94 Symbols->push_back(CurSymbol);
95} 95}
96 96
97 97
98// add single char to the character set 98// add single char to the character set
99void CAlphabet::AddChar(const string NewCharacter, const string Display, const string Colour, const string Foreground) 99void CAlphabet::AddChar(const string NewCharacter, const string Display, const string Colour, const string Foreground)
100{ 100{
101 m_Characters.push_back(NewCharacter); 101 m_Characters.push_back(NewCharacter);
102 m_Display.push_back(Display); 102 m_Display.push_back(Display);
103 m_Colours.push_back(Colour); 103 m_Colours.push_back(Colour);
104 m_Foreground.push_back(Foreground); 104 m_Foreground.push_back(Foreground);
105 m_Group.push_back(m_Groups); 105 m_Group.push_back(m_Groups);
106 106
107 symbol ThisSymbol = m_Characters.size()-1; 107 symbol ThisSymbol = m_Characters.size()-1;
108 TextMap.Add(NewCharacter, ThisSymbol); 108 TextMap.Add(NewCharacter, ThisSymbol);
109} 109}
110 110
111 111
112void CAlphabet::StartNewGroup() 112void CAlphabet::StartNewGroup()
113{ 113{
114 m_Groups++; 114 m_Groups++;
115} 115}
116 116
117 117
118// diagnostic dump of character set 118// diagnostic dump of character set
119void CAlphabet::dump() const { 119void CAlphabet::dump() const {
120// TODO 120// TODO
121/* 121/*
122 dchar deb[256]; 122 dchar deb[256];
123 unsigned int i; 123 unsigned int i;
124 for (i=1;i<m_vtCharacters.size();i++) { 124 for (i=1;i<m_vtCharacters.size();i++) {
125 //wsprintf(deb,TEXT("%d %c %d\n"),i,m_vtCharacters[i],m_viGroup[i]); // Windows specific 125 //wsprintf(deb,TEXT("%d %c %d\n"),i,m_vtCharacters[i],m_viGroup[i]); // Windows specific
126 Usprintf(deb,TEXT("%d %c %d\n"),i,m_vtCharacters[i],m_viGroup[i]); 126 Usprintf(deb,TEXT("%d %c %d\n"),i,m_vtCharacters[i],m_viGroup[i]);
127 DebugOutput(deb); 127 DebugOutput(deb);
128 } 128 }
129*/ 129*/
130} 130}
131 131
132int CAlphabet::GetTextColour(symbol Symbol) 132int CAlphabet::GetTextColour(symbol Symbol)
133{ 133{
134 std::string TextColour=m_Foreground[Symbol]; 134 std::string TextColour=m_Foreground[Symbol];
135 if (TextColour != "") { 135 if (TextColour != "") {
136 return atoi(TextColour.c_str()); 136 return atoi(TextColour.c_str());
137 } else { 137 } else {
138 return 0; 138 return 0;
139 } 139 }
140} 140}
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,86 +1,86 @@
1// AlphabetMap.cpp 1// AlphabetMap.cpp
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9#include "AlphabetMap.h" 9#include "AlphabetMap.h"
10 10
11using namespace Dasher; 11using namespace Dasher;
12using namespace std; 12using namespace std;
13 13
14alphabet_map::alphabet_map(unsigned int InitialTableSize) 14alphabet_map::alphabet_map(unsigned int InitialTableSize)
15 : Undefined(0), HashTable(InitialTableSize<<1) 15 : HashTable(InitialTableSize<<1), Undefined(0)
16{ 16{
17 Entries.reserve(InitialTableSize); 17 Entries.reserve(InitialTableSize);
18} 18}
19 19
20 20
21void alphabet_map::Add(const string& Key, symbol Value) 21void alphabet_map::Add(const string& Key, symbol Value)
22{ 22{
23 RecursiveAdd(Key, Value, false); 23 RecursiveAdd(Key, Value, false);
24} 24}
25 25
26 26
27void alphabet_map::RecursiveAdd(const string& Key, symbol Value, bool PrefixFlag) 27void alphabet_map::RecursiveAdd(const string& Key, symbol Value, bool PrefixFlag)
28{ 28{
29 Entry*& HashEntry = HashTable[Hash(Key)]; 29 Entry*& HashEntry = HashTable[Hash(Key)];
30 30
31 // Loop through Entries with the correct Hash value. 31 // Loop through Entries with the correct Hash value.
32 for (Entry* i = HashEntry; i; i=i->Next) { 32 for (Entry* i = HashEntry; i; i=i->Next) {
33 if (i->Key==Key) { 33 if (i->Key==Key) {
34 if (PrefixFlag) { 34 if (PrefixFlag) {
35 // Just tagging - don't change symbol. Recurse if necessary 35 // Just tagging - don't change symbol. Recurse if necessary
36 i->KeyIsPrefix = true; 36 i->KeyIsPrefix = true;
37 if (Key.size()>1) 37 if (Key.size()>1)
38 RecursiveAdd(Key.substr(Key.size()-1), Undefined, true); 38 RecursiveAdd(Key.substr(Key.size()-1), Undefined, true);
39 } else { 39 } else {
40 // Add symbol and leave 40 // Add symbol and leave
41 i->Symbol = Value; 41 i->Symbol = Value;
42 } 42 }
43 return; 43 return;
44 } 44 }
45 } 45 }
46 46
47 // When hash table gets 1/2 full... 47 // When hash table gets 1/2 full...
48 // (no I haven't optimised when to resize) 48 // (no I haven't optimised when to resize)
49 if (Entries.size()<<1 >= HashTable.size()) { 49 if (Entries.size()<<1 >= HashTable.size()) {
50 // Double up all the storage 50 // Double up all the storage
51 HashTable.clear(); 51 HashTable.clear();
52 HashTable.resize(Entries.size()<<2); 52 HashTable.resize(Entries.size()<<2);
53 Entries.reserve(Entries.size()<<1); 53 Entries.reserve(Entries.size()<<1);
54 54
55 // Rehash as the pointers will all be mangled. 55 // Rehash as the pointers will all be mangled.
56 for (uint j=0; j<Entries.size(); j++) { 56 for (uint j=0; j<Entries.size(); j++) {
57 Entry*& HashEntry2 = HashTable[Hash(Entries[j].Key)]; 57 Entry*& HashEntry2 = HashTable[Hash(Entries[j].Key)];
58 Entries[j].Next = HashEntry2; 58 Entries[j].Next = HashEntry2;
59 HashEntry2 = &Entries[j]; 59 HashEntry2 = &Entries[j];
60 } 60 }
61 61
62 // Have to recall this function as the key's hash needs recalculating 62 // Have to recall this function as the key's hash needs recalculating
63 RecursiveAdd(Key, Value, PrefixFlag); 63 RecursiveAdd(Key, Value, PrefixFlag);
64 return; 64 return;
65 } 65 }
66 66
67 Entries.push_back(Entry(Key, Value, HashEntry)); 67 Entries.push_back(Entry(Key, Value, HashEntry));
68 HashEntry = &Entries.back(); 68 HashEntry = &Entries.back();
69} 69}
70 70
71 71
72symbol alphabet_map::Get(const string& Key, bool* KeyIsPrefix) const 72symbol alphabet_map::Get(const string& Key, bool* KeyIsPrefix) const
73{ 73{
74 // Loop through Entries with the correct Hash value. 74 // Loop through Entries with the correct Hash value.
75 for (Entry* i = HashTable[Hash(Key)]; i; i=i->Next) { 75 for (Entry* i = HashTable[Hash(Key)]; i; i=i->Next) {
76 if (i->Key==Key) { 76 if (i->Key==Key) {
77 if (KeyIsPrefix!=0) 77 if (KeyIsPrefix!=0)
78 *KeyIsPrefix = i->KeyIsPrefix; 78 *KeyIsPrefix = i->KeyIsPrefix;
79 return i->Symbol; 79 return i->Symbol;
80 } 80 }
81 } 81 }
82 82
83 if (KeyIsPrefix!=0) 83 if (KeyIsPrefix!=0)
84 *KeyIsPrefix = false; 84 *KeyIsPrefix = false;
85 return Undefined; 85 return Undefined;
86} 86}
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
@@ -1,111 +1,111 @@
1// AlphabetMap.h 1// AlphabetMap.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10/* 10/*
11If I were just using GCC, which comes with the CGI "STL" implementation, I would 11If I were just using GCC, which comes with the CGI "STL" implementation, I would
12use hash_map (which isn't part of the ANSI/ISO standard C++ STL, but hey it's nice). 12use hash_map (which isn't part of the ANSI/ISO standard C++ STL, but hey it's nice).
13Using a plain map is just too slow for training on large files (or it is with certain 13Using a plain map is just too slow for training on large files (or it is with certain
14STL implementations). I'm sure training could be made much faster still, but that's 14STL implementations). I'm sure training could be made much faster still, but that's
15another matter... 15another matter...
16 16
17While I could (and probably should) get a hash_map for VC++ from 17While I could (and probably should) get a hash_map for VC++ from
18http://www.stlport.org I thought it would be nicer if people didn't have 18http://www.stlport.org I thought it would be nicer if people didn't have
19to download extra stuff and then have to get it working alongside the STL 19to download extra stuff and then have to get it working alongside the STL
20with VC++, especially for just one small part of Dasher. 20with VC++, especially for just one small part of Dasher.
21 21
22The result is this: 22The result is this:
23*************************************************** 23***************************************************
24very much thrown together to get Dasher out ASAP. 24very much thrown together to get Dasher out ASAP.
25*************************************************** 25***************************************************
26It is deliberately not like an STL container. 26It is deliberately not like an STL container.
27However, as it has a tiny interface, it should still be easy to replace. 27However, as it has a tiny interface, it should still be easy to replace.
28Sorry if this seems really unprofressional. 28Sorry if this seems really unprofressional.
29 29
30Replacing it might be a good idea. On the other hand it could be customised 30Replacing it might be a good idea. On the other hand it could be customised
31to the needs of the alphabet, so that it works faster. For example, 31to the needs of the alphabet, so that it works faster. For example,
32currently if I have a string "asdf", it might be that "a" is checked 32currently if I have a string "asdf", it might be that "a" is checked
33then "as" is checked then "asd" is checked. I shouldn't need to keep 33then "as" is checked then "asd" is checked. I shouldn't need to keep
34rehashing the leading characters. I plan to fix that here. Doing so with 34rehashing the leading characters. I plan to fix that here. Doing so with
35a standard hash_map would be hard. 35a standard hash_map would be hard.
36 36
37 37
38Usage: 38Usage:
39alphabet_map MyMap(NumberOfEntriesWeExpect); // Can omit NumberOfEntriesWeExpect 39alphabet_map MyMap(NumberOfEntriesWeExpect); // Can omit NumberOfEntriesWeExpect
40MyMap.add("asdf", 15); 40MyMap.add("asdf", 15);
41symbol i = MyMap.get("asdf") // i=15 41symbol i = MyMap.get("asdf") // i=15
42symbol j = MyMap.get("fdsa") // j=0 42symbol j = MyMap.get("fdsa") // j=0
43 43
44You can't remove items once they are added as Dasher has no need for that. 44You can't remove items once they are added as Dasher has no need for that.
45 45
46IAM 08/2002 46IAM 08/2002
47*/ 47*/
48 48
49#ifndef __AlphabetMap_h__ 49#ifndef __AlphabetMap_h__
50#define __AlphabetMap_h__ 50#define __AlphabetMap_h__
51 51
52#include "MSVC_Unannoy.h" 52#include "MSVC_Unannoy.h"
53#include <vector> 53#include <vector>
54#include <string> 54#include <string>
55 55
56#include "DasherTypes.h" 56#include "DasherTypes.h"
57 57
58namespace Dasher {class alphabet_map;} 58namespace Dasher {class alphabet_map;}
59class Dasher::alphabet_map 59class Dasher::alphabet_map
60{ 60{
61public: 61public:
62 alphabet_map(uint InitialTableSize=255); 62 alphabet_map(uint InitialTableSize=255);
63 void Add(const std::string& Key, symbol Value); 63 void Add(const std::string& Key, symbol Value);
64 symbol Get(const std::string& Key, bool* KeyIsPrefix=0) const; 64 symbol Get(const std::string& Key, bool* KeyIsPrefix=0) const;
65 65
66private: 66private:
67 class Entry 67 class Entry
68 { 68 {
69 public: 69 public:
70 Entry(std::string Key, symbol Symbol, Entry* Next) 70 Entry(std::string Key, symbol Symbol, Entry* Next)
71 : Key(Key), Symbol(Symbol), Next(Next), KeyIsPrefix(false) {} 71 : Key(Key), KeyIsPrefix(false), Symbol(Symbol), Next(Next) {}
72 72
73 std::string Key; 73 std::string Key;
74 bool KeyIsPrefix; 74 bool KeyIsPrefix;
75 symbol Symbol; 75 symbol Symbol;
76 Entry* Next; 76 Entry* Next;
77 }; 77 };
78 78
79 void RecursiveAdd(const std::string& Key, symbol Value, bool PrefixFlag); 79 void RecursiveAdd(const std::string& Key, symbol Value, bool PrefixFlag);
80 80
81 // A standard hash -- could try and research something specific. 81 // A standard hash -- could try and research something specific.
82 inline uint Hash(const std::string& Input) const { 82 inline uint Hash(const std::string& Input) const {
83 uint Result = 0; 83 uint Result = 0;
84 84
85 typedef std::string::const_iterator CI; 85 typedef std::string::const_iterator CI;
86 CI Cur = Input.begin(); 86 CI Cur = Input.begin();
87 CI end = Input.end(); 87 CI end = Input.end();
88 88
89 while (Cur!=end) Result = (Result<<1)^*Cur++; 89 while (Cur!=end) Result = (Result<<1)^*Cur++;
90 Result %= HashTable.size(); 90 Result %= HashTable.size();
91 91
92 return Result; 92 return Result;
93 /* 93 /*
94 if (Input.size()==1) // Speedup for ASCII text 94 if (Input.size()==1) // Speedup for ASCII text
95 return Input[0]; 95 return Input[0];
96 96
97 for (int i=0; i<Input.size(); i++) 97 for (int i=0; i<Input.size(); i++)
98 Result = (Result<<1)^Input[i]; 98 Result = (Result<<1)^Input[i];
99 99
100 100
101 return Result%HashTable.size(); 101 return Result%HashTable.size();
102 */ 102 */
103 } 103 }
104 104
105 std::vector<Entry> Entries; 105 std::vector<Entry> Entries;
106 std::vector<Entry*> HashTable; 106 std::vector<Entry*> HashTable;
107 const symbol Undefined; 107 const symbol Undefined;
108}; 108};
109 109
110 110
111#endif /* #ifndef __AlphabetMap_h__ */ 111#endif /* #ifndef __AlphabetMap_h__ */
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,163 +1,163 @@
1//! Class definition for an edit box 1//! Class definition for an edit box
2// DashEdit.h 2// DashEdit.h
3// 3//
4///////////////////////////////////////////////////////////////////////////// 4/////////////////////////////////////////////////////////////////////////////
5// 5//
6// Copyright (c) 2002 Iain Murray 6// Copyright (c) 2002 Iain Murray
7// 7//
8///////////////////////////////////////////////////////////////////////////// 8/////////////////////////////////////////////////////////////////////////////
9 9
10/* 10/*
11An abstract DashEditbox class is described here. 11An abstract DashEditbox class is described here.
12An implementation will handle interaction between Dasher and an actual Edit control. 12An implementation will handle interaction between Dasher and an actual Edit control.
13e.g. - output characters to the edit control 13e.g. - output characters to the edit control
14 - tapping on the edit box updates the Dasher display 14 - tapping on the edit box updates the Dasher display
15*/ 15*/
16 16
17#ifndef __DashEdit_h__ 17#ifndef __DashEdit_h__
18#define __DashEdit_h__ 18#define __DashEdit_h__
19 19
20#include "DasherWidgetInterface.h" 20#include "DasherWidgetInterface.h"
21 21
22namespace Dasher {class CDashEditbox;} 22namespace Dasher {class CDashEditbox;}
23class Dasher::CDashEditbox 23class Dasher::CDashEditbox
24{ 24{
25public: 25public:
26 CDashEditbox() : m_iFlushed(0), m_DasherInterface(0), m_dirty(false) {} 26 CDashEditbox() : m_dirty(false),m_iFlushed(0), m_DasherInterface(0) {}
27 27
28 //! Provide the Editbox with a widget interface 28 //! Provide the Editbox with a widget interface
29 virtual void SetInterface(CDasherWidgetInterface* DasherInterface) {m_DasherInterface = DasherInterface;} 29 virtual void SetInterface(CDasherWidgetInterface* DasherInterface) {m_DasherInterface = DasherInterface;}
30 30
31 //! Write some buffered output to a file 31 //! Write some buffered output to a file
32 virtual void write_to_file()=0; 32 virtual void write_to_file()=0;
33 33
34 //! Set the number of flushed characters 34 //! Set the number of flushed characters
35 // 35 //
36 //! Set the number of flushed characters to an arbitrary number. 36 //! Set the number of flushed characters to an arbitrary number.
37 //! Usually used to reset it to 0 after unflushing 37 //! Usually used to reset it to 0 after unflushing
38 void set_flushed(int i) {m_iFlushed=i;} 38 void set_flushed(int i) {m_iFlushed=i;}
39 39
40 //! Provide context from the editbox for the core 40 //! Provide context from the editbox for the core
41 // 41 //
42 //! Provide the context at the current position within the editbox to 42 //! Provide the context at the current position within the editbox to
43 //! the core. Set str to up to max characters before 43 //! the core. Set str to up to max characters before
44 //! the cursor position within the editbox. 44 //! the cursor position within the editbox.
45 virtual void get_new_context(std::string& str, int max)=0; 45 virtual void get_new_context(std::string& str, int max)=0;
46 46
47 //! Delete flushed text from the editbox 47 //! Delete flushed text from the editbox
48 virtual inline void unflush()=0; 48 virtual void unflush()=0;
49 49
50 //! Enter a the character Symbol into the text box 50 //! Enter a the character Symbol into the text box
51 virtual void output(symbol Symbol)=0; 51 virtual void output(symbol Symbol)=0;
52 52
53 //! Delete the previous symbol from the text box 53 //! Delete the previous symbol from the text box
54 virtual void deletetext()=0; 54 virtual void deletetext()=0;
55 55
56 //! Enter a character into the text box and remember that it is flushed 56 //! Enter a character into the text box and remember that it is flushed
57 // 57 //
58 //! Output the character and increment m_iFlushed. When unflush is 58 //! Output the character and increment m_iFlushed. When unflush is
59 //! called, remove the previous m_iFlushed characters 59 //! called, remove the previous m_iFlushed characters
60 virtual void flush(symbol Symbol)=0; 60 virtual void flush(symbol Symbol)=0;
61 61
62 // File I/O (optional) 62 // File I/O (optional)
63 63
64 //! If Value is true, timestamp all new files (optional) 64 //! If Value is true, timestamp all new files (optional)
65 // 65 //
66 //! If switched on, all new files should be timestamped, either in the 66 //! If switched on, all new files should be timestamped, either in the
67 //! filename or in file metadata 67 //! filename or in file metadata
68 virtual void TimeStampNewFiles(bool Value) {} 68 virtual void TimeStampNewFiles(bool ) {}
69 69
70 //! Return true if any text has been modified since the last save (optional) 70 //! Return true if any text has been modified since the last save (optional)
71 bool IsDirty() {return m_dirty;} 71 bool IsDirty() {return m_dirty;}
72 72
73 //! Generate a new file (optional) 73 //! Generate a new file (optional)
74 // 74 //
75 //! New file - provide a file save dialogue and return the filename in 75 //! New file - provide a file save dialogue and return the filename in
76 //! filename, or provide a blank filename and present a file 76 //! filename, or provide a blank filename and present a file
77 //! save dialogue when Save() is called 77 //! save dialogue when Save() is called
78 virtual void New(const std::string& filename) {}; // filename can be "", but you cannot call Save() without having set a filename. 78 virtual void New(const std::string& ) {}; // filename can be "", but you cannot call Save() without having set a filename.
79 79
80 //! Open a file (optional) 80 //! Open a file (optional)
81 // 81 //
82 //! Provide a file open dialogue and set filename to the 82 //! Provide a file open dialogue and set filename to the
83 //! filename. Return true if a file is chosen and opened successfully, 83 //! filename. Return true if a file is chosen and opened successfully,
84 //! false otherwise 84 //! false otherwise
85 virtual bool Open(const std::string& filename) {return false;}; 85 virtual bool Open(const std::string& ) {return false;};
86 86
87 //! Open a file and append to it (optional) 87 //! Open a file and append to it (optional)
88 // 88 //
89 //! Provide a file open dialogue and set filename to the 89 //! Provide a file open dialogue and set filename to the
90 //! filename. The file will then have any new text appended to it. 90 //! filename. The file will then have any new text appended to it.
91 //! Return true if a file is chosen and opened successfully, false 91 //! Return true if a file is chosen and opened successfully, false
92 //! otherwise 92 //! otherwise
93 virtual bool OpenAppendMode(const std::string& filename) {return false;}; 93 virtual bool OpenAppendMode(const std::string& ) {return false;};
94 //! Save a file as a provided filename (optional) 94 //! Save a file as a provided filename (optional)
95 // 95 //
96 //! Provide a file save dialogue and set filename to the 96 //! Provide a file save dialogue and set filename to the
97 //! filename. Return true if a file is chosen and saved successfully, 97 //! filename. Return true if a file is chosen and saved successfully,
98 //! false otherwise 98 //! false otherwise
99 virtual bool SaveAs(const std::string& filename) {return false;}; 99 virtual bool SaveAs(const std::string& ) {return false;};
100 100
101 //! Save the current file (optional) 101 //! Save the current file (optional)
102 // 102 //
103 //! Save file to the current filename. If there is no current filename, 103 //! Save file to the current filename. If there is no current filename,
104 //! or if saving fails, return false 104 //! or if saving fails, return false
105 virtual bool Save() {return false;}; // returns false if there is no filename set, or if saving fails 105 virtual bool Save() {return false;}; // returns false if there is no filename set, or if saving fails
106 106
107 // Clipboard (optional) 107 // Clipboard (optional)
108 //! Cut selected text (optional) 108 //! Cut selected text (optional)
109 // 109 //
110 //! Copy the selected text to the clipboard and remove it from the 110 //! Copy the selected text to the clipboard and remove it from the
111 //! editbox 111 //! editbox
112 virtual void Cut() {}; 112 virtual void Cut() {};
113 113
114 //! Copy selected text (optional) 114 //! Copy selected text (optional)
115 // 115 //
116 //! Copy the selected text to the clipboard 116 //! Copy the selected text to the clipboard
117 virtual void Copy() {}; 117 virtual void Copy() {};
118 118
119 //! Copy all text (optional) 119 //! Copy all text (optional)
120 // 120 //
121 //! Copy all text in the editbox to the clipboard 121 //! Copy all text in the editbox to the clipboard
122 virtual void CopyAll() {}; 122 virtual void CopyAll() {};
123 123
124 //! Paste text from clipboard (optional) 124 //! Paste text from clipboard (optional)
125 // 125 //
126 //! Paste text from the clipboard into the editbox at the current 126 //! Paste text from the clipboard into the editbox at the current
127 //! position 127 //! position
128 virtual void Paste() {}; 128 virtual void Paste() {};
129 129
130 //! Select all text in the editbox (optional) 130 //! Select all text in the editbox (optional)
131 virtual void SelectAll() {}; 131 virtual void SelectAll() {};
132 132
133 //! Clear all text from the editbox (REQUIRED) 133 //! Clear all text from the editbox (REQUIRED)
134 virtual void Clear()=0; // Must at least be able to clear edit box 134 virtual void Clear()=0; // Must at least be able to clear edit box
135 135
136 //! Set the file encoding 136 //! Set the file encoding
137 // 137 //
138 //! Set the file encoding to the provided encoding Encoding. 138 //! Set the file encoding to the provided encoding Encoding.
139 //! The editbox is responsible for saving the file in the encoding 139 //! The editbox is responsible for saving the file in the encoding
140 //! desired by the user. As Dasher is internally UTF8, it may well be 140 //! desired by the user. As Dasher is internally UTF8, it may well be
141 //! necessary to save in an alternative format based on locale and OS. 141 //! necessary to save in an alternative format based on locale and OS.
142 virtual void SetEncoding(Opts::FileEncodingFormats Encoding)=0; 142 virtual void SetEncoding(Opts::FileEncodingFormats Encoding)=0;
143 143
144 //! Set the font used in the editbox 144 //! Set the font used in the editbox
145 // 145 //
146 //! Set the font used in the editbox to Name and size 146 //! Set the font used in the editbox to Name and size
147 //! Size (in points) 147 //! Size (in points)
148 virtual void SetFont(std::string Name, long Size)=0; 148 virtual void SetFont(std::string Name, long Size)=0;
149 149
150// TODO sort relationship between CDashEditbox and derived classes 150// TODO sort relationship between CDashEditbox and derived classes
151protected: 151protected:
152 //! Have the contents of the editbox been altered since the last save? 152 //! Have the contents of the editbox been altered since the last save?
153 bool m_dirty; 153 bool m_dirty;
154 154
155 //! Record the number of characters that have been flushed 155 //! Record the number of characters that have been flushed
156 int m_iFlushed; // how many characters have been flushed 156 int m_iFlushed; // how many characters have been flushed
157 157
158 //! Pointer to a DasherWidgetInterface for communication with the core 158 //! Pointer to a DasherWidgetInterface for communication with the core
159 CDasherWidgetInterface* m_DasherInterface; 159 CDasherWidgetInterface* m_DasherInterface;
160}; 160};
161 161
162 162
163#endif /* #ifndef __DashEdit_h__ */ 163#endif /* #ifndef __DashEdit_h__ */
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,636 +1,653 @@
1// DasherInterface.cpp 1// DasherInterface.cpp
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10 10
11#include "DasherInterface.h" 11#include "DasherInterface.h"
12//#include "EnglishAlphabet.h" 12//#include "EnglishAlphabet.h"
13#include "CustomAlphabet.h" 13#include "CustomAlphabet.h"
14#include "DasherViewSquare.h" 14#include "DasherViewSquare.h"
15#include "PPMLanguageModel.h" 15#include "PPMLanguageModel.h"
16#include <iostream> 16#include <iostream>
17namespace { 17namespace {
18 #include "stdio.h" 18 #include "stdio.h"
19} 19}
20using namespace Dasher; 20using namespace Dasher;
21using namespace std; 21using namespace std;
22 22
23 23
24const string CDasherInterface::EmptyString = ""; 24const string CDasherInterface::EmptyString = "";
25 25
26 26
27CDasherInterface::CDasherInterface() 27CDasherInterface::CDasherInterface()
28 : m_DashEditbox(0), m_DasherScreen(0), m_LanguageModel(0), TrainContext(0), m_Alphabet(0), 28 : m_Alphabet(0),
29 m_DasherModel(0), m_DasherView(0), AlphabetID(""), LanguageModelID(-1), ViewID(-1), 29 m_LanguageModel(0),
30 m_MaxBitRate(-1), m_Orientation(Opts::LeftToRight), m_SettingsStore(0), m_SettingsUI(0), 30 m_DasherModel(0),
31 m_UserLocation("usr_"), m_SystemLocation("sys_"), m_AlphIO(0), m_TrainFile(""), 31 m_DashEditbox(0),
32 m_DasherFont(""), m_EditFont(""), m_EditFontSize(0), m_DrawKeyboard(false) 32 m_DasherScreen(0),
33 m_DasherView(0),
34 m_SettingsStore(0),
35 m_SettingsUI(0),
36 m_AlphIO(0),
37 TrainContext(0),
38 AlphabetID(""),
39 LanguageModelID(-1),
40 ViewID(-1),
41 m_MaxBitRate(-1),
42 m_DrawKeyboard(false),
43 m_Orientation(Opts::LeftToRight),
44 m_UserLocation("usr_"),
45 m_SystemLocation("sys_"),
46 m_TrainFile(""),
47 m_DasherFont(""),
48 m_EditFont(""),
49 m_EditFontSize(0)
33{ 50{
34} 51}
35 52
36 53
37CDasherInterface::~CDasherInterface() 54CDasherInterface::~CDasherInterface()
38{ 55{
39 if (m_LanguageModel) 56 if (m_LanguageModel)
40 m_LanguageModel->ReleaseNodeContext(TrainContext); 57 m_LanguageModel->ReleaseNodeContext(TrainContext);
41 delete m_DasherModel; // The order of some of these deletions matters 58 delete m_DasherModel; // The order of some of these deletions matters
42 delete m_LanguageModel; // eg DasherModel has a pointer to LanguageModel. 59 delete m_LanguageModel; // eg DasherModel has a pointer to LanguageModel.
43 delete m_Alphabet; // DM baulks if LM is deleted before it is. 60 delete m_Alphabet; // DM baulks if LM is deleted before it is.
44 delete m_DasherView; 61 delete m_DasherView;
45 // Do NOT delete Edit box or Screen. This class did not create them. 62 // Do NOT delete Edit box or Screen. This class did not create them.
46} 63}
47 64
48 65
49void CDasherInterface::SetSettingsStore(CSettingsStore* SettingsStore) 66void CDasherInterface::SetSettingsStore(CSettingsStore* SettingsStore)
50{ 67{
51 delete m_SettingsStore; 68 delete m_SettingsStore;
52 m_SettingsStore = SettingsStore; 69 m_SettingsStore = SettingsStore;
53 this->SettingsDefaults(m_SettingsStore); 70 this->SettingsDefaults(m_SettingsStore);
54} 71}
55 72
56 73
57void CDasherInterface::SetSettingsUI(CDasherSettingsInterface* SettingsUI) 74void CDasherInterface::SetSettingsUI(CDasherSettingsInterface* SettingsUI)
58{ 75{
59 delete m_SettingsUI; 76 delete m_SettingsUI;
60 m_SettingsUI = SettingsUI; 77 m_SettingsUI = SettingsUI;
61 //this->SettingsDefaults(m_SettingsStore); 78 //this->SettingsDefaults(m_SettingsStore);
62 m_SettingsUI->SettingsDefaults(m_SettingsStore); 79 m_SettingsUI->SettingsDefaults(m_SettingsStore);
63} 80}
64 81
65 82
66void CDasherInterface::SetUserLocation(std::string UserLocation) 83void CDasherInterface::SetUserLocation(std::string UserLocation)
67{ 84{
68 // Nothing clever updates. (At the moment) it is assumed that 85 // Nothing clever updates. (At the moment) it is assumed that
69 // this is set before anything much happens and that it does 86 // this is set before anything much happens and that it does
70 // not require changing. 87 // not require changing.
71 m_UserLocation = UserLocation; 88 m_UserLocation = UserLocation;
72 if (m_Alphabet!=0) 89 if (m_Alphabet!=0)
73 m_TrainFile = m_UserLocation + m_Alphabet->GetTrainingFile(); 90 m_TrainFile = m_UserLocation + m_Alphabet->GetTrainingFile();
74} 91}
75 92
76 93
77void CDasherInterface::SetSystemLocation(std::string SystemLocation) 94void CDasherInterface::SetSystemLocation(std::string SystemLocation)
78{ 95{
79 // Nothing clever updates. (At the moment) it is assumed that 96 // Nothing clever updates. (At the moment) it is assumed that
80 // this is set before anything much happens and that it does 97 // this is set before anything much happens and that it does
81 // not require changing. 98 // not require changing.
82 m_SystemLocation = SystemLocation; 99 m_SystemLocation = SystemLocation;
83} 100}
84 101
85 102
86void CDasherInterface::CreateDasherModel() 103void CDasherInterface::CreateDasherModel()
87{ 104{
88 105
89 if (m_DashEditbox!=0 && m_LanguageModel!=0) { 106 if (m_DashEditbox!=0 && m_LanguageModel!=0) {
90 delete m_DasherModel; 107 delete m_DasherModel;
91 m_DasherModel = new CDasherModel(m_DashEditbox, m_LanguageModel, m_Dimensions); 108 m_DasherModel = new CDasherModel(m_DashEditbox, m_LanguageModel, m_Dimensions);
92 if (m_MaxBitRate>=0) 109 if (m_MaxBitRate>=0)
93 m_DasherModel->SetMaxBitrate(m_MaxBitRate); 110 m_DasherModel->SetMaxBitrate(m_MaxBitRate);
94 if (ViewID!=-1) 111 if (ViewID!=-1)
95 ChangeView(ViewID); 112 ChangeView(ViewID);
96 } 113 }
97 114
98 115
99} 116}
100 117
101 118
102void CDasherInterface::Start() 119void CDasherInterface::Start()
103{ 120{
104 if (m_DasherModel!=0) 121 if (m_DasherModel!=0)
105 m_DasherModel->Start(); 122 m_DasherModel->Start();
106} 123}
107 124
108 125
109void CDasherInterface::PauseAt(int MouseX, int MouseY) 126void CDasherInterface::PauseAt(int MouseX, int MouseY)
110{ 127{
111 if (m_DasherView!=0) 128 if (m_DasherView!=0)
112 m_DasherView->FlushAt(MouseX, MouseY); 129 m_DasherView->FlushAt(MouseX, MouseY);
113 if (m_DashEditbox!=0) { 130 if (m_DashEditbox!=0) {
114 m_DashEditbox->write_to_file(); 131 m_DashEditbox->write_to_file();
115 if (m_CopyAllOnStop) 132 if (m_CopyAllOnStop)
116 m_DashEditbox->CopyAll(); 133 m_DashEditbox->CopyAll();
117 } 134 }
118} 135}
119 136
120 137
121void CDasherInterface::Unpause(unsigned long Time) 138void CDasherInterface::Unpause(unsigned long Time)
122{ 139{
123 if (m_DashEditbox!=0) 140 if (m_DashEditbox!=0)
124 m_DashEditbox->unflush(); 141 m_DashEditbox->unflush();
125 if (m_DasherModel!=0) 142 if (m_DasherModel!=0)
126 m_DasherModel->Reset_framerate(Time); 143 m_DasherModel->Reset_framerate(Time);
127} 144}
128 145
129 146
130void CDasherInterface::Redraw() 147void CDasherInterface::Redraw()
131{ 148{
132 149
133 if (m_DasherView!=0) { 150 if (m_DasherView!=0) {
134 m_DasherView->Render(); 151 m_DasherView->Render();
135 m_DasherView->Display(); 152 m_DasherView->Display();
136 } 153 }
137 154
138} 155}
139 156
140 157
141void CDasherInterface::TapOn(int MouseX, int MouseY, unsigned long Time) 158void CDasherInterface::TapOn(int MouseX, int MouseY, unsigned long Time)
142{ 159{
143 if (m_DasherView!=0) { 160 if (m_DasherView!=0) {
144 m_DasherView->TapOnDisplay(MouseX, MouseY, Time); 161 m_DasherView->TapOnDisplay(MouseX, MouseY, Time);
145 m_DasherView->Render(); 162 m_DasherView->Render();
146 if (m_DrawMouse==true) { 163 if (m_DrawMouse==true) {
147 m_DasherView->DrawMouse(MouseX, MouseY); 164 m_DasherView->DrawMouse(MouseX, MouseY);
148 } 165 }
149 if (m_DrawKeyboard==true) { 166 if (m_DrawKeyboard==true) {
150 m_DasherView->DrawKeyboard(); 167 m_DasherView->DrawKeyboard();
151 } 168 }
152 m_DasherView->Display(); 169 m_DasherView->Display();
153 } 170 }
154 if (m_DasherModel!=0) 171 if (m_DasherModel!=0)
155 m_DasherModel->NewFrame(Time); 172 m_DasherModel->NewFrame(Time);
156} 173}
157 174
158 175
159void CDasherInterface::ChangeAlphabet(const std::string& NewAlphabetID) 176void CDasherInterface::ChangeAlphabet(const std::string& NewAlphabetID)
160{ 177{
161 if (m_SettingsUI!=0) 178 if (m_SettingsUI!=0)
162 m_SettingsUI->ChangeAlphabet(NewAlphabetID); 179 m_SettingsUI->ChangeAlphabet(NewAlphabetID);
163 if (m_SettingsStore!=0) 180 if (m_SettingsStore!=0)
164 m_SettingsStore->SetStringOption(Keys::ALPHABET_ID, NewAlphabetID); 181 m_SettingsStore->SetStringOption(Keys::ALPHABET_ID, NewAlphabetID);
165 182
166 AlphabetID = NewAlphabetID; 183 AlphabetID = NewAlphabetID;
167 if (!m_AlphIO) 184 if (!m_AlphIO)
168 m_AlphIO = new CAlphIO(m_SystemLocation, m_UserLocation); 185 m_AlphIO = new CAlphIO(m_SystemLocation, m_UserLocation);
169 CAlphIO::AlphInfo Info = m_AlphIO->GetInfo(NewAlphabetID); 186 CAlphIO::AlphInfo Info = m_AlphIO->GetInfo(NewAlphabetID);
170 187
171 CAlphabet* old = m_Alphabet; 188 CAlphabet* old = m_Alphabet;
172 m_Alphabet = new CCustomAlphabet(Info); 189 m_Alphabet = new CCustomAlphabet(Info);
173 190
174 // Apply options from alphabet 191 // Apply options from alphabet
175 192
176 m_TrainFile = m_UserLocation + m_Alphabet->GetTrainingFile(); 193 m_TrainFile = m_UserLocation + m_Alphabet->GetTrainingFile();
177 194
178 // Recreate widgets and language model 195 // Recreate widgets and language model
179 if (m_DashEditbox!=0) 196 if (m_DashEditbox!=0)
180 m_DashEditbox->SetInterface(this); 197 m_DashEditbox->SetInterface(this);
181 if (m_DasherScreen!=0) 198 if (m_DasherScreen!=0)
182 m_DasherScreen->SetInterface(this); 199 m_DasherScreen->SetInterface(this);
183 if (LanguageModelID!=-1 || m_LanguageModel) 200 if (LanguageModelID!=-1 || m_LanguageModel)
184 ChangeLanguageModel(LanguageModelID); 201 ChangeLanguageModel(LanguageModelID);
185 202
186 delete old; // only delete old alphabet after telling all other objects not to use it 203 delete old; // only delete old alphabet after telling all other objects not to use it
187 204
188 Start(); 205 Start();
189 206
190 // We can only change the orientation after we have called 207 // We can only change the orientation after we have called
191 // Start, as this will prompt a redraw, which will fail if the 208 // Start, as this will prompt a redraw, which will fail if the
192 // model hasn't been updated for the new alphabet 209 // model hasn't been updated for the new alphabet
193 210
194 if (m_Orientation==Opts::Alphabet) 211 if (m_Orientation==Opts::Alphabet)
195 ChangeOrientation(Opts::Alphabet); 212 ChangeOrientation(Opts::Alphabet);
196 213
197 Redraw(); 214 Redraw();
198} 215}
199 216
200 217
201void CDasherInterface::ChangeMaxBitRate(double NewMaxBitRate) 218void CDasherInterface::ChangeMaxBitRate(double NewMaxBitRate)
202{ 219{
203 m_MaxBitRate = NewMaxBitRate; 220 m_MaxBitRate = NewMaxBitRate;
204 221
205 if (m_DasherModel!=0) 222 if (m_DasherModel!=0)
206 m_DasherModel->SetMaxBitrate(m_MaxBitRate); 223 m_DasherModel->SetMaxBitrate(m_MaxBitRate);
207 if (m_SettingsUI!=0) 224 if (m_SettingsUI!=0)
208 m_SettingsUI->ChangeMaxBitRate(m_MaxBitRate); 225 m_SettingsUI->ChangeMaxBitRate(m_MaxBitRate);
209 if (m_SettingsStore!=0) 226 if (m_SettingsStore!=0)
210 m_SettingsStore->SetLongOption(Keys::MAX_BITRATE_TIMES100, long(m_MaxBitRate*100) ); 227 m_SettingsStore->SetLongOption(Keys::MAX_BITRATE_TIMES100, long(m_MaxBitRate*100) );
211 228
212 if (m_DrawKeyboard==true && m_DasherView!=NULL) { 229 if (m_DrawKeyboard==true && m_DasherView!=NULL) {
213 m_DasherView->DrawKeyboard(); 230 m_DasherView->DrawKeyboard();
214 } 231 }
215} 232}
216 233
217 234
218void CDasherInterface::ChangeLanguageModel(unsigned int NewLanguageModelID) 235void CDasherInterface::ChangeLanguageModel(unsigned int NewLanguageModelID)
219{ 236{
220 LanguageModelID = NewLanguageModelID; 237 LanguageModelID = NewLanguageModelID;
221 if (m_Alphabet!=0) { 238 if (m_Alphabet!=0) {
222 if (m_LanguageModel) 239 if (m_LanguageModel)
223 m_LanguageModel->ReleaseNodeContext(TrainContext); 240 m_LanguageModel->ReleaseNodeContext(TrainContext);
224 TrainContext = 0; 241 TrainContext = 0;
225 delete m_DasherModel; // Have to delete DasherModel, or removing its LanguageModel will confuse it 242 delete m_DasherModel; // Have to delete DasherModel, or removing its LanguageModel will confuse it
226 m_DasherModel = 0; 243 m_DasherModel = 0;
227 delete m_LanguageModel; 244 delete m_LanguageModel;
228 // TODO Use LanguageModelID to decide which model to use 245 // TODO Use LanguageModelID to decide which model to use
229 m_LanguageModel = new CPPMLanguageModel(m_Alphabet,1<<10); 246 m_LanguageModel = new CPPMLanguageModel(m_Alphabet,1<<10);
230 TrainContext = m_LanguageModel->GetRootNodeContext(); 247 TrainContext = m_LanguageModel->GetRootNodeContext();
231 string T = m_Alphabet->GetTrainingFile(); 248 string T = m_Alphabet->GetTrainingFile();
232 TrainFile(m_SystemLocation+T); 249 TrainFile(m_SystemLocation+T);
233 TrainFile(m_UserLocation+T); 250 TrainFile(m_UserLocation+T);
234 CreateDasherModel(); 251 CreateDasherModel();
235 } 252 }
236} 253}
237 254
238 255
239void CDasherInterface::ChangeScreen() 256void CDasherInterface::ChangeScreen()
240{ 257{
241 if (m_DasherView!=0) { 258 if (m_DasherView!=0) {
242 m_DasherView->ChangeScreen(m_DasherScreen); 259 m_DasherView->ChangeScreen(m_DasherScreen);
243 } else { 260 } else {
244 if (ViewID!=-1) 261 if (ViewID!=-1)
245 ChangeView(ViewID); 262 ChangeView(ViewID);
246 } 263 }
247} 264}
248 265
249 266
250void CDasherInterface::ChangeScreen(CDasherScreen* NewScreen) 267void CDasherInterface::ChangeScreen(CDasherScreen* NewScreen)
251{ 268{
252 m_DasherScreen = NewScreen; 269 m_DasherScreen = NewScreen;
253 m_DasherScreen->SetFont(m_DasherFont); 270 m_DasherScreen->SetFont(m_DasherFont);
254 m_DasherScreen->SetInterface(this); 271 m_DasherScreen->SetInterface(this);
255 ChangeScreen(); 272 ChangeScreen();
256 Redraw(); 273 Redraw();
257} 274}
258 275
259 276
260void CDasherInterface::ChangeView(unsigned int NewViewID) 277void CDasherInterface::ChangeView(unsigned int NewViewID)
261{ 278{
262 //TODO Use DasherViewID 279 //TODO Use DasherViewID
263 ViewID = NewViewID; 280 ViewID = NewViewID;
264 if (m_DasherScreen!=0 && m_DasherModel!=0) { 281 if (m_DasherScreen!=0 && m_DasherModel!=0) {
265 delete m_DasherView; 282 delete m_DasherView;
266 if (m_Orientation==Opts::Alphabet) 283 if (m_Orientation==Opts::Alphabet)
267 m_DasherView = new CDasherViewSquare(m_DasherScreen, *m_DasherModel, GetAlphabetOrientation()); 284 m_DasherView = new CDasherViewSquare(m_DasherScreen, *m_DasherModel, GetAlphabetOrientation());
268 else 285 else
269 m_DasherView = new CDasherViewSquare(m_DasherScreen, *m_DasherModel, m_Orientation); 286 m_DasherView = new CDasherViewSquare(m_DasherScreen, *m_DasherModel, m_Orientation);
270 } 287 }
271} 288}
272 289
273 290
274void CDasherInterface::ChangeOrientation(Opts::ScreenOrientations Orientation) 291void CDasherInterface::ChangeOrientation(Opts::ScreenOrientations Orientation)
275{ 292{
276 m_Orientation = Orientation; 293 m_Orientation = Orientation;
277 if (m_DasherView!=0) { 294 if (m_DasherView!=0) {
278 if (Orientation==Opts::Alphabet) 295 if (Orientation==Opts::Alphabet)
279 m_DasherView->ChangeOrientation(GetAlphabetOrientation()); 296 m_DasherView->ChangeOrientation(GetAlphabetOrientation());
280 else 297 else
281 m_DasherView->ChangeOrientation(Orientation); 298 m_DasherView->ChangeOrientation(Orientation);
282 } 299 }
283 if (m_SettingsUI!=0) 300 if (m_SettingsUI!=0)
284 m_SettingsUI->ChangeOrientation(Orientation); 301 m_SettingsUI->ChangeOrientation(Orientation);
285 if (m_SettingsStore!=0) 302 if (m_SettingsStore!=0)
286 m_SettingsStore->SetLongOption(Keys::SCREEN_ORIENTATION, Orientation); 303 m_SettingsStore->SetLongOption(Keys::SCREEN_ORIENTATION, Orientation);
287} 304}
288 305
289 306
290void CDasherInterface::SetFileEncoding(Opts::FileEncodingFormats Encoding) 307void CDasherInterface::SetFileEncoding(Opts::FileEncodingFormats Encoding)
291{ 308{
292 if (m_SettingsUI!=0) 309 if (m_SettingsUI!=0)
293 m_SettingsUI->SetFileEncoding(Encoding); 310 m_SettingsUI->SetFileEncoding(Encoding);
294 if (m_SettingsStore!=0) 311 if (m_SettingsStore!=0)
295 m_SettingsStore->SetLongOption(Keys::FILE_ENCODING, Encoding); 312 m_SettingsStore->SetLongOption(Keys::FILE_ENCODING, Encoding);
296 if (m_DashEditbox) 313 if (m_DashEditbox)
297 m_DashEditbox->SetEncoding(Encoding); 314 m_DashEditbox->SetEncoding(Encoding);
298} 315}
299 316
300 317
301void CDasherInterface::ShowToolbar(bool Value) 318void CDasherInterface::ShowToolbar(bool Value)
302{ 319{
303 if (m_SettingsUI!=0) 320 if (m_SettingsUI!=0)
304 m_SettingsUI->ShowToolbar(Value); 321 m_SettingsUI->ShowToolbar(Value);
305 if (m_SettingsStore!=0) 322 if (m_SettingsStore!=0)
306 m_SettingsStore->SetBoolOption(Keys::SHOW_TOOLBAR, Value); 323 m_SettingsStore->SetBoolOption(Keys::SHOW_TOOLBAR, Value);
307} 324}
308 325
309 326
310void CDasherInterface::ShowToolbarText(bool Value) 327void CDasherInterface::ShowToolbarText(bool Value)
311{ 328{
312 if (m_SettingsUI!=0) 329 if (m_SettingsUI!=0)
313 m_SettingsUI->ShowToolbarText(Value); 330 m_SettingsUI->ShowToolbarText(Value);
314 if (m_SettingsStore!=0) 331 if (m_SettingsStore!=0)
315 m_SettingsStore->SetBoolOption(Keys::SHOW_TOOLBAR_TEXT, Value); 332 m_SettingsStore->SetBoolOption(Keys::SHOW_TOOLBAR_TEXT, Value);
316} 333}
317 334
318 335
319void CDasherInterface::ShowToolbarLargeIcons(bool Value) 336void CDasherInterface::ShowToolbarLargeIcons(bool Value)
320{ 337{
321 if (m_SettingsUI!=0) 338 if (m_SettingsUI!=0)
322 m_SettingsUI->ShowToolbarLargeIcons(Value); 339 m_SettingsUI->ShowToolbarLargeIcons(Value);
323 if (m_SettingsStore!=0) 340 if (m_SettingsStore!=0)
324 m_SettingsStore->SetBoolOption(Keys::SHOW_LARGE_ICONS, Value); 341 m_SettingsStore->SetBoolOption(Keys::SHOW_LARGE_ICONS, Value);
325} 342}
326 343
327 344
328void CDasherInterface::ShowSpeedSlider(bool Value) 345void CDasherInterface::ShowSpeedSlider(bool Value)
329{ 346{
330 if (m_SettingsUI!=0) 347 if (m_SettingsUI!=0)
331 m_SettingsUI->ShowSpeedSlider(Value); 348 m_SettingsUI->ShowSpeedSlider(Value);
332 if (m_SettingsStore!=0) 349 if (m_SettingsStore!=0)
333 m_SettingsStore->SetBoolOption(Keys::SHOW_SLIDER, Value); 350 m_SettingsStore->SetBoolOption(Keys::SHOW_SLIDER, Value);
334} 351}
335 352
336 353
337void CDasherInterface::FixLayout(bool Value) 354void CDasherInterface::FixLayout(bool Value)
338{ 355{
339 if (m_SettingsUI!=0) 356 if (m_SettingsUI!=0)
340 m_SettingsUI->FixLayout(Value); 357 m_SettingsUI->FixLayout(Value);
341 if (m_SettingsStore!=0) 358 if (m_SettingsStore!=0)
342 m_SettingsStore->SetBoolOption(Keys::FIX_LAYOUT, Value); 359 m_SettingsStore->SetBoolOption(Keys::FIX_LAYOUT, Value);
343} 360}
344 361
345 362
346void CDasherInterface::TimeStampNewFiles(bool Value) 363void CDasherInterface::TimeStampNewFiles(bool Value)
347{ 364{
348 if (m_SettingsUI!=0) 365 if (m_SettingsUI!=0)
349 m_SettingsUI->TimeStampNewFiles(Value); 366 m_SettingsUI->TimeStampNewFiles(Value);
350 if (m_SettingsStore!=0) 367 if (m_SettingsStore!=0)
351 m_SettingsStore->SetBoolOption(Keys::TIME_STAMP, Value); 368 m_SettingsStore->SetBoolOption(Keys::TIME_STAMP, Value);
352 if (m_DashEditbox!=0) 369 if (m_DashEditbox!=0)
353 m_DashEditbox->TimeStampNewFiles(Value); 370 m_DashEditbox->TimeStampNewFiles(Value);
354} 371}
355 372
356 373
357void CDasherInterface::CopyAllOnStop(bool Value) 374void CDasherInterface::CopyAllOnStop(bool Value)
358{ 375{
359 m_CopyAllOnStop = Value; 376 m_CopyAllOnStop = Value;
360 if (m_SettingsUI!=0) 377 if (m_SettingsUI!=0)
361 m_SettingsUI->CopyAllOnStop(Value); 378 m_SettingsUI->CopyAllOnStop(Value);
362 if (m_SettingsStore!=0) 379 if (m_SettingsStore!=0)
363 m_SettingsStore->SetBoolOption(Keys::COPY_ALL_ON_STOP, Value); 380 m_SettingsStore->SetBoolOption(Keys::COPY_ALL_ON_STOP, Value);
364} 381}
365 382
366void CDasherInterface::DrawMouse(bool Value) 383void CDasherInterface::DrawMouse(bool Value)
367{ 384{
368 m_DrawMouse = Value; 385 m_DrawMouse = Value;
369 if (m_SettingsUI!=0) 386 if (m_SettingsUI!=0)
370 m_SettingsUI->DrawMouse(Value); 387 m_SettingsUI->DrawMouse(Value);
371 if (m_SettingsStore!=0) 388 if (m_SettingsStore!=0)
372 m_SettingsStore->SetBoolOption(Keys::DRAW_MOUSE, Value); 389 m_SettingsStore->SetBoolOption(Keys::DRAW_MOUSE, Value);
373} 390}
374 391
375void CDasherInterface::StartOnSpace(bool Value) 392void CDasherInterface::StartOnSpace(bool Value)
376{ 393{
377 m_StartSpace = Value; 394 m_StartSpace = Value;
378 if (m_SettingsUI!=0) 395 if (m_SettingsUI!=0)
379 m_SettingsUI->StartOnSpace(Value); 396 m_SettingsUI->StartOnSpace(Value);
380 if (m_SettingsStore!=0) 397 if (m_SettingsStore!=0)
381 m_SettingsStore->SetBoolOption(Keys::START_SPACE, Value); 398 m_SettingsStore->SetBoolOption(Keys::START_SPACE, Value);
382} 399}
383 400
384void CDasherInterface::StartOnLeft(bool Value) 401void CDasherInterface::StartOnLeft(bool Value)
385{ 402{
386 m_StartLeft = Value; 403 m_StartLeft = Value;
387 if (m_SettingsUI!=0) 404 if (m_SettingsUI!=0)
388 m_SettingsUI->StartOnLeft(Value); 405 m_SettingsUI->StartOnLeft(Value);
389 if (m_SettingsStore!=0) 406 if (m_SettingsStore!=0)
390 m_SettingsStore->SetBoolOption(Keys::START_MOUSE, Value); 407 m_SettingsStore->SetBoolOption(Keys::START_MOUSE, Value);
391} 408}
392 409
393void CDasherInterface::KeyControl(bool Value) 410void CDasherInterface::KeyControl(bool Value)
394{ 411{
395 m_KeyControl = Value; 412 m_KeyControl = Value;
396 if (m_SettingsUI!=0) 413 if (m_SettingsUI!=0)
397 m_SettingsUI->KeyControl(Value); 414 m_SettingsUI->KeyControl(Value);
398 if (m_SettingsStore!=0) 415 if (m_SettingsStore!=0)
399 m_SettingsStore->SetBoolOption(Keys::KEY_CONTROL, Value); 416 m_SettingsStore->SetBoolOption(Keys::KEY_CONTROL, Value);
400} 417}
401 418
402void CDasherInterface::WindowPause(bool Value) 419void CDasherInterface::WindowPause(bool Value)
403{ 420{
404 m_KeyControl = Value; 421 m_KeyControl = Value;
405 if (m_SettingsUI!=0) 422 if (m_SettingsUI!=0)
406 m_SettingsUI->WindowPause(Value); 423 m_SettingsUI->WindowPause(Value);
407 if (m_SettingsStore!=0) 424 if (m_SettingsStore!=0)
408 m_SettingsStore->SetBoolOption(Keys::WINDOW_PAUSE, Value); 425 m_SettingsStore->SetBoolOption(Keys::WINDOW_PAUSE, Value);
409} 426}
410 427
411void CDasherInterface::SetEditFont(string Name, long Size) 428void CDasherInterface::SetEditFont(string Name, long Size)
412{ 429{
413 m_EditFont = Name; 430 m_EditFont = Name;
414 m_EditFontSize = Size; 431 m_EditFontSize = Size;
415 if (m_DashEditbox) 432 if (m_DashEditbox)
416 m_DashEditbox->SetFont(Name, Size); 433 m_DashEditbox->SetFont(Name, Size);
417 if (m_SettingsUI!=0) 434 if (m_SettingsUI!=0)
418 m_SettingsUI->SetEditFont(Name, Size); 435 m_SettingsUI->SetEditFont(Name, Size);
419 if (m_SettingsStore!=0) { 436 if (m_SettingsStore!=0) {
420 m_SettingsStore->SetStringOption(Keys::EDIT_FONT, Name); 437 m_SettingsStore->SetStringOption(Keys::EDIT_FONT, Name);
421 m_SettingsStore->SetLongOption(Keys::EDIT_FONT_SIZE, Size); 438 m_SettingsStore->SetLongOption(Keys::EDIT_FONT_SIZE, Size);
422 } 439 }
423} 440}
424 441
425 442
426void CDasherInterface::SetDasherFont(string Name) 443void CDasherInterface::SetDasherFont(string Name)
427{ 444{
428 if (m_SettingsStore!=0) 445 if (m_SettingsStore!=0)
429 m_SettingsStore->SetStringOption(Keys::DASHER_FONT, Name); 446 m_SettingsStore->SetStringOption(Keys::DASHER_FONT, Name);
430 m_DasherFont = Name; 447 m_DasherFont = Name;
431 if (m_DasherScreen!=0) 448 if (m_DasherScreen!=0)
432 m_DasherScreen->SetFont(Name); 449 m_DasherScreen->SetFont(Name);
433 Redraw(); 450 Redraw();
434} 451}
435 452
436void CDasherInterface::SetDasherFontSize(FontSize fontsize) 453void CDasherInterface::SetDasherFontSize(FontSize fontsize)
437{ 454{
438 if (m_SettingsStore!=0) 455 if (m_SettingsStore!=0)
439 m_SettingsStore->SetLongOption(Keys::DASHER_FONTSIZE, fontsize); 456 m_SettingsStore->SetLongOption(Keys::DASHER_FONTSIZE, fontsize);
440 if (m_DasherScreen!=0) { 457 if (m_DasherScreen!=0) {
441 m_DasherScreen->SetFontSize(fontsize); 458 m_DasherScreen->SetFontSize(fontsize);
442 } 459 }
443 Redraw(); 460 Redraw();
444} 461}
445 462
446void CDasherInterface::SetDasherDimensions(bool Value) 463void CDasherInterface::SetDasherDimensions(bool Value)
447{ 464{
448 m_Dimensions=Value; 465 m_Dimensions=Value;
449 if (m_SettingsStore!=0) 466 if (m_SettingsStore!=0)
450 m_SettingsStore->SetBoolOption(Keys::DASHER_DIMENSIONS, Value); 467 m_SettingsStore->SetBoolOption(Keys::DASHER_DIMENSIONS, Value);
451 if (m_DasherModel!=0) { 468 if (m_DasherModel!=0) {
452 m_DasherModel->Set_dimensions(Value); 469 m_DasherModel->Set_dimensions(Value);
453 } 470 }
454 if (m_SettingsUI!=0) { 471 if (m_SettingsUI!=0) {
455 m_SettingsUI->SetDasherDimensions(Value); 472 m_SettingsUI->SetDasherDimensions(Value);
456 } 473 }
457} 474}
458 475
459 476
460unsigned int CDasherInterface::GetNumberSymbols() 477unsigned int CDasherInterface::GetNumberSymbols()
461{ 478{
462 if (m_Alphabet!=0) 479 if (m_Alphabet!=0)
463 return m_Alphabet->GetNumberSymbols(); 480 return m_Alphabet->GetNumberSymbols();
464 else 481 else
465 return 0; 482 return 0;
466} 483}
467 484
468 485
469const string& CDasherInterface::GetDisplayText(symbol Symbol) 486const string& CDasherInterface::GetDisplayText(symbol Symbol)
470{ 487{
471 if (m_Alphabet!=0) 488 if (m_Alphabet!=0)
472 return m_Alphabet->GetDisplayText(Symbol); 489 return m_Alphabet->GetDisplayText(Symbol);
473 else 490 else
474 return EmptyString; 491 return EmptyString;
475} 492}
476 493
477 494
478const string& CDasherInterface::GetEditText(symbol Symbol) 495const string& CDasherInterface::GetEditText(symbol Symbol)
479{ 496{
480 if (m_Alphabet!=0) 497 if (m_Alphabet!=0)
481 return m_Alphabet->GetText(Symbol); 498 return m_Alphabet->GetText(Symbol);
482 else 499 else
483 return EmptyString; 500 return EmptyString;
484} 501}
485 502
486int CDasherInterface::GetTextColour(symbol Symbol) 503int CDasherInterface::GetTextColour(symbol Symbol)
487{ 504{
488 if (m_Alphabet!=0) 505 if (m_Alphabet!=0)
489 return m_Alphabet->GetTextColour(Symbol); 506 return m_Alphabet->GetTextColour(Symbol);
490 else 507 else
491 return 0; 508 return 0;
492} 509}
493 510
494 511
495Opts::ScreenOrientations CDasherInterface::GetAlphabetOrientation() 512Opts::ScreenOrientations CDasherInterface::GetAlphabetOrientation()
496{ 513{
497 return m_Alphabet->GetOrientation(); 514 return m_Alphabet->GetOrientation();
498} 515}
499 516
500 517
501Opts::AlphabetTypes CDasherInterface::GetAlphabetType() 518Opts::AlphabetTypes CDasherInterface::GetAlphabetType()
502{ 519{
503 return m_Alphabet->GetType(); 520 return m_Alphabet->GetType();
504} 521}
505 522
506 523
507const std::string& CDasherInterface::GetTrainFile() 524const std::string& CDasherInterface::GetTrainFile()
508{ 525{
509 return m_TrainFile; 526 return m_TrainFile;
510} 527}
511 528
512 529
513void CDasherInterface::GetAlphabets(std::vector< std::string >* AlphabetList) 530void CDasherInterface::GetAlphabets(std::vector< std::string >* AlphabetList)
514{ 531{
515 if (!m_AlphIO) 532 if (!m_AlphIO)
516 m_AlphIO = new CAlphIO(m_SystemLocation, m_UserLocation); 533 m_AlphIO = new CAlphIO(m_SystemLocation, m_UserLocation);
517 m_AlphIO->GetAlphabets(AlphabetList); 534 m_AlphIO->GetAlphabets(AlphabetList);
518} 535}
519 536
520 537
521const CAlphIO::AlphInfo& CDasherInterface::GetInfo(const std::string& AlphID) 538const CAlphIO::AlphInfo& CDasherInterface::GetInfo(const std::string& AlphID)
522{ 539{
523 if (!m_AlphIO) 540 if (!m_AlphIO)
524 m_AlphIO = new CAlphIO(m_SystemLocation, m_UserLocation); 541 m_AlphIO = new CAlphIO(m_SystemLocation, m_UserLocation);
525 542
526 return m_AlphIO->GetInfo(AlphID); 543 return m_AlphIO->GetInfo(AlphID);
527} 544}
528 545
529 546
530void CDasherInterface::SetInfo(const CAlphIO::AlphInfo& NewInfo) 547void CDasherInterface::SetInfo(const CAlphIO::AlphInfo& NewInfo)
531{ 548{
532 if (!m_AlphIO) 549 if (!m_AlphIO)
533 m_AlphIO = new CAlphIO(m_SystemLocation, m_UserLocation); 550 m_AlphIO = new CAlphIO(m_SystemLocation, m_UserLocation);
534 551
535 m_AlphIO->SetInfo(NewInfo); 552 m_AlphIO->SetInfo(NewInfo);
536} 553}
537 554
538 555
539void CDasherInterface::DeleteAlphabet(const std::string& AlphID) 556void CDasherInterface::DeleteAlphabet(const std::string& AlphID)
540{ 557{
541 if (!m_AlphIO) 558 if (!m_AlphIO)
542 m_AlphIO = new CAlphIO(m_SystemLocation, m_UserLocation); 559 m_AlphIO = new CAlphIO(m_SystemLocation, m_UserLocation);
543 560
544 m_AlphIO->Delete(AlphID); 561 m_AlphIO->Delete(AlphID);
545} 562}
546 563
547 564
548void CDasherInterface::ChangeEdit() 565void CDasherInterface::ChangeEdit()
549{ 566{
550 CreateDasherModel(); 567 CreateDasherModel();
551 if (m_DasherModel!=0) 568 if (m_DasherModel!=0)
552 m_DasherModel->Start(); 569 m_DasherModel->Start();
553 if (m_DasherView!=0) 570 if (m_DasherView!=0)
554 m_DasherView->Render(); 571 m_DasherView->Render();
555} 572}
556 573
557 574
558void CDasherInterface::ChangeEdit(CDashEditbox* NewEdit) 575void CDasherInterface::ChangeEdit(CDashEditbox* NewEdit)
559{ 576{
560 m_DashEditbox = NewEdit; 577 m_DashEditbox = NewEdit;
561 m_DashEditbox->SetFont(m_EditFont, m_EditFontSize); 578 m_DashEditbox->SetFont(m_EditFont, m_EditFontSize);
562 m_DashEditbox->SetInterface(this); 579 m_DashEditbox->SetInterface(this);
563 if (m_SettingsStore!=0) 580 if (m_SettingsStore!=0)
564 m_DashEditbox->TimeStampNewFiles(m_SettingsStore->GetBoolOption(Keys::TIME_STAMP)); 581 m_DashEditbox->TimeStampNewFiles(m_SettingsStore->GetBoolOption(Keys::TIME_STAMP));
565 m_DashEditbox->New(""); 582 m_DashEditbox->New("");
566 ChangeEdit(); 583 ChangeEdit();
567} 584}
568 585
569 586
570void CDasherInterface::Train(string* TrainString, bool IsMore) 587void CDasherInterface::Train(string* TrainString, bool IsMore)
571{ 588{
572 m_LanguageModel->LearnText(TrainContext, TrainString, IsMore); 589 m_LanguageModel->LearnText(TrainContext, TrainString, IsMore);
573 return; 590 return;
574} 591}
575 592
576 593
577/* 594/*
578 I've used C style I/O because I found that C++ style I/O bloated 595 I've used C style I/O because I found that C++ style I/O bloated
579 the Win32 code enormously. The overhead of loading the buffer into 596 the Win32 code enormously. The overhead of loading the buffer into
580 the string instead of reading straight into a string seems to be 597 the string instead of reading straight into a string seems to be
581 negligible compared to huge requirements elsewhere. 598 negligible compared to huge requirements elsewhere.
582*/ 599*/
583void CDasherInterface::TrainFile(string Filename) 600void CDasherInterface::TrainFile(string Filename)
584{ 601{
585 if (Filename=="") 602 if (Filename=="")
586 return; 603 return;
587 604
588 FILE* InputFile; 605 FILE* InputFile;
589 if ( (InputFile = fopen(Filename.c_str(), "r")) == (FILE*)0) 606 if ( (InputFile = fopen(Filename.c_str(), "r")) == (FILE*)0)
590 return; 607 return;
591 608
592 const int BufferSize = 1024; 609 const int BufferSize = 1024;
593 char InputBuffer[BufferSize]; 610 char InputBuffer[BufferSize];
594 string StringBuffer; 611 string StringBuffer;
595 int NumberRead; 612 int NumberRead;
596 613
597 do { 614 do {
598 NumberRead = fread(InputBuffer, 1, BufferSize-1, InputFile); 615 NumberRead = fread(InputBuffer, 1, BufferSize-1, InputFile);
599 InputBuffer[NumberRead] = '\0'; 616 InputBuffer[NumberRead] = '\0';
600 StringBuffer += InputBuffer; 617 StringBuffer += InputBuffer;
601 if (NumberRead == (BufferSize-1)) { 618 if (NumberRead == (BufferSize-1)) {
602 m_LanguageModel->LearnText(TrainContext, &StringBuffer, true); 619 m_LanguageModel->LearnText(TrainContext, &StringBuffer, true);
603 } else { 620 } else {
604 m_LanguageModel->LearnText(TrainContext, &StringBuffer, false); 621 m_LanguageModel->LearnText(TrainContext, &StringBuffer, false);
605 } 622 }
606 } while (NumberRead==BufferSize-1); 623 } while (NumberRead==BufferSize-1);
607 624
608 fclose(InputFile); 625 fclose(InputFile);
609} 626}
610 627
611void CDasherInterface::GetFontSizes(std::vector<int> *FontSizes) 628void CDasherInterface::GetFontSizes(std::vector<int> *FontSizes)
612{ 629{
613 FontSizes->push_back(20); 630 FontSizes->push_back(20);
614 FontSizes->push_back(14); 631 FontSizes->push_back(14);
615 FontSizes->push_back(11); 632 FontSizes->push_back(11);
616 FontSizes->push_back(40); 633 FontSizes->push_back(40);
617 FontSizes->push_back(28); 634 FontSizes->push_back(28);
618 FontSizes->push_back(22); 635 FontSizes->push_back(22);
619 FontSizes->push_back(80); 636 FontSizes->push_back(80);
620 FontSizes->push_back(56); 637 FontSizes->push_back(56);
621 FontSizes->push_back(44); 638 FontSizes->push_back(44);
622} 639}
623 640
624 641
625double CDasherInterface::GetCurCPM() 642double CDasherInterface::GetCurCPM()
626{ 643{
627 // 644 //
628 return 0; 645 return 0;
629} 646}
630 647
631 648
632double CDasherInterface::GetCurFPS() 649double CDasherInterface::GetCurFPS()
633{ 650{
634 // 651 //
635 return 0; 652 return 0;
636} 653}
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
@@ -1,170 +1,170 @@
1// DasherInterface.h 1// DasherInterface.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10 10
11#ifndef __DasherInterface_h__ 11#ifndef __DasherInterface_h__
12#define __DasherInterface_h__ 12#define __DasherInterface_h__
13 13
14// TODO - there is a list of things to be configurable in my notes 14// TODO - there is a list of things to be configurable in my notes
15// Check that everything that is not self-contained within the GUI is covered. 15// Check that everything that is not self-contained within the GUI is covered.
16 16
17#include "MSVC_Unannoy.h" 17#include "MSVC_Unannoy.h"
18#include "NoClones.h" 18#include "NoClones.h"
19 19
20#include "DasherWidgetInterface.h" 20#include "DasherWidgetInterface.h"
21#include "DasherAppInterface.h" 21#include "DasherAppInterface.h"
22#include "DasherSettingsInterface.h" 22#include "DasherSettingsInterface.h"
23 23
24#include "DasherScreen.h" 24#include "DasherScreen.h"
25#include "Alphabet.h" 25#include "Alphabet.h"
26#include "AlphIO.h" 26#include "AlphIO.h"
27#include "LanguageModel.h" 27#include "LanguageModel.h"
28#include "DasherModel.h" 28#include "DasherModel.h"
29#include "DashEdit.h" 29#include "DashEdit.h"
30#include "DasherView.h" 30#include "DasherView.h"
31 31
32#include "MSVC_Unannoy.h" 32#include "MSVC_Unannoy.h"
33#include <map> 33#include <map>
34 34
35namespace Dasher {class CDasherInterface;} 35namespace Dasher {class CDasherInterface;}
36class Dasher::CDasherInterface : private NoClones, 36class Dasher::CDasherInterface : private NoClones,
37 public CDasherWidgetInterface, public CDasherAppInterface, public CDasherSettingsInterface 37 public CDasherWidgetInterface, public CDasherAppInterface, public CDasherSettingsInterface
38{ 38{
39public: 39public:
40 CDasherInterface(); 40 CDasherInterface();
41 ~CDasherInterface(); 41 virtual ~CDasherInterface();
42 42
43 //! Tell the core which CSettingsStore should be used 43 //! Tell the core which CSettingsStore should be used
44 void SetSettingsStore(CSettingsStore* SettingsStore); 44 void SetSettingsStore(CSettingsStore* SettingsStore);
45 45
46 //! Tell the core which CDasherSettingsInterface should be used 46 //! Tell the core which CDasherSettingsInterface should be used
47 // 47 //
48 //! Provide a pointer to an instance of CDasherSettingsInterface in 48 //! Provide a pointer to an instance of CDasherSettingsInterface in
49 //! order to allow for platform dependent configuration of certain 49 //! order to allow for platform dependent configuration of certain
50 //! options 50 //! options
51 void SetSettingsUI(CDasherSettingsInterface* SettingsUI); 51 void SetSettingsUI(CDasherSettingsInterface* SettingsUI);
52 52
53 //! Set the path for user specific configuration and files 53 //! Set the path for user specific configuration and files
54 void SetUserLocation(std::string UserLocation); 54 void SetUserLocation(std::string UserLocation);
55 55
56 //! Set the path for system-wide configuration and files 56 //! Set the path for system-wide configuration and files
57 void SetSystemLocation(std::string SystemLocation); 57 void SetSystemLocation(std::string SystemLocation);
58 58
59 // Widget Interface 59 // Widget Interface
60 // ----------------------------------------------------- 60 // -----------------------------------------------------
61 void Start(); 61 void Start();
62 62
63 void TapOn(int MouseX, int MouseY, unsigned long Time); // Times in milliseconds 63 void TapOn(int MouseX, int MouseY, unsigned long Time); // Times in milliseconds
64 void PauseAt(int MouseX, int MouseY); // are required to make 64 void PauseAt(int MouseX, int MouseY); // are required to make
65 void Unpause(unsigned long Time); // Dasher run at the 65 void Unpause(unsigned long Time); // Dasher run at the
66 void Redraw(); // correct speed. 66 void Redraw(); // correct speed.
67 67
68 void ChangeScreen(); // The widgets need to tell the engine when they have been 68 void ChangeScreen(); // The widgets need to tell the engine when they have been
69 void ChangeEdit(); // affected by external interaction 69 void ChangeEdit(); // affected by external interaction
70 70
71 unsigned int GetNumberSymbols(); // These are needed so widgets know 71 unsigned int GetNumberSymbols(); // These are needed so widgets know
72 const std::string& GetDisplayText(symbol Symbol); // how to render the alphabet. All 72 const std::string& GetDisplayText(symbol Symbol); // how to render the alphabet. All
73 const std::string& GetEditText(symbol Symbol); // strings are encoded in UTF-8 73 const std::string& GetEditText(symbol Symbol); // strings are encoded in UTF-8
74 int GetTextColour(symbol Symbol); // the foreground colour of the text 74 int GetTextColour(symbol Symbol); // the foreground colour of the text
75 Opts::ScreenOrientations GetAlphabetOrientation(); 75 Opts::ScreenOrientations GetAlphabetOrientation();
76 Opts::AlphabetTypes GetAlphabetType(); 76 Opts::AlphabetTypes GetAlphabetType();
77 const std::string& GetTrainFile(); 77 const std::string& GetTrainFile();
78 78
79 // App Interface 79 // App Interface
80 // ----------------------------------------------------- 80 // -----------------------------------------------------
81 81
82 // std::map<int, std::string>& GetAlphabets(); // map<key, value> int is a UID string can change. Store UID in preferences. Display string to user. 82 // std::map<int, std::string>& GetAlphabets(); // map<key, value> int is a UID string can change. Store UID in preferences. Display string to user.
83 // std::vector<std::string>& GetAlphabets(); 83 // std::vector<std::string>& GetAlphabets();
84 // std::vector<std::string>& GetLangModels(); 84 // std::vector<std::string>& GetLangModels();
85 // std::vector<std::string>& GetViews(); 85 // std::vector<std::string>& GetViews();
86 86
87 void ChangeScreen(CDasherScreen* NewScreen); // We may change the widgets Dasher uses 87 void ChangeScreen(CDasherScreen* NewScreen); // We may change the widgets Dasher uses
88 void ChangeEdit(CDashEditbox* NewEdit); // at run time. 88 void ChangeEdit(CDashEditbox* NewEdit); // at run time.
89 89
90 void Train(std::string* TrainString, bool IsMore); // Training by string segments or file 90 void Train(std::string* TrainString, bool IsMore); // Training by string segments or file
91 void TrainFile(std::string Filename); // all training data must be in UTF-8. 91 void TrainFile(std::string Filename); // all training data must be in UTF-8.
92 92
93 void GetFontSizes(std::vector<int> *FontSizes); 93 void GetFontSizes(std::vector<int> *FontSizes);
94 94
95 double GetCurCPM(); // App may want to display characters per minute 95 double GetCurCPM(); // App may want to display characters per minute
96 double GetCurFPS(); // or frames per second. 96 double GetCurFPS(); // or frames per second.
97 97
98 // Customize alphabet 98 // Customize alphabet
99 void GetAlphabets(std::vector< std::string >* AlphabetList); 99 void GetAlphabets(std::vector< std::string >* AlphabetList);
100 const CAlphIO::AlphInfo& GetInfo(const std::string& AlphID); 100 const CAlphIO::AlphInfo& GetInfo(const std::string& AlphID);
101 void SetInfo(const CAlphIO::AlphInfo& NewInfo); 101 void SetInfo(const CAlphIO::AlphInfo& NewInfo);
102 void DeleteAlphabet(const std::string& AlphID); 102 void DeleteAlphabet(const std::string& AlphID);
103 103
104 // Settings Interface (options saved between sessions) 104 // Settings Interface (options saved between sessions)
105 // ----------------------------------------------------- 105 // -----------------------------------------------------
106 106
107 void ChangeAlphabet(const std::string& NewAlphabetID); 107 void ChangeAlphabet(const std::string& NewAlphabetID);
108 void ChangeMaxBitRate(double NewMaxBitRate); 108 void ChangeMaxBitRate(double NewMaxBitRate);
109 void ChangeLanguageModel(unsigned int NewLanguageModelID); 109 void ChangeLanguageModel(unsigned int NewLanguageModelID);
110 void ChangeView(unsigned int NewViewID); 110 void ChangeView(unsigned int NewViewID);
111 void ChangeOrientation(Opts::ScreenOrientations Orientation); 111 void ChangeOrientation(Opts::ScreenOrientations Orientation);
112 void SetFileEncoding(Opts::FileEncodingFormats Encoding); 112 void SetFileEncoding(Opts::FileEncodingFormats Encoding);
113 // TODO Color customization. 113 // TODO Color customization.
114 114
115 void ShowToolbar(bool Value); 115 void ShowToolbar(bool Value);
116 void ShowToolbarText(bool Value); 116 void ShowToolbarText(bool Value);
117 void ShowToolbarLargeIcons(bool Value); 117 void ShowToolbarLargeIcons(bool Value);
118 void ShowSpeedSlider(bool Value); 118 void ShowSpeedSlider(bool Value);
119 void FixLayout(bool Value); 119 void FixLayout(bool Value);
120 void TimeStampNewFiles(bool Value); 120 void TimeStampNewFiles(bool Value);
121 void CopyAllOnStop(bool Value); 121 void CopyAllOnStop(bool Value);
122 void DrawMouse(bool Value); 122 void DrawMouse(bool Value);
123 void StartOnSpace(bool Value); 123 void StartOnSpace(bool Value);
124 void StartOnLeft(bool Value); 124 void StartOnLeft(bool Value);
125 void KeyControl(bool Value); 125 void KeyControl(bool Value);
126 void WindowPause(bool Value); 126 void WindowPause(bool Value);
127 void SetEditFont(std::string Name, long Size); 127 void SetEditFont(std::string Name, long Size);
128 void SetDasherFont(std::string Name); 128 void SetDasherFont(std::string Name);
129 void SetDasherFontSize(FontSize fontsize); 129 void SetDasherFontSize(FontSize fontsize);
130 void SetDasherDimensions(bool Value); 130 void SetDasherDimensions(bool Value);
131 131
132private: 132private:
133 CAlphabet* m_Alphabet; 133 CAlphabet* m_Alphabet;
134 CLanguageModel* m_LanguageModel; 134 CLanguageModel* m_LanguageModel;
135 CDasherModel* m_DasherModel; 135 CDasherModel* m_DasherModel;
136 CDashEditbox* m_DashEditbox; 136 CDashEditbox* m_DashEditbox;
137 CDasherScreen* m_DasherScreen; 137 CDasherScreen* m_DasherScreen;
138 CDasherView* m_DasherView; 138 CDasherView* m_DasherView;
139 CSettingsStore* m_SettingsStore; 139 CSettingsStore* m_SettingsStore;
140 CDasherSettingsInterface* m_SettingsUI; 140 CDasherSettingsInterface* m_SettingsUI;
141 CAlphIO* m_AlphIO; 141 CAlphIO* m_AlphIO;
142 142
143 CLanguageModel::CNodeContext* TrainContext; 143 CLanguageModel::CNodeContext* TrainContext;
144 144
145 std::string AlphabetID; 145 std::string AlphabetID;
146 int LanguageModelID; 146 int LanguageModelID;
147 int ViewID; 147 int ViewID;
148 double m_MaxBitRate; 148 double m_MaxBitRate;
149 bool m_CopyAllOnStop; 149 bool m_CopyAllOnStop;
150 bool m_DrawMouse; 150 bool m_DrawMouse;
151 bool m_DrawKeyboard; 151 bool m_DrawKeyboard;
152 bool m_StartSpace; 152 bool m_StartSpace;
153 bool m_StartLeft; 153 bool m_StartLeft;
154 bool m_KeyControl; 154 bool m_KeyControl;
155 bool m_Dimensions; 155 bool m_Dimensions;
156 bool m_WindowPause; 156 bool m_WindowPause;
157 Opts::ScreenOrientations m_Orientation; 157 Opts::ScreenOrientations m_Orientation;
158 std::string m_UserLocation; 158 std::string m_UserLocation;
159 std::string m_SystemLocation; 159 std::string m_SystemLocation;
160 std::string m_TrainFile; 160 std::string m_TrainFile;
161 std::string m_DasherFont; 161 std::string m_DasherFont;
162 std::string m_EditFont; 162 std::string m_EditFont;
163 int m_EditFontSize; 163 int m_EditFontSize;
164 static const std::string EmptyString; 164 static const std::string EmptyString;
165 165
166 void CreateDasherModel(); 166 void CreateDasherModel();
167}; 167};
168 168
169 169
170#endif /* #ifndef __DasherInterface_h__ */ 170#endif /* #ifndef __DasherInterface_h__ */
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,322 +1,322 @@
1// DasherModel.h 1// DasherModel.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2001-2002 David Ward 5// Copyright (c) 2001-2002 David Ward
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9#include <iostream> 9#include <iostream>
10#include "DasherModel.h" 10#include "DasherModel.h"
11 11
12using namespace Dasher; 12using namespace Dasher;
13using namespace std; 13using namespace std;
14 14
15////////////////////////////////////////////////////////////////////// 15//////////////////////////////////////////////////////////////////////
16// CDasherModel 16// CDasherModel
17////////////////////////////////////////////////////////////////////// 17//////////////////////////////////////////////////////////////////////
18 18
19CDasherModel::CDasherModel(CDashEditbox* Editbox, CLanguageModel* LanguageModel, bool Dimensions) 19CDasherModel::CDasherModel(CDashEditbox* Editbox, CLanguageModel* LanguageModel, bool Dimensions)
20 : m_editbox(Editbox), m_languagemodel(LanguageModel), m_Root(0), m_Dimensions(Dimensions) 20 : m_Dimensions(Dimensions), m_editbox(Editbox), m_languagemodel(LanguageModel), m_Root(0)
21{ 21{
22 LearnContext = m_languagemodel->GetRootNodeContext(); 22 LearnContext = m_languagemodel->GetRootNodeContext();
23 23
24 // various settings 24 // various settings
25 int iShift = 12; 25 int iShift = 12;
26 m_DasherY = 1<<iShift; 26 m_DasherY = 1<<iShift;
27 m_DasherOY = m_DasherY/2; 27 m_DasherOY = m_DasherY/2;
28 m_DasherOX = m_DasherY/2; 28 m_DasherOX = m_DasherY/2;
29 m_dAddProb = 0.003; 29 m_dAddProb = 0.003;
30} 30}
31 31
32 32
33CDasherModel::~CDasherModel() 33CDasherModel::~CDasherModel()
34{ 34{
35 m_languagemodel->ReleaseNodeContext(LearnContext); 35 m_languagemodel->ReleaseNodeContext(LearnContext);
36 delete m_Root; // which will also delete all the whole structure 36 delete m_Root; // which will also delete all the whole structure
37} 37}
38 38
39 39
40void CDasherModel::Make_root(int whichchild) 40void CDasherModel::Make_root(int whichchild)
41 // find a new root node 41 // find a new root node
42{ 42{
43 symbol t=m_Root->Symbol(); 43 symbol t=m_Root->Symbol();
44 if (t) { 44 if (t) {
45 m_editbox->output(t); 45 m_editbox->output(t);
46 m_languagemodel->LearnNodeSymbol(LearnContext, t); 46 m_languagemodel->LearnNodeSymbol(LearnContext, t);
47 } 47 }
48 48
49 CDasherNode * oldroot=m_Root; 49 CDasherNode * oldroot=m_Root;
50 50
51 CDasherNode **children=m_Root->Children(); 51 CDasherNode **children=m_Root->Children();
52 m_Root=children[whichchild]; 52 m_Root=children[whichchild];
53 //oldroot->Children()[whichchild]=0; // null the pointer so we don't delete the whole tree 53 //oldroot->Children()[whichchild]=0; // null the pointer so we don't delete the whole tree
54 //delete oldroot; 54 //delete oldroot;
55 55
56 oldroots.push_back(oldroot); 56 oldroots.push_back(oldroot);
57 57
58 myint range=m_Rootmax-m_Rootmin; 58 myint range=m_Rootmax-m_Rootmin;
59 m_Rootmax=m_Rootmin+(range*m_Root->Hbnd())/Normalization(); 59 m_Rootmax=m_Rootmin+(range*m_Root->Hbnd())/Normalization();
60 m_Rootmin+=(range*m_Root->Lbnd())/Normalization(); 60 m_Rootmin+=(range*m_Root->Lbnd())/Normalization();
61} 61}
62 62
63void CDasherModel::Reparent_root(int lower, int upper) 63void CDasherModel::Reparent_root(int lower, int upper)
64{ 64{
65 /* Change the root node to the parent of the existing node 65 /* Change the root node to the parent of the existing node
66 We need to recalculate the coordinates for the "new" root as the 66 We need to recalculate the coordinates for the "new" root as the
67 user may have moved around within the current root */ 67 user may have moved around within the current root */
68 68
69 /* Determine how zoomed in we are */ 69 /* Determine how zoomed in we are */
70 float scalefactor=(m_Rootmax-m_Rootmin)/(upper-lower); 70 float scalefactor=(m_Rootmax-m_Rootmin)/(upper-lower);
71 71
72 m_Rootmax=int(m_Rootmax+((1024-upper)*scalefactor)); 72 m_Rootmax=int(m_Rootmax+((1024-upper)*scalefactor));
73 m_Rootmin=int(m_Rootmin-(lower*scalefactor)); 73 m_Rootmin=int(m_Rootmin-(lower*scalefactor));
74 74
75 m_editbox->deletetext(); 75 m_editbox->deletetext();
76 76
77 m_Root=oldroots.back(); 77 m_Root=oldroots.back();
78 oldroots.pop_back(); 78 oldroots.pop_back();
79} 79}
80 80
81///////////////////////////////////////////////////////////////////////////// 81/////////////////////////////////////////////////////////////////////////////
82 82
83CDasherNode * CDasherModel::Get_node_under_crosshair() 83CDasherNode * CDasherModel::Get_node_under_crosshair()
84{ 84{
85 return m_Root->Get_node_under(Normalization(),m_Rootmin,m_Rootmax,m_DasherOX,m_DasherOY); 85 return m_Root->Get_node_under(Normalization(),m_Rootmin,m_Rootmax,m_DasherOX,m_DasherOY);
86} 86}
87 87
88///////////////////////////////////////////////////////////////////////////// 88/////////////////////////////////////////////////////////////////////////////
89 89
90 90
91CDasherNode * CDasherModel::Get_node_under_mouse(myint Mousex,myint Mousey) 91CDasherNode * CDasherModel::Get_node_under_mouse(myint Mousex,myint Mousey)
92{ 92{
93 return m_Root->Get_node_under(Normalization(),m_Rootmin,m_Rootmax,Mousex,Mousey); 93 return m_Root->Get_node_under(Normalization(),m_Rootmin,m_Rootmax,Mousex,Mousey);
94} 94}
95 95
96///////////////////////////////////////////////////////////////////////////// 96/////////////////////////////////////////////////////////////////////////////
97 97
98 98
99void CDasherModel::Get_string_under_mouse(const myint Mousex,const myint Mousey, vector<symbol> &str) 99void CDasherModel::Get_string_under_mouse(const myint Mousex,const myint Mousey, vector<symbol> &str)
100{ 100{
101 m_Root->Get_string_under(Normalization(),m_Rootmin,m_Rootmax,Mousex,Mousey,str); 101 m_Root->Get_string_under(Normalization(),m_Rootmin,m_Rootmax,Mousex,Mousey,str);
102 return; 102 return;
103} 103}
104 104
105///////////////////////////////////////////////////////////////////////////// 105/////////////////////////////////////////////////////////////////////////////
106 106
107 107
108void CDasherModel::Flush(const myint Mousex,const myint Mousey) 108void CDasherModel::Flush(const myint ,const myint )
109{ 109{
110 vector<symbol> vtUnder; 110 vector<symbol> vtUnder;
111 Get_string_under_mouse(m_DasherOX,m_DasherOY,vtUnder); 111 Get_string_under_mouse(m_DasherOX,m_DasherOY,vtUnder);
112 unsigned int i; 112 unsigned int i;
113 for (i=0;i<vtUnder.size();i++) { 113 for (i=0;i<vtUnder.size();i++) {
114 if (vtUnder[i]==0) 114 if (vtUnder[i]==0)
115 continue; 115 continue;
116 m_editbox->flush(vtUnder[i]); 116 m_editbox->flush(vtUnder[i]);
117 } 117 }
118} 118}
119 119
120///////////////////////////////////////////////////////////////////////////// 120/////////////////////////////////////////////////////////////////////////////
121 121
122void CDasherModel::Update(CDasherNode *node,CDasherNode *under_mouse,int iSafe) 122void CDasherModel::Update(CDasherNode *node,CDasherNode *under_mouse,int iSafe)
123// go through the Dasher nodes, delete ones who have expired 123// go through the Dasher nodes, delete ones who have expired
124// decrease the time left for nodes which arent safe 124// decrease the time left for nodes which arent safe
125// safe nodes are those which are under the mouse or offspring of this node 125// safe nodes are those which are under the mouse or offspring of this node
126{ 126{
127 //if (node->pushme ) 127 //if (node->pushme )
128 // node->push_node(); 128 // node->push_node();
129 if (node==under_mouse) 129 if (node==under_mouse)
130 iSafe=1; 130 iSafe=1;
131 if (!iSafe) 131 if (!iSafe)
132 node->Age(); 132 node->Age();
133 //dchar debug[256]; 133 //dchar debug[256];
134 //wsprintf(debug,TEXT("node->Age %d %f\n"),node->Age, fr.framerate()); 134 //wsprintf(debug,TEXT("node->Age %d %f\n"),node->Age, fr.framerate());
135 //OutputDebugString(debug); 135 //OutputDebugString(debug);
136 136
137 137
138 if (node->Age() > Framerate()) 138 if (node->Age() > Framerate())
139 node->Kill(); 139 node->Kill();
140 140
141 141
142 if (node->Alive()) { 142 if (node->Alive()) {
143 CDasherNode **children=node->Children(); 143 CDasherNode **children=node->Children();
144 if (children) { 144 if (children) {
145 unsigned int i; 145 unsigned int i;
146 for (i=1;i<node->Chars();i++) 146 for (i=1;i<node->Chars();i++)
147 Update(children[i],under_mouse,iSafe); 147 Update(children[i],under_mouse,iSafe);
148 } 148 }
149 } 149 }
150 return; 150 return;
151} 151}
152 152
153///////////////////////////////////////////////////////////////////////////// 153/////////////////////////////////////////////////////////////////////////////
154 154
155void CDasherModel::Start() 155void CDasherModel::Start()
156{ 156{
157 m_Rootmin=0; 157 m_Rootmin=0;
158 m_Rootmax=m_DasherY; 158 m_Rootmax=m_DasherY;
159 159
160 delete m_Root; 160 delete m_Root;
161 CLanguageModel::CNodeContext* therootcontext=m_languagemodel->GetRootNodeContext(); 161 CLanguageModel::CNodeContext* therootcontext=m_languagemodel->GetRootNodeContext();
162 162
163 //Rootparent=new DasherNode(0,0,0,therootcontext,0,0,0,Normalization(),languagemodel); 163 //Rootparent=new DasherNode(0,0,0,therootcontext,0,0,0,Normalization(),languagemodel);
164 if (m_editbox) { 164 if (m_editbox) {
165 m_editbox->set_flushed(0); 165 m_editbox->set_flushed(0);
166 string ContextString; 166 string ContextString;
167 m_editbox->get_new_context(ContextString,5); 167 m_editbox->get_new_context(ContextString,5);
168 if (ContextString.size() != 0) { 168 if (ContextString.size() != 0) {
169 m_languagemodel->EnterText(therootcontext, ContextString); 169 m_languagemodel->EnterText(therootcontext, ContextString);
170 } 170 }
171 m_languagemodel->ReleaseNodeContext(LearnContext); 171 m_languagemodel->ReleaseNodeContext(LearnContext);
172 LearnContext = m_languagemodel->CloneNodeContext(therootcontext); 172 LearnContext = m_languagemodel->CloneNodeContext(therootcontext);
173 } 173 }
174 m_Root=new CDasherNode(0,0,0,0,Opts::Nodes1,0,Normalization(),m_languagemodel); 174 m_Root=new CDasherNode(0,0,0,0,Opts::Nodes1,0,Normalization(),m_languagemodel);
175 m_Root->Push_Node(therootcontext); 175 m_Root->Push_Node(therootcontext);
176 176
177 m_languagemodel->ReleaseNodeContext(therootcontext); 177 m_languagemodel->ReleaseNodeContext(therootcontext);
178 //ppmmodel->dump(); 178 //ppmmodel->dump();
179 //dump(); 179 //dump();
180 180
181} 181}
182 182
183///////////////////////////////////////////////////////////////////////////// 183/////////////////////////////////////////////////////////////////////////////
184 184
185void CDasherModel::Get_new_root_coords(myint Mousex,myint Mousey) 185void CDasherModel::Get_new_root_coords(myint Mousex,myint Mousey)
186{ 186{
187 int cappedrate=0; 187 // int cappedrate=0;
188 double dRx=1.0,dRxnew=1.0; 188 double dRx=1.0,dRxnew=1.0;
189 double dRxnew2; 189 double dRxnew2;
190 190
191 int iSteps=m_fr.Steps(); 191 int iSteps=m_fr.Steps();
192 192
193 if (Mousex<m_DasherOX) { 193 if (Mousex<m_DasherOX) {
194 //rx=1.0001*Ixmap[mx]/Ixmap[cx]; 194 //rx=1.0001*Ixmap[mx]/Ixmap[cx];
195 if (Mousex<=0) 195 if (Mousex<=0)
196 Mousex=1; 196 Mousex=1;
197 dRx=1.0*m_DasherOX/Mousex; 197 dRx=1.0*m_DasherOX/Mousex;
198 dRxnew=pow(dRx,1.0/iSteps); // or exp(log(rx)/steps) - i think the replacement is faster 198 dRxnew=pow(dRx,1.0/iSteps); // or exp(log(rx)/steps) - i think the replacement is faster
199 199
200 dRxnew2=1+(dRx-1)/iSteps; 200 dRxnew2=1+(dRx-1)/iSteps;
201 //+(rx-1)*(rx-1)*(1.0/fr.steps()-1.0)/2/fr.steps(); 201 //+(rx-1)*(rx-1)*(1.0/fr.steps()-1.0)/2/fr.steps();
202 202
203 203
204 const double dRxmax=m_fr.Rxmax(); 204 const double dRxmax=m_fr.Rxmax();
205 if (dRxnew>dRxmax) 205 if (dRxnew>dRxmax)
206 dRxnew=dRxmax; 206 dRxnew=dRxmax;
207 // cappedrate=1; 207 // cappedrate=1;
208 } else { 208 } else {
209 if (Mousex==m_DasherOX) 209 if (Mousex==m_DasherOX)
210 Mousex++; 210 Mousex++;
211 // OutputDebugString(TEXT("zoom out\n")); 211 // OutputDebugString(TEXT("zoom out\n"));
212 dRx=1.0001*m_DasherOX/Mousex; 212 dRx=1.0001*m_DasherOX/Mousex;
213 dRxnew=exp(log(dRx)/iSteps); 213 dRxnew=exp(log(dRx)/iSteps);
214 //get_coords(root->lbnd,root->hbnd,&x1,&y1,&y2); 214 //get_coords(root->lbnd,root->hbnd,&x1,&y1,&y2);
215 //if (x1>0 || y1>0 || y2<CanvasY) 215 //if (x1>0 || y1>0 || y2<CanvasY)
216 //go_back_a_char(); 216 //go_back_a_char();
217 if (m_Rootmax<m_DasherY && m_Rootmin>0) 217 if (m_Rootmax<m_DasherY && m_Rootmin>0)
218 return; 218 return;
219 } 219 }
220 //dchar debug[256]; 220 //dchar debug[256];
221 //_stprintf(debug,TEXT("rx %f rxnew %f approx %f\n"),rx,rxnew,rxnew2); 221 //_stprintf(debug,TEXT("rx %f rxnew %f approx %f\n"),rx,rxnew,rxnew2);
222 //OutputDebugString(debug); 222 //OutputDebugString(debug);
223 //wsprintf(debug,TEXT("rx %f rxnew %f\n"),rx,rxnew); 223 //wsprintf(debug,TEXT("rx %f rxnew %f\n"),rx,rxnew);
224 //OutputDebugString(debug); 224 //OutputDebugString(debug);
225 myint above=(Mousey-m_Rootmin);//*(1-rxnew)/(1-rx); 225 myint above=(Mousey-m_Rootmin);//*(1-rxnew)/(1-rx);
226 myint below=(m_Rootmax-Mousey);//*(1-rxnew)/(1-rx); 226 myint below=(m_Rootmax-Mousey);//*(1-rxnew)/(1-rx);
227 227
228 //wsprintf(debug,TEXT("above %I64d below %I64d \n"),above,below); 228 //wsprintf(debug,TEXT("above %I64d below %I64d \n"),above,below);
229 //OutputDebugString(debug); 229 //OutputDebugString(debug);
230 230
231 myint miDistance=m_DasherY/2-Mousey; 231 myint miDistance=m_DasherY/2-Mousey;
232 miDistance=myint(miDistance*(dRxnew-1)/(dRx-1)); 232 miDistance=myint(miDistance*(dRxnew-1)/(dRx-1));
233 myint miNewrootzoom=Mousey+miDistance; 233 myint miNewrootzoom=Mousey+miDistance;
234 234
235 myint newRootmax=miNewrootzoom+myint(below*dRxnew); 235 myint newRootmax=miNewrootzoom+myint(below*dRxnew);
236 myint newRootmin=miNewrootzoom-myint(above*dRxnew); 236 myint newRootmin=miNewrootzoom-myint(above*dRxnew);
237 if (newRootmin<m_DasherY/2 && newRootmax>m_DasherY/2 && newRootmax<LLONG_MAX && newRootmin>LLONG_MIN) { 237 if (newRootmin<m_DasherY/2 && newRootmax>m_DasherY/2 && newRootmax<LLONG_MAX && newRootmin>LLONG_MIN) {
238 m_Rootmax=newRootmax; 238 m_Rootmax=newRootmax;
239 m_Rootmin=newRootmin; 239 m_Rootmin=newRootmin;
240 } 240 }
241 241
242} 242}
243 243
244///////////////////////////////////////////////////////////////////////////// 244/////////////////////////////////////////////////////////////////////////////
245 245
246void CDasherModel::Tap_on_display(myint miMousex,myint miMousey, unsigned long Time) 246void CDasherModel::Tap_on_display(myint miMousex,myint miMousey, unsigned long )
247 // work out the next viewpoint, opens some new nodes 247 // work out the next viewpoint, opens some new nodes
248{ 248{
249 // works out next viewpoint 249 // works out next viewpoint
250 Get_new_root_coords(miMousex,miMousey); 250 Get_new_root_coords(miMousex,miMousey);
251 251
252 // opens up new nodes 252 // opens up new nodes
253 253
254 // push node under mouse 254 // push node under mouse
255 CDasherNode *under_mouse=Get_node_under_mouse(miMousex,miMousey); 255 CDasherNode *under_mouse=Get_node_under_mouse(miMousex,miMousey);
256 under_mouse->Push_Node(); 256 under_mouse->Push_Node();
257 257
258 258
259 if (Framerate() > 4) { 259 if (Framerate() > 4) {
260 // push node under mouse but with x coord on RHS 260 // push node under mouse but with x coord on RHS
261 CDasherNode *right=Get_node_under_mouse(50,miMousey); 261 CDasherNode *right=Get_node_under_mouse(50,miMousey);
262 right->Push_Node(); 262 right->Push_Node();
263 } 263 }
264 264
265 if (Framerate() > 8) { 265 if (Framerate() > 8) {
266 // push node under the crosshair 266 // push node under the crosshair
267 CDasherNode *under_cross=Get_node_under_crosshair(); 267 CDasherNode *under_cross=Get_node_under_crosshair();
268 under_cross->Push_Node(); 268 under_cross->Push_Node();
269 } 269 }
270 270
271 unsigned int iRandom; 271 unsigned int iRandom;
272#if defined(_WIN32_WCE) 272#if defined(_WIN32_WCE)
273 iRandom=Random(); 273 iRandom=Random();
274#else 274#else
275 iRandom=rand(); 275 iRandom=rand();
276#endif 276#endif
277 if (Framerate() > 8) { 277 if (Framerate() > 8) {
278 // add some noise and push another node 278 // add some noise and push another node
279 CDasherNode *right=Get_node_under_mouse(50,miMousey+iRandom%500-250); 279 CDasherNode *right=Get_node_under_mouse(50,miMousey+iRandom%500-250);
280 right->Push_Node(); 280 right->Push_Node();
281 } 281 }
282#if defined(_WIN32_WCE) 282#if defined(_WIN32_WCE)
283 iRandom=Random(); 283 iRandom=Random();
284#else 284#else
285 iRandom=rand(); 285 iRandom=rand();
286#endif 286#endif
287 if (Framerate() > 15) { 287 if (Framerate() > 15) {
288 // add some noise and push another node 288 // add some noise and push another node
289 CDasherNode *right=Get_node_under_mouse(50,miMousey+iRandom%500-250); 289 CDasherNode *right=Get_node_under_mouse(50,miMousey+iRandom%500-250);
290 right->Push_Node(); 290 right->Push_Node();
291 } 291 }
292 292
293 // only do this is Dasher is flying 293 // only do this is Dasher is flying
294 if (Framerate() > 30) { 294 if (Framerate() > 30) {
295 for (int i=1;i<int(Framerate()-30)/3;i++) { 295 for (int i=1;i<int(Framerate()-30)/3;i++) {
296 #if defined(_WIN32_WCE) 296 #if defined(_WIN32_WCE)
297 iRandom=Random(); 297 iRandom=Random();
298#else 298#else
299 iRandom=rand(); 299 iRandom=rand();
300#endif 300#endif
301 // push at a random node on the RHS 301 // push at a random node on the RHS
302 CDasherNode *right=Get_node_under_mouse(50,miMousey+iRandom%1000-500); 302 CDasherNode *right=Get_node_under_mouse(50,miMousey+iRandom%1000-500);
303 right->Push_Node(); 303 right->Push_Node();
304 304
305 } 305 }
306 } 306 }
307 Update(m_Root,under_mouse,0); 307 Update(m_Root,under_mouse,0);
308 308
309 309
310} 310}
311 311
312///////////////////////////////////////////////////////////////////////////// 312/////////////////////////////////////////////////////////////////////////////
313 313
314void CDasherModel::Dump() const 314void CDasherModel::Dump() const
315 // diagnostic dump 315 // diagnostic dump
316{ 316{
317 // OutputDebugString(TEXT(" ptr symbol context Next Child pushme pushed cscheme lbnd hbnd \n")); 317 // OutputDebugString(TEXT(" ptr symbol context Next Child pushme pushed cscheme lbnd hbnd \n"));
318 m_Root->Dump_node(); 318 m_Root->Dump_node();
319} 319}
320 320
321 321
322 322
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
@@ -1,167 +1,167 @@
1// DasherNode.cpp 1// DasherNode.cpp
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2001-2002 David Ward 5// Copyright (c) 2001-2002 David Ward
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9#include "DasherNode.h" 9#include "DasherNode.h"
10using namespace Dasher; 10using namespace Dasher;
11using namespace Opts; 11using namespace Opts;
12using namespace std; 12using namespace std;
13 13
14///////////////////////////////////////////////////////////////////////////// 14/////////////////////////////////////////////////////////////////////////////
15 15
16void CDasherNode::Dump_node () const 16void CDasherNode::Dump_node () const
17 { 17 {
18 /* TODO sort out 18 /* TODO sort out
19 dchar out[256]; 19 dchar out[256];
20 if (m_Symbol) 20 if (m_Symbol)
21 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); 21 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);
22 else 22 else
23 wsprintf(out,TEXT("%7x %7x %5d %7x %5d %8x %8x \n"),this,m_iGroup,m_context,m_Children,m_Cscheme,m_iLbnd,m_iHbnd); 23 wsprintf(out,TEXT("%7x %7x %5d %7x %5d %8x %8x \n"),this,m_iGroup,m_context,m_Children,m_Cscheme,m_iLbnd,m_iHbnd);
24 24
25 OutputDebugString(out); 25 OutputDebugString(out);
26 26
27 if (m_Children) { 27 if (m_Children) {
28 unsigned int i; 28 unsigned int i;
29 for (i=1;i<m_iChars;i++) 29 for (i=1;i<m_iChars;i++)
30 m_Children[i]->Dump_node(); 30 m_Children[i]->Dump_node();
31 } 31 }
32 */ 32 */
33} 33}
34 34
35void CDasherNode::Generic_Push_Node(CLanguageModel::CNodeContext *context) { 35void CDasherNode::Generic_Push_Node(CLanguageModel::CNodeContext *) {
36 36
37 m_iAge=0; 37 m_iAge=0;
38 m_bAlive=true; 38 m_bAlive=true;
39 if (m_Symbol && !m_iChars) // make sure it's a valid symbol and don't enter if already done 39 if (m_Symbol && !m_iChars) // make sure it's a valid symbol and don't enter if already done
40 m_languagemodel->EnterNodeSymbol(m_context,m_Symbol); 40 m_languagemodel->EnterNodeSymbol(m_context,m_Symbol);
41 41
42 42
43 vector<symbol> newchars; // place to put this list of characters 43 vector<symbol> newchars; // place to put this list of characters
44 vector<unsigned int> cum,groups; // for the probability list 44 vector<unsigned int> cum,groups; // for the probability list
45 m_languagemodel->GetNodeProbs(m_context,newchars,groups,cum,0.003); 45 m_languagemodel->GetNodeProbs(m_context,newchars,groups,cum,0.003);
46 m_iChars=newchars.size(); 46 m_iChars=newchars.size();
47 // work out cumulative probs 47 // work out cumulative probs
48 unsigned int i; 48 unsigned int i;
49 for (i=1;i<m_iChars;i++) 49 for (i=1;i<m_iChars;i++)
50 cum[i]+=cum[i-1]; 50 cum[i]+=cum[i-1];
51 51
52 m_Children =new CDasherNode *[m_iChars]; 52 m_Children =new CDasherNode *[m_iChars];
53 53
54 // create the children 54 // create the children
55 ColorSchemes NormalScheme, SpecialScheme; 55 ColorSchemes NormalScheme, SpecialScheme;
56 if ((m_ColorScheme==Nodes1) || (m_ColorScheme==Special1)) { 56 if ((m_ColorScheme==Nodes1) || (m_ColorScheme==Special1)) {
57 NormalScheme = Nodes2; 57 NormalScheme = Nodes2;
58 SpecialScheme = Special2; 58 SpecialScheme = Special2;
59 } else { 59 } else {
60 NormalScheme = Nodes1; 60 NormalScheme = Nodes1;
61 SpecialScheme = Special1; 61 SpecialScheme = Special1;
62 } 62 }
63 63
64 ColorSchemes ChildScheme; 64 ColorSchemes ChildScheme;
65 for (i=1;i<m_iChars;i++) { 65 for (i=1;i<m_iChars;i++) {
66 if (newchars[i]==this->m_languagemodel->GetSpaceSymbol()) 66 if (newchars[i]==this->m_languagemodel->GetSpaceSymbol())
67 ChildScheme = SpecialScheme; 67 ChildScheme = SpecialScheme;
68 else 68 else
69 ChildScheme = NormalScheme; 69 ChildScheme = NormalScheme;
70 m_Children[i]=new CDasherNode(this,newchars[i],groups[i],i,ChildScheme,cum[i-1],cum[i],m_languagemodel,m_languagemodel->GetColour(i)); 70 m_Children[i]=new CDasherNode(this,newchars[i],groups[i],i,ChildScheme,cum[i-1],cum[i],m_languagemodel,m_languagemodel->GetColour(i));
71 } 71 }
72} 72}
73 73
74///////////////////////////////////////////////////////////////////////////// 74/////////////////////////////////////////////////////////////////////////////
75 75
76void CDasherNode::Push_Node(CLanguageModel::CNodeContext *context) 76void CDasherNode::Push_Node(CLanguageModel::CNodeContext *context)
77// push a node copying the specified context 77// push a node copying the specified context
78{ 78{
79 79
80 if (m_Children) { 80 if (m_Children) {
81 // if there are children just give them a poke 81 // if there are children just give them a poke
82 unsigned int i; 82 unsigned int i;
83 for (i=1;i<m_iChars;i++) { 83 for (i=1;i<m_iChars;i++) {
84 m_Children[i]->m_iAge=0; 84 m_Children[i]->m_iAge=0;
85 m_Children[i]->m_bAlive=1; 85 m_Children[i]->m_bAlive=1;
86 } 86 }
87 return; 87 return;
88 } 88 }
89 89
90 // if we haven't got a context then try to get a new one 90 // if we haven't got a context then try to get a new one
91 m_context=m_languagemodel->CloneNodeContext(context); 91 m_context=m_languagemodel->CloneNodeContext(context);
92 // if it fails, be patient 92 // if it fails, be patient
93 if (!m_context) 93 if (!m_context)
94 return; 94 return;
95 Generic_Push_Node(m_context); 95 Generic_Push_Node(m_context);
96} 96}
97 97
98///////////////////////////////////////////////////////////////////////////// 98/////////////////////////////////////////////////////////////////////////////
99 99
100void CDasherNode::Push_Node() 100void CDasherNode::Push_Node()
101{ 101{
102 102
103 if (m_Children) { 103 if (m_Children) {
104 // if there are children just give them a poke 104 // if there are children just give them a poke
105 unsigned int i; 105 unsigned int i;
106 for (i=1;i<m_iChars;i++) { 106 for (i=1;i<m_iChars;i++) {
107 m_Children[i]->m_iAge=0; 107 m_Children[i]->m_iAge=0;
108 m_Children[i]->m_bAlive=1; 108 m_Children[i]->m_bAlive=1;
109 } 109 }
110 return; 110 return;
111 } 111 }
112 112
113 // if we haven't got a context then try to get a new one 113 // if we haven't got a context then try to get a new one
114 if (m_parent) 114 if (m_parent)
115 m_context=m_languagemodel->CloneNodeContext(m_parent->m_context); 115 m_context=m_languagemodel->CloneNodeContext(m_parent->m_context);
116 else 116 else
117 m_context=m_languagemodel->GetRootNodeContext(); 117 m_context=m_languagemodel->GetRootNodeContext();
118 118
119 // if it fails, be patient 119 // if it fails, be patient
120 if (!m_context) 120 if (!m_context)
121 return; 121 return;
122 Generic_Push_Node(m_context); 122 Generic_Push_Node(m_context);
123} 123}
124 124
125///////////////////////////////////////////////////////////////////////////// 125/////////////////////////////////////////////////////////////////////////////
126 126
127void CDasherNode::Get_string_under(const int iNormalization,const myint miY1,const myint miY2,const myint miMousex,const myint miMousey, vector<symbol> &vString) const 127void CDasherNode::Get_string_under(const int iNormalization,const myint miY1,const myint miY2,const myint miMousex,const myint miMousey, vector<symbol> &vString) const
128{ 128{
129 // we are over (*this) node so add it to the string 129 // we are over (*this) node so add it to the string
130 vString.push_back(m_Symbol); 130 vString.push_back(m_Symbol);
131 131
132 // look for children who might also be under the coords 132 // look for children who might also be under the coords
133 if (m_Children) { 133 if (m_Children) {
134 myint miRange=miY2-miY1; 134 myint miRange=miY2-miY1;
135 unsigned int i; 135 unsigned int i;
136 for (i=1;i<m_iChars;i++) { 136 for (i=1;i<m_iChars;i++) {
137 myint miNewy1=miY1+(miRange*m_Children[i]->m_iLbnd)/iNormalization; 137 myint miNewy1=miY1+(miRange*m_Children[i]->m_iLbnd)/iNormalization;
138 myint miNewy2=miY1+(miRange*m_Children[i]->m_iHbnd)/iNormalization; 138 myint miNewy2=miY1+(miRange*m_Children[i]->m_iHbnd)/iNormalization;
139 if (miMousey<miNewy2 && miMousey>miNewy1 && miMousex<miNewy2-miNewy1) { 139 if (miMousey<miNewy2 && miMousey>miNewy1 && miMousex<miNewy2-miNewy1) {
140 m_Children[i]->Get_string_under(iNormalization,miNewy1,miNewy2,miMousex,miMousey,vString); 140 m_Children[i]->Get_string_under(iNormalization,miNewy1,miNewy2,miMousex,miMousey,vString);
141 return; 141 return;
142 } 142 }
143 } 143 }
144 } 144 }
145 return; 145 return;
146} 146}
147 147
148///////////////////////////////////////////////////////////////////////////// 148/////////////////////////////////////////////////////////////////////////////
149 149
150CDasherNode * const CDasherNode::Get_node_under(int iNormalization,myint miY1,myint miY2,myint miMousex,myint miMousey) 150CDasherNode * const CDasherNode::Get_node_under(int iNormalization,myint miY1,myint miY2,myint miMousex,myint miMousey)
151{ 151{
152 if (m_Children) { 152 if (m_Children) {
153 myint miRange=miY2-miY1; 153 myint miRange=miY2-miY1;
154 m_iAge=0; 154 m_iAge=0;
155 m_bAlive=true; 155 m_bAlive=true;
156 unsigned int i; 156 unsigned int i;
157 for (i=1;i<m_iChars;i++) { 157 for (i=1;i<m_iChars;i++) {
158 myint miNewy1=miY1+(miRange*m_Children[i]->m_iLbnd)/iNormalization; 158 myint miNewy1=miY1+(miRange*m_Children[i]->m_iLbnd)/iNormalization;
159 myint miNewy2=miY1+(miRange*m_Children[i]->m_iHbnd)/iNormalization; 159 myint miNewy2=miY1+(miRange*m_Children[i]->m_iHbnd)/iNormalization;
160 if (miMousey<miNewy2 && miMousey>miNewy1 && miMousex<miNewy2-miNewy1) 160 if (miMousey<miNewy2 && miMousey>miNewy1 && miMousex<miNewy2-miNewy1)
161 return m_Children[i]->Get_node_under(iNormalization,miNewy1,miNewy2,miMousex,miMousey); 161 return m_Children[i]->Get_node_under(iNormalization,miNewy1,miNewy2,miMousex,miMousey);
162 } 162 }
163 } 163 }
164 return this; 164 return this;
165} 165}
166 166
167///////////////////////////////////////////////////////////////////////////// 167/////////////////////////////////////////////////////////////////////////////
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
@@ -1,127 +1,141 @@
1// DasherNode.h 1// DasherNode.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2001-2002 David Ward 5// Copyright (c) 2001-2002 David Ward
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9#ifndef __DasherNode_h__ 9#ifndef __DasherNode_h__
10#define __DasherNode_h__ 10#define __DasherNode_h__
11 11
12#include "NoClones.h" 12#include "NoClones.h"
13#include "DasherTypes.h" 13#include "DasherTypes.h"
14#include "LanguageModel.h" 14#include "LanguageModel.h"
15 15
16namespace Dasher {class CDasherNode;} 16namespace Dasher {class CDasherNode;}
17class Dasher::CDasherNode : private NoClones 17class Dasher::CDasherNode : private NoClones
18{ 18{
19 // CDasherNode represents a rectangle and character 19 // CDasherNode represents a rectangle and character
20 // nodes have children, siblings and parents 20 // nodes have children, siblings and parents
21private: 21private:
22 const unsigned int m_iLbnd,m_iHbnd;// the cumulative lower and upper bound prob relative to parent 22 const unsigned int m_iLbnd,m_iHbnd;// the cumulative lower and upper bound prob relative to parent
23 const unsigned int m_iGroup; // group membership - e.g. 0=nothing 1=caps 2=punc 23 const unsigned int m_iGroup; // group membership - e.g. 0=nothing 1=caps 2=punc
24 unsigned int m_iChars, m_iAge; 24 unsigned int m_iChars, m_iAge;
25 bool m_bAlive; // if true, then display node, else dont bother 25 bool m_bAlive; // if true, then display node, else dont bother
26 bool m_bControlNode; // if true, node is a control node 26 bool m_bControlNode; // if true, node is a control node
27 bool m_bControlChild; // if true, node is offspring of a control node 27 bool m_bControlChild; // if true, node is offspring of a control node
28 //bool m_Cscheme; // color scheme for the node - alternates through relatives 28 //bool m_Cscheme; // color scheme for the node - alternates through relatives
29 Opts::ColorSchemes m_ColorScheme; 29 Opts::ColorSchemes m_ColorScheme;
30 int m_iPhase; // index for coloring 30 int m_iPhase; // index for coloring
31 int m_iColour; // for the advanced colour mode 31 int m_iColour; // for the advanced colour mode
32 32
33 const symbol m_Symbol; // the character to display 33 const symbol m_Symbol; // the character to display
34 CLanguageModel *m_languagemodel; // pointer to the language model - in future, could be different for each node 34 CLanguageModel *m_languagemodel; // pointer to the language model - in future, could be different for each node
35 CDasherNode **m_Children; // pointer to array of children 35 CDasherNode **m_Children; // pointer to array of children
36 CDasherNode *m_parent; // pointer to parent - only needed to grab parent context 36 CDasherNode *m_parent; // pointer to parent - only needed to grab parent context
37 CLanguageModel::CNodeContext *m_context; 37 CLanguageModel::CNodeContext *m_context;
38public: 38public:
39 39
40 CDasherNode(CDasherNode *parent,symbol Symbol, unsigned int igroup, int iphase, Opts::ColorSchemes ColorScheme,int ilbnd,int ihbnd,CLanguageModel *lm, int Colour); 40 CDasherNode(CDasherNode *parent,symbol Symbol, unsigned int igroup, int iphase, Opts::ColorSchemes ColorScheme,int ilbnd,int ihbnd,CLanguageModel *lm, int Colour);
41 ~CDasherNode(); 41 ~CDasherNode();
42 bool m_bForce; // flag to force a node to be drawn - shouldn't be public 42 bool m_bForce; // flag to force a node to be drawn - shouldn't be public
43 43
44 // return private data members - read only 44 // return private data members - read only
45 CDasherNode ** const Children() const {return m_Children;} 45 CDasherNode ** const Children() const {return m_Children;}
46 unsigned int Lbnd() const {return m_iLbnd;} 46 unsigned int Lbnd() const {return m_iLbnd;}
47 bool Alive() {return m_bAlive;} 47 bool Alive() {return m_bAlive;}
48 bool Control() {return m_bControlChild;} 48 bool Control() {return m_bControlChild;}
49 void Kill() {m_bAlive=0;m_iAge=0;} 49 void Kill() {m_bAlive=0;m_iAge=0;}
50 unsigned int Hbnd() const {return m_iHbnd;} 50 unsigned int Hbnd() const {return m_iHbnd;}
51 unsigned int Group() const {return m_iGroup;} 51 unsigned int Group() const {return m_iGroup;}
52 unsigned int Age() const {return m_iAge;} 52 unsigned int Age() const {return m_iAge;}
53 symbol Symbol() const {return m_Symbol;} 53 symbol Symbol() const {return m_Symbol;}
54 unsigned int Chars() const {return m_iChars;} 54 unsigned int Chars() const {return m_iChars;}
55 int Phase() const {return m_iPhase;} 55 int Phase() const {return m_iPhase;}
56 Opts::ColorSchemes Cscheme() const {return m_ColorScheme;} 56 Opts::ColorSchemes Cscheme() const {return m_ColorScheme;}
57 int Colour() const {return m_iColour;} 57 int Colour() const {return m_iColour;}
58 58
59 CDasherNode* const Get_node_under(int,myint y1,myint y2,myint smousex,myint smousey); // find node under given co-ords 59 CDasherNode* const Get_node_under(int,myint y1,myint y2,myint smousex,myint smousey); // find node under given co-ords
60 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 60 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
61 void Generic_Push_Node(CLanguageModel::CNodeContext *context); 61 void Generic_Push_Node(CLanguageModel::CNodeContext *context);
62 void Push_Node(); // give birth to children 62 void Push_Node(); // give birth to children
63 void Push_Node(CLanguageModel::CNodeContext *context); // give birth to children with this context 63 void Push_Node(CLanguageModel::CNodeContext *context); // give birth to children with this context
64 void Delete_children(); 64 void Delete_children();
65 void Dump_node() const; // diagnostic 65 void Dump_node() const; // diagnostic
66}; 66};
67 67
68///////////////////////////////////////////////////////////////////////////// 68/////////////////////////////////////////////////////////////////////////////
69// Inline functions 69// Inline functions
70///////////////////////////////////////////////////////////////////////////// 70/////////////////////////////////////////////////////////////////////////////
71 71
72using namespace Dasher; 72using namespace Dasher;
73using namespace Opts; 73using namespace Opts;
74 74
75///////////////////////////////////////////////////////////////////////////// 75/////////////////////////////////////////////////////////////////////////////
76 76
77inline CDasherNode::CDasherNode(CDasherNode *parent,symbol Symbol, unsigned int igroup, int iphase, ColorSchemes ColorScheme,int ilbnd,int ihbnd,CLanguageModel *lm, int Colour=0) 77inline CDasherNode::CDasherNode(CDasherNode *parent,symbol Symbol, unsigned int igroup, int iphase, ColorSchemes ColorScheme,int ilbnd,int ihbnd,CLanguageModel *lm, int Colour=0) :
78 : m_parent(parent),m_Symbol(Symbol),m_iGroup(igroup),m_iLbnd(ilbnd),m_iHbnd(ihbnd),m_languagemodel(lm),m_iPhase(iphase), 78 m_iLbnd(ilbnd),
79 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) 79 m_iHbnd(ihbnd),
80 m_iGroup(igroup),
81 m_iChars(0),
82 m_iAge(0),
83 m_bAlive(1),
84 m_bControlChild(false),
85 m_ColorScheme(ColorScheme),
86 m_iPhase(iphase),
87 m_iColour(Colour),
88 m_Symbol(Symbol),
89 m_languagemodel(lm),
90 m_Children(0),
91 m_parent(parent),
92 m_context(0),
93 m_bForce(false)
80{ 94{
81 /* 95 /*
82 switch (ColorScheme) { 96 switch (ColorScheme) {
83 case Nodes1: 97 case Nodes1:
84 m_ColorScheme = Nodes2; 98 m_ColorScheme = Nodes2;
85 break; 99 break;
86 case Nodes2: 100 case Nodes2:
87 m_ColorScheme = Nodes1; 101 m_ColorScheme = Nodes1;
88 break; 102 break;
89 case Special1: 103 case Special1:
90 m_ColorScheme = Special2; 104 m_ColorScheme = Special2;
91 break; 105 break;
92 case Special2: 106 case Special2:
93 m_ColorScheme = Special1; 107 m_ColorScheme = Special1;
94 break; 108 break;
95 case default: 109 case default:
96 m_ColorScheme = ColorScheme; 110 m_ColorScheme = ColorScheme;
97 break; 111 break;
98 } 112 }
99 */ 113 */
100} 114}
101 115
102///////////////////////////////////////////////////////////////////////////// 116/////////////////////////////////////////////////////////////////////////////
103 117
104inline void CDasherNode::Delete_children() 118inline void CDasherNode::Delete_children()
105{ 119{
106 if (m_Children) { 120 if (m_Children) {
107 unsigned int i; 121 unsigned int i;
108 for (i=1;i<m_iChars;i++) 122 for (i=1;i<m_iChars;i++)
109 delete m_Children[i]; 123 delete m_Children[i];
110 delete [] m_Children; 124 delete [] m_Children;
111 } 125 }
112 m_Children=0; 126 m_Children=0;
113 127
114} 128}
115 129
116///////////////////////////////////////////////////////////////////////////// 130/////////////////////////////////////////////////////////////////////////////
117 131
118inline CDasherNode::~CDasherNode() 132inline CDasherNode::~CDasherNode()
119{ 133{
120 Delete_children(); 134 Delete_children();
121 if (m_context) 135 if (m_context)
122 m_languagemodel->ReleaseNodeContext(m_context); 136 m_languagemodel->ReleaseNodeContext(m_context);
123} 137}
124 138
125///////////////////////////////////////////////////////////////////////////// 139/////////////////////////////////////////////////////////////////////////////
126 140
127#endif /* #ifndef __DasherNode_h__ */ 141#endif /* #ifndef __DasherNode_h__ */
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,149 +1,149 @@
1// DasherSettingsInterface.h 1// DasherSettingsInterface.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10#ifndef __DasherSettingsInterface_h__ 10#ifndef __DasherSettingsInterface_h__
11#define __DasherSettingsInterface_h__ 11#define __DasherSettingsInterface_h__
12 12
13#include "DasherTypes.h" 13#include "DasherTypes.h"
14#include "SettingsStore.h" 14#include "SettingsStore.h"
15 15
16namespace Dasher {class CDasherSettingsInterface;} 16namespace Dasher {class CDasherSettingsInterface;}
17class Dasher::CDasherSettingsInterface 17class Dasher::CDasherSettingsInterface
18{ 18{
19public: 19public:
20 void SettingsDefaults(CSettingsStore* Store); 20 void SettingsDefaults(CSettingsStore* Store);
21 21
22 // These actually affect the way Dasher works 22 // These actually affect the way Dasher works
23 //! Change the alphabet in use to NewAlphabetID 23 //! Change the alphabet in use to NewAlphabetID
24 virtual void ChangeAlphabet(const std::string& NewAlphabetID) {}; 24 virtual void ChangeAlphabet(const std::string& ) {};
25 25
26 //! Change the maximum bitrate (effectively the speed) of Dasher 26 //! Change the maximum bitrate (effectively the speed) of Dasher
27 virtual void ChangeMaxBitRate(double NewMaxBitRate) {}; 27 virtual void ChangeMaxBitRate(double ) {};
28 28
29 //! Generate a new langage model. Not usually needed 29 //! Generate a new langage model. Not usually needed
30 virtual void ChangeLanguageModel(unsigned int NewLanguageModelID) {}; 30 virtual void ChangeLanguageModel(unsigned int ) {};
31 31
32 //! Generate a new view of the model. Call it with 0 when starting up 32 //! Generate a new view of the model. Call it with 0 when starting up
33 virtual void ChangeView(unsigned int NewViewID) {}; 33 virtual void ChangeView(unsigned int ) {};
34 34
35 //! Change the orientation (l->r, r->l, so on) of the model 35 //! Change the orientation (l->r, r->l, so on) of the model
36 virtual void ChangeOrientation(Opts::ScreenOrientations Orientation) {}; 36 virtual void ChangeOrientation(Opts::ScreenOrientations ) {};
37 37
38 //! Set the file encoding of output files to Encoding 38 //! Set the file encoding of output files to Encoding
39 virtual void SetFileEncoding(Opts::FileEncodingFormats Encoding) {}; 39 virtual void SetFileEncoding(Opts::FileEncodingFormats ) {};
40 40
41 //! Inform the core that the screen has this size 41 //! Inform the core that the screen has this size
42 virtual void SetScreenSize(long Width, long Height) {}; 42 virtual void SetScreenSize(long , long ) {};
43 43
44 //! Set the size of the font used in the Dasher canvas 44 //! Set the size of the font used in the Dasher canvas
45 virtual void SetDasherFontSize(Dasher::Opts::FontSize fontsize) {}; 45 virtual void SetDasherFontSize(Dasher::Opts::FontSize ) {};
46 46
47 //! Set the number of dimensions of input (either 1 or 2) 47 //! Set the number of dimensions of input (either 1 or 2)
48 virtual void SetDasherDimensions(bool Value) {}; 48 virtual void SetDasherDimensions(bool ) {};
49 49
50 // These are recommended options for the Dasher GUI. {{{ They don't actually 50 // These are recommended options for the Dasher GUI. {{{ They don't actually
51 // change the way Dasher works. They are part of the Dasher interface 51 // change the way Dasher works. They are part of the Dasher interface
52 // anyway so that it can handle option saving for you, and to make it 52 // anyway so that it can handle option saving for you, and to make it
53 // easy for the Dasher engine to control the GUI later on. }}} 53 // easy for the Dasher engine to control the GUI later on. }}}
54 54
55 //! True if toolbar should be shown, false otherwise 55 //! True if toolbar should be shown, false otherwise
56 virtual void ShowToolbar(bool Value) {}; 56 virtual void ShowToolbar(bool ) {};
57 57
58 //! True if toolbar should show text, false otherwse 58 //! True if toolbar should show text, false otherwse
59 virtual void ShowToolbarText(bool Value) {}; 59 virtual void ShowToolbarText(bool ) {};
60 60
61 //! True if toolbar should have large icons, false otherwise 61 //! True if toolbar should have large icons, false otherwise
62 virtual void ShowToolbarLargeIcons(bool Value) {}; 62 virtual void ShowToolbarLargeIcons(bool ) {};
63 63
64 //! True if the speed slider should be shown, false otherwise 64 //! True if the speed slider should be shown, false otherwise
65 virtual void ShowSpeedSlider(bool Value) {}; 65 virtual void ShowSpeedSlider(bool ) {};
66 66
67 //! True if the window layout should be fixed, false otherwise 67 //! True if the window layout should be fixed, false otherwise
68 virtual void FixLayout(bool Value) {}; 68 virtual void FixLayout(bool ) {};
69 69
70 //! True if new files should be timestamped, false otherwise 70 //! True if new files should be timestamped, false otherwise
71 virtual void TimeStampNewFiles(bool Value) {}; 71 virtual void TimeStampNewFiles(bool ) {};
72 72
73 //! True if all text should be copied to clipboard when Dasher is stopped, false otherwise 73 //! True if all text should be copied to clipboard when Dasher is stopped, false otherwise
74 virtual void CopyAllOnStop(bool Value) {}; 74 virtual void CopyAllOnStop(bool ) {};
75 75
76 //! True if a box should be drawn to represent the logical position of the mouse 76 //! True if a box should be drawn to represent the logical position of the mouse
77 virtual void DrawMouse(bool Value) {}; 77 virtual void DrawMouse(bool ) {};
78 78
79 //! Set the editbox font 79 //! Set the editbox font
80 virtual void SetEditFont(std::string Name, long Size) {}; 80 virtual void SetEditFont(std::string , long ) {};
81 81
82 //! Set the canvas font 82 //! Set the canvas font
83 virtual void SetDasherFont(std::string Name) {}; 83 virtual void SetDasherFont(std::string ) {};
84 84
85 //! Set the height of the edit box 85 //! Set the height of the edit box
86 virtual void SetEditHeight(long Value) {}; 86 virtual void SetEditHeight(long ) {};
87 87
88 //! Should Dasher start and stop on space bar? 88 //! Should Dasher start and stop on space bar?
89 virtual void StartOnSpace(bool Value) {}; 89 virtual void StartOnSpace(bool ) {};
90 90
91 //! Should Dasher start and stop on left mouse button? 91 //! Should Dasher start and stop on left mouse button?
92 virtual void StartOnLeft(bool Value) {}; 92 virtual void StartOnLeft(bool ) {};
93 93
94 //! Should Dasher be keyboard controlled? 94 //! Should Dasher be keyboard controlled?
95 virtual void KeyControl(bool Value) {}; 95 virtual void KeyControl(bool ) {};
96 96
97 //! Should Dasher pause when the pointer leaves the window? 97 //! Should Dasher pause when the pointer leaves the window?
98 virtual void WindowPause(bool Value) {}; 98 virtual void WindowPause(bool ) {};
99}; 99};
100 100
101 101
102#include <string> 102#include <string>
103 103
104namespace Dasher 104namespace Dasher
105{ 105{
106namespace Keys 106namespace Keys
107{ 107{
108 // Standard Option strings. You are encouraged to use these constants. 108 // Standard Option strings. You are encouraged to use these constants.
109 // ------------------------------------------------------------------- 109 // -------------------------------------------------------------------
110 110
111 // bool options 111 // bool options
112 extern const std::string TIME_STAMP; 112 extern const std::string TIME_STAMP;
113 extern const std::string SHOW_TOOLBAR; 113 extern const std::string SHOW_TOOLBAR;
114 extern const std::string SHOW_TOOLBAR_TEXT; 114 extern const std::string SHOW_TOOLBAR_TEXT;
115 extern const std::string SHOW_LARGE_ICONS; 115 extern const std::string SHOW_LARGE_ICONS;
116 extern const std::string FIX_LAYOUT; 116 extern const std::string FIX_LAYOUT;
117 extern const std::string SHOW_SLIDER; 117 extern const std::string SHOW_SLIDER;
118 extern const std::string COPY_ALL_ON_STOP; 118 extern const std::string COPY_ALL_ON_STOP;
119 extern const std::string DRAW_MOUSE; 119 extern const std::string DRAW_MOUSE;
120 extern const std::string START_SPACE; 120 extern const std::string START_SPACE;
121 extern const std::string START_MOUSE; 121 extern const std::string START_MOUSE;
122 extern const std::string KEY_CONTROL; 122 extern const std::string KEY_CONTROL;
123 extern const std::string WINDOW_PAUSE; 123 extern const std::string WINDOW_PAUSE;
124 // long options 124 // long options
125 extern const std::string FILE_ENCODING; 125 extern const std::string FILE_ENCODING;
126 extern const std::string MAX_BITRATE_TIMES100; 126 extern const std::string MAX_BITRATE_TIMES100;
127 extern const std::string SCREEN_ORIENTATION; 127 extern const std::string SCREEN_ORIENTATION;
128 extern const std::string VIEW_ID; 128 extern const std::string VIEW_ID;
129 extern const std::string LANGUAGE_MODEL_ID; 129 extern const std::string LANGUAGE_MODEL_ID;
130 extern const std::string EDIT_FONT_SIZE; 130 extern const std::string EDIT_FONT_SIZE;
131 extern const std::string EDIT_HEIGHT; 131 extern const std::string EDIT_HEIGHT;
132 extern const std::string SCREEN_WIDTH; 132 extern const std::string SCREEN_WIDTH;
133 extern const std::string SCREEN_HEIGHT; 133 extern const std::string SCREEN_HEIGHT;
134 extern const std::string DASHER_FONTSIZE; 134 extern const std::string DASHER_FONTSIZE;
135 extern const std::string DASHER_DIMENSIONS; 135 extern const std::string DASHER_DIMENSIONS;
136 136
137 // string options 137 // string options
138 extern const std::string ALPHABET_ID; 138 extern const std::string ALPHABET_ID;
139 extern const std::string DASHER_FONT; 139 extern const std::string DASHER_FONT;
140 extern const std::string EDIT_FONT; 140 extern const std::string EDIT_FONT;
141} 141}
142} // namespace Dasher 142} // namespace Dasher
143 143
144 144
145#endif /* #ifndef __DasherSettingsInterface_h__ */ 145#endif /* #ifndef __DasherSettingsInterface_h__ */
146 146
147 147
148 148
149 149
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,93 +1,93 @@
1// DasherView.cpp 1// DasherView.cpp
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2001-2002 David Ward 5// Copyright (c) 2001-2002 David Ward
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9#include "DasherView.h" 9#include "DasherView.h"
10using namespace Dasher; 10using namespace Dasher;
11 11
12 12
13CDasherView::CDasherView(CDasherScreen* DasherScreen, CDasherModel& DasherModel, Opts::ScreenOrientations Orientation) 13CDasherView::CDasherView(CDasherScreen* DasherScreen, CDasherModel& DasherModel, Opts::ScreenOrientations Orientation)
14 : m_Screen(DasherScreen), m_DasherModel(DasherModel), ScreenOrientation(Orientation), ColourMode(false) 14 : m_Screen(DasherScreen), m_DasherModel(DasherModel), ScreenOrientation(Orientation), ColourMode(false)
15{ 15{
16 //XYScale = (double)m_Screen->GetHeight() / m_Screen->GetWidth(); 16 //XYScale = (double)m_Screen->GetHeight() / m_Screen->GetWidth();
17} 17}
18 18
19 19
20void CDasherView::ChangeOrientation(Dasher::Opts::ScreenOrientations Orientation) 20void CDasherView::ChangeOrientation(Dasher::Opts::ScreenOrientations Orientation)
21{ 21{
22 ScreenOrientation = Orientation; 22 ScreenOrientation = Orientation;
23 Render(); 23 Render();
24} 24}
25 25
26 26
27void CDasherView::FlushAt(int mousex,int mousey) 27void CDasherView::FlushAt(int ,int )
28{ 28{
29 m_DasherModel.Flush(0,0); 29 m_DasherModel.Flush(0,0);
30} 30}
31 31
32int CDasherView::RecursiveRender(CDasherNode* Render, myint y1,myint y2,int mostleft, bool text) 32int CDasherView::RecursiveRender(CDasherNode* Render, myint y1,myint y2,int mostleft, bool text)
33{ 33{
34 symbol CurChar = Render->Symbol(); 34 // symbol CurChar = Render->Symbol();
35 int Color; 35 int Color;
36 36
37 if (ColourMode==true) { 37 if (ColourMode==true) {
38 Color = Render->Colour(); 38 Color = Render->Colour();
39 } else { 39 } else {
40 Color = Render->Phase()%3; 40 Color = Render->Phase()%3;
41 } 41 }
42 42
43 if (RenderNode(Render->Symbol(), Color, Render->Cscheme(), y1, y2, mostleft, Render->m_bForce, text)) 43 if (RenderNode(Render->Symbol(), Color, Render->Cscheme(), y1, y2, mostleft, Render->m_bForce, text))
44 RenderGroups(Render, y1, y2, text); 44 RenderGroups(Render, y1, y2, text);
45 else 45 else
46 Render->Kill(); 46 Render->Kill();
47 47
48 CDasherNode** const Children=Render->Children(); 48 CDasherNode** const Children=Render->Children();
49 if (!Children) 49 if (!Children)
50 return 0; 50 return 0;
51 int norm=DasherModel().Normalization(); 51 int norm=DasherModel().Normalization();
52 for (unsigned int i=1; i<Render->Chars(); i++) { 52 for (unsigned int i=1; i<Render->Chars(); i++) {
53 if (Children[i]->Alive()) { 53 if (Children[i]->Alive()) {
54 myint Range=y2-y1; 54 myint Range=y2-y1;
55 myint newy1=y1+(Range*Children[i]->Lbnd())/norm; 55 myint newy1=y1+(Range*Children[i]->Lbnd())/norm;
56 myint newy2=y1+(Range*Children[i]->Hbnd())/norm; 56 myint newy2=y1+(Range*Children[i]->Hbnd())/norm;
57 RecursiveRender(Children[i], newy1, newy2, mostleft, text); 57 RecursiveRender(Children[i], newy1, newy2, mostleft, text);
58 } 58 }
59 } 59 }
60 return 1; 60 return 1;
61 61
62 62
63} 63}
64 64
65 65
66void CDasherView::RenderGroups(CDasherNode* Render, myint y1, myint y2, bool text) 66void CDasherView::RenderGroups(CDasherNode* Render, myint y1, myint y2, bool text)
67{ 67{
68 CDasherNode** Children = Render->Children(); 68 CDasherNode** Children = Render->Children();
69 if (!Children) 69 if (!Children)
70 return; 70 return;
71 int current=0; 71 int current=0;
72 int lower=0; 72 int lower=0;
73 int upper=0; 73 int upper=0;
74 myint range=y2-y1; 74 myint range=y2-y1;
75 for (unsigned int i=1; i<Render->Chars(); i++) { 75 for (unsigned int i=1; i<Render->Chars(); i++) {
76 int g=Children[i]->Group(); 76 int g=Children[i]->Group();
77 if (g!=current) { 77 if (g!=current) {
78 lower=upper; 78 lower=upper;
79 upper=i; 79 upper=i;
80 80
81 if (current!=0) { 81 if (current!=0) {
82 myint lbnd=Children[lower]->Lbnd(); 82 myint lbnd=Children[lower]->Lbnd();
83 myint hbnd=Children[upper]->Lbnd(); 83 myint hbnd=Children[upper]->Lbnd();
84 myint newy1=y1+(range*lbnd)/m_DasherModel.Normalization(); 84 myint newy1=y1+(range*lbnd)/m_DasherModel.Normalization();
85 myint newy2=y1+(range*hbnd)/m_DasherModel.Normalization(); 85 myint newy2=y1+(range*hbnd)/m_DasherModel.Normalization();
86 int mostleft; 86 int mostleft;
87 bool force; 87 bool force;
88 RenderNode(0,current-1,Opts::Groups,newy1,newy2,mostleft,force,text); 88 RenderNode(0,current-1,Opts::Groups,newy1,newy2,mostleft,force,text);
89 } 89 }
90 current=g; 90 current=g;
91 } 91 }
92 } 92 }
93} 93}
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,99 +1,99 @@
1// DasherView.h 1// DasherView.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2001-2002 David Ward 5// Copyright (c) 2001-2002 David Ward
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10////////////////////////////////////////////////////////////////////// 10//////////////////////////////////////////////////////////////////////
11// DasherView.h: interface for the DasherView class. 11// DasherView.h: interface for the DasherView class.
12// Copyright 2002 David Ward 12// Copyright 2002 David Ward
13////////////////////////////////////////////////////////////////////// 13//////////////////////////////////////////////////////////////////////
14 14
15#ifndef __DasherView_h_ 15#ifndef __DasherView_h_
16#define __DasherView_h_ 16#define __DasherView_h_
17 17
18#include "MSVC_Unannoy.h" 18#include "MSVC_Unannoy.h"
19#include "DasherScreen.h" 19#include "DasherScreen.h"
20#include "DasherModel.h" 20#include "DasherModel.h"
21 21
22// CDasherView is an abstract view class 22// CDasherView is an abstract view class
23// The implentation must provide several functions - defined here as pure virtual functions 23// The implentation must provide several functions - defined here as pure virtual functions
24// See the CDasherViewSquare class for an example 24// See the CDasherViewSquare class for an example
25 25
26namespace Dasher {class CDasherView;} 26namespace Dasher {class CDasherView;}
27class Dasher::CDasherView 27class Dasher::CDasherView
28{ 28{
29public: 29public:
30 CDasherView(CDasherScreen* DasherScreen, CDasherModel& DasherModel, Dasher::Opts::ScreenOrientations Orientation=Dasher::Opts::LeftToRight); 30 CDasherView(CDasherScreen* DasherScreen, CDasherModel& DasherModel, Dasher::Opts::ScreenOrientations Orientation=Dasher::Opts::LeftToRight);
31 ~CDasherView() {} 31 virtual ~CDasherView() {}
32 32
33 void ChangeOrientation(Dasher::Opts::ScreenOrientations Orientation); 33 void ChangeOrientation(Dasher::Opts::ScreenOrientations Orientation);
34 34
35 // TODO Sort this out 35 // TODO Sort this out
36 void FlushAt(int mousex,int mousey); 36 void FlushAt(int mousex,int mousey);
37 37
38 // renders Dasher 38 // renders Dasher
39 inline void Render(); 39 inline void Render();
40 40
41 // translates the screen coordinates to Dasher coordinates and calls 41 // translates the screen coordinates to Dasher coordinates and calls
42 // dashermodel.TapOnDisplay 42 // dashermodel.TapOnDisplay
43 virtual void TapOnDisplay(int mousex, int mousey, unsigned long Time)=0; 43 virtual void TapOnDisplay(int mousex, int mousey, unsigned long Time)=0;
44 44
45 virtual void ChangeScreen(CDasherScreen* NewScreen) 45 virtual void ChangeScreen(CDasherScreen* NewScreen)
46 { 46 {
47 m_Screen=NewScreen; 47 m_Screen=NewScreen;
48 48
49 // DJW - removed floating point stuff 49 // DJW - removed floating point stuff
50 //XYScale = (double)m_Screen->GetHeight() / m_Screen->GetWidth(); 50 //XYScale = (double)m_Screen->GetHeight() / m_Screen->GetWidth();
51 } 51 }
52 52
53 virtual void DrawMouse(int mousex, int mousey)=0; 53 virtual void DrawMouse(int mousex, int mousey)=0;
54 virtual void DrawKeyboard()=0; 54 virtual void DrawKeyboard()=0;
55 55
56 // Return references to the model and the screen: 56 // Return references to the model and the screen:
57 CDasherModel& DasherModel() {return m_DasherModel;} 57 CDasherModel& DasherModel() {return m_DasherModel;}
58 CDasherScreen& Screen() {return *m_Screen;} 58 CDasherScreen& Screen() {return *m_Screen;}
59 59
60 void Display() {m_Screen->Display();} 60 void Display() {m_Screen->Display();}
61 61
62 // Toggle advanced colour mode 62 // Toggle advanced colour mode
63 void SetColourMode(bool colourmode) {ColourMode=colourmode;} 63 void SetColourMode(bool colourmode) {ColourMode=colourmode;}
64 64
65protected: 65protected:
66 // Orientation of Dasher Screen 66 // Orientation of Dasher Screen
67 inline void MapScreen(int* DrawX, int* DrawY); 67 inline void MapScreen(int* DrawX, int* DrawY);
68 inline void UnMapScreen(int* DrawX, int* DrawY); 68 inline void UnMapScreen(int* DrawX, int* DrawY);
69 69
70private: 70private:
71 CDasherScreen* m_Screen; // provides the graphics (text, lines, rectangles): 71 CDasherScreen* m_Screen; // provides the graphics (text, lines, rectangles):
72 CDasherModel& m_DasherModel; // Model view represents 72 CDasherModel& m_DasherModel; // Model view represents
73 73
74 // Pure virtuals to implement 74 // Pure virtuals to implement
75 virtual void Crosshair(myint sx)=0; // Tells m_Screen to draw a crosshair - or other static decoration 75 virtual void Crosshair(myint sx)=0; // Tells m_Screen to draw a crosshair - or other static decoration
76 virtual int RenderNode(const symbol Character, const int Color, Opts::ColorSchemes ColorScheme, 76 virtual int RenderNode(const symbol Character, const int Color, Opts::ColorSchemes ColorScheme,
77 myint y1, myint y2, int& mostleft, bool& force, bool text)=0; 77 myint y1, myint y2, int& mostleft, bool& force, bool text)=0;
78 78
79 // Responsible for all the Render_node calls 79 // Responsible for all the Render_node calls
80 int RecursiveRender(CDasherNode* Render, myint y1,myint y2,int mostleft, bool text); 80 int RecursiveRender(CDasherNode* Render, myint y1,myint y2,int mostleft, bool text);
81 81
82 // Displays some nodes inside one parent node. Used to group capital letters, accents, punctuation etc. 82 // Displays some nodes inside one parent node. Used to group capital letters, accents, punctuation etc.
83 void RenderGroups(CDasherNode* Render, myint y1, myint y2, bool text); 83 void RenderGroups(CDasherNode* Render, myint y1, myint y2, bool text);
84 84
85 // Orientation of Dasher Screen 85 // Orientation of Dasher Screen
86 Dasher::Opts::ScreenOrientations ScreenOrientation; 86 Dasher::Opts::ScreenOrientations ScreenOrientation;
87 87
88 // Advanced colour mode 88 // Advanced colour mode
89 bool ColourMode; 89 bool ColourMode;
90 90
91 // DJW - removed floating point stuff 91 // DJW - removed floating point stuff
92 //double XYScale; 92 //double XYScale;
93}; 93};
94 94
95 95
96#include "DasherView.inl" 96#include "DasherView.inl"
97 97
98 98
99#endif /* #ifndef __DasherView_h_ */ 99#endif /* #ifndef __DasherView_h_ */
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
@@ -1,309 +1,309 @@
1// PPMLanguageModel.h 1// PPMLanguageModel.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 1999-2002 David Ward 5// Copyright (c) 1999-2002 David Ward
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9#include <math.h> 9#include <math.h>
10#include "PPMLanguageModel.h" 10#include "PPMLanguageModel.h"
11 11
12using namespace Dasher; 12using namespace Dasher;
13using namespace std; 13using namespace std;
14 14
15// static TCHAR debug[256]; 15// static TCHAR debug[256];
16typedef unsigned long ulong; 16typedef unsigned long ulong;
17 17
18//////////////////////////////////////////////////////////////////////// 18////////////////////////////////////////////////////////////////////////
19/// PPMnode definitions 19/// PPMnode definitions
20//////////////////////////////////////////////////////////////////////// 20////////////////////////////////////////////////////////////////////////
21 21
22CPPMLanguageModel::CPPMnode *CPPMLanguageModel::CPPMnode::find_symbol(int sym) 22CPPMLanguageModel::CPPMnode *CPPMLanguageModel::CPPMnode::find_symbol(int sym)
23// see if symbol is a child of node 23// see if symbol is a child of node
24{ 24{
25 // printf("finding symbol %d at node %d\n",sym,node->id); 25 // printf("finding symbol %d at node %d\n",sym,node->id);
26 CPPMnode *found=child; 26 CPPMnode *found=child;
27 while (found) { 27 while (found) {
28 if (found->symbol==sym) 28 if (found->symbol==sym)
29 return found; 29 return found;
30 found=found->next; 30 found=found->next;
31 } 31 }
32 return 0; 32 return 0;
33} 33}
34 34
35 35
36CPPMLanguageModel::CPPMnode * CPPMLanguageModel::CPPMnode::add_symbol_to_node(int sym,int *update) 36CPPMLanguageModel::CPPMnode * CPPMLanguageModel::CPPMnode::add_symbol_to_node(int sym,int *update)
37{ 37{
38 CPPMnode *born,*search; 38 CPPMnode *born,*search;
39 search=find_symbol(sym); 39 search=find_symbol(sym);
40 if (!search) { 40 if (!search) {
41 born = new CPPMnode(sym); 41 born = new CPPMnode(sym);
42 born->next=child; 42 born->next=child;
43 child=born; 43 child=born;
44 // node->count=1; 44 // node->count=1;
45 return born; 45 return born;
46 } else { 46 } else {
47 if (*update) { // perform update exclusions 47 if (*update) { // perform update exclusions
48 search->count++; 48 search->count++;
49 *update=0; 49 *update=0;
50 } 50 }
51 return search; 51 return search;
52 } 52 }
53 53
54} 54}
55 55
56 56
57///////////////////////////////////////////////////////////////////// 57/////////////////////////////////////////////////////////////////////
58// CPPMLanguageModel defs 58// CPPMLanguageModel defs
59///////////////////////////////////////////////////////////////////// 59/////////////////////////////////////////////////////////////////////
60 60
61CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization) 61CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization)
62 : CLanguageModel(_alphabet,_normalization) 62 : CLanguageModel(_alphabet,_normalization)
63{ 63{
64 root=new CPPMnode(-1); 64 root=new CPPMnode(-1);
65 m_rootcontext=new CPPMContext(root,0); 65 m_rootcontext=new CPPMContext(root,0);
66} 66}
67 67
68 68
69CPPMLanguageModel::~CPPMLanguageModel() 69CPPMLanguageModel::~CPPMLanguageModel()
70{ 70{
71 delete root; 71 delete root;
72} 72}
73 73
74 74
75bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double addprob) 75bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double )
76 // get the probability distribution at the context 76 // get the probability distribution at the context
77{ 77{
78 // seems like we have to have this hack for VC++ 78 // seems like we have to have this hack for VC++
79 CPPMContext *ppmcontext=static_cast<CPPMContext *> (context); 79 CPPMContext *ppmcontext=static_cast<CPPMContext *> (context);
80 80
81 81
82 int modelchars=GetNumberModelChars(); 82 int modelchars=GetNumberModelChars();
83 int norm=CLanguageModel::normalization(); 83 int norm=CLanguageModel::normalization();
84 probs.resize(modelchars); 84 probs.resize(modelchars);
85 CPPMnode *temp,*s; 85 CPPMnode *temp,*s;
86 int loop,total; 86 int loop,total;
87 int sym; 87 int sym;
88 ulong spent=0; 88 // ulong spent=0;
89 ulong size_of_slice; 89 ulong size_of_slice;
90 bool *exclusions=new bool [modelchars]; 90 bool *exclusions=new bool [modelchars];
91 ulong uniform=modelchars; 91 ulong uniform=modelchars;
92 ulong tospend=norm-uniform; 92 ulong tospend=norm-uniform;
93 temp=ppmcontext->head; 93 temp=ppmcontext->head;
94 for (loop=0; loop <modelchars; loop++) { /* set up the exclusions array */ 94 for (loop=0; loop <modelchars; loop++) { /* set up the exclusions array */
95 probs[loop]=0; 95 probs[loop]=0;
96 exclusions[loop]=0; 96 exclusions[loop]=0;
97 } 97 }
98 while (temp!=0) { 98 while (temp!=0) {
99 //Usprintf(debug,TEXT("tospend %u\n"),tospend); 99 //Usprintf(debug,TEXT("tospend %u\n"),tospend);
100 //DebugOutput(TEXT("round\n")); 100 //DebugOutput(TEXT("round\n"));
101 total=0; 101 total=0;
102 s=temp->child; 102 s=temp->child;
103 while (s) { 103 while (s) {
104 sym=s->symbol; 104 sym=s->symbol;
105 if (!exclusions[s->symbol]) 105 if (!exclusions[s->symbol])
106 total=total+s->count; 106 total=total+s->count;
107 s=s->next; 107 s=s->next;
108 } 108 }
109 if (total) { 109 if (total) {
110 //Usprintf(debug,TEXT"escape %u\n"),tospend* 110 //Usprintf(debug,TEXT"escape %u\n"),tospend*
111 size_of_slice=tospend; 111 size_of_slice=tospend;
112 s=temp->child; 112 s=temp->child;
113 while (s) { 113 while (s) {
114 if (!exclusions[s->symbol]) { 114 if (!exclusions[s->symbol]) {
115 exclusions[s->symbol]=1; 115 exclusions[s->symbol]=1;
116 ulong p=size_of_slice*(2*s->count-1)/2/ulong(total); 116 ulong p=size_of_slice*(2*s->count-1)/2/ulong(total);
117 probs[s->symbol]+=p; 117 probs[s->symbol]+=p;
118 tospend-=p; 118 tospend-=p;
119 } 119 }
120 // Usprintf(debug,TEXT("sym %u counts %d p %u tospend %u \n"),sym,s->count,p,tospend); 120 // Usprintf(debug,TEXT("sym %u counts %d p %u tospend %u \n"),sym,s->count,p,tospend);
121 // DebugOutput(debug); 121 // DebugOutput(debug);
122 s=s->next; 122 s=s->next;
123 } 123 }
124 } 124 }
125 temp = temp->vine; 125 temp = temp->vine;
126 } 126 }
127 //Usprintf(debug,TEXT("Norm %u tospend %u\n"),Norm,tospend); 127 //Usprintf(debug,TEXT("Norm %u tospend %u\n"),Norm,tospend);
128 //DebugOutput(debug); 128 //DebugOutput(debug);
129 129
130 size_of_slice=tospend; 130 size_of_slice=tospend;
131 int symbolsleft=0; 131 int symbolsleft=0;
132 for (sym=1;sym<modelchars;sym++) 132 for (sym=1;sym<modelchars;sym++)
133 if (!probs[sym]) 133 if (!probs[sym])
134 symbolsleft++; 134 symbolsleft++;
135 for (sym=1;sym<modelchars;sym++) 135 for (sym=1;sym<modelchars;sym++)
136 if (!probs[sym]) { 136 if (!probs[sym]) {
137 ulong p=size_of_slice/symbolsleft; 137 ulong p=size_of_slice/symbolsleft;
138 probs[sym]+=p; 138 probs[sym]+=p;
139 tospend-=p; 139 tospend-=p;
140 } 140 }
141 141
142 // distribute what's left evenly 142 // distribute what's left evenly
143 tospend+=uniform; 143 tospend+=uniform;
144 for (sym=1;sym<modelchars;sym++) { 144 for (sym=1;sym<modelchars;sym++) {
145 ulong p=tospend/(modelchars-sym); 145 ulong p=tospend/(modelchars-sym);
146 probs[sym]+=p; 146 probs[sym]+=p;
147 tospend-=p; 147 tospend-=p;
148 } 148 }
149 //Usprintf(debug,TEXT("finaltospend %u\n"),tospend); 149 //Usprintf(debug,TEXT("finaltospend %u\n"),tospend);
150 //DebugOutput(debug); 150 //DebugOutput(debug);
151 151
152 // free(exclusions); // !!! 152 // free(exclusions); // !!!
153 // !!! NB by IAM: p577 Stroustrup 3rd Edition: "Allocating an object using new and deleting it using free() is asking for trouble" 153 // !!! NB by IAM: p577 Stroustrup 3rd Edition: "Allocating an object using new and deleting it using free() is asking for trouble"
154 delete[] exclusions; 154 delete[] exclusions;
155 return true; 155 return true;
156} 156}
157 157
158 158
159void CPPMLanguageModel::AddSymbol(CPPMLanguageModel::CPPMContext &context,int symbol) 159void CPPMLanguageModel::AddSymbol(CPPMLanguageModel::CPPMContext &context,int symbol)
160 // add symbol to the context 160 // add symbol to the context
161 // creates new nodes, updates counts 161 // creates new nodes, updates counts
162 // and leaves 'context' at the new context 162 // and leaves 'context' at the new context
163{ 163{
164 // sanity check 164 // sanity check
165 if (symbol==0 || symbol>=GetNumberModelChars()) 165 if (symbol==0 || symbol>=GetNumberModelChars())
166 return; 166 return;
167 167
168 CPPMnode *vineptr,*temp; 168 CPPMnode *vineptr,*temp;
169 int updatecnt=1; 169 int updatecnt=1;
170 170
171 temp=context.head->vine; 171 temp=context.head->vine;
172 context.head=context.head->add_symbol_to_node(symbol,&updatecnt); 172 context.head=context.head->add_symbol_to_node(symbol,&updatecnt);
173 vineptr=context.head; 173 vineptr=context.head;
174 context.order++; 174 context.order++;
175 175
176 while (temp!=0) { 176 while (temp!=0) {
177 vineptr->vine=temp->add_symbol_to_node(symbol,&updatecnt); 177 vineptr->vine=temp->add_symbol_to_node(symbol,&updatecnt);
178 vineptr=vineptr->vine; 178 vineptr=vineptr->vine;
179 temp=temp->vine; 179 temp=temp->vine;
180 } 180 }
181 vineptr->vine=root; 181 vineptr->vine=root;
182 if (context.order>MAX_ORDER){ 182 if (context.order>MAX_ORDER){
183 context.head=context.head->vine; 183 context.head=context.head->vine;
184 context.order--; 184 context.order--;
185 } 185 }
186} 186}
187 187
188 188
189// update context with symbol 'Symbol' 189// update context with symbol 'Symbol'
190void CPPMLanguageModel::EnterSymbol(CContext* Context, modelchar Symbol) 190void CPPMLanguageModel::EnterSymbol(CContext* Context, modelchar Symbol)
191{ 191{
192 CPPMLanguageModel::CPPMContext& context = * static_cast<CPPMContext *> (Context); 192 CPPMLanguageModel::CPPMContext& context = * static_cast<CPPMContext *> (Context);
193 193
194 CPPMnode *find; 194 CPPMnode *find;
195 CPPMnode *temp=context.head; 195 // CPPMnode *temp=context.head;
196 196
197 while (context.head) { 197 while (context.head) {
198 find =context.head->find_symbol(Symbol); 198 find =context.head->find_symbol(Symbol);
199 if (find) { 199 if (find) {
200 context.order++; 200 context.order++;
201 context.head=find; 201 context.head=find;
202 //Usprintf(debug,TEXT("found context %x order %d\n"),head,order); 202 //Usprintf(debug,TEXT("found context %x order %d\n"),head,order);
203 //DebugOutput(debug); 203 //DebugOutput(debug);
204 return; 204 return;
205 } 205 }
206 context.order--; 206 context.order--;
207 context.head=context.head->vine; 207 context.head=context.head->vine;
208 } 208 }
209 209
210 if (context.head==0) { 210 if (context.head==0) {
211 context.head=root; 211 context.head=root;
212 context.order=0; 212 context.order=0;
213 } 213 }
214 214
215} 215}
216 216
217 217
218void CPPMLanguageModel::LearnSymbol(CContext* Context, modelchar Symbol) 218void CPPMLanguageModel::LearnSymbol(CContext* Context, modelchar Symbol)
219{ 219{
220 CPPMLanguageModel::CPPMContext& context = * static_cast<CPPMContext *> (Context); 220 CPPMLanguageModel::CPPMContext& context = * static_cast<CPPMContext *> (Context);
221 AddSymbol(context, Symbol); 221 AddSymbol(context, Symbol);
222} 222}
223 223
224 224
225void CPPMLanguageModel::dumpSymbol(int symbol) 225void CPPMLanguageModel::dumpSymbol(int symbol)
226{ 226{
227 if ((symbol <= 32) || (symbol >= 127)) 227 if ((symbol <= 32) || (symbol >= 127))
228 printf( "<%d>", symbol ); 228 printf( "<%d>", symbol );
229 else 229 else
230 printf( "%c", symbol ); 230 printf( "%c", symbol );
231} 231}
232 232
233 233
234void CPPMLanguageModel::dumpString( char *str, int pos, int len ) 234void CPPMLanguageModel::dumpString( char *str, int pos, int len )
235 // Dump the string STR starting at position POS 235 // Dump the string STR starting at position POS
236{ 236{
237 char cc; 237 char cc;
238 int p; 238 int p;
239 for (p = pos; p<pos+len; p++) { 239 for (p = pos; p<pos+len; p++) {
240 cc = str [p]; 240 cc = str [p];
241 if ((cc <= 31) || (cc >= 127)) 241 if ((cc <= 31) || (cc >= 127))
242 printf( "<%d>", cc ); 242 printf( "<%d>", cc );
243 else 243 else
244 printf( "%c", cc ); 244 printf( "%c", cc );
245 } 245 }
246} 246}
247 247
248 248
249void CPPMLanguageModel::dumpTrie( CPPMLanguageModel::CPPMnode *t, int d ) 249void CPPMLanguageModel::dumpTrie( CPPMLanguageModel::CPPMnode *, int )
250 // diagnostic display of the PPM trie from node t and deeper 250 // diagnostic display of the PPM trie from node t and deeper
251{ 251{
252//TODO 252//TODO
253/* 253/*
254 dchar debug[256]; 254 dchar debug[256];
255 int sym; 255 int sym;
256 CPPMnode *s; 256 CPPMnode *s;
257 Usprintf( debug,TEXT("%5d %7x "), d, t ); 257 Usprintf( debug,TEXT("%5d %7x "), d, t );
258 //TODO: Uncomment this when headers sort out 258 //TODO: Uncomment this when headers sort out
259 //DebugOutput(debug); 259 //DebugOutput(debug);
260 if (t < 0) // pointer to input 260 if (t < 0) // pointer to input
261 printf( " <" ); 261 printf( " <" );
262 else { 262 else {
263 Usprintf(debug,TEXT( " %3d %5d %7x %7x %7x <"), t->symbol,t->count, t->vine, t->child, t->next ); 263 Usprintf(debug,TEXT( " %3d %5d %7x %7x %7x <"), t->symbol,t->count, t->vine, t->child, t->next );
264 //TODO: Uncomment this when headers sort out 264 //TODO: Uncomment this when headers sort out
265 //DebugOutput(debug); 265 //DebugOutput(debug);
266 } 266 }
267 267
268 dumpString( dumpTrieStr, 0, d ); 268 dumpString( dumpTrieStr, 0, d );
269 Usprintf( debug,TEXT(">\n") ); 269 Usprintf( debug,TEXT(">\n") );
270 //TODO: Uncomment this when headers sort out 270 //TODO: Uncomment this when headers sort out
271 //DebugOutput(debug); 271 //DebugOutput(debug);
272 if (t != 0) { 272 if (t != 0) {
273 s = t->child; 273 s = t->child;
274 while (s != 0) { 274 while (s != 0) {
275 sym =s->symbol; 275 sym =s->symbol;
276 276
277 dumpTrieStr [d] = sym; 277 dumpTrieStr [d] = sym;
278 dumpTrie( s, d+1 ); 278 dumpTrie( s, d+1 );
279 s = s->next; 279 s = s->next;
280 } 280 }
281 } 281 }
282*/ 282*/
283} 283}
284 284
285 285
286void CPPMLanguageModel::dump() 286void CPPMLanguageModel::dump()
287 // diagnostic display of the whole PPM trie 287 // diagnostic display of the whole PPM trie
288{ 288{
289// TODO: 289// TODO:
290/* 290/*
291 dchar debug[256]; 291 dchar debug[256];
292 Usprintf(debug,TEXT( "Dump of Trie : \n" )); 292 Usprintf(debug,TEXT( "Dump of Trie : \n" ));
293 //TODO: Uncomment this when headers sort out 293 //TODO: Uncomment this when headers sort out
294 //DebugOutput(debug); 294 //DebugOutput(debug);
295 Usprintf(debug,TEXT( "---------------\n" )); 295 Usprintf(debug,TEXT( "---------------\n" ));
296 //TODO: Uncomment this when headers sort out 296 //TODO: Uncomment this when headers sort out
297 //DebugOutput(debug); 297 //DebugOutput(debug);
298 Usprintf( debug,TEXT( "depth node symbol count vine child next context\n") ); 298 Usprintf( debug,TEXT( "depth node symbol count vine child next context\n") );
299 //TODO: Uncomment this when headers sort out 299 //TODO: Uncomment this when headers sort out
300 //DebugOutput(debug); 300 //DebugOutput(debug);
301 dumpTrie( root, 0 ); 301 dumpTrie( root, 0 );
302 Usprintf( debug,TEXT( "---------------\n" )); 302 Usprintf( debug,TEXT( "---------------\n" ));
303 //TODO: Uncomment this when headers sort out 303 //TODO: Uncomment this when headers sort out
304 //DebugOutput(debug); 304 //DebugOutput(debug);
305 Usprintf(debug,TEXT( "\n" )); 305 Usprintf(debug,TEXT( "\n" ));
306 //TODO: Uncomment this when headers sort out 306 //TODO: Uncomment this when headers sort out
307 //DebugOutput(debug); 307 //DebugOutput(debug);
308*/ 308*/
309} 309}
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,122 +1,123 @@
1// PPMLanguageModel.h 1// PPMLanguageModel.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 1999-2002 David Ward 5// Copyright (c) 1999-2002 David Ward
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9#ifndef __PPMLanguageModel_h__ 9#ifndef __PPMLanguageModel_h__
10#define __PPMLanguageModel_h__ 10#define __PPMLanguageModel_h__
11 11
12#include "NoClones.h" 12#include "NoClones.h"
13#include "MSVC_Unannoy.h" 13#include "MSVC_Unannoy.h"
14#include <vector> 14#include <vector>
15#include <stdio.h> 15#include <stdio.h>
16 16
17#include "LanguageModel.h" 17#include "LanguageModel.h"
18 18
19static char dumpTrieStr[40000]; 19// static char dumpTrieStr[40000];
20const int MAX_ORDER = 5; 20const int MAX_ORDER = 5;
21const int maxcont =200; 21const int maxcont =200;
22 22
23namespace Dasher {class CPPMLanguageModel;} 23namespace Dasher {class CPPMLanguageModel;}
24class Dasher::CPPMLanguageModel : public Dasher::CLanguageModel, private NoClones 24class Dasher::CPPMLanguageModel : public Dasher::CLanguageModel, private NoClones
25{ 25{
26public: 26public:
27 CPPMLanguageModel(CAlphabet *_alphabet, int _normalization); 27 CPPMLanguageModel(CAlphabet *_alphabet, int _normalization);
28 ~CPPMLanguageModel(); 28 virtual ~CPPMLanguageModel();
29 29
30 class CPPMnode { 30 class CPPMnode {
31 public: 31 public:
32 CPPMnode* find_symbol(int sym); 32 CPPMnode* find_symbol(int sym);
33 CPPMnode* add_symbol_to_node(int sym,int *update); 33 CPPMnode* add_symbol_to_node(int sym,int *update);
34 CPPMnode* child; 34 CPPMnode* child;
35 CPPMnode* next; 35 CPPMnode* next;
36 CPPMnode* vine; 36 CPPMnode* vine;
37 short int count; 37 short int count;
38 const short int symbol; 38 const short int symbol;
39 CPPMnode(int sym); 39 CPPMnode(int sym);
40 }; 40 };
41 41
42 class CPPMContext : public CContext { 42 class CPPMContext : public CContext {
43 public: 43 public:
44 CPPMContext(CPPMContext const &input) {head = input.head;order= input.order;} 44 CPPMContext(CPPMContext const &input) : CContext(input)
45 { head = input.head;order= input.order;}
45 CPPMContext(CPPMnode* _head=0, int _order=0) : head(_head),order(_order) {}; 46 CPPMContext(CPPMnode* _head=0, int _order=0) : head(_head),order(_order) {};
46 ~CPPMContext() {}; 47 ~CPPMContext() {};
47 void dump(); 48 void dump();
48 CPPMnode* head; 49 CPPMnode* head;
49 int order; 50 int order;
50 }; 51 };
51 52
52 void ReleaseContext(CContext*); 53 void ReleaseContext(CContext*);
53 CContext* GetRootContext(); 54 CContext* GetRootContext();
54 inline CContext* CloneContext(CContext*); 55 inline CContext* CloneContext(CContext*);
55 void EnterSymbol(CContext* context, modelchar Symbol); 56 void EnterSymbol(CContext* context, modelchar Symbol);
56 //inline bool GetProbs(CContext*,std::vector<symbol> &newchars,std::vector<unsigned int> &groups,std::vector<unsigned int> &probs,double addprob); 57 //inline bool GetProbs(CContext*,std::vector<symbol> &newchars,std::vector<unsigned int> &groups,std::vector<unsigned int> &probs,double addprob);
57 bool GetProbs(CContext*, std::vector<unsigned int> &Probs, double AddProb); 58 bool GetProbs(CContext*, std::vector<unsigned int> &Probs, double AddProb);
58 59
59 void LearnSymbol(CContext* Context, modelchar Symbol); 60 void LearnSymbol(CContext* Context, modelchar Symbol);
60 void dump(); 61 void dump();
61 62
62private: 63private:
63 CPPMContext *m_rootcontext; 64 CPPMContext *m_rootcontext;
64 CPPMnode *root; 65 CPPMnode *root;
65 void AddSymbol(CPPMContext& context,int symbol); 66 void AddSymbol(CPPMContext& context,int symbol);
66 void dumpSymbol(int symbol); 67 void dumpSymbol(int symbol);
67 void dumpString( char *str, int pos, int len ); 68 void dumpString( char *str, int pos, int len );
68 void dumpTrie( CPPMnode *t, int d ); 69 void dumpTrie( CPPMnode *t, int d );
69 70
70 71
71 72
72}; 73};
73 74
74//////////////////////////////////////////////////////////////////////// 75////////////////////////////////////////////////////////////////////////
75// Inline functions 76// Inline functions
76//////////////////////////////////////////////////////////////////////// 77////////////////////////////////////////////////////////////////////////
77 78
78//////////////////////////////////////////////////////////////////////// 79////////////////////////////////////////////////////////////////////////
79 80
80inline CPPMLanguageModel::CPPMnode::CPPMnode(int sym) : symbol(sym) 81inline CPPMLanguageModel::CPPMnode::CPPMnode(int sym) : symbol(sym)
81{ 82{
82 child=next=vine=0; 83 child=next=vine=0;
83 count=1; 84 count=1;
84} 85}
85 86
86/////////////////////////////////////////////////////////////////// 87///////////////////////////////////////////////////////////////////
87 88
88inline void CPPMLanguageModel::CPPMContext::dump() 89inline void CPPMLanguageModel::CPPMContext::dump()
89 // diagnostic output 90 // diagnostic output
90{ 91{
91 // TODO uncomment this when headers sorted out 92 // TODO uncomment this when headers sorted out
92 //dchar debug[128]; 93 //dchar debug[128];
93 //Usprintf(debug,TEXT("head %x order %d\n"),head,order); 94 //Usprintf(debug,TEXT("head %x order %d\n"),head,order);
94 //DebugOutput(debug); 95 //DebugOutput(debug);
95} 96}
96 97
97/////////////////////////////////////////////////////////////////// 98///////////////////////////////////////////////////////////////////
98 99
99inline CContext* CPPMLanguageModel::GetRootContext() 100inline CContext* CPPMLanguageModel::GetRootContext()
100{ 101{
101 CPPMContext * nc = new CPPMLanguageModel::CPPMContext(*m_rootcontext); 102 CPPMContext * nc = new CPPMLanguageModel::CPPMContext(*m_rootcontext);
102 CContext *cont=static_cast<CContext *> (nc); 103 CContext *cont=static_cast<CContext *> (nc);
103 return cont; 104 return cont;
104} 105}
105 106
106/////////////////////////////////////////////////////////////////// 107///////////////////////////////////////////////////////////////////
107 108
108inline CContext* CPPMLanguageModel::CloneContext(CContext *copythis) 109inline CContext* CPPMLanguageModel::CloneContext(CContext *copythis)
109{ 110{
110 CPPMContext *ppmcontext=static_cast<CPPMContext *> (copythis); 111 CPPMContext *ppmcontext=static_cast<CPPMContext *> (copythis);
111 CPPMContext * nc = new CPPMLanguageModel::CPPMContext(*ppmcontext); 112 CPPMContext * nc = new CPPMLanguageModel::CPPMContext(*ppmcontext);
112 return static_cast<CContext *> (nc); 113 return static_cast<CContext *> (nc);
113} 114}
114 115
115/////////////////////////////////////////////////////////////////// 116///////////////////////////////////////////////////////////////////
116 117
117inline void CPPMLanguageModel::ReleaseContext(CContext *release) 118inline void CPPMLanguageModel::ReleaseContext(CContext *release)
118{ 119{
119 delete release; 120 delete release;
120} 121}
121 122
122#endif /* #ifndef __PPMLanguageModel_H__ */ 123#endif /* #ifndef __PPMLanguageModel_H__ */
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,87 +1,87 @@
1#include <iostream> 1#include <iostream>
2#include <qapplication.h> 2#include <qapplication.h>
3#include <qobject.h> 3#include <qobject.h>
4#include <qpixmap.h> 4#include <qpixmap.h>
5#include "DasherInterface.h" 5#include "DasherInterface.h"
6#include "QtDasherScreen.h" 6#include "QtDasherScreen.h"
7#include "QtDasherImpl.h" 7#include "QtDasherImpl.h"
8 8
9/* XPM */ 9/* XPM */
10static const char * qtdasher_xpm[]={ 10static const char * qtdasher_xpm[]={
11"28 7 2 1", 11"28 7 2 1",
12"# c #303030", 12"# c #303030",
13" c None", 13" c None",
14" ########################## ", 14" ########################## ",
15" ", 15" ",
16" # # ", 16" # # ",
17" # # # # ", 17" # # # # ",
18" # # # # ", 18" # # # # ",
19" # # # ", 19" # # # ",
20" ########################## "}; 20" ########################## "};
21 21
22 22
23QtDasherImpl::QtDasherImpl() 23QtDasherImpl::QtDasherImpl()
24 : qtdasherwidget(0), icn(0), qtdasherinterface(0) 24 : qtdasherinterface(0), qtdasherwidget(0), icn(0)
25{ 25{
26} 26}
27 27
28QtDasherImpl::~QtDasherImpl() 28QtDasherImpl::~QtDasherImpl()
29{ 29{
30 delete qtdasherwidget; 30 delete qtdasherwidget;
31 delete icn; 31 delete icn;
32} 32}
33 33
34QWidget *QtDasherImpl::inputMethod( QWidget *parent, Qt::WFlags f ) 34QWidget *QtDasherImpl::inputMethod( QWidget *parent, Qt::WFlags f )
35{ 35{
36 if ( !qtdasherwidget ) { 36 if ( !qtdasherwidget ) {
37 qtdasherwidget = new QtDasherPlugin( parent, "Dasher", f ); 37 qtdasherwidget = new QtDasherPlugin( parent, "Dasher", f );
38 } 38 }
39 return qtdasherwidget; 39 return qtdasherwidget;
40} 40}
41 41
42void QtDasherImpl::resetState() 42void QtDasherImpl::resetState()
43{ 43{
44 if ( qtdasherwidget ) 44 if ( qtdasherwidget )
45 qtdasherwidget->resetState(); 45 qtdasherwidget->resetState();
46} 46}
47 47
48QPixmap *QtDasherImpl::icon() 48QPixmap *QtDasherImpl::icon()
49{ 49{
50 if ( !icn ) 50 if ( !icn )
51 icn = new QPixmap( (const char **)qtdasher_xpm ); 51 icn = new QPixmap( (const char **)qtdasher_xpm );
52 return icn; 52 return icn;
53} 53}
54 54
55QString QtDasherImpl::name() 55QString QtDasherImpl::name()
56{ 56{
57 return qApp->translate( "InputMethods", "Dasher" ); 57 return qApp->translate( "InputMethods", "Dasher" );
58} 58}
59 59
60void QtDasherImpl::onKeyPress( QObject *receiver, const char *slot ) 60void QtDasherImpl::onKeyPress( QObject *receiver, const char *slot )
61{ 61{
62 if ( qtdasherwidget ) 62 if ( qtdasherwidget )
63 QObject::connect( qtdasherwidget, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); 63 QObject::connect( qtdasherwidget, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
64} 64}
65 65
66#ifndef QT_NO_COMPONENT 66#ifndef QT_NO_COMPONENT
67QRESULT QtDasherImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 67QRESULT QtDasherImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
68{ 68{
69 *iface = 0; 69 *iface = 0;
70 if ( uuid == IID_QUnknown ) 70 if ( uuid == IID_QUnknown )
71 *iface = this; 71 *iface = this;
72 else if ( uuid == IID_InputMethod ) 72 else if ( uuid == IID_InputMethod )
73 *iface = this; 73 *iface = this;
74 else 74 else
75 return QS_FALSE; 75 return QS_FALSE;
76 76
77 if ( *iface ) 77 if ( *iface )
78 (*iface)->addRef(); 78 (*iface)->addRef();
79 return QS_OK; 79 return QS_OK;
80} 80}
81 81
82Q_EXPORT_INTERFACE() 82Q_EXPORT_INTERFACE()
83{ 83{
84 Q_CREATE_INSTANCE( QtDasherImpl ) 84 Q_CREATE_INSTANCE( QtDasherImpl )
85} 85}
86#endif 86#endif
87 87
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
@@ -1,79 +1,79 @@
1#include "QtDasherPlugin.h" 1#include "QtDasherPlugin.h"
2 2
3#include <qpe/global.h> 3#include <qpe/global.h>
4 4
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qlist.h> 6#include <qlist.h>
7#include <qbitmap.h> 7#include <qbitmap.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qvbox.h> 9#include <qvbox.h>
10#include <qdialog.h> 10#include <qdialog.h>
11#include <qscrollview.h> 11#include <qscrollview.h>
12#include <qpopupmenu.h> 12#include <qpopupmenu.h>
13#include <qhbuttongroup.h> 13#include <qhbuttongroup.h>
14#include <qpushbutton.h> 14#include <qpushbutton.h>
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16#include <qwindowsystem_qws.h> 16#include <qwindowsystem_qws.h>
17 17
18QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f) 18QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f)
19{ 19{
20 (new QHBoxLayout(this))->setAutoAdd(TRUE); 20 (new QHBoxLayout(this))->setAutoAdd(TRUE);
21 interface = new CDasherInterface; 21 interface = new CDasherInterface;
22 interface->SetSystemLocation("/opt/QtPalmtop/share/dasher/"); 22 interface->SetSystemLocation("/opt/QtPalmtop/share/dasher/");
23 interface->Unpause(0); 23 interface->Unpause(0);
24 interface->Start(); 24 interface->Start();
25 d = new QtDasherScreen(240,100,interface,this,this); 25 d = new QtDasherScreen(240,100,interface,this,this);
26 interface->ChangeMaxBitRate(2.5); 26 interface->ChangeMaxBitRate(2.5);
27 d->show(); 27 d->show();
28 utf8_codec = new QUtf8Codec; 28 utf8_codec = new QUtf8Codec;
29} 29}
30 30
31QSize QtDasherPlugin::sizeHint() const 31QSize QtDasherPlugin::sizeHint() const
32{ 32{
33 return QSize(240,100); 33 return QSize(240,100);
34} 34}
35 35
36QtDasherPlugin::~QtDasherPlugin() 36QtDasherPlugin::~QtDasherPlugin()
37{ 37{
38 delete d; 38 delete d;
39} 39}
40 40
41void QtDasherPlugin::resetState() 41void QtDasherPlugin::resetState()
42{ 42{
43 flushcount=0; 43 flushcount=0;
44 interface->Start(); 44 interface->Start();
45 interface->Redraw(); 45 interface->Redraw();
46} 46}
47 47
48void QtDasherPlugin::unflush() 48void QtDasherPlugin::unflush()
49{ 49{
50 if (flushcount==0) 50 if (flushcount==0)
51 return; 51 return;
52 for (flushcount; flushcount>0; flushcount--) { 52 for (; flushcount>0; flushcount--) {
53 deletetext(); 53 deletetext();
54 } 54 }
55} 55}
56 56
57void QtDasherPlugin::output(int Symbol) 57void QtDasherPlugin::output(int Symbol)
58{ 58{
59 std::string label = interface->GetEditText(Symbol); 59 std::string label = interface->GetEditText(Symbol);
60 QString unicodestring = utf8_codec->toUnicode(label.c_str()); 60 QString unicodestring = utf8_codec->toUnicode(label.c_str());
61 for (int i=0; i<int(unicodestring.length()); i++) { 61 for (int i=0; i<int(unicodestring.length()); i++) {
62 emit key( unicodestring[i].unicode(), 0, 0, true, false ); 62 emit key( unicodestring[i].unicode(), 0, 0, true, false );
63 emit key( unicodestring[i].unicode(), 0, 0, false, false ); 63 emit key( unicodestring[i].unicode(), 0, 0, false, false );
64 } 64 }
65} 65}
66 66
67void QtDasherPlugin::deletetext() 67void QtDasherPlugin::deletetext()
68{ 68{
69 emit key( 0, Qt::Key_Backspace, 0, true, false); 69 emit key( 0, Qt::Key_Backspace, 0, true, false);
70 emit key( 0, Qt::Key_Backspace, 0, false, false); 70 emit key( 0, Qt::Key_Backspace, 0, false, false);
71} 71}
72 72
73void QtDasherPlugin::flush(int Symbol) 73void QtDasherPlugin::flush(int Symbol)
74{ 74{
75 if (Symbol==0) 75 if (Symbol==0)
76 return; 76 return;
77 output(Symbol); 77 output(Symbol);
78 flushcount++; 78 flushcount++;
79} 79}
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 @@
1#include <qutfcodec.h> 1#include <qutfcodec.h>
2#include <qframe.h> 2#include <qframe.h>
3#include "QtDasherScreen.h" 3#include "QtDasherScreen.h"
4#include "DasherInterface.h" 4#include "DasherInterface.h"
5#include "DashEdit.h" 5#include "DashEdit.h"
6 6
7class QtDasherPlugin : public QFrame, public CDashEditbox 7class QtDasherPlugin : public QFrame, public CDashEditbox
8{ 8{
9 Q_OBJECT 9 Q_OBJECT
10public: 10public:
11 QtDasherPlugin(QWidget* parent=0, const char* name=0, WFlags f=0); 11 QtDasherPlugin(QWidget* parent=0, const char* name=0, WFlags f=0);
12 ~QtDasherPlugin(); 12 ~QtDasherPlugin();
13 13
14 void resetState(); 14 void resetState();
15 QSize sizeHint() const; 15 QSize sizeHint() const;
16 16
17 void write_to_file() {}; 17 void write_to_file() {};
18 void get_new_context(std::string&, int) {}; 18 void get_new_context(std::string&, int) {};
19 void unflush(); 19 void unflush();
20 void output(int); 20 void output(int);
21 void deletetext(); 21 void deletetext();
22 void flush(int); 22 void flush(int);
23 void Clear() {}; 23 void Clear() {};
24 void SetEncoding(Dasher::Opts::FileEncodingFormats) {}; 24 void SetEncoding(Dasher::Opts::FileEncodingFormats) {};
25 void SetFont(std::string Name, long Size) {}; 25 void SetFont(std::string , long ) {};
26 26
27 signals: 27 signals:
28 void key( ushort, ushort, ushort, bool, bool); 28 void key( ushort, ushort, ushort, bool, bool);
29 29
30 private: 30 private:
31 QtDasherScreen *d; 31 QtDasherScreen *d;
32 CDasherInterface *interface; 32 CDasherInterface *interface;
33 int flushcount; 33 int flushcount;
34 QUtf8Codec *utf8_codec; 34 QUtf8Codec *utf8_codec;
35}; 35};
36 36
37 37
38 38
39 39
40 40
41 41
42 42
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,177 +1,182 @@
1// QtDasherScreen.cc 1// QtDasherScreen.cc
2// (c) 2003 Yann Dirson 2// (c) 2003 Yann Dirson
3// Derived from GtkDasherCanvas.cc 3// Derived from GtkDasherCanvas.cc
4// (c) 2002 Philip Cowans 4// (c) 2002 Philip Cowans
5 5
6#include <iostream> 6#include <iostream>
7#include <string> 7#include <string>
8 8
9#include <qpointarray.h> 9#include <qpointarray.h>
10#include <qpoint.h> 10#include <qpoint.h>
11 11
12#include "QtDasherScreen.h" 12#include "QtDasherScreen.h"
13#include "DasherScreen.h" 13#include "DasherScreen.h"
14#include "SettingsStore.h" 14#include "SettingsStore.h"
15 15
16#define MAXFONTSIZE 25 16#define MAXFONTSIZE 25
17#define MINFONTSIZE 8 17#define MINFONTSIZE 8
18 18
19QtDasherScreen::QtDasherScreen (int _width, int _height, 19QtDasherScreen::QtDasherScreen (int _width, int _height,
20 CDasherInterface *_interface, 20 CDasherInterface *_interface,
21 QWidget * _parent, Dasher::CDashEditbox *edit): 21 QWidget * _parent,
22 QWidget(_parent), interface( _interface ), 22 Dasher::CDashEditbox *_edit):
23 fontname( "fixed" ), fontsize(12), 23 QWidget(_parent),
24 Dasher::CDasherScreen(_width, _height) 24 Dasher::CDasherScreen(_width, _height),
25 fontsize(12),
26 interface( _interface ),
27 fontname( "fixed" )
25{ 28{
26 font = QFont (fontname.c_str(), fontsize); 29 font = QFont (fontname.c_str(), fontsize);
27 painter = new QPainter (); 30 painter = new QPainter ();
28 31
29 pixmap = new QPixmap (_width, _height); 32 pixmap = new QPixmap (_width, _height);
30 pixmap->setOptimization(QPixmap::BestOptim); 33 pixmap->setOptimization(QPixmap::BestOptim);
31 interface->SetSettingsStore(new CSettingsStore); 34 interface->SetSettingsStore(new CSettingsStore);
32 35
33 interface->ChangeLanguageModel(0); 36 interface->ChangeLanguageModel(0);
34 interface->ChangeView(0); 37 interface->ChangeView(0);
35 interface->ChangeEdit(edit); 38 interface->ChangeEdit(_edit);
39 edit = _edit;
40
36 41
37/* interface->GetFontSizes(&FontSizes); 42/* interface->GetFontSizes(&FontSizes);
38 43
39 for (int i=0; i<FontSizes.size(); i++) { 44 for (int i=0; i<FontSizes.size(); i++) {
40 if (FontSizes[i]>Fonts.size()) 45 if (FontSizes[i]>Fonts.size())
41 Fonts.resize((FontSizes[i])+1); 46 Fonts.resize((FontSizes[i])+1);
42 Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]); 47 Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]);
43// Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); 48// Fonts[FontSizes[i]].setPixelSize(FontSizes[i]);
44 } 49 }
45*/ 50*/
46 interface->ChangeScreen(this); 51 interface->ChangeScreen(this);
47 52
48 paused=true; 53 paused=true;
49 54
50 QTimer *tmr = new QTimer(this); 55 QTimer *tmr = new QTimer(this);
51 connect (tmr, SIGNAL(timeout()), SLOT(timer())); 56 connect (tmr, SIGNAL(timeout()), SLOT(timer()));
52 tmr->start(200); 57 tmr->start(200);
53 58
54} 59}
55 60
56long QtDasherScreen::get_time() 61long QtDasherScreen::get_time()
57{ 62{
58 long s_now; 63 long s_now;
59 long ms_now; 64 long ms_now;
60 65
61 struct timeval tv; 66 struct timeval tv;
62 struct timezone tz; 67 struct timezone tz;
63 68
64 gettimeofday( &tv, &tz ); 69 gettimeofday( &tv, &tz );
65 70
66 s_now = tv.tv_sec-1054487600; 71 s_now = tv.tv_sec-1054487600;
67 72
68 ms_now = tv.tv_usec / 1000; 73 ms_now = tv.tv_usec / 1000;
69 74
70 return( long(s_now*1000 + ms_now) ); 75 return( long(s_now*1000 + ms_now) );
71 76
72} 77}
73 78
74QtDasherScreen::~QtDasherScreen() 79QtDasherScreen::~QtDasherScreen()
75{ 80{
76 delete painter; 81 delete painter;
77 delete interface; 82 delete interface;
78 delete edit; 83 delete edit;
79} 84}
80 85
81QColor QtDasherScreen::getColor(int Color, const Opts::ColorSchemes ColorScheme) const 86QColor QtDasherScreen::getColor(int Color, const Opts::ColorSchemes ColorScheme) const
82{ 87{
83 switch (ColorScheme) { 88 switch (ColorScheme) {
84 case Dasher::Opts::Nodes1: 89 case Dasher::Opts::Nodes1:
85 switch (Color) { 90 switch (Color) {
86 case 0: return QColor (180, 245, 180); 91 case 0: return QColor (180, 245, 180);
87 case 1: return QColor (160, 200, 160); 92 case 1: return QColor (160, 200, 160);
88 case 2: return QColor (0, 255, 255); 93 case 2: return QColor (0, 255, 255);
89 default: abort (); 94 default: abort ();
90 } 95 }
91 case Dasher::Opts::Nodes2: 96 case Dasher::Opts::Nodes2:
92 switch (Color) { 97 switch (Color) {
93 case 0: return QColor (255, 185, 255); 98 case 0: return QColor (255, 185, 255);
94 case 1: return QColor (140, 200, 255); 99 case 1: return QColor (140, 200, 255);
95 case 2: return QColor (255, 175, 175); 100 case 2: return QColor (255, 175, 175);
96 default: abort (); 101 default: abort ();
97 } 102 }
98 case Dasher::Opts::Special1: return QColor (240, 240, 240); 103 case Dasher::Opts::Special1: return QColor (240, 240, 240);
99 case Dasher::Opts::Special2: return QColor (255, 255, 255); 104 case Dasher::Opts::Special2: return QColor (255, 255, 255);
100 case Dasher::Opts::Groups: 105 case Dasher::Opts::Groups:
101 switch (Color) { 106 switch (Color) {
102 case 0: return QColor (255, 255, 0); 107 case 0: return QColor (255, 255, 0);
103 case 1: return QColor (255, 100, 100); 108 case 1: return QColor (255, 100, 100);
104 case 2: return QColor (0, 255, 0); 109 case 2: return QColor (0, 255, 0);
105 default: abort (); 110 default: abort ();
106 } 111 }
107 case Dasher::Opts::Objects: return QColor (0, 0, 0); 112 case Dasher::Opts::Objects: return QColor (0, 0, 0);
108 default: abort(); 113 default: abort();
109 } 114 }
110} 115}
111 116
112void QtDasherScreen::DrawRectangle(int x1, int y1, int x2, int y2, 117void QtDasherScreen::DrawRectangle(int x1, int y1, int x2, int y2,
113 int Color, Opts::ColorSchemes ColorScheme) const 118 int Color, Opts::ColorSchemes ColorScheme) const
114{ 119{
115 painter->setBrush (getColor (Color, ColorScheme)); 120 painter->setBrush (getColor (Color, ColorScheme));
116 painter->drawRect (x1, y1, x2-x1, y2-y1); 121 painter->drawRect (x1, y1, x2-x1, y2-y1);
117} 122}
118 123
119static void Points_to_QPointArray(const Dasher::CDasherScreen::point* const points, 124static void Points_to_QPointArray(const Dasher::CDasherScreen::point* const points,
120 int number, 125 int number,
121 QPointArray &qpa) 126 QPointArray &qpa)
122{ 127{
123 for (int i = 0; i < number; i++) { 128 for (int i = 0; i < number; i++) {
124 qpa.setPoint (i, points[i].x, points[i].y); 129 qpa.setPoint (i, points[i].x, points[i].y);
125 } 130 }
126} 131}
127 132
128void QtDasherScreen::Polyline(point* Points, int Number) const 133void QtDasherScreen::Polyline(point* Points, int Number) const
129{ 134{
130 QPointArray qpa(Number); 135 QPointArray qpa(Number);
131 Points_to_QPointArray (Points, Number, qpa); 136 Points_to_QPointArray (Points, Number, qpa);
132 painter->setPen (SolidLine); 137 painter->setPen (SolidLine);
133 painter->drawPolyline (qpa); 138 painter->drawPolyline (qpa);
134 painter->setPen (NoPen); 139 painter->setPen (NoPen);
135} 140}
136 141
137void QtDasherScreen::DrawPolygon(point* Points, int Number, int Color, 142void QtDasherScreen::DrawPolygon(point* Points, int Number, int Color,
138 Opts::ColorSchemes ColorScheme) const 143 Opts::ColorSchemes ColorScheme) const
139{ 144{
140 painter->setBrush (getColor (Color, ColorScheme)); 145 painter->setBrush (getColor (Color, ColorScheme));
141 QPointArray qpa(Number); 146 QPointArray qpa(Number);
142 Points_to_QPointArray (Points, Number, qpa); 147 Points_to_QPointArray (Points, Number, qpa);
143 painter->drawPolygon (qpa); 148 painter->drawPolygon (qpa);
144} 149}
145 150
146void QtDasherScreen::mousePressEvent (QMouseEvent *e) 151void QtDasherScreen::mousePressEvent (QMouseEvent *)
147{ 152{
148 paused=false; 153 paused=false;
149 interface->Unpause(get_time()); 154 interface->Unpause(get_time());
150} 155}
151 156
152void QtDasherScreen::mouseReleaseEvent(QMouseEvent *e) 157void QtDasherScreen::mouseReleaseEvent(QMouseEvent *e)
153{ 158{
154 QPoint p = e->pos(); 159 QPoint p = e->pos();
155 interface->PauseAt(p.x(), p.y()); 160 interface->PauseAt(p.x(), p.y());
156 paused=true; 161 paused=true;
157} 162}
158 163
159void QtDasherScreen::timer() 164void QtDasherScreen::timer()
160{ 165{
161 if (paused==false) { 166 if (paused==false) {
162 QPoint cursorpos; 167 QPoint cursorpos;
163 cursorpos=this->cursor().pos(); 168 cursorpos=this->cursor().pos();
164 cursorpos=mapFromGlobal(cursorpos); 169 cursorpos=mapFromGlobal(cursorpos);
165 170
166 interface->TapOn(cursorpos.x(), cursorpos.y(), get_time()); 171 interface->TapOn(cursorpos.x(), cursorpos.y(), get_time());
167 } 172 }
168} 173}
169 174
170 175
171 176
172 177
173 178
174 179
175 180
176 181
177 182
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
@@ -1,116 +1,116 @@
1// QtDasherScreen.h 1// QtDasherScreen.h
2// (c) 2003 Yann Dirson 2// (c) 2003 Yann Dirson
3// Derived from GtkDasherCanvas.h 3// Derived from GtkDasherCanvas.h
4// (c) 2002 Philip Cowans 4// (c) 2002 Philip Cowans
5 5
6#ifndef QT_DASHER_SCREEN_H 6#ifndef QT_DASHER_SCREEN_H
7#define QT_DASHER_SCREEN_H 7#define QT_DASHER_SCREEN_H
8 8
9#include <string> 9#include <string>
10#include <sys/time.h> 10#include <sys/time.h>
11 11
12#include <qwidget.h> 12#include <qwidget.h>
13#include <qpainter.h> 13#include <qpainter.h>
14#include <qfont.h> 14#include <qfont.h>
15#include <qstring.h> 15#include <qstring.h>
16#include <qpixmap.h> 16#include <qpixmap.h>
17#include <qtimer.h> 17#include <qtimer.h>
18#include <qcursor.h> 18#include <qcursor.h>
19 19
20#include "DasherScreen.h" 20#include "DasherScreen.h"
21#include "DashEdit.h" 21#include "DashEdit.h"
22#include "DasherInterface.h" 22#include "DasherInterface.h"
23 23
24using namespace Dasher; 24using namespace Dasher;
25 25
26class QtDasherScreen : public QWidget, public Dasher::CDasherScreen 26class QtDasherScreen : public QWidget, public Dasher::CDasherScreen
27 27
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30 public: 30 public:
31 QtDasherScreen (int _width, int _height, 31 QtDasherScreen (int _width, int _height,
32 CDasherInterface *_interface, 32 CDasherInterface *_interface,
33 QWidget * _parent=0, Dasher::CDashEditbox* edit=0); 33 QWidget * _parent=0, Dasher::CDashEditbox* edit=0);
34 QtDasherScreen::~QtDasherScreen(); 34 QtDasherScreen::~QtDasherScreen();
35 35
36 void SetFont(std::string Name) 36 void SetFont(std::string Name)
37 { fontname = Name; /* set_the_font(); */ } 37 { fontname = Name; /* set_the_font(); */ }
38 38
39 void SetFontSize(Dasher::Opts::FontSize fontsize) 39 void SetFontSize(Dasher::Opts::FontSize )
40 { 40 {
41#warning QtDasherScreen::SetFontSize() not implemented 41#warning QtDasherScreen::SetFontSize() not implemented
42 } 42 }
43 Dasher::Opts::FontSize GetFontSize() 43 Dasher::Opts::FontSize GetFontSize()
44 { 44 {
45#warning QtDasherScreen::GetFontSize() not implemented 45#warning QtDasherScreen::GetFontSize() not implemented
46 return (Dasher::Opts::Normal); 46 return (Dasher::Opts::Normal);
47 } 47 }
48 48
49 void TextSize(symbol Character, int* Width, int* Height, int Size) const 49 void TextSize(symbol , int* Width, int* Height, int ) const
50 { 50 {
51 // should probably use QPainter::boundingRect() 51 // should probably use QPainter::boundingRect()
52 *Width = *Height = font.pixelSize(); 52 *Width = *Height = font.pixelSize();
53 53
54 } 54 }
55 void DrawText(symbol Character, int x1, int y1, int Size) const 55 void DrawText(symbol Character, int x1, int y1, int Size) const
56 { 56 {
57 // QFont font = QFont (fontname.c_str(), Size); 57 // QFont font = QFont (fontname.c_str(), Size);
58 // font.setPixelSize(Size); 58 // font.setPixelSize(Size);
59 QPoint point = QPoint(x1, y1+Size/2); 59 QPoint point = QPoint(x1, y1+Size/2);
60 60
61 painter->setFont (font); 61 painter->setFont (font);
62 painter->drawText (point, 62 painter->drawText (point,
63 QString(interface->GetDisplayText(Character).c_str())); 63 QString(interface->GetDisplayText(Character).c_str()));
64 } 64 }
65 65
66 void DrawRectangle(int x1, int y1, int x2, int y2, 66 void DrawRectangle(int x1, int y1, int x2, int y2,
67 int Color, Opts::ColorSchemes ColorScheme) const; 67 int Color, Opts::ColorSchemes ColorScheme) const;
68 void Polyline(point* Points, int Number) const; 68 void Polyline(point* Points, int Number) const;
69 void DrawPolygon(point* Points, int Number, int Color, 69 void DrawPolygon(point* Points, int Number, int Color,
70 Opts::ColorSchemes ColorScheme) const; 70 Opts::ColorSchemes ColorScheme) const;
71 71
72 std::vector<int> FontSizes; 72 std::vector<int> FontSizes;
73 std::vector<QFont> Fonts; 73 std::vector<QFont> Fonts;
74 QFont font; 74 QFont font;
75 int fontsize; 75 int fontsize;
76 void Blank() const { 76 void Blank() const {
77 painter->begin(pixmap); 77 painter->begin(pixmap);
78 painter->setPen (NoPen); 78 painter->setPen (NoPen);
79 painter->fillRect(0, 0, m_iWidth, m_iHeight, 79 painter->fillRect(0, 0, m_iWidth, m_iHeight,
80 QColor(255,255,255)); 80 QColor(255,255,255));
81 } 81 }
82 void Display() { 82 void Display() {
83 painter->end(); 83 painter->end();
84 repaint(); 84 repaint();
85 } 85 }
86 86
87 void paintEvent( QPaintEvent * ) 87 void paintEvent( QPaintEvent * )
88 { 88 {
89 bitBlt(this, 0, 0, pixmap); 89 bitBlt(this, 0, 0, pixmap);
90 } 90 }
91 91
92 void mousePressEvent (QMouseEvent *e); 92 void mousePressEvent (QMouseEvent *e);
93 void mouseReleaseEvent (QMouseEvent *e); 93 void mouseReleaseEvent (QMouseEvent *e);
94 94
95 protected: 95 protected:
96 QColor getColor(int Color, const Opts::ColorSchemes ColorScheme) const; 96 QColor getColor(int Color, const Opts::ColorSchemes ColorScheme) const;
97 97
98 long QtDasherScreen::get_time(); 98 long QtDasherScreen::get_time();
99 99
100 CDasherInterface* interface; 100 CDasherInterface* interface;
101 Dasher::CDashEditbox* edit; 101 Dasher::CDashEditbox* edit;
102 102
103 bool paused; 103 bool paused;
104 104
105 QPainter* painter; 105 QPainter* painter;
106 106
107 QPixmap* pixmap; 107 QPixmap* pixmap;
108 108
109 std::string fontname; 109 std::string fontname;
110 110
111 protected slots: 111 protected slots:
112 void timer(); 112 void timer();
113 113
114}; 114};
115 115
116#endif 116#endif
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
@@ -1,135 +1,135 @@
1// SettingsStore.cpp 1// SettingsStore.cpp
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10 10
11 11
12#include "SettingsStore.h" 12#include "SettingsStore.h"
13 13
14using namespace std; 14using namespace std;
15 15
16/* TODO: Consider using Template functions to make this neater. */ 16/* TODO: Consider using Template functions to make this neater. */
17 17
18 18
19bool CSettingsStore::GetBoolOption(const string& Key) 19bool CSettingsStore::GetBoolOption(const string& Key)
20{ 20{
21 if (BoolMap.find(Key)==BoolMap.end()) { 21 if (BoolMap.find(Key)==BoolMap.end()) {
22 bool Value = false; 22 bool Value = false;
23 LoadSetting(Key, &Value); 23 LoadSetting(Key, &Value);
24 BoolMap[Key] = Value; 24 BoolMap[Key] = Value;
25 } 25 }
26 26
27 return BoolMap[Key]; 27 return BoolMap[Key];
28} 28}
29 29
30 30
31long CSettingsStore::GetLongOption(const string& Key) 31long CSettingsStore::GetLongOption(const string& Key)
32{ 32{
33 if (LongMap.find(Key)==LongMap.end()) { 33 if (LongMap.find(Key)==LongMap.end()) {
34 long Value = 0l; 34 long Value = 0l;
35 LoadSetting(Key, &Value); 35 LoadSetting(Key, &Value);
36 LongMap[Key] = Value; 36 LongMap[Key] = Value;
37 } 37 }
38 38
39 return LongMap[Key]; 39 return LongMap[Key];
40} 40}
41 41
42 42
43string& CSettingsStore::GetStringOption(const string& Key) 43string& CSettingsStore::GetStringOption(const string& Key)
44{ 44{
45 if (StringMap.find(Key)==StringMap.end()) { 45 if (StringMap.find(Key)==StringMap.end()) {
46 string Value = ""; 46 string Value = "";
47 LoadSetting(Key, &Value); 47 LoadSetting(Key, &Value);
48 StringMap[Key] = Value; 48 StringMap[Key] = Value;
49 } 49 }
50 50
51 return StringMap[Key]; 51 return StringMap[Key];
52} 52}
53 53
54 54
55void CSettingsStore::SetBoolOption(const string& Key, bool Value) 55void CSettingsStore::SetBoolOption(const string& Key, bool Value)
56{ 56{
57 BoolMap[Key] = Value; 57 BoolMap[Key] = Value;
58 SaveSetting(Key, Value); 58 SaveSetting(Key, Value);
59} 59}
60 60
61 61
62void CSettingsStore::SetLongOption(const string& Key, long Value) 62void CSettingsStore::SetLongOption(const string& Key, long Value)
63{ 63{
64 LongMap[Key] = Value; 64 LongMap[Key] = Value;
65 SaveSetting(Key, Value); 65 SaveSetting(Key, Value);
66} 66}
67 67
68 68
69void CSettingsStore::SetStringOption(const string& Key, const string& Value) 69void CSettingsStore::SetStringOption(const string& Key, const string& Value)
70{ 70{
71 StringMap[Key] = Value; 71 StringMap[Key] = Value;
72 SaveSetting(Key, Value); 72 SaveSetting(Key, Value);
73} 73}
74 74
75 75
76void CSettingsStore::SetBoolDefault(const string& Key, bool Value) 76void CSettingsStore::SetBoolDefault(const string& Key, bool Value)
77{ 77{
78 bool TmpValue; 78 bool TmpValue;
79 if ( (BoolMap.find(Key)==BoolMap.end()) && (!LoadSetting(Key, &TmpValue)) ) 79 if ( (BoolMap.find(Key)==BoolMap.end()) && (!LoadSetting(Key, &TmpValue)) )
80 SetBoolOption(Key, Value); 80 SetBoolOption(Key, Value);
81} 81}
82 82
83 83
84void CSettingsStore::SetLongDefault(const string& Key, long Value) 84void CSettingsStore::SetLongDefault(const string& Key, long Value)
85{ 85{
86 long TmpValue; 86 long TmpValue;
87 if ( (LongMap.find(Key)==LongMap.end()) && (!LoadSetting(Key, &TmpValue)) ) 87 if ( (LongMap.find(Key)==LongMap.end()) && (!LoadSetting(Key, &TmpValue)) )
88 SetLongOption(Key, Value); 88 SetLongOption(Key, Value);
89} 89}
90 90
91 91
92void CSettingsStore::SetStringDefault(const string& Key, const string& Value) 92void CSettingsStore::SetStringDefault(const string& Key, const string& Value)
93{ 93{
94 string TmpValue; 94 string TmpValue;
95 if ( (StringMap.find(Key)==StringMap.end()) && (!LoadSetting(Key, &TmpValue)) ) 95 if ( (StringMap.find(Key)==StringMap.end()) && (!LoadSetting(Key, &TmpValue)) )
96 SetStringOption(Key, Value); 96 SetStringOption(Key, Value);
97} 97}
98 98
99 99
100/* Private functions -- Settings are not saved between sessions unless these 100/* Private functions -- Settings are not saved between sessions unless these
101functions are over-ridden. 101functions are over-ridden.
102--------------------------------------------------------------------------*/ 102--------------------------------------------------------------------------*/
103 103
104 104
105bool CSettingsStore::LoadSetting(const string& Key, bool* Value) 105bool CSettingsStore::LoadSetting(const string& , bool* )
106{ 106{
107 return false; 107 return false;
108} 108}
109 109
110 110
111bool CSettingsStore::LoadSetting(const string& Key, long* Value) 111bool CSettingsStore::LoadSetting(const string& , long* )
112{ 112{
113 return false; 113 return false;
114} 114}
115 115
116 116
117bool CSettingsStore::LoadSetting(const string& Key, string* Value) 117bool CSettingsStore::LoadSetting(const string& , string* )
118{ 118{
119 return false; 119 return false;
120} 120}
121 121
122 122
123void CSettingsStore::SaveSetting(const string& Key, bool Value) 123void CSettingsStore::SaveSetting(const string& , bool )
124{ 124{
125} 125}
126 126
127 127
128void CSettingsStore::SaveSetting(const string& Key, long Value) 128void CSettingsStore::SaveSetting(const string& , long )
129{ 129{
130} 130}
131 131
132 132
133void CSettingsStore::SaveSetting(const string& Key, const string& Value) 133void CSettingsStore::SaveSetting(const string& , const string& )
134{ 134{
135} 135}