예제 #1
0
/* BrowserWindow::openTree
 * 'Opens' the items in [node] and all its children, adding them
 * to the browser canvas' list of items. If [clear] is true, the
 * current list contents will be cleared
 *******************************************************************/
void BrowserWindow::openTree(BrowserTreeNode* node, bool clear)
{
	// Clear if needed
	if (clear)
	{
		canvas->clearItems();

		// Also add global items
		for (unsigned a = 0; a < items_global.size(); a++)
			canvas->addItem(items_global[a]);
	}

	// Add all items in the node
	for (unsigned a = 0; a < node->nItems(); a++)
	{
		canvas->addItem(node->getItem(a));
		node->getItem(a)->parent = this;
	}

	// Add all child nodes' items
	for (unsigned a = 0; a < node->nChildren(); a++)
		openTree((BrowserTreeNode*)node->getChild(a), false);

	// If the list was cleared, sort it, filter it and update the canvas scrollbar
	if (clear)
	{
		doSort(choice_sort->GetSelection());
		canvas->filterItems(text_filter->GetValue());
		canvas->showSelectedItem();
	}
}
예제 #2
0
/* BrowserWindow::onTreeItemSelected
 * Called when an item on the category wxTreeCtrl is selected
 *******************************************************************/
void BrowserWindow::onTreeItemSelected(wxTreeListEvent& e)
{
	BrowserTreeItemData* data = (BrowserTreeItemData*)tree_items->GetItemData(e.GetItem());
	if (data)
		openTree(data->getNode());
	canvas->Refresh();
}
예제 #3
0
void App::openTree(int index, const QString &file)
{
    // no file selected
    if (index == -1)
        return;

    // new data file
    if (index == -2)
    {
        newFile();

        return;
    }

    createNotes();
    if (!openTree(file))
    {
        destroyNotes();

        return;
    }
    
    currentFile = file;
    setModified(false);
    
    foreignDeletedNode = !notes->isClipboardEmpty();
    
    if (preferences.showReminder)
        notes->showReminder(false);
	notes->repaint();
}
예제 #4
0
ThingTypeBrowser::ThingTypeBrowser(wxWindow* parent, int type) : BrowserWindow(parent)
{
	// Set window title
	SetTitle("Browse Thing Types");

	// Add 'Details view' checkbox
	cb_view_tiles = new wxCheckBox(this, -1, "Details view");
	cb_view_tiles->SetValue(browser_thing_tiles);
	sizer_bottom->Add(cb_view_tiles, 0, wxEXPAND|wxRIGHT, 4);

	// Populate tree
	vector<tt_t> types = theGameConfiguration->allThingTypes();
	for (unsigned a = 0; a < types.size(); a++)
		addItem(new ThingBrowserItem(types[a].type->getName(), types[a].type, types[a].number), types[a].type->getGroup());
	populateItemTree();

	// Set browser options
	canvas->setItemNameType(BrowserCanvas::NAMES_INDEX);
	setupViewOptions();

	// Select initial item if any
	if (type >= 0)
		selectItem(theGameConfiguration->thingType(type)->getName());
	else
		openTree(items_root);	// Otherwise open 'all' category


	// Bind events
	cb_view_tiles->Bind(wxEVT_CHECKBOX, &ThingTypeBrowser::onViewTilesClicked, this);

	Layout();
}
예제 #5
0
/* BrowserWindow::selectItem
 * Finds the item matching [name] in the tree, starting from [node].
 * If the item is found, its parent node is opened in the browser
 * and the item is selected
 *******************************************************************/
bool BrowserWindow::selectItem(string name, BrowserTreeNode* node)
{
	// Check node was given, if not start from root
	if (!node)
		node = items_root;

	// Check global items
	for (unsigned a = 0; a < items_global.size(); a++)
	{
		if (S_CMPNOCASE(name, items_global[a]->getName()))
		{
			openTree(node);
			canvas->selectItem(items_global[a]);
			canvas->showSelectedItem();
			return true;
		}
	}

	// Go through all items in this node
	for (unsigned a = 0;  a < node->nItems(); a++)
	{
		// Check for name match (not case-sensitive)
		if (S_CMPNOCASE(node->getItem(a)->getName(), name))
		{
			// Open this node in the browser and select the item
			openTree(node);
			canvas->selectItem(node->getItem(a));
			canvas->showSelectedItem();
			tree_items->Select(node->getTreeId());
			tree_items->Expand(node->getTreeId());
			return true;
		}
	}

	// Item not found in this one, try its child nodes
	for (unsigned a = 0; a < node->nChildren(); a++)
	{
		if (selectItem(name, (BrowserTreeNode*)node->getChild(a)))
			return true;
	}

	// Item not found
	return false;
}
예제 #6
0
// The following function takes a visible row index (hidden rows skipped)
// dir: -1 = left (close), 0 = auto (toggle), 1 = right (open)
void GUITable::toggleVisibleTree(s32 row_i, int dir, bool move_selection)
{
	// Check if the chosen tree is currently open
	const Row *row = getRow(row_i);
	if (row == NULL)
		return;

	bool was_open = false;
	for (s32 j = 0; j < row->cellcount; ++j) {
		if (row->cells[j].content_type == COLUMN_TYPE_TREE) {
			was_open = row->cells[j].content_index == 0;
			break;
		}
	}

	// Check if the chosen tree should be opened
	bool do_open = !was_open;
	if (dir < 0)
		do_open = false;
	else if (dir > 0)
		do_open = true;

	// Close or open the tree; the heavy lifting is done by setOpenedTrees
	if (was_open && !do_open)
		closeTree(m_visible_rows[row_i]);
	else if (!was_open && do_open)
		openTree(m_visible_rows[row_i]);

	// Change selected row if requested by caller,
	// this is useful for keyboard navigation
	if (move_selection) {
		s32 sel = row_i;
		if (was_open && do_open) {
			// Move selection to first child
			const Row *maybe_child = getRow(sel + 1);
			if (maybe_child && maybe_child->indent > row->indent)
				sel++;
		}
		else if (!was_open && !do_open) {
			// Move selection to parent
			assert(getRow(sel) != NULL);
			while (sel > 0 && getRow(sel - 1)->indent >= row->indent)
				sel--;
			sel--;
			if (sel < 0)  // was root already selected?
				sel = row_i;
		}
		if (sel != m_selected) {
			m_selected = sel;
			autoScroll();
			sendTableEvent(0, false);
		}
	}
}
예제 #7
0
void App::newFile()
{
    if (!closeFile())
        return;

    createNotes();
    if (!openTree("#init_file#"))
    {
        destroyNotes();

        return;
    }

    currentFile = "";
    setModified(false);
#ifndef DEMO
    setCaption("IQNotes :: (untitled)");
#else
	setCaption("IQNotes :: DEMO");
#endif
	
    
    foreignDeletedNode = !notes->isClipboardEmpty();
}