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
);
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
);
519 //----------------------------------------------------------------------------
521 //----------------------------------------------------------------------------
523 class wxCanvasControl
: public wxCanvasObject
526 wxCanvasControl( wxWindow
*control
);
531 void SetPosXY( double x
, double y
);
533 void TransLate( double x
, double y
);
534 void MoveRelative( double x
, double y
);
536 void CalcBoundingBox();
544 class wxCanvasText
: public wxCanvasObject
547 wxCanvasText( const wxString
&text
, double x
, double y
, const wxString
&foneFile
, int size
);
550 double GetPosX() { return m_x
; }
551 double GetPosY() { return m_y
; }
552 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
554 void TransLate( double x
, double y
);
556 void CalcBoundingBox();
558 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
559 virtual void WriteSVG( wxTextOutputStream
&stream
);
561 void SetRGB( unsigned char red
, unsigned char green
, unsigned char blue
);
562 void SetFlag( int flag
);
563 int GetFlag() { return m_flag
; }
569 unsigned char *m_alpha
;
575 wxString m_fontFileName
;
580 // wxCanvas is used to display a wxCanvasGroupObject, which contains wxCanvasObject derived
581 // drawable objects. The group to draw is called the root.
582 // All objects are defined in world coordinates, relative to its parent (e.g. nested groups)
583 // There are methods to convert from world to device coordinates and visa versa.
584 // Rendering a draw is normally started on the root, it to a buffer, afterwords
585 // an update of the damaged parts will blitted from the buffer to the screen.
586 // This is done in Idle time, but can also be forced.
587 // World coordinates can be with the Y axis going up are down.
588 // The area of the drawing in world coordinates that is visible on the canvas
589 // can be set. Parts of this area can be zoomed into resulting in scroll bars
591 class wxCanvas
: public wxScrolledWindow
594 // constructors and destructors
595 wxCanvas( wxCanvasAdmin
* admin
,wxWindow
*parent
, wxWindowID id
= -1,
596 const wxPoint
& pos
= wxDefaultPosition
,
597 const wxSize
& size
= wxDefaultSize
,
598 long style
= wxScrolledWindowStyle
);
601 //background colour for the canvas
602 virtual void SetColour( const wxColour
& background
);
604 //update the area given in device coordinates
605 virtual void Update( int x
, int y
, int width
, int height
, bool blit
= TRUE
);
607 //blit all updated areas now to the screen, else it will happen in idle time.
608 //Use this to support dragging for instance, becuase in such cases idle time
610 virtual void UpdateNow();
612 //prevent canvas activety
613 virtual void Freeze();
614 //allow canvas activety
617 //get the buffer that is used for rendering in general
618 inline wxBitmap
*GetBuffer() { return &m_buffer
; }
619 //get the DC that is used for rendering
620 inline wxDC
*GetDC() { return m_renderDC
; }
621 //set the DC that is used for rendering
622 inline void SetDC(wxDC
* dc
) { m_renderDC
=dc
; }
624 inline int GetBufferWidth() { return m_buffer
.GetWidth(); }
625 inline int GetBufferHeight() { return m_buffer
.GetHeight(); }
627 //updating is needed for the canvas if the buffer did change
628 bool NeedUpdate() { return m_needUpdate
; }
629 bool IsFrozen() { return m_frozen
; }
631 //blit damaged areas in the buffer to the screen
632 void BlitBuffer( wxDC
&dc
);
634 //redirect events to this canvas object
635 void SetCaptureMouse( wxCanvasObject
*obj
);
636 //are events redirected, if so return the object else NULL
637 inline wxCanvasObject
* GetCaptured() { return m_captureMouse
;}
639 //set the root group where the objects for this canvas are stored
640 void SetRoot(wxCanvasObjectGroup
* aroot
){m_root
=aroot
;}
642 //get root group that is displayed on the canvas
643 wxCanvasObjectGroup
* GetRoot(){return m_root
;}
645 //scroll the window in device coordinates
646 virtual void ScrollWindow( int dx
, int dy
,
647 const wxRect
* rect
= (wxRect
*) NULL
);
649 //get y axis orientation
650 virtual bool GetYaxis() { return FALSE
; }
652 //get the visible part in world coordinates
653 virtual double GetMinX() const;
654 virtual double GetMinY() const;
655 virtual double GetMaxX() const;
656 virtual double GetMaxY() const;
658 //convert from window to virtual coordinates
659 virtual double DeviceToLogicalX(int x
) const;
660 virtual double DeviceToLogicalY(int y
) const;
661 virtual double DeviceToLogicalXRel(int x
) const;
662 virtual double DeviceToLogicalYRel(int y
) const;
663 virtual int LogicalToDeviceX(double x
) const;
664 virtual int LogicalToDeviceY(double y
) const;
665 virtual int LogicalToDeviceXRel(double x
) const;
666 virtual int LogicalToDeviceYRel(double y
) const;
671 //always available and m_buffer selected
675 wxList m_updateRects
;
676 wxCanvasObjectGroup
* m_root
;
678 wxColour m_background
;
680 wxCanvasObject
*m_lastMouse
;
681 wxCanvasObject
*m_captureMouse
;
683 int m_oldDeviceX
,m_oldDeviceY
;
685 wxCanvasAdmin
* m_admin
;
688 int m_bufferX
,m_bufferY
;
691 void OnMouse( wxMouseEvent
&event
);
692 void OnPaint( wxPaintEvent
&event
);
693 void OnSize( wxSizeEvent
&event
);
694 void OnIdle( wxIdleEvent
&event
);
695 void OnSetFocus( wxFocusEvent
&event
);
696 void OnKillFocus( wxFocusEvent
&event
);
697 void OnEraseBackground( wxEraseEvent
&event
);
700 DECLARE_CLASS(wxCanvas
)
701 DECLARE_EVENT_TABLE()
706 class wxVectorCanvas
: public wxCanvas
709 // constructors and destructors
710 wxVectorCanvas( wxCanvasAdmin
* admin
,wxWindow
*parent
, wxWindowID id
= -1,
711 const wxPoint
& pos
= wxDefaultPosition
,
712 const wxSize
& size
= wxDefaultSize
,
713 long style
= wxScrolledWindowStyle
);
715 //scroll the window in device coordinates
716 virtual void ScrollWindow( int dx
, int dy
,
717 const wxRect
* rect
= (wxRect
*) NULL
);
719 //set if the Yaxis goes up or down
720 void SetYaxis(bool up
) { m_yaxis
=up
; }
722 //get currently used Yaxis setting
723 virtual bool GetYaxis() { return m_yaxis
; }
725 //to set the total area in world coordinates that can be scrolled.
726 // when totaly zoomed out (SetMappingScroll same size as given here),
727 // this will be the area displayed.
728 // To display all of a drawing, set this here to the boundingbox of the root group
730 void SetScroll(double vx1
,double vy1
,double vx2
,double vy2
);
732 //given the virtual size to be displayed, the mappingmatrix will be calculated
733 //in such a manner that it fits (same ratio in width and height) to the window size.
734 //The window size is used to intitialize the mapping.
735 //The virtual size is just an indication, it will be ajusted to fit in the client window ratio.
736 //When border is set an extra margin is added so that the drawing will fit nicely.
737 // To display all of a drawing, set this here to the boundingbox of the root group
739 void SetMappingScroll(double vx1
,double vy1
,double vx2
,double vy2
,bool border
);
741 //matrix for calculating the virtual coordinate given a screen coordinate
742 wxTransformMatrix
GetInverseMappingMatrix();
744 //matrix for calculating the screen coordinate given a virtual coordinate
745 wxTransformMatrix
GetMappingMatrix();
747 //get minimum X of the visible part in world coordinates
748 virtual double GetMinX() const;
749 virtual double GetMinY() const;
750 virtual double GetMaxX() const;
751 virtual double GetMaxY() const;
753 //convert from window to virtual coordinates and back
754 virtual double DeviceToLogicalX(int x
) const;
755 virtual double DeviceToLogicalY(int y
) const;
756 virtual double DeviceToLogicalXRel(int x
) const;
757 virtual double DeviceToLogicalYRel(int y
) const;
758 virtual int LogicalToDeviceX(double x
) const;
759 virtual int LogicalToDeviceY(double y
) const;
760 virtual int LogicalToDeviceXRel(double x
) const;
761 virtual int LogicalToDeviceYRel(double y
) const;
767 // holds the matrix for mapping from virtual to screen coordinates
768 wxTransformMatrix m_mapping_matrix
;
770 // holds the inverse of the mapping matrix
771 wxTransformMatrix m_inverse_mapping
;
773 //virtual coordinates of total drawing
774 double m_virtm_minX
, m_virtm_minY
, m_virtm_maxX
, m_virtm_maxY
;
776 // virtual coordinates box
777 double m_virt_minX
, m_virt_minY
, m_virt_maxX
, m_virt_maxY
;
780 double m_minX
, m_minY
, m_maxX
, m_maxY
;
782 //are scroll bars active?
786 void OnScroll(wxScrollWinEvent
& event
);
787 void OnChar( wxKeyEvent
&event
);
788 void OnSize( wxSizeEvent
&event
);
791 DECLARE_CLASS(wxVectorCanvas
)
792 DECLARE_EVENT_TABLE()
798 //Contains a list of wxCanvas Objects that will be maintained through this class.
799 //Each wxCanvasObject can be displayed on several wxCanvas Objects at the same time.
800 //The active wxCanvas is used to render and convert coordinates from world to device.
801 //So it is important to set the active wxCanvas based on the wxCanvas that has the focus
802 //or is scrolled etc. This is normally done within wxCanvas when appropriate.
806 // constructors and destructors
808 virtual ~wxCanvasAdmin();
810 //convert from window to virtual coordinates
811 double DeviceToLogicalX(int x
) const;
812 //convert from window to virtual coordinates
813 double DeviceToLogicalY(int y
) const;
814 //convert from window to virtual coordinates relatif
815 double DeviceToLogicalXRel(int x
) const;
816 //convert from window to virtual coordinates relatif
817 double DeviceToLogicalYRel(int y
) const;
818 //convert from virtual to window coordinates
819 int LogicalToDeviceX(double x
) const;
820 //convert from virtual to window coordinates
821 int LogicalToDeviceY(double y
) const;
822 //convert from virtual to window coordinates relatif
823 int LogicalToDeviceXRel(double x
) const;
824 //convert from virtual to window coordinates relatif
825 int LogicalToDeviceYRel(double y
) const;
827 //update in the buffer off all canvases, the area given in world coordinates
828 virtual void Update(wxCanvasObject
* obj
, double x
, double y
, double width
, double height
);
830 //blit all updated areas now to the screen, else it will happen in idle time.
831 //Use this to support dragging for instance, becuase in such cases idle time
833 virtual void UpdateNow();
835 //append another canvas
836 virtual void Append( wxCanvas
* canvas
);
839 virtual void Remove( wxCanvas
* canvas
);
841 //set the given canvas as active (for rendering, coordinate conversion etc.)
842 void SetActive(wxCanvas
* activate
);
845 inline wxCanvas
* GetActive() {return m_active
;};