Exemplo n.º 1
0
bool Panel::onTabClose( TabPtr tab )
{
	bool doClose = false;

	int cnt = Manager::instance().dock()->getContentCount( tab->getContent()->getContentID() );
	ASSERT( cnt != 0 );

	Content::OnCloseAction response = tab->getContent()->onClose( (cnt == 1) );
	if ( response == Content::CONTENT_KEEP )
	{
		doClose = false;
	}
	else if ( response == Content::CONTENT_HIDE )
	{
		showTab( tab, false );
		doClose = true;
	}
	else if ( response == Content::CONTENT_DESTROY )
	{
		detachTab( tab );
		doClose = true;
	}
	else
		ASSERT( 0 );

	return doClose;
}
Exemplo n.º 2
0
bool Panel::load( DataSectionPtr section )
{
	lastX_ = section->readInt( "lastX", lastX_ );
	lastY_ = section->readInt( "lastY", lastY_ );
	isExpanded_ = section->readBool( "expanded", isExpanded_ );
	expandedSize_ = section->readInt( "expandedSize", expandedSize_ );
	isFloating_ = section->readBool( "floating", isFloating_ );

	std::vector<DataSectionPtr> tabs;
	section->openSections( "Tab", tabs );
	if ( tabs.empty() )
		return false;
	activeTab_ = 0;
	TabPtr firstTab = 0;
	for( std::vector<DataSectionPtr>::iterator i = tabs.begin(); i != tabs.end(); ++i )
	{
		std::string contentID = (*i)->readString( "contentID" );
		if ( contentID.empty() )
			continue;

		TabPtr newTab = new Tab( this, contentID );

		if ( !newTab->getContent() )
			continue;

		newTab->setVisible( (*i)->readBool( "visible", true ) );

		// ignoring if loading a tab returns false
		newTab->load( *i );

		addTab( newTab );

		newTab->getCWnd()->ShowWindow( SW_HIDE );

		if ( !firstTab && !!activeTab_ )
			firstTab = activeTab_;
	}
	if ( firstTab )
		setActiveTab( firstTab );

	if ( activeTab_ )
	{
		updateTabBar();

		if ( isExpanded_ )
			activeTab_->getCWnd()->ShowWindow( SW_SHOW );
		else
			activeTab_->getCWnd()->ShowWindow( SW_HIDE );
	}

	int w;
	int h;
	getPreferredSize( w, h );
	SetWindowPos( 0, 0, 0,
		section->readInt( "lastWidth", w ), section->readInt( "lastHeight", h ),
		SWP_NOMOVE | SWP_NOZORDER );

	return true;
}
Exemplo n.º 3
0
bool Panel::tabContains( TabPtr t, ContentPtr content )
{
	Content* tcontent = t->getContent().getObject();
	if ( !tcontent )
		return 0;
	
	return tcontent == content ||
			( tcontent->getContentID() == ContentContainer::contentID &&
			((ContentContainer*)tcontent)->contains( content ) );
}
Exemplo n.º 4
0
int Panel::tabContains( TabPtr t, const std::string contentID )
{
	Content* tcontent = t->getContent().getObject();
	if ( !tcontent )
		return 0;
	
	int cnt = 0;

	if ( contentID.compare( tcontent->getContentID() ) == 0 )
		++cnt;
	else if ( tcontent->getContentID() == ContentContainer::contentID )
		cnt += ((ContentContainer*)tcontent)->contains( contentID );
	
	return cnt;
}