force entire window redraw?
force entire window redraw?
- Subject: force entire window redraw?
- From: Michael Hanna <email@hidden>
- Date: Tue, 28 Sep 2004 16:25:46 -0400
Hi, I'm performing a short dark "flash" on my NSWindow, but when I
restore the original cached image, it doesn't completely return to its
original state:
http://www.siddha.ca/~tao/darkened.jpg
any ideas on how to force it to return completely?
here's my code:
~~~~
-(void)doSignal
{
[...............]
if([defaults boolForKey:TAOFlashWindowKey] == YES)
{
NSTimer *flashTimer;
NSView * flashView = [myWindow contentView];
NSRect theRect = [flashView bounds];
NSData * viewData = [flashView dataWithPDFInsideRect:[flashView
bounds]];
NSImage * theImage = [[NSImage alloc] initWithData:viewData];
[myWindow cacheImageInRect:theRect];
[flashView lockFocus]; // draw onto the contentView
[[NSColor colorWithDeviceWhite:0.0f alpha:0.8f] set];
[theImage compositeToPoint:NSMakePoint(0.0, 0.0) fromRect:theRect
operation:NSCompositeSourceOver];
NSRectFillUsingOperation(theRect,NSCompositeSourceAtop);
[flashView unlockFocus];
[myWindow flushWindow]; // draw darkened image
// add a slight delay
flashTimer = [NSTimer timerWithTimeInterval:1 target:self
selector:@selector(darkenDelay:) userInfo:nil repeats: NO];
[[NSRunLoop currentRunLoop] addTimer:theTimer
forMode:NSEventTrackingRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer:theTimer
forMode:NSDefaultRunLoopMode];
[myWindow setViewsNeedDisplay:YES];
[theImage release];
}
}
- (void)darkenDelay
{
[myWindow restoreCachedImage];
[myWindow flushWindow]; // draw undarkened image
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden