]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/canvas/canvas.h
b4a9b46dc88d0973d15a1a191c6e8d8c3a1b6e1f
[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 // wxCanvas
96 //----------------------------------------------------------------------------
97
98 class wxCanvas: public wxScrolledWindow
99 {
100 public:
101 // constructors and destructors
102 wxCanvas( wxWindow *parent, wxWindowID id = -1,
103 const wxPoint& pos = wxDefaultPosition,
104 const wxSize& size = wxDefaultSize,
105 long style = wxScrolledWindowStyle );
106 virtual ~wxCanvas();
107
108 virtual void SetArea( int width, int height );
109 virtual void Update( int x, int y, int width, int height );
110 virtual void UpdateNow();
111
112 virtual void Prepend( wxCanvasObject* obj );
113 virtual void Append( wxCanvasObject* obj );
114 virtual void Insert( size_t before, wxCanvasObject* obj );
115 virtual void Remove( wxCanvasObject* obj );
116
117 wxImage *GetBuffer() { return &m_buffer; }
118 bool NeedUpdate() { return m_needUpdate; }
119
120 void BlitBuffer( wxDC &dc );
121
122 private:
123 wxImage m_buffer;
124 bool m_needUpdate;
125 wxList m_updateRects;
126 wxList m_objects;
127
128 friend class wxCanvasObject;
129
130 private:
131 void OnChar( wxKeyEvent &event );
132 void OnPaint( wxPaintEvent &event );
133 void OnMouse( wxMouseEvent &event );
134 void OnSize( wxSizeEvent &event );
135 void OnIdle( wxIdleEvent &event );
136 void OnSetFocus( wxFocusEvent &event );
137 void OnKillFocus( wxFocusEvent &event );
138
139 private:
140 DECLARE_CLASS(wxCanvas)
141 DECLARE_EVENT_TABLE()
142 };
143
144
145 #endif
146 // WXCANVAS
147