author | mickeyl <mickeyl> | 2003-09-27 11:29:26 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-09-27 11:29:26 (UTC) |
commit | 651b6c612db4e809c506973996f2580c4158ac3a (patch) (side-by-side diff) | |
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 @@ +// AlphIO.cpp +// +///////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2002 Iain Murray +// +///////////////////////////////////////////////////////////////////////////// + + + +#include "AlphIO.h" + +using namespace Dasher; +using namespace std; + +CAlphIO::CAlphIO(string SystemLocation, string UserLocation) + : SystemLocation(SystemLocation), UserLocation(UserLocation), + BlankInfo(), CData("") +{ + CreateDefault(); +} + + +void CAlphIO::GetAlphabets(std::vector< std::string > * AlphabetList) const +{ + AlphabetList->clear(); + + typedef std::map<std::string, AlphInfo>::const_iterator CI; + CI End = Alphabets.end(); + + for (CI Cur=Alphabets.begin(); Cur!=End; Cur++) + AlphabetList->push_back( (*Cur).second.AlphID); +} + + +const CAlphIO::AlphInfo& CAlphIO::GetInfo(const std::string& AlphID) +{ + if (AlphID=="") + return Alphabets["Default"]; + else { + AlphInfo& CurInfo = Alphabets[AlphID]; + Alphabets[AlphID].AlphID = AlphID; // Ensure consistency + return Alphabets[AlphID]; + } +} + + +void CAlphIO::SetInfo(const AlphInfo& NewInfo) +{ + Alphabets[NewInfo.AlphID] = NewInfo; +} + + +void CAlphIO::Delete(const std::string& AlphID) +{ + if (Alphabets.find(AlphID)!=Alphabets.end()) { + Alphabets.erase(AlphID); + } +} + + +void CAlphIO::CreateDefault() +{ + // TODO I appreciate these strings should probably be in a resource file. + // Not urgent though as this is not intended to be used. It's just a + // last ditch effort in case file I/O totally fails. + AlphInfo& Default = Alphabets["Default"]; + Default.AlphID = "Default"; + Default.Type = Opts::Western; + Default.Mutable = false; + Default.Orientation = Opts::LeftToRight; + Default.SpaceCharacter.Display = "_"; + Default.SpaceCharacter.Text = " "; + Default.TrainingFile = "training_english_GB.txt"; + string Chars = "abcdefghijklmnopqrstuvwxyz"; + Default.Groups.resize(1); + Default.Groups[0].Description = "Lower case Latin letters"; + Default.Groups[0].Characters.resize(Chars.size()); + for (unsigned int i=0; i<Chars.size(); i++) { + Default.Groups[0].Characters[i].Text = Chars[i]; + Default.Groups[0].Characters[i].Display = Chars[i]; + } +} |