X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a1b806b98241ab649c169aaa1f134df85e80fb8b..e91e1e3d5cab263883c1cee1689c898b8f7c4ecd:/include/wx/dc.h diff --git a/include/wx/dc.h b/include/wx/dc.h index 1f1731d4a6..d13720500b 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -4,7 +4,6 @@ // Author: Vadim Zeitlin // Modified by: // Created: 05/25/99 -// RCS-ID: $Id$ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -43,6 +42,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 +282,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 +432,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 +480,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; @@ -511,6 +520,21 @@ public: // this needs to overidden if the axis is inverted virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); + + virtual double GetContentScaleFactor() const { return m_contentScaleFactor; } + +#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 @@ -581,15 +605,15 @@ public: { return wxNullBitmap; } - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset ) = 0; virtual void DrawLines(const wxPointList *list, wxCoord xoffset, wxCoord yoffset ); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) = 0; - virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], + virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle); void DrawPolygon(const wxPointList *list, @@ -601,7 +625,7 @@ public: void DrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3); - void DrawSpline(int n, wxPoint points[]); + void DrawSpline(int n, const wxPoint points[]); void DrawSpline(const wxPointList *points) { DoDrawSpline(points); } virtual void DoDrawSpline(const wxPointList *points); @@ -627,6 +651,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; @@ -717,6 +748,8 @@ protected: double m_scaleX, m_scaleY; // calculated from logical scale and user scale int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes + + double m_contentScaleFactor; // used by high resolution displays (retina) // what is a mm on a screen you don't know the size of? double m_mm_to_pix_x, @@ -763,6 +796,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(); } @@ -797,6 +833,9 @@ public: virtual int GetResolution() const { return m_pimpl->GetResolution(); } + double GetContentScaleFactor() const + { return m_pimpl->GetContentScaleFactor(); } + // Right-To-Left (RTL) modes void SetLayoutDirection(wxLayoutDirection dir) @@ -996,7 +1035,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) @@ -1106,7 +1145,7 @@ public: void DrawPoint(const wxPoint& pt) { m_pimpl->DoDrawPoint(pt.x, pt.y); } - void DrawLines(int n, wxPoint points[], + void DrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); } void DrawLines(const wxPointList *list, @@ -1117,7 +1156,7 @@ public: wxCoord xoffset = 0, wxCoord yoffset = 0) ); #endif // WXWIN_COMPATIBILITY_2_8 - void DrawPolygon(int n, wxPoint points[], + void DrawPolygon(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } @@ -1125,7 +1164,7 @@ public: wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); } - void DrawPolyPolygon(int n, int count[], wxPoint points[], + void DrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } @@ -1248,7 +1287,7 @@ public: wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3) { m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); } - void DrawSpline(int n, wxPoint points[]) + void DrawSpline(int n, const wxPoint points[]) { m_pimpl->DrawSpline(n,points); } void DrawSpline(const wxPointList *points) { m_pimpl->DrawSpline(points); } @@ -1316,6 +1355,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) { }