]>
Commit | Line | Data |
---|---|---|
457814b5 | 1 | ///////////////////////////////////////////////////////////////////////////// |
2d1df0fc | 2 | // Name: samples/docview/view.h |
457814b5 JS |
3 | // Purpose: View classes |
4 | // Author: Julian Smart | |
2d1df0fc | 5 | // Modified by: Vadim Zeitlin: merge with the MDI version and general cleanup |
457814b5 JS |
6 | // Created: 04/01/98 |
7 | // RCS-ID: $Id$ | |
2d1df0fc VZ |
8 | // Copyright: (c) 1998 Julian Smart |
9 | // (c) 2008 Vadim Zeitlin | |
526954c5 | 10 | // Licence: wxWindows licence |
457814b5 JS |
11 | ///////////////////////////////////////////////////////////////////////////// |
12 | ||
2d1df0fc VZ |
13 | #ifndef _WX_SAMPLES_DOCVIEW_VIEW_H_ |
14 | #define _WX_SAMPLES_DOCVIEW_VIEW_H_ | |
457814b5 JS |
15 | |
16 | #include "wx/docview.h" | |
17 | ||
2d1df0fc VZ |
18 | // ---------------------------------------------------------------------------- |
19 | // Drawing view classes | |
20 | // ---------------------------------------------------------------------------- | |
21 | ||
22 | // The window showing the drawing itself | |
6bdf5153 | 23 | class MyCanvas : public wxScrolledWindow |
457814b5 | 24 | { |
f6bcfd97 | 25 | public: |
2d1df0fc VZ |
26 | // view may be NULL if we're not associated with one yet, but parent must |
27 | // be a valid pointer | |
9b341e6f | 28 | MyCanvas(wxView *view, wxWindow *parent = NULL); |
2d1df0fc | 29 | virtual ~MyCanvas(); |
6bdf5153 | 30 | |
457814b5 | 31 | virtual void OnDraw(wxDC& dc); |
6bdf5153 | 32 | |
2d1df0fc VZ |
33 | // in a normal multiple document application a canvas is associated with |
34 | // one view from the beginning until the end, but to support the single | |
35 | // document mode in which all documents reuse the same MyApp::GetCanvas() | |
36 | // we need to allow switching the canvas from one view to another one | |
37 | ||
38 | void SetView(wxView *view) | |
39 | { | |
40 | wxASSERT_MSG( !m_view, "shouldn't be already associated with a view" ); | |
41 | ||
42 | m_view = view; | |
43 | } | |
44 | ||
45 | void ResetView() | |
46 | { | |
47 | wxASSERT_MSG( m_view, "should be associated with a view" ); | |
48 | ||
49 | m_view = NULL; | |
50 | } | |
51 | ||
52 | private: | |
457814b5 | 53 | void OnMouseEvent(wxMouseEvent& event); |
457814b5 | 54 | |
2d1df0fc VZ |
55 | wxView *m_view; |
56 | ||
57 | // the segment being currently drawn or NULL if none | |
58 | DoodleSegment *m_currentSegment; | |
6bdf5153 | 59 | |
2d1df0fc VZ |
60 | // the last mouse press position |
61 | wxPoint m_lastMousePos; | |
62 | ||
63 | DECLARE_EVENT_TABLE() | |
457814b5 JS |
64 | }; |
65 | ||
2d1df0fc | 66 | // The view using MyCanvas to show its contents |
6bdf5153 | 67 | class DrawingView : public wxView |
457814b5 | 68 | { |
f6bcfd97 | 69 | public: |
9b341e6f | 70 | DrawingView() : wxView(), m_canvas(NULL) {} |
6bdf5153 VZ |
71 | |
72 | virtual bool OnCreate(wxDocument *doc, long flags); | |
73 | virtual void OnDraw(wxDC *dc); | |
74 | virtual void OnUpdate(wxView *sender, wxObject *hint = NULL); | |
75 | virtual bool OnClose(bool deleteWindow = true); | |
76 | ||
77 | DrawingDocument* GetDocument(); | |
78 | ||
2d1df0fc | 79 | private: |
f6bcfd97 | 80 | void OnCut(wxCommandEvent& event); |
6bdf5153 | 81 | |
2d1df0fc VZ |
82 | MyCanvas *m_canvas; |
83 | ||
f6bcfd97 | 84 | DECLARE_EVENT_TABLE() |
6bdf5153 | 85 | DECLARE_DYNAMIC_CLASS(DrawingView) |
457814b5 JS |
86 | }; |
87 | ||
2d1df0fc VZ |
88 | // ---------------------------------------------------------------------------- |
89 | // Text view classes | |
90 | // ---------------------------------------------------------------------------- | |
91 | ||
92 | // The view using a standard wxTextCtrl to show its contents | |
6bdf5153 | 93 | class TextEditView : public wxView |
457814b5 | 94 | { |
f6bcfd97 | 95 | public: |
9b341e6f | 96 | TextEditView() : wxView(), m_text(NULL) {} |
6bdf5153 VZ |
97 | |
98 | virtual bool OnCreate(wxDocument *doc, long flags); | |
99 | virtual void OnDraw(wxDC *dc); | |
6bdf5153 | 100 | virtual bool OnClose(bool deleteWindow = true); |
6bdf5153 | 101 | |
2d1df0fc VZ |
102 | wxTextCtrl *GetText() const { return m_text; } |
103 | ||
6bdf5153 | 104 | private: |
2d1df0fc VZ |
105 | void OnCopy(wxCommandEvent& WXUNUSED(event)) { m_text->Copy(); } |
106 | void OnPaste(wxCommandEvent& WXUNUSED(event)) { m_text->Paste(); } | |
107 | void OnSelectAll(wxCommandEvent& WXUNUSED(event)) { m_text->SelectAll(); } | |
108 | ||
2d1df0fc | 109 | wxTextCtrl *m_text; |
4e553af1 VZ |
110 | |
111 | DECLARE_EVENT_TABLE() | |
6bdf5153 | 112 | DECLARE_DYNAMIC_CLASS(TextEditView) |
457814b5 JS |
113 | }; |
114 | ||
f37f49b6 | 115 | // ---------------------------------------------------------------------------- |
2d4a03f8 | 116 | // ImageCanvas |
f37f49b6 JS |
117 | // ---------------------------------------------------------------------------- |
118 | ||
2d4a03f8 | 119 | class ImageCanvas : public wxScrolledWindow |
f37f49b6 JS |
120 | { |
121 | public: | |
9b341e6f | 122 | ImageCanvas(wxView*); |
f37f49b6 JS |
123 | |
124 | virtual void OnDraw(wxDC& dc); | |
2d4a03f8 | 125 | private: |
f37f49b6 | 126 | wxView *m_view; |
f37f49b6 JS |
127 | }; |
128 | ||
129 | // ---------------------------------------------------------------------------- | |
2d4a03f8 | 130 | // ImageView |
f37f49b6 JS |
131 | // ---------------------------------------------------------------------------- |
132 | ||
2d4a03f8 | 133 | class ImageView : public wxView |
f37f49b6 JS |
134 | { |
135 | public: | |
9b341e6f | 136 | ImageView() : wxView() {} |
f37f49b6 JS |
137 | |
138 | virtual bool OnCreate(wxDocument*, long flags); | |
139 | virtual void OnDraw(wxDC*); | |
140 | virtual bool OnClose(bool deleteWindow = true); | |
141 | virtual void OnUpdate(wxView *sender, wxObject *hint = NULL); | |
142 | ||
2d4a03f8 | 143 | ImageDocument* GetDocument(); |
f37f49b6 | 144 | |
2d4a03f8 | 145 | private: |
2d4a03f8 | 146 | ImageCanvas* m_canvas; |
f37f49b6 | 147 | |
2d4a03f8 | 148 | DECLARE_DYNAMIC_CLASS(ImageView) |
f37f49b6 JS |
149 | }; |
150 | ||
4db97e24 VZ |
151 | // ---------------------------------------------------------------------------- |
152 | // ImageDetailsView | |
153 | // ---------------------------------------------------------------------------- | |
154 | ||
155 | class ImageDetailsView : public wxView | |
156 | { | |
157 | public: | |
158 | ImageDetailsView(ImageDetailsDocument *doc); | |
159 | ||
160 | virtual void OnDraw(wxDC *dc); | |
161 | virtual bool OnClose(bool deleteWindow); | |
162 | ||
163 | private: | |
164 | wxFrame *m_frame; | |
165 | ||
166 | wxDECLARE_NO_COPY_CLASS(ImageDetailsView); | |
167 | }; | |
168 | ||
2d1df0fc | 169 | #endif // _WX_SAMPLES_DOCVIEW_VIEW_H_ |