]> git.saurik.com Git - wxWidgets.git/blame - samples/docview/view.h
Applied #15226 with modifications: wxRichTextCtrl: Implement setting properties with...
[wxWidgets.git] / samples / docview / view.h
CommitLineData
457814b5 1/////////////////////////////////////////////////////////////////////////////
2d1df0fc 2// Name: samples/docview/view.h
457814b5
JS
3// Purpose: View classes
4// Author: Julian Smart
2d1df0fc 5// Modified by: Vadim Zeitlin: merge with the MDI version and general cleanup
457814b5 6// Created: 04/01/98
2d1df0fc
VZ
7// Copyright: (c) 1998 Julian Smart
8// (c) 2008 Vadim Zeitlin
526954c5 9// Licence: wxWindows licence
457814b5
JS
10/////////////////////////////////////////////////////////////////////////////
11
2d1df0fc
VZ
12#ifndef _WX_SAMPLES_DOCVIEW_VIEW_H_
13#define _WX_SAMPLES_DOCVIEW_VIEW_H_
457814b5
JS
14
15#include "wx/docview.h"
16
2d1df0fc
VZ
17// ----------------------------------------------------------------------------
18// Drawing view classes
19// ----------------------------------------------------------------------------
20
21// The window showing the drawing itself
6bdf5153 22class MyCanvas : public wxScrolledWindow
457814b5 23{
f6bcfd97 24public:
2d1df0fc
VZ
25 // view may be NULL if we're not associated with one yet, but parent must
26 // be a valid pointer
9b341e6f 27 MyCanvas(wxView *view, wxWindow *parent = NULL);
2d1df0fc 28 virtual ~MyCanvas();
6bdf5153 29
457814b5 30 virtual void OnDraw(wxDC& dc);
6bdf5153 31
2d1df0fc
VZ
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
51private:
457814b5 52 void OnMouseEvent(wxMouseEvent& event);
457814b5 53
2d1df0fc
VZ
54 wxView *m_view;
55
56 // the segment being currently drawn or NULL if none
57 DoodleSegment *m_currentSegment;
6bdf5153 58
2d1df0fc
VZ
59 // the last mouse press position
60 wxPoint m_lastMousePos;
61
62 DECLARE_EVENT_TABLE()
457814b5
JS
63};
64
2d1df0fc 65// The view using MyCanvas to show its contents
6bdf5153 66class DrawingView : public wxView
457814b5 67{
f6bcfd97 68public:
9b341e6f 69 DrawingView() : wxView(), m_canvas(NULL) {}
6bdf5153
VZ
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
2d1df0fc 78private:
f6bcfd97 79 void OnCut(wxCommandEvent& event);
6bdf5153 80
2d1df0fc
VZ
81 MyCanvas *m_canvas;
82
f6bcfd97 83 DECLARE_EVENT_TABLE()
6bdf5153 84 DECLARE_DYNAMIC_CLASS(DrawingView)
457814b5
JS
85};
86
2d1df0fc
VZ
87// ----------------------------------------------------------------------------
88// Text view classes
89// ----------------------------------------------------------------------------
90
91// The view using a standard wxTextCtrl to show its contents
6bdf5153 92class TextEditView : public wxView
457814b5 93{
f6bcfd97 94public:
9b341e6f 95 TextEditView() : wxView(), m_text(NULL) {}
6bdf5153
VZ
96
97 virtual bool OnCreate(wxDocument *doc, long flags);
98 virtual void OnDraw(wxDC *dc);
6bdf5153 99 virtual bool OnClose(bool deleteWindow = true);
6bdf5153 100
2d1df0fc
VZ
101 wxTextCtrl *GetText() const { return m_text; }
102
6bdf5153 103private:
2d1df0fc
VZ
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
2d1df0fc 108 wxTextCtrl *m_text;
4e553af1
VZ
109
110 DECLARE_EVENT_TABLE()
6bdf5153 111 DECLARE_DYNAMIC_CLASS(TextEditView)
457814b5
JS
112};
113
f37f49b6 114// ----------------------------------------------------------------------------
2d4a03f8 115// ImageCanvas
f37f49b6
JS
116// ----------------------------------------------------------------------------
117
2d4a03f8 118class ImageCanvas : public wxScrolledWindow
f37f49b6
JS
119{
120public:
9b341e6f 121 ImageCanvas(wxView*);
f37f49b6
JS
122
123 virtual void OnDraw(wxDC& dc);
2d4a03f8 124private:
f37f49b6 125 wxView *m_view;
f37f49b6
JS
126};
127
128// ----------------------------------------------------------------------------
2d4a03f8 129// ImageView
f37f49b6
JS
130// ----------------------------------------------------------------------------
131
2d4a03f8 132class ImageView : public wxView
f37f49b6
JS
133{
134public:
9b341e6f 135 ImageView() : wxView() {}
f37f49b6
JS
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
2d4a03f8 142 ImageDocument* GetDocument();
f37f49b6 143
2d4a03f8 144private:
2d4a03f8 145 ImageCanvas* m_canvas;
f37f49b6 146
2d4a03f8 147 DECLARE_DYNAMIC_CLASS(ImageView)
f37f49b6
JS
148};
149
4db97e24
VZ
150// ----------------------------------------------------------------------------
151// ImageDetailsView
152// ----------------------------------------------------------------------------
153
154class ImageDetailsView : public wxView
155{
156public:
157 ImageDetailsView(ImageDetailsDocument *doc);
158
159 virtual void OnDraw(wxDC *dc);
160 virtual bool OnClose(bool deleteWindow);
161
162private:
163 wxFrame *m_frame;
164
165 wxDECLARE_NO_COPY_CLASS(ImageDetailsView);
166};
167
2d1df0fc 168#endif // _WX_SAMPLES_DOCVIEW_VIEW_H_