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