* Source/NSView.m (-resizeWithOldSuperviewSize): Reimplement to

resize proportionally as Cocoa does.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33482 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2011-07-07 22:19:07 +00:00
parent 89b296dd0b
commit 9c681fa416
2 changed files with 20 additions and 15 deletions

View file

@ -1,3 +1,8 @@
2011-07-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSView.m (-resizeWithOldSuperviewSize): Reimplement to
resize proportionally as Cocoa does.
2011-07-07 Eric Wasylishen <ewasylishen@gmail.com> 2011-07-07 Eric Wasylishen <ewasylishen@gmail.com>
* Source/GSCharacterPanel.m: Double click inserts character into * Source/GSCharacterPanel.m: Double click inserts character into

View file

@ -1934,7 +1934,7 @@ convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matrix1,
- (void) resizeWithOldSuperviewSize: (NSSize)oldSize - (void) resizeWithOldSuperviewSize: (NSSize)oldSize
{ {
int options = 0; CGFloat options = 0.0;
NSSize superViewFrameSize; NSSize superViewFrameSize;
NSRect newFrame = _frame; NSRect newFrame = _frame;
@ -1949,56 +1949,56 @@ convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matrix1,
* 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 += newFrame.size.width;
if (_autoresizingMask & NSViewMinXMargin) if (_autoresizingMask & NSViewMinXMargin)
options++; options += newFrame.origin.x;
if (_autoresizingMask & NSViewMaxXMargin) if (_autoresizingMask & NSViewMaxXMargin)
options++; options += oldSize.width - newFrame.origin.x - newFrame.size.width;
/* /*
* 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 > 0) if (options > 0.0)
{ {
CGFloat change = superViewFrameSize.width - oldSize.width; CGFloat change = superViewFrameSize.width - oldSize.width;
CGFloat changePerOption = change / options; CGFloat changePerOption = change / options;
if (_autoresizingMask & NSViewWidthSizable) if (_autoresizingMask & NSViewWidthSizable)
{ {
newFrame.size.width += changePerOption; newFrame.size.width += changePerOption * newFrame.size.width;
} }
if (_autoresizingMask & NSViewMinXMargin) if (_autoresizingMask & NSViewMinXMargin)
{ {
newFrame.origin.x += changePerOption; newFrame.origin.x += changePerOption * newFrame.origin.x;
} }
} }
/* /*
* determine if and how the Y axis can be resized * determine if and how the Y axis can be resized
*/ */
options = 0; options = 0.0;
if (_autoresizingMask & NSViewHeightSizable) if (_autoresizingMask & NSViewHeightSizable)
options++; options += newFrame.size.height;
if (_autoresizingMask & NSViewMinYMargin) if (_autoresizingMask & NSViewMinYMargin)
options++; options += newFrame.origin.y;
if (_autoresizingMask & NSViewMaxYMargin) if (_autoresizingMask & NSViewMaxYMargin)
options++; options += oldSize.height - newFrame.origin.y - newFrame.size.height;
/* /*
* 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 > 0) if (options > 0.0)
{ {
CGFloat change = superViewFrameSize.height - oldSize.height; CGFloat change = superViewFrameSize.height - oldSize.height;
CGFloat changePerOption = change / options; CGFloat changePerOption = change / options;
if (_autoresizingMask & NSViewHeightSizable) if (_autoresizingMask & NSViewHeightSizable)
{ {
newFrame.size.height += changePerOption; newFrame.size.height += changePerOption * newFrame.size.height;
} }
if (_autoresizingMask & (NSViewMaxYMargin | NSViewMinYMargin)) if (_autoresizingMask & (NSViewMaxYMargin | NSViewMinYMargin))
{ {
@ -2006,14 +2006,14 @@ convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matrix1,
{ {
if (_autoresizingMask & NSViewMaxYMargin) if (_autoresizingMask & NSViewMaxYMargin)
{ {
newFrame.origin.y += changePerOption; newFrame.origin.y += changePerOption * newFrame.origin.y;
} }
} }
else else
{ {
if (_autoresizingMask & NSViewMinYMargin) if (_autoresizingMask & NSViewMinYMargin)
{ {
newFrame.origin.y += changePerOption; newFrame.origin.y += changePerOption * newFrame.origin.y;
} }
} }
} }