00001 /*
00002 *
00003 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
00004 *
00005 * This library is free software; you can redistribute it and/or
00006 * modify it under the terms of the GNU Lesser General Public
00007 * License as published by the Free Software Foundation; either
00008 * version 2.1 of the License, or (at your option) any later version.
00009 *
00010 * This library 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 GNU
00013 * Lesser General Public License for more details.
00014 *
00015 * Further, this software is distributed without any warranty that it is
00016 * free of the rightful claim of any third person regarding infringement
00017 * or the like. Any license provided herein, whether implied or
00018 * otherwise, applies only to this software file. Patent licenses, if
00019 * any, provided herein do not apply to combinations of this program with
00020 * other software, or any other product whatsoever.
00021 *
00022 * You should have received a copy of the GNU Lesser General Public
00023 * License along with this library; if not, write to the Free Software
00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00025 *
00026 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
00027 * Mountain View, CA 94043, or:
00028 *
00029 * http://www.sgi.com
00030 *
00031 * For further information regarding this notice, see:
00032 *
00033 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
00034 *
00035 */
00036
00037 // -*- C++ -*-
00038
00039 /*
00040 * Copyright (C) 1994-95 Silicon Graphics, Inc.
00041 *
00042 _______________________________________________________________________
00043 ______________ S I L I C O N G R A P H I C S I N C . ____________
00044 |
00045 | $Revision: 1.1 $
00046 |
00047 | Description:
00048 | This class supports the "drop" in "drag and drop". Meaning, if
00049 | a file or object is dropped on a widget, this will do all the Motif
00050 | and Inventor stuff necessary to import the data.
00051 |
00052 ______________ S I L I C O N G R A P H I C S I N C . ____________
00053 _______________________________________________________________________
00054 */
00055
00056 #ifndef _MY_DROP_SITE_
00057 #define _MY_DROP_SITE_
00058
00059
00060 #include <X11/Intrinsic.h>
00061
00062 class SbStringList;
00063
00064 // Callbacks should return TRUE if it accepted the dropped data.
00065 // The x,y value is the position of the cursor when the drop occured.
00066
00067 // Typedef for callback invoked for each dropped file.
00068 typedef SbBool MyIconDropCB(void *userData, const char *filename);
00069
00070 // Typedef for callback invoked for each dropped object
00071 typedef SbBool MyObjectDropCB(
00072 void *userData,
00073 Atom dataType,
00074 void *data, uint32_t numBytes);
00075
00077 //
00078 // This class has all static methods.
00079 // registerCallback() should be called just once.
00080 //
00082
00083 class MyDropSite {
00084 public:
00085 // Registers a callback to invoke for each dropped file
00086 static void registerCallback(
00087 Widget site,
00088 MyIconDropCB *iconDropCB,
00089 MyObjectDropCB *objDropCB,
00090 void *data = NULL);
00091
00092 private:
00093 static Widget siteWidget;
00094 static MyIconDropCB *iconDropCB;
00095 static MyObjectDropCB *objDropCB;
00096 static void *dropCBData;
00097
00098 static Atom importList[10];
00099 static int numImportTargets;
00100
00101
00102 // This callback is invoked when the drop occurs
00103 static void handleDrop(Widget w,
00104 XtPointer client_data, XtPointer call_data,
00105 XtPointer proc);
00106
00107 // Reads the files/objects that were dropped
00108 static void transferIconProc(Widget, XtPointer, Atom *, Atom *type,
00109 XtPointer value, unsigned long *length, int);
00110 static void transferObjectProc(Widget, XtPointer, Atom *, Atom *type,
00111 XtPointer value, unsigned long *length, int);
00112
00113 // Find a match between the senders export list and our import list.
00114 static Atom chooseTarget(
00115 Atom *exportList,
00116 int numExportTargets);
00117
00118 // Parses the icon information from the drop action and
00119 // extracts a list of file names to open.
00120 static void parseIcon(Atom *type, XtPointer value, unsigned long *length,
00121 SbStringList *fileList);
00122 };
00123
00124 #endif /* _MY_DROP_SITE_ */
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001