]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/graphics.h
Added wxBackingFile and wxBackedInputStream.
[wxWidgets.git] / include / wx / graphics.h
index 9f4abde1adcf2468e62814cd263b4cf278030a6a..e47ba09df8b84390bf8070bdaf0ccdc4fb39c736 100755 (executable)
 #ifndef _WX_GRAPHICS_H_
 #define _WX_GRAPHICS_H_
 
-#if wxMAC_USE_CORE_GRAPHICS
-#undef wxUSE_GRAPHICS_CONTEXT
-#define wxUSE_GRAPHICS_CONTEXT 1
-#endif
-
-#ifndef wxUSE_GRAPHICS_CONTEXT
-#define wxUSE_GRAPHICS_CONTEXT 0
-#endif
-
 #if wxUSE_GRAPHICS_CONTEXT
 
-// ---------------------------------------------------------------------------
-// macros
-// ---------------------------------------------------------------------------
-
 #include "wx/geometry.h"
-#include "wx/dcclient.h"
 #include "wx/dynarray.h"
 
+class WXDLLEXPORT wxWindowDC;
+
 /*
  * notes about the graphics context apis
  *
@@ -38,7 +26,7 @@
  * in direction of positive y axis.
  */
  
-class WXDLLEXPORT wxGraphicsPath
+class WXDLLEXPORT wxGraphicsPath : public wxObject
 {
 public :
     wxGraphicsPath() {}
@@ -94,32 +82,96 @@ public :
     void AddCurveToPoint( const wxPoint2DDouble& c1, const wxPoint2DDouble& c2, const wxPoint2DDouble& e);
 
     void AddArc( const wxPoint2DDouble& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise);
+       
+       // returns the native path
+       virtual void * GetNativePath() const = 0;
+       
+       // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
+       virtual void UnGetNativePath(void *p) = 0;
 
     DECLARE_NO_COPY_CLASS(wxGraphicsPath)
+    DECLARE_ABSTRACT_CLASS(wxGraphicsPath)
 };
 
-class WXDLLEXPORT wxGraphicsContext
+/*
+class WXDLLEXPORT wxGraphicsMatrix
+{
+public :
+       wxGraphicsMatrix() {}
+       
+       virtual ~wxGraphicsMatrix() {}
+       
+       wxGraphicsMatrix* Concat( const wxGraphicsMatrix *t ) const;
+       
+       // returns the inverse matrix
+       wxGraphicsMatrix* Invert() const;
+       
+       // returns true if the elements of the transformation matrix are equal ?
+    bool operator==(const wxGraphicsMatrix& t) const;
+       
+       // return true if this is the identity matrix
+       bool IsIdentity();
+       
+    //
+    // transformation
+    //
+    
+    // translate
+    virtual void Translate( wxDouble dx , wxDouble dy ) = 0;
+
+    // scale
+    virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0;
+
+    // rotate (radians)
+    virtual void Rotate( wxDouble angle ) = 0; 
+} ;
+*/
+
+class WXDLLEXPORT wxGraphicsContext : public wxObject
 {
 public:
     wxGraphicsContext() {}
+
     virtual ~wxGraphicsContext() {}
     
     static wxGraphicsContext* Create( const wxWindowDC& dc) ;
+       
+    static wxGraphicsContext* CreateFromNative( void * context ) ;
+
+#ifdef __WXMAC__
+    static wxGraphicsContext* CreateFromNativeWindow( void * window ) ;
+#endif
+    static wxGraphicsContext* Create( wxWindow* window ) ;
 
     // creates a path instance that corresponds to the type of graphics context, ie GDIPlus, cairo, CoreGraphics ...
     virtual wxGraphicsPath * CreatePath() = 0;
-
+       
+       /*
+       // create a 'native' matrix corresponding to these values
+       virtual wxGraphicsMatrix* CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, 
+               wxDouble tx=0.0, wxDouble ty=0.0) = 0;
+       */
+       
     // push the current state of the context, ie the transformation matrix on a stack
     virtual void PushState() = 0;
 
     // pops a stored state from the stack
     virtual void PopState() = 0;
 
-    // clips drawings to the region
+    // clips drawings to the region, combined to current clipping region
     virtual void Clip( const wxRegion &region ) = 0;
 
+    // clips drawings to the rect
+    virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0;
+       
+       // resets the clipping to original extent
+       virtual void ResetClip() = 0 ;
+
+       // returns the native context
+       virtual void * GetNativeContext() = 0;
+
     //
-    // transformation
+    // transformation : changes the current transformation matrix CTM of the context
     //
     
     // translate
@@ -164,7 +216,7 @@ public:
 
     // draws a path by first filling and then stroking
     virtual void DrawPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE );
-
+       
     //
     // text
     //
@@ -214,151 +266,9 @@ public:
      // wrappers using wxPoint2DDouble TODO
 
     DECLARE_NO_COPY_CLASS(wxGraphicsContext)
+    DECLARE_ABSTRACT_CLASS(wxGraphicsContext)
 };
 
-class WXDLLEXPORT wxGCDC: public wxDC
-{
-    DECLARE_DYNAMIC_CLASS(wxGCDC)
-    DECLARE_NO_COPY_CLASS(wxGCDC)
-
-public:
-    wxGCDC(const wxWindowDC& dc);
-    wxGCDC();
-    virtual ~wxGCDC();
-
-    void Init();
-
-
-    // implement base class pure virtuals
-    // ----------------------------------
-
-    virtual void Clear();
-
-    virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
-    virtual void EndDoc(void) {}
-
-    virtual void StartPage(void) {}
-    virtual void EndPage(void) {}
-
-    virtual void SetFont(const wxFont& font);
-    virtual void SetPen(const wxPen& pen);
-    virtual void SetBrush(const wxBrush& brush);
-    virtual void SetBackground(const wxBrush& brush);
-    virtual void SetBackgroundMode(int mode);
-    virtual void SetPalette(const wxPalette& palette);
-
-    virtual void DestroyClippingRegion();
-
-    virtual wxCoord GetCharHeight() const;
-    virtual wxCoord GetCharWidth() const;
-
-    virtual bool CanDrawBitmap() const;
-    virtual bool CanGetTextExtent() const;
-    virtual int GetDepth() const;
-    virtual wxSize GetPPI() const;
-
-    virtual void SetMapMode(int mode);
-    virtual void SetUserScale(double x, double y);
-
-    virtual void SetLogicalScale(double x, double y);
-    virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
-    virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
-    virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
-    virtual void SetLogicalFunction(int function);
-
-    virtual void SetTextForeground(const wxColour& colour);
-    virtual void SetTextBackground(const wxColour& colour);
-
-    virtual void ComputeScaleAndOrigin();
-
-    wxGraphicsContext* GetGraphicContext() { return m_graphicContext; }
-
-protected:
-    // the true implementations
-    virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
-        int style = wxFLOOD_SURFACE);
-
-    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;
-
-    virtual void DoDrawPoint(wxCoord x, wxCoord y);
-
-#if wxUSE_SPLINES
-    virtual void DoDrawSpline(wxList *points);
-#endif
-
-    virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
-
-    virtual void DoDrawArc(wxCoord x1, wxCoord y1,
-        wxCoord x2, wxCoord y2,
-        wxCoord xc, wxCoord yc);
-
-    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);
-
-    virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
-    virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
-        wxCoord width, wxCoord height,
-        double radius);
-    virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
-
-    virtual void DoCrossHair(wxCoord x, wxCoord y);
-
-    virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
-    virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
-        bool useMask = false);
-
-    virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
-    virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
-        double angle);
-
-    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 = -1, wxCoord ysrcMask = -1);
-
-    virtual void DoGetSize(int *,int *) const;
-    virtual void DoGetSizeMM(int* width, int* height) const;
-
-    virtual void DoDrawLines(int n, wxPoint points[],
-        wxCoord xoffset, wxCoord yoffset);
-    virtual void DoDrawPolygon(int n, wxPoint points[],
-        wxCoord xoffset, wxCoord yoffset,
-        int fillStyle = wxODDEVEN_RULE);
-    virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
-        wxCoord xoffset, wxCoord yoffset,
-        int fillStyle);
-
-    virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
-    virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
-        wxCoord width, wxCoord height);
-
-    virtual void DoGetTextExtent(const wxString& string,
-        wxCoord *x, wxCoord *y,
-        wxCoord *descent = NULL,
-        wxCoord *externalLeading = NULL,
-        wxFont *theFont = NULL) const;
-
-    virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
-
-protected:
-    // scaling variables
-    double       m_mm_to_pix_x, m_mm_to_pix_y;
-
-    wxGraphicsContext* m_graphicContext;
-};
 #endif
 
-#endif
-    // _WX_GRID_H_BASE_
+#endif // _WX_GRAPHICS_H_