00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TDNDManager
00013 #define ROOT_TDNDManager
00014
00015 #ifndef ROOT_TGFrame
00016 #include "TGFrame.h"
00017 #endif
00018
00019 class TGMainFrame;
00020 class TGDragWindow;
00021 class TTimer;
00022
00023
00024
00025 class TGDragWindow : public TGFrame {
00026
00027 protected:
00028 static Cursor_t fgDefaultCursor;
00029
00030 protected:
00031 virtual void DoRedraw();
00032
00033 Window_t fInput;
00034 Pixmap_t fPic, fMask;
00035 UInt_t fPw, fPh;
00036
00037 public:
00038 TGDragWindow(const TGWindow *p, Pixmap_t pic, Pixmap_t mask,
00039 UInt_t options = kChildFrame, Pixel_t back = GetWhitePixel());
00040 virtual ~TGDragWindow();
00041
00042 virtual TGDimension GetDefaultSize() const { return TGDimension(fPw, fPh); }
00043
00044 virtual void MapWindow();
00045 virtual void UnmapWindow();
00046 virtual void RaiseWindow();
00047 virtual void LowerWindow();
00048 virtual void MapRaised();
00049
00050 virtual void Layout();
00051
00052 Window_t GetInputId() const { return fInput; }
00053 Bool_t HasWindow(Window_t w) const { return (w == fId || w == fInput); }
00054
00055 ClassDef(TGDragWindow, 0)
00056 };
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 class TDNDData : public TObject {
00068 private:
00069 TDNDData(const TDNDData&);
00070 TDNDData& operator=(const TDNDData&);
00071
00072 public:
00073 TDNDData(Atom_t dt = kNone, void *d = 0, Int_t len = 0, Atom_t act = kNone) :
00074 fDataType(dt), fAction(act), fData(d), fDataLength(len) {}
00075 ~TDNDData() {}
00076
00077 Atom_t fDataType;
00078 Atom_t fAction;
00079 void *fData;
00080 Int_t fDataLength;
00081
00082 ClassDef(TDNDData, 0)
00083 };
00084
00085
00086
00087 class TGDNDManager : public TObject {
00088
00089 private:
00090 TGDNDManager(const TGDNDManager&);
00091 TGDNDManager& operator=(const TGDNDManager&);
00092
00093 protected:
00094 TGFrame *fMain;
00095 Atom_t fVersion;
00096 Atom_t *fTypelist, *fDraggerTypes;
00097 Atom_t fDropType;
00098 Atom_t fAcceptedAction, fLocalAction;
00099
00100 Bool_t fDragging;
00101 Bool_t fDropAccepted;
00102 Bool_t fStatusPending;
00103 Bool_t fUseVersion;
00104 Bool_t fProxyOurs;
00105 Window_t fSource, fTarget;
00106 Bool_t fTargetIsDNDAware;
00107 UInt_t fGrabEventMask;
00108 TGFrame *fLocalSource, *fLocalTarget;
00109
00110 TTimer *fDropTimeout;
00111 TGDragWindow *fDragWin;
00112
00113 Pixmap_t fPic, fMask;
00114 Int_t fHotx, fHoty;
00115 Cursor_t fDNDNoDropCursor;
00116
00117 protected:
00118 static Atom_t fgDNDAware, fgDNDSelection, fgDNDProxy;
00119 static Atom_t fgDNDEnter, fgDNDLeave, fgDNDPosition, fgDNDStatus;
00120 static Atom_t fgDNDDrop, fgDNDFinished;
00121 static Atom_t fgDNDVersion;
00122 static Atom_t fgDNDActionCopy, fgDNDActionMove, fgDNDActionLink;
00123 static Atom_t fgDNDActionAsk, fgDNDActionPrivate;
00124 static Atom_t fgDNDTypeList, fgDNDActionList, fgDNDActionDescrip;
00125 static Atom_t fgXCDNDData;
00126
00127 static Bool_t fgInit;
00128 static Atom_t fgXAWMState;
00129
00130 protected:
00131 void InitAtoms();
00132 Window_t GetRootProxy();
00133 Window_t FindWindow(Window_t root, Int_t x, Int_t y, Int_t maxd);
00134 Bool_t IsDNDAware(Window_t win, Atom_t *typelist = 0);
00135 Bool_t IsTopLevel(Window_t win);
00136
00137 void SendDNDEnter(Window_t target);
00138 void SendDNDLeave(Window_t target);
00139 void SendDNDPosition(Window_t target, int x, int y,
00140 Atom_t action, Time_t timestamp);
00141 void SendDNDStatus(Window_t target, Atom_t action);
00142 void SendDNDDrop(Window_t target);
00143 void SendDNDFinished(Window_t src);
00144
00145 Bool_t HandleDNDEnter(Window_t src, long vers, Atom_t dataTypes[3]);
00146 Bool_t HandleDNDLeave(Window_t src);
00147 Bool_t HandleDNDPosition(Window_t src, int x_root, int y_root, Atom_t action, Time_t timestamp);
00148 Bool_t HandleDNDStatus(Window_t from, int accepted,
00149 Rectangle_t skip, Atom_t action);
00150 Bool_t HandleDNDDrop(Window_t src, Time_t timestamp);
00151 Bool_t HandleDNDFinished(Window_t target);
00152
00153 public:
00154 TGDNDManager(TGFrame *toplevel, Atom_t *typelist);
00155 virtual ~TGDNDManager();
00156
00157 Bool_t HandleClientMessage(Event_t *event);
00158 Bool_t HandleSelectionRequest(Event_t *event);
00159 Bool_t HandleSelection(Event_t *event);
00160
00161 Bool_t HandleTimer(TTimer *t);
00162
00163
00164
00165 TGFrame *GetMainFrame() const { return fMain; }
00166 void SetMainFrame(TGFrame *main) { fMain = main; }
00167 void SetDragPixmap(Pixmap_t pic, Pixmap_t mask, Int_t hot_x, Int_t hot_y);
00168 Bool_t SetRootProxy();
00169 Bool_t RemoveRootProxy();
00170
00171 Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root,
00172 Window_t grabWin = kNone);
00173 Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp);
00174 Bool_t Drop();
00175 Bool_t EndDrag();
00176
00177 Bool_t IsDragging() const { return fDragging; }
00178 Window_t GetSource() const { return fSource; }
00179 Window_t GetTarget() const { return fTarget; }
00180 Atom_t *GetTypeList() const { return fTypelist; }
00181
00182 static Atom_t GetDNDAware();
00183 static Atom_t GetDNDSelection();
00184 static Atom_t GetDNDProxy();
00185 static Atom_t GetDNDEnter();
00186 static Atom_t GetDNDLeave();
00187 static Atom_t GetDNDPosition();
00188 static Atom_t GetDNDStatus();
00189 static Atom_t GetDNDDrop();
00190 static Atom_t GetDNDFinished();
00191 static Atom_t GetDNDVersion();
00192 static Atom_t GetDNDActionCopy();
00193 static Atom_t GetDNDActionMove();
00194 static Atom_t GetDNDActionLink();
00195 static Atom_t GetDNDActionAsk();
00196 static Atom_t GetDNDActionPrivate();
00197 static Atom_t GetDNDTypeList();
00198 static Atom_t GetDNDActionList();
00199 static Atom_t GetDNDActionDescrip();
00200 static Atom_t GetXCDNDData();
00201
00202 ClassDef(TGDNDManager, 0)
00203 };
00204
00205 R__EXTERN TGDNDManager *gDNDManager;
00206
00207 #endif // ROOT_TDNDManager
00208