adding overlay implementation for core graphics

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41912 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2006-10-10 19:09:01 +00:00
parent d72e4d138a
commit e412f8928f
2 changed files with 43 additions and 2 deletions

View File

@ -20,6 +20,10 @@
#include "wx/listctrl.h"
#include "wx/log.h"
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
#include "wx/dc.h"
#endif
/*
To use this class, create a wxDragImage when you start dragging, for example:
@ -158,7 +162,12 @@ public:
// For efficiency, tell wxGenericDragImage to use a bitmap that's already
// created (e.g. from last drag)
void SetBackingBitmap(wxBitmap* bitmap) { m_pBackingBitmap = bitmap; }
void SetBackingBitmap(wxBitmap* bitmap) {
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
#else
m_pBackingBitmap = bitmap;
#endif
}
// Operations
////////////////////////////////////////////////////////////////////////////
@ -242,12 +251,17 @@ protected:
wxWindow* m_window;
wxDC* m_windowDC;
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
wxOverlay m_overlay;
wxDCOverlay* m_dcOverlay;
#else
// Stores the window contents while we're dragging the image around
wxBitmap m_backingBitmap;
wxBitmap* m_pBackingBitmap; // Pointer to existing backing bitmap
// (pass to wxGenericDragImage as an efficiency measure)
// A temporary bitmap for repairing/redrawing
wxBitmap m_repairBitmap;
#endif
wxRect m_boundingRect;
bool m_fullScreen;

View File

@ -72,7 +72,11 @@ void wxGenericDragImage::Init()
m_windowDC = (wxDC*) NULL;
m_window = (wxWindow*) NULL;
m_fullScreen = false;
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
m_dcOverlay = NULL;
#else
m_pBackingBitmap = (wxBitmap*) NULL;
#endif
}
#if WXWIN_COMPATIBILITY_2_6
@ -284,10 +288,14 @@ bool wxGenericDragImage::BeginDrag(const wxPoint& hotspot,
}
}
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
// nothing to setup here
#else
wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap);
if (!backing->Ok() || (backing->GetWidth() < clientSize.x || backing->GetHeight() < clientSize.y))
(*backing) = wxBitmap(clientSize.x, clientSize.y);
#endif
if (!m_fullScreen)
{
@ -350,12 +358,20 @@ bool wxGenericDragImage::EndDrag()
if (m_windowDC)
{
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
m_overlay.Reset();
#else
m_windowDC->DestroyClippingRegion();
#endif
delete m_windowDC;
m_windowDC = (wxDC*) NULL;
}
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
// nothing to do for overlays
#else
m_repairBitmap = wxNullBitmap;
#endif
return true;
}
@ -397,6 +413,9 @@ bool wxGenericDragImage::Show()
// This is where we restore the backing bitmap, in case
// something has changed on the window.
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
// overlay will be set up in the drawing routine
#else
wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap);
wxMemoryDC memDC;
memDC.SelectObject(* backing);
@ -405,6 +424,7 @@ bool wxGenericDragImage::Show()
//memDC.Blit(0, 0, m_boundingRect.width, m_boundingRect.height, m_windowDC, m_boundingRect.x, m_boundingRect.y);
memDC.SelectObject(wxNullBitmap);
#endif
RedrawImage(m_position - m_offset, m_position - m_offset, false, true);
}
@ -446,6 +466,13 @@ bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, const wxPoint& newPo
if (!m_windowDC)
return false;
#if defined(wxMAC_USE_CORE_GRAPHICS) && wxMAC_USE_CORE_GRAPHICS
wxDCOverlay dcoverlay( m_overlay, (wxWindowDC*) m_windowDC ) ;
if ( eraseOld )
dcoverlay.Clear() ;
if (drawNew)
DoDrawImage(*m_windowDC, newPos);
#else
wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap);
if (!backing->Ok())
return false;
@ -511,7 +538,7 @@ bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, const wxPoint& newPo
memDCTemp.SelectObject(wxNullBitmap);
memDC.SelectObject(wxNullBitmap);
#endif
return true;
}