Esempio n. 1
0
	wxTreeItemId CategoryTree::addTextEntry( const wxTreeItemId& p_parent, const DatIndexEntry& p_entry ) {
		wxTreeItemIdValue cookie;
		wxTreeItemId previous;
		auto child = this->GetFirstChild( p_parent, cookie );

		while ( child.IsOk( ) ) {
			auto text = this->GetItemText( child );
			// Compare
			if ( text > p_entry.name( ) ) {
				break;
			}
			// Move to next
			previous = child;
			child = this->GetNextChild( p_parent, cookie );
		}

		// This item should be first if there *is* something in this list, but previous is nothing
		if ( child.IsOk( ) && !previous.IsOk( ) ) {
			return this->InsertItem( p_parent, 0, p_entry.name( ), this->getImageForEntry( p_entry ) );
		}
		// This item should be squashed in if both child and previous are ok
		if ( child.IsOk( ) && previous.IsOk( ) ) {
			return this->InsertItem( p_parent, previous, p_entry.name( ), this->getImageForEntry( p_entry ) );
		}
		// If the above fails, it means we went through the entire list without finding a proper spot
		return this->AppendItem( p_parent, p_entry.name( ), this->getImageForEntry( p_entry ) );
	}
Esempio n. 2
0
	wxTreeItemId CategoryTree::addEntry( const wxTreeItemId& p_parent, const DatIndexEntry& p_entry ) {
		if ( p_entry.name( ).IsNumber( ) ) {
			ulong number;
			p_entry.name( ).ToULong( &number );
			return this->addNumberEntry( p_parent, p_entry, number );
		}

		// NaN :)
		return this->addTextEntry( p_parent, p_entry );
	}