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
22class TGDragWindow : public TGFrame {
23
24protected:
25 static Cursor_t fgDefaultCursor; // Default Cursor
26
27protected:
28 void DoRedraw() override;
29
30 Window_t fInput; ///< Input Window
31 Pixmap_t fPic, fMask; ///< Pixmaps used as Window shape
32 UInt_t fPw, fPh; ///< Hot point coordinates (x and y)
33
34public:
36 UInt_t options = kChildFrame, Pixel_t back = GetWhitePixel());
37 ~TGDragWindow() override;
38
39 TGDimension GetDefaultSize() const override { return TGDimension(fPw, fPh); }
40
41 void MapWindow() override;
42 void UnmapWindow() override;
43 void RaiseWindow() override;
44 void LowerWindow() override;
45 void MapRaised() override;
46
47 void Layout() override;
48
49 Window_t GetInputId() const { return fInput; }
50 Bool_t HasWindow(Window_t w) const { return (w == fId || w == fInput); }
51
52 ClassDefOverride(TGDragWindow, 0) // Window used for dragging
53};
54
55
56/** \class TDNDData
57 \ingroup guiwidgets
58
59Drag and drop data container.
60
61*/
62
63
64class TDNDData : public TObject {
65private:
66 TDNDData(const TDNDData&) = delete;
67 TDNDData& operator=(const TDNDData&) = delete;
68
69public:
70 TDNDData(Atom_t dt = kNone, void *d = nullptr, Int_t len = 0, Atom_t act = kNone) :
71 fDataType(dt), fAction(act), fData(d), fDataLength(len) {}
72 ~TDNDData() override {}
73
74 Atom_t fDataType; ///< Data type description
75 Atom_t fAction; ///< Action description
76 void *fData; ///< Actual data
77 Int_t fDataLength; ///< Length of data
78
79 ClassDefOverride(TDNDData, 0) // Drag and drop specific data
80};
81
82
83class TGDNDManager : public TObject {
84
85private:
86 TGDNDManager(const TGDNDManager&) = delete;
88
89protected:
90 TGFrame *fMain; ///< pointer on TGMainFrame
91 Atom_t fVersion; ///< not really an Atom, but a long
92 Atom_t *fTypelist, *fDraggerTypes; ///< lists of DND types
93 Atom_t fDropType; ///< drop type
94 Atom_t fAcceptedAction, fLocalAction; ///< accepted and local actions
95
96 Bool_t fDragging; ///< kTRUE while dragging
97 Bool_t fDropAccepted; ///< kTRUE if drop accepted
98 Bool_t fStatusPending; ///< kTRUE if status is pending
99 Bool_t fUseVersion; ///< kTRUE if DND version is used
100 Bool_t fProxyOurs; ///< kTRUE if root proxy is ours
101 Window_t fSource, fTarget; ///< source and target windows
102 Bool_t fTargetIsDNDAware; ///< kTRUE if target is DND aware
103 UInt_t fGrabEventMask; ///< pointer grab event mask
104 TGFrame *fLocalSource, *fLocalTarget; ///< local source and target
105
106 TTimer *fDropTimeout; ///< drop timeout
107 TGDragWindow *fDragWin; ///< drag window
108
109 Pixmap_t fPic, fMask; ///< pixmap used for the drag window
110 Int_t fHotx, fHoty; ///< hot point coordinates
111 Cursor_t fDNDNoDropCursor; ///< no drop cursor type
112
113protected:
122
125
126protected:
127 void InitAtoms();
132
135 void SendDNDPosition(Window_t target, int x, int y,
136 Atom_t action, Time_t timestamp);
137 void SendDNDStatus(Window_t target, Atom_t action);
140
141 Bool_t HandleDNDEnter(Window_t src, long vers, Atom_t dataTypes[3]);
143 Bool_t HandleDNDPosition(Window_t src, int x_root, int y_root, Atom_t action, Time_t timestamp);
144 Bool_t HandleDNDStatus(Window_t from, int accepted,
145 Rectangle_t skip, Atom_t action);
148
149public:
150 TGDNDManager(TGFrame *toplevel, Atom_t *typelist);
151 ~TGDNDManager() override;
152
156
157 Bool_t HandleTimer(TTimer *t) override;
158
159 //--- called by widgets
160
161 TGFrame *GetMainFrame() const { return fMain; }
163 void SetDragPixmap(Pixmap_t pic, Pixmap_t mask, Int_t hot_x, Int_t hot_y);
166
167 Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root,
168 Window_t grabWin = kNone);
169 Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp);
170 Bool_t Drop();
171 Bool_t EndDrag();
172
173 Bool_t IsDragging() const { return fDragging; }
174 Window_t GetSource() const { return fSource; }
175 Window_t GetTarget() const { return fTarget; }
176 Atom_t *GetTypeList() const { return fTypelist; }
177
178 static Atom_t GetDNDAware();
179 static Atom_t GetDNDSelection();
180 static Atom_t GetDNDProxy();
181 static Atom_t GetDNDEnter();
182 static Atom_t GetDNDLeave();
183 static Atom_t GetDNDPosition();
184 static Atom_t GetDNDStatus();
185 static Atom_t GetDNDDrop();
186 static Atom_t GetDNDFinished();
187 static Atom_t GetDNDVersion();
188 static Atom_t GetDNDActionCopy();
189 static Atom_t GetDNDActionMove();
190 static Atom_t GetDNDActionLink();
191 static Atom_t GetDNDActionAsk();
193 static Atom_t GetDNDTypeList();
194 static Atom_t GetDNDActionList();
196 static Atom_t GetXCDNDData();
197
198 ClassDefOverride(TGDNDManager, 0) // The main Drag and Drop Manager
199};
200
201R__EXTERN TGDNDManager *gDNDManager; // global drag and drop manager
202
203#endif // ROOT_TGDNDManager
204
#define R__EXTERN
Definition DllImport.h:26
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
ULong_t Time_t
Event time.
Definition GuiTypes.h:42
@ kChildFrame
Definition GuiTypes.h:379
Handle_t Cursor_t
Cursor handle.
Definition GuiTypes.h:34
const Handle_t kNone
Definition GuiTypes.h:88
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
int main()
Definition Prototype.cxx:12
#define d(i)
Definition RSha256.hxx:102
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
R__EXTERN TGDNDManager * gDNDManager
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t Atom_t typelist
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Drag and drop data container.
TDNDData & operator=(const TDNDData &)=delete
TDNDData(Atom_t dt=kNone, void *d=nullptr, Int_t len=0, Atom_t act=kNone)
Atom_t fDataType
Data type description.
Int_t fDataLength
Length of data.
void * fData
Actual data.
Atom_t fAction
Action description.
TDNDData(const TDNDData &)=delete
~TDNDData() override
static Atom_t fgDNDAware
static Atom_t fgDNDVersion
Bool_t HandleDNDEnter(Window_t src, long vers, Atom_t dataTypes[3])
Handle DND enter event.
static Atom_t fgDNDActionPrivate
Window_t fSource
static Atom_t fgDNDActionAsk
static Atom_t GetDNDDrop()
static Atom_t GetDNDActionAsk()
TGFrame * fMain
pointer on TGMainFrame
static Atom_t fgDNDActionMove
Pixmap_t fMask
pixmap used for the drag window
Bool_t HandleSelectionRequest(Event_t *event)
Handle selection request event.
static Atom_t fgDNDActionLink
Int_t fHoty
hot point coordinates
Bool_t HandleClientMessage(Event_t *event)
Handle DND related client messages.
TTimer * fDropTimeout
drop timeout
static Atom_t fgDNDActionDescrip
void SendDNDEnter(Window_t target)
Send DND enter message to target window.
static Atom_t fgDNDSelection
Bool_t fTargetIsDNDAware
kTRUE if target is DND aware
Bool_t fStatusPending
kTRUE if status is pending
TGDNDManager(const TGDNDManager &)=delete
Window_t GetTarget() const
void InitAtoms()
Initialize drag and drop atoms.
static Atom_t fgDNDFinished
Atom_t fDropType
drop type
static Atom_t fgDNDDrop
static Atom_t GetXCDNDData()
static Atom_t GetDNDVersion()
Bool_t fProxyOurs
kTRUE if root proxy is ours
static Atom_t GetDNDActionLink()
static Atom_t fgDNDEnter
Bool_t HandleDNDDrop(Window_t src, Time_t timestamp)
Handle DND drop event.
static Atom_t GetDNDStatus()
Atom_t * fDraggerTypes
lists of DND types
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
accepted and local actions
Bool_t IsDragging() const
TGFrame * fLocalSource
static Atom_t GetDNDTypeList()
static Bool_t fgInit
Window_t GetSource() const
~TGDNDManager() override
TGDNDManager destructor.
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
kTRUE if DND version is used
void SendDNDStatus(Window_t target, Atom_t action)
Send DND status message to source window.
Bool_t IsDNDAware(Window_t win, Atom_t *typelist=nullptr)
Check if window win is DND aware.
Bool_t fDragging
kTRUE while dragging
static Atom_t GetDNDAware()
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
pointer grab event mask
Bool_t fDropAccepted
kTRUE if drop accepted
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
not really an Atom, but a long
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
no drop cursor type
Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp)
Process drag event.
TGFrame * fLocalTarget
local source and target
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
source and target windows
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
drag window
Atom_t * fTypelist
Bool_t Drop()
Drop.
TGFrame * GetMainFrame() const
Bool_t SetRootProxy()
Set root window proxy.
static Atom_t GetDNDActionCopy()
Bool_t HandleTimer(TTimer *t) override
Handle Drop timeout.
Bool_t EndDrag()
End dragging.
static Atom_t GetDNDActionMove()
static Atom_t GetDNDLeave()
Window used as drag icon during drag and drop operations.
void MapWindow() override
Map TGDragWindow.
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Bool_t HasWindow(Window_t w) const
void LowerWindow() override
Lower TGDragWindow.
~TGDragWindow() override
TGDragWindow destructor.
void UnmapWindow() override
Unmap TGDragWindow.
void DoRedraw() override
Redraw TGDragWindow.
Window_t GetInputId() const
void RaiseWindow() override
Raise TGDragWindow.
void Layout() override
Layout TGDragWindow.
Window_t fInput
Input Window.
void MapRaised() override
Map and Raise TGDragWindow.
Pixmap_t fMask
Pixmaps used as Window shape.
Pixmap_t fPic
UInt_t fPh
Hot point coordinates (x and y)
static Cursor_t fgDefaultCursor
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:709
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:397
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
ROOT GUI Window base class.
Definition TGWindow.h:23
Mother of all ROOT objects.
Definition TObject.h:41
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
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