Changeset 7450 in orxonox.OLD for trunk/src/lib/graphics/text_engine/multi_line_text.h
- Timestamp:
- Apr 29, 2006, 9:38:44 PM (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine/multi_line_text.h
r7449 r7450 1 1 /*! 2 * @file text.h2 * @file multi_line_text.h 3 3 * @brief Definition of a text Class, that is able to render text. 4 4 */ 5 5 6 #ifndef _ TEXT_H7 #define _ TEXT_H6 #ifndef _MULTI_LINE_TEXT_H 7 #define _MULTI_LINE_TEXT_H 8 8 9 #include " element_2d.h"9 #include "text.h" 10 10 11 #include "glincl.h" 12 13 #define TEXT_ALIGN_LEFT E2D_ALIGN_LEFT 14 #define TEXT_ALIGN_RIGHT E2D_ALIGN_RIGHT 15 #define TEXT_ALIGN_CENTER E2D_ALIGN_CENTER 16 #define TEXT_ALIGN_SCREEN_CENTER E2D_ALIGN_SCREEN_CENTER 17 #define TEXT_DEFAULT_COLOR Vector(1.0, 1.0, 1.0) //!< the default Color (white) 18 #define TEXT_DEFAULT_BLENDING 1.0f //!< the default blending of the text, (no blending at all) 19 20 #define TEXT_DEFAULT_ALIGNMENT TEXT_ALIGN_LEFT //!< default alignment 21 #define TEXT_DEFAULT_SIZE 20 //!< default size of the Text 22 23 24 // FORWARD DECLARATION 25 class Font; 26 struct SDL_Surface; 27 28 //! A Struct to handel Texture Coordinates for quads 29 struct TexCoord 30 { 31 float minU; //!< The minimum U-Coordinate 32 float maxU; //!< The maximum U-Coordinate 33 float minV; //!< The minimum V-Coordinate 34 float maxV; //!< The maximum V-Coordinate 35 }; 11 #include <vector> 36 12 37 13 //! Represents one textElement. 38 class Text : public Element2D14 class MultiLineText : public Text 39 15 { 40 16 public: 41 Text(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE); 42 virtual ~Text(); 17 MultiLineText(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE); 43 18 44 void setFont(const std::string& fontFile, unsigned int renderSize); 19 // Setup: 20 void setLineWidth(float lineWidth); 21 /** @param lineSpacing: the Spacing between the lines */ 22 void setLineSpacing(float lineSpacing) { this->lineSpacing = lineSpacing; }; 45 23 46 void setText(const std::string& text); 47 48 /** @returns the String this Text displays */ 49 inline const std::string& getText() const { return this->text; }; 50 /** @param blending the blending intensity to set (between 0.0 and 1.0) */ 51 inline void setBlending(float blending) { this->blending = blending; }; 52 /** sets the Color of the Text to render (values in [0-1]) @param r red @param g green @param b blue */ 53 void setColor(float r, float g, float b) { this->color = Vector(r, g, b); }; 54 /** sets the Size of the Font */ 55 void setSize(float size) { this->setSizeY2D(size); }; 56 /** @returns the Size of the Text */ 57 // void getSize(float &x, float& y) const { return this->size; }; 24 // Retrieve: 25 /** @returns the LineWidth (maximum distance from the left to the right */ 26 inline float getLineWidth() const { return this->lineWidth; }; 27 /** @returns the LineSpacing */ 28 inline float getLineSpacing() const { return this->lineSpacing; }; 58 29 59 30 virtual void draw() const; 60 31 61 void debug() const; 62 63 // helpers. 64 static GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord); 65 static int powerOfTwo(int input); 32 protected: 33 virtual void setupTextWidth(); 66 34 67 35 private: 68 Font* font; //!< Font of this text 69 70 std::string text; //!< The text to display 71 Vector color; //!< The color of the font. 72 float blending; //!< The blending intensity. 36 float lineWidth; 37 float lineSpacing; 38 std::vector<unsigned int> lineEnds; 73 39 }; 74 40 75 #endif /* _ TEXT_H */41 #endif /* _MULTI_LINE_TEXT_H */
Note: See TracChangeset
for help on using the changeset viewer.