00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef MMSTEXTBOXWIDGET_H_
00034 #define MMSTEXTBOXWIDGET_H_
00035
00036 #include "mmsgui/mmswidget.h"
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 class MMSTextBoxWidget : public MMSWidget {
00047 private:
00048 typedef struct {
00049 MMSFBRectangle geom;
00050 string word;
00051 unsigned int line;
00052 unsigned int paragraph;
00053 } TEXTBOX_WORDGEOM;
00054
00055 string className;
00056 MMSTextBoxWidgetClass *textBoxWidgetClass;
00057 MMSTextBoxWidgetClass myTextBoxWidgetClass;
00058
00059
00060 MMSLanguage lang;
00061
00062
00063 MMSFBFont *font;
00064
00065
00066 string fontpath;
00067
00068
00069 string fontname;
00070
00071
00072 unsigned int fontsize;
00073
00074
00075 bool load_font;
00076
00077
00078 vector<TEXTBOX_WORDGEOM *> wordgeom;
00079
00080 string lasttext;
00081 bool surfaceChanged;
00082
00083
00084 string translated_text;
00085
00086
00087 bool translated;
00088
00089
00090 bool swap_left_right;
00091
00092
00093 MMSFile *file;
00094
00095
00096 bool current_fgset;
00097
00098
00099 MMSFBColor current_fgcolor;
00100
00101 bool create(MMSWindow *root, string className, MMSTheme *theme);
00102
00103 void initLanguage(MMSTextBoxWidget *widget = NULL);
00104 void loadFont(MMSTextBoxWidget *widget = NULL);
00105
00106 bool setSurfaceGeometry(unsigned int width = 0, unsigned int height = 0);
00107
00108 bool calcWordGeom(string &text, unsigned int startWidth, unsigned int startHeight,
00109 unsigned int *realWidth, unsigned int *realHeight,
00110 unsigned int *scrollDX, unsigned int *scrollDY, unsigned int *lines, unsigned int *paragraphs,
00111 bool wrap = true, bool splitwords = true, MMSALIGNMENT alignment = MMSALIGNMENT_CENTER,
00112 unsigned int *minWidth = NULL, unsigned int *minHeight = NULL, bool force_recalc = false);
00113
00114 bool init();
00115 bool release();
00116
00117 bool prepareText(int *width, int *height, bool recalc = false);
00118 void calcContentSize();
00119
00120 void getForeground(MMSFBColor *color);
00121 bool enableRefresh(bool enable = true);
00122 bool checkRefreshStatus();
00123
00124 bool draw(bool *backgroundFilled = NULL);
00125
00126
00127 void targetLangChanged(MMSLanguage lang);
00128
00129 bool loadFile(bool refresh);
00130
00131 public:
00132 MMSTextBoxWidget(MMSWindow *root, string className, MMSTheme *theme = NULL);
00133 ~MMSTextBoxWidget();
00134
00135 MMSWidget *copyWidget();
00136
00137 public:
00138
00139 bool reloadFile();
00140
00141
00142 string getFontPath();
00143 string getFontName(MMSLanguage lang = MMSLANG_NONE);
00144 unsigned int getFontSize();
00145 MMSALIGNMENT getAlignment();
00146 bool getWrap();
00147 bool getSplitWords();
00148 MMSFBColor getColor();
00149 MMSFBColor getSelColor();
00150 MMSFBColor getColor_p();
00151 MMSFBColor getSelColor_p();
00152 MMSFBColor getColor_i();
00153 MMSFBColor getSelColor_i();
00154 string getText();
00155 void getText(string &text);
00156 bool getTranslate();
00157 string getFilePath();
00158 string getFileName();
00159 MMSFBColor getShadowColor(MMSPOSITION position);
00160 MMSFBColor getSelShadowColor(MMSPOSITION position);
00161
00162 void setFontPath(string fontpath, bool load = true, bool refresh = true);
00163 void setFontName(MMSLanguage lang, string fontname, bool load = true, bool refresh = true);
00164 void setFontName(string fontname, bool load = true, bool refresh = true);
00165 void setFontSize(unsigned int fontsize, bool load = true, bool refresh = true);
00166 void setFont(MMSLanguage lang, string fontpath, string fontname, unsigned int fontsize, bool load = true, bool refresh = true);
00167 void setFont(string fontpath, string fontname, unsigned int fontsize, bool load = true, bool refresh = true);
00168 void setAlignment(MMSALIGNMENT alignment, bool refresh = true);
00169 void setWrap(bool wrap, bool refresh = true);
00170 void setSplitWords(bool splitwords, bool refresh = true);
00171 void setColor(MMSFBColor color, bool refresh = true);
00172 void setSelColor(MMSFBColor selcolor, bool refresh = true);
00173 void setColor_p(MMSFBColor color_p, bool refresh = true);
00174 void setSelColor_p(MMSFBColor selcolor_p, bool refresh = true);
00175 void setColor_i(MMSFBColor color_i, bool refresh = true);
00176 void setSelColor_i(MMSFBColor selcolor_i, bool refresh = true);
00177 void setText(string *text, bool refresh = true);
00178 void setText(string text, bool refresh = true);
00179 void setTranslate(bool translate, bool refresh = true);
00180 void setFilePath(string filepath, bool load = true, bool refresh = true);
00181 void setFileName(string filename, bool load = true, bool refresh = true);
00182 void setShadowColor(MMSPOSITION position, MMSFBColor color, bool refresh = true);
00183 void setSelShadowColor(MMSPOSITION position, MMSFBColor selcolor, bool refresh = true);
00184
00185 void updateFromThemeClass(MMSTextBoxWidgetClass *themeClass);
00186
00187
00188 friend class MMSWindow;
00189 };
00190
00191 #endif