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 //----------------------------------------------------------------------------
31 #define IMAGE_CANVAS 0
36 //----------------------------------------------------------------------------
38 //----------------------------------------------------------------------------
39 enum DRAGMODE
{DRAG_RECTANGLE
,DRAG_ONTOP
,DRAG_REDRAW
};
42 // wxCanvasObject is the base class for Canvas Objects.
43 // All Objects for drawing one the canvas are derived from this class.
44 // It supports dragging and moving methods that can be used in derived
45 // classes for defining several ways of dragging.
46 // Also it is possible to plug in events handlers to do this for all derived classes at once.
48 // wxCanvasObjects have themselves as their event handlers by default,
49 // but their event handlers could be set to another object entirely. This
50 // separation can reduce the amount of derivation required, and allow
51 // alteration of a wxCanvasObject functionality
52 class wxCanvasObject
: public wxEvtHandler
58 //If the position (x,y) is within the object this return a pointer to the object
59 //Normally this function needs to be defined for each derived wxCanvasObject.
60 //The default is a simple bounding box test.
61 virtual wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
63 //render this object to the canvas (either on its buffer or directly on the canvas)
64 //this depends on the wxDC that is set for the active canvas.
65 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
67 //x position in world coordinates of the object
68 virtual double GetPosX()=0;
69 //y position in world coordinates of the object
70 virtual double GetPosY()=0;
72 //set position in world coordinates for the object
73 virtual void SetPosXY( double x
, double y
)=0;
75 //absolute moving the object to position x,y in world coordinates
76 //also does an update of the old and new area
77 virtual void MoveAbsolute( double x
, double y
);
79 //relative moving the object to position x,y in world coordinates
80 //also does an update of the old and new area
81 virtual void MoveRelative( double x
, double y
);
83 //relative translate the object to position x,y in world coordinates
84 //does NOT update the old and new area
85 //this function must be defined for each derived object,
86 //it is used internally for dragging and moving objects.
87 virtual void TransLate( double x
, double y
)=0;
89 //choose one of the three diffrenet drag methods |
90 //DRAG_RECTANGLE = as a rectangle when drag is in progress |
91 //DRAG_ONTOP = only redraw the object when dragging |
92 //DRAG_REDRAW = redraw the damaged areas when dragging
93 void SetDragMode(DRAGMODE mode
) { m_dragmode
=mode
; };
96 DRAGMODE
GetDragMode() { return m_dragmode
; };
98 //called when starting a drag
99 virtual void DragStart();
100 //called when dragging is in progress
101 virtual void DragRelative( double x
, double y
);
102 //called when dragging is ended
103 virtual void DragEnd();
105 //return the object if it is part of the given object or
106 //if the given object is part of a group within this object.
107 //For group objects this means recursively search for it.
108 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
110 //calculate the boundingbox in world coordinates
111 virtual void CalcBoundingBox()=0;
113 //write the object as SVG (scalable vector grafhics
114 virtual void WriteSVG( wxTextOutputStream
&stream
);
116 //get the administrator for the object,
117 //this will give access to the canvas's where it is displayed upon.
118 //It is used to render the object to the active canvas.
119 //Conversion from world to Device coordinates and visa versa is
120 //done using the Active canvas at that moment.
121 wxCanvasAdmin
*GetAdmin() { return m_admin
; }
123 //set the administrator
124 virtual void SetAdmin( wxCanvasAdmin
*admin
) { m_admin
= admin
; }
126 //is this a control type of canvas object
127 bool IsControl() { return m_isControl
; }
128 //is this a vector type of canvas object
129 bool IsVector() { return m_isVector
; }
130 //is this an Image type of canvas object
131 bool IsImage() { return m_isImage
; }
133 //get minimum X of the boundingbox in world coordinates
134 inline double GetXMin() { return m_bbox
.GetMinX(); }
135 //get minimum Y of the boundingbox in world coordinates
136 inline double GetYMin() { return m_bbox
.GetMinY(); }
137 //get maximum X of the boundingbox in world coordinates
138 inline double GetXMax() { return m_bbox
.GetMaxX(); }
139 //get maximum Y of the boundingbox in world coordinates
140 inline double GetYMax() { return m_bbox
.GetMaxY(); }
143 inline wxBoundingBox
GetBbox() { return m_bbox
; }
145 //redirect all mouse events for the canvas to this object
147 //release the mouse capture for this object
149 //is the mouse captured for this object
150 bool IsCapturedMouse();
152 //set if this object will visible (be rendered or not)
153 inline void SetVisible(bool visible
) { m_visible
=visible
; }
155 inline bool GetVisible() {return m_visible
; }
157 //can the object be dragged
158 inline void SetDraggable(bool drag
) { m_dragable
=drag
; }
159 //get if the object can be dragged
160 inline bool GetDraggable() {return m_dragable
; }
162 //get absolute area in the device coordinates where the object
163 //its boundingbox in world coordinates is first translated using the matrix.
164 wxRect
GetAbsoluteArea(const wxTransformMatrix
& cworld
);
166 //get currently used eventhandler (always the first in the list)
167 wxEvtHandler
*GetEventHandler() const { return m_eventHandler
; }
169 //process an event for the object, starting with the first eventhandler
171 bool ProcessCanvasObjectEvent(wxEvent
& event
);
173 // push/pop event handler: allows to chain a custom event handler to
174 // already existing ones
175 void PushEventHandler( wxEvtHandler
*handler
);
177 //remove first eventhandler in the list (one will be always stay in)
178 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
179 //append an eventhandler to the list, this event handler will be called
180 //if the other skipped the event to process.
181 void AppendEventHandler(wxEvtHandler
*handler
);
182 //remove last event handler in the list (one will always stay in)
183 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
187 //administator for rendering and accessing the canvas's
188 wxCanvasAdmin
* m_admin
;
190 //active event handler, default the object itself
191 wxEvtHandler
* m_eventHandler
;
198 DRAGMODE m_dragmode
:2;
200 //boundingbox in world coordinates
201 wxBoundingBox m_bbox
;
208 // wxCanvasObjectGroup is a container for wxCanvas derived Objects.
209 // It renders itself by calling the render methods of the wxCanvasObjects it contains.
210 // It can have nested groups also, in the same way as the other wxCanvasObjects it already contains.
211 // The group has a matrix to position/rotate/scale the group.
212 class wxCanvasObjectGroup
: public wxCanvasObject
215 wxCanvasObjectGroup(double x
, double y
);
216 virtual ~wxCanvasObjectGroup();
218 void SetAdmin(wxCanvasAdmin
* admin
);
220 //prepend a wxCanvasObject to this group
221 virtual void Prepend( wxCanvasObject
* obj
);
222 //append a wxCanvasObject to this group
223 virtual void Append( wxCanvasObject
* obj
);
224 //insert a wxCanvasObject to this group
225 virtual void Insert( size_t before
, wxCanvasObject
* obj
);
226 //remove the given object from the group
227 virtual void Remove( wxCanvasObject
* obj
);
229 //those this group contain the given object.
230 //in case of nested groups also search in there to the lowwest level.
231 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
233 //returns index of the given wxCanvasObject in this group
234 virtual int IndexOf( wxCanvasObject
* obj
);
236 double GetPosX() { return lworld
.GetValue(2,0); }
237 double GetPosY() { return lworld
.GetValue(2,1); }
238 void SetPosXY( double x
, double y
) {lworld
.SetValue(2,0,x
);lworld
.SetValue(2,1,y
);CalcBoundingBox();};
240 void TransLate( double x
, double y
);
242 void CalcBoundingBox();
243 //remove all wxCanvasObjects from the group (flag for deletion of the objectsalso)
244 void DeleteContents( bool );
245 virtual void Render(wxTransformMatrix
* cworld
,int x
, int y
, int width
, int height
);
246 virtual void WriteSVG( wxTextOutputStream
&stream
);
248 //recursive call the IsHitWorld on all contained objects, the first
249 //one that is hit will be returned
250 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
252 //recursive calls for contained objects to set eventhandlers,
253 //and also sets its own eventhandler
254 void PushEventHandler( wxEvtHandler
*handler
);
255 //recursive calls for contained objects to set eventhandlers,
256 //and also sets its own eventhandler
257 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
258 //recursive calls for contained objects to set eventhandlers,
259 //and also sets its own eventhandler
260 void AppendEventHandler(wxEvtHandler
*handler
);
261 //recursive calls for contained objects to set eventhandlers,
262 //and also sets its own eventhandler
263 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
267 //to position the object
268 wxTransformMatrix lworld
;
272 friend class wxCanvas
;
276 // wxCanvasObjectRef is a reference to any wxCanvasObject derived class.
277 // It does not duplicate the referenced object.
278 // It has a matrix to reposition/rotate/scale the object it references.
279 // The position/matrix of the referenced Object is accumulated with the one here.
280 class wxCanvasObjectRef
: public wxCanvasObject
283 wxCanvasObjectRef(double x
, double y
,wxCanvasObject
* obj
);
285 //set rotation for the reference
286 void SetRotation(double rotation
);
288 //set scale in x and y ( > zero)
289 void SetScale( double scalex
, double scaley
);
291 void SetAdmin(wxCanvasAdmin
* admin
);
293 double GetPosX() { return lworld
.GetValue(2,0); }
294 double GetPosY() { return lworld
.GetValue(2,1); }
295 void SetPosXY( double x
, double y
) {lworld
.SetValue(2,0,x
);lworld
.SetValue(2,1,y
);CalcBoundingBox();};
297 void TransLate( double x
, double y
);
298 void CalcBoundingBox();
299 virtual void Render(wxTransformMatrix
* cworld
,int x
, int y
, int width
, int height
);
300 virtual void WriteSVG( wxTextOutputStream
&stream
);
302 //return this object if one of the objects it references is hit
303 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
304 virtual wxCanvasObject
* Contains( wxCanvasObject
* obj
);
306 //recursive calls for contained objects to set eventhandlers,
307 //and also sets its own eventhandler
308 void PushEventHandler( wxEvtHandler
*handler
);
309 //recursive calls for contained objects to set eventhandlers,
310 //and also sets its own eventhandler
311 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
312 //recursive calls for contained objects to set eventhandlers,
313 //and also sets its own eventhandler
314 void AppendEventHandler(wxEvtHandler
*handler
);
315 //recursive calls for contained objects to set eventhandlers,
316 //and also sets its own eventhandler
317 wxEvtHandler
*RemoveLastEventHandler(bool deleteHandler
);
321 //to position the object
322 wxTransformMatrix lworld
;
324 //reference to another wxCanvasObject
325 wxCanvasObject
* m_obj
;
330 class wxCanvasRect
: public wxCanvasObject
333 wxCanvasRect( double x
, double y
, double w
, double h
, double radius
=0 );
334 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
335 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
337 double GetPosX() { return m_x
; }
338 double GetPosY() { return m_y
; }
339 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
341 void TransLate( double x
, double y
);
342 void CalcBoundingBox();
344 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
345 virtual void WriteSVG( wxTextOutputStream
&stream
);
358 //----------------------------------------------------------------------------
360 //----------------------------------------------------------------------------
361 class wxCanvasCircle
: public wxCanvasObject
364 wxCanvasCircle( double x
, double y
, double radius
);
365 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
366 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
368 double GetPosX() { return m_x
; }
369 double GetPosY() { return m_y
; }
370 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
372 void TransLate( double x
, double y
);
374 void CalcBoundingBox();
376 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
377 virtual void WriteSVG( wxTextOutputStream
&stream
);
379 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
392 class wxCanvasEllipse
: public wxCanvasObject
395 wxCanvasEllipse( double x
, double y
, double width
, double height
);
396 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
397 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
399 double GetPosX() { return m_x
; }
400 double GetPosY() { return m_y
; }
401 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
403 void TransLate( double x
, double y
);
405 void CalcBoundingBox();
407 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
408 virtual void WriteSVG( wxTextOutputStream
&stream
);
410 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
423 // wxCanvasEllipticArc
424 class wxCanvasEllipticArc
: public wxCanvasObject
427 wxCanvasEllipticArc( double x
, double y
, double width
, double height
, double start
, double end
);
428 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; };
429 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
431 double GetPosX() { return m_x
; }
432 double GetPosY() { return m_y
; }
433 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
; CalcBoundingBox();};
435 void TransLate( double x
, double y
);
436 void CalcBoundingBox();
438 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
439 virtual void WriteSVG( wxTextOutputStream
&stream
);
441 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
457 class wxCanvasLine
: public wxCanvasObject
460 wxCanvasLine( double x1
, double y1
, double x2
, double y2
);
461 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); };
464 double GetPosX() { return m_x1
; }
465 double GetPosY() { return m_y1
; }
466 void SetPosXY( double x
, double y
) {m_x1
=x
; m_y1
=y
; CalcBoundingBox();};
468 void TransLate( double x
, double y
);
470 void CalcBoundingBox();
472 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
473 virtual void WriteSVG( wxTextOutputStream
&stream
);
475 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
488 class wxCanvasImage
: public wxCanvasObject
491 wxCanvasImage( const wxImage
&image
, double x
, double y
, double w
, double h
);
493 double GetPosX() { return m_x
; }
494 double GetPosY() { return m_y
; }
495 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
497 void TransLate( double x
, double y
);
499 void CalcBoundingBox();
501 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
502 virtual void WriteSVG( wxTextOutputStream
&stream
);
515 //----------------------------------------------------------------------------
517 //----------------------------------------------------------------------------
519 class wxCanvasControl
: public wxCanvasObject
522 wxCanvasControl( wxWindow
*control
);
527 void SetPosXY( double x
, double y
);
529 void TransLate( double x
, double y
);
530 void MoveRelative( double x
, double y
);
532 void CalcBoundingBox();
540 class wxCanvasText
: public wxCanvasObject
543 wxCanvasText( const wxString
&text
, double x
, double y
, const wxString
&foneFile
, int size
);
546 double GetPosX() { return m_x
; }
547 double GetPosY() { return m_y
; }
548 void SetPosXY( double x
, double y
) {m_x
=x
; m_y
=y
;CalcBoundingBox(); };
550 void TransLate( double x
, double y
);
552 void CalcBoundingBox();
554 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
555 virtual void WriteSVG( wxTextOutputStream
&stream
);
557 void SetRGB( unsigned char red
, unsigned char green
, unsigned char blue
);
558 void SetFlag( int flag
);
559 int GetFlag() { return m_flag
; }
565 unsigned char *m_alpha
;
571 wxString m_fontFileName
;
576 // wxCanvas is used to display a wxCanvasGroupObject, which contains wxCanvasObject derived
577 // drawable objects. The group to draw is called the root.
578 // All objects are defined in world coordinates, relative to its parent (e.g. nested groups)
579 // There are methods to convert from world to device coordinates and visa versa.
580 // Rendering a draw is normally started on the root, it to a buffer, afterwords
581 // an update of the damaged parts will blitted from the buffer to the screen.
582 // This is done in Idle time, but can also be forced.
583 // World coordinates can be with the Y axis going up are down.
584 // The area of the drawing in world coordinates that is visible on the canvas
585 // can be set. Parts of this area can be zoomed into resulting in scroll bars
587 class wxCanvas
: public wxWindow
590 // constructors and destructors
591 wxCanvas( wxCanvasAdmin
* admin
,wxWindow
*parent
, wxWindowID id
= -1,
592 const wxPoint
& pos
= wxDefaultPosition
,
593 const wxSize
& size
= wxDefaultSize
,
594 long style
= wxScrolledWindowStyle
);
597 //intercept scroll events
598 virtual void OnScroll(wxScrollWinEvent
& event
);
600 //background colour for the canvas
601 virtual void SetColour( const wxColour
& background
);
603 //update the area given in device coordinates
604 virtual void Update( int x
, int y
, int width
, int height
, bool blit
= TRUE
);
606 //blit all updated areas now to the screen, else it will happen in idle time.
607 //Use this to support dragging for instance, becuase in such cases idle time
609 virtual void UpdateNow();
611 //prevent canvas activety
612 virtual void Freeze();
613 //allow canvas activety
617 inline wxImage
*GetBuffer() { return &m_buffer
; }
619 //get the buffer that is used for rendering in general
620 inline wxBitmap
*GetBuffer() { return &m_buffer
; }
621 //get the DC that is used for rendering
622 inline wxDC
*GetDC() { return m_renderDC
; }
623 //set the DC that is used for rendering
624 inline void SetDC(wxDC
* dc
) { m_renderDC
=dc
; }
627 inline int GetBufferWidth() { return m_buffer
.GetWidth(); }
628 inline int GetBufferHeight() { return m_buffer
.GetHeight(); }
630 //updating is needed for the canvas if the buffer did change
631 bool NeedUpdate() { return m_needUpdate
; }
632 bool IsFrozen() { return m_frozen
; }
634 //blit damaged areas in the buffer to the screen
635 void BlitBuffer( wxDC
&dc
);
637 //redirect events to this canvas object
638 void SetCaptureMouse( wxCanvasObject
*obj
);
639 //are events redirected, if so return the object else NULL
640 inline wxCanvasObject
* GetCaptured() { return m_captureMouse
;}
642 //set the root group where the objects for this canvas are stored
643 void SetRoot(wxCanvasObjectGroup
* aroot
){m_root
=aroot
;}
645 //get root group that is displayed on the canvas
646 wxCanvasObjectGroup
* GetRoot(){return m_root
;}
648 //scroll the window in device coordinates
649 virtual void ScrollWindow( int dx
, int dy
,
650 const wxRect
* rect
= (wxRect
*) NULL
);
652 //set if the Yaxis goes up or down
653 void SetYaxis(bool up
){m_yaxis
=up
;}
655 //get currently used Yaxis setting
656 bool GetYaxis(){return m_yaxis
;}
658 //to set the total area in world coordinates that can be scrolled.
659 // when totaly zoomed out (SetMappingScroll same size as given here),
660 // this will be the area displayed.
661 // To display all of a drawing, set this here to the boundingbox of the root group
663 void SetScroll(double vx1
,double vy1
,double vx2
,double vy2
);
665 //given the virtual size to be displayed, the mappingmatrix will be calculated
666 //in such a manner that it fits (same ratio in width and height) to the window size.
667 //The window size is used to intitialize the mapping.
668 //The virtual size is just an indication, it will be ajusted to fit in the client window ratio.
669 //When border is set an extra margin is added so that the drawing will fit nicely.
670 // To display all of a drawing, set this here to the boundingbox of the root group
672 void SetMappingScroll(double vx1
,double vy1
,double vx2
,double vy2
,bool border
);
674 //matrix for calculating the virtual coordinate given a screen coordinate
675 wxTransformMatrix
GetInverseMappingMatrix();
677 //matrix for calculating the screen coordinate given a virtual coordinate
678 wxTransformMatrix
GetMappingMatrix();
680 //get minimum X of the visible part in world coordinates
681 inline double GetMinX(){return m_virt_minX
;};
682 //get minimum Y of the visible part in world coordinates
683 inline double GetMinY(){return m_virt_minY
;};
684 //get maximum X of the visible part in world coordinates
685 inline double GetMaxX(){return m_virt_maxX
;};
686 //get maximum Y of the visible part in world coordinates
687 inline double GetMaxY(){return m_virt_maxY
;};
690 //convert from window to virtual coordinates
691 double DeviceToLogicalX(int x
) const;
692 //convert from window to virtual coordinates
693 double DeviceToLogicalY(int y
) const;
694 //convert from window to virtual coordinates relatif
695 double DeviceToLogicalXRel(int x
) const;
696 //convert from window to virtual coordinates relatif
697 double DeviceToLogicalYRel(int y
) const;
698 //convert from virtual to window coordinates
699 int LogicalToDeviceX(double x
) const;
700 //convert from virtual to window coordinates
701 int LogicalToDeviceY(double y
) const;
702 //convert from virtual to window coordinates relatif
703 int LogicalToDeviceXRel(double x
) const;
704 //convert from virtual to window coordinates relatif
705 int LogicalToDeviceYRel(double y
) const;
711 // holds the matrix for mapping from virtual to screen coordinates
712 wxTransformMatrix m_mapping_matrix
;
714 // holds the inverse of the mapping matrix
715 wxTransformMatrix m_inverse_mapping
;
717 //virtual coordinates of total drawing
718 double m_virtm_minX
, m_virtm_minY
, m_virtm_maxX
, m_virtm_maxY
;
720 // virtual coordinates box
721 double m_virt_minX
, m_virt_minY
, m_virt_maxX
, m_virt_maxY
;
724 double m_minX
, m_minY
, m_maxX
, m_maxY
;
726 //are scroll bars active?
735 //always available and m_buffer selected
739 wxList m_updateRects
;
740 wxCanvasObjectGroup
* m_root
;
742 wxColour m_background
;
744 wxCanvasObject
*m_lastMouse
;
745 wxCanvasObject
*m_captureMouse
;
747 int m_oldDeviceX
,m_oldDeviceY
;
749 wxCanvasAdmin
* m_admin
;
753 void OnMouse( wxMouseEvent
&event
);
756 void OnChar( wxKeyEvent
&event
);
757 void OnPaint( wxPaintEvent
&event
);
758 void OnSize( wxSizeEvent
&event
);
759 void OnIdle( wxIdleEvent
&event
);
760 void OnSetFocus( wxFocusEvent
&event
);
761 void OnKillFocus( wxFocusEvent
&event
);
762 void OnEraseBackground( wxEraseEvent
&event
);
765 DECLARE_CLASS(wxCanvas
)
766 DECLARE_EVENT_TABLE()
771 //Contains a list of wxCanvas Objects that will be maintained through this class.
772 //Each wxCanvasObject can be displayed on several wxCanvas Objects at the same time.
773 //The active wxCanvas is used to render and convert coordinates from world to device.
774 //So it is important to set the active wxCanvas based on the wxCanvas that has the focus
775 //or is scrolled etc. This is normally done within wxCanvas when appropriate.
779 // constructors and destructors
781 virtual ~wxCanvasAdmin();
783 //convert from window to virtual coordinates
784 double DeviceToLogicalX(int x
) const;
785 //convert from window to virtual coordinates
786 double DeviceToLogicalY(int y
) const;
787 //convert from window to virtual coordinates relatif
788 double DeviceToLogicalXRel(int x
) const;
789 //convert from window to virtual coordinates relatif
790 double DeviceToLogicalYRel(int y
) const;
791 //convert from virtual to window coordinates
792 int LogicalToDeviceX(double x
) const;
793 //convert from virtual to window coordinates
794 int LogicalToDeviceY(double y
) const;
795 //convert from virtual to window coordinates relatif
796 int LogicalToDeviceXRel(double x
) const;
797 //convert from virtual to window coordinates relatif
798 int LogicalToDeviceYRel(double y
) const;
800 //update in the buffer off all canvases, the area given in world coordinates
801 virtual void Update(wxCanvasObject
* obj
, double x
, double y
, double width
, double height
);
803 //blit all updated areas now to the screen, else it will happen in idle time.
804 //Use this to support dragging for instance, becuase in such cases idle time
806 virtual void UpdateNow();
808 //append another canvas
809 virtual void Append( wxCanvas
* canvas
);
812 virtual void Remove( wxCanvas
* canvas
);
814 //set the given canvas as active (for rendering, coordinate conversion etc.)
815 void SetActive(wxCanvas
* activate
);
818 inline wxCanvas
* GetActive() {return m_active
;};