]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/canvas/canvas.h
b821ebef0c92b2e0ef1291cfe76d044cd6cf8b80
[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 );
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 };
120
121 //----------------------------------------------------------------------------
122 // wxCanvas
123 //----------------------------------------------------------------------------
124
125 class wxCanvas: public wxScrolledWindow
126 {
127 public:
128 // constructors and destructors
129 wxCanvas( wxWindow *parent, wxWindowID id = -1,
130 const wxPoint& pos = wxDefaultPosition,
131 const wxSize& size = wxDefaultSize,
132 long style = wxScrolledWindowStyle );
133 virtual ~wxCanvas();
134
135 virtual void SetArea( int width, int height );
136 virtual void Update( int x, int y, int width, int height );
137 virtual void UpdateNow();
138
139 virtual void Prepend( wxCanvasObject* obj );
140 virtual void Append( wxCanvasObject* obj );
141 virtual void Insert( size_t before, wxCanvasObject* obj );
142 virtual void Remove( wxCanvasObject* obj );
143
144 wxImage *GetBuffer() { return &m_buffer; }
145 bool NeedUpdate() { return m_needUpdate; }
146
147 void BlitBuffer( wxDC &dc );
148
149 private:
150 wxImage m_buffer;
151 bool m_needUpdate;
152 wxList m_updateRects;
153 wxList m_objects;
154
155 friend class wxCanvasObject;
156
157 private:
158 void OnChar( wxKeyEvent &event );
159 void OnPaint( wxPaintEvent &event );
160 void OnMouse( wxMouseEvent &event );
161 void OnSize( wxSizeEvent &event );
162 void OnIdle( wxIdleEvent &event );
163 void OnSetFocus( wxFocusEvent &event );
164 void OnKillFocus( wxFocusEvent &event );
165
166 private:
167 DECLARE_CLASS(wxCanvas)
168 DECLARE_EVENT_TABLE()
169 };
170
171
172 #endif
173 // WXCANVAS
174