+// ----------------------------------------------------------------------------
+// headers which we must include here
+// ----------------------------------------------------------------------------
+
+#include "wx/object.h" // the base class
+
+#include "wx/intl.h" // for wxLayoutDirection
+#include "wx/cursor.h" // we have member variables of these classes
+#include "wx/font.h" // so we can't do without them
+#include "wx/colour.h"
+#include "wx/bitmap.h" // for wxNullBitmap
+#include "wx/brush.h"
+#include "wx/pen.h"
+#include "wx/palette.h"
+#include "wx/list.h" // we use wxList in inline functions
+#include "wx/dynarray.h"
+#include "wx/math.h"
+
+ // 1 if using the reorganized DC code
+#define wxUSE_NEW_DC 0
+
+
+#if wxUSE_NEW_DC
+
+//-----------------------------------------------------------------------------
+// wxDCFactory
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_FWD_CORE wxImplDC;
+
+class WXDLLIMPEXP_CORE wxDCFactory
+{
+public:
+ wxDCFactory() {}
+ virtual ~wxDCFactory() {}
+
+ virtual wxImplDC* CreateWindowDC() = 0;
+ virtual wxImplDC* CreateWindowDC( wxWindow *window ) = 0;
+ virtual wxImplDC* CreateClientDC() = 0;
+ virtual wxImplDC* CreateClientDC( wxWindow *window ) = 0;
+ virtual wxImplDC* CreatePaintDC() = 0;
+ virtual wxImplDC* CreatePaintDC( wxWindow *window ) = 0;
+ virtual wxImplDC* CreateMemoryDC() = 0;
+ virtual wxImplDC* CreateMemoryDC( wxBitmap &bitmap ) = 0;
+ virtual wxImplDC* CreateMemoryDC( wxDC *dc ) = 0;
+
+ static void SetDCFactory( wxDCFactory *factory );
+ static wxDCFactory *GetFactory();
+private:
+ static wxDCFactory *m_factory;
+};
+
+//-----------------------------------------------------------------------------
+// wxNativeDCFactory
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxDCFactory
+{
+public:
+ wxNativeDCFactory() {}
+
+ virtual wxImplDC* CreateWindowDC();
+ virtual wxImplDC* CreateWindowDC( wxWindow *window );
+ virtual wxImplDC* CreateClientDC();
+ virtual wxImplDC* CreateClientDC( wxWindow *window );
+ virtual wxImplDC* CreatePaintDC();
+ virtual wxImplDC* CreatePaintDC( wxWindow *window );
+ virtual wxImplDC* CreateMemoryDC();
+ virtual wxImplDC* CreateMemoryDC( wxBitmap &bitmap );
+ virtual wxImplDC* CreateMemoryDC( wxDC *dc );
+};
+
+//-----------------------------------------------------------------------------
+// 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)
+};
+
+//-----------------------------------------------------------------------------
+// wxMemoryDC
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxMemoryDC: public wxDC
+{
+public:
+ wxMemoryDC();
+ wxMemoryDC( wxBitmap& bitmap );
+ wxMemoryDC( wxDC *dc );
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxMemoryDC)
+};
+
+//-----------------------------------------------------------------------------
+// wxPaintDC
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxPaintDC : public wxDC
+{
+public:
+ wxPaintDC();
+ wxPaintDC( wxWindow *win );
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxPaintDC)
+};
+
+//-----------------------------------------------------------------------------
+// wxImplDC
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxImplDC: public wxObject
+{
+public:
+ wxImplDC( wxDC *owner );
+ ~wxImplDC();
+
+ wxDC *GetOwner() { return m_owner; }
+
+ virtual bool IsOk() const { return m_ok; }
+
+ // query capabilities
+
+ virtual bool CanDrawBitmap() const = 0;
+ virtual bool CanGetTextExtent() const = 0;
+
+ // query dimension, colour deps, resolution
+
+ virtual void DoGetSize(int *width, int *height) const = 0;
+ virtual void DoGetSizeMM(int* width, int* height) const = 0;
+
+ virtual int GetDepth() const = 0;
+ virtual wxSize GetPPI() const = 0;
+
+ // Right-To-Left (RTL) modes
+
+ virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { }
+ virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; }
+
+ // page and document
+
+ virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
+ virtual void EndDoc() { }
+
+ virtual void StartPage() { }
+ virtual void EndPage() { }
+
+ // 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;
+ }
+
+ wxCoord MinX() const { return m_minX; }
+ wxCoord MaxX() const { return m_maxX; }
+ wxCoord MinY() const { return m_minY; }
+ wxCoord MaxY() const { return m_maxY; }
+
+ // setters and getters
+
+ virtual void SetFont(const wxFont& font) = 0;
+ virtual const wxFont& GetFont() const { return m_font; }
+
+ virtual void SetPen(const wxPen& pen) = 0;
+ virtual const wxPen& GetPen() const { return m_pen; }
+
+ virtual void SetBrush(const wxBrush& brush) = 0;
+ virtual const wxBrush& GetBrush() const { return m_brush; }
+
+ virtual void SetBackground(const wxBrush& brush) = 0;
+ virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
+
+ virtual void SetBackgroundMode(int mode) = 0;
+ virtual int GetBackgroundMode() const { return m_backgroundMode; }
+
+ virtual void SetTextForeground(const wxColour& colour)
+ { m_textForegroundColour = colour; }
+ virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
+
+ virtual void SetTextBackground(const wxColour& colour)
+ { m_textBackgroundColour = colour; }
+ virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
+
+#if wxUSE_PALETTE
+ virtual void SetPalette(const wxPalette& palette) = 0;
+#endif // wxUSE_PALETTE
+
+ // logical functions
+
+ virtual void SetLogicalFunction(int function) = 0;
+ virtual int GetLogicalFunction() const { return m_logicalFunction; }
+
+ // text measurement
+
+ virtual wxCoord GetCharHeight() const = 0;
+ virtual wxCoord GetCharWidth() const = 0;
+ virtual void DoGetTextExtent(const wxString& string,
+ wxCoord *x, wxCoord *y,
+ wxCoord *descent = NULL,
+ wxCoord *externalLeading = NULL,
+ const wxFont *theFont = NULL) const = 0;
+ virtual void GetMultiLineTextExtent(const wxString& string,
+ wxCoord *width,
+ wxCoord *height,
+ wxCoord *heightLine = NULL,
+ const wxFont *font = NULL) const;
+ virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
+
+ // clearing
+
+ virtual void Clear() = 0;
+
+ // clipping
+
+ virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
+ wxCoord width, wxCoord height) = 0;
+ virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 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 DestroyClippingRegion() { ResetClipping(); }
+
+
+ // 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);
+ virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
+ {
+ if ( x ) *x = m_logicalOriginX;
+ if ( y ) *y = m_logicalOriginY;
+ }
+
+ virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
+ virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
+ {
+ if ( x ) *x = m_deviceOriginX;
+ if ( y ) *y = m_deviceOriginY;
+ }
+
+ virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
+
+ virtual void ComputeScaleAndOrigin();
+
+ // this needs to overidden if the axis is inverted
+ virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
+
+ // ---------------------------------------------------------
+ // the actual drawing API
+
+ 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 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);
+
+
+
+#if wxUSE_SPLINES
+ virtual void DoDrawSpline(wxList *points);