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:
@@ -362,3 +362,76 @@ bool ImageView::OnClose(bool deleteWindow)
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ImageDetailsView
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
ImageDetailsView::ImageDetailsView(ImageDetailsDocument *doc)
|
||||
: wxView()
|
||||
{
|
||||
SetDocument(doc);
|
||||
|
||||
m_frame = wxGetApp().CreateChildFrame(this, false);
|
||||
m_frame->SetTitle("Image Details");
|
||||
|
||||
wxPanel * const panel = new wxPanel(m_frame);
|
||||
wxFlexGridSizer * const sizer = new wxFlexGridSizer(2, wxSize(5, 5));
|
||||
const wxSizerFlags
|
||||
flags = wxSizerFlags().Align(wxALIGN_CENTRE_VERTICAL).Border();
|
||||
|
||||
sizer->Add(new wxStaticText(panel, wxID_ANY, "Image &file:"), flags);
|
||||
sizer->Add(new wxStaticText(panel, wxID_ANY, doc->GetFilename()), flags);
|
||||
|
||||
sizer->Add(new wxStaticText(panel, wxID_ANY, "Image &type:"), flags);
|
||||
wxString typeStr;
|
||||
switch ( doc->GetType() )
|
||||
{
|
||||
case wxBITMAP_TYPE_PNG:
|
||||
typeStr = "PNG";
|
||||
break;
|
||||
|
||||
case wxBITMAP_TYPE_JPEG:
|
||||
typeStr = "JPEG";
|
||||
break;
|
||||
|
||||
default:
|
||||
typeStr = "Unknown";
|
||||
}
|
||||
sizer->Add(new wxStaticText(panel, wxID_ANY, typeStr), flags);
|
||||
|
||||
sizer->Add(new wxStaticText(panel, wxID_ANY, "Image &size:"), flags);
|
||||
wxSize size = doc->GetSize();
|
||||
sizer->Add(new wxStaticText(panel, wxID_ANY,
|
||||
wxString::Format("%d*%d", size.x, size.y)),
|
||||
flags);
|
||||
|
||||
sizer->Add(new wxStaticText(panel, wxID_ANY, "Number of unique &colours:"),
|
||||
flags);
|
||||
sizer->Add(new wxStaticText(panel, wxID_ANY,
|
||||
wxString::Format("%lu", doc->GetNumColours())),
|
||||
flags);
|
||||
|
||||
sizer->Add(new wxStaticText(panel, wxID_ANY, "Uses &alpha:"), flags);
|
||||
sizer->Add(new wxStaticText(panel, wxID_ANY,
|
||||
doc->HasAlpha() ? "Yes" : "No"), flags);
|
||||
|
||||
panel->SetSizer(sizer);
|
||||
m_frame->SetClientSize(panel->GetBestSize());
|
||||
m_frame->Show(true);
|
||||
}
|
||||
|
||||
void ImageDetailsView::OnDraw(wxDC * WXUNUSED(dc))
|
||||
{
|
||||
// nothing to do here, we use controls to show our information
|
||||
}
|
||||
|
||||
bool ImageDetailsView::OnClose(bool deleteWindow)
|
||||
{
|
||||
if ( wxGetApp().GetMode() != MyApp::Mode_Single && deleteWindow )
|
||||
{
|
||||
delete m_frame;
|
||||
m_frame = NULL;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user