• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

MyGUI_FontData.h

Go to the documentation of this file.
00001 
00007 /*
00008     This file is part of MyGUI.
00009     
00010     MyGUI is free software: you can redistribute it and/or modify
00011     it under the terms of the GNU Lesser General Public License as published by
00012     the Free Software Foundation, either version 3 of the License, or
00013     (at your option) any later version.
00014     
00015     MyGUI is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU Lesser General Public License for more details.
00019     
00020     You should have received a copy of the GNU Lesser General Public License
00021     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 #ifndef __MYGUI_FONT_DATA_H__
00024 #define __MYGUI_FONT_DATA_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 
00028 namespace MyGUI
00029 {
00030 
00031     struct MYGUI_EXPORT FontCodeType
00032     {
00033         enum Enum
00034         {
00035             Selected = 6,
00036             SelectedBack = 7,
00037             Cursor = 8,
00038             Tab = 9,
00039             LF = 0x000A,
00040             CR = 0x000D,
00041             Space = 0x0020,
00042             LatinStart = 0x0021,
00043             NEL = 0x0085,
00044             LatinEnd = 0x00A6,
00045             MAX
00046         };
00047 
00048         FontCodeType(Enum _value = MAX) : value(_value) { }
00049 
00050         friend bool operator == (FontCodeType const& a, FontCodeType const& b) { return a.value == b.value; }
00051         friend bool operator != (FontCodeType const& a, FontCodeType const& b) { return a.value != b.value; }
00052 
00053     private:
00054         Enum value;
00055     };
00056 
00057     // информация об одном символе
00058     struct GlyphInfo
00059     {
00060         FloatRect uvRect;
00061         Char codePoint;
00062         int width;
00063 
00064         GlyphInfo() : codePoint(0), width(0) { }
00065     };
00066 
00067     typedef std::vector<GlyphInfo> VectorGlyphInfo;
00068 
00069     // информация об диапазоне
00070     //FIXME move to std::pair
00071     class PairCodePoint
00072     {
00073     public:
00074         PairCodePoint() : first(0), last(0) { }
00075         PairCodePoint(Char _first, Char _last) : first(_first), last(_last) { }
00076 
00077         // проверяет входит ли символ в диапазон
00078         bool isExist(Char _code) { return _code >= first && _code <= last; }
00079 
00080     public:
00081         Char first;
00082         Char last;
00083     };
00084 
00085     // инфомация о диапазоне символов
00086     class RangeInfo
00087     {
00088     public:
00089         RangeInfo() : first(0), last(0) { }
00090         RangeInfo(Char _first, Char _last) :
00091             first(_first),
00092             last(_last)
00093         {
00094             range.resize(last - first + 1);
00095         }
00096 
00097         // проверяет входит ли символ в диапазон
00098         bool isExist(Char _code) { return _code >= first && _code <= last; }
00099 
00100         // возвращает указатель на глиф, или 0, если код не входит в диапазон
00101         GlyphInfo* getInfo(Char _code) { return isExist(_code) ? &range[_code - first] : nullptr; }
00102         void setInfo(Char _code, GlyphInfo* _value) { if (isExist(_code)) range[_code - first] = *_value; }
00103 
00104     public:
00105         Char first;
00106         Char last;
00107         VectorGlyphInfo range;
00108     };
00109 
00110     // FIXME move to resource font
00111     class PairCodeCoord
00112     {
00113     public:
00114         PairCodeCoord() : code(0) { }
00115         PairCodeCoord(Char _code, const IntCoord& _coord) :
00116             code(_code),
00117             coord(_coord)
00118         {
00119         }
00120 
00121         bool operator < (const PairCodeCoord& _value) const { return code < _value.code; }
00122 
00123         Char code;
00124         IntCoord coord;
00125     };
00126 
00127 } // namespace MyGUI
00128 
00129 #endif // __MYGUI_FONT_DATA_H__

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1