From 888dde65f43d5f57e8fb2028b27191cca1741403 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 30 Nov 2007 13:48:22 +0000 Subject: [PATCH] DC reorganization git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50348 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dc.h | 924 ++----------------------------- include/wx/dcbuffer.h | 8 +- include/wx/dcclient.h | 68 ++- include/wx/dcgraph.h | 39 +- include/wx/dcmemory.h | 68 --- include/wx/dcprint.h | 21 +- include/wx/dcscreen.h | 30 +- include/wx/dcsvg.h | 12 +- include/wx/generic/dcpsg.h | 16 +- include/wx/generic/prntdlgg.h | 1 + include/wx/graphics.h | 6 +- include/wx/gtk/dataview.h | 2 +- include/wx/gtk/dc.h | 21 +- include/wx/gtk/dcclient.h | 77 +-- include/wx/gtk/dcmemory.h | 36 +- include/wx/gtk/dcscreen.h | 31 +- include/wx/gtk/gnome/gprint.h | 14 +- include/wx/gtk/print.h | 14 +- include/wx/gtk/private.h | 3 + include/wx/mac/carbon/dcclient.h | 70 ++- include/wx/mac/carbon/dcmemory.h | 26 +- include/wx/mac/carbon/dcprint.h | 20 +- include/wx/mac/carbon/dcscreen.h | 25 +- include/wx/mac/carbon/metafile.h | 58 +- include/wx/mac/carbon/private.h | 3 + include/wx/msw/dc.h | 43 +- include/wx/msw/dcclient.h | 37 +- include/wx/msw/dcmemory.h | 14 +- include/wx/msw/dcprint.h | 38 +- include/wx/msw/dcscreen.h | 16 +- include/wx/msw/enhmeta.h | 13 - include/wx/msw/metafile.h | 43 +- include/wx/msw/private.h | 5 + include/wx/prntbase.h | 5 +- samples/drawing/drawing.cpp | 1 + src/aui/dockart.cpp | 3 +- src/aui/framemanager.cpp | 5 +- src/common/dcbase.cpp | 378 +++---------- src/common/dcgraph.cpp | 235 ++++---- src/common/dcsvg.cpp | 78 +-- src/common/graphcmn.cpp | 3 +- src/common/overlaycmn.cpp | 13 - src/common/prntbase.cpp | 29 +- src/generic/datavgen.cpp | 3 +- src/generic/dcpsg.cpp | 138 ++--- src/generic/graphicc.cpp | 30 +- src/gtk/dataview.cpp | 56 +- src/gtk/dc.cpp | 26 +- src/gtk/dcclient.cpp | 503 ++++++++--------- src/gtk/dcmemory.cpp | 90 +-- src/gtk/dcscreen.cpp | 30 +- src/gtk/gnome/gprint.cpp | 102 ++-- src/gtk/minifram.cpp | 13 +- src/gtk/print.cpp | 104 ++-- src/gtk/renderer.cpp | 34 +- src/gtk/tbargtk.cpp | 10 + src/gtk/textctrl.cpp | 1 + src/mac/carbon/dcclient.cpp | 74 ++- src/mac/carbon/dcmemory.cpp | 38 +- src/mac/carbon/dcprint.cpp | 48 +- src/mac/carbon/dcscreen.cpp | 8 +- src/mac/carbon/graphics.cpp | 31 +- src/mac/carbon/metafile.cpp | 31 +- src/mac/carbon/overlay.cpp | 17 +- src/mac/carbon/printmac.cpp | 4 +- src/mac/carbon/renderer.cpp | 15 +- src/msw/app.cpp | 2 +- src/msw/bitmap.cpp | 18 +- src/msw/checklst.cpp | 3 +- src/msw/combo.cpp | 4 +- src/msw/dc.cpp | 236 ++++---- src/msw/dcclient.cpp | 189 ++++--- src/msw/dcmemory.cpp | 49 +- src/msw/dcprint.cpp | 46 +- src/msw/dcscreen.cpp | 8 +- src/msw/enhmeta.cpp | 52 +- src/msw/imaglist.cpp | 9 +- src/msw/notebook.cpp | 6 +- src/msw/ownerdrw.cpp | 3 +- src/msw/printdlg.cpp | 3 +- src/msw/printwin.cpp | 20 +- src/msw/renderer.cpp | 18 +- src/msw/statbox.cpp | 16 +- src/msw/tbar95.cpp | 12 +- src/msw/window.cpp | 27 +- 85 files changed, 1837 insertions(+), 2842 deletions(-) diff --git a/include/wx/dc.h b/include/wx/dc.h index 97f362589c..6a86ae856d 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -29,12 +29,10 @@ #include "wx/dynarray.h" #include "wx/math.h" #include "wx/image.h" +#include "wx/cmndata.h" - // 1 if using the reorganized DC code -#define wxUSE_NEW_DC 0 - +#define wxUSE_NEW_DC 1 -#if wxUSE_NEW_DC class WXDLLIMPEXP_FWD_CORE wxDC; class WXDLLIMPEXP_FWD_CORE wxClientDC; class WXDLLIMPEXP_FWD_CORE wxPaintDC; @@ -42,10 +40,10 @@ class WXDLLIMPEXP_FWD_CORE wxWindowDC; class WXDLLIMPEXP_FWD_CORE wxScreenDC; class WXDLLIMPEXP_FWD_CORE wxMemoryDC; class WXDLLIMPEXP_FWD_CORE wxPrinterDC; -#include "wx/cmndata.h" -#else -class WXDLLIMPEXP_FWD_CORE wxDCBase; -#endif + +//----------------------------------------------------------------------------- +// wxDrawObject helper class +//----------------------------------------------------------------------------- class WXDLLEXPORT wxDrawObject { @@ -58,11 +56,7 @@ public: virtual ~wxDrawObject() { } -#if wxUSE_NEW_DC virtual void Draw(wxDC&) const { } -#else - virtual void Draw(wxDCBase&) const { } -#endif virtual void CalcBoundingBox(wxCoord x, wxCoord y) { @@ -109,13 +103,11 @@ protected: }; -#if wxUSE_NEW_DC - //----------------------------------------------------------------------------- // wxDCFactory //----------------------------------------------------------------------------- -class WXDLLIMPEXP_FWD_CORE wxImplDC; +class WXDLLIMPEXP_FWD_CORE wxDCImpl; class WXDLLIMPEXP_CORE wxDCFactory { @@ -123,17 +115,17 @@ public: wxDCFactory() {} virtual ~wxDCFactory() {} - virtual wxImplDC* CreateWindowDC( wxWindowDC *owner ) = 0; - virtual wxImplDC* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0; - virtual wxImplDC* CreateClientDC( wxClientDC *owner ) = 0; - virtual wxImplDC* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 0; - virtual wxImplDC* CreatePaintDC( wxPaintDC *owner ) = 0; - virtual wxImplDC* CreatePaintDC( wxPaintDC *owner, wxWindow *window ) = 0; - virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner ) = 0; - virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) = 0; - virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) = 0; - virtual wxImplDC* CreateScreenDC( wxScreenDC *owner ) = 0; - virtual wxImplDC* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) = 0; + virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner ) = 0; + virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0; + virtual wxDCImpl* CreateClientDC( wxClientDC *owner ) = 0; + virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 0; + virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner ) = 0; + virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window ) = 0; + virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner ) = 0; + virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) = 0; + virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) = 0; + virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner ) = 0; + virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) = 0; static void SetDCFactory( wxDCFactory *factory ); static wxDCFactory *GetFactory(); @@ -150,31 +142,33 @@ class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory public: wxNativeDCFactory() {} - virtual wxImplDC* CreateWindowDC( wxWindowDC *owner ); - virtual wxImplDC* CreateWindowDC( wxWindowDC *owner, wxWindow *window ); - virtual wxImplDC* CreateClientDC( wxClientDC *owner ); - virtual wxImplDC* CreateClientDC( wxClientDC *owner, wxWindow *window ); - virtual wxImplDC* CreatePaintDC( wxPaintDC *owner ); - virtual wxImplDC* CreatePaintDC( wxPaintDC *owner, wxWindow *window ); - virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner ); - virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ); - virtual wxImplDC* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ); - virtual wxImplDC* CreateScreenDC( wxScreenDC *owner ); - virtual wxImplDC* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ); + virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner ); + virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ); + virtual wxDCImpl* CreateClientDC( wxClientDC *owner ); + virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ); + virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner ); + virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window ); + virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner ); + virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ); + virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ); + virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner ); + virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ); }; //----------------------------------------------------------------------------- -// wxImplDC +// wxDCImpl //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxImplDC: public wxObject +class WXDLLIMPEXP_CORE wxDCImpl: public wxObject { public: - wxImplDC( wxDC *owner ); - ~wxImplDC(); + wxDCImpl( wxDC *owner ); + ~wxDCImpl(); wxDC *GetOwner() const { return m_owner; } + wxWindow* GetWindow() const { return m_window; } + virtual bool IsOk() const { return m_ok; } // query capabilities @@ -476,7 +470,7 @@ public: { return -1; } private: - wxDC *m_owner; + wxDC *m_owner; protected: // unset clipping variables (after clipping region was destroyed) @@ -487,6 +481,9 @@ protected: m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0; } + // window on which the DC draws or NULL + wxWindow *m_window; + // flags bool m_colour:1; bool m_ok:1; @@ -536,20 +533,23 @@ protected: #endif // wxUSE_PALETTE private: - DECLARE_ABSTRACT_CLASS(wxImplDC) + DECLARE_ABSTRACT_CLASS(wxDCImpl) }; -class wxDC: public wxObject +class WXDLLIMPEXP_CORE wxDC: public wxObject { public: wxDC() { m_pimpl = NULL; } + ~wxDC() { if (m_pimpl) delete m_pimpl; } - wxImplDC *GetImpl() + wxDCImpl *GetImpl() { return m_pimpl; } - const wxImplDC *GetImpl() const + const wxDCImpl *GetImpl() const { return m_pimpl; } + wxWindow *GetWindow() + { return m_pimpl->GetWindow(); } bool IsOk() const { return m_pimpl && m_pimpl->IsOk(); } @@ -1032,840 +1032,12 @@ public: protected: - wxImplDC *m_pimpl; - -private: - DECLARE_ABSTRACT_CLASS(wxImplDC) -}; - - -//----------------------------------------------------------------------------- -// wxWindowDC -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxWindowDC : public wxDC -{ -public: - wxWindowDC(); - wxWindowDC( wxWindow *win ); - -private: - DECLARE_DYNAMIC_CLASS(wxWindowDC) -}; - -//----------------------------------------------------------------------------- -// wxClientDC -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxClientDC : public wxDC -{ -public: - wxClientDC(); - wxClientDC( wxWindow *win ); - -private: - DECLARE_DYNAMIC_CLASS(wxClientDC) -}; - -//----------------------------------------------------------------------------- -// wxPaintDC -//----------------------------------------------------------------------------- - -class WXDLLIMPEXP_CORE wxPaintDC : public wxDC -{ -public: - wxPaintDC(); - wxPaintDC( wxWindow *win ); + wxDCImpl *m_pimpl; private: - DECLARE_DYNAMIC_CLASS(wxPaintDC) + DECLARE_ABSTRACT_CLASS(wxDC) }; -#else // wxUSE_NEW_DC - - -class WXDLLIMPEXP_FWD_CORE wxDC; - -// --------------------------------------------------------------------------- -// global variables -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -// wxDC is the device context - object on which any drawing is done -// --------------------------------------------------------------------------- - -class WXDLLEXPORT wxDCBase : public wxObject -{ -public: - wxDCBase(); - virtual ~wxDCBase(); - - // graphic primitives - // ------------------ - - virtual void DrawObject(wxDrawObject* drawobject) - { - drawobject->Draw(*this); - CalcBoundingBox(drawobject->MinX(),drawobject->MinY()); - CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); - } - - wxDC *GetOwner() const { return (wxDC*) this; } - - bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, - int style = wxFLOOD_SURFACE) - { return DoFloodFill(x, y, col, style); } - bool FloodFill(const wxPoint& pt, const wxColour& col, - int style = wxFLOOD_SURFACE) - { return DoFloodFill(pt.x, pt.y, col, style); } - - // fill the area specified by rect with a radial gradient, starting from - // initialColour in the centre of the cercle and fading to destColour. - void GradientFillConcentric(const wxRect& rect, - const wxColour& initialColour, - const wxColour& destColour) - { GradientFillConcentric(rect, initialColour, destColour, - wxPoint(rect.GetWidth() / 2, - rect.GetHeight() / 2)); } - - void GradientFillConcentric(const wxRect& rect, - const wxColour& initialColour, - const wxColour& destColour, - const wxPoint& circleCenter) - { DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); } - - // fill the area specified by rect with a linear gradient - void GradientFillLinear(const wxRect& rect, - const wxColour& initialColour, - const wxColour& destColour, - wxDirection nDirection = wxEAST) - { DoGradientFillLinear(rect, initialColour, destColour, nDirection); } - - bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const - { return DoGetPixel(x, y, col); } - bool GetPixel(const wxPoint& pt, wxColour *col) const - { return DoGetPixel(pt.x, pt.y, col); } - - void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) - { DoDrawLine(x1, y1, x2, y2); } - void DrawLine(const wxPoint& pt1, const wxPoint& pt2) - { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); } - - void CrossHair(wxCoord x, wxCoord y) - { DoCrossHair(x, y); } - void CrossHair(const wxPoint& pt) - { DoCrossHair(pt.x, pt.y); } - - void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, - wxCoord xc, wxCoord yc) - { DoDrawArc(x1, y1, x2, y2, xc, yc); } - void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre) - { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); } - - void DrawCheckMark(wxCoord x, wxCoord y, - wxCoord width, wxCoord height) - { DoDrawCheckMark(x, y, width, height); } - void DrawCheckMark(const wxRect& rect) - { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); } - - void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, - double sa, double ea) - { DoDrawEllipticArc(x, y, w, h, sa, ea); } - void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, - double sa, double ea) - { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); } - - void DrawPoint(wxCoord x, wxCoord y) - { DoDrawPoint(x, y); } - void DrawPoint(const wxPoint& pt) - { DoDrawPoint(pt.x, pt.y); } - - void DrawLines(int n, wxPoint points[], - wxCoord xoffset = 0, wxCoord yoffset = 0) - { DoDrawLines(n, points, xoffset, yoffset); } - void DrawLines(const wxPointList *list, - wxCoord xoffset = 0, wxCoord yoffset = 0); - -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( void DrawLines(const wxList *list, - wxCoord xoffset = 0, wxCoord yoffset = 0) ); -#endif // WXWIN_COMPATIBILITY_2_8 - - - void DrawPolygon(int n, wxPoint points[], - wxCoord xoffset = 0, wxCoord yoffset = 0, - int fillStyle = wxODDEVEN_RULE) - { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } - - void DrawPolygon(const wxPointList *list, - wxCoord xoffset = 0, wxCoord yoffset = 0, - int fillStyle = wxODDEVEN_RULE); - -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( void DrawPolygon(const wxList *list, - wxCoord xoffset = 0, wxCoord yoffset = 0, - int fillStyle = wxODDEVEN_RULE) ); -#endif // WXWIN_COMPATIBILITY_2_8 - - void DrawPolyPolygon(int n, int count[], wxPoint points[], - wxCoord xoffset = 0, wxCoord yoffset = 0, - int fillStyle = wxODDEVEN_RULE) - { DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } - - void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) - { DoDrawRectangle(x, y, width, height); } - void DrawRectangle(const wxPoint& pt, const wxSize& sz) - { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); } - void DrawRectangle(const wxRect& rect) - { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); } - - void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, - double radius) - { DoDrawRoundedRectangle(x, y, width, height, radius); } - void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, - double radius) - { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); } - void DrawRoundedRectangle(const wxRect& r, double radius) - { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); } - - void DrawCircle(wxCoord x, wxCoord y, wxCoord radius) - { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); } - void DrawCircle(const wxPoint& pt, wxCoord radius) - { DrawCircle(pt.x, pt.y, radius); } - - void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) - { DoDrawEllipse(x, y, width, height); } - void DrawEllipse(const wxPoint& pt, const wxSize& sz) - { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); } - void DrawEllipse(const wxRect& rect) - { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); } - - void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) - { DoDrawIcon(icon, x, y); } - void DrawIcon(const wxIcon& icon, const wxPoint& pt) - { DoDrawIcon(icon, pt.x, pt.y); } - - void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, - bool useMask = false) - { DoDrawBitmap(bmp, x, y, useMask); } - void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, - bool useMask = false) - { DoDrawBitmap(bmp, pt.x, pt.y, useMask); } - - void DrawText(const wxString& text, wxCoord x, wxCoord y) - { DoDrawText(text, x, y); } - void DrawText(const wxString& text, const wxPoint& pt) - { DoDrawText(text, pt.x, pt.y); } - - void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) - { DoDrawRotatedText(text, x, y, angle); } - void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle) - { DoDrawRotatedText(text, pt.x, pt.y, angle); } - - // this version puts both optional bitmap and the text into the given - // rectangle and aligns is as specified by alignment parameter; it also - // will emphasize the character with the given index if it is != -1 and - // return the bounding rectangle if required - virtual void DrawLabel(const wxString& text, - const wxBitmap& image, - const wxRect& rect, - int alignment = wxALIGN_LEFT | wxALIGN_TOP, - int indexAccel = -1, - wxRect *rectBounding = NULL); - - void DrawLabel(const wxString& text, const wxRect& rect, - int alignment = wxALIGN_LEFT | wxALIGN_TOP, - int indexAccel = -1) - { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); } - - bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, - int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) - { - return DoBlit(xdest, ydest, width, height, - source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); - } - bool Blit(const wxPoint& destPt, const wxSize& sz, - wxDC *source, const wxPoint& srcPt, - int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition) - { - return DoBlit(destPt.x, destPt.y, sz.x, sz.y, - source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y); - } - - bool StretchBlit(wxCoord dstX, wxCoord dstY, - wxCoord dstWidth, wxCoord dstHeight, - wxDC *source, - wxCoord srcX, wxCoord srcY, - wxCoord srcWidth, wxCoord srcHeight, - int rop = wxCOPY, bool useMask = false, - wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord) - { - return DoStretchBlit(dstX, dstY, dstWidth, dstHeight, - source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY); - } - bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize, - wxDC *source, const wxPoint& srcPt, const wxSize& srcSize, - int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition) - { - return DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y, - source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y); - } - - wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const - { - return DoGetAsBitmap(subrect); - } - -#if wxUSE_SPLINES - void DrawSpline(wxCoord x1, wxCoord y1, - wxCoord x2, wxCoord y2, - wxCoord x3, wxCoord y3); - void DrawSpline(int n, wxPoint points[]); - - void DrawSpline(const wxPointList *points) { DoDrawSpline(points); } - -#if WXWIN_COMPATIBILITY_2_8 - wxDEPRECATED( void DrawSpline(const wxList *points) ); -#endif // WXWIN_COMPATIBILITY_2_8 - -#endif // wxUSE_SPLINES - - // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE -#ifdef __WXWINCE__ - //! Generic method to draw ellipses, circles and arcs with current pen and brush. - /*! \param x Upper left corner of bounding box. - * \param y Upper left corner of bounding box. - * \param w Width of bounding box. - * \param h Height of bounding box. - * \param sa Starting angle of arc - * (counterclockwise, start at 3 o'clock, 360 is full circle). - * \param ea Ending angle of arc. - * \param angle Rotation angle, the Arc will be rotated after - * calculating begin and end. - */ - void DrawEllipticArcRot( wxCoord x, wxCoord y, - wxCoord width, wxCoord height, - double sa = 0, double ea = 0, double angle = 0 ) - { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); } - - void DrawEllipticArcRot( const wxPoint& pt, - const wxSize& sz, - double sa = 0, double ea = 0, double angle = 0 ) - { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); } - - void DrawEllipticArcRot( const wxRect& rect, - double sa = 0, double ea = 0, double angle = 0 ) - { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); } - - virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y, - wxCoord w, wxCoord h, - double sa = 0, double ea = 0, double angle = 0 ); - - //! Rotates points around center. - /*! This is a quite straight method, it calculates in pixels - * and so it produces rounding errors. - * \param points The points inside will be rotated. - * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle). - * \param center Center of rotation. - */ - void Rotate( wxPointList* points, double angle, wxPoint center = wxPoint(0,0) ); - - // used by DrawEllipticArcRot - // Careful: wxList gets filled with points you have to delete later. - void CalculateEllipticPoints( wxPointList* points, - wxCoord xStart, wxCoord yStart, - wxCoord w, wxCoord h, - double sa, double ea ); -#endif - - // global DC operations - // -------------------- - - virtual void Clear() = 0; - - virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; } - virtual void EndDoc() { } - - virtual void StartPage() { } - virtual void EndPage() { } - -#if WXWIN_COMPATIBILITY_2_6 - wxDEPRECATED( void BeginDrawing() ); - wxDEPRECATED( void EndDrawing() ); -#endif // WXWIN_COMPATIBILITY_2_6 - - - // set objects to use for drawing - // ------------------------------ - - virtual void SetFont(const wxFont& font) = 0; - virtual void SetPen(const wxPen& pen) = 0; - virtual void SetBrush(const wxBrush& brush) = 0; - virtual void SetBackground(const wxBrush& brush) = 0; - virtual void SetBackgroundMode(int mode) = 0; -#if wxUSE_PALETTE - virtual void SetPalette(const wxPalette& palette) = 0; -#endif // wxUSE_PALETTE - - // clipping region - // --------------- - - void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) - { DoSetClippingRegion(x, y, width, height); } - void SetClippingRegion(const wxPoint& pt, const wxSize& sz) - { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); } - void SetClippingRegion(const wxRect& rect) - { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); } - void SetClippingRegion(const wxRegion& region) - { DoSetClippingRegionAsRegion(region); } - - virtual void DestroyClippingRegion() { ResetClipping(); } - - void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const - { DoGetClippingBox(x, y, w, h); } - void GetClippingBox(wxRect& rect) const - { - DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); - } - - // text extent - // ----------- - - virtual wxCoord GetCharHeight() const = 0; - virtual wxCoord GetCharWidth() const = 0; - - // only works for single line strings - void GetTextExtent(const wxString& string, - wxCoord *x, wxCoord *y, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL, - const wxFont *theFont = NULL) const - { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); } - - wxSize GetTextExtent(const wxString& string) const - { - wxCoord w, h; - DoGetTextExtent(string, &w, &h); - return wxSize(w, h); - } - - // works for single as well as multi-line strings - virtual void GetMultiLineTextExtent(const wxString& string, - wxCoord *width, - wxCoord *height, - wxCoord *heightLine = NULL, - const wxFont *font = NULL) const; - - wxSize GetMultiLineTextExtent(const wxString& string) const - { - wxCoord w, h; - GetMultiLineTextExtent(string, &w, &h); - return wxSize(w, h); - } - - // Measure cumulative width of text after each character - bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const - { return DoGetPartialTextExtents(text, widths); } - - - // size and resolution - // ------------------- - - // in device units - void GetSize(int *width, int *height) const - { DoGetSize(width, height); } - wxSize GetSize() const - { - int w, h; - DoGetSize(&w, &h); - - return wxSize(w, h); - } - - // in mm - void GetSizeMM(int* width, int* height) const - { DoGetSizeMM(width, height); } - wxSize GetSizeMM() const - { - int w, h; - DoGetSizeMM(&w, &h); - - return wxSize(w, h); - } - - // query DC capabilities - // --------------------- - - virtual bool CanDrawBitmap() const = 0; - virtual bool CanGetTextExtent() const = 0; - - // colour depth - virtual int GetDepth() const = 0; - - // Resolution in Pixels per inch - virtual wxSize GetPPI() const = 0; - - virtual int GetResolution() - { return -1; } - - virtual bool Ok() const { return IsOk(); } - virtual bool IsOk() const { return m_ok; } - - // accessors and setters - // --------------------- - - virtual int GetBackgroundMode() const { return m_backgroundMode; } - virtual const wxBrush& GetBackground() const { return m_backgroundBrush; } - virtual const wxBrush& GetBrush() const { return m_brush; } - virtual const wxFont& GetFont() const { return m_font; } - virtual const wxPen& GetPen() const { return m_pen; } - - virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; } - virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; } - virtual void SetTextForeground(const wxColour& colour) - { m_textForegroundColour = colour; } - virtual void SetTextBackground(const wxColour& colour) - { m_textBackgroundColour = colour; } - - - // coordinates conversions and transforms - // -------------------------------------- - - virtual wxCoord DeviceToLogicalX(wxCoord x) const; - virtual wxCoord DeviceToLogicalY(wxCoord y) const; - virtual wxCoord DeviceToLogicalXRel(wxCoord x) const; - virtual wxCoord DeviceToLogicalYRel(wxCoord y) const; - virtual wxCoord LogicalToDeviceX(wxCoord x) const; - virtual wxCoord LogicalToDeviceY(wxCoord y) const; - virtual wxCoord LogicalToDeviceXRel(wxCoord x) const; - virtual wxCoord LogicalToDeviceYRel(wxCoord y) const; - - virtual void SetMapMode(int mode); - virtual int GetMapMode() const { return m_mappingMode; } - - virtual void SetUserScale(double x, double y); - virtual void GetUserScale(double *x, double *y) const - { - if ( x ) *x = m_userScaleX; - if ( y ) *y = m_userScaleY; - } - - virtual void SetLogicalScale(double x, double y); - virtual void GetLogicalScale(double *x, double *y) - { - if ( x ) *x = m_logicalScaleX; - if ( y ) *y = m_logicalScaleY; - } - - virtual void SetLogicalOrigin(wxCoord x, wxCoord y); - void GetLogicalOrigin(wxCoord *x, wxCoord *y) const - { DoGetLogicalOrigin(x, y); } - wxPoint GetLogicalOrigin() const - { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); } - - virtual void SetDeviceOrigin(wxCoord x, wxCoord y); - void GetDeviceOrigin(wxCoord *x, wxCoord *y) const - { DoGetDeviceOrigin(x, y); } - wxPoint GetDeviceOrigin() const - { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); } - - virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y ); - - virtual void ComputeScaleAndOrigin(); - - // this needs to overidden if the axis is inverted (such - // as when using Postscript, where 0,0 is the lower left - // corner, not the upper left). - virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); - - // logical functions - // --------------------------- - - virtual int GetLogicalFunction() const { return m_logicalFunction; } - virtual void SetLogicalFunction(int function) = 0; - - // bounding box - // ------------ - - virtual void CalcBoundingBox(wxCoord x, wxCoord y) - { - if ( m_isBBoxValid ) - { - if ( x < m_minX ) m_minX = x; - if ( y < m_minY ) m_minY = y; - if ( x > m_maxX ) m_maxX = x; - if ( y > m_maxY ) m_maxY = y; - } - else - { - m_isBBoxValid = true; - - m_minX = x; - m_minY = y; - m_maxX = x; - m_maxY = y; - } - } - - void ResetBoundingBox() - { - m_isBBoxValid = false; - - m_minX = m_maxX = m_minY = m_maxY = 0; - } - - // Get the final bounding box of the PostScript or Metafile picture. - wxCoord MinX() const { return m_minX; } - wxCoord MaxX() const { return m_maxX; } - wxCoord MinY() const { return m_minY; } - wxCoord MaxY() const { return m_maxY; } - - // misc old functions - // ------------------ - -#if WXWIN_COMPATIBILITY_2_8 - // for compatibility with the old code when wxCoord was long everywhere - wxDEPRECATED( void GetTextExtent(const wxString& string, - long *x, long *y, - long *descent = NULL, - long *externalLeading = NULL, - const wxFont *theFont = NULL) const ); - wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const ); - wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const ); - wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const ); -#endif // WXWIN_COMPATIBILITY_2_8 - - // RTL related functions - // --------------------- - - // get or change the layout direction (LTR or RTL) for this dc, - // wxLayout_Default is returned if layout direction is not supported - virtual wxLayoutDirection GetLayoutDirection() const - { return wxLayout_Default; } - virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) - { } - -protected: - // the pure virtual functions which should be implemented by wxDC - virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, - int style = wxFLOOD_SURFACE) = 0; - - virtual void DoGradientFillLinear(const wxRect& rect, - const wxColour& initialColour, - const wxColour& destColour, - wxDirection nDirection = wxEAST); - - virtual void DoGradientFillConcentric(const wxRect& rect, - const wxColour& initialColour, - const wxColour& destColour, - const wxPoint& circleCenter); - - virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0; - - virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0; - virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0; - - virtual void DoDrawArc(wxCoord x1, wxCoord y1, - wxCoord x2, wxCoord y2, - wxCoord xc, wxCoord yc) = 0; - virtual void DoDrawCheckMark(wxCoord x, wxCoord y, - wxCoord width, wxCoord height); - virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, - double sa, double ea) = 0; - - virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0; - virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, - wxCoord width, wxCoord height, - double radius) = 0; - virtual void DoDrawEllipse(wxCoord x, wxCoord y, - wxCoord width, wxCoord height) = 0; - - virtual void DoCrossHair(wxCoord x, wxCoord y) = 0; - - virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0; - virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, - bool useMask = false) = 0; - - virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0; - virtual void DoDrawRotatedText(const wxString& text, - wxCoord x, wxCoord y, double angle) = 0; - - virtual bool DoBlit(wxCoord xdest, wxCoord ydest, - wxCoord width, wxCoord height, - wxDC *source, - wxCoord xsrc, wxCoord ysrc, - int rop = wxCOPY, - bool useMask = false, - wxCoord xsrcMask = wxDefaultCoord, - wxCoord ysrcMask = wxDefaultCoord) = 0; - - virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest, - wxCoord dstWidth, wxCoord dstHeight, - wxDC *source, - wxCoord xsrc, wxCoord ysrc, - wxCoord srcWidth, wxCoord srcHeight, - int rop = wxCOPY, - bool useMask = false, - wxCoord xsrcMask = wxDefaultCoord, - wxCoord ysrcMask = wxDefaultCoord); - - virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const - { return wxNullBitmap; } - - virtual void DoGetSize(int *width, int *height) const = 0; - virtual void DoGetSizeMM(int* width, int* height) const = 0; - - virtual void DoDrawLines(int n, wxPoint points[], - wxCoord xoffset, wxCoord yoffset) = 0; - virtual void DoDrawPolygon(int n, wxPoint points[], - wxCoord xoffset, wxCoord yoffset, - int fillStyle = wxODDEVEN_RULE) = 0; - virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], - wxCoord xoffset, wxCoord yoffset, - int fillStyle); - - virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0; - virtual void DoSetClippingRegion(wxCoord x, wxCoord y, - wxCoord width, wxCoord height) = 0; - - virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, - wxCoord *w, wxCoord *h) const - { - if ( x ) - *x = m_clipX1; - if ( y ) - *y = m_clipY1; - if ( w ) - *w = m_clipX2 - m_clipX1; - if ( h ) - *h = m_clipY2 - m_clipY1; - } - - virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const - { - if ( x ) *x = m_logicalOriginX; - if ( y ) *y = m_logicalOriginY; - } - - virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const - { - if ( x ) *x = m_deviceOriginX; - if ( y ) *y = m_deviceOriginY; - } - - virtual void DoGetTextExtent(const wxString& string, - wxCoord *x, wxCoord *y, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL, - const wxFont *theFont = NULL) const = 0; - - virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; - -#if wxUSE_SPLINES - virtual void DoDrawSpline(const wxPointList *points); -#endif - -protected: - // unset clipping variables (after clipping region was destroyed) - void ResetClipping() - { - m_clipping = false; - - m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0; - } - - // flags - bool m_colour:1; - bool m_ok:1; - bool m_clipping:1; - bool m_isInteractive:1; - bool m_isBBoxValid:1; - - // coordinate system variables - - // TODO short descriptions of what exactly they are would be nice... - - wxCoord m_logicalOriginX, m_logicalOriginY; - wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user - - wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner - // is not at 0,0. This was the case under - // Mac's GrafPorts (coordinate system - // used toplevel window's origin) and - // e.g. for Postscript, where the native - // origin in the bottom left corner. - double m_logicalScaleX, m_logicalScaleY; - double m_userScaleX, m_userScaleY; - double m_scaleX, m_scaleY; // calculated from logical scale and user scale - - // Used by SetAxisOrientation() to invert the axes - int m_signX, m_signY; - - // what is a mm on a screen you don't know the size of? - double m_mm_to_pix_x, - m_mm_to_pix_y; - - // bounding and clipping boxes - wxCoord m_minX, m_minY, m_maxX, m_maxY; - wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2; - - int m_logicalFunction; - int m_backgroundMode; - int m_mappingMode; - - // GDI objects - wxPen m_pen; - wxBrush m_brush; - wxBrush m_backgroundBrush; - wxColour m_textForegroundColour; - wxColour m_textBackgroundColour; - wxFont m_font; - -#if wxUSE_PALETTE - wxPalette m_palette; - bool m_hasCustomPalette; -#endif // wxUSE_PALETTE - -private: - DECLARE_NO_COPY_CLASS(wxDCBase) - DECLARE_ABSTRACT_CLASS(wxDCBase) -}; - -#endif // wxUSE_NEW_DC - -// ---------------------------------------------------------------------------- -// now include the declaration of wxDC class -// ---------------------------------------------------------------------------- - -#if defined(__WXPALMOS__) - #include "wx/palmos/dc.h" -#elif defined(__WXMSW__) - #include "wx/msw/dc.h" -#elif defined(__WXMOTIF__) - #include "wx/motif/dc.h" -#elif defined(__WXGTK20__) - #include "wx/gtk/dc.h" -#elif defined(__WXGTK__) - #include "wx/gtk1/dc.h" -#elif defined(__WXX11__) - #include "wx/x11/dc.h" -#elif defined(__WXMGL__) - #include "wx/mgl/dc.h" -#elif defined(__WXDFB__) - #include "wx/dfb/dc.h" -#elif defined(__WXMAC__) - #include "wx/mac/dc.h" -#elif defined(__WXCOCOA__) - #include "wx/cocoa/dc.h" -#elif defined(__WXPM__) - #include "wx/os2/dc.h" -#endif - -#if wxUSE_GRAPHICS_CONTEXT - #include "wx/dcgraph.h" -#endif - // ---------------------------------------------------------------------------- // helper class: you can use it to temporarily change the DC text colour and // restore it automatically when the object goes out of scope diff --git a/include/wx/dcbuffer.h b/include/wx/dcbuffer.h index 1ef12f47b4..30598a1d3e 100644 --- a/include/wx/dcbuffer.h +++ b/include/wx/dcbuffer.h @@ -41,7 +41,7 @@ // is private style and not returned by GetStyle. #define wxBUFFER_USES_SHARED_BUFFER 0x04 -class WXDLLEXPORT wxBufferedDC : public wxMemoryDC +class WXDLLIMPEXP_CORE wxBufferedDC : public wxMemoryDC { public: // Default ctor, must subsequently call Init for two stage construction. @@ -149,7 +149,7 @@ private: // Creates a double buffered wxPaintDC, optionally allowing the // user to specify their own buffer to use. -class WXDLLEXPORT wxBufferedPaintDC : public wxBufferedDC +class WXDLLIMPEXP_CORE wxBufferedPaintDC : public wxBufferedDC { public: // If no bitmap is supplied by the user, a temporary one will be created. @@ -219,7 +219,7 @@ private: #ifdef __WXDEBUG__ -class wxAutoBufferedPaintDC : public wxAutoBufferedPaintDCBase +class WXDLLIMPEXP_CORE wxAutoBufferedPaintDC : public wxAutoBufferedPaintDCBase { public: @@ -247,7 +247,7 @@ private: #else // !__WXDEBUG__ // In release builds, just use typedef -typedef wxAutoBufferedPaintDCBase wxAutoBufferedPaintDC; +typedef WXDLLIMPEXP_CORE wxAutoBufferedPaintDCBase wxAutoBufferedPaintDC; #endif diff --git a/include/wx/dcclient.h b/include/wx/dcclient.h index d8076390a4..27aae06a02 100644 --- a/include/wx/dcclient.h +++ b/include/wx/dcclient.h @@ -12,31 +12,49 @@ #ifndef _WX_DCCLIENT_H_BASE_ #define _WX_DCCLIENT_H_BASE_ -#include "wx/defs.h" - -#if defined(__WXPALMOS__) -#include "wx/palmos/dcclient.h" -#elif defined(__WXMSW__) -#include "wx/msw/dcclient.h" -#elif defined(__WXMOTIF__) -#include "wx/motif/dcclient.h" -#elif defined(__WXGTK20__) -#include "wx/gtk/dcclient.h" -#elif defined(__WXGTK__) -#include "wx/gtk1/dcclient.h" -#elif defined(__WXX11__) -#include "wx/x11/dcclient.h" -#elif defined(__WXMGL__) -#include "wx/mgl/dcclient.h" -#elif defined(__WXDFB__) -#include "wx/dfb/dcclient.h" -#elif defined(__WXMAC__) -#include "wx/mac/dcclient.h" -#elif defined(__WXCOCOA__) -#include "wx/cocoa/dcclient.h" -#elif defined(__WXPM__) -#include "wx/os2/dcclient.h" -#endif +#include "wx/dc.h" + +//----------------------------------------------------------------------------- +// wxWindowDC +//----------------------------------------------------------------------------- + +class WXDLLIMPEXP_CORE wxWindowDC : public wxDC +{ +public: + wxWindowDC(); + wxWindowDC( wxWindow *win ); + +private: + DECLARE_DYNAMIC_CLASS(wxWindowDC) +}; + +//----------------------------------------------------------------------------- +// wxClientDC +//----------------------------------------------------------------------------- + +class WXDLLIMPEXP_CORE wxClientDC : public wxWindowDC +{ +public: + wxClientDC(); + wxClientDC( wxWindow *win ); + +private: + DECLARE_DYNAMIC_CLASS(wxClientDC) +}; + +//----------------------------------------------------------------------------- +// wxPaintDC +//----------------------------------------------------------------------------- + +class WXDLLIMPEXP_CORE wxPaintDC : public wxClientDC +{ +public: + wxPaintDC(); + wxPaintDC( wxWindow *win ); + +private: + DECLARE_DYNAMIC_CLASS(wxPaintDC) +}; #endif // _WX_DCCLIENT_H_BASE_ diff --git a/include/wx/dcgraph.h b/include/wx/dcgraph.h index 7ac6f8b47e..61d7104efa 100644 --- a/include/wx/dcgraph.h +++ b/include/wx/dcgraph.h @@ -20,27 +20,32 @@ class WXDLLIMPEXP_FWD_CORE wxWindowDC; -#ifdef __WXMAC__ -#define wxGCDC wxDC -#endif -class WXDLLEXPORT wxGCDC: -#ifdef __WXMAC__ - public wxDCBase -#else - public wxDC -#endif +class WXDLLEXPORT wxGCDC: public wxDC { +public: + wxGCDC( const wxWindowDC& dc ); + wxGCDC( const wxMemoryDC& dc ); + wxGCDC(); + + wxGraphicsContext* GetGraphicsContext(); + void SetGraphicsContext( wxGraphicsContext* ctx ); + +private: DECLARE_DYNAMIC_CLASS(wxGCDC) DECLARE_NO_COPY_CLASS(wxGCDC) +}; + + +class WXDLLEXPORT wxGCDCImpl: public wxDCImpl +{ public: - wxGCDC(const wxWindowDC& dc); -#ifdef __WXMSW__ - wxGCDC( const wxMemoryDC& dc); -#endif - wxGCDC(); - virtual ~wxGCDC(); + wxGCDCImpl( wxDC *owner, const wxWindowDC& dc ); + wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ); + wxGCDCImpl( wxDC *owner ); + + virtual ~wxGCDCImpl(); void Init(); @@ -190,6 +195,10 @@ protected: double m_formerScaleX, m_formerScaleY; wxGraphicsContext* m_graphicContext; + +private: + DECLARE_CLASS(wxGCDCImpl) + DECLARE_NO_COPY_CLASS(wxGCDCImpl) }; #endif diff --git a/include/wx/dcmemory.h b/include/wx/dcmemory.h index 12eef132aa..d84d5be6d8 100644 --- a/include/wx/dcmemory.h +++ b/include/wx/dcmemory.h @@ -15,9 +15,6 @@ #include "wx/dc.h" #include "wx/bitmap.h" - -#if wxUSE_NEW_DC - //----------------------------------------------------------------------------- // wxMemoryDC //----------------------------------------------------------------------------- @@ -44,70 +41,5 @@ private: }; - -#else - -// NOTE: different native implementations of wxMemoryDC will derive from -// different wxDC classes (wxPaintDC, wxWindowDC, etc), so that -// we cannot derive wxMemoryDCBase from wxDC and then use it as the -// only base class for native impl of wxMemoryDC... -class WXDLLEXPORT wxMemoryDCBase -{ -public: - wxMemoryDCBase() { } - - // avoid warnings about having virtual functions but non virtual dtor - virtual ~wxMemoryDCBase() { } - - // select the given bitmap to draw on it - void SelectObject(wxBitmap& bmp) - { - // make sure that the given wxBitmap is not sharing its data with other - // wxBitmap instances as its contents will be modified by any drawing - // operation done on this DC - if (bmp.IsOk()) - bmp.UnShare(); - - DoSelect(bmp); - } - - // select the given bitmap for read-only - virtual void SelectObjectAsSource(const wxBitmap& bmp) - { - DoSelect(bmp); - } - -protected: - virtual void DoSelect(const wxBitmap& bmp) = 0; -}; - - -#endif - - -#if defined(__WXPALMOS__) -#include "wx/palmos/dcmemory.h" -#elif defined(__WXMSW__) -#include "wx/msw/dcmemory.h" -#elif defined(__WXMOTIF__) -#include "wx/motif/dcmemory.h" -#elif defined(__WXGTK20__) -#include "wx/gtk/dcmemory.h" -#elif defined(__WXGTK__) -#include "wx/gtk1/dcmemory.h" -#elif defined(__WXX11__) -#include "wx/x11/dcmemory.h" -#elif defined(__WXMGL__) -#include "wx/mgl/dcmemory.h" -#elif defined(__WXDFB__) -#include "wx/dfb/dcmemory.h" -#elif defined(__WXMAC__) -#include "wx/mac/dcmemory.h" -#elif defined(__WXCOCOA__) -#include "wx/cocoa/dcmemory.h" -#elif defined(__WXPM__) -#include "wx/os2/dcmemory.h" -#endif - #endif // _WX_DCMEMORY_H_BASE_ diff --git a/include/wx/dcprint.h b/include/wx/dcprint.h index 338f2f017a..2ae605b7e4 100644 --- a/include/wx/dcprint.h +++ b/include/wx/dcprint.h @@ -16,8 +16,6 @@ #if wxUSE_PRINTING_ARCHITECTURE -#if wxUSE_NEW_DC - #include "wx/dc.h" //----------------------------------------------------------------------------- @@ -38,22 +36,9 @@ private: DECLARE_DYNAMIC_CLASS() }; -#else - -#if defined(__WXPALMOS__) -#include "wx/palmos/dcprint.h" -#elif defined(__WXMSW__) -#include "wx/msw/dcprint.h" -#endif -#if defined(__WXPM__) -#include "wx/os2/dcprint.h" -#endif -#if defined(__WXMAC__) -#include "wx/mac/dcprint.h" -#endif - -#endif // wxUSE_NEW_DC -#endif // wxUSE_PRINTING_ARCHITECTURE +#endif + // wxUSE_PRINTING_ARCHITECTURE + #endif // _WX_DCPRINT_H_BASE_ diff --git a/include/wx/dcscreen.h b/include/wx/dcscreen.h index cc5a8832a9..763ccb830b 100644 --- a/include/wx/dcscreen.h +++ b/include/wx/dcscreen.h @@ -15,9 +15,7 @@ #include "wx/defs.h" #include "wx/dc.h" -#if wxUSE_NEW_DC - -class WXDLLIMPEXP_CORE wxScreenDC : public wxWindowDC +class WXDLLIMPEXP_CORE wxScreenDC : public wxDC { public: wxScreenDC(); @@ -33,32 +31,6 @@ private: DECLARE_DYNAMIC_CLASS(wxScreenDC) }; -#endif - -#if defined(__WXPALMOS__) -#include "wx/palmos/dcscreen.h" -#elif defined(__WXMSW__) -#include "wx/msw/dcscreen.h" -#elif defined(__WXMOTIF__) -#include "wx/motif/dcscreen.h" -#elif defined(__WXGTK20__) -#include "wx/gtk/dcscreen.h" -#elif defined(__WXGTK__) -#include "wx/gtk1/dcscreen.h" -#elif defined(__WXX11__) -#include "wx/x11/dcscreen.h" -#elif defined(__WXMGL__) -#include "wx/mgl/dcscreen.h" -#elif defined(__WXDFB__) -#include "wx/dfb/dcscreen.h" -#elif defined(__WXMAC__) -#include "wx/mac/dcscreen.h" -#elif defined(__WXCOCOA__) -#include "wx/cocoa/dcscreen.h" -#elif defined(__WXPM__) -#include "wx/os2/dcscreen.h" -#endif - #endif // _WX_DCSCREEN_H_BASE_ diff --git a/include/wx/dcsvg.h b/include/wx/dcsvg.h index cd3f46d474..b30d21790c 100644 --- a/include/wx/dcsvg.h +++ b/include/wx/dcsvg.h @@ -31,23 +31,23 @@ class WXDLLIMPEXP_FWD_BASE wxFileOutputStream; #if wxUSE_NEW_DC class WXDLLIMPEXP_FWD_BASE wxSVGFileDC; -class WXDLLIMPEXP_CORE wxSVGFileImplDC : public wxImplDC +class WXDLLIMPEXP_CORE wxSVGFileDCImpl : public wxDCImpl #else -#define wxSVGFileImplDC wxSVGFileDC +#define wxSVGFileDCImpl wxSVGFileDC class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC #endif { public: #if wxUSE_NEW_DC - wxSVGFileImplDC( wxSVGFileDC *owner, const wxString &filename, + wxSVGFileDCImpl( wxSVGFileDC *owner, const wxString &filename, int width=320, int height=240, double dpi=72.0 ); #else wxSVGFileDC( const wxString &filename, int width=320, int height=240, double dpi=72.0 ); #endif - virtual ~wxSVGFileImplDC(); + virtual ~wxSVGFileDCImpl(); bool IsOk() const { return m_OK; } @@ -217,7 +217,7 @@ private: double m_dpi; private: - DECLARE_ABSTRACT_CLASS(wxSVGFileImplDC) + DECLARE_ABSTRACT_CLASS(wxSVGFileDCImpl) }; @@ -228,7 +228,7 @@ public: wxSVGFileDC( const wxString &filename, int width=320, int height=240, double dpi=72.0 ) { - m_pimpl = new wxSVGFileImplDC( this, filename, width, height, dpi ); + m_pimpl = new wxSVGFileDCImpl( this, filename, width, height, dpi ); } }; #endif diff --git a/include/wx/generic/dcpsg.h b/include/wx/generic/dcpsg.h index 4e84bfeffe..4e05b2e930 100644 --- a/include/wx/generic/dcpsg.h +++ b/include/wx/generic/dcpsg.h @@ -44,18 +44,18 @@ private: #endif #if wxUSE_NEW_DC -class WXDLLEXPORT wxPostScriptImplDC : public wxImplDC +class WXDLLEXPORT wxPostScriptDCImpl : public wxDCImpl #else -#define wxPostScriptImplDC wxPostScriptDC +#define wxPostScriptDCImpl wxPostScriptDC class WXDLLEXPORT wxPostScriptDC : public wxDC #endif { public: #if wxUSE_NEW_DC - wxPostScriptImplDC( wxPrinterDC *owner ); - wxPostScriptImplDC( wxPrinterDC *owner, const wxPrintData& data ); - wxPostScriptImplDC( wxPostScriptDC *owner ); - wxPostScriptImplDC( wxPostScriptDC *owner, const wxPrintData& data ); + wxPostScriptDCImpl( wxPrinterDC *owner ); + wxPostScriptDCImpl( wxPrinterDC *owner, const wxPrintData& data ); + wxPostScriptDCImpl( wxPostScriptDC *owner ); + wxPostScriptDCImpl( wxPostScriptDC *owner, const wxPrintData& data ); #else wxPostScriptDC(); @@ -65,7 +65,7 @@ public: void Init(); - virtual ~wxPostScriptImplDC(); + virtual ~wxPostScriptDCImpl(); virtual bool Ok() const { return IsOk(); } virtual bool IsOk() const; @@ -168,7 +168,7 @@ protected: double m_pageHeight; private: - DECLARE_DYNAMIC_CLASS(wxPostScriptImplDC) + DECLARE_DYNAMIC_CLASS(wxPostScriptDCImpl) }; #endif diff --git a/include/wx/generic/prntdlgg.h b/include/wx/generic/prntdlgg.h index 9c3f717ce2..79e3c9d099 100644 --- a/include/wx/generic/prntdlgg.h +++ b/include/wx/generic/prntdlgg.h @@ -23,6 +23,7 @@ #include "wx/printdlg.h" #include "wx/listctrl.h" +#include "wx/dc.h" #if wxUSE_POSTSCRIPT #include "wx/dcps.h" #endif diff --git a/include/wx/graphics.h b/include/wx/graphics.h index a9abd36406..4390621291 100644 --- a/include/wx/graphics.h +++ b/include/wx/graphics.h @@ -395,10 +395,7 @@ public: virtual ~wxGraphicsContext(); static wxGraphicsContext* Create( const wxWindowDC& dc) ; - -#ifdef __WXMSW__ static wxGraphicsContext * Create( const wxMemoryDC& dc) ; -#endif static wxGraphicsContext* CreateFromNative( void * context ) ; @@ -654,9 +651,8 @@ public : // Context virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0 ; -#ifdef __WXMSW__ virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc) = 0 ; -#endif + virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ) = 0; virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ) = 0; diff --git a/include/wx/gtk/dataview.h b/include/wx/gtk/dataview.h index 4011143485..c85c6d34f7 100644 --- a/include/wx/gtk/dataview.h +++ b/include/wx/gtk/dataview.h @@ -414,7 +414,7 @@ protected: virtual void DoSetIndent(); private: - friend class wxDataViewCtrlDC; + friend class wxDataViewCtrlDCImpl; friend class wxDataViewColumn; friend class wxGtkDataViewModelNotifier; GtkWidget *m_treeview; diff --git a/include/wx/gtk/dc.h b/include/wx/gtk/dc.h index d19fbdc1d2..e66316d56a 100644 --- a/include/wx/gtk/dc.h +++ b/include/wx/gtk/dc.h @@ -15,22 +15,11 @@ // wxDC //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -class WXDLLIMPEXP_CORE wxGTKImplDC : public wxImplDC -#else -#define wxGTKImplDC wxDC -class WXDLLIMPEXP_CORE wxDC : public wxDCBase -#endif - +class WXDLLIMPEXP_CORE wxGTKDCImpl : public wxDCImpl { public: -#if wxUSE_NEW_DC - wxGTKImplDC( wxDC *owner ); -#else - wxDC(); -#endif - - virtual ~wxGTKImplDC(); + wxGTKDCImpl( wxDC *owner ); + virtual ~wxGTKDCImpl(); #if wxUSE_PALETTE void SetColourMap( const wxPalette& palette ) { SetPalette(palette); }; @@ -52,10 +41,10 @@ protected: virtual void DoGetSizeMM(int* width, int* height) const; private: - DECLARE_ABSTRACT_CLASS(wxGTKImplDC) + DECLARE_ABSTRACT_CLASS(wxGTKDCImpl) }; -// this must be defined when wxDC::Blit() honours the DC origian and needed to +// this must be defined when wxDC::Blit() honours the DC origin and needed to // allow wxUniv code in univ/winuniv.cpp to work with versions of wxGTK // 2.3.[23] #ifndef wxHAS_WORKING_GTK_DC_BLIT diff --git a/include/wx/gtk/dcclient.h b/include/wx/gtk/dcclient.h index 065e32a235..41cc073dac 100644 --- a/include/wx/gtk/dcclient.h +++ b/include/wx/gtk/dcclient.h @@ -11,33 +11,23 @@ #define __GTKDCCLIENTH__ #include "wx/dc.h" +#include "wx/gtk/dc.h" +#include "wx/dcclient.h" #include "wx/region.h" class WXDLLIMPEXP_FWD_CORE wxWindow; //----------------------------------------------------------------------------- -// wxWindowDC +// wxWindowDCImpl //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -class WXDLLIMPEXP_CORE wxGTKWindowImplDC : public wxGTKImplDC -#else -#define wxGTKWindowImplDC wxWindowDC -class WXDLLIMPEXP_CORE wxWindowDC : public wxDC -#endif +class WXDLLIMPEXP_CORE wxWindowDCImpl : public wxGTKDCImpl { public: + wxWindowDCImpl( wxDC *owner ); + wxWindowDCImpl( wxDC *owner, wxWindow *win ); - -#if wxUSE_NEW_DC - wxGTKWindowImplDC( wxDC *owner ); - wxGTKWindowImplDC( wxDC *owner, wxWindow *win ); -#else - wxWindowDC(); - wxWindowDC( wxWindow *win ); -#endif - - virtual ~wxGTKWindowImplDC(); + virtual ~wxWindowDCImpl(); virtual bool CanDrawBitmap() const { return true; } virtual bool CanGetTextExtent() const { return true; } @@ -116,14 +106,13 @@ public: // implementation // -------------- - GdkWindow *m_window; + GdkWindow *m_gdkwindow; GdkGC *m_penGC; GdkGC *m_brushGC; GdkGC *m_textGC; GdkGC *m_bgGC; GdkColormap *m_cmap; bool m_isScreenDC; - wxWindow *m_owningWindow; wxRegion m_currentClippingRegion; wxRegion m_paintClippingRegion; @@ -137,63 +126,43 @@ public: virtual void ComputeScaleAndOrigin(); - virtual GdkWindow *GetGDKWindow() const { return m_window; } + virtual GdkWindow *GetGDKWindow() const { return m_gdkwindow; } private: - DECLARE_ABSTRACT_CLASS(wxGTKWindowImplDC) + DECLARE_ABSTRACT_CLASS(wxWindowDCImpl) }; //----------------------------------------------------------------------------- -// wxClientDC +// wxClientDCImpl //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -class WXDLLIMPEXP_CORE wxGTKClientImplDC : public wxGTKWindowImplDC -#else -#define wxGTKClientImplDC wxClientDC -class WXDLLIMPEXP_CORE wxClientDC : public wxWindowDC -#endif +class WXDLLIMPEXP_CORE wxClientDCImpl : public wxWindowDCImpl { public: - -#if wxUSE_NEW_DC - wxGTKClientImplDC( wxDC *owner ); - wxGTKClientImplDC( wxDC *owner, wxWindow *win ); -#else - wxClientDC(); - wxClientDC( wxWindow *win ); -#endif + wxClientDCImpl( wxDC *owner ); + wxClientDCImpl( wxDC *owner, wxWindow *win ); protected: virtual void DoGetSize(int *width, int *height) const; private: - DECLARE_ABSTRACT_CLASS(wxGTKClientImplDC) + DECLARE_ABSTRACT_CLASS(wxClientDCImpl) }; //----------------------------------------------------------------------------- -// wxPaintDC +// wxPaintDCImpl //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -class WXDLLIMPEXP_CORE wxGTKPaintImplDC : public wxGTKClientImplDC -#else -#define wxGTKPaintImplDC wxPaintDC -class WXDLLIMPEXP_CORE wxPaintDC : public wxClientDC -#endif +class WXDLLIMPEXP_CORE wxPaintDCImpl : public wxClientDCImpl { public: - -#if wxUSE_NEW_DC - wxGTKPaintImplDC( wxDC *owner ); - wxGTKPaintImplDC( wxDC *owner, wxWindow *win ); -#else - wxPaintDC(); - wxPaintDC( wxWindow *win ); -#endif + wxPaintDCImpl( wxDC *owner ); + wxPaintDCImpl( wxDC *owner, wxWindow *win ); private: - DECLARE_ABSTRACT_CLASS(wxGTKPaintImplDC) + DECLARE_ABSTRACT_CLASS(wxPaintDCImpl) }; -#endif // __GTKDCCLIENTH__ +#endif + // __GTKDCCLIENTH__ + diff --git a/include/wx/gtk/dcmemory.h b/include/wx/gtk/dcmemory.h index b987d4609d..eefcadab27 100644 --- a/include/wx/gtk/dcmemory.h +++ b/include/wx/gtk/dcmemory.h @@ -10,33 +10,21 @@ #ifndef _WX_GTK_DCMEMORY_H_ #define _WX_GTK_DCMEMORY_H_ -#include "wx/dcclient.h" +#include "wx/dcmemory.h" +#include "wx/gtk/dcclient.h" //----------------------------------------------------------------------------- -// wxMemoryDC +// wxMemoryDCImpl //----------------------------------------------------------------------------- - -#if wxUSE_NEW_DC -class WXDLLIMPEXP_CORE wxGTKMemoryImplDC : public wxGTKWindowImplDC -#else -#define wxGTKMemoryImplDC wxMemoryDC -class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC, public wxMemoryDCBase -#endif +class WXDLLIMPEXP_CORE wxMemoryDCImpl : public wxWindowDCImpl { public: - -#if wxUSE_NEW_DC - wxGTKMemoryImplDC( wxMemoryDC *owner ); - wxGTKMemoryImplDC( wxMemoryDC *owner, wxBitmap& bitmap ); - wxGTKMemoryImplDC( wxMemoryDC *owner, wxDC *dc ); -#else - wxMemoryDC(); - wxMemoryDC(wxBitmap& bitmap); - wxMemoryDC( wxDC *dc ); -#endif + wxMemoryDCImpl( wxMemoryDC *owner ); + wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap ); + wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ); - virtual ~wxGTKMemoryImplDC(); + virtual ~wxMemoryDCImpl(); // these get reimplemented for mono-bitmaps to behave // more like their Win32 couterparts. They now interpret @@ -49,7 +37,7 @@ public: virtual void SetTextBackground( const wxColour &col ); protected: - // overridden from wxImplDC + // overridden from wxDCImpl virtual void DoGetSize( int *width, int *height ) const; virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const; @@ -66,7 +54,9 @@ private: private: void Init(); - DECLARE_ABSTRACT_CLASS(wxGTKMemoryImplDC) + DECLARE_ABSTRACT_CLASS(wxMemoryDCImpl) }; -#endif // _WX_GTK_DCMEMORY_H_ +#endif + // _WX_GTK_DCMEMORY_H_ + diff --git a/include/wx/gtk/dcscreen.h b/include/wx/gtk/dcscreen.h index 1e8a9425ac..5f9538b4ce 100644 --- a/include/wx/gtk/dcscreen.h +++ b/include/wx/gtk/dcscreen.h @@ -10,35 +10,18 @@ #ifndef __GTKDCSCREENH__ #define __GTKDCSCREENH__ -#include "wx/dcclient.h" +#include "wx/dcscreen.h" +#include "wx/gtk/dcclient.h" //----------------------------------------------------------------------------- -// wxScreenDC +// wxScreenDCImpl //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -class WXDLLIMPEXP_CORE wxGTKScreenImplDC : public wxGTKWindowImplDC -#else -#define wxGTKScreenImplDC wxScreenDC -class WXDLLIMPEXP_CORE wxScreenDC : public wxWindowDC -#endif +class WXDLLIMPEXP_CORE wxScreenDCImpl : public wxWindowDCImpl { public: - -#if wxUSE_NEW_DC - wxGTKScreenImplDC( wxScreenDC *owner ); -#else - wxScreenDC(); -#endif - - ~wxGTKScreenImplDC(); - - static bool StartDrawingOnTop(wxWindow * WXUNUSED(window)) - { return true; } - static bool StartDrawingOnTop(wxRect * WXUNUSED(rect) = NULL) - { return true; } - static bool EndDrawingOnTop() { return true; } - + wxScreenDCImpl( wxScreenDC *owner ); + ~wxScreenDCImpl(); protected: virtual void DoGetSize(int *width, int *height) const; @@ -46,7 +29,7 @@ protected: void Init(); private: - DECLARE_ABSTRACT_CLASS(wxGTKScreenImplDC) + DECLARE_ABSTRACT_CLASS(wxScreenDCImpl) }; #endif // __GTKDCSCREENH__ diff --git a/include/wx/gtk/gnome/gprint.h b/include/wx/gtk/gnome/gprint.h index 7e8b421adf..d4c585e413 100644 --- a/include/wx/gtk/gnome/gprint.h +++ b/include/wx/gtk/gnome/gprint.h @@ -92,7 +92,7 @@ public: wxPageSetupDialogData * data = NULL ); #if wxUSE_NEW_DC - virtual wxImplDC* CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ); + virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); #else virtual wxDC* CreatePrinterDC( const wxPrintData& data ); #endif @@ -212,19 +212,19 @@ private: //----------------------------------------------------------------------------- #if wxUSE_NEW_DC -class wxGnomePrinterImplDC : public wxImplDC +class wxGnomePrinterDCImpl : public wxDCImpl #else -#define wxGnomePrinterImplDC wxGnomePrinterDC +#define wxGnomePrinterDCImpl wxGnomePrinterDC class wxGnomePrinterDC : public wxDC #endif { public: #if wxUSE_NEW_DC - wxGnomePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ); + wxGnomePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); #else wxGnomePrinterDC( const wxPrintData& data ); #endif - virtual ~wxGnomePrinterImplDC(); + virtual ~wxGnomePrinterDCImpl(); bool Ok() const { return IsOk(); } bool IsOk() const; @@ -307,8 +307,8 @@ private: void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height); private: - DECLARE_DYNAMIC_CLASS(wxGnomePrinterImplDC) - DECLARE_NO_COPY_CLASS(wxGnomePrinterImplDC) + DECLARE_DYNAMIC_CLASS(wxGnomePrinterDCImpl) + DECLARE_NO_COPY_CLASS(wxGnomePrinterDCImpl) }; // ---------------------------------------------------------------------------- diff --git a/include/wx/gtk/print.h b/include/wx/gtk/print.h index 492554a6ae..17e0c12e7f 100644 --- a/include/wx/gtk/print.h +++ b/include/wx/gtk/print.h @@ -54,7 +54,7 @@ public: wxPageSetupDialogData * data = NULL ); #if wxUSE_NEW_DC - virtual wxImplDC* CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ); + virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); #else virtual wxDC* CreatePrinterDC( const wxPrintData& data ); #endif @@ -223,19 +223,19 @@ private: //----------------------------------------------------------------------------- #if wxUSE_NEW_DC -class WXDLLIMPEXP_CORE wxGtkPrinterImplDC : public wxImplDC +class WXDLLIMPEXP_CORE wxGtkPrinterDCImpl : public wxDCImpl #else -#define wxGtkPrinterImplDC wxGtkPrinterDC +#define wxGtkPrinterDCImpl wxGtkPrinterDC class WXDLLIMPEXP_CORE wxGtkPrinterDC : public wxDC #endif { public: #if wxUSE_NEW_DC - wxGtkPrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ); + wxGtkPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); #else wxGtkPrinterDC( const wxPrintData& data ); #endif - virtual ~wxGtkPrinterImplDC(); + virtual ~wxGtkPrinterDCImpl(); bool Ok() const { return IsOk(); } bool IsOk() const; @@ -320,8 +320,8 @@ private: double m_PS2DEV; double m_DEV2PS; - DECLARE_DYNAMIC_CLASS(wxGtkPrinterImplDC) - DECLARE_NO_COPY_CLASS(wxGtkPrinterImplDC) + DECLARE_DYNAMIC_CLASS(wxGtkPrinterDCImpl) + DECLARE_NO_COPY_CLASS(wxGtkPrinterDCImpl) }; // ---------------------------------------------------------------------------- diff --git a/include/wx/gtk/private.h b/include/wx/gtk/private.h index 1ca5e884d9..1e1d07f15a 100644 --- a/include/wx/gtk/private.h +++ b/include/wx/gtk/private.h @@ -15,6 +15,9 @@ #include #include "wx/gtk/private/string.h" +#include "wx/gtk/dc.h" +#include "wx/gtk/dcclient.h" +#include "wx/gtk/dcmemory.h" // pango_version_check symbol is quite recent ATM (4/2007)... so we // use our own wrapper which implements a smart trick. diff --git a/include/wx/mac/carbon/dcclient.h b/include/wx/mac/carbon/dcclient.h index 448d6b4322..6bb45e4a73 100644 --- a/include/wx/mac/carbon/dcclient.h +++ b/include/wx/mac/carbon/dcclient.h @@ -13,6 +13,7 @@ #define _WX_DCCLIENT_H_ #include "wx/dc.h" +#include "wx/dcgraph.h" //----------------------------------------------------------------------------- // classes @@ -21,59 +22,52 @@ class WXDLLIMPEXP_FWD_CORE wxPaintDC; class WXDLLIMPEXP_FWD_CORE wxWindow; -class WXDLLEXPORT wxWindowDC: public wxDC +class WXDLLEXPORT wxWindowDCImpl: public wxGCDCImpl { - DECLARE_DYNAMIC_CLASS(wxWindowDC) - - public: - wxWindowDC(void); - - // Create a DC corresponding to a canvas - wxWindowDC(wxWindow *win); - - virtual ~wxWindowDC(void); - wxWindow *GetWindow() const { return m_window; } - protected : +public: + wxWindowDCImpl( wxDC *owner ); + wxWindowDCImpl( wxDC *owner, wxWindow *window ); + virtual ~wxWindowDCImpl(); + +protected : virtual void DoGetSize( int *width, int *height ) const; virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const; - wxWindow *m_window; - bool m_release; - int m_width; - int m_height; + bool m_release; + int m_width; + int m_height; +private: + DECLARE_CLASS(wxWindowDCImpl) + DECLARE_NO_COPY_CLASS(wxWindowDCImpl) }; -class WXDLLEXPORT wxClientDC: public wxWindowDC +class WXDLLEXPORT wxClientDCImpl: public wxWindowDCImpl { - DECLARE_DYNAMIC_CLASS(wxClientDC) - - public: - wxClientDC(void); - - // Create a DC corresponding to a canvas - wxClientDC(wxWindow *win); - - virtual ~wxClientDC(void); - -protected: +public: + wxClientDCImpl( wxDC *owner ); + wxClientDCImpl( wxDC *owner, wxWindow *window ); + virtual ~wxClientDCImpl(); + +private: + DECLARE_CLASS(wxClientDCImpl) + DECLARE_NO_COPY_CLASS(wxClientDCImpl) }; -class WXDLLEXPORT wxPaintDC: public wxWindowDC -{ - DECLARE_DYNAMIC_CLASS(wxPaintDC) - - public: - wxPaintDC(void); - // Create a DC corresponding to a canvas - wxPaintDC(wxWindow *win); - - virtual ~wxPaintDC(void); +class WXDLLEXPORT wxPaintDCImpl: public wxWindowDCImpl +{ +public: + wxPaintDCImpl( wxDC *owner ); + wxPaintDCImpl( wxDC *owner, wxWindow *win ); + virtual ~wxPaintDCImpl(); protected: + DECLARE_CLASS(wxPaintDCImpl) + DECLARE_NO_COPY_CLASS(wxPaintDCImpl) }; + #endif // _WX_DCCLIENT_H_ diff --git a/include/wx/mac/carbon/dcmemory.h b/include/wx/mac/carbon/dcmemory.h index d2eb3d4acc..e97091b201 100644 --- a/include/wx/mac/carbon/dcmemory.h +++ b/include/wx/mac/carbon/dcmemory.h @@ -12,33 +12,31 @@ #ifndef _WX_DCMEMORY_H_ #define _WX_DCMEMORY_H_ -#include "wx/dcclient.h" +#include "wx/mac/carbon/dcclient.h" -class WXDLLEXPORT wxMemoryDC: public wxPaintDC, public wxMemoryDCBase +class WXDLLEXPORT wxMemoryDCImpl: public wxPaintDCImpl { - DECLARE_DYNAMIC_CLASS(wxMemoryDC) - public: - wxMemoryDC() { Init(); } - wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); } - wxMemoryDC( wxDC *dc ); // Create compatible DC - virtual ~wxMemoryDC(void); - - const wxBitmap& GetSelectedBitmap() const { return m_selected; } - wxBitmap GetSelectedBitmap() { return m_selected; } - - wxBitmap GetSelectedObject() { return GetSelectedBitmap() ; } + wxMemoryDCImpl( wxMemoryDC *owner ); + wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap ); + wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ); + + virtual ~wxMemoryDCImpl(); protected: virtual void DoGetSize( int *width, int *height ) const; virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const - { return subrect == NULL ? GetSelectedBitmap() : GetSelectedBitmap().GetSubBitmap(*subrect); } + { return subrect == NULL ? GetSelectedBitmap() : GetSelectedBitmap().GetSubBitmap(*subrect); } virtual void DoSelect(const wxBitmap& bitmap); private: void Init(); wxBitmap m_selected; + +private: + DECLARE_CLASS(wxMemoryDCImpl) + DECLARE_NO_COPY_CLASS(wxMemoryDCImpl) }; #endif diff --git a/include/wx/mac/carbon/dcprint.h b/include/wx/mac/carbon/dcprint.h index 79f8d3b2f7..e11ee31570 100644 --- a/include/wx/mac/carbon/dcprint.h +++ b/include/wx/mac/carbon/dcprint.h @@ -13,19 +13,18 @@ #define _WX_DCPRINT_H_ #include "wx/dc.h" +#include "wx/dcgraph.h" #include "wx/cmndata.h" class wxNativePrinterDC ; -class WXDLLEXPORT wxPrinterDC: public wxDC +class WXDLLEXPORT wxPrinterDCImpl: public wxGCDCImpl { - public: +public: #if wxUSE_PRINTING_ARCHITECTURE - DECLARE_CLASS(wxPrinterDC) - // Create a printer DC - wxPrinterDC(const wxPrintData& printdata ); - virtual ~wxPrinterDC(); + wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& printdata ); + virtual ~wxPrinterDCImpl(); virtual bool StartDoc( const wxString& WXUNUSED(message) ) ; virtual void EndDoc(void) ; @@ -36,10 +35,15 @@ class WXDLLEXPORT wxPrinterDC: public wxDC wxPrintData& GetPrintData() { return m_printData; } virtual wxSize GetPPI() const; - protected: + +protected: virtual void DoGetSize( int *width, int *height ) const; - wxPrintData m_printData ; + + wxPrintData m_printData ; wxNativePrinterDC* m_nativePrinterDC ; + +private: + DECLARE_CLASS(wxPrinterDC) #endif // wxUSE_PRINTING_ARCHITECTURE }; diff --git a/include/wx/mac/carbon/dcscreen.h b/include/wx/mac/carbon/dcscreen.h index 6b126f54bd..a687ee80a4 100644 --- a/include/wx/mac/carbon/dcscreen.h +++ b/include/wx/mac/carbon/dcscreen.h @@ -13,23 +13,20 @@ #define _WX_DCSCREEN_H_ #include "wx/dcclient.h" +#include "wx/mac/carbon/dcclient.h" -class WXDLLEXPORT wxScreenDC: public wxWindowDC +class WXDLLEXPORT wxScreenDCImpl: public wxWindowDCImpl { - DECLARE_DYNAMIC_CLASS(wxScreenDC) +public: + wxScreenDCImpl( wxDC *owner ); + virtual ~wxScreenDCImpl(); - public: - // Create a DC representing the whole screen - wxScreenDC(); - virtual ~wxScreenDC(); - - // Compatibility with X's requirements for - // drawing on top of all windows - static bool StartDrawingOnTop(wxWindow* WXUNUSED(window)) { return TRUE; } - static bool StartDrawingOnTop(wxRect* WXUNUSED(rect) = NULL) { return TRUE; } - static bool EndDrawingOnTop() { return TRUE; } - private: - void* m_overlayWindow; +private: + void* m_overlayWindow; + +private: + DECLARE_CLASS(wxScreenDCImpl) + DECLARE_NO_COPY_CLASS(wxScreenDCImpl) }; #endif diff --git a/include/wx/mac/carbon/metafile.h b/include/wx/mac/carbon/metafile.h index 21ee5672d4..119ed37967 100644 --- a/include/wx/mac/carbon/metafile.h +++ b/include/wx/mac/carbon/metafile.h @@ -22,6 +22,8 @@ #include "wx/dataobj.h" #endif +#include "wx/mac/carbon/dcclient.h" + /* * Metafile and metafile device context classes * @@ -65,32 +67,56 @@ public: #endif }; -class WXDLLEXPORT wxMetafileDC: public wxDC -{ - DECLARE_DYNAMIC_CLASS(wxMetafileDC) - public: - // the ctor parameters specify the filename (empty for memory metafiles), - // the metafile picture size and the optional description/comment - wxMetafileDC(const wxString& filename = wxEmptyString, - int width = 0, int height = 0, - const wxString& description = wxEmptyString); +class WXDLLEXPORT wxMetafileDCImpl: public wxGCDCImpl +{ +public: + wxMetafileDCImpl( wxDC *owner, + const wxString& filename, + int width, int height, + const wxString& description ); - virtual ~wxMetafileDC(void); + virtual ~wxMetafileDCImpl(); - // Should be called at end of drawing - virtual wxMetafile *Close(void); + // Should be called at end of drawing + virtual wxMetafile *Close(); - // Implementation - inline wxMetafile *GetMetaFile(void) const { return m_metaFile; } - inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; } + // Implementation + wxMetafile *GetMetaFile(void) const { return m_metaFile; } + void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; } protected: virtual void DoGetSize(int *width, int *height) const; - wxMetafile* m_metaFile; + wxMetafile* m_metaFile; + +private: + DECLARE_CLASS(wxMetafileDCImpl) + DECLARE_NO_COPY_CLASS(wxMetafileDCImpl) }; +class WXDLLEXPORT wxMetafileDC: public wxDC +{ + public: + // the ctor parameters specify the filename (empty for memory metafiles), + // the metafile picture size and the optional description/comment + wxMetafileDC( const wxString& filename = wxEmptyString, + int width = 0, int height = 0, + const wxString& description = wxEmptyString ) + { m_pimpl = new wxMetafileDCImpl( this, filename, width, height, description ); } + + wxMetafile *GetMetafile() const + { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); } + + wxMetafile *Close() + { return ((wxMetafileDCImpl*)m_pimpl)->Close(); } + +private: + DECLARE_CLASS(wxMetafileDC) + DECLARE_NO_COPY_CLASS(wxMetafileDC) +}; + + /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, diff --git a/include/wx/mac/carbon/private.h b/include/wx/mac/carbon/private.h index e73554f676..eb68ae30f2 100644 --- a/include/wx/mac/carbon/private.h +++ b/include/wx/mac/carbon/private.h @@ -29,6 +29,9 @@ typedef SInt32 SRefCon; #if wxUSE_GUI #include "wx/listbox.h" +#include "wx/mac/carbon/dc.h" +#include "wx/mac/carbon/dcclient.h" +#include "wx/mac/carbon/dcmemory.h" class WXDLLEXPORT wxMacCGContextStateSaver { diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h index fc9f9477a2..87abc35421 100644 --- a/include/wx/msw/dc.h +++ b/include/wx/msw/dc.h @@ -13,6 +13,7 @@ #define _WX_MSW_DC_H_ #include "wx/defs.h" +#include "wx/dc.h" // --------------------------------------------------------------------------- // macros @@ -42,11 +43,11 @@ public: // this is an ABC: use one of the derived classes to create a DC associated // with a window, screen, printer and so on -class WXDLLEXPORT wxDC : public wxDCBase +class WXDLLEXPORT wxMSWDCImpl: public wxDCImpl { public: - wxDC(WXHDC hDC) { Init(); m_hDC = hDC; } - virtual ~wxDC(); + wxMSWDCImpl(wxDC *owner, WXHDC hDC); + virtual ~wxMSWDCImpl(); // implement base class pure virtuals // ---------------------------------- @@ -94,10 +95,9 @@ public: virtual void SetRop(WXHDC cdc); virtual void SelectOldObjects(WXHDC dc); - wxWindow *GetWindow() const { return m_canvas; } void SetWindow(wxWindow *win) { - m_canvas = win; + m_window = win; #if wxUSE_PALETTE // if we have palettes use the correct one for this window @@ -145,7 +145,6 @@ public: protected: void Init() { - m_canvas = NULL; m_bOwnsDC = false; m_hDC = NULL; @@ -161,7 +160,7 @@ protected: // create an uninitialized DC: this should be only used by the derived // classes - wxDC() { Init(); } + wxMSWDCImpl( wxDC *owner ) : wxDCImpl( owner ) { Init(); } void RealizeScaleAndOrigin(); @@ -302,12 +301,12 @@ protected: #endif // wxUSE_PALETTE #if wxUSE_DC_CACHEING - static wxList sm_bitmapCache; - static wxList sm_dcCache; + static wxObjectList sm_bitmapCache; + static wxObjectList sm_dcCache; #endif - DECLARE_DYNAMIC_CLASS(wxDC) - DECLARE_NO_COPY_CLASS(wxDC) + DECLARE_CLASS(wxMSWDCImpl) + DECLARE_NO_COPY_CLASS(wxMSWDCImpl) }; // ---------------------------------------------------------------------------- @@ -315,18 +314,18 @@ protected: // only/mainly) // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxDCTemp : public wxDC +class WXDLLEXPORT wxDCTempImpl: public wxMSWDCImpl { public: // construct a temporary DC with the specified HDC and size (it should be // specified whenever we know it for this HDC) - wxDCTemp(WXHDC hdc, const wxSize& size = wxDefaultSize) - : wxDC(hdc), + wxDCTempImpl(wxDC *owner, WXHDC hdc, const wxSize& size ) + : wxMSWDCImpl( owner, hdc ), m_size(size) { } - virtual ~wxDCTemp() + virtual ~wxDCTempImpl() { // prevent base class dtor from freeing it SetHDC((WXHDC)NULL); @@ -349,8 +348,20 @@ private: // find it ourselves const wxSize m_size; - DECLARE_NO_COPY_CLASS(wxDCTemp) + DECLARE_NO_COPY_CLASS(wxDCTempImpl) }; +class WXDLLEXPORT wxDCTemp: public wxDC +{ +public: + wxDCTemp( WXHDC hdc, const wxSize& size = wxDefaultSize ) + { + m_pimpl = new wxDCTempImpl( this, hdc, size ); + } + +}; + + + #endif // _WX_MSW_DC_H_ diff --git a/include/wx/msw/dcclient.h b/include/wx/msw/dcclient.h index 6399130d1c..5dfe3bdc6c 100644 --- a/include/wx/msw/dcclient.h +++ b/include/wx/msw/dcclient.h @@ -17,6 +17,8 @@ // ---------------------------------------------------------------------------- #include "wx/dc.h" +#include "wx/msw/dc.h" +#include "wx/dcclient.h" #include "wx/dynarray.h" // ---------------------------------------------------------------------------- @@ -32,14 +34,14 @@ WX_DECLARE_EXPORTED_OBJARRAY(wxPaintDCInfo, wxArrayDCInfo); // DC classes // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxWindowDC : public wxDC +class WXDLLEXPORT wxWindowDCImpl : public wxMSWDCImpl { public: // default ctor - wxWindowDC(); + wxWindowDCImpl( wxDC *owner ); // Create a DC corresponding to the whole window - wxWindowDC(wxWindow *win); + wxWindowDCImpl( wxDC *owner, wxWindow *win ); protected: // initialize the newly created DC @@ -49,19 +51,20 @@ protected: virtual void DoGetSize(int *width, int *height) const; private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxWindowDC) + DECLARE_CLASS(wxWindowDCImpl) + DECLARE_NO_COPY_CLASS(wxWindowDCImpl) }; -class WXDLLEXPORT wxClientDC : public wxWindowDC +class WXDLLEXPORT wxClientDCImpl : public wxWindowDCImpl { public: // default ctor - wxClientDC(); + wxClientDCImpl( wxDC *owner ); // Create a DC corresponding to the client area of the window - wxClientDC(wxWindow *win); + wxClientDCImpl( wxDC *owner, wxWindow *win ); - virtual ~wxClientDC(); + virtual ~wxClientDCImpl(); protected: void InitDC(); @@ -70,18 +73,19 @@ protected: virtual void DoGetSize(int *width, int *height) const; private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxClientDC) + DECLARE_CLASS(wxClientDCImpl) + DECLARE_NO_COPY_CLASS(wxClientDCImpl) }; -class WXDLLEXPORT wxPaintDC : public wxClientDC +class WXDLLEXPORT wxPaintDCImpl : public wxClientDCImpl { public: - wxPaintDC(); + wxPaintDCImpl( wxDC *owner ); // Create a DC corresponding for painting the window in OnPaint() - wxPaintDC(wxWindow *win); + wxPaintDCImpl( wxDC *owner, wxWindow *win ); - virtual ~wxPaintDC(); + virtual ~wxPaintDCImpl(); // find the entry for this DC in the cache (keyed by the window) static WXHDC FindDCInCache(wxWindow* win); @@ -93,7 +97,8 @@ protected: wxPaintDCInfo *FindInCache(size_t *index = NULL) const; private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxPaintDC) + DECLARE_CLASS(wxPaintDCImpl) + DECLARE_NO_COPY_CLASS(wxPaintDCImpl) }; /* @@ -106,10 +111,8 @@ class WXDLLEXPORT wxPaintDCEx : public wxPaintDC { public: wxPaintDCEx(wxWindow *canvas, WXHDC dc); - virtual ~wxPaintDCEx(); + private: - int saveState; - DECLARE_CLASS(wxPaintDCEx) DECLARE_NO_COPY_CLASS(wxPaintDCEx) }; diff --git a/include/wx/msw/dcmemory.h b/include/wx/msw/dcmemory.h index fd2c032c7d..d7c5918fa2 100644 --- a/include/wx/msw/dcmemory.h +++ b/include/wx/msw/dcmemory.h @@ -12,14 +12,15 @@ #ifndef _WX_DCMEMORY_H_ #define _WX_DCMEMORY_H_ -#include "wx/dcclient.h" +#include "wx/dcmemory.h" +#include "wx/msw/dc.h" -class WXDLLEXPORT wxMemoryDC : public wxDC, public wxMemoryDCBase +class WXDLLEXPORT wxMemoryDCImpl: public wxMSWDCImpl { public: - wxMemoryDC() { CreateCompatible(NULL); Init(); } - wxMemoryDC(wxBitmap& bitmap) { CreateCompatible(NULL); Init(); SelectObject(bitmap); } - wxMemoryDC(wxDC *dc); // Create compatible DC + wxMemoryDCImpl( wxMemoryDC *owner ); + wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap ); + wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ); // Create compatible DC protected: @@ -38,7 +39,8 @@ protected: void Init(); private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxMemoryDC) + DECLARE_CLASS(wxMemoryDCImpl) + DECLARE_NO_COPY_CLASS(wxMemoryDCImpl) }; #endif diff --git a/include/wx/msw/dcprint.h b/include/wx/msw/dcprint.h index 29a79daf18..6fe3feab10 100644 --- a/include/wx/msw/dcprint.h +++ b/include/wx/msw/dcprint.h @@ -14,19 +14,20 @@ #if wxUSE_PRINTING_ARCHITECTURE -#include "wx/dc.h" +#include "wx/dcprint.h" #include "wx/cmndata.h" +#include "wx/msw/dc.h" -class WXDLLEXPORT wxPrinterDC : public wxDC +// ------------------------------------------------------------------------ +// wxPrinterDCImpl +// + +class WXDLLEXPORT wxPrinterDCImpl : public wxMSWDCImpl { public: - // Create a printer DC (obsolete function: use wxPrintData version now) - wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = true, int orientation = wxPORTRAIT); - // Create from print data - wxPrinterDC(const wxPrintData& data); - - wxPrinterDC(WXHDC theDC); + wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); + wxPrinterDCImpl( wxPrinterDC *owner, WXHDC theDC ); // override some base class virtuals virtual bool StartDoc(const wxString& message); @@ -34,7 +35,7 @@ public: virtual void StartPage(); virtual void EndPage(); - wxRect GetPaperRect(); + virtual wxRect GetPaperRect(); protected: virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, @@ -55,15 +56,26 @@ protected: wxPrintData m_printData; private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxPrinterDC) + DECLARE_CLASS(wxPrinterDCImpl) + DECLARE_NO_COPY_CLASS(wxPrinterDCImpl) }; -// Gets an HDC for the default printer configuration -// WXHDC WXDLLEXPORT wxGetPrinterDC(int orientation); - // Gets an HDC for the specified printer configuration WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& data); +// ------------------------------------------------------------------------ +// wxPrinterDCromHDC +// + +class WXDLLEXPORT wxPrinterDCFromHDC: public wxPrinterDC +{ +public: + wxPrinterDCFromHDC( WXHDC theDC ) + { + m_pimpl = new wxPrinterDCImpl( this, theDC ); + } +}; + #endif // wxUSE_PRINTING_ARCHITECTURE #endif // _WX_MSW_DCPRINT_H_ diff --git a/include/wx/msw/dcscreen.h b/include/wx/msw/dcscreen.h index f48275e41b..983d052a6a 100644 --- a/include/wx/msw/dcscreen.h +++ b/include/wx/msw/dcscreen.h @@ -12,19 +12,14 @@ #ifndef _WX_MSW_DCSCREEN_H_ #define _WX_MSW_DCSCREEN_H_ -#include "wx/dc.h" +#include "wx/dcscreen.h" +#include "wx/msw/dc.h" -class WXDLLEXPORT wxScreenDC : public wxDC +class WXDLLEXPORT wxScreenDCImpl : public wxMSWDCImpl { public: // Create a DC representing the whole screen - wxScreenDC(); - - // Compatibility with X's requirements for drawing on top of all windows: - // they don't do anything under MSW - static bool StartDrawingOnTop(wxWindow* WXUNUSED(window)) { return true; } - static bool StartDrawingOnTop(wxRect* WXUNUSED(rect) = NULL) { return true; } - static bool EndDrawingOnTop() { return true; } + wxScreenDCImpl( wxScreenDC *owner ); protected: virtual void DoGetSize(int *w, int *h) const @@ -33,7 +28,8 @@ protected: } private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxScreenDC) + DECLARE_CLASS(wxScreenDCImpl) + DECLARE_NO_COPY_CLASS(wxScreenDCImpl) }; #endif // _WX_MSW_DCSCREEN_H_ diff --git a/include/wx/msw/enhmeta.h b/include/wx/msw/enhmeta.h index fa5389b1d0..f03827e52b 100644 --- a/include/wx/msw/enhmeta.h +++ b/include/wx/msw/enhmeta.h @@ -82,19 +82,6 @@ public: int width = 0, int height = 0, const wxString& description = wxEmptyString); - virtual ~wxEnhMetaFileDC(); - - // obtain a pointer to the new metafile (caller should delete it) - wxEnhMetaFile *Close(); - -protected: - virtual void DoGetSize(int *width, int *height) const; - -private: - // size passed to ctor and returned by DoGetSize() - int m_width, - m_height; - DECLARE_DYNAMIC_CLASS_NO_COPY(wxEnhMetaFileDC) }; diff --git a/include/wx/msw/metafile.h b/include/wx/msw/metafile.h index 0ef7398f88..8ac8a37734 100644 --- a/include/wx/msw/metafile.h +++ b/include/wx/msw/metafile.h @@ -72,20 +72,13 @@ private: DECLARE_DYNAMIC_CLASS(wxMetafile) }; -class WXDLLEXPORT wxMetafileDC: public wxDC +class WXDLLEXPORT wxMetafileDCImpl: public wxMSWDCImpl { public: - // Don't supply origin and extent - // Supply them to wxMakeMetaFilePlaceable instead. - wxMetafileDC(const wxString& file = wxEmptyString); - - // Supply origin and extent (recommended). - // Then don't need to supply them to wxMakeMetaFilePlaceable. + wxMetafileDCImpl(const wxString& file = wxEmptyString); wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg); + virtual ~wxMetafileDCImpl(); - virtual ~wxMetafileDC(); - - // Should be called at end of drawing virtual wxMetafile *Close(); virtual void SetMapMode(int mode); virtual void DoGetTextExtent(const wxString& string, @@ -107,9 +100,37 @@ protected: wxMetafile* m_metaFile; private: - DECLARE_DYNAMIC_CLASS(wxMetafileDC) + DECLARE_CLASS(wxMetafileDCImpl) + DECLARE_NO_COPY_CLASS(wxMetafileDCImpl) }; +class WXDLLEXPORT wxMetafileDC: public wxDC +{ +public: + // Don't supply origin and extent + // Supply them to wxMakeMetaFilePlaceable instead. + wxMetafileDC(const wxString& file); + { m_pimpl = new wxMetafileDCImpl( this, file ); } + + // Supply origin and extent (recommended). + // Then don't need to supply them to wxMakeMetaFilePlaceable. + wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg) + { m_pimpl = new wxMetafileDCImpl( this, file, xext, yext, xorg, yorg ); } + + wxMetafile *GetMetafile() const + { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); } + + wxMetafile *Close() + { return ((wxMetafileDCImpl*)m_pimpl)->Close(); } + +private: + DECLARE_CLASS(wxMetafileDC) + DECLARE_NO_COPY_CLASS(wxMetafileDC) +}; + + + + /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index f31355f2cb..7944e1b976 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -213,6 +213,11 @@ struct WinStruct : public T #include "wx/gdicmn.h" #include "wx/colour.h" +#include "wx/msw/dc.h" +#include "wx/msw/dcclient.h" +#include "wx/msw/dcmemory.h" + + // make conversion from wxColour and COLORREF a bit less painful inline COLORREF wxColourToRGB(const wxColour& c) { diff --git a/include/wx/prntbase.h b/include/wx/prntbase.h index 7e74c3b235..1dd8637927 100644 --- a/include/wx/prntbase.h +++ b/include/wx/prntbase.h @@ -22,6 +22,7 @@ #include "wx/scrolwin.h" #include "wx/dialog.h" #include "wx/frame.h" +#include "wx/dc.h" class WXDLLIMPEXP_FWD_CORE wxDC; class WXDLLIMPEXP_FWD_CORE wxButton; @@ -77,7 +78,7 @@ public: virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, wxPageSetupDialogData * data = NULL ) = 0; - virtual wxDC* CreatePrinterDC( const wxPrintData& data ) = 0; + virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) = 0; // What to do and what to show in the wxPrintDialog // a) Use the generic print setup dialog or a native one? @@ -121,7 +122,7 @@ public: virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, wxPageSetupDialogData * data = NULL ); - virtual wxDC* CreatePrinterDC( const wxPrintData& data ); + virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); virtual bool HasPrintSetupDialog(); virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index 120579cc40..9de12ad7af 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -33,6 +33,7 @@ #include "wx/colordlg.h" #include "wx/image.h" #include "wx/artprov.h" +#include "wx/dcgraph.h" #define wxTEST_GRAPHICS 1 diff --git a/src/aui/dockart.cpp b/src/aui/dockart.cpp index 06870399cd..fd09783713 100644 --- a/src/aui/dockart.cpp +++ b/src/aui/dockart.cpp @@ -412,7 +412,8 @@ void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation, HIRect splitterRect = CGRectMake( rect.x , rect.y , rect.width , rect.height ); CGContextRef cgContext ; - cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext() ; + wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl(); + cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext() ; HIThemeSplitterDrawInfo drawInfo ; drawInfo.version = 0 ; diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index 9e91f09a2a..c94279ccd6 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -70,6 +70,7 @@ DEFINE_EVENT_TYPE(wxEVT_AUI_FIND_MANAGER) #ifdef __WXMSW__ #include "wx/msw/wrapwin.h" #include "wx/msw/private.h" + #include "wx/msw/dc.h" #endif IMPLEMENT_DYNAMIC_CLASS(wxAuiManagerEvent, wxEvent) @@ -297,7 +298,8 @@ static void DrawResizeHint(wxDC& dc, const wxRect& rect) wxBrush brush(stipple); dc.SetBrush(brush); #ifdef __WXMSW__ - PatBlt(GetHdcOf(dc), rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight(), PATINVERT); + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + PatBlt(GetHdcOf(*impl), rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight(), PATINVERT); #else dc.SetPen(*wxTRANSPARENT_PEN); @@ -771,6 +773,7 @@ void wxAuiManager::UpdateHintWindowConfig() { wxFrame* f = static_cast(w); can_do_transparent = f->CanSetTransparent(); + break; } diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index be5eeb9578..194e4422fb 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -36,9 +36,25 @@ #include "wx/math.h" #endif +#if wxUSE_NEW_DC +#ifdef __WXMSW__ +#include "wx/msw/dcclient.h" +#include "wx/msw/dcmemory.h" +#include "wx/msw/dcscreen.h" +#endif -#if wxUSE_NEW_DC +#ifdef __WXGTK__ +#include "wx/gtk/dcclient.h" +#include "wx/gtk/dcmemory.h" +#include "wx/gtk/dcscreen.h" +#endif + +#ifdef __WXMAC__ +#include "wx/mac/dcclient.h" +#include "wx/mac/dcmemory.h" +#include "wx/mac/dcscreen.h" +#endif //---------------------------------------------------------------------------- // wxDCFactory @@ -66,280 +82,60 @@ wxDCFactory *wxDCFactory::GetFactory() // wxNativeDCFactory //----------------------------------------------------------------------------- -wxImplDC* wxNativeDCFactory::CreateWindowDC( wxWindowDC *owner ) +wxDCImpl* wxNativeDCFactory::CreateWindowDC( wxWindowDC *owner ) { -#if defined(__WXMSW__) - return new wxWindowsWindowImplDC( owner ); -#elif defined(__WXGTK20__) - return new wxGTKWindowImplDC( owner ); -#elif defined(__WXGTK__) - return new wxGTKWindowImplDC( owner ); -#elif defined(__WXMAC__) - return new wxMacWindowImplDC( owner ); -#elif defined(__WXCOCOA__) - return new wxCocoaWindowImplDC( owner ); -#elif defined(__WXMOTIF__) - return new wxMotifWindowImplDC( owner ); -#elif defined(__WXX11__) - return new wxX11WindowImplDC( owner ); -#elif defined(__WXMGL__) - return new wxMGLWindowImplDC( owner ); -#elif defined(__WXDFB__) - return new wxDFBWindowImplDC( owner ); -#elif defined(__WXPM__) - return new wxPMWindowImplDC( owner ); -#elif defined(__PALMOS__) - return new wxPalmWindowImplDC( owner ); -#endif + return new wxWindowDCImpl( owner ); } -wxImplDC* wxNativeDCFactory::CreateWindowDC( wxWindowDC *owner, wxWindow *window ) +wxDCImpl* wxNativeDCFactory::CreateWindowDC( wxWindowDC *owner, wxWindow *window ) { -#if defined(__WXMSW__) - return new wxWindowsWindowImplDC( owner, window ); -#elif defined(__WXGTK20__) - return new wxGTKWindowImplDC( owner, window ); -#elif defined(__WXGTK__) - return new wxGTKWindowImplDC( owner, window ); -#elif defined(__WXMAC__) - return new wxMacWindowImplDC( owner, window ); -#elif defined(__WXCOCOA__) - return new wxCocoaWindowImplDC( owner, window ); -#elif defined(__WXMOTIF__) - return new wxMotifWindowImplDC( owner, window ); -#elif defined(__WXX11__) - return new wxX11WindowImplDC( owner, window ); -#elif defined(__WXMGL__) - return new wxMGLWindowImplDC( owner, window ); -#elif defined(__WXDFB__) - return new wxDFBWindowImplDC( owner, window ); -#elif defined(__WXPM__) - return new wxPMWindowImplDC( owner, window ); -#elif defined(__PALMOS__) - return new wxPalmWindowImplDC( owner, window ); -#endif + return new wxWindowDCImpl( owner, window ); } -wxImplDC* wxNativeDCFactory::CreateClientDC( wxClientDC *owner ) -{ -#if defined(__WXMSW__) - return new wxWindowsClientImplDC( owner ); -#elif defined(__WXGTK20__) - return new wxGTKClientImplDC( owner ); -#elif defined(__WXGTK__) - return new wxGTKClientImplDC( owner ); -#elif defined(__WXMAC__) - return new wxMacClientImplDC( owner ); -#elif defined(__WXCOCOA__) - return new wxCocoaClientImplDC( owner ); -#elif defined(__WXMOTIF__) - return new wxMotifClientImplDC( owner ); -#elif defined(__WXX11__) - return new wxX11ClientImplDC( owner ); -#elif defined(__WXMGL__) - return new wxMGLClientImplDC( owner ); -#elif defined(__WXDFB__) - return new wxDFBClientImplDC( owner ); -#elif defined(__WXPM__) - return new wxPMClientImplDC( owner ); -#elif defined(__PALMOS__) - return new wxPalmClientImplDC( owner ); -#endif +wxDCImpl* wxNativeDCFactory::CreateClientDC( wxClientDC *owner ) +{ + return new wxClientDCImpl( owner ); } -wxImplDC* wxNativeDCFactory::CreateClientDC( wxClientDC *owner, wxWindow *window ) -{ -#if defined(__WXMSW__) - return new wxWindowsClientImplDC( owner, window ); -#elif defined(__WXGTK20__) - return new wxGTKClientImplDC( owner, window ); -#elif defined(__WXGTK__) - return new wxGTKClientImplDC( owner, window ); -#elif defined(__WXMAC__) - return new wxMacClientImplDC( owner, window ); -#elif defined(__WXCOCOA__) - return new wxCocoaClientImplDC( owner, window ); -#elif defined(__WXMOTIF__) - return new wxMotifClientImplDC( owner, window ); -#elif defined(__WXX11__) - return new wxX11ClientImplDC( owner, window ); -#elif defined(__WXMGL__) - return new wxMGLClientImplDC( owner, window ); -#elif defined(__WXDFB__) - return new wxDFBClientImplDC( owner, window ); -#elif defined(__WXPM__) - return new wxPMClientImplDC( owner, window ); -#elif defined(__PALMOS__) - return new wxPalmClientImplDC( owner, window ); -#endif +wxDCImpl* wxNativeDCFactory::CreateClientDC( wxClientDC *owner, wxWindow *window ) +{ + return new wxClientDCImpl( owner, window ); } -wxImplDC* wxNativeDCFactory::CreatePaintDC( wxPaintDC *owner ) -{ -#if defined(__WXMSW__) - return new wxWindowsPaintImplDC( owner ); -#elif defined(__WXGTK20__) - return new wxGTKPaintImplDC( owner ); -#elif defined(__WXGTK__) - return new wxGTKPaintImplDC( owner ); -#elif defined(__WXMAC__) - return new wxMacPaintImplDC( owner ); -#elif defined(__WXCOCOA__) - return new wxCocoaPaintImplDC( owner ); -#elif defined(__WXMOTIF__) - return new wxMotifPaintImplDC( owner ); -#elif defined(__WXX11__) - return new wxX11PaintImplDC( owner ); -#elif defined(__WXMGL__) - return new wxMGLPaintImplDC( owner ); -#elif defined(__WXDFB__) - return new wxDFBPaintImplDC( owner ); -#elif defined(__WXPM__) - return new wxPMPaintImplDC( owner ); -#elif defined(__PALMOS__) - return new wxPalmPaintImplDC( owner ); -#endif +wxDCImpl* wxNativeDCFactory::CreatePaintDC( wxPaintDC *owner ) +{ + return new wxPaintDCImpl( owner ); } -wxImplDC* wxNativeDCFactory::CreatePaintDC( wxPaintDC *owner, wxWindow *window ) -{ -#if defined(__WXMSW__) - return new wxWindowsPaintImplDC( owner, window ); -#elif defined(__WXGTK20__) - return new wxGTKPaintImplDC( owner, window ); -#elif defined(__WXGTK__) - return new wxGTKPaintImplDC( owner, window ); -#elif defined(__WXMAC__) - return new wxMacPaintImplDC( owner, window ); -#elif defined(__WXCOCOA__) - return new wxCocoaPaintImplDC( owner, window ); -#elif defined(__WXMOTIF__) - return new wxMotifPaintImplDC( owner, window ); -#elif defined(__WXX11__) - return new wxX11PaintImplDC( owner, window ); -#elif defined(__WXMGL__) - return new wxMGLPaintImplDC( owner, window ); -#elif defined(__WXDFB__) - return new wxDFBPaintImplDC( owner, window ); -#elif defined(__WXPM__) - return new wxPMPaintImplDC( owner, window ); -#elif defined(__PALMOS__) - return new wxPalmPaintImplDC( owner, window ); -#endif +wxDCImpl* wxNativeDCFactory::CreatePaintDC( wxPaintDC *owner, wxWindow *window ) +{ + return new wxPaintDCImpl( owner, window ); } -wxImplDC* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner ) -{ -#if defined(__WXMSW__) - return new wxWindowsMemoryImplDC( owner ); -#elif defined(__WXGTK20__) - return new wxGTKMemoryImplDC( owner ); -#elif defined(__WXGTK__) - return new wxGTKMemoryImplDC( owner ); -#elif defined(__WXMAC__) - return new wxMacMemoryImplDC( owner ); -#elif defined(__WXCOCOA__) - return new wxCocoaMemoryImplDC( owner ); -#elif defined(__WXMOTIF__) - return new wxMotifMemoryImplDC( owner ); -#elif defined(__WXX11__) - return new wxX11MemoryImplDC( owner ); -#elif defined(__WXMGL__) - return new wxMGLMemoryImplDC( owner ); -#elif defined(__WXDFB__) - return new wxDFBMemoryImplDC( owner ); -#elif defined(__WXPM__) - return new wxPMMemoryImplDC( owner ); -#elif defined(__PALMOS__) - return new wxPalmMemoryImplDC( owner ); -#endif +wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner ) +{ + return new wxMemoryDCImpl( owner ); } -wxImplDC* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) -{ -#if defined(__WXMSW__) - return new wxWindowsMemoryImplDC( owner, bitmap ); -#elif defined(__WXGTK20__) - return new wxGTKMemoryImplDC( owner, bitmap ); -#elif defined(__WXGTK__) - return new wxGTKMemoryImplDC( owner, bitmap ); -#elif defined(__WXMAC__) - return new wxMacMemoryImplDC( owner, bitmap ); -#elif defined(__WXCOCOA__) - return new wxCocoaMemoryImplDC( owner, bitmap ); -#elif defined(__WXMOTIF__) - return new wxMotifMemoryImplDC( owner, bitmap ); -#elif defined(__WXX11__) - return new wxX11MemoryImplDC( owner, bitmap ); -#elif defined(__WXMGL__) - return new wxMGLMemoryImplDC( owner, bitmap ); -#elif defined(__WXDFB__) - return new wxDFBMemoryImplDC( owner, bitmap ); -#elif defined(__WXPM__) - return new wxPMMemoryImplDC( owner, bitmap ); -#elif defined(__PALMOS__) - return new wxPalmMemoryImplDC( owner, bitmap ); -#endif +wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) +{ + return new wxMemoryDCImpl( owner, bitmap ); } -wxImplDC* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) -{ -#if defined(__WXMSW__) - return new wxWindowsMemoryImplDC( owner, dc ); -#elif defined(__WXGTK20__) - return new wxGTKMemoryImplDC( owner, dc ); -#elif defined(__WXGTK__) - return new wxGTKMemoryImplDC( owner, dc ); -#elif defined(__WXMAC__) - return new wxMacMemoryImplDC( owner, dc ); -#elif defined(__WXCOCOA__) - return new wxCocoaMemoryImplDC( owner, dc ); -#elif defined(__WXMOTIF__) - return new wxMotifMemoryImplDC( owner, dc ); -#elif defined(__WXX11__) - return new wxX11MemoryImplDC( owner, dc ); -#elif defined(__WXMGL__) - return new wxMGLMemoryImplDC( owner, dc ); -#elif defined(__WXDFB__) - return new wxDFBMemoryImplDC( owner, dc ); -#elif defined(__WXPM__) - return new wxPMMemoryImplDC( owner, dc ); -#elif defined(__PALMOS__) - return new wxPalmMemoryImplDC( owner, dc ); -#endif +wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) +{ + return new wxMemoryDCImpl( owner, dc ); } -wxImplDC* wxNativeDCFactory::CreateScreenDC( wxScreenDC *owner ) -{ -#if defined(__WXMSW__) - return new wxWindowsScreenImplDC( owner ); -#elif defined(__WXGTK20__) - return new wxGTKScreenImplDC( owner ); -#elif defined(__WXGTK__) - return new wxGTKScreenImplDC( owner ); -#elif defined(__WXMAC__) - return new wxMacScreenImplDC( owner ); -#elif defined(__WXCOCOA__) - return new wxCocoaScreenImplDC( owner ); -#elif defined(__WXMOTIF__) - return new wxMotifScreenImplDC( owner ); -#elif defined(__WXX11__) - return new wxX11ScreenImplDC( owner ); -#elif defined(__WXMGL__) - return new wxMGLScreenImplDC( owner ); -#elif defined(__WXDFB__) - return new wxDFBScreenImplDC( owner ); -#elif defined(__WXPM__) - return new wxPMScreenImplDC( owner ); -#elif defined(__PALMOS__) - return new wxPalmScreenImplDC( owner ); -#endif +wxDCImpl* wxNativeDCFactory::CreateScreenDC( wxScreenDC *owner ) +{ + return new wxScreenDCImpl( owner ); } -wxImplDC *wxNativeDCFactory::CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) +wxDCImpl *wxNativeDCFactory::CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) { wxPrintFactory *factory = wxPrintFactory::GetFactory(); - return factory->CreatePrinterImplDC( owner, data ); + return factory->CreatePrinterDCImpl( owner, data ); } //----------------------------------------------------------------------------- @@ -350,8 +146,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) wxWindowDC::wxWindowDC() { - wxDCFactory *factory = wxDCFactory::GetFactory(); - m_pimpl = factory->CreateWindowDC( this ); } wxWindowDC::wxWindowDC( wxWindow *win ) @@ -364,12 +158,10 @@ wxWindowDC::wxWindowDC( wxWindow *win ) // wxClientDC //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxDC) +IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) wxClientDC::wxClientDC() { - wxDCFactory *factory = wxDCFactory::GetFactory(); - m_pimpl = factory->CreateClientDC( this ); } wxClientDC::wxClientDC( wxWindow *win ) @@ -433,12 +225,10 @@ wxBitmap& wxMemoryDC::GetSelectedBitmap() // wxPaintDC //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxDC) +IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC) wxPaintDC::wxPaintDC() { - wxDCFactory *factory = wxDCFactory::GetFactory(); - m_pimpl = factory->CreatePaintDC( this ); } wxPaintDC::wxPaintDC( wxWindow *win ) @@ -467,8 +257,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxPrinterDC, wxDC) wxPrinterDC::wxPrinterDC() { + wxPrintData data; // Does this make sense? wxDCFactory *factory = wxDCFactory::GetFactory(); - // m_pimpl = factory->CreatePrinterDC( this, data ); + m_pimpl = factory->CreatePrinterDC( this, data ); } wxPrinterDC::wxPrinterDC( const wxPrintData &data ) @@ -493,13 +284,14 @@ int wxPrinterDC::GetResolution() //----------------------------------------------------------------------------- -// wxImplDC +// wxDCImpl //----------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxImplDC, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxDCImpl, wxObject) -wxImplDC::wxImplDC( wxDC *owner ) - : m_colour(wxColourDisplay()) +wxDCImpl::wxDCImpl( wxDC *owner ) + : m_window(NULL) + , m_colour(wxColourDisplay()) , m_ok(true) , m_clipping(false) , m_isInteractive(0) @@ -538,7 +330,7 @@ wxImplDC::wxImplDC( wxDC *owner ) ResetClipping(); } -wxImplDC::~wxImplDC() +wxDCImpl::~wxDCImpl() { } @@ -546,53 +338,53 @@ wxImplDC::~wxImplDC() // coordinate conversions and transforms // ---------------------------------------------------------------------------- -wxCoord wxImplDC::DeviceToLogicalX(wxCoord x) const +wxCoord wxDCImpl::DeviceToLogicalX(wxCoord x) const { return wxRound((double)(x - m_deviceOriginX - m_deviceLocalOriginX) / m_scaleX) * m_signX + m_logicalOriginX; } -wxCoord wxImplDC::DeviceToLogicalY(wxCoord y) const +wxCoord wxDCImpl::DeviceToLogicalY(wxCoord y) const { return wxRound((double)(y - m_deviceOriginY - m_deviceLocalOriginY) / m_scaleY) * m_signY + m_logicalOriginY; } -wxCoord wxImplDC::DeviceToLogicalXRel(wxCoord x) const +wxCoord wxDCImpl::DeviceToLogicalXRel(wxCoord x) const { return wxRound((double)(x) / m_scaleX); } -wxCoord wxImplDC::DeviceToLogicalYRel(wxCoord y) const +wxCoord wxDCImpl::DeviceToLogicalYRel(wxCoord y) const { return wxRound((double)(y) / m_scaleY); } -wxCoord wxImplDC::LogicalToDeviceX(wxCoord x) const +wxCoord wxDCImpl::LogicalToDeviceX(wxCoord x) const { return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX * m_signY + m_deviceLocalOriginX; } -wxCoord wxImplDC::LogicalToDeviceY(wxCoord y) const +wxCoord wxDCImpl::LogicalToDeviceY(wxCoord y) const { return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY * m_signY + m_deviceLocalOriginY; } -wxCoord wxImplDC::LogicalToDeviceXRel(wxCoord x) const +wxCoord wxDCImpl::LogicalToDeviceXRel(wxCoord x) const { return wxRound((double)(x) * m_scaleX); } -wxCoord wxImplDC::LogicalToDeviceYRel(wxCoord y) const +wxCoord wxDCImpl::LogicalToDeviceYRel(wxCoord y) const { return wxRound((double)(y) * m_scaleY); } -void wxImplDC::ComputeScaleAndOrigin() +void wxDCImpl::ComputeScaleAndOrigin() { m_scaleX = m_logicalScaleX * m_userScaleX; m_scaleY = m_logicalScaleY * m_userScaleY; } -void wxImplDC::SetMapMode( int mode ) +void wxDCImpl::SetMapMode( int mode ) { switch (mode) { @@ -616,7 +408,7 @@ void wxImplDC::SetMapMode( int mode ) m_mappingMode = mode; } -void wxImplDC::SetUserScale( double x, double y ) +void wxDCImpl::SetUserScale( double x, double y ) { // allow negative ? -> no m_userScaleX = x; @@ -624,7 +416,7 @@ void wxImplDC::SetUserScale( double x, double y ) ComputeScaleAndOrigin(); } -void wxImplDC::SetLogicalScale( double x, double y ) +void wxDCImpl::SetLogicalScale( double x, double y ) { // allow negative ? m_logicalScaleX = x; @@ -632,28 +424,28 @@ void wxImplDC::SetLogicalScale( double x, double y ) ComputeScaleAndOrigin(); } -void wxImplDC::SetLogicalOrigin( wxCoord x, wxCoord y ) +void wxDCImpl::SetLogicalOrigin( wxCoord x, wxCoord y ) { m_logicalOriginX = x * m_signX; m_logicalOriginY = y * m_signY; ComputeScaleAndOrigin(); } -void wxImplDC::SetDeviceOrigin( wxCoord x, wxCoord y ) +void wxDCImpl::SetDeviceOrigin( wxCoord x, wxCoord y ) { m_deviceOriginX = x; m_deviceOriginY = y; ComputeScaleAndOrigin(); } -void wxImplDC::SetDeviceLocalOrigin( wxCoord x, wxCoord y ) +void wxDCImpl::SetDeviceLocalOrigin( wxCoord x, wxCoord y ) { m_deviceLocalOriginX = x; m_deviceLocalOriginY = y; ComputeScaleAndOrigin(); } -void wxImplDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) +void wxDCImpl::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) { // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there // wxWidgets 2.9: no longer override it @@ -692,7 +484,7 @@ public: static FontWidthCache s_fontWidthCache; -bool wxImplDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const +bool wxDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const { int totalWidth = 0; @@ -736,7 +528,7 @@ bool wxImplDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) return true; } -void wxImplDC::GetMultiLineTextExtent(const wxString& text, +void wxDCImpl::GetMultiLineTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *h, @@ -802,7 +594,7 @@ void wxImplDC::GetMultiLineTextExtent(const wxString& text, *h = heightLine; } -void wxImplDC::DoDrawCheckMark(wxCoord x1, wxCoord y1, +void wxDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1, wxCoord width, wxCoord height) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -824,7 +616,7 @@ void wxImplDC::DoDrawCheckMark(wxCoord x1, wxCoord y1, } bool -wxImplDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, +wxDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, wxCoord dstWidth, wxCoord dstHeight, wxDC *source, wxCoord xsrc, wxCoord ysrc, @@ -855,7 +647,7 @@ wxImplDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, return rc; } -void wxImplDC::DrawLines(const wxPointList *list, wxCoord xoffset, wxCoord yoffset) +void wxDCImpl::DrawLines(const wxPointList *list, wxCoord xoffset, wxCoord yoffset) { int n = list->GetCount(); wxPoint *points = new wxPoint[n]; @@ -873,7 +665,7 @@ void wxImplDC::DrawLines(const wxPointList *list, wxCoord xoffset, wxCoord yoffs delete [] points; } -void wxImplDC::DrawPolygon(const wxPointList *list, +void wxDCImpl::DrawPolygon(const wxPointList *list, wxCoord xoffset, wxCoord yoffset, int fillStyle) { @@ -894,7 +686,7 @@ void wxImplDC::DrawPolygon(const wxPointList *list, } void -wxImplDC::DoDrawPolyPolygon(int n, +wxDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, @@ -938,7 +730,7 @@ wxImplDC::DoDrawPolyPolygon(int n, #if wxUSE_SPLINES -void wxImplDC::DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3) +void wxDCImpl::DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3) { wxPointList point_list; @@ -963,7 +755,7 @@ void wxImplDC::DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo } } -void wxImplDC::DoDrawSpline(int n, wxPoint points[]) +void wxDCImpl::DoDrawSpline(int n, wxPoint points[]) { wxPointList list; for (int i =0; i < n; i++) @@ -1085,7 +877,7 @@ static void wx_spline_draw_point_array(wxDC *dc) } } -void wxImplDC::DoDrawSpline( const wxPointList *points ) +void wxDCImpl::DoDrawSpline( const wxPointList *points ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -1149,7 +941,7 @@ void wxImplDC::DoDrawSpline( const wxPointList *points ) -void wxImplDC::DoGradientFillLinear(const wxRect& rect, +void wxDCImpl::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection) @@ -1245,7 +1037,7 @@ void wxImplDC::DoGradientFillLinear(const wxRect& rect, SetBrush(oldBrush); } -void wxImplDC::DoGradientFillConcentric(const wxRect& rect, +void wxDCImpl::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 54ecf302cb..4e1fdfed7f 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -19,6 +19,7 @@ #if wxUSE_GRAPHICS_CONTEXT #include "wx/graphics.h" +#include "wx/dcgraph.h" #ifndef WX_PRECOMP #include "wx/icon.h" @@ -49,18 +50,46 @@ static inline double DegToRad(double deg) // wxDC bridge class //----------------------------------------------------------------------------- -#ifdef __WXMAC__ -IMPLEMENT_DYNAMIC_CLASS(wxGCDC, wxDCBase) -#else IMPLEMENT_DYNAMIC_CLASS(wxGCDC, wxDC) -#endif + +wxGCDC::wxGCDC(const wxWindowDC& dc) +{ + m_pimpl = new wxGCDCImpl( this, dc ); +} + +wxGCDC::wxGCDC( const wxMemoryDC& dc) +{ + m_pimpl = new wxGCDCImpl( this, dc ); +} wxGCDC::wxGCDC() { - Init(); + m_pimpl = new wxGCDCImpl( this ); +} + +wxGraphicsContext* wxGCDC::GetGraphicsContext() +{ + if (!m_pimpl) return NULL; + wxGCDCImpl *gc_impl = (wxGCDCImpl*) m_pimpl; + return gc_impl->GetGraphicsContext(); } void wxGCDC::SetGraphicsContext( wxGraphicsContext* ctx ) +{ + if (!m_pimpl) return; + wxGCDCImpl *gc_impl = (wxGCDCImpl*) m_pimpl; + gc_impl->SetGraphicsContext( ctx ); +} + +IMPLEMENT_ABSTRACT_CLASS(wxGCDCImpl, wxDCImpl) + +wxGCDCImpl::wxGCDCImpl( wxDC *owner ) : + wxDCImpl( owner ) +{ + Init(); +} + +void wxGCDCImpl::SetGraphicsContext( wxGraphicsContext* ctx ) { delete m_graphicContext; m_graphicContext = ctx; @@ -76,21 +105,21 @@ void wxGCDC::SetGraphicsContext( wxGraphicsContext* ctx ) } } -wxGCDC::wxGCDC(const wxWindowDC& dc) +wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxWindowDC& dc ) : + wxDCImpl( owner ) { Init(); SetGraphicsContext( wxGraphicsContext::Create(dc) ); } -#ifdef __WXMSW__ -wxGCDC::wxGCDC(const wxMemoryDC& dc) +wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) : + wxDCImpl( owner ) { Init(); SetGraphicsContext( wxGraphicsContext::Create(dc) ); } -#endif -void wxGCDC::Init() +void wxGCDCImpl::Init() { m_ok = false; m_colour = true; @@ -106,15 +135,15 @@ void wxGCDC::Init() } -wxGCDC::~wxGCDC() +wxGCDCImpl::~wxGCDCImpl() { delete m_graphicContext; } -void wxGCDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool WXUNUSED(useMask) ) +void wxGCDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool WXUNUSED(useMask) ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") ); - wxCHECK_RET( bmp.Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") ); + wxCHECK_RET( bmp.IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") ); if ( bmp.GetDepth() == 1 ) { @@ -130,10 +159,10 @@ void wxGCDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool WXUNU m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() ); } -void wxGCDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) +void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") ); - wxCHECK_RET( icon.Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") ); + wxCHECK_RET( icon.IsOk(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") ); wxCoord w = icon.GetWidth(); wxCoord h = icon.GetHeight(); @@ -141,33 +170,33 @@ void wxGCDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) m_graphicContext->DrawIcon( icon , x, y, w, h ); } -bool wxGCDC::StartDoc( const wxString& WXUNUSED(message) ) +bool wxGCDCImpl::StartDoc( const wxString& WXUNUSED(message) ) { return false; } -void wxGCDC::EndDoc() +void wxGCDCImpl::EndDoc() { } -void wxGCDC::StartPage() +void wxGCDCImpl::StartPage() { } -void wxGCDC::EndPage() +void wxGCDCImpl::EndPage() { } -void wxGCDC::Flush() +void wxGCDCImpl::Flush() { #ifdef __WXMAC__ CGContextFlush( (CGContextRef) m_graphicContext->GetNativeContext() ); #endif } -void wxGCDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) +void wxGCDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") ); m_graphicContext->Clip( x, y, w, h ); if ( m_clipping ) @@ -188,10 +217,10 @@ void wxGCDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) } } -void wxGCDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) +void wxGCDCImpl::DoSetClippingRegionAsRegion( const wxRegion ®ion ) { // region is in device coordinates - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegionAsRegion - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetClippingRegionAsRegion - invalid DC") ); if (region.Empty()) { @@ -224,13 +253,13 @@ void wxGCDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) } } -void wxGCDC::DestroyClippingRegion() +void wxGCDCImpl::DestroyClippingRegion() { m_graphicContext->ResetClip(); // currently the clip eg of a window extends to the area between the scrollbars // so we must explicitely make sure it only covers the area we want it to draw int width, height ; - GetSize( &width , &height ) ; + GetOwner()->GetSize( &width , &height ) ; m_graphicContext->Clip( DeviceToLogicalX(0) , DeviceToLogicalY(0) , DeviceToLogicalXRel(width), DeviceToLogicalYRel(height) ); m_graphicContext->SetPen( m_pen ); @@ -239,20 +268,20 @@ void wxGCDC::DestroyClippingRegion() m_clipping = false; } -void wxGCDC::DoGetSizeMM( int* width, int* height ) const +void wxGCDCImpl::DoGetSizeMM( int* width, int* height ) const { int w = 0, h = 0; - GetSize( &w, &h ); + GetOwner()->GetSize( &w, &h ); if (width) *width = long( double(w) / (m_scaleX * m_mm_to_pix_x) ); if (height) *height = long( double(h) / (m_scaleY * m_mm_to_pix_y) ); } -void wxGCDC::SetTextForeground( const wxColour &col ) +void wxGCDCImpl::SetTextForeground( const wxColour &col ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") ); if ( col != m_textForegroundColour ) { @@ -261,14 +290,14 @@ void wxGCDC::SetTextForeground( const wxColour &col ) } } -void wxGCDC::SetTextBackground( const wxColour &col ) +void wxGCDCImpl::SetTextBackground( const wxColour &col ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextBackground - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::SetTextBackground - invalid DC") ); m_textBackgroundColour = col; } -void wxGCDC::SetMapMode( int mode ) +void wxGCDCImpl::SetMapMode( int mode ) { switch (mode) { @@ -297,7 +326,7 @@ void wxGCDC::SetMapMode( int mode ) ComputeScaleAndOrigin(); } -void wxGCDC::SetUserScale( double x, double y ) +void wxGCDCImpl::SetUserScale( double x, double y ) { // allow negative ? -> no @@ -306,7 +335,7 @@ void wxGCDC::SetUserScale( double x, double y ) ComputeScaleAndOrigin(); } -void wxGCDC::SetLogicalScale( double x, double y ) +void wxGCDCImpl::SetLogicalScale( double x, double y ) { // allow negative ? m_logicalScaleX = x; @@ -314,38 +343,38 @@ void wxGCDC::SetLogicalScale( double x, double y ) ComputeScaleAndOrigin(); } -void wxGCDC::SetLogicalOrigin( wxCoord x, wxCoord y ) +void wxGCDCImpl::SetLogicalOrigin( wxCoord x, wxCoord y ) { m_logicalOriginX = x * m_signX; // is this still correct ? m_logicalOriginY = y * m_signY; ComputeScaleAndOrigin(); } -void wxGCDC::SetDeviceOrigin( wxCoord x, wxCoord y ) +void wxGCDCImpl::SetDeviceOrigin( wxCoord x, wxCoord y ) { m_deviceOriginX = x; m_deviceOriginY = y; ComputeScaleAndOrigin(); } -void wxGCDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) +void wxGCDCImpl::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) { m_signX = (xLeftRight ? 1 : -1); m_signY = (yBottomUp ? -1 : 1); ComputeScaleAndOrigin(); } -wxSize wxGCDC::GetPPI() const +wxSize wxGCDCImpl::GetPPI() const { return wxSize(72, 72); } -int wxGCDC::GetDepth() const +int wxGCDCImpl::GetDepth() const { return 32; } -void wxGCDC::ComputeScaleAndOrigin() +void wxGCDCImpl::ComputeScaleAndOrigin() { m_scaleX = m_logicalScaleX * m_userScaleX; m_scaleY = m_logicalScaleY * m_userScaleY; @@ -363,29 +392,29 @@ void wxGCDC::ComputeScaleAndOrigin() } } -void wxGCDC::SetPalette( const wxPalette& WXUNUSED(palette) ) +void wxGCDCImpl::SetPalette( const wxPalette& WXUNUSED(palette) ) { } -void wxGCDC::SetBackgroundMode( int mode ) +void wxGCDCImpl::SetBackgroundMode( int mode ) { m_backgroundMode = mode; } -void wxGCDC::SetFont( const wxFont &font ) +void wxGCDCImpl::SetFont( const wxFont &font ) { m_font = font; if ( m_graphicContext ) { wxFont f = font; - if ( f.Ok() ) + if ( f.IsOk() ) f.SetPointSize( /*LogicalToDeviceYRel*/(font.GetPointSize())); m_graphicContext->SetFont( f, m_textForegroundColour ); } } -void wxGCDC::SetPen( const wxPen &pen ) +void wxGCDCImpl::SetPen( const wxPen &pen ) { if ( m_pen == pen ) return; @@ -397,7 +426,7 @@ void wxGCDC::SetPen( const wxPen &pen ) } } -void wxGCDC::SetBrush( const wxBrush &brush ) +void wxGCDCImpl::SetBrush( const wxBrush &brush ) { if (m_brush == brush) return; @@ -409,17 +438,17 @@ void wxGCDC::SetBrush( const wxBrush &brush ) } } -void wxGCDC::SetBackground( const wxBrush &brush ) +void wxGCDCImpl::SetBackground( const wxBrush &brush ) { if (m_backgroundBrush == brush) return; m_backgroundBrush = brush; - if (!m_backgroundBrush.Ok()) + if (!m_backgroundBrush.IsOk()) return; } -void wxGCDC::SetLogicalFunction( int function ) +void wxGCDCImpl::SetLogicalFunction( int function ) { if (m_logicalFunction == function) return; @@ -431,21 +460,21 @@ void wxGCDC::SetLogicalFunction( int function ) m_logicalFunctionSupported=false; } -bool wxGCDC::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), +bool wxGCDCImpl::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour& WXUNUSED(col), int WXUNUSED(style)) { return false; } -bool wxGCDC::DoGetPixel( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour *WXUNUSED(col) ) const +bool wxGCDCImpl::DoGetPixel( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour *WXUNUSED(col) ) const { // wxCHECK_MSG( 0 , false, wxT("wxGCDC(cg)::DoGetPixel - not implemented") ); return false; } -void wxGCDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) +void wxGCDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -456,16 +485,16 @@ void wxGCDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) CalcBoundingBox(x2, y2); } -void wxGCDC::DoCrossHair( wxCoord x, wxCoord y ) +void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") ); if ( !m_logicalFunctionSupported ) return; int w = 0, h = 0; - GetSize( &w, &h ); + GetOwner()->GetSize( &w, &h ); m_graphicContext->StrokeLine(0,y,w,y); m_graphicContext->StrokeLine(x,0,x,h); @@ -474,11 +503,11 @@ void wxGCDC::DoCrossHair( wxCoord x, wxCoord y ) CalcBoundingBox(0+w, 0+h); } -void wxGCDC::DoDrawArc( wxCoord x1, wxCoord y1, +void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -520,10 +549,10 @@ void wxGCDC::DoDrawArc( wxCoord x1, wxCoord y1, m_graphicContext->DrawPath(path); } -void wxGCDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, +void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -559,17 +588,17 @@ void wxGCDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, m_graphicContext->PopState(); } -void wxGCDC::DoDrawPoint( wxCoord x, wxCoord y ) +void wxGCDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPoint - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawPoint - invalid DC") ); DoDrawLine( x , y , x + 1 , y + 1 ); } -void wxGCDC::DoDrawLines(int n, wxPoint points[], +void wxGCDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -586,9 +615,9 @@ void wxGCDC::DoDrawLines(int n, wxPoint points[], } #if wxUSE_SPLINES -void wxGCDC::DoDrawSpline(const wxPointList *points) +void wxGCDCImpl::DoDrawSpline(const wxPointList *points) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -644,11 +673,11 @@ void wxGCDC::DoDrawSpline(const wxPointList *points) } #endif // wxUSE_SPLINES -void wxGCDC::DoDrawPolygon( int n, wxPoint points[], +void wxGCDCImpl::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle ) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPolygon - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawPolygon - invalid DC") ); if ( n <= 0 || (m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) ) return; @@ -672,7 +701,7 @@ void wxGCDC::DoDrawPolygon( int n, wxPoint points[], delete[] pointsD; } -void wxGCDC::DoDrawPolyPolygon(int n, +void wxGCDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, @@ -701,9 +730,9 @@ void wxGCDC::DoDrawPolyPolygon(int n, m_graphicContext->DrawPath( path , fillStyle); } -void wxGCDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) +void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -722,11 +751,11 @@ void wxGCDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) m_graphicContext->DrawRectangle(x,y,w,h); } -void wxGCDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, +void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double radius) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -748,9 +777,9 @@ void wxGCDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, m_graphicContext->DrawRoundedRectangle( x,y,w,h,radius); } -void wxGCDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) +void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") ); if ( !m_logicalFunctionSupported ) return; @@ -765,12 +794,12 @@ void wxGCDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) m_graphicContext->DrawEllipse(x,y,w,h); } -bool wxGCDC::CanDrawBitmap() const +bool wxGCDCImpl::CanDrawBitmap() const { return true; } -bool wxGCDC::DoBlit( +bool wxGCDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask, wxCoord xsrcMask, wxCoord ysrcMask ) @@ -780,14 +809,14 @@ bool wxGCDC::DoBlit( xsrcMask,ysrcMask ); } -bool wxGCDC::DoStretchBlit( +bool wxGCDCImpl::DoStretchBlit( wxCoord xdest, wxCoord ydest, wxCoord dstWidth, wxCoord dstHeight, wxDC *source, wxCoord xsrc, wxCoord ysrc, wxCoord srcWidth, wxCoord srcHeight, int logical_func , bool WXUNUSED(useMask), wxCoord xsrcMask, wxCoord ysrcMask ) { - wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoStretchBlit - invalid DC") ); - wxCHECK_MSG( source->Ok(), false, wxT("wxGCDC(cg)::DoStretchBlit - invalid source DC") ); + wxCHECK_MSG( IsOk(), false, wxT("wxGCDC(cg)::DoStretchBlit - invalid DC") ); + wxCHECK_MSG( source->IsOk(), false, wxT("wxGCDC(cg)::DoStretchBlit - invalid source DC") ); if ( logical_func == wxNO_OP ) return true; @@ -821,7 +850,7 @@ bool wxGCDC::DoStretchBlit( wxBitmap blit = source->GetAsBitmap( &subrect ); - if ( blit.Ok() ) + if ( blit.IsOk() ) { m_graphicContext->DrawBitmap( blit, xdest, ydest, dstWidth, dstHeight); @@ -838,10 +867,10 @@ bool wxGCDC::DoStretchBlit( return true; } -void wxGCDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, +void wxGCDCImpl::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, double angle) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") ); if ( str.length() == 0 ) return; @@ -854,9 +883,9 @@ void wxGCDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, m_graphicContext->DrawText( str, x ,y , DegToRad(angle ), m_graphicContext->CreateBrush( wxBrush(m_textBackgroundColour,wxSOLID) ) ); } -void wxGCDC::DoDrawText(const wxString& str, wxCoord x, wxCoord y) +void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") ); if ( str.length() == 0 ) return; @@ -870,18 +899,18 @@ void wxGCDC::DoDrawText(const wxString& str, wxCoord x, wxCoord y) m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush( wxBrush(m_textBackgroundColour,wxSOLID) ) ); } -bool wxGCDC::CanGetTextExtent() const +bool wxGCDCImpl::CanGetTextExtent() const { - wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::CanGetTextExtent - invalid DC") ); + wxCHECK_MSG( IsOk(), false, wxT("wxGCDC(cg)::CanGetTextExtent - invalid DC") ); return true; } -void wxGCDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height, +void wxGCDCImpl::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading , const wxFont *theFont ) const { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") ); if ( theFont ) { @@ -907,9 +936,9 @@ void wxGCDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *heig } } -bool wxGCDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const +bool wxGCDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const { - wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoGetPartialTextExtents - invalid DC") ); + wxCHECK_MSG( IsOk(), false, wxT("wxGCDC(cg)::DoGetPartialTextExtents - invalid DC") ); widths.Clear(); widths.Add(0,text.Length()); if ( text.IsEmpty() ) @@ -924,7 +953,7 @@ bool wxGCDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) c return true; } -wxCoord wxGCDC::GetCharWidth(void) const +wxCoord wxGCDCImpl::GetCharWidth(void) const { wxCoord width; DoGetTextExtent( wxT("g") , &width , NULL , NULL , NULL , NULL ); @@ -932,7 +961,7 @@ wxCoord wxGCDC::GetCharWidth(void) const return width; } -wxCoord wxGCDC::GetCharHeight(void) const +wxCoord wxGCDCImpl::GetCharHeight(void) const { wxCoord height; DoGetTextExtent( wxT("g") , NULL , &height , NULL , NULL , NULL ); @@ -940,9 +969,9 @@ wxCoord wxGCDC::GetCharHeight(void) const return height; } -void wxGCDC::Clear(void) +void wxGCDCImpl::Clear(void) { - wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::Clear - invalid DC") ); + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::Clear - invalid DC") ); // TODO better implementation / incorporate size info into wxGCDC or context m_graphicContext->SetBrush( m_backgroundBrush ); wxPen p = *wxTRANSPARENT_PEN; @@ -952,13 +981,13 @@ void wxGCDC::Clear(void) m_graphicContext->SetBrush( m_brush ); } -void wxGCDC::DoGetSize(int *width, int *height) const +void wxGCDCImpl::DoGetSize(int *width, int *height) const { *width = 10000; *height = 10000; } -void wxGCDC::DoGradientFillLinear(const wxRect& rect, +void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection ) @@ -1001,7 +1030,7 @@ void wxGCDC::DoGradientFillLinear(const wxRect& rect, m_graphicContext->SetPen(m_pen); } -void wxGCDC::DoGradientFillConcentric(const wxRect& rect, +void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter) @@ -1029,10 +1058,10 @@ void wxGCDC::DoGradientFillConcentric(const wxRect& rect, m_graphicContext->SetPen(m_pen); } -void wxGCDC::DoDrawCheckMark(wxCoord x, wxCoord y, +void wxGCDCImpl::DoDrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { - wxDCBase::DoDrawCheckMark(x,y,width,height); + wxDCImpl::DoDrawCheckMark(x,y,width,height); } #endif // wxUSE_GRAPHICS_CONTEXT diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 924bef6440..ceefb7cfd7 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -74,12 +74,12 @@ wxString wxBrushString ( wxColour c, int style ) // wxSVGFileDC // ---------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxSVGFileImplDC, wxDC) +IMPLEMENT_ABSTRACT_CLASS(wxSVGFileDCImpl, wxDC) #if wxUSE_NEW_DC - wxSVGFileImplDC::wxSVGFileImplDC( wxSVGFileDC *owner, const wxString &filename, + wxSVGFileDCImpl::wxSVGFileDCImpl( wxSVGFileDC *owner, const wxString &filename, int width, int height, double dpi ) : - wxImplDC( owner ) + wxDCImpl( owner ) { Init( filename, width, height, dpi ); } @@ -91,7 +91,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxSVGFileImplDC, wxDC) } #endif -void wxSVGFileImplDC::Init (const wxString &filename, int Width, int Height, double dpi) +void wxSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, double dpi) { m_width = Width ; m_height = Height ; @@ -143,14 +143,14 @@ void wxSVGFileImplDC::Init (const wxString &filename, int Width, int Height, dou -wxSVGFileImplDC::~wxSVGFileImplDC() +wxSVGFileDCImpl::~wxSVGFileDCImpl() { wxString s = wxT(" \n \n") ; write(s); delete m_outfile ; } -void wxSVGFileImplDC::DoGetSizeMM( int *width, int *height ) const +void wxSVGFileDCImpl::DoGetSizeMM( int *width, int *height ) const { if (width) *width = wxRound( (double)m_width / m_mm_to_pix_x ); @@ -159,12 +159,12 @@ void wxSVGFileImplDC::DoGetSizeMM( int *width, int *height ) const *height = wxRound( (double)m_height / m_mm_to_pix_y ); } -wxSize wxSVGFileImplDC::GetPPI() const +wxSize wxSVGFileDCImpl::GetPPI() const { return wxSize( wxRound(m_dpi), wxRound(m_dpi) ); } -void wxSVGFileImplDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) +void wxSVGFileDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { if (m_graphics_changed) NewGraphics (); wxString s ; @@ -179,7 +179,7 @@ void wxSVGFileImplDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 return; } -void wxSVGFileImplDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset , wxCoord yoffset ) +void wxSVGFileDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset , wxCoord yoffset ) { for ( int i = 1; i < n ; i++ ) { @@ -189,7 +189,7 @@ void wxSVGFileImplDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset , wxC } -void wxSVGFileImplDC::DoDrawPoint (wxCoord x1, wxCoord y1) +void wxSVGFileDCImpl::DoDrawPoint (wxCoord x1, wxCoord y1) { wxString s; if (m_graphics_changed) NewGraphics (); @@ -201,24 +201,24 @@ void wxSVGFileImplDC::DoDrawPoint (wxCoord x1, wxCoord y1) } -void wxSVGFileImplDC::DoDrawCheckMark(wxCoord x1, wxCoord y1, wxCoord width, wxCoord height) +void wxSVGFileDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1, wxCoord width, wxCoord height) { #if wxUSE_NEW_DC - wxImplDC::DoDrawCheckMark (x1,y1,width,height) ; + wxDCImpl::DoDrawCheckMark (x1,y1,width,height) ; #else wxDCBase::DoDrawCheckMark (x1,y1,width,height) ; #endif } -void wxSVGFileImplDC::DoDrawText(const wxString& text, wxCoord x1, wxCoord y1) +void wxSVGFileDCImpl::DoDrawText(const wxString& text, wxCoord x1, wxCoord y1) { DoDrawRotatedText(text, x1,y1,0.0); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawText Call executed")) ; } -void wxSVGFileImplDC::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, double angle) +void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, double angle) { //known bug; if the font is drawn in a scaled DC, it will not behave exactly as wxMSW if (m_graphics_changed) NewGraphics (); @@ -280,13 +280,13 @@ void wxSVGFileImplDC::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor } -void wxSVGFileImplDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxSVGFileDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { DoDrawRoundedRectangle(x, y, width, height, 0) ; } -void wxSVGFileImplDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) +void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) { if (m_graphics_changed) NewGraphics (); @@ -305,7 +305,7 @@ void wxSVGFileImplDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width } -void wxSVGFileImplDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle) +void wxSVGFileDCImpl::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle) { if (m_graphics_changed) NewGraphics (); wxString s, sTmp ; @@ -331,7 +331,7 @@ void wxSVGFileImplDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wx } -void wxSVGFileImplDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxSVGFileDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height) { if (m_graphics_changed) NewGraphics (); @@ -351,7 +351,7 @@ void wxSVGFileImplDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoor } -void wxSVGFileImplDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) +void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) { /* Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1) and ending at (x2, y2). The current pen is used for the outline @@ -403,7 +403,7 @@ void wxSVGFileImplDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, } -void wxSVGFileImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) +void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { /* Draws an arc of an ellipse. The current pen is used for drawing the arc @@ -467,7 +467,7 @@ void wxSVGFileImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h, } -void wxSVGFileImplDC::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent , wxCoord *externalLeading , const wxFont *font) const +void wxSVGFileDCImpl::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent , wxCoord *externalLeading , const wxFont *font) const { wxScreenDC sDC ; @@ -479,7 +479,7 @@ void wxSVGFileImplDC::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoor } -wxCoord wxSVGFileImplDC::GetCharHeight() const +wxCoord wxSVGFileDCImpl::GetCharHeight() const { wxScreenDC sDC ; @@ -491,7 +491,7 @@ wxCoord wxSVGFileImplDC::GetCharHeight() const } -wxCoord wxSVGFileImplDC::GetCharWidth() const +wxCoord wxSVGFileDCImpl::GetCharWidth() const { wxScreenDC sDC ; sDC.SetFont (m_font); @@ -503,7 +503,7 @@ wxCoord wxSVGFileImplDC::GetCharWidth() const /// Set Functions ///////////////////////////////////////////////////////////////// -void wxSVGFileImplDC::SetBackground( const wxBrush &brush ) +void wxSVGFileDCImpl::SetBackground( const wxBrush &brush ) { m_backgroundBrush = brush; @@ -511,14 +511,14 @@ void wxSVGFileImplDC::SetBackground( const wxBrush &brush ) } -void wxSVGFileImplDC::SetBackgroundMode( int mode ) +void wxSVGFileDCImpl::SetBackgroundMode( int mode ) { m_backgroundMode = mode; return; } -void wxSVGFileImplDC::SetBrush(const wxBrush& brush) +void wxSVGFileDCImpl::SetBrush(const wxBrush& brush) { m_brush = brush ; @@ -528,7 +528,7 @@ void wxSVGFileImplDC::SetBrush(const wxBrush& brush) } -void wxSVGFileImplDC::SetPen(const wxPen& pen) +void wxSVGFileDCImpl::SetPen(const wxPen& pen) { // width, color, ends, joins : currently implemented // dashes, stipple : not implemented @@ -538,7 +538,7 @@ void wxSVGFileImplDC::SetPen(const wxPen& pen) wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::SetPen Call executed")) ; } -void wxSVGFileImplDC::NewGraphics () +void wxSVGFileDCImpl::NewGraphics () { int w = m_pen.GetWidth (); @@ -597,7 +597,7 @@ void wxSVGFileImplDC::NewGraphics () } -void wxSVGFileImplDC::SetFont(const wxFont& font) +void wxSVGFileDCImpl::SetFont(const wxFont& font) { m_font = font ; @@ -607,7 +607,7 @@ void wxSVGFileImplDC::SetFont(const wxFont& font) // export a bitmap as a raster image in png -bool wxSVGFileImplDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, +bool wxSVGFileDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc, int logicalFunc /*= wxCOPY*/, bool useMask /*= FALSE*/, wxCoord /*xsrcMask = -1*/, wxCoord /*ysrcMask = -1*/) @@ -632,7 +632,7 @@ bool wxSVGFileImplDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoor return FALSE ; } -void wxSVGFileImplDC::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord y) +void wxSVGFileDCImpl::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord y) { wxBitmap myBitmap (myIcon.GetWidth(), myIcon.GetHeight() ) ; wxMemoryDC memDC; @@ -644,7 +644,7 @@ void wxSVGFileImplDC::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord return ; } -void wxSVGFileImplDC::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoord y , bool WXUNUSED(bTransparent) /*=0*/ ) +void wxSVGFileDCImpl::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoord y , bool WXUNUSED(bTransparent) /*=0*/ ) { if (m_graphics_changed) NewGraphics (); @@ -685,7 +685,7 @@ void wxSVGFileImplDC::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoor return ; } -void wxSVGFileImplDC::write(const wxString &s) +void wxSVGFileDCImpl::write(const wxString &s) { const wxCharBuffer buf = s.utf8_str(); m_outfile->Write(buf, strlen((const char *)buf)); @@ -698,32 +698,32 @@ void wxSVGFileImplDC::write(const wxString &s) #if wxUSE_NEW_DC #else -void wxSVGFileImplDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) +void wxSVGFileDCImpl::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) { wxDCBase::SetAxisOrientation( xLeftRight, yBottomUp ); } -void wxSVGFileImplDC::SetMapMode(int mode) +void wxSVGFileDCImpl::SetMapMode(int mode) { wxDCBase::SetMapMode(mode); } -void wxSVGFileImplDC::SetUserScale(double x, double y) +void wxSVGFileDCImpl::SetUserScale(double x, double y) { wxDCBase::SetUserScale(x,y); } -void wxSVGFileImplDC::SetLogicalScale(double x, double y) +void wxSVGFileDCImpl::SetLogicalScale(double x, double y) { wxDCBase::SetLogicalScale(x,y); } -void wxSVGFileImplDC::SetLogicalOrigin(wxCoord x, wxCoord y) +void wxSVGFileDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y) { wxDCBase::SetLogicalOrigin(x,y); } -void wxSVGFileImplDC::SetDeviceOrigin(wxCoord x, wxCoord y) +void wxSVGFileDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y) { wxDCBase::SetDeviceOrigin(x,y); } diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index 1d94e4a003..4fbab9c909 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -774,12 +774,11 @@ wxGraphicsContext* wxGraphicsContext::Create( const wxWindowDC& dc) { return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc); } -#ifdef __WXMSW__ + wxGraphicsContext* wxGraphicsContext::Create( const wxMemoryDC& dc) { return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc); } -#endif wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context ) { diff --git a/src/common/overlaycmn.cpp b/src/common/overlaycmn.cpp index 0551e88cc7..bda66e1161 100644 --- a/src/common/overlaycmn.cpp +++ b/src/common/overlaycmn.cpp @@ -146,20 +146,7 @@ bool wxOverlayImpl::IsOk() void wxOverlayImpl::Init( wxWindowDC* dc, int x , int y , int width , int height ) { -#if defined(__WXGTK20__) -#if wxUSE_NEW_DC - wxImplDC *impl = dc->GetImpl(); - wxGTKWindowImplDC *gtk_impl = wxDynamicCast( impl, wxGTKWindowImplDC ); - if (gtk_impl) - m_window = gtk_impl->m_owningWindow; -#else - m_window = dc->m_owningWindow; -#endif -#elif defined(__WXGTK__) - m_window = dc->m_owner; -#elif defined(__WXMSW__) m_window = dc->GetWindow(); -#endif wxMemoryDC dcMem ; m_bmpSaved.Create( width, height ); dcMem.SelectObject( m_bmpSaved ); diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index 112f818218..32ace7ddef 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -52,9 +52,11 @@ #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) #include "wx/msw/printdlg.h" +#include "wx/msw/dcprint.h" #elif defined(__WXMAC__) #include "wx/mac/printdlg.h" #include "wx/mac/private/print.h" +#include "wx/mac/dcprint.h" #else #include "wx/generic/prntdlgg.h" #include "wx/dcps.h" @@ -205,34 +207,15 @@ wxDialog *wxNativePrintFactory::CreatePrintSetupDialog( wxWindow *parent, #endif } -#if wxUSE_NEW_DC - -wxImplDC* wxNativePrintFactory::CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ) -{ -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) - return new wxWindowsPrinterDCImpl( owner, data ); -#elif defined(__WXMAC__) - return new wxMacPrinterDCImpl( owner, data ); -#else - return new wxPostScriptImplDC( owner, data ); -#endif -} - -#else - -wxDC* wxNativePrintFactory::CreatePrinterDC( const wxPrintData& data ) +wxDCImpl* wxNativePrintFactory::CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) { -#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) - return new wxPrinterDC(data); -#elif defined(__WXMAC__) - return new wxPrinterDC(data); +#if defined(__WXGTK__) || defined(__WXUNIVERSAL__) + return new wxPostScriptDCImpl( owner, data ); #else - return new wxPostScriptDC(data); + return new wxPrinterDCImpl( owner, data ); #endif } -#endif - bool wxNativePrintFactory::HasOwnPrintToFile() { // Only relevant for PostScript and here the diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index a21401fd6f..8804aad3f5 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -2276,7 +2276,8 @@ void wxDataViewMainWindow::ScrollTo( int rows, int column ) void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) { wxDataViewModel *model = GetOwner()->GetModel(); - wxAutoBufferedPaintDC dc( this ); + //wxAutoBufferedPaintDC dc( this ); + wxPaintDC dc(this); // prepare the DC dc.SetBackground(GetBackgroundColour()); diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index a2762fd7e4..aa8def57a1 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -242,12 +242,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC) wxPostScriptDC::wxPostScriptDC() { - m_pimpl = new wxPostScriptImplDC( this ); + m_pimpl = new wxPostScriptDCImpl( this ); } wxPostScriptDC::wxPostScriptDC(const wxPrintData& printData) { - m_pimpl = new wxPostScriptImplDC( this, printData ); + m_pimpl = new wxPostScriptDCImpl( this, printData ); } #endif @@ -268,7 +268,7 @@ static const double DEV2PS = 72.0 / 600.0; #if wxUSE_NEW_DC -IMPLEMENT_ABSTRACT_CLASS(wxPostScriptImplDC, wxImplDC) +IMPLEMENT_ABSTRACT_CLASS(wxPostScriptDCImpl, wxDCImpl) #else IMPLEMENT_ABSTRACT_CLASS(wxPostScriptDC, wxDC) #endif @@ -276,8 +276,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxPostScriptDC, wxDC) //------------------------------------------------------------------------------- #if wxUSE_NEW_DC -wxPostScriptImplDC::wxPostScriptImplDC( wxPostScriptDC *owner ) : - wxImplDC( owner ) +wxPostScriptDCImpl::wxPostScriptDCImpl( wxPostScriptDC *owner ) : + wxDCImpl( owner ) { Init(); @@ -286,8 +286,8 @@ wxPostScriptImplDC::wxPostScriptImplDC( wxPostScriptDC *owner ) : m_ok = true; } -wxPostScriptImplDC::wxPostScriptImplDC( wxPostScriptDC *owner, const wxPrintData& data ) : - wxImplDC( owner ) +wxPostScriptDCImpl::wxPostScriptDCImpl( wxPostScriptDC *owner, const wxPrintData& data ) : + wxDCImpl( owner ) { Init(); @@ -301,8 +301,8 @@ wxPostScriptImplDC::wxPostScriptImplDC( wxPostScriptDC *owner, const wxPrintData #if wxUSE_NEW_DC -wxPostScriptImplDC::wxPostScriptImplDC( wxPrinterDC *owner ) : - wxImplDC( owner ) +wxPostScriptDCImpl::wxPostScriptDCImpl( wxPrinterDC *owner ) : + wxDCImpl( owner ) #else wxPostScriptDC::wxPostScriptDC() #endif @@ -315,8 +315,8 @@ wxPostScriptDC::wxPostScriptDC() } #if wxUSE_NEW_DC -wxPostScriptImplDC::wxPostScriptImplDC( wxPrinterDC *owner, const wxPrintData& data ) : - wxImplDC( owner ) +wxPostScriptDCImpl::wxPostScriptDCImpl( wxPrinterDC *owner, const wxPrintData& data ) : + wxDCImpl( owner ) #else wxPostScriptDC::wxPostScriptDC( const wxPrintData& data ) #endif @@ -330,7 +330,7 @@ wxPostScriptDC::wxPostScriptDC( const wxPrintData& data ) m_ok = true; } -void wxPostScriptImplDC::Init() +void wxPostScriptDCImpl::Init() { m_pstream = (FILE*) NULL; @@ -347,7 +347,7 @@ void wxPostScriptImplDC::Init() } -wxPostScriptImplDC::~wxPostScriptImplDC () +wxPostScriptDCImpl::~wxPostScriptDCImpl () { if (m_pstream) { @@ -356,12 +356,12 @@ wxPostScriptImplDC::~wxPostScriptImplDC () } } -bool wxPostScriptImplDC::IsOk() const +bool wxPostScriptDCImpl::IsOk() const { return m_ok; } -wxRect wxPostScriptImplDC::GetPaperRect() +wxRect wxPostScriptDCImpl::GetPaperRect() { int w = 0; int h = 0; @@ -369,12 +369,12 @@ wxRect wxPostScriptImplDC::GetPaperRect() return wxRect(0,0,w,h); } -int wxPostScriptImplDC::GetResolution() +int wxPostScriptDCImpl::GetResolution() { return DPI; } -void wxPostScriptImplDC::DoSetClippingRegion (wxCoord x, wxCoord y, wxCoord w, wxCoord h) +void wxPostScriptDCImpl::DoSetClippingRegion (wxCoord x, wxCoord y, wxCoord w, wxCoord h) { wxCHECK_RET( m_ok , wxT("invalid postscript dc") ); @@ -409,7 +409,7 @@ void wxPostScriptImplDC::DoSetClippingRegion (wxCoord x, wxCoord y, wxCoord w, w } -void wxPostScriptImplDC::DestroyClippingRegion() +void wxPostScriptDCImpl::DestroyClippingRegion() { wxCHECK_RET( m_ok , wxT("invalid postscript dc") ); @@ -420,37 +420,37 @@ void wxPostScriptImplDC::DestroyClippingRegion() } #if wxUSE_NEW_DC - wxImplDC::DestroyClippingRegion(); + wxDCImpl::DestroyClippingRegion(); #else wxDC::DestroyClippingRegion(); #endif } -void wxPostScriptImplDC::Clear() +void wxPostScriptDCImpl::Clear() { // This should fail silently to avoid unnecessary // asserts - // wxFAIL_MSG( wxT("wxPostScriptImplDC::Clear not implemented.") ); + // wxFAIL_MSG( wxT("wxPostScriptDCImpl::Clear not implemented.") ); } -bool wxPostScriptImplDC::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) +bool wxPostScriptDCImpl::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) { - wxFAIL_MSG( wxT("wxPostScriptImplDC::FloodFill not implemented.") ); + wxFAIL_MSG( wxT("wxPostScriptDCImpl::FloodFill not implemented.") ); return false; } -bool wxPostScriptImplDC::DoGetPixel (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour * WXUNUSED(col)) const +bool wxPostScriptDCImpl::DoGetPixel (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour * WXUNUSED(col)) const { - wxFAIL_MSG( wxT("wxPostScriptImplDC::GetPixel not implemented.") ); + wxFAIL_MSG( wxT("wxPostScriptDCImpl::GetPixel not implemented.") ); return false; } -void wxPostScriptImplDC::DoCrossHair (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) +void wxPostScriptDCImpl::DoCrossHair (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { - wxFAIL_MSG( wxT("wxPostScriptImplDC::CrossHair not implemented.") ); + wxFAIL_MSG( wxT("wxPostScriptDCImpl::CrossHair not implemented.") ); } -void wxPostScriptImplDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) +void wxPostScriptDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -472,7 +472,7 @@ void wxPostScriptImplDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord CalcBoundingBox( x2, y2 ); } -void wxPostScriptImplDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) +void wxPostScriptDCImpl::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -550,7 +550,7 @@ void wxPostScriptImplDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord } } -void wxPostScriptImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) +void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -604,7 +604,7 @@ void wxPostScriptImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord } } -void wxPostScriptImplDC::DoDrawPoint (wxCoord x, wxCoord y) +void wxPostScriptDCImpl::DoDrawPoint (wxCoord x, wxCoord y) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -625,7 +625,7 @@ void wxPostScriptImplDC::DoDrawPoint (wxCoord x, wxCoord y) CalcBoundingBox( x, y ); } -void wxPostScriptImplDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +void wxPostScriptDCImpl::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -695,7 +695,7 @@ void wxPostScriptImplDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset } } -void wxPostScriptImplDC::DoDrawPolyPolygon (int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -771,7 +771,7 @@ void wxPostScriptImplDC::DoDrawPolyPolygon (int n, int count[], wxPoint points[] } } -void wxPostScriptImplDC::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxPostScriptDCImpl::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -805,7 +805,7 @@ void wxPostScriptImplDC::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, PsPrint( "stroke\n" ); } -void wxPostScriptImplDC::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxPostScriptDCImpl::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -859,7 +859,7 @@ void wxPostScriptImplDC::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, w } } -void wxPostScriptImplDC::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) +void wxPostScriptDCImpl::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -941,7 +941,7 @@ void wxPostScriptImplDC::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord w } } -void wxPostScriptImplDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxPostScriptDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -983,7 +983,7 @@ void wxPostScriptImplDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxC } } -void wxPostScriptImplDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) +void wxPostScriptDCImpl::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) { DoDrawBitmap( icon, x, y, true ); } @@ -991,7 +991,7 @@ void wxPostScriptImplDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) /* this has to be char, not wxChar */ static char hexArray[] = "0123456789ABCDEF"; -void wxPostScriptImplDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool WXUNUSED(useMask) ) +void wxPostScriptDCImpl::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool WXUNUSED(useMask) ) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -1061,7 +1061,7 @@ void wxPostScriptImplDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoor PsPrint( "origstate restore\n" ); } -void wxPostScriptImplDC::SetFont( const wxFont& font ) +void wxPostScriptDCImpl::SetFont( const wxFont& font ) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -1155,7 +1155,7 @@ void wxPostScriptImplDC::SetFont( const wxFont& font ) PsPrint( buffer ); } -void wxPostScriptImplDC::SetPen( const wxPen& pen ) +void wxPostScriptDCImpl::SetPen( const wxPen& pen ) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -1263,7 +1263,7 @@ void wxPostScriptImplDC::SetPen( const wxPen& pen ) } } -void wxPostScriptImplDC::SetBrush( const wxBrush& brush ) +void wxPostScriptDCImpl::SetBrush( const wxBrush& brush ) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -1307,7 +1307,7 @@ void wxPostScriptImplDC::SetBrush( const wxBrush& brush ) } } -void wxPostScriptImplDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y ) +void wxPostScriptDCImpl::DoDrawText( const wxString& text, wxCoord x, wxCoord y ) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -1415,7 +1415,7 @@ void wxPostScriptImplDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y CalcBoundingBox( x + size * text.length() * 2/3 , y ); } -void wxPostScriptImplDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle ) +void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle ) { if ( wxIsNullDouble(angle) ) { @@ -1530,18 +1530,18 @@ void wxPostScriptImplDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxC CalcBoundingBox( x + size * text.length() * 2/3 , y ); } -void wxPostScriptImplDC::SetBackground (const wxBrush& brush) +void wxPostScriptDCImpl::SetBackground (const wxBrush& brush) { m_backgroundBrush = brush; } -void wxPostScriptImplDC::SetLogicalFunction (int WXUNUSED(function)) +void wxPostScriptDCImpl::SetLogicalFunction (int WXUNUSED(function)) { - wxFAIL_MSG( wxT("wxPostScriptImplDC::SetLogicalFunction not implemented.") ); + wxFAIL_MSG( wxT("wxPostScriptDCImpl::SetLogicalFunction not implemented.") ); } #if wxUSE_SPLINES -void wxPostScriptImplDC::DoDrawSpline( const wxPointList *points ) +void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points ) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -1622,13 +1622,13 @@ void wxPostScriptImplDC::DoDrawSpline( const wxPointList *points ) } #endif // wxUSE_SPLINES -wxCoord wxPostScriptImplDC::GetCharWidth() const +wxCoord wxPostScriptDCImpl::GetCharWidth() const { // Chris Breeze: reasonable approximation using wxMODERN/Courier return (wxCoord) (GetCharHeight() * 72.0 / 120.0); } -void wxPostScriptImplDC::SetPrintData(const wxPrintData& data) +void wxPostScriptDCImpl::SetPrintData(const wxPrintData& data) { m_printData = data; @@ -1651,43 +1651,43 @@ void wxPostScriptImplDC::SetPrintData(const wxPrintData& data) #if wxUSE_NEW_DC #else -void wxPostScriptImplDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) +void wxPostScriptDCImpl::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) { wxDCBase::SetAxisOrientation(xLeftRight,yBottomUp); } -void wxPostScriptImplDC::SetMapMode(int mode) +void wxPostScriptDCImpl::SetMapMode(int mode) { wxDCBase::SetMapMode(mode); } -void wxPostScriptImplDC::SetUserScale(double x, double y) +void wxPostScriptDCImpl::SetUserScale(double x, double y) { wxDCBase::SetUserScale(x,y); } -void wxPostScriptImplDC::SetLogicalScale(double x, double y) +void wxPostScriptDCImpl::SetLogicalScale(double x, double y) { wxDCBase::SetLogicalScale(x,y); } -void wxPostScriptImplDC::SetLogicalOrigin(wxCoord x, wxCoord y) +void wxPostScriptDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y) { wxDCBase::SetLogicalOrigin(x,y); } -void wxPostScriptImplDC::SetDeviceOrigin(wxCoord x, wxCoord y) +void wxPostScriptDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y) { wxDCBase::SetDeviceOrigin(x,y); } #endif -void wxPostScriptImplDC::ComputeScaleAndOrigin() +void wxPostScriptDCImpl::ComputeScaleAndOrigin() { const wxRealPoint origScale(m_scaleX, m_scaleY); #if wxUSE_NEW_DC - wxImplDC::ComputeScaleAndOrigin(); + wxDCImpl::ComputeScaleAndOrigin(); #else wxDC::ComputeScaleAndOrigin(); #endif @@ -1701,7 +1701,7 @@ void wxPostScriptImplDC::ComputeScaleAndOrigin() } } -void wxPostScriptImplDC::DoGetSize(int* width, int* height) const +void wxPostScriptDCImpl::DoGetSize(int* width, int* height) const { wxPaperSize id = m_printData.GetPaperId(); @@ -1731,7 +1731,7 @@ void wxPostScriptImplDC::DoGetSize(int* width, int* height) const *height = wxRound( h * PS2DEV ); } -void wxPostScriptImplDC::DoGetSizeMM(int *width, int *height) const +void wxPostScriptDCImpl::DoGetSizeMM(int *width, int *height) const { wxPaperSize id = m_printData.GetPaperId(); @@ -1759,13 +1759,13 @@ void wxPostScriptImplDC::DoGetSizeMM(int *width, int *height) const } // Resolution in pixels per logical inch -wxSize wxPostScriptImplDC::GetPPI(void) const +wxSize wxPostScriptDCImpl::GetPPI(void) const { return wxSize( DPI, DPI ); } -bool wxPostScriptImplDC::StartDoc( const wxString& message ) +bool wxPostScriptDCImpl::StartDoc( const wxString& message ) { wxCHECK_MSG( m_ok, false, wxT("invalid postscript dc") ); @@ -1854,7 +1854,7 @@ bool wxPostScriptImplDC::StartDoc( const wxString& message ) return true; } -void wxPostScriptImplDC::EndDoc () +void wxPostScriptDCImpl::EndDoc () { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -1954,7 +1954,7 @@ void wxPostScriptImplDC::EndDoc () #endif } -void wxPostScriptImplDC::StartPage() +void wxPostScriptDCImpl::StartPage() { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -1992,14 +1992,14 @@ void wxPostScriptImplDC::StartPage() PsPrint( "90 rotate\n" ); } -void wxPostScriptImplDC::EndPage () +void wxPostScriptDCImpl::EndPage () { wxCHECK_RET( m_ok , wxT("invalid postscript dc") ); PsPrint( "showpage\n" ); } -bool wxPostScriptImplDC::DoBlit( wxCoord xdest, wxCoord ydest, +bool wxPostScriptDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord fwidth, wxCoord fheight, wxDC *source, wxCoord xsrc, wxCoord ysrc, @@ -2022,7 +2022,7 @@ bool wxPostScriptImplDC::DoBlit( wxCoord xdest, wxCoord ydest, return true; } -wxCoord wxPostScriptImplDC::GetCharHeight() const +wxCoord wxPostScriptDCImpl::GetCharHeight() const { if (m_font.Ok()) return m_font.GetPointSize(); @@ -2030,7 +2030,7 @@ wxCoord wxPostScriptImplDC::GetCharHeight() const return 12; } -void wxPostScriptImplDC::PsPrint( const wxString& str ) +void wxPostScriptDCImpl::PsPrint( const wxString& str ) { const wxCharBuffer psdata(str.utf8_str()); @@ -2057,7 +2057,7 @@ void wxPostScriptImplDC::PsPrint( const wxString& str ) } } -void wxPostScriptImplDC::DoGetTextExtent(const wxString& string, +void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, const wxFont *theFont ) const diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index df232c1db3..af6ee1db26 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -99,6 +99,7 @@ static inline double RadToDeg(double deg) #ifdef __WXGTK__ #include #include "wx/fontutil.h" +#include "wx/gtk/dc.h" #endif #ifdef __WXMSW__ @@ -323,6 +324,7 @@ class WXDLLIMPEXP_CORE wxCairoContext : public wxGraphicsContext public: wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& dc ); + wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& dc ); #ifdef __WXGTK__ wxCairoContext( wxGraphicsRenderer* renderer, GdkDrawable *drawable ); #endif @@ -1036,12 +1038,25 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& : wxGraphicsContext(renderer) { #ifdef __WXGTK__ -#if wxUSE_NEW_DC - wxGTKImplDC *impldc = (wxGTKImplDC*) dc.GetImpl(); + wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); -#else - Init( gdk_cairo_create( dc.m_window ) ); #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 ) ); + cairo_surface_destroy( surface ); +#endif +} + +wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& dc ) +: wxGraphicsContext(renderer) +{ +#ifdef __WXGTK__ + wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); + Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); #endif #ifdef __WXMAC__ int width, height; @@ -1465,10 +1480,7 @@ public : // Context virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc); - -#ifdef __WXMSW__ virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc); -#endif virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ); @@ -1531,12 +1543,10 @@ wxGraphicsContext * wxCairoRenderer::CreateContext( const wxWindowDC& dc) return new wxCairoContext(this,dc); } -#ifdef __WXMSW__ wxGraphicsContext * wxCairoRenderer::CreateContext( const wxMemoryDC& dc) { - return NULL; + return new wxCairoContext(this,dc); } -#endif wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeContext( void * context ) { diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 6cb1646fbe..239f0280fe 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -32,6 +32,8 @@ #include "wx/listimpl.cpp" #include "wx/gtk/private.h" +#include "wx/gtk/dc.h" +#include "wx/gtk/dcclient.h" //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -939,20 +941,12 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer, { wxRect renderrect( rect.x, rect.y, rect.width, rect.height ); wxWindowDC* dc = (wxWindowDC*) cell->GetDC(); -#if wxUSE_NEW_DC - wxGTKWindowDCImpl *impldc = (wxGTKWindowDCImpl *) dc->GetImpl(); - if (impldc->m_window == NULL) + wxWindowDCImpl *impl = (wxWindowDCImpl *) dc->GetImpl(); + if (impl->m_gdkwindow == NULL) { - impldc->m_window = window; - impldc->SetUpDC(); + impl->m_gdkwindow = window; + impl->SetUpDC(); } -#else - if (dc->m_window == NULL) - { - dc->m_window = window; - dc->SetUpDC(); - } -#endif int state = 0; if (flags & GTK_CELL_RENDERER_SELECTED) @@ -1657,41 +1651,37 @@ bool wxDataViewToggleRenderer::GetValue( wxVariant &value ) const // wxDataViewCustomRenderer // --------------------------------------------------------- -class wxDataViewCtrlDC: public wxWindowDC +class wxDataViewCtrlDCImpl: public wxWindowDCImpl { public: - wxDataViewCtrlDC( wxDataViewCtrl *window ) - { -#if wxUSE_NEW_DC - wxGTKWindowDCImpl *impl = (wxGTKWindowDCImpl*) GetImpl(); - + wxDataViewCtrlDCImpl( wxDC *owner, wxDataViewCtrl *window ) : + wxWindowDCImpl( owner ) + { GtkWidget *widget = window->m_treeview; // Set later - impl->m_window = NULL; - - impl->m_context = window->GtkGetPangoDefaultContext(); - impl->m_layout = pango_layout_new( impl->m_context ); - impl->m_fontdesc = pango_font_description_copy( widget->style->font_desc ); - - impl->m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget ); - -#else - GtkWidget *widget = window->m_treeview; - // Set later - m_window = NULL; + m_gdkwindow = NULL; + + m_window = window; m_context = window->GtkGetPangoDefaultContext(); m_layout = pango_layout_new( m_context ); m_fontdesc = pango_font_description_copy( widget->style->font_desc ); m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget ); -#endif - // Set m_window later + + // Set m_gdkwindow later // SetUpDC(); - // m_owner = window; } }; +class wxDataViewCtrlDC: public wxWindowDC +{ +public: + wxDataViewCtrlDC( wxDataViewCtrl *window ) + { m_pimpl = new wxDataViewCtrlDCImpl( this, window ); } +}; + + // --------------------------------------------------------- // wxDataViewCustomRenderer // --------------------------------------------------------- diff --git a/src/gtk/dc.cpp b/src/gtk/dc.cpp index fc3b001282..0b26d59db9 100644 --- a/src/gtk/dc.cpp +++ b/src/gtk/dc.cpp @@ -11,24 +11,16 @@ #include "wx/wxprec.h" #include "wx/dc.h" - +#include "wx/gtk/private.h" //----------------------------------------------------------------------------- -// wxDC +// wxGTKDCImpl //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -IMPLEMENT_ABSTRACT_CLASS(wxGTKImplDC, wxImplDC) -#else -IMPLEMENT_ABSTRACT_CLASS(wxGTKImplDC, wxDCBase) -#endif +IMPLEMENT_ABSTRACT_CLASS(wxGTKDCImpl, wxDCImpl) -#if wxUSE_NEW_DC -wxGTKImplDC::wxGTKImplDC( wxDC *owner ) - : wxImplDC( owner ) -#else -wxDC::wxDC() -#endif +wxGTKDCImpl::wxGTKDCImpl( wxDC *owner ) + : wxDCImpl( owner ) { m_ok = FALSE; @@ -37,11 +29,11 @@ wxDC::wxDC() m_brush = *wxWHITE_BRUSH; } -wxGTKImplDC::~wxGTKImplDC() +wxGTKDCImpl::~wxGTKDCImpl() { } -void wxGTKImplDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +void wxGTKDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { m_clipping = TRUE; m_clipX1 = x; @@ -54,7 +46,7 @@ void wxGTKImplDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCo // get DC capabilities // --------------------------------------------------------------------------- -void wxGTKImplDC::DoGetSizeMM( int* width, int* height ) const +void wxGTKDCImpl::DoGetSizeMM( int* width, int* height ) const { int w = 0; int h = 0; @@ -64,7 +56,7 @@ void wxGTKImplDC::DoGetSizeMM( int* width, int* height ) const } // Resolution in pixels per logical inch -wxSize wxGTKImplDC::GetPPI() const +wxSize wxGTKDCImpl::GetPPI() const { // TODO (should probably be pure virtual) return wxSize(0, 0); diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 1e8787ca40..43ac53209d 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -14,6 +14,7 @@ #define XCopyPlane XCOPYPLANE #endif +#include "wx/dc.h" #include "wx/dcclient.h" #ifndef WX_PRECOMP @@ -250,46 +251,34 @@ static void wxFreePoolGC( GdkGC *gc ) // wxWindowDC //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -IMPLEMENT_ABSTRACT_CLASS(wxGTKWindowImplDC, wxGTKImplDC) -#else -IMPLEMENT_ABSTRACT_CLASS(wxWindowDC, wxDC) -#endif +IMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl, wxGTKDCImpl) -#if wxUSE_NEW_DC -wxGTKWindowImplDC::wxGTKWindowImplDC( wxDC *owner ) : - wxGTKImplDC( owner ) -#else -wxWindowDC::wxWindowDC() -#endif +wxWindowDCImpl::wxWindowDCImpl( wxDC *owner ) : + wxGTKDCImpl( owner ) { + m_gdkwindow = (GdkWindow*) NULL; m_penGC = (GdkGC *) NULL; m_brushGC = (GdkGC *) NULL; m_textGC = (GdkGC *) NULL; m_bgGC = (GdkGC *) NULL; m_cmap = (GdkColormap *) NULL; m_isScreenDC = false; - m_owningWindow = (wxWindow *)NULL; m_context = (PangoContext *)NULL; m_layout = (PangoLayout *)NULL; m_fontdesc = (PangoFontDescription *)NULL; } -#if wxUSE_NEW_DC -wxGTKWindowImplDC::wxGTKWindowImplDC( wxDC *owner, wxWindow *window ) : - wxGTKImplDC( owner ) -#else -wxWindowDC::wxWindowDC( wxWindow *window ) -#endif +wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) : + wxGTKDCImpl( owner ) { wxASSERT_MSG( window, wxT("DC needs a window") ); + m_gdkwindow = (GdkWindow*) NULL; m_penGC = (GdkGC *) NULL; m_brushGC = (GdkGC *) NULL; m_textGC = (GdkGC *) NULL; m_bgGC = (GdkGC *) NULL; m_cmap = (GdkColormap *) NULL; - m_owningWindow = (wxWindow *)NULL; m_isScreenDC = false; m_font = window->GetFont(); @@ -310,10 +299,10 @@ wxWindowDC::wxWindowDC( wxWindow *window ) m_layout = pango_layout_new( m_context ); m_fontdesc = pango_font_description_copy( widget->style->font_desc ); - m_window = widget->window; + m_gdkwindow = widget->window; // Window not realized ? - if (!m_window) + if (!m_gdkwindow) { // Don't report problems as per MSW. m_ok = true; @@ -332,20 +321,20 @@ wxWindowDC::wxWindowDC( wxWindow *window ) is white whereas a window might assume gray to be the standard (as e.g. wxStatusBar) */ - m_owningWindow = window; + m_window = window; - if (m_owningWindow && m_owningWindow->m_wxwindow && - (m_owningWindow->GetLayoutDirection() == wxLayout_RightToLeft)) + if (m_window && m_window->m_wxwindow && + (m_window->GetLayoutDirection() == wxLayout_RightToLeft)) { // reverse sense m_signX = -1; // origin in the upper right corner - m_deviceOriginX = m_owningWindow->GetClientSize().x; + m_deviceOriginX = m_window->GetClientSize().x; } } -wxGTKWindowImplDC::~wxGTKWindowImplDC() +wxWindowDCImpl::~wxWindowDCImpl() { Destroy(); @@ -355,7 +344,7 @@ wxGTKWindowImplDC::~wxGTKWindowImplDC() pango_font_description_free( m_fontdesc ); } -void wxGTKWindowImplDC::SetUpDC( bool isMemDC ) +void wxWindowDCImpl::SetUpDC( bool isMemDC ) { m_ok = true; @@ -363,15 +352,14 @@ void wxGTKWindowImplDC::SetUpDC( bool isMemDC ) bool done = false; - if (isMemDC) + if ((isMemDC) && (GetSelectedBitmap().IsOk())) { - wxGTKMemoryImplDC *mem_dc = (wxGTKMemoryImplDC*) this; - if (mem_dc->GetSelectedBitmap().GetDepth() == 1) + if (GetSelectedBitmap().GetDepth() == 1) { - m_penGC = wxGetPoolGC( m_window, wxPEN_MONO ); - m_brushGC = wxGetPoolGC( m_window, wxBRUSH_MONO ); - m_textGC = wxGetPoolGC( m_window, wxTEXT_MONO ); - m_bgGC = wxGetPoolGC( m_window, wxBG_MONO ); + m_penGC = wxGetPoolGC( m_gdkwindow, wxPEN_MONO ); + m_brushGC = wxGetPoolGC( m_gdkwindow, wxBRUSH_MONO ); + m_textGC = wxGetPoolGC( m_gdkwindow, wxTEXT_MONO ); + m_bgGC = wxGetPoolGC( m_gdkwindow, wxBG_MONO ); done = true; } } @@ -380,17 +368,17 @@ void wxGTKWindowImplDC::SetUpDC( bool isMemDC ) { if (m_isScreenDC) { - m_penGC = wxGetPoolGC( m_window, wxPEN_SCREEN ); - m_brushGC = wxGetPoolGC( m_window, wxBRUSH_SCREEN ); - m_textGC = wxGetPoolGC( m_window, wxTEXT_SCREEN ); - m_bgGC = wxGetPoolGC( m_window, wxBG_SCREEN ); + m_penGC = wxGetPoolGC( m_gdkwindow, wxPEN_SCREEN ); + m_brushGC = wxGetPoolGC( m_gdkwindow, wxBRUSH_SCREEN ); + m_textGC = wxGetPoolGC( m_gdkwindow, wxTEXT_SCREEN ); + m_bgGC = wxGetPoolGC( m_gdkwindow, wxBG_SCREEN ); } else { - m_penGC = wxGetPoolGC( m_window, wxPEN_COLOUR ); - m_brushGC = wxGetPoolGC( m_window, wxBRUSH_COLOUR ); - m_textGC = wxGetPoolGC( m_window, wxTEXT_COLOUR ); - m_bgGC = wxGetPoolGC( m_window, wxBG_COLOUR ); + m_penGC = wxGetPoolGC( m_gdkwindow, wxPEN_COLOUR ); + m_brushGC = wxGetPoolGC( m_gdkwindow, wxBRUSH_COLOUR ); + m_textGC = wxGetPoolGC( m_gdkwindow, wxTEXT_COLOUR ); + m_bgGC = wxGetPoolGC( m_gdkwindow, wxBG_COLOUR ); } } @@ -453,14 +441,14 @@ void wxGTKWindowImplDC::SetUpDC( bool isMemDC ) } } -void wxGTKWindowImplDC::DoGetSize( int* width, int* height ) const +void wxWindowDCImpl::DoGetSize( int* width, int* height ) const { - wxCHECK_RET( m_owningWindow, _T("GetSize() doesn't work without window") ); + wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") ); - m_owningWindow->GetSize(width, height); + m_window->GetSize(width, height); } -bool wxGTKWindowImplDC::DoFloodFill(wxCoord x, wxCoord y, +bool wxWindowDCImpl::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) { #if wxUSE_IMAGE @@ -478,7 +466,7 @@ bool wxGTKWindowImplDC::DoFloodFill(wxCoord x, wxCoord y, #endif } -bool wxGTKWindowImplDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const +bool wxWindowDCImpl::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const { #if wxUSE_IMAGE // Generic (and therefore rather inefficient) method. @@ -486,7 +474,7 @@ bool wxGTKWindowImplDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) cons wxMemoryDC memdc; wxBitmap bitmap(1, 1); memdc.SelectObject(bitmap); - memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1); + memdc.Blit(0, 0, 1, 1, GetOwner(), x1, y1); memdc.SelectObject(wxNullBitmap); wxImage image = bitmap.ConvertToImage(); @@ -501,21 +489,21 @@ bool wxGTKWindowImplDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) cons #endif // wxUSE_IMAGE/!wxUSE_IMAGE } -void wxGTKWindowImplDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) +void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (m_pen.GetStyle() != wxTRANSPARENT) { - if (m_window) - gdk_draw_line( m_window, m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) ); + if (m_gdkwindow) + gdk_draw_line( m_gdkwindow, m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) ); CalcBoundingBox(x1, y1); CalcBoundingBox(x2, y2); } } -void wxGTKWindowImplDC::DoCrossHair( wxCoord x, wxCoord y ) +void wxWindowDCImpl::DoCrossHair( wxCoord x, wxCoord y ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -526,15 +514,15 @@ void wxGTKWindowImplDC::DoCrossHair( wxCoord x, wxCoord y ) GetOwner()->GetSize( &w, &h ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); - if (m_window) + if (m_gdkwindow) { - gdk_draw_line( m_window, m_penGC, 0, yy, XLOG2DEVREL(w), yy ); - gdk_draw_line( m_window, m_penGC, xx, 0, xx, YLOG2DEVREL(h) ); + gdk_draw_line( m_gdkwindow, m_penGC, 0, yy, XLOG2DEVREL(w), yy ); + gdk_draw_line( m_gdkwindow, m_penGC, xx, 0, xx, YLOG2DEVREL(h) ); } } } -void wxGTKWindowImplDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, +void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -575,7 +563,7 @@ void wxGTKWindowImplDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y while (alpha2 <= 0) alpha2 += 360*64; while (alpha1 > 360*64) alpha1 -= 360*64; - if (m_window) + if (m_gdkwindow) { if (m_brush.GetStyle() != wxTRANSPARENT) { @@ -584,19 +572,19 @@ void wxGTKWindowImplDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_textGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); + gdk_draw_arc( m_gdkwindow, m_textGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); gdk_gc_set_ts_origin( m_textGC, 0, 0 ); } else if (IS_15_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (IS_16_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (m_brush.GetStyle() == wxSTIPPLE) @@ -604,23 +592,23 @@ void wxGTKWindowImplDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else { - gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); } } if (m_pen.GetStyle() != wxTRANSPARENT) { - gdk_draw_arc( m_window, m_penGC, FALSE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); + gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); if ((m_brush.GetStyle() != wxTRANSPARENT) && (alpha2 - alpha1 != 360*64)) { - gdk_draw_line( m_window, m_penGC, xx1, yy1, xxc, yyc ); - gdk_draw_line( m_window, m_penGC, xxc, yyc, xx2, yy2 ); + gdk_draw_line( m_gdkwindow, m_penGC, xx1, yy1, xxc, yyc ); + gdk_draw_line( m_gdkwindow, m_penGC, xxc, yyc, xx2, yy2 ); } } } @@ -629,7 +617,7 @@ void wxGTKWindowImplDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y CalcBoundingBox (x2, y2); } -void wxGTKWindowImplDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) +void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -642,7 +630,7 @@ void wxGTKWindowImplDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, if (ww < 0) { ww = -ww; xx = xx - ww; } if (hh < 0) { hh = -hh; yy = yy - hh; } - if (m_window) + if (m_gdkwindow) { wxCoord start = wxCoord(sa * 64.0); wxCoord end = wxCoord((ea-sa) * 64.0); @@ -654,19 +642,19 @@ void wxGTKWindowImplDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy, ww, hh, start, end ); + gdk_draw_arc( m_gdkwindow, m_textGC, TRUE, xx, yy, ww, hh, start, end ); gdk_gc_set_ts_origin( m_textGC, 0, 0 ); } else if (IS_15_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (IS_16_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (m_brush.GetStyle() == wxSTIPPLE) @@ -674,34 +662,34 @@ void wxGTKWindowImplDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else { - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); } } if (m_pen.GetStyle() != wxTRANSPARENT) - gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, start, end ); + gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xx, yy, ww, hh, start, end ); } CalcBoundingBox (x, y); CalcBoundingBox (x + width, y + height); } -void wxGTKWindowImplDC::DoDrawPoint( wxCoord x, wxCoord y ) +void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if ((m_pen.GetStyle() != wxTRANSPARENT) && m_window) - gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) ); + if ((m_pen.GetStyle() != wxTRANSPARENT) && m_gdkwindow) + gdk_draw_point( m_gdkwindow, m_penGC, XLOG2DEV(x), YLOG2DEV(y) ); CalcBoundingBox (x, y); } -void wxGTKWindowImplDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) +void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -728,14 +716,14 @@ void wxGTKWindowImplDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, w CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset); } - if (m_window) - gdk_draw_lines( m_window, m_penGC, gpts, n); + if (m_gdkwindow) + gdk_draw_lines( m_gdkwindow, m_penGC, gpts, n); if (doScale) delete[] gpts; } -void wxGTKWindowImplDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int WXUNUSED(fillStyle) ) +void wxWindowDCImpl::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int WXUNUSED(fillStyle) ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -762,7 +750,7 @@ void wxGTKWindowImplDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset); } - if (m_window) + if (m_gdkwindow) { if (m_brush.GetStyle() != wxTRANSPARENT) { @@ -771,19 +759,19 @@ void wxGTKWindowImplDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_polygon( m_window, m_textGC, TRUE, gdkpoints, n ); + gdk_draw_polygon( m_gdkwindow, m_textGC, TRUE, gdkpoints, n ); gdk_gc_set_ts_origin( m_textGC, 0, 0 ); } else if (IS_15_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); + gdk_draw_polygon( m_gdkwindow, m_brushGC, TRUE, gdkpoints, n ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (IS_16_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); + gdk_draw_polygon( m_gdkwindow, m_brushGC, TRUE, gdkpoints, n ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (m_brush.GetStyle() == wxSTIPPLE) @@ -791,12 +779,12 @@ void wxGTKWindowImplDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); + gdk_draw_polygon( m_gdkwindow, m_brushGC, TRUE, gdkpoints, n ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else { - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); + gdk_draw_polygon( m_gdkwindow, m_brushGC, TRUE, gdkpoints, n ); } } @@ -805,14 +793,14 @@ void wxGTKWindowImplDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, /* for (i = 0 ; i < n ; i++) { - gdk_draw_line( m_window, m_penGC, + gdk_draw_line( m_gdkwindow, m_penGC, gdkpoints[i%n].x, gdkpoints[i%n].y, gdkpoints[(i+1)%n].x, gdkpoints[(i+1)%n].y); } */ - gdk_draw_polygon( m_window, m_penGC, FALSE, gdkpoints, n ); + gdk_draw_polygon( m_gdkwindow, m_penGC, FALSE, gdkpoints, n ); } } @@ -821,7 +809,7 @@ void wxGTKWindowImplDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, delete[] gdkpoints; } -void wxGTKWindowImplDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -837,7 +825,7 @@ void wxGTKWindowImplDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wx if (ww < 0) { ww = -ww; xx = xx - ww; } if (hh < 0) { hh = -hh; yy = yy - hh; } - if (m_window) + if (m_gdkwindow) { if (m_brush.GetStyle() != wxTRANSPARENT) { @@ -846,19 +834,19 @@ void wxGTKWindowImplDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wx gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh ); + gdk_draw_rectangle( m_gdkwindow, m_textGC, TRUE, xx, yy, ww, hh ); gdk_gc_set_ts_origin( m_textGC, 0, 0 ); } else if (IS_15_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (IS_16_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (m_brush.GetStyle() == wxSTIPPLE) @@ -866,12 +854,12 @@ void wxGTKWindowImplDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wx gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else { - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh ); } } @@ -887,13 +875,13 @@ void wxGTKWindowImplDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wx if (m_signX == -1) { // Different for RTL - gdk_draw_rectangle( m_window, m_penGC, FALSE, xx+1, yy, ww-2, hh-2 ); - gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy-1, ww, hh ); + gdk_draw_rectangle( m_gdkwindow, m_penGC, FALSE, xx+1, yy, ww-2, hh-2 ); + gdk_draw_rectangle( m_gdkwindow, m_penGC, FALSE, xx, yy-1, ww, hh ); } else { - gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-2, hh-2 ); - gdk_draw_rectangle( m_window, m_penGC, FALSE, xx-1, yy-1, ww, hh ); + gdk_draw_rectangle( m_gdkwindow, m_penGC, FALSE, xx, yy, ww-2, hh-2 ); + gdk_draw_rectangle( m_gdkwindow, m_penGC, FALSE, xx-1, yy-1, ww, hh ); } // reset @@ -903,7 +891,7 @@ void wxGTKWindowImplDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wx #endif { // Just use X11 for other cases - gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 ); + gdk_draw_rectangle( m_gdkwindow, m_penGC, FALSE, xx, yy, ww-1, hh-1 ); } } } @@ -912,7 +900,7 @@ void wxGTKWindowImplDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wx CalcBoundingBox( x + width, y + height ); } -void wxGTKWindowImplDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) +void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -947,7 +935,7 @@ void wxGTKWindowImplDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord wi hh--; } - if (m_window) + if (m_gdkwindow) { // CMB: ensure dd is not larger than rectangle otherwise we // get an hour glass shape @@ -963,34 +951,34 @@ void wxGTKWindowImplDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord wi gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_rectangle( m_window, m_textGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + gdk_draw_rectangle( m_gdkwindow, m_textGC, TRUE, xx+rr, yy, ww-dd+1, hh ); + gdk_draw_rectangle( m_gdkwindow, m_textGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); + gdk_draw_arc( m_gdkwindow, m_textGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_textGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_textGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_textGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); gdk_gc_set_ts_origin( m_textGC, 0, 0 ); } else if (IS_15_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (IS_16_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (m_brush.GetStyle() == wxSTIPPLE) @@ -998,35 +986,35 @@ void wxGTKWindowImplDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord wi gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else { - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); + gdk_draw_rectangle( m_gdkwindow, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); } } if (m_pen.GetStyle() != wxTRANSPARENT) { - gdk_draw_line( m_window, m_penGC, xx+rr+1, yy, xx+ww-rr, yy ); - gdk_draw_line( m_window, m_penGC, xx+rr+1, yy+hh, xx+ww-rr, yy+hh ); - gdk_draw_line( m_window, m_penGC, xx, yy+rr+1, xx, yy+hh-rr ); - gdk_draw_line( m_window, m_penGC, xx+ww, yy+rr+1, xx+ww, yy+hh-rr ); - gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_penGC, FALSE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_penGC, FALSE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + gdk_draw_line( m_gdkwindow, m_penGC, xx+rr+1, yy, xx+ww-rr, yy ); + gdk_draw_line( m_gdkwindow, m_penGC, xx+rr+1, yy+hh, xx+ww-rr, yy+hh ); + gdk_draw_line( m_gdkwindow, m_penGC, xx, yy+rr+1, xx, yy+hh-rr ); + gdk_draw_line( m_gdkwindow, m_penGC, xx+ww, yy+rr+1, xx+ww, yy+hh-rr ); + gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xx, yy, dd, dd, 90*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); } } @@ -1035,7 +1023,7 @@ void wxGTKWindowImplDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord wi CalcBoundingBox( x + width, y + height ); } -void wxGTKWindowImplDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -1048,7 +1036,7 @@ void wxGTKWindowImplDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCo if (ww < 0) { ww = -ww; xx = xx - ww; } if (hh < 0) { hh = -hh; yy = yy - hh; } - if (m_window) + if (m_gdkwindow) { if (m_brush.GetStyle() != wxTRANSPARENT) { @@ -1057,19 +1045,19 @@ void wxGTKWindowImplDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCo gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); + gdk_draw_arc( m_gdkwindow, m_textGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); gdk_gc_set_ts_origin( m_textGC, 0, 0 ); } else if (IS_15_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (IS_16_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (m_brush.GetStyle() == wxSTIPPLE) @@ -1077,30 +1065,30 @@ void wxGTKWindowImplDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCo gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else { - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); + gdk_draw_arc( m_gdkwindow, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); } } if (m_pen.GetStyle() != wxTRANSPARENT) - gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, 0, 360*64 ); + gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xx, yy, ww, hh, 0, 360*64 ); } CalcBoundingBox( x, y ); CalcBoundingBox( x + width, y + height ); } -void wxGTKWindowImplDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) +void wxWindowDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) { // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why DoDrawBitmap( (const wxBitmap&)icon, x, y, true ); } -void wxGTKWindowImplDC::DoDrawBitmap( const wxBitmap &bitmap, +void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap, wxCoord x, wxCoord y, bool useMask ) { @@ -1117,13 +1105,13 @@ void wxGTKWindowImplDC::DoDrawBitmap( const wxBitmap &bitmap, int w = bitmap.GetWidth(); int h = bitmap.GetHeight(); - if (m_owningWindow && m_owningWindow->GetLayoutDirection() == wxLayout_RightToLeft) + if (m_window && m_window->GetLayoutDirection() == wxLayout_RightToLeft) xx -= w; CalcBoundingBox( x, y ); CalcBoundingBox( x + w, y + h ); - if (!m_window) return; + if (!m_gdkwindow) return; int ww = XLOG2DEVREL(w); int hh = YLOG2DEVREL(h); @@ -1188,7 +1176,7 @@ void wxGTKWindowImplDC::DoDrawBitmap( const wxBitmap &bitmap, gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() ); gdk_wx_draw_bitmap(bitmap2, gc, use_bitmap.GetPixmap(), 0, 0); - gdk_draw_drawable(m_window, use_gc, bitmap2, 0, 0, xx, yy, -1, -1); + gdk_draw_drawable(m_gdkwindow, use_gc, bitmap2, 0, 0, xx, yy, -1, -1); g_object_unref (bitmap2); g_object_unref (gc); @@ -1197,14 +1185,14 @@ void wxGTKWindowImplDC::DoDrawBitmap( const wxBitmap &bitmap, { if (use_bitmap.HasPixbuf()) { - gdk_draw_pixbuf(m_window, use_gc, + gdk_draw_pixbuf(m_gdkwindow, use_gc, use_bitmap.GetPixbuf(), 0, 0, xx, yy, -1, -1, GDK_RGB_DITHER_NORMAL, xx, yy); } else { - gdk_draw_drawable(m_window, use_gc, + gdk_draw_drawable(m_gdkwindow, use_gc, use_bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1); } @@ -1222,7 +1210,7 @@ void wxGTKWindowImplDC::DoDrawBitmap( const wxBitmap &bitmap, } } -bool wxGTKWindowImplDC::DoBlit( wxCoord xdest, wxCoord ydest, +bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, @@ -1234,7 +1222,7 @@ bool wxGTKWindowImplDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCHECK_MSG( source, false, wxT("invalid source dc") ); - if (!m_window) return false; + if (!m_gdkwindow) return false; // transform the source DC coords to the device ones xsrc = source->LogicalToDeviceX(xsrc); @@ -1408,15 +1396,15 @@ bool wxGTKWindowImplDC::DoBlit( wxCoord xdest, wxCoord ydest, gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() ); gdk_wx_draw_bitmap(bitmap, gc, use_bitmap.GetPixmap(), 0, 0); - gdk_draw_drawable(m_window, use_gc, bitmap, xsrc, ysrc, cx, cy, cw, ch); + gdk_draw_drawable(m_gdkwindow, use_gc, bitmap, xsrc, ysrc, cx, cy, cw, ch); g_object_unref (bitmap); g_object_unref (gc); } else { - // was: gdk_draw_drawable( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh ); - gdk_draw_drawable(m_window, use_gc, use_bitmap.GetPixmap(), xsrc, ysrc, cx, cy, cw, ch); + // was: gdk_draw_drawable( m_gdkwindow, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh ); + gdk_draw_drawable(m_gdkwindow, use_gc, use_bitmap.GetPixmap(), xsrc, ysrc, cx, cy, cw, ch); } // remove mask again if any @@ -1445,16 +1433,16 @@ bool wxGTKWindowImplDC::DoBlit( wxCoord xdest, wxCoord ydest, wxBitmap bitmap = selected.Rescale( cx-xx, cy-yy, cw, ch, ww, hh ); // draw scaled bitmap - // was: gdk_draw_drawable( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 ); - gdk_draw_drawable( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, cx, cy, -1, -1 ); + // was: gdk_draw_drawable( m_gdkwindow, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 ); + gdk_draw_drawable( m_gdkwindow, m_penGC, bitmap.GetPixmap(), 0, 0, cx, cy, -1, -1 ); } else { // No scaling and not a memory dc with a mask either #if wxUSE_NEW_DC GdkWindow* window = NULL; - wxImplDC *impl = source->GetImpl(); - wxGTKWindowImplDC *gtk_impl = wxDynamicCast(impl, wxGTKWindowImplDC); + wxDCImpl *impl = source->GetImpl(); + wxWindowDCImpl *gtk_impl = wxDynamicCast(impl, wxWindowDCImpl); if (gtk_impl) window = gtk_impl->GetGDKWindow(); #else @@ -1465,7 +1453,7 @@ bool wxGTKWindowImplDC::DoBlit( wxCoord xdest, wxCoord ydest, // copy including child window contents gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS ); - gdk_draw_drawable( m_window, m_penGC, + gdk_draw_drawable( m_gdkwindow, m_penGC, window, xsrc, ysrc, xx, yy, width, height ); @@ -1478,11 +1466,11 @@ bool wxGTKWindowImplDC::DoBlit( wxCoord xdest, wxCoord ydest, return true; } -void wxGTKWindowImplDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) +void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (!m_window) return; + if (!m_gdkwindow) return; if (text.empty()) return; @@ -1588,15 +1576,15 @@ void wxGTKWindowImplDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) if ( m_backgroundMode == wxSOLID ) { gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor()); - gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h); + gdk_draw_rectangle(m_gdkwindow, m_textGC, TRUE, x, y, w, h); gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor()); } // Draw layout. - if (m_owningWindow && m_owningWindow->GetLayoutDirection() == wxLayout_RightToLeft) - gdk_draw_layout( m_window, m_textGC, x-w, y, m_layout ); + if (m_window && m_window->GetLayoutDirection() == wxLayout_RightToLeft) + gdk_draw_layout( m_gdkwindow, m_textGC, x-w, y, m_layout ); else - gdk_draw_layout( m_window, m_textGC, x, y, m_layout ); + gdk_draw_layout( m_gdkwindow, m_textGC, x, y, m_layout ); // reset unscaled size pango_font_description_set_size( m_fontdesc, oldSize ); @@ -1610,15 +1598,15 @@ void wxGTKWindowImplDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) if ( m_backgroundMode == wxSOLID ) { gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor()); - gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h); + gdk_draw_rectangle(m_gdkwindow, m_textGC, TRUE, x, y, w, h); gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor()); } // Draw layout. - if (m_owningWindow && m_owningWindow->GetLayoutDirection() == wxLayout_RightToLeft) - gdk_draw_layout( m_window, m_textGC, x-w, y, m_layout ); + if (m_window && m_window->GetLayoutDirection() == wxLayout_RightToLeft) + gdk_draw_layout( m_gdkwindow, m_textGC, x-w, y, m_layout ); else - gdk_draw_layout( m_window, m_textGC, x, y, m_layout ); + gdk_draw_layout( m_gdkwindow, m_textGC, x, y, m_layout ); } if (underlined) @@ -1644,10 +1632,10 @@ void wxGTKWindowImplDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) // a better approach here: // http://www.daa.com.au/pipermail/pygtk/2003-April/005052.html -void wxGTKWindowImplDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle ) +void wxWindowDCImpl::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle ) { #if wxUSE_IMAGE - if (!m_window || text.empty()) + if (!m_gdkwindow || text.empty()) return; wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -1736,7 +1724,7 @@ void wxGTKWindowImplDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCo #if 0 if ( m_font.GetUnderlined() ) { - gdk_draw_line( m_window, m_textGC, + gdk_draw_line( m_gdkwindow, m_textGC, XLOG2DEV(x + x4), YLOG2DEV(y + y4 + font->descent), XLOG2DEV(x + x3), YLOG2DEV(y + y3 + font->descent)); } @@ -1753,7 +1741,7 @@ void wxGTKWindowImplDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCo #endif // wxUSE_IMAGE/!wxUSE_IMAGE } -void wxGTKWindowImplDC::DoGetTextExtent(const wxString &string, +void wxWindowDCImpl::DoGetTextExtent(const wxString &string, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading, const wxFont *theFont) const @@ -1817,7 +1805,7 @@ void wxGTKWindowImplDC::DoGetTextExtent(const wxString &string, } -bool wxGTKWindowImplDC::DoGetPartialTextExtents(const wxString& text, +bool wxWindowDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const { const size_t len = text.length(); @@ -1860,7 +1848,7 @@ bool wxGTKWindowImplDC::DoGetPartialTextExtents(const wxString& text, } -wxCoord wxGTKWindowImplDC::GetCharWidth() const +wxCoord wxWindowDCImpl::GetCharWidth() const { pango_layout_set_text( m_layout, "H", 1 ); int w; @@ -1868,7 +1856,7 @@ wxCoord wxGTKWindowImplDC::GetCharWidth() const return w; } -wxCoord wxGTKWindowImplDC::GetCharHeight() const +wxCoord wxWindowDCImpl::GetCharHeight() const { PangoFontMetrics *metrics = pango_context_get_metrics (m_context, m_fontdesc, pango_context_get_language(m_context)); wxCHECK_MSG( metrics, -1, _T("failed to get pango font metrics") ); @@ -1879,18 +1867,18 @@ wxCoord wxGTKWindowImplDC::GetCharHeight() const return h; } -void wxGTKWindowImplDC::Clear() +void wxWindowDCImpl::Clear() { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (!m_window) return; + if (!m_gdkwindow) return; int width,height; DoGetSize( &width, &height ); - gdk_draw_rectangle( m_window, m_bgGC, TRUE, 0, 0, width, height ); + gdk_draw_rectangle( m_gdkwindow, m_bgGC, TRUE, 0, 0, width, height ); } -void wxGTKWindowImplDC::SetFont( const wxFont &font ) +void wxWindowDCImpl::SetFont( const wxFont &font ) { m_font = font; @@ -1902,11 +1890,11 @@ void wxGTKWindowImplDC::SetFont( const wxFont &font ) m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description ); - if (m_owningWindow) + if (m_window) { PangoContext *oldContext = m_context; - m_context = m_owningWindow->GtkGetPangoDefaultContext(); + m_context = m_window->GtkGetPangoDefaultContext(); // If we switch back/forth between different contexts // we also have to create a new layout. I think so, @@ -1924,7 +1912,7 @@ void wxGTKWindowImplDC::SetFont( const wxFont &font ) } } -void wxGTKWindowImplDC::SetPen( const wxPen &pen ) +void wxWindowDCImpl::SetPen( const wxPen &pen ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -1934,7 +1922,7 @@ void wxGTKWindowImplDC::SetPen( const wxPen &pen ) if (!m_pen.IsOk()) return; - if (!m_window) return; + if (!m_gdkwindow) return; gint width = m_pen.GetWidth(); if (width <= 0) @@ -2074,7 +2062,7 @@ void wxGTKWindowImplDC::SetPen( const wxPen &pen ) gdk_gc_set_foreground( m_penGC, m_pen.GetColour().GetColor() ); } -void wxGTKWindowImplDC::SetBrush( const wxBrush &brush ) +void wxWindowDCImpl::SetBrush( const wxBrush &brush ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -2084,7 +2072,7 @@ void wxGTKWindowImplDC::SetBrush( const wxBrush &brush ) if (!m_brush.IsOk()) return; - if (!m_window) return; + if (!m_gdkwindow) return; m_brush.GetColour().CalcPixel( m_cmap ); gdk_gc_set_foreground( m_brushGC, m_brush.GetColour().GetColor() ); @@ -2119,7 +2107,7 @@ void wxGTKWindowImplDC::SetBrush( const wxBrush &brush ) } } -void wxGTKWindowImplDC::SetBackground( const wxBrush &brush ) +void wxWindowDCImpl::SetBackground( const wxBrush &brush ) { /* CMB 21/7/98: Added SetBackground. Sets background brush * for Clear() and bg colour for shapes filled with cross-hatch brush */ @@ -2132,7 +2120,7 @@ void wxGTKWindowImplDC::SetBackground( const wxBrush &brush ) if (!m_backgroundBrush.IsOk()) return; - if (!m_window) return; + if (!m_gdkwindow) return; m_backgroundBrush.GetColour().CalcPixel( m_cmap ); gdk_gc_set_background( m_brushGC, m_backgroundBrush.GetColour().GetColor() ); @@ -2164,7 +2152,7 @@ void wxGTKWindowImplDC::SetBackground( const wxBrush &brush ) } } -void wxGTKWindowImplDC::SetLogicalFunction( int function ) +void wxWindowDCImpl::SetLogicalFunction( int function ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -2172,7 +2160,7 @@ void wxGTKWindowImplDC::SetLogicalFunction( int function ) return; // VZ: shouldn't this be a CHECK? - if (!m_window) + if (!m_gdkwindow) return; GdkFunction mode; @@ -2212,7 +2200,7 @@ void wxGTKWindowImplDC::SetLogicalFunction( int function ) gdk_gc_set_function( m_textGC, mode ); } -void wxGTKWindowImplDC::SetTextForeground( const wxColour &col ) +void wxWindowDCImpl::SetTextForeground( const wxColour &col ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -2224,14 +2212,14 @@ void wxGTKWindowImplDC::SetTextForeground( const wxColour &col ) m_textForegroundColour = col; - if ( m_window ) + if ( m_gdkwindow ) { m_textForegroundColour.CalcPixel( m_cmap ); gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() ); } } -void wxGTKWindowImplDC::SetTextBackground( const wxColour &col ) +void wxWindowDCImpl::SetTextBackground( const wxColour &col ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -2241,20 +2229,20 @@ void wxGTKWindowImplDC::SetTextBackground( const wxColour &col ) m_textBackgroundColour = col; - if ( m_window ) + if ( m_gdkwindow ) { m_textBackgroundColour.CalcPixel( m_cmap ); gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() ); } } -void wxGTKWindowImplDC::SetBackgroundMode( int mode ) +void wxWindowDCImpl::SetBackgroundMode( int mode ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); m_backgroundMode = mode; - if (!m_window) return; + if (!m_gdkwindow) return; // CMB 21/7/98: fill style of cross-hatch brushes is affected by // transparent/solid background mode @@ -2266,16 +2254,16 @@ void wxGTKWindowImplDC::SetBackgroundMode( int mode ) } } -void wxGTKWindowImplDC::SetPalette( const wxPalette& WXUNUSED(palette) ) +void wxWindowDCImpl::SetPalette( const wxPalette& WXUNUSED(palette) ) { - wxFAIL_MSG( wxT("wxGTKWindowImplDC::SetPalette not implemented") ); + wxFAIL_MSG( wxT("wxWindowDCImpl::SetPalette not implemented") ); } -void wxGTKWindowImplDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +void wxWindowDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (!m_window) return; + if (!m_gdkwindow) return; wxRect rect; rect.x = XLOG2DEV(x); @@ -2283,8 +2271,8 @@ void wxGTKWindowImplDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width rect.width = XLOG2DEVREL(width); rect.height = YLOG2DEVREL(height); - if (m_owningWindow && m_owningWindow->m_wxwindow && - (m_owningWindow->GetLayoutDirection() == wxLayout_RightToLeft)) + if (m_window && m_window->m_wxwindow && + (m_window->GetLayoutDirection() == wxLayout_RightToLeft)) { rect.x -= rect.width; } @@ -2302,7 +2290,7 @@ void wxGTKWindowImplDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width wxCoord xx, yy, ww, hh; m_currentClippingRegion.GetBox( xx, yy, ww, hh ); #if wxUSE_NEW_DC - wxGTKImplDC::DoSetClippingRegion( xx, yy, ww, hh ); + wxGTKDCImpl::DoSetClippingRegion( xx, yy, ww, hh ); #else wxDC::DoSetClippingRegion( xx, yy, ww, hh ); #endif @@ -2313,7 +2301,7 @@ void wxGTKWindowImplDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width gdk_gc_set_clip_region( m_bgGC, m_currentClippingRegion.GetRegion() ); } -void wxGTKWindowImplDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) +void wxWindowDCImpl::DoSetClippingRegionAsRegion( const wxRegion ®ion ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -2323,7 +2311,7 @@ void wxGTKWindowImplDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) return; } - if (!m_window) return; + if (!m_gdkwindow) return; if (!m_currentClippingRegion.IsNull()) m_currentClippingRegion.Intersect( region ); @@ -2338,7 +2326,7 @@ void wxGTKWindowImplDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) wxCoord xx, yy, ww, hh; m_currentClippingRegion.GetBox( xx, yy, ww, hh ); #if wxUSE_NEW_DC - wxGTKImplDC::DoSetClippingRegion( xx, yy, ww, hh ); + wxGTKDCImpl::DoSetClippingRegion( xx, yy, ww, hh ); #else wxDC::DoSetClippingRegion( xx, yy, ww, hh ); #endif @@ -2349,12 +2337,12 @@ void wxGTKWindowImplDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) gdk_gc_set_clip_region( m_bgGC, m_currentClippingRegion.GetRegion() ); } -void wxGTKWindowImplDC::DestroyClippingRegion() +void wxWindowDCImpl::DestroyClippingRegion() { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); #if wxUSE_NEW_DC - wxImplDC::DestroyClippingRegion(); + wxDCImpl::DestroyClippingRegion(); #else wxDC::DestroyClippingRegion(); #endif @@ -2366,7 +2354,7 @@ void wxGTKWindowImplDC::DestroyClippingRegion() m_currentClippingRegion.Union( m_paintClippingRegion ); #endif - if (!m_window) return; + if (!m_gdkwindow) return; if (m_currentClippingRegion.IsEmpty()) { @@ -2384,7 +2372,7 @@ void wxGTKWindowImplDC::DestroyClippingRegion() } } -void wxGTKWindowImplDC::Destroy() +void wxWindowDCImpl::Destroy() { if (m_penGC) wxFreePoolGC( m_penGC ); m_penGC = (GdkGC*) NULL; @@ -2396,7 +2384,7 @@ void wxGTKWindowImplDC::Destroy() m_bgGC = (GdkGC*) NULL; } -void wxGTKWindowImplDC::SetDeviceOrigin( wxCoord x, wxCoord y ) +void wxWindowDCImpl::SetDeviceOrigin( wxCoord x, wxCoord y ) { m_deviceOriginX = x; m_deviceOriginY = y; @@ -2404,24 +2392,24 @@ void wxGTKWindowImplDC::SetDeviceOrigin( wxCoord x, wxCoord y ) ComputeScaleAndOrigin(); } -void wxGTKWindowImplDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) +void wxWindowDCImpl::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) { m_signX = (xLeftRight ? 1 : -1); m_signY = (yBottomUp ? -1 : 1); - if (m_owningWindow && m_owningWindow->m_wxwindow && - (m_owningWindow->GetLayoutDirection() == wxLayout_RightToLeft)) + if (m_window && m_window->m_wxwindow && + (m_window->GetLayoutDirection() == wxLayout_RightToLeft)) m_signX = -m_signX; ComputeScaleAndOrigin(); } -void wxGTKWindowImplDC::ComputeScaleAndOrigin() +void wxWindowDCImpl::ComputeScaleAndOrigin() { const wxRealPoint origScale(m_scaleX, m_scaleY); #if wxUSE_NEW_DC - wxImplDC::ComputeScaleAndOrigin(); + wxDCImpl::ComputeScaleAndOrigin(); #else wxDC::ComputeScaleAndOrigin(); #endif @@ -2438,71 +2426,54 @@ void wxGTKWindowImplDC::ComputeScaleAndOrigin() } // Resolution in pixels per logical inch -wxSize wxGTKWindowImplDC::GetPPI() const +wxSize wxWindowDCImpl::GetPPI() const { return wxSize( (int) (m_mm_to_pix_x * 25.4 + 0.5), (int) (m_mm_to_pix_y * 25.4 + 0.5)); } -int wxGTKWindowImplDC::GetDepth() const +int wxWindowDCImpl::GetDepth() const { - return gdk_drawable_get_depth(m_window); + return gdk_drawable_get_depth(m_gdkwindow); } //----------------------------------------------------------------------------- -// wxClientDC +// wxClientDCImpl //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -IMPLEMENT_ABSTRACT_CLASS(wxGTKClientImplDC, wxGTKWindowImplDC) -#else -IMPLEMENT_ABSTRACT_CLASS(wxClientDC, wxWindowDC) -#endif +IMPLEMENT_ABSTRACT_CLASS(wxClientDCImpl, wxWindowDCImpl) -#if wxUSE_NEW_DC -wxGTKClientImplDC::wxGTKClientImplDC( wxDC *owner ) - : wxGTKWindowImplDC( owner ) +wxClientDCImpl::wxClientDCImpl( wxDC *owner ) + : wxWindowDCImpl( owner ) { } -wxGTKClientImplDC::wxGTKClientImplDC( wxDC *owner, wxWindow *win ) - : wxGTKWindowImplDC( owner, win ) -#else -wxClientDC::wxClientDC() +wxClientDCImpl::wxClientDCImpl( wxDC *owner, wxWindow *win ) + : wxWindowDCImpl( owner, win ) { -} - -wxClientDC::wxClientDC( wxWindow *win ) - : wxWindowDC( win ) -#endif - -{ - wxCHECK_RET( win, _T("NULL window in wxGTKClientImplDC::wxClientDC") ); + wxCHECK_RET( win, _T("NULL window in wxClientDCImpl::wxClientDC") ); #ifdef __WXUNIVERSAL__ wxPoint ptOrigin = win->GetClientAreaOrigin(); SetDeviceOrigin(ptOrigin.x, ptOrigin.y); wxSize size = win->GetClientSize(); SetClippingRegion(wxPoint(0, 0), size); -#endif // __WXUNIVERSAL__ +#endif + // __WXUNIVERSAL__ } -void wxGTKClientImplDC::DoGetSize(int *width, int *height) const +void wxClientDCImpl::DoGetSize(int *width, int *height) const { - wxCHECK_RET( m_owningWindow, _T("GetSize() doesn't work without window") ); + wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") ); - m_owningWindow->GetClientSize( width, height ); + m_window->GetClientSize( width, height ); } //----------------------------------------------------------------------------- -// wxPaintDC +// wxPaintDCImpl //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -IMPLEMENT_ABSTRACT_CLASS(wxGTKPaintImplDC, wxGTKClientImplDC) -#else -IMPLEMENT_ABSTRACT_CLASS(wxPaintDC, wxClientDC) -#endif +IMPLEMENT_ABSTRACT_CLASS(wxPaintDCImpl, wxClientDCImpl) // Limit the paint region to the window size. Sometimes // the paint region is too big, and this risks X11 errors @@ -2523,23 +2494,13 @@ static void wxLimitRegionToSize(wxRegion& region, const wxSize& sz) } } -#if wxUSE_NEW_DC -wxGTKPaintImplDC::wxGTKPaintImplDC( wxDC *owner ) - : wxGTKClientImplDC( owner ) +wxPaintDCImpl::wxPaintDCImpl( wxDC *owner ) + : wxClientDCImpl( owner ) { } -wxGTKPaintImplDC::wxGTKPaintImplDC( wxDC *owner, wxWindow *win ) - : wxGTKClientImplDC( owner, win ) -#else -wxPaintDC::wxPaintDC() - : wxClientDC() -{ -} - -wxPaintDC::wxPaintDC( wxWindow *win ) - : wxClientDC( win ) -#endif +wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *win ) + : wxClientDCImpl( owner, win ) { #if USE_PAINT_REGION if (!win->m_clipPaintRegion) @@ -2563,7 +2524,7 @@ wxPaintDC::wxPaintDC( wxWindow *win ) gdk_gc_set_clip_region( m_textGC, region ); gdk_gc_set_clip_region( m_bgGC, region ); } -#endif // USE_PAINT_REGION +#endif } // ---------------------------------------------------------------------------- diff --git a/src/gtk/dcmemory.cpp b/src/gtk/dcmemory.cpp index 948f09826a..2a0d2687cb 100644 --- a/src/gtk/dcmemory.cpp +++ b/src/gtk/dcmemory.cpp @@ -11,64 +11,42 @@ #include "wx/wxprec.h" #include "wx/dcmemory.h" +#include "wx/gtk/dcmemory.h" #include #include //----------------------------------------------------------------------------- -// wxMemoryDC +// wxMemoryDCImpl //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -IMPLEMENT_ABSTRACT_CLASS(wxGTKMemoryImplDC, wxGTKWindowImplDC) -#else -IMPLEMENT_ABSTRACT_CLASS(wxMemoryDC,wxWindowDC) -#endif +IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxWindowDCImpl) -#if wxUSE_NEW_DC -wxGTKMemoryImplDC::wxGTKMemoryImplDC( wxMemoryDC *owner ) - : wxGTKWindowImplDC( owner ) +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner ) + : wxWindowDCImpl( owner ) { Init(); } -wxGTKMemoryImplDC::wxGTKMemoryImplDC( wxMemoryDC *owner, wxBitmap& bitmap) - : wxGTKWindowImplDC( owner ) +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap) + : wxWindowDCImpl( owner ) { Init(); owner->SelectObject(bitmap); } -wxGTKMemoryImplDC::wxGTKMemoryImplDC( wxMemoryDC *owner, wxDC *WXUNUSED(dc) ) - : wxGTKWindowImplDC( owner ) +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxDC *WXUNUSED(dc) ) + : wxWindowDCImpl( owner ) { Init(); } -#else -wxMemoryDC::wxMemoryDC() -{ - Init(); -} - -wxMemoryDC::wxMemoryDC(wxBitmap& bitmap) -{ - Init(); - SelectObject(bitmap); -} -wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) - : wxWindowDC() -{ - Init(); -} -#endif - -wxGTKMemoryImplDC::~wxGTKMemoryImplDC() +wxMemoryDCImpl::~wxMemoryDCImpl() { g_object_unref(m_context); } -void wxGTKMemoryImplDC::Init() +void wxMemoryDCImpl::Init() { m_ok = false; @@ -82,14 +60,14 @@ void wxGTKMemoryImplDC::Init() m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) ); } -void wxGTKMemoryImplDC::DoSelect( const wxBitmap& bitmap ) +void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) { Destroy(); m_selected = bitmap; if (m_selected.Ok()) { - m_window = m_selected.GetPixmap(); + m_gdkwindow = m_selected.GetPixmap(); m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap); @@ -98,11 +76,11 @@ void wxGTKMemoryImplDC::DoSelect( const wxBitmap& bitmap ) else { m_ok = false; - m_window = (GdkWindow *) NULL; + m_gdkwindow = (GdkWindow *) NULL; } } -void wxGTKMemoryImplDC::SetPen( const wxPen& penOrig ) +void wxMemoryDCImpl::SetPen( const wxPen& penOrig ) { wxPen pen( penOrig ); if ( m_selected.Ok() && @@ -112,10 +90,10 @@ void wxGTKMemoryImplDC::SetPen( const wxPen& penOrig ) pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); } - wxGTKWindowImplDC::SetPen( pen ); + wxWindowDCImpl::SetPen( pen ); } -void wxGTKMemoryImplDC::SetBrush( const wxBrush& brushOrig ) +void wxMemoryDCImpl::SetBrush( const wxBrush& brushOrig ) { wxBrush brush( brushOrig ); if ( m_selected.Ok() && @@ -125,10 +103,10 @@ void wxGTKMemoryImplDC::SetBrush( const wxBrush& brushOrig ) brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE); } - wxGTKWindowImplDC::SetBrush( brush ); + wxWindowDCImpl::SetBrush( brush ); } -void wxGTKMemoryImplDC::SetBackground( const wxBrush& brushOrig ) +void wxMemoryDCImpl::SetBackground( const wxBrush& brushOrig ) { wxBrush brush(brushOrig); @@ -139,34 +117,26 @@ void wxGTKMemoryImplDC::SetBackground( const wxBrush& brushOrig ) brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); } - wxGTKWindowImplDC::SetBackground( brush ); + wxWindowDCImpl::SetBackground( brush ); } -void wxGTKMemoryImplDC::SetTextForeground( const wxColour& col ) +void wxMemoryDCImpl::SetTextForeground( const wxColour& col ) { if ( m_selected.Ok() && m_selected.GetDepth() == 1 ) - { - wxGTKWindowImplDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE); - } + wxWindowDCImpl::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE); else - { - wxGTKWindowImplDC::SetTextForeground( col ); - } + wxWindowDCImpl::SetTextForeground( col ); } -void wxGTKMemoryImplDC::SetTextBackground( const wxColour &col ) +void wxMemoryDCImpl::SetTextBackground( const wxColour &col ) { if (m_selected.Ok() && m_selected.GetDepth() == 1) - { - wxGTKWindowImplDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE ); - } + wxWindowDCImpl::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE ); else - { - wxGTKWindowImplDC::SetTextBackground( col ); - } + wxWindowDCImpl::SetTextBackground( col ); } -void wxGTKMemoryImplDC::DoGetSize( int *width, int *height ) const +void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const { if (m_selected.Ok()) { @@ -180,18 +150,18 @@ void wxGTKMemoryImplDC::DoGetSize( int *width, int *height ) const } } -wxBitmap wxGTKMemoryImplDC::DoGetAsBitmap(const wxRect *subrect) const +wxBitmap wxMemoryDCImpl::DoGetAsBitmap(const wxRect *subrect) const { wxBitmap bmp = GetSelectedBitmap(); return subrect ? bmp.GetSubBitmap(*subrect) : bmp; } -const wxBitmap& wxGTKMemoryImplDC::GetSelectedBitmap() const +const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const { return m_selected; } -wxBitmap& wxGTKMemoryImplDC::GetSelectedBitmap() +wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() { return m_selected; } diff --git a/src/gtk/dcscreen.cpp b/src/gtk/dcscreen.cpp index 9883225620..e32427f51e 100644 --- a/src/gtk/dcscreen.cpp +++ b/src/gtk/dcscreen.cpp @@ -11,6 +11,7 @@ #include "wx/wxprec.h" #include "wx/dcscreen.h" +#include "wx/gtk/dcscreen.h" #ifndef WX_PRECOMP #include "wx/window.h" @@ -20,36 +21,23 @@ #include #include - //----------------------------------------------------------------------------- -// wxScreenDC +// wxScreenDCImpl //----------------------------------------------------------------------------- -#if wxUSE_NEW_DC -IMPLEMENT_ABSTRACT_CLASS(wxGTKScreenImplDC, wxGTKWindowImplDC) -#else -IMPLEMENT_ABSTRACT_CLASS(wxScreenDC,wxWindowDC) -#endif +IMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl, wxWindowDCImpl) -#if wxUSE_NEW_DC -wxGTKScreenImplDC::wxGTKScreenImplDC( wxScreenDC *owner ) - : wxGTKWindowImplDC( owner ) +wxScreenDCImpl::wxScreenDCImpl( wxScreenDC *owner ) + : wxWindowDCImpl( owner ) { Init(); } -#else -wxScreenDC::wxScreenDC() -{ - Init(); -} -#endif - -void wxGTKScreenImplDC::Init() +void wxScreenDCImpl::Init() { m_ok = false; m_cmap = gdk_colormap_get_system(); - m_window = gdk_get_default_root_window(); + m_gdkwindow = gdk_get_default_root_window(); m_context = gdk_pango_context_get(); // Note: The Sun customised version of Pango shipping with Solaris 10 @@ -68,7 +56,7 @@ void wxGTKScreenImplDC::Init() gdk_gc_set_subwindow( m_bgGC, GDK_INCLUDE_INFERIORS ); } -wxGTKScreenImplDC::~wxGTKScreenImplDC() +wxScreenDCImpl::~wxScreenDCImpl() { gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); gdk_gc_set_subwindow( m_brushGC, GDK_CLIP_BY_CHILDREN ); @@ -76,7 +64,7 @@ wxGTKScreenImplDC::~wxGTKScreenImplDC() gdk_gc_set_subwindow( m_bgGC, GDK_CLIP_BY_CHILDREN ); } -void wxGTKScreenImplDC::DoGetSize(int *width, int *height) const +void wxScreenDCImpl::DoGetSize(int *width, int *height) const { wxDisplaySize(width, height); } diff --git a/src/gtk/gnome/gprint.cpp b/src/gtk/gnome/gprint.cpp index 9790c465aa..5b9a82211a 100644 --- a/src/gtk/gnome/gprint.cpp +++ b/src/gtk/gnome/gprint.cpp @@ -480,9 +480,9 @@ wxGnomePrintFactory::CreatePrintSetupDialog(wxWindow * WXUNUSED(parent), #if wxUSE_NEW_DC -wxImplDC* wxGnomePrintFactory::CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ) +wxDCImpl* wxGnomePrintFactory::CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) { - return new wxGnomePrinterImplDC( owner, data ); + return new wxGnomePrinterDCImpl( owner, data ); } #else @@ -1006,14 +1006,14 @@ static const double DEV2PS = 72.0 / 600.0; #define YLOG2DEVREL(x) ((double)(LogicalToDeviceYRel(x)) * DEV2PS) #if wxUSE_NEW_DC -IMPLEMENT_ABSTRACT_CLASS(wxGnomePrinterImplDC, wxImplDC) +IMPLEMENT_ABSTRACT_CLASS(wxGnomePrinterDCImpl, wxDCImpl) #else IMPLEMENT_ABSTRACT_CLASS(wxGnomePrinterDC, wxDC) #endif #if wxUSE_NEW_DC -wxGnomePrinterImplDC::wxGnomePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ) : - wxImplDC( owner ) +wxGnomePrinterDCImpl::wxGnomePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) : + wxDCImpl( owner ) #else wxGnomePrinterDC::wxGnomePrinterDC( const wxPrintData& data ) #endif @@ -1041,17 +1041,17 @@ wxGnomePrinterDC::wxGnomePrinterDC( const wxPrintData& data ) m_pageHeight = ph * PS2DEV; } -wxGnomePrinterImplDC::~wxGnomePrinterImplDC() +wxGnomePrinterDCImpl::~wxGnomePrinterDCImpl() { } -bool wxGnomePrinterImplDC::IsOk() const +bool wxGnomePrinterDCImpl::IsOk() const { return true; } bool -wxGnomePrinterImplDC::DoFloodFill(wxCoord WXUNUSED(x1), +wxGnomePrinterDCImpl::DoFloodFill(wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1), const wxColour& WXUNUSED(col), int WXUNUSED(style)) @@ -1060,14 +1060,14 @@ wxGnomePrinterImplDC::DoFloodFill(wxCoord WXUNUSED(x1), } bool -wxGnomePrinterImplDC::DoGetPixel(wxCoord WXUNUSED(x1), +wxGnomePrinterDCImpl::DoGetPixel(wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1), wxColour * WXUNUSED(col)) const { return false; } -void wxGnomePrinterImplDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) +void wxGnomePrinterDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { if (m_pen.GetStyle() == wxTRANSPARENT) return; @@ -1081,11 +1081,11 @@ void wxGnomePrinterImplDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoor CalcBoundingBox( x2, y2 ); } -void wxGnomePrinterImplDC::DoCrossHair(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) +void wxGnomePrinterDCImpl::DoCrossHair(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { } -void wxGnomePrinterImplDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) +void wxGnomePrinterDCImpl::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) { double dx = x1 - xc; double dy = y1 - yc; @@ -1141,7 +1141,7 @@ void wxGnomePrinterImplDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2 CalcBoundingBox (xc, yc); } -void wxGnomePrinterImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) +void wxGnomePrinterDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { x += w/2; y += h/2; @@ -1186,11 +1186,11 @@ void wxGnomePrinterImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoo CalcBoundingBox( x+w, y+h ); } -void wxGnomePrinterImplDC::DoDrawPoint(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) +void wxGnomePrinterDCImpl::DoDrawPoint(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { } -void wxGnomePrinterImplDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxGnomePrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { if (m_pen.GetStyle() == wxTRANSPARENT) return; @@ -1210,7 +1210,7 @@ void wxGnomePrinterImplDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, gs_libGnomePrint->gnome_print_stroke ( m_gpc); } -void wxGnomePrinterImplDC::DoDrawPolygon(int n, wxPoint points[], +void wxGnomePrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int WXUNUSED(fillStyle)) { @@ -1258,16 +1258,16 @@ void wxGnomePrinterImplDC::DoDrawPolygon(int n, wxPoint points[], } } -void wxGnomePrinterImplDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +void wxGnomePrinterDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { #if wxUSE_NEW_DC - wxImplDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); + wxDCImpl::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); #else wxDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); #endif } -void wxGnomePrinterImplDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxGnomePrinterDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { width--; height--; @@ -1305,7 +1305,7 @@ void wxGnomePrinterImplDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, } } -void wxGnomePrinterImplDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) +void wxGnomePrinterDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) { width--; height--; @@ -1377,7 +1377,7 @@ void wxGnomePrinterImplDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord } } -void wxGnomePrinterImplDC::makeEllipticalPath(wxCoord x, wxCoord y, +void wxGnomePrinterDCImpl::makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { double r = 4 * (sqrt(2.) - 1) / 3; @@ -1423,7 +1423,7 @@ void wxGnomePrinterImplDC::makeEllipticalPath(wxCoord x, wxCoord y, gs_libGnomePrint->gnome_print_closepath(m_gpc); } -void wxGnomePrinterImplDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxGnomePrinterDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { width--; height--; @@ -1448,7 +1448,7 @@ void wxGnomePrinterImplDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wx } #if wxUSE_SPLINES -void wxGnomePrinterImplDC::DoDrawSpline(const wxPointList *points) +void wxGnomePrinterDCImpl::DoDrawSpline(const wxPointList *points) { SetPen (m_pen); @@ -1508,7 +1508,7 @@ void wxGnomePrinterImplDC::DoDrawSpline(const wxPointList *points) #endif // wxUSE_SPLINES bool -wxGnomePrinterImplDC::DoBlit(wxCoord xdest, wxCoord ydest, +wxGnomePrinterDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, @@ -1531,13 +1531,13 @@ wxGnomePrinterImplDC::DoBlit(wxCoord xdest, wxCoord ydest, return true; } -void wxGnomePrinterImplDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) +void wxGnomePrinterDCImpl::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) { DoDrawBitmap( icon, x, y, true ); } void -wxGnomePrinterImplDC::DoDrawBitmap(const wxBitmap& bitmap, +wxGnomePrinterDCImpl::DoDrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool WXUNUSED(useMask)) { @@ -1589,12 +1589,12 @@ wxGnomePrinterImplDC::DoDrawBitmap(const wxBitmap& bitmap, } } -void wxGnomePrinterImplDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y ) +void wxGnomePrinterDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y ) { DoDrawRotatedText( text, x, y, 0.0 ); } -void wxGnomePrinterImplDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) +void wxGnomePrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) { double xx = XLOG2DEV(x); double yy = YLOG2DEV(y); @@ -1676,11 +1676,11 @@ void wxGnomePrinterImplDC::DoDrawRotatedText(const wxString& text, wxCoord x, wx CalcBoundingBox (x + w, y + h); } -void wxGnomePrinterImplDC::Clear() +void wxGnomePrinterDCImpl::Clear() { } -void wxGnomePrinterImplDC::SetFont( const wxFont& font ) +void wxGnomePrinterDCImpl::SetFont( const wxFont& font ) { m_font = font; @@ -1695,7 +1695,7 @@ void wxGnomePrinterImplDC::SetFont( const wxFont& font ) } } -void wxGnomePrinterImplDC::SetPen( const wxPen& pen ) +void wxGnomePrinterDCImpl::SetPen( const wxPen& pen ) { if (!pen.Ok()) return; @@ -1761,7 +1761,7 @@ void wxGnomePrinterImplDC::SetPen( const wxPen& pen ) } } -void wxGnomePrinterImplDC::SetBrush( const wxBrush& brush ) +void wxGnomePrinterDCImpl::SetBrush( const wxBrush& brush ) { if (!brush.Ok()) return; @@ -1800,15 +1800,15 @@ void wxGnomePrinterImplDC::SetBrush( const wxBrush& brush ) } } -void wxGnomePrinterImplDC::SetLogicalFunction(int WXUNUSED(function)) +void wxGnomePrinterDCImpl::SetLogicalFunction(int WXUNUSED(function)) { } -void wxGnomePrinterImplDC::SetBackground(const wxBrush& WXUNUSED(brush)) +void wxGnomePrinterDCImpl::SetBackground(const wxBrush& WXUNUSED(brush)) { } -void wxGnomePrinterImplDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxGnomePrinterDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { #if wxUSE_NEW_DC m_clipping = TRUE; // TODO move somewhere else @@ -1831,10 +1831,10 @@ void wxGnomePrinterImplDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord wid gs_libGnomePrint->gnome_print_clip( m_gpc ); } -void wxGnomePrinterImplDC::DestroyClippingRegion() +void wxGnomePrinterDCImpl::DestroyClippingRegion() { #if wxUSE_NEW_DC - wxImplDC::DestroyClippingRegion(); + wxDCImpl::DestroyClippingRegion(); #else wxDC::DestroyClippingRegion(); #endif @@ -1850,27 +1850,27 @@ void wxGnomePrinterImplDC::DestroyClippingRegion() #endif } -bool wxGnomePrinterImplDC::StartDoc(const wxString& WXUNUSED(message)) +bool wxGnomePrinterDCImpl::StartDoc(const wxString& WXUNUSED(message)) { return true; } -void wxGnomePrinterImplDC::EndDoc() +void wxGnomePrinterDCImpl::EndDoc() { gs_libGnomePrint->gnome_print_end_doc( m_gpc ); } -void wxGnomePrinterImplDC::StartPage() +void wxGnomePrinterDCImpl::StartPage() { gs_libGnomePrint->gnome_print_beginpage( m_gpc, (const guchar*) "page" ); } -void wxGnomePrinterImplDC::EndPage() +void wxGnomePrinterDCImpl::EndPage() { gs_libGnomePrint->gnome_print_showpage( m_gpc ); } -wxCoord wxGnomePrinterImplDC::GetCharHeight() const +wxCoord wxGnomePrinterDCImpl::GetCharHeight() const { pango_layout_set_text( m_layout, "H", 1 ); @@ -1880,7 +1880,7 @@ wxCoord wxGnomePrinterImplDC::GetCharHeight() const return h; } -wxCoord wxGnomePrinterImplDC::GetCharWidth() const +wxCoord wxGnomePrinterDCImpl::GetCharWidth() const { pango_layout_set_text( m_layout, "H", 1 ); @@ -1890,7 +1890,7 @@ wxCoord wxGnomePrinterImplDC::GetCharWidth() const return w; } -void wxGnomePrinterImplDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height, +void wxGnomePrinterDCImpl::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading, const wxFont *theFont ) const @@ -1954,7 +1954,7 @@ void wxGnomePrinterImplDC::DoGetTextExtent(const wxString& string, wxCoord *widt pango_layout_set_font_description( m_layout, m_fontdesc ); } -void wxGnomePrinterImplDC::DoGetSize(int* width, int* height) const +void wxGnomePrinterDCImpl::DoGetSize(int* width, int* height) const { wxGnomePrintNativeData *native = (wxGnomePrintNativeData*) m_printData.GetNativeData(); @@ -1970,7 +1970,7 @@ void wxGnomePrinterImplDC::DoGetSize(int* width, int* height) const *height = wxRound( ph * PS2DEV ); } -void wxGnomePrinterImplDC::DoGetSizeMM(int *width, int *height) const +void wxGnomePrinterDCImpl::DoGetSizeMM(int *width, int *height) const { wxGnomePrintNativeData *native = (wxGnomePrintNativeData*) m_printData.GetNativeData(); @@ -1993,12 +1993,12 @@ void wxGnomePrinterImplDC::DoGetSizeMM(int *width, int *height) const *height = (int) (ph + 0.5); } -wxSize wxGnomePrinterImplDC::GetPPI() const +wxSize wxGnomePrinterDCImpl::GetPPI() const { return wxSize(DPI,DPI); } -void wxGnomePrinterImplDC::SetPrintData(const wxPrintData& data) +void wxGnomePrinterDCImpl::SetPrintData(const wxPrintData& data) { m_printData = data; @@ -2012,12 +2012,12 @@ void wxGnomePrinterImplDC::SetPrintData(const wxPrintData& data) // overridden for wxPrinterDC Impl -int wxGnomePrinterImplDC::GetResolution() +int wxGnomePrinterDCImpl::GetResolution() { return DPI; } -wxRect wxGnomePrinterImplDC::GetPaperRect() +wxRect wxGnomePrinterDCImpl::GetPaperRect() { // GNOME print doesn't support printer margins int w = 0; @@ -2110,7 +2110,7 @@ void wxGnomePrintPreview::DetermineScaling() wxSize sizeDevUnits(paper->GetSizeDeviceUnits()); - // TODO: get better resolution information from wxGnomePrinterImplDC, if possible. + // TODO: get better resolution information from wxGnomePrinterDCImpl, if possible. sizeDevUnits.x = (wxCoord)((float)sizeDevUnits.x * resolution / 72.0); sizeDevUnits.y = (wxCoord)((float)sizeDevUnits.y * resolution / 72.0); diff --git a/src/gtk/minifram.cpp b/src/gtk/minifram.cpp index 7cdf1b9f62..9febe6584f 100644 --- a/src/gtk/minifram.cpp +++ b/src/gtk/minifram.cpp @@ -13,6 +13,7 @@ #if wxUSE_MINIFRAME #include "wx/minifram.h" +#include "wx/gtk/dcclient.h" #ifndef WX_PRECOMP #include "wx/settings.h" @@ -73,15 +74,9 @@ static gboolean gtk_window_own_expose_callback(GtkWidget* widget, GdkEventExpose wxClientDC dc(win); -#if wxUSE_NEW_DC - wxImplDC *impl = dc.GetImpl(); - wxGTKClientImplDC *client_impl = wxDynamicCast( impl, wxGTKClientImplDC ); - // Hack alert - client_impl->m_window = widget->window; -#else - // Hack alert - dc.m_window = widget->window; -#endif + wxDCImpl *impl = dc.GetImpl(); + wxClientDCImpl *gtk_impl = wxDynamicCast( impl, wxClientDCImpl ); + gtk_impl->m_gdkwindow = widget->window; // Hack alert if (style & wxRESIZE_BORDER) { diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index 53af6cc2e4..de6c14664f 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -145,9 +145,9 @@ wxGtkPrintFactory::CreatePrintSetupDialog(wxWindow * WXUNUSED(parent), #if wxUSE_NEW_DC -wxImplDC* wxGtkPrintFactory::CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ) +wxDCImpl* wxGtkPrintFactory::CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) { - return new wxGtkPrinterImplDC( owner, data ); + return new wxGtkPrinterDCImpl( owner, data ); } #else @@ -1105,14 +1105,14 @@ bool wxGtkPrinter::Setup( wxWindow * WXUNUSED(parent) ) #if wxUSE_NEW_DC -IMPLEMENT_ABSTRACT_CLASS(wxGtkPrinterImplDC, wxImplDC) +IMPLEMENT_ABSTRACT_CLASS(wxGtkPrinterDCImpl, wxDCImpl) #else IMPLEMENT_ABSTRACT_CLASS(wxGtkPrinterDC, wxDC) #endif #if wxUSE_NEW_DC -wxGtkPrinterImplDC::wxGtkPrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ) : - wxImplDC( owner ) +wxGtkPrinterDCImpl::wxGtkPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) : + wxDCImpl( owner ) #else wxGtkPrinterDC::wxGtkPrinterDC( const wxPrintData& data ) #endif @@ -1155,18 +1155,18 @@ wxGtkPrinterDC::wxGtkPrinterDC( const wxPrintData& data ) gs_cairo->cairo_translate(m_cairo, -ml, -mt); } -wxGtkPrinterImplDC::~wxGtkPrinterImplDC() +wxGtkPrinterDCImpl::~wxGtkPrinterDCImpl() { g_object_unref(m_context); g_object_unref(m_layout); } -bool wxGtkPrinterImplDC::IsOk() const +bool wxGtkPrinterDCImpl::IsOk() const { return m_gpc != NULL; } -bool wxGtkPrinterImplDC::DoFloodFill(wxCoord WXUNUSED(x1), +bool wxGtkPrinterDCImpl::DoFloodFill(wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1), const wxColour& WXUNUSED(col), int WXUNUSED(style)) @@ -1177,7 +1177,7 @@ bool wxGtkPrinterImplDC::DoFloodFill(wxCoord WXUNUSED(x1), return false; } -void wxGtkPrinterImplDC::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter) +void wxGtkPrinterDCImpl::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter) { wxCoord xC = circleCenter.x; wxCoord yC = circleCenter.y; @@ -1223,7 +1223,7 @@ void wxGtkPrinterImplDC::DoGradientFillConcentric(const wxRect& rect, const wxCo CalcBoundingBox(xR+w, yR+h); } -void wxGtkPrinterImplDC::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection) +void wxGtkPrinterDCImpl::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection) { wxCoord x = rect.x; wxCoord y = rect.y; @@ -1273,7 +1273,7 @@ void wxGtkPrinterImplDC::DoGradientFillLinear(const wxRect& rect, const wxColour CalcBoundingBox(x+w, y+h); } -bool wxGtkPrinterImplDC::DoGetPixel(wxCoord WXUNUSED(x1), +bool wxGtkPrinterDCImpl::DoGetPixel(wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1), wxColour * WXUNUSED(col)) const { @@ -1281,7 +1281,7 @@ bool wxGtkPrinterImplDC::DoGetPixel(wxCoord WXUNUSED(x1), return false; } -void wxGtkPrinterImplDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) +void wxGtkPrinterDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { if (m_pen.GetStyle() == wxTRANSPARENT) return; @@ -1294,7 +1294,7 @@ void wxGtkPrinterImplDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord CalcBoundingBox( x2, y2 ); } -void wxGtkPrinterImplDC::DoCrossHair(wxCoord x, wxCoord y) +void wxGtkPrinterDCImpl::DoCrossHair(wxCoord x, wxCoord y) { int w, h; DoGetSize(&w, &h); @@ -1311,7 +1311,7 @@ void wxGtkPrinterImplDC::DoCrossHair(wxCoord x, wxCoord y) CalcBoundingBox( w, h ); } -void wxGtkPrinterImplDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) +void wxGtkPrinterDCImpl::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) { double dx = x1 - xc; double dy = y1 - yc; @@ -1363,7 +1363,7 @@ void wxGtkPrinterImplDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,w CalcBoundingBox (x2, y2); } -void wxGtkPrinterImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) +void wxGtkPrinterDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { gs_cairo->cairo_save( m_cairo ); @@ -1389,7 +1389,7 @@ void wxGtkPrinterImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord CalcBoundingBox( x+w, y+h ); } -void wxGtkPrinterImplDC::DoDrawPoint(wxCoord x, wxCoord y) +void wxGtkPrinterDCImpl::DoDrawPoint(wxCoord x, wxCoord y) { if (m_pen.GetStyle() == wxTRANSPARENT) return; @@ -1402,7 +1402,7 @@ void wxGtkPrinterImplDC::DoDrawPoint(wxCoord x, wxCoord y) CalcBoundingBox( x, y ); } -void wxGtkPrinterImplDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxGtkPrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { if (m_pen.GetStyle() == wxTRANSPARENT) return; @@ -1422,7 +1422,7 @@ void wxGtkPrinterImplDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, w gs_cairo->cairo_stroke ( m_cairo); } -void wxGtkPrinterImplDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +void wxGtkPrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { if (n==0) return; @@ -1456,16 +1456,16 @@ void wxGtkPrinterImplDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, gs_cairo->cairo_restore(m_cairo); } -void wxGtkPrinterImplDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +void wxGtkPrinterDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { #if wxUSE_NEW_DC - wxImplDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); + wxDCImpl::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); #else wxDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); #endif } -void wxGtkPrinterImplDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxGtkPrinterDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { width--; height--; @@ -1483,7 +1483,7 @@ void wxGtkPrinterImplDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wx CalcBoundingBox( x + width, y + height ); } -void wxGtkPrinterImplDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) +void wxGtkPrinterDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) { width--; height--; @@ -1531,7 +1531,7 @@ void wxGtkPrinterImplDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord wi CalcBoundingBox(x+width,y+height); } -void wxGtkPrinterImplDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxGtkPrinterDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { width--; height--; @@ -1557,7 +1557,7 @@ void wxGtkPrinterImplDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCo } #if wxUSE_SPLINES -void wxGtkPrinterImplDC::DoDrawSpline(const wxPointList *points) +void wxGtkPrinterDCImpl::DoDrawSpline(const wxPointList *points) { SetPen (m_pen); @@ -1616,7 +1616,7 @@ void wxGtkPrinterImplDC::DoDrawSpline(const wxPointList *points) } #endif // wxUSE_SPLINES -bool wxGtkPrinterImplDC::DoBlit(wxCoord xdest, wxCoord ydest, +bool wxGtkPrinterDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask, @@ -1641,14 +1641,14 @@ bool wxGtkPrinterImplDC::DoBlit(wxCoord xdest, wxCoord ydest, return true; } -void wxGtkPrinterImplDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) +void wxGtkPrinterDCImpl::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) { DoDrawBitmap( icon, x, y, true ); } -void wxGtkPrinterImplDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) +void wxGtkPrinterDCImpl::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) { - wxCHECK_RET( bitmap.IsOk(), wxT("Invalid bitmap in wxGtkPrinterImplDC::DoDrawBitmap")); + wxCHECK_RET( bitmap.IsOk(), wxT("Invalid bitmap in wxGtkPrinterDCImpl::DoDrawBitmap")); cairo_surface_t* surface; x = wxCoord(XLOG2DEV(x)); @@ -1759,12 +1759,12 @@ void wxGtkPrinterImplDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoor gs_cairo->cairo_restore(m_cairo); } -void wxGtkPrinterImplDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y ) +void wxGtkPrinterDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y ) { DoDrawRotatedText( text, x, y, 0.0 ); } -void wxGtkPrinterImplDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) +void wxGtkPrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) { double xx = XLOG2DEV(x); double yy = YLOG2DEV(y); @@ -1876,7 +1876,7 @@ void wxGtkPrinterImplDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCo CalcBoundingBox (x + w, y + h); } -void wxGtkPrinterImplDC::Clear() +void wxGtkPrinterDCImpl::Clear() { // Clear does nothing for printing, but keep the code // for later reuse @@ -1889,7 +1889,7 @@ void wxGtkPrinterImplDC::Clear() */ } -void wxGtkPrinterImplDC::SetFont( const wxFont& font ) +void wxGtkPrinterDCImpl::SetFont( const wxFont& font ) { m_font = font; @@ -1910,7 +1910,7 @@ void wxGtkPrinterImplDC::SetFont( const wxFont& font ) } } -void wxGtkPrinterImplDC::SetPen( const wxPen& pen ) +void wxGtkPrinterDCImpl::SetPen( const wxPen& pen ) { if (!pen.Ok()) return; @@ -1989,7 +1989,7 @@ void wxGtkPrinterImplDC::SetPen( const wxPen& pen ) } } -void wxGtkPrinterImplDC::SetBrush( const wxBrush& brush ) +void wxGtkPrinterDCImpl::SetBrush( const wxBrush& brush ) { if (!brush.Ok()) return; @@ -2082,7 +2082,7 @@ void wxGtkPrinterImplDC::SetBrush( const wxBrush& brush ) } } -void wxGtkPrinterImplDC::SetLogicalFunction( int function ) +void wxGtkPrinterDCImpl::SetLogicalFunction( int function ) { if (function == wxCLEAR) gs_cairo->cairo_set_operator (m_cairo, CAIRO_OPERATOR_CLEAR); @@ -2100,7 +2100,7 @@ void wxGtkPrinterImplDC::SetLogicalFunction( int function ) gs_cairo->cairo_set_operator (m_cairo, CAIRO_OPERATOR_SOURCE); } -void wxGtkPrinterImplDC::SetBackground( const wxBrush& brush ) +void wxGtkPrinterDCImpl::SetBackground( const wxBrush& brush ) { m_backgroundBrush = brush; gs_cairo->cairo_save(m_cairo); @@ -2111,7 +2111,7 @@ void wxGtkPrinterImplDC::SetBackground( const wxBrush& brush ) gs_cairo->cairo_restore(m_cairo); } -void wxGtkPrinterImplDC::SetBackgroundMode(int mode) +void wxGtkPrinterDCImpl::SetBackgroundMode(int mode) { if (mode == wxSOLID) m_backgroundMode = wxSOLID; @@ -2119,38 +2119,38 @@ void wxGtkPrinterImplDC::SetBackgroundMode(int mode) m_backgroundMode = wxTRANSPARENT; } -void wxGtkPrinterImplDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxGtkPrinterDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { gs_cairo->cairo_rectangle ( m_cairo, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEVREL(width), YLOG2DEVREL(height)); gs_cairo->cairo_clip(m_cairo); } -void wxGtkPrinterImplDC::DestroyClippingRegion() +void wxGtkPrinterDCImpl::DestroyClippingRegion() { gs_cairo->cairo_reset_clip(m_cairo); } -bool wxGtkPrinterImplDC::StartDoc(const wxString& WXUNUSED(message)) +bool wxGtkPrinterDCImpl::StartDoc(const wxString& WXUNUSED(message)) { return true; } -void wxGtkPrinterImplDC::EndDoc() +void wxGtkPrinterDCImpl::EndDoc() { return; } -void wxGtkPrinterImplDC::StartPage() +void wxGtkPrinterDCImpl::StartPage() { return; } -void wxGtkPrinterImplDC::EndPage() +void wxGtkPrinterDCImpl::EndPage() { return; } -wxCoord wxGtkPrinterImplDC::GetCharHeight() const +wxCoord wxGtkPrinterDCImpl::GetCharHeight() const { pango_layout_set_text( m_layout, "H", 1 ); @@ -2160,7 +2160,7 @@ wxCoord wxGtkPrinterImplDC::GetCharHeight() const return wxRound( h * m_PS2DEV ); } -wxCoord wxGtkPrinterImplDC::GetCharWidth() const +wxCoord wxGtkPrinterDCImpl::GetCharWidth() const { pango_layout_set_text( m_layout, "H", 1 ); @@ -2170,7 +2170,7 @@ wxCoord wxGtkPrinterImplDC::GetCharWidth() const return wxRound( w * m_PS2DEV ); } -void wxGtkPrinterImplDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height, +void wxGtkPrinterDCImpl::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading, const wxFont *theFont ) const @@ -2228,7 +2228,7 @@ void wxGtkPrinterImplDC::DoGetTextExtent(const wxString& string, wxCoord *width, pango_layout_set_font_description( m_layout, m_fontdesc ); } -void wxGtkPrinterImplDC::DoGetSize(int* width, int* height) const +void wxGtkPrinterDCImpl::DoGetSize(int* width, int* height) const { GtkPageSetup *setup = gtk_print_context_get_page_setup( m_gpc ); @@ -2238,7 +2238,7 @@ void wxGtkPrinterImplDC::DoGetSize(int* width, int* height) const *height = wxRound( gtk_page_setup_get_paper_height( setup, GTK_UNIT_POINTS ) * m_PS2DEV ); } -void wxGtkPrinterImplDC::DoGetSizeMM(int *width, int *height) const +void wxGtkPrinterDCImpl::DoGetSizeMM(int *width, int *height) const { GtkPageSetup *setup = gtk_print_context_get_page_setup( m_gpc ); @@ -2248,19 +2248,19 @@ void wxGtkPrinterImplDC::DoGetSizeMM(int *width, int *height) const *height = wxRound( gtk_page_setup_get_paper_height( setup, GTK_UNIT_MM ) ); } -wxSize wxGtkPrinterImplDC::GetPPI() const +wxSize wxGtkPrinterDCImpl::GetPPI() const { return wxSize( (int)m_resolution, (int)m_resolution ); } -void wxGtkPrinterImplDC::SetPrintData(const wxPrintData& data) +void wxGtkPrinterDCImpl::SetPrintData(const wxPrintData& data) { m_printData = data; } // overriden for wxPrinterDC Impl -wxRect wxGtkPrinterImplDC::GetPaperRect() +wxRect wxGtkPrinterDCImpl::GetPaperRect() { // Does GtkPrint support printer margins? int w = 0; @@ -2269,7 +2269,7 @@ wxRect wxGtkPrinterImplDC::GetPaperRect() return wxRect( 0,0,w,h ); } -int wxGtkPrinterImplDC::GetResolution() +int wxGtkPrinterDCImpl::GetResolution() { return m_resolution; } diff --git a/src/gtk/renderer.cpp b/src/gtk/renderer.cpp index 3f32713a49..de54e0aea2 100644 --- a/src/gtk/renderer.cpp +++ b/src/gtk/renderer.cpp @@ -33,6 +33,8 @@ #include "wx/module.h" #endif +#include "wx/gtk/dc.h" + #include // ---------------------------------------------------------------------------- @@ -282,8 +284,8 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win, GdkWindow* gdk_window = NULL; #if wxUSE_NEW_DC - wxImplDC *impl = dc.GetImpl(); - wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC ); + wxDCImpl *impl = dc.GetImpl(); + wxGTKDCImpl *gtk_impl = wxDynamicCast( impl, wxGTKDCImpl ); if (gtk_impl) gdk_window = gtk_impl->GetGDKWindow(); #else @@ -329,8 +331,8 @@ wxRendererGTK::DrawTreeItemButton(wxWindow* win, GdkWindow* gdk_window = NULL; #if wxUSE_NEW_DC - wxImplDC *impl = dc.GetImpl(); - wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC ); + wxDCImpl *impl = dc.GetImpl(); + wxGTKDCImpl *gtk_impl = wxDynamicCast( impl, wxGTKDCImpl ); if (gtk_impl) gdk_window = gtk_impl->GetGDKWindow(); #else @@ -416,8 +418,8 @@ wxRendererGTK::DrawSplitterSash(wxWindow *win, GdkWindow* gdk_window = NULL; #if wxUSE_NEW_DC - wxImplDC *impl = dc.GetImpl(); - wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC ); + wxDCImpl *impl = dc.GetImpl(); + wxGTKDCImpl *gtk_impl = wxDynamicCast( impl, wxGTKDCImpl ); if (gtk_impl) gdk_window = gtk_impl->GetGDKWindow(); #else @@ -484,8 +486,8 @@ wxRendererGTK::DrawDropArrow(wxWindow *WXUNUSED(win), // are derived from it) and use its m_window. GdkWindow* gdk_window = NULL; #if wxUSE_NEW_DC - wxImplDC *impl = dc.GetImpl(); - wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC ); + wxDCImpl *impl = dc.GetImpl(); + wxGTKDCImpl *gtk_impl = wxDynamicCast( impl, wxGTKDCImpl ); if (gtk_impl) gdk_window = gtk_impl->GetGDKWindow(); #else @@ -554,8 +556,8 @@ wxRendererGTK::DrawCheckBox(wxWindow *WXUNUSED(win), GdkWindow* gdk_window = NULL; #if wxUSE_NEW_DC - wxImplDC *impl = dc.GetImpl(); - wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC ); + wxDCImpl *impl = dc.GetImpl(); + wxGTKDCImpl *gtk_impl = wxDynamicCast( impl, wxGTKDCImpl ); if (gtk_impl) gdk_window = gtk_impl->GetGDKWindow(); #else @@ -600,8 +602,8 @@ wxRendererGTK::DrawPushButton(wxWindow *WXUNUSED(win), GdkWindow* gdk_window = NULL; #if wxUSE_NEW_DC - wxImplDC *impl = dc.GetImpl(); - wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC ); + wxDCImpl *impl = dc.GetImpl(); + wxGTKDCImpl *gtk_impl = wxDynamicCast( impl, wxGTKDCImpl ); if (gtk_impl) gdk_window = gtk_impl->GetGDKWindow(); #else @@ -643,8 +645,8 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow *win, { GdkWindow* gdk_window = NULL; #if wxUSE_NEW_DC - wxImplDC *impl = dc.GetImpl(); - wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC ); + wxDCImpl *impl = dc.GetImpl(); + wxGTKDCImpl *gtk_impl = wxDynamicCast( impl, wxGTKDCImpl ); if (gtk_impl) gdk_window = gtk_impl->GetGDKWindow(); #else @@ -700,8 +702,8 @@ void wxRendererGTK::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, i { GdkWindow* gdk_window = NULL; #if wxUSE_NEW_DC - wxImplDC *impl = dc.GetImpl(); - wxGTKImplDC *gtk_impl = wxDynamicCast( impl, wxGTKImplDC ); + wxDCImpl *impl = dc.GetImpl(); + wxGTKDCImpl *gtk_impl = wxDynamicCast( impl, wxGTKDCImpl ); if (gtk_impl) gdk_window = gtk_impl->GetGDKWindow(); #else diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index 68b72f8fbc..a4aa985348 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -629,6 +629,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) return true; case wxTOOL_STYLE_CONTROL: +#if 1 GtkWidget* align = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(align); gtk_container_add((GtkContainer*)align, tool->GetControl()->m_widget); @@ -639,6 +640,15 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) (const char *) NULL, posGtk ); +#else + gtk_toolbar_insert_widget( + m_toolbar, + tool->GetControl()->m_widget, + (const char *) NULL, + (const char *) NULL, + posGtk + ); +#endif // release reference obtained by wxInsertChildInToolBar g_object_unref(tool->GetControl()->m_widget); break; diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index e511ce39c3..8fc7205172 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -701,6 +701,7 @@ bool wxTextCtrl::Create( wxWindow *parent, if (style & wxNO_BORDER) g_object_set (m_text, "has-frame", FALSE, NULL); + } m_parent->DoAddChild( this ); diff --git a/src/mac/carbon/dcclient.cpp b/src/mac/carbon/dcclient.cpp index bc776fb9dd..39d21a8af1 100644 --- a/src/mac/carbon/dcclient.cpp +++ b/src/mac/carbon/dcclient.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/mac/carbon/dcclient.cpp -// Purpose: wxClientDC class +// Purpose: wxClientDCImpl class // Author: Stefan Csomor // Modified by: // Created: 01/02/97 @@ -28,36 +28,22 @@ #include "wx/mac/private.h" //----------------------------------------------------------------------------- -// constants +// wxWindowDCImpl //----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// wxPaintDC -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) -IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) -IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) - -/* - * wxWindowDC - */ +IMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl, wxGCDCImpl) -#include "wx/mac/uma.h" -#include "wx/notebook.h" -#include "wx/tabctrl.h" - - - -wxWindowDC::wxWindowDC() +wxWindowDCImpl::wxWindowDCImpl( wxDC *owner ) + : wxGCDCImpl( owner ) { - m_window = NULL ; m_release = false; } -wxWindowDC::wxWindowDC(wxWindow *window) +wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) + : wxGCDCImpl( owner ) { - m_window = window ; + m_window = window; + wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; if (!rootwindow) return; @@ -82,14 +68,14 @@ wxWindowDC::wxWindowDC(wxWindow *window) SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) ); } - SetClippingRegion( 0 , 0 , m_width , m_height ) ; + DoSetClippingRegion( 0 , 0 , m_width , m_height ) ; SetBackground(wxBrush(window->GetBackgroundColour(),wxSOLID)); SetFont( window->GetFont() ) ; } -wxWindowDC::~wxWindowDC() +wxWindowDCImpl::~wxWindowDCImpl() { if ( m_release ) { @@ -100,7 +86,7 @@ wxWindowDC::~wxWindowDC() } } -void wxWindowDC::DoGetSize( int* width, int* height ) const +void wxWindowDCImpl::DoGetSize( int* width, int* height ) const { if ( width ) *width = m_width; @@ -108,7 +94,7 @@ void wxWindowDC::DoGetSize( int* width, int* height ) const *height = m_height; } -wxBitmap wxWindowDC::DoGetAsBitmap(const wxRect *subrect) const +wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const { // wxScreenDC is derived from wxWindowDC, so a screen dc will // call this method when a Blit is performed with it as a source. @@ -168,46 +154,50 @@ wxBitmap wxWindowDC::DoGetAsBitmap(const wxRect *subrect) const } /* - * wxClientDC + * wxClientDCImpl */ -wxClientDC::wxClientDC() +IMPLEMENT_ABSTRACT_CLASS(wxClientDCImpl, wxWindowDCImpl) + +wxClientDCImpl::wxClientDCImpl( wxDC *owner ) + : wxWindowDCImpl( owner ) { - m_window = NULL ; } -wxClientDC::wxClientDC(wxWindow *window) : - wxWindowDC( window ) +wxClientDCImpl::wxClientDCImpl( wxDC *owner, wxWindow *window ) : + wxWindowDCImpl( owner, window ) { - wxCHECK_RET( window, _T("invalid window in wxClientDC") ); + wxCHECK_RET( window, _T("invalid window in wxClientDCImpl") ); wxPoint origin = window->GetClientAreaOrigin() ; m_window->GetClientSize( &m_width , &m_height); SetDeviceOrigin( origin.x, origin.y ); - SetClippingRegion( 0 , 0 , m_width , m_height ) ; + DoSetClippingRegion( 0 , 0 , m_width , m_height ) ; } -wxClientDC::~wxClientDC() +wxClientDCImpl::~wxClientDCImpl() { } /* - * wxPaintDC + * wxPaintDCImpl */ -wxPaintDC::wxPaintDC() +IMPLEMENT_ABSTRACT_CLASS(wxPaintDCImpl, wxWindowDCImpl) + +wxPaintDCImpl::wxPaintDCImpl( wxDC *owner ) + : wxWindowDCImpl( owner ) { - m_window = NULL ; } -wxPaintDC::wxPaintDC(wxWindow *window) : - wxWindowDC( window ) +wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) : + wxWindowDCImpl( owner, window ) { wxPoint origin = window->GetClientAreaOrigin() ; m_window->GetClientSize( &m_width , &m_height); SetDeviceOrigin( origin.x, origin.y ); - SetClippingRegion( 0 , 0 , m_width , m_height ) ; + DoSetClippingRegion( 0 , 0 , m_width , m_height ) ; } -wxPaintDC::~wxPaintDC() +wxPaintDCImpl::~wxPaintDCImpl() { } diff --git a/src/mac/carbon/dcmemory.cpp b/src/mac/carbon/dcmemory.cpp index 0ab0aea085..2302c3d776 100644 --- a/src/mac/carbon/dcmemory.cpp +++ b/src/mac/carbon/dcmemory.cpp @@ -17,12 +17,32 @@ #include "wx/mac/private.h" //----------------------------------------------------------------------------- -// wxMemoryDC +// wxMemoryDCImpl //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) +IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl,wxPaintDCImpl) -void wxMemoryDC::Init() + +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner ) + : wxPaintDCImpl( owner ) +{ + Init(); +} + +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap ) + : wxPaintDCImpl( owner ) +{ + Init(); + DoSelect(bitmap); +} + +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ) + : wxPaintDCImpl( owner ) +{ + Init(); +} + +void wxMemoryDCImpl::Init() { m_ok = true; SetBackground(*wxWHITE_BRUSH); @@ -32,13 +52,7 @@ void wxMemoryDC::Init() m_ok = false; } -wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) -: m_selected() -{ - Init(); -} - -wxMemoryDC::~wxMemoryDC() +wxMemoryDCImpl::~wxMemoryDCImpl() { if ( m_selected.Ok() ) { @@ -48,7 +62,7 @@ wxMemoryDC::~wxMemoryDC() } } -void wxMemoryDC::DoSelect( const wxBitmap& bitmap ) +void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) { if ( m_selected.Ok() ) { @@ -82,7 +96,7 @@ void wxMemoryDC::DoSelect( const wxBitmap& bitmap ) } } -void wxMemoryDC::DoGetSize( int *width, int *height ) const +void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const { if (m_selected.Ok()) { diff --git a/src/mac/carbon/dcprint.cpp b/src/mac/carbon/dcprint.cpp index 8f09600531..00d49e53eb 100644 --- a/src/mac/carbon/dcprint.cpp +++ b/src/mac/carbon/dcprint.cpp @@ -27,9 +27,10 @@ #include "wx/mac/uma.h" #include "wx/mac/private/print.h" +#include "wx/mac/carbon/dcprint.h" #include "wx/graphics.h" -IMPLEMENT_CLASS(wxPrinterDC, wxDC) +IMPLEMENT_ABSTRACT_CLASS(wxPrinterDCImpl, wxGCDCImpl) class wxNativePrinterDC { @@ -107,7 +108,8 @@ bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED if ( m_err ) return false ; - wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().GetNativeData() ; + wxPrinterDCImpl *impl = (wxPrinterDCImpl*) dc->GetImpl(); + wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) impl->GetPrintData().GetNativeData() ; m_err = PMSessionBeginCGDocumentNoDialog(native->m_macPrintSession, native->m_macPrintSettings, @@ -149,7 +151,8 @@ void wxMacCarbonPrinterDC::EndDoc( wxPrinterDC* dc ) if ( m_err ) return ; - wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().GetNativeData() ; + wxPrinterDCImpl *impl = (wxPrinterDCImpl*) dc->GetImpl(); + wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) impl->GetPrintData().GetNativeData() ; m_err = PMSessionEndDocumentNoDialog(native->m_macPrintSession); } @@ -159,7 +162,8 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc ) if ( m_err ) return ; - wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().GetNativeData() ; + wxPrinterDCImpl *impl = (wxPrinterDCImpl*) dc->GetImpl(); + wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) impl->GetPrintData().GetNativeData() ; m_err = PMSessionBeginPageNoDialog(native->m_macPrintSession, native->m_macPageFormat, @@ -195,7 +199,7 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc ) // since this is a non-critical error, we set the flag back m_err = noErr ; } - dc->SetGraphicsContext( wxGraphicsContext::CreateFromNative( pageContext ) ); + impl->SetGraphicsContext( wxGraphicsContext::CreateFromNative( pageContext ) ); } void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc ) @@ -203,7 +207,8 @@ void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc ) if ( m_err ) return ; - wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().GetNativeData() ; + wxPrinterDCImpl *impl = (wxPrinterDCImpl*) dc->GetImpl(); + wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) impl->GetPrintData().GetNativeData() ; m_err = PMSessionEndPageNoDialog(native->m_macPrintSession); if ( m_err != noErr ) @@ -211,7 +216,7 @@ void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc ) PMSessionEndDocumentNoDialog(native->m_macPrintSession); } // the cg context we got when starting the page isn't valid anymore, so replace it - dc->SetGraphicsContext( wxGraphicsContext::Create() ); + impl->SetGraphicsContext( wxGraphicsContext::Create() ); } void wxMacCarbonPrinterDC::GetSize( int *w , int *h) const @@ -231,7 +236,8 @@ wxSize wxMacCarbonPrinterDC::GetPPI() const // // -wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) +wxPrinterDCImpl::wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& printdata ) + : wxGCDCImpl( owner ) { m_ok = false ; m_printData = printdata ; @@ -259,24 +265,24 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) } } -wxSize wxPrinterDC::GetPPI() const +wxSize wxPrinterDCImpl::GetPPI() const { return m_nativePrinterDC->GetPPI() ; } -wxPrinterDC::~wxPrinterDC(void) +wxPrinterDCImpl::~wxPrinterDCImpl() { delete m_nativePrinterDC ; } -bool wxPrinterDC::StartDoc( const wxString& message ) +bool wxPrinterDCImpl::StartDoc( const wxString& message ) { wxASSERT_MSG( Ok() , wxT("Called wxPrinterDC::StartDoc from an invalid object") ) ; if ( !m_ok ) return false ; - if ( m_nativePrinterDC->StartDoc(this, message ) ) + if ( m_nativePrinterDC->StartDoc( (wxPrinterDC*) GetOwner(), message ) ) { // in case we have to do additional things when successful } @@ -292,12 +298,12 @@ bool wxPrinterDC::StartDoc( const wxString& message ) return m_ok ; } -void wxPrinterDC::EndDoc(void) +void wxPrinterDCImpl::EndDoc(void) { if ( !m_ok ) return ; - m_nativePrinterDC->EndDoc( this ) ; + m_nativePrinterDC->EndDoc( (wxPrinterDC*) GetOwner() ) ; m_ok = m_nativePrinterDC->Ok() ; if ( !m_ok ) @@ -309,10 +315,10 @@ void wxPrinterDC::EndDoc(void) } } -wxRect wxPrinterDC::GetPaperRect() +wxRect wxPrinterDCImpl::GetPaperRect() { wxCoord w, h; - GetSize(&w, &h); + GetOwner()->GetSize(&w, &h); wxRect pageRect(0, 0, w, h); wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) m_printData.GetNativeData() ; OSStatus err = noErr ; @@ -324,7 +330,7 @@ wxRect wxPrinterDC::GetPaperRect() wxCoord(rPaper.right - rPaper.left), wxCoord(rPaper.bottom - rPaper.top)); } -void wxPrinterDC::StartPage(void) +void wxPrinterDCImpl::StartPage() { if ( !m_ok ) return ; @@ -340,21 +346,21 @@ void wxPrinterDC::StartPage(void) m_brush = *wxTRANSPARENT_BRUSH; m_backgroundBrush = *wxWHITE_BRUSH; - m_nativePrinterDC->StartPage(this) ; + m_nativePrinterDC->StartPage( (wxPrinterDC*) GetOwner() ) ; m_ok = m_nativePrinterDC->Ok() ; } -void wxPrinterDC::EndPage(void) +void wxPrinterDCImpl::EndPage() { if ( !m_ok ) return ; - m_nativePrinterDC->EndPage(this) ; + m_nativePrinterDC->EndPage( (wxPrinterDC*) GetOwner() ); m_ok = m_nativePrinterDC->Ok() ; } -void wxPrinterDC::DoGetSize(int *width, int *height) const +void wxPrinterDCImpl::DoGetSize(int *width, int *height) const { wxCHECK_RET( m_ok , _T("GetSize() doesn't work without a valid wxPrinterDC") ); m_nativePrinterDC->GetSize(width, height ) ; diff --git a/src/mac/carbon/dcscreen.cpp b/src/mac/carbon/dcscreen.cpp index ba827defdd..ad8ac0be4a 100644 --- a/src/mac/carbon/dcscreen.cpp +++ b/src/mac/carbon/dcscreen.cpp @@ -12,18 +12,20 @@ #include "wx/wxprec.h" #include "wx/dcscreen.h" +#include "wx/mac/carbon/dcscreen.h" #include "wx/mac/uma.h" #include "wx/graphics.h" -IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) +IMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl, wxWindowDCImpl) // TODO : for the Screenshot use case, which doesn't work in Quartz // we should do a GetAsBitmap using something like // http://www.cocoabuilder.com/archive/message/cocoa/2005/8/13/144256 // Create a DC representing the whole screen -wxScreenDC::wxScreenDC() +wxScreenDCImpl::wxScreenDCImpl( wxDC *owner ) : + wxWindowDCImpl( owner ) { #ifdef __LP64__ m_graphicContext = NULL; @@ -46,7 +48,7 @@ wxScreenDC::wxScreenDC() #endif } -wxScreenDC::~wxScreenDC() +wxScreenDCImpl::~wxScreenDCImpl() { delete m_graphicContext; m_graphicContext = NULL; diff --git a/src/mac/carbon/graphics.cpp b/src/mac/carbon/graphics.cpp index c255dda34f..4b550355b3 100644 --- a/src/mac/carbon/graphics.cpp +++ b/src/mac/carbon/graphics.cpp @@ -2166,6 +2166,7 @@ public : // Context virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc); + virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc); virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ); @@ -2218,18 +2219,26 @@ wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer() return &gs_MacCoreGraphicsRenderer; } -wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC& dc) +wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC& dc ) { - wxMemoryDC* mdc = wxDynamicCast(&dc, wxMemoryDC); - if ( mdc ) - { - return new wxMacCoreGraphicsContext(this, - (CGContextRef)mdc->GetGraphicsContext()->GetNativeContext()); - } - else - { - return new wxMacCoreGraphicsContext(this,(CGContextRef)dc.GetWindow()->MacGetCGContextRef() ); - } + const wxDCImpl* impl = dc.GetImpl(); + wxWindowDCImpl *win_impl = wxDynamicCast( impl, wxWindowDCImpl ); + if (win_impl) + return new wxMacCoreGraphicsContext( this, + (CGContextRef)(win_impl->GetWindow()->MacGetCGContextRef()) ); + + return NULL; +} + +wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxMemoryDC& dc ) +{ + const wxDCImpl* impl = dc.GetImpl(); + wxMemoryDCImpl *mem_impl = wxDynamicCast( impl, wxMemoryDCImpl ); + if (mem_impl) + return new wxMacCoreGraphicsContext( this, + (CGContextRef)(mem_impl->GetGraphicsContext()->GetNativeContext()) ); + + return NULL; } wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContextFromNativeContext( void * context ) diff --git a/src/mac/carbon/metafile.cpp b/src/mac/carbon/metafile.cpp index dee2ea8291..a82cf5bfd0 100644 --- a/src/mac/carbon/metafile.cpp +++ b/src/mac/carbon/metafile.cpp @@ -26,12 +26,14 @@ #include "wx/clipbrd.h" #include "wx/mac/uma.h" #include "wx/graphics.h" +#include "wx/mac/carbon/metafile.h" #include #include IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC) +IMPLEMENT_ABSTRACT_CLASS(wxMetafileDCImpl, wxGCDCImpl) #define M_METAFILEREFDATA( a ) ((wxMetafileRefData*)(a).GetRefData()) @@ -226,15 +228,20 @@ bool wxMetaFile::Play(wxDC *dc) if (!m_refData) return false; - if (!dc->Ok()) + if (!dc->IsOk()) return false; { - CGContextRef cg = (CGContextRef) dc->GetGraphicsContext()->GetNativeContext(); - CGPDFDocumentRef doc = M_METAFILEDATA->GetPDFDocument(); - CGPDFPageRef page = CGPDFDocumentGetPage( doc, 1 ); - wxMacCGContextStateSaver save(cg); - CGContextDrawPDFPage( cg, page ); + wxDCImpl *impl = dc->GetImpl(); + wxGCDCImpl *gc_impl = wxDynamicCast(impl, wxGCDCImpl); + if (gc_impl) + { + CGContextRef cg = (CGContextRef) (gc_impl->GetGraphicsContext()->GetNativeContext()); + CGPDFDocumentRef doc = M_METAFILEDATA->GetPDFDocument(); + CGPDFPageRef page = CGPDFDocumentGetPage( doc, 1 ); + wxMacCGContextStateSaver save(cg); + CGContextDrawPDFPage( cg, page ); + } // CGContextTranslateCTM( cg, 0, bounds.size.width ); // CGContextScaleCTM( cg, 1, -1 ); } @@ -260,10 +267,12 @@ wxSize wxMetaFile::GetSize() const // New constructor that takes origin and extent. If you use this, don't // give origin/extent arguments to wxMakeMetaFilePlaceable. -wxMetaFileDC::wxMetaFileDC( +wxMetafileDCImpl::wxMetafileDCImpl( + wxDC *owner, const wxString& filename, int width, int height, - const wxString& WXUNUSED(description) ) + const wxString& WXUNUSED(description) ) : + wxGCDCImpl( owner ) { wxASSERT_MSG( width != 0 || height != 0, wxT("no arbitration of metafile size supported") ); wxASSERT_MSG( filename.empty(), wxT("no file based metafile support yet")); @@ -279,11 +288,11 @@ wxMetaFileDC::wxMetaFileDC( SetMapMode( wxMM_TEXT ); } -wxMetaFileDC::~wxMetaFileDC() +wxMetafileDCImpl::~wxMetafileDCImpl() { } -void wxMetaFileDC::DoGetSize(int *width, int *height) const +void wxMetafileDCImpl::DoGetSize(int *width, int *height) const { wxCHECK_RET( m_metaFile, wxT("GetSize() doesn't work without a metafile") ); @@ -294,7 +303,7 @@ void wxMetaFileDC::DoGetSize(int *width, int *height) const (*height) = sz.y; } -wxMetaFile *wxMetaFileDC::Close() +wxMetaFile *wxMetafileDCImpl::Close() { delete m_graphicContext; m_graphicContext = NULL; diff --git a/src/mac/carbon/overlay.cpp b/src/mac/carbon/overlay.cpp index 933aa8bf01..c33c96e8e7 100644 --- a/src/mac/carbon/overlay.cpp +++ b/src/mac/carbon/overlay.cpp @@ -134,14 +134,23 @@ void wxOverlayImpl::Init( wxWindowDC* dc, int x , int y , int width , int height void wxOverlayImpl::BeginDrawing( wxWindowDC* dc) { - dc->SetGraphicsContext( wxGraphicsContext::CreateFromNative( m_overlayContext ) ); - wxSize size = dc->GetSize() ; - dc->SetClippingRegion( 0 , 0 , size.x , size.y ) ; + wxDCImpl *impl = dc->GetImpl(); + wxWindowDCImpl *win_impl = wxDynamicCast(impl,wxWindowDCImpl); + if (win_impl) + { + win_impl->SetGraphicsContext( wxGraphicsContext::CreateFromNative( m_overlayContext ) ); + wxSize size = dc->GetSize() ; + dc->SetClippingRegion( 0 , 0 , size.x , size.y ) ; + } } void wxOverlayImpl::EndDrawing( wxWindowDC* dc) { - dc->SetGraphicsContext(NULL); + wxDCImpl *impl = dc->GetImpl(); + wxWindowDCImpl *win_impl = wxDynamicCast(impl,wxWindowDCImpl); + if (win_impl) + win_impl->SetGraphicsContext(NULL); + CGContextFlush( m_overlayContext ); } diff --git a/src/mac/carbon/printmac.cpp b/src/mac/carbon/printmac.cpp index 7d35f7a8e5..a219a09bd2 100644 --- a/src/mac/carbon/printmac.cpp +++ b/src/mac/carbon/printmac.cpp @@ -403,7 +403,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) } // May have pressed cancel. - if (!dc || !dc->Ok()) + if (!dc || !dc->IsOk()) { if (dc) delete dc; @@ -606,7 +606,7 @@ void wxMacPrintPreview::DetermineScaling(void) // Get a device context for the currently selected printer wxPrinterDC printerDC(m_printDialogData.GetPrintData()); - if (printerDC.Ok()) + if (printerDC.IsOk()) { printerDC.GetSizeMM(&ww, &hh); printerDC.GetSize( &w , &h ) ; diff --git a/src/mac/carbon/renderer.cpp b/src/mac/carbon/renderer.cpp index fb16dd723a..fb5e8d29aa 100644 --- a/src/mac/carbon/renderer.cpp +++ b/src/mac/carbon/renderer.cpp @@ -126,8 +126,9 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win, else { CGContextRef cgContext; - - cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext(); + wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl(); + + cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext(); { HIThemeButtonDrawInfo drawInfo; @@ -209,7 +210,8 @@ void wxRendererMac::DrawTreeItemButton( wxWindow *win, { CGContextRef cgContext; - cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext(); + wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl(); + cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext(); HIThemeButtonDrawInfo drawInfo; HIRect labelRect; @@ -255,8 +257,8 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win, else { CGContextRef cgContext; - - cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext(); + wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl(); + cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext(); HIThemeSplitterDrawInfo drawInfo; drawInfo.version = 0; @@ -309,8 +311,9 @@ wxRendererMac::DrawMacThemeButton(wxWindow *win, } else { + wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl(); CGContextRef cgContext; - cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext(); + cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext(); HIThemeButtonDrawInfo drawInfo; HIRect labelRect; diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 537b447d18..156fbfc146 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -559,7 +559,7 @@ void wxApp::OnIdle(wxIdleEvent& WXUNUSED(event)) // if it's likely that the app has finished with them, that is, we // get an idle event and we're not dragging anything. if (!::GetKeyState(MK_LBUTTON) && !::GetKeyState(MK_MBUTTON) && !::GetKeyState(MK_RBUTTON)) - wxDC::ClearCache(); + wxMSWDCImpl::ClearCache(); #endif // wxUSE_DC_CACHEING } diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index f3221c6e73..d06251a599 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -535,9 +535,14 @@ bool wxBitmap::Create(int width, int height, int depth) bool wxBitmap::Create(int width, int height, const wxDC& dc) { - wxCHECK_MSG( dc.Ok(), false, _T("invalid HDC in wxBitmap::Create()") ); + wxCHECK_MSG( dc.IsOk(), false, _T("invalid HDC in wxBitmap::Create()") ); - return DoCreate(width, height, -1, dc.GetHDC()); + const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl ); + + if (impl) + return DoCreate(width, height, -1, impl->GetHDC()); + else + return false; } bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc) @@ -805,10 +810,15 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth) bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc) { - wxCHECK_MSG( dc.Ok(), false, + wxCHECK_MSG( dc.IsOk(), false, _T("invalid HDC in wxBitmap::CreateFromImage()") ); - return CreateFromImage(image, -1, dc.GetHDC()); + const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl ); + + if (impl) + return CreateFromImage(image, -1, impl->GetHDC()); + else + return false; } #if wxUSE_WXDIB diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index 98a4e6763b..1ac17a4420 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -174,8 +174,9 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, if ( !wxOwnerDrawn::OnDrawItem(dc, rc, act, stat) ) return false; + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); // now draw the check mark part - HDC hdc = GetHdcOf(dc); + HDC hdc = GetHdcOf(*impl); int nBmpWidth = ::GetSystemMetrics(SM_CXMENUCHECK), nBmpHeight = ::GetSystemMetrics(SM_CYMENUCHECK); diff --git a/src/msw/combo.cpp b/src/msw/combo.cpp index 04e430c428..72b053da45 100644 --- a/src/msw/combo.cpp +++ b/src/msw/combo.cpp @@ -41,6 +41,7 @@ #if wxUSE_UXTHEME #include "wx/msw/uxtheme.h" #endif +#include "wx/msw/dc.h" // Change to #if 1 to include tmschema.h for easier testing of theme // parameters. @@ -479,7 +480,8 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) #if wxUSE_UXTHEME const bool isEnabled = IsEnabled(); - HDC hDc = GetHdcOf(dc); + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + HDC hDc = GetHdcOf(*impl); HWND hWnd = GetHwndOf(this); wxUxThemeEngine* theme = NULL; diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 0801815ebf..de8d163efa 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -76,7 +76,7 @@ #define WXMICROWIN_CHECK_HDC_RET(x) #endif -IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase) +IMPLEMENT_ABSTRACT_CLASS(wxMSWDCImpl, wxDCImpl) // --------------------------------------------------------------------------- // constants @@ -161,11 +161,11 @@ wxAlphaBlend(HDC hdcDst, int xDst, int yDst, class wxColourChanger { public: - wxColourChanger(wxDC& dc); + wxColourChanger(wxMSWDCImpl& dc); ~wxColourChanger(); private: - wxDC& m_dc; + wxMSWDCImpl& m_dc; COLORREF m_colFgOld, m_colBgOld; @@ -279,7 +279,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxGDIDLLsCleanupModule, wxModule) // wxColourChanger // ---------------------------------------------------------------------------- -wxColourChanger::wxColourChanger(wxDC& dc) : m_dc(dc) +wxColourChanger::wxColourChanger(wxMSWDCImpl& dc) : m_dc(dc) { const wxBrush& brush = dc.GetBrush(); if ( brush.Ok() && brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE ) @@ -330,10 +330,17 @@ wxColourChanger::~wxColourChanger() } // --------------------------------------------------------------------------- -// wxDC +// wxMSWDCImpl // --------------------------------------------------------------------------- -wxDC::~wxDC() +wxMSWDCImpl::wxMSWDCImpl( wxDC *owner, WXHDC hDC ) : + wxDCImpl( owner ) +{ + Init(); + m_hDC = hDC; +} + +wxMSWDCImpl::~wxMSWDCImpl() { if ( m_hDC != 0 ) { @@ -347,9 +354,9 @@ wxDC::~wxDC() } else // we don't own our HDC { - if (m_canvas) + if (m_window) { - ::ReleaseDC(GetHwndOf(m_canvas), GetHdc()); + ::ReleaseDC(GetHwndOf(m_window), GetHdc()); } else { @@ -363,7 +370,7 @@ wxDC::~wxDC() // This will select current objects out of the DC, // which is what you have to do before deleting the // DC. -void wxDC::SelectOldObjects(WXHDC dc) +void wxMSWDCImpl::SelectOldObjects(WXHDC dc) { if (dc) { @@ -417,7 +424,7 @@ void wxDC::SelectOldObjects(WXHDC dc) // clipping // --------------------------------------------------------------------------- -void wxDC::UpdateClipBox() +void wxMSWDCImpl::UpdateClipBox() { WXMICROWIN_CHECK_HDC @@ -431,25 +438,25 @@ void wxDC::UpdateClipBox() } void -wxDC::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const +wxMSWDCImpl::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const { // check if we should try to retrieve the clipping region possibly not set // by our SetClippingRegion() but preset by Windows:this can only happen // when we're associated with an existing HDC usign SetHDC(), see there if ( m_clipping && !m_clipX1 && !m_clipX2 ) { - wxDC *self = wxConstCast(this, wxDC); + wxMSWDCImpl *self = wxConstCast(this, wxMSWDCImpl); self->UpdateClipBox(); if ( !m_clipX1 && !m_clipX2 ) self->m_clipping = false; } - wxDCBase::DoGetClippingBox(x, y, w, h); + wxDCImpl::DoGetClippingBox(x, y, w, h); } // common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion() -void wxDC::SetClippingHrgn(WXHRGN hrgn) +void wxMSWDCImpl::SetClippingHrgn(WXHRGN hrgn) { wxCHECK_RET( hrgn, wxT("invalid clipping region") ); @@ -494,7 +501,7 @@ void wxDC::SetClippingHrgn(WXHRGN hrgn) UpdateClipBox(); } -void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) +void wxMSWDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { // the region coords are always the device ones, so do the translation // manually @@ -516,12 +523,12 @@ void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) } } -void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) +void wxMSWDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region) { SetClippingHrgn(region.GetHRGN()); } -void wxDC::DestroyClippingRegion() +void wxMSWDCImpl::DestroyClippingRegion() { WXMICROWIN_CHECK_HDC @@ -545,19 +552,19 @@ void wxDC::DestroyClippingRegion() #endif } - wxDCBase::DestroyClippingRegion(); + wxDCImpl::DestroyClippingRegion(); } // --------------------------------------------------------------------------- // query capabilities // --------------------------------------------------------------------------- -bool wxDC::CanDrawBitmap() const +bool wxMSWDCImpl::CanDrawBitmap() const { return true; } -bool wxDC::CanGetTextExtent() const +bool wxMSWDCImpl::CanGetTextExtent() const { #ifdef __WXMICROWIN__ // TODO Extend MicroWindows' GetDeviceCaps function @@ -570,7 +577,7 @@ bool wxDC::CanGetTextExtent() const #endif } -int wxDC::GetDepth() const +int wxMSWDCImpl::GetDepth() const { WXMICROWIN_CHECK_HDC_RET(16) @@ -581,14 +588,14 @@ int wxDC::GetDepth() const // drawing // --------------------------------------------------------------------------- -void wxDC::Clear() +void wxMSWDCImpl::Clear() { WXMICROWIN_CHECK_HDC RECT rect; - if ( m_canvas ) + if (m_window) { - GetClientRect((HWND) m_canvas->GetHWND(), &rect); + GetClientRect((HWND) m_window->GetHWND(), &rect); } else { @@ -615,7 +622,7 @@ void wxDC::Clear() RealizeScaleAndOrigin(); } -bool wxDC::DoFloodFill(wxCoord WXUNUSED_IN_WINCE(x), +bool wxMSWDCImpl::DoFloodFill(wxCoord WXUNUSED_IN_WINCE(x), wxCoord WXUNUSED_IN_WINCE(y), const wxColour& WXUNUSED_IN_WINCE(col), int WXUNUSED_IN_WINCE(style)) @@ -652,11 +659,11 @@ bool wxDC::DoFloodFill(wxCoord WXUNUSED_IN_WINCE(x), #endif } -bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const +bool wxMSWDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const { WXMICROWIN_CHECK_HDC_RET(false) - wxCHECK_MSG( col, false, _T("NULL colour parameter in wxDC::GetPixel") ); + wxCHECK_MSG( col, false, _T("NULL colour parameter in wxMSWDCImpl::GetPixel") ); // get the color of the pixel COLORREF pixelcolor = ::GetPixel(GetHdc(), XLOG2DEV(x), YLOG2DEV(y)); @@ -666,7 +673,7 @@ bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const return true; } -void wxDC::DoCrossHair(wxCoord x, wxCoord y) +void wxMSWDCImpl::DoCrossHair(wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC @@ -682,7 +689,7 @@ void wxDC::DoCrossHair(wxCoord x, wxCoord y) CalcBoundingBox(x2, y2); } -void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) +void wxMSWDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { WXMICROWIN_CHECK_HDC @@ -694,7 +701,7 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1) // and ending at (x2, y2) -void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, +void wxMSWDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) { @@ -719,7 +726,7 @@ void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, // treat the special case of full circle separately if ( x1 == x2 && y1 == y2 ) { - DrawEllipse(xc - r, yc - r, 2*r, 2*r); + GetOwner()->DrawEllipse(xc - r, yc - r, 2*r, 2*r); return; } @@ -755,7 +762,7 @@ void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, #endif } -void wxDC::DoDrawCheckMark(wxCoord x1, wxCoord y1, +void wxMSWDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1, wxCoord width, wxCoord height) { // cases when we don't have DrawFrameControl() @@ -782,7 +789,7 @@ void wxDC::DoDrawCheckMark(wxCoord x1, wxCoord y1, #endif // Microwin/Normal } -void wxDC::DoDrawPoint(wxCoord x, wxCoord y) +void wxMSWDCImpl::DoDrawPoint(wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC @@ -797,7 +804,7 @@ void wxDC::DoDrawPoint(wxCoord x, wxCoord y) CalcBoundingBox(x, y); } -void wxDC::DoDrawPolygon(int n, +void wxMSWDCImpl::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, @@ -845,7 +852,7 @@ void wxDC::DoDrawPolygon(int n, } void -wxDC::DoDrawPolyPolygon(int n, +wxMSWDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, @@ -899,7 +906,7 @@ wxDC::DoDrawPolyPolygon(int n, // __WXWINCE__ } -void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxMSWDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { WXMICROWIN_CHECK_HDC @@ -928,7 +935,7 @@ void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset } } -void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxMSWDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { WXMICROWIN_CHECK_HDC @@ -970,7 +977,7 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) CalcBoundingBox(x2, y2); } -void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) +void wxMSWDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) { WXMICROWIN_CHECK_HDC @@ -1004,7 +1011,7 @@ void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h CalcBoundingBox(x2, y2); } -void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxMSWDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { WXMICROWIN_CHECK_HDC @@ -1020,7 +1027,7 @@ void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) } #if wxUSE_SPLINES -void wxDC::DoDrawSpline(const wxPointList *points) +void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) { #ifdef __WXWINCE__ // WinCE does not support ::PolyBezier so use generic version @@ -1119,7 +1126,7 @@ void wxDC::DoDrawSpline(const wxPointList *points) #endif // Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows -void wxDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) +void wxMSWDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { #ifdef __WXWINCE__ DoDrawEllipticArcRot( x, y, w, h, sa, ea ); @@ -1180,7 +1187,7 @@ void wxDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,d #endif } -void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) +void wxMSWDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC @@ -1196,11 +1203,11 @@ void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) CalcBoundingBox(x + icon.GetWidth(), y + icon.GetHeight()); } -void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) +void wxMSWDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) { WXMICROWIN_CHECK_HDC - wxCHECK_RET( bmp.Ok(), _T("invalid bitmap in wxDC::DrawBitmap") ); + wxCHECK_RET( bmp.Ok(), _T("invalid bitmap in wxMSWDCImpl::DrawBitmap") ); int width = bmp.GetWidth(), height = bmp.GetHeight(); @@ -1275,13 +1282,13 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask if ( !ok ) #endif // Win32 { - // Rather than reproduce wxDC::Blit, let's do it at the wxWin API + // Rather than reproduce wxMSWDCImpl::Blit, let's do it at the wxWin API // level wxMemoryDC memDC; memDC.SelectObjectAsSource(bmp); - Blit(x, y, width, height, &memDC, 0, 0, wxCOPY, useMask); + GetOwner()->Blit(x, y, width, height, &memDC, 0, 0, wxCOPY, useMask); memDC.SelectObject(wxNullBitmap); } @@ -1330,7 +1337,7 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask } } -void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) +void wxMSWDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC @@ -1340,11 +1347,11 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) CalcBoundingBox(x, y); wxCoord w, h; - GetTextExtent(text, &w, &h); + GetOwner()->GetTextExtent(text, &w, &h); CalcBoundingBox(x + w, y + h); } -void wxDC::DrawAnyText(const wxString& text, wxCoord x, wxCoord y) +void wxMSWDCImpl::DrawAnyText(const wxString& text, wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC @@ -1384,7 +1391,7 @@ void wxDC::DrawAnyText(const wxString& text, wxCoord x, wxCoord y) SetBkMode(GetHdc(), TRANSPARENT); } -void wxDC::DoDrawRotatedText(const wxString& text, +void wxMSWDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) { @@ -1436,7 +1443,7 @@ void wxDC::DoDrawRotatedText(const wxString& text, // containing the text to it (simpler and probably not slower than // determining which of them is really topmost/leftmost/...) wxCoord w, h; - GetTextExtent(text, &w, &h); + GetOwner()->GetTextExtent(text, &w, &h); double rad = DegToRad(angle); @@ -1459,7 +1466,7 @@ void wxDC::DoDrawRotatedText(const wxString& text, #if wxUSE_PALETTE -void wxDC::DoSelectPalette(bool realize) +void wxMSWDCImpl::DoSelectPalette(bool realize) { WXMICROWIN_CHECK_HDC @@ -1484,7 +1491,7 @@ void wxDC::DoSelectPalette(bool realize) } } -void wxDC::SetPalette(const wxPalette& palette) +void wxMSWDCImpl::SetPalette(const wxPalette& palette) { if ( palette.Ok() ) { @@ -1493,13 +1500,13 @@ void wxDC::SetPalette(const wxPalette& palette) } } -void wxDC::InitializePalette() +void wxMSWDCImpl::InitializePalette() { if ( wxDisplayDepth() <= 8 ) { // look for any window or parent that has a custom palette. If any has // one then we need to use it in drawing operations - wxWindow *win = m_canvas->GetAncestorWithCustomPalette(); + wxWindow *win = m_window->GetAncestorWithCustomPalette(); m_hasCustomPalette = win && win->HasCustomPalette(); if ( m_hasCustomPalette ) @@ -1517,7 +1524,7 @@ void wxDC::InitializePalette() // SetFont/Pen/Brush() really ask to be implemented as a single template // function... but doing it is not worth breaking OpenWatcom build -void wxDC::SetFont(const wxFont& font) +void wxMSWDCImpl::SetFont(const wxFont& font) { WXMICROWIN_CHECK_HDC @@ -1555,7 +1562,7 @@ void wxDC::SetFont(const wxFont& font) } } -void wxDC::SetPen(const wxPen& pen) +void wxMSWDCImpl::SetPen(const wxPen& pen) { WXMICROWIN_CHECK_HDC @@ -1593,7 +1600,7 @@ void wxDC::SetPen(const wxPen& pen) } } -void wxDC::SetBrush(const wxBrush& brush) +void wxMSWDCImpl::SetBrush(const wxBrush& brush) { WXMICROWIN_CHECK_HDC @@ -1648,7 +1655,7 @@ void wxDC::SetBrush(const wxBrush& brush) } } -void wxDC::SetBackground(const wxBrush& brush) +void wxMSWDCImpl::SetBackground(const wxBrush& brush) { WXMICROWIN_CHECK_HDC @@ -1660,7 +1667,7 @@ void wxDC::SetBackground(const wxBrush& brush) } } -void wxDC::SetBackgroundMode(int mode) +void wxMSWDCImpl::SetBackgroundMode(int mode) { WXMICROWIN_CHECK_HDC @@ -1670,7 +1677,7 @@ void wxDC::SetBackgroundMode(int mode) // and m_backgroundMode is used there } -void wxDC::SetLogicalFunction(int function) +void wxMSWDCImpl::SetLogicalFunction(int function) { WXMICROWIN_CHECK_HDC @@ -1679,7 +1686,7 @@ void wxDC::SetLogicalFunction(int function) SetRop(m_hDC); } -void wxDC::SetRop(WXHDC dc) +void wxMSWDCImpl::SetRop(WXHDC dc) { if ( !dc || m_logicalFunction < 0 ) return; @@ -1713,21 +1720,21 @@ void wxDC::SetRop(WXHDC dc) SetROP2(GetHdc(), rop); } -bool wxDC::StartDoc(const wxString& WXUNUSED(message)) +bool wxMSWDCImpl::StartDoc(const wxString& WXUNUSED(message)) { // We might be previewing, so return true to let it continue. return true; } -void wxDC::EndDoc() +void wxMSWDCImpl::EndDoc() { } -void wxDC::StartPage() +void wxMSWDCImpl::StartPage() { } -void wxDC::EndPage() +void wxMSWDCImpl::EndPage() { } @@ -1735,7 +1742,7 @@ void wxDC::EndPage() // text metrics // --------------------------------------------------------------------------- -wxCoord wxDC::GetCharHeight() const +wxCoord wxMSWDCImpl::GetCharHeight() const { WXMICROWIN_CHECK_HDC_RET(0) @@ -1746,7 +1753,7 @@ wxCoord wxDC::GetCharHeight() const return lpTextMetric.tmHeight; } -wxCoord wxDC::GetCharWidth() const +wxCoord wxMSWDCImpl::GetCharWidth() const { WXMICROWIN_CHECK_HDC_RET(0) @@ -1757,7 +1764,7 @@ wxCoord wxDC::GetCharWidth() const return lpTextMetric.tmAveCharWidth; } -void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, +void wxMSWDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, const wxFont *font) const { @@ -1775,7 +1782,7 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, HFONT hfontOld; if ( font ) { - wxASSERT_MSG( font->Ok(), _T("invalid font in wxDC::GetTextExtent") ); + wxASSERT_MSG( font->Ok(), _T("invalid font in wxMSWDCImpl::GetTextExtent") ); hfontOld = (HFONT)::SelectObject(GetHdc(), GetHfontOf(*font)); } @@ -1841,7 +1848,7 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, // Each element of the array will be the width of the string up to and // including the coresoponding character in text. -bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const +bool wxMSWDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const { static int maxLenText = -1; static int maxWidth = -1; @@ -1879,7 +1886,7 @@ bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) con return true; } -void wxDC::RealizeScaleAndOrigin() +void wxMSWDCImpl::RealizeScaleAndOrigin() { // VZ: it seems very wasteful to always use MM_ANISOTROPIC when in 99% of // cases we could do with MM_TEXT and in the remaining 0.9% with @@ -1899,7 +1906,7 @@ void wxDC::RealizeScaleAndOrigin() } -void wxDC::SetMapMode(int mode) +void wxMSWDCImpl::SetMapMode(int mode) { WXMICROWIN_CHECK_HDC @@ -1958,19 +1965,19 @@ void wxDC::SetMapMode(int mode) RealizeScaleAndOrigin(); } -void wxDC::SetUserScale(double x, double y) +void wxMSWDCImpl::SetUserScale(double x, double y) { WXMICROWIN_CHECK_HDC if ( x == m_userScaleX && y == m_userScaleY ) return; - wxDCBase::SetUserScale(x,y); + wxDCImpl::SetUserScale(x,y); RealizeScaleAndOrigin(); } -void wxDC::SetAxisOrientation(bool xLeftRight, +void wxMSWDCImpl::SetAxisOrientation(bool xLeftRight, bool yBottomUp) { WXMICROWIN_CHECK_HDC @@ -1981,33 +1988,33 @@ void wxDC::SetAxisOrientation(bool xLeftRight, if (signX == m_signX && signY == m_signY) return; - wxDCBase::SetAxisOrientation( xLeftRight, yBottomUp ); + wxDCImpl::SetAxisOrientation( xLeftRight, yBottomUp ); RealizeScaleAndOrigin(); } -void wxDC::SetLogicalOrigin(wxCoord x, wxCoord y) +void wxMSWDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC if ( x == m_logicalOriginX && y == m_logicalOriginY ) return; - wxDCBase::SetLogicalOrigin( x, y ); + wxDCImpl::SetLogicalOrigin( x, y ); #ifndef __WXWINCE__ ::SetWindowOrgEx(GetHdc(), (int)m_logicalOriginX, (int)m_logicalOriginY, NULL); #endif } -void wxDC::SetDeviceOrigin(wxCoord x, wxCoord y) +void wxMSWDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y) { WXMICROWIN_CHECK_HDC if ( x == m_deviceOriginX && y == m_deviceOriginY ) return; - wxDCBase::SetDeviceOrigin( x, y ); + wxDCImpl::SetDeviceOrigin( x, y ); ::SetViewportOrgEx(GetHdc(), (int)m_deviceOriginX, (int)m_deviceOriginY, NULL); } @@ -2016,7 +2023,7 @@ void wxDC::SetDeviceOrigin(wxCoord x, wxCoord y) // bit blit // --------------------------------------------------------------------------- -bool wxDC::DoBlit(wxCoord dstX, wxCoord dstY, +bool wxMSWDCImpl::DoBlit(wxCoord dstX, wxCoord dstY, wxCoord dstWidth, wxCoord dstHeight, wxDC *source, wxCoord srcX, wxCoord srcY, @@ -2026,7 +2033,7 @@ bool wxDC::DoBlit(wxCoord dstX, wxCoord dstY, return DoStretchBlit(dstX, dstY, dstWidth, dstHeight, source, srcX, srcY, dstWidth, dstHeight, rop, useMask, srcMaskX, srcMaskY); } -bool wxDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, +bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, wxCoord dstWidth, wxCoord dstHeight, wxDC *source, wxCoord xsrc, wxCoord ysrc, @@ -2034,18 +2041,27 @@ bool wxDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, int rop, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask) { - wxCHECK_MSG( source, false, _T("wxDC::Blit(): NULL wxDC pointer") ); + wxCHECK_MSG( source, false, _T("wxMSWDCImpl::Blit(): NULL wxDC pointer") ); WXMICROWIN_CHECK_HDC_RET(false) + wxDCImpl *impl = source->GetImpl(); + wxMSWDCImpl *msw_impl = wxDynamicCast( impl, wxMSWDCImpl ); + if (!msw_impl) + { + // TODO: Do we want to be able to blit + // from other DCs too? + return false; + } + // if either the source or destination has alpha channel, we must use // AlphaBlt() as other function don't handle it correctly - const wxBitmap& bmpSrc = source->m_selectedBitmap; + const wxBitmap& bmpSrc = msw_impl->GetSelectedBitmap(); if ( bmpSrc.Ok() && (bmpSrc.HasAlpha() || (m_selectedBitmap.Ok() && m_selectedBitmap.HasAlpha())) ) { if ( AlphaBlt(GetHdc(), xdest, ydest, dstWidth, dstHeight, - xsrc, ysrc, srcWidth, srcHeight, GetHdcOf(*source), bmpSrc) ) + xsrc, ysrc, srcWidth, srcHeight, GetHdcOf(*msw_impl), bmpSrc) ) return true; } @@ -2125,7 +2141,7 @@ bool wxDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, ( GetHdc(), xdest, ydest, dstWidth, dstHeight, - GetHdcOf(*source), + GetHdcOf(*msw_impl), xsrc, ysrc, (HBITMAP)mask->GetMaskBitmap(), xsrcMask, ysrcMask, @@ -2144,7 +2160,7 @@ bool wxDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, #if wxUSE_DC_CACHEING // create a temp buffer bitmap and DCs to access it and the mask - wxDCCacheEntry* dcCacheEntry1 = FindDCInCache(NULL, source->GetHDC()); + wxDCCacheEntry* dcCacheEntry1 = FindDCInCache(NULL, msw_impl->GetHDC()); dc_mask = (HDC) dcCacheEntry1->m_dc; wxDCCacheEntry* dcCacheEntry2 = FindDCInCache(dcCacheEntry1, GetHDC()); @@ -2176,7 +2192,7 @@ bool wxDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, // copy src to buffer using selected raster op if ( !::StretchBlt(dc_buffer, 0, 0, (int)dstWidth, (int)dstHeight, - GetHdcOf(*source), xsrc, ysrc, srcWidth, srcHeight, dwRop) ) + GetHdcOf(*msw_impl), xsrc, ysrc, srcWidth, srcHeight, dwRop) ) { wxLogLastError(wxT("StretchBlt")); } @@ -2287,7 +2303,7 @@ bool wxDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, ( GetHdc(), xdest, ydest, dstWidth, dstHeight, - GetHdcOf(*source), + GetHdcOf(*msw_impl), xsrc, ysrc, srcWidth, srcHeight, dwRop ) ) @@ -2307,7 +2323,7 @@ bool wxDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, GetHdc(), xdest, ydest, (int)dstWidth, (int)dstHeight, - GetHdcOf(*source), + GetHdcOf(*msw_impl), xsrc, ysrc, dwRop ) ) @@ -2327,7 +2343,7 @@ bool wxDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, return success; } -void wxDC::GetDeviceSize(int *width, int *height) const +void wxMSWDCImpl::GetDeviceSize(int *width, int *height) const { WXMICROWIN_CHECK_HDC @@ -2337,7 +2353,7 @@ void wxDC::GetDeviceSize(int *width, int *height) const *height = ::GetDeviceCaps(GetHdc(), VERTRES); } -void wxDC::DoGetSizeMM(int *w, int *h) const +void wxMSWDCImpl::DoGetSizeMM(int *w, int *h) const { WXMICROWIN_CHECK_HDC @@ -2367,7 +2383,7 @@ void wxDC::DoGetSizeMM(int *w, int *h) const } } -wxSize wxDC::GetPPI() const +wxSize wxMSWDCImpl::GetPPI() const { WXMICROWIN_CHECK_HDC_RET(wxSize(0,0)) @@ -2378,11 +2394,11 @@ wxSize wxDC::GetPPI() const } // For use by wxWidgets only, unless custom units are required. -void wxDC::SetLogicalScale(double x, double y) +void wxMSWDCImpl::SetLogicalScale(double x, double y) { WXMICROWIN_CHECK_HDC - wxDCBase::SetLogicalScale(x,y); + wxDCImpl::SetLogicalScale(x,y); } // ---------------------------------------------------------------------------- @@ -2397,8 +2413,8 @@ void wxDC::SetLogicalScale(double x, double y) * entry for the bitmap, and two for the DCs. -- JACS */ -wxList wxDC::sm_bitmapCache; -wxList wxDC::sm_dcCache; +wxObjectList wxMSWDCImpl::sm_bitmapCache; +wxObjectList wxMSWDCImpl::sm_dcCache; wxDCCacheEntry::wxDCCacheEntry(WXHBITMAP hBitmap, int w, int h, int depth) { @@ -2426,7 +2442,7 @@ wxDCCacheEntry::~wxDCCacheEntry() ::DeleteDC((HDC) m_dc); } -wxDCCacheEntry* wxDC::FindBitmapInCache(WXHDC dc, int w, int h) +wxDCCacheEntry* wxMSWDCImpl::FindBitmapInCache(WXHDC dc, int w, int h) { int depth = ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL); wxList::compatibility_iterator node = sm_bitmapCache.GetFirst(); @@ -2462,7 +2478,7 @@ wxDCCacheEntry* wxDC::FindBitmapInCache(WXHDC dc, int w, int h) return entry; } -wxDCCacheEntry* wxDC::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc) +wxDCCacheEntry* wxMSWDCImpl::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc) { int depth = ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL); wxList::compatibility_iterator node = sm_dcCache.GetFirst(); @@ -2491,17 +2507,17 @@ wxDCCacheEntry* wxDC::FindDCInCache(wxDCCacheEntry* notThis, WXHDC dc) return entry; } -void wxDC::AddToBitmapCache(wxDCCacheEntry* entry) +void wxMSWDCImpl::AddToBitmapCache(wxDCCacheEntry* entry) { sm_bitmapCache.Append(entry); } -void wxDC::AddToDCCache(wxDCCacheEntry* entry) +void wxMSWDCImpl::AddToDCCache(wxDCCacheEntry* entry) { sm_dcCache.Append(entry); } -void wxDC::ClearCache() +void wxMSWDCImpl::ClearCache() { WX_CLEAR_LIST(wxList, sm_dcCache); WX_CLEAR_LIST(wxList, sm_bitmapCache); @@ -2512,7 +2528,7 @@ class wxDCModule : public wxModule { public: virtual bool OnInit() { return true; } - virtual void OnExit() { wxDC::ClearCache(); } + virtual void OnExit() { wxMSWDCImpl::ClearCache(); } private: DECLARE_DYNAMIC_CLASS(wxDCModule) @@ -2647,7 +2663,7 @@ wxAlphaBlend(HDC hdcDst, int xDst, int yDst, #endif // #ifdef wxHAVE_RAW_BITMAP -void wxDC::DoGradientFillLinear (const wxRect& rect, +void wxMSWDCImpl::DoGradientFillLinear (const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection) @@ -2708,7 +2724,7 @@ void wxDC::DoGradientFillLinear (const wxRect& rect, } #endif // wxUSE_DYNLIB_CLASS - wxDCBase::DoGradientFillLinear(rect, initialColour, destColour, nDirection); + wxDCImpl::DoGradientFillLinear(rect, initialColour, destColour, nDirection); } #if wxUSE_DYNLIB_CLASS @@ -2722,7 +2738,7 @@ static DWORD wxGetDCLayout(HDC hdc) return s_pfnGetLayout ? s_pfnGetLayout(hdc) : (DWORD)-1; } -wxLayoutDirection wxDC::GetLayoutDirection() const +wxLayoutDirection wxMSWDCImpl::GetLayoutDirection() const { DWORD layout = wxGetDCLayout(GetHdc()); @@ -2732,7 +2748,7 @@ wxLayoutDirection wxDC::GetLayoutDirection() const return layout & LAYOUT_RTL ? wxLayout_RightToLeft : wxLayout_LeftToRight; } -void wxDC::SetLayoutDirection(wxLayoutDirection dir) +void wxMSWDCImpl::SetLayoutDirection(wxLayoutDirection dir) { typedef DWORD (WINAPI *SetLayout_t)(HDC, DWORD); static SetLayout_t @@ -2759,12 +2775,12 @@ void wxDC::SetLayoutDirection(wxLayoutDirection dir) #else // !wxUSE_DYNLIB_CLASS // we can't provide RTL support without dynamic loading, so stub it out -wxLayoutDirection wxDC::GetLayoutDirection() const +wxLayoutDirection wxMSWDCImpl::GetLayoutDirection() const { return wxLayout_Default; } -void wxDC::SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) +void wxMSWDCImpl::SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { } diff --git a/src/msw/dcclient.cpp b/src/msw/dcclient.cpp index 75c1c9a550..96737f424e 100644 --- a/src/msw/dcclient.cpp +++ b/src/msw/dcclient.cpp @@ -25,6 +25,7 @@ #endif #include "wx/dcclient.h" +#include "wx/msw/dcclient.h" #ifndef WX_PRECOMP #include "wx/string.h" @@ -40,7 +41,7 @@ struct WXDLLEXPORT wxPaintDCInfo { - wxPaintDCInfo(wxWindow *win, wxDC *dc) + wxPaintDCInfo(wxWindow *win, wxPaintDCImpl *dc) { hwnd = win->GetHWND(); hdc = dc->GetHDC(); @@ -60,11 +61,6 @@ WX_DEFINE_OBJARRAY(wxArrayDCInfo) // macros // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) -IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) -IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC) -IMPLEMENT_CLASS(wxPaintDCEx, wxPaintDC) - // ---------------------------------------------------------------------------- // global variables // ---------------------------------------------------------------------------- @@ -84,34 +80,37 @@ static PAINTSTRUCT g_paintStruct; // =========================================================================== // ---------------------------------------------------------------------------- -// wxWindowDC +// wxMSWWindowDCImpl // ---------------------------------------------------------------------------- -wxWindowDC::wxWindowDC() +IMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl, wxMSWDCImpl) + +wxWindowDCImpl::wxWindowDCImpl( wxDC *owner ) : + wxMSWDCImpl( owner ) { - m_canvas = NULL; } -wxWindowDC::wxWindowDC(wxWindow *canvas) +wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) : + wxMSWDCImpl( owner ) { - wxCHECK_RET( canvas, _T("invalid window in wxWindowDC") ); + wxCHECK_RET( window, _T("invalid window in wxWindowDCImpl") ); - m_canvas = canvas; - m_hDC = (WXHDC) ::GetWindowDC(GetHwndOf(m_canvas)); + m_window = window; + m_hDC = (WXHDC) ::GetWindowDC(GetHwndOf(m_window)); // m_bOwnsDC was already set to false in the base class ctor, so the DC // will be released (and not deleted) in ~wxDC InitDC(); } -void wxWindowDC::InitDC() +void wxWindowDCImpl::InitDC() { // the background mode is only used for text background and is set in // DrawText() to OPAQUE as required, otherwise always TRANSPARENT, ::SetBkMode(GetHdc(), TRANSPARENT); // default bg colour is pne of the window - SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID)); + SetBackground(wxBrush(m_window->GetBackgroundColour(), wxSOLID)); // since we are a window dc we need to grab the palette from the window #if wxUSE_PALETTE @@ -119,28 +118,31 @@ void wxWindowDC::InitDC() #endif } -void wxWindowDC::DoGetSize(int *width, int *height) const +void wxWindowDCImpl::DoGetSize(int *width, int *height) const { - wxCHECK_RET( m_canvas, _T("wxWindowDC without a window?") ); + wxCHECK_RET( m_window, _T("wxWindowDCImpl without a window?") ); - m_canvas->GetSize(width, height); + m_window->GetSize(width, height); } // ---------------------------------------------------------------------------- -// wxClientDC +// wxClientDCImpl // ---------------------------------------------------------------------------- -wxClientDC::wxClientDC() +IMPLEMENT_ABSTRACT_CLASS(wxClientDCImpl, wxWindowDCImpl) + +wxClientDCImpl::wxClientDCImpl( wxDC *owner ) : + wxWindowDCImpl( owner ) { - m_canvas = NULL; } -wxClientDC::wxClientDC(wxWindow *canvas) +wxClientDCImpl::wxClientDCImpl( wxDC *owner, wxWindow *window ) : + wxWindowDCImpl( owner ) { - wxCHECK_RET( canvas, _T("invalid window in wxClientDC") ); + wxCHECK_RET( window, _T("invalid window in wxClientDCImpl") ); - m_canvas = canvas; - m_hDC = (WXHDC)::GetDC(GetHwndOf(m_canvas)); + m_window = window; + m_hDC = (WXHDC)::GetDC(GetHwndOf(window)); // m_bOwnsDC was already set to false in the base class ctor, so the DC // will be released (and not deleted) in ~wxDC @@ -148,9 +150,9 @@ wxClientDC::wxClientDC(wxWindow *canvas) InitDC(); } -void wxClientDC::InitDC() +void wxClientDCImpl::InitDC() { - wxWindowDC::InitDC(); + wxWindowDCImpl::InitDC(); // in wxUniv build we must manually do some DC adjustments usually // performed by Windows for us @@ -159,7 +161,7 @@ void wxClientDC::InitDC() // Windows CE because they're just another control there, not anything // special as usually under Windows #if defined(__WXUNIVERSAL__) || defined(__WXWINCE__) - wxPoint ptOrigin = m_canvas->GetClientAreaOrigin(); + wxPoint ptOrigin = m_window->GetClientAreaOrigin(); if ( ptOrigin.x || ptOrigin.y ) { // no need to shift DC origin if shift is null @@ -167,23 +169,23 @@ void wxClientDC::InitDC() } // clip the DC to avoid overwriting the non client area - SetClippingRegion(wxPoint(0,0), m_canvas->GetClientSize()); + SetClippingRegion(wxPoint(0,0), m_window->GetClientSize()); #endif // __WXUNIVERSAL__ || __WXWINCE__ } -wxClientDC::~wxClientDC() +wxClientDCImpl::~wxClientDCImpl() { } -void wxClientDC::DoGetSize(int *width, int *height) const +void wxClientDCImpl::DoGetSize(int *width, int *height) const { - wxCHECK_RET( m_canvas, _T("wxClientDC without a window?") ); + wxCHECK_RET( m_window, _T("wxClientDCImpl without a window?") ); - m_canvas->GetClientSize(width, height); + m_window->GetClientSize(width, height); } // ---------------------------------------------------------------------------- -// wxPaintDC +// wxPaintDCImpl // ---------------------------------------------------------------------------- // VZ: initial implementation (by JACS) only remembered the last wxPaintDC @@ -202,27 +204,30 @@ void wxClientDC::DoGetSize(int *width, int *height) const // "wxPaintDC *" parameter to wxPaintEvent which should be used if it's // !NULL instead of creating a new DC. -wxArrayDCInfo wxPaintDC::ms_cache; +IMPLEMENT_ABSTRACT_CLASS(wxPaintDCImpl, wxClientDCImpl) -wxPaintDC::wxPaintDC() +wxArrayDCInfo wxPaintDCImpl::ms_cache; + +wxPaintDCImpl::wxPaintDCImpl( wxDC *owner ) : + wxClientDCImpl( owner ) { - m_canvas = NULL; } -wxPaintDC::wxPaintDC(wxWindow *canvas) +wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) : + wxClientDCImpl( owner ) { - wxCHECK_RET( canvas, wxT("NULL canvas in wxPaintDC ctor") ); + wxCHECK_RET( window, wxT("NULL canvas in wxPaintDCImpl ctor") ); #ifdef __WXDEBUG__ if ( g_isPainting <= 0 ) { - wxFAIL_MSG( wxT("wxPaintDC may be created only in EVT_PAINT handler!") ); + wxFAIL_MSG( wxT("wxPaintDCImpl may be created only in EVT_PAINT handler!") ); return; } #endif // __WXDEBUG__ - m_canvas = canvas; + m_window = window; // do we have a DC for this window in the cache? wxPaintDCInfo *info = FindInCache(); @@ -233,9 +238,9 @@ wxPaintDC::wxPaintDC(wxWindow *canvas) } else // not in cache, create a new one { - m_hDC = (WXHDC)::BeginPaint(GetHwndOf(m_canvas), &g_paintStruct); + m_hDC = (WXHDC)::BeginPaint(GetHwndOf(m_window), &g_paintStruct); if (m_hDC) - ms_cache.Add(new wxPaintDCInfo(m_canvas, this)); + ms_cache.Add(new wxPaintDCInfo(m_window, this)); } // Note: at this point m_hDC can be NULL under MicroWindows, when dragging. @@ -250,7 +255,7 @@ wxPaintDC::wxPaintDC(wxWindow *canvas) m_clipping = true; } -wxPaintDC::~wxPaintDC() +wxPaintDCImpl::~wxPaintDCImpl() { if ( m_hDC ) { @@ -263,7 +268,7 @@ wxPaintDC::~wxPaintDC() if ( --info->count == 0 ) { - ::EndPaint(GetHwndOf(m_canvas), &g_paintStruct); + ::EndPaint(GetHwndOf(m_window), &g_paintStruct); ms_cache.RemoveAt(index); @@ -279,14 +284,14 @@ wxPaintDC::~wxPaintDC() } } -wxPaintDCInfo *wxPaintDC::FindInCache(size_t *index) const +wxPaintDCInfo *wxPaintDCImpl::FindInCache(size_t *index) const { wxPaintDCInfo *info = NULL; size_t nCache = ms_cache.GetCount(); for ( size_t n = 0; n < nCache; n++ ) { wxPaintDCInfo *info1 = &ms_cache[n]; - if ( info1->hwnd == m_canvas->GetHWND() ) + if ( info1->hwnd == m_window->GetHWND() ) { info = info1; if ( index ) @@ -299,7 +304,7 @@ wxPaintDCInfo *wxPaintDC::FindInCache(size_t *index) const } // find the entry for this DC in the cache (keyed by the window) -WXHDC wxPaintDC::FindDCInCache(wxWindow* win) +WXHDC wxPaintDCImpl::FindDCInCache(wxWindow* win) { size_t nCache = ms_cache.GetCount(); for ( size_t n = 0; n < nCache; n++ ) @@ -317,47 +322,71 @@ WXHDC wxPaintDC::FindDCInCache(wxWindow* win) * wxPaintDCEx */ -// TODO: don't duplicate wxPaintDC code here!! +// TODO: don't duplicate wxPaintDCImpl code here!! -wxPaintDCEx::wxPaintDCEx(wxWindow *canvas, WXHDC dc) : saveState(0) +class wxPaintDCExImpl: public wxPaintDCImpl { - wxCHECK_RET( dc, wxT("wxPaintDCEx requires an existing device context") ); +public: + wxPaintDCExImpl( wxDC *owner, wxWindow *window, WXHDC dc ); + ~wxPaintDCExImpl(); + + int m_saveState; +}; - m_canvas = canvas; - wxPaintDCInfo *info = FindInCache(); - if ( info ) - { - m_hDC = info->hdc; - info->count++; - } - else // not in cache, create a new one - { - m_hDC = dc; - ms_cache.Add(new wxPaintDCInfo(m_canvas, this)); - saveState = SaveDC((HDC) dc); - } +IMPLEMENT_ABSTRACT_CLASS(wxPaintDCEx,wxPaintDC) + +wxPaintDCEx::wxPaintDCEx( wxWindow *window, WXHDC dc ) +{ + m_pimpl = new wxPaintDCExImpl( this, window, dc ); } -wxPaintDCEx::~wxPaintDCEx() + + +wxPaintDCExImpl::wxPaintDCExImpl( wxDC *owner, wxWindow *window, WXHDC dc ) : + wxPaintDCImpl( owner ) { - size_t index; - wxPaintDCInfo *info = FindInCache(&index); + wxCHECK_RET( dc, wxT("wxPaintDCEx requires an existing device context") ); - wxCHECK_RET( info, wxT("existing DC should have a cache entry") ); + m_saveState = 0; + + m_window = window; - if ( --info->count == 0 ) - { - RestoreDC((HDC) m_hDC, saveState); - ms_cache.RemoveAt(index); + wxPaintDCInfo *info = FindInCache(); + if ( info ) + { + m_hDC = info->hdc; + info->count++; + } + else // not in cache, create a new one + { + m_hDC = dc; + ms_cache.Add(new wxPaintDCInfo(m_window, this)); + m_saveState = SaveDC((HDC) dc); + } +} - // Reduce the number of bogus reports of non-freed memory - // at app exit - if (ms_cache.IsEmpty()) - ms_cache.Clear(); - } - //else: cached DC entry is still in use +wxPaintDCExImpl::~wxPaintDCExImpl() +{ + size_t index; + wxPaintDCInfo *info = FindInCache(&index); + + wxCHECK_RET( info, wxT("existing DC should have a cache entry") ); - // prevent the base class dtor from ReleaseDC()ing it again - m_hDC = 0; + if ( --info->count == 0 ) + { + RestoreDC((HDC) m_hDC, m_saveState); + ms_cache.RemoveAt(index); + + // Reduce the number of bogus reports of non-freed memory + // at app exit + if (ms_cache.IsEmpty()) + ms_cache.Clear(); + } + //else: cached DC entry is still in use + + // prevent the base class dtor from ReleaseDC()ing it again + m_hDC = 0; } + + diff --git a/src/msw/dcmemory.cpp b/src/msw/dcmemory.cpp index 5565670444..37605f4750 100644 --- a/src/msw/dcmemory.cpp +++ b/src/msw/dcmemory.cpp @@ -25,6 +25,7 @@ #endif #include "wx/dcmemory.h" +#include "wx/msw/dcmemory.h" #ifndef WX_PRECOMP #include "wx/utils.h" @@ -34,20 +35,28 @@ #include "wx/msw/private.h" // ---------------------------------------------------------------------------- -// wxWin macros +// wxMemoryDCImpl // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) +IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxMSWDCImpl) -// ============================================================================ -// implementation -// ============================================================================ +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner ) + : wxMSWDCImpl( owner ) +{ + CreateCompatible(NULL); + Init(); +} -// ---------------------------------------------------------------------------- -// wxMemoryDC -// ---------------------------------------------------------------------------- +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap ) + : wxMSWDCImpl( owner ) +{ + CreateCompatible(NULL); + Init(); + DoSelect(bitmap); +} -wxMemoryDC::wxMemoryDC(wxDC *dc) +wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ) + : wxMSWDCImpl( owner ) { wxCHECK_RET( dc, _T("NULL dc in wxMemoryDC ctor") ); @@ -56,7 +65,7 @@ wxMemoryDC::wxMemoryDC(wxDC *dc) Init(); } -void wxMemoryDC::Init() +void wxMemoryDCImpl::Init() { if ( m_ok ) { @@ -69,9 +78,17 @@ void wxMemoryDC::Init() } } -bool wxMemoryDC::CreateCompatible(wxDC *dc) +bool wxMemoryDCImpl::CreateCompatible(wxDC *dc) { - m_hDC = (WXHDC)::CreateCompatibleDC(dc ? GetHdcOf(*dc) : NULL); + wxDCImpl *impl = dc->GetImpl(); + wxMSWDCImpl *msw_impl = wxDynamicCast( impl, wxMSWDCImpl ); + if (!msw_impl) + { + m_ok = false; + return false; + } + + m_hDC = (WXHDC)::CreateCompatibleDC(dc ? GetHdcOf(*msw_impl) : NULL); // as we created the DC, we must delete it in the dtor m_bOwnsDC = true; @@ -81,7 +98,7 @@ bool wxMemoryDC::CreateCompatible(wxDC *dc) return m_ok; } -void wxMemoryDC::DoSelect( const wxBitmap& bitmap) +void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) { // select old bitmap out of the device context if ( m_oldBitmap ) @@ -123,7 +140,7 @@ void wxMemoryDC::DoSelect( const wxBitmap& bitmap) } } -void wxMemoryDC::DoGetSize(int *width, int *height) const +void wxMemoryDCImpl::DoGetSize(int *width, int *height) const { if ( m_selectedBitmap.Ok() ) { @@ -174,7 +191,7 @@ static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoo #endif // wxUSE_MEMORY_DC_DRAW_RECTANGLE -void wxMemoryDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxMemoryDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { // Set this to 1 to work around an apparent video driver bug // (visible with e.g. 70x70 rectangle on a memory DC; see Drawing sample) @@ -189,6 +206,6 @@ void wxMemoryDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord he else #endif // wxUSE_MEMORY_DC_DRAW_RECTANGLE { - wxDC::DoDrawRectangle(x, y, width, height); + wxMSWDCImpl::DoDrawRectangle(x, y, width, height); } } diff --git a/src/msw/dcprint.cpp b/src/msw/dcprint.cpp index 92425e9cf7..628e6e81b2 100644 --- a/src/msw/dcprint.cpp +++ b/src/msw/dcprint.cpp @@ -27,6 +27,7 @@ #if wxUSE_PRINTING_ARCHITECTURE #include "wx/dcprint.h" +#include "wx/msw/dcprint.h" #ifndef WX_PRECOMP #include "wx/msw/wrapcdlg.h" @@ -66,7 +67,7 @@ // wxWin macros // ---------------------------------------------------------------------------- -IMPLEMENT_CLASS(wxPrinterDC, wxDC) +IMPLEMENT_ABSTRACT_CLASS(wxPrinterDCImpl, wxMSWDCImpl) // ============================================================================ // implementation @@ -76,6 +77,7 @@ IMPLEMENT_CLASS(wxPrinterDC, wxDC) // wxPrinterDC construction // ---------------------------------------------------------------------------- +#if 0 // This form is deprecated wxPrinterDC::wxPrinterDC(const wxString& driver_name, const wxString& device_name, @@ -136,8 +138,10 @@ wxPrinterDC::wxPrinterDC(const wxString& driver_name, Init(); } +#endif -wxPrinterDC::wxPrinterDC(const wxPrintData& printData) +wxPrinterDCImpl::wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& printData ) : + wxMSWDCImpl( owner ) { m_printData = printData; @@ -151,7 +155,8 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printData) } -wxPrinterDC::wxPrinterDC(WXHDC dc) +wxPrinterDCImpl::wxPrinterDCImpl( wxPrinterDC *owner, WXHDC dc ) : + wxMSWDCImpl( owner ) { m_isInteractive = false; @@ -160,7 +165,7 @@ wxPrinterDC::wxPrinterDC(WXHDC dc) m_ok = true; } -void wxPrinterDC::Init() +void wxPrinterDCImpl::Init() { if ( m_hDC ) { @@ -174,10 +179,10 @@ void wxPrinterDC::Init() } // ---------------------------------------------------------------------------- -// wxPrinterDC {Start/End}{Page/Doc} methods +// wxPrinterDCImpl {Start/End}{Page/Doc} methods // ---------------------------------------------------------------------------- -bool wxPrinterDC::StartDoc(const wxString& message) +bool wxPrinterDCImpl::StartDoc(const wxString& message) { DOCINFO docinfo; docinfo.cbSize = sizeof(DOCINFO); @@ -205,28 +210,28 @@ bool wxPrinterDC::StartDoc(const wxString& message) return true; } -void wxPrinterDC::EndDoc() +void wxPrinterDCImpl::EndDoc() { if (m_hDC) ::EndDoc((HDC) m_hDC); } -void wxPrinterDC::StartPage() +void wxPrinterDCImpl::StartPage() { if (m_hDC) ::StartPage((HDC) m_hDC); } -void wxPrinterDC::EndPage() +void wxPrinterDCImpl::EndPage() { if (m_hDC) ::EndPage((HDC) m_hDC); } -wxRect wxPrinterDC::GetPaperRect() +wxRect wxPrinterDCImpl::GetPaperRect() { - if (!Ok()) return wxRect(0, 0, 0, 0); + if (!IsOk()) return wxRect(0, 0, 0, 0); int w = ::GetDeviceCaps((HDC) m_hDC, PHYSICALWIDTH); int h = ::GetDeviceCaps((HDC) m_hDC, PHYSICALHEIGHT); int x = -::GetDeviceCaps((HDC) m_hDC, PHYSICALOFFSETX); @@ -338,7 +343,7 @@ WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst) } // ---------------------------------------------------------------------------- -// wxPrinterDC bit blitting/bitmap drawing +// wxPrinterDCImpl bit blitting/bitmap drawing // ---------------------------------------------------------------------------- // helper of DoDrawBitmap() and DoBlit() @@ -386,7 +391,7 @@ bool DrawBitmapUsingStretchDIBits(HDC hdc, #endif } -void wxPrinterDC::DoDrawBitmap(const wxBitmap& bmp, +void wxPrinterDCImpl::DoDrawBitmap(const wxBitmap& bmp, wxCoord x, wxCoord y, bool useMask) { @@ -403,27 +408,32 @@ void wxPrinterDC::DoDrawBitmap(const wxBitmap& bmp, memDC.SelectObjectAsSource(bmp); - Blit(x, y, width, height, &memDC, 0, 0, wxCOPY, useMask); + GetOwner()->Blit(x, y, width, height, &memDC, 0, 0, wxCOPY, useMask); memDC.SelectObject(wxNullBitmap); } } -bool wxPrinterDC::DoBlit(wxCoord xdest, wxCoord ydest, +bool wxPrinterDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord WXUNUSED(xsrc), wxCoord WXUNUSED(ysrc), int WXUNUSED(rop), bool useMask, wxCoord WXUNUSED(xsrcMask), wxCoord WXUNUSED(ysrcMask)) { - wxBitmap& bmp = source->GetSelectedBitmap(); + wxDCImpl *impl = source->GetImpl(); + wxMSWDCImpl *msw_impl = wxDynamicCast(impl, wxMSWDCImpl); + if (!msw_impl) + return false; + + wxBitmap& bmp = msw_impl->GetSelectedBitmap(); wxMask *mask = useMask ? bmp.GetMask() : NULL; if ( mask ) { // If we are printing source colours are screen colours not printer // colours and so we need copy the bitmap pixel by pixel. RECT rect; - HDC dcSrc = GetHdcOf(*source); + HDC dcSrc = GetHdcOf(*msw_impl); MemoryHDC dcMask(dcSrc); SelectInHDC selectMask(dcMask, (HBITMAP)mask->GetMaskBitmap()); @@ -454,7 +464,7 @@ bool wxPrinterDC::DoBlit(wxCoord xdest, wxCoord ydest, // as we are printing, source colours are screen colours not // printer colours and so we need copy the bitmap pixel by pixel. - HDC dcSrc = GetHdcOf(*source); + HDC dcSrc = GetHdcOf(*msw_impl); RECT rect; for (int y = 0; y < height; y++) { diff --git a/src/msw/dcscreen.cpp b/src/msw/dcscreen.cpp index 26d350895d..f55eddd5a0 100644 --- a/src/msw/dcscreen.cpp +++ b/src/msw/dcscreen.cpp @@ -16,7 +16,7 @@ #pragma hdrstop #endif -#include "wx/dcscreen.h" +#include "wx/msw/dcscreen.h" #ifndef WX_PRECOMP #include "wx/string.h" @@ -25,10 +25,11 @@ #include "wx/msw/private.h" -IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxDC) +IMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl, wxMSWDCImpl) // Create a DC representing the whole screen -wxScreenDC::wxScreenDC() +wxScreenDCImpl::wxScreenDCImpl( wxScreenDC *owner ) : + wxMSWDCImpl( owner ) { m_hDC = (WXHDC) ::GetDC((HWND) NULL); @@ -36,3 +37,4 @@ wxScreenDC::wxScreenDC() // DrawText() to OPAQUE as required, otherwise always TRANSPARENT ::SetBkMode( GetHdc(), TRANSPARENT ); } + diff --git a/src/msw/enhmeta.cpp b/src/msw/enhmeta.cpp index aaf3f59857..818d796a81 100644 --- a/src/msw/enhmeta.cpp +++ b/src/msw/enhmeta.cpp @@ -32,6 +32,9 @@ #include "wx/intl.h" #endif //WX_PRECOMP +#include "wx/dc.h" +#include "wx/msw/dc.h" + #include "wx/metafile.h" #include "wx/clipbrd.h" @@ -42,7 +45,6 @@ // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxEnhMetaFile, wxObject) -IMPLEMENT_ABSTRACT_CLASS(wxEnhMetaFileDC, wxDC) // ---------------------------------------------------------------------------- // macros @@ -136,7 +138,12 @@ bool wxEnhMetaFile::Play(wxDC *dc, wxRect *rectBound) rect.bottom = size.y; } - if ( !::PlayEnhMetaFile(GetHdcOf(*dc), GetEMF(), &rect) ) + wxDCImpl *impl = dc->GetImpl(); + wxMSWDCImpl *msw_impl = wxDynamicCast( impl, wxMSWDCImpl ); + if (!msw_impl) + return false; + + if ( !::PlayEnhMetaFile(GetHdcOf(*msw_impl), GetEMF(), &rect) ) { wxLogLastError(_T("PlayEnhMetaFile")); @@ -190,9 +197,42 @@ bool wxEnhMetaFile::SetClipboard(int WXUNUSED(width), int WXUNUSED(height)) // wxEnhMetaFileDC // ---------------------------------------------------------------------------- +class wxEnhMetaFileDCImpl : public wxMSWDCImpl +{ +public: + wxEnhMetaFileDCImpl( wxEnhMetaFileDC *owner, + const wxString& filename, int width, int height, + const wxString& description ); + virtual ~wxEnhMetaFileDCImpl(); + + // obtain a pointer to the new metafile (caller should delete it) + wxEnhMetaFile *Close(); + +protected: + virtual void DoGetSize(int *width, int *height) const; + +private: + // size passed to ctor and returned by DoGetSize() + int m_width, + m_height; +}; + + +IMPLEMENT_ABSTRACT_CLASS(wxEnhMetaFileDC, wxDC) + wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename, int width, int height, const wxString& description) +{ + m_pimpl = new wxEnhMetaFileDCImpl( this, filename, width, height, description ); +} + + +wxEnhMetaFileDCImpl::wxEnhMetaFileDCImpl( wxEnhMetaFileDC* owner, + const wxString& filename, + int width, int height, + const wxString& description ) + : wxMSWDCImpl( owner ) { m_width = width; m_height = height; @@ -226,7 +266,7 @@ wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename, } } -void wxEnhMetaFileDC::DoGetSize(int *width, int *height) const +void wxEnhMetaFileDCImpl::DoGetSize(int *width, int *height) const { if ( width ) *width = m_width; @@ -234,9 +274,9 @@ void wxEnhMetaFileDC::DoGetSize(int *width, int *height) const *height = m_height; } -wxEnhMetaFile *wxEnhMetaFileDC::Close() +wxEnhMetaFile *wxEnhMetaFileDCImpl::Close() { - wxCHECK_MSG( Ok(), NULL, _T("invalid wxEnhMetaFileDC") ); + wxCHECK_MSG( IsOk(), NULL, _T("invalid wxEnhMetaFileDC") ); HENHMETAFILE hMF = ::CloseEnhMetaFile(GetHdc()); if ( !hMF ) @@ -251,7 +291,7 @@ wxEnhMetaFile *wxEnhMetaFileDC::Close() return mf; } -wxEnhMetaFileDC::~wxEnhMetaFileDC() +wxEnhMetaFileDCImpl::~wxEnhMetaFileDCImpl() { // avoid freeing it in the base class dtor m_hDC = 0; diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp index 7548695b8c..4fb0fbb83d 100644 --- a/src/msw/imaglist.cpp +++ b/src/msw/imaglist.cpp @@ -38,6 +38,8 @@ #endif #include "wx/imaglist.h" +#include "wx/dc.h" +#include "wx/msw/dc.h" #include "wx/msw/private.h" // ---------------------------------------------------------------------------- @@ -241,7 +243,12 @@ bool wxImageList::Draw(int index, int flags, bool solidBackground) { - HDC hDC = GetHdcOf(dc); + wxDCImpl *impl = dc.GetImpl(); + wxMSWDCImpl *msw_impl = wxDynamicCast( impl, wxMSWDCImpl ); + if (!msw_impl) + return false; + + HDC hDC = GetHdcOf(*msw_impl); wxCHECK_MSG( hDC, false, _T("invalid wxDC in wxImageList::Draw") ); COLORREF clr = CLR_NONE; // transparent by default diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 91fb5b93a2..93b01f37f6 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -945,9 +945,11 @@ void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event)) hbr = GetHbrushOf(brush); } - ::FillRect(GetHdcOf(memdc), &rc, hbr); + wxMSWDCImpl *impl = (wxMSWDCImpl*) memdc.GetImpl(); - MSWDefWindowProc(WM_PAINT, (WPARAM)memdc.GetHDC(), 0); + ::FillRect(GetHdcOf(*impl), &rc, hbr); + + MSWDefWindowProc(WM_PAINT, (WPARAM)(impl->GetHDC()), 0); // For some reason in RTL mode, source offset has to be -1, otherwise the // right border (physical) remains unpainted. diff --git a/src/msw/ownerdrw.cpp b/src/msw/ownerdrw.cpp index 12f6d210bc..c781c560c3 100644 --- a/src/msw/ownerdrw.cpp +++ b/src/msw/ownerdrw.cpp @@ -312,7 +312,8 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc, } - HDC hdc = GetHdcOf(dc); + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + HDC hdc = GetHdcOf(*impl); COLORREF colOldText = ::SetTextColor(hdc, colText), colOldBack = ::SetBkColor(hdc, colBack); diff --git a/src/msw/printdlg.cpp b/src/msw/printdlg.cpp index a9b861d09f..575fb82ffd 100644 --- a/src/msw/printdlg.cpp +++ b/src/msw/printdlg.cpp @@ -37,6 +37,7 @@ #include "wx/printdlg.h" #include "wx/msw/printdlg.h" +#include "wx/msw/dcprint.h" #include "wx/paper.h" #include @@ -638,7 +639,7 @@ int wxWindowsPrintDialog::ShowModal() if ( ret && (pd->hDC) ) { - wxPrinterDC *pdc = new wxPrinterDC( (WXHDC) pd->hDC ); + wxPrinterDC *pdc = new wxPrinterDCFromHDC( (WXHDC) pd->hDC ); m_printerDC = pdc; ConvertFromNative( m_printDialogData ); return wxID_OK; diff --git a/src/msw/printwin.cpp b/src/msw/printwin.cpp index 310db919dd..98dae5fc75 100644 --- a/src/msw/printwin.cpp +++ b/src/msw/printwin.cpp @@ -44,6 +44,7 @@ #include "wx/msw/printwin.h" #include "wx/msw/printdlg.h" #include "wx/msw/private.h" +#include "wx/msw/dcprint.h" #include @@ -119,19 +120,21 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt } // May have pressed cancel. - if (!dc || !dc->Ok()) + if (!dc || !dc->IsOk()) { if (dc) delete dc; return false; } + wxPrinterDCImpl *impl = (wxPrinterDCImpl*) dc->GetImpl(); + HDC hdc = ::GetDC(NULL); int logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX); int logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY); ::ReleaseDC(NULL, hdc); - int logPPIPrinterX = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSX); - int logPPIPrinterY = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSY); + int logPPIPrinterX = ::GetDeviceCaps((HDC) impl->GetHDC(), LOGPIXELSX); + int logPPIPrinterY = ::GetDeviceCaps((HDC) impl->GetHDC(), LOGPIXELSY); if (logPPIPrinterX == 0 || logPPIPrinterY == 0) { delete dc; @@ -179,12 +182,12 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt #if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__GNUWIN32__) || defined(__SALFORDC__) || !defined(__WIN32__) #ifdef STRICT - ::SetAbortProc((HDC) dc->GetHDC(), (ABORTPROC) m_lpAbortProc); + ::SetAbortProc((HDC) impl->GetHDC(), (ABORTPROC) m_lpAbortProc); #else - ::SetAbortProc((HDC) dc->GetHDC(), (FARPROC) m_lpAbortProc); + ::SetAbortProc((HDC) impl->GetHDC(), (FARPROC) m_lpAbortProc); #endif #else - ::SetAbortProc((HDC) dc->GetHDC(), (int (_stdcall *) + ::SetAbortProc((HDC) impl->GetHDC(), (int (_stdcall *) // cast it to right type only if required // FIXME it's really cdecl and we're casting it to stdcall - either there is // something I don't understand or it will crash at first usage @@ -370,9 +373,10 @@ void wxWindowsPrintPreview::DetermineScaling() wxRect paperRect; - if ( printerDC.Ok() ) + if ( printerDC.IsOk() ) { - HDC dc = GetHdcOf(printerDC); + wxPrinterDCImpl *impl = (wxPrinterDCImpl*) printerDC.GetImpl(); + HDC dc = GetHdcOf(*impl); printerWidthMM = ::GetDeviceCaps(dc, HORZSIZE); printerHeightMM = ::GetDeviceCaps(dc, VERTSIZE); printerXRes = ::GetDeviceCaps(dc, HORZRES); diff --git a/src/msw/renderer.cpp b/src/msw/renderer.cpp index 285dfabbd1..cbbd2a406a 100644 --- a/src/msw/renderer.cpp +++ b/src/msw/renderer.cpp @@ -227,7 +227,7 @@ wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win), if ( flags & wxCONTROL_PRESSED ) style |= DFCS_PUSHED | DFCS_FLAT; - ::DrawFrameControl(GetHdcOf(dc), &r, DFC_SCROLL, style); + ::DrawFrameControl(GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), &r, DFC_SCROLL, style); } void @@ -251,7 +251,7 @@ wxRendererMSW::DrawCheckBox(wxWindow * WXUNUSED(win), if ( flags & wxCONTROL_CURRENT ) style |= DFCS_HOT; - ::DrawFrameControl(GetHdcOf(dc), &r, DFC_BUTTON, style); + ::DrawFrameControl(GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), &r, DFC_BUTTON, style); } void @@ -280,7 +280,7 @@ wxRendererMSW::DrawPushButton(wxWindow * WXUNUSED(win), RECT rc; wxCopyRectToRECT(rect, rc); - ::DrawFrameControl(GetHdcOf(dc), &rc, DFC_BUTTON, style); + ::DrawFrameControl(GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), &rc, DFC_BUTTON, style); } void wxRendererMSW::DrawFocusRect(wxWindow * WXUNUSED(win), @@ -291,7 +291,7 @@ void wxRendererMSW::DrawFocusRect(wxWindow * WXUNUSED(win), RECT rc; wxCopyRectToRECT(rect, rc); - ::DrawFocusRect(GetHdcOf(dc), &rc); + ::DrawFocusRect(GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), &rc); } int wxRendererMSW::GetHeaderButtonHeight(wxWindow * WXUNUSED(win)) @@ -363,7 +363,7 @@ wxRendererXP::DrawComboBoxDropButton(wxWindow * win, wxUxThemeEngine::Get()->DrawThemeBackground ( hTheme, - GetHdcOf(dc), + GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), CP_DROPDOWNBUTTON, state, &r, @@ -399,7 +399,7 @@ wxRendererXP::DrawHeaderButton(wxWindow *win, wxUxThemeEngine::Get()->DrawThemeBackground ( hTheme, - GetHdcOf(dc), + GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), HP_HEADERITEM, state, &r, @@ -435,7 +435,7 @@ wxRendererXP::DrawTreeItemButton(wxWindow *win, wxUxThemeEngine::Get()->DrawThemeBackground ( hTheme, - GetHdcOf(dc), + GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), TVP_GLYPH, state, &r, @@ -485,7 +485,7 @@ wxRendererXP::DrawCheckBox(wxWindow *win, wxUxThemeEngine::Get()->DrawThemeBackground ( hTheme, - GetHdcOf(dc), + GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), BP_CHECKBOX, state, &r, @@ -524,7 +524,7 @@ wxRendererXP::DrawPushButton(wxWindow * win, wxUxThemeEngine::Get()->DrawThemeBackground ( hTheme, - GetHdcOf(dc), + GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())), BP_PUSHBUTTON, state, &r, diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index e568f4475d..ca30667415 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -363,7 +363,8 @@ void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc) // 3. this is backwards compatible behaviour and some people rely on it, // see http://groups.google.com/groups?selm=4252E932.3080801%40able.es wxWindow *parent = GetParent(); - HBRUSH hbr = (HBRUSH)parent->MSWGetBgBrush(dc.GetHDC(), GetHWND()); + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + HBRUSH hbr = (HBRUSH)parent->MSWGetBgBrush(impl->GetHDC(), GetHWND()); // if there is no special brush for painting this control, just use the // solid background colour @@ -374,12 +375,13 @@ void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc) hbr = GetHbrushOf(brush); } - ::FillRect(GetHdcOf(dc), &rc, hbr); + ::FillRect(GetHdcOf(*impl), &rc, hbr); } void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) { - MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(dc), 0); + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(*impl), 0); // when using XP themes, neither setting the text colour nor transparent // background mode doesn't change anything: the static box def window proc @@ -388,7 +390,7 @@ void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) if ( m_hasFgCol && wxUxThemeEngine::GetIfActive() ) { // draw over the text in default colour in our colour - HDC hdc = GetHdcOf(dc); + HDC hdc = GetHdcOf(*impl); ::SetTextColor(hdc, GetForegroundColour().GetPixel()); const bool rtl = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft; @@ -484,7 +486,8 @@ void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) // the label: this is consistent with the behaviour under pre-XP // systems (i.e. without visual themes) and generally makes sense wxBrush brush = wxBrush(GetBackgroundColour()); - ::FillRect(GetHdcOf(dc), &dimensions, GetHbrushOf(brush)); + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + ::FillRect(GetHdcOf(*impl), &dimensions, GetHbrushOf(brush)); } else // paint parent background { @@ -552,7 +555,8 @@ void wxStaticBox::OnPaint(wxPaintEvent& WXUNUSED(event)) // and also the box itself MSWGetRegionWithoutSelf((WXHRGN) hrgn, rc.right, rc.bottom); - HDCClipper clipToBg(GetHdcOf(dc), hrgn); + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + HDCClipper clipToBg(GetHdcOf(*impl), hrgn); // paint the inside of the box (excluding box itself and child controls) PaintBackground(dc, rc); diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index be1e998141..f8a827fbcf 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -44,6 +44,7 @@ #endif #include "wx/sysopt.h" +#include "wx/dcclient.h" #include "wx/msw/private.h" @@ -1543,7 +1544,11 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event) void wxToolBar::OnEraseBackground(wxEraseEvent& event) { RECT rect = wxGetClientRect(GetHwnd()); - HDC hdc = GetHdcOf((*event.GetDC())); + + wxDC *dc = event.GetDC(); + if (!dc) return; + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc->GetImpl(); + HDC hdc = GetHdcOf(*impl); int majorVersion, minorVersion; wxGetOsVersion(& majorVersion, & minorVersion); @@ -1775,8 +1780,9 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) r.right = clientSize.x; r.top = 0; r.bottom = clientSize.y; - - HRESULT hr = theme->DrawThemeBackground(hTheme, (HDC) dc.GetHDC(), 0, 0, & r, & clipRect); + + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + HRESULT hr = theme->DrawThemeBackground(hTheme, GetHdcOf(*impl), 0, 0, & r, & clipRect); if ( hr == S_OK ) haveRefreshed = true; } diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 25f5de9c7d..c4517a2a94 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -79,6 +79,7 @@ #endif #include "wx/msw/private.h" +#include "wx/msw/dcclient.h" #if wxUSE_TOOLTIPS #include "wx/tooltip.h" @@ -3430,9 +3431,10 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l wxUxThemeHandle hTheme((wxWindow *)this, L"EDIT"); RECT rcClient = { 0, 0, 0, 0 }; wxClientDC dc((wxWindow *)this); + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); if (theme->GetThemeBackgroundContentRect( - hTheme, GetHdcOf(dc), EP_EDITTEXT, ETS_NORMAL, + hTheme, GetHdcOf(*impl), EP_EDITTEXT, ETS_NORMAL, &rect, &rcClient) == S_OK) { InflateRect(&rcClient, -1, -1); @@ -3458,6 +3460,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l wxUxThemeHandle hTheme((wxWindow *)this, L"EDIT"); wxWindowDC dc((wxWindow *)this); + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); // Clip the DC so that you only draw on the non-client area RECT rcBorder; @@ -3465,16 +3468,16 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l RECT rcClient; theme->GetThemeBackgroundContentRect( - hTheme, GetHdcOf(dc), EP_EDITTEXT, ETS_NORMAL, &rcBorder, &rcClient); + hTheme, GetHdcOf(*impl), EP_EDITTEXT, ETS_NORMAL, &rcBorder, &rcClient); InflateRect(&rcClient, -1, -1); - ::ExcludeClipRect(GetHdcOf(dc), rcClient.left, rcClient.top, + ::ExcludeClipRect(GetHdcOf(*impl), rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); // Make sure the background is in a proper state if (theme->IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL)) { - theme->DrawThemeParentBackground(GetHwnd(), GetHdcOf(dc), &rcBorder); + theme->DrawThemeParentBackground(GetHwnd(), GetHdcOf(*impl), &rcBorder); } // Draw the border @@ -3486,7 +3489,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l // nState = ETS_READONLY; else nState = ETS_NORMAL; - theme->DrawThemeBackground(hTheme, GetHdcOf(dc), EP_EDITTEXT, nState, &rcBorder, NULL); + theme->DrawThemeBackground(hTheme, GetHdcOf(*impl), EP_EDITTEXT, nState, &rcBorder, NULL); } } break; @@ -4685,7 +4688,7 @@ void wxWindowMSW::OnPaint(wxPaintEvent& event) #ifdef __WXUNIVERSAL__ event.Skip(); #else - HDC hDC = (HDC) wxPaintDC::FindDCInCache((wxWindow*) event.GetEventObject()); + HDC hDC = (HDC) wxPaintDCImpl::FindDCInCache((wxWindow*) event.GetEventObject()); if (hDC != 0) { MSWDefWindowProc(WM_PAINT, (WPARAM) hDC, 0); @@ -4696,16 +4699,17 @@ void wxWindowMSW::OnPaint(wxPaintEvent& event) bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc) { wxDCTemp dc(hdc, GetClientSize()); + wxDCTempImpl *impl = (wxDCTempImpl*) dc.GetImpl(); - dc.SetHDC(hdc); - dc.SetWindow((wxWindow *)this); + impl->SetHDC(hdc); + impl->SetWindow((wxWindow *)this); wxEraseEvent event(m_windowId, &dc); event.SetEventObject(this); bool rc = HandleWindowEvent(event); // must be called manually as ~wxDC doesn't do anything for wxDCTemp - dc.SelectOldObjects(hdc); + impl->SelectOldObjects(hdc); return rc; } @@ -4729,9 +4733,12 @@ void wxWindowMSW::OnEraseBackground(wxEraseEvent& event) return; } + wxDC *dc = event.GetDC(); + if (!dc) return; + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc->GetImpl(); // do default background painting - if ( !DoEraseBackground(GetHdcOf(*event.GetDC())) ) + if ( !DoEraseBackground(GetHdcOf(*impl)) ) { // let the system paint the background event.Skip(); -- 2.45.2