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:
Marcian Lytwyn 2012-10-11 21:03:00 +00:00
parent 4c16370ff9
commit f59b23c3fe
2 changed files with 166 additions and 101 deletions

View file

@ -42,6 +42,7 @@
#import "GSToolTips.h"
#import "GSFastEnumeration.h"
@interface NSWindow (GNUstepPrivate)
+ (void) _setToolTipVisible: (GSToolTips*)t;
@ -122,15 +123,86 @@
}
@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
// Tooltip panel that will not try to become main or key
- (BOOL) canBecomeKeyWindow;
- (BOOL) canBecomeMainWindow;
- (void) setToolTipText: (NSAttributedString*)text;
@end
@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
{
return NO;
@ -143,9 +215,7 @@
@end
@interface GSToolTips (Private)
- (void) _drawText: (NSAttributedString *)text;
- (void) _endDisplay;
- (void) _timedOut: (NSTimer *)timer;
@end
@ -183,6 +253,8 @@ static BOOL restoreMouseMoved;
[window setExcludedFromWindowsMenu: YES];
[window setLevel: NSStatusWindowLevel];
[window setAutodisplay: NO];
[window setOneShot: YES];
[window setTitle:@"GSToolTips"];
}
+ (void) removeTipsForView: (NSView*)aView
@ -505,26 +577,6 @@ static BOOL restoreMouseMoved;
@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
{
if (isOpening)
@ -547,7 +599,11 @@ static BOOL restoreMouseMoved;
}
if (window != nil)
{
#if 0
[window close];
#else
[window orderOut:self];
#endif
}
if (restoreMouseMoved == YES)
{
@ -605,6 +661,9 @@ static BOOL restoreMouseMoved;
[self _endDisplay];
}
if ((toolTipString == nil) || ([toolTipString length] == 0))
return;
size = [[NSUserDefaults standardUserDefaults]
floatForKey: @"NSToolTipsFontSize"];
@ -659,11 +718,9 @@ static BOOL restoreMouseMoved;
offset.width = rect.origin.x - mouseLocation.x;
isOpening = YES;
[window setToolTipText:toolTipText];
[window setFrame:rect display:NO];
[window orderFront: nil];
[window display];
[self _drawText: toolTipText];
[window flushWindow];
[window orderFront:self];
isOpening = NO;
RELEASE(toolTipText);

View file

@ -1750,6 +1750,7 @@ many times.
{
GSDisplayServer *srv = GSServerForWindow(self);
BOOL display = NO;
BOOL redisplay = NO;
if (YES == [[NSUserDefaults standardUserDefaults]
boolForKey: @"GSBackgroundApp"])
@ -1790,6 +1791,8 @@ many times.
[self _initBackendWindow];
display = YES;
}
else
redisplay = (_f.visible == NO);
}
/* If a hide on deactivate window is explicitly ordered in or out while
@ -1800,11 +1803,11 @@ many times.
[NSApp _setWindow: self inactive: NO];
}
#if 1
// Draw content before backend window ordering
if (display)
[_wv display];
else if (place != NSWindowOut)
[_wv displayIfNeeded];
[self display];
#endif
/* The backend will keep us below the current key window unless we
force it not too */
@ -1815,7 +1818,8 @@ many times.
otherWin = -1;
[srv orderwindow: place : otherWin : _windowNum];
if (display)
if (redisplay)
[self display];
if (place != NSWindowOut)
@ -1854,6 +1858,11 @@ many times.
[srv setinputfocus: _windowNum];
}
_f.visible = YES;
#if 1
[self displayIfNeeded];
#else
// [self display];
#endif
}
else if ([self isOneShot])
{
@ -2370,7 +2379,7 @@ many times.
- (void) display
{
if (_gstate == 0 || _f.visible == NO)
if (_gstate == 0)
return;
[_wv display];
@ -2385,9 +2394,7 @@ many times.
if (_f.views_need_display)
{
[_wv displayIfNeeded];
[self discardCachedImage];
_f.views_need_display = NO;
[self display];
}
}
@ -5695,3 +5702,4 @@ NSWindow* GSWindowWithNumber(int num)
return (NSWindow*)NSMapGet(windowmaps, (void*)(intptr_t)num);
return nil;
}