mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 17:31:18 +00:00
TEMPORARY updaste for cairo and tooltips
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@35669 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4c16370ff9
commit
f59b23c3fe
2 changed files with 166 additions and 101 deletions
|
@ -42,6 +42,7 @@
|
||||||
#import "GSToolTips.h"
|
#import "GSToolTips.h"
|
||||||
#import "GSFastEnumeration.h"
|
#import "GSFastEnumeration.h"
|
||||||
|
|
||||||
|
|
||||||
@interface NSWindow (GNUstepPrivate)
|
@interface NSWindow (GNUstepPrivate)
|
||||||
|
|
||||||
+ (void) _setToolTipVisible: (GSToolTips*)t;
|
+ (void) _setToolTipVisible: (GSToolTips*)t;
|
||||||
|
@ -122,15 +123,86 @@
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface GSTTView : NSView
|
||||||
|
{
|
||||||
|
NSAttributedString *_text;
|
||||||
|
}
|
||||||
|
- (void)setText: (NSAttributedString *)text;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation GSTTView
|
||||||
|
- (id)initWithFrame:(NSRect)frameRect
|
||||||
|
{
|
||||||
|
self = [super initWithFrame:frameRect];
|
||||||
|
if (self)
|
||||||
|
{
|
||||||
|
[self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setText:(NSAttributedString *)text
|
||||||
|
{
|
||||||
|
if (_text != text)
|
||||||
|
{
|
||||||
|
ASSIGN(_text, text);
|
||||||
|
[self setNeedsDisplay: YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)drawRect:(id)dirtyRect
|
||||||
|
{
|
||||||
|
if (_text)
|
||||||
|
{
|
||||||
|
NSRect bounds = [self bounds];
|
||||||
|
NSRect frame = [self frame];
|
||||||
|
NSRect textRect = NSInsetRect(frame, 2, 2);
|
||||||
|
|
||||||
|
#if 1 // THIS DOESN'T WORK ON winlib - 2 SIDES OF THE RECT ARE MISSING!!!
|
||||||
|
// WILL DEBUG THIS AFTER CHECKING IN A WORKING VERSION
|
||||||
|
NSBezierPath *path = [NSBezierPath bezierPathWithRect:bounds];
|
||||||
|
[[NSColor blackColor] setStroke];
|
||||||
|
[path stroke];
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
NSRectEdge sides[] = {NSMinXEdge, NSMaxYEdge, NSMaxXEdge, NSMinYEdge};
|
||||||
|
NSColor *black = [NSColor blackColor];
|
||||||
|
NSColor *colors[] = {black, black, black, black};
|
||||||
|
NSDrawColorTiledRects(bounds, bounds, sides, colors, 4);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
[_text drawInRect: textRect];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@interface GSTTPanel : NSPanel
|
@interface GSTTPanel : NSPanel
|
||||||
// Tooltip panel that will not try to become main or key
|
// Tooltip panel that will not try to become main or key
|
||||||
- (BOOL) canBecomeKeyWindow;
|
- (BOOL) canBecomeKeyWindow;
|
||||||
- (BOOL) canBecomeMainWindow;
|
- (BOOL) canBecomeMainWindow;
|
||||||
|
- (void) setToolTipText: (NSAttributedString*)text;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation GSTTPanel
|
@implementation GSTTPanel
|
||||||
|
|
||||||
|
- (id) initWithContentRect: (NSRect)contentRect
|
||||||
|
styleMask: (unsigned int)aStyle
|
||||||
|
backing: (NSBackingStoreType)bufferingType
|
||||||
|
defer: (BOOL)flag;
|
||||||
|
{
|
||||||
|
self = [super initWithContentRect:contentRect styleMask:aStyle backing:bufferingType defer:flag];
|
||||||
|
if (self)
|
||||||
|
{
|
||||||
|
[self setContentView:[[[GSTTView alloc] initWithFrame: contentRect] autorelease]];
|
||||||
|
}
|
||||||
|
return(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setToolTipText:(NSAttributedString *)text
|
||||||
|
{
|
||||||
|
[(GSTTView*)([self contentView]) setText:text];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) canBecomeKeyWindow
|
- (BOOL) canBecomeKeyWindow
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -143,9 +215,7 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@interface GSToolTips (Private)
|
@interface GSToolTips (Private)
|
||||||
- (void) _drawText: (NSAttributedString *)text;
|
|
||||||
- (void) _endDisplay;
|
- (void) _endDisplay;
|
||||||
- (void) _timedOut: (NSTimer *)timer;
|
- (void) _timedOut: (NSTimer *)timer;
|
||||||
@end
|
@end
|
||||||
|
@ -183,6 +253,8 @@ static BOOL restoreMouseMoved;
|
||||||
[window setExcludedFromWindowsMenu: YES];
|
[window setExcludedFromWindowsMenu: YES];
|
||||||
[window setLevel: NSStatusWindowLevel];
|
[window setLevel: NSStatusWindowLevel];
|
||||||
[window setAutodisplay: NO];
|
[window setAutodisplay: NO];
|
||||||
|
[window setOneShot: YES];
|
||||||
|
[window setTitle:@"GSToolTips"];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) removeTipsForView: (NSView*)aView
|
+ (void) removeTipsForView: (NSView*)aView
|
||||||
|
@ -505,26 +577,6 @@ static BOOL restoreMouseMoved;
|
||||||
|
|
||||||
@implementation GSToolTips (Private)
|
@implementation GSToolTips (Private)
|
||||||
|
|
||||||
- (void) _drawText: (NSAttributedString *)text
|
|
||||||
{
|
|
||||||
NSRectEdge sides[] = {NSMinXEdge, NSMaxYEdge, NSMaxXEdge, NSMinYEdge};
|
|
||||||
NSColor *black = [NSColor blackColor];
|
|
||||||
NSColor *colors[] = {black, black, black, black};
|
|
||||||
NSRect bounds = [[window contentView] bounds];
|
|
||||||
NSRect textRect;
|
|
||||||
|
|
||||||
textRect = [window frame];
|
|
||||||
textRect.origin.x = 2;
|
|
||||||
textRect.origin.y = -2;
|
|
||||||
|
|
||||||
[[window contentView] lockFocus];
|
|
||||||
|
|
||||||
[text drawInRect: textRect];
|
|
||||||
NSDrawColorTiledRects(bounds, bounds, sides, colors, 4);
|
|
||||||
|
|
||||||
[[window contentView] unlockFocus];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _endDisplay
|
- (void) _endDisplay
|
||||||
{
|
{
|
||||||
if (isOpening)
|
if (isOpening)
|
||||||
|
@ -547,7 +599,11 @@ static BOOL restoreMouseMoved;
|
||||||
}
|
}
|
||||||
if (window != nil)
|
if (window != nil)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
[window close];
|
||||||
|
#else
|
||||||
[window orderOut:self];
|
[window orderOut:self];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (restoreMouseMoved == YES)
|
if (restoreMouseMoved == YES)
|
||||||
{
|
{
|
||||||
|
@ -605,6 +661,9 @@ static BOOL restoreMouseMoved;
|
||||||
[self _endDisplay];
|
[self _endDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((toolTipString == nil) || ([toolTipString length] == 0))
|
||||||
|
return;
|
||||||
|
|
||||||
size = [[NSUserDefaults standardUserDefaults]
|
size = [[NSUserDefaults standardUserDefaults]
|
||||||
floatForKey: @"NSToolTipsFontSize"];
|
floatForKey: @"NSToolTipsFontSize"];
|
||||||
|
|
||||||
|
@ -659,11 +718,9 @@ static BOOL restoreMouseMoved;
|
||||||
offset.width = rect.origin.x - mouseLocation.x;
|
offset.width = rect.origin.x - mouseLocation.x;
|
||||||
|
|
||||||
isOpening = YES;
|
isOpening = YES;
|
||||||
|
[window setToolTipText:toolTipText];
|
||||||
[window setFrame:rect display:NO];
|
[window setFrame:rect display:NO];
|
||||||
[window orderFront: nil];
|
[window orderFront:self];
|
||||||
[window display];
|
|
||||||
[self _drawText: toolTipText];
|
|
||||||
[window flushWindow];
|
|
||||||
isOpening = NO;
|
isOpening = NO;
|
||||||
|
|
||||||
RELEASE(toolTipText);
|
RELEASE(toolTipText);
|
||||||
|
|
|
@ -1750,6 +1750,7 @@ many times.
|
||||||
{
|
{
|
||||||
GSDisplayServer *srv = GSServerForWindow(self);
|
GSDisplayServer *srv = GSServerForWindow(self);
|
||||||
BOOL display = NO;
|
BOOL display = NO;
|
||||||
|
BOOL redisplay = NO;
|
||||||
|
|
||||||
if (YES == [[NSUserDefaults standardUserDefaults]
|
if (YES == [[NSUserDefaults standardUserDefaults]
|
||||||
boolForKey: @"GSBackgroundApp"])
|
boolForKey: @"GSBackgroundApp"])
|
||||||
|
@ -1790,6 +1791,8 @@ many times.
|
||||||
[self _initBackendWindow];
|
[self _initBackendWindow];
|
||||||
display = YES;
|
display = YES;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
redisplay = (_f.visible == NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If a hide on deactivate window is explicitly ordered in or out while
|
/* If a hide on deactivate window is explicitly ordered in or out while
|
||||||
|
@ -1800,11 +1803,11 @@ many times.
|
||||||
[NSApp _setWindow: self inactive: NO];
|
[NSApp _setWindow: self inactive: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
// Draw content before backend window ordering
|
// Draw content before backend window ordering
|
||||||
if (display)
|
if (display)
|
||||||
[_wv display];
|
[self display];
|
||||||
else if (place != NSWindowOut)
|
#endif
|
||||||
[_wv displayIfNeeded];
|
|
||||||
|
|
||||||
/* The backend will keep us below the current key window unless we
|
/* The backend will keep us below the current key window unless we
|
||||||
force it not too */
|
force it not too */
|
||||||
|
@ -1815,7 +1818,8 @@ many times.
|
||||||
otherWin = -1;
|
otherWin = -1;
|
||||||
|
|
||||||
[srv orderwindow: place : otherWin : _windowNum];
|
[srv orderwindow: place : otherWin : _windowNum];
|
||||||
if (display)
|
|
||||||
|
if (redisplay)
|
||||||
[self display];
|
[self display];
|
||||||
|
|
||||||
if (place != NSWindowOut)
|
if (place != NSWindowOut)
|
||||||
|
@ -1854,6 +1858,11 @@ many times.
|
||||||
[srv setinputfocus: _windowNum];
|
[srv setinputfocus: _windowNum];
|
||||||
}
|
}
|
||||||
_f.visible = YES;
|
_f.visible = YES;
|
||||||
|
#if 1
|
||||||
|
[self displayIfNeeded];
|
||||||
|
#else
|
||||||
|
// [self display];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if ([self isOneShot])
|
else if ([self isOneShot])
|
||||||
{
|
{
|
||||||
|
@ -2370,7 +2379,7 @@ many times.
|
||||||
|
|
||||||
- (void) display
|
- (void) display
|
||||||
{
|
{
|
||||||
if (_gstate == 0 || _f.visible == NO)
|
if (_gstate == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[_wv display];
|
[_wv display];
|
||||||
|
@ -2385,9 +2394,7 @@ many times.
|
||||||
|
|
||||||
if (_f.views_need_display)
|
if (_f.views_need_display)
|
||||||
{
|
{
|
||||||
[_wv displayIfNeeded];
|
[self display];
|
||||||
[self discardCachedImage];
|
|
||||||
_f.views_need_display = NO;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5695,3 +5702,4 @@ NSWindow* GSWindowWithNumber(int num)
|
||||||
return (NSWindow*)NSMapGet(windowmaps, (void*)(intptr_t)num);
|
return (NSWindow*)NSMapGet(windowmaps, (void*)(intptr_t)num);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue