Back to home page

EIC code displayed by LXR

 
 

    


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 // @(#)root/gui:$Id$
0002 // Author: Bertrand Bellenot   19/04/07
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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; // Default Cursor
0026 
0027 protected:
0028    void DoRedraw() override;
0029 
0030    Window_t fInput;                 ///< Input Window
0031    Pixmap_t fPic, fMask;            ///< Pixmaps used as Window shape
0032    UInt_t   fPw, fPh;               ///< Hot point coordinates (x and y)
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) // Window used for dragging
0053 };
0054 
0055 
0056 /** \class TDNDData
0057     \ingroup guiwidgets
0058 
0059 Drag and drop data container.
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;       ///< Data type description
0075    Atom_t    fAction;         ///< Action description
0076    void     *fData;           ///< Actual data
0077    Int_t     fDataLength;     ///< Length of data
0078 
0079    ClassDefOverride(TDNDData, 0) // Drag and drop specific data
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;                         ///< pointer on TGMainFrame
0091    Atom_t         fVersion;                      ///< not really an Atom, but a long
0092    Atom_t        *fTypelist, *fDraggerTypes;     ///< lists of DND types
0093    Atom_t         fDropType;                     ///< drop type
0094    Atom_t         fAcceptedAction, fLocalAction; ///< accepted and local actions
0095 
0096    Bool_t         fDragging;                     ///< kTRUE while dragging
0097    Bool_t         fDropAccepted;                 ///< kTRUE if drop accepted
0098    Bool_t         fStatusPending;                ///< kTRUE if status is pending
0099    Bool_t         fUseVersion;                   ///< kTRUE if DND version is used
0100    Bool_t         fProxyOurs;                    ///< kTRUE if root proxy is ours
0101    Window_t       fSource, fTarget;              ///< source and target windows
0102    Bool_t         fTargetIsDNDAware;             ///< kTRUE if target is DND aware
0103    UInt_t         fGrabEventMask;                ///< pointer grab event mask
0104    TGFrame       *fLocalSource, *fLocalTarget;   ///< local source and target
0105 
0106    TTimer        *fDropTimeout;                  ///< drop timeout
0107    TGDragWindow  *fDragWin;                      ///< drag window
0108 
0109    Pixmap_t       fPic, fMask;                   ///< pixmap used for the drag window
0110    Int_t          fHotx, fHoty;                  ///< hot point coordinates
0111    Cursor_t       fDNDNoDropCursor;              ///< no drop cursor type
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   //--- called by widgets
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) // The main Drag and Drop Manager
0199 };
0200 
0201 R__EXTERN TGDNDManager *gDNDManager; // global drag and drop manager
0202 
0203 #endif  // ROOT_TGDNDManager
0204