#include "wx/menu.h"
#include "wx/list.h"
#include "wx/filedlg.h"
+#include <wx/intl.h>
+#endif
+
+#ifdef __WXGTK__
+#include "wx/mdi.h"
#endif
#include "wx/msgdlg.h"
#include "wx/generic/prntdlgg.h"
#include "wx/generic/printps.h"
-/*
-#ifdef __WINDOWS__
-#include "wx/mdi.h"
-#endif
-*/
-
#include <stdio.h>
#include <string.h>
if (!docTemplate)
return FALSE;
- char *tmp = wxFileSelector("Save as", docTemplate->GetDirectory(), GetFilename(),
+ 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();
if (wxTheApp->GetAppName() != "")
msgTitle = wxTheApp->GetAppName();
else
- msgTitle = wxString("File error");
+ msgTitle = wxString(_("File error"));
ofstream store(file);
if (store.fail() || store.bad())
{
- (void)wxMessageBox("Sorry, could not open this file for saving.", msgTitle, wxOK | wxICON_EXCLAMATION,
+ (void)wxMessageBox(_("Sorry, could not open this file for saving."), msgTitle, wxOK | wxICON_EXCLAMATION,
GetDocumentWindow());
// Saving error
return FALSE;
}
if (SaveObject(store)==FALSE)
{
- (void)wxMessageBox("Sorry, could not save this file.", msgTitle, wxOK | wxICON_EXCLAMATION,
+ (void)wxMessageBox(_("Sorry, could not save this file."), msgTitle, wxOK | wxICON_EXCLAMATION,
GetDocumentWindow());
// Saving error
return FALSE;
if (wxTheApp->GetAppName() != "")
msgTitle = wxTheApp->GetAppName();
else
- msgTitle = wxString("File error");
+ msgTitle = wxString(_("File error"));
ifstream store(file);
if (store.fail() || store.bad())
{
- (void)wxMessageBox("Sorry, could not open this file.", msgTitle, wxOK|wxICON_EXCLAMATION,
+ (void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
GetDocumentWindow());
return FALSE;
}
if (LoadObject(store)==FALSE)
{
- (void)wxMessageBox("Sorry, could not open this file.", msgTitle, wxOK|wxICON_EXCLAMATION,
+ (void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
GetDocumentWindow());
return FALSE;
}
}
else
{
- buf = "unnamed";
+ buf = _("unnamed");
return TRUE;
}
}
if (wxTheApp->GetAppName() != "")
msgTitle = wxTheApp->GetAppName();
else
- msgTitle = wxString("Warning");
+ msgTitle = wxString(_("Warning"));
- sprintf(buf, "Do you want to save changes to document %s?", (const char *)title);
+ 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());
if (res == wxNO)
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);
}
}
{
// TODO: trouble about this is that it pulls in the postscript
// code unecessarily
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS )
{
wxWindowsPrinter printer;
wxPrintData data;
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS )
{
wxPrintDialog printerDialog(parentWin, & data);
{
// 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",
+ wxPreviewFrame *frame = new wxPreviewFrame(preview, (wxFrame *)wxTheApp->GetTopWindow(), _("Print Preview"),
wxPoint(100, 100), wxSize(600, 650));
frame->Centre(wxBOTH);
frame->Initialize();
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()];
bool wxDocManager::MakeDefaultName(wxString& name)
{
char buf[256];
- sprintf(buf, "unnamed%d", m_defaultDocumentNameCounter);
+ sprintf(buf, _("unnamed%d"), m_defaultDocumentNameCounter);
m_defaultDocumentNameCounter ++;
name = buf;
return TRUE;
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;
// Omit final "|"
descrBuf[len-1] = 0;
- char *pathTmp = wxFileSelector("Select a file", "", "", "", descrBuf, 0, wxTheApp->GetTopWindow());
+ char *pathTmp = wxFileSelector(_("Select a file"), "", "", "", descrBuf, 0, wxTheApp->GetTopWindow());
delete[] descrBuf;
if (pathTmp)
{
if (!temp)
return NULL;
- char *pathTmp = wxFileSelector("Select a file", "", "",
+ char *pathTmp = wxFileSelector(_("Select a file"), "", "",
temp->GetDefaultExtension(),
temp->GetFileFilter(),
0, wxTheApp->GetTopWindow());
return temp;
}
- wxDocTemplate *theTemplate = (wxDocTemplate *)wxGetSingleChoiceData("Select a document template", "Templates", n,
+ wxDocTemplate *theTemplate = (wxDocTemplate *)wxGetSingleChoiceData(_("Select a document template"), _("Templates"), n,
strings, data);
delete[] strings;
delete[] data;
n ++;
}
}
- wxDocTemplate *theTemplate = (wxDocTemplate *)wxGetSingleChoiceData("Select a document view", "Views", n,
+ wxDocTemplate *theTemplate = (wxDocTemplate *)wxGetSingleChoiceData(_("Select a document view"), _("Views"), n,
strings, data);
delete[] strings;
delete[] data;
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;
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;
}
{
wxCommand *command = (wxCommand *)m_currentCommand->Data();
wxString commandName(command->GetName());
- if (commandName == "") commandName = "Unnamed command";
+ if (commandName == "") commandName = _("Unnamed command");
bool canUndo = command->CanUndo();
if (canUndo)
- buf = wxString("&Undo ") + commandName;
+ buf = wxString(_("&Undo ")) + commandName;
else
- buf = wxString("Can't &Undo ") + commandName;
+ buf = wxString(_("Can't &Undo ")) + commandName;
m_commandEditMenu->SetLabel(wxID_UNDO, buf);
m_commandEditMenu->Enable(wxID_UNDO, canUndo);
{
wxCommand *redoCommand = (wxCommand *)m_currentCommand->Next()->Data();
wxString redoCommandName(redoCommand->GetName());
- if (redoCommandName == "") redoCommandName = "Unnamed command";
- buf = wxString("&Redo ") + redoCommandName;
+ if (redoCommandName == "") redoCommandName = _("Unnamed command");
+ buf = wxString(_("&Redo ")) + redoCommandName;
m_commandEditMenu->SetLabel(wxID_REDO, buf);
m_commandEditMenu->Enable(wxID_REDO, TRUE);
}
else
{
- m_commandEditMenu->SetLabel(wxID_REDO, "&Redo");
+ m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo"));
m_commandEditMenu->Enable(wxID_REDO, FALSE);
}
}
else
{
- m_commandEditMenu->SetLabel(wxID_UNDO, "&Undo");
+ m_commandEditMenu->SetLabel(wxID_UNDO, _("&Undo"));
m_commandEditMenu->Enable(wxID_UNDO, FALSE);
if (m_commands.Number() == 0)
{
- m_commandEditMenu->SetLabel(wxID_REDO, "&Redo");
+ m_commandEditMenu->SetLabel(wxID_REDO, _("&Redo"));
m_commandEditMenu->Enable(wxID_REDO, FALSE);
}
else
// we've undone to the start of the list, but can redo the first.
wxCommand *redoCommand = (wxCommand *)m_commands.First()->Data();
wxString redoCommandName(redoCommand->GetName());
- if (!redoCommandName) redoCommandName = "Unnamed command";
- buf = wxString("&Redo ") + redoCommandName;
+ if (!redoCommandName) redoCommandName = _("Unnamed command");
+ buf = wxString(_("&Redo ")) + redoCommandName;
m_commandEditMenu->SetLabel(wxID_REDO, buf);
m_commandEditMenu->Enable(wxID_REDO, TRUE);
}
{
if (m_fileHistoryN == 0)
m_fileMenu->AppendSeparator();
- m_fileMenu->Append(wxID_FILE1+m_fileHistoryN, "[EMPTY]");
+ m_fileMenu->Append(wxID_FILE1+m_fileHistoryN, _("[EMPTY]"));
m_fileHistoryN ++;
}
// Shuffle filenames down