Changeset 8539 in orxonox.OLD for branches/gui/src/lib/graphics/text_engine/limited_width_text.cc
- Timestamp:
- Jun 16, 2006, 4:52:35 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/graphics/text_engine/limited_width_text.cc
r8538 r8539 62 62 // drawing this Text. 63 63 // setting the Blending effects 64 glColor4fv(&this-> getColor()[0]);64 glColor4fv(&this->color()[0]); 65 65 66 66 … … 72 72 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 73 73 74 glBindTexture(GL_TEXTURE_2D, this-> getFont()->getTexture());74 glBindTexture(GL_TEXTURE_2D, this->font()->getTexture()); 75 75 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); 76 76 glRotatef(this->getAbsDir2D(), 0, 0, 1); … … 81 81 for (unsigned int i = 0; i < this->_dotedText.size(); i++) 82 82 { 83 if(likely((tmpGlyph = this-> getFont()->getGlyphArray()[this->_dotedText[i]]) != NULL))83 if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_dotedText[i]]) != NULL)) 84 84 { 85 85 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); 86 glVertex2d(posX+tmpGlyph->maxX*this-> getSize(), 0);86 glVertex2d(posX+tmpGlyph->maxX*this->size(), 0); 87 87 88 88 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]); 89 glVertex2d(posX+tmpGlyph->maxX*this-> getSize(), this->getSize());89 glVertex2d(posX+tmpGlyph->maxX*this->size(), this->size()); 90 90 91 91 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]); 92 glVertex2d(posX+tmpGlyph->minX*this-> getSize(), this->getSize());92 glVertex2d(posX+tmpGlyph->minX*this->size(), this->size()); 93 93 94 94 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]); 95 glVertex2d(posX+tmpGlyph->minX*this-> getSize(), 0);95 glVertex2d(posX+tmpGlyph->minX*this->size(), 0); 96 96 97 posX += tmpGlyph->advance * this-> getSize();97 posX += tmpGlyph->advance * this->size(); 98 98 } 99 99 } … … 109 109 void LimitedWidthText::setupTextWidth() 110 110 { 111 float dotsSize = this-> getFont()->getGlyphArray()[46]->advance * 3.0;111 float dotsSize = this->font()->getGlyphArray()[46]->advance * 3.0; 112 112 113 113 float width = 0.0f; 114 float maxWidth = this->_lineWidth / this-> getSize();114 float maxWidth = this->_lineWidth / this->size(); 115 115 116 116 switch (this->_dotsPosition) 117 117 { 118 118 case End: 119 for (unsigned int i = 0; i < this-> getText().size(); i++)119 for (unsigned int i = 0; i < this->text().size(); i++) 120 120 { 121 121 if (width + dotsSize > maxWidth ) 122 122 { 123 this->_dotedText = this-> getText().substr(0, i) + "...";123 this->_dotedText = this->text().substr(0, i) + "..."; 124 124 width += dotsSize; 125 125 break; 126 126 } 127 127 // Advance the Text. 128 if(this-> getFont()->getGlyphArray()[this->getText()[i]] != NULL)129 width += this-> getFont()->getGlyphArray()[this->getText()[i]]->advance;128 if(this->font()->getGlyphArray()[this->text()[i]] != NULL) 129 width += this->font()->getGlyphArray()[this->text()[i]]->advance; 130 130 } 131 131 this->setSizeX2D(width); 132 132 break; 133 133 case Begin: 134 for (unsigned int i = this-> getText().size() - 1; i < 0; i--)134 for (unsigned int i = this->text().size() - 1; i < 0; i--) 135 135 { 136 136 if (width + dotsSize > maxWidth ) 137 137 { 138 this->_dotedText = std::string("...") + this-> getText().substr(i);138 this->_dotedText = std::string("...") + this->text().substr(i); 139 139 width += dotsSize; 140 140 break; 141 141 } 142 142 // Advance the Text. 143 if(this-> getFont()->getGlyphArray()[this->getText()[i]] != NULL)144 width += this-> getFont()->getGlyphArray()[this->getText()[i]]->advance;143 if(this->font()->getGlyphArray()[this->text()[i]] != NULL) 144 width += this->font()->getGlyphArray()[this->text()[i]]->advance; 145 145 } 146 146 this->setSizeX2D(width);
Note: See TracChangeset
for help on using the changeset viewer.