X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/debe6624c1e9d4bf3243381153d1e173c849bcd8..a3622daa901777a33969d8bc04e2d62dee14d164:/src/common/docview.cpp?ds=sidebyside diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 81d86a85a2..876c51c9cb 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -36,6 +36,10 @@ #include "wx/filedlg.h" #endif +#ifdef __WXGTK__ +#include "wx/mdi.h" +#endif + #include "wx/msgdlg.h" #include "wx/choicdlg.h" #include "wx/docview.h" @@ -43,12 +47,6 @@ #include "wx/generic/prntdlgg.h" #include "wx/generic/printps.h" -/* -#ifdef __WINDOWS__ -#include "wx/mdi.h" -#endif -*/ - #include #include @@ -198,16 +196,28 @@ bool wxDocument::SaveAs(void) char *tmp = wxFileSelector("Save as", docTemplate->GetDirectory(), GetFilename(), docTemplate->GetDefaultExtension(), docTemplate->GetFileFilter(), - 0, GetDocumentWindow()); + wxSAVE|wxOVERWRITE_PROMPT, GetDocumentWindow()); if (!tmp) return FALSE; else { - SetFilename(tmp); - SetTitle(wxFileNameFromPath(tmp)); + wxString fileName(tmp); + wxString path(""); + wxString name(""); + wxString ext(""); + wxSplitPath(fileName, & path, & name, & ext); + + if (ext.IsEmpty() || ext == "") + { + fileName += "."; + fileName += docTemplate->GetDefaultExtension(); + } + + SetFilename(fileName); + SetTitle(wxFileNameFromPath(fileName)); - GetDocumentManager()->AddFileToHistory(tmp); + GetDocumentManager()->AddFileToHistory(fileName); // Notify the views that the filename has changed wxNode *node = m_documentViews.First(); @@ -488,28 +498,7 @@ void wxView::OnChangeFilename(void) wxString name; GetDocument()->GetPrintableName(name); - // If the frame is an MDI child, just set the title - // to the name. - // Otherwise, append the document name to the name of the application -#ifdef __WINDOWS__ - if (GetFrame()->IsKindOf(CLASSINFO(wxMDIChildFrame))) -#else - if (FALSE) -#endif - { - GetFrame()->SetTitle(name); - } - else - { - if (wxTheApp->GetAppName() != "") - { - char buf[400]; - sprintf(buf, "%s - %s", (const char *)wxTheApp->GetAppName(), (const char *)name); - GetFrame()->SetTitle(buf); - } - else - GetFrame()->SetTitle(name); - } + GetFrame()->SetTitle(name); } } @@ -753,7 +742,7 @@ void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event)) { // TODO: trouble about this is that it pulls in the postscript // code unecessarily -#ifdef __WINDOWS__ +#ifdef __WXMSW__ if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS ) { wxWindowsPrinter printer; @@ -779,7 +768,7 @@ void wxDocManager::OnPrintSetup(wxCommandEvent& WXUNUSED(event)) wxPrintData data; -#ifdef __WINDOWS__ +#ifdef __WXMSW__ if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS ) { wxPrintDialog printerDialog(parentWin, & data); @@ -806,12 +795,12 @@ void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event)) { // Pass two printout objects: for preview, and possible printing. wxPrintPreviewBase *preview = NULL; -#ifdef __WINDOWS__ +#ifdef __WXMSW__ if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS ) preview = new wxWindowsPrintPreview(printout, view->OnCreatePrintout()); else #endif - preview = new wxPostScriptPrintPreview(printout, view->OnCreatePrintout()); + preview = new wxPostScriptPrintPreview(printout, view->OnCreatePrintout()); wxPreviewFrame *frame = new wxPreviewFrame(preview, (wxFrame *)wxTheApp->GetTopWindow(), "Print Preview", wxPoint(100, 100), wxSize(600, 650)); @@ -839,6 +828,30 @@ void wxDocManager::OnRedo(wxCommandEvent& WXUNUSED(event)) doc->GetCommandProcessor()->Redo(); } +wxView *wxDocManager::GetCurrentView(void) const +{ + if (m_currentView) + return m_currentView; + if (m_docs.Number() == 1) + { + wxDocument* doc = (wxDocument*) m_docs.First()->Data(); + return doc->GetFirstView(); + } + return NULL; +} + +// Extend event processing to search the view's event table +bool wxDocManager::ProcessEvent(wxEvent& event) +{ + wxView* view = GetCurrentView(); + if (view) + { + if (view->ProcessEvent(event)) + return TRUE; + } + return wxEvtHandler::ProcessEvent(event); +} + wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags) { wxDocTemplate **templates = new wxDocTemplate *[m_templates.Number()]; @@ -1126,7 +1139,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, int noTemplates, wxString& path, long WXUNUSED(flags), bool WXUNUSED(save)) { // We can only have multiple filters in Windows -#ifdef __WINDOWS__ +#ifdef __WXMSW__ char *descrBuf = new char[1000]; descrBuf[0] = 0; int i; @@ -1307,9 +1320,9 @@ BEGIN_EVENT_TABLE(wxDocChildFrame, wxFrame) EVT_ACTIVATE(wxDocChildFrame::OnActivate) END_EVENT_TABLE() -wxDocChildFrame::wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, const wxString& title, +wxDocChildFrame::wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name): - wxFrame(frame, -1, title, pos, size, style, name) + wxFrame(frame, id, title, pos, size, style, name) { m_childDocument = doc; m_childView = view; @@ -1373,12 +1386,12 @@ bool wxDocChildFrame::OnClose(void) BEGIN_EVENT_TABLE(wxDocParentFrame, wxFrame) EVT_MENU(wxID_EXIT, wxDocParentFrame::OnExit) - EVT_MENU_RANGE(wxID_FILE1, wxID_FILE2, wxDocParentFrame::OnMRUFile) + EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, wxDocParentFrame::OnMRUFile) END_EVENT_TABLE() -wxDocParentFrame::wxDocParentFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, +wxDocParentFrame::wxDocParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name): - wxFrame(frame, -1, title, pos, size, style, name) + wxFrame(frame, id, title, pos, size, style, name) { m_docManager = manager; }