Пример #1
0
void InstanceCtrl::OnInstDragged(InstanceCtrlEvent& event)
{
	// No DnD in single column mode.
	if (GetWindowStyle() & wxINST_SINGLE_COLUMN)
		return;

	Instance *selectedInst = m_instList->GetSelectedInstance();
	if (!selectedInst)
		return;

	wxTextDataObject instDataObj(selectedInst->GetInstID());

	wxDropSource dragSource(instDataObj, this);
	dragSource.DoDragDrop(wxDrag_AllowMove);
	
	// Make sure we reset the group highlighting when the DnD operation is done.
	HighlightGroup(VisualCoord());
}
Пример #2
0
bool InstanceCtrl::InstCtrlDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data)
{
	// Unhighlight group.
	m_parent->HighlightGroup(VisualCoord());

	VisualCoord coord;
	m_parent->HitTest(wxPoint(x, y), coord);

	// Make sure we target a group, always.
	if (coord.itemIndex >= 0)
		coord.itemIndex = -1;
	GroupVisual *gv = m_parent->GetGroup(coord);
	if (gv)
	{
		for (int i = 0; i < m_parent->m_instList->size(); i++)
		{
			Instance * inst = m_parent->m_instList->at(i);
			if (inst->GetInstID() == data)
			{
				if(gv->isUngrouped() && inst->GetGroup() == "" && coord.isHeader() || coord.isHeaderTicker())
				{
					inst->SetGroup("New Group");
				}
				else if(gv->isUngrouped())
				{
					inst->SetGroup(wxEmptyString);
				}
				else
				{
					inst->SetGroup(gv->GetName());
				}
				m_parent->ReloadAll();

				return true;
			}
		}
	}

	return false;
}