]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/include/wx/canvas/canvas.h
change in XRC format
[wxWidgets.git] / contrib / include / wx / canvas / canvas.h
index d3a416e60e92efebdff184dd06346e255de4dbe1..f1255760b3d0c36027a102c77eb0a292dda0e322 100644 (file)
 
 #include "wx/image.h"
 #include "wx/txtstrm.h"
+#include "wx/geometry.h"
 
-class wxCanvas;
 
-// WDR: class declarations
+//----------------------------------------------------------------------------
+// decls
+//----------------------------------------------------------------------------
+
+#define IMAGE_CANVAS 0
+
+class wxCanvas;
 
 //----------------------------------------------------------------------------
 // wxCanvasObject
@@ -106,12 +112,12 @@ public:
     virtual bool IsHit( int x, int y, int margin );
     virtual wxCanvasObject* IsHitObject( int x, int y, int margin );
 
-    void ExtendArea(int x, int y);
+    void ExtendArea(double x, double y);
 
-    inline int  GetXMin()     { return m_minx; }
-    inline int  GetYMin()     { return m_miny; }
-    inline int  GetXMax()     { return m_maxx; }
-    inline int  GetYMax()     { return m_maxy; }
+    inline double  GetXMin()     { return m_minx; }
+    inline double  GetYMin()     { return m_miny; }
+    inline double  GetXMax()     { return m_maxx; }
+    inline double  GetYMax()     { return m_maxy; }
 
 protected:
     wxCanvas   *m_owner;
@@ -145,10 +151,10 @@ public:
     virtual bool IsHit( int x, int y, int margin );
     void Move( int x, int y );
 
-    inline int  GetPosX()          { return m_x; }
-    inline int  GetPosY()          { return m_y; }
+    inline double  GetPosX()          { return m_x; }
+    inline double  GetPosY()          { return m_y; }
 
-    void ExtendArea(int x, int y);
+    void ExtendArea(double x, double y);
     virtual wxCanvasObject* IsHitObject( int x, int y, int margin );
 
 protected:
@@ -168,6 +174,76 @@ protected:
 
 };
 
+//----------------------------------------------------------------------------
+// wxCanvasPolygon
+//----------------------------------------------------------------------------
+
+class wxCanvasPolygon: public wxCanvasObject
+{
+public:
+    wxCanvasPolygon( int n, wxPoint2DDouble points[] );
+    ~wxCanvasPolygon();
+    void SetBrush(wxBrush& brush)  { m_brush = brush; };
+    void SetPen(wxPen& pen)        { m_pen = pen; };
+
+    virtual void Recreate();
+
+    virtual void Render(int xabs, int yabs, int clip_x, int clip_y, int clip_width, int clip_height );
+    virtual void WriteSVG( wxTextOutputStream &stream );
+
+private:
+    void ExtendArea(double x, double y);
+
+    wxBrush       m_brush;
+    wxPen         m_pen;
+
+    int           m_n;
+    wxPoint2DDouble* m_points;
+
+    //bounding box
+    double        m_minx;
+    double        m_miny;
+    double        m_maxx;
+    double        m_maxy;
+    bool          m_validbounds;
+
+};
+
+//----------------------------------------------------------------------------
+// wxCanvasPolyline
+//----------------------------------------------------------------------------
+
+class wxCanvasPolyline: public wxCanvasObject
+{
+public:
+    wxCanvasPolyline(int n, wxPoint2DDouble points[]);
+    ~wxCanvasPolyline();
+    void SetPen(wxPen& pen)    { m_pen = pen; };
+
+    virtual void Recreate();
+
+    virtual void Render(int xabs, int yabs, int clip_x, int clip_y, int clip_width, int clip_height );
+    virtual void WriteSVG( wxTextOutputStream &stream );
+
+private:
+    void ExtendArea(double x, double y);
+
+    wxPen         m_pen;
+
+    int           m_n;
+    wxPoint2DDouble* m_points;
+
+    //bounding box
+    double        m_minx;
+    double        m_miny;
+    double        m_maxx;
+    double        m_maxy;
+    bool          m_validbounds;
+
+};
+
+
+
 //----------------------------------------------------------------------------
 // wxCanvasRect
 //----------------------------------------------------------------------------
@@ -175,8 +251,9 @@ protected:
 class wxCanvasRect: public wxCanvasObject
 {
 public:
-    wxCanvasRect( double x, double y, double w, double h,
-                  unsigned char red, unsigned char green, unsigned char blue );
+    wxCanvasRect( double x, double y, double w, double h );
+    void SetBrush(wxBrush& brush)  { m_brush = brush; };
+    void SetPen(wxPen& pen)        { m_pen = pen; };
 
     virtual void Recreate();
 
@@ -184,14 +261,13 @@ public:
     virtual void WriteSVG( wxTextOutputStream &stream );
 
 private:
+    wxPen         m_pen;
+    wxBrush       m_brush;
+
     double        m_x;
     double        m_y;
     double        m_width;
     double        m_height;
-
-    unsigned char m_red;
-    unsigned char m_green;
-    unsigned char m_blue;
 };
 
 //----------------------------------------------------------------------------
@@ -201,8 +277,8 @@ private:
 class wxCanvasLine: public wxCanvasObject
 {
 public:
-    wxCanvasLine( double x1, double y1, double x2, double y2,
-                  unsigned char red, unsigned char green, unsigned char blue );
+    wxCanvasLine( double x1, double y1, double x2, double y2 );
+    void SetPen(wxPen& pen)    { m_pen = pen; };
 
     virtual void Recreate();
 
@@ -210,14 +286,12 @@ public:
     virtual void WriteSVG( wxTextOutputStream &stream );
     
 private:
+    wxPen         m_pen;
+
     double        m_x1;
     double        m_y1;
     double        m_x2;
     double        m_y2;
-
-    unsigned char m_red;
-    unsigned char m_green;
-    unsigned char m_blue;
 };
 
 //----------------------------------------------------------------------------
@@ -241,7 +315,11 @@ private:
     double      m_height;
     
     wxImage     m_image;
+#if IMAGE_CANVAS
     wxImage     m_tmp;
+#else
+    wxBitmap    m_tmp;
+#endif
 };
 
 //----------------------------------------------------------------------------
@@ -331,7 +409,12 @@ public:
     // ... and call this to tell all objets to recreate then
     virtual void Recreate();
 
+#if IMAGE_CANVAS
     inline wxImage *GetBuffer()  { return &m_buffer; }
+#else
+    inline wxBitmap *GetBuffer() { return &m_buffer; }
+    inline wxMemoryDC *GetDC()   { return m_renderDC; }
+#endif
     inline int GetBufferX()      { return m_bufferX; }
     inline int GetBufferY()      { return m_bufferY; }
     inline int GetBufferWidth()  { return m_buffer.GetWidth(); }
@@ -348,7 +431,12 @@ public:
                                const wxRect* rect = (wxRect *) NULL );
 
 private:
+#if IMAGE_CANVAS
     wxImage          m_buffer;
+#else
+    wxBitmap         m_buffer;
+    wxMemoryDC      *m_renderDC;
+#endif
     int              m_bufferX;
     int              m_bufferY;
     bool             m_needUpdate;
@@ -357,9 +445,10 @@ private:
 
     unsigned char    m_green,m_red,m_blue;
     bool             m_frozen;
-    bool             m_requestNewBuffer;
     wxCanvasObject  *m_lastMouse;
     wxCanvasObject  *m_captureMouse;
+    
+    int              m_oldDeviceX,m_oldDeviceY;
 
     friend class wxCanvasObject;