Logo ROOT   6.08/07
Reference Guide
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 #ifndef ROOT_TGFrame
23 #include "TGFrame.h"
24 #endif
25 
26 #ifndef ROOT_TVirtualDragManager
27 #include "TVirtualDragManager.h"
28 #endif
29 
30 class TTimer;
31 class TGuiBldDragManagerPimpl;
32 class TRootGuiBuilder;
33 class TQUndoManager;
34 class TGPopupMenu;
35 class TGuiBldEditor;
36 class TGColorDialog;
37 class TGFontDialog;
38 class TGTextButton;
39 class TGPictureButton;
40 class TGCanvas;
41 class TGComboBox;
42 class TGLabel;
43 class TGListBox;
44 class TGProgressBar;
45 class TGScrollBar;
46 class TGTextEntry;
47 class TGIcon;
48 
49 
59 };
60 
61 //////////////////////////////////////////////////////////////////////////
63 
64 friend class TGClient;
65 friend class TGFrame;
66 friend class TGMainFrame;
67 friend class TGGrabRect;
68 friend class TRootGuiBuilder;
70 friend class TGuiBldMenuDialog;
71 friend class TGuiBldGeometryFrame;
72 friend class TGuiBldEditor;
73 
74 private:
75  TGuiBldDragManagerPimpl *fPimpl; // private data
76 
77  TRootGuiBuilder *fBuilder; // pointer to gui builder
78  TGuiBldEditor *fEditor; // frame property editor
79  Bool_t fLassoDrawn; // kTRUE if lasso drawn
80  TString fPasteFileName; // paste_clippboard file name
81  TString fTmpBuildFile; // temporary file name
82  Bool_t fSelectionIsOn; // selection with Shift key pressed
83  TGPopupMenu *fFrameMenu; // context menu for frames
84  TGPopupMenu *fLassoMenu; // context menu for lasso drawn
85  Window_t fTargetId; // an id of window where drop
86  Bool_t fDropStatus; // kTRUE if drop was successfull
87  Bool_t fStop; // kTRUE if stopped
88  TGFrame *fSelected; // selected frame. In most cases selected is
89  // the same frame as grabbed frame.
90  TList *fListOfDialogs; // list of dialog methods
91 
92  static TGColorDialog *fgGlobalColorDialog; // color dialog
94 
95  static TGFontDialog *fgGlobalFontDialog; // font dialog
96  static TGFontDialog *GetGlobalFontDialog(); //
97 
98 
99  void Reset1();
100  void DrawGrabRectangles(TGWindow *win = 0);
101  void DrawGrabRect(Int_t i, Int_t x, Int_t y);
105  void CloseMenus();
106  Bool_t IsEditDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisable)); }
107  Bool_t IsGrabDisabled(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableGrab)); }
109  Bool_t IsFixedLayout(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableLayout)); }
110  Bool_t IsFixedH(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableHeight)); }
111  Bool_t IsFixedW(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableWidth)); }
112  Bool_t IsFixedSize(TGWindow *f) const { return (f && (f->GetEditDisabled() & kEditDisableResize)); }
113  Bool_t CanChangeLayout(TGWindow *w) const;
115  Bool_t CanCompact(TGWindow *w) const;
116 
117  void ChangeSelected(TGFrame *f);
123  void RaiseMdiFrame(TGFrame *in);
125  void AddClassMenuMethods(TGPopupMenu *menu, TObject *object);
126  void AddDialogMethods(TGPopupMenu *menu, TObject *object);
127  void DeleteMenuDialog();
128  void CreateListOfDialogs();
129 
130 private:
132  void GrabFrame(TGFrame *frame);
133  void UngrabFrame();
135  void DeletePropertyEditor();
136 
137  TList *GetFramesInside(Int_t x0, Int_t y0, Int_t x, Int_t y);
138  void ToGrid(Int_t &x, Int_t &y);
139  void DoReplace(TGFrame *frame);
140  void DeleteFrame(TGFrame *frame);
141  void HandleDelete(Bool_t crop = kFALSE);
142  void HandleReturn(Bool_t on = kFALSE);
143  void HandleAlignment(Int_t to, Bool_t lineup = kFALSE);
144  void HandleCut();
145  void HandleCopy(Bool_t brk_layout = kTRUE);
146  void HandlePaste();
147  void HandleReplace();
148  void HandleGrid();
149  void CloneEditable();
150  void DropCanvas(TGCanvas *canvas);
151  void PutToCanvas(TGCompositeFrame *cont);
152  Bool_t Save(const char *file = "");
153  Bool_t SaveFrame(const char *file = 0);
155  void DoResize();
156  void DoMove();
157  void DrawLasso();
158  void PlaceFrame(TGFrame*, TGLayoutHints *);
159  void ReparentFrames(TGFrame *newfr,
160  TGCompositeFrame *oldfr);
162  void SetCursorType(Int_t cur);
163  void CheckTargetUnderGrab();
165  void Compact(Bool_t global = kTRUE);
166  Bool_t StartDrag(TGFrame *src, Int_t x, Int_t y);
167  Bool_t EndDrag();
168  Bool_t Drop();
169  Bool_t Cancel(Bool_t delSrc);
170  void Menu4Frame(TGFrame *, Int_t x, Int_t y);
171  void Menu4Lasso(Int_t x, Int_t y);
172  void CreatePropertyEditor();
173  void DoRedraw();
174  void SwitchEditable(TGFrame *frame);
175  void UnmapAllPopups();
176  void BreakLayout();
177  void SwitchLayout();
178 
179  Bool_t RecognizeGesture(Event_t *, TGFrame *frame = 0);
191  void HandleButon3Pressed(Event_t *, TGFrame *frame = 0);
194 
195  Bool_t IsMoveWaiting() const;
196  Bool_t IsLassoDrawn() const { return fLassoDrawn; }
197  void SetLassoDrawn(Bool_t on);
198  void HideGrabRectangles();
202 
203 public:
205  virtual ~TGuiBldDragManager();
206 
207  void HandleAction(Int_t act);
209 
210  TGFrame *GetTarget() const { return fTarget; }
211  TGFrame *GetSelected() const;
212  void Snap2Grid();
213  void SetGridStep(UInt_t step);
216  Int_t GetStrartDragX() const;
217  Int_t GetStrartDragY() const;
218  Int_t GetEndDragX() const;
219  Int_t GetEndDragY() const;
220 
221  Bool_t GetDropStatus() const { return fDropStatus; }
222  void SetBuilder(TRootGuiBuilder *b) { fBuilder = b; }
223 
224  Bool_t IsStopped() const { return fStop; }
225  void SetEditable(Bool_t on = kTRUE);
226  void SelectFrame(TGFrame *frame, Bool_t add = kFALSE);
227 
228  static void MapGlobalDialog(TGMainFrame *dialog, TGFrame *fr);
229 
231  void TimerEvent(Event_t *ev)
232  { Emit("TimerEvent(Event_t*)", (Long_t)ev); } // *SIGNAL*
233 
234  // hadndling dynamic context menus
235  void DoClassMenu(Int_t);
236  void DoDialogOK();
237  void DoDialogApply();
238  void DoDialogCancel();
239 
240  void ChangeProperties(TGLabel *); //*MENU* *DIALOG*icon=bld_fontselect.png*
241  void ChangeProperties(TGTextButton *); //*MENU* *DIALOG*icon=bld_fontselect.png*
242 
243  void ChangeTextFont(TGGroupFrame *); //*MENU* *DIALOG*icon=bld_fontselect.png*
244  void ChangeTextFont(TGTextEntry *); //*MENU* *DIALOG*icon=bld_fontselect.png*
245 
246  void ChangePicture(TGPictureButton *); //*MENU* *DIALOG*icon=bld_open.png*
247  void ChangeImage(TGIcon *); //*MENU* *DIALOG*icon=bld_open.png*
248 
249  void ChangeBarColor(TGProgressBar *); //*MENU* *DIALOG*icon=bld_colorselect.png*
250 
251  void ChangeTextColor(TGGroupFrame *); //*MENU* *DIALOG*icon=bld_colorselect.png*
252  void ChangeTextColor(TGLabel *); //*MENU* *DIALOG*icon=bld_colorselect.png*
253  void ChangeTextColor(TGTextButton *); //*MENU* *DIALOG*icon=bld_colorselect.png*
254  void ChangeTextColor(TGProgressBar *); //*MENU* *DIALOG*icon=bld_colorselect.png*
255  void ChangeTextColor(TGTextEntry *); //*MENU* *DIALOG*icon=bld_colorselect.png*
256 
257  void ChangeBackgroundColor(TGListBox *); //*MENU* *DIALOG*icon=bld_colorselect.png*
258  void ChangeBackgroundColor(TGCanvas *); //*MENU* *DIALOG*icon=bld_colorselect.png*
259  void ChangeBackgroundColor(TGComboBox *); //*MENU* *DIALOG*icon=bld_colorselect.png*
260  void ChangeBackgroundColor(TGFrame *); //*MENU* *DIALOG*icon=bld_colorselect.png*
261  void ChangeBackgroundColor(TGCompositeFrame *); //*MENU* *DIALOG*icon=bld_colorselect.png*
262 
263  ClassDef(TGuiBldDragManager,0) // drag and drop manager
264 };
265 
266 
267 #endif
virtual UInt_t GetEditDisabled() const
Definition: TGWindow.h:118
void HandleCut()
Handle cut action.
void SelectFrame(TGFrame *frame, Bool_t add=kFALSE)
Grab/Select frame.
Bool_t IsEventsDisabled(TGWindow *f) const
Bool_t HandleMotion(Event_t *)
Handle motion event.
Int_t GetEndDragX() const
Return the current X coordinate of the dragged frame.
TGCompositeFrame * FindCompositeFrame(Window_t id)
Find the first composite parent of window.
Bool_t IsFixedW(TGWindow *f) const
void ChangeProperties(TGLabel *)
Edit properties via font selection dialog.
TGFrame * GetSelected() const
Return the current grabbed/selected frame.
void ChangeImage(TGIcon *)
Invoke file dialog to assign a new image.
TGCompositeFrame * FindLayoutFrame(TGFrame *f)
Helper to find a frame which can be layouted.
void CheckTargetUnderGrab()
Look for the drop target under grabbed/selected frame while moving.
void UngrabFrame()
Ungrab/Unselect selected/grabbed frame.
void DeleteFrame(TGFrame *frame)
Delete frame.
Bool_t IsStopped() const
Bool_t IsMoveWaiting() const
Waits for either the mouse move from the given initial ButtonPress location or for the mouse button t...
UInt_t GetGridStep()
Return the grid step.
void PutToCanvas(TGCompositeFrame *cont)
Create a new TGCanvas and place container into it.
TGFrame * FindMdiFrame(TGFrame *in)
Return a pointer to the parent mdi frame.
Bool_t Save(const char *file="")
Save an editted frame to the file.
static TGColorDialog * fgGlobalColorDialog
static TGColorDialog * GetGlobalColorDialog(Bool_t create=kTRUE)
Return pointer to global color dialog.
void UnmapAllPopups()
Unmap all popups.
Bool_t HandleButtonRelease(Event_t *)
Handle button release event.
static void MapGlobalDialog(TGMainFrame *dialog, TGFrame *fr)
Map dialog and place it relative to selected frame.
void DrawGrabRect(Int_t i, Int_t x, Int_t y)
Helper method to draw grab rectangle at position x,y.
Bool_t HandleTimerEvent(Event_t *ev, TTimer *t)
Handle timer events or events coming from the recorder.
Bool_t CanChangeLayoutOrder(TGWindow *w) const
kTRUE - if it's possible to change layout order in the parent's layout of window w ...
void ChangeSelected(TGFrame *f)
Inform outside wold that selected frame was changed.
Basic string class.
Definition: TString.h:137
friend class TGuiBldDragManagerRepeatTimer
void SetCursorType(Int_t cur)
Set cursor for selcted/grabbed frame.
Bool_t IsFixedLayout(TGWindow *f) const
void HandleGrid()
Switch on/of grid drawn.
TGFrame * InEditable(Window_t id)
Return a pointer to the parent window (which is being editted)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t Drop()
Drop grabbed frame.
const Bool_t kFALSE
Definition: Rtypes.h:92
Bool_t HandleConfigureNotify(Event_t *)
Resize events.
void CreatePropertyEditor()
Create widget property editor (it could be located outside of guibuilder)
TGWindow * GetResizableParent(TGWindow *p)
Find parent frame which can be resized.
void HandleLayoutOrder(Bool_t forward=kTRUE)
Change layout order.
void HandleReturn(Bool_t on=kFALSE)
Handling of return/enter key pressing.
Bool_t CheckTargetAtPoint(Int_t x, Int_t y)
Helper. Look for the drop target under grabbed/selected frame while moving.
void SetLassoDrawn(Bool_t on)
Set lasso drawn flag.
void AddDialogMethods(TGPopupMenu *menu, TObject *object)
Add DIALOG entries to the selected frame popup menu.
void AddClassMenuMethods(TGPopupMenu *menu, TObject *object)
Add entries with class //*MENU* methods.
void CloneEditable()
Create a frame which is the same as currently editted frame.
TRootGuiBuilder * fBuilder
void SetPropertyEditor(TGuiBldEditor *e)
Helper method.
Bool_t EndDrag()
End dragging.
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
void HandleDelete(Bool_t crop=kFALSE)
Handle delete or crop action.
Bool_t HandleButtonPress(Event_t *)
Handle button press event.
Bool_t GetDropStatus() const
Bool_t IsPointVisible(Int_t x, Int_t y)
Helper function for IsSelectedWindow method.
Definition: TGIcon.h:34
Bool_t CheckDragResize(Event_t *event)
Check resize type event.
Bool_t IsFixedSize(TGWindow *f) const
void Snap2Grid()
Draw grid on editable frame and restore background on previuosly editted one.
void ToGrid(Int_t &x, Int_t &y)
Return grid coordinates which are close to given.
void Reset1()
Reset some parameters.
void ChangeBarColor(TGProgressBar *)
Set progress bar color via TGColorDialog.
void DoDialogOK()
Process dialog OK button pressed.
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:561
void TimerEvent(Event_t *ev)
virtual ~TGuiBldDragManager()
Destructor.
A doubly linked list.
Definition: TList.h:47
Bool_t HandleClientMessage(Event_t *)
Handle client message.
void DropCanvas(TGCanvas *canvas)
Drop canvas container.
Bool_t HandleButton(Event_t *)
Handle button event occured in some ROOT frame.
void DrawLasso()
Draw lasso for allocation new object.
void HandleAction(Int_t act)
Main handler of actions.
Bool_t HandleDoubleClick(Event_t *)
Mouse double click handler (never should happen)
void CreateListOfDialogs()
Create a list of dialog methods.
TGPopupMenu * fLassoMenu
Bool_t HandleExpose(Event_t *)
Handle repaint event.
Bool_t HandleKey(Event_t *)
Handle key event.
void SwitchEditable(TGFrame *frame)
Switch editable.
Bool_t IsEditDisabled(TGWindow *f) const
void SwitchLayout()
Switch Horizontal/Vertical layout of selected/grabbed composite frame.
void Compact(Bool_t global=kTRUE)
Layout and Resize frame.
void HandlePaste()
Handle paste action.
TList * GetFramesInside(Int_t x0, Int_t y0, Int_t x, Int_t y)
Return the list of frames inside of some area.
Bool_t IsPasteFrameExist()
Return kTRUE if paste frame exist.
Bool_t CanCompact(TGWindow *w) const
kTRUE is frame could be compacted/"layouted"
unsigned int UInt_t
Definition: RtypesCore.h:42
void SetEditable(Bool_t on=kTRUE)
Grab server.
Bool_t IsFixedH(TGWindow *f) const
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
void RaiseMdiFrame(TGFrame *in)
Raise guibuilder's mdi frame.
void HandleAlignment(Int_t to, Bool_t lineup=kFALSE)
Align frames located inside lasso area.
static TGFontDialog * GetGlobalFontDialog()
Create global font dialog.
Bool_t SaveFrame(const char *file=0)
Save composite frame as macro.
EActionType
void DeleteMenuDialog()
Delete dialog and trash.
static TGFontDialog * fgGlobalFontDialog
void DoDialogApply()
Process dialog Apply button pressed.
void SetBuilder(TRootGuiBuilder *b)
TGuiBldDragManagerPimpl * fPimpl
Bool_t IsGrabDisabled(TGWindow *f) const
void HandleReplace()
Handle replace.
long Long_t
Definition: RtypesCore.h:50
Bool_t HandleEvent(Event_t *)
Handle all events.
void ChangePicture(TGPictureButton *)
Invoke file dialog to assign a new picture.
void DeletePropertyEditor()
Delete widget property editor.
double f(double x)
TGPopupMenu * fFrameMenu
Bool_t HandleDestroyNotify(Event_t *)
Handle destroy notify.
Double_t y[n]
Definition: legend1.C:17
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN
Definition: NeuralNet.icc:539
Bool_t RecognizeGesture(Event_t *, TGFrame *frame=0)
Recognize what was done when mouse button pressed.
Int_t GetEndDragY() const
Returns the current Y coordinate of the dragged frame.
TGFrame * GetEditableParent(TGFrame *f)
Return the parent frame which can be editted.
TGFrame * GetTarget() const
void PlaceFrame(TGFrame *, TGLayoutHints *)
Put created frame at position of the last mouse click.
void HighlightCompositeFrame(Window_t)
Raise composite frame when mouse is moving over it.
Bool_t StartDrag(TGFrame *src, Int_t x, Int_t y)
Start dragging.
Mother of all ROOT objects.
Definition: TObject.h:37
Handle_t Window_t
Definition: GuiTypes.h:30
Bool_t IsLassoDrawn() const
void SetGridStep(UInt_t step)
Set the grid step.
void DrawGrabRectangles(TGWindow *win=0)
Draw small grab rectangles around grabbed/selected/frame.
void DoRedraw()
Redraw the editted window.
void HandleButon3Pressed(Event_t *, TGFrame *frame=0)
Handle 3d mouse pressed (popup context menu)
Recorder of operations for undo and redo.
Definition: TQCommand.h:105
Definition: file.py:1
Bool_t IsSelectedVisible()
Return kTRUE if grabbed/selected frame is not overlapped by other windows.
void HandleCopy(Bool_t brk_layout=kTRUE)
Handle copy.
void DoClassMenu(Int_t)
Process a method chosen via frame context menu.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
void ChangeBackgroundColor(TGListBox *)
Set background color for list box entries.
Bool_t HandleSelection(Event_t *)
not used yet.
void HideGrabRectangles()
Hide/Unmap grab rectangles.
Bool_t CanChangeLayout(TGWindow *w) const
kTRUE - if it's possible to switch disable/enable layout
friend class TGuiBldMenuDialog
void GrabFrame(TGFrame *frame)
grab frame (see SelectFrame)
TGFrame * GetBtnEnableParent(TGFrame *fr)
Return a parent which can handle button evevents.
void ReparentFrames(TGFrame *newfr, TGCompositeFrame *oldfr)
Reparent frames.
const Bool_t kTRUE
Definition: Rtypes.h:91
void ChangeTextColor(TGGroupFrame *)
Change text color via color selection dialog.
void DoResize()
handle resize
void HandleUpdateSelected(TGFrame *)
When selected frame was changed by guibuilder editor -> update its appearence.
void DoReplace(TGFrame *frame)
Replace frame (doesn't work yet properly)
Int_t GetStrartDragX() const
Return the X coordinate where drag started.
Bool_t HandleTimer(TTimer *)
The main event loop is originated here It repeadeatly queries pointer state and position on the scree...
Int_t GetStrartDragY() const
Return the Y coordinate where drag started.
Bool_t HandleSelectionRequest(Event_t *)
not used yet.
void Menu4Frame(TGFrame *, Int_t x, Int_t y)
Create and place context menu for selected frame.
void Menu4Lasso(Int_t x, Int_t y)
Create context menu for lasso actions.
void DoDialogCancel()
Process dialog Cancel button pressed.
void DoMove()
Handle move.
TGuiBldEditor * fEditor
void CloseMenus()
Helper to close all menus.
TGFrame * GetMovableParent(TGWindow *p)
Find parent frame which can be dragged.
void ChangeTextFont(TGGroupFrame *)
Change text font via font selection dialog.
Bool_t IgnoreEvent(Event_t *e)
Return kTRUE if event is rejected for processing by drag manager.
void BreakLayout()
Disable/Enable layout for selected/grabbed composite frame.
Bool_t Cancel(Bool_t delSrc)
Do cancel action.