-wxString wxFileHistory::GetHistoryFile(int i) const
-{
- wxString s;
- if ( i < m_fileHistoryN )
- {
- s = m_fileHistory[i];
- }
- else
- {
- wxFAIL_MSG( wxT("bad index in wxFileHistory::GetHistoryFile") );
- }
-
- return s;
-}
-
-void wxFileHistory::UseMenu(wxMenu *menu)
-{
- if (!m_fileMenus.Member(menu))
- m_fileMenus.Append(menu);
-}
-
-void wxFileHistory::RemoveMenu(wxMenu *menu)
-{
- m_fileMenus.DeleteObject(menu);
-}
-
-#if wxUSE_CONFIG
-void wxFileHistory::Load(wxConfigBase& config)
-{
- m_fileHistoryN = 0;
- wxString buf;
- buf.Printf(wxT("file%d"), m_fileHistoryN+1);
- wxString historyFile;
- while ((m_fileHistoryN <= m_fileMaxFiles) && config.Read(buf, &historyFile) && (historyFile != wxT("")))
- {
- m_fileHistory[m_fileHistoryN] = copystring((const wxChar*) historyFile);
- m_fileHistoryN ++;
- buf.Printf(wxT("file%d"), m_fileHistoryN+1);
- historyFile = "";
- }
- AddFilesToMenu();
-}
-
-void wxFileHistory::Save(wxConfigBase& config)
-{
- int i;
- for (i = 0; i < m_fileHistoryN; i++)
- {
- wxString buf;
- buf.Printf(wxT("file%d"), i+1);
- config.Write(buf, wxString(m_fileHistory[i]));
- }
-}
-#endif // wxUSE_CONFIG
-
-void wxFileHistory::AddFilesToMenu()
-{
- if (m_fileHistoryN > 0)
- {
- wxNode* node = m_fileMenus.First();
- while (node)
- {
- wxMenu* menu = (wxMenu*) node->Data();
- menu->AppendSeparator();
- int i;
- for (i = 0; i < m_fileHistoryN; i++)
- {
- if (m_fileHistory[i])
- {
- wxString buf;
- buf.Printf(s_MRUEntryFormat, i+1, m_fileHistory[i]);
- menu->Append(wxID_FILE1+i, buf);
- }
- }
- node = node->Next();
- }
- }
-}
-
-void wxFileHistory::AddFilesToMenu(wxMenu* menu)
-{
- if (m_fileHistoryN > 0)
- {
- menu->AppendSeparator();
- int i;
- for (i = 0; i < m_fileHistoryN; i++)
- {
- if (m_fileHistory[i])
- {
- wxString buf;
- buf.Printf(s_MRUEntryFormat, i+1, m_fileHistory[i]);
- menu->Append(wxID_FILE1+i, buf);
- }
- }
- }
-}
-
-// ----------------------------------------------------------------------------
-// Permits compatibility with existing file formats and functions that
-// manipulate files directly
-// ----------------------------------------------------------------------------
-
-#if wxUSE_STD_IOSTREAM
-bool wxTransferFileToStream(const wxString& filename, ostream& stream)
-{
- FILE *fd1;
- int ch;
-
- if ((fd1 = fopen (filename.fn_str(), "rb")) == NULL)
- return FALSE;
-
- while ((ch = getc (fd1)) != EOF)
- stream << (unsigned char)ch;
-
- fclose (fd1);
- return TRUE;
-}
-
-bool wxTransferStreamToFile(istream& stream, const wxString& filename)
-{
- FILE *fd1;
- int ch;
-
- if ((fd1 = fopen (filename.fn_str(), "wb")) == NULL)
- {
- return FALSE;
- }
-
- while (!stream.eof())
- {
- ch = stream.get();
- if (!stream.eof())
- putc (ch, fd1);
- }
- fclose (fd1);
- return TRUE;
-}
-#endif