+#include "wx/dynarray.h"
+#include "wx/math.h"
+#include "wx/image.h"
+#include "wx/region.h"
+#include "wx/affinematrix2d.h"
+
+#define wxUSE_NEW_DC 1
+
+class WXDLLIMPEXP_FWD_CORE wxDC;
+class WXDLLIMPEXP_FWD_CORE wxClientDC;
+class WXDLLIMPEXP_FWD_CORE wxPaintDC;
+class WXDLLIMPEXP_FWD_CORE wxWindowDC;
+class WXDLLIMPEXP_FWD_CORE wxScreenDC;
+class WXDLLIMPEXP_FWD_CORE wxMemoryDC;
+class WXDLLIMPEXP_FWD_CORE wxPrinterDC;
+class WXDLLIMPEXP_FWD_CORE wxPrintData;
+
+#if wxUSE_GRAPHICS_CONTEXT
+class WXDLLIMPEXP_FWD_CORE wxGraphicsContext;
+#endif
+
+// Logical ops
+enum wxRasterOperationMode
+{
+ wxCLEAR, // 0
+ wxXOR, // src XOR dst
+ wxINVERT, // NOT dst
+ wxOR_REVERSE, // src OR (NOT dst)
+ wxAND_REVERSE, // src AND (NOT dst)
+ wxCOPY, // src
+ wxAND, // src AND dst
+ wxAND_INVERT, // (NOT src) AND dst
+ wxNO_OP, // dst
+ wxNOR, // (NOT src) AND (NOT dst)
+ wxEQUIV, // (NOT src) XOR dst
+ wxSRC_INVERT, // (NOT src)
+ wxOR_INVERT, // (NOT src) OR dst
+ wxNAND, // (NOT src) OR (NOT dst)
+ wxOR, // src OR dst
+ wxSET // 1
+#if WXWIN_COMPATIBILITY_2_8
+ ,wxROP_BLACK = wxCLEAR,
+ wxBLIT_BLACKNESS = wxCLEAR,
+ wxROP_XORPEN = wxXOR,
+ wxBLIT_SRCINVERT = wxXOR,
+ wxROP_NOT = wxINVERT,
+ wxBLIT_DSTINVERT = wxINVERT,
+ wxROP_MERGEPENNOT = wxOR_REVERSE,
+ wxBLIT_00DD0228 = wxOR_REVERSE,
+ wxROP_MASKPENNOT = wxAND_REVERSE,
+ wxBLIT_SRCERASE = wxAND_REVERSE,
+ wxROP_COPYPEN = wxCOPY,
+ wxBLIT_SRCCOPY = wxCOPY,
+ wxROP_MASKPEN = wxAND,
+ wxBLIT_SRCAND = wxAND,
+ wxROP_MASKNOTPEN = wxAND_INVERT,
+ wxBLIT_00220326 = wxAND_INVERT,
+ wxROP_NOP = wxNO_OP,
+ wxBLIT_00AA0029 = wxNO_OP,
+ wxROP_NOTMERGEPEN = wxNOR,
+ wxBLIT_NOTSRCERASE = wxNOR,
+ wxROP_NOTXORPEN = wxEQUIV,
+ wxBLIT_00990066 = wxEQUIV,
+ wxROP_NOTCOPYPEN = wxSRC_INVERT,
+ wxBLIT_NOTSCRCOPY = wxSRC_INVERT,
+ wxROP_MERGENOTPEN = wxOR_INVERT,
+ wxBLIT_MERGEPAINT = wxOR_INVERT,
+ wxROP_NOTMASKPEN = wxNAND,
+ wxBLIT_007700E6 = wxNAND,
+ wxROP_MERGEPEN = wxOR,
+ wxBLIT_SRCPAINT = wxOR,
+ wxROP_WHITE = wxSET,
+ wxBLIT_WHITENESS = wxSET
+#endif //WXWIN_COMPATIBILITY_2_8
+};
+
+// Flood styles
+enum wxFloodFillStyle
+{
+ wxFLOOD_SURFACE = 1,
+ wxFLOOD_BORDER
+};
+
+// Mapping modes
+enum wxMappingMode
+{
+ wxMM_TEXT = 1,
+ wxMM_METRIC,
+ wxMM_LOMETRIC,
+ wxMM_TWIPS,
+ wxMM_POINTS
+};
+
+// Description of text characteristics.
+struct wxFontMetrics
+{
+ wxFontMetrics()
+ {
+ height =
+ ascent =
+ descent =
+ internalLeading =
+ externalLeading =
+ averageWidth = 0;
+ }
+
+ int height, // Total character height.
+ ascent, // Part of the height above the baseline.
+ descent, // Part of the height below the baseline.
+ internalLeading, // Intra-line spacing.
+ externalLeading, // Inter-line spacing.
+ averageWidth; // Average font width, a.k.a. "x-width".
+};
+
+#if WXWIN_COMPATIBILITY_2_8
+
+//-----------------------------------------------------------------------------
+// wxDrawObject helper class
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxDrawObject
+{
+public:
+ wxDEPRECATED_CONSTRUCTOR(wxDrawObject)()
+ : m_isBBoxValid(false)
+ , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
+ { }
+
+ virtual ~wxDrawObject() { }
+
+ virtual void Draw(wxDC&) const { }
+
+ 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; }
+
+ //to define the type of object for derived objects
+ virtual int GetType()=0;
+
+protected:
+ //for boundingbox calculation
+ bool m_isBBoxValid:1;
+ //for boundingbox calculation
+ wxCoord m_minX, m_minY, m_maxX, m_maxY;
+};
+
+#endif // WXWIN_COMPATIBILITY_2_8
+
+
+//-----------------------------------------------------------------------------
+// wxDCFactory
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_FWD_CORE wxDCImpl;
+
+class WXDLLIMPEXP_CORE wxDCFactory
+{
+public:
+ wxDCFactory() {}
+ virtual ~wxDCFactory() {}
+
+ virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0;
+ virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 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;
+#if wxUSE_PRINTING_ARCHITECTURE
+ virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) = 0;
+#endif
+
+ static void Set(wxDCFactory *factory);
+ static wxDCFactory *Get();
+
+private:
+ static wxDCFactory *m_factory;
+};
+
+//-----------------------------------------------------------------------------
+// wxNativeDCFactory
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory
+{
+public:
+ wxNativeDCFactory() {}
+
+ virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window );
+ virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window );
+ 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 );
+#if wxUSE_PRINTING_ARCHITECTURE
+ virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data );
+#endif
+};
+
+//-----------------------------------------------------------------------------
+// wxDCImpl
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxDCImpl: public wxObject
+{
+public:
+ wxDCImpl( wxDC *owner );
+ virtual ~wxDCImpl();
+
+ wxDC *GetOwner() const { return m_owner; }
+
+ wxWindow* GetWindow() const { return m_window; }
+
+ virtual bool IsOk() const { return m_ok; }
+
+ // query capabilities
+
+ virtual bool CanDrawBitmap() const = 0;
+ virtual bool CanGetTextExtent() const = 0;
+
+ // get Cairo context
+ virtual void* GetCairoContext() const
+ {
+ return NULL;
+ }
+
+ virtual void* GetHandle() const { return NULL; }
+
+ // query dimension, colour deps, resolution
+
+ virtual void DoGetSize(int *width, int *height) const = 0;
+ void GetSize(int *width, int *height) const
+ {
+ DoGetSize(width, height);
+ return ;
+ }
+
+ wxSize GetSize() const
+ {
+ int w, h;
+ DoGetSize(&w, &h);
+ return wxSize(w, h);
+ }
+
+ 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() { }
+
+ // flushing the content of this dc immediately eg onto screen
+ virtual void Flush() { }
+
+ // 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
+
+ // inherit the DC attributes (font and colours) from the given window
+ //
+ // this is called automatically when a window, client or paint DC is
+ // created
+ virtual void InheritAttributes(wxWindow *win);
+
+
+ // logical functions
+
+ virtual void SetLogicalFunction(wxRasterOperationMode function) = 0;
+ virtual wxRasterOperationMode GetLogicalFunction() const
+ { return m_logicalFunction; }
+
+ // text measurement
+
+ virtual wxCoord GetCharHeight() const = 0;
+ virtual wxCoord GetCharWidth() const = 0;
+
+ // The derived classes should really override DoGetFontMetrics() to return
+ // the correct values in the future but for now provide a default
+ // implementation in terms of DoGetTextExtent() to avoid breaking the
+ // compilation of all other ports as wxMSW is the only one to implement it.
+ virtual void DoGetFontMetrics(int *height,
+ int *ascent,
+ int *descent,
+ int *internalLeading,
+ int *externalLeading,
+ int *averageWidth) const;
+
+ 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