Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: added MultiLineText a Text for multiple line-input, that should automatically shilft position

File size: 2.6 KB
Line 
1/*!
2 * @file text.h
3 * @brief Definition of a text Class, that is able to render text.
4 */
5
6#ifndef _TEXT_H
7#define _TEXT_H
8
9#include "element_2d.h"
10
11#define  TEXT_ALIGN_LEFT             E2D_ALIGN_LEFT
12#define  TEXT_ALIGN_RIGHT            E2D_ALIGN_RIGHT
13#define  TEXT_ALIGN_CENTER           E2D_ALIGN_CENTER
14#define  TEXT_ALIGN_SCREEN_CENTER    E2D_ALIGN_SCREEN_CENTER
15#define  TEXT_DEFAULT_COLOR          Vector(1.0, 1.0, 1.0)      //!< the default Color (white)
16#define  TEXT_DEFAULT_BLENDING       1.0f                       //!< the default blending of the text, (no blending at all)
17
18#define  TEXT_DEFAULT_ALIGNMENT      TEXT_ALIGN_LEFT            //!< default alignment
19#define  TEXT_DEFAULT_SIZE           20                         //!< default size of the Text
20
21// FORWARD DECLARATION
22class Font;
23struct SDL_Surface;
24
25//! Represents one textElement.
26class Text : public Element2D
27{
28  public:
29    Text(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE);
30    virtual ~Text();
31
32    // SETUP
33    void setFont(const std::string& fontFile, unsigned int renderSize);
34    void setText(const std::string& text);
35    /** @param blending the blending intensity to set (between 0.0 and 1.0) */
36    inline void setBlending(float blending) { this->blending = blending; };
37    /** @param r red @param g green @param b blue @brief sets the Color of the Text to render (values in [0-1]) */
38    void setColor(float r, float g, float b) { this->color = Vector(r, g, b); };
39    /** @param size the Size of the Text @brief sets the Size of the Font */
40    inline void setSize(float size) { this->setSizeY2D(size); };
41
42    /// RETRIEVE
43    /** @returns the pointer to the stored Font (not changeable) */
44    inline const Font* const getFont() const { return this->font; };
45    /** @returns the String this Text displays */
46    inline const std::string& getText() const { return this->text; };
47    /** @returns the Blending Value [0 invisible 1.0 full visible */
48    inline float getBlending() const { return this->blending; };
49    /** @returns: a Vector(r,g,b) @brief: retrieve a Vector holding the Color of the Text */
50    inline const Vector& getColor() const { return this->color; };
51    /** @returns the Size of the Text */
52    inline float getSize() const { return this->getSizeY2D(); };
53
54    virtual void draw() const;
55
56    void debug() const;
57
58  protected:
59    virtual void setupTextWidth();
60  private:
61    Font*             font;           //!< Font of this text
62
63    std::string       text;           //!< The text to display
64    Vector            color;          //!< The color of the font.
65    float             blending;       //!< The blending intensity.
66};
67
68#endif /* _TEXT_H */
Note: See TracBrowser for help on using the repository browser.