Blender  V2.59
GHOST_EventDragnDrop.h
Go to the documentation of this file.
00001 /*
00002  * $Id: GHOST_EventDragnDrop.h 35152 2011-02-25 11:28:33Z jesterking $
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00020  * All rights reserved.
00021  *
00022  * The Original Code is: all of this file.
00023  *
00024  * Contributor(s): Damien Plisson 11/2009
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #ifndef _GHOST_EVENT_DRAGNDROP_H_
00035 #define _GHOST_EVENT_DRAGNDROP_H_
00036 
00037 #include "GHOST_Event.h"
00038 extern "C" {
00039 #include "IMB_imbuf.h"
00040 #include "IMB_imbuf_types.h"
00041 };
00042 
00069 class GHOST_EventDragnDrop : public GHOST_Event
00070 {
00071 public:
00082         GHOST_EventDragnDrop(GHOST_TUns64 time, GHOST_TEventType type, GHOST_TDragnDropTypes dataType, GHOST_IWindow* window,
00083                                                  int x, int y, GHOST_TEventDataPtr data)
00084                 : GHOST_Event(time, type, window)
00085         {
00086                 m_dragnDropEventData.x = x;
00087                 m_dragnDropEventData.y = y;
00088                 m_dragnDropEventData.dataType = dataType;
00089                 m_dragnDropEventData.data = data;
00090                 m_data = &m_dragnDropEventData;
00091         }
00092         
00093         ~GHOST_EventDragnDrop()
00094         {
00095                 //Free the dropped object data
00096                 if (m_dragnDropEventData.data == NULL)
00097                         return;
00098                 
00099                 switch (m_dragnDropEventData.dataType) {
00100                         case GHOST_kDragnDropTypeBitmap:
00101                                 IMB_freeImBuf((ImBuf*)m_dragnDropEventData.data);
00102                                 break;
00103                         case GHOST_kDragnDropTypeFilenames:
00104                         {
00105                                 GHOST_TStringArray *strArray = (GHOST_TStringArray*)m_dragnDropEventData.data;
00106                                 int i;
00107                                 
00108                                 for (i=0;i<strArray->count;i++)
00109                                         free(strArray->strings[i]);
00110                                 
00111                                 free(strArray);
00112                         }
00113                                 break;
00114                         case GHOST_kDragnDropTypeString:
00115                                 free(m_dragnDropEventData.data);
00116                         break;
00117 
00118                         default:
00119                                 break;
00120                 }
00121         }
00122         
00123         
00124 
00125 protected:
00127         GHOST_TEventDragnDropData m_dragnDropEventData;
00128 };
00129 
00130 #endif // _GHOST_EVENT_DRAGNDROP_H_
00131