ManaPlus
text.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2008 Douglas Boffey <[email protected]>
4  * Copyright (C) 2008-2009 The Mana World Development Team
5  * Copyright (C) 2009-2010 The Mana Developers
6  * Copyright (C) 2011-2018 The ManaPlus Developers
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef TEXT_H
25 #define TEXT_H
26 
27 #include "enums/simpletypes/move.h"
29 
30 #include "gui/fonts/textchunk.h"
31 
32 #include "render/graphics.h"
33 
34 #include "localconsts.h"
35 
36 class Font;
37 
39 {
40  friend class TextManager;
41 
42  public:
46  Text(const std::string &text,
47  const int x, const int y,
48  const Graphics::Alignment alignment,
49  const Color *const color,
50  const Speech isSpeech,
51  Font *const font);
52 
54 
55 
58  virtual ~Text();
59 
60  void setColor(const Color *const color);
61 
63  { return mWidth; }
64 
66  { return mHeight; }
67 
71  void adviseXY(const int x, const int y, const Move move);
72 
76  virtual void draw(Graphics *const graphics,
77  const int xOff, const int yOff) A_NONNULL(2);
78 
79 // int getWidth() A_WARN_UNUSED;
80 
82  { return mX; }
83 
85  { return mY; }
86 
87  private:
90  int mX;
91  int mY;
92  int mWidth;
93  int mHeight;
94  int mXOffset;
95  static int mInstances;
96  std::string mText;
97  const Color *mColor;
101 
102  protected:
104 };
105 
106 class FlashText final : public Text
107 {
108  public:
109  FlashText(const std::string &text, const int x, const int y,
110  const Graphics::Alignment alignment,
111  const Color *const color,
112  Font *const font = nullptr);
113 
115 
116 
119  void flash(const int time)
120  { mTime = time; }
121 
125  void draw(Graphics *const graphics,
126  const int xOff,
127  const int yOff) override final A_NONNULL(2);
128 
129  private:
130  int mTime;
131 };
132 
133 #endif // TEXT_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
void setColor(const Color *const color)
Definition: text.cpp:129
Definition: font.h:88
int mXOffset
Definition: text.h:94
#define A_WARN_UNUSED
Definition: localconsts.h:172
#define final
Definition: localconsts.h:45
static int mInstances
Definition: text.h:95
#define A_NONNULL(...)
Definition: localconsts.h:179
int mX
Definition: text.h:90
Font * mFont
Definition: text.h:88
int mY
Definition: text.h:91
const Color * mColor
Definition: text.h:97
Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, const Color *const color, const Speech isSpeech, Font *const font)
Definition: text.cpp:45
int getY() const
Definition: text.h:84
#define notfinal
Definition: localconsts.h:289
static ImageRect mBubble
Definition: text.h:103
Color mOutlineColor
Definition: text.h:98
bool move(InputEvent &event)
Definition: commands.cpp:43
bool mTextChanged
Definition: text.h:100
int getX() const
Definition: text.h:81
int mTime
Definition: text.h:130
int getHeight() const
Definition: text.h:65
TextChunk mTextChunk
Definition: text.h:89
int mHeight
Definition: text.h:93
Definition: color.h:74
int getWidth() const
Definition: text.h:62
virtual ~Text()
Definition: text.cpp:111
void adviseXY(const int x, const int y, const Move move)
Definition: text.cpp:143
std::string mText
Definition: text.h:96
#define noexcept2
Definition: localconsts.h:49
Speech mIsSpeech
Definition: text.h:99
virtual void draw(Graphics *const graphics, const int xOff, const int yOff)
Definition: text.cpp:157
Definition: text.h:38
int mWidth
Definition: text.h:92