1 /////////////////////////////////////////////////////////////////////////////
3 // Author: Robert Roebling
5 // Copyright: 2000 (c) Robert Roebling
6 // Licence: wxWindows Licence
7 /////////////////////////////////////////////////////////////////////////////
10 #define __WXCANVAS_H__
13 #pragma interface "canvas.cpp"
21 #include "wx/txtstrm.h"
22 #include "wx/geometry.h"
23 #include "wx/matrix.h"
27 //----------------------------------------------------------------------------
29 //----------------------------------------------------------------------------
34 //----------------------------------------------------------------------------
36 //----------------------------------------------------------------------------
45 // wxCanvasObject is the base class for Canvas Objects.
46 // All Objects for drawing one the canvas are derived from this class.
47 // It supports dragging and moving methods that can be used in derived
48 // classes for defining several ways of dragging.
49 // Also it is possible to plug in events handlers to do this for all derived classes at once.
51 // wxCanvasObjects have themselves as their event handlers by default,
52 // but their event handlers could be set to another object entirely. This
53 // separation can reduce the amount of derivation required, and allow
54 // alteration of a wxCanvasObject functionality
55 class wxCanvasObject
: public wxEvtHandler
61 //If the position (x,y) is within the object this return a pointer to the object
62 //Normally this function needs to be defined for each derived wxCanvasObject.
63 //The default is a simple bounding box test.
64 virtual wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
66 //render this object to the canvas (either on its buffer or directly on the canvas)
67 //this depends on the wxDC that is set for the active canvas.
68 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
70 //x position in world coordinates of the object
71 virtual double GetPosX()=0;
72 //y position in world coordinates of the object
73 virtual double GetPosY()=0;
75 //set position in world coordinates for the object
76 virtual void SetPosXY( double x
, double y
)=0;
78 //absolute moving the object to position x,y in world coordinates
79 //also does an update of the old and new area
80 virtual void MoveAbsolute( double x
, double y
);
82 //relative moving the object to position x,y in world coordinates
83 //also does an update of the old and new area
84 virtual void MoveRelative( double x
, double y
);
86 //relative translate the object to position x,y in world coordinates
87 //does NOT update the old and new area
88 //this function must be defined for each derived object,
89 //it is used internally for dragging and moving objects.
90 virtual void TransLate( double x
, double y
)=0;
92 //choose one of the three diffrenet drag methods |
93 //DRAG_RECTANGLE = as a rectangle when drag is in progress |
94 //DRAG_ONTOP = only redraw the object when dragging |
95 //DRAG_REDRAW = redraw the damaged areas when dragging
96 void SetDragMode(wxDRAG_MODE mode
) { m_dragmode
=mode
; };
99 wxDRAG_MODE
GetDragMode() { return m_dragmode
; };
101 //called when starting a drag
102 virtual void DragStart();
103 //called when dragging is in progress
104 virtual void DragRelative( double x
, double y
);
105 //called when dragging is ended
106 virtual void DragEnd();
108 //return the object if it is part of the given object or
109 //if the given object is part of a group within this object.
110 //For group objects this means recursively search for it.
111 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
113 //calculate the boundingbox in world coordinates
114 virtual void CalcBoundingBox()=0;
116 //write the object as SVG (scalable vector grafhics
117 virtual void WriteSVG( wxTextOutputStream
&stream
);
119 //get the administrator for the object,
120 //this will give access to the canvas's where it is displayed upon.
121 //It is used to render the object to the active canvas.
122 //Conversion from world to Device coordinates and visa versa is
123 //done using the Active canvas at that moment.
124 wxCanvasAdmin
*GetAdmin() { return m_admin
; }
126 //set the administrator
127 virtual void SetAdmin( wxCanvasAdmin
*admin
) { m_admin
= admin
; }
129 //is this a control type of canvas object
130 bool IsControl() { return m_isControl
; }
131 //is this a vector type of canvas object
132 bool IsVector() { return m_isVector
; }
133 //is this an Image type of canvas object
134 bool IsImage() { return m_isImage
; }
136 //get minimum X of the boundingbox in world coordinates
137 inline double GetXMin() { return m_bbox
.GetMinX(); }
138 //get minimum Y of the boundingbox in world coordinates
139 inline double GetYMin() { return m_bbox
.GetMinY(); }
140 //get maximum X of the boundingbox in world coordinates
141 inline double GetXMax() { return m_bbox
.GetMaxX(); }
142 //get maximum Y of the boundingbox in world coordinates
143 inline double GetYMax() { return m_bbox
.GetMaxY(); }
146 inline wxBoundingBox
GetBbox() { return m_bbox
; }
148 //redirect all mouse events for the canvas to this object
150 //release the mouse capture for this object
152 //is the mouse captured for this object
153 bool IsCapturedMouse();
155 //set if this object will visible (be rendered or not)
156 inline void SetVisible(bool visible
) { m_visible
=visible
; }
158 inline bool GetVisible() {return m_visible
; }
160 //can the object be dragged
161 inline void SetDraggable(bool drag
) { m_dragable
=drag
; }
162 //get if the object can be dragged
163 inline bool GetDraggable() {return m_dragable
; }
165 //get absolute area in the device coordinates where the object
166 //its boundingbox in world coordinates is first translated using the matrix.
167 wxRect
GetAbsoluteArea(const wxTransformMatrix
& cworld
);
169 //get currently used eventhandler (always the first in the list)
170 wxEvtHandler
*GetEventHandler() const { return m_eventHandler
; }
172 //process an event for the object, starting with the first eventhandler
174 bool ProcessCanvasObjectEvent(wxEvent
& event
);
176 // push/pop event handler: allows to chain a custom event handler to
177 // already existing ones
178 void PushEventHandler( wxEvtHandler
*handler
);
180 //remove first eventhandler in the list (one will be always stay in)
181 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
182 //append an eventhandler to the list, this event handler will be called
183 //if the other skipped the event to process.
184 void AppendEventHandler(wxEvtHandler
*handler
);
185 //remove last event handler in the list (one will always stay in)
186 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
190 //administator for rendering and accessing the canvas's
191 wxCanvasAdmin
* m_admin
;
193 //active event handler, default the object itself
194 wxEvtHandler
* m_eventHandler
;
201 wxDRAG_MODE m_dragmode
:3;
203 //boundingbox in world coordinates
204 wxBoundingBox m_bbox
;
211 // wxCanvasObjectGroup is a container for wxCanvas derived Objects.
212 // It renders itself by calling the render methods of the wxCanvasObjects it contains.
213 // It can have nested groups also, in the same way as the other wxCanvasObjects it already contains.
214 // The group has a matrix to position/rotate/scale the group.
215 class wxCanvasObjectGroup
: public wxCanvasObject
218 wxCanvasObjectGroup(double x
, double y
);
219 virtual ~wxCanvasObjectGroup();
221 void SetAdmin(wxCanvasAdmin
* admin
);
223 //prepend a wxCanvasObject to this group
224 virtual void Prepend( wxCanvasObject
* obj
);
225 //append a wxCanvasObject to this group
226 virtual void Append( wxCanvasObject
* obj
);
227 //insert a wxCanvasObject to this group
228 virtual void Insert( size_t before
, wxCanvasObject
* obj
);
229 //remove the given object from the group
230 virtual void Remove( wxCanvasObject
* obj
);
232 //those this group contain the given object.
233 //in case of nested groups also search in there to the lowwest level.
234 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
236 //returns index of the given wxCanvasObject in this group
237 virtual int IndexOf( wxCanvasObject
* obj
);
239 double GetPosX() { return lworld
.GetValue(2,0); }
240 double GetPosY() { return lworld
.GetValue(2,1); }
241 void SetPosXY( double x
, double y
) {lworld
.SetValue(2,0,x
);lworld
.SetValue(2,1,y
);CalcBoundingBox();};
243 void TransLate( double x
, double y
);
245 void CalcBoundingBox();
246 //remove all wxCanvasObjects from the group (flag for deletion of the objectsalso)
247 void DeleteContents( bool );
248 virtual void Render(wxTransformMatrix
* cworld
,int x
, int y
, int width
, int height
);
249 virtual void WriteSVG( wxTextOutputStream
&stream
);
251 //recursive call the IsHitWorld on all contained objects, the first
252 //one that is hit will be returned
253 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
255 //recursive calls for contained objects to set eventhandlers,
256 //and also sets its own eventhandler
257 void PushEventHandler( wxEvtHandler
*handler
);
258 //recursive calls for contained objects to set eventhandlers,
259 //and also sets its own eventhandler
260 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
261 //recursive calls for contained objects to set eventhandlers,
262 //and also sets its own eventhandler
263 void AppendEventHandler(wxEvtHandler
*handler
);
264 //recursive calls for contained objects to set eventhandlers,
265 //and also sets its own eventhandler
266 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
270 //to position the object
271 wxTransformMatrix lworld
;
275 friend class wxCanvas
;
279 // wxCanvasObjectRef is a reference to any wxCanvasObject derived class.
280 // It does not duplicate the referenced object.
281 // It has a matrix to reposition/rotate/scale the object it references.
282 // The position/matrix of the referenced Object is accumulated with the one here.
283 class wxCanvasObjectRef
: public wxCanvasObject
286 wxCanvasObjectRef(double x
, double y
,wxCanvasObject
* obj
);
288 //set rotation for the reference
289 void SetRotation(double rotation
);
291 //set scale in x and y ( > zero)
292 void SetScale( double scalex
, double scaley
);
294 void SetAdmin(wxCanvasAdmin
* admin
);
296 double GetPosX() { return lworld
.GetValue(2,0); }
297 double GetPosY() { return lworld
.GetValue(2,1); }
298 void SetPosXY( double x
, double y
) {lworld
.SetValue(2,0,x
);lworld
.SetValue(2,1,y
);CalcBoundingBox();};
300 void TransLate( double x
, double y
);
301 void CalcBoundingBox();
302 virtual void Render(wxTransformMatrix
* cworld
,int x
, int y
, int width
, int height
);
303 virtual void WriteSVG( wxTextOutputStream
&stream
);
305 //return this object if one of the objects it references is hit
306 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
307 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
309 //recursive calls for contained objects to set eventhandlers,
310 //and also sets its own eventhandler
311 void PushEventHandler( wxEvtHandler
*handler
);
312 //recursive calls for contained objects to set eventhandlers,
313 //and also sets its own eventhandler
314 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
315 //recursive calls for contained objects to set eventhandlers,
316 //and also sets its own eventhandler
317 void AppendEventHandler(wxEvtHandler
*handler
);
318 //recursive calls for contained objects to set eventhandlers,
319 //and also sets its own eventhandler
320 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
324 //to position the object
325 wxTransformMatrix lworld
;
327 //reference to another wxCanvasObject
328 wxCanvasObject
* m_obj
;
333 class wxCanvasRect
: public wxCanvasObject
336 wxCanvasRect( double x
, double y
, double w
, double h
, double radius
=0 );
337 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
338 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
340 double GetPosX() { return m_x
; }
341 double GetPosY() { return m_y
; }
342 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
344 void TransLate( double x
, double y
);
345 void CalcBoundingBox();
347 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
348 virtual void WriteSVG( wxTextOutputStream
&stream
);
361 //----------------------------------------------------------------------------
363 //----------------------------------------------------------------------------
364 class wxCanvasCircle
: public wxCanvasObject
367 wxCanvasCircle( double x
, double y
, double radius
);
368 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
369 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
371 double GetPosX() { return m_x
; }
372 double GetPosY() { return m_y
; }
373 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
375 void TransLate( double x
, double y
);
377 void CalcBoundingBox();
379 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
380 virtual void WriteSVG( wxTextOutputStream
&stream
);
382 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
395 class wxCanvasEllipse
: public wxCanvasObject
398 wxCanvasEllipse( double x
, double y
, double width
, double height
);
399 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
400 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
402 double GetPosX() { return m_x
; }
403 double GetPosY() { return m_y
; }
404 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
406 void TransLate( double x
, double y
);
408 void CalcBoundingBox();
410 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
411 virtual void WriteSVG( wxTextOutputStream
&stream
);
413 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
426 // wxCanvasEllipticArc
427 class wxCanvasEllipticArc
: public wxCanvasObject
430 wxCanvasEllipticArc( double x
, double y
, double width
, double height
, double start
, double end
);
431 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
432 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
434 double GetPosX() { return m_x
; }
435 double GetPosY() { return m_y
; }
436 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
438 void TransLate( double x
, double y
);
439 void CalcBoundingBox();
441 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
442 virtual void WriteSVG( wxTextOutputStream
&stream
);
444 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
460 class wxCanvasLine
: public wxCanvasObject
463 wxCanvasLine( double x1
, double y1
, double x2
, double y2
);
464 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
467 double GetPosX() { return m_x1
; }
468 double GetPosY() { return m_y1
; }
469 void SetPosXY( double x
, double y
) {m_x1
=x
; m_y1
=y
; CalcBoundingBox();};
471 void TransLate( double x
, double y
);
473 void CalcBoundingBox();
475 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
476 virtual void WriteSVG( wxTextOutputStream
&stream
);
478 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
491 class wxCanvasImage
: public wxCanvasObject
494 wxCanvasImage( const wxImage
&image
, double x
, double y
, double w
, double h
);
496 double GetPosX() { return m_x
; }
497 double GetPosY() { return m_y
; }
498 void SetPosXY( double x
, double y
);
500 void TransLate( double x
, double y
);
502 void CalcBoundingBox();
504 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
505 virtual void WriteSVG( wxTextOutputStream
&stream
);
524 //----------------------------------------------------------------------------
526 //----------------------------------------------------------------------------
528 class wxCanvasControl
: public wxCanvasObject
531 wxCanvasControl( wxWindow
*control
);
536 void SetPosXY( double x
, double y
);
538 void TransLate( double x
, double y
);
539 void MoveRelative( double x
, double y
);
541 void CalcBoundingBox();
549 class wxCanvasText
: public wxCanvasObject
552 wxCanvasText( const wxString
&text
, double x
, double y
, const wxString
&foneFile
, int size
);
555 double GetPosX() { return m_x
; }
556 double GetPosY() { return m_y
; }
557 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
559 void TransLate( double x
, double y
);
561 void CalcBoundingBox();
563 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
564 virtual void WriteSVG( wxTextOutputStream
&stream
);
566 void SetRGB( unsigned char red
, unsigned char green
, unsigned char blue
);
567 void SetFlag( int flag
);
568 int GetFlag() { return m_flag
; }
574 unsigned char *m_alpha
;
580 wxString m_fontFileName
;
585 // wxCanvas is used to display a wxCanvasGroupObject, which contains wxCanvasObject derived
586 // drawable objects. The group to draw is called the root.
587 // All objects are defined in world coordinates, relative to its parent (e.g. nested groups)
588 // There are methods to convert from world to device coordinates and visa versa.
589 // Rendering a draw is normally started on the root, it to a buffer, afterwords
590 // an update of the damaged parts will blitted from the buffer to the screen.
591 // This is done in Idle time, but can also be forced.
592 // World coordinates can be with the Y axis going up are down.
593 // The area of the drawing in world coordinates that is visible on the canvas
594 // can be set. Parts of this area can be zoomed into resulting in scroll bars
596 class wxCanvas
: public wxScrolledWindow
599 // constructors and destructors
600 wxCanvas( wxCanvasAdmin
* admin
,wxWindow
*parent
, wxWindowID id
= -1,
601 const wxPoint
& pos
= wxDefaultPosition
,
602 const wxSize
& size
= wxDefaultSize
,
603 long style
= wxScrolledWindowStyle
);
606 //background colour for the canvas
607 virtual void SetColour( const wxColour
& background
);
609 //update the area given in device coordinates
610 virtual void Update( int x
, int y
, int width
, int height
, bool blit
= TRUE
);
612 //blit all updated areas now to the screen, else it will happen in idle time.
613 //Use this to support dragging for instance, becuase in such cases idle time
615 virtual void UpdateNow();
617 //prevent canvas activety
618 virtual void Freeze();
619 //allow canvas activety
622 //get the buffer that is used for rendering in general
623 inline wxBitmap
*GetBuffer() { return &m_buffer
; }
624 //get the DC that is used for rendering
625 inline wxDC
*GetDC() { return m_renderDC
; }
626 //set the DC that is used for rendering
627 inline void SetDC(wxDC
* dc
) { m_renderDC
=dc
; }
629 inline int GetBufferWidth() { return m_buffer
.GetWidth(); }
630 inline int GetBufferHeight() { return m_buffer
.GetHeight(); }
632 //updating is needed for the canvas if the buffer did change
633 bool NeedUpdate() { return m_needUpdate
; }
634 bool IsFrozen() { return m_frozen
; }
636 //blit damaged areas in the buffer to the screen
637 void BlitBuffer( wxDC
&dc
);
639 //redirect events to this canvas object
640 void SetCaptureMouse( wxCanvasObject
*obj
);
641 //are events redirected, if so return the object else NULL
642 inline wxCanvasObject
* GetCaptured() { return m_captureMouse
;}
644 //set the root group where the objects for this canvas are stored
645 void SetRoot(wxCanvasObjectGroup
* aroot
){m_root
=aroot
;}
647 //get root group that is displayed on the canvas
648 wxCanvasObjectGroup
* GetRoot(){return m_root
;}
650 //scroll the window in device coordinates
651 virtual void ScrollWindow( int dx
, int dy
,
652 const wxRect
* rect
= (wxRect
*) NULL
);
654 //get y axis orientation
655 virtual bool GetYaxis() { return FALSE
; }
657 //get the visible part in world coordinates
658 virtual double GetMinX() const;
659 virtual double GetMinY() const;
660 virtual double GetMaxX() const;
661 virtual double GetMaxY() const;
663 //convert from window to virtual coordinates
664 virtual double DeviceToLogicalX(int x
) const;
665 virtual double DeviceToLogicalY(int y
) const;
666 virtual double DeviceToLogicalXRel(int x
) const;
667 virtual double DeviceToLogicalYRel(int y
) const;
668 virtual int LogicalToDeviceX(double x
) const;
669 virtual int LogicalToDeviceY(double y
) const;
670 virtual int LogicalToDeviceXRel(double x
) const;
671 virtual int LogicalToDeviceYRel(double y
) const;
676 //always available and m_buffer selected
680 wxList m_updateRects
;
681 wxCanvasObjectGroup
* m_root
;
683 wxColour m_background
;
685 wxCanvasObject
*m_lastMouse
;
686 wxCanvasObject
*m_captureMouse
;
688 int m_oldDeviceX
,m_oldDeviceY
;
690 wxCanvasAdmin
* m_admin
;
693 int m_bufferX
,m_bufferY
;
696 void OnMouse( wxMouseEvent
&event
);
697 void OnPaint( wxPaintEvent
&event
);
698 void OnSize( wxSizeEvent
&event
);
699 void OnIdle( wxIdleEvent
&event
);
700 void OnSetFocus( wxFocusEvent
&event
);
701 void OnKillFocus( wxFocusEvent
&event
);
702 void OnEraseBackground( wxEraseEvent
&event
);
705 DECLARE_CLASS(wxCanvas
)
706 DECLARE_EVENT_TABLE()
711 class wxVectorCanvas
: public wxCanvas
714 // constructors and destructors
715 wxVectorCanvas( wxCanvasAdmin
* admin
,wxWindow
*parent
, wxWindowID id
= -1,
716 const wxPoint
& pos
= wxDefaultPosition
,
717 const wxSize
& size
= wxDefaultSize
,
718 long style
= wxScrolledWindowStyle
);
720 //scroll the window in device coordinates
721 virtual void ScrollWindow( int dx
, int dy
,
722 const wxRect
* rect
= (wxRect
*) NULL
);
724 //set if the Yaxis goes up or down
725 void SetYaxis(bool up
) { m_yaxis
=up
; }
727 //get currently used Yaxis setting
728 virtual bool GetYaxis() { return m_yaxis
; }
730 //to set the total area in world coordinates that can be scrolled.
731 // when totaly zoomed out (SetMappingScroll same size as given here),
732 // this will be the area displayed.
733 // To display all of a drawing, set this here to the boundingbox of the root group
735 void SetScroll(double vx1
,double vy1
,double vx2
,double vy2
);
737 //given the virtual size to be displayed, the mappingmatrix will be calculated
738 //in such a manner that it fits (same ratio in width and height) to the window size.
739 //The window size is used to intitialize the mapping.
740 //The virtual size is just an indication, it will be ajusted to fit in the client window ratio.
741 //When border is set an extra margin is added so that the drawing will fit nicely.
742 // To display all of a drawing, set this here to the boundingbox of the root group
744 void SetMappingScroll(double vx1
,double vy1
,double vx2
,double vy2
,bool border
);
746 //matrix for calculating the virtual coordinate given a screen coordinate
747 wxTransformMatrix
GetInverseMappingMatrix();
749 //matrix for calculating the screen coordinate given a virtual coordinate
750 wxTransformMatrix
GetMappingMatrix();
752 //get minimum X of the visible part in world coordinates
753 virtual double GetMinX() const;
754 virtual double GetMinY() const;
755 virtual double GetMaxX() const;
756 virtual double GetMaxY() const;
758 //convert from window to virtual coordinates and back
759 virtual double DeviceToLogicalX(int x
) const;
760 virtual double DeviceToLogicalY(int y
) const;
761 virtual double DeviceToLogicalXRel(int x
) const;
762 virtual double DeviceToLogicalYRel(int y
) const;
763 virtual int LogicalToDeviceX(double x
) const;
764 virtual int LogicalToDeviceY(double y
) const;
765 virtual int LogicalToDeviceXRel(double x
) const;
766 virtual int LogicalToDeviceYRel(double y
) const;
772 // holds the matrix for mapping from virtual to screen coordinates
773 wxTransformMatrix m_mapping_matrix
;
775 // holds the inverse of the mapping matrix
776 wxTransformMatrix m_inverse_mapping
;
778 //virtual coordinates of total drawing
779 double m_virtm_minX
, m_virtm_minY
, m_virtm_maxX
, m_virtm_maxY
;
781 // virtual coordinates box
782 double m_virt_minX
, m_virt_minY
, m_virt_maxX
, m_virt_maxY
;
785 double m_minX
, m_minY
, m_maxX
, m_maxY
;
787 //are scroll bars active?
791 void OnScroll(wxScrollWinEvent
& event
);
792 void OnChar( wxKeyEvent
&event
);
793 void OnSize( wxSizeEvent
&event
);
796 DECLARE_CLASS(wxVectorCanvas
)
797 DECLARE_EVENT_TABLE()
803 //Contains a list of wxCanvas Objects that will be maintained through this class.
804 //Each wxCanvasObject can be displayed on several wxCanvas Objects at the same time.
805 //The active wxCanvas is used to render and convert coordinates from world to device.
806 //So it is important to set the active wxCanvas based on the wxCanvas that has the focus
807 //or is scrolled etc. This is normally done within wxCanvas when appropriate.
811 // constructors and destructors
813 virtual ~wxCanvasAdmin();
815 //convert from window to virtual coordinates
816 double DeviceToLogicalX(int x
) const;
817 //convert from window to virtual coordinates
818 double DeviceToLogicalY(int y
) const;
819 //convert from window to virtual coordinates relatif
820 double DeviceToLogicalXRel(int x
) const;
821 //convert from window to virtual coordinates relatif
822 double DeviceToLogicalYRel(int y
) const;
823 //convert from virtual to window coordinates
824 int LogicalToDeviceX(double x
) const;
825 //convert from virtual to window coordinates
826 int LogicalToDeviceY(double y
) const;
827 //convert from virtual to window coordinates relatif
828 int LogicalToDeviceXRel(double x
) const;
829 //convert from virtual to window coordinates relatif
830 int LogicalToDeviceYRel(double y
) const;
832 //update in the buffer off all canvases, the area given in world coordinates
833 virtual void Update(wxCanvasObject
* obj
, double x
, double y
, double width
, double height
);
835 //blit all updated areas now to the screen, else it will happen in idle time.
836 //Use this to support dragging for instance, becuase in such cases idle time
838 virtual void UpdateNow();
840 //append another canvas
841 virtual void Append( wxCanvas
* canvas
);
844 virtual void Remove( wxCanvas
* canvas
);
846 //set the given canvas as active (for rendering, coordinate conversion etc.)
847 void SetActive(wxCanvas
* activate
);
850 inline wxCanvas
* GetActive() {return m_active
;};