]>
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
; }
75 friend class wxCanvas
;
78 //----------------------------------------------------------------------------
80 //----------------------------------------------------------------------------
82 class wxCanvasRect
: public wxCanvasObject
85 wxCanvasRect( double x
, double y
, double w
, double h
,
86 unsigned char red
, unsigned char green
, unsigned char blue
);
88 virtual void Recreate();
90 virtual void Render( int clip_x
, int clip_y
, int clip_width
, int clip_height
);
91 virtual void WriteSVG( wxTextOutputStream
&stream
);
100 unsigned char m_green
;
101 unsigned char m_blue
;
104 //----------------------------------------------------------------------------
106 //----------------------------------------------------------------------------
108 class wxCanvasLine
: public wxCanvasObject
111 wxCanvasLine( double x1
, double y1
, double x1
, double y1
,
112 unsigned char red
, unsigned char green
, unsigned char blue
);
114 virtual void Recreate();
116 virtual void Render( int clip_x
, int clip_y
, int clip_width
, int clip_height
);
117 virtual void WriteSVG( wxTextOutputStream
&stream
);
126 unsigned char m_green
;
127 unsigned char m_blue
;
130 //----------------------------------------------------------------------------
132 //----------------------------------------------------------------------------
134 class wxCanvasImage
: public wxCanvasObject
137 wxCanvasImage( const wxImage
&image
, double x
, double y
, double w
, double h
);
139 virtual void Recreate();
141 virtual void Render( int clip_x
, int clip_y
, int clip_width
, int clip_height
);
142 virtual void WriteSVG( wxTextOutputStream
&stream
);
154 //----------------------------------------------------------------------------
156 //----------------------------------------------------------------------------
158 class wxCanvasControl
: public wxCanvasObject
161 wxCanvasControl( wxWindow
*control
);
164 virtual void Recreate();
166 virtual void Move( int x
, int y
);
172 //----------------------------------------------------------------------------
174 //----------------------------------------------------------------------------
176 class wxCanvasText
: public wxCanvasObject
179 wxCanvasText( const wxString
&text
, double x
, double y
, const wxString
&foneFile
, int size
);
184 virtual void Render( int clip_x
, int clip_y
, int clip_width
, int clip_height
);
185 virtual void WriteSVG( wxTextOutputStream
&stream
);
187 void SetRGB( unsigned char red
, unsigned char green
, unsigned char blue
);
188 void SetFlag( int flag
);
189 int GetFlag() { return m_flag
; }
195 unsigned char *m_alpha
;
201 wxString m_fontFileName
;
205 //----------------------------------------------------------------------------
207 //----------------------------------------------------------------------------
209 class wxCanvas
: public wxScrolledWindow
212 // constructors and destructors
213 wxCanvas( wxWindow
*parent
, wxWindowID id
= -1,
214 const wxPoint
& pos
= wxDefaultPosition
,
215 const wxSize
& size
= wxDefaultSize
,
216 long style
= wxScrolledWindowStyle
);
219 virtual void SetArea( int width
, int height
);
220 virtual void SetColour( unsigned char red
, unsigned char green
, unsigned char blue
);
221 virtual void Update( int x
, int y
, int width
, int height
);
222 virtual void UpdateNow();
224 virtual void Freeze();
227 virtual void Prepend( wxCanvasObject
* obj
);
228 virtual void Append( wxCanvasObject
* obj
);
229 virtual void Insert( size_t before
, wxCanvasObject
* obj
);
230 virtual void Remove( wxCanvasObject
* obj
);
232 // override these to change your coordiate system ...
233 virtual int GetDeviceX( double x
);
234 virtual int GetDeviceY( double y
);
235 virtual int GetDeviceWidth( double width
);
236 virtual int GetDeviceHeight( double height
);
238 // ... and call this to tell all objets to recreate then
239 virtual void Recreate();
241 void CaptureMouse( wxCanvasObject
*obj
);
244 wxImage
*GetBuffer() { return &m_buffer
; }
245 bool NeedUpdate() { return m_needUpdate
; }
246 bool IsFrozen() { return m_frozen
; }
248 void BlitBuffer( wxDC
&dc
);
253 wxList m_updateRects
;
255 unsigned char m_green
,m_red
,m_blue
;
257 wxCanvasObject
*m_lastMouse
;
258 wxCanvasObject
*m_captureMouse
;
260 friend class wxCanvasObject
;
263 void OnChar( wxKeyEvent
&event
);
264 void OnPaint( wxPaintEvent
&event
);
265 void OnMouse( wxMouseEvent
&event
);
266 void OnSize( wxSizeEvent
&event
);
267 void OnIdle( wxIdleEvent
&event
);
268 void OnSetFocus( wxFocusEvent
&event
);
269 void OnKillFocus( wxFocusEvent
&event
);
272 DECLARE_CLASS(wxCanvas
)
273 DECLARE_EVENT_TABLE()