Implement wxGraphicsContext::GetSize() for Cairo.
As the implementation of this method is basically the same for all ports move it to the base class itself instead of requiring the derived classes to implement it. Now the derived classes need to fill in m_width and m_height members instead. Do fill them when creating wxGraphicsContext in Cairo version. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67359 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
cdcc1edaf2
commit
b129eaa377
@ -506,6 +506,7 @@ GTK:
|
||||
- Switch to GtkTooltip from deprecated GtkTooltips (Emilien Kia).
|
||||
- wxTLW generates wxEVT_MAXIMIZE.
|
||||
- Fix copying clipboard data to primary selection (David Hart).
|
||||
- Implement wxGraphicsContext::GetSize() (Marcin Wojdyr).
|
||||
|
||||
MSW:
|
||||
|
||||
|
@ -503,7 +503,13 @@ public:
|
||||
virtual bool SetCompositionMode(wxCompositionMode op) = 0;
|
||||
|
||||
// returns the size of the graphics context in device coordinates
|
||||
virtual void GetSize( wxDouble* width, wxDouble* height);
|
||||
void GetSize(wxDouble* width, wxDouble* height)
|
||||
{
|
||||
if ( width )
|
||||
*width = m_width;
|
||||
if ( height )
|
||||
*height = m_height;
|
||||
}
|
||||
|
||||
// returns the resolution of the graphics context in device points per inch
|
||||
virtual void GetDPI( wxDouble* dpiX, wxDouble* dpiY);
|
||||
@ -638,6 +644,9 @@ public:
|
||||
virtual bool ShouldOffset() const { return false; }
|
||||
|
||||
protected:
|
||||
// These fields must be initialized in the derived class ctors.
|
||||
wxDouble m_width,
|
||||
m_height;
|
||||
|
||||
wxGraphicsPen m_pen;
|
||||
wxGraphicsBrush m_brush;
|
||||
|
@ -575,12 +575,6 @@ wxDouble wxGraphicsContext::GetAlpha() const
|
||||
}
|
||||
#endif
|
||||
|
||||
void wxGraphicsContext::GetSize( wxDouble* width, wxDouble* height)
|
||||
{
|
||||
*width = 10000.0;
|
||||
*height = 10000.0;
|
||||
}
|
||||
|
||||
void wxGraphicsContext::GetDPI( wxDouble* dpiX, wxDouble* dpiY)
|
||||
{
|
||||
*dpiX = 72.0;
|
||||
|
@ -1189,6 +1189,10 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC&
|
||||
const wxDCImpl *impl = dc.GetImpl();
|
||||
Init( (cairo_t*) impl->GetCairoContext() );
|
||||
|
||||
wxSize sz = dc.GetSize();
|
||||
m_width = sz.x;
|
||||
m_height = sz.y;
|
||||
|
||||
wxPoint org = dc.GetDeviceOrigin();
|
||||
cairo_translate( m_context, org.x, org.y );
|
||||
|
||||
@ -1204,6 +1208,11 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC&
|
||||
wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& dc )
|
||||
: wxGraphicsContext(renderer)
|
||||
{
|
||||
int width, height;
|
||||
dc.GetSize( &width, &height );
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
|
||||
#ifdef __WXGTK20__
|
||||
wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
|
||||
Init( gdk_cairo_create( impldc->GetGDKWindow() ) );
|
||||
@ -1226,8 +1235,6 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC&
|
||||
#endif
|
||||
|
||||
#ifdef __WXMAC__
|
||||
int width, height;
|
||||
dc.GetSize( &width, &height );
|
||||
CGContextRef cgcontext = (CGContextRef)dc.GetWindow()->MacGetCGContextRef();
|
||||
cairo_surface_t* surface = cairo_quartz_surface_create_for_cg_context(cgcontext, width, height);
|
||||
Init( cairo_create( surface ) );
|
||||
@ -1238,6 +1245,11 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC&
|
||||
wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& dc )
|
||||
: wxGraphicsContext(renderer)
|
||||
{
|
||||
int width, height;
|
||||
dc.GetSize( &width, &height );
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
|
||||
#ifdef __WXGTK20__
|
||||
wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
|
||||
Init( gdk_cairo_create( impldc->GetGDKWindow() ) );
|
||||
@ -1260,8 +1272,6 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC&
|
||||
#endif
|
||||
|
||||
#ifdef __WXMAC__
|
||||
int width, height;
|
||||
dc.GetSize( &width, &height );
|
||||
CGContextRef cgcontext = (CGContextRef)dc.GetWindow()->MacGetCGContextRef();
|
||||
cairo_surface_t* surface = cairo_quartz_surface_create_for_cg_context(cgcontext, width, height);
|
||||
Init( cairo_create( surface ) );
|
||||
@ -1274,6 +1284,11 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, GdkDrawable *drawa
|
||||
: wxGraphicsContext(renderer)
|
||||
{
|
||||
Init( gdk_cairo_create( drawable ) );
|
||||
|
||||
int width, height;
|
||||
gdk_drawable_get_size( drawable, &width, &height );
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1282,9 +1297,9 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, HDC handle )
|
||||
: wxGraphicsContext(renderer)
|
||||
{
|
||||
m_mswSurface = cairo_win32_surface_create(handle);
|
||||
m_context = cairo_create(m_mswSurface);
|
||||
PushState();
|
||||
PushState();
|
||||
Init( cairo_create(m_mswSurface) );
|
||||
m_width =
|
||||
m_height = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1293,6 +1308,8 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, cairo_t *context )
|
||||
: wxGraphicsContext(renderer)
|
||||
{
|
||||
Init( context );
|
||||
m_width =
|
||||
m_height = 0;
|
||||
}
|
||||
|
||||
wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, wxWindow *window)
|
||||
@ -1312,6 +1329,10 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, wxWindow *window)
|
||||
wxASSERT_MSG( window->m_wxwindow, wxT("wxCairoContext needs a widget") );
|
||||
|
||||
Init(gdk_cairo_create(window->GTKGetDrawingWindow()));
|
||||
|
||||
wxSize sz = window->GetSize();
|
||||
m_width = sz.x;
|
||||
m_height = sz.y;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -387,9 +387,6 @@ private:
|
||||
GraphicsState m_state1;
|
||||
GraphicsState m_state2;
|
||||
|
||||
wxDouble m_width;
|
||||
wxDouble m_height;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxGDIPlusContext)
|
||||
};
|
||||
|
||||
|
@ -1390,9 +1390,6 @@ public:
|
||||
|
||||
void Init();
|
||||
|
||||
// returns the size of the graphics context in device coordinates
|
||||
virtual void GetSize( wxDouble* width, wxDouble* height);
|
||||
|
||||
virtual void StartPage( wxDouble width, wxDouble height );
|
||||
|
||||
virtual void EndPage();
|
||||
@ -1506,8 +1503,6 @@ private:
|
||||
#endif
|
||||
bool m_contextSynthesized;
|
||||
CGAffineTransform m_windowTransform;
|
||||
wxDouble m_width;
|
||||
wxDouble m_height;
|
||||
bool m_invisible;
|
||||
|
||||
#if wxOSX_USE_COCOA_OR_CARBON
|
||||
@ -1644,12 +1639,6 @@ wxMacCoreGraphicsContext::~wxMacCoreGraphicsContext()
|
||||
SetNativeContext(NULL);
|
||||
}
|
||||
|
||||
void wxMacCoreGraphicsContext::GetSize( wxDouble* width, wxDouble* height)
|
||||
{
|
||||
*width = m_width;
|
||||
*height = m_height;
|
||||
}
|
||||
|
||||
|
||||
void wxMacCoreGraphicsContext::StartPage( wxDouble width, wxDouble height )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user