Пример #1
0
void TabStrip::Layout( Skin::Base* skin )
{
	Gwen::Point pLargestTab( 5, 5 );

	int iNum = 0;
	for ( Base::List::iterator iter = Children.begin(); iter != Children.end(); ++iter )
	{
		TabButton* pButton = gwen_cast<TabButton>(*iter);
		if ( !pButton ) continue;

		pButton->SizeToContents();

		Margin m;
		int iNotFirst = iNum > 0 ? -1 : 0;

		if ( m_iDock == Pos::Top )
		{
			m.left = iNotFirst;
			pButton->Dock( Pos::Left );
		}

		if ( m_iDock == Pos::Left )
		{
			m.top = iNotFirst;
			pButton->Dock( Pos::Top );
		}

		if ( m_iDock == Pos::Right )
		{
			m.top = iNotFirst;
			pButton->Dock( Pos::Top );
		}

		if ( m_iDock == Pos::Bottom )
		{
			m.left = iNotFirst;
			pButton->Dock( Pos::Left );
		}

		pLargestTab.x = Utility::Max( pLargestTab.x, pButton->Width() );
		pLargestTab.y = Utility::Max( pLargestTab.y, pButton->Height() );

		pButton->SetMargin( m );
		iNum++;
	}

	if ( m_iDock == Pos::Top || m_iDock == Pos::Bottom )
		SetSize( Width(), pLargestTab.y );

	if ( m_iDock == Pos::Left || m_iDock == Pos::Right )
		SetSize( pLargestTab.x, Height() );

	BaseClass::Layout( skin );
}
Пример #2
0
void TabStrip::Layout(Skin::Base* skin)
{
	Gwen::Point pLargestTab(5, 5);

	int iNum = 0;
	for (Base::List::iterator iter = Children.begin(); iter != Children.end(); ++iter)
	{
		if (!*iter)
			continue;

		TabButton* pButton = (*iter)->DynamicCastTabButton();
		if (!pButton) continue;

		pButton->SizeToContents();

		Margin m;
		int iActive = pButton->IsActive() ? 0 : 2;
		int iNotFirst = iNum > 0 ? -1 : 0;
		int iControlOverhang = -3;

		if (m_iDock == Pos::Top)
		{
			m.top = iActive;
			m.left = iNotFirst;
			m.bottom = iControlOverhang;
			pButton->Dock(Pos::Left);
		}

		if (m_iDock == Pos::Left)
		{
			m.left = iActive * 2;
			m.right = iControlOverhang;
			m.top = iNotFirst;
			pButton->Dock(Pos::Top);
		}

		if (m_iDock == Pos::Right)
		{
			m.right = iActive * 2;
			m.left = iControlOverhang;
			m.top = iNotFirst;
			pButton->Dock(Pos::Top);
		}

		if (m_iDock == Pos::Bottom)
		{
			m.bottom = iActive;
			m.left = iNotFirst;
			m.top = iControlOverhang;
			pButton->Dock(Pos::Left);
		}

		pLargestTab.x = Utility::Max(pLargestTab.x, pButton->Width());
		pLargestTab.y = Utility::Max(pLargestTab.y, pButton->Height());

		pButton->SetMargin(m);
		iNum++;
	}

	if (m_iDock == Pos::Top || m_iDock == Pos::Bottom)
		SetSize(Width(), pLargestTab.y);

	if (m_iDock == Pos::Left || m_iDock == Pos::Right)
		SetSize(pLargestTab.x, Height());

	BaseClass::Layout(skin);
}