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
57 DECLARE_CLASS(wxCanvasObject
)
62 //If the position (x,y) is within the object this return a pointer to the object
63 //Normally this function needs to be defined for each derived wxCanvasObject.
64 //The default is a simple bounding box test.
65 virtual wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
67 //render this object to the canvas (either on its buffer or directly on the canvas)
68 //this depends on the wxDC that is set for the active canvas.
69 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
71 //x position in world coordinates of the object
72 virtual double GetPosX()=0;
73 //y position in world coordinates of the object
74 virtual double GetPosY()=0;
76 //set position in world coordinates for the object
77 virtual void SetPosXY( double x
, double y
)=0;
79 //absolute moving the object to position x,y in world coordinates
80 //also does an update of the old and new area
81 virtual void MoveAbsolute( double x
, double y
);
83 //relative moving the object to position x,y in world coordinates
84 //also does an update of the old and new area
85 virtual void MoveRelative( double x
, double y
);
87 //relative translate the object to position x,y in world coordinates
88 //does NOT update the old and new area
89 //this function must be defined for each derived object,
90 //it is used internally for dragging and moving objects.
91 virtual void TransLate( double x
, double y
)=0;
93 //choose one of the three diffrenet drag methods |
94 //DRAG_RECTANGLE = as a rectangle when drag is in progress |
95 //DRAG_ONTOP = only redraw the object when dragging |
96 //DRAG_REDRAW = redraw the damaged areas when dragging
97 void SetDragMode(wxDRAG_MODE mode
) { m_dragmode
=mode
; };
100 wxDRAG_MODE
GetDragMode() { return m_dragmode
; };
102 //called when starting a drag
103 virtual void DragStart();
104 //called when dragging is in progress
105 virtual void DragRelative( double x
, double y
);
106 //called when dragging is ended
107 virtual void DragEnd();
109 //return the object if it is part of the given object or
110 //if the given object is part of a group within this object.
111 //For group objects this means recursively search for it.
112 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
114 //calculate the boundingbox in world coordinates
115 virtual void CalcBoundingBox()=0;
117 //write the object as SVG (scalable vector grafhics
118 virtual void WriteSVG( wxTextOutputStream
&stream
);
120 //get the administrator for the object,
121 //this will give access to the canvas's where it is displayed upon.
122 //It is used to render the object to the active canvas.
123 //Conversion from world to Device coordinates and visa versa is
124 //done using the Active canvas at that moment.
125 wxCanvasAdmin
*GetAdmin() { return m_admin
; }
127 //set the administrator
128 virtual void SetAdmin( wxCanvasAdmin
*admin
) { m_admin
= admin
; }
130 //is this a control type of canvas object
131 bool IsControl() { return m_isControl
; }
132 //is this a vector type of canvas object
133 bool IsVector() { return m_isVector
; }
134 //is this an Image type of canvas object
135 bool IsImage() { return m_isImage
; }
137 //get minimum X of the boundingbox in world coordinates
138 inline double GetXMin() { return m_bbox
.GetMinX(); }
139 //get minimum Y of the boundingbox in world coordinates
140 inline double GetYMin() { return m_bbox
.GetMinY(); }
141 //get maximum X of the boundingbox in world coordinates
142 inline double GetXMax() { return m_bbox
.GetMaxX(); }
143 //get maximum Y of the boundingbox in world coordinates
144 inline double GetYMax() { return m_bbox
.GetMaxY(); }
147 inline wxBoundingBox
GetBbox() { return m_bbox
; }
149 //redirect all mouse events for the canvas to this object
151 //release the mouse capture for this object
153 //is the mouse captured for this object
154 bool IsCapturedMouse();
156 //set if this object will visible (be rendered or not)
157 inline void SetVisible(bool visible
) { m_visible
=visible
; }
159 inline bool GetVisible() {return m_visible
; }
161 //can the object be dragged
162 inline void SetDraggable(bool drag
) { m_dragable
=drag
; }
163 //get if the object can be dragged
164 inline bool GetDraggable() {return m_dragable
; }
166 //get absolute area in the device coordinates where the object
167 //its boundingbox in world coordinates is first translated using the matrix.
168 wxRect
GetAbsoluteArea(const wxTransformMatrix
& cworld
);
170 //get currently used eventhandler (always the first in the list)
171 wxEvtHandler
*GetEventHandler() const { return m_eventHandler
; }
173 //process an event for the object, starting with the first eventhandler
175 bool ProcessCanvasObjectEvent(wxEvent
& event
);
177 // push/pop event handler: allows to chain a custom event handler to
178 // already existing ones
179 void PushEventHandler( wxEvtHandler
*handler
);
181 //remove first eventhandler in the list (one will be always stay in)
182 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
183 //append an eventhandler to the list, this event handler will be called
184 //if the other skipped the event to process.
185 void AppendEventHandler(wxEvtHandler
*handler
);
186 //remove last event handler in the list (one will always stay in)
187 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
191 //administator for rendering and accessing the canvas's
192 wxCanvasAdmin
* m_admin
;
194 //active event handler, default the object itself
195 wxEvtHandler
* m_eventHandler
;
202 wxDRAG_MODE m_dragmode
:3;
204 //boundingbox in world coordinates
205 wxBoundingBox m_bbox
;
212 // wxCanvasObjectGroup is a container for wxCanvas derived Objects.
213 // It renders itself by calling the render methods of the wxCanvasObjects it contains.
214 // It can have nested groups also, in the same way as the other wxCanvasObjects it already contains.
215 // The group has a matrix to position/rotate/scale the group.
216 class wxCanvasObjectGroup
: public wxCanvasObject
218 DECLARE_CLASS(wxCanvasObjectGroup
)
220 wxCanvasObjectGroup(double x
, double y
);
221 virtual ~wxCanvasObjectGroup();
223 void SetAdmin(wxCanvasAdmin
* admin
);
225 //prepend a wxCanvasObject to this group
226 virtual void Prepend( wxCanvasObject
* obj
);
227 //append a wxCanvasObject to this group
228 virtual void Append( wxCanvasObject
* obj
);
229 //insert a wxCanvasObject to this group
230 virtual void Insert( size_t before
, wxCanvasObject
* obj
);
231 //remove the given object from the group
232 virtual void Remove( wxCanvasObject
* obj
);
234 //those this group contain the given object.
235 //in case of nested groups also search in there to the lowwest level.
236 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
238 //returns index of the given wxCanvasObject in this group
239 virtual int IndexOf( wxCanvasObject
* obj
);
241 double GetPosX() { return lworld
.GetValue(2,0); }
242 double GetPosY() { return lworld
.GetValue(2,1); }
243 void SetPosXY( double x
, double y
) {lworld
.SetValue(2,0,x
);lworld
.SetValue(2,1,y
);CalcBoundingBox();};
245 void TransLate( double x
, double y
);
247 void CalcBoundingBox();
248 //remove all wxCanvasObjects from the group (flag for deletion of the objectsalso)
249 void DeleteContents( bool );
250 virtual void Render(wxTransformMatrix
* cworld
,int x
, int y
, int width
, int height
);
251 virtual void WriteSVG( wxTextOutputStream
&stream
);
253 //recursive call the IsHitWorld on all contained objects, the first
254 //one that is hit will be returned
255 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
257 //recursive calls for contained objects to set eventhandlers,
258 //and also sets its own eventhandler
259 void PushEventHandler( wxEvtHandler
*handler
);
260 //recursive calls for contained objects to set eventhandlers,
261 //and also sets its own eventhandler
262 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
263 //recursive calls for contained objects to set eventhandlers,
264 //and also sets its own eventhandler
265 void AppendEventHandler(wxEvtHandler
*handler
);
266 //recursive calls for contained objects to set eventhandlers,
267 //and also sets its own eventhandler
268 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
272 //to position the object
273 wxTransformMatrix lworld
;
277 friend class wxCanvas
;
281 // wxCanvasObjectRef is a reference to any wxCanvasObject derived class.
282 // It does not duplicate the referenced object.
283 // It has a matrix to reposition/rotate/scale the object it references.
284 // The position/matrix of the referenced Object is accumulated with the one here.
285 class wxCanvasObjectRef
: public wxCanvasObject
287 DECLARE_CLASS(wxCanvasObjectRef
)
289 wxCanvasObjectRef(double x
, double y
,wxCanvasObject
* obj
);
291 //set rotation for the reference
292 void SetRotation(double rotation
);
294 //set scale in x and y ( > zero)
295 void SetScale( double scalex
, double scaley
);
297 void SetAdmin(wxCanvasAdmin
* admin
);
299 double GetPosX() { return lworld
.GetValue(2,0); }
300 double GetPosY() { return lworld
.GetValue(2,1); }
301 void SetPosXY( double x
, double y
) {lworld
.SetValue(2,0,x
);lworld
.SetValue(2,1,y
);CalcBoundingBox();};
303 void TransLate( double x
, double y
);
304 void CalcBoundingBox();
305 virtual void Render(wxTransformMatrix
* cworld
,int x
, int y
, int width
, int height
);
306 virtual void WriteSVG( wxTextOutputStream
&stream
);
308 //return this object if one of the objects it references is hit
309 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
310 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
312 //recursive calls for contained objects to set eventhandlers,
313 //and also sets its own eventhandler
314 void PushEventHandler( wxEvtHandler
*handler
);
315 //recursive calls for contained objects to set eventhandlers,
316 //and also sets its own eventhandler
317 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
318 //recursive calls for contained objects to set eventhandlers,
319 //and also sets its own eventhandler
320 void AppendEventHandler(wxEvtHandler
*handler
);
321 //recursive calls for contained objects to set eventhandlers,
322 //and also sets its own eventhandler
323 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
327 //to position the object
328 wxTransformMatrix lworld
;
330 //reference to another wxCanvasObject
331 wxCanvasObject
* m_obj
;
336 class wxCanvasRect
: public wxCanvasObject
338 DECLARE_CLASS(wxCanvasRect
)
340 wxCanvasRect( double x
, double y
, double w
, double h
, double radius
=0 );
341 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
342 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
344 double GetPosX() { return m_x
; }
345 double GetPosY() { return m_y
; }
346 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
348 void TransLate( double x
, double y
);
349 void CalcBoundingBox();
351 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
352 virtual void WriteSVG( wxTextOutputStream
&stream
);
365 //----------------------------------------------------------------------------
367 //----------------------------------------------------------------------------
368 class wxCanvasCircle
: public wxCanvasObject
371 wxCanvasCircle( double x
, double y
, double radius
);
372 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
373 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
375 double GetPosX() { return m_x
; }
376 double GetPosY() { return m_y
; }
377 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
379 void TransLate( double x
, double y
);
381 void CalcBoundingBox();
383 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
384 virtual void WriteSVG( wxTextOutputStream
&stream
);
386 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
399 class wxCanvasEllipse
: public wxCanvasObject
402 wxCanvasEllipse( double x
, double y
, double width
, double height
);
403 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
404 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
406 double GetPosX() { return m_x
; }
407 double GetPosY() { return m_y
; }
408 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
410 void TransLate( double x
, double y
);
412 void CalcBoundingBox();
414 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
415 virtual void WriteSVG( wxTextOutputStream
&stream
);
417 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
430 // wxCanvasEllipticArc
431 class wxCanvasEllipticArc
: public wxCanvasObject
434 wxCanvasEllipticArc( double x
, double y
, double width
, double height
, double start
, double end
);
435 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
436 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
438 double GetPosX() { return m_x
; }
439 double GetPosY() { return m_y
; }
440 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
442 void TransLate( double x
, double y
);
443 void CalcBoundingBox();
445 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
446 virtual void WriteSVG( wxTextOutputStream
&stream
);
448 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
464 class wxCanvasLine
: public wxCanvasObject
467 wxCanvasLine( double x1
, double y1
, double x2
, double y2
);
468 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
471 double GetPosX() { return m_x1
; }
472 double GetPosY() { return m_y1
; }
473 void SetPosXY( double x
, double y
) {m_x1
=x
; m_y1
=y
; CalcBoundingBox();};
475 void TransLate( double x
, double y
);
477 void CalcBoundingBox();
479 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
480 virtual void WriteSVG( wxTextOutputStream
&stream
);
482 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
495 class wxCanvasImage
: public wxCanvasObject
498 wxCanvasImage( const wxImage
&image
, double x
, double y
, double w
, double h
);
500 double GetPosX() { return m_x
; }
501 double GetPosY() { return m_y
; }
502 void SetPosXY( double x
, double y
);
504 void TransLate( double x
, double y
);
506 void CalcBoundingBox();
508 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
509 virtual void WriteSVG( wxTextOutputStream
&stream
);
528 //----------------------------------------------------------------------------
530 //----------------------------------------------------------------------------
532 class wxCanvasControl
: public wxCanvasObject
535 wxCanvasControl( wxWindow
*control
);
540 void SetPosXY( double x
, double y
);
542 void TransLate( double x
, double y
);
543 void MoveRelative( double x
, double y
);
545 void CalcBoundingBox();
553 class wxCanvasText
: public wxCanvasObject
556 wxCanvasText( const wxString
&text
, double x
, double y
, const wxString
&foneFile
, int size
);
559 double GetPosX() { return m_x
; }
560 double GetPosY() { return m_y
; }
561 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
563 void TransLate( double x
, double y
);
565 void CalcBoundingBox();
567 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
568 virtual void WriteSVG( wxTextOutputStream
&stream
);
570 void SetRGB( unsigned char red
, unsigned char green
, unsigned char blue
);
571 void SetFlag( int flag
);
572 int GetFlag() { return m_flag
; }
578 unsigned char *m_alpha
;
584 wxString m_fontFileName
;
589 // wxCanvas is used to display a wxCanvasGroupObject, which contains wxCanvasObject derived
590 // drawable objects. The group to draw is called the root.
591 // All objects are defined in world coordinates, relative to its parent (e.g. nested groups)
592 // There are methods to convert from world to device coordinates and visa versa.
593 // Rendering a draw is normally started on the root, it to a buffer, afterwords
594 // an update of the damaged parts will blitted from the buffer to the screen.
595 // This is done in Idle time, but can also be forced.
596 // World coordinates can be with the Y axis going up are down.
597 // The area of the drawing in world coordinates that is visible on the canvas
598 // can be set. Parts of this area can be zoomed into resulting in scroll bars
600 class wxCanvas
: public wxScrolledWindow
603 // constructors and destructors
604 wxCanvas( wxCanvasAdmin
* admin
,wxWindow
*parent
, wxWindowID id
= -1,
605 const wxPoint
& pos
= wxDefaultPosition
,
606 const wxSize
& size
= wxDefaultSize
,
607 long style
= wxScrolledWindowStyle
);
610 //background colour for the canvas
611 virtual void SetColour( const wxColour
& background
);
613 //update the area given in device coordinates
614 virtual void Update( int x
, int y
, int width
, int height
, bool blit
= TRUE
);
616 //blit all updated areas now to the screen, else it will happen in idle time.
617 //Use this to support dragging for instance, becuase in such cases idle time
619 virtual void UpdateNow();
621 //prevent canvas activety
622 virtual void Freeze();
623 //allow canvas activety
626 //get the buffer that is used for rendering in general
627 inline wxBitmap
*GetBuffer() { return &m_buffer
; }
628 //get the DC that is used for rendering
629 inline wxDC
*GetDC() { return m_renderDC
; }
630 //set the DC that is used for rendering
631 inline void SetDC(wxDC
* dc
) { m_renderDC
=dc
; }
633 inline int GetBufferWidth() { return m_buffer
.GetWidth(); }
634 inline int GetBufferHeight() { return m_buffer
.GetHeight(); }
636 //updating is needed for the canvas if the buffer did change
637 bool NeedUpdate() { return m_needUpdate
; }
638 bool IsFrozen() { return m_frozen
; }
640 //blit damaged areas in the buffer to the screen
641 void BlitBuffer( wxDC
&dc
);
643 //redirect events to this canvas object
644 void SetCaptureMouse( wxCanvasObject
*obj
);
645 //are events redirected, if so return the object else NULL
646 inline wxCanvasObject
* GetCaptured() { return m_captureMouse
;}
648 //set the root group where the objects for this canvas are stored
649 void SetRoot(wxCanvasObjectGroup
* aroot
){m_root
=aroot
;}
651 //get root group that is displayed on the canvas
652 wxCanvasObjectGroup
* GetRoot(){return m_root
;}
654 //scroll the window in device coordinates
655 virtual void ScrollWindow( int dx
, int dy
,
656 const wxRect
* rect
= (wxRect
*) NULL
);
658 //get y axis orientation
659 virtual bool GetYaxis() { return FALSE
; }
661 //get the visible part in world coordinates
662 virtual double GetMinX() const;
663 virtual double GetMinY() const;
664 virtual double GetMaxX() const;
665 virtual double GetMaxY() const;
667 //convert from window to virtual coordinates
668 virtual double DeviceToLogicalX(int x
) const;
669 virtual double DeviceToLogicalY(int y
) const;
670 virtual double DeviceToLogicalXRel(int x
) const;
671 virtual double DeviceToLogicalYRel(int y
) const;
672 virtual int LogicalToDeviceX(double x
) const;
673 virtual int LogicalToDeviceY(double y
) const;
674 virtual int LogicalToDeviceXRel(double x
) const;
675 virtual int LogicalToDeviceYRel(double y
) const;
680 //always available and m_buffer selected
684 wxList m_updateRects
;
685 wxCanvasObjectGroup
* m_root
;
687 wxColour m_background
;
689 wxCanvasObject
*m_lastMouse
;
690 wxCanvasObject
*m_captureMouse
;
692 int m_oldDeviceX
,m_oldDeviceY
;
694 wxCanvasAdmin
* m_admin
;
697 int m_bufferX
,m_bufferY
;
700 void OnMouse( wxMouseEvent
&event
);
701 void OnPaint( wxPaintEvent
&event
);
702 void OnSize( wxSizeEvent
&event
);
703 void OnIdle( wxIdleEvent
&event
);
704 void OnSetFocus( wxFocusEvent
&event
);
705 void OnKillFocus( wxFocusEvent
&event
);
706 void OnEraseBackground( wxEraseEvent
&event
);
709 DECLARE_CLASS(wxCanvas
)
710 DECLARE_EVENT_TABLE()
715 class wxVectorCanvas
: public wxCanvas
718 // constructors and destructors
719 wxVectorCanvas( wxCanvasAdmin
* admin
,wxWindow
*parent
, wxWindowID id
= -1,
720 const wxPoint
& pos
= wxDefaultPosition
,
721 const wxSize
& size
= wxDefaultSize
,
722 long style
= wxScrolledWindowStyle
);
724 //scroll the window in device coordinates
725 virtual void ScrollWindow( int dx
, int dy
,
726 const wxRect
* rect
= (wxRect
*) NULL
);
728 //set if the Yaxis goes up or down
729 void SetYaxis(bool up
) { m_yaxis
=up
; }
731 //get currently used Yaxis setting
732 virtual bool GetYaxis() { return m_yaxis
; }
734 //to set the total area in world coordinates that can be scrolled.
735 // when totaly zoomed out (SetMappingScroll same size as given here),
736 // this will be the area displayed.
737 // To display all of a drawing, set this here to the boundingbox of the root group
739 void SetScroll(double vx1
,double vy1
,double vx2
,double vy2
);
741 //given the virtual size to be displayed, the mappingmatrix will be calculated
742 //in such a manner that it fits (same ratio in width and height) to the window size.
743 //The window size is used to intitialize the mapping.
744 //The virtual size is just an indication, it will be ajusted to fit in the client window ratio.
745 //When border is set an extra margin is added so that the drawing will fit nicely.
746 // To display all of a drawing, set this here to the boundingbox of the root group
748 void SetMappingScroll(double vx1
,double vy1
,double vx2
,double vy2
,bool border
);
750 //matrix for calculating the virtual coordinate given a screen coordinate
751 wxTransformMatrix
GetInverseMappingMatrix();
753 //matrix for calculating the screen coordinate given a virtual coordinate
754 wxTransformMatrix
GetMappingMatrix();
756 //get minimum X of the visible part in world coordinates
757 virtual double GetMinX() const;
758 virtual double GetMinY() const;
759 virtual double GetMaxX() const;
760 virtual double GetMaxY() const;
762 //convert from window to virtual coordinates and back
763 virtual double DeviceToLogicalX(int x
) const;
764 virtual double DeviceToLogicalY(int y
) const;
765 virtual double DeviceToLogicalXRel(int x
) const;
766 virtual double DeviceToLogicalYRel(int y
) const;
767 virtual int LogicalToDeviceX(double x
) const;
768 virtual int LogicalToDeviceY(double y
) const;
769 virtual int LogicalToDeviceXRel(double x
) const;
770 virtual int LogicalToDeviceYRel(double y
) const;
776 // holds the matrix for mapping from virtual to screen coordinates
777 wxTransformMatrix m_mapping_matrix
;
779 // holds the inverse of the mapping matrix
780 wxTransformMatrix m_inverse_mapping
;
782 //virtual coordinates of total drawing
783 double m_virtm_minX
, m_virtm_minY
, m_virtm_maxX
, m_virtm_maxY
;
785 // virtual coordinates box
786 double m_virt_minX
, m_virt_minY
, m_virt_maxX
, m_virt_maxY
;
789 double m_minX
, m_minY
, m_maxX
, m_maxY
;
791 //are scroll bars active?
795 void OnScroll(wxScrollWinEvent
& event
);
796 void OnChar( wxKeyEvent
&event
);
797 void OnSize( wxSizeEvent
&event
);
800 DECLARE_CLASS(wxVectorCanvas
)
801 DECLARE_EVENT_TABLE()
807 //Contains a list of wxCanvas Objects that will be maintained through this class.
808 //Each wxCanvasObject can be displayed on several wxCanvas Objects at the same time.
809 //The active wxCanvas is used to render and convert coordinates from world to device.
810 //So it is important to set the active wxCanvas based on the wxCanvas that has the focus
811 //or is scrolled etc. This is normally done within wxCanvas when appropriate.
815 // constructors and destructors
817 virtual ~wxCanvasAdmin();
819 //convert from window to virtual coordinates
820 double DeviceToLogicalX(int x
) const;
821 //convert from window to virtual coordinates
822 double DeviceToLogicalY(int y
) const;
823 //convert from window to virtual coordinates relatif
824 double DeviceToLogicalXRel(int x
) const;
825 //convert from window to virtual coordinates relatif
826 double DeviceToLogicalYRel(int y
) const;
827 //convert from virtual to window coordinates
828 int LogicalToDeviceX(double x
) const;
829 //convert from virtual to window coordinates
830 int LogicalToDeviceY(double y
) const;
831 //convert from virtual to window coordinates relatif
832 int LogicalToDeviceXRel(double x
) const;
833 //convert from virtual to window coordinates relatif
834 int LogicalToDeviceYRel(double y
) const;
836 //update in the buffer off all canvases, the area given in world coordinates
837 virtual void Update(wxCanvasObject
* obj
, double x
, double y
, double width
, double height
);
839 //blit all updated areas now to the screen, else it will happen in idle time.
840 //Use this to support dragging for instance, becuase in such cases idle time
842 virtual void UpdateNow();
844 //append another canvas
845 virtual void Append( wxCanvas
* canvas
);
848 virtual void Remove( wxCanvas
* canvas
);
850 //set the given canvas as active (for rendering, coordinate conversion etc.)
851 void SetActive(wxCanvas
* activate
);
854 inline wxCanvas
* GetActive() {return m_active
;};