void
GMMessageDragSource::GetDNDAskActions
	(
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers,
	JArray<Atom>*			askActionList,
	JPtrArray<JString>*		askDescriptionList
	)
{
	JXDNDManager* dndMgr = GetDNDManager();
	askActionList->AppendElement(dndMgr->GetDNDActionCopyXAtom());
	askActionList->AppendElement(dndMgr->GetDNDActionMoveXAtom());

	JString* s = new JString(kDNDActionCopyDescrip);
	assert( s != NULL );
	askDescriptionList->Append(s);

	s = new JString(kDNDActionMoveDescrip);
	assert( s != NULL );
	askDescriptionList->Append(s);
}
Esempio n. 2
0
void
SyGGetDNDAskActions
	(
	JArray<Atom>*		actionList,
	JPtrArray<JString>*	descriptionList
	)
{
	JXDNDManager* dndMgr = ((JXGetApplication())->GetCurrentDisplay())->GetDNDManager();
	actionList->AppendElement(dndMgr->GetDNDActionCopyXAtom());
	actionList->AppendElement(dndMgr->GetDNDActionMoveXAtom());
	actionList->AppendElement(dndMgr->GetDNDActionLinkXAtom());

	JString* s = new JString(JGetString(kDNDCopyDescriptionID));
	assert( s != NULL );
	descriptionList->Append(s);

	s = new JString(JGetString(kDNDMoveDescriptionID));
	assert( s != NULL );
	descriptionList->Append(s);

	s = new JString(JGetString(kDNDLinkDescriptionID));
	assert( s != NULL );
	descriptionList->Append(s);
}
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();
}