wxWindow *GetWindow() const { return m_window; }
   protected :
     virtual void DoGetSize( int *width, int *height ) const;
-    virtual wxBitmap DoGetAsBitmap() const; 
+    virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const; 
     wxWindow     *m_window;
 #if wxMAC_USE_CORE_GRAPHICS
        bool            m_release;
 
     if ( cg == NULL )
     {
         SetGraphicsContext( wxGraphicsContext::Create( window ) ) ;
-        SetDeviceOrigin( x, y );
     }
     else
     {
 #endif
 }
 
-wxBitmap wxWindowDC::DoGetAsBitmap() const
+wxBitmap wxWindowDC::DoGetAsBitmap(const wxRect *subrect) const
 {
     ControlRef handle = (ControlRef) m_window->GetHandle(); 
     if ( !handle )
     
     HIViewCreateOffscreenImage( handle, 0, &rect, &image);
     
-    int width = rect.size.width;
-    int height = rect.size.height; 
+    
+    int width = subrect != NULL ? subrect->width : rect.size.width;
+    int height = subrect !=  NULL ? subrect->height : rect.size.height ; 
     
     bytesPerRow = ( ( width * 8 * 4 + 7 ) / 8 );
 
     data = calloc( 1, bytesPerRow * height );
     context = CGBitmapContextCreate( data, width, height, 8, bytesPerRow, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedFirst );
     
+    if ( subrect )
+        rect = CGRectOffset( rect, -subrect->x, -subrect->y ) ;
     CGContextDrawImage( context, rect, image );
 
     unsigned char* buffer = (unsigned char*) data;