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