Mana
Loading...
Searching...
No Matches
button.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-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
22#pragma once
23
24#include <guichan/widgets/button.hpp>
25
26#include <memory>
27#include <vector>
28
29class Image;
30class TextPopup;
31
37class Button : public gcn::Button
38{
39 public:
43 Button();
44
49 Button(const std::string &caption, const std::string &actionEventId,
50 gcn::ActionListener *listener);
51
52 ~Button() override;
53
57 void draw(gcn::Graphics *graphics) override;
58
59 void adjustSize();
60
61 void setCaption(const std::string &caption);
62
71 bool setButtonIcon(const std::string &iconFile);
72
78 void setButtonPopupText(const std::string &text)
79 { mPopupText = text; }
80
81 void mouseMoved(gcn::MouseEvent &event) override;
82 void mouseExited(gcn::MouseEvent &event) override;
83
84 private:
85 void init();
86
87 void removeButtonIcon();
88
89 std::vector<std::unique_ptr<Image>> mButtonIcon;
96 std::string mPopupText;
97};
Button widget.
Definition button.h:38
static TextPopup * mTextPopup
The buttons popup.
Definition button.h:95
void setCaption(const std::string &caption)
Definition button.cpp:226
Button()
Default constructor.
Definition button.cpp:45
void init()
Definition button.cpp:109
bool setButtonIcon(const std::string &iconFile)
Set the icons available next to the text.
Definition button.cpp:66
void draw(gcn::Graphics *graphics) override
Draws the button.
Definition button.cpp:121
void removeButtonIcon()
Definition button.cpp:100
void adjustSize()
Definition button.cpp:207
std::vector< std::unique_ptr< Image > > mButtonIcon
Button Icons graphics.
Definition button.h:89
std::string mPopupText
the current button text
Definition button.h:96
~Button() override
void mouseExited(gcn::MouseEvent &event) override
Definition button.cpp:255
void mouseMoved(gcn::MouseEvent &event) override
Definition button.cpp:232
void setButtonPopupText(const std::string &text)
Set the button popup text when hovering it for a few seconds.
Definition button.h:78
Defines a class for loading and storing images.
Definition image.h:45
A popup that displays information about an item.
Definition textpopup.h:36
Graphics * graphics
Definition client.cpp:104