// wxWindows macros
// ----------------------------------------------------------------------------
-#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxDocument, wxEvtHandler)
IMPLEMENT_ABSTRACT_CLASS(wxView, wxEvtHandler)
IMPLEMENT_ABSTRACT_CLASS(wxDocTemplate, wxObject)
IMPLEMENT_CLASS(wxCommand, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxCommandProcessor, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxFileHistory, wxObject)
-#endif
// ----------------------------------------------------------------------------
// function prototypes
// local constants
// ----------------------------------------------------------------------------
-static const char *s_MRUEntryFormat = wxT("&%d %s");
+static const wxChar *s_MRUEntryFormat = wxT("&%d %s");
// ============================================================================
// implementation
if (store.fail() || store.bad())
#else
wxFileOutputStream store(wxString(file.fn_str()));
- if (store.LastError() != 0)
+ if (store.LastError() != wxSTREAM_NOERROR)
#endif
{
(void)wxMessageBox(_("Sorry, could not open this file for saving."), msgTitle, wxOK | wxICON_EXCLAMATION,
if (store.fail() || store.bad())
#else
wxFileInputStream store(wxString(file.fn_str()));
- if (store.LastError() != 0)
+ if (store.LastError() != wxSTREAM_NOERROR)
#endif
{
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
GetDocumentWindow());
return FALSE;
}
+#if wxUSE_STD_IOSTREAM
if (!LoadObject(store))
+#else
+ int res = LoadObject(store).LastError();
+ if ((res != wxSTREAM_NOERROR) &&
+ (res != wxSTREAM_EOF))
+#endif
{
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
GetDocumentWindow());
// SetDocument(doc);
m_viewDocument = (wxDocument*) NULL;
- m_viewTypeName = "";
+ m_viewTypeName = wxT("");
m_viewFrame = (wxFrame *) NULL;
}
wxView::~wxView()
{
- GetDocumentManager()->ActivateView(this, FALSE, TRUE);
+// GetDocumentManager()->ActivateView(this, FALSE, TRUE);
m_viewDocument->RemoveView(this);
}
// template extension.
wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
-#ifdef __WXMSW__
+#if defined(__WXMSW__) || defined(__WXGTK__)
int noTemplates,
#else
int WXUNUSED(noTemplates),
long WXUNUSED(flags),
bool WXUNUSED(save))
{
- // We can only have multiple filters in Windows
-#ifdef __WXMSW__
+ // We can only have multiple filters in Windows and GTK
+#if defined(__WXMSW__) || defined(__WXGTK__)
wxString descrBuf;
int i;
int FilterIndex = 0;
wxString pathTmp = wxFileSelectorEx(_("Select a file"),
- wxT(""),
+ m_lastDirectory,
wxT(""),
&FilterIndex,
descrBuf,
if (!pathTmp.IsEmpty())
{
+ m_lastDirectory = wxPathOnly(pathTmp);
+
path = pathTmp;
wxString theExt = FindExtension(path);
if (!theExt)
}
wxDocTemplate *theTemplate = (wxDocTemplate *)wxGetSingleChoiceData(_("Select a document template"), _("Templates"), n,
- strings, (char **)data);
+ strings, (void **)data);
delete[] strings;
delete[] data;
return theTemplate;
}
}
wxDocTemplate *theTemplate = (wxDocTemplate *)wxGetSingleChoiceData(_("Select a document view"), _("Views"), n,
- strings, (char **)data);
+ strings, (void **)data);
delete[] strings;
delete[] data;
return theTemplate;
{
wxMenu* menu = (wxMenu*) node->Data();
- // wxMenu::Delete() is missing from wxGTK, so this can't be done :-(
-#if 0
- // delete the menu items
- menu->Delete(wxID_FILE1 + i);
-#endif
-
// delete the element from the array (could use memmove() too...)
delete [] m_fileHistory[i];
menu->SetLabel(wxID_FILE1 + j, buf);
}
- // to be removed as soon as wxMenu::Delete() is implemented
-#if 1
- menu->SetLabel(wxID_FILE1 + m_fileHistoryN - 1, wxT(""));
-#endif
-
node = node->Next();
+
+ // delete the last menu item which is unused now
+ menu->Delete(wxID_FILE1 + m_fileHistoryN - 1);
+
+ // delete the last separator too if no more files are left
+ if ( m_fileHistoryN == 1 )
+ {
+ wxMenuItemList::Node *node = menu->GetMenuItems().GetLast();
+ if ( node )
+ {
+ wxMenuItem *menuItem = node->GetData();
+ if ( menuItem->IsSeparator() )
+ {
+ menu->Delete(menuItem);
+ }
+ //else: should we search backwards for the last separator?
+ }
+ //else: menu is empty somehow
+ }
}
+
m_fileHistoryN--;
}
wxString wxFileHistory::GetHistoryFile(int i) const
{
- if (i < m_fileHistoryN)
- return wxString(m_fileHistory[i]);
+ wxString s;
+ if ( i < m_fileHistoryN )
+ {
+ s = m_fileHistory[i];
+ }
else
- return wxString("");
+ {
+ wxFAIL_MSG( wxT("bad index in wxFileHistory::GetHistoryFile") );
+ }
+
+ return s;
}
void wxFileHistory::UseMenu(wxMenu *menu)
m_fileHistory[m_fileHistoryN] = copystring((const wxChar*) historyFile);
m_fileHistoryN ++;
buf.Printf(wxT("file%d"), m_fileHistoryN+1);
- historyFile = "";
+ historyFile = wxT("");
}
AddFilesToMenu();
}