bool C4EditCursor::LeftButtonDown(DWORD dwKeyState)
{

	// Hold
	Hold=true;

	switch (Mode)
	{
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	case C4CNS_ModeEdit:
		if (dwKeyState & MK_CONTROL)
		{
			// Toggle target
			if (Target)
				if (!RemoveFromSelection(Target))
					AddToSelection(Target);
		}
		else
		{
			// Click on unselected: select single
			if (Target)
			{
				C4ObjectLink * it;
				for(it = Selection.First; it; it = it->Next){
					if(it->Obj->At(X, Y))
						break;
				}
				if(!it) // means loop didn't break
					{ ClearSelection(); AddToSelection(Target); }
			}
			// Click on nothing: drag frame
			if (!Target)
				{ ClearSelection(); DragFrame=true; X2=X; Y2=Y; }
		}
		break;
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	case C4CNS_ModeDraw:
		switch (Console.ToolsDlg.Tool)
		{
		case C4TLS_Brush: ApplyToolBrush(); break;
		case C4TLS_Line: DragLine=true; X2=X; Y2=Y; break;
		case C4TLS_Rect: DragFrame=true; X2=X; Y2=Y; break;
		case C4TLS_Fill:
			if (Game.HaltCount)
				{ Hold=false; Console.Message(LoadResStr("IDS_CNS_FILLNOHALT")); return false; }
			break;
		case C4TLS_Picker: ApplyToolPicker(); break;
		}
		break;
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	}

	DropTarget=NULL;

	OnSelectionChanged();
	return true;
}
NS_IMETHODIMP
sbLocalDatabaseMediaListViewSelection::SelectOnly(PRInt32 aIndex)
{
  NS_ENSURE_ARG_RANGE(aIndex, 0, (PRInt32) mLength - 1);
  nsresult rv;

  mCurrentIndex = aIndex;
  rv = GetUniqueIdForIndex(mCurrentIndex, mCurrentUID);
  NS_ENSURE_SUCCESS(rv, rv);

  mSelection.Clear();
  mSelectionIsAll = PR_FALSE;

  rv = AddToSelection(aIndex);
  NS_ENSURE_SUCCESS(rv, rv);

  CheckSelectAll();

  NOTIFY_LISTENERS(OnSelectionChanged, ());

#ifdef DEBUG
  LogSelection();
#endif

  return NS_OK;
}
bool C4EditCursor::RightButtonDown(DWORD dwKeyState)
{

	switch (Mode)
	{
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	case C4CNS_ModeEdit:
		if ( (dwKeyState & MK_CONTROL) == 0)
		{
			// Check whether cursor is on anything in the selection
			bool fCursorIsOnSelection = false;
			for (C4ObjectLink *pLnk = Selection.First; pLnk; pLnk = pLnk->Next)
				if (pLnk->Obj->At(X,Y))
				{
					fCursorIsOnSelection = true;
					break;
				}
			if (!fCursorIsOnSelection)
			{
				// Click on unselected
				if (Target && !Selection.GetLink(Target))
				{
					ClearSelection(); AddToSelection(Target);
				}
				// Click on nothing
				if (!Target) ClearSelection();
			}
		}
		break;
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	}

	OnSelectionChanged();
	return true;
}
NS_IMETHODIMP
sbLocalDatabaseMediaListViewSelection::Toggle(PRInt32 aIndex)
{
  NS_ENSURE_ARG_RANGE((PRInt32) aIndex, 0, (PRInt32) mLength - 1);
  nsresult rv;

  mCurrentIndex = aIndex;
  rv = GetUniqueIdForIndex(mCurrentIndex, mCurrentUID);
  NS_ENSURE_SUCCESS(rv, rv);

  // If have an all selection, fill the selection with everything but the
  // toggled index
  if (mSelectionIsAll) {
    mSelectionIsAll = PR_FALSE;
    for (PRUint32 i = 0; i < mLength; i++) {
      if (i != (PRUint32) aIndex) {
        rv = AddToSelection(i);
        NS_ENSURE_SUCCESS(rv, rv);
      }
    }
    return NS_OK;
  }

  // Otherwise, simply do the toggle
  PRBool isSelected;
  rv = IsIndexSelected(aIndex, &isSelected);
  NS_ENSURE_SUCCESS(rv, rv);

  if (isSelected) {
    rv = RemoveFromSelection(aIndex);
    NS_ENSURE_SUCCESS(rv, rv);
  }
  else {
    rv = AddToSelection(aIndex);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  CheckSelectAll();

  NOTIFY_LISTENERS(OnSelectionChanged, ());

#ifdef DEBUG
  LogSelection();
#endif

  return NS_OK;
}
void C4EditCursor::FrameSelection()
{
	ClearSelection();
	C4Object *cobj; C4ObjectLink *clnk;
	for (clnk=::Objects.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
		if (cobj->Status) if (cobj->OCF & OCF_NotContained)
			{
				if (Inside(cobj->GetX(),Min(X,X2),Max(X,X2)) && Inside(cobj->GetY(),Min(Y,Y2),Max(Y,Y2)))
					AddToSelection(cobj);
			}
	OnSelectionChanged();
}
Example #6
0
void
PackageListView::SelectPackage(const PackageInfoRef& package)
{
	PackageRow* row = _FindRow(package);
	BRow* selected = CurrentSelection();
	if (row != selected)
		DeselectAll();
	if (row != NULL) {
		AddToSelection(row);
		SetFocusRow(row, false);
		ScrollTo(row);
	}
}
Example #7
0
void
TreeTable::SelectNode(const TreeTablePath& path, bool extendSelection)
{
	TreeTableNode* node = _NodeForPath(path);
	if (node == NULL)
		return;

	if (!extendSelection) {
		fIgnoreSelectionChange++;
		DeselectAll();
		fIgnoreSelectionChange--;
	}

	AddToSelection(node->Row());
}
NS_IMETHODIMP
sbLocalDatabaseMediaListViewSelection::ClearRange(PRInt32 aStartIndex,
                                                  PRInt32 aEndIndex)
{
  NS_ENSURE_ARG_RANGE(aStartIndex, 0, (PRInt32) mLength - 1);
  NS_ENSURE_ARG_RANGE(aEndIndex,   0, (PRInt32) mLength - 1);

  nsresult rv;

  mCurrentIndex = aEndIndex;
  rv = GetUniqueIdForIndex(mCurrentIndex, mCurrentUID);
  NS_ENSURE_SUCCESS(rv, rv);

  // If have an all selection, fill the selection with everything but the
  // range we're clearing
  if (mSelectionIsAll) {
    mSelectionIsAll = PR_FALSE;
    for (PRUint32 i = 0; i < mLength; i++) {
      if (i < (PRUint32) aStartIndex || i > (PRUint32) aEndIndex) {
        rv = AddToSelection(i);
        NS_ENSURE_SUCCESS(rv, rv);
      }
    }

    NOTIFY_LISTENERS(OnSelectionChanged, ());

    return NS_OK;
  }

  for (PRInt32 i = aStartIndex; i <= aEndIndex; i++) {
    rv = RemoveFromSelection((PRUint32) i);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  NOTIFY_LISTENERS(OnSelectionChanged, ());

#ifdef DEBUG
  LogSelection();
#endif

  return NS_OK;
}
NS_IMETHODIMP
sbLocalDatabaseMediaListViewSelection::SelectRange(PRInt32 aStartIndex,
                                                   PRInt32 aEndIndex)
{
  TRACE(("sbLocalDatabaseMediaListViewSelection[0x%.8x] - SelectRange(%d, %d)",
         this, aStartIndex, aEndIndex));

  NS_ENSURE_ARG_RANGE(aStartIndex, 0, (PRInt32) mLength - 1);
  NS_ENSURE_ARG_RANGE(aEndIndex,   0, (PRInt32) mLength - 1);

  nsresult rv;

  if (mSelectionIsAll) {
    return NS_OK;
  }

  mCurrentIndex = aEndIndex;
  rv = GetUniqueIdForIndex(mCurrentIndex, mCurrentUID);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 start = PR_MIN(aStartIndex, aEndIndex);
  PRInt32 end   = PR_MAX(aStartIndex, aEndIndex);

  for (PRInt32 i = start; i <= end; i++) {
    rv = AddToSelection((PRUint32) i);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  CheckSelectAll();

  NOTIFY_LISTENERS(OnSelectionChanged, ());

#ifdef DEBUG
  LogSelection();
#endif

  return NS_OK;
}