]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/canvas/canvas.h
4c2e43bf801ec7bede479d72121a1bddc509104b
[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 // wxCanvas
79 //----------------------------------------------------------------------------
80
81 class wxCanvas: public wxScrolledWindow
82 {
83 public:
84 // constructors and destructors
85 wxCanvas( wxWindow *parent, wxWindowID id = -1,
86 const wxPoint& pos = wxDefaultPosition,
87 const wxSize& size = wxDefaultSize,
88 long style = wxScrolledWindowStyle );
89 virtual ~wxCanvas();
90
91 virtual void SetArea( int width, int height );
92 virtual void Update( int x, int y, int width, int height );
93 virtual void UpdateNow();
94
95 virtual void Prepend( wxCanvasObject* obj );
96 virtual void Append( wxCanvasObject* obj );
97 virtual void Insert( size_t before, wxCanvasObject* obj );
98 virtual void Remove( wxCanvasObject* obj );
99
100 wxImage *GetBuffer() { return &m_buffer; }
101 bool NeedUpdate() { return m_needUpdate; }
102
103 private:
104 wxImage m_buffer;
105 bool m_needUpdate;
106 wxList m_updateRects;
107 wxList m_objects;
108
109 friend class wxCanvasObject;
110
111 private:
112 void OnChar( wxKeyEvent &event );
113 void OnPaint( wxPaintEvent &event );
114 void OnMouse( wxMouseEvent &event );
115 void OnSize( wxSizeEvent &event );
116 void OnIdle( wxIdleEvent &event );
117 void OnSetFocus( wxFocusEvent &event );
118 void OnKillFocus( wxFocusEvent &event );
119
120 private:
121 DECLARE_CLASS(wxCanvas)
122 DECLARE_EVENT_TABLE()
123 };
124
125
126 #endif
127 // WXCANVAS
128