Mana
Loading...
Searching...
No Matches
textpreview.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2006-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
23
24#include "gui/gui.h"
25
26TextPreview::TextPreview(const std::string &text)
27 : mText(text)
28{
29 mFont = gui->getFont();
31}
32
33void TextPreview::draw(gcn::Graphics *graphics)
34{
35 auto g = static_cast<Graphics*>(graphics);
36 g->drawText(mText, 2, 2, gcn::Graphics::LEFT,
37 gcn::Color(mTextColor->r,
38 mTextColor->g,
39 mTextColor->b,
40 255),
42}
A central point of control for graphics.
Definition graphics.h:78
void drawText(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, const gcn::Color &color, gcn::Font *font, bool outline=false, bool shadow=false, const std::optional< gcn::Color > &outlineColor={}, const std::optional< gcn::Color > &shadowColor={})
Definition graphics.cpp:176
gcn::Font * getFont() const
Return game font.
Definition gui.h:107
TextPreview(const std::string &text)
const gcn::Color * mTextColor
Definition textpreview.h:86
gcn::Font * mFont
Definition textpreview.h:84
void draw(gcn::Graphics *graphics) override
Widget's draw method.
std::string mText
Definition textpreview.h:85
static const gcn::Color & getThemeColor(int type)
Gets the color associated with the type in the default palette (0).
Definition theme.cpp:313
@ TEXT
Definition theme.h:214
Graphics * graphics
Definition client.cpp:104
Gui * gui
The GUI system.
Definition gui.cpp:50