diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-11-22 18:47:48 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-11-22 18:47:48 +0100 |
commit | 1c392d41f9004c3bf0b8455465ec62fe89109a63 (patch) | |
tree | e6011b93c74aaac4d5c419c2559bee8d6f27be24 /src/text.h | |
parent | f0ce72bc759a99cbe6611b54e6f307e39c3634f4 (diff) | |
download | mana-1c392d41f9004c3bf0b8455465ec62fe89109a63.tar.gz mana-1c392d41f9004c3bf0b8455465ec62fe89109a63.tar.bz2 mana-1c392d41f9004c3bf0b8455465ec62fe89109a63.tar.xz mana-1c392d41f9004c3bf0b8455465ec62fe89109a63.zip |
Fixed non-virtual destructor
The class had virtual methods, in which case it's good practice to also
make the destructor virtual. Otherwise you can end up with destructors
of subclasses not being called on deletion.
Diffstat (limited to 'src/text.h')
-rw-r--r-- | src/text.h | 47 |
1 files changed, 22 insertions, 25 deletions
@@ -30,43 +30,41 @@ class TextManager; class Text { - friend class TextManager; + friend class TextManager; + public: /** - * Constructor creates a text object to display on the screen + * Constructor creates a text object to display on the screen. */ Text(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, gcn::Font *font, gcn::Color colour); /** - * Allows the originator of the text to specify the ideal coordinates + * Destructor. The text is removed from the screen. */ - void - adviseXY(int x, int y); + virtual ~Text(); /** - * Remove the text from the screen + * Allows the originator of the text to specify the ideal coordinates. */ - ~Text(); + void adviseXY(int x, int y); /** - * Draws the text + * Draws the text. */ - virtual void - draw(Graphics *graphics, int xOff, int yOff); + virtual void draw(Graphics *graphics, int xOff, int yOff); private: - - int mX; /**< Actual x-value of left of text written */ - int mY; /**< Actual y-value of top of text written */ - int mWidth; /**< The width of the text */ - int mHeight; /**< The height of the text */ - int mXOffset; /**< The offset of mX from the desired x */ - static int mInstances; /**< Instances of text */ - gcn::Font *mFont; /**< The font used */ - std::string mText; /**< The text to display */ - gcn::Color mColour; /**< The colour of the text */ + int mX; /**< Actual x-value of left of text written. */ + int mY; /**< Actual y-value of top of text written. */ + int mWidth; /**< The width of the text. */ + int mHeight; /**< The height of the text. */ + int mXOffset; /**< The offset of mX from the desired x. */ + static int mInstances; /**< Instances of text. */ + gcn::Font *mFont; /**< The font used. */ + std::string mText; /**< The text to display. */ + gcn::Color mColour; /**< The colour of the text. */ }; class FlashText : public Text @@ -77,18 +75,17 @@ class FlashText : public Text gcn::Color colour); /** - * Flash the text for so many refreshes + * Flash the text for so many refreshes. */ void flash(int time) {mTime = time; } /** - * Draws the text + * Draws the text. */ - virtual void - draw(Graphics *graphics, int xOff, int yOff); + virtual void draw(Graphics *graphics, int xOff, int yOff); private: - int mTime; /**< Time left for flashing */ + int mTime; /**< Time left for flashing. */ }; #endif // _TMW_TEXT_H |