Forward port of r60190 (wxMSW Cairo support) to trunk.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62681 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -611,6 +611,7 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    static wxGraphicsRenderer* GetDefaultRenderer();
 | 
					    static wxGraphicsRenderer* GetDefaultRenderer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static wxGraphicsRenderer* GetCairoRenderer();
 | 
				
			||||||
    // Context
 | 
					    // Context
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0;
 | 
					    virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -666,6 +666,18 @@
 | 
				
			|||||||
#define wxUSE_GRAPHICS_CONTEXT 0
 | 
					#define wxUSE_GRAPHICS_CONTEXT 0
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Enable the new wxCairoContext classes for an advanced
 | 
				
			||||||
 | 
					// 2D drawing API.  (Still somewhat experimental)
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Please note that you will need to link with Cairo for this to work.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Default is 0
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Recommended setting: 1
 | 
				
			||||||
 | 
					#ifndef wxUSE_CAIRO
 | 
				
			||||||
 | 
					#define wxUSE_CAIRO 0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ----------------------------------------------------------------------------
 | 
					// ----------------------------------------------------------------------------
 | 
				
			||||||
// Individual GUI controls
 | 
					// Individual GUI controls
 | 
				
			||||||
// ----------------------------------------------------------------------------
 | 
					// ----------------------------------------------------------------------------
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -172,7 +172,15 @@ wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) :
 | 
				
			|||||||
   wxDCImpl( owner )
 | 
					   wxDCImpl( owner )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Init();
 | 
					    Init();
 | 
				
			||||||
    SetGraphicsContext( wxGraphicsContext::Create(dc) );
 | 
					    wxGraphicsContext* context;
 | 
				
			||||||
 | 
					#if wxUSE_CAIRO
 | 
				
			||||||
 | 
					    wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetCairoRenderer();
 | 
				
			||||||
 | 
					    context = renderer->CreateContext(dc);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    context = wxGraphicsContext::Create(dc);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetGraphicsContext( context );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if wxUSE_PRINTING_ARCHITECTURE
 | 
					#if wxUSE_PRINTING_ARCHITECTURE
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,10 +15,11 @@
 | 
				
			|||||||
    #pragma hdrstop
 | 
					    #pragma hdrstop
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if wxUSE_GRAPHICS_CONTEXT
 | 
					#include "wx/cairo.h"
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "wx/graphics.h"
 | 
					#include "wx/graphics.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if wxUSE_GRAPHICS_CONTEXT && wxUSE_CAIRO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef WX_PRECOMP
 | 
					#ifndef WX_PRECOMP
 | 
				
			||||||
    #include "wx/bitmap.h"
 | 
					    #include "wx/bitmap.h"
 | 
				
			||||||
    #include "wx/icon.h"
 | 
					    #include "wx/icon.h"
 | 
				
			||||||
@@ -60,6 +61,10 @@ using namespace std;
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <cairo.h>
 | 
					#include <cairo.h>
 | 
				
			||||||
 | 
					#ifdef __WXMSW__
 | 
				
			||||||
 | 
					#include <cairo-win32.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __WXGTK__
 | 
					#ifdef __WXGTK__
 | 
				
			||||||
#include <gtk/gtk.h>
 | 
					#include <gtk/gtk.h>
 | 
				
			||||||
#include "wx/fontutil.h"
 | 
					#include "wx/fontutil.h"
 | 
				
			||||||
@@ -284,6 +289,9 @@ private :
 | 
				
			|||||||
    cairo_font_slant_t m_slant;
 | 
					    cairo_font_slant_t m_slant;
 | 
				
			||||||
    cairo_font_weight_t m_weight;
 | 
					    cairo_font_weight_t m_weight;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef __WXMSW__
 | 
				
			||||||
 | 
					    wxCairoContext( wxGraphicsRenderer* renderer, HDC context );
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class wxCairoBitmapData : public wxGraphicsObjectRefData
 | 
					class wxCairoBitmapData : public wxGraphicsObjectRefData
 | 
				
			||||||
@@ -331,6 +339,9 @@ public:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual void Clip( const wxRegion ®ion );
 | 
					    virtual void Clip( const wxRegion ®ion );
 | 
				
			||||||
 | 
					#ifdef __WXMSW__
 | 
				
			||||||
 | 
					    cairo_surface_t* m_mswSurface;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // clips drawings to the rect
 | 
					    // clips drawings to the rect
 | 
				
			||||||
    virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
 | 
					    virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
 | 
				
			||||||
@@ -1227,6 +1238,18 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, GdkDrawable *drawa
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __WXMSW__
 | 
				
			||||||
 | 
					wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, HDC handle )
 | 
				
			||||||
 | 
					: wxGraphicsContext(renderer)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    m_mswSurface = cairo_win32_surface_create(handle);
 | 
				
			||||||
 | 
					    m_context = cairo_create(m_mswSurface);
 | 
				
			||||||
 | 
					    PushState();
 | 
				
			||||||
 | 
					    PushState();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, cairo_t *context )
 | 
					wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, cairo_t *context )
 | 
				
			||||||
: wxGraphicsContext(renderer)
 | 
					: wxGraphicsContext(renderer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -1258,9 +1281,17 @@ wxCairoContext::~wxCairoContext()
 | 
				
			|||||||
    if ( m_context )
 | 
					    if ( m_context )
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        PopState();
 | 
					        PopState();
 | 
				
			||||||
 | 
					#ifdef __WXMSW__
 | 
				
			||||||
 | 
					    m_mswSurface = cairo_win32_surface_create((HDC)window->GetHandle());
 | 
				
			||||||
 | 
					    m_context = cairo_create(m_mswSurface);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
        PopState();
 | 
					        PopState();
 | 
				
			||||||
        cairo_destroy(m_context);
 | 
					        cairo_destroy(m_context);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					#ifdef __WXMSW__
 | 
				
			||||||
 | 
					    if ( m_mswSurface )
 | 
				
			||||||
 | 
					        cairo_surface_destroy(m_mswSurface);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wxCairoContext::Init(cairo_t *context)
 | 
					void wxCairoContext::Init(cairo_t *context)
 | 
				
			||||||
@@ -1768,7 +1799,12 @@ wxGraphicsContext * wxCairoRenderer::CreateContext( const wxPrinterDC& dc)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeContext( void * context )
 | 
					wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeContext( void * context )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					#if __WXMSW__
 | 
				
			||||||
 | 
					    return new wxCairoContext(this,(HDC)context);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#if __WXGTK__
 | 
				
			||||||
    return new wxCairoContext(this,(cairo_t*)context);
 | 
					    return new wxCairoContext(this,(cairo_t*)context);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1913,4 +1949,15 @@ wxCairoRenderer::CreateSubBitmap(const wxGraphicsBitmap& WXUNUSED(bitmap),
 | 
				
			|||||||
    return wxNullGraphicsBitmap;
 | 
					    return wxNullGraphicsBitmap;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif  // wxUSE_GRAPHICS_CONTEXT
 | 
					#endif  // wxUSE_GRAPHICS_CONTEXT && wxUSE_CAIRO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if wxUSE_GRAPHICS_CONTEXT
 | 
				
			||||||
 | 
					wxGraphicsRenderer* wxGraphicsRenderer::GetCairoRenderer()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if wxUSE_CAIRO
 | 
				
			||||||
 | 
					    return &gs_cairoGraphicsRenderer;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    return NULL;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user