Public Member Functions | Static Public Attributes

DropScriptDropType Class Reference

Search for all occurrences

Detailed Description

See also:
Class DropType, Class DragAndDropHandler, Class FPParams, Class MacroEntry, DropTypes.

Description:
This class is available in release 4.0 and later only.

This class is an intermediate base class for drop content that comes in the form of a dropScript. This is a special kind of macroScript that implements dropScript event handlers (see the DropScript documentation for details.) The prime subclass is DropScriptFileDropType which recognizes files of type .ds. The parsed data for this type is a single parsed macroScript, represented as a MacroEntrypointer. The DropScriptDropType class provides utility methods for compiling a .ds file into the current_dropscript slot and for running the drag and drop-associated handlers in the current dropScript.

The methods RunDropScriptDragEnter(FPParams* params), RunDropScriptDragOver(FPParams* params) and RunDropScriptDrop(FPParams* params) take care of the 'on droppable' handler in the current_dropscript, if supplied. The DragAndDropHandler::DragEnter call is usualy made once on initial entry to a registered drag and drop target window and DragAndDropHandler::DragOver is usually called as the mouse moves over this window. In both cases, the handler returns true or false to indicate whether the dropping dropScript will be accepted. If a handler is not supplied, the dropScript is always deemed droppable. If the handler returns false, the not-droppable cursor is shown.

The handler is called with a set of arguments, supplied by the DragAndDropHandler, that usually depends on the window currently under the mouse pointer. For example, over a viewport, the current mouse coordinates, scene node under the mouse, slot number in a list window, etc. By convention, the first argument is positional and always a window type name, such as "Viewport" or "MaterialEditor", and all the others are keyword arguments, since they will vary from window to window. They are delivered to the RunDropScriptXXX methods in a Function Publishing FPParam object, so that handler code needs to deal as little as possible with the MAXScript SDK. Here's an example code fragment from the default drop handler:

FPParams params (6,
TYPE_NAME, (vpwin ? _M("viewport") : _M("max")),
TYPE_KEYARG_MARKER,
TYPE_NAME, _M("node"),
TYPE_INODE, m_nodectx,
TYPE_NAME, _M("point"),
TYPE_POINT, &pt);
// run the dragEnter handler & set dropeffect based on result
if (dropScriptFileDropType.RunDropScriptDragEnter(&params))
    *pdwEffect = DROPEFFECT_COPY;
else
    *pdwEffect = DROPEFFECT_NONE;
In the above code, the handler is called with 3 actual arguments, one position and two keyword. They are loaded into the 'params' instance with the FPParams varargs constructor. The first is the positional window name, in this case either #viewport or #max, then comes a special TYPE_KEYARG_MARKER signalling that the following arguments are keyword. The keyword args are given in pairs, name then value, in this case node: and point:. See the Function Publishing system documentation for full details on using the FPParams class for passing parameter blocks. An example droppable handler might be as follows:

on droppable window node: do

return window == #viewport and superclassOf node == Shape

This handler effectively makes the dropScript droppable if the mouse is over a Shape object in a viewport window. Notice that the function only looks at the node: keyword argument in this definition; arguments delivered as keyword arguments can vary from call to call and the called function can choose to look at only subset of them.
Data Members:
public

static MacroEntry* current_dropscript;

Cache for current macroScript. See /MAXSDK/INCLUDE/iMacroScript.h for the MacroScript manager public API. There are also utility methods in DropScriptDropType that do all the necessary drag and drop compiling & running of macroScripts, so you only have to deal with the MacroScript manager for special processing.

#include <idraganddrop.h>

Inheritance diagram for DropScriptDropType:
Inheritance graph
[legend]

List of all members.

Public Member Functions

int  TypeCode ()
bool  IsDropType (int code)
DWORD  DropEffect ()
CoreExport BOOL  CompileDropScript (MCHAR *filename)
CoreExport BOOL  RunDropScriptDragEnter (FPParams *params)
CoreExport BOOL  RunDropScriptDragOver (FPParams *params)
CoreExport BOOL  RunDropScriptDrop (FPParams *params)
CoreExport STDMETHODIMP  GetData (FORMATETC *pFormatetc, STGMEDIUM *pmedium)
CoreExport STDMETHODIMP  GetDataHere (FORMATETC *pFormatetc, STGMEDIUM *pmedium)
CoreExport STDMETHODIMP  QueryGetData (FORMATETC *pFormatetc)
void  InitDragDropCheck (MacroEntry *dropscript, LPARAM mousePt, WPARAM keyState, HWND hwnd)
bool  ReadyToDrag ()

Static Public Attributes

static CoreExport MacroEntry current_dropscript

Member Function Documentation

int TypeCode ( ) [inline, virtual]
Remarks:
This method returns the typecode of the DropType.
Default Implementation:
{ return DROPSCRIPT_DROPTYPE; }

Implements DropType.

Reimplemented in DropScriptFileDropType, and MSZipPackageFileDropType.

{ return DROPSCRIPT_DROPTYPE; }
bool IsDropType ( int  code ) [inline, virtual]
Remarks:
This method returns TRUE if the DropType is of the specified DropType code, otherwise FALSE.
Parameters:
int code

The DropType code.
Default Implementation:
{ return code == TypeCode() || code == DROPSCRIPT_DROPTYPE; }

Reimplemented from DropType.

{ return code == TypeCode() || code == DROPSCRIPT_DROPTYPE; }
DWORD DropEffect ( ) [inline, virtual]
Remarks:
This method returns the dropeffect currently supported by the accepted dropping type.
Default Implementation:
{ return DROPEFFECT_MOVE; }

The following methods provide assistance for developing custom drag-and-drop handlers that want to accept dropScripts. They work on the shared current_dropscript static data member in DropScriptDropType.

Reimplemented from DropType.

{ return DROPEFFECT_MOVE; }
CoreExport BOOL CompileDropScript ( MCHAR *  filename )
Remarks:
This method parses the given file, looking for a single macroScript definition. If successful, interns the macroScript and places its corresponding MacroEntry* in the current_dropscript static data member. Note that if there is more code than just a single macroScript in the file, only the last macroScript definition is taken; the other code is NOT executed, so you cannot include auxiliary global functions and other prep code in the file. These should be inside the body of the macroScript, as local data and functions.
Parameters:
MCHAR* filename

The filename of the script.
Returns:
TRUE if successfully compiled, otherwise FALSE.
CoreExport BOOL RunDropScriptDragEnter ( FPParams params )
Remarks:
This methods takes care of the 'on droppable' handler in the current_dropscript, if supplied. If the handler returns false, the not-droppable cursor is shown.
Parameters:
FPParams* params

The set of arguments for the handler.
Returns:
TRUE if droppable script will be accepted, otherwise FALSE.
CoreExport BOOL RunDropScriptDragOver ( FPParams params )
Remarks:
This methods takes care of the 'on droppable' handler in the current_dropscript, if supplied, during the process of dragging contents over the drop target. If the handler returns false, the not-droppable cursor is shown.
Parameters:
FPParams* params

The set of arguments for the handler.
Returns:
TRUE if droppable script will be accepted, otherwise FALSE.
CoreExport BOOL RunDropScriptDrop ( FPParams params )
Remarks:
This methods takes care of the 'on droppable' handler in the current_dropscript, if supplied and handles the parsing of the dropped script. If the handler returns false, the not-droppable cursor is shown.
Parameters:
FPParams* params

The set of arguments for the handler.
Returns:
TRUE if droppable script will be accepted, otherwise FALSE.
CoreExport STDMETHODIMP GetData ( FORMATETC *  pFormatetc,
STGMEDIUM *  pmedium 
)

Reimplemented from DropType.

CoreExport STDMETHODIMP GetDataHere ( FORMATETC *  pFormatetc,
STGMEDIUM *  pmedium 
)

Reimplemented from DropType.

CoreExport STDMETHODIMP QueryGetData ( FORMATETC *  pFormatetc )

Reimplemented from DropType.

void InitDragDropCheck ( MacroEntry dropscript,
LPARAM  mousePt,
WPARAM  keyState,
HWND  hwnd 
) [inline]
Remarks:
This method will initialize a drag and drop check.
Parameters:
MacroEntry* dropscript

The drop script macro entry.

LPARAM mousePt

The initial mouse cursor position.

WPARAM keyState

They initial state of the keyboard.

HWND hwnd

The handle to the initial start window.
   {
      DropType::InitDragDropCheck(mousePt, keyState, hwnd);
      current_dropscript = dropscript;
   }
bool ReadyToDrag ( ) [inline, virtual]
Remarks:
This method returns TRUE if the system is ready to drag, otherwise FALSE.
Default Implementation:
{ return current_dropscript != NULL; }

Reimplemented from DropType.

{ return current_dropscript != NULL; }

Member Data Documentation

CoreExport MacroEntry* current_dropscript [static]

DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType
DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType DropScriptDropType