コード例 #1
0
ファイル: ThingTypeTreeView.cpp プロジェクト: IjonTichy/SLADE
ThingTypeTreeView::ThingTypeTreeView(wxWindow* parent) : wxDataViewTreeCtrl(parent, -1)
{
	parent_dialog = NULL;

	// Create root item
	root = AppendContainer(wxDataViewItem(0), "Thing Types", -1, 1);

	// Populate tree
	vector<tt_t> specials = theGameConfiguration->allThingTypes();
	for (unsigned a = 0; a < specials.size(); a++)
	{
		AppendItem(getGroup(specials[a].type->getGroup()),
		           S_FMT("%d: %s", specials[a].number, CHR(specials[a].type->getName())), -1);
	}

	// Bind events
	Bind(wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING, &ThingTypeTreeView::onItemEdit, this);
	Bind(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, &ThingTypeTreeView::onItemActivated, this);

	Expand(root);
}
コード例 #2
0
	wxDataViewItem getGroup(string group)
	{
		// Check if group was already made
		for (unsigned a = 0; a < groups_.size(); a++)
		{
			if (group == groups_[a].name)
				return groups_[a].item;
		}

		// Split group into subgroups
		auto path = wxSplit(group, '/');

		// Create group needed
		auto current = root_;
		string fullpath = "";
		for (unsigned p = 0; p < path.size(); p++)
		{
			if (p > 0) fullpath += "/";
			fullpath += path[p];

			bool found = false;
			for (unsigned a = 0; a < groups_.size(); a++)
			{
				if (groups_[a].name == fullpath)
				{
					current = groups_[a].item;
					found = true;
					break;
				}
			}

			if (!found)
			{
				current = AppendContainer(current, path[p], -1, 1);
				groups_.push_back({ current, fullpath });
			}
		}

		return current;
	}
コード例 #3
0
/* ActionSpecialTreeView::getGroup
 * Returns the parent wxDataViewItem representing action special
 * group [group]
 *******************************************************************/
wxDataViewItem ActionSpecialTreeView::getGroup(string group)
{
	// Check if group was already made
	for (unsigned a = 0; a < groups.size(); a++)
	{
		if (group == groups[a].name)
			return groups[a].item;
	}

	// Split group into subgroups
	wxArrayString path = wxSplit(group, '/');

	// Create group needed
	wxDataViewItem current = root;
	string fullpath = "";
	for (unsigned p = 0; p < path.size(); p++)
	{
		if (p > 0) fullpath += "/";
		fullpath += path[p];

		bool found = false;
		for (unsigned a = 0; a < groups.size(); a++)
		{
			if (groups[a].name == fullpath)
			{
				current = groups[a].item;
				found = true;
				break;
			}
		}

		if (!found)
		{
			current = AppendContainer(current, path[p], -1, 1);
			groups.push_back(astv_group_t(current, fullpath));
		}
	}

	return current;
}