Warning, file /include/root/TGDNDManager.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGDNDManager
0013 #define ROOT_TGDNDManager
0014
0015 #include "TGFrame.h"
0016
0017 class TGMainFrame;
0018 class TGDragWindow;
0019 class TTimer;
0020
0021
0022 class TGDragWindow : public TGFrame {
0023
0024 protected:
0025 static Cursor_t fgDefaultCursor;
0026
0027 protected:
0028 void DoRedraw() override;
0029
0030 Window_t fInput;
0031 Pixmap_t fPic, fMask;
0032 UInt_t fPw, fPh;
0033
0034 public:
0035 TGDragWindow(const TGWindow *p, Pixmap_t pic, Pixmap_t mask,
0036 UInt_t options = kChildFrame, Pixel_t back = GetWhitePixel());
0037 ~TGDragWindow() override;
0038
0039 TGDimension GetDefaultSize() const override { return TGDimension(fPw, fPh); }
0040
0041 void MapWindow() override;
0042 void UnmapWindow() override;
0043 void RaiseWindow() override;
0044 void LowerWindow() override;
0045 void MapRaised() override;
0046
0047 void Layout() override;
0048
0049 Window_t GetInputId() const { return fInput; }
0050 Bool_t HasWindow(Window_t w) const { return (w == fId || w == fInput); }
0051
0052 ClassDefOverride(TGDragWindow, 0)
0053 };
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 class TDNDData : public TObject {
0065 private:
0066 TDNDData(const TDNDData&) = delete;
0067 TDNDData& operator=(const TDNDData&) = delete;
0068
0069 public:
0070 TDNDData(Atom_t dt = kNone, void *d = nullptr, Int_t len = 0, Atom_t act = kNone) :
0071 fDataType(dt), fAction(act), fData(d), fDataLength(len) {}
0072 ~TDNDData() override {}
0073
0074 Atom_t fDataType;
0075 Atom_t fAction;
0076 void *fData;
0077 Int_t fDataLength;
0078
0079 ClassDefOverride(TDNDData, 0)
0080 };
0081
0082
0083 class TGDNDManager : public TObject {
0084
0085 private:
0086 TGDNDManager(const TGDNDManager&) = delete;
0087 TGDNDManager& operator=(const TGDNDManager&) = delete;
0088
0089 protected:
0090 TGFrame *fMain;
0091 Atom_t fVersion;
0092 Atom_t *fTypelist, *fDraggerTypes;
0093 Atom_t fDropType;
0094 Atom_t fAcceptedAction, fLocalAction;
0095
0096 Bool_t fDragging;
0097 Bool_t fDropAccepted;
0098 Bool_t fStatusPending;
0099 Bool_t fUseVersion;
0100 Bool_t fProxyOurs;
0101 Window_t fSource, fTarget;
0102 Bool_t fTargetIsDNDAware;
0103 UInt_t fGrabEventMask;
0104 TGFrame *fLocalSource, *fLocalTarget;
0105
0106 TTimer *fDropTimeout;
0107 TGDragWindow *fDragWin;
0108
0109 Pixmap_t fPic, fMask;
0110 Int_t fHotx, fHoty;
0111 Cursor_t fDNDNoDropCursor;
0112
0113 protected:
0114 static Atom_t fgDNDAware, fgDNDSelection, fgDNDProxy;
0115 static Atom_t fgDNDEnter, fgDNDLeave, fgDNDPosition, fgDNDStatus;
0116 static Atom_t fgDNDDrop, fgDNDFinished;
0117 static Atom_t fgDNDVersion;
0118 static Atom_t fgDNDActionCopy, fgDNDActionMove, fgDNDActionLink;
0119 static Atom_t fgDNDActionAsk, fgDNDActionPrivate;
0120 static Atom_t fgDNDTypeList, fgDNDActionList, fgDNDActionDescrip;
0121 static Atom_t fgXCDNDData;
0122
0123 static Bool_t fgInit;
0124 static Atom_t fgXAWMState;
0125
0126 protected:
0127 void InitAtoms();
0128 Window_t GetRootProxy();
0129 Window_t FindWindow(Window_t root, Int_t x, Int_t y, Int_t maxd);
0130 Bool_t IsDNDAware(Window_t win, Atom_t *typelist = nullptr);
0131 Bool_t IsTopLevel(Window_t win);
0132
0133 void SendDNDEnter(Window_t target);
0134 void SendDNDLeave(Window_t target);
0135 void SendDNDPosition(Window_t target, int x, int y,
0136 Atom_t action, Time_t timestamp);
0137 void SendDNDStatus(Window_t target, Atom_t action);
0138 void SendDNDDrop(Window_t target);
0139 void SendDNDFinished(Window_t src);
0140
0141 Bool_t HandleDNDEnter(Window_t src, long vers, Atom_t dataTypes[3]);
0142 Bool_t HandleDNDLeave(Window_t src);
0143 Bool_t HandleDNDPosition(Window_t src, int x_root, int y_root, Atom_t action, Time_t timestamp);
0144 Bool_t HandleDNDStatus(Window_t from, int accepted,
0145 Rectangle_t skip, Atom_t action);
0146 Bool_t HandleDNDDrop(Window_t src, Time_t timestamp);
0147 Bool_t HandleDNDFinished(Window_t target);
0148
0149 public:
0150 TGDNDManager(TGFrame *toplevel, Atom_t *typelist);
0151 ~TGDNDManager() override;
0152
0153 Bool_t HandleClientMessage(Event_t *event);
0154 Bool_t HandleSelectionRequest(Event_t *event);
0155 Bool_t HandleSelection(Event_t *event);
0156
0157 Bool_t HandleTimer(TTimer *t) override;
0158
0159
0160
0161 TGFrame *GetMainFrame() const { return fMain; }
0162 void SetMainFrame(TGFrame *main) { fMain = main; }
0163 void SetDragPixmap(Pixmap_t pic, Pixmap_t mask, Int_t hot_x, Int_t hot_y);
0164 Bool_t SetRootProxy();
0165 Bool_t RemoveRootProxy();
0166
0167 Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root,
0168 Window_t grabWin = kNone);
0169 Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp);
0170 Bool_t Drop();
0171 Bool_t EndDrag();
0172
0173 Bool_t IsDragging() const { return fDragging; }
0174 Window_t GetSource() const { return fSource; }
0175 Window_t GetTarget() const { return fTarget; }
0176 Atom_t *GetTypeList() const { return fTypelist; }
0177
0178 static Atom_t GetDNDAware();
0179 static Atom_t GetDNDSelection();
0180 static Atom_t GetDNDProxy();
0181 static Atom_t GetDNDEnter();
0182 static Atom_t GetDNDLeave();
0183 static Atom_t GetDNDPosition();
0184 static Atom_t GetDNDStatus();
0185 static Atom_t GetDNDDrop();
0186 static Atom_t GetDNDFinished();
0187 static Atom_t GetDNDVersion();
0188 static Atom_t GetDNDActionCopy();
0189 static Atom_t GetDNDActionMove();
0190 static Atom_t GetDNDActionLink();
0191 static Atom_t GetDNDActionAsk();
0192 static Atom_t GetDNDActionPrivate();
0193 static Atom_t GetDNDTypeList();
0194 static Atom_t GetDNDActionList();
0195 static Atom_t GetDNDActionDescrip();
0196 static Atom_t GetXCDNDData();
0197
0198 ClassDefOverride(TGDNDManager, 0)
0199 };
0200
0201 R__EXTERN TGDNDManager *gDNDManager;
0202
0203 #endif
0204