author | mickeyl <mickeyl> | 2003-09-27 11:29:26 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-09-27 11:29:26 (UTC) |
commit | 651b6c612db4e809c506973996f2580c4158ac3a (patch) (unidiff) | |
tree | 8c8edc86e4b206dd4542a6b556ad1a319d6698ab /inputmethods/dasher/AlphIO.cpp | |
parent | d1a11b45e805fe7771ea05944757d767c3c4c8ea (diff) | |
download | opie-651b6c612db4e809c506973996f2580c4158ac3a.zip opie-651b6c612db4e809c506973996f2580c4158ac3a.tar.gz opie-651b6c612db4e809c506973996f2580c4158ac3a.tar.bz2 |
merge dasher which has been introduced in BRANCH first (wtf?) into HEAD
Diffstat (limited to 'inputmethods/dasher/AlphIO.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/dasher/AlphIO.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/inputmethods/dasher/AlphIO.cpp b/inputmethods/dasher/AlphIO.cpp new file mode 100644 index 0000000..41b1b23 --- a/dev/null +++ b/inputmethods/dasher/AlphIO.cpp | |||
@@ -0,0 +1,83 @@ | |||
1 | // AlphIO.cpp | ||
2 | // | ||
3 | ///////////////////////////////////////////////////////////////////////////// | ||
4 | // | ||
5 | // Copyright (c) 2002 Iain Murray | ||
6 | // | ||
7 | ///////////////////////////////////////////////////////////////////////////// | ||
8 | |||
9 | |||
10 | |||
11 | #include "AlphIO.h" | ||
12 | |||
13 | using namespace Dasher; | ||
14 | using namespace std; | ||
15 | |||
16 | CAlphIO::CAlphIO(string SystemLocation, string UserLocation) | ||
17 | : SystemLocation(SystemLocation), UserLocation(UserLocation), | ||
18 | BlankInfo(), CData("") | ||
19 | { | ||
20 | CreateDefault(); | ||
21 | } | ||
22 | |||
23 | |||
24 | void CAlphIO::GetAlphabets(std::vector< std::string > * AlphabetList) const | ||
25 | { | ||
26 | AlphabetList->clear(); | ||
27 | |||
28 | typedef std::map<std::string, AlphInfo>::const_iterator CI; | ||
29 | CI End = Alphabets.end(); | ||
30 | |||
31 | for (CI Cur=Alphabets.begin(); Cur!=End; Cur++) | ||
32 | AlphabetList->push_back( (*Cur).second.AlphID); | ||
33 | } | ||
34 | |||
35 | |||
36 | const CAlphIO::AlphInfo& CAlphIO::GetInfo(const std::string& AlphID) | ||
37 | { | ||
38 | if (AlphID=="") | ||
39 | return Alphabets["Default"]; | ||
40 | else { | ||
41 | AlphInfo& CurInfo = Alphabets[AlphID]; | ||
42 | Alphabets[AlphID].AlphID = AlphID; // Ensure consistency | ||
43 | return Alphabets[AlphID]; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | |||
48 | void CAlphIO::SetInfo(const AlphInfo& NewInfo) | ||
49 | { | ||
50 | Alphabets[NewInfo.AlphID] = NewInfo; | ||
51 | } | ||
52 | |||
53 | |||
54 | void CAlphIO::Delete(const std::string& AlphID) | ||
55 | { | ||
56 | if (Alphabets.find(AlphID)!=Alphabets.end()) { | ||
57 | Alphabets.erase(AlphID); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | |||
62 | void CAlphIO::CreateDefault() | ||
63 | { | ||
64 | // 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 | ||
66 | // last ditch effort in case file I/O totally fails. | ||
67 | AlphInfo& Default = Alphabets["Default"]; | ||
68 | Default.AlphID = "Default"; | ||
69 | Default.Type = Opts::Western; | ||
70 | Default.Mutable = false; | ||
71 | Default.Orientation = Opts::LeftToRight; | ||
72 | Default.SpaceCharacter.Display = "_"; | ||
73 | Default.SpaceCharacter.Text = " "; | ||
74 | Default.TrainingFile = "training_english_GB.txt"; | ||
75 | string Chars = "abcdefghijklmnopqrstuvwxyz"; | ||
76 | Default.Groups.resize(1); | ||
77 | Default.Groups[0].Description = "Lower case Latin letters"; | ||
78 | Default.Groups[0].Characters.resize(Chars.size()); | ||
79 | for (unsigned int i=0; i<Chars.size(); i++) { | ||
80 | Default.Groups[0].Characters[i].Text = Chars[i]; | ||
81 | Default.Groups[0].Characters[i].Display = Chars[i]; | ||
82 | } | ||
83 | } | ||