Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

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

Location:
trunk/src/lib/graphics/text_engine
Files:
2 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
  • trunk/src/lib/graphics/text_engine/text.h

    r7453 r7753  
    2828  public:
    2929    Text(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE);
     30    Text(const Text& text);
    3031    virtual ~Text();
     32    bool operator==(const Text& text) const;
     33    bool operator==(const std::string& text) const;
     34    Text& operator=(const Text& text);
    3135
    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
    3342    void setFont(const std::string& fontFile, unsigned int renderSize);
    34     void setText(const std::string& text);
    3543    /** @param blending the blending intensity to set (between 0.0 and 1.0) */
    3644    inline void setBlending(float blending) { this->blending = blending; };
     
    3947    void setSize(float size);
    4048
     49
    4150    /// RETRIEVE
     51    /** @returns the String this Text displays */
     52    inline const std::string& getText() const { return this->text; };
     53
    4254    /** @returns the pointer to the stored Font (not changeable) */
    4355    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; };
    4656    /** @returns the Blending Value [0 invisible 1.0 full visible */
    4757    inline float getBlending() const { return this->blending; };
     
    5767  protected:
    5868    virtual void setupTextWidth();
     69  private:
     70    void init();
    5971
    6072  private:
Note: See TracChangeset for help on using the changeset viewer.