// Note: Instrumentation statements are highlighted in green 

#include "trash can.hpp"
#include "devices.hpp"

///////////////////////////////////////////////////////////////////////////////
// DeviceTrashCan class
///////////////////////////////////////////////////////////////////////////////

// Visual Member Definition 
VISIBILITY_START(DeviceTrashCan, "DeviceTrashCan", 0)
VISIBILITY_END

DeviceTrashCan::DeviceTrashCan(void)
{
}

DeviceTrashCan::DeviceTrashCan(const DeviceTrashCan & that)
{
}

DeviceTrashCan & DeviceTrashCan::operator=(const DeviceTrashCan& that)
{
  return *this;
}

// Override VObject's isDataDropable function and allow a list of selected device controllers to be dropped onto this object
unsigned short DeviceTrashCan::isDataDropable(VObject * & drop_target, VObject * & drag_parent, VObject * & drag_object,
                                                unsigned short drop_type, unsigned short src_drag_drop_flags)
{
  VSelectionList * selection_list = dynamic_cast<VSelectionList *>(drag_object);
  if (selection_list && (selection_list->size() >= 1)) {
    VSelectionList::iterator sel_iter = selection_list->begin();
    if ((selection_list->begin() != selection_list->end()) &&
          dynamic_cast<DeviceController *>(*selection_list->begin())) {
      return  VDRAGDROP_DEST_MOVE | VDRAGDROP_DEST_COPY;
    }
  }
   return 0;
}

// Override VObject's dropData function and remove the list of dropped items from their container and delete
// them if necessary.
bool DeviceTrashCan::dropData(VObject * & drop_target, VObject * drag_parent, VObject * drag_object,
                                unsigned short drop_type, unsigned short src_dragdrop_flags,
                                float x_origin, float y_origin, float object_x, float object_y, unsigned short coord_type)
{
  VSelectionList * selection_list = dynamic_cast<VSelectionList *>(drag_object);
  if (selection_list) {
    VContainerObject * src_container = dynamic_cast<VContainerObject *>(drag_parent);
    VSelectionList::reverse_iterator rsel_iter = selection_list->rbegin();
    while (rsel_iter != selection_list->rend()) {
      src_container->eraseVObject(*rsel_iter);
      if (src_dragdrop_flags & VDRAGDROP_OWNER_CONTAINER)
        delete *rsel_iter;
      rsel_iter++;
    }
    return true;
  }
  return false;
}


Copyright 2002-2007 Outerface Technologies, Inc.