--- NSWindow.m.org	Tue Jul  9 18:32:31 2002
+++ NSWindow.m	Tue Jul  9 19:48:40 2002
@@ -68,6 +68,7 @@
 #include <AppKit/NSHelpManager.h>
 #include <AppKit/NSGraphics.h>
 #include <AppKit/GSDisplayServer.h>
+#include <AppKit/NSCachedImageRep.h>
 
 BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
 
@@ -622,6 +623,7 @@
   TEST_RELEASE(_rectsBeingDrawn);
   TEST_RELEASE(_initialFirstResponder);
   TEST_RELEASE(_defaultButtonCell);
+  TEST_RELEASE(_cachedImage);
   RELEASE(_screen);
 
   /*
@@ -1735,6 +1737,7 @@
   [_wv display];
   [self enableFlushWindow];
   [self flushWindowIfNeeded];
+  [self discardCachedImage];
 }
 
 - (void) displayIfNeeded
@@ -1893,17 +1896,42 @@
 
 - (void) cacheImageInRect: (NSRect)aRect
 {
-  // FIXME: This Method is missing
+  NSView *cacheView;
+  NSRect cacheRect;
+
+  aRect = NSIntegralRect(NSIntersectionRect(aRect, [_contentView frame]));
+  _cachedImageOrigin = aRect.origin;
+  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
 {
-  // FIXME: This Method is missing
+  DESTROY(_cachedImage);
 }
 
 - (void) restoreCachedImage
 {
-  // FIXME: This Method is missing
+  if (_cachedImage == nil)
+    {
+      return;
+    }
+  [_contentView lockFocus];
+  NSCopyBits([[_cachedImage window] gState], [_cachedImage rect],
+             _cachedImageOrigin);
+  [_contentView unlockFocus];
 }
 
 - (void) useOptimizedDrawing: (BOOL)flag
