Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/text_engine/text.h @ 8619

Last change on this file since 8619 was 8619, checked in by bensch, 18 years ago

trunk: merged the gui-branche back.
merged with command:
svn merge -r8520:HEAD https://svn.orxonox.net/orxonox/branches/gui
no conflicts

File size: 3.0 KB
RevLine 
[4838]1/*!
[5343]2 * @file text.h
3 * @brief Definition of a text Class, that is able to render text.
[7355]4 */
[1853]5
[5343]6#ifndef _TEXT_H
7#define _TEXT_H
[1853]8
[5343]9#include "element_2d.h"
[8448]10#include "color.h"
[1853]11
[5343]12#define  TEXT_ALIGN_LEFT             E2D_ALIGN_LEFT
13#define  TEXT_ALIGN_RIGHT            E2D_ALIGN_RIGHT
14#define  TEXT_ALIGN_CENTER           E2D_ALIGN_CENTER
15#define  TEXT_ALIGN_SCREEN_CENTER    E2D_ALIGN_SCREEN_CENTER
[8448]16#define  TEXT_DEFAULT_COLOR          Color(1.0, 1.0, 1.0, 1.0f) //!< the default Color (white, fully visible)
[5343]17
[5421]18#define  TEXT_DEFAULT_ALIGNMENT      TEXT_ALIGN_LEFT            //!< default alignment
19#define  TEXT_DEFAULT_SIZE           20                         //!< default size of the Text
[5343]20
[4838]21// FORWARD DECLARATION
[5343]22class Font;
[5427]23struct SDL_Surface;
[3543]24
[5343]25//! Represents one textElement.
26class Text : public Element2D
27{
28  public:
[7221]29    Text(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE);
[7753]30    Text(const Text& text);
[6981]31    virtual ~Text();
[7753]32    bool operator==(const Text& text) const;
33    bool operator==(const std::string& text) const;
34    Text& operator=(const Text& text);
[3245]35
[7753]36    /// Final Interfacing.
37    void setText(const std::string& text);
38    void append(const std::string& appendText);
[7919]39    void appendCharacter(char character);
[7753]40    const std::string& operator<<(const std::string& appendText);
[7919]41    void removeCharacters(unsigned int chars);
[8518]42    void clear();
[7753]43
44    /// SETUP
[7221]45    void setFont(const std::string& fontFile, unsigned int renderSize);
[7450]46    /** @param blending the blending intensity to set (between 0.0 and 1.0) */
[8619]47    inline void setBlending(float blending) { this->_color.a() = blending; };
[7450]48    /** @param r red @param g green @param b blue @brief sets the Color of the Text to render (values in [0-1]) */
[8619]49    void setColor(float r, float g, float b) { this->_color = Color(r, g, b, this->_color.a()); };
50    void setColor(float r, float g, float b, float a) { this->_color = Color(r, g, b, a); };
51    void setColor(const Color& color) { this->_color = color; };
[7453]52    void setSize(float size);
[5367]53
[7753]54
[7450]55    /// RETRIEVE
[7753]56    /** @returns the String this Text displays */
[8619]57    inline const std::string& text() const { return this->_text; };
[7753]58
[7450]59    /** @returns the pointer to the stored Font (not changeable) */
[8619]60    inline const Font* const font() const { return this->_font; };
[7450]61    /** @returns the Blending Value [0 invisible 1.0 full visible */
[8619]62    inline float blending() const { return this->_color.a(); };
[7450]63    /** @returns: a Vector(r,g,b) @brief: retrieve a Vector holding the Color of the Text */
[8619]64    inline const Color& color() const { return this->_color; };
[5369]65    /** @returns the Size of the Text */
[8619]66    inline float size() const { return this->_size; };
[5343]67
68    virtual void draw() const;
69
70    void debug() const;
71
[7450]72  protected:
73    virtual void setupTextWidth();
[7753]74  private:
75    void init();
[7453]76
[5343]77  private:
[8619]78    Font*             _font;           //!< Font of this text
[5343]79
[8619]80    std::string       _text;           //!< The text to display
81    Color             _color;          //!< The color of the font.
82    float             _size;           //!< The size of the Text.
[1853]83};
84
[5343]85#endif /* _TEXT_H */
Note: See TracBrowser for help on using the repository browser.