/* ----------------------------------------------------------------------------- GSFramework Copyright 2001-2013 Emmanuel Julien. All Rights Reserved. ----------------------------------------------------------------------------- */ #ifndef __NUIWIDGETTEXT__ #define __NUIWIDGETTEXT__ #include "ui/widget.h" #include "font/font_renderer.h" namespace GS { namespace S2D { /*! @short Text widget. @author Emmanuel Julien (ejulien@nworks.fr) */ class TextWidget : public Widget { protected: TextState state; ///< Widget text state. String text; ///< Widget text. public: const char *GetText() const { return text.c_str(); } void SetText(const char *); /// Set text block formatting rule. void SetTextFormat(TextState::Format f) { if (state.format != f) { state.format = f; Invalidate(); } } /// Get text formatting rule. TextState::Format GetTextFormat() const { return state.format; } /// Get text alignment rule. TextState::Alignment GetTextAlignment() const { return state.alignment; } /// Set text alignment rule. void SetTextAlignment(TextState::Alignment align) { if (state.alignment != align) { state.alignment = align; Invalidate(); } } void SetFont(FontEx *); void SetFontSize(int size); void SetFontColor(float r, float g, float b, float a = 1.0); /// Set column formatting width in character. void SetColumnWidth(int w) { state.column_width = w; Invalidate(); } /// Set font tracking. void SetTextTracking(float tracking_offset = 0) { state.SetTracking(tracking_offset); dirty = true; } /// Set font heading. void SetTextHeading(float heading_offset = 0) { state.SetLeading(heading_offset); dirty = true; } void SetTextState(const TextState &); void GetTextState(TextState &) const; virtual void Refresh(); virtual void Compose(Picture &output, const iRect &clip_rect); TextWidget(int id = -1, const char * = "Text", FontEx * = 0, int size = 16); }; } // S2D } // GS #endif // __NUIWIDGETTEXT__