Author Topic: Doubt in projectmanager.cpp  (Read 3125 times)

Offline puneet_m

  • Multiple posting newcomer
  • *
  • Posts: 73
Doubt in projectmanager.cpp
« on: September 06, 2007, 09:47:34 pm »
In Codeblock GUI, am trying to do drag and drop from Open files List panel to Project panel. But it is not working. Below is the code for drag and drop in projectmanager.cpp. What could be error? (I am using the code for version 4360).


void ProjectManager::OnTreeBeginDrag(wxTreeEvent& event)
{
//    wxString text = m_pTree->GetItemText(event.GetItem());
//    DBGLOG(_T("BeginDrag: %s"), text.c_str());

    // what item do we start dragging?
    wxTreeItemId id = event.GetItem();
    if (!id.IsOk())
        return;

    // if no data associated with it, disallow
    FileTreeData* ftd = (FileTreeData*)m_pTree->GetItemData(id);
    if (!ftd)
        return;

    // if no project, disallow
    cbProject* prj = ftd->GetProject();
    if (!prj)
        return;

    // allow only if the project approves
    if (!prj->CanDragNode(m_pTree, id))
        return;

    // allowed
    m_DraggingItem = id;
    event.Allow();
}

void ProjectManager::OnTreeEndDrag(wxTreeEvent& event)
{
//    wxString text = m_pTree->GetItemText(event.GetItem());
//    wxString oldtext = m_pTree->GetItemText(m_DraggingItem);
//    DBGLOG(_T("EndDrag: %s to %s"), oldtext.c_str(), text.c_str());

    wxTreeItemId from = m_DraggingItem;
    wxTreeItemId to = event.GetItem();
    m_DraggingItem.Unset();

    // are both items valid?
    if (!from.IsOk() || !to.IsOk())
        return;

    // if no data associated with any of them, disallow
    FileTreeData* ftd1 = (FileTreeData*)m_pTree->GetItemData(from);
    FileTreeData* ftd2 = (FileTreeData*)m_pTree->GetItemData(to);
    if (!ftd1 || !ftd2)
        return;

    // if no project or different projects, disallow
    cbProject* prj1 = ftd1->GetProject();
    cbProject* prj2 = ftd2->GetProject();
    if (!prj1 || prj1 != prj2)
        return;

    // allow only if the project approves
    if (!prj1->NodeDragged(m_pTree, from, to))
        return;

    event.Allow();
}