]>
Commit | Line | Data |
---|---|---|
2108f33a JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: doc.h | |
3 | // Purpose: Document classes | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
6aa89a22 | 8 | // Copyright: (c) Julian Smart |
2f6c54eb | 9 | // Licence: wxWindows license |
2108f33a JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
2108f33a JS |
12 | #ifndef __DOCSAMPLEH__ |
13 | #define __DOCSAMPLEH__ | |
14 | ||
15 | #include "wx/docview.h" | |
ff8b6290 | 16 | #include "wx/cmdproc.h" |
2108f33a JS |
17 | |
18 | // Plots a line from one point to the other | |
19 | class DoodleLine: public wxObject | |
20 | { | |
21 | public: | |
23a54e14 RR |
22 | wxInt32 x1; |
23 | wxInt32 y1; | |
24 | wxInt32 x2; | |
25 | wxInt32 y2; | |
2108f33a JS |
26 | }; |
27 | ||
28 | // Contains a list of lines: represents a mouse-down doodle | |
29 | class DoodleSegment: public wxObject | |
30 | { | |
31 | public: | |
32 | wxList lines; | |
33 | ||
958d3a7e | 34 | DoodleSegment(void){}; |
fbfb8bcc | 35 | DoodleSegment(const DoodleSegment& seg); |
2108f33a JS |
36 | ~DoodleSegment(void); |
37 | ||
38 | void Draw(wxDC *dc); | |
958d3a7e | 39 | |
23a54e14 | 40 | #if wxUSE_STD_IOSTREAM |
dd107c50 VZ |
41 | wxSTD ostream& SaveObject(wxSTD ostream& text_stream); |
42 | wxSTD istream& LoadObject(wxSTD istream& text_stream); | |
23a54e14 RR |
43 | #else |
44 | wxOutputStream& SaveObject(wxOutputStream& stream); | |
45 | wxInputStream& LoadObject(wxInputStream& stream); | |
46 | #endif | |
2108f33a JS |
47 | }; |
48 | ||
49 | class DrawingDocument: public wxDocument | |
50 | { | |
51 | DECLARE_DYNAMIC_CLASS(DrawingDocument) | |
52 | private: | |
53 | public: | |
54 | wxList doodleSegments; | |
958d3a7e WS |
55 | |
56 | DrawingDocument(void){}; | |
2108f33a JS |
57 | ~DrawingDocument(void); |
58 | ||
23a54e14 | 59 | #if wxUSE_STD_IOSTREAM |
dd107c50 VZ |
60 | wxSTD ostream& SaveObject(wxSTD ostream& text_stream); |
61 | wxSTD istream& LoadObject(wxSTD istream& text_stream); | |
23a54e14 RR |
62 | #else |
63 | wxOutputStream& SaveObject(wxOutputStream& stream); | |
64 | wxInputStream& LoadObject(wxInputStream& stream); | |
65 | #endif | |
2108f33a JS |
66 | |
67 | inline wxList& GetDoodleSegments(void) const { return (wxList&) doodleSegments; }; | |
68 | }; | |
69 | ||
70 | #define DOODLE_CUT 1 | |
71 | #define DOODLE_ADD 2 | |
72 | ||
73 | class DrawingCommand: public wxCommand | |
74 | { | |
75 | protected: | |
76 | DoodleSegment *segment; | |
77 | DrawingDocument *doc; | |
78 | int cmd; | |
79 | public: | |
80 | DrawingCommand(const wxString& name, int cmd, DrawingDocument *ddoc, DoodleSegment *seg); | |
81 | ~DrawingCommand(void); | |
82 | ||
83 | bool Do(void); | |
84 | bool Undo(void); | |
85 | }; | |
86 | ||
87 | class TextEditDocument: public wxDocument | |
88 | { | |
89 | DECLARE_DYNAMIC_CLASS(TextEditDocument) | |
90 | private: | |
91 | public: | |
92 | /* | |
dd107c50 VZ |
93 | wxSTD ostream& SaveObject(wxSTD ostream& stream); |
94 | wxSTD istream& LoadObject(wxSTD istream& stream); | |
2108f33a JS |
95 | */ |
96 | virtual bool OnSaveDocument(const wxString& filename); | |
97 | virtual bool OnOpenDocument(const wxString& filename); | |
98 | virtual bool IsModified(void) const; | |
99 | virtual void Modify(bool mod); | |
100 | ||
101 | TextEditDocument(void) {} | |
102 | ~TextEditDocument(void) {} | |
103 | }; | |
104 | ||
105 | ||
106 | #endif |