DropClipFormat Class Reference

#include <idraganddrop.h>

Class Description

See also
Class DropType, Class VIZableClipFmt, Class DropScriptClipFmt, DropTypes.
Description:
DropClipFormat is the base class for the various supported clipboard formats contained in a dropped IDataObject. Subclasses represent particular IDataObject clip format or package of related formats that can be accepted by various windows in 3ds Max. The prime responsibility of each is to recognize its presence in a dropped IDataObject and to parse the data object into one of the supported DropTypes. Each subclass should have a singleton instance created. This is automatically registered with the drag and drop system for use in the clipform recognition routines.
Data Members:
protected:

static Tab<DropClipFormat*> clipFmts;

The table of supported clip formats.
+ Inheritance diagram for DropClipFormat:

Public Member Functions

 DropClipFormat ()
 
virtual bool CheckClipFormat (IDataObject *pDataObject)
 
virtual DropTypeParseDataObject (IDataObject *pDataObject)
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 
virtual UtilExport BaseInterfaceGetInterface (Interface_ID id)
 

Static Public Member Functions

static CoreExport DropClipFormatFindClipFormat (IDataObject *pDataObject)
 
- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Static Protected Attributes

static CoreExport Tab< DropClipFormat * > clipFmts
 

Constructor & Destructor Documentation

DropClipFormat ( )
inline
Remarks
Constructor.

Each DropClimFormat instance created is kept in the clipFmts table
572 { DropClipFormat* cf = this; clipFmts.Append(1, &cf); }
static CoreExport Tab< DropClipFormat * > clipFmts
Definition: idraganddrop.h:566
Definition: idraganddrop.h:563
int Append(int num, T *el, int allocExtra=0)
Appends items at the end of the Tab.
Definition: tab.h:281

Member Function Documentation

static CoreExport DropClipFormat* FindClipFormat ( IDataObject *  pDataObject)
static
Remarks
This method returns a pointer to the DropClipFormat (singleton) corresponding to the clip format in the given IDataObject, or NULL if the IDataObject contains no recognizable formats. This is primarily used by the low-level default DragEnter() function in drag and drop manager.
Parameters:
IDataObject* pDataObject

The data object you wish to return the clip format for.
virtual bool CheckClipFormat ( IDataObject *  pDataObject)
inlinevirtual
Remarks
This method should be implemented by each subclass to detect the presence of its clipformat(s) in the given IDataObject. See ParseDataObject() below for a detailed example.
Parameters:
IDataObject* pDataObject

The data object.
Returns
TRUE if the data was queries successfully, otherwise FALSE.
Default Implementation:
{ return false; }

Reimplemented in DropScriptClipFmt, VIZableClipFmt, and IDropPackageClipFmt.

597 { return false; }
virtual DropType* ParseDataObject ( IDataObject *  pDataObject)
inlinevirtual
Remarks
This method should be implemented by each subclass to parse its clipformat(s) in the given IDataObject into the corresponding DropType subclass instance. For example, the DropClipFormats that accept dropped files will typically return one of the FileDropType subclasses depending on the filename suffix. A list of built-in clipformats:

IDropPackageClipFmt iDrop XML package
VIZableClipFmt VIZable file URL
DropScriptClipFmt internal dropScript

Here's an example (simplified) VIZableClipFmt implementation, which accepts a custom CF_MAXURL clip format containing the URL of a file. CheckClipFormat() returns true if it finds the CF_MAXURL clipboard format present in the given IDataObject. Because this is a dropping file, ParseDataObject() clears the current droptype data (the FileDropType::Init(), extracts the file name from the IDataObject and installs it into the FileDropType current_package variable. It then asks the FileDropType class to recognize the actual file type being dropped and return the corresponding FileDropType subclass instance (using FileDropType::FindDropType()).

bool VIZableClipFmt::CheckClipFormat(IDataObject* pDataObject)
{
// accept CF_MAXURL clip formats
FORMATETC fmt = { NULL, NULL, DVASPECT_CONTENT, -1, NULL };
fmt.cfFormat = RegisterClipboardFormat(_M("CF_MAXURL"));
fmt.tymed = TYMED_HGLOBAL;
return SUCCEEDED(pDataObject->QueryGetData(&fmt)) ==
TRUE;
}
DropType* VIZableClipFmt::ParseDataObject(IDataObject* pDataObject)
{
// parse a CF_MAXURL clipformat into one of the FileDropTypes
&
// fill in the FileDropType::current_packge URLTab
HRESULT hr;
FORMATETC fmt = { NULL, NULL, DVASPECT_CONTENT, -1, NULL };
STGMEDIUM stg = { TYMED_NULL, NULL, NULL };
fmt.tymed = TYMED_HGLOBAL;
fmt.cfFormat = RegisterClipboardFormat(_M("CF_MAXURL"));
// clear out the file drop current data
// look for CF_MAXURL formats
hr = pDataObject->GetData(&fmt, &stg);
if(SUCCEEDED(hr)) {
// found, get the max file name
MCHAR szUrl[MAX_PATH];
ZeroMemory(szUrl, sizeof(szUrl));
wcstombs(szUrl,
reinterpret_cast<wchar_t*>(GlobalLock(stg.hGlobal)),
MAX_PATH-1);
GlobalUnlock(stg.hGlobal);
ReleaseStgMedium(&stg);
// add it to the current_package URLTab
}
// if we have a non-NULL package, get the appropriate
// FileDropType (usually based on file extension), by asking the
// utility DropType finder in FileDropType
else
return NULL;
}
Parameters:
IDataObject* pDataObject

The data object.
Returns
A pointer to the drop-type.
Default Implementation:
{ return NULL; }

Reimplemented in DropScriptClipFmt, VIZableClipFmt, and IDropPackageClipFmt.

678 { return NULL; }
#define NULL
Definition: autoptr.h:18

Member Data Documentation

CoreExport Tab<DropClipFormat*> clipFmts
staticprotected