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

@@ -250,7 +250,7 @@ wxTextCtrl* TextEditDocument::GetTextCtrl() const
}
// ----------------------------------------------------------------------------
// ImageDocument and wxImageDetailsDocument implementation
// ImageDocument and ImageDetailsDocument implementation
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(ImageDocument, wxDocument)
@@ -260,3 +260,29 @@ bool ImageDocument::DoOpenDocument(const wxString& file)
return m_image.LoadFile(file);
}
bool ImageDocument::OnOpenDocument(const wxString& filename)
{
if ( !wxDocument::OnOpenDocument(filename) )
return false;
// we don't have a wxDocTemplate for the image details document as it's
// never created by wxWidgets automatically, instead just do it manually
ImageDetailsDocument * const docDetails = new ImageDetailsDocument(this);
docDetails->SetFilename(filename);
new ImageDetailsView(docDetails);
return true;
}
ImageDetailsDocument::ImageDetailsDocument(ImageDocument *parent)
: wxDocument(parent)
{
const wxImage image = parent->GetImage();
m_size.x = image.GetWidth();
m_size.y = image.GetHeight();
m_numColours = image.CountColours();
m_type = image.GetType();
m_hasAlpha = image.HasAlpha();
}