X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e71508e160653f122f8e5d7f73c2ebf7f928964b..f6669958924c3c3833e2932b65598b06073d2e65:/include/wx/dc.h diff --git a/include/wx/dc.h b/include/wx/dc.h index 5734cde438..34f58e2662 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -43,6 +43,10 @@ class WXDLLIMPEXP_FWD_CORE wxMemoryDC; class WXDLLIMPEXP_FWD_CORE wxPrinterDC; class WXDLLIMPEXP_FWD_CORE wxPrintData; +#if wxUSE_GRAPHICS_CONTEXT +class WXDLLIMPEXP_FWD_CORE wxGraphicsContext; +#endif + // Logical ops enum wxRasterOperationMode { @@ -279,6 +283,8 @@ public: return NULL; } + virtual void* GetHandle() const { return NULL; } + // query dimension, colour deps, resolution virtual void DoGetSize(int *width, int *height) const = 0; @@ -427,8 +433,12 @@ public: // clipping + // Note that this pure virtual method has an implementation that updates + // the values returned by DoGetClippingBox() and so can be called from the + // derived class overridden version if it makes sense (i.e. if the clipping + // box coordinates are not already updated in some other way). virtual void DoSetClippingRegion(wxCoord x, wxCoord y, - wxCoord width, wxCoord height) = 0; + wxCoord w, wxCoord h) = 0; // NB: this function works with device coordinates, not the logical ones! virtual void DoSetDeviceClippingRegion(const wxRegion& region) = 0; @@ -471,7 +481,7 @@ public: } virtual void SetLogicalScale(double x, double y); - virtual void GetLogicalScale(double *x, double *y) + virtual void GetLogicalScale(double *x, double *y) const { if ( x ) *x = m_logicalScaleX; if ( y ) *y = m_logicalScaleY; @@ -512,6 +522,19 @@ public: // this needs to overidden if the axis is inverted virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); +#ifdef __WXMSW__ + // Native Windows functions using the underlying HDC don't honour GDI+ + // transformations which may be applied to it. Using this function we can + // transform the coordinates manually before passing them to such functions + // (as in e.g. wxRendererMSW code). It doesn't do anything if this is not a + // wxGCDC. + virtual wxRect MSWApplyGDIPlusTransform(const wxRect& r) const + { + return r; + } +#endif // __WXMSW__ + + // --------------------------------------------------------- // the actual drawing API @@ -627,6 +650,13 @@ public: virtual int GetResolution() const { return -1; } +#if wxUSE_GRAPHICS_CONTEXT + virtual wxGraphicsContext* GetGraphicsContext() const + { return NULL; } + virtual void SetGraphicsContext( wxGraphicsContext* WXUNUSED(ctx) ) + {} +#endif + private: wxDC *m_owner; @@ -763,6 +793,9 @@ public: wxWindow *GetWindow() const { return m_pimpl->GetWindow(); } + void *GetHandle() const + { return m_pimpl->GetHandle(); } + bool IsOk() const { return m_pimpl && m_pimpl->IsOk(); } @@ -996,7 +1029,7 @@ public: void SetLogicalScale(double x, double y) { m_pimpl->SetLogicalScale( x, y ); } - void GetLogicalScale(double *x, double *y) + void GetLogicalScale(double *x, double *y) const { m_pimpl->GetLogicalScale( x, y ); } void SetLogicalOrigin(wxCoord x, wxCoord y) @@ -1316,6 +1349,17 @@ public: TempHDC GetTempHDC() { return TempHDC(*this); } #endif // __WXMSW__ +#if wxUSE_GRAPHICS_CONTEXT + virtual wxGraphicsContext* GetGraphicsContext() const + { + return m_pimpl->GetGraphicsContext(); + } + virtual void SetGraphicsContext( wxGraphicsContext* ctx ) + { + m_pimpl->SetGraphicsContext(ctx); + } +#endif + protected: // ctor takes ownership of the pointer wxDC(wxDCImpl *pimpl) : m_pimpl(pimpl) { } @@ -1344,13 +1388,13 @@ public: ~wxDCTextColourChanger() { - if ( m_colFgOld.Ok() ) + if ( m_colFgOld.IsOk() ) m_dc.SetTextForeground(m_colFgOld); } void Set(const wxColour& col) { - if ( !m_colFgOld.Ok() ) + if ( !m_colFgOld.IsOk() ) m_colFgOld = m_dc.GetTextForeground(); m_dc.SetTextForeground(col); } @@ -1378,7 +1422,7 @@ public: ~wxDCPenChanger() { - if ( m_penOld.Ok() ) + if ( m_penOld.IsOk() ) m_dc.SetPen(m_penOld); } @@ -1405,7 +1449,7 @@ public: ~wxDCBrushChanger() { - if ( m_brushOld.Ok() ) + if ( m_brushOld.IsOk() ) m_dc.SetBrush(m_brushOld); } @@ -1461,14 +1505,14 @@ public: void Set(const wxFont& font) { - if ( !m_fontOld.Ok() ) + if ( !m_fontOld.IsOk() ) m_fontOld = m_dc.GetFont(); m_dc.SetFont(font); } ~wxDCFontChanger() { - if ( m_fontOld.Ok() ) + if ( m_fontOld.IsOk() ) m_dc.SetFont(m_fontOld); }