X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0b822969a677939811d9fb966177031fb5fc625b..d7c6d397381a8c3c7b873a9427ad1de12aa24781:/interface/graphics.h diff --git a/interface/graphics.h b/interface/graphics.h index d1cdf137b2..45360115b7 100644 --- a/interface/graphics.h +++ b/interface/graphics.h @@ -203,7 +203,7 @@ public: wxPaintDC dc(this); // Create graphics context from it - wxGraphicsContext *gc = wxGraphicsContext::CreateContext( dc ); + wxGraphicsContext *gc = wxGraphicsContext::Create( dc ); if (gc) { @@ -218,9 +218,9 @@ public: path.CloseSubpath(); path.AddRectangle(25.0, 25.0, 50.0, 50.0); - gc->StrokePath(path); + gc->StrokePath(path); - delete gc; + delete gc; } } @endcode @@ -229,7 +229,7 @@ public: @library{wxcore} @category{FIXME} - @see wxGraphicsRenderer:: CreateContext + @see wxGraphicsRenderer::CreateContext(), wxGCDC, wxDC */ class wxGraphicsContext : public wxGraphicsObject { @@ -256,9 +256,11 @@ public: static wxGraphicsContext * Create( const wxMemoryDC& dc) ; /** - Creates a wxGraphicsContext from a wxPrinterDC + Creates a wxGraphicsContext from a wxPrinterDC. Under + GTK+, this will only work when using the GtkPrint + printing backend which is available since GTK+ 2.10. - @see wxGraphicsRenderer::CreateContext() + @see wxGraphicsRenderer::CreateContext(), @ref overview_unixprinting "Printing under Unix" */ static wxGraphicsContext * Create( const wxPrinterDC& dc) ; @@ -294,13 +296,13 @@ public: eg a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus or a cairo_t pointer for cairo. - Creates a wxGraphicsContext from a native window. - @see wxGraphicsRenderer:: CreateContextFromNativeContext */ wxGraphicsContext* CreateFromNative(void* context); /** + Creates a wxGraphicsContext from a native window. + @see wxGraphicsRenderer:: CreateContextFromNativeWindow */ wxGraphicsContext* CreateFromNativeWindow(void* window); @@ -515,7 +517,18 @@ public: @wxheader{graphics.h} A wxGraphicsRenderer is the instance corresponding to the rendering engine - used. There may be multiple instances on a system, if there are different rendering engines present, but there is always one instance per engine, eg there is ONE core graphics renderer instance on OSX. This instance is pointed back to by all objects created by it (wxGraphicsContext, wxGraphicsPath etc). Therefore you can create ag additional instances of paths etc. by calling GetRenderer() and then using the appropriate CreateXXX function. + used. There may be multiple instances on a system, if there are different + rendering engines present, but there is always only one instance per engine. + This instance is pointed back to by all objects created by it (wxGraphicsContext, + wxGraphicsPath etc) and can be retrieved through their wxGraphicsObject::GetRenderer() + method. Therefore you can create an additional instance of a path etc. by calling + wxGraphicsObject::GetRenderer() and then using the appropriate CreateXXX function + of that renderer. + + @code + wxGraphicsPath *path = // from somewhere + wxGraphicsBrush *brush = path->GetRenderer()->CreateBrush( *wxBLACK_BRUSH ); + @endcode @library{wxcore} @category{FIXME} @@ -524,21 +537,35 @@ class wxGraphicsRenderer : public wxObject { public: /** - Creates a native brush from a wxBrush. + Creates a wxGraphicsContext from a wxWindow. */ - wxGraphicsBrush CreateBrush(const wxBrush& brush); + virtual wxGraphicsContext* CreateContext(wxWindow* window) = 0; + + /** + Creates a wxGraphicsContext from a wxWindowDC + */ + virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0 ; + + /** + Creates a wxGraphicsContext from a wxMemoryDC + */ + virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc) = 0 ; + + /** + Creates a wxGraphicsContext from a wxPrinterDC + */ + virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc) = 0 ; - //@{ /** - Creates a wxGraphicsContext from a wxWindow. + Creates a native brush from a wxBrush. */ - wxGraphicsContext* CreateContext(const wxWindowDC& dc); - wxGraphicsContext* CreateContext(wxWindow* window); - //@} + wxGraphicsBrush CreateBrush(const wxBrush& brush); + /** Creates a wxGraphicsContext from a native context. This native context must be - eg a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus or a cairo_t pointer for cairo. + eg a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus or a cairo_t + pointer for cairo. */ wxGraphicsContext* CreateContextFromNativeContext(void* context); @@ -600,7 +627,7 @@ public: Returns the default renderer on this platform. On OS X this is the Core Graphics (a.k.a. Quartz 2D) renderer, on MSW the GDIPlus renderer, and on GTK we currently default to the cairo renderer. */ - wxGraphicsRenderer* GetDefaultRenderer(); + static wxGraphicsRenderer* GetDefaultRenderer(); };