]>
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
8 // Copyright: (c) 1998 Julian Smart
9 // (c) 2008 Vadim Zeitlin
10 // Licence: wxWindows license
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
);
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() { m_canvas
= NULL
; m_frame
= 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
);
86 DECLARE_DYNAMIC_CLASS(DrawingView
)
89 // ----------------------------------------------------------------------------
91 // ----------------------------------------------------------------------------
93 // The view using a standard wxTextCtrl to show its contents
94 class TextEditView
: public wxView
97 TextEditView() : wxView() { m_frame
= NULL
; m_text
= NULL
; }
99 virtual bool OnCreate(wxDocument
*doc
, long flags
);
100 virtual void OnDraw(wxDC
*dc
);
101 virtual bool OnClose(bool deleteWindow
= true);
103 wxTextCtrl
*GetText() const { return m_text
; }
106 void OnCopy(wxCommandEvent
& WXUNUSED(event
)) { m_text
->Copy(); }
107 void OnPaste(wxCommandEvent
& WXUNUSED(event
)) { m_text
->Paste(); }
108 void OnSelectAll(wxCommandEvent
& WXUNUSED(event
)) { m_text
->SelectAll(); }
113 DECLARE_EVENT_TABLE()
114 DECLARE_DYNAMIC_CLASS(TextEditView
)
117 #endif // _WX_SAMPLES_DOCVIEW_VIEW_H_