- if (!m_fileMenu)
- return;
-
- int i;
-
- // Check we don't already have this file
- for (i = 0; i < m_fileHistoryN; i++)
- {
- if (m_fileHistory[i] && wxString(m_fileHistory[i]) == file)
- return;
- }
-
- // Add to the project file history:
- // 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] = NULL;
- }
- if (m_fileHistoryN < m_fileMaxFiles)
- {
- if (m_fileHistoryN == 0)
- m_fileMenu->AppendSeparator();
- m_fileMenu->Append(wxID_FILE1+m_fileHistoryN, _("[EMPTY]"));
- m_fileHistoryN ++;
- }
- // Shuffle filenames down
- for (i = (m_fileHistoryN-1); i > 0; i--)
- {
- m_fileHistory[i] = m_fileHistory[i-1];
- }
- m_fileHistory[0] = copystring(file);
-
- for (i = 0; i < m_fileHistoryN; i++)
- if (m_fileHistory[i])
- {
- char buf[400];
- sprintf(buf, "&%d %s", i+1, m_fileHistory[i]);
- m_fileMenu->SetLabel(wxID_FILE1+i, buf);
- }
-}
-
-wxString wxFileHistory::GetHistoryFile(int i) const
-{
- if (i < m_fileHistoryN)
- return wxString(m_fileHistory[i]);
- else
- return wxString("");
-}
-
-void wxFileHistory::FileHistoryUseMenu(wxMenu *menu)
-{
- m_fileMenu = menu;
-}
-
-void wxFileHistory::FileHistoryLoad(const wxString& resourceFile, const wxString& section)
-{
-#if USE_RESOURCES
- m_fileHistoryN = 0;
- char buf[400];
- sprintf(buf, "file%d", m_fileHistoryN+1);
- char *historyFile = NULL;
- while ((m_fileHistoryN <= m_fileMaxFiles) && wxGetResource(section, buf, &historyFile, resourceFile) && historyFile)
- {
- // wxGetResource allocates memory so this is o.k.
- m_fileHistory[m_fileHistoryN] = historyFile;
- m_fileHistoryN ++;
- sprintf(buf, "file%d", m_fileHistoryN+1);
- historyFile = NULL;
- }
-#endif
-}