void Panel::detachTab( TabPtr tab )
{
	for(TabItr i = tabList_.begin(); i != tabList_.end(); ++i )
	{
		if ( (*i) == tab )
		{
			if ( activeTab_ == tab )
				activeTab_ = 0;
			tab->getCWnd()->ShowWindow( SW_HIDE );
			tab->getCWnd()->SetParent( 0 );
			tabBar_->removeItem( tab.getObject() );
			tabList_.erase( i );
			for( i = tabList_.begin(); i != tabList_.end(); ++i )
			{
				if ( tabBar_->contains( (*i).getObject() ) )
				{
					setActiveTab( *i );
					break;
				}
			}
			if ( i == tabList_.end() )
				setActiveTab( 0 );

			break;
		}
	}
}
void Panel::showTab( TabPtr tab, bool show )
{
	TabItr i;
	for( i = tabList_.begin(); i != tabList_.end(); ++i )
		if ( (*i) == tab )
			break;

	if ( i == tabList_.end() )
		return;

	if ( show )
	{
		if ( !tabBar_->contains( tab.getObject() ) )
		{
			tab->setVisible( true );
			tabBar_->insertItem( tab->getTabDisplayString(), tab->getIcon(), tab.getObject() );
		}

		setActiveTab( tab );
	}
	else
	{
		if ( tabBar_->contains( tab.getObject() ) )
		{
			tab->show( false );
			tabBar_->removeItem( tab.getObject() );
		}

		if ( activeTab_ == tab )
		{
			for( i = tabList_.begin(); i != tabList_.end(); ++i )
			{
				if ( tabBar_->contains( (*i).getObject() ) )
				{
					setActiveTab( (*i) );
					break;
				}
			}
		}
	}

	updateTabBar();

	if ( tabBar_->itemCount() == 0 )
		Manager::instance().dock()->showPanel( this, false );
}
void Panel::addTab( const std::string contentID )
{
	TabPtr newTab = new Tab( this, contentID );
	tabList_.push_back( newTab );
	tabBar_->insertItem( newTab->getTabDisplayString(), newTab->getIcon(), newTab.getObject() );
	newTab->show( true );
	setActiveTab( newTab );
}
void Panel::insertTempTab( TabPtr tab )
{
	if ( activeTab_ && isExpanded_ )
		activeTab_->getCWnd()->ShowWindow( SW_HIDE );
	tempTab_ = tab;
	tabBar_->insertItem( tab->getTabDisplayString(), tab->getIcon(), tab.getObject() );
	updateTabBar();
	recalcSize();
	UpdateWindow();
}
void Panel::addTab( TabPtr tab )
{
	tab->getCWnd()->SetParent( this );
	tabList_.push_back( tab );
	if ( tab->isVisible() )
	{
		tabBar_->insertItem( tab->getTabDisplayString(), tab->getIcon(), tab.getObject() );
		setActiveTab( tab );
	}
}