Added wxDC::CreateGraphicsContext and implemented it for a few DCs

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53344 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2008-04-25 11:05:16 +00:00
parent 4c7b80fb91
commit 2b44ffc0e7
11 changed files with 99 additions and 0 deletions

View File

@@ -42,6 +42,11 @@ class WXDLLIMPEXP_FWD_CORE wxMemoryDC;
class WXDLLIMPEXP_FWD_CORE wxPrinterDC; class WXDLLIMPEXP_FWD_CORE wxPrinterDC;
class WXDLLIMPEXP_FWD_CORE wxPrintData; class WXDLLIMPEXP_FWD_CORE wxPrintData;
#if wxUSE_GRAPHICS_CONTEXT
class WXDLLIMPEXP_FWD_CORE wxGraphicsContext;
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxDrawObject helper class // wxDrawObject helper class
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -182,6 +187,15 @@ public:
virtual bool CanDrawBitmap() const = 0; virtual bool CanDrawBitmap() const = 0;
virtual bool CanGetTextExtent() const = 0; virtual bool CanGetTextExtent() const = 0;
// get graphics context from
#if wxUSE_GRAPHICS_CONTEXT
virtual wxGraphicsContext* CreateGraphicsContext()
{
return NULL;
}
#endif
// query dimension, colour deps, resolution // query dimension, colour deps, resolution
virtual void DoGetSize(int *width, int *height) const = 0; virtual void DoGetSize(int *width, int *height) const = 0;
@@ -620,6 +634,11 @@ public:
bool IsOk() const bool IsOk() const
{ return m_pimpl && m_pimpl->IsOk(); } { return m_pimpl && m_pimpl->IsOk(); }
#if wxUSE_GRAPHICS_CONTEXT
wxGraphicsContext* CreateGraphicsContext()
{ return m_pimpl->CreateGraphicsContext(); }
#endif
// query capabilities // query capabilities
bool CanDrawBitmap() const bool CanDrawBitmap() const

View File

@@ -28,6 +28,10 @@ public:
virtual ~wxWindowDCImpl(); virtual ~wxWindowDCImpl();
#if wxUSE_GRAPHICS_CONTEXT
virtual wxGraphicsContext* CreateGraphicsContext();
#endif
virtual bool CanDrawBitmap() const { return true; } virtual bool CanDrawBitmap() const { return true; }
virtual bool CanGetTextExtent() const { return true; } virtual bool CanGetTextExtent() const { return true; }

View File

@@ -26,6 +26,10 @@ public:
virtual ~wxMemoryDCImpl(); virtual ~wxMemoryDCImpl();
#if wxUSE_GRAPHICS_CONTEXT
virtual wxGraphicsContext* CreateGraphicsContext();
#endif
// these get reimplemented for mono-bitmaps to behave // these get reimplemented for mono-bitmaps to behave
// more like their Win32 couterparts. They now interpret // more like their Win32 couterparts. They now interpret
// wxWHITE, wxWHITE_BRUSH and wxWHITE_PEN as drawing 0 // wxWHITE, wxWHITE_BRUSH and wxWHITE_PEN as drawing 0

View File

@@ -227,6 +227,10 @@ public:
bool Ok() const { return IsOk(); } bool Ok() const { return IsOk(); }
bool IsOk() const; bool IsOk() const;
#if wxUSE_GRAPHICS_CONTEXT
virtual wxGraphicsContext* CreateGraphicsContext();
#endif
bool CanDrawBitmap() const { return true; } bool CanDrawBitmap() const { return true; }
void Clear(); void Clear();
void SetFont( const wxFont& font ); void SetFont( const wxFont& font );

View File

@@ -43,6 +43,10 @@ public:
// Create a DC corresponding to the whole window // Create a DC corresponding to the whole window
wxWindowDCImpl( wxDC *owner, wxWindow *win ); wxWindowDCImpl( wxDC *owner, wxWindow *win );
#if wxUSE_GRAPHICS_CONTEXT
virtual wxGraphicsContext* CreateGraphicsContext();
#endif
virtual void DoGetSize(int *width, int *height) const; virtual void DoGetSize(int *width, int *height) const;
protected: protected:

View File

@@ -22,6 +22,10 @@ public:
wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap ); wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap );
wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ); // Create compatible DC wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ); // Create compatible DC
#if wxUSE_GRAPHICS_CONTEXT
virtual wxGraphicsContext* CreateGraphicsContext();
#endif
// override some base class virtuals // override some base class virtuals
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoGetSize(int* width, int* height) const; virtual void DoGetSize(int* width, int* height) const;

View File

@@ -31,6 +31,11 @@
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#if wxUSE_GRAPHICS_CONTEXT
#include "wx/graphics.h"
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// local defines // local defines
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -365,6 +370,14 @@ wxWindowDCImpl::~wxWindowDCImpl()
pango_font_description_free( m_fontdesc ); pango_font_description_free( m_fontdesc );
} }
#if wxUSE_GRAPHICS_CONTEXT
wxGraphicsContext* wxWindowDCImpl::CreateGraphicsContext()
{
wxWindowDC *windowdc = (wxWindowDC*) GetOwner();
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *windowdc );
}
#endif
void wxWindowDCImpl::SetUpDC( bool isMemDC ) void wxWindowDCImpl::SetUpDC( bool isMemDC )
{ {
m_ok = true; m_ok = true;

View File

@@ -16,6 +16,10 @@
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#if wxUSE_GRAPHICS_CONTEXT
#include "wx/graphics.h"
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMemoryDCImpl // wxMemoryDCImpl
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -60,6 +64,14 @@ void wxMemoryDCImpl::Init()
m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) ); m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
} }
#if wxUSE_GRAPHICS_CONTEXT
wxGraphicsContext* wxMemoryDCImpl::CreateGraphicsContext()
{
wxMemoryDC *memdc = (wxMemoryDC*) GetOwner();
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *memdc );
}
#endif
void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
{ {
Destroy(); Destroy();

View File

@@ -39,6 +39,10 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gtk/gtkpagesetupunixdialog.h> #include <gtk/gtkpagesetupunixdialog.h>
#if wxUSE_GRAPHICS_CONTEXT
#include "wx/graphics.h"
#endif
#include "wx/link.h" #include "wx/link.h"
wxFORCE_LINK_THIS_MODULE(gtk_print) wxFORCE_LINK_THIS_MODULE(gtk_print)
@@ -1155,6 +1159,13 @@ bool wxGtkPrinterDCImpl::IsOk() const
return m_gpc != NULL; return m_gpc != NULL;
} }
#if wxUSE_GRAPHICS_CONTEXT
wxGraphicsContext* wxGtkPrinterDCImpl::CreateGraphicsContext()
{
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeContext( (void*) m_cairo );
}
#endif
bool wxGtkPrinterDCImpl::DoFloodFill(wxCoord WXUNUSED(x1), bool wxGtkPrinterDCImpl::DoFloodFill(wxCoord WXUNUSED(x1),
wxCoord WXUNUSED(y1), wxCoord WXUNUSED(y1),
const wxColour& WXUNUSED(col), const wxColour& WXUNUSED(col),

View File

@@ -33,6 +33,10 @@
#include "wx/window.h" #include "wx/window.h"
#endif #endif
#if wxUSE_GRAPHICS_CONTEXT
#include "wx/graphics.h"
#endif
#include "wx/msw/private.h" #include "wx/msw/private.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -118,6 +122,14 @@ void wxWindowDCImpl::InitDC()
#endif #endif
} }
#if wxUSE_GRAPHICS_CONTEXT
wxGraphicsContext* wxWindowDCImpl::CreateGraphicsContext()
{
wxWindowDC *windowdc = (wxWindowDC*) GetOwner();
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *windowdc );
}
#endif
void wxWindowDCImpl::DoGetSize(int *width, int *height) const void wxWindowDCImpl::DoGetSize(int *width, int *height) const
{ {
wxCHECK_RET( m_window, _T("wxWindowDCImpl without a window?") ); wxCHECK_RET( m_window, _T("wxWindowDCImpl without a window?") );

View File

@@ -32,6 +32,10 @@
#include "wx/log.h" #include "wx/log.h"
#endif #endif
#if wxUSE_GRAPHICS_CONTEXT
#include "wx/graphics.h"
#endif
#include "wx/msw/private.h" #include "wx/msw/private.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -78,6 +82,14 @@ void wxMemoryDCImpl::Init()
} }
} }
#if wxUSE_GRAPHICS_CONTEXT
wxGraphicsContext* wxMemoryDCImpl::CreateGraphicsContext()
{
wxMemoryDC *memdc = (wxMemoryDC*) GetOwner();
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *memdc );
}
#endif
bool wxMemoryDCImpl::CreateCompatible(wxDC *dc) bool wxMemoryDCImpl::CreateCompatible(wxDC *dc)
{ {
wxDCImpl *impl = dc ? dc->GetImpl() : NULL ; wxDCImpl *impl = dc ? dc->GetImpl() : NULL ;