RichLabel.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. GWEN
  3. Copyright (c) 2010 Facepunch Studios
  4. See license in Gwen.h
  5. */
  6. #pragma once
  7. #ifndef GWEN_CONTROLS_RICHLABEL_H
  8. #define GWEN_CONTROLS_RICHLABEL_H
  9. #include "Gwen/BaseRender.h"
  10. #include "Gwen/Controls/Base.h"
  11. #include "Gwen/Controls/Text.h"
  12. #include "Gwen/TextObject.h"
  13. namespace Gwen
  14. {
  15. namespace Controls
  16. {
  17. class GWEN_EXPORT RichLabel : public Controls::Base
  18. {
  19. public:
  20. GWEN_CONTROL( RichLabel, Gwen::Controls::Base );
  21. void AddLineBreak();
  22. void AddText( const Gwen::TextObject& text, Gwen::Color color, Gwen::Font* font = NULL );
  23. virtual bool SizeToChildren( bool w = true, bool h = true );
  24. protected:
  25. struct DividedText
  26. {
  27. typedef std::list<DividedText> List;
  28. DividedText()
  29. {
  30. type = 0;
  31. font = NULL;
  32. }
  33. unsigned char type;
  34. Gwen::UnicodeString text;
  35. Gwen::Color color;
  36. Gwen::Font* font;
  37. };
  38. void Layout( Gwen::Skin::Base* skin );
  39. void SplitLabel( const Gwen::UnicodeString& text, Gwen::Font* pFont, const DividedText& txt, int& x, int& y, int& lineheight );
  40. void CreateNewline( int& x, int& y, int& lineheight );
  41. void CreateLabel( const Gwen::UnicodeString& text, const DividedText& txt, int& x, int& y, int& lineheight, bool NoSplit );
  42. void Rebuild();
  43. void OnBoundsChanged( Gwen::Rect oldBounds );
  44. DividedText::List m_TextBlocks;
  45. bool m_bNeedsRebuild;
  46. };
  47. }
  48. }
  49. #endif