Text.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /******************************************************************************/
  2. const_mem_addr STRUCT(Text , GuiObj) // Gui Text !! must be stored in constant memory address !!
  3. //{
  4. AUTO_LINE_MODE auto_line; // automatically calculate new lines when drawing text, default=AUTO_LINE_NONE
  5. TextStylePtr text_style; // text style , default=null (if set to null then current value of 'skin.text.text_style' is used)
  6. GuiSkinPtr skin; // skin override, default=null (if set to null then current value of 'Gui.skin' is used)
  7. // manage
  8. Text& del ( ); // delete
  9. Text& create( C Str &text=S, C TextStylePtr &ts=null); // create, 'ts'=text style (the object is not copied, only the pointer to the object is remembered, therefore it must point to a constant memory address !!)
  10. Text& create(C Vec2 &rect, C Str &text=S, C TextStylePtr &ts=null) {create(text, ts).rect(rect); return T;} // create, 'ts'=text style (the object is not copied, only the pointer to the object is remembered, therefore it must point to a constant memory address !!)
  11. Text& create(C Rect &rect, C Str &text=S, C TextStylePtr &ts=null) {create(text, ts).rect(rect); return T;} // create, 'ts'=text style (the object is not copied, only the pointer to the object is remembered, therefore it must point to a constant memory address !!)
  12. Text& create(C Text &src ); // create from 'src'
  13. // get / set
  14. Text& clear( ); // clear text value
  15. Text& set (C Str &text); C Str& operator()()C {return _text;} // set/get text value
  16. Text& code (C Str &code); Str code ()C; // set/get text value in code format
  17. // 1. code format accepts following keywords: in following formats:
  18. // col, color RGB, RGBA, RRGGBB, RRGGBBAA (hexadecimal format)
  19. // shadow X, XX (hexadecimal format)
  20. // 2. codes should be surrounded by '[' ']' signs
  21. // 3. removing the effect of a code should be handled by '/' sign followed by code name
  22. // 4. sample codes:
  23. // "Text without code. [color=F00]Text with code[/color]" - will force red color on "Text with code"
  24. // "[shadow=0]No Shadow[/shadow] [shadow=F]Full Shadow[/shadow]" - will force no shadow on "No Shadow" and full shadow on "Full Shadow"
  25. GuiSkin * getSkin ()C {return skin ? skin() : Gui.skin();} // get actual skin
  26. TextStyle* getTextStyle()C; // get actual text style
  27. Vec2 textSize()C; // get visible text size
  28. // main
  29. virtual void draw(C GuiPC &gpc); // draw object
  30. #if EE_PRIVATE
  31. void zero();
  32. #endif
  33. ~Text() {del();}
  34. Text();
  35. protected:
  36. virtual Bool save(File &f, CChar *path=null)C;
  37. virtual Bool load(File &f, CChar *path=null) ;
  38. Str _text;
  39. #if !EE_PRIVATE
  40. Ptr _code; Int _codes;
  41. #else
  42. TextCodeData *_code; Int _codes;
  43. #endif
  44. NO_COPY_CONSTRUCTOR(Text);
  45. };
  46. /******************************************************************************/