]>
git.saurik.com Git - wxWidgets.git/blob - 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
7 // Copyright: (c) 1998 Julian Smart
8 // (c) 2008 Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_SAMPLES_DOCVIEW_VIEW_H_
13 #define _WX_SAMPLES_DOCVIEW_VIEW_H_
15 #include "wx/docview.h"
17 // ----------------------------------------------------------------------------
18 // Drawing view classes
19 // ----------------------------------------------------------------------------
21 // The window showing the drawing itself
22 class MyCanvas
: public wxScrolledWindow
25 // view may be NULL if we're not associated with one yet, but parent must
27 MyCanvas(wxView
*view
, wxWindow
*parent
= NULL
);
30 virtual void OnDraw(wxDC
& dc
);
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
37 void SetView(wxView
*view
)
39 wxASSERT_MSG( !m_view
, "shouldn't be already associated with a view" );
46 wxASSERT_MSG( m_view
, "should be associated with a view" );
52 void OnMouseEvent(wxMouseEvent
& event
);
56 // the segment being currently drawn or NULL if none
57 DoodleSegment
*m_currentSegment
;
59 // the last mouse press position
60 wxPoint m_lastMousePos
;
65 // The view using MyCanvas to show its contents
66 class DrawingView
: public wxView
69 DrawingView() : wxView(), m_canvas(NULL
) {}
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);
76 DrawingDocument
* GetDocument();
79 void OnCut(wxCommandEvent
& event
);
84 DECLARE_DYNAMIC_CLASS(DrawingView
)
87 // ----------------------------------------------------------------------------
89 // ----------------------------------------------------------------------------
91 // The view using a standard wxTextCtrl to show its contents
92 class TextEditView
: public wxView
95 TextEditView() : wxView(), m_text(NULL
) {}
97 virtual bool OnCreate(wxDocument
*doc
, long flags
);
98 virtual void OnDraw(wxDC
*dc
);
99 virtual bool OnClose(bool deleteWindow
= true);
101 wxTextCtrl
*GetText() const { return m_text
; }
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(); }
110 DECLARE_EVENT_TABLE()
111 DECLARE_DYNAMIC_CLASS(TextEditView
)
114 // ----------------------------------------------------------------------------
116 // ----------------------------------------------------------------------------
118 class ImageCanvas
: public wxScrolledWindow
121 ImageCanvas(wxView
*);
123 virtual void OnDraw(wxDC
& dc
);
128 // ----------------------------------------------------------------------------
130 // ----------------------------------------------------------------------------
132 class ImageView
: public wxView
135 ImageView() : wxView() {}
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
);
142 ImageDocument
* GetDocument();
145 ImageCanvas
* m_canvas
;
147 DECLARE_DYNAMIC_CLASS(ImageView
)
150 // ----------------------------------------------------------------------------
152 // ----------------------------------------------------------------------------
154 class ImageDetailsView
: public wxView
157 ImageDetailsView(ImageDetailsDocument
*doc
);
159 virtual void OnDraw(wxDC
*dc
);
160 virtual bool OnClose(bool deleteWindow
);
165 wxDECLARE_NO_COPY_CLASS(ImageDetailsView
);
168 #endif // _WX_SAMPLES_DOCVIEW_VIEW_H_