* GormBoxEditor.m: removed NSLogs.

* GormViewEditor.m: neater display of intelligent placement hints.
* GormControlEditor.m: intelligent placement take minsize into account.
* GormViewWithContentEditor.m: fixed display problem when moving  selection.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@14274 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Pierre-Yves Rivaille 2002-08-14 17:26:51 +00:00
parent 1452b805da
commit 3b8f69f231
5 changed files with 638 additions and 221 deletions

View file

@ -1,7 +1,12 @@
2002-08-14 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr> 2002-08-14 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
* GormSplitViewEditor.m: removean extra ; that was breaking gcc 2.* * GormSplitViewEditor.m: removed an extra ; that was breaking gcc 2.*.
* GormBoxEditor.m: removed NSLogs.
* GormViewEditor.m: neater display of intelligent placement hints.
* GormControlEditor.m: intelligent placement take minsize into account.
* GormViewWithContentEditor.m: fixed display problem when moving
selection.
2002-08-14 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr> 2002-08-14 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
* Major changes in editing widgets. * Major changes in editing widgets.

View file

@ -174,7 +174,7 @@
if (opened == NO) if (opened == NO)
{ {
NSLog(@"GormBoxEditor not opened"); // NSLog(@"GormBoxEditor not opened");
[super mouseDown: theEvent]; [super mouseDown: theEvent];
return; return;
} }
@ -183,14 +183,14 @@
if ([[_EO hitTest: [theEvent locationInWindow]] if ([[_EO hitTest: [theEvent locationInWindow]]
isDescendantOf: contentViewEditor]) isDescendantOf: contentViewEditor])
{ {
NSLog(@"md %@ descendant of", self); // NSLog(@"md %@ descendant of", self);
if ([contentViewEditor isOpened] == NO) if ([contentViewEditor isOpened] == NO)
[contentViewEditor setOpened: YES]; [contentViewEditor setOpened: YES];
[contentViewEditor mouseDown: theEvent]; [contentViewEditor mouseDown: theEvent];
} }
else else
{ {
NSLog(@"md %@ not descendant of sending to %@", self, _EO); // NSLog(@"md %@ not descendant of sending to %@", self, _EO);
if ([contentViewEditor isOpened] == YES) if ([contentViewEditor isOpened] == YES)
[contentViewEditor setOpened: NO]; [contentViewEditor setOpened: NO];

View file

@ -203,17 +203,278 @@
gpi->oldRect.size.height += 2; gpi->oldRect.size.height += 2;
} }
// - (void) _displayFrameWithHint: (NSRect) frame
// withPlacementInfo: (GormPlacementInfo*)gpi
// {
// float leftOfFrame = NSMinX(frame);
// float rightOfFrame = NSMaxX(frame);
// float topOfFrame = NSMaxY(frame);
// float bottomOfFrame = NSMinY(frame);
// int i;
// int count;
// int lastDistance;
// int minimum = 10;
// NSMutableArray *bests;
// if (gpi->hintInitialized == NO)
// {
// [self _initializeHintWithInfo: gpi];
// }
// {
// if (gpi->firstPass == NO)
// [gpi->resizingIn displayRect: gpi->oldRect];
// else
// gpi->firstPass = NO;
// }
// {
// [gpi->resizingIn setNeedsDisplayInRect: gpi->lastLeftRect];
// [[self window] displayIfNeeded];
// gpi->lastLeftRect = NSZeroRect;
// }
// {
// [gpi->resizingIn setNeedsDisplayInRect: gpi->lastRightRect];
// [[self window] displayIfNeeded];
// gpi->lastRightRect = NSZeroRect;
// }
// {
// [gpi->resizingIn setNeedsDisplayInRect: gpi->lastTopRect];
// [[self window] displayIfNeeded];
// gpi->lastTopRect = NSZeroRect;
// }
// {
// [gpi->resizingIn setNeedsDisplayInRect: gpi->lastBottomRect];
// [[self window] displayIfNeeded];
// gpi->lastBottomRect = NSZeroRect;
// }
// if (gpi->knob == IBTopLeftKnobPosition
// || gpi->knob == IBMiddleLeftKnobPosition
// || gpi->knob == IBBottomLeftKnobPosition)
// {
// bests = [NSMutableArray arrayWithCapacity: 4];
// minimum = 6;
// count = [gpi->leftHints count];
// for ( i = 0; i < count; i++ )
// {
// lastDistance = [[gpi->leftHints objectAtIndex: i]
// distanceToFrame: frame];
// if (lastDistance < minimum)
// {
// bests = [NSMutableArray arrayWithCapacity: 4];
// [bests addObject: [gpi->leftHints objectAtIndex: i]];
// minimum = lastDistance;
// }
// else if (lastDistance == minimum)
// [bests addObject: [gpi->leftHints objectAtIndex: i]];
// }
// count = [bests count];
// if (count >= 1)
// {
// float start, end, position;
// position = [[bests objectAtIndex: 0] position];
// start = NSMinY(frame);
// end = NSMaxY(frame);
// for ( i = 0; i < count; i++ )
// {
// start = MIN(NSMinY([[bests objectAtIndex: i] frame]), start);
// end = MAX(NSMaxY([[bests objectAtIndex: i] frame]), end);
// }
// [[NSColor redColor] set];
// NSRectFill(NSMakeRect(position - 1, start, 2, end - start));
// gpi->lastLeftRect = NSMakeRect(position - 1, start, 2, end - start);
// leftOfFrame = position;
// }
// }
// if (gpi->knob == IBTopRightKnobPosition
// || gpi->knob == IBMiddleRightKnobPosition
// || gpi->knob == IBBottomRightKnobPosition)
// {
// bests = [NSMutableArray arrayWithCapacity: 4];
// minimum = 6;
// count = [gpi->rightHints count];
// for ( i = 0; i < count; i++ )
// {
// lastDistance = [[gpi->rightHints objectAtIndex: i]
// distanceToFrame: frame];
// if (lastDistance < minimum)
// {
// bests = [NSMutableArray arrayWithCapacity: 4];
// [bests addObject: [gpi->rightHints objectAtIndex: i]];
// minimum = lastDistance;
// }
// else if (lastDistance == minimum)
// [bests addObject: [gpi->rightHints objectAtIndex: i]];
// }
// count = [bests count];
// if (count >= 1)
// {
// float start, end, position;
// position = [[bests objectAtIndex: 0] position];
// start = NSMinY(frame);
// end = NSMaxY(frame);
// for ( i = 0; i < count; i++ )
// {
// start = MIN(NSMinY([[bests objectAtIndex: i] frame]), start);
// end = MAX(NSMaxY([[bests objectAtIndex: i] frame]), end);
// }
// [[NSColor redColor] set];
// NSRectFill(NSMakeRect(position - 1, start, 2, end - start));
// gpi->lastRightRect = NSMakeRect(position - 1, start, 2, end - start);
// rightOfFrame = position;
// }
// }
// if (gpi->knob == IBTopRightKnobPosition
// || gpi->knob == IBTopLeftKnobPosition
// || gpi->knob == IBTopMiddleKnobPosition)
// {
// bests = [NSMutableArray arrayWithCapacity: 4];
// minimum = 6;
// count = [gpi->topHints count];
// for ( i = 0; i < count; i++ )
// {
// lastDistance = [[gpi->topHints objectAtIndex: i]
// distanceToFrame: frame];
// if (lastDistance < minimum)
// {
// bests = [NSMutableArray arrayWithCapacity: 4];
// [bests addObject: [gpi->topHints objectAtIndex: i]];
// minimum = lastDistance;
// }
// else if (lastDistance == minimum)
// [bests addObject: [gpi->topHints objectAtIndex: i]];
// }
// count = [bests count];
// if (count >= 1)
// {
// float start, end, position;
// position = [[bests objectAtIndex: 0] position];
// start = NSMinX(frame);
// end = NSMaxX(frame);
// for ( i = 0; i < count; i++ )
// {
// start = MIN(NSMinX([[bests objectAtIndex: i] frame]), start);
// end = MAX(NSMaxX([[bests objectAtIndex: i] frame]), end);
// }
// [[NSColor redColor] set];
// NSRectFill(NSMakeRect(start, position - 1, end - start, 2));
// gpi->lastTopRect = NSMakeRect(start, position - 1, end - start, 2);
// topOfFrame = position;
// }
// }
// if (gpi->knob == IBBottomRightKnobPosition
// || gpi->knob == IBBottomLeftKnobPosition
// || gpi->knob == IBBottomMiddleKnobPosition)
// {
// bests = [NSMutableArray arrayWithCapacity: 4];
// minimum = 6;
// count = [gpi->bottomHints count];
// for ( i = 0; i < count; i++ )
// {
// lastDistance = [[gpi->bottomHints objectAtIndex: i]
// distanceToFrame: frame];
// if (lastDistance < minimum)
// {
// bests = [NSMutableArray arrayWithCapacity: 4];
// [bests addObject: [gpi->bottomHints objectAtIndex: i]];
// minimum = lastDistance;
// }
// else if (lastDistance == minimum)
// [bests addObject: [gpi->bottomHints objectAtIndex: i]];
// }
// count = [bests count];
// if (count >= 1)
// {
// float start, end, position;
// position = [[bests objectAtIndex: 0] position];
// start = NSMinX(frame);
// end = NSMaxX(frame);
// for ( i = 0; i < count; i++ )
// {
// start = MIN(NSMinX([[bests objectAtIndex: i] frame]), start);
// end = MAX(NSMaxX([[bests objectAtIndex: i] frame]), end);
// }
// [[NSColor redColor] set];
// NSRectFill(NSMakeRect(start, position - 1, end - start, 2));
// gpi->lastBottomRect = NSMakeRect(start, position - 1, end - start, 2);
// bottomOfFrame = position;
// }
// }
// gpi->hintFrame = NSMakeRect (leftOfFrame, bottomOfFrame,
// rightOfFrame - leftOfFrame,
// topOfFrame - bottomOfFrame);
// GormShowFrameWithKnob(gpi->hintFrame, gpi->knob);
// gpi->oldRect = GormExtBoundsForRect(gpi->hintFrame);
// gpi->oldRect.origin.x--;
// gpi->oldRect.origin.y--;
// gpi->oldRect.size.width += 2;
// gpi->oldRect.size.height += 2;
// }
#undef MIN
#undef MAX
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
- (void) _displayFrameWithHint: (NSRect) frame - (void) _displayFrameWithHint: (NSRect) frame
withPlacementInfo: (GormPlacementInfo*)gpi withPlacementInfo: (GormPlacementInfo*)gpi
{ {
float leftOfFrame = NSMinX(frame); float leftOfFrame;
float rightOfFrame = NSMaxX(frame); float rightOfFrame;
float topOfFrame = NSMaxY(frame); float topOfFrame;
float bottomOfFrame = NSMinY(frame); float bottomOfFrame;
int i; int i;
int count; int count;
int lastDistance; int lastDistance;
int minimum = 10; int minimum = 10;
BOOL leftEmpty = YES;
BOOL rightEmpty = YES;
BOOL topEmpty = YES;
BOOL bottomEmpty = YES;
float bestLeftPosition;
float bestRightPosition;
float bestTopPosition;
float bestBottomPosition;
float leftStart;
float rightStart;
float topStart;
float bottomStart;
float leftEnd;
float rightEnd;
float topEnd;
float bottomEnd;
NSSize minSize;
minSize = [[_EO cell] cellSize];
NSMutableArray *bests; NSMutableArray *bests;
if (gpi->hintInitialized == NO) if (gpi->hintInitialized == NO)
{ {
@ -248,47 +509,94 @@
} }
if (frame.size.width < minSize.width)
{
switch (gpi->knob)
{
case IBBottomLeftKnobPosition:
case IBMiddleLeftKnobPosition:
case IBTopLeftKnobPosition:
frame.origin.x = NSMaxX([self frame]) - minSize.width;
frame.size.width = minSize.width;
break;
case IBTopRightKnobPosition:
case IBMiddleRightKnobPosition:
case IBBottomRightKnobPosition:
frame.size.width = minSize.width;
break;
case IBTopMiddleKnobPosition:
case IBBottomMiddleKnobPosition:
case IBNoneKnobPosition:
break;
}
}
if (frame.size.height < minSize.height)
{
switch (gpi->knob)
{
case IBBottomLeftKnobPosition:
case IBBottomRightKnobPosition:
case IBBottomMiddleKnobPosition:
frame.origin.y = NSMaxY([self frame]) - minSize.height;
frame.size.height = minSize.height;
break;
case IBTopMiddleKnobPosition:
case IBTopRightKnobPosition:
case IBTopLeftKnobPosition:
frame.size.height = minSize.height;
break;
case IBMiddleLeftKnobPosition:
case IBMiddleRightKnobPosition:
case IBNoneKnobPosition:
break;
}
}
leftOfFrame = NSMinX(frame);
rightOfFrame = NSMaxX(frame);
topOfFrame = NSMaxY(frame);
bottomOfFrame = NSMinY(frame);
if (gpi->knob == IBTopLeftKnobPosition if (gpi->knob == IBTopLeftKnobPosition
|| gpi->knob == IBMiddleLeftKnobPosition || gpi->knob == IBMiddleLeftKnobPosition
|| gpi->knob == IBBottomLeftKnobPosition) || gpi->knob == IBBottomLeftKnobPosition)
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
minimum = 10; minimum = 6;
count = [gpi->leftHints count]; count = [gpi->leftHints count];
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
lastDistance = [[gpi->leftHints objectAtIndex: i] lastDistance = [[gpi->leftHints objectAtIndex: i]
distanceToFrame: frame]; distanceToFrame: frame];
if (lastDistance < minimum) if ((lastDistance < minimum)
&& (rightOfFrame - [[gpi->leftHints objectAtIndex: i] position]
>= minSize.width))
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
[bests addObject: [gpi->leftHints objectAtIndex: i]]; [bests addObject: [gpi->leftHints objectAtIndex: i]];
minimum = lastDistance; minimum = lastDistance;
bestLeftPosition = [[gpi->leftHints objectAtIndex: i] position];
leftEmpty = NO;
} }
else if (lastDistance == minimum) else if ((lastDistance == minimum) && (leftEmpty == NO)
&& ([[gpi->leftHints objectAtIndex: i] position] == bestLeftPosition))
[bests addObject: [gpi->leftHints objectAtIndex: i]]; [bests addObject: [gpi->leftHints objectAtIndex: i]];
} }
count = [bests count]; count = [bests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; leftStart = NSMinY([[bests objectAtIndex: 0] frame]);
position = [[bests objectAtIndex: 0] position]; leftEnd = NSMaxY([[bests objectAtIndex: 0] frame]);
start = NSMinY(frame); for ( i = 1; i < count; i++ )
end = NSMaxY(frame);
for ( i = 0; i < count; i++ )
{ {
start = MIN(NSMinY([[bests objectAtIndex: i] frame]), start); leftStart = MIN(NSMinY([[bests objectAtIndex: i] frame]), leftStart);
end = MAX(NSMaxY([[bests objectAtIndex: i] frame]), end); leftEnd = MAX(NSMaxY([[bests objectAtIndex: i] frame]), leftEnd);
} }
leftOfFrame = bestLeftPosition;
[[NSColor redColor] set];
NSRectFill(NSMakeRect(position - 1, start, 2, end - start));
gpi->lastLeftRect = NSMakeRect(position - 1, start, 2, end - start);
leftOfFrame = position;
} }
} }
@ -297,42 +605,39 @@
|| gpi->knob == IBBottomRightKnobPosition) || gpi->knob == IBBottomRightKnobPosition)
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
minimum = 10; minimum = 6;
count = [gpi->rightHints count]; count = [gpi->rightHints count];
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
lastDistance = [[gpi->rightHints objectAtIndex: i] lastDistance = [[gpi->rightHints objectAtIndex: i]
distanceToFrame: frame]; distanceToFrame: frame];
if (lastDistance < minimum) if (lastDistance < minimum
&& ([[gpi->rightHints objectAtIndex: i] position] - leftOfFrame
>= minSize.width))
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
[bests addObject: [gpi->rightHints objectAtIndex: i]]; [bests addObject: [gpi->rightHints objectAtIndex: i]];
minimum = lastDistance; minimum = lastDistance;
bestRightPosition = [[gpi->rightHints objectAtIndex: i] position];
rightEmpty = NO;
} }
else if (lastDistance == minimum) else if ((lastDistance == minimum) && (rightEmpty == NO)
&& ([[gpi->rightHints objectAtIndex: i] position] == bestRightPosition))
[bests addObject: [gpi->rightHints objectAtIndex: i]]; [bests addObject: [gpi->rightHints objectAtIndex: i]];
} }
count = [bests count]; count = [bests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; rightStart = NSMinY([[bests objectAtIndex: 0] frame]);
position = [[bests objectAtIndex: 0] position]; rightEnd = NSMaxY([[bests objectAtIndex: 0] frame]);
start = NSMinY(frame); for ( i = 1; i < count; i++ )
end = NSMaxY(frame);
for ( i = 0; i < count; i++ )
{ {
start = MIN(NSMinY([[bests objectAtIndex: i] frame]), start); rightStart = MIN(NSMinY([[bests objectAtIndex: i] frame]), rightStart);
end = MAX(NSMaxY([[bests objectAtIndex: i] frame]), end); rightEnd = MAX(NSMaxY([[bests objectAtIndex: i] frame]), rightEnd);
} }
rightOfFrame = bestRightPosition;
[[NSColor redColor] set];
NSRectFill(NSMakeRect(position - 1, start, 2, end - start));
gpi->lastRightRect = NSMakeRect(position - 1, start, 2, end - start);
rightOfFrame = position;
} }
} }
@ -341,42 +646,39 @@
|| gpi->knob == IBTopMiddleKnobPosition) || gpi->knob == IBTopMiddleKnobPosition)
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
minimum = 10; minimum = 6;
count = [gpi->topHints count]; count = [gpi->topHints count];
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
lastDistance = [[gpi->topHints objectAtIndex: i] lastDistance = [[gpi->topHints objectAtIndex: i]
distanceToFrame: frame]; distanceToFrame: frame];
if (lastDistance < minimum) if (lastDistance < minimum
&& ([[gpi->topHints objectAtIndex: i] position] - bottomOfFrame
>= minSize.height))
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
[bests addObject: [gpi->topHints objectAtIndex: i]]; [bests addObject: [gpi->topHints objectAtIndex: i]];
minimum = lastDistance; minimum = lastDistance;
bestTopPosition = [[gpi->topHints objectAtIndex: i] position];
topEmpty = NO;
} }
else if (lastDistance == minimum) else if ((lastDistance == minimum) && (topEmpty == NO)
&& ([[gpi->topHints objectAtIndex: i] position] == bestTopPosition))
[bests addObject: [gpi->topHints objectAtIndex: i]]; [bests addObject: [gpi->topHints objectAtIndex: i]];
} }
count = [bests count]; count = [bests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; topStart = NSMinX([[bests objectAtIndex: 0] frame]);
position = [[bests objectAtIndex: 0] position]; topEnd = NSMaxX([[bests objectAtIndex: 0] frame]);
for ( i = 1; i < count; i++ )
start = NSMinX(frame);
end = NSMaxX(frame);
for ( i = 0; i < count; i++ )
{ {
start = MIN(NSMinX([[bests objectAtIndex: i] frame]), start); topStart = MIN(NSMinX([[bests objectAtIndex: i] frame]), topStart);
end = MAX(NSMaxX([[bests objectAtIndex: i] frame]), end); topEnd = MAX(NSMaxX([[bests objectAtIndex: i] frame]), topEnd);
} }
topOfFrame = bestTopPosition;
[[NSColor redColor] set];
NSRectFill(NSMakeRect(start, position - 1, end - start, 2));
gpi->lastTopRect = NSMakeRect(start, position - 1, end - start, 2);
topOfFrame = position;
} }
} }
@ -385,48 +687,82 @@
|| gpi->knob == IBBottomMiddleKnobPosition) || gpi->knob == IBBottomMiddleKnobPosition)
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
minimum = 10; minimum = 6;
count = [gpi->bottomHints count]; count = [gpi->bottomHints count];
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
lastDistance = [[gpi->bottomHints objectAtIndex: i] lastDistance = [[gpi->bottomHints objectAtIndex: i]
distanceToFrame: frame]; distanceToFrame: frame];
if (lastDistance < minimum) if (lastDistance < minimum
&& (topOfFrame - [[gpi->bottomHints objectAtIndex: i] position]
>= minSize.height))
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
[bests addObject: [gpi->bottomHints objectAtIndex: i]]; [bests addObject: [gpi->bottomHints objectAtIndex: i]];
minimum = lastDistance; minimum = lastDistance;
bestBottomPosition = [[gpi->bottomHints objectAtIndex: i] position];
bottomEmpty = NO;
} }
else if (lastDistance == minimum) else if ((lastDistance == minimum) && (bottomEmpty == NO)
&& ([[gpi->bottomHints objectAtIndex: i] position] == bestBottomPosition))
[bests addObject: [gpi->bottomHints objectAtIndex: i]]; [bests addObject: [gpi->bottomHints objectAtIndex: i]];
} }
count = [bests count]; count = [bests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; bottomStart = NSMinX([[bests objectAtIndex: 0] frame]);
position = [[bests objectAtIndex: 0] position]; bottomEnd = NSMaxX([[bests objectAtIndex: 0] frame]);
for ( i = 1; i < count; i++ )
start = NSMinX(frame);
end = NSMaxX(frame);
for ( i = 0; i < count; i++ )
{ {
start = MIN(NSMinX([[bests objectAtIndex: i] frame]), start); bottomStart = MIN(NSMinX([[bests objectAtIndex: i] frame]), bottomStart);
end = MAX(NSMaxX([[bests objectAtIndex: i] frame]), end); bottomEnd = MAX(NSMaxX([[bests objectAtIndex: i] frame]), bottomEnd);
} }
bottomOfFrame = bestBottomPosition;
[[NSColor redColor] set];
NSRectFill(NSMakeRect(start, position - 1, end - start, 2));
gpi->lastBottomRect = NSMakeRect(start, position - 1, end - start, 2);
bottomOfFrame = position;
} }
} }
gpi->hintFrame = NSMakeRect (leftOfFrame, bottomOfFrame, gpi->hintFrame = NSMakeRect (leftOfFrame, bottomOfFrame,
rightOfFrame - leftOfFrame, rightOfFrame - leftOfFrame,
topOfFrame - bottomOfFrame); topOfFrame - bottomOfFrame);
{
[[NSColor redColor] set];
if (!leftEmpty)
{
leftStart = MIN(NSMinY(gpi->hintFrame), leftStart);
leftEnd = MAX(NSMaxY(gpi->hintFrame), leftEnd);
gpi->lastLeftRect = NSMakeRect(bestLeftPosition - 1, leftStart,
2, leftEnd - leftStart);
NSRectFill(gpi->lastLeftRect);
}
if (!rightEmpty)
{
rightStart = MIN(NSMinY(gpi->hintFrame), rightStart);
rightEnd = MAX(NSMaxY(gpi->hintFrame), rightEnd);
gpi->lastRightRect = NSMakeRect(bestRightPosition - 1, rightStart,
2, rightEnd - rightStart);
NSRectFill(gpi->lastRightRect);
}
if (!topEmpty)
{
topStart = MIN(NSMinX(gpi->hintFrame), topStart);
topEnd = MAX(NSMaxX(gpi->hintFrame), topEnd);
gpi->lastTopRect = NSMakeRect(topStart, bestTopPosition - 1,
topEnd - topStart, 2);
NSRectFill(gpi->lastTopRect);
}
if (!bottomEmpty)
{
bottomStart = MIN(NSMinX(gpi->hintFrame), bottomStart);
bottomEnd = MAX(NSMaxX(gpi->hintFrame), bottomEnd);
gpi->lastBottomRect = NSMakeRect(bottomStart, bestBottomPosition - 1,
bottomEnd - bottomStart, 2);
NSRectFill(gpi->lastBottomRect);
}
}
GormShowFrameWithKnob(gpi->hintFrame, gpi->knob); GormShowFrameWithKnob(gpi->hintFrame, gpi->knob);
gpi->oldRect = GormExtBoundsForRect(gpi->hintFrame); gpi->oldRect = GormExtBoundsForRect(gpi->hintFrame);
@ -437,6 +773,7 @@
} }
- (void) updateResizingWithFrame: (NSRect) frame - (void) updateResizingWithFrame: (NSRect) frame
andEvent: (NSEvent *)theEvent andEvent: (NSEvent *)theEvent
andPlacementInfo: (GormPlacementInfo*) gpi andPlacementInfo: (GormPlacementInfo*) gpi

View file

@ -98,33 +98,21 @@
- (int) distanceToFrame: (NSRect) frame - (int) distanceToFrame: (NSRect) frame
{ {
NSRect rect = [self rectWithHalfDistance: 5]; NSRect rect = [self rectWithHalfDistance: 6];
if (NSIntersectsRect(frame, rect) == NO) if (NSIntersectsRect(frame, rect) == NO)
return 20; return 10;
switch (_border) switch (_border)
{ {
case Top: case Top:
if (_position >= NSMaxY(frame)) return abs (_position - NSMaxY(frame));
return 2 * (_position - NSMaxY(frame));
else
return 2 * (- _position + NSMaxY(frame)) + 1;
case Bottom: case Bottom:
if (_position >= NSMinY(frame)) return abs (_position - NSMinY(frame));
return 2 * (_position - NSMinY(frame));
else
return 2 * (- _position + NSMinY(frame)) + 1;
case Left: case Left:
if (_position >= NSMinX(frame)) return abs (_position - NSMinX(frame));
return 2 * (_position - NSMinX(frame));
else
return 2 * (- _position + NSMinX(frame)) + 1;
case Right: case Right:
if (_position >= NSMaxX(frame)) return abs (_position - NSMaxX(frame));
return 2 * (_position - NSMaxX(frame));
else
return 2 * (- _position + NSMaxX(frame)) + 1;
default: default:
return 20; return 10;
} }
} }
@end @end
@ -527,6 +515,23 @@ static BOOL currently_displaying = NO;
int count; int count;
int lastDistance; int lastDistance;
int minimum = 10; int minimum = 10;
BOOL leftEmpty = YES;
BOOL rightEmpty = YES;
BOOL topEmpty = YES;
BOOL bottomEmpty = YES;
float bestLeftPosition;
float bestRightPosition;
float bestTopPosition;
float bestBottomPosition;
float leftStart;
float rightStart;
float topStart;
float bottomStart;
float leftEnd;
float rightEnd;
float topEnd;
float bottomEnd;
NSMutableArray *bests; NSMutableArray *bests;
if (gpi->hintInitialized == NO) if (gpi->hintInitialized == NO)
{ {
@ -566,7 +571,7 @@ static BOOL currently_displaying = NO;
|| gpi->knob == IBBottomLeftKnobPosition) || gpi->knob == IBBottomLeftKnobPosition)
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
minimum = 10; minimum = 6;
count = [gpi->leftHints count]; count = [gpi->leftHints count];
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
@ -577,31 +582,26 @@ static BOOL currently_displaying = NO;
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
[bests addObject: [gpi->leftHints objectAtIndex: i]]; [bests addObject: [gpi->leftHints objectAtIndex: i]];
minimum = lastDistance; minimum = lastDistance;
bestLeftPosition = [[gpi->leftHints objectAtIndex: i] position];
leftEmpty = NO;
} }
else if (lastDistance == minimum) else if ((lastDistance == minimum) && (leftEmpty == NO)
&& ([[gpi->leftHints objectAtIndex: i] position] == bestLeftPosition))
[bests addObject: [gpi->leftHints objectAtIndex: i]]; [bests addObject: [gpi->leftHints objectAtIndex: i]];
} }
count = [bests count]; count = [bests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; leftStart = NSMinY([[bests objectAtIndex: 0] frame]);
position = [[bests objectAtIndex: 0] position]; leftEnd = NSMaxY([[bests objectAtIndex: 0] frame]);
start = NSMinY(frame); for ( i = 1; i < count; i++ )
end = NSMaxY(frame);
for ( i = 0; i < count; i++ )
{ {
start = MIN(NSMinY([[bests objectAtIndex: i] frame]), start); leftStart = MIN(NSMinY([[bests objectAtIndex: i] frame]), leftStart);
end = MAX(NSMaxY([[bests objectAtIndex: i] frame]), end); leftEnd = MAX(NSMaxY([[bests objectAtIndex: i] frame]), leftEnd);
} }
leftOfFrame = bestLeftPosition;
[[NSColor redColor] set];
NSRectFill(NSMakeRect(position - 1, start, 2, end - start));
gpi->lastLeftRect = NSMakeRect(position - 1, start, 2, end - start);
leftOfFrame = position;
} }
} }
@ -610,7 +610,7 @@ static BOOL currently_displaying = NO;
|| gpi->knob == IBBottomRightKnobPosition) || gpi->knob == IBBottomRightKnobPosition)
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
minimum = 10; minimum = 6;
count = [gpi->rightHints count]; count = [gpi->rightHints count];
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
@ -621,31 +621,26 @@ static BOOL currently_displaying = NO;
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
[bests addObject: [gpi->rightHints objectAtIndex: i]]; [bests addObject: [gpi->rightHints objectAtIndex: i]];
minimum = lastDistance; minimum = lastDistance;
bestRightPosition = [[gpi->rightHints objectAtIndex: i] position];
rightEmpty = NO;
} }
else if (lastDistance == minimum) else if ((lastDistance == minimum) && (rightEmpty == NO)
&& ([[gpi->rightHints objectAtIndex: i] position] == bestRightPosition))
[bests addObject: [gpi->rightHints objectAtIndex: i]]; [bests addObject: [gpi->rightHints objectAtIndex: i]];
} }
count = [bests count]; count = [bests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; rightStart = NSMinY([[bests objectAtIndex: 0] frame]);
position = [[bests objectAtIndex: 0] position]; rightEnd = NSMaxY([[bests objectAtIndex: 0] frame]);
start = NSMinY(frame); for ( i = 1; i < count; i++ )
end = NSMaxY(frame);
for ( i = 0; i < count; i++ )
{ {
start = MIN(NSMinY([[bests objectAtIndex: i] frame]), start); rightStart = MIN(NSMinY([[bests objectAtIndex: i] frame]), rightStart);
end = MAX(NSMaxY([[bests objectAtIndex: i] frame]), end); rightEnd = MAX(NSMaxY([[bests objectAtIndex: i] frame]), rightEnd);
} }
rightOfFrame = bestRightPosition;
[[NSColor redColor] set];
NSRectFill(NSMakeRect(position - 1, start, 2, end - start));
gpi->lastRightRect = NSMakeRect(position - 1, start, 2, end - start);
rightOfFrame = position;
} }
} }
@ -654,7 +649,7 @@ static BOOL currently_displaying = NO;
|| gpi->knob == IBTopMiddleKnobPosition) || gpi->knob == IBTopMiddleKnobPosition)
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
minimum = 10; minimum = 6;
count = [gpi->topHints count]; count = [gpi->topHints count];
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
@ -665,31 +660,25 @@ static BOOL currently_displaying = NO;
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
[bests addObject: [gpi->topHints objectAtIndex: i]]; [bests addObject: [gpi->topHints objectAtIndex: i]];
minimum = lastDistance; minimum = lastDistance;
bestTopPosition = [[gpi->topHints objectAtIndex: i] position];
topEmpty = NO;
} }
else if (lastDistance == minimum) else if ((lastDistance == minimum) && (topEmpty == NO)
&& ([[gpi->topHints objectAtIndex: i] position] == bestTopPosition))
[bests addObject: [gpi->topHints objectAtIndex: i]]; [bests addObject: [gpi->topHints objectAtIndex: i]];
} }
count = [bests count]; count = [bests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; topStart = NSMinX([[bests objectAtIndex: 0] frame]);
position = [[bests objectAtIndex: 0] position]; topEnd = NSMaxX([[bests objectAtIndex: 0] frame]);
for ( i = 1; i < count; i++ )
start = NSMinX(frame);
end = NSMaxX(frame);
for ( i = 0; i < count; i++ )
{ {
start = MIN(NSMinX([[bests objectAtIndex: i] frame]), start); topStart = MIN(NSMinX([[bests objectAtIndex: i] frame]), topStart);
end = MAX(NSMaxX([[bests objectAtIndex: i] frame]), end); topEnd = MAX(NSMaxX([[bests objectAtIndex: i] frame]), topEnd);
} }
topOfFrame = bestTopPosition;
[[NSColor redColor] set];
NSRectFill(NSMakeRect(start, position - 1, end - start, 2));
gpi->lastTopRect = NSMakeRect(start, position - 1, end - start, 2);
topOfFrame = position;
} }
} }
@ -698,7 +687,7 @@ static BOOL currently_displaying = NO;
|| gpi->knob == IBBottomMiddleKnobPosition) || gpi->knob == IBBottomMiddleKnobPosition)
{ {
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
minimum = 10; minimum = 6;
count = [gpi->bottomHints count]; count = [gpi->bottomHints count];
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
@ -709,37 +698,69 @@ static BOOL currently_displaying = NO;
bests = [NSMutableArray arrayWithCapacity: 4]; bests = [NSMutableArray arrayWithCapacity: 4];
[bests addObject: [gpi->bottomHints objectAtIndex: i]]; [bests addObject: [gpi->bottomHints objectAtIndex: i]];
minimum = lastDistance; minimum = lastDistance;
bestBottomPosition = [[gpi->bottomHints objectAtIndex: i] position];
bottomEmpty = NO;
} }
else if (lastDistance == minimum) else if ((lastDistance == minimum) && (bottomEmpty == NO)
&& ([[gpi->bottomHints objectAtIndex: i] position] == bestBottomPosition))
[bests addObject: [gpi->bottomHints objectAtIndex: i]]; [bests addObject: [gpi->bottomHints objectAtIndex: i]];
} }
count = [bests count]; count = [bests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; bottomStart = NSMinX([[bests objectAtIndex: 0] frame]);
position = [[bests objectAtIndex: 0] position]; bottomEnd = NSMaxX([[bests objectAtIndex: 0] frame]);
for ( i = 1; i < count; i++ )
start = NSMinX(frame);
end = NSMaxX(frame);
for ( i = 0; i < count; i++ )
{ {
start = MIN(NSMinX([[bests objectAtIndex: i] frame]), start); bottomStart = MIN(NSMinX([[bests objectAtIndex: i] frame]), bottomStart);
end = MAX(NSMaxX([[bests objectAtIndex: i] frame]), end); bottomEnd = MAX(NSMaxX([[bests objectAtIndex: i] frame]), bottomEnd);
} }
bottomOfFrame = bestBottomPosition;
[[NSColor redColor] set];
NSRectFill(NSMakeRect(start, position - 1, end - start, 2));
gpi->lastBottomRect = NSMakeRect(start, position - 1, end - start, 2);
bottomOfFrame = position;
} }
} }
gpi->hintFrame = NSMakeRect (leftOfFrame, bottomOfFrame, gpi->hintFrame = NSMakeRect (leftOfFrame, bottomOfFrame,
rightOfFrame - leftOfFrame, rightOfFrame - leftOfFrame,
topOfFrame - bottomOfFrame); topOfFrame - bottomOfFrame);
{
[[NSColor redColor] set];
if (!leftEmpty)
{
leftStart = MIN(NSMinY(gpi->hintFrame), leftStart);
leftEnd = MAX(NSMaxY(gpi->hintFrame), leftEnd);
gpi->lastLeftRect = NSMakeRect(bestLeftPosition - 1, leftStart,
2, leftEnd - leftStart);
NSRectFill(gpi->lastLeftRect);
}
if (!rightEmpty)
{
rightStart = MIN(NSMinY(gpi->hintFrame), rightStart);
rightEnd = MAX(NSMaxY(gpi->hintFrame), rightEnd);
gpi->lastRightRect = NSMakeRect(bestRightPosition - 1, rightStart,
2, rightEnd - rightStart);
NSRectFill(gpi->lastRightRect);
}
if (!topEmpty)
{
topStart = MIN(NSMinX(gpi->hintFrame), topStart);
topEnd = MAX(NSMaxX(gpi->hintFrame), topEnd);
gpi->lastTopRect = NSMakeRect(topStart, bestTopPosition - 1,
topEnd - topStart, 2);
NSRectFill(gpi->lastTopRect);
}
if (!bottomEmpty)
{
bottomStart = MIN(NSMinX(gpi->hintFrame), bottomStart);
bottomEnd = MAX(NSMaxX(gpi->hintFrame), bottomEnd);
gpi->lastBottomRect = NSMakeRect(bottomStart, bestBottomPosition - 1,
bottomEnd - bottomStart, 2);
NSRectFill(gpi->lastBottomRect);
}
}
GormShowFrameWithKnob(gpi->hintFrame, gpi->knob); GormShowFrameWithKnob(gpi->hintFrame, gpi->knob);
gpi->oldRect = GormExtBoundsForRect(gpi->hintFrame); gpi->oldRect = GormExtBoundsForRect(gpi->hintFrame);
@ -797,6 +818,22 @@ static BOOL currently_displaying = NO;
int count; int count;
int lastDistance; int lastDistance;
int minimum = 10; int minimum = 10;
BOOL leftEmpty = YES;
BOOL rightEmpty = YES;
BOOL topEmpty = YES;
BOOL bottomEmpty = YES;
float bestLeftPosition;
float bestRightPosition;
float bestTopPosition;
float bestBottomPosition;
float leftStart;
float rightStart;
float topStart;
float bottomStart;
float leftEnd;
float rightEnd;
float topEnd;
float bottomEnd;
if (gpi->hintInitialized == NO) if (gpi->hintInitialized == NO)
{ {
@ -826,10 +863,11 @@ static BOOL currently_displaying = NO;
{ {
BOOL empty = YES;
float bestPosition; float bestPosition;
NSMutableArray *leftBests; NSMutableArray *leftBests;
NSMutableArray *rightBests; NSMutableArray *rightBests;
minimum = 10; minimum = 6;
count = [gpi->leftHints count]; count = [gpi->leftHints count];
leftBests = [NSMutableArray arrayWithCapacity: 4]; leftBests = [NSMutableArray arrayWithCapacity: 4];
@ -843,8 +881,10 @@ static BOOL currently_displaying = NO;
[leftBests addObject: [gpi->leftHints objectAtIndex: i]]; [leftBests addObject: [gpi->leftHints objectAtIndex: i]];
minimum = lastDistance; minimum = lastDistance;
bestPosition = [[gpi->leftHints objectAtIndex: i] position]; bestPosition = [[gpi->leftHints objectAtIndex: i] position];
empty = NO;
} }
else if (lastDistance == minimum) else if ((lastDistance == minimum) && (empty == NO)
&& ([[gpi->leftHints objectAtIndex: i] position] == bestPosition))
[leftBests addObject: [gpi->leftHints objectAtIndex: i]]; [leftBests addObject: [gpi->leftHints objectAtIndex: i]];
} }
@ -862,8 +902,9 @@ static BOOL currently_displaying = NO;
minimum = lastDistance; minimum = lastDistance;
bestPosition = [[gpi->rightHints objectAtIndex: i] position] bestPosition = [[gpi->rightHints objectAtIndex: i] position]
- widthOfFrame; - widthOfFrame;
empty = NO;
} }
else if (lastDistance == minimum else if ((lastDistance == minimum) && (empty == NO)
&& ([[gpi->rightHints objectAtIndex: i] position] - bestPosition && ([[gpi->rightHints objectAtIndex: i] position] - bestPosition
== widthOfFrame)) == widthOfFrame))
[rightBests addObject: [gpi->rightHints objectAtIndex: i]]; [rightBests addObject: [gpi->rightHints objectAtIndex: i]];
@ -872,20 +913,18 @@ static BOOL currently_displaying = NO;
count = [leftBests count]; count = [leftBests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; float position;
leftEmpty = NO;
position = [[leftBests objectAtIndex: 0] position]; position = [[leftBests objectAtIndex: 0] position];
start = NSMinY(frame); leftStart = NSMinY([[leftBests objectAtIndex: 0] frame]);
end = NSMaxY(frame); leftEnd = NSMaxY([[leftBests objectAtIndex: 0] frame]);
for ( i = 0; i < count; i++ ) for ( i = 1; i < count; i++ )
{ {
start = MIN(NSMinY([[leftBests objectAtIndex: i] frame]), start); leftStart = MIN(NSMinY([[leftBests objectAtIndex: i] frame]), leftStart);
end = MAX(NSMaxY([[leftBests objectAtIndex: i] frame]), end); leftEnd = MAX(NSMaxY([[leftBests objectAtIndex: i] frame]), leftEnd);
} }
[[NSColor redColor] set];
NSRectFill(NSMakeRect(position - 1, start, 2, end - start));
gpi->lastLeftRect = NSMakeRect(position - 1, start, 2, end - start);
leftOfFrame = position; leftOfFrame = position;
rightOfFrame = position + widthOfFrame; rightOfFrame = position + widthOfFrame;
} }
@ -893,30 +932,29 @@ static BOOL currently_displaying = NO;
count = [rightBests count]; count = [rightBests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; float position;
rightEmpty = NO;
position = [[rightBests objectAtIndex: 0] position]; position = [[rightBests objectAtIndex: 0] position];
start = NSMinY(frame); rightStart = NSMinY([[rightBests objectAtIndex: 0] frame]);
end = NSMaxY(frame); rightEnd = NSMaxY([[rightBests objectAtIndex: 0] frame]);
for ( i = 0; i < count; i++ ) for ( i = 1; i < count; i++ )
{ {
start = MIN(NSMinY([[rightBests objectAtIndex: i] frame]), start); rightStart = MIN(NSMinY([[rightBests objectAtIndex: i] frame]), rightStart);
end = MAX(NSMaxY([[rightBests objectAtIndex: i] frame]), end); rightEnd = MAX(NSMaxY([[rightBests objectAtIndex: i] frame]), rightEnd);
} }
[[NSColor redColor] set];
NSRectFill(NSMakeRect(position - 1, start, 2, end - start));
gpi->lastRightRect = NSMakeRect(position - 1, start, 2, end - start);
rightOfFrame = position; rightOfFrame = position;
leftOfFrame = position - widthOfFrame; leftOfFrame = position - widthOfFrame;
} }
} }
{ {
BOOL empty = YES;
float bestPosition; float bestPosition;
NSMutableArray *bottomBests; NSMutableArray *bottomBests;
NSMutableArray *topBests; NSMutableArray *topBests;
minimum = 10; minimum = 6;
count = [gpi->bottomHints count]; count = [gpi->bottomHints count];
bottomBests = [NSMutableArray arrayWithCapacity: 4]; bottomBests = [NSMutableArray arrayWithCapacity: 4];
@ -930,8 +968,10 @@ static BOOL currently_displaying = NO;
[bottomBests addObject: [gpi->bottomHints objectAtIndex: i]]; [bottomBests addObject: [gpi->bottomHints objectAtIndex: i]];
minimum = lastDistance; minimum = lastDistance;
bestPosition = [[gpi->bottomHints objectAtIndex: i] position]; bestPosition = [[gpi->bottomHints objectAtIndex: i] position];
empty = NO;
} }
else if (lastDistance == minimum) else if ((lastDistance == minimum) && (empty == NO)
&& ([[gpi->bottomHints objectAtIndex: i] position] == bestPosition))
[bottomBests addObject: [gpi->bottomHints objectAtIndex: i]]; [bottomBests addObject: [gpi->bottomHints objectAtIndex: i]];
} }
@ -949,8 +989,9 @@ static BOOL currently_displaying = NO;
minimum = lastDistance; minimum = lastDistance;
bestPosition = [[gpi->topHints objectAtIndex: i] position] bestPosition = [[gpi->topHints objectAtIndex: i] position]
- heightOfFrame; - heightOfFrame;
empty = NO;
} }
else if (lastDistance == minimum else if (lastDistance == minimum && (empty == NO)
&& ([[gpi->topHints objectAtIndex: i] position] - bestPosition && ([[gpi->topHints objectAtIndex: i] position] - bestPosition
== heightOfFrame)) == heightOfFrame))
[topBests addObject: [gpi->topHints objectAtIndex: i]]; [topBests addObject: [gpi->topHints objectAtIndex: i]];
@ -959,20 +1000,18 @@ static BOOL currently_displaying = NO;
count = [bottomBests count]; count = [bottomBests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; float position;
bottomEmpty = NO;
position = [[bottomBests objectAtIndex: 0] position]; position = [[bottomBests objectAtIndex: 0] position];
start = NSMinX(frame); bottomStart = NSMinX([[bottomBests objectAtIndex: 0] frame]);
end = NSMaxX(frame); bottomEnd = NSMaxX([[bottomBests objectAtIndex: 0] frame]);
for ( i = 0; i < count; i++ ) for ( i = 1; i < count; i++ )
{ {
start = MIN(NSMinX([[bottomBests objectAtIndex: i] frame]), start); bottomStart = MIN(NSMinX([[bottomBests objectAtIndex: i] frame]), bottomStart);
end = MAX(NSMaxX([[bottomBests objectAtIndex: i] frame]), end); bottomEnd = MAX(NSMaxX([[bottomBests objectAtIndex: i] frame]), bottomEnd);
} }
[[NSColor redColor] set];
NSRectFill(NSMakeRect(start, position - 1, end - start, 2));
gpi->lastBottomRect = NSMakeRect(start, position - 1, end - start, 2);
bottomOfFrame = position; bottomOfFrame = position;
topOfFrame = position + heightOfFrame; topOfFrame = position + heightOfFrame;
} }
@ -980,28 +1019,67 @@ static BOOL currently_displaying = NO;
count = [topBests count]; count = [topBests count];
if (count >= 1) if (count >= 1)
{ {
float start, end, position; float position;
topEmpty = NO;
position = [[topBests objectAtIndex: 0] position]; position = [[topBests objectAtIndex: 0] position];
start = NSMinX(frame); topStart = NSMinX([[topBests objectAtIndex: 0] frame]);
end = NSMaxX(frame); topEnd = NSMaxX([[topBests objectAtIndex: 0] frame]);
for ( i = 0; i < count; i++ ) for ( i = 1; i < count; i++ )
{ {
start = MIN(NSMinX([[topBests objectAtIndex: i] frame]), start); topStart = MIN(NSMinX([[topBests objectAtIndex: i] frame]), topStart);
end = MAX(NSMaxX([[topBests objectAtIndex: i] frame]), end); topEnd = MAX(NSMaxX([[topBests objectAtIndex: i] frame]), topEnd);
} }
[[NSColor redColor] set];
NSRectFill(NSMakeRect(start, position - 1, end - start, 2));
gpi->lastTopRect = NSMakeRect(start, position - 1, end - start, 2);
topOfFrame = position; topOfFrame = position;
bottomOfFrame = position - heightOfFrame; bottomOfFrame = position - heightOfFrame;
} }
} }
return NSMakeRect (leftOfFrame, bottomOfFrame, gpi->hintFrame = NSMakeRect (leftOfFrame, bottomOfFrame,
rightOfFrame - leftOfFrame, rightOfFrame - leftOfFrame,
topOfFrame - bottomOfFrame); topOfFrame - bottomOfFrame);
{
[[NSColor redColor] set];
if (!leftEmpty)
{
leftStart = MIN(NSMinY(gpi->hintFrame), leftStart);
leftEnd = MAX(NSMaxY(gpi->hintFrame), leftEnd);
gpi->lastLeftRect = NSMakeRect(leftOfFrame - 1, leftStart,
2, leftEnd - leftStart);
NSRectFill(gpi->lastLeftRect);
}
if (!rightEmpty)
{
rightStart = MIN(NSMinY(gpi->hintFrame), rightStart);
rightEnd = MAX(NSMaxY(gpi->hintFrame), rightEnd);
gpi->lastRightRect = NSMakeRect(rightOfFrame - 1, rightStart,
2, rightEnd - rightStart);
NSRectFill(gpi->lastRightRect);
}
if (!topEmpty)
{
topStart = MIN(NSMinX(gpi->hintFrame), topStart);
topEnd = MAX(NSMaxX(gpi->hintFrame), topEnd);
gpi->lastTopRect = NSMakeRect(topStart, topOfFrame - 1,
topEnd - topStart, 2);
NSRectFill(gpi->lastTopRect);
}
if (!bottomEmpty)
{
bottomStart = MIN(NSMinX(gpi->hintFrame), bottomStart);
bottomEnd = MAX(NSMaxX(gpi->hintFrame), bottomEnd);
gpi->lastBottomRect = NSMakeRect(bottomStart, bottomOfFrame - 1,
bottomEnd - bottomStart, 2);
NSRectFill(gpi->lastBottomRect);
}
}
return gpi->hintFrame;
} }

View file

@ -527,16 +527,13 @@
if ([selection count] == 1) if ([selection count] == 1)
{ {
{ NSRect tempFrame = [[selection objectAtIndex: 0] frame];
NSRect tempFrame = [[selection objectAtIndex: 0] frame]; [[selection objectAtIndex: 0]
[[selection objectAtIndex: 0] setFrameOrigin:
setFrameOrigin: NSMakePoint(NSMaxX([self bounds]),
NSMakePoint(NSMaxX([self bounds]), NSMaxY([self bounds]))];
NSMaxY([self bounds]))]; [superview display];
[superview display];
[[selection objectAtIndex: 0]
setFrameOrigin: tempFrame.origin];
}
r = oldMovingFrame; r = oldMovingFrame;
r.origin.x += xDiff; r.origin.x += xDiff;
r.origin.y += yDiff; r.origin.y += yDiff;