TGuiBldDragManager.h

Go to the documentation of this file.
00001 // @(#)root/guibuilder:$Id: TGuiBldDragManager.h 30063 2009-09-08 12:15:59Z bellenot $
00002 // Author: Valeriy Onuchin   12/09/04
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGuiBldDragManager
00013 #define ROOT_TGuiBldDragManager
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGuiBldDragManager                                                   //
00019 //                                                                      //
00020 //////////////////////////////////////////////////////////////////////////
00021 
00022 #ifndef ROOT_TGFrame
00023 #include "TGFrame.h"
00024 #endif
00025 
00026 #ifndef ROOT_TVirtualDragManager
00027 #include "TVirtualDragManager.h"
00028 #endif
00029 
00030 class TTimer;
00031 class TGuiBldDragManagerPimpl;
00032 class TRootGuiBuilder;
00033 class TQUndoManager;
00034 class TGPopupMenu;
00035 class TGuiBldEditor;
00036 class TGColorDialog;
00037 class TGFontDialog;
00038 class TGTextButton;
00039 class TGPictureButton;
00040 class TGCanvas;
00041 class TGComboBox;
00042 class TGLabel;
00043 class TGListBox;
00044 class TGProgressBar;
00045 class TGScrollBar;
00046 class TGTextEntry;
00047 class TGIcon;
00048 
00049 
00050 enum EActionType {
00051    kNoneAct, kPropertyAct, kEditableAct, kReparentAct,
00052    kDropAct, kCutAct, kCopyAct, kPasteAct, kCropAct,
00053    kCompactAct, kCompactGlobalAct, kLayUpAct, kLayDownAct,
00054    kCloneAct, kSaveAct, kSaveFrameAct, kGrabAct, kDeleteAct,
00055    kLeftAct, kRightAct, kUpAct, kDownAct, kEndEditAct, kReplaceAct,
00056    kGridAct, kBreakLayoutAct, kSwitchLayoutAct, kNewAct,
00057    kOpenAct, kLayoutHAct, kLayoutVAct, kUndoAct, kRedoAct,
00058    kSelectAct, kMethodMenuAct, kToggleMenuAct
00059 };
00060 
00061 //////////////////////////////////////////////////////////////////////////
00062 class TGuiBldDragManager : public TVirtualDragManager, public TGFrame {
00063 
00064 friend class TGClient;
00065 friend class TGFrame;
00066 friend class TGMainFrame;
00067 friend class TGGrabRect;
00068 friend class TRootGuiBuilder;
00069 friend class TGuiBldDragManagerRepeatTimer;
00070 friend class TGuiBldMenuDialog;
00071 friend class TGuiBldGeometryFrame;
00072 friend class TGuiBldEditor;
00073 
00074 private:
00075    TGuiBldDragManagerPimpl *fPimpl;    // private data
00076 
00077    TRootGuiBuilder   *fBuilder;        // pointer to gui builder
00078    TGuiBldEditor *fEditor;             // frame property editor
00079    Bool_t         fLassoDrawn;         // kTRUE if  lasso drawn
00080    TString        fPasteFileName;      // paste_clippboard file name
00081    TString        fTmpBuildFile;       // temporary file name
00082    Bool_t         fSelectionIsOn;      // selection with Shift key pressed
00083    TGPopupMenu   *fFrameMenu;          // context menu for frames
00084    TGPopupMenu   *fLassoMenu;          // context menu for lasso drawn
00085    Window_t       fTargetId;           // an id of window where drop
00086    Bool_t         fDropStatus;         // kTRUE if drop was successfull
00087    Bool_t         fStop;               // kTRUE if stopped
00088    TGFrame       *fSelected;           // selected frame. In most cases selected is
00089                                        // the same frame as grabbed frame.
00090    TList         *fListOfDialogs;      // list of dialog methods
00091 
00092    static TGColorDialog *fgGlobalColorDialog;   // color dialog
00093    static TGColorDialog *GetGlobalColorDialog(Bool_t create = kTRUE);
00094 
00095    static TGFontDialog *fgGlobalFontDialog;     // font dialog
00096    static TGFontDialog *GetGlobalFontDialog();  //
00097 
00098 
00099    void           Reset1();
00100    void           DrawGrabRectangles(TGWindow *win = 0);
00101    void           DrawGrabRect(Int_t i, Int_t x, Int_t y);
00102    TGCompositeFrame *FindLayoutFrame(TGFrame *f);
00103    Bool_t         IsPointVisible(Int_t x, Int_t y);
00104    Bool_t         IsSelectedVisible();
00105    void           CloseMenus();
00106    Bool_t         IsEditDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisable)); }
00107    Bool_t         IsGrabDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableGrab)); }
00108    Bool_t         IsEventsDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableEvents)); }
00109    Bool_t         IsFixedLayout(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableLayout)); }
00110    Bool_t         IsFixedH(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableHeight)); }
00111    Bool_t         IsFixedW(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableWidth)); }
00112    Bool_t         IsFixedSize(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableResize)); }
00113    Bool_t         CanChangeLayout(TGWindow *w) const;
00114    Bool_t         CanChangeLayoutOrder(TGWindow *w) const;
00115    Bool_t         CanCompact(TGWindow *w) const;
00116 
00117    void           ChangeSelected(TGFrame *f);
00118    TGFrame       *GetEditableParent(TGFrame *f);
00119    TGFrame       *GetMovableParent(TGWindow *p);
00120    TGFrame       *GetBtnEnableParent(TGFrame *fr);
00121    TGWindow      *GetResizableParent(TGWindow *p);
00122    TGFrame       *FindMdiFrame(TGFrame *in);
00123    void           RaiseMdiFrame(TGFrame *in);
00124    Bool_t         CheckTargetAtPoint(Int_t x, Int_t y);
00125    void           AddClassMenuMethods(TGPopupMenu *menu, TObject *object);
00126    void           AddDialogMethods(TGPopupMenu *menu, TObject *object);
00127    void           DeleteMenuDialog();
00128    void           CreateListOfDialogs();
00129 
00130 private:
00131    TGFrame       *InEditable(Window_t id);
00132    void           GrabFrame(TGFrame *frame);
00133    void           UngrabFrame();
00134    void           SetPropertyEditor(TGuiBldEditor *e);
00135    void           DeletePropertyEditor();
00136 
00137    TList         *GetFramesInside(Int_t x0, Int_t y0, Int_t x, Int_t y);
00138    void           ToGrid(Int_t &x, Int_t &y);
00139    void           DoReplace(TGFrame *frame);
00140    void           DeleteFrame(TGFrame *frame);
00141    void           HandleDelete(Bool_t crop = kFALSE);
00142    void           HandleReturn(Bool_t on = kFALSE);
00143    void           HandleAlignment(Int_t to, Bool_t lineup = kFALSE);
00144    void           HandleCut();
00145    void           HandleCopy(Bool_t brk_layout = kTRUE);
00146    void           HandlePaste();
00147    void           HandleReplace();
00148    void           HandleGrid();
00149    void           CloneEditable();
00150    void           DropCanvas(TGCanvas *canvas);
00151    void           PutToCanvas(TGCompositeFrame *cont);
00152    Bool_t         Save(const char *file = "");
00153    Bool_t         SaveFrame(const char *file = 0);
00154    void           HandleLayoutOrder(Bool_t forward = kTRUE);
00155    void           DoResize();
00156    void           DoMove();
00157    void           DrawLasso();
00158    void           PlaceFrame(TGFrame*, TGLayoutHints *);
00159    void           ReparentFrames(TGFrame *newfr,
00160                                  TGCompositeFrame *oldfr);
00161    TGCompositeFrame *FindCompositeFrame(Window_t id);
00162    void           SetCursorType(Int_t cur);
00163    void           CheckTargetUnderGrab();
00164    void           HighlightCompositeFrame(Window_t);
00165    void           Compact(Bool_t global = kTRUE);
00166    Bool_t         StartDrag(TGFrame *src, Int_t x, Int_t y);
00167    Bool_t         EndDrag();
00168    Bool_t         Drop();
00169    Bool_t         Cancel(Bool_t delSrc);
00170    void           Menu4Frame(TGFrame *, Int_t x, Int_t y);
00171    void           Menu4Lasso(Int_t x, Int_t y);
00172    void           CreatePropertyEditor();
00173    void           DoRedraw();
00174    void           SwitchEditable(TGFrame *frame);
00175    void           UnmapAllPopups();
00176    void           BreakLayout();
00177    void           SwitchLayout();
00178 
00179    Bool_t         RecognizeGesture(Event_t *, TGFrame *frame = 0);
00180    Bool_t         HandleButtonPress(Event_t *);
00181    Bool_t         HandleButtonRelease(Event_t *);
00182    Bool_t         HandleButton(Event_t *);
00183    Bool_t         HandleDoubleClick(Event_t*);
00184    Bool_t         HandleMotion(Event_t *);
00185    Bool_t         HandleClientMessage(Event_t *);
00186    Bool_t         HandleDestroyNotify(Event_t *);
00187    Bool_t         HandleSelection(Event_t *);
00188    Bool_t         HandleExpose(Event_t *);
00189    Bool_t         HandleConfigureNotify(Event_t *);
00190    Bool_t         HandleSelectionRequest(Event_t *);
00191    void           HandleButon3Pressed(Event_t *, TGFrame *frame = 0);
00192    Bool_t         HandleEvent(Event_t *);
00193    Bool_t         HandleTimer(TTimer *);
00194 
00195    Bool_t         IsMoveWaiting() const;
00196    Bool_t         IsLassoDrawn() const { return fLassoDrawn; }
00197    void           SetLassoDrawn(Bool_t on);
00198    void           HideGrabRectangles();
00199    Bool_t         IgnoreEvent(Event_t *e);
00200    Bool_t         CheckDragResize(Event_t *event);
00201    Bool_t         IsPasteFrameExist();
00202 
00203 public:
00204    TGuiBldDragManager();
00205    virtual        ~TGuiBldDragManager();
00206 
00207    void           HandleAction(Int_t act);
00208    Bool_t         HandleKey(Event_t *);
00209 
00210    TGFrame       *GetTarget() const { return fTarget; }
00211    TGFrame       *GetSelected() const;
00212    void           Snap2Grid();
00213    void           SetGridStep(UInt_t step);
00214    UInt_t         GetGridStep();
00215    void           HandleUpdateSelected(TGFrame *);
00216    Int_t          GetStrartDragX() const;
00217    Int_t          GetStrartDragY() const;
00218    Int_t          GetEndDragX() const;
00219    Int_t          GetEndDragY() const;
00220 
00221    Bool_t         GetDropStatus() const { return fDropStatus; }
00222    void           SetBuilder(TRootGuiBuilder *b) { fBuilder = b; }
00223 
00224    Bool_t         IsStopped() const { return fStop; }
00225    void           SetEditable(Bool_t on = kTRUE);
00226    void           SelectFrame(TGFrame *frame, Bool_t add = kFALSE);
00227 
00228    static void    MapGlobalDialog(TGMainFrame *dialog, TGFrame *fr);
00229 
00230    Bool_t         HandleTimerEvent(Event_t *ev, TTimer *t);
00231    void           TimerEvent(Event_t *ev)
00232                      { Emit("TimerEvent(Event_t*)", (Long_t)ev); } // *SIGNAL*
00233 
00234    // hadndling dynamic context menus
00235    void DoClassMenu(Int_t);
00236    void DoDialogOK();
00237    void DoDialogApply();
00238    void DoDialogCancel();
00239 
00240    void ChangeProperties(TGLabel *);         //*MENU* *DIALOG*icon=bld_fontselect.png*
00241    void ChangeProperties(TGTextButton *);    //*MENU* *DIALOG*icon=bld_fontselect.png*
00242 
00243    void ChangeTextFont(TGGroupFrame *);      //*MENU* *DIALOG*icon=bld_fontselect.png*
00244    void ChangeTextFont(TGTextEntry *);       //*MENU* *DIALOG*icon=bld_fontselect.png*
00245 
00246    void ChangePicture(TGPictureButton *);    //*MENU* *DIALOG*icon=bld_open.png*
00247    void ChangeImage(TGIcon *);               //*MENU* *DIALOG*icon=bld_open.png*
00248 
00249    void ChangeBarColor(TGProgressBar *);     //*MENU* *DIALOG*icon=bld_colorselect.png*
00250 
00251    void ChangeTextColor(TGGroupFrame *);     //*MENU* *DIALOG*icon=bld_colorselect.png*
00252    void ChangeTextColor(TGLabel *);          //*MENU* *DIALOG*icon=bld_colorselect.png*
00253    void ChangeTextColor(TGTextButton *);     //*MENU* *DIALOG*icon=bld_colorselect.png*
00254    void ChangeTextColor(TGProgressBar *);    //*MENU* *DIALOG*icon=bld_colorselect.png*
00255    void ChangeTextColor(TGTextEntry *);      //*MENU* *DIALOG*icon=bld_colorselect.png*
00256 
00257    void ChangeBackgroundColor(TGListBox *);  //*MENU* *DIALOG*icon=bld_colorselect.png*
00258    void ChangeBackgroundColor(TGCanvas *);   //*MENU* *DIALOG*icon=bld_colorselect.png*
00259    void ChangeBackgroundColor(TGComboBox *); //*MENU* *DIALOG*icon=bld_colorselect.png*
00260    void ChangeBackgroundColor(TGFrame *);             //*MENU* *DIALOG*icon=bld_colorselect.png*
00261    void ChangeBackgroundColor(TGCompositeFrame *);    //*MENU* *DIALOG*icon=bld_colorselect.png*
00262 
00263    ClassDef(TGuiBldDragManager,0)  // drag and drop manager
00264 };
00265 
00266 
00267 #endif

Generated on Tue Jul 5 14:22:08 2011 for ROOT_528-00b_version by  doxygen 1.5.1