//
//	Copyright © 2006 Nemetschek North America 
//	All Rights Reserved.
//
// Created by Vladislav Stanev

#include "StdHeaders.h"

#include "TreeCtrl.h"

#include "Dialog.h"

using namespace VectorWorks::VWUI;

VWTreeCtrl::VWTreeCtrl(TControlID id)
: VWControl( id )
{
}

VWTreeCtrl::~VWTreeCtrl()
{
}

bool VWTreeCtrl::CreateControl(VWDialog* pDlg, short widthInCharacters, short heightInLines/*=1*/)
{
	::GS_CreateTreeControl( gCBP, pDlg->GetControlID(), fControlID, widthInCharacters, heightInLines );
	return VWControl::CreateControl( pDlg );
}

VWTreeCtrlItem VWTreeCtrl::AddChildItem(const TXString& text)
{
	VWTreeCtrlItem	rootItem( fpParentDlg->GetControlID(), fControlID, -1 );
	return rootItem.AddChildItem( text );
}

VWTreeCtrlItem VWTreeCtrl::InsertChildItem(const TXString& text, VWTreeCtrlItem	afterItem)
{
	VWTreeCtrlItem	rootItem( fpParentDlg->GetControlID(), fControlID, -1 );
	return rootItem.InsertChildItem( text, afterItem );
}

VWTreeCtrlItem VWTreeCtrl::GetSelectedItem() const
{
	VWTreeCtrlItem	item;
	int				itemID	= -1;
	if ( fpParentDlg && ::GS_GetTreeControlSelectedItem( gCBP, fpParentDlg->GetControlID(), fControlID, itemID ) ) {
		return VWTreeCtrlItem( fpParentDlg->GetControlID(), fControlID, itemID );
	}
	else {
		return VWTreeCtrlItem();
	}
}
