bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSWindow (cacheImageInRect) & Puzzle.


From: Marko Riedel
Subject: NSWindow (cacheImageInRect) & Puzzle.
Date: Tue, 16 Jul 2002 15:58:29 +0200 (CEST)

Hi all,

NSWindow's cacheImageInRect: is now working. I applied a fix. I
believe there has to be a better way, but perhaps my patch is good
enough for now. I don't have a CVS account and someone else should
check it in. Here is the code:

- (void) cacheImageInRect: (NSRect)aRect
{
  NSView *cacheView;
  NSRect cacheRect, cframe = [_contentView frame];
  
  aRect = NSIntegralRect(NSIntersectionRect(aRect, cframe));

  _cachedImageOrigin.x = aRect.origin.x;
  _cachedImageOrigin.y = cframe.size.height - aRect.size.height - 
aRect.origin.y;


  DESTROY(_cachedImage);
  
  if (NSIsEmptyRect (aRect))
    {
      return;
    }
  
  cacheRect.origin = NSZeroPoint;
  cacheRect.size = aRect.size;
  _cachedImage = [[NSCachedImageRep alloc] initWithWindow: nil 
                                           rect: cacheRect];
  cacheView = [[_cachedImage window] contentView];
  [cacheView lockFocus];
  NSCopyBits (_gstate, aRect, NSZeroPoint);
  [cacheView unlockFocus];
}

- (void) discardCachedImage
{
  DESTROY(_cachedImage);
}

- (void) restoreCachedImage
{
  if (_cachedImage == nil)
    {
      return;
    }
  [_contentView lockFocus];
  
  NSCopyBits ([[_cachedImage window] gState], 
              [_cachedImage rect],
              _cachedImageOrigin);
  [_contentView unlockFocus];
}

I have also uploaded a new version of my Puzzle program to my GNUstep
page. There is some improvement, but not as much as I would like.

Please post feedback re. the future of "cacheImageInRect."

Best regards,

-- 
+------------------------------------------------------------+
| Marko Riedel, EDV Neue Arbeit gGmbH, mriedel@neuearbeit.de |
| http://www.geocities.com/markoriedelde/index.html          |
+------------------------------------------------------------+



reply via email to

[Prev in Thread] Current Thread [Next in Thread]