- if ( mImpl->mHeightPolicy == Toolkit::Control::Fixed )
- {
- // If a control says it has a fixed size, then use the size set by the application / control.
- Vector2 setSize( mImpl->mSetSize );
- if ( setSize != Vector2::ZERO )
- {
- size = setSize;
-
- // Policy is set to Fixed, so if the application / control has not set one of the dimensions,
- // then we should use the natural size of the control rather than the full allocation.
- if ( EqualsZero( size.width ) )
- {
- size.width = GetWidthForHeight( size.height );
- }
- else if ( EqualsZero( size.height ) )
- {
- size.height = GetHeightForWidth( size.width );
- }
- }
- else
- {
- // If that is not set then set the size to the control's natural size
- size = Vector2( GetNaturalSize() );
- }
- }
- else
- {
- // Width is fixed so if the application / control has set it, then use that.
- if ( !EqualsZero( mImpl->mSetSize.width ) )
- {
- size.width = mImpl->mSetSize.width;
- }
- else
- {
- // Otherwise, set the width to what has been allocated.
- size.width = allocatedSize.width;
- }
-
- // Height is flexible so ask control what the height should be for our width.
- size.height = GetHeightForWidth( size.width );
-
- // Ensure height is within our policy rules
- size.height = Calculate( mImpl->mHeightPolicy, mImpl->mMinimumSize.height, mImpl->mMaximumSize.height, size.height );
- }