]>
git.saurik.com Git - wxWidgets.git/blob - samples/docview/view.h
3ba84d88476509d50e0d2cd40a7ca42167b2690a
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
8 // Copyright: (c) 1998 Julian Smart
9 // (c) 2008 Vadim Zeitlin
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_SAMPLES_DOCVIEW_VIEW_H_
14 #define _WX_SAMPLES_DOCVIEW_VIEW_H_
16 #include "wx/docview.h"
18 // ----------------------------------------------------------------------------
19 // Drawing view classes
20 // ----------------------------------------------------------------------------
22 // The window showing the drawing itself
23 class MyCanvas
: public wxScrolledWindow
26 // view may be NULL if we're not associated with one yet, but parent must
28 MyCanvas(wxView
*view
, wxWindow
*parent
= NULL
);
31 virtual void OnDraw(wxDC
& dc
);
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
38 void SetView(wxView
*view
)
40 wxASSERT_MSG( !m_view
, "shouldn't be already associated with a view" );
47 wxASSERT_MSG( m_view
, "should be associated with a view" );
53 void OnMouseEvent(wxMouseEvent
& event
);
57 // the segment being currently drawn or NULL if none
58 DoodleSegment
*m_currentSegment
;
60 // the last mouse press position
61 wxPoint m_lastMousePos
;
66 // The view using MyCanvas to show its contents
67 class DrawingView
: public wxView
70 DrawingView() : wxView(), m_canvas(NULL
) {}
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);
77 DrawingDocument
* GetDocument();
80 void OnCut(wxCommandEvent
& event
);
85 DECLARE_DYNAMIC_CLASS(DrawingView
)
88 // ----------------------------------------------------------------------------
90 // ----------------------------------------------------------------------------
92 // The view using a standard wxTextCtrl to show its contents
93 class TextEditView
: public wxView
96 TextEditView() : wxView(), m_text(NULL
) {}
98 virtual bool OnCreate(wxDocument
*doc
, long flags
);
99 virtual void OnDraw(wxDC
*dc
);
100 virtual bool OnClose(bool deleteWindow
= true);
102 wxTextCtrl
*GetText() const { return m_text
; }
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(); }
111 DECLARE_EVENT_TABLE()
112 DECLARE_DYNAMIC_CLASS(TextEditView
)
115 // ----------------------------------------------------------------------------
117 // ----------------------------------------------------------------------------
119 class ImageCanvas
: public wxScrolledWindow
122 ImageCanvas(wxView
*);
124 virtual void OnDraw(wxDC
& dc
);
129 // ----------------------------------------------------------------------------
131 // ----------------------------------------------------------------------------
133 class ImageView
: public wxView
136 ImageView() : wxView() {}
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
);
143 ImageDocument
* GetDocument();
146 ImageCanvas
* m_canvas
;
148 DECLARE_DYNAMIC_CLASS(ImageView
)
151 // ----------------------------------------------------------------------------
153 // ----------------------------------------------------------------------------
155 class ImageDetailsView
: public wxView
158 ImageDetailsView(ImageDetailsDocument
*doc
);
160 virtual void OnDraw(wxDC
*dc
);
161 virtual bool OnClose(bool deleteWindow
);
166 wxDECLARE_NO_COPY_CLASS(ImageDetailsView
);
169 #endif // _WX_SAMPLES_DOCVIEW_VIEW_H_