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: doc.h 56679 2008-11-04 17:47:07Z VZ $ 8// Copyright: (c) Julian Smart 9// Licence: wxWindows license 10///////////////////////////////////////////////////////////////////////////// 11 12#ifndef __DOCSAMPLEH__ 13#define __DOCSAMPLEH__ 14 15#include "wx/docview.h" 16#include "wx/cmdproc.h" 17 18// Plots a line from one point to the other 19class DoodleLine: public wxObject 20{ 21 public: 22 wxInt32 x1; 23 wxInt32 y1; 24 wxInt32 x2; 25 wxInt32 y2; 26}; 27 28// Contains a list of lines: represents a mouse-down doodle 29class DoodleSegment: public wxObject 30{ 31 public: 32 wxList lines; 33 34 DoodleSegment(void){}; 35 DoodleSegment(const DoodleSegment& seg); 36 ~DoodleSegment(void); 37 38 void Draw(wxDC *dc); 39 40#if wxUSE_STD_IOSTREAM 41 wxSTD ostream& SaveObject(wxSTD ostream& text_stream); 42 wxSTD istream& LoadObject(wxSTD istream& text_stream); 43#else 44 wxOutputStream& SaveObject(wxOutputStream& stream); 45 wxInputStream& LoadObject(wxInputStream& stream); 46#endif 47}; 48 49class DrawingDocument: public wxDocument 50{ 51 DECLARE_DYNAMIC_CLASS(DrawingDocument) 52 private: 53 public: 54 wxList doodleSegments; 55 56 DrawingDocument(void){}; 57 ~DrawingDocument(void); 58 59#if wxUSE_STD_IOSTREAM 60 wxSTD ostream& SaveObject(wxSTD ostream& text_stream); 61 wxSTD istream& LoadObject(wxSTD istream& text_stream); 62#else 63 wxOutputStream& SaveObject(wxOutputStream& stream); 64 wxInputStream& LoadObject(wxInputStream& stream); 65#endif 66 67 inline wxList& GetDoodleSegments(void) const { return (wxList&) doodleSegments; }; 68}; 69 70#define DOODLE_CUT 1 71#define DOODLE_ADD 2 72 73class 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 87class TextEditDocument: public wxDocument 88{ 89 DECLARE_DYNAMIC_CLASS(TextEditDocument) 90 private: 91 public: 92/* 93 wxSTD ostream& SaveObject(wxSTD ostream& stream); 94 wxSTD istream& LoadObject(wxSTD istream& stream); 95*/ 96 virtual bool IsModified(void) const; 97 virtual void Modify(bool mod); 98 99 TextEditDocument(void) {} 100 virtual ~TextEditDocument(void) {} 101protected: 102 virtual bool DoOpenDocument(const wxString& filename); 103 virtual bool DoSaveDocument(const wxString& filename); 104}; 105 106 107#endif 108