Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGDNDManager.h
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Bertrand Bellenot 19/04/07
3
4/*************************************************************************
5 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TGDNDManager
13#define ROOT_TGDNDManager
14
15#include "TGFrame.h"
16
17class TGMainFrame;
18class TGDragWindow;
19class TTimer;
20
21//----------------------------------------------------------------------
22
23class TGDragWindow : public TGFrame {
24
25protected:
26 static Cursor_t fgDefaultCursor; // Default Cursor
27
28protected:
29 virtual void DoRedraw();
30
31 Window_t fInput; // Input Window
32 Pixmap_t fPic, fMask; // Pixmaps used as Window shape
33 UInt_t fPw, fPh; // Hot point coordinates (x and y)
34
35public:
36 TGDragWindow(const TGWindow *p, Pixmap_t pic, Pixmap_t mask,
37 UInt_t options = kChildFrame, Pixel_t back = GetWhitePixel());
38 virtual ~TGDragWindow();
39
40 virtual TGDimension GetDefaultSize() const { return TGDimension(fPw, fPh); }
41
42 virtual void MapWindow();
43 virtual void UnmapWindow();
44 virtual void RaiseWindow();
45 virtual void LowerWindow();
46 virtual void MapRaised();
47
48 virtual void Layout();
49
50 Window_t GetInputId() const { return fInput; }
51 Bool_t HasWindow(Window_t w) const { return (w == fId || w == fInput); }
52
53 ClassDef(TGDragWindow, 0) // Window used for dragging
54};
55
56//----------------------------------------------------------------------
57
58//_____________________________________________________________________________
59//
60// TDNDData
61//
62// Drag and drop data container.
63//_____________________________________________________________________________
64
65class TDNDData : public TObject {
66private:
67 TDNDData(const TDNDData&) = delete;
68 TDNDData& operator=(const TDNDData&) = delete;
69
70public:
71 TDNDData(Atom_t dt = kNone, void *d = nullptr, Int_t len = 0, Atom_t act = kNone) :
72 fDataType(dt), fAction(act), fData(d), fDataLength(len) {}
74
75 Atom_t fDataType; // Data type description
76 Atom_t fAction; // Action description
77 void *fData; // Actual data
78 Int_t fDataLength; // Length of data
79
80 ClassDef(TDNDData, 0) // Drag and drop specific data
81};
82
83//----------------------------------------------------------------------
84
85class TGDNDManager : public TObject {
86
87private:
88 TGDNDManager(const TGDNDManager&) = delete;
90
91protected:
92 TGFrame *fMain; // pointer on TGMainFrame
93 Atom_t fVersion; // not really an Atom, but a long
94 Atom_t *fTypelist, *fDraggerTypes; // lists of DND types
95 Atom_t fDropType; // drop type
96 Atom_t fAcceptedAction, fLocalAction; // accepted and local actions
97
98 Bool_t fDragging; // kTRUE while dragging
99 Bool_t fDropAccepted; // kTRUE if drop accepted
100 Bool_t fStatusPending; // kTRUE if status is pending
101 Bool_t fUseVersion; // kTRUE if DND version is used
102 Bool_t fProxyOurs; // kTRUE if root proxy is ours
103 Window_t fSource, fTarget; // source and target windows
104 Bool_t fTargetIsDNDAware; // kTRUE if target is DND aware
105 UInt_t fGrabEventMask; // pointer grab event mask
106 TGFrame *fLocalSource, *fLocalTarget; // local source and target
107
108 TTimer *fDropTimeout; // drop timeout
109 TGDragWindow *fDragWin; // drag window
110
111 Pixmap_t fPic, fMask; // pixmap used for the drag window
112 Int_t fHotx, fHoty; // hot point coordinates
113 Cursor_t fDNDNoDropCursor; // no drop cursor type
114
115protected:
124
127
128protected:
129 void InitAtoms();
132 Bool_t IsDNDAware(Window_t win, Atom_t *typelist = 0);
134
135 void SendDNDEnter(Window_t target);
136 void SendDNDLeave(Window_t target);
137 void SendDNDPosition(Window_t target, int x, int y,
138 Atom_t action, Time_t timestamp);
139 void SendDNDStatus(Window_t target, Atom_t action);
140 void SendDNDDrop(Window_t target);
141 void SendDNDFinished(Window_t src);
142
143 Bool_t HandleDNDEnter(Window_t src, long vers, Atom_t dataTypes[3]);
145 Bool_t HandleDNDPosition(Window_t src, int x_root, int y_root, Atom_t action, Time_t timestamp);
146 Bool_t HandleDNDStatus(Window_t from, int accepted,
147 Rectangle_t skip, Atom_t action);
148 Bool_t HandleDNDDrop(Window_t src, Time_t timestamp);
150
151public:
152 TGDNDManager(TGFrame *toplevel, Atom_t *typelist);
153 virtual ~TGDNDManager();
154
158
160
161 //--- called by widgets
162
163 TGFrame *GetMainFrame() const { return fMain; }
165 void SetDragPixmap(Pixmap_t pic, Pixmap_t mask, Int_t hot_x, Int_t hot_y);
168
169 Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root,
170 Window_t grabWin = kNone);
171 Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp);
172 Bool_t Drop();
173 Bool_t EndDrag();
174
175 Bool_t IsDragging() const { return fDragging; }
176 Window_t GetSource() const { return fSource; }
177 Window_t GetTarget() const { return fTarget; }
178 Atom_t *GetTypeList() const { return fTypelist; }
179
180 static Atom_t GetDNDAware();
181 static Atom_t GetDNDSelection();
182 static Atom_t GetDNDProxy();
183 static Atom_t GetDNDEnter();
184 static Atom_t GetDNDLeave();
185 static Atom_t GetDNDPosition();
186 static Atom_t GetDNDStatus();
187 static Atom_t GetDNDDrop();
188 static Atom_t GetDNDFinished();
189 static Atom_t GetDNDVersion();
190 static Atom_t GetDNDActionCopy();
191 static Atom_t GetDNDActionMove();
192 static Atom_t GetDNDActionLink();
193 static Atom_t GetDNDActionAsk();
195 static Atom_t GetDNDTypeList();
196 static Atom_t GetDNDActionList();
198 static Atom_t GetXCDNDData();
199
200 ClassDef(TGDNDManager, 0) // The main Drag and Drop Manager
201};
202
203R__EXTERN TGDNDManager *gDNDManager; // global drag and drop manager
204
205#endif // ROOT_TGDNDManager
206
#define R__EXTERN
Definition DllImport.h:27
Handle_t Cursor_t
Cursor handle.
Definition GuiTypes.h:34
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
ULong_t Time_t
Event time.
Definition GuiTypes.h:42
@ kChildFrame
Definition GuiTypes.h:379
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
const Handle_t kNone
Definition GuiTypes.h:88
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
#define d(i)
Definition RSha256.hxx:102
int Int_t
Definition RtypesCore.h:45
bool Bool_t
Definition RtypesCore.h:63
#define ClassDef(name, id)
Definition Rtypes.h:325
R__EXTERN TGDNDManager * gDNDManager
TDNDData & operator=(const TDNDData &)=delete
TDNDData(Atom_t dt=kNone, void *d=nullptr, Int_t len=0, Atom_t act=kNone)
Atom_t fDataType
Int_t fDataLength
void * fData
Atom_t fAction
TDNDData(const TDNDData &)=delete
static Atom_t fgDNDAware
static Atom_t fgDNDVersion
Bool_t HandleDNDEnter(Window_t src, long vers, Atom_t dataTypes[3])
Handle DND enter event.
virtual ~TGDNDManager()
TGDNDManager destructor.
static Atom_t fgDNDActionPrivate
Window_t fSource
static Atom_t fgDNDActionAsk
static Atom_t GetDNDDrop()
static Atom_t GetDNDActionAsk()
TGFrame * fMain
static Atom_t fgDNDActionMove
Pixmap_t fMask
Bool_t HandleSelectionRequest(Event_t *event)
Handle selection request event.
static Atom_t fgDNDActionLink
Bool_t HandleClientMessage(Event_t *event)
Handle DND related client messages.
TTimer * fDropTimeout
static Atom_t fgDNDActionDescrip
void SendDNDEnter(Window_t target)
Send DND enter message to target window.
static Atom_t fgDNDSelection
Bool_t fTargetIsDNDAware
Bool_t fStatusPending
TGDNDManager(const TGDNDManager &)=delete
Window_t GetTarget() const
void InitAtoms()
Initialize drag and drop atoms.
static Atom_t fgDNDFinished
Atom_t fDropType
static Atom_t fgDNDDrop
static Atom_t GetXCDNDData()
static Atom_t GetDNDVersion()
Bool_t fProxyOurs
static Atom_t GetDNDActionLink()
static Atom_t fgDNDEnter
Bool_t HandleTimer(TTimer *t)
Handle Drop timeout.
Bool_t HandleDNDDrop(Window_t src, Time_t timestamp)
Handle DND drop event.
static Atom_t GetDNDStatus()
Atom_t * fDraggerTypes
static Atom_t fgXCDNDData
Bool_t HandleDNDFinished(Window_t target)
Handle DND finished event.
static Atom_t fgDNDPosition
Atom_t * GetTypeList() const
static Atom_t fgDNDLeave
Bool_t HandleSelection(Event_t *event)
Handle selection event.
Atom_t fLocalAction
Bool_t IsDragging() const
TGFrame * fLocalSource
static Atom_t GetDNDTypeList()
static Bool_t fgInit
Window_t GetSource() const
Window_t GetRootProxy()
Get root window proxy.
Bool_t HandleDNDStatus(Window_t from, int accepted, Rectangle_t skip, Atom_t action)
Handle DND status event.
void SetMainFrame(TGFrame *main)
static Atom_t fgDNDActionCopy
static Atom_t GetDNDProxy()
static Atom_t fgDNDProxy
TGDNDManager & operator=(const TGDNDManager &)=delete
static Atom_t GetDNDActionDescrip()
Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root, Window_t grabWin=kNone)
Start dragging.
Bool_t fUseVersion
void SendDNDStatus(Window_t target, Atom_t action)
Send DND status message to source window.
Bool_t fDragging
static Atom_t GetDNDAware()
Bool_t IsDNDAware(Window_t win, Atom_t *typelist=0)
Check if window win is DND aware.
void SetDragPixmap(Pixmap_t pic, Pixmap_t mask, Int_t hot_x, Int_t hot_y)
Set drag window pixmaps and hotpoint.
Bool_t IsTopLevel(Window_t win)
static Atom_t GetDNDFinished()
static Atom_t GetDNDSelection()
static Atom_t fgDNDActionList
UInt_t fGrabEventMask
Bool_t fDropAccepted
static Atom_t GetDNDActionList()
Window_t FindWindow(Window_t root, Int_t x, Int_t y, Int_t maxd)
Search for DND aware window at position x,y.
static Atom_t fgDNDTypeList
Atom_t fVersion
Bool_t RemoveRootProxy()
Remove root window proxy.
static Atom_t GetDNDEnter()
Bool_t HandleDNDPosition(Window_t src, int x_root, int y_root, Atom_t action, Time_t timestamp)
Handle DND position event.
static Atom_t fgXAWMState
Pixmap_t fPic
void SendDNDPosition(Window_t target, int x, int y, Atom_t action, Time_t timestamp)
Send DND position message to target window.
void SendDNDFinished(Window_t src)
Send DND finished message to source window.
Cursor_t fDNDNoDropCursor
Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp)
Process drag event.
TGFrame * fLocalTarget
void SendDNDDrop(Window_t target)
Send DND drop message to target window.
static Atom_t GetDNDPosition()
static Atom_t GetDNDActionPrivate()
static Atom_t fgDNDStatus
Window_t fTarget
Bool_t HandleDNDLeave(Window_t src)
Handle DND leave event.
Atom_t fAcceptedAction
void SendDNDLeave(Window_t target)
Send DND leave message to target window.
TGDragWindow * fDragWin
Atom_t * fTypelist
Bool_t Drop()
Drop.
TGFrame * GetMainFrame() const
Bool_t SetRootProxy()
Set root window proxy.
static Atom_t GetDNDActionCopy()
Bool_t EndDrag()
End dragging.
static Atom_t GetDNDActionMove()
static Atom_t GetDNDLeave()
virtual ~TGDragWindow()
TGDragWindow destructor.
virtual void DoRedraw()
Redraw TGDragWindow.
virtual void MapRaised()
Map and Raise TGDragWindow.
virtual void Layout()
Layout TGDragWindow.
virtual void RaiseWindow()
Raise TGDragWindow.
virtual void UnmapWindow()
Unmap TGDragWindow.
Bool_t HasWindow(Window_t w) const
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Window_t GetInputId() const
virtual void LowerWindow()
Lower TGDragWindow.
Window_t fInput
Pixmap_t fMask
Pixmap_t fPic
static Cursor_t fgDefaultCursor
virtual void MapWindow()
Map TGDragWindow.
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:694
Handle_t fId
Definition TGObject.h:36
Mother of all ROOT objects.
Definition TObject.h:37
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
int main()
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
Rectangle structure (maps to the X11 XRectangle structure)
Definition GuiTypes.h:361