Esempio n. 1
0
void FileExplorerTab::ClearSelections()
{
    if(GetSelectionCount()) {
        // multiple selections
        Tree()->GetTreeCtrl()->UnselectAll();
    }
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedColumnCount(PRUint32* aCount)
{
  NS_ENSURE_ARG_POINTER(aCount);
  *aCount = 0;

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  // If all the row has been selected, then all the columns are selected,
  // because we can't select a column alone.

  PRInt32 rowCount = 0;
  nsresult rv = GetRowCount(&rowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 selectedrowCount = 0;
  rv = GetSelectionCount(&selectedrowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  if (rowCount == selectedrowCount) {
    PRInt32 columnCount = 0;
    rv = GetColumnCount(&columnCount);
    NS_ENSURE_SUCCESS(rv, rv);

    *aCount = columnCount;
  }

  return NS_OK;
}
void ResultCheckListCtrl::OnUnselectAll(wxCommandEvent& WXUNUSED(event))
{
    long Item = -1;
    if(GetSelectionCount() == 1)
    {
        //If user has selected only 1 item, that apply to all files
        for ( ;; )
        {
            Item = GetNextItem(Item);
            if(Item == -1)
                break;
            SetItemImage(Item, 1);
        }
    }
    else
    {
        //If user has selected more than 1 item, that apply to selected files
        for ( ;; )
        {
            Item = GetNextItem(Item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            if(Item == -1)
                break;
            SetItemImage(Item, 1);
        }
    }
}
Esempio n. 4
0
void CDirstatDoc::OnEditCopy()
{
    CString paths;
    for (size_t i = 0; i < GetSelectionCount(); i++)
    {
        if (i > 0)
            paths += _T("\r\n");

        paths += GetSelection(i)->GetPath();
    }

    // FIXME: Need to fix the clipboard code!!!
    AfxMessageBox(paths);
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedRowCount(PRUint32* aCount)
{
  NS_ENSURE_ARG_POINTER(aCount);
  *aCount = 0;

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  PRInt32 selectedrowCount = 0;
  nsresult rv = GetSelectionCount(&selectedrowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  *aCount = selectedrowCount;
  return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedCellIndices(PRUint32 *aCellsCount,
                                                PRInt32 **aCells)
{
  NS_ENSURE_ARG_POINTER(aCellsCount);
  *aCellsCount = 0;
  NS_ENSURE_ARG_POINTER(aCells);
  *aCells = nsnull;

  PRInt32 selectedrowCount = 0;
  nsresult rv = GetSelectionCount(&selectedrowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 columnCount = 0;
  rv = GetColumnCount(&columnCount);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 selectedCellCount = selectedrowCount * columnCount;
  PRInt32* outArray = static_cast<PRInt32*>(
    nsMemory::Alloc(selectedCellCount * sizeof(PRInt32)));
  NS_ENSURE_TRUE(outArray, NS_ERROR_OUT_OF_MEMORY);

  nsCOMPtr<nsITreeSelection> selection;
  rv = mTreeView->GetSelection(getter_AddRefs(selection));
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 rowCount = 0;
  rv = GetRowCount(&rowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  PRBool isSelected;
  for (PRInt32 rowIdx = 0, arrayIdx = 0; rowIdx < rowCount; rowIdx++) {
    selection->IsSelected(rowIdx, &isSelected);
    if (isSelected) {
      for (PRInt32 colIdx = 0; colIdx < columnCount; colIdx++)
        outArray[arrayIdx++] = rowIdx * columnCount + colIdx;
    }
  }

  *aCellsCount = selectedCellCount;
  *aCells = outArray;
  return NS_OK;
}
void ResultCheckListCtrl::OnInvertSelection(wxCommandEvent& event)
{
    long Item = -1;
    if(GetSelectionCount() == 1)
    {
        //If user has selected only 1 item, that apply to all files
        for ( ;; )
        {
            Item = GetNextItem(Item);
            if(Item == -1)
                break;

            wxListItem LItem;
            LItem.SetId(Item);
            GetItem(LItem);

            if(LItem.GetImage())
                SetItemImage(Item, 0);
            else
                SetItemImage(Item, 1);
        }
    }
    else
    {
        //If user has selected more than 1 item, that apply to selected files
        for ( ;; )
        {
            Item = GetNextItem(Item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            if(Item == -1)
                break;

            wxListItem LItem;
            LItem.SetId(Item);
            GetItem(LItem);

            if(LItem.GetImage())
                SetItemImage(Item, 0);
            else
                SetItemImage(Item, 1);
        }
    }
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedColumnIndices(PRUint32 *acolumnCount,
                                                  PRInt32 **aColumns)
{
  NS_ENSURE_ARG_POINTER(acolumnCount);
  *acolumnCount = 0;
  NS_ENSURE_ARG_POINTER(aColumns);
  *aColumns = nsnull;

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  // If all the row has been selected, then all the columns are selected.
  // Because we can't select a column alone.

  PRInt32 rowCount = 0;
  nsresult rv = GetRowCount(&rowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 selectedrowCount = 0;
  rv = GetSelectionCount(&selectedrowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  if (rowCount != selectedrowCount)
    return NS_OK;

  PRInt32 columnCount = 0;
  rv = GetColumnCount(&columnCount);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32* outArray = static_cast<PRInt32*>(
    nsMemory::Alloc(columnCount * sizeof(PRInt32)));
  NS_ENSURE_TRUE(outArray, NS_ERROR_OUT_OF_MEMORY);

  for (PRInt32 colIdx = 0; colIdx < columnCount; colIdx++)
    outArray[colIdx] = colIdx;

  *acolumnCount = columnCount;
  *aColumns = outArray;
  return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedCells(nsIArray **aCells)
{
  NS_ENSURE_ARG_POINTER(aCells);
  *aCells = nsnull;

  nsCOMPtr<nsIMutableArray> selCells = do_CreateInstance(NS_ARRAY_CONTRACTID);
  NS_ENSURE_TRUE(selCells, NS_ERROR_FAILURE);

  PRInt32 selectedrowCount = 0;
  nsresult rv = GetSelectionCount(&selectedrowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 columnCount = 0;
  rv = GetColumnCount(&columnCount);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsITreeSelection> selection;
  rv = mTreeView->GetSelection(getter_AddRefs(selection));
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 rowCount = 0;
  rv = GetRowCount(&rowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  PRBool isSelected;
  for (PRInt32 rowIdx = 0; rowIdx < rowCount; rowIdx++) {
    selection->IsSelected(rowIdx, &isSelected);
    if (isSelected) {
      for (PRInt32 colIdx = 0; colIdx < columnCount; colIdx++) {
        nsCOMPtr<nsIAccessible> cell;
        GetCellAt(rowIdx, colIdx, getter_AddRefs(cell));
        selCells->AppendElement(cell, PR_FALSE);
      }
    }
  }

  NS_ADDREF(*aCells = selCells);
  return NS_OK;
}
Esempio n. 10
0
	// Prepares data for selection operation
	void GaSelectionOperation::Prepare(GaPopulation& population,
		GaChromosomeGroup& output,
		const GaSelectionParams& parameters,
		const GaCouplingConfig& configuration,
		int branchCount) const
	{
		int crossoverBufferTagID = parameters.GetCrossoverBuffersTagID();
		const Chromosome::GaMatingConfig& config = configuration.GetMating().GetConfiguration();

		// setup output chromsome group
		output.Clear();
		output.SetSize( GetSelectionCount( parameters, &config ) );
		output.SetPopulation( &population );
		output.SetObjectRecycling( crossoverBufferTagID >= 0 );

		// creating crossover buffers if selection operation should produce offspring chromosomes
		if( crossoverBufferTagID >= 0 )
		{
			int index = population.GetTagManager().AddTag( crossoverBufferTagID, Common::Data::GaSizableTagLifecycle<GaPartialCrossoverBuffer>() );
			population.GetTagByIndex<GaPartialCrossoverBuffer>( index ).SetSize( branchCount,
				GaCrossoverStorageBuffer( &population, config.GetParentCount(), config.GetOffspringCount() ) );
		}
	}
NS_IMETHODIMP
nsXULTreeGridAccessible::IsColumnSelected(PRInt32 aColumnIndex,
                                          PRBool *aIsSelected)
{
  NS_ENSURE_ARG_POINTER(aIsSelected);
  *aIsSelected = PR_FALSE;

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  // If all the row has been selected, then all the columns are selected.
  // Because we can't select a column alone.
  
  PRInt32 rowCount = 0;
  nsresult rv = GetRowCount(&rowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 selectedrowCount = 0;
  rv = GetSelectionCount(&selectedrowCount);
  NS_ENSURE_SUCCESS(rv, rv);

  *aIsSelected = rowCount == selectedrowCount;
  return NS_OK;
}
void ResultCheckListCtrl::ShowContextMenu(const wxPoint& pos)
{
    wxMenu menu;

    if(GetSelectionCount() ==1)
    {
        //Context menu for 1 selected item by user
        menu.Append(ID_CHECKLIST_SELECT_ALL, wxString(i8n("&Select all files"), wxConvUTF8));
        menu.Append(ID_CHECKLIST_UNSELECT_ALL, wxString(i8n("&Unselect all files"), wxConvUTF8));
        menu.Append(ID_CHECKLIST_INVERT_SELECTION, wxString(i8n("&Invert selection"), wxConvUTF8));
        menu.AppendSeparator();
        menu.Append(ID_CHECKLIST_SELECT_FROM_SAME_FOLDER, wxString(i8n("&Select all files from same folder"), wxConvUTF8));
        menu.Append(ID_CHECKLIST_UNSELECT_FROM_SAME_FOLDER, wxString(i8n("&Unselect all files from same folder"), wxConvUTF8));
    }
    else
    {
        //Context menu for more than 1 selected item by user
        menu.Append(ID_CHECKLIST_SELECT_ALL, wxString(i8n("&Select all files"), wxConvUTF8));
        menu.Append(ID_CHECKLIST_UNSELECT_ALL, wxString(i8n("&Unselect all files"), wxConvUTF8));
        menu.Append(ID_CHECKLIST_INVERT_SELECTION, wxString(i8n("&Invert selection"), wxConvUTF8));
    }

    PopupMenu(&menu, pos.x, pos.y);
}