#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
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;
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:
};
+//----------------------------------------------------------------------------
+// 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
//----------------------------------------------------------------------------
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();
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;
};
//----------------------------------------------------------------------------
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();
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;
};
//----------------------------------------------------------------------------
double m_height;
wxImage m_image;
+#if IMAGE_CANVAS
wxImage m_tmp;
+#else
+ wxBitmap m_tmp;
+#endif
};
//----------------------------------------------------------------------------
// ... 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(); }
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;
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;