From 5dea1a263136c4cbe011de3325605dd3dc4523af Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 13 Oct 2012 15:38:03 +0000 Subject: Added dialog infrastructure. --- src/client/dialog.cc | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/client/dialog.cc (limited to 'src/client/dialog.cc') 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 -- cgit v1.2.3