Пример #1
0
void EffectEditor::createArgumentWidgets(ResponseEffect& effect)
{
	ResponseEffect::ArgumentList& list = effect.getArguments();

	// Remove all possible previous items from the list
	_argumentItems.clear();

	// Remove the old table if there exists one
	if (_argTable != NULL)
	{
		// This removes the old table from the alignment container
		_argAlignment->remove();

		/*// greebo: Increase the refCount of the table to prevent destruction.
		// Destruction would cause weird shutdown crashes.
		// greebo: Is this true for gtkmm, I wonder?
		g_object_ref(G_OBJECT(_argTable));
		gtk_container_remove(GTK_CONTAINER(_argAlignment), _argTable);*/
	}

	// Setup the table with default spacings
	_argTable = Gtk::manage(new Gtk::Table(static_cast<guint>(list.size()), 3, false));
    _argTable->set_col_spacings(12);
    _argTable->set_row_spacings(6);

	_argAlignment->add(*_argTable);

	for (ResponseEffect::ArgumentList::iterator i = list.begin();
		 i != list.end(); ++i)
	{
		int index = i->first;
		ResponseEffect::Argument& arg = i->second;
		ArgumentItemPtr item;

		if (arg.type == "s")
		{
			// Create a new string argument item
			item = ArgumentItemPtr(new StringArgument(arg));
		}
		else if (arg.type == "f") {
			// Create a new string argument item
			item = ArgumentItemPtr(new FloatArgument(arg));
		}
		else if (arg.type == "v") {
			// Create a new vector argument item
			item = ArgumentItemPtr(new VectorArgument(arg));
		}
		else if (arg.type == "e") {
			// Create a new string argument item
			item = ArgumentItemPtr(new EntityArgument(arg, _entityStore));
		}
		else if (arg.type == "b") {
			// Create a new bool item
			item = ArgumentItemPtr(new BooleanArgument(arg));
		}
		else if (arg.type == "t") {
			// Create a new stim type item
			item = ArgumentItemPtr(new StimTypeArgument(arg, _stimTypes));
		}

		if (item != NULL)
		{
			_argumentItems.push_back(item);

			if (arg.type != "b")
			{
				// The label
				_argTable->attach(
					item->getLabelWidget(),
					0, 1, index-1, index, // index starts with 1, hence the -1
					Gtk::FILL, Gtk::AttachOptions(0), 0, 0
				);

				// The edit widgets
				_argTable->attach(
					item->getEditWidget(),
					1, 2, index-1, index // index starts with 1, hence the -1
				);
			}
			else {
				// This is a checkbutton - should be spanned over two columns
				_argTable->attach(
					item->getEditWidget(),
					0, 2, index-1, index, // index starts with 1, hence the -1
					Gtk::FILL, Gtk::AttachOptions(0), 0, 0
				);
			}

			// The help widgets
			_argTable->attach(
				item->getHelpWidget(),
				2, 3, index-1, index, // index starts with 1, hence the -1
				Gtk::AttachOptions(0), Gtk::AttachOptions(0), 0, 0
			);
		}
	}

	// Show the table and all subwidgets
	_argTable->show_all();
}
Пример #2
0
void EffectEditor::createArgumentWidgets(ResponseEffect& effect)
{
	ResponseEffect::ArgumentList& list = effect.getArguments();

	// Remove all possible previous items from the list
	_argumentItems.clear();

	// Clear the old table
	_argTable->DeleteWindows();

	for (ResponseEffect::ArgumentList::iterator i = list.begin();
		 i != list.end(); ++i)
	{
		int index = i->first;
		ResponseEffect::Argument& arg = i->second;
		ArgumentItemPtr item;

		if (arg.type == "s")
		{
			// Create a new string argument item
			item = ArgumentItemPtr(new StringArgument(this, arg));
		}
		else if (arg.type == "f")
		{
			// Create a new string argument item
			item = ArgumentItemPtr(new FloatArgument(this, arg));
		}
		else if (arg.type == "v")
		{
			// Create a new vector argument item
			item = ArgumentItemPtr(new VectorArgument(this, arg));
		}
		else if (arg.type == "e") 
		{
			// Create a new string argument item
			item = ArgumentItemPtr(new EntityArgument(this, arg, _entityChoices));
		}
		else if (arg.type == "b")
		{
			// Create a new bool item
			item = ArgumentItemPtr(new BooleanArgument(this, arg));
		}
		else if (arg.type == "t")
		{
			// Create a new stim type item
			item = ArgumentItemPtr(new StimTypeArgument(this, arg, _stimTypes));
		}

		if (item != NULL)
		{
			_argumentItems.push_back(item);

			if (arg.type != "b")
			{
				// The label
				_argTable->Add(item->getLabelWidget(), 0, wxALIGN_CENTER_VERTICAL);

				// The edit widgets
				_argTable->Add(item->getEditWidget(), 1, wxEXPAND);
			}
			else 
			{
				// The label
				_argTable->Add(new wxStaticText(this, wxID_ANY, ""), 0, wxALIGN_CENTER_VERTICAL);

				// The edit widgets
				_argTable->Add(item->getEditWidget(), 1, wxEXPAND);
			}

			// The help widgets
			_argTable->Add(item->getHelpWidget(), 0, wxALIGN_CENTER_VERTICAL);
		}
	}

	_argTable->Layout();
	Layout();
	Fit();
}