Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGuiBldDragManager.h
Go to the documentation of this file.
1 // @(#)root/guibuilder:$Id$
2 // Author: Valeriy Onuchin 12/09/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, 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_TGuiBldDragManager
13 #define ROOT_TGuiBldDragManager
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGuiBldDragManager //
19 // //
20 //////////////////////////////////////////////////////////////////////////
21 
22 #include "TGFrame.h"
23 
24 #include "TVirtualDragManager.h"
25 
26 class TTimer;
27 class TGuiBldDragManagerPimpl;
28 class TRootGuiBuilder;
29 class TQUndoManager;
30 class TGPopupMenu;
31 class TGuiBldEditor;
32 class TGColorDialog;
33 class TGFontDialog;
34 class TGTextButton;
35 class TGPictureButton;
36 class TGCanvas;
37 class TGComboBox;
38 class TGLabel;
39 class TGListBox;
40 class TGProgressBar;
41 class TGScrollBar;
42 class TGTextEntry;
43 class TGIcon;
44 
45 
46 enum EActionType {
47  kNoneAct, kPropertyAct, kEditableAct, kReparentAct,
48  kDropAct, kCutAct, kCopyAct, kPasteAct, kCropAct,
49  kCompactAct, kCompactGlobalAct, kLayUpAct, kLayDownAct,
50  kCloneAct, kSaveAct, kSaveFrameAct, kGrabAct, kDeleteAct,
51  kLeftAct, kRightAct, kUpAct, kDownAct, kEndEditAct, kReplaceAct,
52  kGridAct, kBreakLayoutAct, kSwitchLayoutAct, kNewAct,
53  kOpenAct, kLayoutHAct, kLayoutVAct, kUndoAct, kRedoAct,
54  kSelectAct, kMethodMenuAct, kToggleMenuAct
55 };
56 
57 //////////////////////////////////////////////////////////////////////////
58 class TGuiBldDragManager : public TVirtualDragManager, public TGFrame {
59 
60 friend class TGClient;
61 friend class TGFrame;
62 friend class TGMainFrame;
63 friend class TGGrabRect;
64 friend class TRootGuiBuilder;
65 friend class TGuiBldDragManagerRepeatTimer;
66 friend class TGuiBldMenuDialog;
67 friend class TGuiBldGeometryFrame;
68 friend class TGuiBldEditor;
69 
70 private:
71  TGuiBldDragManagerPimpl *fPimpl; // private data
72 
73  TRootGuiBuilder *fBuilder; // pointer to gui builder
74  TGuiBldEditor *fEditor; // frame property editor
75  Bool_t fLassoDrawn; // kTRUE if lasso drawn
76  TString fPasteFileName; // paste_clippboard file name
77  TString fTmpBuildFile; // temporary file name
78  Bool_t fSelectionIsOn; // selection with Shift key pressed
79  TGPopupMenu *fFrameMenu; // context menu for frames
80  TGPopupMenu *fLassoMenu; // context menu for lasso drawn
81  Window_t fTargetId; // an id of window where drop
82  Bool_t fDropStatus; // kTRUE if drop was successfull
83  Bool_t fStop; // kTRUE if stopped
84  TGFrame *fSelected; // selected frame. In most cases selected is
85  // the same frame as grabbed frame.
86  TList *fListOfDialogs; // list of dialog methods
87 
88  static TGColorDialog *fgGlobalColorDialog; // color dialog
89  static TGColorDialog *GetGlobalColorDialog(Bool_t create = kTRUE);
90 
91  static TGFontDialog *fgGlobalFontDialog; // font dialog
92  static TGFontDialog *GetGlobalFontDialog(); //
93 
94 
95  void Reset1();
96  void DrawGrabRectangles(TGWindow *win = 0);
97  void DrawGrabRect(Int_t i, Int_t x, Int_t y);
98  TGCompositeFrame *FindLayoutFrame(TGFrame *f);
99  Bool_t IsPointVisible(Int_t x, Int_t y);
100  Bool_t IsSelectedVisible();
101  void CloseMenus();
102  Bool_t IsEditDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisable)); }
103  Bool_t IsGrabDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableGrab)); }
104  Bool_t IsEventsDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableEvents)); }
105  Bool_t IsFixedLayout(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableLayout)); }
106  Bool_t IsFixedH(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableHeight)); }
107  Bool_t IsFixedW(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableWidth)); }
108  Bool_t IsFixedSize(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableResize)); }
109  Bool_t CanChangeLayout(TGWindow *w) const;
110  Bool_t CanChangeLayoutOrder(TGWindow *w) const;
111  Bool_t CanCompact(TGWindow *w) const;
112 
113  void ChangeSelected(TGFrame *f);
114  TGFrame *GetEditableParent(TGFrame *f);
115  TGFrame *GetMovableParent(TGWindow *p);
116  TGFrame *GetBtnEnableParent(TGFrame *fr);
117  TGWindow *GetResizableParent(TGWindow *p);
118  TGFrame *FindMdiFrame(TGFrame *in);
119  void RaiseMdiFrame(TGFrame *in);
120  Bool_t CheckTargetAtPoint(Int_t x, Int_t y);
121  void AddClassMenuMethods(TGPopupMenu *menu, TObject *object);
122  void AddDialogMethods(TGPopupMenu *menu, TObject *object);
123  void DeleteMenuDialog();
124  void CreateListOfDialogs();
125 
126 private:
127  TGFrame *InEditable(Window_t id);
128  void GrabFrame(TGFrame *frame);
129  void UngrabFrame();
130  void SetPropertyEditor(TGuiBldEditor *e);
131  void DeletePropertyEditor();
132 
133  TList *GetFramesInside(Int_t x0, Int_t y0, Int_t x, Int_t y);
134  void ToGrid(Int_t &x, Int_t &y);
135  void DoReplace(TGFrame *frame);
136  void DeleteFrame(TGFrame *frame);
137  void HandleDelete(Bool_t crop = kFALSE);
138  void HandleReturn(Bool_t on = kFALSE);
139  void HandleAlignment(Int_t to, Bool_t lineup = kFALSE);
140  void HandleCut();
141  void HandleCopy(Bool_t brk_layout = kTRUE);
142  void HandlePaste();
143  void HandleReplace();
144  void HandleGrid();
145  void CloneEditable();
146  void DropCanvas(TGCanvas *canvas);
147  void PutToCanvas(TGCompositeFrame *cont);
148  Bool_t Save(const char *file = "");
149  Bool_t SaveFrame(const char *file = 0);
150  void HandleLayoutOrder(Bool_t forward = kTRUE);
151  void DoResize();
152  void DoMove();
153  void DrawLasso();
154  void PlaceFrame(TGFrame*, TGLayoutHints *);
155  void ReparentFrames(TGFrame *newfr,
156  TGCompositeFrame *oldfr);
157  TGCompositeFrame *FindCompositeFrame(Window_t id);
158  void SetCursorType(Int_t cur);
159  void CheckTargetUnderGrab();
160  void HighlightCompositeFrame(Window_t);
161  void Compact(Bool_t global = kTRUE);
162  Bool_t StartDrag(TGFrame *src, Int_t x, Int_t y);
163  Bool_t EndDrag();
164  Bool_t Drop();
165  Bool_t Cancel(Bool_t delSrc);
166  void Menu4Frame(TGFrame *, Int_t x, Int_t y);
167  void Menu4Lasso(Int_t x, Int_t y);
168  void CreatePropertyEditor();
169  void DoRedraw();
170  void SwitchEditable(TGFrame *frame);
171  void UnmapAllPopups();
172  void BreakLayout();
173  void SwitchLayout();
174 
175  Bool_t RecognizeGesture(Event_t *, TGFrame *frame = 0);
176  Bool_t HandleButtonPress(Event_t *);
177  Bool_t HandleButtonRelease(Event_t *);
178  Bool_t HandleButton(Event_t *);
179  Bool_t HandleDoubleClick(Event_t*);
180  Bool_t HandleMotion(Event_t *);
181  Bool_t HandleClientMessage(Event_t *);
182  Bool_t HandleDestroyNotify(Event_t *);
183  Bool_t HandleSelection(Event_t *);
184  Bool_t HandleExpose(Event_t *);
185  Bool_t HandleConfigureNotify(Event_t *);
186  Bool_t HandleSelectionRequest(Event_t *);
187  void HandleButon3Pressed(Event_t *, TGFrame *frame = 0);
188  Bool_t HandleEvent(Event_t *);
189  Bool_t HandleTimer(TTimer *);
190 
191  Bool_t IsMoveWaiting() const;
192  Bool_t IsLassoDrawn() const { return fLassoDrawn; }
193  void SetLassoDrawn(Bool_t on);
194  void HideGrabRectangles();
195  Bool_t IgnoreEvent(Event_t *e);
196  Bool_t CheckDragResize(Event_t *event);
197  Bool_t IsPasteFrameExist();
198 
199 public:
200  TGuiBldDragManager();
201  virtual ~TGuiBldDragManager();
202 
203  void HandleAction(Int_t act);
204  Bool_t HandleKey(Event_t *);
205 
206  TGFrame *GetTarget() const { return fTarget; }
207  TGFrame *GetSelected() const;
208  void Snap2Grid();
209  void SetGridStep(UInt_t step);
210  UInt_t GetGridStep();
211  void HandleUpdateSelected(TGFrame *);
212  Int_t GetStrartDragX() const;
213  Int_t GetStrartDragY() const;
214  Int_t GetEndDragX() const;
215  Int_t GetEndDragY() const;
216 
217  Bool_t GetDropStatus() const { return fDropStatus; }
218  void SetBuilder(TRootGuiBuilder *b) { fBuilder = b; }
219 
220  Bool_t IsStopped() const { return fStop; }
221  void SetEditable(Bool_t on = kTRUE);
222  void SelectFrame(TGFrame *frame, Bool_t add = kFALSE);
223 
224  static void MapGlobalDialog(TGMainFrame *dialog, TGFrame *fr);
225 
226  Bool_t HandleTimerEvent(Event_t *ev, TTimer *t);
227  void TimerEvent(Event_t *ev)
228  { Emit("TimerEvent(Event_t*)", (Long_t)ev); } // *SIGNAL*
229 
230  // hadndling dynamic context menus
231  void DoClassMenu(Int_t);
232  void DoDialogOK();
233  void DoDialogApply();
234  void DoDialogCancel();
235 
236  void ChangeProperties(TGLabel *); //*MENU* *DIALOG*icon=bld_fontselect.png*
237  void ChangeProperties(TGTextButton *); //*MENU* *DIALOG*icon=bld_fontselect.png*
238 
239  void ChangeTextFont(TGGroupFrame *); //*MENU* *DIALOG*icon=bld_fontselect.png*
240  void ChangeTextFont(TGTextEntry *); //*MENU* *DIALOG*icon=bld_fontselect.png*
241 
242  void ChangePicture(TGPictureButton *); //*MENU* *DIALOG*icon=bld_open.png*
243  void ChangeImage(TGIcon *); //*MENU* *DIALOG*icon=bld_open.png*
244 
245  void ChangeBarColor(TGProgressBar *); //*MENU* *DIALOG*icon=bld_colorselect.png*
246 
247  void ChangeTextColor(TGGroupFrame *); //*MENU* *DIALOG*icon=bld_colorselect.png*
248  void ChangeTextColor(TGLabel *); //*MENU* *DIALOG*icon=bld_colorselect.png*
249  void ChangeTextColor(TGTextButton *); //*MENU* *DIALOG*icon=bld_colorselect.png*
250  void ChangeTextColor(TGProgressBar *); //*MENU* *DIALOG*icon=bld_colorselect.png*
251  void ChangeTextColor(TGTextEntry *); //*MENU* *DIALOG*icon=bld_colorselect.png*
252 
253  void ChangeBackgroundColor(TGListBox *); //*MENU* *DIALOG*icon=bld_colorselect.png*
254  void ChangeBackgroundColor(TGCanvas *); //*MENU* *DIALOG*icon=bld_colorselect.png*
255  void ChangeBackgroundColor(TGComboBox *); //*MENU* *DIALOG*icon=bld_colorselect.png*
256  void ChangeBackgroundColor(TGFrame *); //*MENU* *DIALOG*icon=bld_colorselect.png*
257  void ChangeBackgroundColor(TGCompositeFrame *); //*MENU* *DIALOG*icon=bld_colorselect.png*
258 
259  ClassDef(TGuiBldDragManager,0) // drag and drop manager
260 };
261 
262 
263 #endif