Пример #1
0
void mmFileHistory::Clear()
{
    int count = GetCount();
    for (int i = 0; i < count; i++)
    {
        RemoveFileFromHistory(0);
    }
}
Пример #2
0
void wxFileHistoryBase::AddFileToHistory(const wxString& file)
{
    // Check if we don't already have this file. Notice that we avoid
    // wxFileName::operator==(wxString) here as it converts the string to
    // wxFileName and then normalizes it using all normalizations which is too
    // slow (see the comment above), so we use our own quick normalization
    // functions and a string comparison.
    const wxFileName fnNew(file);
    const wxString newFile = NormalizeFileName(fnNew);
    size_t i,
           numFiles = m_fileHistory.size();
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( i = 0; i < numFiles; i++ )
    {
        if ( newFile == NormalizeFileName(m_fileHistory[i]) )
        {
            // we do have it, move it to the top of the history
            RemoveFileFromHistory(i);
            numFiles--;
            break;
        }
    }

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

    // add a new menu item to all file menus (they will be updated below)
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( wxList::compatibility_iterator node = m_fileMenus.GetFirst();
        node;
        node = node->GetNext() )
    {
        wxMenu * const menu = (wxMenu *)node->GetData();

        if ( !numFiles && 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(m_idBase + numFiles, " ");
    }

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

    // update the labels in all menus
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( i = 0; i < numFiles; i++ )
    {
        // if in same directory just show the filename; otherwise the full path
        const wxFileName fnOld(m_fileHistory[i]);

        wxString pathInMenu;
        if ( (fnOld.GetPath() == fnNew.GetPath()) && fnOld.HasName() )
        {
            pathInMenu = fnOld.GetFullName();
        }
        else // file in different directory or it's not a file but a directory
        {
            // absolute path; could also set relative path
            pathInMenu = m_fileHistory[i];
        }

#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
        for ( wxList::compatibility_iterator node = m_fileMenus.GetFirst();
              node;
              node = node->GetNext() )
        {
            wxMenu * const menu = (wxMenu *)node->GetData();

            menu->SetLabel(m_idBase + i, GetMRUEntryLabel(i, pathInMenu));
        }
    }
}
// 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();
            }
        }
    }
}
Пример #4
0
void wxFileHistoryBase::AddFileToHistory(const wxString& file)
{
    // check if we don't already have this file
    const wxFileName fnNew(file);
    size_t i,
           numFiles = m_fileHistory.size();
    for ( i = 0; i < numFiles; i++ )
    {
        if ( fnNew == m_fileHistory[i] )
        {
            // we do have it, move it to the top of the history
            RemoveFileFromHistory(i);
            numFiles--;
            break;
        }
    }

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

    // add a new menu item to all file 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 ( !numFiles && 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(m_idBase + numFiles, " ");
    }

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

    // update the labels in all menus
    for ( i = 0; i < numFiles; i++ )
    {
        // if in same directory just show the filename; otherwise the full path
        const wxFileName fnOld(m_fileHistory[i]);

        wxString pathInMenu;
        if ( fnOld.GetPath() == fnNew.GetPath() )
        {
            pathInMenu = fnOld.GetFullName();
        }
        else // file in different directory
        {
            // absolute path; could also set relative path
            pathInMenu = m_fileHistory[i];
        }

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

            menu->SetLabel(m_idBase + i, GetMRUEntryLabel(i, pathInMenu));
        }
    }
}
Пример #5
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
}