Quite a bit of stuff
[dasher.git] / Src / DasherCore / Alphabet / Alphabet.h
blob6ec7810c5e43d446bfe89167973a29bd47001955
1 // Alphabet.h
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 // Alphabet.h
5 //
6 /////////////////////////////////////////////////////////////////////////////
7 //
8 // Copyright (c) 2001-2002 David Ward
9 //
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __DASHER_ALPHABET_H__
13 #define __DASHER_ALPHABET_H__
15 #include "../DasherTypes.h"
16 #include "GroupInfo.h"
18 #include <cstdlib>
19 #include <vector>
20 #include "AlphabetMap.h"
21 #include "AlphIO.h"
23 namespace Dasher {
25 ///
26 /// \defgroup Alphabet Alphabet information
27 /// @{
29 class CAlphabet {
30 public:
33 CAlphabet();
35 CAlphabet(const CAlphIO::AlphInfo & AlphInfo);
37 ~CAlphabet() {
40 // Return size of alphabet, including control symbols
41 int GetNumberSymbols() const {
42 return m_Characters.size();
43 } // return size of alphabet
44 // Return number of text symbols
45 int GetNumberTextSymbols() const {
46 return m_Characters.size() - 1;
49 Opts::ScreenOrientations GetOrientation() {
50 return m_Orientation;
53 Opts::AlphabetTypes GetType() {
54 return m_DefaultEncoding;
57 std::string & GetTrainingFile() {
58 return m_TrainingFile;
60 std::string GetGameModeFile() {
61 return m_GameModeFile;
63 std::string & GetPalette() {
64 return m_DefaultPalette;
67 symbol GetParagraphSymbol() const;
68 symbol GetSpaceSymbol() const;
69 symbol GetControlSymbol() const;
70 //-- Added for Kanji Conversion 13 July 2005 by T.Kaburagi
71 symbol GetStartConversionSymbol() const;
72 symbol GetEndConversionSymbol() const;
74 const std::string & GetDisplayText(symbol i) const {
75 return m_Display[i];
77 // return display string for i'th symbol
79 const std::string & GetText(symbol i) const {
80 return m_Characters[i];
82 // return string for i'th symbol
84 int GetColour(symbol i) const {
85 return m_Colours[i];
87 // return the colour for i'th symbol
89 /* int GetGroupColour(int i) const { */
90 /* return m_GroupColour[i]; */
91 /* } */
92 // return the colour for i'th group
94 /* std::string GetGroupLabel(int i)const { */
95 /* return m_GroupLabel[i]; */
96 /* } */
98 int GetTextColour(symbol i); // return the foreground colour for i'th symbol
99 const std::string & GetForeground(symbol i) const {
100 return m_Foreground[i];
101 } // return the foreground colour for i'th symbol
103 /* int GetGroupCount() const { */
104 /* return m_iGroups; */
105 /* } int GetGroupStart(int i) const { */
106 /* return m_GroupStart[i]; */
107 /* } int GetGroupEnd(int i) const { */
108 /* return m_GroupEnd[i]; */
109 /* } */
111 //int get_group(symbol i) const {return m_Group[i];}
112 // return group membership of i'th symbol
113 // Fills Symbols with the symbols corresponding to Input. {{{ Note that this
114 // is not necessarily reversible by repeated use of GetText. Some text
115 // may not be recognised and so discarded. If IsMore is true then Input
116 // is truncated to any final characters that were not used due to ambiguous
117 // continuation. If IsMore is false Input is assumed to be all the available
118 // text and so a symbol will be returned for a final "a" even if "ae" is
119 // defined as its own symbol. }}}
120 void GetSymbols(std::vector<symbol> *Symbols, std::string * Input, bool IsMore) const;
122 void Trace() const; // diagnostic
124 // Add the characters that can appear in Nodes
125 void AddChar(std::string NewCharacter, std::string Display, int Colour, std::string Foreground); // add single char to the alphabet
127 // Alphabet language parameters
128 void AddParagraphSymbol(std::string NewCharacter, std::string Display, int Colour, std::string Foreground);
129 void AddSpaceSymbol(std::string NewCharacter, std::string Display, int Colour, std::string Foreground);
130 void AddControlSymbol(std::string NewCharacter, std::string Display, int Colour, std::string Foreground);
131 //-- Added for Kanji Conversion 13 July 2005 by T.Kaburagi
132 void AddStartConversionSymbol(std::string NewCharacter, std::string Display, int Colour, std::string Foreground);
133 void AddEndConversionSymbol(std::string NewCharacter, std::string Display, int Colour, std::string Foreground);
135 void SetOrientation(Opts::ScreenOrientations Orientation) {
136 m_Orientation = Orientation;
138 void SetLanguage(Opts::AlphabetTypes Group) {
139 m_DefaultEncoding = Group;
141 void SetTrainingFile(std::string TrainingFile) {
142 m_TrainingFile = TrainingFile;
144 void SetGameModeFile(std::string GameModeFile) {
145 m_GameModeFile = GameModeFile;
147 void SetPalette(std::string Palette) {
148 m_DefaultPalette = Palette;
151 const alphabet_map GetAlphabetMap() const {
152 return TextMap;
155 const std::string &GetDefaultContext() const {
156 return m_strDefaultContext;
159 SGroupInfo *m_pBaseGroup;
162 private:
164 Opts::AlphabetTypes m_DefaultEncoding;
165 Opts::ScreenOrientations m_Orientation;
166 symbol m_ParagraphSymbol;
167 symbol m_SpaceSymbol;
168 symbol m_ControlSymbol;
169 //-- Added for Kanji Conversion 13 July 2005 by T.Kaburagi
170 symbol m_StartConversionSymbol;
171 symbol m_EndConversionSymbol;
173 std::string m_TrainingFile;
174 std::string m_GameModeFile;
175 std::string m_DefaultPalette;
177 std::vector < std::string > m_Characters; // stores the characters
178 std::vector < std::string > m_Display; // stores how the characters are visually represented in the Dasher nodes
179 std::vector < int >m_Colours; // stores the colour of the characters
180 std::vector < std::string > m_Foreground; // stores the colour of the character foreground
182 // int m_iGroups; // number of groups
184 /* std::vector < int >m_GroupStart; // stores the group start index */
185 /* std::vector < int >m_GroupEnd; // stores the group end index (1 past the last) */
186 /* std::vector < int >m_GroupColour; // stores the colour of the group */
187 /* std::vector < std::string > m_GroupLabel; */
189 SGroupInfo *pFirstGroup;
191 alphabet_map TextMap;
193 std::string m_strDefaultContext;
195 // friend class CGroupAdder;
198 /// @}
200 inline symbol CAlphabet::GetParagraphSymbol() const {
201 return m_ParagraphSymbol;
204 inline symbol CAlphabet::GetSpaceSymbol() const {
205 return m_SpaceSymbol;
208 inline symbol CAlphabet::GetControlSymbol() const {
209 return m_ControlSymbol;
212 inline symbol CAlphabet::GetStartConversionSymbol() const {
213 return m_StartConversionSymbol;
216 inline symbol CAlphabet::GetEndConversionSymbol() const {
217 return m_EndConversionSymbol;
219 } // end namespace dasher
221 #endif // ifndef __DASHER_ALPHABET_H__