]>
git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/canvas/canvas.h
d8d7075ce0fda58d8f05a2977820bbb52b047e42
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();
93 void SetOwner(wxCanvas
* canvas
);
94 wxCanvas
*GetOwner() { return m_owner
; }
96 virtual void Prepend( wxCanvasObject
* obj
);
97 virtual void Append( wxCanvasObject
* obj
);
98 virtual void Insert( size_t before
, wxCanvasObject
* obj
);
99 virtual void Remove( wxCanvasObject
* obj
);
101 virtual void Recreate();
102 void DeleteContents( bool );
103 virtual void Render(int xabs
, int yabs
,int x
, int y
, int width
, int height
);
104 virtual void WriteSVG( wxTextOutputStream
&stream
);
105 virtual bool IsHit( int x
, int y
, int margin
);
106 virtual wxCanvasObject
* IsHitObject( int x
, int y
, int margin
);
108 void ExtendArea(int x
, int y
);
110 inline int GetXMin() { return m_minx
; }
111 inline int GetYMin() { return m_miny
; }
112 inline int GetXMax() { return m_maxx
; }
113 inline int GetYMax() { return m_maxy
; }
127 friend class wxCanvas
;
130 //----------------------------------------------------------------------------
131 // wxCanvasObjectGroupRef
132 //----------------------------------------------------------------------------
134 class wxCanvasObjectGroupRef
: public wxCanvasObject
137 wxCanvasObjectGroupRef(double x
, double y
,wxCanvasObjectGroup
* group
);
139 void SetOwner(wxCanvas
* canvas
);
141 virtual void Recreate();
142 virtual void Render(int xabs
, int yabs
,int x
, int y
, int width
, int height
);
143 virtual void WriteSVG( wxTextOutputStream
&stream
);
144 virtual bool IsHit( int x
, int y
, int margin
);
145 void Move( int x
, int y
);
147 inline int GetPosX() { return m_x
; }
148 inline int GetPosY() { return m_y
; }
150 void ExtendArea(int x
, int y
);
151 virtual wxCanvasObject
* IsHitObject( int x
, int y
, int margin
);
154 //position of the group
158 //reference to the group
159 wxCanvasObjectGroup
* m_group
;
170 //----------------------------------------------------------------------------
172 //----------------------------------------------------------------------------
174 class wxCanvasRect
: public wxCanvasObject
177 wxCanvasRect( double x
, double y
, double w
, double h
,
178 unsigned char red
, unsigned char green
, unsigned char blue
);
180 virtual void Recreate();
182 virtual void Render(int xabs
, int yabs
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
183 virtual void WriteSVG( wxTextOutputStream
&stream
);
192 unsigned char m_green
;
193 unsigned char m_blue
;
196 //----------------------------------------------------------------------------
198 //----------------------------------------------------------------------------
200 class wxCanvasLine
: public wxCanvasObject
203 wxCanvasLine( double x1
, double y1
, double x2
, double y2
,
204 unsigned char red
, unsigned char green
, unsigned char blue
);
206 virtual void Recreate();
208 virtual void Render(int xabs
, int yabs
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
209 virtual void WriteSVG( wxTextOutputStream
&stream
);
218 unsigned char m_green
;
219 unsigned char m_blue
;
222 //----------------------------------------------------------------------------
224 //----------------------------------------------------------------------------
226 class wxCanvasImage
: public wxCanvasObject
229 wxCanvasImage( const wxImage
&image
, double x
, double y
, double w
, double h
);
231 virtual void Recreate();
233 virtual void Render(int xabs
, int yabs
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
234 virtual void WriteSVG( wxTextOutputStream
&stream
);
246 //----------------------------------------------------------------------------
248 //----------------------------------------------------------------------------
250 class wxCanvasControl
: public wxCanvasObject
253 wxCanvasControl( wxWindow
*control
);
256 virtual void Recreate();
258 virtual void Move( int x
, int y
);
264 //----------------------------------------------------------------------------
266 //----------------------------------------------------------------------------
268 class wxCanvasText
: public wxCanvasObject
271 wxCanvasText( const wxString
&text
, double x
, double y
, const wxString
&foneFile
, int size
);
276 virtual void Render(int xabs
, int yabs
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
277 virtual void WriteSVG( wxTextOutputStream
&stream
);
279 void SetRGB( unsigned char red
, unsigned char green
, unsigned char blue
);
280 void SetFlag( int flag
);
281 int GetFlag() { return m_flag
; }
287 unsigned char *m_alpha
;
293 wxString m_fontFileName
;
297 //----------------------------------------------------------------------------
299 //----------------------------------------------------------------------------
301 class wxCanvas
: public wxScrolledWindow
304 // constructors and destructors
305 wxCanvas( wxWindow
*parent
, wxWindowID id
= -1,
306 const wxPoint
& pos
= wxDefaultPosition
,
307 const wxSize
& size
= wxDefaultSize
,
308 long style
= wxScrolledWindowStyle
);
311 virtual void SetArea( int width
, int height
);
312 virtual void SetColour( unsigned char red
, unsigned char green
, unsigned char blue
);
313 virtual void Update( int x
, int y
, int width
, int height
, bool blit
= TRUE
);
314 virtual void UpdateNow();
316 virtual void Freeze();
319 virtual void Prepend( wxCanvasObject
* obj
);
320 virtual void Append( wxCanvasObject
* obj
);
321 virtual void Insert( size_t before
, wxCanvasObject
* obj
);
322 virtual void Remove( wxCanvasObject
* obj
);
324 // override these to change your coordiate system ...
325 virtual int GetDeviceX( double x
);
326 virtual int GetDeviceY( double y
);
327 virtual int GetDeviceWidth( double width
);
328 virtual int GetDeviceHeight( double height
);
330 // ... and call this to tell all objets to recreate then
331 virtual void Recreate();
333 inline wxImage
*GetBuffer() { return &m_buffer
; }
334 inline int GetBufferX() { return m_bufferX
; }
335 inline int GetBufferY() { return m_bufferY
; }
336 inline int GetBufferWidth() { return m_buffer
.GetWidth(); }
337 inline int GetBufferHeight() { return m_buffer
.GetHeight(); }
339 bool NeedUpdate() { return m_needUpdate
; }
340 bool IsFrozen() { return m_frozen
; }
342 void BlitBuffer( wxDC
&dc
);
344 void SetCaptureMouse( wxCanvasObject
*obj
);
346 virtual void ScrollWindow( int dx
, int dy
,
347 const wxRect
* rect
= (wxRect
*) NULL
);
354 wxList m_updateRects
;
355 wxCanvasObjectGroup
* m_root
;
357 unsigned char m_green
,m_red
,m_blue
;
359 bool m_requestNewBuffer
;
360 wxCanvasObject
*m_lastMouse
;
361 wxCanvasObject
*m_captureMouse
;
363 friend class wxCanvasObject
;
366 void OnChar( wxKeyEvent
&event
);
367 void OnPaint( wxPaintEvent
&event
);
368 void OnMouse( wxMouseEvent
&event
);
369 void OnSize( wxSizeEvent
&event
);
370 void OnIdle( wxIdleEvent
&event
);
371 void OnSetFocus( wxFocusEvent
&event
);
372 void OnKillFocus( wxFocusEvent
&event
);
373 void OnEraseBackground( wxEraseEvent
&event
);
376 DECLARE_CLASS(wxCanvas
)
377 DECLARE_EVENT_TABLE()