Add support for child documents to docview framework.

Child documents are virtual documents corresponding to parts of their parent
document which can't be saved nor loaded independently of their parent and are
closed when the parent is closed.

This finally makes some use of wxDocument::m_documentParent field which was
always present in the docview code but never used before.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68051 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-06-27 00:09:37 +00:00
parent 9f3b6638e4
commit 4db97e24f5
8 changed files with 255 additions and 6 deletions

View File

@@ -198,14 +198,19 @@ public:
};
// ----------------------------------------------------------------------------
// A document class representing an image
// 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:
@@ -218,4 +223,28 @@ private:
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_