Mana
Loading...
Searching...
No Matches
connectiondialog.cpp
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#include "connectiondialog.h"
23
24#include "log.h"
25
26#include "gui/widgets/button.h"
27#include "gui/widgets/label.h"
28#include "gui/widgets/layout.h"
30
31#include "utils/gettext.h"
32
33ConnectionDialog::ConnectionDialog(const std::string &text,
34 State cancelState):
35 Window(std::string()),
36 mCancelState(cancelState)
37{
38 setTitleBarHeight(0);
39 setMovable(false);
40 setMinWidth(0);
41
42 auto *progressIndicator = new ProgressIndicator;
43 gcn::Label *label = new Label(text);
44 auto *cancelButton = new Button(_("Cancel"), "cancelButton", this);
45
46 place(0, 0, progressIndicator);
47 place(0, 1, label);
48 place(0, 2, cancelButton).setHAlign(LayoutCell::CENTER);
50
51 center();
52 setVisible(true);
53}
54
55void ConnectionDialog::action(const gcn::ActionEvent &)
56{
57 Log::info("Cancel pressed");
59}
60
61void ConnectionDialog::draw(gcn::Graphics *graphics)
62{
63 // Don't draw the window background, only draw the children
64 drawChildren(graphics);
65}
Button widget.
Definition button.h:38
static void setState(State state)
Definition client.h:169
void action(const gcn::ActionEvent &) override
Called when the user presses Cancel.
ConnectionDialog(const std::string &text, State cancelState)
Constructor.
void draw(gcn::Graphics *graphics) override
Label widget.
Definition label.h:34
LayoutCell & setHAlign(Alignment a)
Sets the horizontal alignment of the cell content.
Definition layout.h:185
A widget that indicates progress.
A window.
Definition window.h:59
void center()
Positions the window in the center of it's parent.
Definition window.cpp:768
virtual void setVisible(bool visible)
Overloads window setVisible by Guichan to allow sticky window handling.
Definition window.cpp:282
void reflowLayout(int w=0, int h=0)
Computes the position of the widgets according to the current layout.
Definition window.cpp:748
LayoutCell & place(int x, int y, gcn::Widget *, int w=1, int h=1)
Adds a widget to the window and sets it at given cell.
Definition window.cpp:737
void setMinWidth(int width)
Sets the minimum width of the window.
Definition window.cpp:192
Graphics * graphics
Definition client.cpp:104
State
All client states.
Definition client.h:59
#define _(s)
Definition gettext.h:38
void info(const char *log_text,...) LOG_PRINTF_ATTR