Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGuiBldDragManager.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/guibuilder:$Id$
0002 // Author: Valeriy Onuchin   12/09/04
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, 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_TGuiBldDragManager
0013 #define ROOT_TGuiBldDragManager
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TGuiBldDragManager                                                   //
0019 //                                                                      //
0020 //////////////////////////////////////////////////////////////////////////
0021 
0022 #include "TGFrame.h"
0023 
0024 #include "TVirtualDragManager.h"
0025 
0026 class TTimer;
0027 class TGuiBldDragManagerPimpl;
0028 class TRootGuiBuilder;
0029 class TQUndoManager;
0030 class TGPopupMenu;
0031 class TGuiBldEditor;
0032 class TGColorDialog;
0033 class TGFontDialog;
0034 class TGTextButton;
0035 class TGPictureButton;
0036 class TGCanvas;
0037 class TGComboBox;
0038 class TGLabel;
0039 class TGListBox;
0040 class TGProgressBar;
0041 class TGScrollBar;
0042 class TGTextEntry;
0043 class TGIcon;
0044 
0045 
0046 enum EActionType {
0047    kNoneAct, kPropertyAct, kEditableAct, kReparentAct,
0048    kDropAct, kCutAct, kCopyAct, kPasteAct, kCropAct,
0049    kCompactAct, kCompactGlobalAct, kLayUpAct, kLayDownAct,
0050    kCloneAct, kSaveAct, kSaveFrameAct, kGrabAct, kDeleteAct,
0051    kLeftAct, kRightAct, kUpAct, kDownAct, kEndEditAct, kReplaceAct,
0052    kGridAct, kBreakLayoutAct, kSwitchLayoutAct, kNewAct,
0053    kOpenAct, kLayoutHAct, kLayoutVAct, kUndoAct, kRedoAct,
0054    kSelectAct, kMethodMenuAct, kToggleMenuAct
0055 };
0056 
0057 //////////////////////////////////////////////////////////////////////////
0058 class TGuiBldDragManager : public TVirtualDragManager, public TGFrame {
0059 
0060 friend class TGClient;
0061 friend class TGFrame;
0062 friend class TGMainFrame;
0063 friend class TGGrabRect;
0064 friend class TRootGuiBuilder;
0065 friend class TGuiBldDragManagerRepeatTimer;
0066 friend class TGuiBldMenuDialog;
0067 friend class TGuiBldGeometryFrame;
0068 friend class TGuiBldEditor;
0069 
0070 private:
0071    TGuiBldDragManagerPimpl *fPimpl;    // private data
0072 
0073    TRootGuiBuilder   *fBuilder;        // pointer to gui builder
0074    TGuiBldEditor *fEditor;             // frame property editor
0075    Bool_t         fLassoDrawn;         // kTRUE if  lasso drawn
0076    TString        fPasteFileName;      // paste_clippboard file name
0077    TString        fTmpBuildFile;       // temporary file name
0078    Bool_t         fSelectionIsOn;      // selection with Shift key pressed
0079    TGPopupMenu   *fFrameMenu;          // context menu for frames
0080    TGPopupMenu   *fLassoMenu;          // context menu for lasso drawn
0081    Window_t       fTargetId;           // an id of window where drop
0082    Bool_t         fDropStatus;         // kTRUE if drop was successfull
0083    Bool_t         fStop;               // kTRUE if stopped
0084    TGFrame       *fSelected;           // selected frame. In most cases selected is
0085                                        // the same frame as grabbed frame.
0086    TList         *fListOfDialogs;      // list of dialog methods
0087 
0088    static TGColorDialog *fgGlobalColorDialog;   // color dialog
0089    static TGColorDialog *GetGlobalColorDialog(Bool_t create = kTRUE);
0090 
0091    static TGFontDialog *fgGlobalFontDialog;     // font dialog
0092    static TGFontDialog *GetGlobalFontDialog();  //
0093 
0094 
0095    void           Reset1();
0096    void           DrawGrabRectangles(TGWindow *win = nullptr);
0097    void           DrawGrabRect(Int_t i, Int_t x, Int_t y);
0098    TGCompositeFrame *FindLayoutFrame(TGFrame *f);
0099    Bool_t         IsPointVisible(Int_t x, Int_t y);
0100    Bool_t         IsSelectedVisible();
0101    void           CloseMenus();
0102    Bool_t         IsEditDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisable)); }
0103    Bool_t         IsGrabDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableGrab)); }
0104    Bool_t         IsEventsDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableEvents)); }
0105    Bool_t         IsFixedLayout(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableLayout)); }
0106    Bool_t         IsFixedH(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableHeight)); }
0107    Bool_t         IsFixedW(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableWidth)); }
0108    Bool_t         IsFixedSize(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableResize)); }
0109    Bool_t         CanChangeLayout(TGWindow *w) const;
0110    Bool_t         CanChangeLayoutOrder(TGWindow *w) const;
0111    Bool_t         CanCompact(TGWindow *w) const;
0112 
0113    void           ChangeSelected(TGFrame *f);
0114    TGFrame       *GetEditableParent(TGFrame *f);
0115    TGFrame       *GetMovableParent(TGWindow *p);
0116    TGFrame       *GetBtnEnableParent(TGFrame *fr);
0117    TGWindow      *GetResizableParent(TGWindow *p);
0118    TGFrame       *FindMdiFrame(TGFrame *in);
0119    void           RaiseMdiFrame(TGFrame *in);
0120    Bool_t         CheckTargetAtPoint(Int_t x, Int_t y);
0121    void           AddClassMenuMethods(TGPopupMenu *menu, TObject *object);
0122    void           AddDialogMethods(TGPopupMenu *menu, TObject *object);
0123    void           DeleteMenuDialog();
0124    void           CreateListOfDialogs();
0125 
0126 private:
0127    TGFrame       *InEditable(Window_t id);
0128    void           GrabFrame(TGFrame *frame);
0129    void           UngrabFrame();
0130    void           SetPropertyEditor(TGuiBldEditor *e);
0131    void           DeletePropertyEditor();
0132 
0133    TList         *GetFramesInside(Int_t x0, Int_t y0, Int_t x, Int_t y);
0134    void           ToGrid(Int_t &x, Int_t &y);
0135    void           DoReplace(TGFrame *frame);
0136    void           DeleteFrame(TGFrame *frame);
0137    void           HandleDelete(Bool_t crop = kFALSE);
0138    void           HandleReturn(Bool_t on = kFALSE);
0139    void           HandleAlignment(Int_t to, Bool_t lineup = kFALSE);
0140    void           HandleCut();
0141    void           HandleCopy(Bool_t brk_layout = kTRUE);
0142    void           HandlePaste();
0143    void           HandleReplace();
0144    void           HandleGrid();
0145    void           CloneEditable();
0146    void           DropCanvas(TGCanvas *canvas);
0147    void           PutToCanvas(TGCompositeFrame *cont);
0148    Bool_t         Save(const char *file = "");
0149    Bool_t         SaveFrame(const char *file = nullptr);
0150    void           HandleLayoutOrder(Bool_t forward = kTRUE);
0151    void           DoResize();
0152    void           DoMove();
0153    void           DrawLasso();
0154    void           PlaceFrame(TGFrame*, TGLayoutHints *);
0155    void           ReparentFrames(TGFrame *newfr,
0156                                  TGCompositeFrame *oldfr);
0157    TGCompositeFrame *FindCompositeFrame(Window_t id);
0158    void           SetCursorType(Int_t cur);
0159    void           CheckTargetUnderGrab();
0160    void           HighlightCompositeFrame(Window_t);
0161    void           Compact(Bool_t global = kTRUE);
0162    Bool_t         StartDrag(TGFrame *src, Int_t x, Int_t y) override;
0163    Bool_t         EndDrag() override;
0164    Bool_t         Drop() override;
0165    Bool_t         Cancel(Bool_t delSrc) override;
0166    void           Menu4Frame(TGFrame *, Int_t x, Int_t y);
0167    void           Menu4Lasso(Int_t x, Int_t y);
0168    void           CreatePropertyEditor();
0169    void           DoRedraw() override;
0170    void           SwitchEditable(TGFrame *frame);
0171    void           UnmapAllPopups();
0172    void           BreakLayout();
0173    void           SwitchLayout();
0174 
0175    Bool_t         RecognizeGesture(Event_t *, TGFrame *frame = nullptr);
0176    Bool_t         HandleButtonPress(Event_t *);
0177    Bool_t         HandleButtonRelease(Event_t *);
0178    Bool_t         HandleButton(Event_t *) override;
0179    Bool_t         HandleDoubleClick(Event_t*) override;
0180    Bool_t         HandleMotion(Event_t *) override;
0181    Bool_t         HandleClientMessage(Event_t *) override;
0182    Bool_t         HandleDestroyNotify(Event_t *);
0183    Bool_t         HandleSelection(Event_t *) override;
0184    Bool_t         HandleExpose(Event_t *) override;
0185    Bool_t         HandleConfigureNotify(Event_t *) override;
0186    Bool_t         HandleSelectionRequest(Event_t *) override;
0187    void           HandleButon3Pressed(Event_t *, TGFrame *frame = nullptr);
0188    Bool_t         HandleEvent(Event_t *) override;
0189    Bool_t         HandleTimer(TTimer *) override;
0190 
0191    Bool_t         IsMoveWaiting() const;
0192    Bool_t         IsLassoDrawn() const { return fLassoDrawn; }
0193    void           SetLassoDrawn(Bool_t on);
0194    void           HideGrabRectangles();
0195    Bool_t         IgnoreEvent(Event_t *e) override;
0196    Bool_t         CheckDragResize(Event_t *event);
0197    Bool_t         IsPasteFrameExist();
0198 
0199 public:
0200    TGuiBldDragManager();
0201           ~TGuiBldDragManager() override;
0202 
0203    void           HandleAction(Int_t act);
0204    Bool_t         HandleKey(Event_t *) override;
0205 
0206    TGFrame       *GetTarget() const { return fTarget; }
0207    TGFrame       *GetSelected() const;
0208    void           Snap2Grid();
0209    void           SetGridStep(UInt_t step);
0210    UInt_t         GetGridStep();
0211    void           HandleUpdateSelected(TGFrame *);
0212    Int_t          GetStrartDragX() const override;
0213    Int_t          GetStrartDragY() const override;
0214    Int_t          GetEndDragX() const override;
0215    Int_t          GetEndDragY() const override;
0216 
0217    Bool_t         GetDropStatus() const { return fDropStatus; }
0218    void           SetBuilder(TRootGuiBuilder *b) { fBuilder = b; }
0219 
0220    Bool_t         IsStopped() const { return fStop; }
0221    void           SetEditable(Bool_t on = kTRUE) override;
0222    void           SelectFrame(TGFrame *frame, Bool_t add = kFALSE);
0223 
0224    static void    MapGlobalDialog(TGMainFrame *dialog, TGFrame *fr);
0225 
0226    Bool_t         HandleTimerEvent(Event_t *ev, TTimer *t) override;
0227    void           TimerEvent(Event_t *ev)
0228                      { Emit("TimerEvent(Event_t*)", (Longptr_t)ev); } // *SIGNAL*
0229 
0230    // hadndling dynamic context menus
0231    void DoClassMenu(Int_t);
0232    void DoDialogOK();
0233    void DoDialogApply();
0234    void DoDialogCancel();
0235 
0236    void ChangeProperties(TGLabel *);         //*MENU* *DIALOG*icon=bld_fontselect.png*
0237    void ChangeProperties(TGTextButton *);    //*MENU* *DIALOG*icon=bld_fontselect.png*
0238 
0239    void ChangeTextFont(TGGroupFrame *);      //*MENU* *DIALOG*icon=bld_fontselect.png*
0240    void ChangeTextFont(TGTextEntry *);       //*MENU* *DIALOG*icon=bld_fontselect.png*
0241 
0242    void ChangePicture(TGPictureButton *);    //*MENU* *DIALOG*icon=bld_open.png*
0243    void ChangeImage(TGIcon *);               //*MENU* *DIALOG*icon=bld_open.png*
0244 
0245    void ChangeBarColor(TGProgressBar *);     //*MENU* *DIALOG*icon=bld_colorselect.png*
0246 
0247    void ChangeTextColor(TGGroupFrame *);     //*MENU* *DIALOG*icon=bld_colorselect.png*
0248    void ChangeTextColor(TGLabel *);          //*MENU* *DIALOG*icon=bld_colorselect.png*
0249    void ChangeTextColor(TGTextButton *);     //*MENU* *DIALOG*icon=bld_colorselect.png*
0250    void ChangeTextColor(TGProgressBar *);    //*MENU* *DIALOG*icon=bld_colorselect.png*
0251    void ChangeTextColor(TGTextEntry *);      //*MENU* *DIALOG*icon=bld_colorselect.png*
0252 
0253    void ChangeBackgroundColor(TGListBox *);  //*MENU* *DIALOG*icon=bld_colorselect.png*
0254    void ChangeBackgroundColor(TGCanvas *);   //*MENU* *DIALOG*icon=bld_colorselect.png*
0255    void ChangeBackgroundColor(TGComboBox *); //*MENU* *DIALOG*icon=bld_colorselect.png*
0256    void ChangeBackgroundColor(TGFrame *);             //*MENU* *DIALOG*icon=bld_colorselect.png*
0257    void ChangeBackgroundColor(TGCompositeFrame *);    //*MENU* *DIALOG*icon=bld_colorselect.png*
0258 
0259    ClassDefOverride(TGuiBldDragManager,0)  // drag and drop manager
0260 };
0261 
0262 
0263 #endif