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 //----------------------------------------------------------------------------
37 enum DRAGMODE
{DRAG_RECTANGLE
,DRAG_ONTOP
,DRAG_REDRAW
};
40 // wxCanvasObject is the base class for Canvas Objects.
41 // All Objects for drawing one the canvas are derived from this class.
42 // It supports dragging and moving methods that can be used in derived
43 // classes for defining several ways of dragging.
44 // Also it is possible to plug in events handlers to do this for all derived classes at once.
46 // wxCanvasObjects have themselves as their event handlers by default,
47 // but their event handlers could be set to another object entirely. This
48 // separation can reduce the amount of derivation required, and allow
49 // alteration of a wxCanvasObject functionality
50 class wxCanvasObject
: public wxEvtHandler
56 //If the position (x,y) is within the object this return a pointer to the object
57 //Normally this function needs to be defined for each derived wxCanvasObject.
58 //The default is a simple bounding box test.
59 virtual wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
61 //render this object to the canvas (either on its buffer or directly on the canvas)
62 //this depends on the wxDC that is set for the active canvas.
63 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
65 //x position in world coordinates of the object
66 virtual double GetPosX()=0;
67 //y position in world coordinates of the object
68 virtual double GetPosY()=0;
70 //set position in world coordinates for the object
71 virtual void SetPosXY( double x
, double y
)=0;
73 //absolute moving the object to position x,y in world coordinates
74 //also does an update of the old and new area
75 virtual void MoveAbsolute( double x
, double y
);
77 //relative moving the object to position x,y in world coordinates
78 //also does an update of the old and new area
79 virtual void MoveRelative( double x
, double y
);
81 //relative translate the object to position x,y in world coordinates
82 //does NOT update the old and new area
83 //this function must be defined for each derived object,
84 //it is used internally for dragging and moving objects.
85 virtual void TransLate( double x
, double y
)=0;
87 //choose one of the three diffrenet drag methods |
88 //DRAG_RECTANGLE = as a rectangle when drag is in progress |
89 //DRAG_ONTOP = only redraw the object when dragging |
90 //DRAG_REDRAW = redraw the damaged areas when dragging
91 void SetDragMode(DRAGMODE mode
) { m_dragmode
=mode
; };
94 DRAGMODE
GetDragMode() { return m_dragmode
; };
96 //called when starting a drag
97 virtual void DragStart();
98 //called when dragging is in progress
99 virtual void DragRelative( double x
, double y
);
100 //called when dragging is ended
101 virtual void DragEnd();
103 //return the object if it is part of the given object or
104 //if the given object is part of a group within this object.
105 //For group objects this means recursively search for it.
106 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
108 //calculate the boundingbox in world coordinates
109 virtual void CalcBoundingBox()=0;
111 //write the object as SVG (scalable vector grafhics
112 virtual void WriteSVG( wxTextOutputStream
&stream
);
114 //get the administrator for the object,
115 //this will give access to the canvas's where it is displayed upon.
116 //It is used to render the object to the active canvas.
117 //Conversion from world to Device coordinates and visa versa is
118 //done using the Active canvas at that moment.
119 wxCanvasAdmin
*GetAdmin() { return m_admin
; }
121 //set the administrator
122 virtual void SetAdmin( wxCanvasAdmin
*admin
) { m_admin
= admin
; }
124 //is this a control type of canvas object
125 bool IsControl() { return m_isControl
; }
126 //is this a vector type of canvas object
127 bool IsVector() { return m_isVector
; }
128 //is this an Image type of canvas object
129 bool IsImage() { return m_isImage
; }
131 //get minimum X of the boundingbox in world coordinates
132 inline double GetXMin() { return m_bbox
.GetMinX(); }
133 //get minimum Y of the boundingbox in world coordinates
134 inline double GetYMin() { return m_bbox
.GetMinY(); }
135 //get maximum X of the boundingbox in world coordinates
136 inline double GetXMax() { return m_bbox
.GetMaxX(); }
137 //get maximum Y of the boundingbox in world coordinates
138 inline double GetYMax() { return m_bbox
.GetMaxY(); }
141 inline wxBoundingBox
GetBbox() { return m_bbox
; }
143 //redirect all mouse events for the canvas to this object
145 //release the mouse capture for this object
147 //is the mouse captured for this object
148 bool IsCapturedMouse();
150 //set if this object will visible (be rendered or not)
151 inline void SetVisible(bool visible
) { m_visible
=visible
; }
153 inline bool GetVisible() {return m_visible
; }
155 //can the object be dragged
156 inline void SetDraggable(bool drag
) { m_dragable
=drag
; }
157 //get if the object can be dragged
158 inline bool GetDraggable() {return m_dragable
; }
160 //get absolute area in the device coordinates where the object
161 //its boundingbox in world coordinates is first translated using the matrix.
162 wxRect
GetAbsoluteArea(const wxTransformMatrix
& cworld
);
164 //get currently used eventhandler (always the first in the list)
165 wxEvtHandler
*GetEventHandler() const { return m_eventHandler
; }
167 //process an event for the object, starting with the first eventhandler
169 bool ProcessCanvasObjectEvent(wxEvent
& event
);
171 // push/pop event handler: allows to chain a custom event handler to
172 // already existing ones
173 void PushEventHandler( wxEvtHandler
*handler
);
175 //remove first eventhandler in the list (one will be always stay in)
176 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
177 //append an eventhandler to the list, this event handler will be called
178 //if the other skipped the event to process.
179 void AppendEventHandler(wxEvtHandler
*handler
);
180 //remove last event handler in the list (one will always stay in)
181 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
185 //administator for rendering and accessing the canvas's
186 wxCanvasAdmin
* m_admin
;
188 //active event handler, default the object itself
189 wxEvtHandler
* m_eventHandler
;
196 DRAGMODE m_dragmode
:2;
198 //boundingbox in world coordinates
199 wxBoundingBox m_bbox
;
206 // wxCanvasObjectGroup is a container for wxCanvas derived Objects.
207 // It renders itself by calling the render methods of the wxCanvasObjects it contains.
208 // It can have nested groups also, in the same way as the other wxCanvasObjects it already contains.
209 // The group has a matrix to position/rotate/scale the group.
210 class wxCanvasObjectGroup
: public wxCanvasObject
213 wxCanvasObjectGroup(double x
, double y
);
214 virtual ~wxCanvasObjectGroup();
216 void SetAdmin(wxCanvasAdmin
* admin
);
218 //prepend a wxCanvasObject to this group
219 virtual void Prepend( wxCanvasObject
* obj
);
220 //append a wxCanvasObject to this group
221 virtual void Append( wxCanvasObject
* obj
);
222 //insert a wxCanvasObject to this group
223 virtual void Insert( size_t before
, wxCanvasObject
* obj
);
224 //remove the given object from the group
225 virtual void Remove( wxCanvasObject
* obj
);
227 //those this group contain the given object.
228 //in case of nested groups also search in there to the lowwest level.
229 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
231 //returns index of the given wxCanvasObject in this group
232 virtual int IndexOf( wxCanvasObject
* obj
);
234 double GetPosX() { return lworld
.GetValue(2,0); }
235 double GetPosY() { return lworld
.GetValue(2,1); }
236 void SetPosXY( double x
, double y
) {lworld
.SetValue(2,0,x
);lworld
.SetValue(2,1,y
);CalcBoundingBox();};
238 void TransLate( double x
, double y
);
240 void CalcBoundingBox();
241 //remove all wxCanvasObjects from the group (flag for deletion of the objectsalso)
242 void DeleteContents( bool );
243 virtual void Render(wxTransformMatrix
* cworld
,int x
, int y
, int width
, int height
);
244 virtual void WriteSVG( wxTextOutputStream
&stream
);
246 //recursive call the IsHitWorld on all contained objects, the first
247 //one that is hit will be returned
248 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
250 //recursive calls for contained objects to set eventhandlers,
251 //and also sets its own eventhandler
252 void PushEventHandler( wxEvtHandler
*handler
);
253 //recursive calls for contained objects to set eventhandlers,
254 //and also sets its own eventhandler
255 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
256 //recursive calls for contained objects to set eventhandlers,
257 //and also sets its own eventhandler
258 void AppendEventHandler(wxEvtHandler
*handler
);
259 //recursive calls for contained objects to set eventhandlers,
260 //and also sets its own eventhandler
261 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
265 //to position the object
266 wxTransformMatrix lworld
;
270 friend class wxCanvas
;
274 // wxCanvasObjectRef is a reference to any wxCanvasObject derived class.
275 // It does not duplicate the referenced object.
276 // It has a matrix to reposition/rotate/scale the object it references.
277 // The position/matrix of the referenced Object is accumulated with the one here.
278 class wxCanvasObjectRef
: public wxCanvasObject
281 wxCanvasObjectRef(double x
, double y
,wxCanvasObject
* obj
);
283 //set rotation for the reference
284 void SetRotation(double rotation
);
286 //set scale in x and y ( > zero)
287 void SetScale( double scalex
, double scaley
);
289 void SetAdmin(wxCanvasAdmin
* admin
);
291 double GetPosX() { return lworld
.GetValue(2,0); }
292 double GetPosY() { return lworld
.GetValue(2,1); }
293 void SetPosXY( double x
, double y
) {lworld
.SetValue(2,0,x
);lworld
.SetValue(2,1,y
);CalcBoundingBox();};
295 void TransLate( double x
, double y
);
296 void CalcBoundingBox();
297 virtual void Render(wxTransformMatrix
* cworld
,int x
, int y
, int width
, int height
);
298 virtual void WriteSVG( wxTextOutputStream
&stream
);
300 //return this object if one of the objects it references is hit
301 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
302 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
304 //recursive calls for contained objects to set eventhandlers,
305 //and also sets its own eventhandler
306 void PushEventHandler( wxEvtHandler
*handler
);
307 //recursive calls for contained objects to set eventhandlers,
308 //and also sets its own eventhandler
309 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
310 //recursive calls for contained objects to set eventhandlers,
311 //and also sets its own eventhandler
312 void AppendEventHandler(wxEvtHandler
*handler
);
313 //recursive calls for contained objects to set eventhandlers,
314 //and also sets its own eventhandler
315 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
319 //to position the object
320 wxTransformMatrix lworld
;
322 //reference to another wxCanvasObject
323 wxCanvasObject
* m_obj
;
328 class wxCanvasRect
: public wxCanvasObject
331 wxCanvasRect( double x
, double y
, double w
, double h
, double radius
=0 );
332 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
333 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
335 double GetPosX() { return m_x
; }
336 double GetPosY() { return m_y
; }
337 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
339 void TransLate( double x
, double y
);
340 void CalcBoundingBox();
342 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
343 virtual void WriteSVG( wxTextOutputStream
&stream
);
356 //----------------------------------------------------------------------------
358 //----------------------------------------------------------------------------
359 class wxCanvasCircle
: public wxCanvasObject
362 wxCanvasCircle( double x
, double y
, double radius
);
363 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
364 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
366 double GetPosX() { return m_x
; }
367 double GetPosY() { return m_y
; }
368 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
370 void TransLate( double x
, double y
);
372 void CalcBoundingBox();
374 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
375 virtual void WriteSVG( wxTextOutputStream
&stream
);
377 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
390 class wxCanvasEllipse
: public wxCanvasObject
393 wxCanvasEllipse( double x
, double y
, double width
, double height
);
394 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
395 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
397 double GetPosX() { return m_x
; }
398 double GetPosY() { return m_y
; }
399 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
401 void TransLate( double x
, double y
);
403 void CalcBoundingBox();
405 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
406 virtual void WriteSVG( wxTextOutputStream
&stream
);
408 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
421 // wxCanvasEllipticArc
422 class wxCanvasEllipticArc
: public wxCanvasObject
425 wxCanvasEllipticArc( double x
, double y
, double width
, double height
, double start
, double end
);
426 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
427 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
429 double GetPosX() { return m_x
; }
430 double GetPosY() { return m_y
; }
431 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
433 void TransLate( double x
, double y
);
434 void CalcBoundingBox();
436 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
437 virtual void WriteSVG( wxTextOutputStream
&stream
);
439 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
455 class wxCanvasLine
: public wxCanvasObject
458 wxCanvasLine( double x1
, double y1
, double x2
, double y2
);
459 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
462 double GetPosX() { return m_x1
; }
463 double GetPosY() { return m_y1
; }
464 void SetPosXY( double x
, double y
) {m_x1
=x
; m_y1
=y
; CalcBoundingBox();};
466 void TransLate( double x
, double y
);
468 void CalcBoundingBox();
470 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
471 virtual void WriteSVG( wxTextOutputStream
&stream
);
473 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
486 class wxCanvasImage
: public wxCanvasObject
489 wxCanvasImage( const wxImage
&image
, double x
, double y
, double w
, double h
);
491 double GetPosX() { return m_x
; }
492 double GetPosY() { return m_y
; }
493 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
495 void TransLate( double x
, double y
);
497 void CalcBoundingBox();
499 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
500 virtual void WriteSVG( wxTextOutputStream
&stream
);
513 //----------------------------------------------------------------------------
515 //----------------------------------------------------------------------------
517 class wxCanvasControl
: public wxCanvasObject
520 wxCanvasControl( wxWindow
*control
);
525 void SetPosXY( double x
, double y
);
527 void TransLate( double x
, double y
);
528 void MoveRelative( double x
, double y
);
530 void CalcBoundingBox();
538 class wxCanvasText
: public wxCanvasObject
541 wxCanvasText( const wxString
&text
, double x
, double y
, const wxString
&foneFile
, int size
);
544 double GetPosX() { return m_x
; }
545 double GetPosY() { return m_y
; }
546 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
548 void TransLate( double x
, double y
);
550 void CalcBoundingBox();
552 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
553 virtual void WriteSVG( wxTextOutputStream
&stream
);
555 void SetRGB( unsigned char red
, unsigned char green
, unsigned char blue
);
556 void SetFlag( int flag
);
557 int GetFlag() { return m_flag
; }
563 unsigned char *m_alpha
;
569 wxString m_fontFileName
;
574 // wxCanvas is used to display a wxCanvasGroupObject, which contains wxCanvasObject derived
575 // drawable objects. The group to draw is called the root.
576 // All objects are defined in world coordinates, relative to its parent (e.g. nested groups)
577 // There are methods to convert from world to device coordinates and visa versa.
578 // Rendering a draw is normally started on the root, it to a buffer, afterwords
579 // an update of the damaged parts will blitted from the buffer to the screen.
580 // This is done in Idle time, but can also be forced.
581 // World coordinates can be with the Y axis going up are down.
582 // The area of the drawing in world coordinates that is visible on the canvas
583 // can be set. Parts of this area can be zoomed into resulting in scroll bars
585 class wxCanvas
: public wxScrolledWindow
588 // constructors and destructors
589 wxCanvas( wxCanvasAdmin
* admin
,wxWindow
*parent
, wxWindowID id
= -1,
590 const wxPoint
& pos
= wxDefaultPosition
,
591 const wxSize
& size
= wxDefaultSize
,
592 long style
= wxScrolledWindowStyle
);
595 //background colour for the canvas
596 virtual void SetColour( const wxColour
& background
);
598 //update the area given in device coordinates
599 virtual void Update( int x
, int y
, int width
, int height
, bool blit
= TRUE
);
601 //blit all updated areas now to the screen, else it will happen in idle time.
602 //Use this to support dragging for instance, becuase in such cases idle time
604 virtual void UpdateNow();
606 //prevent canvas activety
607 virtual void Freeze();
608 //allow canvas activety
611 //get the buffer that is used for rendering in general
612 inline wxBitmap
*GetBuffer() { return &m_buffer
; }
613 //get the DC that is used for rendering
614 inline wxDC
*GetDC() { return m_renderDC
; }
615 //set the DC that is used for rendering
616 inline void SetDC(wxDC
* dc
) { m_renderDC
=dc
; }
618 inline int GetBufferWidth() { return m_buffer
.GetWidth(); }
619 inline int GetBufferHeight() { return m_buffer
.GetHeight(); }
621 //updating is needed for the canvas if the buffer did change
622 bool NeedUpdate() { return m_needUpdate
; }
623 bool IsFrozen() { return m_frozen
; }
625 //blit damaged areas in the buffer to the screen
626 void BlitBuffer( wxDC
&dc
);
628 //redirect events to this canvas object
629 void SetCaptureMouse( wxCanvasObject
*obj
);
630 //are events redirected, if so return the object else NULL
631 inline wxCanvasObject
* GetCaptured() { return m_captureMouse
;}
633 //set the root group where the objects for this canvas are stored
634 void SetRoot(wxCanvasObjectGroup
* aroot
){m_root
=aroot
;}
636 //get root group that is displayed on the canvas
637 wxCanvasObjectGroup
* GetRoot(){return m_root
;}
639 //scroll the window in device coordinates
640 virtual void ScrollWindow( int dx
, int dy
,
641 const wxRect
* rect
= (wxRect
*) NULL
);
643 //get y axis orientation
644 virtual bool GetYaxis() { return FALSE
; }
646 //get the visible part in world coordinates
647 virtual double GetMinX() const;
648 virtual double GetMinY() const;
649 virtual double GetMaxX() const;
650 virtual double GetMaxY() const;
652 //convert from window to virtual coordinates
653 virtual double DeviceToLogicalX(int x
) const;
654 virtual double DeviceToLogicalY(int y
) const;
655 virtual double DeviceToLogicalXRel(int x
) const;
656 virtual double DeviceToLogicalYRel(int y
) const;
657 virtual int LogicalToDeviceX(double x
) const;
658 virtual int LogicalToDeviceY(double y
) const;
659 virtual int LogicalToDeviceXRel(double x
) const;
660 virtual int LogicalToDeviceYRel(double y
) const;
665 //always available and m_buffer selected
669 wxList m_updateRects
;
670 wxCanvasObjectGroup
* m_root
;
672 wxColour m_background
;
674 wxCanvasObject
*m_lastMouse
;
675 wxCanvasObject
*m_captureMouse
;
677 int m_oldDeviceX
,m_oldDeviceY
;
679 wxCanvasAdmin
* m_admin
;
682 int m_bufferX
,m_bufferY
;
685 void OnMouse( wxMouseEvent
&event
);
686 void OnPaint( wxPaintEvent
&event
);
687 void OnSize( wxSizeEvent
&event
);
688 void OnIdle( wxIdleEvent
&event
);
689 void OnSetFocus( wxFocusEvent
&event
);
690 void OnKillFocus( wxFocusEvent
&event
);
691 void OnEraseBackground( wxEraseEvent
&event
);
694 DECLARE_CLASS(wxCanvas
)
695 DECLARE_EVENT_TABLE()
700 class wxVectorCanvas
: public wxCanvas
703 // constructors and destructors
704 wxVectorCanvas( wxCanvasAdmin
* admin
,wxWindow
*parent
, wxWindowID id
= -1,
705 const wxPoint
& pos
= wxDefaultPosition
,
706 const wxSize
& size
= wxDefaultSize
,
707 long style
= wxScrolledWindowStyle
);
709 //scroll the window in device coordinates
710 virtual void ScrollWindow( int dx
, int dy
,
711 const wxRect
* rect
= (wxRect
*) NULL
);
713 //set if the Yaxis goes up or down
714 void SetYaxis(bool up
) { m_yaxis
=up
; }
716 //get currently used Yaxis setting
717 virtual bool GetYaxis() { return m_yaxis
; }
719 //to set the total area in world coordinates that can be scrolled.
720 // when totaly zoomed out (SetMappingScroll same size as given here),
721 // this will be the area displayed.
722 // To display all of a drawing, set this here to the boundingbox of the root group
724 void SetScroll(double vx1
,double vy1
,double vx2
,double vy2
);
726 //given the virtual size to be displayed, the mappingmatrix will be calculated
727 //in such a manner that it fits (same ratio in width and height) to the window size.
728 //The window size is used to intitialize the mapping.
729 //The virtual size is just an indication, it will be ajusted to fit in the client window ratio.
730 //When border is set an extra margin is added so that the drawing will fit nicely.
731 // To display all of a drawing, set this here to the boundingbox of the root group
733 void SetMappingScroll(double vx1
,double vy1
,double vx2
,double vy2
,bool border
);
735 //matrix for calculating the virtual coordinate given a screen coordinate
736 wxTransformMatrix
GetInverseMappingMatrix();
738 //matrix for calculating the screen coordinate given a virtual coordinate
739 wxTransformMatrix
GetMappingMatrix();
741 //get minimum X of the visible part in world coordinates
742 virtual double GetMinX() const;
743 virtual double GetMinY() const;
744 virtual double GetMaxX() const;
745 virtual double GetMaxY() const;
747 //convert from window to virtual coordinates and back
748 virtual double DeviceToLogicalX(int x
) const;
749 virtual double DeviceToLogicalY(int y
) const;
750 virtual double DeviceToLogicalXRel(int x
) const;
751 virtual double DeviceToLogicalYRel(int y
) const;
752 virtual int LogicalToDeviceX(double x
) const;
753 virtual int LogicalToDeviceY(double y
) const;
754 virtual int LogicalToDeviceXRel(double x
) const;
755 virtual int LogicalToDeviceYRel(double y
) const;
761 // holds the matrix for mapping from virtual to screen coordinates
762 wxTransformMatrix m_mapping_matrix
;
764 // holds the inverse of the mapping matrix
765 wxTransformMatrix m_inverse_mapping
;
767 //virtual coordinates of total drawing
768 double m_virtm_minX
, m_virtm_minY
, m_virtm_maxX
, m_virtm_maxY
;
770 // virtual coordinates box
771 double m_virt_minX
, m_virt_minY
, m_virt_maxX
, m_virt_maxY
;
774 double m_minX
, m_minY
, m_maxX
, m_maxY
;
776 //are scroll bars active?
780 void OnScroll(wxScrollWinEvent
& event
);
781 void OnChar( wxKeyEvent
&event
);
782 void OnSize( wxSizeEvent
&event
);
785 DECLARE_CLASS(wxVectorCanvas
)
786 DECLARE_EVENT_TABLE()
792 //Contains a list of wxCanvas Objects that will be maintained through this class.
793 //Each wxCanvasObject can be displayed on several wxCanvas Objects at the same time.
794 //The active wxCanvas is used to render and convert coordinates from world to device.
795 //So it is important to set the active wxCanvas based on the wxCanvas that has the focus
796 //or is scrolled etc. This is normally done within wxCanvas when appropriate.
800 // constructors and destructors
802 virtual ~wxCanvasAdmin();
804 //convert from window to virtual coordinates
805 double DeviceToLogicalX(int x
) const;
806 //convert from window to virtual coordinates
807 double DeviceToLogicalY(int y
) const;
808 //convert from window to virtual coordinates relatif
809 double DeviceToLogicalXRel(int x
) const;
810 //convert from window to virtual coordinates relatif
811 double DeviceToLogicalYRel(int y
) const;
812 //convert from virtual to window coordinates
813 int LogicalToDeviceX(double x
) const;
814 //convert from virtual to window coordinates
815 int LogicalToDeviceY(double y
) const;
816 //convert from virtual to window coordinates relatif
817 int LogicalToDeviceXRel(double x
) const;
818 //convert from virtual to window coordinates relatif
819 int LogicalToDeviceYRel(double y
) const;
821 //update in the buffer off all canvases, the area given in world coordinates
822 virtual void Update(wxCanvasObject
* obj
, double x
, double y
, double width
, double height
);
824 //blit all updated areas now to the screen, else it will happen in idle time.
825 //Use this to support dragging for instance, becuase in such cases idle time
827 virtual void UpdateNow();
829 //append another canvas
830 virtual void Append( wxCanvas
* canvas
);
833 virtual void Remove( wxCanvas
* canvas
);
835 //set the given canvas as active (for rendering, coordinate conversion etc.)
836 void SetActive(wxCanvas
* activate
);
839 inline wxCanvas
* GetActive() {return m_active
;};