Пример #1
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;
}
Пример #2
0
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 );
}