]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/canvas/canvas.h
4015e9d3dd1f8826c8f1c9f7466ad8d3764c6b43
[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 // wxCanvasImage
63 //----------------------------------------------------------------------------
64
65 class wxCanvasImage: public wxCanvasObject
66 {
67 public:
68 wxCanvasImage( const wxImage &image, int x, int y );
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 wxImage m_image;
75 };
76
77 //----------------------------------------------------------------------------
78 // wxCanvasControl
79 //----------------------------------------------------------------------------
80
81 class wxCanvasControl: public wxCanvasObject
82 {
83 public:
84 wxCanvasControl( wxWindow *control );
85 ~wxCanvasControl();
86
87 virtual void Move( int x, int y );
88 void UpdateSize();
89
90 private:
91 wxWindow *m_control;
92 };
93
94 //----------------------------------------------------------------------------
95 // wxCanvasText
96 //----------------------------------------------------------------------------
97
98 class wxCanvasText: public wxCanvasObject
99 {
100 public:
101 wxCanvasText( const wxString &text, int x, int y, const wxString &foneFile, int size );
102 ~wxCanvasText();
103
104 virtual void Render( int clip_x, int clip_y, int clip_width, int clip_height );
105 virtual void WriteSVG( wxTextOutputStream &stream );
106
107 void CreateBuffer();
108 void SetRGB( unsigned char red, unsigned char green, unsigned char blue );
109 void SetFlag( int flag );
110
111 private:
112 wxString m_text;
113 unsigned char *m_alpha;
114 void *m_faceData;
115 int m_flag;
116 int m_red;
117 int m_green;
118 int m_blue;
119 wxString m_fontFileName;
120 int m_size;
121 };
122
123 //----------------------------------------------------------------------------
124 // wxCanvas
125 //----------------------------------------------------------------------------
126
127 class wxCanvas: public wxScrolledWindow
128 {
129 public:
130 // constructors and destructors
131 wxCanvas( wxWindow *parent, wxWindowID id = -1,
132 const wxPoint& pos = wxDefaultPosition,
133 const wxSize& size = wxDefaultSize,
134 long style = wxScrolledWindowStyle );
135 virtual ~wxCanvas();
136
137 virtual void SetArea( int width, int height );
138 virtual void SetColour( unsigned char red, unsigned char green, unsigned char blue );
139 virtual void Update( int x, int y, int width, int height );
140 virtual void UpdateNow();
141
142 virtual void Prepend( wxCanvasObject* obj );
143 virtual void Append( wxCanvasObject* obj );
144 virtual void Insert( size_t before, wxCanvasObject* obj );
145 virtual void Remove( wxCanvasObject* obj );
146
147 wxImage *GetBuffer() { return &m_buffer; }
148 bool NeedUpdate() { return m_needUpdate; }
149
150 void BlitBuffer( wxDC &dc );
151
152 private:
153 wxImage m_buffer;
154 bool m_needUpdate;
155 wxList m_updateRects;
156 wxList m_objects;
157 unsigned char m_green,m_red,m_blue;
158
159 friend class wxCanvasObject;
160
161 private:
162 void OnChar( wxKeyEvent &event );
163 void OnPaint( wxPaintEvent &event );
164 void OnMouse( wxMouseEvent &event );
165 void OnSize( wxSizeEvent &event );
166 void OnIdle( wxIdleEvent &event );
167 void OnSetFocus( wxFocusEvent &event );
168 void OnKillFocus( wxFocusEvent &event );
169
170 private:
171 DECLARE_CLASS(wxCanvas)
172 DECLARE_EVENT_TABLE()
173 };
174
175
176 #endif
177 // WXCANVAS
178