]>
git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/canvas/canvas.h
d3a416e60e92efebdff184dd06346e255de4dbe1
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"
25 // WDR: class declarations
27 //----------------------------------------------------------------------------
29 //----------------------------------------------------------------------------
31 class wxCanvasObject
: public wxEvtHandler
36 // Area occupied by object. Used for clipping, intersection,
37 // mouse enter etc. Screen coordinates
38 void SetArea( int x
, int y
, int width
, int height
);
39 void SetArea( wxRect rect
);
41 // These are for screen output only therefore use
42 // int as coordinates.
43 virtual bool IsHit( int x
, int y
, int margin
= 0 );
44 virtual void Render(int xabs
, int yabs
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
47 virtual void Move( int x
, int y
);
49 // Once we have world coordinates in doubles, this will get
50 // called for every object if the world coordinate system
52 virtual void Recreate();
55 virtual void WriteSVG( wxTextOutputStream
&stream
);
57 wxCanvas
*GetOwner() { return m_owner
; }
58 virtual void SetOwner( wxCanvas
*owner
) { m_owner
= owner
; }
60 bool IsControl() { return m_isControl
; }
61 bool IsVector() { return m_isVector
; }
62 bool IsImage() { return m_isImage
; }
63 inline int GetX() { return m_area
.x
; }
64 inline int GetY() { return m_area
.y
; }
65 inline int GetWidth() { return m_area
.width
; }
66 inline int GetHeight() { return m_area
.height
; }
70 bool IsCapturedMouse();
78 //relative boundingbox in parent in pixels
81 friend class wxCanvas
;
84 //----------------------------------------------------------------------------
85 // wxCanvasObjectGroup
86 //----------------------------------------------------------------------------
88 class wxCanvasObjectGroup
91 wxCanvasObjectGroup();
92 virtual ~wxCanvasObjectGroup();
94 void SetOwner(wxCanvas
* canvas
);
95 wxCanvas
*GetOwner() { return m_owner
; }
97 virtual void Prepend( wxCanvasObject
* obj
);
98 virtual void Append( wxCanvasObject
* obj
);
99 virtual void Insert( size_t before
, wxCanvasObject
* obj
);
100 virtual void Remove( wxCanvasObject
* obj
);
102 virtual void Recreate();
103 void DeleteContents( bool );
104 virtual void Render(int xabs
, int yabs
,int x
, int y
, int width
, int height
);
105 virtual void WriteSVG( wxTextOutputStream
&stream
);
106 virtual bool IsHit( int x
, int y
, int margin
);
107 virtual wxCanvasObject
* IsHitObject( int x
, int y
, int margin
);
109 void ExtendArea(int x
, int y
);
111 inline int GetXMin() { return m_minx
; }
112 inline int GetYMin() { return m_miny
; }
113 inline int GetXMax() { return m_maxx
; }
114 inline int GetYMax() { return m_maxy
; }
128 friend class wxCanvas
;
131 //----------------------------------------------------------------------------
132 // wxCanvasObjectGroupRef
133 //----------------------------------------------------------------------------
135 class wxCanvasObjectGroupRef
: public wxCanvasObject
138 wxCanvasObjectGroupRef(double x
, double y
,wxCanvasObjectGroup
* group
);
140 void SetOwner(wxCanvas
* canvas
);
142 virtual void Recreate();
143 virtual void Render(int xabs
, int yabs
,int x
, int y
, int width
, int height
);
144 virtual void WriteSVG( wxTextOutputStream
&stream
);
145 virtual bool IsHit( int x
, int y
, int margin
);
146 void Move( int x
, int y
);
148 inline int GetPosX() { return m_x
; }
149 inline int GetPosY() { return m_y
; }
151 void ExtendArea(int x
, int y
);
152 virtual wxCanvasObject
* IsHitObject( int x
, int y
, int margin
);
155 //position of the group
159 //reference to the group
160 wxCanvasObjectGroup
* m_group
;
171 //----------------------------------------------------------------------------
173 //----------------------------------------------------------------------------
175 class wxCanvasRect
: public wxCanvasObject
178 wxCanvasRect( double x
, double y
, double w
, double h
,
179 unsigned char red
, unsigned char green
, unsigned char blue
);
181 virtual void Recreate();
183 virtual void Render(int xabs
, int yabs
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
184 virtual void WriteSVG( wxTextOutputStream
&stream
);
193 unsigned char m_green
;
194 unsigned char m_blue
;
197 //----------------------------------------------------------------------------
199 //----------------------------------------------------------------------------
201 class wxCanvasLine
: public wxCanvasObject
204 wxCanvasLine( double x1
, double y1
, double x2
, double y2
,
205 unsigned char red
, unsigned char green
, unsigned char blue
);
207 virtual void Recreate();
209 virtual void Render(int xabs
, int yabs
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
210 virtual void WriteSVG( wxTextOutputStream
&stream
);
219 unsigned char m_green
;
220 unsigned char m_blue
;
223 //----------------------------------------------------------------------------
225 //----------------------------------------------------------------------------
227 class wxCanvasImage
: public wxCanvasObject
230 wxCanvasImage( const wxImage
&image
, double x
, double y
, double w
, double h
);
232 virtual void Recreate();
234 virtual void Render(int xabs
, int yabs
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
235 virtual void WriteSVG( wxTextOutputStream
&stream
);
247 //----------------------------------------------------------------------------
249 //----------------------------------------------------------------------------
251 class wxCanvasControl
: public wxCanvasObject
254 wxCanvasControl( wxWindow
*control
);
257 virtual void Recreate();
259 virtual void Move( int x
, int y
);
265 //----------------------------------------------------------------------------
267 //----------------------------------------------------------------------------
269 class wxCanvasText
: public wxCanvasObject
272 wxCanvasText( const wxString
&text
, double x
, double y
, const wxString
&foneFile
, int size
);
277 virtual void Render(int xabs
, int yabs
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
278 virtual void WriteSVG( wxTextOutputStream
&stream
);
280 void SetRGB( unsigned char red
, unsigned char green
, unsigned char blue
);
281 void SetFlag( int flag
);
282 int GetFlag() { return m_flag
; }
288 unsigned char *m_alpha
;
294 wxString m_fontFileName
;
298 //----------------------------------------------------------------------------
300 //----------------------------------------------------------------------------
302 class wxCanvas
: public wxScrolledWindow
305 // constructors and destructors
306 wxCanvas( wxWindow
*parent
, wxWindowID id
= -1,
307 const wxPoint
& pos
= wxDefaultPosition
,
308 const wxSize
& size
= wxDefaultSize
,
309 long style
= wxScrolledWindowStyle
);
312 virtual void SetArea( int width
, int height
);
313 virtual void SetColour( unsigned char red
, unsigned char green
, unsigned char blue
);
314 virtual void Update( int x
, int y
, int width
, int height
, bool blit
= TRUE
);
315 virtual void UpdateNow();
317 virtual void Freeze();
320 virtual void Prepend( wxCanvasObject
* obj
);
321 virtual void Append( wxCanvasObject
* obj
);
322 virtual void Insert( size_t before
, wxCanvasObject
* obj
);
323 virtual void Remove( wxCanvasObject
* obj
);
325 // override these to change your coordiate system ...
326 virtual int GetDeviceX( double x
);
327 virtual int GetDeviceY( double y
);
328 virtual int GetDeviceWidth( double width
);
329 virtual int GetDeviceHeight( double height
);
331 // ... and call this to tell all objets to recreate then
332 virtual void Recreate();
334 inline wxImage
*GetBuffer() { return &m_buffer
; }
335 inline int GetBufferX() { return m_bufferX
; }
336 inline int GetBufferY() { return m_bufferY
; }
337 inline int GetBufferWidth() { return m_buffer
.GetWidth(); }
338 inline int GetBufferHeight() { return m_buffer
.GetHeight(); }
340 bool NeedUpdate() { return m_needUpdate
; }
341 bool IsFrozen() { return m_frozen
; }
343 void BlitBuffer( wxDC
&dc
);
345 void SetCaptureMouse( wxCanvasObject
*obj
);
347 virtual void ScrollWindow( int dx
, int dy
,
348 const wxRect
* rect
= (wxRect
*) NULL
);
355 wxList m_updateRects
;
356 wxCanvasObjectGroup
* m_root
;
358 unsigned char m_green
,m_red
,m_blue
;
360 bool m_requestNewBuffer
;
361 wxCanvasObject
*m_lastMouse
;
362 wxCanvasObject
*m_captureMouse
;
364 friend class wxCanvasObject
;
367 void OnChar( wxKeyEvent
&event
);
368 void OnPaint( wxPaintEvent
&event
);
369 void OnMouse( wxMouseEvent
&event
);
370 void OnSize( wxSizeEvent
&event
);
371 void OnIdle( wxIdleEvent
&event
);
372 void OnSetFocus( wxFocusEvent
&event
);
373 void OnKillFocus( wxFocusEvent
&event
);
374 void OnEraseBackground( wxEraseEvent
&event
);
377 DECLARE_CLASS(wxCanvas
)
378 DECLARE_EVENT_TABLE()