WgHook * WgStackPanel::_firstHookWithGeo( WgRect& writeGeo ) const
{
	WgStackHook * p = _firstHook();
	if( p )
		writeGeo = p->_getGeo(m_size);

	return p;
}
Beispiel #2
0
	Widget * Container::_firstWidget() const 
	{ 
		Hook * p = _firstHook(); 
		if( p ) 
			return p->_widget(); 
		else 
			return 0;
	}
void WgStackPanel::_adaptChildrenToSize()
{
	WgStackHook * pHook = _firstHook();
	while( pHook )
	{
		pHook->_widget()->_onNewSize( pHook->_getGeo(m_size) );
		pHook = pHook->_next();
	}
}
int WgStackPanel::MatchingWidth( int height ) const
{
	int width = 0;

	WgStackHook * pHook = _firstHook();
	while( pHook )
	{
		int w = pHook->_widget()->MatchingWidth(height);
		if( w > width )
			width = w;
		pHook = pHook->_next();
	}

	return width;
}
int WgStackPanel::MatchingHeight( int width ) const
{
	int height = 0;

	WgStackHook * pHook = _firstHook();
	while( pHook )
	{
		int h = pHook->_widget()->MatchingHeight(width);
		if( h > height )
			height = h;
		pHook = pHook->_next();
	}

	return height;
}
void WgStackPanel::_onWidgetDisappeared( WgVectorHook * _pToBeRemoved )
{
	bool	bRequestResize = false;
	WgStackHook * pToBeRemoved = (WgStackHook*) _pToBeRemoved;

	// Get dirty rectangles for all visible sections of pToBeRemoved.

	_onRenderRequested( pToBeRemoved );

	// Update m_preferredSize, skiping pToBeRemoved

	WgSize	preferredSize;
	WgStackHook * pHook = _firstHook();
	while( pHook )
	{
		if( pHook != pToBeRemoved )
		{
			WgSize sz = pHook->_widget()->PreferredSize();
			if( sz.w > preferredSize.w )
				preferredSize.w = sz.w;
			if( sz.h > preferredSize.h )
				preferredSize.h = sz.h;
		}
		pHook = pHook->_next();
	}

	if( preferredSize != m_preferredSize )
		bRequestResize = true;

	m_preferredSize = preferredSize;

	// Check if removal might affect height for current width

	int height = pToBeRemoved->_widget()->MatchingHeight(m_size.w);
	if( height >= m_size.h )
		bRequestResize = true;

	//

	if( bRequestResize )
		_requestResize();
}
void WgStackPanel::_refreshPreferredSize()
{
	WgSize	preferredSize;

	WgStackHook * pHook = _firstHook();
	while( pHook )
	{
		WgSize sz = pHook->_paddedPreferredSize();
		if( sz.w > preferredSize.w )
			preferredSize.w = sz.w;
		if( sz.h > preferredSize.h )
			preferredSize.h = sz.h;
		pHook = pHook->_next();
	}

	if( m_preferredSize != preferredSize)
	{
		m_preferredSize = preferredSize;
		_requestResize();
	}
}