00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00023 #ifndef INCLUDE_TEXT_3D_H
00024 #define INCLUDE_TEXT_3D_H
00025
00026 #pragma warning( disable : 4217 )
00027 #pragma warning( disable : 4099 )
00028
00029 #include "material.h"
00030 #include <ftgl/ftfont.h>
00031
00032 typedef enum
00033 {
00034 align_begin,
00035 align_center,
00036 align_end,
00037 align_justify
00038 } TextAlign;
00039
00041 class ParsingElem
00042 {
00043 public:
00044 GLfloat deltaX;
00045 BOOL isWord;
00046
00047 ParsingElem();
00048 void operator=(ParsingElem &src);
00049 };
00050
00052 class ParsingWord : public ParsingElem
00053 {
00054 public:
00055 MyString text;
00056
00057 ParsingWord();
00058 void operator=(ParsingWord &src);
00059 };
00060
00072 class ParsingLine : public ParsingElem
00073 {
00074 public:
00075 GLfloat deltaY;
00076 TextAlign align;
00077 MyList<ParsingWord *> words;
00078 double xJustify;
00079 double xPos;
00080 int nbChar;
00081
00082 ParsingLine();
00083 void operator=(ParsingLine &src);
00084 };
00085
00086 typedef enum
00087 {
00088 ft_texture,
00089 ft_extrude,
00090 ft_outline,
00091 ft_polygon,
00092 ft_bitmap,
00093 ft_pixmap,
00094 ft_unknown
00095 } FontType;
00096
00122 class BasicText3D
00123 {
00124 public:
00125 FontType type;
00126 FTFont *font;
00127 Material material;
00128 float depth;
00129 int xCenter;
00130 int yCenter;
00131 GLdouble zCenter;
00132 double scale;
00133 BOOL usePicking;
00134 double ratioXY;
00135 double ratioYX;
00136
00137 public:
00138 BasicText3D();
00139 void SetRatioXY(GLdouble value);
00140 void Setup(FTFont *f,FontType t,int x=0,int y=0);
00141 void operator=(BasicText3D &src);
00142 BOOL DrawPicking(char *text);
00143 BOOL Draw(char *text);
00144 BOOL Draw(char letter);
00145
00146 Point3D<float> GetBox(char *text);
00147 float GetAscender();
00148 float GetDescender();
00149 float GetHeight();
00150 float GetWidth(char *text);
00151 float GetWidth(char letter);
00152 };
00153
00192 class Text3D : public BasicText3D
00193 {
00194 private:
00195 BOOL enableClipping;
00196 Point2D<GLdouble> clipping;
00197 Point2D<GLdouble> realClipping;
00198 int idCallList;
00199 BOOL isChanged;
00200 GLdouble yJustify;
00201
00202 MyString value;
00203 MyList<ParsingLine> lines;
00204 MyList<ParsingWord> words;
00205 MyList<ParsingLine> layoutLines;
00206 MyList<ParsingWord> layoutWords;
00207 MyList<ParsingLine *> linesUses;
00208
00209 void DrawLine(ParsingLine *line);
00210 float AddLine(ParsingLine *line);
00211
00212 public:
00213 TextAlign xAlign;
00214 TextAlign yAlign;
00215 GLdouble xJustifyLimit;
00216 GLdouble yJustifyLimit;
00217 BOOL wordWrap;
00218 BOOL lineWrap;
00219 BOOL letterWrap;
00220
00221 Text3D();
00222 ~Text3D();
00223 void operator=(Text3D &src);
00224 void SetJustifyLimit(GLdouble x,GLdouble y);
00225 void SetWrapping(BOOL line,BOOL word,BOOL letter);
00226 void SetClipping(double x,double y);
00227 void SetClipping(Point2D<double> newClipping);
00228 void SetAlign(TextAlign x=align_center,TextAlign y=align_center);
00229 void Setup(FTFont *f,FontType t=ft_texture);
00230 BOOL Draw();
00231 BOOL DrawPicking();
00232 void ComputeSize(MyList<ParsingLine> *linesCur,BOOL isWordSizeCompute);
00233 void ComputeLineSize(ParsingLine *line,BOOL isWordSizeCompute);
00234
00235 float ComputeLayout();
00236 void ApplyRealClipping();
00237
00238 void SetText(char *text);
00239 char * GetText();
00240 BOOL AnalyseLex(int indBegin,int *indEnd,BOOL *isEnd,BOOL *isReturn);
00241 void AnalyseGram();
00242 };
00243
00244 #endif