]>
git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/canvas/canvas.h
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 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 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();
79 friend class wxCanvas
;
82 //----------------------------------------------------------------------------
84 //----------------------------------------------------------------------------
86 class wxCanvasRect
: public wxCanvasObject
89 wxCanvasRect( double x
, double y
, double w
, double h
,
90 unsigned char red
, unsigned char green
, unsigned char blue
);
92 virtual void Recreate();
94 virtual void Render( int clip_x
, int clip_y
, int clip_width
, int clip_height
);
95 virtual void WriteSVG( wxTextOutputStream
&stream
);
104 unsigned char m_green
;
105 unsigned char m_blue
;
108 //----------------------------------------------------------------------------
110 //----------------------------------------------------------------------------
112 class wxCanvasLine
: public wxCanvasObject
115 wxCanvasLine( double x1
, double y1
, double x2
, double y2
,
116 unsigned char red
, unsigned char green
, unsigned char blue
);
118 virtual void Recreate();
120 virtual void Render( int clip_x
, int clip_y
, int clip_width
, int clip_height
);
121 virtual void WriteSVG( wxTextOutputStream
&stream
);
130 unsigned char m_green
;
131 unsigned char m_blue
;
134 //----------------------------------------------------------------------------
136 //----------------------------------------------------------------------------
138 class wxCanvasImage
: public wxCanvasObject
141 wxCanvasImage( const wxImage
&image
, double x
, double y
, double w
, double h
);
143 virtual void Recreate();
145 virtual void Render( int clip_x
, int clip_y
, int clip_width
, int clip_height
);
146 virtual void WriteSVG( wxTextOutputStream
&stream
);
158 //----------------------------------------------------------------------------
160 //----------------------------------------------------------------------------
162 class wxCanvasControl
: public wxCanvasObject
165 wxCanvasControl( wxWindow
*control
);
168 virtual void Recreate();
170 virtual void Move( int x
, int y
);
176 //----------------------------------------------------------------------------
178 //----------------------------------------------------------------------------
180 class wxCanvasText
: public wxCanvasObject
183 wxCanvasText( const wxString
&text
, double x
, double y
, const wxString
&foneFile
, int size
);
188 virtual void Render( int clip_x
, int clip_y
, int clip_width
, int clip_height
);
189 virtual void WriteSVG( wxTextOutputStream
&stream
);
191 void SetRGB( unsigned char red
, unsigned char green
, unsigned char blue
);
192 void SetFlag( int flag
);
193 int GetFlag() { return m_flag
; }
199 unsigned char *m_alpha
;
205 wxString m_fontFileName
;
209 //----------------------------------------------------------------------------
211 //----------------------------------------------------------------------------
213 class wxCanvas
: public wxScrolledWindow
216 // constructors and destructors
217 wxCanvas( wxWindow
*parent
, wxWindowID id
= -1,
218 const wxPoint
& pos
= wxDefaultPosition
,
219 const wxSize
& size
= wxDefaultSize
,
220 long style
= wxScrolledWindowStyle
);
223 virtual void SetArea( int width
, int height
);
224 virtual void SetColour( unsigned char red
, unsigned char green
, unsigned char blue
);
225 virtual void Update( int x
, int y
, int width
, int height
, bool blit
= TRUE
);
226 virtual void UpdateNow();
228 virtual void Freeze();
231 virtual void Prepend( wxCanvasObject
* obj
);
232 virtual void Append( wxCanvasObject
* obj
);
233 virtual void Insert( size_t before
, wxCanvasObject
* obj
);
234 virtual void Remove( wxCanvasObject
* obj
);
236 // override these to change your coordiate system ...
237 virtual int GetDeviceX( double x
);
238 virtual int GetDeviceY( double y
);
239 virtual int GetDeviceWidth( double width
);
240 virtual int GetDeviceHeight( double height
);
242 // ... and call this to tell all objets to recreate then
243 virtual void Recreate();
245 inline wxImage
*GetBuffer() { return &m_buffer
; }
246 inline int GetBufferX() { return m_bufferX
; }
247 inline int GetBufferY() { return m_bufferY
; }
248 inline int GetBufferWidth() { return m_buffer
.GetWidth(); }
249 inline int GetBufferHeight() { return m_buffer
.GetHeight(); }
251 bool NeedUpdate() { return m_needUpdate
; }
252 bool IsFrozen() { return m_frozen
; }
254 void BlitBuffer( wxDC
&dc
);
256 void SetCaptureMouse( wxCanvasObject
*obj
);
258 virtual void ScrollWindow( int dx
, int dy
,
259 const wxRect
* rect
= (wxRect
*) NULL
);
266 wxList m_updateRects
;
268 unsigned char m_green
,m_red
,m_blue
;
270 bool m_requestNewBuffer
;
271 wxCanvasObject
*m_lastMouse
;
272 wxCanvasObject
*m_captureMouse
;
274 friend class wxCanvasObject
;
277 void OnChar( wxKeyEvent
&event
);
278 void OnPaint( wxPaintEvent
&event
);
279 void OnMouse( wxMouseEvent
&event
);
280 void OnSize( wxSizeEvent
&event
);
281 void OnIdle( wxIdleEvent
&event
);
282 void OnSetFocus( wxFocusEvent
&event
);
283 void OnKillFocus( wxFocusEvent
&event
);
284 void OnEraseBackground( wxEraseEvent
&event
);
287 DECLARE_CLASS(wxCanvas
)
288 DECLARE_EVENT_TABLE()