summaryrefslogtreecommitdiffstats
path: root/kolf/editor.cpp
blob: 88e3c3759020cf7b86adcf996a4e01bae12f59e4 (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
#include <kdialog.h>
#include <klistbox.h>

#include <tqlabel.h>
#include <tqlayout.h>
#include <tqwidget.h>
#include <tqframe.h>

#include "editor.h"
#include "game.h"

Editor::Editor(ObjectList *list, TQWidget *tqparent, const char *name)
	: TQWidget(tqparent, name)
{
	this->list = list;
	config = 0;

	htqlayout = new TQHBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());

	TQVBoxLayout *vtqlayout = new TQVBoxLayout(htqlayout, KDialog::spacingHint());
	vtqlayout->addWidget(new TQLabel(i18n("Add object:"), this));
	listbox = new KListBox(this, "Listbox");
	vtqlayout->addWidget(listbox);
	htqlayout->setStretchFactor(vtqlayout, 2);

	TQStringList items;
	Object *obj = 0;
	for (obj = list->first(); obj; obj = list->next())
		items.append(obj->name());

	listbox->insertStringList(items);

	connect(listbox, TQT_SIGNAL(executed(TQListBoxItem *)), TQT_SLOT(listboxExecuted(TQListBoxItem *)));
}

void Editor::listboxExecuted(TQListBoxItem * /*item*/)
{
	int curItem = listbox->currentItem();
	if (curItem < 0)
		return;

	emit addNewItem(list->at(curItem));
}

void Editor::setItem(CanvasItem *item)
{
	delete config;
	config = item->config(this);
	if (!config)
		return;
	config->ctorDone();
	htqlayout->addWidget(config);
	htqlayout->setStretchFactor(config, 2);
	config->setFrameStyle(TQFrame::Box | TQFrame::Raised);
	config->setLineWidth(1);
	config->show();
	connect(config, TQT_SIGNAL(modified()), this, TQT_SIGNAL(changed()));
}

#include "editor.moc"