1 /***********************************************************************/ 2 /* Open Visualization Data Explorer */ 3 /* (C) Copyright IBM Corp. 1989,1999 */ 4 /* ALL RIGHTS RESERVED */ 5 /* This code licensed under the */ 6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */ 7 /***********************************************************************/ 8 9 #include <dxconfig.h> 10 #include "../base/defines.h" 11 12 13 14 15 #ifndef _DragSource_h 16 #define _DragSource_h 17 18 #include <Xm/Xm.h> 19 20 #include "Base.h" 21 #include "TransferStyle.h" 22 23 class Dictionary; 24 25 // 26 // Class name definition: 27 // 28 #define ClassDragSource "DragSource" 29 30 extern "C" void DragSource_StartDrag (Widget, XEvent*, String*, Cardinal*); 31 extern "C" Boolean DragSource_ConvertProc(Widget, Atom*, Atom*, Atom*, 32 XtPointer*, unsigned long*, int*); 33 extern "C" void DragSource_DropFinishCB(Widget, XtPointer, XtPointer); 34 extern "C" void DragSource_TopLevelLeaveCB (Widget, XtPointer, XtPointer); 35 extern "C" void DragSource_TopLevelEnterCB (Widget, XtPointer, XtPointer); 36 37 // 38 // DragSource class definition: 39 // 40 class DragSource : public Base 41 { 42 private: 43 // 44 // "Class" data 45 static boolean DragSourceClassInitialized; 46 static XtTranslations drag_tranlations; 47 static void* TransferData; 48 49 // 50 // Private member data: 51 // 52 XContext context; 53 Widget drag_icon; 54 Widget drag_context; 55 Pixmap drag_pixmap; 56 Pixmap drag_mask; 57 int icon_width; 58 int icon_height; 59 long operation; 60 61 // 62 // On behalf of pagetabs, enforce d-n-d inside a single top level window. 63 // intra_toplevel == TRUE iff we want to enforce this behavior. 64 // inside_own_shell is maintained during the drag operation. It's set to TRUE 65 // if the pointer is still inside the initiating top level shell. 66 // 67 Window top_level_window; 68 boolean intra_toplevel; 69 boolean inside_own_shell; 70 71 72 // 73 // Private member functions: 74 // 75 friend void DragSource_StartDrag (Widget, XEvent*, String*, Cardinal*); 76 friend Boolean DragSource_ConvertProc(Widget, Atom*, Atom*, Atom*, 77 XtPointer*, unsigned long*, int*); 78 friend void DragSource_DropFinishCB(Widget, XtPointer, XtPointer); 79 friend void DragSource_TopLevelLeaveCB (Widget, XtPointer, XtPointer); 80 friend void DragSource_TopLevelEnterCB (Widget, XtPointer, XtPointer); 81 82 void startDrag(Widget, XEvent*); 83 84 protected: 85 86 // 87 // Protected member data: 88 // 89 char *converted_data; 90 91 virtual void setDragWidget(Widget); 92 virtual Widget createDragIcon(int width, int height, char *bits, char *maskbits); 93 virtual void setDragIcon(Widget); 94 virtual void dropFinish(long operation, int tag, unsigned char completion_status); 95 96 // 97 // This function is called prior to starting a drag. 98 // Abort aborts the drag and beeps, 99 // Inactive aborts the drag, no beep. Needed because it's easier to do 100 // this than to reinstall translations in order to turn off a drag source. The 101 // book says that's the way to turn off a drag source. 102 // 103 enum { 104 Proceed = 1, 105 Abort = 2, 106 Inactive = 3 107 }; decideToDrag(XEvent *)108 virtual int decideToDrag(XEvent *){return DragSource::Proceed;}; 109 110 // 111 // There was a Dictionary* up in private. It's replaced with this call. 112 // Subclasses want to enforce sharing a common dictionary among their members. 113 // 114 virtual Dictionary *getDragDictionary() = 0; 115 116 // 117 // Instead of passing around a stored value for this, make the subclasses 118 // implement a proc which decodes according to an enum and then invokes a member. 119 // 120 virtual boolean decodeDragType (int, char *, XtPointer*, unsigned long*, long) = 0; 121 setIntraShellBehavior(boolean intra_shell)122 void setIntraShellBehavior(boolean intra_shell) { 123 this->intra_toplevel = intra_shell; 124 } 125 boolean isIntraShell(); 126 127 public: 128 129 void addSupportedType (int, const char *, boolean); 130 131 // 132 // Constructor: 133 // 134 DragSource(); 135 136 // 137 // Destructor: 138 // 139 ~DragSource(); 140 141 // 142 // Returns a pointer to the class name. 143 // getClassName()144 const char* getClassName() 145 { 146 return ClassDragSource; 147 } 148 }; 149 150 151 #endif // _DragSource_h 152