#if wxUSE_IOSTREAMH
#include <iostream.h>
+#include <fstream.h>
#else
#include <iostream>
+#include <fstream>
+# ifdef _MSC_VER
+ using namespace std;
+# endif
#endif
-#include "fstream.h"
-
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxDocument, wxEvtHandler)
IMPLEMENT_ABSTRACT_CLASS(wxView, wxEvtHandler)
{
if (IsModified())
{
- char buf[400];
wxString title;
GetPrintableName(title);
else
msgTitle = wxString(_("Warning"));
- sprintf(buf, _("Do you want to save changes to document %s?"), (const char *)title);
- int res = wxMessageBox(buf, msgTitle, wxYES_NO|wxCANCEL|wxICON_QUESTION,
- GetDocumentWindow());
+ wxString prompt;
+ prompt.Printf(_("Do you want to save changes to document %s?"),
+ (const char *)title);
+ int res = wxMessageBox(prompt, msgTitle,
+ wxYES_NO|wxCANCEL|wxICON_QUESTION,
+ GetDocumentWindow());
if (res == wxNO)
{
Modify(FALSE);
// Make a default document name
bool wxDocManager::MakeDefaultName(wxString& name)
{
- char buf[256];
- sprintf(buf, _("unnamed%d"), m_defaultDocumentNameCounter);
- m_defaultDocumentNameCounter ++;
- name = buf;
+ name.Printf(_("unnamed%d"), m_defaultDocumentNameCounter);
+ m_defaultDocumentNameCounter++;
+
return TRUE;
}
// How to implement in wxWindows? Must extend the file selector
// dialog or implement own; OR match the extension to the
// template extension.
+
+#ifdef __WXMSW__
wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
int noTemplates, wxString& path, long WXUNUSED(flags), bool WXUNUSED(save))
+#else
+wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **WXUNUSED(templates),
+ int WXUNUSED(noTemplates), wxString& path, long WXUNUSED(flags), bool WXUNUSED(save))
+#endif
{
// We can only have multiple filters in Windows
#ifdef __WXMSW__
- char *descrBuf = new char[1000];
+ char *descrBuf = new char[1000]; // FIXME static buffer
descrBuf[0] = 0;
int i;
for (i = 0; i < noTemplates; i++)
if (len > 0)
// Omit final "|"
descrBuf[len-1] = 0;
+#else
+ char* descrBuf = copystring("*.*");
+#endif
char *pathTmp = wxFileSelector(_("Select a file"), "", "", "", descrBuf, 0, wxTheApp->GetTopWindow());
delete[] descrBuf;
path = "";
return (wxDocTemplate *) NULL;
}
-#else
+#if 0
// In all other windowing systems, until we have more advanced
// file selectors, we must select the document type (template) first, and
// _then_ pop up the file selector.
BEGIN_EVENT_TABLE(wxDocChildFrame, wxFrame)
EVT_ACTIVATE(wxDocChildFrame::OnActivate)
+ EVT_CLOSE(wxDocChildFrame::OnCloseWindow)
END_EVENT_TABLE()
wxDocChildFrame::wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, wxWindowID id, const wxString& title,
m_childView->Activate(event.GetActive());
}
-bool wxDocChildFrame::OnClose(void)
+void wxDocChildFrame::OnCloseWindow(wxCloseEvent& event)
{
- // Close view but don't delete the frame while doing so!
- // ...since it will be deleted by wxWindows if we return TRUE.
if (m_childView)
{
- bool ans = m_childView->Close(FALSE); // FALSE means don't delete associated window
+ bool ans = FALSE;
+ if (!event.CanVeto())
+ ans = TRUE; // Must delete.
+ else
+ ans = m_childView->Close(FALSE); // FALSE means don't delete associated window
+
if (ans)
{
m_childView->Activate(FALSE);
delete m_childView;
m_childView = (wxView *) NULL;
m_childDocument = (wxDocument *) NULL;
+
+ this->Destroy();
}
-
- return ans;
+ else
+ event.Veto();
}
- else return TRUE;
+ else
+ event.Veto();
}
/*
BEGIN_EVENT_TABLE(wxDocParentFrame, wxFrame)
EVT_MENU(wxID_EXIT, wxDocParentFrame::OnExit)
EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, wxDocParentFrame::OnMRUFile)
+ EVT_CLOSE(wxDocParentFrame::OnCloseWindow)
END_EVENT_TABLE()
wxDocParentFrame::wxDocParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title,
// Define the behaviour for the frame closing
// - must delete all frames except for the main one.
-bool wxDocParentFrame::OnClose(void)
+void wxDocParentFrame::OnCloseWindow(wxCloseEvent& event)
{
- return m_docManager->Clear(FALSE);
+ if (m_docManager->Clear(!event.CanVeto()))
+ {
+ this->Destroy();
+ }
+ else
+ event.Veto();
}
#if wxUSE_PRINTING_ARCHITECTURE
for (i = 0; i < m_fileHistoryN; i++)
if (m_fileHistory[i])
{
- char buf[400];
- sprintf(buf, "&%d %s", i+1, m_fileHistory[i]);
+ wxString buf;
+ buf.Printf("&%d %s", i+1, m_fileHistory[i]);
wxNode* node = m_fileMenus.First();
while (node)
{
void wxFileHistory::Load(wxConfigBase& config)
{
m_fileHistoryN = 0;
- char buf[400];
- sprintf(buf, "file%d", m_fileHistoryN+1);
- wxString historyFile("");
+ wxString buf;
+ buf.Printf("file%d", m_fileHistoryN+1);
+ wxString historyFile;
while ((m_fileHistoryN <= m_fileMaxFiles) && config.Read(buf, &historyFile) && (historyFile != ""))
{
m_fileHistory[m_fileHistoryN] = copystring((const char*) historyFile);
m_fileHistoryN ++;
- sprintf(buf, "file%d", m_fileHistoryN+1);
+ buf.Printf("file%d", m_fileHistoryN+1);
historyFile = "";
}
AddFilesToMenu();