Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7753 in orxonox.OLD for trunk/src/lib/graphics/text_engine/text.cc


Ignore:
Timestamp:
May 21, 2006, 5:24:14 PM (18 years ago)
Author:
bensch
Message:

trunk: removed GTK, and also extended the Text Class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/text_engine/text.cc

    r7742 r7753  
    3939  this->color = TEXT_DEFAULT_COLOR;
    4040
     41  this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
     42
    4143  this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
    42 
    43   this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
    44 }
     44}
     45
     46Text::Text(const Text& text)
     47{
     48  this->setClassID(CL_TEXT, "Text");
     49  this->font = NULL;
     50
     51  *this = text;
     52}
     53
    4554
    4655/**
     
    5362}
    5463
     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 */
     69bool 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 */
     83bool 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 */
     93Text& 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 */
     112void 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 */
     122void 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 */
     132const std::string& Text::operator <<(const std::string& appendText)
     133{
     134  this->append(appendText);
     135  return this->text;
     136}
    55137
    56138/**
     
    87169
    88170/**
    89  * @brief Sets a new Text to the font
    90  * @param text the new text to set
    91  */
    92 void Text::setText(const std::string& text)
    93 {
    94   this->text = text;
    95 
    96   this->setupTextWidth();
    97 }
    98 
    99 
    100 /**
    101171 * @brief sets the Size of the Font
    102172 * @param size :the size of the Text
Note: See TracChangeset for help on using the changeset viewer.