Beispiel #1
0
const GameListItem * CGameListCtrl::GetSelectedISO()
{
	if (m_ISOFiles.size() == 0)
	{
		return nullptr;
	}
	else if (GetSelectedItemCount() == 0)
	{
		return nullptr;
	}
	else
	{
		long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
		if (item == wxNOT_FOUND)
		{
			return nullptr;
		}
		else
		{
			// Here is a little workaround for multiselections:
			// when > 1 item is selected, return info on the first one
			// and deselect it so the next time GetSelectedISO() is called,
			// the next item's info is returned
			if (GetSelectedItemCount() > 1)
				SetItemState(item, 0, wxLIST_STATE_SELECTED);

			return m_ISOFiles[GetItemData(item)];
		}
	}
}
Beispiel #2
0
void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event))
{
	if (GetSelectedItemCount() == 1)
	{
		const GameListItem *iso = GetSelectedISO();
		if (!iso)
			return;
		if (wxMessageBox(_("Are you sure you want to delete this file?  It will be gone forever!"),
					wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION) == wxYES)
		{
			File::Delete(iso->GetFileName());
			Update();
		}
	}
	else
	{
		if (wxMessageBox(_("Are you sure you want to delete these files?\nThey will be gone forever!"),
					wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION) == wxYES)
		{
			int selected = GetSelectedItemCount();

			for (int i = 0; i < selected; i++)
			{
				const GameListItem *iso = GetSelectedISO();
				File::Delete(iso->GetFileName());
			}
			Update();
		}
	}
}
Beispiel #3
0
void CQueueViewFailed::OnRemoveAll(wxCommandEvent& event)
{
#ifndef __WXMSW__
	// GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
	if (GetSelectedItemCount())
#endif
	{
		// First, clear all selections
		int item;
		while ((item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) != -1)
			SetItemState(item, 0, wxLIST_STATE_SELECTED);
	}

	CEditHandler* pEditHandler = CEditHandler::Get();
	if (pEditHandler)
		pEditHandler->RemoveAll(CEditHandler::upload_and_remove_failed);

	for (std::vector<CServerItem*>::iterator iter = m_serverList.begin(); iter != m_serverList.end(); iter++)
		delete *iter;
	m_serverList.clear();

	m_itemCount = 0;
	SaveSetItemCount(0);
	m_fileCount = 0;
	m_folderScanCount = 0;

	DisplayNumberQueuedFiles();

	RefreshListOnly();

	if (!m_itemCount && m_pQueue->GetQueueView()->GetItemCount())
		m_pQueue->SetSelection(0);
}
Beispiel #4
0
void CQueueViewBase::UpdateSelections_ItemRangeAdded(int added, int count)
{
#ifndef __WXMSW__
	// GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
	const int selection_count = GetSelectedItemCount();
	if (!selection_count)
		return;
#endif

	std::list<int> itemsToSelect;

	// Go through all selected items
	int item = GetNextItem(added - 1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);

	while (item != -1)
	{
		// Select new items preceding to current one
		while (!itemsToSelect.empty() && itemsToSelect.front() < item)
		{
			SetItemState(itemsToSelect.front(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
			itemsToSelect.pop_front();
		}
		if (itemsToSelect.empty())
			SetItemState(item, 0, wxLIST_STATE_SELECTED);
		else if (itemsToSelect.front() == item)
			itemsToSelect.pop_front();

		itemsToSelect.push_back(item + count);

		item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	}
	for (std::list<int>::const_iterator iter = itemsToSelect.begin(); iter != itemsToSelect.end(); iter++)
		SetItemState(*iter, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
Beispiel #5
0
void CContactListCtrl::OnRightClick(wxListEvent& e)
{
  wxMenu menu;
  if (GetSelectedItemCount() == 1) {
    // Single selection
    CContact& rContact = m_liEntries[e.GetIndex()];
    const TPhoneList& rPhones = rContact.getConstPhones();
    if (rPhones.size()) {
      wxMenu *submenu = new wxMenu();
      TPhoneList::const_iterator it = rPhones.begin();
      for (int i = 0; it != rPhones.end() && (i < MAX_PHONES); ++it, ++i) {
        submenu->Append(ID_CTX_MAKE_CALL + i,
            wxString::Format(wxT("%s (%s)"), it->getNumber(),
                CPhone::getNumberTypeName(it->getType())));
      }
      if (rPhones.size() > MAX_PHONES) {
        submenu->Append(ID_CTX_SELECT_CALL, _("More..."));
      }
      menu.Append(ID_CTX_SELECT_CALL, _("Call..."));
      menu.AppendSubMenu(submenu, _("Quick Call"));
      menu.AppendSeparator();
    }
    menu.Append(CMD_ADD_ADDRESS, _("Add..."));
    menu.Append(CMD_EDIT_ADDRESS, _("Edit..."));
    menu.AppendSeparator();
    menu.Append(CMD_DEL_ADDRESS, _("Delete"));
  }
  else {
    // Multiple selection
    menu.Append(CMD_ADD_ADDRESS, _("Add..."));
    menu.AppendSeparator();
    menu.Append(CMD_DEL_ADDRESS, _("Delete"));
  }
  PopupMenu(&menu);
}
Beispiel #6
0
void wxExListView::BuildPopupMenu(wxExMenu& menu)
{
  menu.AppendSeparator();
  menu.AppendEdit(true);
  
  const long style = GetWindowStyle();

  if (
    GetItemCount() > 0 && 
    GetSelectedItemCount() == 0 &&
    style & wxLC_REPORT)
  {
    menu.AppendSeparator();

    wxMenu* menuSort = new wxMenu;

    for (
#ifdef wxExUSE_CPP0X	
      auto it = m_Columns.begin();
#else
      std::vector<wxExColumn>::iterator it = m_Columns.begin();
#endif	  
      it != m_Columns.end();
      ++it)
    {
      menuSort->Append(ID_COL_FIRST + it->GetColumn(), it->GetText());
    }

    menu.AppendSubMenu(menuSort, _("Sort On"));
  }
Beispiel #7
0
BOOL ColourGallery::DoDeleteSelection(void)
{
	DWORD TotalItems = GetSelectedItemCount();

	IndexedColour **KillList = new IndexedColourPtr[TotalItems+1];
	if (KillList == NULL)
		return(FALSE);
	
	DWORD KillIndex = 0;
	SequenceItem *Ptr = FindFirstSelected();
	while (Ptr != NULL)
	{
		KillList[KillIndex++] = (IndexedColour *) FindRealItem(Ptr);

		Ptr = FindNextSelected(Ptr);
	}
	
	KillList[KillIndex] = NULL;		// NULL terminate the list

	// Delete (hide, with undo actually) the given colours
	ColourManager::HideColours(ColourManager::GetColourList(), KillList, TRUE);

	// HideColours has made a copy of this list for itself, so we are responsible
	// for deleting our original list
	delete [] KillList;

	return(TRUE);
}
Beispiel #8
0
void CMuleListCtrl::ClearSelection() 
{
	if (GetSelectedItemCount()) {
		long index = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
		while (index != -1) {
			SetItemState(index, 0, wxLIST_STATE_SELECTED);
			index = GetNextItem(index, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
		}
	}
}
Beispiel #9
0
void CGameListCtrl::OnDeleteISO(wxCommandEvent& WXUNUSED (event))
{
	const wxString message = GetSelectedItemCount() == 1 ?
			_("Are you sure you want to delete this file? It will be gone forever!") :
			_("Are you sure you want to delete these files? They will be gone forever!");

	if (wxMessageBox(message, _("Warning"), wxYES_NO | wxICON_EXCLAMATION) == wxYES)
	{
		for (const GameListItem* iso : GetAllSelectedISOs())
			File::Delete(iso->GetFileName());
		Update();
	}
}
Beispiel #10
0
std::vector<int> OrderListCtrl::GetSelectedItems()
{
	int current = -1;
	std::vector<int> items;
	
	while (static_cast<int>(items.size()) < GetSelectedItemCount())
	{
		current = GetNextItem(current, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
		items.push_back(current);
	}

	return items;
}
void wxGxContentView::OnDeselected(wxListEvent& event)
{
	//event.Skip();
    if(GetSelectedItemCount() == 0)
    {
        m_pSelection->Select(m_nParentGxObjectID, false, NOTFIRESELID);
    }
    else
    {
    	LPITEMDATA pItemData = (LPITEMDATA)event.GetData();
	    if(pItemData != NULL)
        {
            m_pSelection->Unselect(pItemData->nObjectID, NOTFIRESELID);
        }
    }

	if(GetSelectedItemCount() == 0)
    {
		m_pSelection->SetInitiator(TREECTRLID);
        if (m_pGxApp)
            m_pGxApp->UpdateNewMenu(m_pSelection);
	}

    wxGISStatusBar* pStatusBar = m_pApp->GetStatusBar();
    if(pStatusBar)
    {
        if(GetSelectedItemCount() > 1)
        {
            pStatusBar->SetMessage(wxString::Format(_("%d objects selected"), GetSelectedItemCount()));
        }
        else
        {
            pStatusBar->SetMessage(wxEmptyString);
        }
    }

}
Beispiel #12
0
void CUnitPane::OnRClick(wxListEvent& event)
{
    wxMenu       menu;
    long         idx   = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    CUnit      * pUnit = GetUnit(idx);
    int          x=0,y;

    int          width, height;

    int nItems = GetSelectedItemCount();


    wxDisplaySize(&width, &height);
    y = event.GetPoint().y;
    ClientToScreen(&x, &y);
    if (height-y < 150)
        y = height-150;
    ScreenToClient(&x, &y);

    if (nItems>1)
    {
        // multiple units
        menu.Append(menu_Popup_IssueOrders     , wxT("Issue orders"));
        menu.Append(menu_Popup_UnitFlags       , wxT("Set custom flags")    );
        menu.Append(menu_Popup_AddToTracking   , wxT("Add to a tracking group"));

        PopupMenu( &menu, event.GetPoint().x, y);
    }
    else
        if (pUnit)
        {
            // single unit
            if (pUnit->IsOurs)
            {
                menu.Append(menu_Popup_ShareSilv     , wxT("Share SILV")        );
                menu.Append(menu_Popup_Teach         , wxT("Teach")             );
                menu.Append(menu_Popup_Split         , wxT("Split")             );
                menu.Append(menu_Popup_DiscardJunk   , wxT("Discard junk items"));
                menu.Append(menu_Popup_GiveEverything, wxT("Give everything")   );
                menu.Append(menu_Popup_DetectSpies   , wxT("Detect spies")      );
            }

            menu.Append(menu_Popup_UnitFlags       , wxT("Set custom flags")    );
            menu.Append(menu_Popup_AddToTracking   , wxT("Add to a tracking group"));


            PopupMenu( &menu, event.GetPoint().x, y);
        }
}
Beispiel #13
0
void CGameListCtrl::OnLeftClick(wxMouseEvent& event)
{
	// Focus the clicked item.
	int flags;
	long item = HitTest(event.GetPosition(), flags);
	if ((item != wxNOT_FOUND) && (GetSelectedItemCount() == 0) &&
			(!event.ControlDown()) && (!event.ShiftDown()))
	{
		SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
		SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
		wxGetApp().GetCFrame()->UpdateGUI();
	}

	event.Skip();
}
void wxGISToolExecuteView::OnDeselected(wxListEvent& event)
{
    if(GetSelectedItemCount() == 0)
        m_pSelection->Select(m_nParentGxObjectId, false, NOTFIRESELID);

    wxGxObject* pObject = m_pCatalog->GetRegisterObject(event.GetData());
    if(!pObject)
        return;

    m_pSelection->Unselect(pObject->GetId(), NOTFIRESELID);

    wxGISStatusBar* pStatusBar = m_pApp->GetStatusBar();
    if(pStatusBar)
    {
        if(GetSelectedItemCount() > 1)
        {
            pStatusBar->SetMessage(wxString::Format(_("%d objects selected"), GetSelectedItemCount()));
        }
        else
        {
            pStatusBar->SetMessage(wxEmptyString);
        }
    }
}
Beispiel #15
0
void CUnitPane::OnPopupMenuUnitFlags (wxCommandEvent& WXUNUSED(event))
{
    long         idx;
    CUnit      * pUnit;
    unsigned int flags = 0;
    BOOL         ManyUnits = (GetSelectedItemCount() > 1);

    if (!ManyUnits)
    {
        idx   = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        pUnit = GetUnit(idx);
        if (pUnit)
            flags = pUnit->Flags;
    }

    CUnitFlagsDlg dlg(this, ManyUnits?eManyUnits:eThisUnit, flags & UNIT_CUSTOM_FLAG_MASK);
    int rc = dlg.ShowModal();
    idx   = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    while (idx>=0)
    {
        pUnit = GetUnit(idx);

        switch (rc)
        {
        case wxID_OK:
            pUnit->Flags    &= ~UNIT_CUSTOM_FLAG_MASK;
            pUnit->FlagsOrg &= ~UNIT_CUSTOM_FLAG_MASK;
            pUnit->Flags    |= (dlg.m_UnitFlags & UNIT_CUSTOM_FLAG_MASK);
            pUnit->FlagsOrg |= (dlg.m_UnitFlags & UNIT_CUSTOM_FLAG_MASK);
            pUnit->FlagsLast = ~pUnit->Flags;
            break;
        case ID_BTN_SET_ALL_UNIT:
            pUnit->Flags    |= (dlg.m_UnitFlags & UNIT_CUSTOM_FLAG_MASK);
            pUnit->FlagsOrg |= (dlg.m_UnitFlags & UNIT_CUSTOM_FLAG_MASK);
            pUnit->FlagsLast = ~pUnit->Flags;
            break;
        case ID_BTN_RMV_ALL_UNIT:
            pUnit->Flags    &= ~(dlg.m_UnitFlags & UNIT_CUSTOM_FLAG_MASK);
            pUnit->FlagsOrg &= ~(dlg.m_UnitFlags & UNIT_CUSTOM_FLAG_MASK);
            pUnit->FlagsLast = ~pUnit->Flags;
            break;
        }
        idx   = GetNextItem(idx, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    }
//    Update(m_pCurLand);
    SetData(sel_by_no, -1, FALSE);

}
Beispiel #16
0
void wxExListViewFile::BuildPopupMenu(wxExMenu& menu)
{
  const long style = menu.GetStyle() |
    (GetFileName().GetStat().IsReadOnly() ? wxExMenu::MENU_IS_READ_ONLY: 0);

  menu.SetStyle(style);

  wxExListViewWithFrame::BuildPopupMenu(menu);
    
  if ( GetSelectedItemCount() == 0 &&
      !GetFileName().GetStat().IsReadOnly())
  {
    menu.AppendSeparator();
    menu.Append(wxID_ADD);
  }
}
Beispiel #17
0
void CQueueViewBase::UpdateSelections_ItemAdded(int added)
{
	// This is the fastest algorithm I can think of to move all
	// selections. Though worst case is still O(n), as with every algorithm to
	// move selections.

#ifndef __WXMSW__
	// GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
	const int selection_count = GetSelectedItemCount();
	if (!selection_count)
		return;
#endif

	// Go through all items, keep record of the previous selected item
	int item = GetNextItem(added - 1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);

	int prevItem = -1;
	while (item != -1)
	{
		if (prevItem != -1)
		{
			if (prevItem + 1 != item)
			{
				// Previous selected item was not the direct predecessor
				// That means we have to select the successor of prevItem
				// and unselect current item
				SetItemState(prevItem + 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
				SetItemState(item, 0, wxLIST_STATE_SELECTED);
			}
		}
		else
		{
			// First selected item, no predecessor yet. We have to unselect
			SetItemState(item, 0, wxLIST_STATE_SELECTED);
		}
		prevItem = item;

		item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	}
	if (prevItem != -1 && prevItem < m_itemCount - 1)
	{
		// Move the very last selected item
		SetItemState(prevItem + 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
	}

	SetItemState(added, 0, wxLIST_STATE_SELECTED);
}
void exclusion_listctrl::popup_menu( wxMouseEvent& event )
{
    wxMenu      a_menu;

    a_menu.Append( PU_ADD_EXCLUSION, _( "Add a new exclusion...") );
    a_menu.Append( PU_EDIT_EXCLUSION, _( "Edit selected exclusion..." ) );
    a_menu.Append( PU_DELETE_EXCLUSION, _( "Delete selected exclusion" ) );
    
    // If no listctrl rows selected, then disable the menu items that require selection
    if ( GetSelectedItemCount() == 0 ) 
    {
        a_menu.Enable( PU_EDIT_EXCLUSION, FALSE );
        a_menu.Enable( PU_DELETE_EXCLUSION, FALSE );
    }

    // Show the popup menu (wxWindow::PopupMenu ), at the x,y position of the click event 
    PopupMenu( &a_menu, event.GetPosition() );
}
Beispiel #19
0
const GameListItem* CGameListCtrl::GetSelectedISO() const
{
	if (m_ISOFiles.size() == 0)
	{
		return nullptr;
	}
	else if (GetSelectedItemCount() == 0)
	{
		return nullptr;
	}
	else
	{
		long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
		if (item == wxNOT_FOUND)
			return nullptr;
		return m_ISOFiles[GetItemData(item)];
	}
}
Beispiel #20
0
CMuleListCtrl::ItemDataList CMuleListCtrl::GetSelectedItems() const
{
	// Create the initial vector with as many items as are selected
	ItemDataList list( GetSelectedItemCount() );
	
	// Current item being located
	unsigned int current = 0;
	
	long pos = GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
	while ( pos != -1 ) {
		wxASSERT( current < list.size() );
	
		list[ current++ ] = GetItemData( pos );

		pos = GetNextItem( pos, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
	}
	
	return list;
}
Beispiel #21
0
void CQueueViewFailed::OnContextMenu(wxContextMenuEvent& event)
{
	wxMenu* pMenu = wxXmlResource::Get()->LoadMenu(_T("ID_MENU_QUEUE_FAILED"));
	if (!pMenu)
		return;

#ifndef __WXMSW__
	// GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
	const bool has_selection = GetSelectedItemCount() != 0;
#else
	const bool has_selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1;
#endif

	pMenu->Enable(XRCID("ID_REMOVE"), has_selection);
	pMenu->Enable(XRCID("ID_REQUEUE"), has_selection);

	PopupMenu(pMenu);
	delete pMenu;
}
Beispiel #22
0
void CFriendListCtrl::OnRemoveFriend(wxCommandEvent& WXUNUSED(event))
{
	wxString question;
	if (GetSelectedItemCount() == 1) {
		question = _("Are you sure that you wish to delete the selected friend?");
	} else {
		question = _("Are you sure that you wish to delete the selected friends?");
	}

	if ( wxMessageBox( question, _("Cancel"), wxICON_QUESTION | wxYES_NO, this) == wxYES ) {
		long index = GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );

		while( index != -1 ) {
			CFriend* cur_friend = (CFriend*)GetItemData(index);
			theApp->friendlist->RemoveFriend(cur_friend);
			// -1 because we changed the list and removed that item.
			index = GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
		}
	}
}
Beispiel #23
0
void CContactListCtrl::DelAddress()
{
  int      count;
  wxString strMessage;
  if ((count = GetSelectedItemCount()) == 1) {
    strMessage = _("Are you sure to delete the selected contact?");
  } else {
    strMessage = wxString::Format(
        _("Are you sure to delete the selected %d contacts?"), count);
  }
  if (wxMessageBox(strMessage, wxMessageBoxCaptionStr, wxICON_QUESTION|wxYES_NO) == wxYES)
  {
    long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    while (item != -1) {
      if (m_pAddressbook) m_pAddressbook->deleteEntry(m_liEntries[item]);
      item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    }
    Update();
  }
}
Beispiel #24
0
void DataListCtrl::OnAddToView(wxCommandEvent& event)
{
   int menu_index = event.GetId() - Menu_View_start;
   int num = GetSelectedItemCount();

   if (num > 0)
   {
      long item = -1;
      for ( ;; )
      {
         item = GetNextItem(item,
               wxLIST_NEXT_ALL,
               wxLIST_STATE_SELECTED);
         if ( item == -1 )
            break;

         AddToView(menu_index, item);
      }
   }
}
Beispiel #25
0
void MyResizableListCtrl::ContextSensitiveMenu( wxMouseEvent& event )
{
    // Make an instance of a menu.
    wxMenu      a_menu;

    a_menu.Append( PU_ADD_RECORD, _( "Add a new record...") );
    a_menu.Append( PU_EDIT_RECORD, _( "Edit selected record..." ) );
    a_menu.Append( PU_DELETE_RECORD, _( "Delete selected record" ) );

    // If no listctrl rows selected, then disable the menu items that
    // require selection
    if ( GetSelectedItemCount() == 0 ) {
        a_menu.Enable( PU_EDIT_RECORD, false );
        a_menu.Enable( PU_DELETE_RECORD, false );
    }

    // Show the popup menu (wxWindow::PopupMenu ), at the x,y position
    // of the click event
    PopupMenu( &a_menu, event.GetPosition() );
}
Beispiel #26
0
void CQueueViewBase::UpdateSelections_ItemRemoved(int removed)
{
#ifndef __WXMSW__
	// GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
	const int selection_count = GetSelectedItemCount();
	if (!selection_count)
		return;
#endif

	SetItemState(removed, 0, wxLIST_STATE_SELECTED);

	int item = GetNextItem(removed - 1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);

	int prevItem = -1;
	while (item != -1)
	{
		if (prevItem != -1)
		{
			if (prevItem + 1 != item)
			{
				// Previous selected item was not the direct predecessor
				// That means we have to select our predecessor and unselect
				// prevItem
				SetItemState(prevItem, 0, wxLIST_STATE_SELECTED);
				SetItemState(item - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
			}
		}
		else
		{
			// First selected item, no predecessor yet. We have to unselect
			SetItemState(item - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
		}
		prevItem = item;

		item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	}
	if (prevItem != -1)
	{
		SetItemState(prevItem, 0, wxLIST_STATE_SELECTED);
	}
}
void main_listctrl::popup_menu( wxMouseEvent& event )
{
    wxMenu      a_menu;

    a_menu.Append( PU_ADD_CHANNEL, _( "Add a new channel..." ) );
    
#if ( setupUSE_WIZARDS )    
    a_menu.Append( PU_ADD_CHANNEL_WIZARD, _( "Add a new channel using wizard..." ) );
#endif    
    
    a_menu.Append( PU_CONFIGURE_CHANNEL, _( "Configure selected channel..." ) );
    a_menu.Append( PU_DELETE_CHANNELS, _( "Delete selected channels" ) );
    a_menu.AppendSeparator();
    a_menu.Append( PU_UPDATE_SELECTED_CHANNELS, _( "Update selected channels" ) );
    a_menu.Append( PU_UPDATE_DUE_CHANNELS, _( "Update all due channels" ) );
    a_menu.Append( PU_UPDATE_ALL_CHANNELS, _( "Update all channels" ) );
    
    // If no listctrl rows selected, then disable the menu items that require selection
    if ( GetSelectedItemCount() == 0 ) 
    {
        a_menu.Enable( PU_CONFIGURE_CHANNEL, FALSE );
        a_menu.Enable( PU_DELETE_CHANNELS, FALSE );
        a_menu.Enable( PU_UPDATE_SELECTED_CHANNELS, FALSE );
    }
    
#if ( setupUSE_DRAG_AND_DROP )    
    a_menu.AppendSeparator();   
    a_menu.Append( PU_PASTE_URL_AS_NEW_CHANNEL, _( "Paste URL as new channel" ) );
    a_menu.Append( PU_PASTE_FULLNAMES_AS_NEW_SEPARATE_CHANNELS, _( "Paste files as separate new channels" ) );
    // Enable/ disable this menu item, and the main frame menuitems if the thing on the 
    // clipboard has a text format. DF_TEXT, DF_FILENAME stands for Data Format Text,
    //  Data Format Filename.
    bool text_enabled       = wxTheClipboard->IsSupported( wxDF_TEXT ) ;
    bool filename_enabled   = wxTheClipboard->IsSupported( wxDF_FILENAME );
    a_menu.Enable( PU_PASTE_URL_AS_NEW_CHANNEL, text_enabled );
    a_menu.Enable( PU_PASTE_FULLNAMES_AS_NEW_SEPARATE_CHANNELS, filename_enabled );        
#endif  // setupUSE_DRAG_AND_DROP

    // Show the popup menu (wxWindow::PopupMenu ), at the x,y position of the click event 
    PopupMenu( &a_menu, event.GetPosition() );
}
Beispiel #28
0
void CQueueViewBase::UpdateSelections_ItemRangeAdded(int added, int count)
{
    wxASSERT(GetItemCount() == m_itemCount);
#ifndef __WXMSW__
    // GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
    const int selection_count = GetSelectedItemCount();
    if (!selection_count) {
        return;
    }
#endif

    std::deque<int> itemsToSelect;

    // Go through all selected items
    int item = GetNextItem(added - 1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    while (item != -1) {
        // Select new items preceding to current one
        while (!itemsToSelect.empty() && itemsToSelect.front() < item) {
            SetItemState(itemsToSelect.front(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
            itemsToSelect.pop_front();
        }
        if (itemsToSelect.front() == item) {
            itemsToSelect.pop_front();
        }
        else {
            SetItemState(item, 0, wxLIST_STATE_SELECTED);
        }

        if (item + count < GetItemCount()) {
            // On generic list controls, new items may be selected by default after
            // increasing the item count: Internally it sometimes keeps track
            // of only unselected items.
            itemsToSelect.push_back(item + count);
        }

        item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    }
    for (auto const& sel : itemsToSelect) {
        SetItemState(sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
    }
}
std::list<wxString> CLocalListView::RememberSelectedItems(wxString& focused)
{
	std::list<wxString> selectedNames;
	// Remember which items were selected
#ifndef __WXMSW__
	// GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
	if (GetSelectedItemCount())
#endif
	{
		int item = -1;
		for (;;)
		{
			item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
			if (item == -1)
				break;
			const CLocalFileData &data = m_fileData[m_indexMapping[item]];
			if (data.flags != fill)
			{
				if (data.dir)
					selectedNames.push_back(_T("d") + data.name);
				else
					selectedNames.push_back(_T("-") + data.name);
			}
			SetSelection(item, false);
		}
	}

	int item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
	if (item != -1)
	{
		const CLocalFileData &data = m_fileData[m_indexMapping[item]];
		if (data.flags != fill)
			focused = data.name;

		SetItemState(item, 0, wxLIST_STATE_FOCUSED);
	}

	return selectedNames;
}
Beispiel #30
0
void CQueueViewBase::UpdateSelections_ItemRangeRemoved(int removed, int count)
{
#ifndef __WXMSW__
    // GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
    const int selection_count = GetSelectedItemCount();
    if (!selection_count)
        return;
#endif

    SetItemState(removed, 0, wxLIST_STATE_SELECTED);

    std::deque<int> itemsToUnselect;

    int item = GetNextItem(removed - 1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);

    while (item != -1) {
        // Unselect new items preceding to current one
        while (!itemsToUnselect.empty() && itemsToUnselect.front() < item - count) {
            SetItemState(itemsToUnselect.front(), 0, wxLIST_STATE_SELECTED);
            itemsToUnselect.pop_front();
        }

        if (itemsToUnselect.empty())
            SetItemState(item - count, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
        else if (itemsToUnselect.front() == item - count)
            itemsToUnselect.pop_front();
        else
            SetItemState(item - count, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);

        itemsToUnselect.push_back(item);

        item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    }
    for (auto const& unsel : itemsToUnselect) {
        SetItemState(unsel, 0, wxLIST_STATE_SELECTED);
    }
}