]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/canvas/canvas.h
6c3747eed2a5c907cbcc0828f9cf1a874ccb96fd
[wxWidgets.git] / contrib / include / wx / canvas / canvas.h
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"
22
23 class wxCanvas;
24
25 // WDR: class declarations
26
27 //----------------------------------------------------------------------------
28 // wxCanvasObject
29 //----------------------------------------------------------------------------
30
31 class wxCanvasObject: public wxEvtHandler
32 {
33 public:
34 wxCanvasObject( int x, int y, int width, int height );
35
36 virtual void Move( int x, int y );
37 virtual bool IsHit( int x, int y, int margin = 0 );
38
39 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
40 virtual void WriteSVG( wxTextOutputStream &stream );
41
42 wxCanvas *GetOwner() { return m_owner; }
43 void SetOwner( wxCanvas *owner ) { m_owner = owner; }
44
45 bool IsControl() { return m_isControl; }
46 bool IsVector() { return m_isVector; }
47 bool IsImage() { return m_isImage; }
48 inline int GetX() { return m_area.x; }
49 inline int GetY() { return m_area.y; }
50 inline int GetWidth() { return m_area.width; }
51 inline int GetHeight() { return m_area.height; }
52
53 protected:
54 wxCanvas *m_owner;
55 bool m_isControl;
56 bool m_isVector;
57 bool m_isImage;
58 wxRect m_area;
59
60 friend class wxCanvas;
61 };
62
63 //----------------------------------------------------------------------------
64 // wxCanvasRect
65 //----------------------------------------------------------------------------
66
67 class wxCanvasRect: public wxCanvasObject
68 {
69 public:
70 wxCanvasRect( int x, int y, int w, int h, unsigned char red, unsigned char green, unsigned char blue );
71
72 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
73 virtual void WriteSVG( wxTextOutputStream &stream );
74
75 private:
76 unsigned char m_red;
77 unsigned char m_green;
78 unsigned char m_blue;
79 };
80
81 //----------------------------------------------------------------------------
82 // wxCanvasLine
83 //----------------------------------------------------------------------------
84
85 class wxCanvasLine: public wxCanvasObject
86 {
87 public:
88 wxCanvasLine( int x, int y, int w, int h, unsigned char red, unsigned char green, unsigned char blue );
89
90 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
91 virtual void WriteSVG( wxTextOutputStream &stream );
92
93 private:
94 unsigned char m_red;
95 unsigned char m_green;
96 unsigned char m_blue;
97 };
98
99 //----------------------------------------------------------------------------
100 // wxCanvasImage
101 //----------------------------------------------------------------------------
102
103 class wxCanvasImage: public wxCanvasObject
104 {
105 public:
106 wxCanvasImage( const wxImage &image, int x, int y );
107
108 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
109 virtual void WriteSVG( wxTextOutputStream &stream );
110
111 private:
112 wxImage m_image;
113 };
114
115 //----------------------------------------------------------------------------
116 // wxCanvasControl
117 //----------------------------------------------------------------------------
118
119 class wxCanvasControl: public wxCanvasObject
120 {
121 public:
122 wxCanvasControl( wxWindow *control );
123 ~wxCanvasControl();
124
125 virtual void Move( int x, int y );
126 void UpdateSize();
127
128 private:
129 wxWindow *m_control;
130 };
131
132 //----------------------------------------------------------------------------
133 // wxCanvasText
134 //----------------------------------------------------------------------------
135
136 class wxCanvasText: public wxCanvasObject
137 {
138 public:
139 wxCanvasText( const wxString &text, int x, int y, const wxString &foneFile, int size );
140 ~wxCanvasText();
141
142 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
143 virtual void WriteSVG( wxTextOutputStream &stream );
144
145 void CreateBuffer();
146 void SetRGB( unsigned char red, unsigned char green, unsigned char blue );
147 void SetFlag( int flag );
148 int GetFlag() { return m_flag; }
149
150 private:
151 wxString m_text;
152 unsigned char *m_alpha;
153 void *m_faceData;
154 int m_flag;
155 int m_red;
156 int m_green;
157 int m_blue;
158 wxString m_fontFileName;
159 int m_size;
160 };
161
162 //----------------------------------------------------------------------------
163 // wxCanvas
164 //----------------------------------------------------------------------------
165
166 class wxCanvas: public wxScrolledWindow
167 {
168 public:
169 // constructors and destructors
170 wxCanvas( wxWindow *parent, wxWindowID id = -1,
171 const wxPoint& pos = wxDefaultPosition,
172 const wxSize& size = wxDefaultSize,
173 long style = wxScrolledWindowStyle );
174 virtual ~wxCanvas();
175
176 virtual void SetArea( int width, int height );
177 virtual void SetColour( unsigned char red, unsigned char green, unsigned char blue );
178 virtual void Update( int x, int y, int width, int height );
179 virtual void UpdateNow();
180
181 virtual void Freeze();
182 virtual void Thaw();
183
184 virtual void Prepend( wxCanvasObject* obj );
185 virtual void Append( wxCanvasObject* obj );
186 virtual void Insert( size_t before, wxCanvasObject* obj );
187 virtual void Remove( wxCanvasObject* obj );
188
189 wxImage *GetBuffer() { return &m_buffer; }
190 bool NeedUpdate() { return m_needUpdate; }
191
192 void BlitBuffer( wxDC &dc );
193
194 private:
195 wxImage m_buffer;
196 bool m_needUpdate;
197 wxList m_updateRects;
198 wxList m_objects;
199 unsigned char m_green,m_red,m_blue;
200 bool m_frozen;
201 wxCanvasObject *m_lastMouse;
202
203
204 friend class wxCanvasObject;
205
206 private:
207 void OnChar( wxKeyEvent &event );
208 void OnPaint( wxPaintEvent &event );
209 void OnMouse( wxMouseEvent &event );
210 void OnSize( wxSizeEvent &event );
211 void OnIdle( wxIdleEvent &event );
212 void OnSetFocus( wxFocusEvent &event );
213 void OnKillFocus( wxFocusEvent &event );
214
215 private:
216 DECLARE_CLASS(wxCanvas)
217 DECLARE_EVENT_TABLE()
218 };
219
220
221 #endif
222 // WXCANVAS
223