Example #1
0
void SubMainFrame::OpenFile(wxString strFilename)
{
    OpenPaintMDIChildFrame *childFrame = new OpenPaintMDIChildFrame(this, wxID_ANY, wxFileNameFromPath(strFilename));
    if(childFrame && childFrame->Open(strFilename))
    {
        AddFileToHistory(strFilename);
        wxLogDebug(wxT("Opened file: %s") , strFilename);
    }
}
Example #2
0
void AddFileViewToHistory( const int CurrIndex, PathList::Data& Data, const int Pos )
{
	// add file view properties
	StrConfig* Cfg = Data.conf.ptr();
	Cfg->Set( VIEW_POS, Pos );
	Cfg->Set( IS_EDIT, 0 );

	// add new item to the end of list
	AddFileToHistory( CurrIndex, Data );
}
Example #3
0
void AddFileEditToHistory( const int CurrIndex, PathList::Data& Data, const int FirstLine, const int Line, const int Pos )
{
	// add file edit properties
	StrConfig* Cfg = Data.conf.ptr();
	Cfg->Set( EDIT_FIRST_LINE, FirstLine );
	Cfg->Set( EDIT_POINT_LINE, Line );
	Cfg->Set( EDIT_POINT_POS, Pos );
	Cfg->Set( IS_EDIT, 1 );

	// add new item to the end of list
	AddFileToHistory( CurrIndex, Data );
}
Example #4
0
bool SubMainFrame::SaveFile()
{
    OpenPaintMDIChildFrame *childFrame = (OpenPaintMDIChildFrame *)this->GetActiveChild();

    wxString strFilename = childFrame->GetFilename();

    if(strFilename.empty())
    {
        SaveAs();
    }
    else if(childFrame && childFrame->Save())
    {
        AddFileToHistory(strFilename);
        wxLogDebug(wxT("Saved as file: %s") , strFilename);
        return true;
    }
    return false;
}
Example #5
0
void mmFileHistory::Load()
{
    int fileCount = 1;
    wxString buf;
    buf.Printf("RECENT_DB_%d", fileCount);

    wxString historyFile;
    while (fileCount <= GetMaxFiles())
    {
        historyFile = Model_Setting::instance().GetStringSetting(buf, wxEmptyString);
        if (!historyFile.empty())
        {
            AddFileToHistory(historyFile);
        }
        buf.Printf("RECENT_DB_%d", GetMaxFiles() - fileCount);
        fileCount++;
    }
}
Example #6
0
void FileHistory::Load(wxConfigBase & config, const wxString & group)
{
   mHistory.Clear();

   config.SetPath(group);

   wxString file;
   long ndx;
   bool got = config.GetFirstEntry(file, ndx);
   while (got) {
      AddFileToHistory(config.Read(file), false);
      got = config.GetNextEntry(file, ndx);
   }

   config.SetPath(wxT(".."));

   AddFilesToMenu();
}
Example #7
0
bool SubMainFrame::SaveAs()
{
    OpenPaintMDIChildFrame *childFrame = (OpenPaintMDIChildFrame *)this->GetActiveChild();

    if(childFrame)
    {
        wxFileName fileName(childFrame->GetFilename());
        wxString strFilename = wxFileSelector(wxT("Choose a file to Save As"),wxT(""),wxT(""), fileName.GetExt(), wxT("Image Files ") + wxImage::GetImageExtWildcard() , wxFD_SAVE);
        wxLogDebug(strFilename);
        
        if(!strFilename.empty() && childFrame->SaveAs(strFilename))
        {
            AddFileToHistory(strFilename);

            wxLogDebug(wxT("Saved as file: %s") , strFilename);

            return true;
        }
    }
    return false;
}
// Recent List management
void MadRecentList::AddFileToHistory(const wxString& file)
#if (wxMAJOR_VERSION < 3)
{
    size_t i;

    // Check we don't already have this item
    for (i = 0; i < m_fileHistoryN; ++i)
    {
        if ( m_fileHistory[i] && ItemEQ(file, m_fileHistory[i]) )
        {
            // we do have it, move it to the top of the history
            RemoveFileFromHistory (i);
            AddFileToHistory (file);
            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:
    // Move existing files (if any) down so we can insert file at beginning.
    if (m_fileHistoryN < m_fileMaxFiles)
    {
        wxList::compatibility_iterator node = m_fileMenus.GetFirst();
        while (node)
        {
            wxMenu* menu = (wxMenu*) node->GetData();
            if ( m_fileHistoryN == 0 && menu->GetMenuItemCount() )
            {
                menu->AppendSeparator();
            }
            menu->Append(GetBaseId()+m_fileHistoryN, _("[EMPTY]"));
            node = node->GetNext();
        }
        ++m_fileHistoryN;
    }
    // Shuffle files down
    for (i = (m_fileHistoryN-1); i > 0; --i)
    {
        m_fileHistory[i] = m_fileHistory[i-1];
    }
    m_fileHistory[0] = MYcopystring(file);

    for (i = 0; i < m_fileHistoryN; ++i)
    {
        if ( m_fileHistory[i] )
        {
            wxString itemInMenu = m_fileHistory[i];

            // we need to quote '&' characters which are used for mnemonics
            itemInMenu.Replace(_T("&"), _T("&&"));
            wxString buf;
            buf.Printf(s_MRUEntryFormat, i + 1, itemInMenu.c_str());
            wxList::compatibility_iterator node = m_fileMenus.GetFirst();
            while (node)
            {
                wxMenu* menu = (wxMenu*) node->GetData();
                menu->SetLabel(GetBaseId() + i, buf);
                node = node->GetNext();
            }
        }
    }
}
Example #9
0
// Recent List management
void wxRecentList::AddFileToHistory(const wxString& item)
{
#if wxMAJOR_VERSION==2
	size_t i;

	// Check we don't already have this item
	for (i = 0; i < m_fileHistoryN; i++)
	{
		if ( m_fileHistory[i] && ItemEqual(item, m_fileHistory[i]) )
		{
			// we do have it, move it to the top of the history
			RemoveFileFromHistory (i);
			AddFileToHistory (item);
			return;
		}
	}

	// if we already have a full history, delete the one at the end
	if ( m_fileMaxFiles == m_fileHistoryN )
	{
		RemoveFileFromHistory (m_fileHistoryN - 1);
		AddFileToHistory (item);
		return;
	}

	// Add to the project item history:
	// Move existing items (if any) down so we can insert item at beginning.
	if (m_fileHistoryN < m_fileMaxFiles)
	{
		wxList::compatibility_iterator node = m_fileMenus.GetFirst();
		while (node)
		{
			wxMenu* menu = (wxMenu*) node->GetData();
			if ( m_fileHistoryN == 0 && menu->GetMenuItemCount() )
			{
				menu->AppendSeparator();
			}
			menu->Append(GetBaseId()+m_fileHistoryN, _("[EMPTY]"));
			node = node->GetNext();
		}
		m_fileHistoryN ++;
	}
	// Shuffle items down
	for (i = (m_fileHistoryN-1); i > 0; i--)
	{
		m_fileHistory[i] = m_fileHistory[i-1];
	}
	m_fileHistory[0] = MYcopystring(item);

	for (i = 0; i < m_fileHistoryN; i++)
	{
		if ( m_fileHistory[i] )
		{
			wxString itemInMenu = m_fileHistory[i];

			// we need to quote '&' characters which are used for mnemonics
			itemInMenu.Replace(_T("&"), _T("&&"));
			wxString buf;
			buf.Printf(s_MRUEntryFormat, i + 1, itemInMenu.c_str());
			wxList::compatibility_iterator node = m_fileMenus.GetFirst();
			while (node)
			{
				wxMenu* menu = (wxMenu*) node->GetData();
				menu->SetLabel(GetBaseId() + i, buf);
				node = node->GetNext();
			}
		}
	}
#else
	// Check if we don't already have this item.
	size_t i, numItems = m_fileHistory.size();
	for (i = 0; i < numItems; i++)
	{
		if (ItemEqual(item, m_fileHistory[i]))
		{
			// we do have it, move it to the top of the history
			RemoveFileFromHistory(i);
			numItems--;
			break;
		}
	}

	// if we already have a full history, delete the one at the end
	if (numItems == m_fileMaxFiles)
	{
		RemoveFileFromHistory(--numItems);
	}

	// add a new menu item to all item menus (they will be updated below)
	for (wxList::compatibility_iterator node = m_fileMenus.GetFirst();
		node;
		node = node->GetNext())
	{
		wxMenu * const menu = (wxMenu *)node->GetData();

		if (!numItems && menu->GetMenuItemCount())
			menu->AppendSeparator();

		// label doesn't matter, it will be set below anyhow, but it can't
		// be empty (this is supposed to indicate a stock item)
		menu->Append(GetBaseId() + numItems, " ");
	}

	// insert the new item in the beginning of the item history
	m_fileHistory.insert(m_fileHistory.begin(), item);
	numItems++;

	// update the labels in all menus
	for (i = 0; i < numItems; i++)
	{

		wxString itemInMenu = m_fileHistory[i];

		for (wxList::compatibility_iterator node = m_fileMenus.GetFirst();
			node;
			node = node->GetNext())
		{
			wxMenu * const menu = (wxMenu *)node->GetData();

			menu->SetLabel(GetBaseId() + i, GetMRUEntryLabel(i, itemInMenu));
		}
	}
#endif
}