Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: b593388d3701fd2f1cb844e65b930b010fc440e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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() * 1.5f
       	);	
	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