00001
00002
00003
00004
00005
00006
00007
00008 #pragma once
00009
00010 #include "maxheap.h"
00011 #include "iFnPub.h"
00012 #include "iMacroScript.h"
00013 #include "GetCOREInterface.h"
00014
00015
00016 class IDragAndDropMgr;
00017 class DragAndDropHandler;
00018 class DropType;
00019
00020
00021
00022
00036 class URLTab : public Tab<MCHAR*>
00037 {
00038 public:
00039 BOOL downloaded;
00040
00044 URLTab() { downloaded = FALSE; }
00050 ~URLTab() { Clear(); }
00052 CoreExport URLTab& operator=(const Tab<MCHAR*>& tb);
00054 CoreExport URLTab& operator=(const URLTab& tb);
00060 CoreExport void Add(MCHAR* url);
00069 CoreExport void Change(int i, MCHAR* url);
00072 CoreExport void Clear();
00073 };
00074
00075
00076 #define DND_MGR_INTERFACE Interface_ID(0x51163ddb, 0x2a4f1619)
00077
00080 inline IDragAndDropMgr* GetDragAndDropMgr() { return (IDragAndDropMgr*)GetCOREInterface(DND_MGR_INTERFACE); }
00081
00082
00084 enum
00085 {
00086 dndmgr_enableDandD,
00087 dndmgr_globalEnableDnD,
00088 dndmgr_isEnabled,
00089 dndmgr_dropPackage,
00090 dndmgr_downloadDirectory,
00091 dndmgr_downloadPackage,
00092 dndmgr_downloadUrlToDisk,
00093 dndmgr_importContextNode,
00094 };
00095
00140 class IDragAndDropMgr : public FPStaticInterface
00141 {
00142 public:
00145 virtual void EnableDandD(BOOL flag)=0;
00146
00149 virtual BOOL IsEnabled()=0;
00150
00152
00161 virtual BOOL EnableDandD(HWND hwnd, BOOL flag, DragAndDropHandler* handler = NULL)=0;
00162
00179 virtual BOOL DropPackage(HWND hwnd, POINT& point, URLTab& module)=0;
00180
00189 virtual BOOL DownloadPackage(URLTab& module, MCHAR* directory, HWND hwnd = NULL, bool showProgress = false)=0;
00190
00193 virtual MCHAR* GetDownloadDirectory()=0;
00194
00197 virtual int NumHandlers(HWND hwnd)=0;
00198
00202 virtual DragAndDropHandler* GetHandler(HWND hwnd, int i)=0;
00203
00213 virtual bool DownloadUrlToDisk(HWND hwnd, MCHAR* url, MCHAR* fileName, DWORD dlgflags=0)=0;
00214
00216 virtual INode* ImportContextNode()=0;
00217 };
00218
00219 #pragma warning(push)
00220 #pragma warning(disable:4100)
00221
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 class DragAndDropHandler : public InterfaceServer
00248 {
00249 public:
00251 DragAndDropHandler()
00252 : current_droptype(NULL)
00253 {
00254 if (dndMgr == NULL)
00255 dndMgr = GetDragAndDropMgr();
00256 }
00257
00316 CoreExport virtual HRESULT DragEnter(HWND window, IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
00317
00342 CoreExport virtual HRESULT Drop(HWND window, IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
00366 CoreExport virtual HRESULT DragOver(HWND window, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect);
00379 CoreExport virtual HRESULT DragLeave(HWND window) { return E_FAIL; }
00380
00381
00415 virtual HRESULT DragEnter(HWND window, DropType* type, DWORD grfKeyState, POINT& pt, DWORD* pdwEffect) { return E_FAIL; }
00487 virtual HRESULT Drop(HWND window, DropType* type, DWORD grfKeyState, POINT& pt, DWORD* pdwEffect) { return E_FAIL; }
00514 virtual HRESULT DragOver(HWND window, DWORD grfKeyState, POINT& pt, DWORD * pdwEffect) { return E_FAIL; }
00515
00523 virtual void Acquire() { };
00526
00532 virtual void Release() { };
00533
00534 protected:
00537 DropType* current_droptype;
00539 CoreExport static IDragAndDropMgr* dndMgr;
00540 };
00541
00542
00543
00544
00545
00546
00547
00548
00549
00565 class DropClipFormat : public InterfaceServer
00566 {
00567 protected:
00568 CoreExport static Tab<DropClipFormat*> clipFmts;
00569 public:
00570
00574 DropClipFormat() { DropClipFormat* cf = this; clipFmts.Append(1, &cf); }
00575
00576
00577
00586 CoreExport static DropClipFormat* FindClipFormat(IDataObject* pDataObject);
00587
00588
00589
00599 virtual bool CheckClipFormat(IDataObject* pDataObject) { return false; }
00600
00601
00602
00680 virtual DropType* ParseDataObject(IDataObject* pDataObject) { return NULL; }
00681 };
00682
00683
00684
00685
00690 class IDropPackageClipFmt : public DropClipFormat
00691 {
00692 public:
00693 bool CheckClipFormat(IDataObject* pDataObject);
00694 DropType* ParseDataObject(IDataObject* pDataObject);
00695 };
00696
00697
00702 class VIZableClipFmt : public DropClipFormat
00703 {
00704 public:
00705 bool CheckClipFormat(IDataObject* pDataObject);
00706 DropType* ParseDataObject(IDataObject* pDataObject);
00707 };
00708
00709
00714 class DropScriptClipFmt : public DropClipFormat
00715 {
00716 public:
00717 bool CheckClipFormat(IDataObject* pDataObject);
00718 DropType* ParseDataObject(IDataObject* pDataObject);
00719 };
00720
00721
00722
00723
00724
00725
00726
00727
00728
00762 class DropType : public MaxHeapOperators, public IDropSource, public IDataObject
00763 {
00764 protected:
00765 CoreExport static IDragAndDropMgr* dndMgr;
00766 CoreExport static bool dragging;
00767 CoreExport static POINT startPt;
00768 CoreExport static WPARAM startKeyState;
00769 CoreExport static HWND startWnd;
00770 CoreExport static bool loaded;
00771
00772 public:
00773
00774 CoreExport static IDataObject* current_dataobject;
00775
00777 DropType() { if (dndMgr == NULL) dndMgr = GetDragAndDropMgr(); }
00779 CoreExport virtual ~DropType();
00780
00781
00785 static void Init() { current_dataobject = NULL; loaded = false; }
00786
00787
00788
00790 virtual int TypeCode()=0;
00805 virtual bool IsDropType(int code) { return code == TypeCode(); }
00806
00807
00808
00809
00810
00821 virtual bool Load(bool showProgress = true) { return true; }
00822
00823
00828 virtual DWORD DropEffect() { return DROPEFFECT_MOVE; }
00829
00830
00831
00832
00833 CoreExport STDMETHODIMP QueryInterface(REFIID iid, void** ppvObject);
00834 CoreExport STDMETHODIMP_(ULONG) AddRef(void) { return 1; }
00835 CoreExport STDMETHODIMP_(ULONG) Release(void) { return 1; }
00836
00837
00838 CoreExport STDMETHODIMP GetData(FORMATETC* pFormatetc, STGMEDIUM* pmedium) { return E_UNEXPECTED; }
00839 CoreExport STDMETHODIMP GetDataHere(FORMATETC* pFormatetc, STGMEDIUM* pmedium) { return E_UNEXPECTED; }
00840 CoreExport STDMETHODIMP QueryGetData(FORMATETC* pFormatetc) { return E_UNEXPECTED; }
00841 CoreExport STDMETHODIMP GetCanonicalFormatEtc(FORMATETC* pFormatetcIn, FORMATETC* pFormatetcOut);
00842 CoreExport STDMETHODIMP SetData(FORMATETC* pFormatetc, STGMEDIUM* pmedium, BOOL fRelease);
00843 CoreExport STDMETHODIMP EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc);
00844 CoreExport STDMETHODIMP DAdvise(FORMATETC* pFormatetc, DWORD advf, IAdviseSink* pAdvSink, DWORD* pdwConnection);
00845 CoreExport STDMETHODIMP DUnadvise(DWORD dwConnection);
00846 CoreExport STDMETHODIMP EnumDAdvise(IEnumSTATDATA** ppenumAdvise);
00847
00848
00849 CoreExport STDMETHODIMP QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState);
00850 CoreExport STDMETHODIMP GiveFeedback(DWORD dwEffect) { return DRAGDROP_S_USEDEFAULTCURSORS; }
00851
00852
00853 CoreExport virtual void InitDragDropCheck(LPARAM mousePt, WPARAM keyState, HWND hwnd);
00854 CoreExport virtual void CancelDragDropCheck();
00855 CoreExport virtual bool DragDropCheck(LPARAM mousePt, WPARAM keyState, DWORD allowedEffects);
00856 CoreExport virtual bool ReadyToDrag(){ return false; }
00857 };
00858
00867 #define FILE_DROPTYPE 0x00000001 //!< A module of file names or URL's.
00868 #define DROPSCRIPT_DROPTYPE 0x00000002 //!< A dropScript.
00869 #define SCENEFILE_DROPTYPE 0x00000003 //!< The *.max scene file.
00870 #define IMAGEFILE_DROPTYPE 0x00000004 //!< The image files (.bmp, .tga, etc.).
00871 #define IMPORTFILE_DROPTYPE 0x00000005 //!< The importable files (.3ds, .dxf, etc.).
00872 #define SCRIPTFILE_DROPTYPE 0x00000006 //!< The script files (.ms, .mse, .mcr).
00873 #define DROPSCRIPTFILE_DROPTYPE 0x00000007 //!< The drop script files (.ds, .dse).
00874 #define BITMAP_DROPTYPE 0x00000008 //!< The bitmap type.
00875 #define MSZIPFILE_DROPTYPE 0x00000009 //!< The script zip module files (.mzp).
00876 #define PATHFILE_DROPTYPE 0x0000000a //!< The path type.
00877
00878
00896 class FileDropType : public DropType
00897 {
00898 protected:
00899 CoreExport static Tab<FileDropType*> fileDropTypes;
00900 CoreExport static MSTR download_directory;
00901
00902
00903 CoreExport static bool CheckForCachedFile(MCHAR* filename);
00904 CoreExport static bool IsInternetCachedFile(const MCHAR* filename);
00905 CoreExport static bool AppendUrlFilename(const MCHAR* szUrl, MCHAR* szPathname, bool& is_URL);
00906
00907 public:
00908 CoreExport static URLTab current_package;
00909
00911 FileDropType() { FileDropType* dt = this; fileDropTypes.Append(1, &dt); }
00915 static void Init() { current_package.Clear(); DropType::Init(); }
00916
00917
00921 int TypeCode() { return FILE_DROPTYPE; }
00929 bool IsDropType(int code) { return code == TypeCode() || code == FILE_DROPTYPE; }
00930
00931
00932
00938 CoreExport bool Load(bool showProgress = true);
00939
00940
00951 CoreExport static FileDropType* FindDropType(MCHAR* filename, IDataObject* pDataObject = NULL);
00952
00953
00962 virtual bool CheckDropType(MCHAR* filename) { return false; }
00963
00964
00980 CoreExport static bool DownloadPackage(URLTab& module, MCHAR* szDirectory, HWND hwnd = NULL, bool showProgress = true);
00983 CoreExport static MCHAR* GetDownloadDirectory();
00999 CoreExport static bool DownloadUrlToDisk(HWND hwnd, MCHAR* szUrl, MCHAR* szPathname, DWORD flags=0);
01000
01001
01002
01003
01004 STDMETHODIMP GetData(FORMATETC* pFormatetc, STGMEDIUM* pmedium) { return E_UNEXPECTED; }
01005 STDMETHODIMP GetDataHere(FORMATETC* pFormatetc, STGMEDIUM* pmedium) { return E_UNEXPECTED; }
01006 STDMETHODIMP QueryGetData(FORMATETC* pFormatetc) { return E_UNEXPECTED; }
01007
01008 };
01009
01010 #pragma warning(pop)
01011
01012
01013
01014
01015
01085 class DropScriptDropType : public DropType
01086 {
01087 public:
01088 CoreExport static MacroEntry* current_dropscript;
01089
01090
01094 int TypeCode() { return DROPSCRIPT_DROPTYPE; }
01102 bool IsDropType(int code) { return code == TypeCode() || code == DROPSCRIPT_DROPTYPE; }
01110 DWORD DropEffect() { return DROPEFFECT_MOVE; }
01111
01112
01113
01114
01127 CoreExport BOOL CompileDropScript(MCHAR* filename);
01135 CoreExport BOOL RunDropScriptDragEnter(FPParams* params);
01144 CoreExport BOOL RunDropScriptDragOver(FPParams* params);
01153 CoreExport BOOL RunDropScriptDrop(FPParams* params);
01154
01155
01156
01157
01158 CoreExport STDMETHODIMP GetData(FORMATETC* pFormatetc, STGMEDIUM* pmedium);
01159 CoreExport STDMETHODIMP GetDataHere(FORMATETC* pFormatetc, STGMEDIUM* pmedium);
01160 CoreExport STDMETHODIMP QueryGetData(FORMATETC* pFormatetc);
01161
01162
01173 void InitDragDropCheck(MacroEntry* dropscript, LPARAM mousePt, WPARAM keyState, HWND hwnd)
01174 {
01175 DropType::InitDragDropCheck(mousePt, keyState, hwnd);
01176 current_dropscript = dropscript;
01177 }
01182 bool ReadyToDrag() { return current_dropscript != NULL; }
01183 };
01184
01185
01186
01187
01188
01189
01190
01196 class SceneFileDropType : public FileDropType
01197 {
01198 public:
01199
01203 int TypeCode() { return SCENEFILE_DROPTYPE; }
01204
01205
01212 CoreExport bool CheckDropType(MCHAR* filename);
01213 };
01214
01215
01221 class ImageFileDropType : public FileDropType
01222 {
01223 public:
01224
01228 int TypeCode() { return IMAGEFILE_DROPTYPE; }
01229
01230
01237 CoreExport bool CheckDropType(MCHAR* filename);
01238 };
01239
01240
01246 class ImportFileDropType : public FileDropType
01247 {
01248 public:
01249
01253 int TypeCode() { return IMPORTFILE_DROPTYPE; }
01254
01255
01262 CoreExport bool CheckDropType(MCHAR* filename);
01263 };
01264
01265
01271 class ScriptFileDropType : public FileDropType
01272 {
01273 public:
01274
01278 int TypeCode() { return SCRIPTFILE_DROPTYPE; }
01279
01280
01287 CoreExport bool CheckDropType(MCHAR* filename);
01288 };
01289
01290
01298 class DropScriptFileDropType : public FileDropType, public DropScriptDropType
01299 {
01300 public:
01301
01305 int TypeCode() { return DROPSCRIPTFILE_DROPTYPE; }
01310 bool Load(bool showProgress = true);
01311
01312
01319 CoreExport bool CheckDropType(MCHAR* filename);
01320 };
01321
01322
01336 class MSZipPackageFileDropType : public FileDropType, public DropScriptDropType
01337 {
01338 public:
01339 MSTR extract_dir;
01340 MSTR drop_file;
01341 DropType* drop_file_type;
01342
01343
01347 int TypeCode() { return MSZIPFILE_DROPTYPE; }
01352 bool Load(bool showProgress = true);
01353
01354
01361 CoreExport bool CheckDropType(MCHAR* filename);
01362 };
01363
01364
01365
01366
01372 class BitmapDropType : public DropType
01373 {
01374 public:
01375
01379 int TypeCode() { return BITMAP_DROPTYPE; }
01380
01381 };
01382
01384
01388 class PathConfigDropType : public FileDropType
01389 {
01390 public:
01392
01393 int TypeCode() { return PATHFILE_DROPTYPE; }
01394
01396
01401 CoreExport bool CheckDropType(MCHAR* filename);
01402 };
01403
01404
01405 extern CoreExport SceneFileDropType sceneFileDropType;
01406 extern CoreExport ImageFileDropType imageFileDropType;
01407 extern CoreExport ScriptFileDropType scriptFileDropType;
01408 extern CoreExport DropScriptFileDropType dropScriptFileDropType;
01409 extern CoreExport DropScriptDropType dropScriptDropType;
01410 extern CoreExport BitmapDropType bitmapDropType;
01411 extern CoreExport MSZipPackageFileDropType msZipPackageFileDropType;
01412 extern CoreExport PathConfigDropType pathConfigDropType;
01413
01414