summaryrefslogtreecommitdiff
path: root/plugins/Skins/SkinLib/Dialog.cpp
blob: edc8437817140d3e1d15c7182a998cb2f02c1065 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "globals.h"
#include "Dialog.h"
#include "DialogState.h"


Dialog::Dialog(const char *aName) : name(aName)
{
}


Dialog::~Dialog()
{
	for(unsigned int i = 0; i < fields.size(); i++) 
		delete fields[i];

	fields.clear();
}


const char * Dialog::getName() const
{
	return name.c_str();
}


bool Dialog::addField(Field *field)
{
	if (getField(field->getName()) != NULL)
		return false;

	fields.push_back(field);
	return true;
}


Field * Dialog::getField(const char *name) const
{
	if (name == NULL || name[0] == 0)
		return NULL;

	for(unsigned int i = 0; i < fields.size(); i++) 
	{
		Field *field = fields[i];
		if (strcmp(name, field->getName()) == 0)
			return field;
	}

	return NULL;
}

Field * Dialog::getField(unsigned int pos) const
{
	if (pos >= fields.size())
		return NULL;
	return fields[pos];
}

int Dialog::getIndexOf(Field *field) const
{
	for(unsigned int i = 0; i < fields.size(); i++) 
	{
		Field *f = fields[i];
		if (field == f)
			return i;
	}

	return -1;
}

unsigned int Dialog::getFieldCount() const
{
	return fields.size();
}

DialogInfo * Dialog::getInfo()
{
	return &info;
}

const Size & Dialog::getSize() const
{
	return size;
}


void Dialog::setSize(const Size &size)
{
	this->size = size;
}


DialogState * Dialog::createState()
{
	DialogState *ret = new DialogState(this);

	for(unsigned int i = 0; i < fields.size(); i++) 
		ret->fields.push_back(fields[i]->createState(ret));

	return ret;
}