Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-10-13 15:38:03 +0000
committerStijn Buys <ingar@osirion.org>2012-10-13 15:38:03 +0000
commit5dea1a263136c4cbe011de3325605dd3dc4523af (patch)
tree6da09a6007a148d5fe13254f275bb68b71242429 /src/client/dialog.cc
parent3b8ea0849fac5532d61a90608bda876cf518ba1b (diff)
Added dialog infrastructure.
Diffstat (limited to 'src/client/dialog.cc')
-rw-r--r--src/client/dialog.cc72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/client/dialog.cc b/src/client/dialog.cc
new file mode 100644
index 0000000..f113433
--- /dev/null
+++ b/src/client/dialog.cc
@@ -0,0 +1,72 @@
+/*
+ client/dialog.cc
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+#include "client/dialog.h"
+#include "ui/ui.h"
+
+namespace client
+{
+
+Dialog::Dialog(ui::Widget * parent) :
+ ui::Window(parent)
+{
+ set_border(false);
+ set_background(false);
+ set_label("dialog");
+
+ dialog_widget = new ui::Widget(this);
+ dialog_widget->set_border(true);
+ dialog_widget->set_background(true);
+
+ dialog_label = new ui::Label(dialog_widget);
+ dialog_label->set_border(false);
+ dialog_label->set_background(false);
+ dialog_label->set_alignment(ui::AlignTop | ui::AlignHCenter);
+
+ dialog_button = new ui::Button(dialog_widget);
+}
+
+Dialog::~Dialog()
+{
+}
+
+void Dialog::set_text(const std::string &text)
+{
+ dialog_label->set_text(text);
+}
+
+void Dialog::set_button(const std::string &text)
+{
+ dialog_button->set_text(text);
+}
+
+void Dialog::set_command(const std::string &command)
+{
+ dialog_button->set_command(command);
+}
+
+void Dialog::resize()
+{
+ const float padding = ui::root()->font_large()->height();
+
+ dialog_widget->set_size(
+ ui::UI::elementsize.width() * 3.0f,
+ ui::UI::elementsize.width() * 2.0f
+ );
+ dialog_widget->set_location(
+ (width() - dialog_widget->width()) * 0.5f,
+ (height() - dialog_widget->height()) * 0.5f
+ );
+
+ dialog_label->set_size(dialog_widget->width() - padding * 2.0f, dialog_widget->height() - padding * 2.0f);
+ dialog_label->set_location(padding, padding);
+
+ dialog_button->set_size(ui::UI::elementsize);
+ dialog_button->set_location((dialog_widget->width() - dialog_button->width()) * 0.5f,
+ dialog_widget->height() - dialog_button->height() - padding);
+}
+
+} // namespace client