]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/canvas/canvas.h
GetSelection() replaced with GetId() in OnMRUFile
[wxWidgets.git] / contrib / include / wx / canvas / canvas.h
CommitLineData
6a2c1874
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: canvas.h
3// Author: Robert Roebling
4// Created: XX/XX/XX
5// Copyright: 2000 (c) Robert Roebling
6// Licence: wxWindows Licence
7/////////////////////////////////////////////////////////////////////////////
8
9#ifndef __WXCANVAS_H__
10#define __WXCANVAS_H__
11
12#ifdef __GNUG__
13 #pragma interface "canvas.cpp"
14#endif
15
16#ifndef WX_PRECOMP
17 #include "wx/wx.h"
18#endif
19
20#include "wx/image.h"
21#include "wx/txtstrm.h"
dc16900b 22
6a2c1874
RR
23class wxCanvas;
24
25// WDR: class declarations
26
27//----------------------------------------------------------------------------
28// wxCanvasObject
29//----------------------------------------------------------------------------
30
31class wxCanvasObject: public wxEvtHandler
32{
33public:
4dbd4ee6 34 wxCanvasObject();
dc16900b 35
4dbd4ee6
RR
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 );
dc16900b 40
1e1af41e
RR
41 // These are for screen output only therefore use
42 // int as coordinates.
239c1f50 43 virtual bool IsHit( int x, int y, int margin = 0 );
6a2c1874 44 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
dc16900b 45
4dbd4ee6
RR
46 // use doubles later
47 virtual void Move( int x, int y );
dc16900b 48
1e1af41e
RR
49 // Once we have world coordinates in doubles, this will get
50 // called for every object if the world coordinate system
51 // changes (zooming).
4dbd4ee6 52 virtual void Recreate();
1e1af41e
RR
53
54 // Later...
6a2c1874 55 virtual void WriteSVG( wxTextOutputStream &stream );
dc16900b
KH
56
57 wxCanvas *GetOwner() { return m_owner; }
58 void SetOwner( wxCanvas *owner ) { m_owner = owner; }
59
6a2c1874
RR
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; }
67
dc16900b
KH
68 void CaptureMouse();
69 void ReleaseMouse();
70 bool IsCapturedMouse();
71
6a2c1874
RR
72protected:
73 wxCanvas *m_owner;
74 bool m_isControl;
75 bool m_isVector;
76 bool m_isImage;
77 wxRect m_area;
dc16900b 78
6a2c1874
RR
79 friend class wxCanvas;
80};
81
21544859
RR
82//----------------------------------------------------------------------------
83// wxCanvasRect
84//----------------------------------------------------------------------------
85
86class wxCanvasRect: public wxCanvasObject
87{
88public:
dc16900b 89 wxCanvasRect( double x, double y, double w, double h,
4dbd4ee6 90 unsigned char red, unsigned char green, unsigned char blue );
dc16900b 91
4dbd4ee6 92 virtual void Recreate();
dc16900b 93
21544859
RR
94 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
95 virtual void WriteSVG( wxTextOutputStream &stream );
dc16900b 96
21544859 97private:
4dbd4ee6
RR
98 double m_x;
99 double m_y;
100 double m_width;
dc16900b 101 double m_height;
4dbd4ee6 102
21544859
RR
103 unsigned char m_red;
104 unsigned char m_green;
105 unsigned char m_blue;
106};
107
239c1f50
RR
108//----------------------------------------------------------------------------
109// wxCanvasLine
110//----------------------------------------------------------------------------
111
112class wxCanvasLine: public wxCanvasObject
113{
114public:
dc16900b 115 wxCanvasLine( double x1, double y1, double x2, double y2,
4dbd4ee6 116 unsigned char red, unsigned char green, unsigned char blue );
dc16900b 117
4dbd4ee6 118 virtual void Recreate();
dc16900b 119
239c1f50
RR
120 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
121 virtual void WriteSVG( wxTextOutputStream &stream );
122
123private:
4dbd4ee6
RR
124 double m_x1;
125 double m_y1;
126 double m_x2;
127 double m_y2;
dc16900b 128
239c1f50
RR
129 unsigned char m_red;
130 unsigned char m_green;
131 unsigned char m_blue;
132};
133
6a2c1874
RR
134//----------------------------------------------------------------------------
135// wxCanvasImage
136//----------------------------------------------------------------------------
137
138class wxCanvasImage: public wxCanvasObject
139{
140public:
4dbd4ee6
RR
141 wxCanvasImage( const wxImage &image, double x, double y, double w, double h );
142
143 virtual void Recreate();
6a2c1874
RR
144
145 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
146 virtual void WriteSVG( wxTextOutputStream &stream );
147
148private:
4dbd4ee6
RR
149 double m_x;
150 double m_y;
151 double m_width;
152 double m_height;
153
6a2c1874 154 wxImage m_image;
4dbd4ee6 155 wxImage m_tmp;
6a2c1874
RR
156};
157
3b111dbe
RR
158//----------------------------------------------------------------------------
159// wxCanvasControl
160//----------------------------------------------------------------------------
161
162class wxCanvasControl: public wxCanvasObject
163{
164public:
165 wxCanvasControl( wxWindow *control );
166 ~wxCanvasControl();
167
4dbd4ee6
RR
168 virtual void Recreate();
169
3b111dbe 170 virtual void Move( int x, int y );
3b111dbe
RR
171
172private:
173 wxWindow *m_control;
174};
175
d1f9b206
RR
176//----------------------------------------------------------------------------
177// wxCanvasText
178//----------------------------------------------------------------------------
179
180class wxCanvasText: public wxCanvasObject
181{
182public:
4dbd4ee6 183 wxCanvasText( const wxString &text, double x, double y, const wxString &foneFile, int size );
d1f9b206 184 ~wxCanvasText();
dc16900b 185
4dbd4ee6 186 void Recreate();
dc16900b 187
d1f9b206
RR
188 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
189 virtual void WriteSVG( wxTextOutputStream &stream );
190
d1f9b206
RR
191 void SetRGB( unsigned char red, unsigned char green, unsigned char blue );
192 void SetFlag( int flag );
239c1f50 193 int GetFlag() { return m_flag; }
dc16900b 194
d1f9b206
RR
195private:
196 wxString m_text;
4dbd4ee6
RR
197 double m_x;
198 double m_y;
d1f9b206
RR
199 unsigned char *m_alpha;
200 void *m_faceData;
201 int m_flag;
202 int m_red;
203 int m_green;
204 int m_blue;
cb281cfc
RR
205 wxString m_fontFileName;
206 int m_size;
d1f9b206
RR
207};
208
6a2c1874
RR
209//----------------------------------------------------------------------------
210// wxCanvas
211//----------------------------------------------------------------------------
212
213class wxCanvas: public wxScrolledWindow
214{
215public:
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 );
221 virtual ~wxCanvas();
dc16900b 222
6a2c1874 223 virtual void SetArea( int width, int height );
cb281cfc 224 virtual void SetColour( unsigned char red, unsigned char green, unsigned char blue );
41328253 225 virtual void Update( int x, int y, int width, int height, bool blit = TRUE );
6a2c1874 226 virtual void UpdateNow();
dc16900b 227
239c1f50
RR
228 virtual void Freeze();
229 virtual void Thaw();
dc16900b 230
6a2c1874
RR
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 );
dc16900b 235
4dbd4ee6
RR
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 );
dc16900b 241
4dbd4ee6
RR
242 // ... and call this to tell all objets to recreate then
243 virtual void Recreate();
244
41328253
RR
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(); }
250
6a2c1874 251 bool NeedUpdate() { return m_needUpdate; }
1e1af41e 252 bool IsFrozen() { return m_frozen; }
dc16900b 253
3b111dbe 254 void BlitBuffer( wxDC &dc );
dc16900b
KH
255
256 void SetCaptureMouse( wxCanvasObject *obj );
257
41328253
RR
258 virtual void ScrollWindow( int dx, int dy,
259 const wxRect* rect = (wxRect *) NULL );
dc16900b 260
6a2c1874 261private:
239c1f50 262 wxImage m_buffer;
41328253
RR
263 int m_bufferX;
264 int m_bufferY;
239c1f50
RR
265 bool m_needUpdate;
266 wxList m_updateRects;
267 wxList m_objects;
268 unsigned char m_green,m_red,m_blue;
269 bool m_frozen;
41328253 270 bool m_requestNewBuffer;
239c1f50 271 wxCanvasObject *m_lastMouse;
4dbd4ee6 272 wxCanvasObject *m_captureMouse;
dc16900b 273
6a2c1874 274 friend class wxCanvasObject;
dc16900b 275
6a2c1874
RR
276private:
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 );
61b64bd9 284 void OnEraseBackground( wxEraseEvent &event );
6a2c1874
RR
285
286private:
287 DECLARE_CLASS(wxCanvas)
288 DECLARE_EVENT_TABLE()
289};
290
291
292#endif
293 // WXCANVAS
294