applied file history patch
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9121 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1386,7 +1386,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
|
|||||||
msgTitle = wxTheApp->GetAppName();
|
msgTitle = wxTheApp->GetAppName();
|
||||||
else
|
else
|
||||||
msgTitle = wxString(_("File error"));
|
msgTitle = wxString(_("File error"));
|
||||||
|
|
||||||
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK | wxICON_EXCLAMATION,
|
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK | wxICON_EXCLAMATION,
|
||||||
parent);
|
parent);
|
||||||
|
|
||||||
@@ -2040,22 +2040,29 @@ wxFileHistory::~wxFileHistory()
|
|||||||
void wxFileHistory::AddFileToHistory(const wxString& file)
|
void wxFileHistory::AddFileToHistory(const wxString& file)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Check we don't already have this file
|
// Check we don't already have this file
|
||||||
for (i = 0; i < m_fileHistoryN; i++)
|
for (i = 0; i < m_fileHistoryN; i++)
|
||||||
{
|
{
|
||||||
if (m_fileHistory[i] && wxString(m_fileHistory[i]) == file)
|
if ( m_fileHistory[i] && (file == m_fileHistory[i]) )
|
||||||
|
{
|
||||||
|
// we do have it, move it to the top of the history
|
||||||
|
RemoveFileFromHistory (i);
|
||||||
|
AddFileToHistory (file);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we already have a full history, delete the one at the end
|
||||||
|
if ( m_fileMaxFiles == m_fileHistoryN )
|
||||||
|
{
|
||||||
|
RemoveFileFromHistory (m_fileHistoryN - 1);
|
||||||
|
AddFileToHistory (file);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to the project file history:
|
// Add to the project file history:
|
||||||
// Move existing files (if any) down so we can insert file at beginning.
|
// Move existing files (if any) down so we can insert file at beginning.
|
||||||
|
|
||||||
// First delete filename that has popped off the end of the array (if any)
|
|
||||||
if (m_fileHistoryN == m_fileMaxFiles)
|
|
||||||
{
|
|
||||||
delete[] m_fileHistory[m_fileMaxFiles-1];
|
|
||||||
m_fileHistory[m_fileMaxFiles-1] = (wxChar *) NULL;
|
|
||||||
}
|
|
||||||
if (m_fileHistoryN < m_fileMaxFiles)
|
if (m_fileHistoryN < m_fileMaxFiles)
|
||||||
{
|
{
|
||||||
wxNode* node = m_fileMenus.First();
|
wxNode* node = m_fileMenus.First();
|
||||||
@@ -2076,19 +2083,40 @@ void wxFileHistory::AddFileToHistory(const wxString& file)
|
|||||||
}
|
}
|
||||||
m_fileHistory[0] = copystring(file);
|
m_fileHistory[0] = copystring(file);
|
||||||
|
|
||||||
|
// this is the directory of the last opened file
|
||||||
|
wxString pathCurrent;
|
||||||
|
wxSplitPath( m_fileHistory[0], &pathCurrent, NULL, NULL );
|
||||||
for (i = 0; i < m_fileHistoryN; i++)
|
for (i = 0; i < m_fileHistoryN; i++)
|
||||||
if (m_fileHistory[i])
|
{
|
||||||
|
if ( m_fileHistory[i] )
|
||||||
{
|
{
|
||||||
|
// if in same directory just show the filename; otherwise the full
|
||||||
|
// path
|
||||||
|
wxString pathInMenu, path, filename, ext;
|
||||||
|
wxSplitPath( m_fileHistory[i], &path, &filename, &ext );
|
||||||
|
if ( path == pathCurrent )
|
||||||
|
{
|
||||||
|
pathInMenu = filename;
|
||||||
|
if ( !ext.empty() )
|
||||||
|
pathInMenu = pathInMenu + wxFILE_SEP_EXT + ext;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// absolute path; could also set relative path
|
||||||
|
pathInMenu = m_fileHistory[i];
|
||||||
|
}
|
||||||
|
|
||||||
wxString buf;
|
wxString buf;
|
||||||
buf.Printf(s_MRUEntryFormat, i+1, m_fileHistory[i]);
|
buf.Printf(s_MRUEntryFormat, i + 1, pathInMenu.c_str());
|
||||||
wxNode* node = m_fileMenus.First();
|
wxNode* node = m_fileMenus.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenu* menu = (wxMenu*) node->Data();
|
wxMenu* menu = (wxMenu*) node->Data();
|
||||||
menu->SetLabel(wxID_FILE1+i, buf);
|
menu->SetLabel(wxID_FILE1 + i, buf);
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileHistory::RemoveFileFromHistory(int i)
|
void wxFileHistory::RemoveFileFromHistory(int i)
|
||||||
|
@@ -23,7 +23,6 @@ ALL_SOURCES = \
|
|||||||
generic/msgdlgg.cpp \
|
generic/msgdlgg.cpp \
|
||||||
generic/numdlgg.cpp \
|
generic/numdlgg.cpp \
|
||||||
generic/panelg.cpp \
|
generic/panelg.cpp \
|
||||||
generic/plot.cpp \
|
|
||||||
generic/printps.cpp \
|
generic/printps.cpp \
|
||||||
generic/prntdlgg.cpp \
|
generic/prntdlgg.cpp \
|
||||||
generic/progdlgg.cpp \
|
generic/progdlgg.cpp \
|
||||||
@@ -369,7 +368,6 @@ ALL_HEADERS = \
|
|||||||
panel.h \
|
panel.h \
|
||||||
paper.h \
|
paper.h \
|
||||||
pen.h \
|
pen.h \
|
||||||
plot.h \
|
|
||||||
print.h \
|
print.h \
|
||||||
printdlg.h \
|
printdlg.h \
|
||||||
prntbase.h \
|
prntbase.h \
|
||||||
@@ -529,7 +527,6 @@ ALL_HEADERS = \
|
|||||||
generic/msgdlgg.h \
|
generic/msgdlgg.h \
|
||||||
generic/notebook.h \
|
generic/notebook.h \
|
||||||
generic/panelg.h \
|
generic/panelg.h \
|
||||||
generic/plot.h \
|
|
||||||
generic/printps.h \
|
generic/printps.h \
|
||||||
generic/prntdlgg.h \
|
generic/prntdlgg.h \
|
||||||
generic/progdlgg.h \
|
generic/progdlgg.h \
|
||||||
@@ -800,7 +797,6 @@ GENERICOBJS = \
|
|||||||
msgdlgg.o \
|
msgdlgg.o \
|
||||||
numdlgg.o \
|
numdlgg.o \
|
||||||
panelg.o \
|
panelg.o \
|
||||||
plot.o \
|
|
||||||
printps.o \
|
printps.o \
|
||||||
prntdlgg.o \
|
prntdlgg.o \
|
||||||
progdlgg.o \
|
progdlgg.o \
|
||||||
@@ -844,7 +840,6 @@ GENERICDEPS = \
|
|||||||
msgdlgg.d \
|
msgdlgg.d \
|
||||||
numdlgg.d \
|
numdlgg.d \
|
||||||
panelg.d \
|
panelg.d \
|
||||||
plot.d \
|
|
||||||
printps.d \
|
printps.d \
|
||||||
prntdlgg.d \
|
prntdlgg.d \
|
||||||
progdlgg.d \
|
progdlgg.d \
|
||||||
|
@@ -23,7 +23,6 @@ ALL_SOURCES = \
|
|||||||
generic/msgdlgg.cpp \
|
generic/msgdlgg.cpp \
|
||||||
generic/numdlgg.cpp \
|
generic/numdlgg.cpp \
|
||||||
generic/panelg.cpp \
|
generic/panelg.cpp \
|
||||||
generic/plot.cpp \
|
|
||||||
generic/printps.cpp \
|
generic/printps.cpp \
|
||||||
generic/prntdlgg.cpp \
|
generic/prntdlgg.cpp \
|
||||||
generic/progdlgg.cpp \
|
generic/progdlgg.cpp \
|
||||||
@@ -369,7 +368,6 @@ ALL_HEADERS = \
|
|||||||
panel.h \
|
panel.h \
|
||||||
paper.h \
|
paper.h \
|
||||||
pen.h \
|
pen.h \
|
||||||
plot.h \
|
|
||||||
print.h \
|
print.h \
|
||||||
printdlg.h \
|
printdlg.h \
|
||||||
prntbase.h \
|
prntbase.h \
|
||||||
@@ -529,7 +527,6 @@ ALL_HEADERS = \
|
|||||||
generic/msgdlgg.h \
|
generic/msgdlgg.h \
|
||||||
generic/notebook.h \
|
generic/notebook.h \
|
||||||
generic/panelg.h \
|
generic/panelg.h \
|
||||||
generic/plot.h \
|
|
||||||
generic/printps.h \
|
generic/printps.h \
|
||||||
generic/prntdlgg.h \
|
generic/prntdlgg.h \
|
||||||
generic/progdlgg.h \
|
generic/progdlgg.h \
|
||||||
@@ -800,7 +797,6 @@ GENERICOBJS = \
|
|||||||
msgdlgg.o \
|
msgdlgg.o \
|
||||||
numdlgg.o \
|
numdlgg.o \
|
||||||
panelg.o \
|
panelg.o \
|
||||||
plot.o \
|
|
||||||
printps.o \
|
printps.o \
|
||||||
prntdlgg.o \
|
prntdlgg.o \
|
||||||
progdlgg.o \
|
progdlgg.o \
|
||||||
@@ -844,7 +840,6 @@ GENERICDEPS = \
|
|||||||
msgdlgg.d \
|
msgdlgg.d \
|
||||||
numdlgg.d \
|
numdlgg.d \
|
||||||
panelg.d \
|
panelg.d \
|
||||||
plot.d \
|
|
||||||
printps.d \
|
printps.d \
|
||||||
prntdlgg.d \
|
prntdlgg.d \
|
||||||
progdlgg.d \
|
progdlgg.d \
|
||||||
|
Reference in New Issue
Block a user