Tooltip rect handling improvments ... reasonable behavior when coordinates

of the view change


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23790 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-10-08 17:50:19 +00:00
parent 4828fe82c3
commit 1995529b8a
4 changed files with 46 additions and 26 deletions

View file

@ -1,3 +1,9 @@
2006-10-06 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSTrackingRect.m: Allow reset rect to another value.
* Source/GSToolTips.m: Improve handling of tips in rects other than
the main one.
2006-10-07 10:20-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/GSNibCompatibility.m: Implement init in NSIBHelpConnector.

View file

@ -54,6 +54,7 @@
inside: (BOOL)flag;
- (NSRect) rectangle;
- (void) reset: (NSRect)aRect inside: (BOOL)flag;
- (NSTrackingRectTag) tag;
- (id) owner;
- (void*) userData;

View file

@ -52,13 +52,15 @@
*/
@interface GSTTProvider : NSObject
{
id object;
void *data;
id object;
void *data;
NSRect viewRect;
}
- (void*) data;
- (id) initWithObject: (id)o userData: (void*)d;
- (id) initWithObject: (id)o userData: (void*)d rect: (NSRect)r;
- (id) object;
- (void) setObject: (id)o;
- (NSRect) viewRect;
@end
@implementation GSTTProvider
@ -66,10 +68,11 @@
{
return data;
}
- (id) initWithObject: (id)o userData: (void*)d
- (id) initWithObject: (id)o userData: (void*)d rect: (NSRect)r
{
data = d;
object = o;
viewRect = r;
return self;
}
- (id) object
@ -80,6 +83,10 @@
{
object = o;
}
- (NSRect) viewRect
{
return viewRect;
}
@end
@interface GSToolTips (Private)
@ -144,6 +151,7 @@ static BOOL restoreMouseMoved;
{
return -1; // A tip is already in progress.
}
aRect = NSIntersectionRect(aRect, [view bounds]);
if (NSEqualRects(aRect, NSZeroRect))
{
return -1; // No rectangle.
@ -153,7 +161,9 @@ static BOOL restoreMouseMoved;
return -1; // No provider object.
}
provider = [[GSTTProvider alloc] initWithObject: anObject userData: data];
provider = [[GSTTProvider alloc] initWithObject: anObject
userData: data
rect: aRect];
tag = [view addTrackingRect: aRect
owner: self
userData: provider
@ -277,23 +287,20 @@ static BOOL restoreMouseMoved;
if (rect->owner == self)
{
GSTTProvider *provider = (GSTTProvider *)rect->user_data;
NSRect frame;
// FIXME can we do anything with tooltips other than the main one?
if (rect->tag == toolTipTag)
{
NSTrackingRectTag tag;
NSRect frame;
[view removeTrackingRect: rect->tag];
frame = [view frame];
frame.origin.x = 0;
frame.origin.y = 0;
tag = [view addTrackingRect: frame
owner: self
userData: provider
assumeInside: NO];
toolTipTag = tag;
frame = [view bounds];
}
else
{
// FIXME is this the thing to do with tooltips other than
// the main one (which we know should cover the whole view)?
frame = [provider viewRect];
}
frame = [view convertRect: frame toView: nil];
[rect reset: frame inside: NO];
}
}
}
@ -352,16 +359,14 @@ static BOOL restoreMouseMoved;
{
NSRect rect;
rect = [view frame];
rect.origin.x = 0;
rect.origin.y = 0;
rect = [view bounds];
provider = [[GSTTProvider alloc] initWithObject: string
userData: nil];
userData: nil
rect: rect];
toolTipTag = [view addTrackingRect: rect
owner: self
userData: provider
assumeInside: NO];
owner: self
userData: provider
assumeInside: NO];
}
else
{

View file

@ -67,6 +67,14 @@
return rectangle;
}
- (void) reset: (NSRect)aRect inside: (BOOL)flag
{
rectangle = aRect;
flags.inside = flag;
flags.isValid = YES;
flags.checked = NO;
}
- (NSTrackingRectTag) tag
{
return tag;