2
// C++ Implementation: EntityIconDragDropTarget
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2007
9
// This program is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU General Public License as published by
11
// the Free Software Foundation; either version 2 of the License, or
12
// (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program; if not, write to the Free Software
21
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//
27
#include "EntityIconDragDropTarget.h"
28
#include "EntityIcon.h"
29
#include <elements/CEGUIDragContainer.h>
30
#include <CEGUIWindow.h>
32
using namespace CEGUI;
38
EntityIconDragDropTarget::EntityIconDragDropTarget(CEGUI::Window* container)
40
container->subscribeEvent(CEGUI::Window::EventDragDropItemEnters, CEGUI::Event::Subscriber(& EntityIconDragDropTarget::dragContainer_DragEnter, this));
41
container->subscribeEvent(CEGUI::Window::EventDragDropItemLeaves, CEGUI::Event::Subscriber(& EntityIconDragDropTarget::dragContainer_DragLeave, this));
42
container->subscribeEvent(CEGUI::Window::EventDragDropItemDropped, CEGUI::Event::Subscriber(& EntityIconDragDropTarget::dragContainer_DragDropped, this));
46
EntityIconDragDropTarget::~EntityIconDragDropTarget()
51
bool EntityIconDragDropTarget::dragContainer_DragEnter(const CEGUI::EventArgs& args)
53
EntityIcon* entityIcon = parseIcon(args);
55
return handleDragEnter(args, entityIcon);
60
bool EntityIconDragDropTarget::dragContainer_DragLeave(const CEGUI::EventArgs& args)
62
EntityIcon* entityIcon = parseIcon(args);
64
return handleDragLeave(args, entityIcon);
69
bool EntityIconDragDropTarget::dragContainer_DragDropped(const CEGUI::EventArgs& args)
71
EntityIcon* entityIcon = parseIcon(args);
73
return handleDragDropped(args, entityIcon);
80
bool EntityIconDragDropTarget::handleDragEnter(const CEGUI::EventArgs& args, EntityIcon* icon)
82
EventIconEntered.emit(icon);
85
bool EntityIconDragDropTarget::handleDragLeave(const CEGUI::EventArgs& args, EntityIcon* icon)
87
EventIconLeaves.emit(icon);
90
bool EntityIconDragDropTarget::handleDragDropped(const CEGUI::EventArgs& args, EntityIcon* icon)
92
EventIconDropped.emit(icon);
96
EntityIcon* EntityIconDragDropTarget::parseIcon(const CEGUI::EventArgs& args)
98
const DragDropEventArgs& ddea = static_cast<const DragDropEventArgs&>(args);
99
DragContainer* container = ddea.dragDropItem;
101
EntityIconUserData* mUserData = static_cast<EntityIconUserData*>(container->getUserData());
103
return &mUserData->getEntityIcon();