this function will create a frame window, child of the mainframe, and will tell that frame about the view. The MutViewFrame is smart enough to know what to do with the view (ie use it for painting).
Definiert in Zeile 72 der Datei MutDocument.cpp.
Benutzt mutaborGUI::MutDocument::CmdNewView(), mutaborGUI::MutDocument::CmdUpdateAllViews(), DEBUGLOG, mutaborGUI::MutDocument::DoOpenDocument(), mutaborGUI::MutDocument::DoSaveDocument(), mutaborGUI::MutView::GetMutFrame(), mutaborGUI::MutView::GetTextsw(), mutaborGUI::MutDocument::IsModified(), mutaborGUI::MutDocument::LoadObject(), mutaborGUI::MutDocument::Modify(), mutaborGUI::MutView::OnCreate(), mutaborGUI::MutDocument::OnCreate(), mutaborGUI::MutDocument::OnNewDocument(), mutaborGUI::MutDocument::OnNewViewUpdateUI() und mutaborGUI::MutDocument::SaveObject().
{
MutDocument::MutDocument():wxDocument()
{
}
MutDocument::~MutDocument()
{
}
bool MutDocument::DoSaveDocument(const wxString& filename)
{
MutView *view = (MutView *)GetFirstView();
if (!view->GetTextsw()->SaveFile(filename))
return false;
return true;
}
bool MutDocument::DoOpenDocument(const wxString& filename)
{
MutView *view = (MutView *)GetFirstView();
if (!view->GetTextsw()->LoadFile(filename))
return false;
DEBUGLOG(docview,_T("New title: ")+GetDocumentManager()->MakeFrameTitle(this));
MutFrame * frame = view->GetMutFrame();
if (frame)
frame->SetTitle(GetDocumentManager()->MakeFrameTitle(this));
return true;
}
bool MutDocument::OnNewDocument()
{
if (!wxDocument::OnNewDocument())
return false;
DEBUGLOG(docview,_T("New title: ")+GetDocumentManager()->MakeFrameTitle(this));
MutView *view = (MutView *)GetFirstView();
if (view) {
MutFrame * frame = view -> GetMutFrame();
if (frame)
frame -> SetTitle(GetDocumentManager()->MakeFrameTitle(this));
}
return true;
}
#if wxUSE_STD_IOSTREAM
wxSTD ostream& MutDocument::SaveObject(wxSTD ostream& stream)
{
printf("cmydoc::saveobject\n");
stream << 5;
stream << 'j';
return stream;
}
wxSTD istream& MutDocument::LoadObject(wxSTD istream& stream)
{
DEBUGLOG(docview,_T(""));
bool bOK(false);
int nA(0);
char ch(0);
stream >> nA;
stream >> ch;
if(stream.good())
{
DEBUGLOG(docview,_T("num is %d and char is %c"), nA, ch);
bOK = true;
}
if(bOK == false)
{
DEBUGLOG(docview,_T("load error"));
stream.clear(std::ios_base::badbit);
}
return stream;
}
#else
wxOutputStream& MutDocument::SaveObject(wxOutputStream& stream)
{
printf("mydoc::saveobject()\n");
return stream;
}
wxInputStream& MutDocument::LoadObject(wxInputStream& stream)
{
printf("mydoc::loadobject()\n");
return stream;
}
#endif
bool MutDocument::OnCreate(const wxString& path, long flags)
{
return wxDocument::OnCreate(path, flags);
}
bool MutDocument::IsModified(void) const
{
MutView *view = (MutView *)GetFirstView();
if (view && view -> GetTextsw())
{
return (wxDocument::IsModified() || view->GetTextsw()->IsModified());
}
else
return wxDocument::IsModified();
}
void MutDocument::Modify(bool mod)
{
MutView *view = (MutView *)GetFirstView();
wxDocument::Modify(mod);
if (!mod && view && view->GetTextsw())
view->GetTextsw()->SetSavePoint();
}
void MutDocument::CmdNewView(wxCommandEvent& event)
{
printf("MutDocument::CmdNewView\n");
MutView* pview = new MutView();
bool bKeep = pview->OnCreate(NULL, 0);
if(bKeep)
{
AddView(pview);
pview->SetDocument(this);
}
else
{
pview->Close(TRUE);
wxFAIL;
}
}
void MutDocument::CmdUpdateAllViews(wxCommandEvent& event)
{
UpdateAllViews();
}
void MutDocument::OnNewViewUpdateUI(wxUpdateUIEvent& event)
{
event.Enable(true);
}
}