void
CBCommandTable::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	if (ScrollForWheel(button, modifiers) ||
		!GetCell(pt, &cell))
		{
		return;
		}

	itsStartPt = pt;
	if (cell.x == kOptionsColumn)
		{
		SelectSingleCell(cell);
		itsOptionsMenu->PopUp(this, pt, buttonStates, modifiers);
		}
	else if (button == kJXLeftButton)
		{
		SelectSingleCell(cell);
		if (clickCount == 2)
			{
			BeginEditing(cell);
			}
		}
}
void
GLFitDescriptionList::HandleMouseDown
	(
	const JPoint& 			pt,
	const JXMouseButton 	button,
	const JSize 			clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	JPoint cell;
	if (button == kJXLeftButton && GetCell(pt, &cell))
		{
		if (GetTableSelection().IsSelected(cell) && clickCount == 2)
			{
			Broadcast(FitInitiated(cell.y));
			}
		else if (!GetTableSelection().IsSelected(cell) && clickCount == 1)
			{
			SelectSingleCell(cell);
			Broadcast(FitSelected(cell.y));
			}
		}
	else
		{
		ScrollForWheel(button, modifiers);
		}
}
void
CBSymbolTable::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	itsKeyBuffer.Clear();

	JPoint cell;
	if (ScrollForWheel(button, modifiers))
		{
		return;
		}
	else if (!GetCell(pt, &cell))
		{
		(GetTableSelection()).ClearSelection();
		}
	else if (button == kJXLeftButton &&
			 clickCount == 2 &&
			 !modifiers.shift() && modifiers.meta() && modifiers.control())
		{
		SelectSingleCell(cell, kJFalse);
		DisplaySelectedSymbols();
		(GetWindow())->Close();
		return;
		}
	else if (clickCount == 2 && modifiers.meta())
		{
		SelectSingleCell(cell, kJFalse);
		FindSelectedSymbols(button);
		}
	else if (button == kJXLeftButton &&
			 clickCount == 2 &&
			 !modifiers.shift() && !modifiers.control())
		{
		DisplaySelectedSymbols();
		}
	else
		{
		BeginSelectionDrag(cell, button, modifiers);
		}
}
void
CBSymbolTable::SelectSingleEntry
	(
	const JIndex	index,
	const JBoolean	scroll
	)
{
	SelectSingleCell(JPoint(1, index), scroll);
	itsKeyBuffer.Clear();
}
void
CMArray2DTable::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	JTableSelection& s = GetTableSelection();

	JPoint cell;
	if (ScrollForWheel(button, modifiers))
		{
		// work has been done
		}
	else if (!GetCell(pt, &cell))
		{
		s.ClearSelection();
		}
	else if (button == kJXLeftButton && modifiers.meta())
		{
		if (!s.IsSelected(cell))
			{
			SelectSingleCell(cell, kJFalse);
			}

		const JString expr = itsArrayDir->GetExpression(cell);
		itsCmdDir->DisplayExpression(expr);
		}
	else if (button == kJXLeftButton && clickCount == 2)
		{
		BeginEditing(cell);
		}
	else if (button == kJXLeftButton && clickCount == 1)
		{
		SelectSingleCell(cell, kJFalse);
		}
}
JXInputField*
CBMacroSetTable::CreateStringTableInput
	(
	const JPoint&		cell,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
{
	SelectSingleCell(cell);

	JXInputField* input =
		JXStringTable::CreateStringTableInput(
							cell, enclosure, hSizing, vSizing, x,y, w,h);
	input->SetIsRequired();
	return input;
}
void
SVNListBase::HandleKeyPress
	(
	const int				key,
	const JXKeyModifiers&	modifiers
	)
{
	JTableSelection& s          = GetTableSelection();
	const JBoolean hadSelection = s.HasSelection();
	itsSavedSelection->CleanOut();

	if (key == kJReturnKey)
		{
		OpenSelectedItems();
		}

	// space->clear is handled by JXStringList

	else if (key == kJUpArrow || key == kJDownArrow)
		{
		ClearIncrementalSearchBuffer();
		if (!hadSelection && key == kJUpArrow && GetRowCount() > 0)
			{
			SelectSingleCell(JPoint(1, GetRowCount()));
			}
		else
			{
			HandleSelectionKeyPress(key, modifiers);
			}
		}

	else
		{
		JXStringList::HandleKeyPress(key, modifiers);
		}
}
void
CBCommandTable::HandleDNDDrop
	(
	const JPoint&		pt,
	const JArray<Atom>&	typeList,
	const Atom			action,
	const Time			time,
	const JXWidget*		source
	)
{
	JXSelectionManager* selMgr = GetSelectionManager();
	JXDNDManager* dndMgr       = GetDNDManager();
	const Atom selName         = dndMgr->GetDNDSelectionName();

	if (source == this && action == dndMgr->GetDNDActionMoveXAtom())
		{
		JPoint cell;
		if ((GetTableSelection()).GetSingleSelectedCell(&cell) &&
			itsDNDRowIndex != JIndex(cell.y) && itsDNDRowIndex != JIndex(cell.y)+1)
			{
			JIndex newIndex = itsDNDRowIndex;
			if (newIndex > JIndex(cell.y))
				{
				newIndex--;
				}
			newIndex = JMin(newIndex, GetRowCount());

			itsCmdList->MoveElementToIndex(cell.y, newIndex);
			MoveRow(cell.y, newIndex);
			SelectSingleCell(JPoint(1, newIndex));
			}
		}
	else if (source == this)
		{
		JPoint cell;
		if ((GetTableSelection()).GetSingleSelectedCell(&cell))
			{
			itsCmdList->InsertElementAtIndex(
				itsDNDRowIndex, (itsCmdList->GetElement(cell.y)).Copy());
			InsertRows(itsDNDRowIndex, 1);
			SelectSingleCell(JPoint(1, itsDNDRowIndex));
			}
		}
	else
		{
		Atom returnType;
		unsigned char* data;
		JSize dataLength;
		JXSelectionManager::DeleteMethod delMethod;
		if (selMgr->GetData(selName, time, itsCommandXAtom,
							&returnType, &data, &dataLength, &delMethod))
			{
			if (returnType == itsCommandXAtom)
				{
				const std::string s((char*) data, dataLength);
				std::istringstream input(s);

				CBCommandManager::CmdInfo cmdInfo =
					CBCommandManager::ReadCmdInfo(input, CBCommandManager::GetCurrentCmdInfoFileVersion());
				if (!input.fail())
					{
					const JIndex newIndex = JMax(JIndex(1), itsDNDRowIndex);
					itsCmdList->InsertElementAtIndex(newIndex, cmdInfo);
					InsertRows(newIndex, 1);
					SelectSingleCell(JPoint(1, newIndex));

					if (action == dndMgr->GetDNDActionMoveXAtom())
						{
						selMgr->SendDeleteRequest(selName, time);
						}
					}
				}

			selMgr->DeleteData(&data, delMethod);
			}
		}

	HandleDNDLeave();
}