From 651b6c612db4e809c506973996f2580c4158ac3a Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sat, 27 Sep 2003 11:29:26 +0000 Subject: merge dasher which has been introduced in BRANCH first (wtf?) into HEAD --- (limited to 'inputmethods/dasher/Alphabet.h') diff --git a/inputmethods/dasher/Alphabet.h b/inputmethods/dasher/Alphabet.h new file mode 100644 index 0000000..5f0f9a5 --- a/dev/null +++ b/inputmethods/dasher/Alphabet.h @@ -0,0 +1,83 @@ +// Alphabet.h +// +///////////////////////////////////////////////////////////////////////////// +// Alphabet.h +// +///////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2001-2002 David Ward +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef __DASHER_ALPHABET_H__ +#define __DASHER_ALPHABET_H__ + + +#include "DasherTypes.h" + +#include "MSVC_Unannoy.h" +#include +#include +#include "AlphabetMap.h" + + +namespace Dasher {class CAlphabet;} +class Dasher::CAlphabet +{ +public: + CAlphabet(); + ~CAlphabet() {} + + int GetNumberSymbols() const { return m_Characters.size();} // return size of alphabet + + Opts::ScreenOrientations GetOrientation() {return m_Orientation;} + Opts::AlphabetTypes GetType() {return m_DefaultEncoding;} + std::string& GetTrainingFile() {return m_TrainingFile;} + + symbol GetSpaceSymbol() {return m_SpaceSymbol;} + const std::string& GetDisplayText(symbol i) const {return m_Display[i];} // return display string for i'th symbol + const std::string& GetText(symbol i) const {return m_Characters[i];} // return string for i'th symbol + const std::string& GetColour(symbol i) const {return m_Colours[i];} // return the colour for i'th symbol + int GetTextColour(symbol i); // return the foreground colour for i'th symbol + const std::string& GetForeground(symbol i) const {return m_Foreground[i];} // return the foreground colour for i'th symbol + int get_group(symbol i) const {return m_Group[i];} // return group membership of i'th symbol + + // Fills Symbols with the symbols corresponding to Input. {{{ Note that this + // is not necessarily reversible by repeated use of GetText. Some text + // may not be recognised and so discarded. If IsMore is true then Input + // is truncated to any final characters that were not used due to ambiguous + // continuation. If IsMore is false Input is assumed to be all the available + // text and so a symbol will be returned for a final "a" even if "ae" is + // defined as its own symbol. }}} + void GetSymbols(std::vector* Symbols, std::string* Input, bool IsMore); + + void dump() const; // diagnostic + +protected: + // Add the characters that can appear in Nodes + void AddChar(const std::string NewCharacter, const std::string Display, const std::string Colour, const std::string Foreground); // add single char to the alphabet + void StartNewGroup(); + + // Alphabet language parameters + void SetSpaceSymbol() {m_SpaceSymbol=m_Characters.size()-1;} // We can set the space symbol to be the last character added + void SetSpaceSymbol(symbol SpaceSymbol) {m_SpaceSymbol=SpaceSymbol;} // ...or any desired symbol. + void SetOrientation(Opts::ScreenOrientations Orientation) {m_Orientation=Orientation;} + void SetLanguage(Opts::AlphabetTypes Group) {m_DefaultEncoding=Group;} + void SetTrainingFile(std::string TrainingFile) {m_TrainingFile=TrainingFile;} +private: + Opts::AlphabetTypes m_DefaultEncoding; + Opts::ScreenOrientations m_Orientation; + symbol m_SpaceSymbol; + std::string m_TrainingFile; + + std::vector m_Characters; // stores the characters + std::vector m_Display; // stores how the characters are visually represented in the Dasher nodes + std::vector m_Colours; // stores the colour of the characters + std::vector m_Foreground; // stores the colour of the character foreground + std::vector m_Group; // stores the group indicators - e.g. caps, numbers, punctuation + int m_Groups; // number of groups + alphabet_map TextMap; +}; + + +#endif // ifndef __DASHER_ALPHABET_H__ -- cgit v0.9.0.2