#ifndef ROOT_TDNDManager
#define ROOT_TDNDManager
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
class TGMainFrame;
class TGDragWindow;
class TTimer;
class TGDragWindow : public TGFrame {
protected:
static Cursor_t fgDefaultCursor;
protected:
virtual void DoRedraw();
Window_t fInput;
Pixmap_t fPic, fMask;
UInt_t fPw, fPh;
public:
TGDragWindow(const TGWindow *p, Pixmap_t pic, Pixmap_t mask,
UInt_t options = kChildFrame, Pixel_t back = GetWhitePixel());
virtual ~TGDragWindow();
virtual TGDimension GetDefaultSize() const { return TGDimension(fPw, fPh); }
virtual void MapWindow();
virtual void UnmapWindow();
virtual void RaiseWindow();
virtual void LowerWindow();
virtual void MapRaised();
virtual void Layout();
Window_t GetInputId() const { return fInput; }
Bool_t HasWindow(Window_t w) const { return (w == fId || w == fInput); }
ClassDef(TGDragWindow, 0)
};
class TDNDData : public TObject {
private:
TDNDData(const TDNDData&);
TDNDData& operator=(const TDNDData&);
public:
TDNDData(Atom_t dt = kNone, void *d = 0, Int_t len = 0, Atom_t act = kNone) :
fDataType(dt), fAction(act), fData(d), fDataLength(len) {}
~TDNDData() {}
Atom_t fDataType;
Atom_t fAction;
void *fData;
Int_t fDataLength;
ClassDef(TDNDData, 0)
};
class TGDNDManager : public TObject {
private:
TGDNDManager(const TGDNDManager&);
TGDNDManager& operator=(const TGDNDManager&);
protected:
TGFrame *fMain;
Atom_t fVersion;
Atom_t *fTypelist, *fDraggerTypes;
Atom_t fDropType;
Atom_t fAcceptedAction, fLocalAction;
Bool_t fDragging;
Bool_t fDropAccepted;
Bool_t fStatusPending;
Bool_t fUseVersion;
Bool_t fProxyOurs;
Window_t fSource, fTarget;
Bool_t fTargetIsDNDAware;
UInt_t fGrabEventMask;
TGFrame *fLocalSource, *fLocalTarget;
TTimer *fDropTimeout;
TGDragWindow *fDragWin;
Pixmap_t fPic, fMask;
Int_t fHotx, fHoty;
Cursor_t fDNDNoDropCursor;
protected:
static Atom_t fgDNDAware, fgDNDSelection, fgDNDProxy;
static Atom_t fgDNDEnter, fgDNDLeave, fgDNDPosition, fgDNDStatus;
static Atom_t fgDNDDrop, fgDNDFinished;
static Atom_t fgDNDVersion;
static Atom_t fgDNDActionCopy, fgDNDActionMove, fgDNDActionLink;
static Atom_t fgDNDActionAsk, fgDNDActionPrivate;
static Atom_t fgDNDTypeList, fgDNDActionList, fgDNDActionDescrip;
static Atom_t fgXCDNDData;
static Bool_t fgInit;
static Atom_t fgXAWMState;
protected:
void InitAtoms();
Window_t GetRootProxy();
Window_t FindWindow(Window_t root, Int_t x, Int_t y, Int_t maxd);
Bool_t IsDNDAware(Window_t win, Atom_t *typelist = 0);
Bool_t IsTopLevel(Window_t win);
void SendDNDEnter(Window_t target);
void SendDNDLeave(Window_t target);
void SendDNDPosition(Window_t target, int x, int y,
Atom_t action, Time_t timestamp);
void SendDNDStatus(Window_t target, Atom_t action);
void SendDNDDrop(Window_t target);
void SendDNDFinished(Window_t src);
Bool_t HandleDNDEnter(Window_t src, long vers, Atom_t dataTypes[3]);
Bool_t HandleDNDLeave(Window_t src);
Bool_t HandleDNDPosition(Window_t src, int x_root, int y_root, Atom_t action, Time_t timestamp);
Bool_t HandleDNDStatus(Window_t from, int accepted,
Rectangle_t skip, Atom_t action);
Bool_t HandleDNDDrop(Window_t src, Time_t timestamp);
Bool_t HandleDNDFinished(Window_t target);
public:
TGDNDManager(TGFrame *toplevel, Atom_t *typelist);
virtual ~TGDNDManager();
Bool_t HandleClientMessage(Event_t *event);
Bool_t HandleSelectionRequest(Event_t *event);
Bool_t HandleSelection(Event_t *event);
Bool_t HandleTimer(TTimer *t);
TGFrame *GetMainFrame() const { return fMain; }
void SetMainFrame(TGFrame *main) { fMain = main; }
void SetDragPixmap(Pixmap_t pic, Pixmap_t mask, Int_t hot_x, Int_t hot_y);
Bool_t SetRootProxy();
Bool_t RemoveRootProxy();
Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root,
Window_t grabWin = kNone);
Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp);
Bool_t Drop();
Bool_t EndDrag();
Bool_t IsDragging() const { return fDragging; }
Window_t GetSource() const { return fSource; }
Window_t GetTarget() const { return fTarget; }
Atom_t *GetTypeList() const { return fTypelist; }
static Atom_t GetDNDAware();
static Atom_t GetDNDSelection();
static Atom_t GetDNDProxy();
static Atom_t GetDNDEnter();
static Atom_t GetDNDLeave();
static Atom_t GetDNDPosition();
static Atom_t GetDNDStatus();
static Atom_t GetDNDDrop();
static Atom_t GetDNDFinished();
static Atom_t GetDNDVersion();
static Atom_t GetDNDActionCopy();
static Atom_t GetDNDActionMove();
static Atom_t GetDNDActionLink();
static Atom_t GetDNDActionAsk();
static Atom_t GetDNDActionPrivate();
static Atom_t GetDNDTypeList();
static Atom_t GetDNDActionList();
static Atom_t GetDNDActionDescrip();
static Atom_t GetXCDNDData();
ClassDef(TGDNDManager, 0)
};
R__EXTERN TGDNDManager *gDNDManager;
#endif // ROOT_TDNDManager