]> git.saurik.com Git - wxWidgets.git/blob - samples/docview/view.h
Added NSApplicationDelegate's openFiles for wxOSX-Cocoa.
[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 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Julian Smart
9 // (c) 2008 Vadim Zeitlin
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_SAMPLES_DOCVIEW_VIEW_H_
14 #define _WX_SAMPLES_DOCVIEW_VIEW_H_
15
16 #include "wx/docview.h"
17
18 // ----------------------------------------------------------------------------
19 // Drawing view classes
20 // ----------------------------------------------------------------------------
21
22 // The window showing the drawing itself
23 class MyCanvas : public wxScrolledWindow
24 {
25 public:
26 // view may be NULL if we're not associated with one yet, but parent must
27 // be a valid pointer
28 MyCanvas(wxView *view, wxWindow *parent = NULL);
29 virtual ~MyCanvas();
30
31 virtual void OnDraw(wxDC& dc);
32
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:
53 void OnMouseEvent(wxMouseEvent& event);
54
55 wxView *m_view;
56
57 // the segment being currently drawn or NULL if none
58 DoodleSegment *m_currentSegment;
59
60 // the last mouse press position
61 wxPoint m_lastMousePos;
62
63 DECLARE_EVENT_TABLE()
64 };
65
66 // The view using MyCanvas to show its contents
67 class DrawingView : public wxView
68 {
69 public:
70 DrawingView() : wxView(), m_canvas(NULL) {}
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
79 private:
80 void OnCut(wxCommandEvent& event);
81
82 MyCanvas *m_canvas;
83
84 DECLARE_EVENT_TABLE()
85 DECLARE_DYNAMIC_CLASS(DrawingView)
86 };
87
88 // ----------------------------------------------------------------------------
89 // Text view classes
90 // ----------------------------------------------------------------------------
91
92 // The view using a standard wxTextCtrl to show its contents
93 class TextEditView : public wxView
94 {
95 public:
96 TextEditView() : wxView(), m_text(NULL) {}
97
98 virtual bool OnCreate(wxDocument *doc, long flags);
99 virtual void OnDraw(wxDC *dc);
100 virtual bool OnClose(bool deleteWindow = true);
101
102 wxTextCtrl *GetText() const { return m_text; }
103
104 private:
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
109 wxTextCtrl *m_text;
110
111 DECLARE_EVENT_TABLE()
112 DECLARE_DYNAMIC_CLASS(TextEditView)
113 };
114
115 // ----------------------------------------------------------------------------
116 // ImageCanvas
117 // ----------------------------------------------------------------------------
118
119 class ImageCanvas : public wxScrolledWindow
120 {
121 public:
122 ImageCanvas(wxView*);
123
124 virtual void OnDraw(wxDC& dc);
125 private:
126 wxView *m_view;
127 };
128
129 // ----------------------------------------------------------------------------
130 // ImageView
131 // ----------------------------------------------------------------------------
132
133 class ImageView : public wxView
134 {
135 public:
136 ImageView() : wxView() {}
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
143 ImageDocument* GetDocument();
144
145 private:
146 ImageCanvas* m_canvas;
147
148 DECLARE_DYNAMIC_CLASS(ImageView)
149 };
150
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
169 #endif // _WX_SAMPLES_DOCVIEW_VIEW_H_