2013-06-14 15:48:13 +00:00
# ifndef _TEXTCOMPONENT_H_
# define _TEXTCOMPONENT_H_
# include "../GuiComponent.h"
# include "../Font.h"
class TextComponent : public GuiComponent
{
public :
TextComponent ( Window * window ) ;
2013-07-03 07:54:55 +00:00
TextComponent ( Window * window , const std : : string & text , std : : shared_ptr < Font > font , Vector2i pos , Vector2u size ) ;
2013-06-14 15:48:13 +00:00
2013-07-03 07:54:55 +00:00
void setFont ( std : : shared_ptr < Font > font ) ;
2013-06-14 15:48:13 +00:00
void setBox ( Vector2i pos , Vector2u size ) ;
2013-07-03 01:01:58 +00:00
void setExtent ( Vector2u size ) ; //Use Vector2u(0, 0) to automatically generate extent on a single line. Use Vector2(value, 0) to automatically generate extent for wrapped text.
2013-06-14 15:48:13 +00:00
void setText ( const std : : string & text ) ;
void setColor ( unsigned int color ) ;
2013-07-02 05:57:31 +00:00
void onRender ( ) override ;
2013-06-14 15:48:13 +00:00
private :
2013-07-03 07:54:55 +00:00
std : : shared_ptr < Font > getFont ( ) const ;
2013-07-03 01:01:58 +00:00
2013-06-19 01:12:30 +00:00
void calculateExtent ( ) ;
2013-06-14 15:48:13 +00:00
unsigned int mColor ;
2013-07-03 07:54:55 +00:00
std : : shared_ptr < Font > mFont ;
2013-07-03 01:01:58 +00:00
Vector2 < bool > mAutoCalcExtent ;
2013-06-14 15:48:13 +00:00
std : : string mText ;
} ;
# endif