X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/828c8f98d5346c58b8fa75b043fba7a2a007b337..c29c95fe24973b94fd724db767193171ca7c513d:/samples/docview/doc.h?ds=sidebyside diff --git a/samples/docview/doc.h b/samples/docview/doc.h index 280f1656c0..c654398222 100644 --- a/samples/docview/doc.h +++ b/samples/docview/doc.h @@ -7,7 +7,7 @@ // RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart // (c) 2008 Vadim Zeitlin -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_SAMPLES_DOCVIEW_DOC_H_ @@ -16,6 +16,7 @@ #include "wx/docview.h" #include "wx/cmdproc.h" #include "wx/vector.h" +#include "wx/image.h" // This sample is written to build both with wxUSE_STD_IOSTREAM==0 and 1, which // somewhat complicates its code but is necessary in order to support building @@ -164,6 +165,9 @@ class wxTextDocument : public wxDocument { public: wxTextDocument() : wxDocument() { } + + virtual bool OnCreate(const wxString& path, long flags); + virtual wxTextCtrl* GetTextCtrl() const = 0; virtual bool IsModified() const; @@ -173,7 +177,9 @@ protected: virtual bool DoSaveDocument(const wxString& filename); virtual bool DoOpenDocument(const wxString& filename); - DECLARE_NO_COPY_CLASS(wxTextDocument) + void OnTextChange(wxCommandEvent& event); + + wxDECLARE_NO_COPY_CLASS(wxTextDocument); DECLARE_CLASS(wxTextDocument) }; @@ -187,8 +193,58 @@ public: TextEditDocument() : wxTextDocument() { } virtual wxTextCtrl* GetTextCtrl() const; - DECLARE_NO_COPY_CLASS(TextEditDocument) + wxDECLARE_NO_COPY_CLASS(TextEditDocument); DECLARE_DYNAMIC_CLASS(TextEditDocument) }; +// ---------------------------------------------------------------------------- +// Image and image details document classes (both are read-only for simplicity) +// ---------------------------------------------------------------------------- + +// This is a normal document containing an image, just like TextEditDocument +// above contains some text. It can be created from an image file on disk as +// usual. +class ImageDocument : public wxDocument +{ +public: + ImageDocument() : wxDocument() { } + + virtual bool OnOpenDocument(const wxString& file); + + wxImage GetImage() const { return m_image; } + +protected: + virtual bool DoOpenDocument(const wxString& file); + +private: + wxImage m_image; + + wxDECLARE_NO_COPY_CLASS(ImageDocument); + DECLARE_DYNAMIC_CLASS(ImageDocument) +}; + +// This is a child document of ImageDocument: this document doesn't +// correspond to any file on disk, it's part of ImageDocument and can't be +// instantiated independently of it. +class ImageDetailsDocument : public wxDocument +{ +public: + ImageDetailsDocument(ImageDocument *parent); + + // accessors for ImageDetailsView + wxSize GetSize() const { return m_size; } + unsigned long GetNumColours() const { return m_numColours; } + wxBitmapType GetType() const { return m_type; } + bool HasAlpha() const { return m_hasAlpha; } + +private: + // some information about the image we choose to show to the user + wxSize m_size; + unsigned long m_numColours; + wxBitmapType m_type; + bool m_hasAlpha; + + wxDECLARE_NO_COPY_CLASS(ImageDetailsDocument); +}; + #endif // _WX_SAMPLES_DOCVIEW_DOC_H_