summaryrefslogtreecommitdiff
path: root/src/text.h
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-11-22 18:47:48 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-11-22 18:47:48 +0100
commit1c392d41f9004c3bf0b8455465ec62fe89109a63 (patch)
treee6011b93c74aaac4d5c419c2559bee8d6f27be24 /src/text.h
parentf0ce72bc759a99cbe6611b54e6f307e39c3634f4 (diff)
downloadmana-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.h47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/text.h b/src/text.h
index e57fc06a..995b9a58 100644
--- a/src/text.h
+++ b/src/text.h
@@ -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