00001 #ifndef GUI_FONTSTRING_HPP 00002 #define GUI_FONTSTRING_HPP 00003 00004 #include <utils.hpp> 00005 #include "gui_layeredregion.hpp" 00006 #include "gui_text.hpp" 00007 00008 namespace gui 00009 { 00011 00014 class font_string : public layered_region 00015 { 00016 public : 00017 00019 explicit font_string(manager* pManager); 00020 00022 virtual ~font_string(); 00023 00025 00028 virtual std::string serialize(const std::string& sTab) const; 00029 00031 virtual void render(); 00032 00034 00036 virtual void copy_from(uiobject* pObj); 00037 00039 virtual void update(float fDelta); 00040 00042 00044 const std::string& get_font_name() const; 00045 00047 00049 uint get_font_height() const; 00050 00052 00056 void set_outlined(bool bIsOutlined); 00057 00059 00061 bool is_outlined() const; 00062 00064 00066 text::alignment get_justify_h() const; 00067 00069 00071 text::vertical_alignment get_justify_v() const; 00072 00074 00076 const color& get_shadow_color() const; 00077 00079 00082 std::array<int,2> get_shadow_offsets() const; 00083 00085 00087 int get_shadow_x_offset() const; 00088 00090 00092 int get_shadow_y_offset() const; 00093 00095 00098 std::array<int,2> get_offsets() const; 00099 00101 00103 float get_spacing() const; 00104 00106 00108 const color& get_text_color() const; 00109 00111 00114 void set_font(const std::string& sFontName, uint uiHeight); 00115 00117 00119 void set_justify_h(text::alignment mJustifyH); 00120 00122 00124 void set_justify_v(text::vertical_alignment mJustifyV); 00125 00127 00129 void set_shadow_color(const color& mShadowColor); 00130 00132 00135 void set_shadow_offsets(int iShadowXOffset, int iShadowYOffset); 00136 00138 00141 void set_shadow_offsets(const std::array<int,2>& lShadowOffsets); 00142 00144 00147 void set_offsets(int iXOffset, int iYOffset); 00148 00150 00153 void set_offsets(const std::array<int,2>& lOffsets); 00154 00156 00158 void set_spacing(float fSpacing); 00159 00161 00163 void set_text_color(const color& mTextColor); 00164 00166 00169 bool can_non_space_wrap() const; 00170 00172 00174 float get_string_height() const; 00175 00177 00179 float get_string_width() const; 00180 00182 00184 const std::string& get_text() const; 00185 00187 00189 const utils::ustring& get_unicode_text() const; 00190 00192 00198 void set_non_space_wrap(bool bCanNonSpaceWrap); 00199 00201 00203 bool has_shadow() const; 00204 00206 00208 void set_shadow(bool bHasShadow); 00209 00211 00215 void set_word_wrap(bool bCanWordWrap, bool bAddEllipsis); 00216 00218 00220 bool can_word_wrap() const; 00221 00223 00226 void enable_formatting(bool bFormatting); 00227 00229 00231 bool is_formatting_enabled() const; 00232 00234 00237 void set_text(const std::string& sText); 00238 00240 virtual void create_glue(); 00241 00243 00245 virtual void parse_block(xml::block* pBlock); 00246 00248 00250 utils::wptr<text> get_text_object(); 00251 00253 static void register_glue(utils::wptr<lua::state> pLua); 00254 00255 private : 00256 00257 void parse_attributes_(xml::block* pBlock); 00258 void parse_color_block_(xml::block* pBlock); 00259 void parse_shadow_block_(xml::block* pBlock); 00260 00261 void update_borders_() const; 00262 00263 mutable utils::refptr<text> pText_; 00264 00265 std::string sText_; 00266 std::string sFontName_; 00267 uint uiHeight_; 00268 00269 float fSpacing_; 00270 text::alignment mJustifyH_; 00271 text::vertical_alignment mJustifyV_; 00272 int iXOffset_; 00273 int iYOffset_; 00274 00275 bool bIsOutlined_; 00276 bool bCanNonSpaceWrap_; 00277 bool bCanWordWrap_; 00278 bool bAddEllipsis_; 00279 bool bFormattingEnabled_; 00280 color mTextColor_; 00281 00282 bool bHasShadow_; 00283 color mShadowColor_; 00284 int iShadowXOffset_; 00285 int iShadowYOffset_; 00286 }; 00287 00291 class lua_font_string : public lua_layered_region 00292 { 00293 public : 00294 00295 explicit lua_font_string(lua_State* pLua); 00296 00297 int _get_font(lua_State*); 00298 int _get_justify_h(lua_State*); 00299 int _get_justify_v(lua_State*); 00300 int _get_shadow_color(lua_State*); 00301 int _get_shadow_offset(lua_State*); 00302 int _get_spacing(lua_State*); 00303 int _get_text_color(lua_State*); 00304 int _set_font(lua_State*); 00305 int _set_justify_h(lua_State*); 00306 int _set_justify_v(lua_State*); 00307 int _set_shadow_color(lua_State*); 00308 int _set_shadow_offset(lua_State*); 00309 int _set_spacing(lua_State*); 00310 int _set_text_color(lua_State*); 00311 int _can_non_space_wrap(lua_State*); 00312 int _can_word_wrap(lua_State*); 00313 int _enable_formatting(lua_State*); 00314 int _get_string_height(lua_State*); 00315 int _get_string_width(lua_State*); 00316 int _get_text(lua_State*); 00317 int _is_formatting_enabled(lua_State*); 00318 int _set_non_space_wrap(lua_State*); 00319 int _set_text(lua_State*); 00320 int _set_word_wrap(lua_State*); 00321 00322 static const char className[]; 00323 static const char* classList[]; 00324 static Lunar<lua_font_string>::RegType methods[]; 00325 00326 protected : 00327 00328 font_string* pFontStringParent_; 00329 }; 00330 00333 } 00334 00335 #endif