fix c99-ism

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29756 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Riccardo Mottola 2010-02-25 21:41:39 +00:00
parent d5cc2fce52
commit 01f7fe5c27
3 changed files with 79 additions and 11 deletions

View file

@ -1,3 +1,7 @@
2010-02-25 Riccardo Mottola <rmottola@users.sf.net>
* Source/NSDrawer.m: removed c99-isms
2010-02-24 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPasteboard.m: remove obsolete code for setting up invocation.

View file

@ -509,13 +509,15 @@ static const int current_version = 1;
- (void) _takeInAccountFlexibleSpaces
{
NSArray *items = [_toolbar items];
NSEnumerator *e = [items objectEnumerator];
NSEnumerator *e;
NSToolbarItem *item;
NSView *backView;
NSRect lastBackViewFrame;
float lengthAvailable;
unsigned int flexibleSpaceItemsNumber = 0;
BOOL mustAdjustNext = NO;
unsigned int flexibleSpaceItemsNumber;
unsigned int resizableItemsNumber;
float resizableSpaceFromMins;
BOOL mustAdjustNext;
float x = 0;
if ([items count] == 0)
@ -527,17 +529,36 @@ static const int current_version = 1;
if (lengthAvailable < 1)
return;
/* search for flexible spaces or for items which are resizable */
flexibleSpaceItemsNumber = 0;
resizableItemsNumber = 0;
resizableSpaceFromMins = 0;
e = [items objectEnumerator];
while ((item = [e nextObject]) != nil)
{
if ([item _isFlexibleSpace])
{
flexibleSpaceItemsNumber++;
float currWidth;
float minWidth;
currWidth = [[item _backView] frame].size.width;
minWidth = [item minSize].width;
if ([item _isFlexibleSpace])
{
flexibleSpaceItemsNumber++;
}
else if (([item maxSize].width > minWidth) && (currWidth > minWidth))
{
resizableItemsNumber++;
resizableSpaceFromMins += currWidth - minWidth;
NSLog(@"%@: min, curr width: %f %f", [item itemIdentifier], minWidth, currWidth);
}
}
}
if (lengthAvailable < flexibleSpaceItemsNumber)
NSLog(@"length available 1: %f", lengthAvailable);
NSLog(@"resizable space %f in %d items", resizableSpaceFromMins, resizableItemsNumber);
if (flexibleSpaceItemsNumber < 1 && resizableSpaceFromMins <= 0)
return;
mustAdjustNext = NO;
e = [items objectEnumerator];
while ((item = [e nextObject]) != nil)
{
@ -560,7 +581,47 @@ static const int current_version = 1;
}
x += [backView frame].size.width;
}
lastBackViewFrame = [[[items lastObject] _backView] frame];
lengthAvailable = [self frame].size.width - NSMaxX(lastBackViewFrame);
NSLog(@"length available 2: %f", lengthAvailable);
if (lengthAvailable <= 0 || resizableItemsNumber < 0)
return;
/* we adjusted all the flexible spaces, now we can try to adjust views to their minimum */
mustAdjustNext = NO;
e = [items objectEnumerator];
while ((item = [e nextObject]) != nil)
{
float currWidth;
float minWidth;
NSRect backViewFrame;
backView = [item _backView];
backViewFrame = [backView frame];
currWidth = backViewFrame.size.width;
minWidth = [item minSize].width;
if (([item maxSize].width > minWidth) && (currWidth > minWidth))
{
float newWidth;
newWidth = currWidth - (lengthAvailable / resizableItemsNumber);
if (newWidth < minWidth)
newWidth = minWidth;
[backView setFrame: NSMakeRect(x, backViewFrame.origin.y,
newWidth,
backViewFrame.size.height)];
mustAdjustNext = YES;
}
else if (mustAdjustNext)
{
[backView setFrame: NSMakeRect(x, backViewFrame.origin.y,
backViewFrame.size.width, backViewFrame.size.height)];
}
x += backViewFrame.size.width;
}
}
- (void) _handleViewsVisibility

View file

@ -112,6 +112,7 @@ static NSNotificationCenter *nc = nil;
{
NSRect rect = contentRect;
NSRect border = contentRect;
NSSize containerContentSize;
rect.origin.x += 6;
rect.origin.y += 6;
@ -140,7 +141,7 @@ static NSNotificationCenter *nc = nil;
[_borderBox addSubview: _container];
// determine the difference between the container's content size and the window content size
NSSize containerContentSize = [[_container contentView] frame].size;
containerContentSize = [[_container contentView] frame].size;
_borderSize = NSMakeSize(contentRect.size.width - containerContentSize.width,
contentRect.size.height - containerContentSize.height);
}
@ -339,12 +340,14 @@ static NSNotificationCenter *nc = nil;
- (void) closeOnEdge
{
NSRect frame;
[self stopTimer];
[self lockBorderBoxForSliding];
[self slideOpen:NO];
[self orderOut: self];
NSRect frame = [self frameFromParentWindowFrameInState:NSDrawerOpenState];
frame = [self frameFromParentWindowFrameInState:NSDrawerOpenState];
[self setFrame:frame display: YES]; // make sure it's the full (open) size again (offscreen) before unlocking
[self performSelector:@selector(unlockBorderBoxAfterSliding) withObject:nil afterDelay:0.01];