Changeset 7753 in orxonox.OLD for trunk/src/lib/graphics/text_engine
- Timestamp:
- May 21, 2006, 5:24:14 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/text_engine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine/text.cc
r7742 r7753 39 39 this->color = TEXT_DEFAULT_COLOR; 40 40 41 this->setAlignment(TEXT_DEFAULT_ALIGNMENT); 42 41 43 this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE); 42 43 this->setAlignment(TEXT_DEFAULT_ALIGNMENT); 44 } 44 } 45 46 Text::Text(const Text& text) 47 { 48 this->setClassID(CL_TEXT, "Text"); 49 this->font = NULL; 50 51 *this = text; 52 } 53 45 54 46 55 /** … … 53 62 } 54 63 64 /** 65 * @brief compare the Text with another Text. 66 * @param text the Text to compare. 67 * @returns true if all the properties Match. 68 */ 69 bool Text::operator==(const Text& text) const 70 { 71 return (this->text == text.text && 72 this->size == text.size && 73 this->font == text.font && 74 this->color == text.color && 75 this->blending == text.blending); 76 } 77 78 /** 79 * @brief compare this Text's internal String with the text. 80 * @param text the Comparator Text. 81 * @returns true on a match. 82 */ 83 bool Text::operator==(const std::string& text) const 84 { 85 return (this->text == text); 86 } 87 88 /** 89 * @brief Copies the properties of one text onto the other one. 90 * @param text: the Text to apply to this one. 91 * @returns This-reference. 92 */ 93 Text& Text::operator=(const Text& text) 94 { 95 this->size = text.size; 96 this->blending = text.blending; 97 this->color = text.color; 98 this->setAlignment(text.getAlignment()); 99 if (this->font != NULL) 100 ResourceManager::getInstance()->unload(this->font); 101 102 this->font = (Font*)ResourceManager::getInstance()->copy( text.font ); //!< HACK 103 104 this->text = text.text; 105 return *this; 106 } 107 108 /** 109 * @brief Sets a new Text to the font 110 * @param text the new text to set 111 */ 112 void Text::setText(const std::string& text) 113 { 114 this->text = text; 115 this->setupTextWidth(); 116 } 117 118 /** 119 * @brief append some text to the already existing Text. 120 * @param appendText The text to append to this Text. 121 */ 122 void Text::append(const std::string& appendText) 123 { 124 this->text += appendText; 125 this->setupTextWidth(); 126 } 127 128 /** 129 * @brief append some text to the already existing Text. 130 * @param appendText The text to append to this Text. 131 */ 132 const std::string& Text::operator <<(const std::string& appendText) 133 { 134 this->append(appendText); 135 return this->text; 136 } 55 137 56 138 /** … … 87 169 88 170 /** 89 * @brief Sets a new Text to the font90 * @param text the new text to set91 */92 void Text::setText(const std::string& text)93 {94 this->text = text;95 96 this->setupTextWidth();97 }98 99 100 /**101 171 * @brief sets the Size of the Font 102 172 * @param size :the size of the Text -
trunk/src/lib/graphics/text_engine/text.h
r7453 r7753 28 28 public: 29 29 Text(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE); 30 Text(const Text& text); 30 31 virtual ~Text(); 32 bool operator==(const Text& text) const; 33 bool operator==(const std::string& text) const; 34 Text& operator=(const Text& text); 31 35 32 // SETUP 36 /// Final Interfacing. 37 void setText(const std::string& text); 38 void append(const std::string& appendText); 39 const std::string& operator<<(const std::string& appendText); 40 41 /// SETUP 33 42 void setFont(const std::string& fontFile, unsigned int renderSize); 34 void setText(const std::string& text);35 43 /** @param blending the blending intensity to set (between 0.0 and 1.0) */ 36 44 inline void setBlending(float blending) { this->blending = blending; }; … … 39 47 void setSize(float size); 40 48 49 41 50 /// RETRIEVE 51 /** @returns the String this Text displays */ 52 inline const std::string& getText() const { return this->text; }; 53 42 54 /** @returns the pointer to the stored Font (not changeable) */ 43 55 inline const Font* const getFont() const { return this->font; }; 44 /** @returns the String this Text displays */45 inline const std::string& getText() const { return this->text; };46 56 /** @returns the Blending Value [0 invisible 1.0 full visible */ 47 57 inline float getBlending() const { return this->blending; }; … … 57 67 protected: 58 68 virtual void setupTextWidth(); 69 private: 70 void init(); 59 71 60 72 private:
Note: See TracChangeset
for help on using the changeset viewer.