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