Text.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. GWEN
  3. Copyright (c) 2010 Facepunch Studios
  4. See license in Gwen.h
  5. */
  6. #pragma once
  7. #ifndef GWEN_CONTROLS_TEXT_H
  8. #define GWEN_CONTROLS_TEXT_H
  9. #include "Gwen/BaseRender.h"
  10. #include "Gwen/Controls/Base.h"
  11. namespace Gwen
  12. {
  13. namespace ControlsInternal
  14. {
  15. class GWEN_EXPORT Text : public Controls::Base
  16. {
  17. public:
  18. GWEN_CONTROL( Text, Controls::Base );
  19. virtual ~Text();
  20. Gwen::Font* GetFont();
  21. void SetString( const UnicodeString& str );
  22. void SetString( const String& str );
  23. void Render( Skin::Base* skin );
  24. void Layout( Skin::Base* skin );
  25. void RefreshSize();
  26. void SetFont( Gwen::Font* pFont ){ m_Font = pFont; }
  27. const UnicodeString& GetText() const { return m_String; }
  28. Gwen::Point GetCharacterPosition( int iChar );
  29. int GetClosestCharacter( Gwen::Point p );
  30. int Length() const { return (int)m_String.size(); }
  31. virtual void SetTextColor( const Gwen::Color& col ){ m_Color = col; }
  32. virtual void OnScaleChanged();
  33. inline const Gwen::Color &TextColor() const { return m_Color; }
  34. private:
  35. Gwen::UnicodeString m_String;
  36. Gwen::Font* m_Font;
  37. Gwen::Color m_Color;
  38. };
  39. }
  40. }
  41. #endif