Namensbereiche | |
namespace | mutabor |
namespace | mutaborGUI |
Main mutabor frame class. | |
Funktionen | |
IMPLEMENT_DYNAMIC_CLASS (MutDocument, wxDocument) BEGIN_EVENT_TABLE(MutDocument | |
wxDocument | END_EVENT_TABLE () namespace mutaborGUI |
IMPLEMENT_DYNAMIC_CLASS (MutView, wxView) BEGIN_EVENT_TABLE(MutView |
wxDocument END_EVENT_TABLE | ( | ) |
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")); // tell the framework to abort the load procedure 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) { // you should call the one in the superclass 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"); //wxMessageBox(wxT("doc newview 1"), _T("dialog"), wxOK | wxICON_INFORMATION, NULL); // we manually create a view, and register it with the document. // the view needs to create a window for itself, which // it can do in OnCreate MutView* pview = new MutView(); bool bKeep = pview->OnCreate(NULL, 0); if(bKeep) { AddView(pview); // we could set the title of the view's frame // AddView() does not set the document in the view, so we do that now pview->SetDocument(this); } else { // kill the view and its window. Hopefully nothing else. pview->Close(TRUE); // I don't think the Close function works wxFAIL; } // wxMessageBox(wxT("doc newview 2"), _T("dialog"), wxOK | wxICON_INFORMATION, NULL); } void MutDocument::CmdUpdateAllViews(wxCommandEvent& event) { UpdateAllViews(); } void MutDocument::OnNewViewUpdateUI(wxUpdateUIEvent& event) { event.Enable(true); // printf("MutDocument::OnNewViewUpdateUI\n"); } }
IMPLEMENT_DYNAMIC_CLASS | ( | MutView | , |
wxView | |||
) |
IMPLEMENT_DYNAMIC_CLASS | ( | MutDocument | , |
wxDocument | |||
) |