mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:40:47 +00:00
Make sure tooltip window starts off on screen.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23756 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a375c38059
commit
42a0cfaa9e
4 changed files with 59 additions and 16 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2006-10-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSToolTips.h: create tool tip wondow fully on screen
|
||||||
|
* Source/GSToolTips.m: ditto
|
||||||
|
* Source/NSView.m: very minor tooltip efficiency tweak.
|
||||||
|
|
||||||
2006-10-04 Enrico Sersale <enrico@fibernet.ro>
|
2006-10-04 Enrico Sersale <enrico@fibernet.ro>
|
||||||
|
|
||||||
* Source/NSView.m: In -setToolTip: sets the has_tooltips flag.
|
* Source/NSView.m: In -setToolTip: sets the has_tooltips flag.
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
NSTrackingRectTag toolTipTag;
|
NSTrackingRectTag toolTipTag;
|
||||||
NSTimer *timer;
|
NSTimer *timer;
|
||||||
NSWindow *window;
|
NSWindow *window;
|
||||||
|
NSSize offset;
|
||||||
BOOL restoreMouseMoved;
|
BOOL restoreMouseMoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "AppKit/NSBezierPath.h"
|
#include "AppKit/NSBezierPath.h"
|
||||||
#include "AppKit/NSView.h"
|
#include "AppKit/NSView.h"
|
||||||
#include "AppKit/NSWindow.h"
|
#include "AppKit/NSWindow.h"
|
||||||
|
#include "AppKit/NSScreen.h"
|
||||||
#include "GNUstepGUI/GSTrackingRect.h"
|
#include "GNUstepGUI/GSTrackingRect.h"
|
||||||
#include "GSToolTips.h"
|
#include "GSToolTips.h"
|
||||||
|
|
||||||
|
@ -92,8 +93,6 @@ typedef struct NSView_struct
|
||||||
@defs(NSView)
|
@defs(NSView)
|
||||||
} *NSViewPtr;
|
} *NSViewPtr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@implementation GSToolTips
|
@implementation GSToolTips
|
||||||
|
|
||||||
static NSMapTable *viewsMap = 0;
|
static NSMapTable *viewsMap = 0;
|
||||||
|
@ -251,8 +250,8 @@ static NSMapTable *viewsMap = 0;
|
||||||
|
|
||||||
mouseLocation = [NSEvent mouseLocation];
|
mouseLocation = [NSEvent mouseLocation];
|
||||||
|
|
||||||
origin = NSMakePoint(mouseLocation.x + 8,
|
origin = NSMakePoint(mouseLocation.x + offset.width,
|
||||||
mouseLocation.y - 16 - [window frame].size.height);
|
mouseLocation.y + offset.height);
|
||||||
|
|
||||||
[window setFrameOrigin: origin];
|
[window setFrameOrigin: origin];
|
||||||
}
|
}
|
||||||
|
@ -455,7 +454,8 @@ static NSMapTable *viewsMap = 0;
|
||||||
NSAttributedString *toolTipText = nil;
|
NSAttributedString *toolTipText = nil;
|
||||||
NSSize textSize;
|
NSSize textSize;
|
||||||
NSPoint mouseLocation = [NSEvent mouseLocation];
|
NSPoint mouseLocation = [NSEvent mouseLocation];
|
||||||
NSRect windowRect;
|
NSRect visible;
|
||||||
|
NSRect rect;
|
||||||
NSColor *color;
|
NSColor *color;
|
||||||
NSMutableDictionary *attributes;
|
NSMutableDictionary *attributes;
|
||||||
|
|
||||||
|
@ -467,15 +467,48 @@ static NSMapTable *viewsMap = 0;
|
||||||
attributes: attributes];
|
attributes: attributes];
|
||||||
textSize = [toolTipText size];
|
textSize = [toolTipText size];
|
||||||
|
|
||||||
// Window
|
/* Create window just off the current mouse position
|
||||||
windowRect = NSMakeRect(mouseLocation.x + 8,
|
* Constrain it to be on screen, shrinking if necessary.
|
||||||
mouseLocation.y - 16 - (textSize.height+3),
|
*/
|
||||||
textSize.width + 4, textSize.height + 4);
|
rect = NSMakeRect(mouseLocation.x + 8,
|
||||||
|
mouseLocation.y - 16 - (textSize.height+3),
|
||||||
|
textSize.width + 4, textSize.height + 4);
|
||||||
|
visible = [[NSScreen mainScreen] visibleFrame];
|
||||||
|
if (NSMaxY(rect) > NSMaxY(visible))
|
||||||
|
{
|
||||||
|
rect.origin.y -= (NSMaxY(rect) - NSMaxY(visible));
|
||||||
|
}
|
||||||
|
if (NSMinY(rect) < NSMinY(visible))
|
||||||
|
{
|
||||||
|
rect.origin.y += (NSMinY(visible) - NSMinY(rect));
|
||||||
|
}
|
||||||
|
if (NSMaxY(rect) > NSMaxY(visible))
|
||||||
|
{
|
||||||
|
rect.origin.y = visible.origin.y;
|
||||||
|
rect.size.height = visible.size.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NSMaxX(rect) > NSMaxX(visible))
|
||||||
|
{
|
||||||
|
rect.origin.x -= (NSMaxX(rect) - NSMaxX(visible));
|
||||||
|
}
|
||||||
|
if (NSMinX(rect) < NSMinX(visible))
|
||||||
|
{
|
||||||
|
rect.origin.x += (NSMinX(visible) - NSMinX(rect));
|
||||||
|
}
|
||||||
|
if (NSMaxX(rect) > NSMaxX(visible))
|
||||||
|
{
|
||||||
|
rect.origin.x = visible.origin.x;
|
||||||
|
rect.size.width = visible.size.width;
|
||||||
|
}
|
||||||
|
offset.height = rect.origin.y - mouseLocation.y;
|
||||||
|
offset.width = rect.origin.x - mouseLocation.x;
|
||||||
|
|
||||||
|
window = [[NSWindow alloc] initWithContentRect: rect
|
||||||
|
styleMask: NSBorderlessWindowMask
|
||||||
|
backing: NSBackingStoreRetained
|
||||||
|
defer: YES];
|
||||||
|
|
||||||
window = [[NSWindow alloc] initWithContentRect: windowRect
|
|
||||||
styleMask: NSBorderlessWindowMask
|
|
||||||
backing: NSBackingStoreRetained
|
|
||||||
defer: YES];
|
|
||||||
color
|
color
|
||||||
= [NSColor colorWithDeviceRed: 1.0 green: 1.0 blue: 0.90 alpha: 1.0];
|
= [NSColor colorWithDeviceRed: 1.0 green: 1.0 blue: 0.90 alpha: 1.0];
|
||||||
[window setBackgroundColor: color];
|
[window setBackgroundColor: color];
|
||||||
|
|
|
@ -4351,10 +4351,13 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
|
|
||||||
- (void) setToolTip: (NSString *)string
|
- (void) setToolTip: (NSString *)string
|
||||||
{
|
{
|
||||||
GSToolTips *tt = [GSToolTips tipsForView: self];
|
if (_rFlags.has_tooltips == 1 || [string length] > 0)
|
||||||
|
{
|
||||||
|
GSToolTips *tt = [GSToolTips tipsForView: self];
|
||||||
|
|
||||||
_rFlags.has_tooltips = 1;
|
_rFlags.has_tooltips = 1;
|
||||||
[tt setToolTip: string];
|
[tt setToolTip: string];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) toolTip
|
- (NSString *) toolTip
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue