home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wxos2240.zip / wxWindows-2.4.0 / samples / docvwmdi / doc.h < prev    next >
C/C++ Source or Header  |  2002-03-17  |  3KB  |  111 lines

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