Cleaned resizeWithOldSuperviewSize:

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11923 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 2002-01-01 15:44:18 +00:00
parent d99ff6a3f9
commit a52c5e85cf

View file

@ -1273,55 +1273,38 @@ GSSetDragTypes(NSView* obj, NSArray *types)
- (void) resizeWithOldSuperviewSize: (NSSize)oldSize - (void) resizeWithOldSuperviewSize: (NSSize)oldSize
{ {
float change;
float changePerOption;
int options = 0; int options = 0;
NSRect newFrame, newBounds;
NSSize superViewFrameSize = [_super_view frame].size; NSSize superViewFrameSize = [_super_view frame].size;
NSRect newFrame = _frame;
BOOL changedOrigin = NO; BOOL changedOrigin = NO;
BOOL changedSize = NO; BOOL changedSize = NO;
/* FIXME: No need to compute the bounds. setFrame: should do that
if needed */
if (_autoresizingMask == NSViewNotSizable) if (_autoresizingMask == NSViewNotSizable)
return; return;
newFrame = _frame;
newBounds = _bounds;
/* /*
* determine if and how the X axis can be resized * determine if and how the X axis can be resized
*/ */
if (_autoresizingMask & NSViewWidthSizable) if (_autoresizingMask & NSViewWidthSizable)
options++; options++;
if (_autoresizingMask & NSViewMinXMargin) if (_autoresizingMask & NSViewMinXMargin)
options++; options++;
if (_autoresizingMask & NSViewMaxXMargin) if (_autoresizingMask & NSViewMaxXMargin)
options++; options++;
/* /*
* adjust the X axis if any X options are set in the mask * adjust the X axis if any X options are set in the mask
*/ */
if (options >= 1) if (options > 0)
{ {
change = superViewFrameSize.width - oldSize.width; float change = superViewFrameSize.width - oldSize.width;
changePerOption = change/options; float changePerOption = change / options;
if (_autoresizingMask & NSViewWidthSizable) if (_autoresizingMask & NSViewWidthSizable)
{ {
float oldFrameWidth = newFrame.size.width;
newFrame.size.width += changePerOption; newFrame.size.width += changePerOption;
if (_is_rotated_or_scaled_from_base)
{
newBounds.size.width *= newFrame.size.width/oldFrameWidth;
}
else
{
newBounds.size.width += changePerOption;
}
changedSize = YES; changedSize = YES;
} }
if (_autoresizingMask & NSViewMinXMargin) if (_autoresizingMask & NSViewMinXMargin)
@ -1337,34 +1320,24 @@ GSSetDragTypes(NSView* obj, NSArray *types)
options = 0; options = 0;
if (_autoresizingMask & NSViewHeightSizable) if (_autoresizingMask & NSViewHeightSizable)
options++; options++;
if (_autoresizingMask & NSViewMinYMargin) if (_autoresizingMask & NSViewMinYMargin)
options++; options++;
if (_autoresizingMask & NSViewMaxYMargin) if (_autoresizingMask & NSViewMaxYMargin)
options++; options++;
/* /*
* adjust the Y axis if any Y options are set in the mask * adjust the Y axis if any Y options are set in the mask
*/ */
if (options >= 1) if (options > 0)
{ {
change = superViewFrameSize.height - oldSize.height; float change = superViewFrameSize.height - oldSize.height;
changePerOption = change/options; float changePerOption = change / options;
if (_autoresizingMask & NSViewHeightSizable) if (_autoresizingMask & NSViewHeightSizable)
{ {
float oldFrameHeight = newFrame.size.height;
newFrame.size.height += changePerOption; newFrame.size.height += changePerOption;
if (_is_rotated_or_scaled_from_base)
{
newBounds.size.height *= newFrame.size.height/oldFrameHeight;
}
else
{
newBounds.size.height += changePerOption;
}
changedSize = YES; changedSize = YES;
} }
if (_autoresizingMask & (NSViewMaxYMargin | NSViewMinYMargin)) if (_autoresizingMask & (NSViewMaxYMargin | NSViewMinYMargin))