X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/89efaf2b6595e59af618556d7e79492cab50c73c..5d57348ef570e5bce5b5148ba63f910c65a9b8dd:/include/wx/dc.h diff --git a/include/wx/dc.h b/include/wx/dc.h index 2357fb12e5..82f4848adf 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -61,7 +61,7 @@ enum wxRasterOperationMode wxNAND, // (NOT src) OR (NOT dst) wxOR, // src OR dst wxSET // 1 -#ifdef WXWIN_COMPATIBILITY_2_8 +#if WXWIN_COMPATIBILITY_2_8 ,wxROP_BLACK = wxCLEAR, wxBLIT_BLACKNESS = wxCLEAR, wxROP_XORPEN = wxXOR, @@ -104,21 +104,18 @@ enum wxFloodFillStyle wxFLOOD_BORDER }; -// Mapping modes (same values as used by Windows, don't change) +// Mapping modes enum wxMappingMode { wxMM_TEXT = 1, + wxMM_METRIC, wxMM_LOMETRIC, - wxMM_HIMETRIC, - wxMM_LOENGLISH, - wxMM_HIENGLISH, wxMM_TWIPS, - wxMM_ISOTROPIC, - wxMM_ANISOTROPIC, - wxMM_POINTS, - wxMM_METRIC + wxMM_POINTS }; +#if WXWIN_COMPATIBILITY_2_8 + //----------------------------------------------------------------------------- // wxDrawObject helper class //----------------------------------------------------------------------------- @@ -126,8 +123,7 @@ enum wxMappingMode class WXDLLIMPEXP_CORE wxDrawObject { public: - - wxDrawObject() + wxDEPRECATED_CONSTRUCTOR(wxDrawObject)() : m_isBBoxValid(false) , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0) { } @@ -180,6 +176,8 @@ protected: wxCoord m_minX, m_minY, m_maxX, m_maxY; }; +#endif // WXWIN_COMPATIBILITY_2_8 + //----------------------------------------------------------------------------- // wxDCFactory @@ -370,7 +368,7 @@ public: // logical functions virtual void SetLogicalFunction(wxRasterOperationMode function) = 0; - virtual wxRasterOperationMode GetLogicalFunction() const + virtual wxRasterOperationMode GetLogicalFunction() const { return m_logicalFunction; } // text measurement @@ -704,6 +702,9 @@ private: class WXDLLIMPEXP_CORE wxDC : public wxObject { public: + // copy attributes (font, colours and writing direction) from another DC + void CopyAttributes(const wxDC& dc); + virtual ~wxDC() { delete m_pimpl; } wxDCImpl *GetImpl() @@ -963,15 +964,6 @@ public: { m_pimpl->SetDeviceLocalOrigin( x, y ); } - // draw generic object - - void DrawObject(wxDrawObject* drawobject) - { - drawobject->Draw(*this); - CalcBoundingBox(drawobject->MinX(),drawobject->MinY()); - CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); - } - // ----------------------------------------------- // the actual drawing API @@ -1140,7 +1132,7 @@ public: bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, + wxRasterOperationMode rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) { return m_pimpl->DoBlit(xdest, ydest, width, height, @@ -1148,7 +1140,7 @@ public: } bool Blit(const wxPoint& destPt, const wxSize& sz, wxDC *source, const wxPoint& srcPt, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, + wxRasterOperationMode rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition) { return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y, @@ -1168,7 +1160,7 @@ public: } bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize, wxDC *source, const wxPoint& srcPt, const wxSize& srcSize, - wxRasterOperationMode rop = wxCOPY, bool useMask = false, + wxRasterOperationMode rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition) { return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y, @@ -1203,10 +1195,54 @@ public: wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const ); wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const ); + wxDEPRECATED( void DrawObject(wxDrawObject* drawobject) ); #endif // WXWIN_COMPATIBILITY_2_8 #ifdef __WXMSW__ + // GetHDC() is the simplest way to retrieve an HDC From a wxDC but only + // works if this wxDC is GDI-based and fails for GDI+ contexts (and + // anything else without HDC, e.g. wxPostScriptDC) WXHDC GetHDC() const; + + // don't use these methods manually, use GetTempHDC() instead + virtual WXHDC AcquireHDC() { return GetHDC(); } + virtual void ReleaseHDC(WXHDC WXUNUSED(hdc)) { } + + // helper class holding the result of GetTempHDC() with std::auto_ptr<>-like + // semantics, i.e. it is moved when copied + class TempHDC + { + public: + TempHDC(wxDC& dc) + : m_dc(dc), + m_hdc(dc.AcquireHDC()) + { + } + + TempHDC(const TempHDC& thdc) + : m_dc(thdc.m_dc), + m_hdc(thdc.m_hdc) + { + const_cast(thdc).m_hdc = 0; + } + + ~TempHDC() + { + if ( m_hdc ) + m_dc.ReleaseHDC(m_hdc); + } + + WXHDC GetHDC() const { return m_hdc; } + + private: + wxDC& m_dc; + WXHDC m_hdc; + + wxDECLARE_NO_ASSIGN_CLASS(TempHDC); + }; + + // GetTempHDC() also works for wxGCDC (but still not for wxPostScriptDC &c) + TempHDC GetTempHDC() { return TempHDC(*this); } #endif // __WXMSW__ protected: @@ -1217,7 +1253,7 @@ protected: private: DECLARE_ABSTRACT_CLASS(wxDC) - DECLARE_NO_COPY_CLASS(wxDC) + wxDECLARE_NO_COPY_CLASS(wxDC); }; // ---------------------------------------------------------------------------- @@ -1253,7 +1289,7 @@ private: wxColour m_colFgOld; - DECLARE_NO_COPY_CLASS(wxDCTextColourChanger) + wxDECLARE_NO_COPY_CLASS(wxDCTextColourChanger); }; // ---------------------------------------------------------------------------- @@ -1280,7 +1316,7 @@ private: wxPen m_penOld; - DECLARE_NO_COPY_CLASS(wxDCPenChanger) + wxDECLARE_NO_COPY_CLASS(wxDCPenChanger); }; // ---------------------------------------------------------------------------- @@ -1307,7 +1343,7 @@ private: wxBrush m_brushOld; - DECLARE_NO_COPY_CLASS(wxDCBrushChanger) + wxDECLARE_NO_COPY_CLASS(wxDCBrushChanger); }; // ---------------------------------------------------------------------------- @@ -1330,7 +1366,7 @@ public: private: wxDC& m_dc; - DECLARE_NO_COPY_CLASS(wxDCClipper) + wxDECLARE_NO_COPY_CLASS(wxDCClipper); }; // ---------------------------------------------------------------------------- @@ -1341,8 +1377,21 @@ private: class WXDLLIMPEXP_CORE wxDCFontChanger { public: - wxDCFontChanger(wxDC& dc, const wxFont& font) : m_dc(dc), m_fontOld(dc.GetFont()) + wxDCFontChanger(wxDC& dc) + : m_dc(dc), m_fontOld() + { + } + + wxDCFontChanger(wxDC& dc, const wxFont& font) + : m_dc(dc), m_fontOld(dc.GetFont()) + { + m_dc.SetFont(font); + } + + void Set(const wxFont& font) { + if ( !m_fontOld.Ok() ) + m_fontOld = m_dc.GetFont(); m_dc.SetFont(font); } @@ -1357,7 +1406,7 @@ private: wxFont m_fontOld; - DECLARE_NO_COPY_CLASS(wxDCFontChanger) + wxDECLARE_NO_COPY_CLASS(wxDCFontChanger); };