- wxDCBase()
- : m_colour(wxColourDisplay())
- , m_ok(true)
- , m_clipping(false)
- , m_isInteractive(0)
- , m_isBBoxValid(false)
- , m_logicalOriginX(0), m_logicalOriginY(0)
- , m_deviceOriginX(0), m_deviceOriginY(0)
- , m_logicalScaleX(1.0), m_logicalScaleY(1.0)
- , m_userScaleX(1.0), m_userScaleY(1.0)
- , m_scaleX(1.0), m_scaleY(1.0)
- , m_signX(1), m_signY(1)
- , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
- , m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0)
- , m_logicalFunction(wxCOPY)
- , m_backgroundMode(wxTRANSPARENT)
- , m_mappingMode(wxMM_TEXT)
- , m_pen()
- , m_brush()
- , m_backgroundBrush(*wxTRANSPARENT_BRUSH)
- , m_textForegroundColour(*wxBLACK)
- , m_textBackgroundColour(*wxWHITE)
- , m_font()
+ 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;
+ }
+
+ // 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; }
+