+
+class wxVectorCanvas: public wxCanvas
+{
+public:
+ // constructors and destructors
+ wxVectorCanvas( wxCanvasAdmin* admin ,wxWindow *parent, wxWindowID id = -1,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxScrolledWindowStyle );
+
+ //scroll the window in device coordinates
+ virtual void ScrollWindow( int dx, int dy,
+ const wxRect* rect = (wxRect *) NULL );
+
+ //set if the Yaxis goes up or down
+ void SetYaxis(bool up) { m_yaxis=up; }
+
+ //get currently used Yaxis setting
+ virtual bool GetYaxis() { return m_yaxis; }
+
+ //to set the total area in world coordinates that can be scrolled.
+ // when totaly zoomed out (SetMappingScroll same size as given here),
+ // this will be the area displayed.
+ // To display all of a drawing, set this here to the boundingbox of the root group
+ // of the canvas.
+ void SetScroll(double vx1,double vy1,double vx2,double vy2);
+
+ //given the virtual size to be displayed, the mappingmatrix will be calculated
+ //in such a manner that it fits (same ratio in width and height) to the window size.
+ //The window size is used to intitialize the mapping.
+ //The virtual size is just an indication, it will be ajusted to fit in the client window ratio.
+ //When border is set an extra margin is added so that the drawing will fit nicely.
+ // To display all of a drawing, set this here to the boundingbox of the root group
+ // of the canvas.
+ void SetMappingScroll(double vx1,double vy1,double vx2,double vy2,bool border);
+
+ //matrix for calculating the virtual coordinate given a screen coordinate
+ wxTransformMatrix GetInverseMappingMatrix();
+
+ //matrix for calculating the screen coordinate given a virtual coordinate
+ wxTransformMatrix GetMappingMatrix();
+
+ //get minimum X of the visible part in world coordinates
+ virtual double GetMinX() const;
+ virtual double GetMinY() const;
+ virtual double GetMaxX() const;
+ virtual double GetMaxY() const;
+
+ //convert from window to virtual coordinates and back
+ virtual double DeviceToLogicalX(int x) const;
+ virtual double DeviceToLogicalY(int y) const;
+ virtual double DeviceToLogicalXRel(int x) const;
+ virtual double DeviceToLogicalYRel(int y) const;
+ virtual int LogicalToDeviceX(double x) const;
+ virtual int LogicalToDeviceY(double y) const;
+ virtual int LogicalToDeviceXRel(double x) const;
+ virtual int LogicalToDeviceYRel(double y) const;
+
+protected:
+ // up or down
+ bool m_yaxis;
+
+ // holds the matrix for mapping from virtual to screen coordinates
+ wxTransformMatrix m_mapping_matrix;
+
+ // holds the inverse of the mapping matrix
+ wxTransformMatrix m_inverse_mapping;
+
+ //virtual coordinates of total drawing
+ double m_virtm_minX, m_virtm_minY, m_virtm_maxX, m_virtm_maxY;
+
+ // virtual coordinates box
+ double m_virt_minX, m_virt_minY, m_virt_maxX, m_virt_maxY;
+
+ // bounding box
+ double m_minX, m_minY, m_maxX, m_maxY;
+
+ //are scroll bars active?
+ bool m_scrolled;
+
+private:
+ void OnScroll(wxScrollWinEvent& event);
+ void OnChar( wxKeyEvent &event );
+ void OnSize( wxSizeEvent &event );
+
+private:
+ DECLARE_CLASS(wxVectorCanvas)
+ DECLARE_EVENT_TABLE()
+};
+
+
+
+//:defenition
+//Contains a list of wxCanvas Objects that will be maintained through this class.
+//Each wxCanvasObject can be displayed on several wxCanvas Objects at the same time.
+//The active wxCanvas is used to render and convert coordinates from world to device.
+//So it is important to set the active wxCanvas based on the wxCanvas that has the focus
+//or is scrolled etc. This is normally done within wxCanvas when appropriate.
+class wxCanvasAdmin
+{
+public:
+ // constructors and destructors
+ wxCanvasAdmin();
+ virtual ~wxCanvasAdmin();
+
+ //convert from window to virtual coordinates
+ double DeviceToLogicalX(int x) const;
+ //convert from window to virtual coordinates
+ double DeviceToLogicalY(int y) const;
+ //convert from window to virtual coordinates relatif
+ double DeviceToLogicalXRel(int x) const;
+ //convert from window to virtual coordinates relatif
+ double DeviceToLogicalYRel(int y) const;
+ //convert from virtual to window coordinates
+ int LogicalToDeviceX(double x) const;
+ //convert from virtual to window coordinates
+ int LogicalToDeviceY(double y) const;
+ //convert from virtual to window coordinates relatif
+ int LogicalToDeviceXRel(double x) const;
+ //convert from virtual to window coordinates relatif
+ int LogicalToDeviceYRel(double y) const;
+
+ //update in the buffer off all canvases, the area given in world coordinates
+ virtual void Update(wxCanvasObject* obj, double x, double y, double width, double height);
+
+ //blit all updated areas now to the screen, else it will happen in idle time.
+ //Use this to support dragging for instance, becuase in such cases idle time
+ //will take to long.
+ virtual void UpdateNow();
+
+ //append another canvas
+ virtual void Append( wxCanvas* canvas );
+
+ //remove a canvas
+ virtual void Remove( wxCanvas* canvas );
+
+ //set the given canvas as active (for rendering, coordinate conversion etc.)
+ void SetActive(wxCanvas* activate);
+
+ //get active canvas
+ inline wxCanvas* GetActive() {return m_active;};
+
+private:
+ wxList m_canvaslist;
+ wxCanvas* m_active;
+};
+