Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGuiBldDragManager.cxx
Go to the documentation of this file.
1// @(#)root/guibuilder:$Id: 99541fed972db7e4279fadcd4c0a0f0ae28a0a4d $
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
13#include "TGuiBldDragManager.h"
14#include "TGuiBldEditor.h"
15#include "TRootGuiBuilder.h"
16
17#include "TTimer.h"
18#include "TList.h"
19#include "TClass.h"
20#include "TSystem.h"
21#include "TROOT.h"
22#include "TColor.h"
23#include "TImage.h"
24
25#include "TError.h"
26#include "TClassMenuItem.h"
27#include "TMethod.h"
28#include "TMethodCall.h"
29#include "TBaseClass.h"
30#include "TDataMember.h"
31#include "TMethodArg.h"
32#include "TToggle.h"
33#include "TDataType.h"
34#include "TObjString.h"
35#include "TInterpreter.h"
36
37#include "KeySymbols.h"
38#include "TGResourcePool.h"
39#include "TGMenu.h"
40#include "TGFileDialog.h"
41#include "TGMsgBox.h"
42#include "TRandom.h"
43#include "TGButton.h"
44#include "TGMdi.h"
45#include "TGTextEntry.h"
46#include "TGDockableFrame.h"
47#include "TGColorDialog.h"
48#include "TGFontDialog.h"
49#include "TGComboBox.h"
50#include "TGCanvas.h"
51#include "TGLabel.h"
52#include "TGProgressBar.h"
53#include "TGScrollBar.h"
54#include "TVirtualX.h"
55#include "strlcpy.h"
56#include "snprintf.h"
57
58#undef DEBUG_LOCAL
59
60
61/** \class TGuiBldDragManager
62 \ingroup guibuilder
63
64Drag and drop manager used by the ROOT GUI Builder.
65
66*/
67
68
70
71static UInt_t gGridStep = 8;
75
76static const char *gSaveMacroTypes[] = {
77 "Macro files", "*.C",
78 "All files", "*",
79 0, 0
80};
81
82static const char *gImageTypes[] = {
83 "All files", "*",
84 "XPM", "*.xpm",
85 "GIF", "*.gif",
86 "PNG", "*.png",
87 "JPEG", "*.jpg",
88 "TARGA", "*.tga",
89 "BMP", "*.bmp",
90 "ICO", "*.ico",
91 "XCF", "*.xcf",
92 "CURSORS", "*.cur",
93 "PPM", "*.ppm",
94 "PNM", "*.pnm",
95 "XBM", "*.xbm",
96 "TIFF", "*.tiff",
97 "Encapsulated PostScript", "*.eps",
98 "PostScript", "*.ps",
99 "PDF", "*.pdf",
100 "ASImage XML","*.xml",
101 0, 0
102};
103
104
105////////////////////////////////////////////////////////////////////////////////
106
107
109
111
112public:
113 TGButton *fOK; // OK button
114 //TGButton *fApply; // apply button
115 TGButton *fCancel; // cancel button
116 TObject *fObject; // selected object/frame
117 TMethod *fMethod; // method to be applied
118 TGLayoutHints *fL1; // internally used layout hints
119 TGLayoutHints *fL2; // internally used layout hints
120 TList *fWidgets; // list of widgets
121
122public:
123 ~TGuiBldMenuDialog() override;
124 TGuiBldMenuDialog(const TGWindow *main, TObject *obj, TMethod *method);
125
126 const char *GetParameters();
127 void CloseWindow() override;
129 void Build();
130 void Popup();
131 void ApplyMethod();
132 void Add(const char *argname, const char *value, const char *type);
133
134};
135
137
138
139////////////////////////////////////////////////////////////////////////////////
140/// ctor.
141
143 TGTransientFrame(gClient->GetDefaultRoot(), main, 200, 100)
144{
145 fObject = obj;
146 fMethod = method;
147 if (!obj) return; // zombie
148
149 fWidgets = new TList();
150
151 fL1 = new TGLayoutHints(kLHintsTop | kLHintsCenterX, 0, 0, 5, 0);
152 fL2 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
153
154 TString title = obj->ClassName();
155 title += "::";
156 title += method->GetName();
157
158 Build();
160
161 SetWindowName(title);
162 SetIconName(title);
164
165 //TRootGuiBuilder::PropagateBgndColor(this, TRootGuiBuilder::GetBgnd());
166}
167
168////////////////////////////////////////////////////////////////////////////////
169/// dtor.
170
172{
173 fWidgets->Delete();
174 delete fWidgets;
175 delete fL1;
176 delete fL2;
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Connect buttons signals
181
183{
184 fOK->Connect("Pressed()", "TGuiBldDragManager", gGuiBldDragManager, "DoDialogOK()");
185 //fApply->Connect("Pressed()", "TGuiBldDragManager", gGuiBldDragManager, "DoDialogApply()");
186 fCancel->Connect("Pressed()", "TGuiBldDragManager", gGuiBldDragManager, "DoDialogCancel()");
187}
188
189////////////////////////////////////////////////////////////////////////////////
190/// execute method for object with input args
191
193{
194 const char *params = GetParameters();
195 fObject->Execute(fMethod->GetName(), params);
196}
197
198////////////////////////////////////////////////////////////////////////////////
199/// Return input parameters as single string.
200
202{
203 static char params[1024];
204 char param[256];
205
206 TObjString *str;
207 TObject *obj;
208
209 Int_t selfobjpos;
210// if (fMenu->GetContextMenu()->GetSelectedMenuItem())
211// selfobjpos = fMenu->GetContextMenu()->GetSelectedMenuItem()->GetSelfObjectPos();
212// else
213 selfobjpos = -1;
214
215 params[0] = 0;
216 TIter next(fWidgets);
217 Int_t nparam = 0;
218
219 while ((obj = next())) { // first element is label, skip...
220 if (obj->IsA() != TGLabel::Class()) break;
221 obj = next(); // get either TGTextEntry or TGComboBox
222 str = (TObjString *) next(); // get type string
223
224 nparam++;
225
226 const char *type = str->GetString().Data();
227 const char *data = 0;
228
229 if (obj->IsA() == TGTextEntry::Class())
230 data = ((TGTextEntry *) obj)->GetBuffer()->GetString();
231
232 // TODO: Combobox...
233
234 // if necessary, replace the selected object by it's address
235 if (selfobjpos == nparam-1) {
236 if (params[0]) strlcat(params, ",", 1024-strlen(params));
237 snprintf(param, 255, "(TObject*)0x%zx", (size_t)fObject);
238 strlcat(params, param, 1024-strlen(params));
239 }
240
241 if (params[0]) strlcat(params, ",", 1024-strlen(params));
242 if (data) {
243 if (!strncmp(type, "char*", 5))
244 snprintf(param, 255, "\"%s\"", data);
245 else
246 strlcpy(param, data, sizeof(param));
247 } else
248 strlcpy(param, "0", sizeof(param));
249
250 strlcat(params, param, 1024-strlen(params));
251 }
252
253 // if selected object is the last argument, have to insert it here
254 if (selfobjpos == nparam) {
255 if (params[0]) strlcat(params, ",", 1024-strlen(params));
256 snprintf(param, 255, "(TObject*)0x%zx", (size_t)fObject);
257 strlcat(params, param, 1024-strlen(params));
258 }
259
260 return params;
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Create a string describing method argument.
265
267{
268 static TString ret;
269
270 if (argument) {
271 ret.Form("(%s) %s", argument->GetTitle(), argument->GetName());
272 if (argument->GetDefault() && *(argument->GetDefault())) {
273 ret += " [default: ";
274 ret += argument->GetDefault();
275 ret += "]";
276 }
277 }
278
279 return ret;
280}
281
282////////////////////////////////////////////////////////////////////////////////
283/// Add a label and text input field.
284
285void TGuiBldMenuDialog::Add(const char *argname, const char *value, const char *type)
286{
287 TGLabel *l = new TGLabel(this, argname);
288 TGTextBuffer *b = new TGTextBuffer(20);
289 b->AddText(0, value);
290 TGTextEntry *t = new TGTextEntry(this, b);
291
292 t->Connect("ReturnPressed()", "TGuiBldDragManager", gGuiBldDragManager, "DoDialogOK()");
293 t->Resize(260, t->GetDefaultHeight());
294 AddFrame(l, fL1);
295 AddFrame(t, fL2);
296
297 fWidgets->Add(l);
298 fWidgets->Add(t);
300}
301
302////////////////////////////////////////////////////////////////////////////////
303/// Close window
304
306{
308}
309
310////////////////////////////////////////////////////////////////////////////////
311/// Build dialog
312
314{
315 TMethodArg *argument = 0;
316 Int_t selfobjpos = -1;
317
319 Int_t argpos = 0;
320
321 while ((argument = (TMethodArg *) next())) {
322 // Do not input argument for self object
323 if (selfobjpos != argpos) {
324 TString arg_name = CreateArgumentTitle(argument);
325 const char *argname = arg_name.Data();
326 const char *type = argument->GetTypeName();
327 TDataType *datatype = gROOT->GetType(type);
328 const char *charstar = "char*";
329 char basictype[32];
330
331 if (datatype) {
332 strlcpy(basictype, datatype->GetTypeName(), sizeof(basictype));
333 } else {
335 if (strncmp(type, "enum", 4) && (cl && !(cl->Property() & kIsEnum)))
336 Warning("Dialog", "data type is not basic type, assuming (int)");
337 strlcpy(basictype, "int", sizeof(basictype));
338 }
339
340 if (strchr(argname, '*')) {
341 strlcat(basictype, "*", 32-strlen(basictype));
342 type = charstar;
343 }
344
345 TDataMember *m = argument->GetDataMember();
346 if (m && m->GetterMethod(fObject->IsA())) {
347
348 // Get the current value and form it as a text:
349 char val[256];
350
351 if (!strncmp(basictype, "char*", 5)) {
352 char *tdefval = 0;
353 m->GetterMethod()->Execute(fObject, "", &tdefval);
354 if (tdefval && strlen(tdefval))
355 strlcpy(val, tdefval, sizeof(val));
356 } else if (!strncmp(basictype, "float", 5) ||
357 !strncmp(basictype, "double", 6)) {
358 Double_t ddefval = 0.0;
359 m->GetterMethod()->Execute(fObject, "", ddefval);
360 snprintf(val, 255, "%g", ddefval);
361 } else if (!strncmp(basictype, "char", 4) ||
362 !strncmp(basictype, "bool", 4) ||
363 !strncmp(basictype, "int", 3) ||
364 !strncmp(basictype, "long", 4) ||
365 !strncmp(basictype, "short", 5)) {
366 Longptr_t ldefval = 0L;
367 m->GetterMethod()->Execute(fObject, "", ldefval);
368 snprintf(val, 255, "%zi", (size_t)ldefval);
369 }
370
371 // Find out whether we have options ...
372
373 if (m->GetOptions()) {
374 Warning("Dialog", "option menu not yet implemented");
375 } else {
376 // we haven't got options - textfield ...
377 Add(argname, val, type);
378 }
379 } else { // if m not found ...
380
381 char val[256] = "";
382 const char *tval = argument->GetDefault();
383 if (tval) strlcpy(val, tval, sizeof(val));
384 Add(argname, val, type);
385 }
386 }
387 argpos++;
388 }
389
390 // add OK, Apply, Cancel buttons
391 TGHorizontalFrame *hf = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
393 UInt_t width = 0, height = 0;
394
395 fWidgets->Add(l1);
396
397 fOK = new TGTextButton(hf, "&OK", 1);
398 hf->AddFrame(fOK, l1);
399 fWidgets->Add(fOK);
401
402/*
403 fApply = new TGTextButton(hf, "&Apply", 2);
404 hf->AddFrame(fApply, l1);
405 fWidgets->Add(fApply);
406 height = fApply->GetDefaultHeight();
407 width = TMath::Max(width, fApply->GetDefaultWidth());
408*/
409
410 fCancel = new TGTextButton(hf, "&Cancel", 3);
411 hf->AddFrame(fCancel, l1);
415
416 // place buttons at the bottom
417 l1 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
418 AddFrame(hf, l1);
419 fWidgets->Add(l1);
420 fWidgets->Add(hf);
421
422 hf->Resize((width + 20) * 3, height);
423
424 // map all widgets and calculate size of dialog
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Popup dialog.
430
432{
435
437
438 Window_t wdummy;
439 Int_t x = (Int_t)((TGFrame*)fMain)->GetWidth();
441 gVirtualX->TranslateCoordinates(fMain->GetId(), fClient->GetDefaultRoot()->GetId(),
442 x, y, x, y, wdummy);
443
444 x += 10;
445 y += 10;
446
447 // make the message box non-resizable
450
456
457 Move(x, y);
458 SetWMPosition(x, y);
459 MapRaised();
460 fClient->WaitFor(this);
461}
462
463
464///////////////////////// auxiliary static functions ///////////////////////////
465////////////////////////////////////////////////////////////////////////////////
466/// Helper. Return a window located at point x,y (in screen coordinates)
467
469{
470 Window_t src, dst, child;
471 Window_t ret = 0;
472 Int_t xx = x;
473 Int_t yy = y;
474
476 !gClient->IsEditable()) return 0;
477
478 dst = src = child = gVirtualX->GetDefaultRootWindow();
479
480 while (child && dst) {
481 src = dst;
482 dst = child;
483 gVirtualX->TranslateCoordinates(src, dst, xx, yy, xx, yy, child);
484 ret = dst;
485 }
486 return ret;
487}
488
489////////////////////////////////////////////////////////////////////////////////
490/// Helper to layout
491
492static void layoutFrame(TGFrame *frame)
493{
494 if (!frame || !frame->InheritsFrom(TGCompositeFrame::Class())) {
495 return;
496 }
497
498 TGCompositeFrame *comp = (TGCompositeFrame*)frame;
499
500 if (comp->GetLayoutManager()) {
501 comp->GetLayoutManager()->Layout();
502 } else {
503 comp->Layout();
504 }
505 gClient->NeedRedraw(comp);
506
507 TIter next(comp->GetList());
508 TGFrameElement *fe;
509
510 while ((fe = (TGFrameElement*)next())) {
511 layoutFrame(fe->fFrame);
512 gClient->NeedRedraw(fe->fFrame);
513 }
514}
515
516////////////////////////////////////////////////////////////////////////////////
517/// Our own error handler (not used yet)
518
519static void GuiBldErrorHandler(Int_t /*level*/, Bool_t /*abort*/,
520 const char * /*location*/, const char * /*msg*/)
521{
522}
523
524////////////////////////////////////////////////////////////////////////////////
526
527public:
530 static TGGC *fgBgnd;
531
535
538 void Draw();
539 void SetStep(UInt_t step);
540 void InitPixmap();
541 void InitBgnd();
542};
543
547
548////////////////////////////////////////////////////////////////////////////////
549/// Create a grid background for the selected window
550
552{
553 fPixmap = 0;
554 fWindow = 0;
555 fWinId = 0;
556
557 if (!fgBgnd) {
558 InitBgnd();
559 }
561}
562
563////////////////////////////////////////////////////////////////////////////////
564/// ctor.
565
567{
568 fWindow = gClient->GetWindowById(fWinId);
569
570 if (fWindow) {
572 fWindow->SetBackgroundColor(((TGFrame*)fWindow)->GetBackground());
573 gClient->NeedRedraw(fWindow, kTRUE);
574 }
575 if (fPixmap) {
576 gVirtualX->DeletePixmap(fPixmap);
577 }
578
579 fPixmap = 0;
580 fWindow = 0;
581 fWinId = 0;
582}
583
584////////////////////////////////////////////////////////////////////////////////
585/// Set the grid step
586
588{
589 if (!gClient || !gClient->IsEditable()) {
590 return;
591 }
592
593 fWindow = (TGWindow*)gClient->GetRoot();
594 fWinId = fWindow->GetId();
595 fgStep = step;
596 InitPixmap();
597
598}
599
600////////////////////////////////////////////////////////////////////////////////
601/// Create grid background.
602
604{
605 if (fgBgnd) {
606 return;
607 }
608
610
611 Float_t r, g, b;
612
613 r = 232./255;
614 g = 232./255;
615 b = 226./255;
616
619}
620
621////////////////////////////////////////////////////////////////////////////////
622/// Create grid background pixmap
623
625{
626 if (fPixmap) {
627 gVirtualX->DeletePixmap(fPixmap);
628 }
629
630 fPixmap = gVirtualX->CreatePixmap(gClient->GetDefaultRoot()->GetId(), fgStep, fgStep);
631 gVirtualX->FillRectangle(fPixmap, fgBgnd->GetGC(), 0, 0, fgStep, fgStep);
632
633 if(fgStep > 2) {
634 gVirtualX->FillRectangle(fPixmap, TGFrame::GetShadowGC()(),
635 fgStep - 1, fgStep - 1, 1, 1);
636 }
637}
638
639////////////////////////////////////////////////////////////////////////////////
640/// Draw grid over edited frame.
641
643{
644 if (!gClient || !gClient->IsEditable()) {
645 return;
646 }
647
648 fWindow = gClient->GetWindowById(fWinId);
649
650 if (fWindow && (fWindow != gClient->GetRoot())) {
652 fWindow->SetBackgroundColor(((TGFrame*)fWindow)->GetBackground());
653 gClient->NeedRedraw(fWindow);
654 }
655
656 if (!fPixmap) {
657 InitPixmap();
658 }
659
660 fWindow = (TGWindow*)gClient->GetRoot();
661 fWinId = fWindow->GetId();
663
664 gClient->NeedRedraw(fWindow);
665}
666
667
668////////////////////////////////////////////////////////////////////////////////
670
671private:
672 TGuiBldDragManager *fManager; // back pointer
673
674public:
676 TTimer(ms, kTRUE) { fManager = m; }
677 Bool_t Notify() override { fManager->HandleTimer(this); Reset(); return kFALSE; }
678};
679
680
681////////////////////////////////////////////////////////////////////////////////
682class TGGrabRect : public TGFrame {
683
684private:
687
688public:
690 ~TGGrabRect() override {}
691
692 Bool_t HandleButton(Event_t *ev) override;
693 ECursor GetType() const { return fType; }
694};
695
696////////////////////////////////////////////////////////////////////////////////
697/// ctor.
698
700 TGFrame(gClient->GetDefaultRoot(), 8, 8, kTempFrame)
701{
702 fType = kTopLeft;
703
704 switch (type) {
705 case 0:
706 fType = kTopLeft;
707 break;
708 case 1:
709 fType = kTopSide;
710 break;
711 case 2:
713 break;
714 case 3:
716 break;
717 case 4:
719 break;
720 case 5:
722 break;
723 case 6:
725 break;
726 case 7:
728 break;
729 }
730
733 attr.fOverrideRedirect = kTRUE;
734 attr.fSaveUnder = kTRUE;
735
736 gVirtualX->ChangeWindowAttributes(fId, &attr);
737
738 fPixmap = gVirtualX->CreatePixmap(gVirtualX->GetDefaultRootWindow(), 8, 8);
740//fClient->GetResourcePool()->GetSelectedBckgndGC();
742
743 Pixel_t back;
744 fClient->GetColorByName("black", back);
745 gc->SetBackground(back);
746 gc->SetForeground(back);
747
748 gVirtualX->FillRectangle(fPixmap, bgc->GetGC(), 0, 0, 7, 7);
749 gVirtualX->DrawRectangle(fPixmap, gc->GetGC(), 0, 0, 7, 7);
750// gVirtualX->DrawRectangle(fPixmap, fClient->GetResourcePool()->GetSelectedBckgndGC()->GetGC(), 1, 1, 5, 5);
751
754
755 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(fType));
756}
757
758////////////////////////////////////////////////////////////////////////////////
759/// Handle button press event.
760
762{
764 return kTRUE;
765}
766
767////////////////////////////////////////////////////////////////////////////////
768class TGAroundFrame : public TGFrame {
769
770public:
772 ~TGAroundFrame() override {}
773};
774
775////////////////////////////////////////////////////////////////////////////////
776/// ctor.
777
778TGAroundFrame::TGAroundFrame() : TGFrame(gClient->GetDefaultRoot(), 1, 1,
780{
783 attr.fOverrideRedirect = kTRUE;
784 attr.fSaveUnder = kTRUE;
785
786 gVirtualX->ChangeWindowAttributes(fId, &attr);
787 ULong_t blue;
788 fClient->GetColorByName("blue", blue);
789 SetBackgroundColor(blue);
790}
791
792
793////////////////////////////////////////////////////////////////////////////////
795
797
798private:
799 TGuiBldDragManager *fManager; // drag and drop manager
800 TTimer *fRepeatTimer; // repeat rate timer (when mouse stays pressed)
801 TGFrame *fGrab; // grabbed/selected frame
802 TGLayoutHints *fGrabLayout; // layout of grabbed frame
803 TGFrame *fSaveGrab; // used during context menu handling
804 TGFrame *fClickFrame; // last clicked frame
806 ECursor fResizeType; // defines resize type
807 Int_t fX0, fY0; // initial drag position in pixels
808 Int_t fX, fY; // current drag position in pixels
809 Int_t fXf, fYf; // offset of initial position inside frame
811 const TGWindow *fGrabParent; // parent of the grabbed/selected frame
814 TGGrabRect *fGrabRect[8]; // small rectangles drawn over grabbed/selected frame
815 TGFrame *fAroundFrame[4]; // red lines drawn over laid out frame
820 TGFrame *fPlane; // highlighted plain composite frame when mose is moving
821 TGFrame *fSpacePressedFrame; // frame which was grabbed via spacebar pressed
822 Bool_t fPlacePopup; // kTRUE is menu fo frame was placed
823 TList *fFrameMenuTrash; // trash list
824 TGFrame *fMenuObject; // object/frame for which context menu is created
825
826public:
828 fManager = m;
830
831 int i = 0;
832 for (i = 0; i <8; i++) {
833 fGrabRect[i] = new TGGrabRect(i);
834 }
835 for (i = 0; i <4; i++) {
836 fAroundFrame[i] = new TGAroundFrame();
837 }
838
839 fFrameMenuTrash = new TList();
840
841 ResetParams();
842 }
843 void ResetParams() {
844 fGrab = 0;
845 fSaveGrab = 0;
846 fClickFrame = 0;
847 fGrid = 0;
848 fX0 = fY0 = fX = fY = fXf = fYf = fGrabX = fGrabY = 0;
849 fGrabParent = 0;
853 fGrabLayout = 0;
858 fPlane = 0;
862 fMenuObject = 0;
863 }
864
866 int i;
867 for (i = 0; i <8; i++) {
868 delete fGrabRect[i];
869 }
870 for (i = 0; i <4; i++) {
871 delete fAroundFrame[i];
872 }
873
874 delete fRepeatTimer;
875 delete fGrab;
877 delete fFrameMenuTrash;
878
879 if (fPlane) {
881 gClient->NeedRedraw(fPlane, kTRUE);
882 fPlane = 0;
883 }
884 }
885};
886
887
888////////////////////////////////////////////////////////////////////////////////
890 TGFrame(gClient->GetDefaultRoot(), 1, 1)
891{
892 // Constructor. Create "fantom window".
893
896 attr.fOverrideRedirect = kTRUE;
897 attr.fSaveUnder = kTRUE;
898
899 gVirtualX->ChangeWindowAttributes(fId, &attr);
900
901 gGuiBldDragManager = this;
903
905 fFrameMenu = 0;
906 fLassoMenu = 0;
907 fEditor = 0;
908 fBuilder = 0;
911 fStop = kTRUE;
912 fSelected = 0;
913 fListOfDialogs = 0;
914
915 Reset1();
917
918 TString tmpfile = gSystem->TempDirectory();
919 char *s = gSystem->ConcatFileName(tmpfile.Data(),
920 TString::Format("RootGuiBldClipboard%d.C", gSystem->GetPid()));
921 fPasteFileName = s;
922 delete [] s;
923
924 s = gSystem->ConcatFileName(tmpfile.Data(),
925 TString::Format("RootGuiBldTmpFile%d.C", gSystem->GetPid()));
926 fTmpBuildFile = s;
927 delete [] s;
928
929 fName = "Gui Builder Drag Manager";
931
932 // let's try to solve the problems by myself
934
936}
937
938////////////////////////////////////////////////////////////////////////////////
939/// Destructor
940
942{
944
945 delete fPimpl;
946
947 delete fBuilder;
948 fBuilder = 0;
949
950// delete fEditor;
951// fEditor = 0;
952
953 delete fFrameMenu;
954 fFrameMenu =0;
955
956 delete fLassoMenu;
957 fLassoMenu = 0;
958
961 }
962
963 delete fListOfDialogs;
964
966}
967
968////////////////////////////////////////////////////////////////////////////////
969/// Reset some parameters
970
972{
974 fTargetId = 0;
977}
978
979////////////////////////////////////////////////////////////////////////////////
980/// Create a list of dialog methods
981
983{
984 fListOfDialogs = new TList();
985
986 TList *methodList = IsA()->GetListOfMethods();
987 TIter next(methodList);
988 TString str;
989 TMethod *method;
990
991 while ((method = (TMethod*) next())) {
992 str = method->GetCommentString();
993 if (str.Contains("*DIALOG")) {
994 fListOfDialogs->Add(method);
995 }
996 }
997}
998
999////////////////////////////////////////////////////////////////////////////////
1000/// Draw grid on editable frame and restore background on previously edited one
1001
1003{
1004 if (fStop) {
1005 return;
1006 }
1007
1008 delete fPimpl->fGrid;
1009
1011 fPimpl->fGrid->Draw();
1012}
1013
1014////////////////////////////////////////////////////////////////////////////////
1015/// Return the grid step
1016
1018{
1019 return fPimpl->fGrid ? fPimpl->fGrid->fgStep : 1;
1020}
1021
1022////////////////////////////////////////////////////////////////////////////////
1023/// Set the grid step
1024
1026{
1027 fPimpl->fGrid->SetStep(step);
1028}
1029
1030////////////////////////////////////////////////////////////////////////////////
1031/// Return kTRUE if event is rejected for processing by drag manager
1032
1034{
1035 if (fStop || !fClient || !fClient->IsEditable()) return kTRUE;
1036 if (event->fType == kClientMessage) return kFALSE;
1037 if (event->fType == kDestroyNotify) return kFALSE;
1038
1040
1041 if (w) {
1042 if (IsEditDisabled(w)) {
1044 return !w;
1045 }
1046 } else {
1047 return kTRUE;
1048 }
1049 return kFALSE;
1050}
1051
1052////////////////////////////////////////////////////////////////////////////////
1053/// Return a pointer to the parent window (which is being edited)
1054
1056{
1057 if (fStop || !id) {
1058 return 0;
1059 }
1060
1061 Window_t preparent = id;
1062 Window_t parent = (Window_t)gVirtualX->GetParent(id);
1063
1064 while (!parent || (parent != fClient->GetDefaultRoot()->GetId())) {
1065 if (parent == fClient->GetRoot()->GetId()) {
1066 TGWindow *w = fClient->GetWindowById(preparent);
1067 return (w ? (TGFrame*)w : 0);
1068 }
1069 preparent = parent;
1070 parent = gVirtualX->GetParent(parent);
1071 }
1072 return 0;
1073}
1074
1075////////////////////////////////////////////////////////////////////////////////
1076/// Find the first composite parent of window
1077
1079{
1080 if (fStop || !id) {
1081 return 0;
1082 }
1083
1084 Window_t parent = id;
1085
1086 while (!parent || (parent != fClient->GetDefaultRoot()->GetId())) {
1087 TGWindow *w = fClient->GetWindowById(parent);
1088 if (w) {
1089 if (w->InheritsFrom(TGCompositeFrame::Class())) {
1090 return (TGCompositeFrame*)w;
1091 }
1092 }
1093 parent = gVirtualX->GetParent(parent);
1094 }
1095 return 0;
1096}
1097
1098////////////////////////////////////////////////////////////////////////////////
1099/// Set cursor for selected/grabbed frame.
1100
1102{
1103 if (fStop) {
1104 return;
1105 }
1106
1107 static UInt_t gid = 0;
1108 static UInt_t rid = 0;
1109
1110 if (fPimpl->fGrab && (gid != fPimpl->fGrab->GetId())) {
1111 gVirtualX->SetCursor(fPimpl->fGrab->GetId(),
1112 gVirtualX->CreateCursor((ECursor)cur));
1113 gid = fPimpl->fGrab->GetId();
1114 }
1115 if (fClient->IsEditable() && (rid != fClient->GetRoot()->GetId())) {
1116 gVirtualX->SetCursor(fClient->GetRoot()->GetId(),
1117 gVirtualX->CreateCursor((ECursor)cur));
1118 rid = fClient->GetRoot()->GetId();
1119 }
1120}
1121
1122////////////////////////////////////////////////////////////////////////////////
1123/// Check resize type event.
1124
1126{
1127 if (fStop) {
1128 return kFALSE;
1129 }
1130
1131 Bool_t ret = kFALSE;
1133
1134 for (int i = 0; i < 8; i++) {
1135 if (fPimpl->fGrabRect[i]->GetId() == event->fWindow) {
1137 ret = kTRUE;
1138 }
1139 }
1140
1141 if ((event->fType == kButtonPress) && (fPimpl->fResizeType != kPointer)) {
1143 ret = kTRUE;
1144 }
1145
1147 return ret;
1148}
1149
1150////////////////////////////////////////////////////////////////////////////////
1151/// Redraw the edited window
1152
1154{
1155 if (fStop || !fClient || !fClient->IsEditable()) {
1156 return;
1157 }
1158
1159 TGWindow *root = (TGWindow*)fClient->GetRoot();
1160
1161 fClient->NeedRedraw(root, kTRUE);
1162
1163 if (fBuilder) {
1165 }
1166}
1167
1168////////////////////////////////////////////////////////////////////////////////
1169/// Switch editable
1170
1172{
1173 if (fStop || !frame) {
1174 return;
1175 }
1176
1177 TGCompositeFrame *comp = 0;
1178
1179 if (frame->InheritsFrom(TGCompositeFrame::Class()) && CanChangeLayout(frame)) {
1180 comp = (TGCompositeFrame *)frame;
1181 } else if (frame->GetParent()->InheritsFrom(TGCompositeFrame::Class())) {
1182 comp = (TGCompositeFrame *)frame->GetParent();
1183 }
1184
1185 if (!comp) {
1186 return;
1187 }
1188
1189 TString str = comp->ClassName();
1190 str += "::";
1191 str += comp->GetName();
1192
1193 if (IsEditDisabled(comp)) {
1194 if (fBuilder) {
1195 str += " cannot be edited.";
1197 }
1198 return;
1199 }
1200
1201 if (frame != comp) {
1202 SelectFrame(frame);
1203 }
1204
1205 if (comp->IsEditable()) {
1206 return;
1207 }
1208
1209 RaiseMdiFrame(comp);
1210 comp->SetEditable(kTRUE);
1211}
1212
1213////////////////////////////////////////////////////////////////////////////////
1214/// Grab/Select frame
1215
1217{
1218 if (fStop || !frame || (frame->GetParent() == fClient->GetDefaultRoot()) ||
1219 !fClient->IsEditable()) {
1220 return;
1221 }
1222
1223 TString str = frame->ClassName();
1224 str += "::";
1225 str += frame->GetName();
1226
1227 if (IsGrabDisabled(frame)) {
1228 if (fBuilder) {
1229 str += "can not be selected";
1231 }
1232 return;
1233 }
1234
1235 // do not grab mdi frames (quick hack)
1236 if (fBuilder && frame->InheritsFrom(TGMdiFrame::Class())) {
1237 return;
1238 }
1239
1240
1241 static Int_t x, x0, y, y0, xx, yy;
1242 Window_t c;
1243
1245 frame->MapRaised();
1246
1247 if (!add) {
1248
1250
1251 gVirtualX->TranslateCoordinates(frame->GetId(),
1253 0, 0, x0, y0, c);
1254
1255 x = x0 + frame->GetWidth();
1256 y = y0 + frame->GetHeight();
1257
1258 if (fBuilder) {
1259 str += " selected";
1260 str += (IsEditDisabled(frame) || IsFixedLayout(frame) ? ". This frame cannot be edited." :
1261 " ");
1262 str += " Press SpaceBar to unselect the frame.";
1263 if (IsFixedSize(frame)) str += " This frame cannot be resized.";
1264
1266 }
1267
1268 } else { //shift mask is on
1269
1270 gVirtualX->TranslateCoordinates(frame->GetId(),
1272 0, 0, xx, yy, c);
1273
1275 fPimpl->fX0 = x0 = TMath::Min(x0, xx);
1276 fPimpl->fX = x = TMath::Max(x, xx + (Int_t)frame->GetWidth());
1277 fPimpl->fY0 = y0 = TMath::Min(y0, yy);
1278 fPimpl->fY = y = TMath::Max(y, yy + (Int_t)frame->GetHeight());
1279
1280 DrawLasso();
1281 }
1282
1283 fFrameUnder = fPimpl->fGrab = frame;
1285
1286 // quick hack. the special case for TGCanvases
1287 if (frame->InheritsFrom(TGCanvas::Class())) {
1288 fSelected = ((TGCanvas*)frame)->GetContainer();
1289
1290 if (!IsEditDisabled(fSelected)) {
1292 if (fBuilder && fBuilder->GetAction()) {
1294 }
1295 }
1296 } else {
1298 }
1300
1302
1305}
1306
1307////////////////////////////////////////////////////////////////////////////////
1308/// Inform outside wold that selected frame was changed
1309
1311{
1312 if (fStop) {
1313 return;
1314 }
1315
1316 TGFrame *sel = fr;
1317
1318 if (fBuilder && (sel == fBuilder->GetMdiMain()->GetCurrent())) {
1319 sel = 0;
1320 }
1321
1322 if (!fr) {
1323 UngrabFrame();
1324 }
1325
1326 if (fEditor) {
1328 }
1329
1330 if (fBuilder) {
1332 //fBuilder->Update();
1333 }
1334}
1335
1336////////////////////////////////////////////////////////////////////////////////
1337/// grab frame (see SelectFrame)
1338
1340{
1341 if (fStop || !frame || !fClient->IsEditable()) {
1342 return;
1343 }
1344
1345 fPimpl->fGrabParent = frame->GetParent();
1346 fPimpl->fGrabX = frame->GetX();
1347 fPimpl->fGrabY = frame->GetY();
1348
1349 Window_t c;
1350
1351 gVirtualX->TranslateCoordinates(frame->GetId(),
1353 0, 0, fPimpl->fX0, fPimpl->fY0, c);
1354
1355 fPimpl->fX = fPimpl->fX0;
1356 fPimpl->fY = fPimpl->fY0;
1357
1358 if (frame->GetFrameElement() && frame->GetFrameElement()->fLayout) {
1360 }
1361
1362 if (fPimpl->fGrabParent && frame->GetFrameElement() &&
1364 TList *li = ((TGCompositeFrame*)fPimpl->fGrabParent)->GetList();
1366 ((TGCompositeFrame*)fPimpl->fGrabParent)->RemoveFrame(frame);
1367 }
1368
1371 attr.fOverrideRedirect = kTRUE;
1372 attr.fSaveUnder = kTRUE;
1373
1374 gVirtualX->ChangeWindowAttributes(frame->GetId(), &attr);
1375
1376 frame->UnmapWindow();
1378 gVirtualX->Update(1);
1379 frame->Move(fPimpl->fX0, fPimpl->fY0);
1380 frame->MapRaised();
1381
1382 if (fBuilder) {
1383 //fBuilder->Update();
1384 TString str = frame->ClassName();
1385 str += "::";
1386 str += frame->GetName();
1387 str += " is grabbed";
1388
1390 }
1391}
1392
1393////////////////////////////////////////////////////////////////////////////////
1394/// Ungrab/Unselect selected/grabbed frame.
1395
1397{
1398 if (fStop || !fPimpl->fGrab) {
1399 return;
1400 }
1401
1404
1405 DoRedraw();
1406
1407 if (fBuilder) {
1408 //fBuilder->Update();
1409 TString str = fPimpl->fGrab->ClassName();
1410 str += "::";
1411 str += fPimpl->fGrab->GetName();
1412 str += " ungrabbed";
1414 }
1415 fSelected = fPimpl->fGrab = 0;
1416}
1417
1418////////////////////////////////////////////////////////////////////////////////
1419/// Helper for IsPointVisible
1420
1422{
1423 const TGWindow *parent = grab;
1424
1425 while (parent && (parent != gClient->GetDefaultRoot())) {
1426 if (parent->GetId() == id) {
1427 return kTRUE;
1428 }
1429 parent = parent->GetParent();
1430 }
1431
1432 return kFALSE;
1433}
1434
1435////////////////////////////////////////////////////////////////////////////////
1436/// Helper function for IsSelectedWindow method
1437
1439{
1440 Window_t w = gVirtualX->GetDefaultRootWindow();
1441 Window_t src, dst, child;
1442 Int_t x = xi;
1443 Int_t y = yi;
1444 Bool_t ret = kFALSE;
1445
1446 gVirtualX->TranslateCoordinates(fPimpl->fGrab->GetId(), w, x, y, x, y, child);
1447
1448 dst = src = child = w;
1449
1450 while (child) {
1451 src = dst;
1452 dst = child;
1453 gVirtualX->TranslateCoordinates(src, dst, x, y, x, y, child);
1454
1456 return kTRUE;
1457 }
1458 }
1459
1460 return ret;
1461}
1462
1463////////////////////////////////////////////////////////////////////////////////
1464/// Return kTRUE if grabbed/selected frame is not overlapped by other windows.
1465
1467{
1468 if (fStop || !fPimpl->fGrab || !fClient->IsEditable()) {
1469 return kFALSE;
1470 }
1471
1472 if (fBuilder) {
1474 if (mdi && (mdi != fBuilder->GetMdiMain()->GetCurrent())) {
1475 return kFALSE;
1476 }
1477 }
1478
1479 // popup menu was placed
1480 if (fPimpl->fPlacePopup) {
1481 return kTRUE;
1482 }
1483
1484 static Long64_t was = gSystem->Now();
1485 static Bool_t visible = kFALSE;
1486
1487 Long64_t now = gSystem->Now();
1488
1489 if (now-was < 100) {
1490 return visible;
1491 }
1492 was = now;
1493
1494 visible = kFALSE;
1495
1496 if (!IsPointVisible(2, 2)) {
1497 return visible;
1498 }
1499
1500 if (!IsPointVisible(2, fPimpl->fGrab->GetHeight()-2)) {
1501 return visible;
1502 }
1503
1504 if (!IsPointVisible(fPimpl->fGrab->GetWidth()-2, 2)) {
1505 return visible;
1506 }
1507
1509 fPimpl->fGrab->GetHeight()-2)) {
1510 return visible;
1511 }
1512
1513 visible = kTRUE;
1514
1515 return visible;
1516}
1517
1518////////////////////////////////////////////////////////////////////////////////
1519/// Draw small grab rectangles around grabbed/selected/frame
1520
1522{
1523 if (fStop) {
1524 return;
1525 }
1526
1527 TGFrame *frame = win ? (TGFrame *)win : fPimpl->fGrab;
1528
1529 if (!frame || !fClient->IsEditable() || fPimpl->fPlacePopup) {
1530 return;
1531 }
1532
1533 Window_t w = gVirtualX->GetDefaultRootWindow();
1534 Window_t c; Int_t x, y;
1535
1536 gVirtualX->TranslateCoordinates(frame->GetId(), w, 0, 0, x, y, c);
1537
1538 if (frame->InheritsFrom(TGCompositeFrame::Class()) &&
1539 CanChangeLayout(frame) && !frame->IsLayoutBroken()) {
1540 fPimpl->fAroundFrame[0]->MoveResize(x-3, y-3, frame->GetWidth()+6, 2);
1542 fPimpl->fAroundFrame[1]->MoveResize(x+frame->GetWidth()+3, y-3, 2, frame->GetHeight()+6);
1544 fPimpl->fAroundFrame[2]->MoveResize(x-3, y+frame->GetHeight()+2, frame->GetWidth()+6, 2);
1546 fPimpl->fAroundFrame[3]->MoveResize(x-3, y-3, 2, frame->GetHeight()+6);
1548 } else {
1549 for (int i = 0; i < 4; i++) fPimpl->fAroundFrame[i]->UnmapWindow();
1550 }
1551
1552 // draw rectangles
1553 DrawGrabRect(0, x - 6, y - 6);
1554 DrawGrabRect(1, x + frame->GetWidth()/2 - 3, y - 6);
1555 DrawGrabRect(2, x + frame->GetWidth(), y - 6);
1556 DrawGrabRect(3, x - 6, y + frame->GetHeight());
1557 DrawGrabRect(4, x - 6, y + frame->GetHeight()/2 - 3);
1558 DrawGrabRect(5, x + frame->GetWidth(), y + frame->GetHeight()/2 - 3);
1559 DrawGrabRect(6, x + frame->GetWidth()/2 - 3, y + frame->GetHeight());
1560 DrawGrabRect(7, x + frame->GetWidth(), y + frame->GetHeight());
1561
1563}
1564
1565////////////////////////////////////////////////////////////////////////////////
1566/// Helper method to draw grab rectangle at position x,y
1567
1569{
1570 if (fStop) {
1571 return;
1572 }
1573
1574 fPimpl->fGrabRect[i]->Move(x, y);
1575 fPimpl->fGrabRect[i]->MapRaised();
1576}
1577
1578////////////////////////////////////////////////////////////////////////////////
1579/// Raise composite frame when mouse is moving over it.
1580/// That allows to highlight position of "plain" composite frames.
1581
1583{
1584 static Window_t gw = 0;
1585
1586 if (fStop || !win || (win == gw)) {
1587 return;
1588 }
1589
1591
1592 if (!w || (w == fPimpl->fPlane) || w->GetEditDisabled() || w->IsEditable() ||
1593 !w->InheritsFrom(TGCompositeFrame::Class())) {
1594 return;
1595 }
1596
1597 TGFrame *frame = (TGFrame*)w;
1598 UInt_t opt = frame->GetOptions();
1599
1600 if ((opt & kRaisedFrame) || (opt & kSunkenFrame)) {
1601 return;
1602 }
1603
1604 gw = win;
1605 if (fPimpl->fPlane) {
1606 fPimpl->fPlane->ChangeOptions(fPimpl->fPlane->GetOptions() & ~kRaisedFrame);
1608 }
1609 fPimpl->fPlane = frame;
1612
1613 if (fBuilder) {
1614 TString str = frame->ClassName();
1615 str += "::";
1616 str += frame->GetName();
1618 }
1619}
1620
1621////////////////////////////////////////////////////////////////////////////////
1622/// The main event loop is originated here
1623/// It repeatedly queries pointer state and position on the screen.
1624/// From this info an Event_t structure is built.
1625
1627{
1628 return HandleTimerEvent(0, t);
1629}
1630
1631////////////////////////////////////////////////////////////////////////////////
1632/// Handle timer events or events coming from the recorder.
1633
1635{
1636 static Int_t gy = 0;
1637 static Int_t gx = 0;
1638 static UInt_t gstate = 0;
1639 static Window_t gw = 0;
1640
1641 Bool_t ret = kTRUE;
1642
1643 // if nothing is edited stop timer and reset everything
1644 if (!fClient || !fClient->IsEditable()) {
1646 return kFALSE;
1647 }
1648 if (!IsSelectedVisible()) {
1650 }
1651 if (e) {
1652 if (fPimpl->fRepeatTimer) {
1653 // we are replaying events from the recorder...
1656 }
1657 if (e->fType == kButtonPress)
1658 return HandleButtonPress(e);
1659 else if (e->fType == kButtonRelease)
1660 return HandleButtonRelease(e);
1661 else if (e->fState & kButton1Mask)
1662 return HandleMotion(e);
1663 return kTRUE;
1664 }
1665 Window_t dum;
1666 Event_t ev;
1667 ev.fCode = kButton1;
1668 ev.fType = kMotionNotify;
1669 ev.fState = 0;
1670
1671 gVirtualX->QueryPointer(gVirtualX->GetDefaultRootWindow(), dum, dum,
1672 ev.fXRoot, ev.fYRoot, ev.fX, ev.fY, ev.fState);
1673
1675
1676 if (ev.fWindow && (gw == ev.fWindow) && (gstate == ev.fState) &&
1677 (ev.fYRoot == gy) && (ev.fXRoot == gx)) {
1678 return kFALSE;
1679 }
1680
1681 gw = ev.fWindow;
1682 gstate = ev.fState;
1683 ev.fState &= ~16; // ignore "num lock" pressed
1684 ev.fState &= ~2; // ignore "caps lock" pressed
1685
1687 ((ev.fState == kButton1Mask) || (ev.fState == kButton3Mask) ||
1688 (ev.fState == (kButton1Mask | kKeyShiftMask)) ||
1689 (ev.fState == (kButton1Mask | kKeyControlMask)))) {
1690
1691 if (ev.fState & kButton1Mask) ev.fCode = kButton1;
1692 if (ev.fState & kButton3Mask) ev.fCode = kButton3;
1693
1694 ev.fType = kButtonPress;
1695 t->SetTime(40);
1696
1700 } else {
1701 fPimpl->fPlane = 0;
1702 }
1703
1704 ret = HandleButtonPress(&ev);
1705 TimerEvent(&ev);
1706 return ret;
1707 }
1708
1709 if ((fDragging || fMoveWaiting) && (!ev.fState || (ev.fState == kKeyShiftMask)) &&
1711
1712 ev.fType = kButtonRelease;
1713 t->SetTime(100);
1714
1715 ret = HandleButtonRelease(&ev);
1716 TimerEvent(&ev);
1717 return ret;
1718 }
1719
1721 (ev.fState & kButton2Mask) ||
1722 (ev.fState & kButton3Mask);
1723
1724 if ((ev.fYRoot == gy) && (ev.fXRoot == gx)) return kFALSE;
1725
1726 gy = ev.fYRoot;
1727 gx = ev.fXRoot;
1728
1729 if (!fMoveWaiting && !fDragging && !ev.fState) {
1730 if (!CheckDragResize(&ev) && fClient->GetWindowById(ev.fWindow)) {
1732 }
1733 } else if (ev.fState & kButton1Mask) {
1734 HandleMotion(&ev);
1735 TimerEvent(&ev);
1736 }
1737 return ret;
1738}
1739
1740////////////////////////////////////////////////////////////////////////////////
1741/// Recognize what was done when mouse button pressed
1742
1744{
1745 if (fStop) {
1746 return kFALSE;
1747 }
1748
1749 if (((event->fCode != kButton1) && (event->fCode != kButton3)) ||
1750 !frame || !fClient->IsEditable()) {
1751 return kFALSE;
1752 }
1753
1754 TGFrame *context_fr = 0;
1755 Bool_t mdi = kFALSE;
1756
1757 // hack for editable mdi frames
1758 if (frame->IsEditable() && frame->InheritsFrom(TGMdiFrame::Class())) {
1759 context_fr = frame;
1760 mdi = kTRUE;
1761 }
1762
1763 // handle context menu
1764 if (event->fCode == kButton3) {
1765 if (!fPimpl->fSpacePressedFrame) {
1766 if (!mdi) {
1767 SelectFrame(frame);
1768 context_fr = fSelected;
1769 }
1770 } else {
1771 context_fr = fPimpl->fSpacePressedFrame;
1772 }
1773
1774 HandleButon3Pressed(event, context_fr);
1775 return kTRUE;
1776 }
1777
1779
1780 if (!fSelectionIsOn) {
1781 fPimpl->fX0 = event->fXRoot;
1782 fPimpl->fY0 = event->fYRoot;
1783 }
1784
1785 //HideGrabRectangles();
1786 fPimpl->fClickFrame = frame;
1787
1788 if (fBuilder && fBuilder->IsExecutable() &&
1790 UngrabFrame();
1791 frame->SetEditable(kTRUE);
1792 fSource = 0;
1794 goto out;
1795 }
1796
1797 if (event->fState & kKeyShiftMask) {
1798 // drag grabbed frame with shift key pressed should create a copy of grabbed frame
1799 // move a copy of editable and selected frame
1800 if (frame == fPimpl->fGrab) {
1801 fSource = frame;
1803 gVirtualX->SetCursor(frame->GetId(), gVirtualX->CreateCursor(kMove));
1804 goto out;
1805 }
1806
1807 // otherwise do lasso selection
1808 if (!fSelectionIsOn) {
1810 } else {
1811 fPimpl->fX = event->fXRoot;
1812 fPimpl->fY = event->fYRoot;
1814 DrawLasso();
1815 return kTRUE;
1816 }
1817 }
1818
1819 CheckDragResize(event);
1820
1821 if (frame->IsEditable()) {
1822 fSource = 0;
1823
1824 if (fDragType != kDragResize) {
1825
1826 // move editable and selected frame
1827 if (frame == fPimpl->fGrab) {
1828 fSource = frame;
1830 gVirtualX->SetCursor(frame->GetId(), gVirtualX->CreateCursor(kMove));
1831 goto out;
1832 }
1833
1835 }
1836 } else if ((fDragType != kDragResize) && !fPimpl->fSpacePressedFrame) {
1837
1838 // special case of TGCanvas
1839 if (!fPimpl->fGrab && frame->InheritsFrom(TGCanvas::Class())) {
1840 TGFrame *cont = ((TGCanvas*)frame)->GetContainer();
1841
1842 if (!cont->IsEditable()) {
1843 cont->SetEditable(kTRUE);
1845 goto out;
1846 }
1847 }
1848
1849 fSource = frame;
1850 SelectFrame(frame, event->fState & kKeyShiftMask);
1851 }
1852
1854 SwitchEditable(frame);
1855 fSource = 0;
1856
1857 // try again
1858 CheckDragResize(event);
1859
1860 if (fDragType == kDragNone) {
1861 return kFALSE;
1862 }
1863 }
1864
1865out:
1866 Window_t c;
1867
1868 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
1869 frame->GetId(),
1870 event->fXRoot, event->fYRoot,
1871 fPimpl->fXf, fPimpl->fYf, c);
1872 fPimpl->fX = event->fXRoot;
1873 fPimpl->fY = event->fYRoot;
1874
1876 DoRedraw();
1877
1878 return kTRUE;
1879}
1880
1881////////////////////////////////////////////////////////////////////////////////
1882/// Handle 3d mouse pressed (popup context menu)
1883
1885{
1886 if (fStop || !frame) {
1887 return;
1888 }
1889
1891 return;
1892 }
1893
1894 if (frame == fSelected) {
1895 Menu4Frame(frame, event->fXRoot, event->fYRoot);
1896 } else if (frame->IsEditable()) {
1897 if (fLassoDrawn) {
1898 Menu4Lasso(event->fXRoot, event->fYRoot);
1899 } else {
1900 Menu4Frame(frame, event->fXRoot, event->fYRoot);
1901 }
1902 } else {
1903 TGFrame *base = InEditable(frame->GetId());
1904 if (base) {
1905 //SelectFrame(base);
1906 Menu4Frame(base, event->fXRoot, event->fYRoot);
1907 } else {
1908 Menu4Frame(frame, event->fXRoot, event->fYRoot);
1909 }
1910 }
1911}
1912
1913////////////////////////////////////////////////////////////////////////////////
1914/// Handle button event occurred in some ROOT frame
1915
1917{
1918 if (fStop) {
1919 return kFALSE;
1920 }
1921
1922 if (event->fCode != kButton3) {
1923 CloseMenus();
1924 }
1925
1926 if (event->fType == kButtonPress) {
1927 return HandleButtonPress(event);
1928 } else {
1929 return HandleButtonRelease(event);
1930 }
1931}
1932
1933////////////////////////////////////////////////////////////////////////////////
1934/// Resize events
1935
1937{
1938 if (fStop) {
1939 return kFALSE;
1940 }
1941
1943
1944 if (!w) {
1945 return kFALSE;
1946 }
1947
1949 return kFALSE;
1950}
1951
1952////////////////////////////////////////////////////////////////////////////////
1953/// Handle repaint event
1954
1956{
1957 if (fStop) {
1958 return kFALSE;
1959 }
1960
1961 static Long64_t was = gSystem->Now();
1962 static Window_t win = 0;
1963 Long64_t now = gSystem->Now();
1964
1965 if (event->fCount || (win == event->fWindow) || (now-was < 50) || fDragging) {
1966 if (fDragging) {
1968 }
1969 return kFALSE;
1970 }
1971
1972 if (gMenuDialog) {
1975 return kFALSE;
1976 }
1977
1978 if (fLassoDrawn) {
1979 DrawLasso();
1980 } else {
1981 if (IsSelectedVisible()) {
1983 }
1984 }
1985
1986 win = event->fWindow;
1987 was = now;
1988
1989 return kFALSE;
1990}
1991
1992////////////////////////////////////////////////////////////////////////////////
1993/// Handle all events.
1994
1996{
1997 if (fStop) {
1998 return kFALSE;
1999 }
2000
2001 if (IgnoreEvent(event)) {
2002 return kFALSE;
2003 }
2004
2005 switch (event->fType) {
2006
2007 case kExpose:
2008 return HandleExpose(event);
2009
2010 case kConfigureNotify:
2011 while (gVirtualX->CheckEvent(fId, kConfigureNotify, *event))
2012 ;
2013 return HandleConfigureNotify(event);
2014
2015 case kGKeyPress:
2016 case kKeyRelease:
2017 return HandleKey(event);
2018
2019 case kFocusIn:
2020 case kFocusOut:
2021 //HandleFocusChange(event);
2022 break;
2023
2024 case kButtonPress:
2025 {
2026 Int_t dbl_clk = kFALSE;
2027
2028 static Window_t gDbw = 0;
2029 static Long_t gLastClick = 0;
2030 static UInt_t gLastButton = 0;
2031 static Int_t gDbx = 0;
2032 static Int_t gDby = 0;
2033
2034 if ((event->fTime - gLastClick < 350) &&
2035 (event->fCode == gLastButton) &&
2036 (TMath::Abs(event->fXRoot - gDbx) < 6) &&
2037 (TMath::Abs(event->fYRoot - gDby) < 6) &&
2038 (event->fWindow == gDbw)) {
2039 dbl_clk = kTRUE;
2040 }
2041
2042 if (dbl_clk) {
2043 if (event->fState & kKeyControlMask) {
2045 return kTRUE;
2046 } else if (!(event->fState & 0xFF)) {
2048
2049 if (w && (w->GetEditDisabled() & kEditDisableBtnEnable)) {
2050 return w->HandleDoubleClick(event);
2051 }
2052 if (SaveFrame(fTmpBuildFile.Data())) {
2053 gROOT->Macro(fTmpBuildFile.Data());
2054 }
2055 // an easy way to start editting
2057 return kTRUE;
2058 }
2059 } else {
2060 gDbw = event->fWindow;
2061 gLastClick = event->fTime;
2062 gLastButton = event->fCode;
2063 gDbx = event->fXRoot;
2064 gDby = event->fYRoot;
2065
2066 Bool_t ret = HandleButtonPress(event);
2067 return ret;
2068 }
2069
2070 return kFALSE;
2071 }
2072
2073 case kButtonRelease:
2074 return HandleButtonRelease(event);
2075
2076 case kEnterNotify:
2077 case kLeaveNotify:
2078 //HandleCrossing(event);
2079 break;
2080
2081 case kMotionNotify:
2082 while (gVirtualX->CheckEvent(fId, kMotionNotify, *event))
2083 ;
2084 return HandleMotion(event);
2085
2086 case kClientMessage:
2087 return HandleClientMessage(event);
2088
2089 case kDestroyNotify:
2090 return HandleDestroyNotify(event);
2091
2092 case kSelectionNotify:
2093 //HandleSelection(event);
2094 break;
2095
2096 case kSelectionRequest:
2097 //HandleSelectionRequest(event);
2098 break;
2099
2100 case kSelectionClear:
2101 //HandleSelectionClear(event);
2102 break;
2103
2104 case kColormapNotify:
2105 //HandleColormapChange(event);
2106 break;
2107
2108 default:
2109 //Warning("HandleEvent", "unknown event (%#x) for (%#x)", event->fType, fId);
2110 break;
2111 }
2112
2113 return kFALSE;
2114}
2115
2116////////////////////////////////////////////////////////////////////////////////
2117/// Mouse double click handler (never should happen)
2118
2120{
2121 if (fStop) {
2122 return kFALSE;
2123 }
2124
2125 return kFALSE;
2126}
2127
2128////////////////////////////////////////////////////////////////////////////////
2129/// Return a parent which can handle button events.
2130
2132{
2133 TGWindow *parent = fr;
2134
2135 while (parent && (parent != fClient->GetDefaultRoot())) {
2136 if (parent->GetEditDisabled() & kEditDisableBtnEnable) {
2137 return (TGFrame*)parent;
2138 }
2139 parent = (TGWindow*)parent->GetParent();
2140 }
2141 return 0;
2142}
2143
2144////////////////////////////////////////////////////////////////////////////////
2145/// Unmap all popups
2146
2148{
2149 TList *li = fClient->GetListOfPopups();
2150 if (!li->GetEntries()) {
2151 return;
2152 }
2153
2154 TGPopupMenu *pup;
2155 TIter next(li);
2156
2157 while ((pup = (TGPopupMenu*)next())) {
2158 pup->UnmapWindow();
2159 fClient->ResetWaitFor(pup);
2160 }
2161 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
2162}
2163
2164////////////////////////////////////////////////////////////////////////////////
2165/// Handle button press event
2166
2168{
2169 if (fStop) {
2170 return kFALSE;
2171 }
2172
2175
2176 if (fPimpl->fPlane) {
2179 }
2180
2181 if (gMenuDialog) { // keep editor on the top
2183 }
2184
2185 // keep undocked toolbar on the top
2186 //(but under win32 key handling will be broken : todo)
2187 if (gVirtualX->InheritsFrom("TGX11") && fBuilder &&
2190 }
2191
2192 // keep color dialog on the top
2195 return kFALSE;
2196 }
2197
2198 if ( ((event->fCode != kButton1) && (event->fCode != kButton3)) ||
2199 (event->fType != kButtonPress) || IgnoreEvent(event)) {
2200 return kFALSE;
2201 }
2202
2203 Reset1();
2204 //HideGrabRectangles();
2205
2206 Window_t w = GetWindowFromPoint(event->fXRoot, event->fYRoot);
2207 TGFrame *fr = 0;
2208
2209 if (w) {
2210 fr = (TGFrame*)fClient->GetWindowById(w);
2211 if (!fr) {
2212 return kFALSE;
2213 }
2214
2215 //fr->HandleButton(event);
2216 if (!IsEventsDisabled(fr)) {
2217 TGFrame *btnframe = GetBtnEnableParent(fr);
2218 if (btnframe) {
2219 event->fUser[0] = fr->GetId();
2220 btnframe->HandleButton(event);
2221 }
2222 }
2223
2224 if (IsGrabDisabled(fr)) {
2225 fr = GetEditableParent(fr);
2226 }
2227
2228 if (!fr) {
2229 return kFALSE;
2230 }
2231 } else {
2232 return kFALSE;
2233 }
2234
2235 return RecognizeGesture(event, fr);
2236}
2237
2238////////////////////////////////////////////////////////////////////////////////
2239/// Handle button release event
2240
2242{
2243 if (fStop) {
2244 return kFALSE;
2245 }
2246
2247 // unmap all waiting popups
2250 }
2251
2253
2254 if (w && !IsEventsDisabled(w)) {
2255 TGFrame *btnframe = GetBtnEnableParent((TGFrame*)w);
2256 if (btnframe) {
2257 event->fUser[0] = w->GetId();
2258 btnframe->HandleButton(event);
2259 }
2260 }
2261
2263 gVirtualX->SetCursor(fClient->GetRoot()->GetId(), gVirtualX->CreateCursor(kPointer));
2264 EndDrag();
2265 fSelectionIsOn &= (event->fState & kKeyShiftMask);
2266
2267 if (fLassoDrawn) {
2268 DrawLasso();
2269 return kTRUE;
2270 }
2271
2273
2274 // make editable the clicked frame if no lasso was drawn
2275 if ((fPimpl->fClickFrame == fPimpl->fGrab) && (fSelected == fPimpl->fGrab) &&
2276 !fPimpl->fGrab->IsEditable()) {
2278 return kTRUE;
2279
2280 // select/grab clicked frame if there was no grab frame
2281 } else if (!fPimpl->fGrab || ((fPimpl->fClickFrame != fPimpl->fGrab) &&
2282 (fPimpl->fClickFrame != fSelected))) {
2284 return kTRUE;
2285 }
2286
2287 }
2288
2290
2291 return kTRUE;
2292}
2293
2294////////////////////////////////////////////////////////////////////////////////
2295/// Handle key event
2296
2298{
2299 if (fStop) {
2300 return kFALSE;
2301 }
2302
2303 char tmp[10];
2304 UInt_t keysym;
2305 Bool_t ret = kFALSE;
2306 TGFileInfo fi;
2307 static TString dir(".");
2308 static Bool_t overwr = kFALSE;
2309 TString fname;
2310
2312
2313 if (!w || !fPimpl) {
2314 return kFALSE;
2315 }
2316
2317 if (w->GetEditDisabled() & kEditDisableKeyEnable) {
2318 return ((TGFrame*)w)->HandleKey(event);
2319 }
2320
2321 if (event->fType != kGKeyPress) {
2322 return kFALSE;
2323 }
2324
2325 if (IsEditDisabled(w)) {
2326 TGFrame *parent = GetEditableParent((TGFrame*)w);
2327 if (parent) {
2328 event->fWindow = parent->GetId();
2329 parent->HandleKey(event);
2330 } else {
2331 return ((TGFrame*)w)->HandleKey(event);
2332 }
2333 }
2334
2336
2337 if (fPimpl->fPlane) {
2340 }
2341
2342 CloseMenus();
2343
2345 fi.SetIniDir(dir);
2346 fi.fOverwrite = overwr;
2347
2348 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
2349
2350 if (event->fState & kKeyControlMask) {
2351
2352 switch ((EKeySym)keysym & ~0x20) {
2353 case kKey_Return:
2354 case kKey_Enter:
2356 ret = kTRUE;
2357 break;
2358 case kKey_X:
2359 HandleCut();
2360 ret = kTRUE;
2361 break;
2362 case kKey_C:
2363 HandleCopy();
2364 ret = kTRUE;
2365 break;
2366 case kKey_V:
2369 }
2370 HandlePaste();
2371 ret = kTRUE;
2372 break;
2373 case kKey_B:
2374 {
2375 if (fPimpl->fGrab ) {
2376 BreakLayout();
2377 }
2378 ret = kTRUE;
2379 break;
2380 }
2381 case kKey_L:
2382 {
2383 if (fPimpl->fGrab && (fPimpl->fClickFrame != fClient->GetRoot())) {
2384 Compact(kFALSE);
2385 } else {
2386 Compact(kTRUE);
2387 }
2388 ret = kTRUE;
2389 break;
2390 }
2391 case kKey_R:
2392 HandleReplace();
2393 ret = kTRUE;
2394 break;
2395 case kKey_S:
2396 Save();
2397 ret = kTRUE;
2398 break;
2399 case kKey_G:
2400 HandleGrid();
2401 ret = kTRUE;
2402 break;
2403 case kKey_H:
2404 SwitchLayout();
2405 ret = kTRUE;
2406 break;
2407 case kKey_N:
2408 if (fBuilder) {
2410 } else {
2411 TGMainFrame *main = new TGMainFrame(fClient->GetDefaultRoot(), 300, 300);
2412 main->MapRaised();
2413 main->SetEditable(kTRUE);
2414 }
2415 ret = kTRUE;
2416 break;
2417 case kKey_O:
2418 if (fBuilder) {
2420 } else {
2421 TGMainFrame *main = new TGMainFrame(fClient->GetDefaultRoot(), 300, 300);
2422 main->MapRaised();
2423 main->SetEditable(kTRUE);
2424 }
2425 new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi);
2426
2427 if (!fi.fFilename) return kTRUE;
2428 dir = fi.fIniDir;
2429 overwr = fi.fOverwrite;
2431
2432 if (fname.EndsWith(".C")) {
2433 gROOT->Macro(fname.Data());
2434 } else {
2435 Int_t retval;
2436 new TGMsgBox(fClient->GetDefaultRoot(), this, "Error...",
2437 TString::Format("file (%s) must have extension .C", fname.Data()),
2439 if (retval == kMBRetry) {
2440 HandleKey(event);
2441 }
2442 }
2443 ret = kTRUE;
2444 break;
2445 default:
2446 break;
2447 }
2448 } else {
2449 switch ((EKeySym)keysym) {
2450 case kKey_Delete:
2451 case kKey_Backspace:
2453 ret = kTRUE;
2454 break;
2455 case kKey_Return:
2456 case kKey_Enter:
2457 //UnmapAllPopups();
2459 ret = kTRUE;
2460 break;
2461 case kKey_Left:
2462 case kKey_Right:
2463 case kKey_Up:
2464 case kKey_Down:
2465 if (fLassoDrawn) {
2466 HandleAlignment(keysym, event->fState & kKeyShiftMask);
2467 } else if (fPimpl->fGrab) {
2468 HandleLayoutOrder((keysym == kKey_Right) || (keysym == kKey_Down));
2469 }
2470 ret = kTRUE;
2471 break;
2472 case kKey_Space:
2473 //UnmapAllPopups();
2474 if (fPimpl->fGrab) {
2476
2478
2479 if (p) {
2480 if (fBuilder && p == fBuilder->GetMdiMain()->GetCurrent()) {
2481 UngrabFrame();
2482 } else {
2483 SelectFrame(p);
2485 }
2486 }
2487 }
2488 ret = kTRUE;
2489 break;
2490 default:
2491 break;
2492 }
2493 }
2494 if (fBuilder) {
2495 fBuilder->SetAction(0);
2496 //fBuilder->Update();
2497 }
2498
2499 if (fLassoDrawn) {
2500 DrawLasso();
2501 }
2502
2503 return ret;
2504}
2505
2506////////////////////////////////////////////////////////////////////////////////
2507/// Reparent frames
2508
2510{
2511 if (fStop || !fClient->IsEditable() || (newfr == fClient->GetDefaultRoot())) {
2512 return;
2513 }
2514
2515 Int_t x0, y0, xx, yy;
2516 Window_t c;
2517 static TGLayoutHints *hints = new TGLayoutHints(kLHintsNormal, 2, 2, 2, 2);
2518
2519 if (!newfr || !newfr->GetId() || !oldfr || !oldfr->GetId()) return;
2520
2521 gVirtualX->TranslateCoordinates(newfr->GetId(), oldfr->GetId(),
2522 0, 0, x0, y0, c);
2523
2524 x0 = x0 < 0 ? 0 : x0;
2525 y0 = y0 < 0 ? 0 : y0;
2526 Int_t x = x0 + newfr->GetWidth();
2527 Int_t y = y0 + newfr->GetHeight();
2528
2529 TGCompositeFrame *comp = 0;
2530
2531 if (newfr->InheritsFrom(TGCompositeFrame::Class())) {
2532 comp = (TGCompositeFrame*)newfr;
2533 comp->SetLayoutBroken();
2534 }
2535
2536 TIter next(oldfr->GetList());
2537 TGFrameElement *el;
2538
2539 while ((el = (TGFrameElement*)next())) {
2540 TGFrame *frame = el->fFrame;
2541
2542 if ((frame->GetX() >= x0) && (frame->GetY() >= y0) &&
2543 (frame->GetX() + (Int_t)frame->GetWidth() <= x) &&
2544 (frame->GetY() + (Int_t)frame->GetHeight() <= y)) {
2545
2546 if (frame == fPimpl->fGrab) {
2547 UngrabFrame();
2548 }
2549
2550 oldfr->RemoveFrame(frame);
2551
2552 gVirtualX->TranslateCoordinates(oldfr->GetId(), newfr->GetId(),
2553 frame->GetX(), frame->GetY(), xx, yy, c);
2554
2555 frame->ReparentWindow(newfr, xx, yy);
2556
2557 if (comp) {
2558 comp->AddFrame(frame, hints); // el->fLayout);
2559 }
2560 }
2561 }
2562}
2563
2564////////////////////////////////////////////////////////////////////////////////
2565/// Return the list of frames inside of some area
2566
2568{
2569 if (fStop) {
2570 return 0;
2571 }
2572
2573 Int_t xx, yy;
2574
2576 return 0;
2577 }
2578
2579 TList *list = new TList();
2580
2581 xx = x0; yy = y0;
2582 x0 = TMath::Min(xx, x); x = TMath::Max(xx, x);
2583 y0 = TMath::Min(yy, y); y = TMath::Max(yy, y);
2584
2585 TIter next(((TGCompositeFrame*)fClient->GetRoot())->GetList());
2586 TGFrameElement *el;
2587
2588 while ((el = (TGFrameElement*)next())) {
2589 if ((el->fFrame->GetX() >= x0) && (el->fFrame->GetY() >= y0) &&
2590 (el->fFrame->GetX() + (Int_t)el->fFrame->GetWidth() <= x) &&
2591 (el->fFrame->GetY() + (Int_t)el->fFrame->GetHeight() <= y)) {
2592 list->Add(el->fFrame);
2593 }
2594 }
2595 if (list->IsEmpty()) {
2596 delete list;
2597 return 0;
2598 }
2599 return list;
2600}
2601
2602////////////////////////////////////////////////////////////////////////////////
2603/// Drop canvas container
2604
2606{
2607 if (fStop) {
2608 return;
2609 }
2610
2611 TGCompositeFrame *comp = (TGCompositeFrame*)canvas->GetParent();
2612 comp->SetEditable(kTRUE);
2613
2615 Int_t x = canvas->GetX();
2616 Int_t y = canvas->GetY();
2617
2618 cont->SetEditDisabled(cont->GetEditDisabled() & ~kEditDisableGrab);
2619 cont->ReparentWindow(comp, x, y);
2620 canvas->SetContainer(0);
2621 comp->AddFrame(cont);
2622 DeleteFrame(canvas);
2623
2624 if (fBuilder) {
2625 TString str = cont->ClassName();
2626 str += "::";
2627 str += cont->GetName();
2628 str += " dropped.";
2630 }
2631 SelectFrame(cont);
2632}
2633
2634////////////////////////////////////////////////////////////////////////////////
2635/// Create a new TGCanvas and place container into it
2636
2638{
2639 if (fStop || !cont) {
2640 return;
2641 }
2642
2644 comp->SetEditable(kTRUE);
2645
2646 UInt_t w = cont->GetWidth()/2;
2647 UInt_t h = cont->GetHeight()/2;
2648
2649 w = w < 100 ? 100 : w;
2650 h = h < 100 ? 100 : h;
2651
2652 TGCanvas *canvas = new TGCanvas(comp, w, h);
2653 canvas->Move(cont->GetX(), cont->GetY());
2654 comp->RemoveFrame(cont);
2655 comp->AddFrame(canvas);
2656 cont->ReparentWindow(canvas->GetViewPort());
2657 canvas->SetContainer(cont);
2658 cont->SetCleanup(kDeepCleanup);
2659 canvas->MapSubwindows();
2660 canvas->MapWindow();
2661 SelectFrame(canvas);
2662
2663 if (fBuilder) {
2664 fBuilder->UpdateStatusBar("Grab action performed. Press Cntrl-Return to Drop grabbed frame.");
2665 }
2666}
2667
2668////////////////////////////////////////////////////////////////////////////////
2669/// Handling of return/enter key pressing
2670///
2671/// If on is kFALSE:
2672/// If Return or Enter key was pressed - Grab Act
2673/// If lasso is drawn - new composite frame is created and
2674/// all frames inside lasso adopted as children.
2675/// If lasso is not drawn and selected frame is composite one,
2676/// - new TGCanvas widget is created and selected frame became
2677/// container for this canvas.
2678///
2679/// If on is kTRUE:
2680/// If Return or Enter key was pressed with Control Key - Drop Act,
2681/// The opposite action to the Grab Act.
2682/// If selected/grabbed frame is not a TGCanvas widget -
2683/// all frames inside the grabbed/selected frame are "dropped" into
2684/// the underlying frame and the grabbed frame is deleted.
2685///
2686/// If selected/grabbed frame is a TGCanvas widget -
2687/// container frame "dropped" to editable frame
2688
2690{
2691 if (fStop) {
2692 return;
2693 }
2694
2695 Int_t x0, y0, x, y, xx, yy;
2696 Window_t c;
2697 TGCompositeFrame *parent = 0;
2698 TList *li = 0;
2699
2701 !fClient->IsEditable()) {
2702 return;
2703 }
2704
2705 // if grabbed frame is editable - we need to switch edit to parent
2706 if (fPimpl->fGrab && fPimpl->fGrab->IsEditable()) {
2708 }
2709
2710 if (fPimpl->fGrab && !fLassoDrawn) {
2711 if (!on) {
2718 return;
2719 }
2720 } else {
2721
2722 if ((fPimpl->fGrab->IsA() == TGCanvas::Class()) &&
2723 !((TGCanvas*)fPimpl->fGrab)->GetContainer()->InheritsFrom(TGContainer::Class()) &&
2726 return;
2727 }
2728 }
2729 }
2730
2732
2733 if (fLassoDrawn) {
2734
2735 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2736 fClient->GetRoot()->GetId(),
2737 fPimpl->fX, fPimpl->fY, x, y, c);
2738 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2739 fClient->GetRoot()->GetId(),
2740 fPimpl->fX0, fPimpl->fY0, x0, y0, c);
2741
2742 xx = x0; yy = y0;
2743 x0 = TMath::Min(xx, x); x = TMath::Max(xx, x);
2744 y0 = TMath::Min(yy, y); y = TMath::Max(yy, y);
2745
2746 li = GetFramesInside(x0, y0, x, y);
2747
2748 if (!on && li) {
2749 parent = new TGCompositeFrame(comp, x - x0, y - y0);
2750 parent->MoveResize(x0, y0, x - x0, y - y0);
2751 ReparentFrames(parent, comp);
2752
2753 comp->AddFrame(parent);
2754 parent->MapWindow();
2756 SelectFrame(parent);
2757
2758 if (fBuilder) {
2759 TString str = "Grab action performed.";
2760 str += " Press Cntrl-Return to Drop grabbed frames.";
2761 str += " Press Return for TCanvas Grab";
2763 }
2764 }
2765 } else if (on && fPimpl->fGrab) {
2766
2767 // check if it is forbidden
2768 if (!CanChangeLayout(fPimpl->fGrab) ||
2770 if (fBuilder) {
2771 fBuilder->UpdateStatusBar("Drop action disabled");
2772 }
2773 return;
2774 }
2775
2777 parent = (TGCompositeFrame*)fPimpl->fGrab;
2778 } else {
2779 //parent = (TGCompositeFrame*)fPimpl->fGrab->GetParent();
2780 }
2781 if (parent) {
2782 ReparentFrames(comp, parent);
2784 UngrabFrame();
2785 ChangeSelected(0); //update editors
2786
2787 if (fBuilder) {
2788 fBuilder->UpdateStatusBar("Drop action performed");
2789 }
2790 }
2791 }
2792 delete li;
2793}
2794
2795////////////////////////////////////////////////////////////////////////////////
2796/// Align frames located inside lasso area.
2797
2799{
2800 if (fStop) {
2801 return;
2802 }
2803
2804 Int_t x0, y0, x, y, xx, yy;
2805 Window_t c;
2806 TGCompositeFrame *comp = 0;
2807
2809 !fClient->IsEditable()) {
2810 return;
2811 }
2812
2813 if (fLassoDrawn) {
2815 fClient->GetRoot()->GetId(),
2816 fPimpl->fX, fPimpl->fY, x, y, c);
2817 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2818 fClient->GetRoot()->GetId(),
2819 fPimpl->fX0, fPimpl->fY0, x0, y0, c);
2820
2821 xx = x0; yy = y0;
2822 x0 = TMath::Min(xx, x); x = TMath::Max(xx, x);
2823 y0 = TMath::Min(yy, y); y = TMath::Max(yy, y);
2824
2825 comp = (TGCompositeFrame*)fClient->GetRoot();
2826
2827 ToGrid(x, y);
2828 ToGrid(x0, y0);
2829
2830 TIter next(comp->GetList());
2831 TGFrameElement *el;
2832 TGFrame *prev = 0;
2833
2834 while ((el = (TGFrameElement*)next())) {
2835 TGFrame *fr = el->fFrame;
2836
2837 if ((fr->GetX() >= x0) && (fr->GetY() >= y0) &&
2838 (fr->GetX() + (Int_t)fr->GetWidth() <= x) &&
2839 (fr->GetY() + (Int_t)fr->GetHeight() <= y)) {
2840
2841 switch ((EKeySym)to) {
2842 case kKey_Left:
2843 fr->Move(x0, fr->GetY());
2844 if (lineup) {
2845 // coverity[dead_error_line]
2846 if (prev) fr->Move(fr->GetX(), prev->GetY() + prev->GetHeight());
2847 else fr->Move(x0, y0);
2848 }
2849 break;
2850 case kKey_Right:
2851 fr->Move(x - fr->GetWidth(), fr->GetY());
2852 if (lineup) {
2853 if (prev) fr->Move(fr->GetX(), prev->GetY() + prev->GetHeight());
2854 else fr->Move(x - fr->GetWidth(), y0);
2855 }
2856 break;
2857 case kKey_Up:
2858 fr->Move(fr->GetX(), y0);
2859 if (lineup) {
2860 if (prev) fr->Move(prev->GetX() + prev->GetWidth(), fr->GetY());
2861 else fr->Move(x0, y0);
2862 }
2863 break;
2864 case kKey_Down:
2865 fr->Move(fr->GetX(), y - fr->GetHeight());
2866 if (lineup) {
2867 if (prev) fr->Move(prev->GetX() + prev->GetWidth(), fr->GetY());
2868 else fr->Move(x0, y - fr->GetHeight());
2869 }
2870 break;
2871 default:
2872 break;
2873 }
2874 prev = fr;
2875 }
2876 }
2877 }
2878 if (fLassoDrawn) {
2879 DrawLasso();
2880 }
2881}
2882
2883////////////////////////////////////////////////////////////////////////////////
2884/// Handle delete or crop action
2885///
2886/// crop is kFALSE - delete action
2887/// - if lasso is drawn -> all frames inside lasso area are deleted
2888/// - if frame is grabbed/selected -> the frame is deleted
2889/// crop is kTRUE - crop action
2890/// - if lasso is drawn -> all frames outside of lasso area are deleted
2891/// - if frame is grabbed/selected -> all frames except the grabbed frame are deleted
2892/// In both cases the main frame is shrunk to the size of crop area.
2893
2895{
2896 if (fStop) {
2897 return;
2898 }
2899
2900 Int_t x0, y0, x, y, xx, yy, w, h;
2901 Window_t c;
2902
2904 !fClient->IsEditable()) {
2905 return;
2906 }
2907
2908 TGCompositeFrame *comp = 0;
2909 Bool_t fromGrab = kFALSE;
2910 TGFrame *frame = fPimpl->fGrab;
2911
2912 if (fBuilder && crop) {
2914 } else {
2915 comp = (TGCompositeFrame*)fClient->GetRoot();
2916 }
2917
2918 if (frame && !CanChangeLayout((TGWindow*)frame->GetParent())) {
2919 frame = GetMovableParent(frame);
2920
2921 if (!frame) {
2922 TString str = fPimpl->fGrab->ClassName();
2923 str += "::";
2924 str += fPimpl->fGrab->GetName();
2925 str += " cannot be deleted";
2926
2927 if (fBuilder) {
2929 }
2930 return;
2931 }
2932 }
2933
2934 // prepare to crop grabbed frame
2935 if (frame && !fLassoDrawn && crop) {
2936 gVirtualX->TranslateCoordinates(frame->GetId(),
2938 -2, -2,
2939 fPimpl->fX0, fPimpl->fY0, c);
2940
2941 fPimpl->fX = fPimpl->fX0 + frame->GetWidth()+4;
2942 fPimpl->fY = fPimpl->fY0 + frame->GetHeight()+4;
2943 fromGrab = kTRUE;
2944 }
2945
2946 x0 = fPimpl->fX0; y0 = fPimpl->fY0;
2947 x = fPimpl->fX; y = fPimpl->fY;
2948 if (comp) {
2949 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2950 comp->GetId(),
2951 fPimpl->fX, fPimpl->fY, x, y, c);
2952 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2953 comp->GetId(),
2954 fPimpl->fX0, fPimpl->fY0, x0, y0, c);
2955 }
2956
2957 xx = x0; yy = y0;
2958 x0 = TMath::Min(xx, x); x = TMath::Max(xx, x);
2959 y0 = TMath::Min(yy, y); y = TMath::Max(yy, y);
2960 w = x - x0;
2961 h = y - y0;
2962
2963 if (fLassoDrawn || fromGrab) {
2964 if (comp) {
2965 TIter next(comp->GetList());
2966 TGFrameElement *el;
2967
2968 while ((el = (TGFrameElement*)next())) {
2969 TGFrame *fr = el->fFrame;
2970
2971 if ((fr->GetX() >= x0) && (fr->GetY() >= y0) &&
2972 (fr->GetX() + (Int_t)fr->GetWidth() <= x) &&
2973 (fr->GetY() + (Int_t)fr->GetHeight() <= y)) {
2974 if (!crop) {
2975 DeleteFrame(fr);
2976 } else {
2977 fr->Move(fr->GetX() - x0, fr->GetY() - y0);
2978 }
2979 } else {
2980 if (crop) {
2981 DeleteFrame(fr);
2982 }
2983 }
2984 }
2985 if (crop && comp) {
2986 gVirtualX->TranslateCoordinates(comp->GetId(), comp->GetParent()->GetId(),
2987 x0, y0, xx, yy, c);
2988
2989 comp->MoveResize(xx, yy, w, h);
2990
2992 TGMdiDecorFrame *decor = (TGMdiDecorFrame *)comp->GetParent();
2993
2994 gVirtualX->TranslateCoordinates(decor->GetId(), decor->GetParent()->GetId(),
2995 xx, yy, xx, yy, c);
2996
2997 Int_t b = 2 * decor->GetBorderWidth();
2998 decor->MoveResize(xx, yy, comp->GetWidth() + b,
2999 comp->GetHeight() + b + decor->GetTitleBar()->GetDefaultHeight());
3000 }
3001 }
3002 }
3003 } else { // no lasso drawn -> delete selected frame
3004 if (frame)
3005 DeleteFrame(frame);
3006 UngrabFrame();
3007 ChangeSelected(0); //update editors
3008 }
3010
3011 if (fBuilder) {
3012 //fBuilder->Update();
3013 fBuilder->UpdateStatusBar(crop ? "Crop action performed" : "Delete action performed");
3014 }
3015}
3016
3017////////////////////////////////////////////////////////////////////////////////
3018/// Delete frame
3019
3021{
3022 if (fStop || !frame) {
3023 return;
3024 }
3025
3026 // remove the frame from the list tree and reset the editor...
3027 fEditor->RemoveFrame(frame);
3028
3029 frame->UnmapWindow();
3030
3031 TGCompositeFrame *comp = 0;
3032
3034 comp = (TGCompositeFrame*)frame->GetParent();
3035 }
3036
3037 if (comp) {
3038 comp->RemoveFrame(frame);
3039 }
3040
3041 if (frame == fPimpl->fGrab) {
3042 UngrabFrame();
3043 }
3044
3045 fClient->UnregisterWindow(frame);
3046
3047 // mem.leak paid for robustness (with possibility "undelete")
3049}
3050
3051////////////////////////////////////////////////////////////////////////////////
3052/// Handle cut action
3053
3055{
3056 if (fStop || !fPimpl->fGrab) {
3057 return;
3058 }
3059
3060 //
3062 HandleCopy();
3064 ChangeSelected(0); //update editors
3065}
3066
3067////////////////////////////////////////////////////////////////////////////////
3068/// Handle copy. This method is also used by SaveFrame method.
3069/// In later case brk_layout == kFALSE
3070
3072{
3073 if (fStop || !fPimpl->fGrab) {
3074 return;
3075 }
3076
3078 fPimpl->fGrab->GetWidth(),
3079 fPimpl->fGrab->GetHeight());
3080
3081 // save coordinates
3082 Int_t x0 = fPimpl->fGrab->GetX();
3083 Int_t y0 = fPimpl->fGrab->GetY();
3084
3085 // save parent name
3087
3088 ((TGWindow*)fPimpl->fGrab->GetParent())->SetName(tmp->GetName());
3089
3090 fPimpl->fGrab->SetX(0);
3091 fPimpl->fGrab->SetY(0);
3092
3094
3095 if (fe) {
3096 tmp->GetList()->Add(fe);
3097 }
3098
3099 tmp->SetLayoutBroken(brk_layout);
3100
3101 if (!brk_layout) { //save frame
3103 tmp->SetWMSize(tmp->GetWidth(), tmp->GetHeight());
3104 tmp->SetWMSizeHints(tmp->GetDefaultWidth(), tmp->GetDefaultHeight(), 10000, 10000, 0, 0);
3105 const char *short_name = gSystem->BaseName(fPasteFileName.Data());
3106 tmp->SetWindowName(short_name);
3107 tmp->SetIconName(short_name);
3108 tmp->SetClassHints(short_name, short_name);
3109 // some problems here under win32
3110 if (gVirtualX->InheritsFrom("TGX11")) tmp->SetIconPixmap("bld_rgb.xpm");
3111 }
3112 Bool_t quite = brk_layout || (fPasteFileName == fTmpBuildFile);
3113 tmp->SaveSource(fPasteFileName.Data(), quite ? "keep_names quiet" : "keep_names");
3114 tmp->GetList()->Remove(fe);
3115
3116 fPimpl->fGrab->SetX(x0);
3117 fPimpl->fGrab->SetY(y0);
3118
3119 ((TGWindow*)fPimpl->fGrab->GetParent())->SetName(name.Data());
3120
3121 if (fBuilder) {
3122 TString str = fPimpl->fGrab->ClassName();
3123 str += "::";
3124 str += fPimpl->fGrab->GetName();
3125 str += " copied to clipboard";
3127 }
3128
3129 delete tmp;
3130}
3131
3132////////////////////////////////////////////////////////////////////////////////
3133/// Handle paste action.
3134
3136{
3137 if (fStop) {
3138 return;
3139 }
3140
3141 Int_t xp = 0;
3142 Int_t yp = 0;
3143
3145 return;
3146 }
3147
3148 fPasting = kTRUE;
3149 gROOT->Macro(fPasteFileName.Data());
3150
3151 Window_t c;
3152 TGFrame *root = (TGFrame*)fClient->GetRoot();
3153
3154 if (!fPimpl->fReplaceOn) {
3155 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
3156 root->GetId(),
3157 fPimpl->fX0, fPimpl->fY0, xp, yp, c);
3158 ToGrid(xp, yp);
3159
3160 // fPasteFrame is defined in TVirtualDragManager.h
3161 // fPasteFrame is a TGMainFrame consisting "the frame to paste"
3162 // into the editable frame (aka fClient->GetRoot())
3163
3164 if (fPasteFrame) {
3166 TGFrame *paste = ((TGFrameElement*)main->GetList()->First())->fFrame;
3167
3168 UInt_t w = paste->GetWidth();
3169 UInt_t h = paste->GetHeight();
3170
3171 if (xp + w > root->GetWidth()) {
3172 w = root->GetWidth() - xp -1;
3173 }
3174 if (yp + h > root->GetHeight()) {
3175 h = root->GetHeight() - yp -1;
3176 }
3177
3178 paste->Resize(w, h);
3179 fPasteFrame->Move(xp, yp);
3181 HandleReturn(1); // drop
3182 }
3183 }
3184
3185 fPasting = kFALSE;
3186
3187 if (fBuilder) {
3188 fBuilder->UpdateStatusBar("Paste action performed");
3189 }
3190}
3191
3192////////////////////////////////////////////////////////////////////////////////
3193/// Replace frame (doesn't work yet properly)
3194
3196{
3197 if (fStop || !frame || !fPimpl->fGrab || !fPimpl->fReplaceOn) {
3198 return;
3199 }
3200
3201 Int_t w = fPimpl->fGrab->GetWidth();
3203 Int_t x = fPimpl->fGrab->GetX();
3204 Int_t y = fPimpl->fGrab->GetY();
3205
3206 if (fBuilder) {
3207 TString str = fPimpl->fGrab->ClassName();
3208 str += "::";
3209 str += fPimpl->fGrab->GetName();
3210 str += " replaced by ";
3211 str += frame->ClassName();
3212 str += "::";
3213 str += frame->GetName();
3215 }
3216
3218
3219 if (fe) {
3220 fe->fFrame = 0;
3222 delete fPimpl->fGrab;
3223 fPimpl->fGrab = 0;
3224
3225 fe->fFrame = frame;
3226 frame->MoveResize(x, y, w, h);
3227 frame->MapRaised();
3228 frame->SetFrameElement(fe);
3229 }
3230
3231 SelectFrame(frame);
3233
3234 TGWindow *root = (TGWindow *)fClient->GetRoot();
3235 root->SetEditable(kFALSE);
3236 DoRedraw();
3237 root->SetEditable(kTRUE);
3238}
3239
3240////////////////////////////////////////////////////////////////////////////////
3241/// Handle replace
3242
3244{
3245 if (fStop || !fPimpl->fGrab) {
3246 return;
3247 }
3248
3250 TGFrame *frame = 0;
3251
3252 if (fBuilder && fBuilder->IsExecutable()) {
3253 frame = (TGFrame *)fBuilder->ExecuteAction();
3254 } else {
3255 HandlePaste();
3256 frame = fPasteFrame;
3257 }
3258 DoReplace(frame);
3260}
3261
3262////////////////////////////////////////////////////////////////////////////////
3263/// Create a frame which is the same as currently edited frame
3264
3266{
3267 if (fStop) {
3268 return;
3269 }
3270
3271 TString tmpfile = gSystem->TempDirectory();
3272 char *s = gSystem->ConcatFileName(tmpfile.Data(), TString::Format("tmp%d.C",
3273 gRandom->Integer(100)));
3274 Save(s);
3275 gROOT->Macro(s);
3276 gSystem->Unlink(s);
3277 delete [] s;
3278
3280 TGFrame *f = (TGFrame *)fClient->GetRoot();
3281 f->Resize(f->GetWidth() + 10, f->GetHeight() + 10);
3282 }
3283}
3284
3285////////////////////////////////////////////////////////////////////////////////
3286/// Save an edited frame to the file
3287
3289{
3290 if (fStop || !fClient->GetRoot() || !fClient->IsEditable()) {
3291 return kFALSE;
3292 }
3293
3295 TGWindow *root = (TGWindow*)fClient->GetRoot();
3296 TString fname = file;
3297
3298 root->SetEditable(kFALSE);
3299
3300 static TImage *img = 0;
3301
3302 if (!img) {
3303 img = TImage::Create();
3304 }
3305 img->FromWindow(main->GetId());
3306
3307 if (!file || !file[0]) {
3308 static TString dir(".");
3309 static Bool_t overwr = kFALSE;
3310 TGFileInfo fi;
3311
3313 fi.SetIniDir(dir);
3314 fi.fOverwrite = overwr;
3315 new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi);
3316
3317 if (!fi.fFilename) goto out;
3318 dir = fi.fIniDir;
3319 overwr = fi.fOverwrite;
3321 }
3322
3323 if (fname.EndsWith(".C")) {
3325 main->SetWMSize(main->GetWidth(), main->GetHeight());
3326 main->SetWMSizeHints(main->GetDefaultWidth(), main->GetDefaultHeight(), 10000, 10000, 0, 0);
3327 main->SetWindowName(fname.Data());
3328 main->SetIconName(fname.Data());
3329 main->SetClassHints(fname.Data(), fname.Data());
3330 // some problems here under win32
3331 if (gVirtualX->InheritsFrom("TGX11")) main->SetIconPixmap("bld_rgb.xpm");
3332 main->SaveSource(fname.Data(), file ? "keep_names quiet" : "keep_names");
3333
3334 if (fBuilder)
3335 fBuilder->AddMacro(fname.Data(), img);
3336
3337 } else {
3338 Int_t retval;
3339 TString msg = TString::Format("file (%s) must have extension .C", fname.Data());
3340
3341 new TGMsgBox(fClient->GetDefaultRoot(), main, "Error...", msg.Data(),
3343
3344 if (retval == kMBRetry) {
3345 return Save();
3346 }
3347 }
3348
3349out:
3350 main->RaiseWindow();
3351 return kTRUE;
3352}
3353
3354////////////////////////////////////////////////////////////////////////////////
3355/// Save composite frame as macro
3356
3358{
3359 if (fStop || !fClient->GetRoot() || !fClient->IsEditable() ||
3361 return kFALSE;
3362 }
3363
3364 TString fname = file;
3365
3366 TGFrame *frame = fPimpl->fGrab;
3368
3369 static TImage *img = 0;
3370
3371 if (!img) {
3372 img = TImage::Create();
3373 }
3374 img->FromWindow(frame->GetId());
3375
3376 static TString dir(".");
3377 static Bool_t overwr = kFALSE;
3378
3379 TString sav = fPasteFileName;
3380
3381 if (!file) {
3382 TGFileInfo fi;
3383
3385 fi.SetIniDir(dir);
3386 fi.fOverwrite = overwr;
3387 new TGFileDialog(fClient->GetDefaultRoot(), frame, kFDSave, &fi);
3388
3389 if (!fi.fFilename) {
3390 goto out;
3391 }
3392
3393 dir = fi.fIniDir;
3394 overwr = fi.fOverwrite;
3396 }
3397
3398 if (fname.EndsWith(".C")) {
3399 fPasteFileName = fname;
3400 fPimpl->fGrab = frame;
3401 fStop = kFALSE;
3402 TGFrameElement *fe = frame->GetFrameElement();
3403
3404 if (!fe) { // should never happen
3405 fe = new TGFrameElement();
3406 fe->fFrame = frame;
3407 fe->fState = kIsMapped;
3408 frame->SetFrameElement(fe);
3409 TGCompositeFrame *comp = (TGCompositeFrame*)frame->GetParent();
3410 comp->GetList()->Add(fe);
3411 }
3412 delete fe->fLayout;
3414
3416 fStop = kTRUE;
3417
3418 fBuilder->AddMacro(fname.Data(), img);
3419 } else {
3420 Int_t retval;
3421 TString msg = TString::Format("file (%s) must have extension .C", fname.Data());
3422
3423 new TGMsgBox(fClient->GetDefaultRoot(), frame, "Error...", msg.Data(),
3425
3426 if (retval == kMBRetry) {
3427 return SaveFrame();
3428 }
3429 }
3430
3431out:
3432 fPasteFileName = sav;
3433 return kTRUE;
3434}
3435/*
3436////////////////////////////////////////////////////////////////////////////////
3437/// Not used yet. Return 0 if all child frames are inside area x,y, w,h
3438
3439static Int_t canResize(TGFrame *frame, Int_t x, Int_t y, UInt_t &w, UInt_t &h)
3440{
3441 if (frame->InheritsFrom(TGCompositeFrame::Class())) return 0;
3442
3443 TGCompositeFrame *comp = (TGCompositeFrame*)frame;
3444
3445 TIter next(comp->GetList());
3446 TGFrameElement *fe;
3447 Int_t d = gGuiBldDragManager->GetGridStep();
3448 Int_t ret = 0;
3449
3450 while ((fe = (TGFrameElement*)next())) {
3451 if (x + fe->fFrame->GetX() + fe->fFrame->GetWidth() > w) {
3452 w = fe->fFrame->GetX() + x + fe->fFrame->GetWidth();
3453 ret |= 4;
3454 }
3455 if (y + fe->fFrame->GetY() + fe->fFrame->GetHeight() > h) {
3456 h = fe->fFrame->GetY() + y + fe->fFrame->GetHeight();
3457 ret |= 8;
3458 }
3459 }
3460 return ret;
3461}
3462*/
3463
3464////////////////////////////////////////////////////////////////////////////////
3465/// handle resize
3466
3468{
3469 if (fStop || !fClient->IsEditable()) {
3470 return;
3471 }
3472
3473 TGFrame *fr = fPimpl->fGrab;
3474
3475 if (!fr || IsFixedSize(fr) ||
3476 IsFixedLayout((TGWindow*)fr->GetParent())) {
3477
3478 fr = (TGFrame*)GetResizableParent(fr);
3479
3480 if (!fr ) {
3481 return;
3482 }
3483 }
3484
3485 TGCompositeFrame *comp = 0;
3486
3488 comp = (TGCompositeFrame*)fr;
3489 }
3490
3491 Window_t c;
3492 Int_t x = fPimpl->fX;
3493 Int_t y = fPimpl->fY;
3494 UInt_t w = 0;
3495 UInt_t h = 0;
3496 UInt_t wp = ((TGFrame*)fr->GetParent())->GetWidth() - 2;
3497 UInt_t hp = ((TGFrame*)fr->GetParent())->GetHeight() - 2;
3498
3499 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
3500 fr->GetId(), x, y, x, y, c);
3501
3502 ToGrid(x, y);
3504
3505 switch (fPimpl->fResizeType) {
3506 case kTopLeft:
3507 if ((((int)fr->GetWidth() > x) || (x < 0)) &&
3508 (((int)fr->GetHeight() > y) || (y < 0))) {
3509
3510 if (fr->GetY() + y < 2) {
3511 y = 2 - fr->GetY();
3512 }
3513 if (fr->GetX() + x < 2) {
3514 x = 2 - fr->GetX();
3515 }
3516 h = fr->GetHeight() - y;
3517 w = fr->GetWidth() - x;
3518 x = fr->GetX() + x;
3519 y = fr->GetY() + y;
3520
3521 if (!IsFixedH(fr) && !IsFixedW(fr)) {
3522 fr->MoveResize(x, y, w, h);
3523 break;
3524 }
3525 if (IsFixedH(fr)) {
3526 fr->MoveResize(x, fr->GetY(), w, fr->GetDefaultHeight());
3527 break;
3528 }
3529 if (IsFixedW(fr)) {
3530 fr->MoveResize(fr->GetX(), y, fr->GetDefaultWidth(), h);
3531 break;
3532 }
3533 }
3534 break;
3535 case kTopRight:
3536 if ((x > 0) && (((int)fr->GetHeight() > y) || (y < 0))) {
3537
3538 if (fr->GetY() + y < 2) {
3539 y = 2 - fr->GetY();
3540 }
3541 h = fr->GetHeight() - y;
3542
3543 if (IsFixedW(fr)) {
3544 w = fr->GetDefaultWidth();
3545 } else {
3546 w = fr->GetX() + x > Int_t(wp) ? wp - fr->GetX() : UInt_t(x);
3547 }
3548 x = fr->GetX();
3549 y = fr->GetY() + y;
3550
3551 if (!IsFixedH(fr)) {
3552 fr->MoveResize(x, y, w, h);
3553 } else {
3554 fr->Resize(x, fr->GetDefaultHeight());
3555 }
3556 }
3557 break;
3558 case kTopSide:
3559 if (((int)fr->GetHeight() > y) || (y < 0)) {
3560 if (IsFixedH(fr)) {
3561 break;
3562 }
3563
3564 if (fr->GetY() + y < 2) {
3565 y = 2 - fr->GetY();
3566 }
3567 h = fr->GetHeight() - y;
3568 w = fr->GetWidth();
3569 x = fr->GetX();
3570 y = fr->GetY() + y;
3571
3572 fr->MoveResize(x, y, w, h);
3573 }
3574 break;
3575 case kBottomLeft:
3576 if ((((int)fr->GetWidth() > x) || (x < 0)) && (y > 0)) {
3577
3578 if (fr->GetX() + x < 2) {
3579 x = 2 - fr->GetX();
3580 }
3581 h = fr->GetY() + y > Int_t(hp) ? hp - fr->GetY() : UInt_t(y);
3582 w = fr->GetWidth() - x;
3583 x = fr->GetX() + x;
3584
3585 if (!IsFixedH(fr) && !IsFixedW(fr)) {
3586 fr->MoveResize(x, fr->GetY(), w, h);
3587 break;
3588 }
3589 if (IsFixedH(fr)) {
3590 fr->MoveResize(x, fr->GetY(), w, fr->GetDefaultHeight());
3591 break;
3592 }
3593 if (IsFixedW(fr)) {
3594 fr->MoveResize(fr->GetX(), fr->GetY(),
3595 fr->GetDefaultWidth(), h);
3596 break;
3597 }
3598 }
3599 break;
3600 case kBottomRight:
3601 if ((x > 0) && (y > 0)) {
3602 w = !IsFixedW(fr) ? UInt_t(x) : fr->GetDefaultWidth();
3603 h = !IsFixedH(fr) ? UInt_t(y) : fr->GetDefaultHeight();
3604
3605 h = fr->GetY() + h > hp ? hp - fr->GetY() : h;
3606 w = fr->GetX() + w > wp ? wp - fr->GetX() : w;
3607
3608 //canResize(comp, 0, 0, w, h);
3609 fr->Resize(w, h);
3610 }
3611 break;
3612 case kBottomSide:
3613 if (y > 0) {
3614 if (IsFixedH(fr)) {
3615 break;
3616 }
3617
3618 w = fr->GetWidth();
3619 h = fr->GetY() + y > (Int_t)hp ? hp - fr->GetY() : UInt_t(y);
3620
3621 //canResize(comp, 0, 0, w, h);
3622 fr->Resize(w, h);
3623 }
3624 break;
3625 case kLeftSide:
3626 if ((int)fr->GetWidth() > x ) {
3627 if (IsFixedW(fr)) {
3628 break;
3629 }
3630
3631 if (fr->GetX() + x < 2) {
3632 x = 2 - fr->GetX();
3633 }
3634 w = fr->GetWidth() - x;
3635 h = fr->GetHeight();
3636 y = fr->GetY();
3637 x = fr->GetX() + x;
3638
3639 //canResize(comp, x, y, w, h);
3640 fr->MoveResize(x, y, w, h);
3641 }
3642 break;
3643 case kRightSide:
3644 if (x > 0) {
3645 if (IsFixedW(fr)) {
3646 break;
3647 }
3648
3649 h = fr->GetHeight();
3650 w = fr->GetX() + x > (Int_t)wp ? wp - fr->GetX() : UInt_t(x);
3651 //canResize(comp, 0, 0, w, h);
3652 fr->Resize(w, h);
3653 }
3654 break;
3655 default:
3656 break;
3657 }
3658 if (comp && (!comp->IsLayoutBroken() || IsFixedLayout(comp))) {
3659 layoutFrame(comp);
3660 }
3661
3662 gVirtualX->SetCursor(fClient->GetRoot()->GetId(),
3663 gVirtualX->CreateCursor(fPimpl->fResizeType));
3664 w = fr->GetWidth();
3665 h = fr->GetHeight();
3666
3667 if (fBuilder) {
3668 TString str = fr->ClassName();
3669 str += "::";
3670 str += fr->GetName();
3671 str += " resized ";
3672 str += TString::Format("(%d x %d)", w, h);
3674 }
3675
3676 fClient->NeedRedraw(fr, kTRUE);
3677 DoRedraw();
3678 fEditor->ChangeSelected(fr); //to update the geometry frame after drag resize
3679}
3680
3681////////////////////////////////////////////////////////////////////////////////
3682/// Handle move
3683
3685{
3686 if (fStop || !fPimpl->fGrab || !fClient->IsEditable()) {
3687 return;
3688 }
3689
3690 TGWindow *parent = (TGWindow*)fPimpl->fGrab->GetParent();
3691
3692 // do not remove frame from fixed layout or non-editable parent
3693 if (IsFixedLayout(parent) || IsEditDisabled(parent)) {
3694 return;
3695 }
3696
3697 Int_t x = fPimpl->fX - fPimpl->fXf;
3698 Int_t y = fPimpl->fY - fPimpl->fYf;
3699
3700 static Int_t qq;
3701 static UInt_t w = 0;
3702 static UInt_t h = 0;
3703
3704 if (w == 0) {
3705 gVirtualX->GetWindowSize(gVirtualX->GetDefaultRootWindow(), qq, qq, w, h);
3706 }
3707
3708 //
3709 Bool_t move = (x > 0) && (y > 0) && ((x + fPimpl->fGrab->GetWidth()) < (w - 0)) &&
3710 ((y + fPimpl->fGrab->GetHeight()) < (h - 30));
3711
3712
3713 // we are out of "win32 world"
3714 if (!move && !gVirtualX->InheritsFrom("TGX11")) {
3715 EndDrag();
3716 return;
3717 }
3718
3719 fPimpl->fGrab->Move(x, y);
3720
3721 if (fBuilder) {
3722 //fBuilder->Update();
3723 TString str = fPimpl->fGrab->ClassName();
3724 str += "::";
3725 str += fPimpl->fGrab->GetName();
3726 str += " is moved to absolute position ";
3727 str += TString::Format("(%d , %d)", x, y);
3729 }
3730
3732}
3733
3734////////////////////////////////////////////////////////////////////////////////
3735/// Return a pointer to the parent mdi frame
3736
3738{
3739 if (fStop || !in) {
3740 return 0;
3741 }
3742
3743 TGFrame *p = in;
3744
3745 while (p && (p != fClient->GetDefaultRoot()) &&
3748 return p;
3749 }
3750 p = (TGFrame*)p->GetParent();
3751 }
3752 return 0;
3753}
3754
3755////////////////////////////////////////////////////////////////////////////////
3756/// Raise guibuilder's mdi frame.
3757
3759{
3760 if (fStop || !comp) {
3761 return;
3762 }
3763
3764 if (comp && comp->InheritsFrom(TGMdiFrame::Class()) && fBuilder) {
3766 if (mdi) {
3767 // dragged frame is taken from some main frame
3768 //if (fPimpl->fGrab && fClient->GetRoot()->InheritsFrom(TGMainFrame::Class())) {
3769 // fBuilder->MapRaised();
3770 //}
3771 }
3772 if (fBuilder->GetMdiMain()->GetCurrent() != comp) {
3774 }
3775 }
3776}
3777
3778////////////////////////////////////////////////////////////////////////////////
3779/// Look for the drop target under grabbed/selected frame while moving
3780
3782{
3783 if (fStop || !fPimpl->fGrab ) {
3784 return;
3785 }
3786
3787 Int_t x = fPimpl->fGrab->GetX();
3788 Int_t y = fPimpl->fGrab->GetY();
3791
3792 Bool_t ok = CheckTargetAtPoint(x - 1, y - 1);
3793
3794 if (!ok) {
3795 ok = CheckTargetAtPoint(x + w + 1, y + h + 1);
3796 }
3797
3798 if (!ok) {
3799 ok = CheckTargetAtPoint(x + w + 1, y - 1);
3800 }
3801
3802 if (!ok) {
3803 CheckTargetAtPoint(x - 1, y + h + 1);
3804 }
3805}
3806
3807////////////////////////////////////////////////////////////////////////////////
3808/// Helper. Look for the drop target under grabbed/selected frame while moving.
3809
3811{
3812 if (fStop || !fPimpl->fGrab) {
3813 return kFALSE;
3814 }
3815
3816 UInt_t ww = fPimpl->fGrab->GetWidth();
3817 UInt_t hh = fPimpl->fGrab->GetHeight();
3818 Bool_t ret = kFALSE;
3819 Window_t c;
3820 TGWindow *win = 0;
3821
3823
3824 if (w && (w != gVirtualX->GetDefaultRootWindow())) {
3826 TGCompositeFrame *comp = 0;
3827
3828 if (!win) {
3829 goto out;
3830 }
3831
3832 if (win->InheritsFrom(TGCompositeFrame::Class())) {
3833 comp = (TGCompositeFrame *)win;
3834 } else if (win->GetParent() != fClient->GetDefaultRoot()) {
3835 comp = (TGCompositeFrame *)win->GetParent();
3836 }
3837
3838 if (comp) {
3839 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
3840 comp->GetId(), x, y, x, y, c);
3841
3842 RaiseMdiFrame(comp);
3843
3844 if ((comp != fPimpl->fGrab) && (x >= 0) && (y >= 0) &&
3845 (x + ww <= comp->GetWidth()) &&
3846 (y + hh <= comp->GetHeight())) {
3847
3848 if (comp != fTarget) {
3850
3852
3853 else Snap2Grid();
3854 } else {
3855 if (fTarget) {
3857 }
3858 }
3859
3860 fTarget = comp;
3861 fTargetId = comp->GetId();
3862 ret = kTRUE;
3863 return ret;
3864
3865 } else {
3866 if (fTarget) {
3868 }
3869 fTarget = 0;
3870 fTargetId = 0;
3871 }
3872 }
3873 }
3874
3875out:
3876 if (fTarget) {
3878 }
3879
3880 if (!w || !win) {
3881 fTarget = 0;
3882 fTargetId = 0;
3883 }
3884 return ret;
3885}
3886
3887////////////////////////////////////////////////////////////////////////////////
3888/// Handle motion event
3889
3891{
3892 if (fStop) {
3893 return kFALSE;
3894 }
3895
3896 static Long64_t was = gSystem->Now();
3897 static Int_t gy = event->fYRoot;
3898 static Int_t gx = event->fXRoot;
3899
3900 Long64_t now = gSystem->Now();
3901
3902 if ((now-was < 100) || !(event->fState & kButton1Mask) ||
3903 ((event->fYRoot == gy) && (event->fXRoot == gx))) {
3904 return kFALSE;
3905 }
3906
3907 was = now;
3908 gy = event->fYRoot;
3909 gx = event->fXRoot;
3910
3911 if (!fDragging) {
3912 if (fMoveWaiting && ((TMath::Abs(fPimpl->fX - event->fXRoot) > 10) ||
3913 (TMath::Abs(fPimpl->fY - event->fYRoot) > 10))) {
3914
3915 return StartDrag(fSource, event->fXRoot, event->fYRoot);
3916 }
3917 } else {
3918 fPimpl->fX = event->fXRoot;
3919 fPimpl->fY = event->fYRoot;
3920
3921 switch (fDragType) {
3922 case kDragLasso:
3923 DrawLasso();
3924 fSelectionIsOn = event->fState & kKeyShiftMask;
3925 break;
3926 case kDragMove:
3927 case kDragCopy:
3928 case kDragLink:
3929 DoMove();
3930 break;
3931 case kDragResize:
3932 DoResize();
3933 break;
3934 default:
3935 break;
3936 }
3937 }
3939 return kTRUE;
3940}
3941
3942////////////////////////////////////////////////////////////////////////////////
3943/// Put created frame at position of the last mouse click
3944
3946{
3947 Int_t x0, y0, x, y;
3948 Window_t c;
3949
3950 if (fStop || !frame || !fClient->IsEditable()) {
3951 return;
3952 }
3953
3954 frame->MapSubwindows();
3955 TGFrame *root = (TGFrame*)fClient->GetRoot();
3956
3957 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
3958 root->GetId(),
3959 fPimpl->fX0 , fPimpl->fY0, x0, y0, c);
3960 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
3961 root->GetId(),
3962 fPimpl->fX , fPimpl->fY, x, y, c);
3963
3964 ToGrid(x, y);
3965 ToGrid(x0, y0);
3966
3967 UInt_t w = TMath::Abs(x - x0);
3968 UInt_t h = TMath::Abs(y - y0);
3969 x = x > x0 ? x0 : x;
3970 y = y > y0 ? y0 : y;
3971
3972 // do not create frame with size smaller when default size
3973 w = w < frame->GetDefaultWidth() + 2 ? frame->GetDefaultWidth() + 2 : w;
3974 h = h < frame->GetDefaultHeight() + 2 ? frame->GetDefaultHeight() + 2 : h;
3975
3976 // do not create frame out of editable space
3977 x = x + w > root->GetWidth() ? Int_t(root->GetWidth() - w) : x;
3978 y = y + h > root->GetHeight() ? Int_t(root->GetHeight() - h) : y;
3979
3980 frame->Move(x, y);
3981
3982 UInt_t grid = GetGridStep();
3983
3984 if (IsFixedW(frame) || IsFixedH(frame) || IsFixedSize(frame)) {
3985 w = IsFixedW(frame) ? frame->GetDefaultWidth() : w;
3986 h = IsFixedH(frame) ? frame->GetDefaultHeight() : h;
3987 frame->Resize(w < grid ? grid : w, h < grid ? grid : h);
3988 } else {
3989 if (frame->InheritsFrom(TGVerticalFrame::Class())) {
3990 frame->Resize(w < grid ? 15*grid : w, h < grid ? 30*grid : h);
3991 } else if (frame->InheritsFrom(TGHorizontalFrame::Class())) {
3992 frame->Resize(w < grid ? 30*grid : w, h < grid ? 15*grid : h);
3993 }
3994 else frame->Resize(w < 2*grid ? 2*grid : w, h < 2*grid ? 2*grid : h);
3995 }
3996
3997 frame->MapRaised();
3998 frame->SetCleanup(kDeepCleanup);
3999 frame->AddInput(kButtonPressMask);
4000
4003 edit->SetCleanup(kDeepCleanup);
4004 ReparentFrames(frame, edit);
4005 frame->MapRaised();
4006 //edit->SetLayoutBroken();
4007 UInt_t g = 2;
4008 // temporary hack for status bar
4009 if (frame->InheritsFrom("TGStatusBar")) {
4011 }
4012 else {
4013 edit->AddFrame(frame, hints ? hints : new TGLayoutHints(kLHintsNormal, g, g, g, g));
4014 }
4015
4016 if (hints && !edit->IsLayoutBroken()) {
4017 edit->GetLayoutManager()->Layout();
4018 } else {
4019 edit->Layout();
4020 }
4021 }
4022 if (fBuilder) {
4023 TString str = frame->ClassName();
4024 str += "::";
4025 str += frame->GetName();
4026 str += " created";
4028 }
4029
4030 if (frame->InheritsFrom(TGCanvas::Class())) {
4031 frame = ((TGCanvas*)frame)->GetContainer();
4032 }
4033
4034 SelectFrame(frame);
4035
4036}
4037////////////////////////////////////////////////////////////////////////////////
4038/// Draw lasso for allocation new object
4039
4041{
4042 if (fStop || !fClient->IsEditable()) {
4043 return;
4044 }
4045
4046 UngrabFrame();
4047
4048 Int_t x0, y0, x, y;
4049 Window_t c;
4050 TGFrame *root = (TGFrame*)fClient->GetRoot();
4051
4052 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(), root->GetId(),
4053 fPimpl->fX0 , fPimpl->fY0, x0, y0, c);
4054 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(), root->GetId(),
4055 fPimpl->fX , fPimpl->fY, x, y, c);
4056
4057 UInt_t w, h;
4058 Bool_t xswap = kFALSE;
4059 Bool_t yswap = kFALSE;
4060
4061 // check limits
4062
4063 if ((x == x0) || ( y==y0 )) return; //lasso is not rectangle -> do not draw it
4064
4065 if (x > x0) {
4066 x0 = x0 < 0 ? 0 : x0;
4067 w = x - x0;
4068 } else {
4069 x = x < 0 ? 0 : x;
4070 w = x0 - x;
4071 x0 = x;
4072 xswap = kTRUE;
4073 }
4074
4075 if (y > y0) {
4076 y0 = y0 < 0 ? 0 : y0;
4077 h = y - y0;
4078 } else {
4079 y = y < 0 ? 0 : y;
4080 h = y0 - y;
4081 y0 = y;
4082 yswap = kTRUE;
4083 }
4084
4085 w = x0 + w > root->GetWidth() ? root->GetWidth() - x0 : w;
4086 h = y0 + h > root->GetHeight() ? root->GetHeight() - y0 : h;
4087 x = x0 + w;
4088 y = y0 + h;
4089
4090 ToGrid(x, y);
4091 ToGrid(x0, y0);
4092
4093 // correct fPimpl->fX0 , fPimpl->fY0 , fPimpl->fX , fPimpl->fY
4094 gVirtualX->TranslateCoordinates(root->GetId(), fClient->GetDefaultRoot()->GetId(),
4095 xswap ? x : x0, yswap ? y : y0,
4096 fPimpl->fX0 , fPimpl->fY0, c);
4097 gVirtualX->TranslateCoordinates(root->GetId(), fClient->GetDefaultRoot()->GetId(),
4098 xswap ? x0 : x, yswap ? y0 : y,
4099 fPimpl->fX , fPimpl->fY, c);
4100 DoRedraw();
4101
4102 gVirtualX->DrawRectangle(fClient->GetRoot()->GetId(),
4103 GetBlackGC()(), x0, y0, w, h);
4104 gVirtualX->DrawRectangle(fClient->GetRoot()->GetId(),
4105 GetBlackGC()(), x0+1, y0+1, w-2, h-2);
4106
4107 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kCross));
4108 gVirtualX->SetCursor(fClient->GetRoot()->GetId(), gVirtualX->CreateCursor(kCross));
4109
4111 root->RequestFocus();
4112
4113 if (fBuilder) {
4114 TString str = "Lasso drawn. Align frames inside or press Return key to grab frames.";
4116 }
4117}
4118
4119////////////////////////////////////////////////////////////////////////////////
4120/// Handle client message
4121
4123{
4124 if (fStop) {
4125 return kFALSE;
4126 }
4127
4128 if ((event->fFormat == 32) && ((Atom_t)event->fUser[0] == gWM_DELETE_WINDOW) &&
4129 (event->fHandle != gROOT_MESSAGE)) {
4130
4131 if (fPimpl->fPlane && (fPimpl->fPlane->GetId() == event->fWindow)) {
4132 fPimpl->fPlane = 0;
4133 }
4134
4135 TGWindow *root = (TGWindow*)fClient->GetRoot();
4136 if (!root || (root == fClient->GetDefaultRoot())) {
4138 return kTRUE;
4139 }
4141
4142 if (event->fWindow == main->GetId()) {
4143 if (main != fBuilder) {
4144 if (fEditor && !fEditor->IsEmbedded()) {
4145 delete fEditor;
4146 fEditor = 0;
4147 }
4148
4150 return kTRUE;
4151 }
4152
4153 delete fFrameMenu;
4154 fFrameMenu =0;
4155
4156 delete fLassoMenu;
4157 fLassoMenu = 0;
4158
4159 delete fPimpl->fGrid;
4160 fPimpl->fGrid = 0;
4161 Reset1();
4162
4163 } else if (fBuilder && (event->fWindow == fBuilder->GetId())) {
4165
4166 } else if (fEditor && (event->fWindow == fEditor->GetMainFrame()->GetId())) {
4168 fEditor = 0;
4169 }
4170
4171 // to avoid segv. stop editting
4173 }
4174
4175 return kFALSE;
4176}
4177
4178////////////////////////////////////////////////////////////////////////////////
4179/// Handle destroy notify
4180
4182{
4183 if (fPimpl->fPlane && (fPimpl->fPlane->GetId() == event->fWindow)) {
4184 fPimpl->fPlane = 0;
4185 }
4186
4187 return kFALSE;
4188}
4189
4190
4191////////////////////////////////////////////////////////////////////////////////
4192/// not used yet.
4193
4195{
4196 if (fStop) {
4197 return kFALSE;
4198 }
4199
4200 return kFALSE;
4201}
4202
4203////////////////////////////////////////////////////////////////////////////////
4204/// not used yet.
4205
4207{
4208 if (fStop) {
4209 return kFALSE;
4210 }
4211
4212 return kFALSE;
4213}
4214
4215////////////////////////////////////////////////////////////////////////////////
4216/// Find parent frame which can be dragged
4217
4219{
4220 if (fStop) {
4221 return 0;
4222 }
4223
4224 TGFrame *ret = (TGFrame*)p;
4225 TGWindow *parent = (TGWindow*)ret->GetParent();
4226
4227 while (parent && (parent != fClient->GetDefaultRoot())) {
4228 if (!IsFixedLayout(parent) && !IsEditDisabled(parent)) {
4229 return ret;
4230 }
4231 ret = (TGFrame*)parent;
4232 parent = (TGWindow*)ret->GetParent();
4233 }
4234
4235 return 0;
4236}
4237
4238////////////////////////////////////////////////////////////////////////////////
4239/// Find parent frame which can be resized
4240
4242{
4243 if (fStop) {
4244 return 0;
4245 }
4246
4247 TGWindow *parent = p;
4248
4249 while (parent && (parent != fClient->GetDefaultRoot())) {
4250 if (!IsFixedSize(parent) &&
4251 !IsFixedLayout((TGWindow*)parent->GetParent()) &&
4252 !IsEditDisabled((TGWindow*)parent->GetParent())) {
4253 return parent;
4254 }
4255 parent = (TGWindow*)parent->GetParent();
4256 }
4257
4258 return 0;
4259}
4260
4261////////////////////////////////////////////////////////////////////////////////
4262/// Start dragging.
4263
4265{
4266 if (fStop || fDragging) {
4267 return kFALSE;
4268 }
4269
4270 TGFrame *mov = src;
4271
4272 // special case when frame was grabbed via spacebar pressing
4274 if (fDragType == kDragNone) {
4277 } else {
4279 }
4280 }
4281
4282 TGWindow *parent = (TGWindow*)(mov ? mov->GetParent() : 0);
4283
4284 // do not remove frame from fixed layout or non-editable parent
4285 // try to drag "draggable parent"
4286 if (parent && (IsFixedLayout(parent) || IsEditDisabled(parent))) {
4287 mov = GetMovableParent(parent);
4288 if (!mov) {
4289 return kFALSE;
4290 }
4291 }
4292
4293 SetEditable(kTRUE); // grab server
4294
4295 fPimpl->fX = x;
4296 fPimpl->fY = y;
4298
4301
4303 fDragging = kTRUE;
4304 if (src) gVirtualX->SetCursor(src->GetId(), gVirtualX->CreateCursor(kMove));
4305
4306 switch (fDragType) {
4307 case kDragCopy:
4308 HandleCopy();
4309 HandlePaste();
4311 break;
4312 case kDragMove:
4313 fPimpl->fGrab = mov;
4315 break;
4316 default:
4317 //fPimpl->fGrab = 0;
4318 break;
4319 }
4320
4321 return kTRUE;
4322}
4323
4324////////////////////////////////////////////////////////////////////////////////
4325/// End dragging.
4326
4328{
4329 TGFrame *frame = 0;
4330 Bool_t ret = kFALSE;
4331
4332 if (fStop) {
4333 return kFALSE;
4334 }
4335
4336 fMoveWaiting = kFALSE; // for sanity check
4337
4338 if (fPimpl->fGrab && (fDragType >= kDragMove) && (fDragType <= kDragLink)) {
4339
4340 ret = Drop();
4341
4342 } else if (fBuilder && fBuilder->IsExecutable() &&
4344
4345 frame = (TGFrame*)fBuilder->ExecuteAction();
4346 PlaceFrame(frame, fBuilder->GetAction()->fHints);
4348 ret = kTRUE;
4349 //return ret;
4350 } else if ((fDragType == kDragLasso) && fSelectionIsOn) {
4351
4353 ret = kTRUE;
4354 }
4355
4356 if (!fLassoDrawn) {
4357 DoRedraw();
4358 }
4359
4360 Reset1();
4362
4363 if (fBuilder) {
4364 fBuilder->SetAction(0);
4365 }
4366
4367 return ret;
4368}
4369
4370////////////////////////////////////////////////////////////////////////////////
4371/// Do cancel action.
4372
4374{
4375 if (fStop) {
4376 return kFALSE;
4377 }
4378
4379 fTarget = 0;
4380 EndDrag();
4381 return kTRUE;
4382}
4383
4384////////////////////////////////////////////////////////////////////////////////
4385/// Drop grabbed frame
4386
4388{
4389 if (fStop || !fDragging || !fPimpl->fGrab ||
4390 !((fDragType >= kDragMove) && (fDragType <= kDragLink))) {
4391 return kFALSE;
4392 }
4393
4395 TGFrame *frame = 0;
4396 TGFrame *parent = 0;
4397 Int_t x, y;
4398 Window_t c;
4399
4400 switch (fDragType) {
4401 case kDragCopy:
4402 case kDragMove:
4403 frame = (TGFrame*)fPimpl->fGrab;
4404 break;
4405 default:
4406 break;
4407 }
4408
4410
4411 if (fTarget && fPimpl->fGrab && (w == fTarget) && w &&
4412 (w != fClient->GetDefaultRoot())) {
4413 parent = fTarget;
4414
4415 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
4416 fTarget->GetId(),
4417 fPimpl->fGrab->GetX(),
4418 fPimpl->fGrab->GetY(), x, y, c);
4420 } else {
4421 parent = (TGFrame*)fPimpl->fGrabParent;
4422 x = fPimpl->fGrabX;
4423 y = fPimpl->fGrabY;
4424 }
4425
4426 //reject move if layout is on
4427 if (parent && !parent->IsLayoutBroken() && (parent == fPimpl->fGrabParent) ) {
4428 fDropStatus = 0;
4429 } else if (parent && frame && (parent != fClient->GetDefaultRoot()) ) {
4430 ToGrid(x, y);
4431 fDropStatus = parent->HandleDragDrop(frame, x, y, fPimpl->fGrabLayout);
4432
4433 // drop was rejected
4434 if (!fDropStatus) {
4435 if (fDragType == kDragMove) { // return dragged frame to initial position
4436 parent = (TGFrame*)fPimpl->fGrabParent;
4437 x = fPimpl->fGrabX;
4438 y = fPimpl->fGrabY;
4439 frame = fPimpl->fGrab;
4440
4441 if (parent && frame && (parent != fClient->GetDefaultRoot())) {
4442 fDropStatus = parent->HandleDragDrop(frame, x, y, fPimpl->fGrabLayout);
4443 }
4444 } else { // (fDragType == kDragCopy) - delete it
4445 DeleteFrame(frame);
4446 }
4447 }
4448 }
4449
4450 if (fDropStatus) {
4451 //do not break layout of the new parent if layout there is enabled
4452 if (parent && !parent->IsLayoutBroken()) {
4453 parent->Layout();
4454 }
4455
4456 if (fBuilder) {
4457 TString str = frame->ClassName();
4458 str += "::";
4459 str += frame->GetName();
4460 str += " dropped into ";
4461 str += parent->ClassName();
4462 str += "::";
4463 str += parent->GetName();
4464 str += " at position ";
4465 str += TString::Format("(%d , %d)", x, y);
4467 }
4468 fTarget = 0;
4469 fTargetId = 0;
4470
4471 if (parent && (parent == fPimpl->fGrabParent) && fPimpl->fGrabListPosition &&
4472 frame && parent->InheritsFrom(TGCompositeFrame::Class())) {
4473
4474 TList *li = ((TGCompositeFrame*)parent)->GetList();
4475 li->Remove(frame->GetFrameElement());
4477 }
4478 } else { // grab frame cannot be dropped
4479// if (fDragType == kDragCopy) { // doesn't work (point is not reached ???)
4480// HandleDelete(kFALSE);
4481// }
4482
4483 if (fPimpl->fGrab && fPimpl->fGrabParent) {
4486 }
4487 }
4488
4489 fPimpl->fGrabParent = 0;
4490 fPimpl->fGrabX = 0;
4491 fPimpl->fGrabY = 0;
4493
4494 return fDropStatus;
4495}
4496
4497////////////////////////////////////////////////////////////////////////////////
4498/// Waits for either the mouse move from the given initial ButtonPress location
4499/// or for the mouse button to be released. If mouse moves away from the initial
4500/// ButtonPress location before the mouse button is released "IsMoveWaiting"
4501/// returns kTRUE. If the mouse button released before the mose moved from the
4502/// initial ButtonPress location, "IsMoveWaiting" returns kFALSE.
4503
4505{
4506 return fMoveWaiting;
4507}
4508
4509////////////////////////////////////////////////////////////////////////////////
4510/// Layout and Resize frame.
4511/// If global is kFALSE - compact selected frame
4512/// If global is kFALSE - compact main frame of selected frame
4513
4515{
4516 TGCompositeFrame *comp = 0;
4517 TGFrameElement *fe;
4518
4519 if (fStop || !fClient || !fClient->IsEditable() || !fPimpl->fGrab) {
4520 return;
4521 }
4522
4523 TGWindow *parent = (TGWindow*)fPimpl->fGrab->GetParent();
4524
4525 if (global) {
4526 if (!fBuilder) {
4528 } else {
4530 if (!comp) {
4532 }
4533 }
4534 } else {
4535 if (fPimpl->fGrab &&
4537 comp = (TGCompositeFrame*)fPimpl->fGrab;
4538 } else {
4539 comp = (TGCompositeFrame*)parent;
4540 }
4541 }
4542
4543 if (!comp || IsFixedLayout(comp) || IsFixedLayout(parent) ||
4544 IsFixedSize(comp) || IsFixedH(comp) || IsFixedW(comp)) return;
4545
4546 comp->SetLayoutBroken(kFALSE);
4547
4548 TIter next(comp->GetList());
4549
4550 TGFrame *root = (TGFrame *)fClient->GetRoot();
4551 root->SetEditable(kFALSE);
4552
4553 TGDimension d;
4554
4555 if (global) {
4556 while ((fe = (TGFrameElement*)next())) {
4557 if (IsFixedLayout(fe->fFrame) || IsFixedSize(fe->fFrame) ||
4558 IsFixedH(fe->fFrame) || IsFixedW(fe->fFrame)) continue;
4559
4561 d = fe->fFrame->GetDefaultSize();
4562
4563 // avoid "to point" resizing
4564 if ((d.fWidth > 10) && (d.fHeight > 10)) {
4565 fe->fFrame->Resize();
4566 } else if (d.fWidth > 10) {
4567 fe->fFrame->Resize(d.fWidth, 10);
4568 } else if (d.fHeight > 10) {
4569 fe->fFrame->Resize(10, d.fHeight);
4570 } else {
4571 fe->fFrame->Resize(10, 10);
4572 }
4574 }
4575 if (!IsFixedLayout(root)) {
4576 root->SetLayoutBroken(kFALSE);
4577 }
4579 }
4580
4581 if (!IsFixedLayout(comp)) {
4582 comp->SetLayoutBroken(kFALSE);
4583 d = comp->GetDefaultSize();
4584
4585 // avoid "to point" resizing
4586 if ((d.fWidth > 10) && (d.fHeight > 10)) {
4587 comp->Resize();
4588 } else if (d.fWidth > 10) {
4589 comp->Resize(d.fWidth, 10);
4590 } else if (d.fHeight > 10) {
4591 comp->Resize(10, d.fHeight);
4592 } else {
4593 comp->Resize(10, 10);
4594 }
4595 layoutFrame(comp);
4596 }
4597
4599 TGMdiDecorFrame *decor = (TGMdiDecorFrame *)comp->GetParent();
4600 Int_t b = 2 * decor->GetBorderWidth();
4601 decor->MoveResize(decor->GetX(), decor->GetY(), comp->GetDefaultWidth() + b,
4602 comp->GetDefaultHeight() + b + decor->GetTitleBar()->GetDefaultHeight());
4603 }
4604
4605 root->SetEditable(kTRUE);
4606
4607 fClient->NeedRedraw(comp);
4608 SelectFrame(comp);
4609 DoRedraw();
4610}
4611
4612////////////////////////////////////////////////////////////////////////////////
4613/// Grab server.
4614
4616{
4617 static Bool_t gon = kFALSE;
4618 static const TGWindow *gw = 0;
4619
4620 if ((gon == on) && (fClient->GetRoot() == gw)) {
4621 return;
4622 }
4623
4624 gon = on; gw = fClient->GetRoot();
4625
4626 if (on) {
4627 fStop = kFALSE;
4628
4629 if (fPimpl->fRepeatTimer) {
4631 } else {
4633 }
4636
4637 Snap2Grid();
4638 } else {
4640
4641 if (fPimpl->fRepeatTimer) {
4643 }
4644
4645 fSelected = fPimpl->fGrab = 0;
4646
4647 delete fPimpl->fGrid;
4648 fPimpl->fGrid = 0;
4649
4651
4652 TGWindow *root = (TGWindow*)fClient->GetRoot();
4653 if (root) {
4654 fClient->SetRoot(0);
4655 }
4656
4659 }
4660
4663 }
4664
4665 if (fBuilder) {
4666 fBuilder->Update();
4667 }
4668 //CloseMenus();
4669
4670 fStop = kTRUE;
4671 }
4672
4673 if (on && fClient->IsEditable()) {
4674 gVirtualX->SetCursor(fClient->GetRoot()->GetId(),
4675 gVirtualX->CreateCursor(kPointer));
4676 }
4677}
4678
4679////////////////////////////////////////////////////////////////////////////////
4680/// Return grid coordinates which are close to given
4681
4683{
4684 UInt_t step = GetGridStep();
4685 x = x - x%step;
4686 y = y - y%step;
4687}
4688
4689////////////////////////////////////////////////////////////////////////////////
4690/// Main handler of actions
4691
4693{
4694 fPimpl->fLastPopupAction = act;
4695
4696 switch ((EActionType)act) {
4697 case kPropertyAct:
4699 break;
4700 case kEditableAct:
4702 if (fBuilder) {
4704 }
4705 break;
4706 case kCutAct:
4707 HandleCut();
4708 break;
4709 case kCopyAct:
4710 HandleCopy();
4711 break;
4712 case kPasteAct:
4713 HandlePaste();
4714 break;
4715 case kCropAct:
4717 break;
4718 case kCompactAct:
4719 Compact(kFALSE);
4720 break;
4721 case kCompactGlobalAct:
4722 Compact(kTRUE);
4723 break;
4724 case kDropAct:
4726 break;
4727 case kLayUpAct:
4729 break;
4730 case kLayDownAct:
4732 break;
4733 case kCloneAct:
4734 CloneEditable();
4735 break;
4736 case kGrabAct:
4738 break;
4739 case kDeleteAct:
4741 break;
4742 case kLeftAct:
4744 break;
4745 case kRightAct:
4747 break;
4748 case kUpAct:
4750 break;
4751 case kDownAct:
4753 break;
4754 case kEndEditAct:
4755 if (fBuilder) {
4757 }
4759 break;
4760 case kReplaceAct:
4761 HandleReplace();
4762 break;
4763 case kGridAct:
4764 HandleGrid();
4765 break;
4766 case kBreakLayoutAct:
4767 BreakLayout();
4768 break;
4769 case kSwitchLayoutAct:
4770 case kLayoutVAct:
4771 case kLayoutHAct:
4772 SwitchLayout();
4773 break;
4774 case kNewAct:
4775 if (fBuilder) {
4777 } else {
4778 TGMainFrame *main = new TGMainFrame(fClient->GetDefaultRoot(), 300, 300);
4779 main->MapRaised();
4780 main->SetEditable(kTRUE);
4781 }
4782 break;
4783 case kOpenAct:
4784 if (fBuilder) {
4786 } else {
4787 TGMainFrame *main = new TGMainFrame(fClient->GetDefaultRoot(), 300, 300);
4788 main->MapRaised();
4789 main->SetEditable(kTRUE);
4790 }
4791 break;
4792 case kSaveAct:
4793 if (fBuilder) {
4797 } else {
4798 Save();
4799 }
4800 } else {
4801 Save();
4802 }
4803 break;
4804 case kSaveFrameAct:
4805 SaveFrame();
4806 break;
4807 default:
4808 break;
4809 }
4810
4812
4813 if (fBuilder) {
4814 fBuilder->SetAction(0);
4815 //fBuilder->Update();
4816 }
4817
4818 if (fPimpl->fSaveGrab) {
4820 }
4821
4822 DoRedraw();
4823}
4824
4825////////////////////////////////////////////////////////////////////////////////
4826/// kTRUE - if it's possible to switch disable/enable layout
4827
4829{
4830 return (!(w->GetEditDisabled() & kEditDisable) &&
4831 !IsFixedLayout(w) && w->InheritsFrom(TGCompositeFrame::Class()));
4832}
4833
4834////////////////////////////////////////////////////////////////////////////////
4835/// kTRUE - if it's possible to change layout order in the parent's layout of window w
4836
4838{
4839 return (w->GetParent()->InheritsFrom(TGCompositeFrame::Class()) &&
4840 !((TGCompositeFrame*)w->GetParent())->IsLayoutBroken() &&
4841 !IsFixedLayout((TGWindow*)w->GetParent()));
4842}
4843
4844////////////////////////////////////////////////////////////////////////////////
4845/// kTRUE is frame could be compacted/"laid out"
4846
4848{
4849 return CanChangeLayout(w);
4850/*
4851 return (!IsFixedLayout(w) &&
4852 w->InheritsFrom(TGCompositeFrame::Class()) &&
4853 ((TGCompositeFrame*)w)->IsLayoutBroken() &&
4854 !IsEditDisabled((TGWindow*)w->GetParent()) &&
4855 !IsFixedLayout((TGWindow*)w->GetParent()));
4856*/
4857}
4858
4859////////////////////////////////////////////////////////////////////////////////
4860/// Create widget property editor (it could be located outside of guibuilder)
4861
4863{
4864// if (!fPimpl->fClickFrame) return;
4865
4866 TGWindow *root = (TGWindow*)fClient->GetRoot();
4867 root->SetEditable(kFALSE);
4868
4870
4874
4875 root->SetEditable(kTRUE);
4876}
4877
4878////////////////////////////////////////////////////////////////////////////////
4879/// Helper method
4880
4882{
4883 fEditor = e;
4884
4885 if (!fEditor) {
4886 return;
4887 }
4888
4890 fEditor->Connect("UpdateSelected(TGFrame*)", "TGuiBldDragManager", this,
4891 "HandleUpdateSelected(TGFrame*)");
4892}
4893
4894////////////////////////////////////////////////////////////////////////////////
4895/// Change layout order
4896
4898{
4899 if (fStop || !fPimpl->fGrab || !fPimpl->fGrab->GetFrameElement() ||
4901 return;
4902 }
4903
4905 TList *li = comp->GetList();
4907
4908 if (!fe) { // sanity check
4909 return;
4910 }
4911
4912 TGFrame *frame;
4913 TGFrameElement *el;
4914
4915 if (forward) {
4916 el = (TGFrameElement *)li->After(fe);
4917 if (!el) return;
4918 frame = el->fFrame;
4919
4920 el->fFrame = fPimpl->fGrab;
4922 fe->fFrame = frame;
4923 frame->SetFrameElement(fe);
4924 } else {
4925 el = (TGFrameElement *)li->Before(fe);
4926
4927 if (!el) {
4928 return;
4929 }
4930 frame = el->fFrame;
4931
4932 el->fFrame = fPimpl->fGrab;
4934 fe->fFrame = frame;
4935 frame->SetFrameElement(fe);
4936 }
4937
4938 Bool_t sav = comp->IsLayoutBroken();
4939 comp->SetLayoutBroken(kFALSE);
4940 TGWindow *root = (TGWindow *)fClient->GetRoot();
4941 root->SetEditable(kFALSE);
4942 comp->Layout();
4943 DoRedraw();
4944 root->SetEditable(kTRUE);
4945
4946 if (sav) {
4947 comp->SetLayoutBroken(kTRUE);
4948 }
4949 SelectFrame(el->fFrame);
4950}
4951
4952////////////////////////////////////////////////////////////////////////////////
4953/// Switch on/of grid drawn.
4954
4956{
4957 if (fStop) {
4958 return;
4959 }
4960
4961 TGWindow *root = (TGWindow*)fClient->GetRoot();
4962
4963 if (!root || (root == fClient->GetDefaultRoot())) {
4964 return;
4965 }
4966
4967 if (fPimpl->fGrid->fgStep > 1) {
4968 fPimpl->fGrid->SetStep(1);
4969 if (fBuilder) {
4970 fBuilder->UpdateStatusBar("Grid switched OFF");
4971 }
4972 } else {
4974
4975 if (fBuilder) {
4976 fBuilder->UpdateStatusBar("Grid switched ON");
4977 }
4978
4980 TGCompositeFrame *comp = (TGCompositeFrame*)root;
4981 TIter next(comp->GetList());
4982 TGFrameElement *fe;
4983 Int_t x, y, w, h;
4984
4985 while ((fe = (TGFrameElement*)next())) {
4986 x = fe->fFrame->GetX();
4987 y = fe->fFrame->GetY();
4988 w = fe->fFrame->GetWidth();
4989 h = fe->fFrame->GetHeight();
4990 ToGrid(x, y);
4991 ToGrid(w, h);
4992 fe->fFrame->MoveResize(x, y, w, h);
4993 }
4994 }
4995 }
4996
4997 Snap2Grid();
4999}
5000
5001////////////////////////////////////////////////////////////////////////////////
5002/// Helper to find a frame which can be laid out
5003
5005{
5006 if (fStop || !f) {
5007 return 0;
5008 }
5009
5010 const TGWindow *parent = f->GetParent();
5011 TGCompositeFrame *ret = 0;
5012
5013 while (parent && (parent != fClient->GetDefaultRoot())) {
5014 ret = (TGCompositeFrame*)parent;
5015 if (parent->InheritsFrom(TGMdiFrame::Class())) return ret;
5016 parent = parent->GetParent();
5017 }
5018 return ret;
5019}
5020
5021////////////////////////////////////////////////////////////////////////////////
5022/// When selected frame was changed by guibuilder editor -> update its appearance
5023
5025{
5026 if (fStop || !f) {
5027 return;
5028 }
5029
5030 TGCompositeFrame *parent = 0;
5031 if (f->GetParent() &&
5032 f->GetParent()->InheritsFrom(TGCompositeFrame::Class())) {
5033 parent = (TGCompositeFrame*)f->GetParent();
5034 }
5035
5036 if (!parent || !CanChangeLayout(parent)) {
5037 return;
5038 }
5039
5040 Bool_t sav = parent->IsLayoutBroken();
5041 parent->SetLayoutBroken(kFALSE);
5042
5043 if ((parent->GetWidth() < parent->GetDefaultWidth()) ||
5044 (parent->GetHeight() < parent->GetDefaultHeight())) {
5045 parent->Resize(parent->GetDefaultSize());
5046 } else {
5047 parent->Layout();
5048 if (f->InheritsFrom(TGCompositeFrame::Class())) {
5049 layoutFrame(f);
5050 }
5051 }
5052 fClient->NeedRedraw(parent, kTRUE);
5054
5055 if (sav) parent->SetLayoutBroken(kTRUE);
5056
5057 SelectFrame(f);
5058}
5059
5060////////////////////////////////////////////////////////////////////////////////
5061/// Hide/Unmap grab rectangles.
5062
5064{
5065 static Bool_t first = kFALSE;
5066
5067 if (fPimpl->fGrabRectHidden) {
5068 return;
5069 }
5070 // skip very first event
5071 if (!first) {
5072 first = kTRUE;
5073 return;
5074 }
5075 int i = 0;
5076 for (i = 0; i < 8; i++) fPimpl->fGrabRect[i]->UnmapWindow();
5077 for (i = 0; i < 4; i++) fPimpl->fAroundFrame[i]->UnmapWindow();
5079}
5080
5081////////////////////////////////////////////////////////////////////////////////
5082/// Delete widget property editor.
5083
5085{
5086 if (fStop || !fEditor) {
5087 return;
5088 }
5089
5091
5092 delete fEditor;
5093 fEditor = 0;
5094}
5095
5096////////////////////////////////////////////////////////////////////////////////
5097/// Return the X coordinate where drag started
5098
5100{
5101 return fPimpl->fX0;
5102}
5103
5104////////////////////////////////////////////////////////////////////////////////
5105/// Return the Y coordinate where drag started
5106
5108{
5109 return fPimpl->fY0;
5110}
5111
5112////////////////////////////////////////////////////////////////////////////////
5113/// Return the current X coordinate of the dragged frame
5114
5116{
5117 return fPimpl->fY;
5118}
5119
5120////////////////////////////////////////////////////////////////////////////////
5121/// Returns the current Y coordinate of the dragged frame
5122
5124{
5125 return fPimpl->fY;
5126}
5127
5128////////////////////////////////////////////////////////////////////////////////
5129/// Disable/Enable layout for selected/grabbed composite frame.
5130
5132{
5133 if (fStop) {
5134 return;
5135 }
5136
5137 TGFrame *frame = fSelected;
5138
5139 if (!frame) {
5140 return;
5141 }
5142
5143 TString str = frame->ClassName();
5144 str += "::";
5145 str += frame->GetName();
5146
5147 if (IsFixedLayout(frame)) {
5148 if (fBuilder) {
5149 str += " layout cannot be broken";
5151 }
5152 return;
5153 }
5154
5155 frame->SetLayoutBroken(!frame->IsLayoutBroken());
5157
5158 if (fBuilder) {
5159 str += (frame->IsLayoutBroken() ? " Disable Layout" : " Enable Layout");
5161 }
5162 if (fPimpl->fGrab && (fPimpl->fGrab->IsA() == TGCanvas::Class())) {
5163 fPimpl->fGrab->Layout();
5164 }
5165}
5166
5167////////////////////////////////////////////////////////////////////////////////
5168/// Switch Horizontal/Vertical layout of selected/grabbed composite frame
5169
5171{
5172 if (fStop || !fPimpl->fGrab) {
5173 return;
5174 }
5175
5177
5178 comp->SetLayoutBroken(kFALSE);
5179
5180 UInt_t opt = comp->GetOptions();
5182
5183 if (!m) {
5184 return;
5185 }
5186
5188 opt &= ~kHorizontalFrame;
5189 opt |= kVerticalFrame;
5190
5191 if (fBuilder) {
5192 TString str = comp->ClassName();
5193 str += "::";
5194 str += comp->GetName();
5195 str += " Vertical Layout ON";
5197 }
5198 } else if (m->InheritsFrom(TGVerticalLayout::Class())) {
5199 opt &= ~kVerticalFrame;
5200 opt |= kHorizontalFrame;
5201
5202 if (fBuilder) {
5203 TString str = comp->ClassName();
5204 str += "::";
5205 str += comp->GetName();
5206 str += " Horizontal Layout ON";
5208 }
5209 }
5210
5211 comp->ChangeOptions(opt);
5212 if (!IsFixedSize(comp)) {
5213 comp->Resize();
5214 }
5215
5216 if (fPimpl->fGrab && (fPimpl->fGrab->IsA() == TGCanvas::Class())) {
5217 fPimpl->fGrab->Layout();
5218 }
5219
5220 fClient->NeedRedraw(comp);
5221 SelectFrame(comp);
5222}
5223
5224////////////////////////////////////////////////////////////////////////////////
5225/// Return the current grabbed/selected frame.
5226
5228{
5229 return fSelected;
5230}
5231
5232////////////////////////////////////////////////////////////////////////////////
5233/// Helper to close all menus
5234
5236{
5237 void *ud;
5238
5239 if (fFrameMenu) {
5240 fFrameMenu->EndMenu(ud);
5241 }
5242 if (fLassoMenu) {
5243 fLassoMenu->EndMenu(ud);
5244 }
5245 //UnmapAllPopups();
5246}
5247
5248////////////////////////////////////////////////////////////////////////////////
5249/// Return the parent frame which can be edited.
5250
5252{
5253 if (!fr || (fr == fClient->GetDefaultRoot())) {
5254 return 0;
5255 }
5256
5257 TGWindow *parent = (TGWindow*)fr->GetParent();
5258
5259 while (parent && (parent != fClient->GetDefaultRoot())) {
5260 if (!IsEditDisabled(parent) && !IsGrabDisabled(parent)) {
5261 return (TGFrame*)parent;
5262 }
5263 parent = (TGWindow*)parent->GetParent();
5264 }
5265 return 0;
5266}
5267
5268////////////////////////////////////////////////////////////////////////////////
5269/// Return a name of icon
5270
5272{
5273 Int_t p1 = in.Index("*icon=", 1);
5274 if (p1 == kNPOS) return "";
5275 p1 += 6;
5276 Int_t p2 = in.Index("*", p1);
5277
5278 if (p2 == kNPOS) return "";
5279
5280 return in(p1, p2-p1);
5281}
5282
5283////////////////////////////////////////////////////////////////////////////////
5284/// Helper
5285
5286static Bool_t containBaseClass(const char *somestring, TClass *cl)
5287{
5288 TString str = somestring;
5289
5290 if (str.Contains(cl->GetName())) {
5291 return kTRUE;
5292 }
5293
5294 TIter nextBaseClass(cl->GetListOfBases());
5295 TBaseClass *bc;
5296
5297 while ((bc = (TBaseClass*)nextBaseClass())) {
5298 if (!bc->GetClassPointer()) {
5299 continue;
5300 }
5301 if (containBaseClass(somestring, bc->GetClassPointer())) {
5302 return kTRUE;
5303 }
5304 }
5305
5306 return kFALSE;
5307}
5308
5309////////////////////////////////////////////////////////////////////////////////
5310/// Add DIALOG entries to the selected frame popup menu
5311
5313{
5314 if (!menu || !object) {
5315 return;
5316 }
5317
5318 TMethod *method;
5319 TIter next(fListOfDialogs);
5320 TString str;
5321 TString pname;
5322 const TGPicture *pic;
5323 TClass *cl = object->IsA();
5324 TString ename;
5325
5326 while ((method = (TMethod*) next())) {
5327 ename = method->GetName();
5328 ename += "...";
5329 if (menu->GetEntry(ename.Data())) {
5330 continue;
5331 }
5332 if (!containBaseClass(method->GetSignature(), cl)) {
5333 continue;
5334 }
5335
5336 str = method->GetCommentString();
5337 pname = FindMenuIconName(str);
5338 pic = fClient->GetPicture(pname.Data());
5339 menu->AddEntry(ename.Data(), kMethodMenuAct, method, pic);
5340 }
5341 menu->AddSeparator();
5342}
5343
5344////////////////////////////////////////////////////////////////////////////////
5345/// Add entries with class //*MENU* methods
5346
5348{
5349 if (!menu || !object) {
5350 return;
5351 }
5352
5353 TList *menuItemList;
5354 TClassMenuItem *menuItem;
5355 TString str;
5356 TString pname;
5357 const TGPicture *pic;
5358 TMethod *method;
5359 TClass *classPtr = 0;
5360 TList *methodList;
5361 EMenuItemKind menuKind;
5362 TDataMember *m;
5363
5364 AddDialogMethods(menu, object);
5365
5366 menuItemList = object->IsA()->GetMenuList();
5367 TIter nextItem(menuItemList);
5368
5369 fPimpl->fMenuObject = (TGFrame*)object;
5370 nextItem.Reset();
5371
5372 while ((menuItem = (TClassMenuItem*) nextItem())) {
5373 switch (menuItem->GetType()) {
5375 {
5376 // Standard list of class methods. Rebuild from scratch.
5377 // Get linked list of objects menu items (i.e. member functions
5378 // with the token *MENU in their comment fields.
5379 methodList = new TList;
5380 object->IsA()->GetMenuItems(methodList);
5381
5382 TIter next(methodList);
5383
5384 while ((method = (TMethod*) next())) {
5385 if (classPtr != method->GetClass()) {
5386// menu->AddSeparator();
5387 classPtr = method->GetClass();
5388 }
5389
5390 menuKind = method->IsMenuItem();
5391
5392 switch (menuKind) {
5393 case kMenuDialog:
5394 {
5395 str = method->GetCommentString();
5396 pname = FindMenuIconName(str);
5397 pic = fClient->GetPicture(pname.Data());
5398 menu->AddEntry(method->GetName(), kMethodMenuAct, method, pic);
5399 break;
5400 }
5401
5402 case kMenuSubMenu:
5403 if ((m = method->FindDataMember())) {
5404 if (m->GetterMethod()) {
5406 menu->AddPopup(method->GetName(), r);
5408 TIter nxt(m->GetOptions());
5409 TOptionListItem *it;
5410
5411 while ((it = (TOptionListItem*) nxt())) {
5412 const char *name = it->fOptName;
5413 Long_t val = it->fValue;
5414
5415 TToggle *t = new TToggle;
5416 t->SetToggledObject(object, method);
5417 t->SetOnValue(val);
5419
5420 //r->AddSeparator();
5421 r->AddEntry(name, kToggleMenuAct, t);
5422 if (t->GetState()) r->CheckEntryByData(t);
5423 }
5424 } else {
5425 menu->AddEntry(method->GetName(), kMethodMenuAct, method);
5426 }
5427 }
5428 break;
5429
5430 case kMenuToggle:
5431 {
5432 TToggle *t = new TToggle;
5433 t->SetToggledObject(object, method);
5434 t->SetOnValue(1);
5436 menu->AddEntry(method->GetName(), kToggleMenuAct, t);
5437 if (t->GetState()) menu->CheckEntryByData(t);
5438 }
5439 break;
5440
5441 default:
5442 break;
5443 }
5444 }
5445 delete methodList;
5446 }
5447 break;
5449 {
5450 if (menuItem->IsToggle()) {
5451 TMethod* method2 =
5452 object->IsA()->GetMethodWithPrototype(menuItem->GetFunctionName(),
5453 menuItem->GetArgs());
5454 if (method2) {
5455 TToggle *t = new TToggle;
5456 t->SetToggledObject(object, method2);
5457 t->SetOnValue(1);
5459
5460 menu->AddEntry(method2->GetName(), kToggleMenuAct, t);
5461 if (t->GetState()) menu->CheckEntryByData(t);
5462 }
5463 } else {
5464 const char* menuItemTitle = menuItem->GetTitle();
5465 if (strlen(menuItemTitle)==0) menuItemTitle = menuItem->GetFunctionName();
5466 menu->AddEntry(menuItemTitle, kMethodMenuAct, menuItem);
5467 }
5468 }
5469
5470 break;
5471 default:
5472 break;
5473 }
5474 }
5475}
5476
5477////////////////////////////////////////////////////////////////////////////////
5478/// Process a method chosen via frame context menu
5479
5481{
5482 if (!fFrameMenu || ((id != kMethodMenuAct) && (id != kToggleMenuAct))) {
5483 return;
5484 }
5485
5486 TGMenuEntry *me = 0;
5487
5488 if (id == kMethodMenuAct) {
5489 delete gMenuDialog;
5490 me = fFrameMenu->GetCurrent();
5491
5492 if (!me || !fPimpl->fMenuObject) {
5493 return;
5494 }
5495 TMethod *method = (TMethod*)me->GetUserData();
5496 TString str = method->GetCommentString();
5497
5498 if (str.Contains("*DIALOG")) {
5499 TString str2;
5500 str2.Form("((TGuiBldDragManager*)0x%zx)->%s((%s*)0x%zx)", (size_t)this, method->GetName(),
5502 gCling->Calc((char *)str2.Data());
5503 //delete fFrameMenu; // suicide (BB)?
5504 //fFrameMenu = 0;
5505 return;
5506 }
5508 gMenuDialog->Popup();
5509
5510 } else if (id == kToggleMenuAct) {
5511 me = fFrameMenu->GetCurrent();
5512 if (!me) {
5513 return;
5514 }
5515 TGPopupMenu *menu = me->GetPopup();
5516 TToggle *toggle = 0;
5517
5518 if (menu) { //process submenu
5519 toggle = (TToggle*)menu->GetCurrent()->GetUserData();
5520 } else { //process check entry
5521 toggle = (TToggle*)fFrameMenu->GetCurrent()->GetUserData();
5522 }
5523 if (toggle) {
5524 toggle->Toggle();
5525 }
5526 }
5527}
5528
5529////////////////////////////////////////////////////////////////////////////////
5530/// Delete dialog and trash
5531
5533{
5536 gMenuDialog = 0;
5537 fPimpl->fMenuObject = 0;
5538}
5539
5540////////////////////////////////////////////////////////////////////////////////
5541/// Process dialog OK button pressed
5542
5544{
5546 DoRedraw();
5548 gMenuDialog = 0;
5549}
5550
5551////////////////////////////////////////////////////////////////////////////////
5552/// Process dialog Apply button pressed
5553
5555{
5557}
5558
5559////////////////////////////////////////////////////////////////////////////////
5560/// Process dialog Cancel button pressed
5561
5563{
5565 gMenuDialog = 0;
5566}
5567
5568////////////////////////////////////////////////////////////////////////////////
5569/// Create and place context menu for selected frame
5570
5572{
5573 if (fStop) {
5574 return;
5575 }
5576
5578 fPimpl->fX0 = x;
5579 fPimpl->fY0 = y;
5580 fPimpl->fClickFrame = frame;
5581
5582 Bool_t composite = frame->InheritsFrom(TGCompositeFrame::Class());
5584
5585 TGCompositeFrame *cfr = 0;
5586 TGCompositeFrame *cfrp = 0;
5587 TGLayoutManager *lm = 0;
5588
5589 if (composite) {
5590 cfr = (TGCompositeFrame *)frame;
5591 lm = cfr->GetLayoutManager();
5592 }
5593 if (compar) {
5594 cfrp = (TGCompositeFrame *)frame->GetParent();
5595 }
5596
5597 delete fFrameMenu;
5598
5600 fFrameMenu->Connect("Activated(Int_t)", "TGuiBldDragManager", this, "DoClassMenu(Int_t)");
5601
5602 TString title = frame->ClassName();
5603 title += "::";
5604 title += frame->GetName();
5605 fFrameMenu->AddLabel(title.Data());
5607
5608 // special case - menu for editable Mdi frame
5609 if (fBuilder && (frame == fBuilder->GetMdiMain()->GetCurrent())) {
5611 fFrameMenu->AddEntry("Paste\tCtrl+V", kPasteAct,
5612 0, fClient->GetPicture("bld_paste.png"));
5613 }
5614 fFrameMenu->AddEntry("Compact\tCtrl+L", kCompactAct,
5615 0, fClient->GetPicture("bld_compact.png"));
5616 fFrameMenu->AddEntry("Grid On/Off\tCtrl+G", kGridAct,
5617 0, fClient->GetPicture("bld_grid.png"));
5618 fFrameMenu->AddEntry("Save As ...\tCtrl+S", kSaveAct,
5619 0, fClient->GetPicture("bld_save.png"));
5620 fFrameMenu->AddEntry("End Edit\tCtrl+DblClick", kEndEditAct,
5621 0, fClient->GetPicture("bld_stop.png"));
5622 goto out;
5623 }
5624
5626
5627 if (!fBuilder) {
5628 fFrameMenu->AddEntry("Gui Builder", kPropertyAct);
5630 }
5631/*
5632 if (!frame->IsEditable() && !InEditable(frame->GetId())) {
5633 fPimpl->fSaveGrab = frame;
5634 goto out;
5635 }
5636*/
5637 if (!IsEditDisabled(cfrp)) {
5639
5640 if (composite && !IsFixedLayout(frame) && cfr->GetList()->GetEntries()) {
5641 fFrameMenu->AddEntry("Drop\tCtrl+Return", kDropAct);
5642 }
5643
5644 if (!IsFixedLayout(cfrp)) {
5645 fFrameMenu->AddEntry("Cut\tCtrl+X", kCutAct,
5646 0, fClient->GetPicture("bld_cut.png"));
5647 }
5648 //
5649 fFrameMenu->AddEntry("Copy\tCtrl+C", kCopyAct,
5650 0, fClient->GetPicture("bld_copy.png"));
5651
5652 if (frame->IsEditable() && !IsFixedLayout(frame) &&
5654 fFrameMenu->AddEntry("Paste\tCtrl+V", kPasteAct,
5655 0, fClient->GetPicture("bld_paste.png"));
5656 }
5657
5658 if (!IsFixedLayout(cfrp)) {
5659 fFrameMenu->AddEntry("Delete\tDel", kDeleteAct,
5660 0, fClient->GetPicture("bld_delete.png"));
5661 }
5662
5663 if (!IsFixedLayout(cfrp)) {
5664 fFrameMenu->AddEntry("Crop\tShift+Del", kCropAct,
5665 0, fClient->GetPicture("bld_crop.png"));
5666 }
5667
5668// if (!IsFixedLayout(cfrp) && !gSystem->AccessPathName(fPasteFileName.Data())) {
5669// fFrameMenu->AddEntry("Replace\tCtrl+R", kReplaceAct,
5670// 0, fClient->GetPicture("bld_paste_into.png"));
5671// }
5672
5674 } else {
5676 fFrameMenu->AddEntry("Paste\tCtrl+V", kPasteAct,
5677 0, fClient->GetPicture("bld_paste.png"));
5678 }
5679 if (frame->GetMainFrame() == frame) {
5680 fFrameMenu->AddEntry("Clone\tCtrl+A", kCloneAct);
5681 }
5683 }
5684
5685 if (CanChangeLayout(frame)) {
5686 const char *label = (frame->IsLayoutBroken() ? "Allow Layout\tCtrl+B" :
5687 "Break Layout\tCtrl+B");
5689 0, fClient->GetPicture("bld_break.png"));
5690 }
5691
5692 if (composite && !cfr->GetList()->IsEmpty()) {
5693 if (CanCompact(frame)) {
5694 if (!frame->IsEditable()) {
5695 fFrameMenu->AddEntry("Compact\tCtrl+L", kCompactAct,
5696 0, fClient->GetPicture("bld_compact.png"));
5697 } else {
5698 fFrameMenu->AddEntry("Compact\tCtrl+L", kCompactGlobalAct,
5699 0, fClient->GetPicture("bld_compact.png"));
5700 }
5701 }
5702
5703 if (lm && ((lm->IsA() == TGVerticalLayout::Class()) ||
5704 (lm->IsA() == TGHorizontalLayout::Class())) && !IsFixedLayout(frame)) {
5705
5706 if (lm->IsA() == TGVerticalLayout::Class()) {
5707 fFrameMenu->AddEntry("Horizontal\tCtrl+H", kSwitchLayoutAct,
5708 0, fClient->GetPicture("bld_hbox.png"));
5709 } else if (lm->IsA() == TGHorizontalLayout::Class()) {
5710 fFrameMenu->AddEntry("Vertical\tCtrl+H", kSwitchLayoutAct,
5711 0, fClient->GetPicture("bld_vbox.png"));
5712 }
5713 }
5714 }
5715
5716 if (compar && (cfrp->GetList()->GetSize() > 1) && CanChangeLayoutOrder(frame)) {
5717 if (cfrp->GetList()->First() != frame->GetFrameElement()) {
5718 fFrameMenu->AddEntry("Lay Up\tUp/Left", kLayUpAct);
5719 }
5720 if (cfrp->GetList()->Last() != frame->GetFrameElement()) {
5721 fFrameMenu->AddEntry("Lay Down\tDown/Right", kLayDownAct);
5722 }
5724 }
5725
5726 if (frame->IsEditable()) {
5727 fFrameMenu->AddEntry("Grid On/Off\tCtrl+G", kGridAct,
5728 0, fClient->GetPicture("bld_grid.png"));
5729 }
5730 if (composite && !cfr->GetList()->IsEmpty()) {
5731 fPimpl->fSaveGrab = frame;
5732 fFrameMenu->AddEntry("Save As ... ", kSaveFrameAct,
5733 0, fClient->GetPicture("bld_save.png"));
5734 }
5735
5736out:
5737 fFrameMenu->Connect("Activated(Int_t)", "TGuiBldDragManager", this, "HandleAction(Int_t)");
5738
5741
5743}
5744
5745////////////////////////////////////////////////////////////////////////////////
5746/// Create context menu for lasso actions.
5747
5749{
5750 if (fStop || !fLassoDrawn) {
5751 return;
5752 }
5753
5754 DrawLasso();
5755
5756 delete fLassoMenu;
5757
5759 fLassoMenu->AddLabel("Edit actions");
5761 fLassoMenu->AddEntry("Grab\tReturn", kGrabAct);
5763 fLassoMenu->AddEntry("Delete\tDelete", kDeleteAct,
5764 0, fClient->GetPicture("bld_delete.png"));
5765 fLassoMenu->AddEntry("Crop\tShift+Delete", kCropAct,
5766 0, fClient->GetPicture("bld_crop.png"));
5768 fLassoMenu->AddEntry("Align Left\tLeft Key", kLeftAct,
5769 0, fClient->GetPicture("bld_AlignLeft.png"));
5770 fLassoMenu->AddEntry("Align Right\tRight Key", kRightAct,
5771 0, fClient->GetPicture("bld_AlignRight.png"));
5772 fLassoMenu->AddEntry("Align Up\tUp Key", kUpAct,
5773 0, fClient->GetPicture("bld_AlignTop.png"));
5774 fLassoMenu->AddEntry("Align Down\tDown Key", kDownAct,
5775 0, fClient->GetPicture("bld_AlignBtm.png"));
5776
5777 fLassoMenu->Connect("Activated(Int_t)", "TGuiBldDragManager", this, "HandleAction(Int_t)");
5778
5782}
5783
5784////////////////////////////////////////////////////////////////////////////////
5785/// Return kTRUE if paste frame exist.
5786
5788{
5790}
5791
5792////////////////////////////////////////////////////////////////////////////////
5793/// Return pointer to global color dialog. If dialog is not yet created
5794/// and input parameter is kTRUE - the dialog will be created.
5795
5797{
5798 static Int_t retc;
5799 static Pixel_t color;
5800
5801 if (!fgGlobalColorDialog && create) {
5802 fgGlobalColorDialog = new TGColorDialog(gClient->GetDefaultRoot(), 0,
5803 &retc, &color, kFALSE);
5804 int i = 0;
5805 for (i = 0; i < 10; i++) {
5807 }
5808 for (i = 0; i < 10; i++) {
5810 }
5811 }
5812 return fgGlobalColorDialog;
5813}
5814
5815////////////////////////////////////////////////////////////////////////////////
5816/// Create global font dialog.
5817
5819{
5821
5822 if (!fgGlobalFontDialog) {
5823 fgGlobalFontDialog = new TGFontDialog(gClient->GetDefaultRoot(), 0, &prop, "", 0, kFALSE);
5824 }
5825 return fgGlobalFontDialog;
5826}
5827
5828////////////////////////////////////////////////////////////////////////////////
5829/// Map dialog and place it relative to selected frame.
5830
5832{
5833 Int_t x = 0, y = 0;
5834 Window_t wdummy;
5835 UInt_t dw = gClient->GetDisplayWidth() - 20;
5836 UInt_t dh = gClient->GetDisplayHeight() - 50;
5837
5838 TGFrame *parent = (TGFrame*)fr->GetParent();
5839 gVirtualX->TranslateCoordinates(parent->GetId(), gClient->GetDefaultRoot()->GetId(),
5840 fr->GetX() + fr->GetWidth(),
5841 fr->GetY() + fr->GetHeight(), x, y, wdummy);
5842
5843 if (x + dialog->GetWidth() > dw) {
5844 x = dw - dialog->GetWidth();
5845 }
5846
5847 if (y + dialog->GetHeight() > dh) {
5848 y = dh - dialog->GetHeight();
5849 }
5850
5851 dialog->Move(x, y);
5852 dialog->SetWMPosition(x, y);
5853 dialog->MapRaised();
5854}
5855
5856////////////////////////////////////////////////////////////////////////////////
5857/// Change background color via context menu.
5858
5860{
5862 cd->SetCurrentColor(fr->GetBackground());
5863 cd->Connect("ColorSelected(Pixel_t)", "TGFrame", fr, "ChangeBackground(Pixel_t)");
5864 MapGlobalDialog(cd, fr);
5865 fClient->WaitForUnmap(cd);
5867}
5868
5869////////////////////////////////////////////////////////////////////////////////
5870/// Change background color via context menu for this frame and all subframes.
5871/// This method is activated via context menu during guibuilding.
5872
5874{
5876 cd->SetCurrentColor(fr->GetBackground());
5877 cd->Connect("ColorSelected(Pixel_t)", "TGCompositeFrame", fr,
5878 "ChangeSubframesBackground(Pixel_t)");
5879 MapGlobalDialog(cd, fr);
5880 fClient->WaitForUnmap(cd);
5882}
5883
5884////////////////////////////////////////////////////////////////////////////////
5885/// Change text color via color selection dialog. This method is activated
5886/// via context menu during guibuilding.
5887
5889{
5891
5892 if (!gc) {
5893 return;
5894 }
5895 ULong_t color = gc->GetForeground();
5896
5898 cd->SetCurrentColor(color);
5899 cd->Connect("ColorSelected(Pixel_t)", "TGGroupFrame", fr, "SetTextColor(Pixel_t)");
5900 MapGlobalDialog(cd, fr);
5901 fClient->WaitForUnmap(cd);
5903}
5904
5905////////////////////////////////////////////////////////////////////////////////
5906/// Change text font via font selection dialog. This method is activated
5907/// via context menu during guibuilding.
5908
5910{
5912
5914
5915 if (!gc) {
5916 return;
5917 }
5918
5920
5921 if (!font) {
5922 return;
5923 }
5924 fd->SetColor(gc->GetForeground());
5925 fd->SetFont(font);
5926 fd->EnableAlign(kFALSE);
5927 fd->Connect("FontSelected(char*)", "TGGroupFrame", fr, "SetTextFont(char*)");
5928 fd->Connect("ColorSelected(Pixel_t)", "TGGroupFrame", fr, "SetTextColor(Pixel_t)");
5929
5930 MapGlobalDialog(fd, fr);
5931 fClient->WaitForUnmap(fd);
5933}
5934
5935////////////////////////////////////////////////////////////////////////////////
5936/// Edit properties via font selection dialog. This method is activated
5937/// via context menu during guibuilding.
5938
5940{
5942
5944 if (!gc) {
5945 return;
5946 }
5947
5949
5950 if (!font) {
5951 return;
5952 }
5953 fd->SetColor(gc->GetForeground());
5954 fd->SetFont(font);
5955 fd->SetAlign(fr->GetTextJustify());
5956
5957 fd->Connect("FontSelected(char*)", "TGTextButton", fr, "SetFont(char*)");
5958 fd->Connect("ColorSelected(Pixel_t)", "TGTextButton", fr, "SetTextColor(Pixel_t)");
5959 fd->Connect("AlignSelected(Int_t)", "TGTextButton", fr, "SetTextJustify(Int_t)");
5960
5961 MapGlobalDialog(fd, fr);
5962 fClient->WaitForUnmap(fd);
5964}
5965
5966////////////////////////////////////////////////////////////////////////////////
5967/// Change text color via color selection dialog. This method is activated
5968/// via context menu during guibuilding.
5969
5971{
5972 TGGC *gc = gClient->GetResourcePool()->GetGCPool()->FindGC(fr->GetNormGC());
5973
5974 if (!gc) {
5975 return;
5976 }
5977 ULong_t color = gc->GetForeground();
5978
5980 cd->SetCurrentColor(color);
5981 cd->Connect("ColorSelected(Pixel_t)", "TGTextButton", fr, "SetTextColor(Pixel_t)");
5982
5983 MapGlobalDialog(cd, fr);
5984 fClient->WaitForUnmap(cd);
5986}
5987
5988////////////////////////////////////////////////////////////////////////////////
5989/// Invoke file dialog to assign a new picture.
5990/// This method is activated via context menu during guibuilding.
5991
5993{
5994 static TGFileInfo fi;
5995 static TString dir(".");
5996 static Bool_t overwr = kFALSE;
5997 TString fname;
5998
6000 fi.SetIniDir(dir);
6001 fi.fOverwrite = overwr;
6002
6003 TGWindow *root = (TGWindow*)fClient->GetRoot();
6005
6006 new TGFileDialog(fClient->GetDefaultRoot(), fr, kFDOpen, &fi);
6007
6008 if (!fi.fFilename) {
6009 root->SetEditable(kTRUE);
6011 return;
6012 }
6013
6014 dir = fi.fIniDir;
6015 overwr = fi.fOverwrite;
6016 fname = fi.fFilename;
6017
6018 const TGPicture *pic = fClient->GetPicture(fname.Data());
6019
6020 if (!pic) {
6021 Int_t retval;
6022 new TGMsgBox(fClient->GetDefaultRoot(), fr, "Error...",
6023 TString::Format("Cannot read image file (%s)", fname.Data()),
6025
6026 if (retval == kMBRetry) {
6027 ChangePicture(fr);
6028 }
6029 } else {
6030 const TGPicture *tmp = fr->GetPicture();
6031 if (tmp) fClient->FreePicture(tmp);
6032
6033 fr->SetPicture(pic);
6034
6035 // not clear how to do at this point
6036 tmp = fr->GetDisabledPicture();
6037 if (tmp) fClient->FreePicture(tmp);
6038 }
6039 root->SetEditable(kTRUE);
6041}
6042
6043////////////////////////////////////////////////////////////////////////////////
6044/// Change background color via context menu
6045
6047{
6049 cd->SetCurrentColor(fr->GetBackground());
6050 cd->Connect("ColorSelected(Pixel_t)", "TGFrame", fr, "ChangeBackground(Pixel_t)");
6051 cd->Connect("ColorSelected(Pixel_t)", "TGScrollBar", fr->GetHScrollbar(), "ChangeBackground(Pixel_t)");
6052 cd->Connect("ColorSelected(Pixel_t)", "TGScrollBar", fr->GetVScrollbar(), "ChangeBackground(Pixel_t)");
6053
6054 MapGlobalDialog(cd, fr);
6055 fClient->WaitForUnmap(cd);
6057}
6058
6059////////////////////////////////////////////////////////////////////////////////
6060/// Change background color for list box entries. This method is invoked
6061/// via context menu during guibuilding.
6062
6064{
6066
6068 cd->SetCurrentColor(color);
6069
6070 cd->Connect("ColorSelected(Pixel_t)", "TGListBox", fr->GetListBox(),
6071 "ChangeBackground(Pixel_t)");
6072
6073 TGLBEntry *se = fr->GetSelectedEntry();
6074
6075 if (se) {
6076 cd->Connect("ColorSelected(Pixel_t)", "TGLBEntry", se,
6077 "SetBackgroundColor(Pixel_t)");
6078 }
6079
6080 TGTextEntry *te = fr->GetTextEntry();
6081
6082 if (te) {
6083 cd->Connect("ColorSelected(Pixel_t)", "TGTextEntry", te,
6084 "SetBackgroundColor(Pixel_t)");
6085 }
6086
6087 MapGlobalDialog(cd, fr);
6088 fClient->WaitForUnmap(cd);
6090
6091 if (se) {
6092 fClient->NeedRedraw(se, kTRUE); // force redraw
6093 }
6094
6095 if (te) {
6096 fClient->NeedRedraw(te, kTRUE);
6097 }
6098}
6099
6100////////////////////////////////////////////////////////////////////////////////
6101/// Edit properties via font selection dialog. This method is activated
6102/// via context menu during guibuilding.
6103
6105{
6107
6109
6110 if (!gc) {
6111 return;
6112 }
6113
6115
6116 if (!font) {
6117 return;
6118 }
6119
6120 fd->SetColor(gc->GetForeground());
6121 fd->SetFont(font);
6122 fd->SetAlign(fr->GetTextJustify());
6123
6124 fd->Connect("FontSelected(char*)", "TGLabel", fr, "SetTextFont(char*)");
6125 fd->Connect("ColorSelected(Pixel_t)", "TGLabel", fr, "SetTextColor(Pixel_t)");
6126 fd->Connect("AlignSelected(Int_t)", "TGLabel", fr, "SetTextJustify(Int_t)");
6127
6128 MapGlobalDialog(fd, fr);
6129 fClient->WaitForUnmap(fd);
6131}
6132
6133////////////////////////////////////////////////////////////////////////////////
6134/// Change text color via color selection dialog. This method is activated
6135/// via context menu during guibuilding.
6136
6138{
6139 TGGC *gc = gClient->GetResourcePool()->GetGCPool()->FindGC(fr->GetNormGC());
6140
6141 if (!gc) {
6142 return;
6143 }
6144
6145 ULong_t color = gc->GetForeground();
6146
6148 cd->SetCurrentColor(color);
6149 cd->Connect("ColorSelected(Pixel_t)", "TGLabel", fr, "SetTextColor(Pixel_t)");
6150
6151 MapGlobalDialog(cd, fr);
6152 fClient->WaitForUnmap(cd);
6154}
6155
6156////////////////////////////////////////////////////////////////////////////////
6157/// Set background color for list box entries. This method is invoked
6158/// via context menu during guibuilding.
6159
6161{
6163
6165 cd->SetCurrentColor(color);
6166 cd->Connect("ColorSelected(Pixel_t)", "TGListBox", fr, "ChangeBackground(Pixel_t)");
6167
6168 MapGlobalDialog(cd, fr);
6169 fClient->WaitForUnmap(cd);
6171}
6172
6173////////////////////////////////////////////////////////////////////////////////
6174/// Set progress bar color via TGColorDialog.
6175/// This method is activated via context menu during guibuilding.
6176
6178{
6179 ULong_t color = fr->GetBarColor();
6180
6182
6183 cd->SetCurrentColor(color);
6184 cd->Connect("ColorSelected(Pixel_t)", "TGProgressBar", fr, "SetBarColor(Pixel_t)");
6185
6186 MapGlobalDialog(cd, fr);
6187 fClient->WaitForUnmap(cd);
6189}
6190
6191////////////////////////////////////////////////////////////////////////////////
6192/// Change text color which displays position.
6193
6195{
6196 TGGC *gc = gClient->GetResourcePool()->GetGCPool()->FindGC(fr->GetNormGC());
6197
6198 if (!gc) {
6199 return;
6200 }
6201
6202 Pixel_t pixel = gc->GetForeground();
6204
6206 cd->Connect("ColorSelected(Pixel_t)", "TGProgressBar", fr,
6207 "SetForegroundColor(Pixel_t)");
6208
6209 MapGlobalDialog(cd, fr);
6210 fClient->WaitForUnmap(cd);
6212}
6213
6214////////////////////////////////////////////////////////////////////////////////
6215/// Set text color. This method is invoked
6216/// via context menu during guibuilding.
6217
6219{
6220 Pixel_t color = fr->GetTextColor();
6221
6223 cd->SetCurrentColor(color);
6224 cd->Connect("ColorSelected(Pixel_t)", "TGTextEntry", fr, "SetTextColor(Pixel_t)");
6225
6226 MapGlobalDialog(cd, fr);
6227 fClient->WaitForUnmap(cd);
6229}
6230
6231////////////////////////////////////////////////////////////////////////////////
6232/// Change text font via font selection dialog. This method is activated
6233/// via context menu during guibuilding.
6234
6236{
6238
6239 fd->SetColor(fr->GetTextColor());
6242
6243 if (font) {
6244 fd->SetFont(font);
6245 }
6246
6247 fd->EnableAlign(kFALSE);
6248 fd->Connect("FontSelected(char*)", "TGTextEntry", fr, "SetFont(char*)");
6249 fd->Connect("ColorSelected(Pixel_t)", "TGTextEntry", fr, "SetTextColor(Pixel_t)");
6250
6251 MapGlobalDialog(fd, fr);
6252 fClient->WaitForUnmap(fd);
6254
6255 int tw, max_ascent, max_descent;
6256 tw = gVirtualX->TextWidth(fs, fr->GetText(), fr->GetBuffer()->GetTextLength());
6257
6258 if (tw < 1) {
6259 TString dummy('w', fr->GetBuffer()->GetBufferLength());
6260 tw = gVirtualX->TextWidth(fs, dummy.Data(), dummy.Length());
6261 }
6262
6263 gVirtualX->GetFontProperties(fs, max_ascent, max_descent);
6264 fr->Resize(tw + 8, max_ascent + max_descent + 7);
6265}
6266
6267////////////////////////////////////////////////////////////////////////////////
6268/// Invoke file dialog to assign a new image.
6269/// This method is activated via context menu during guibuilding.
6270
6272{
6273 static TGFileInfo fi;
6274 static TString dir(".");
6275 static Bool_t overwr = kFALSE;
6276 TString fname;
6277
6279 fi.SetIniDir(dir);
6280 fi.fOverwrite = overwr;
6281
6282 TGWindow *root = (TGWindow*)fClient->GetRoot();
6284
6285 new TGFileDialog(fClient->GetDefaultRoot(), fr, kFDOpen, &fi);
6286
6287 if (!fi.fFilename) {
6288 root->SetEditable(kTRUE);
6290 return;
6291 }
6292
6293 dir = fi.fIniDir;
6294 overwr = fi.fOverwrite;
6295 fname = fi.fFilename;
6296
6297 TImage *img = TImage::Open(fname.Data());
6298
6299 if (!img) {
6300 Int_t retval;
6301 new TGMsgBox(fClient->GetDefaultRoot(), fr, "Error...",
6302 TString::Format("Cannot read image file (%s)", fname.Data()),
6304
6305 if (retval == kMBRetry) {
6306 ChangeImage(fr);
6307 }
6308 } else {
6309 fr->SetImage(img);
6310 fr->SetImagePath(gSystem->GetDirName(fname.Data()));
6311 }
6312
6313 root->SetEditable(kTRUE);
6315}
6316
6317////////////////////////////////////////////////////////////////////////////////
6318/// Set lasso drawn flag
6319
6321{
6322 if (fLassoDrawn == on) {
6323 return;
6324 }
6325
6326 fLassoDrawn = on;
6327
6328 if (fBuilder) {
6329 if (on) {
6331 }
6332
6334 }
6335}
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
@ kSelectionClear
Definition GuiTypes.h:63
@ kColormapNotify
Definition GuiTypes.h:64
@ kConfigureNotify
Definition GuiTypes.h:62
@ kGKeyPress
Definition GuiTypes.h:60
@ kExpose
Definition GuiTypes.h:62
@ kUnmapNotify
Definition GuiTypes.h:62
@ kButtonRelease
Definition GuiTypes.h:60
@ kSelectionNotify
Definition GuiTypes.h:63
@ kButtonPress
Definition GuiTypes.h:60
@ kFocusOut
Definition GuiTypes.h:61
@ kDestroyNotify
Definition GuiTypes.h:62
@ kMotionNotify
Definition GuiTypes.h:61
@ kFocusIn
Definition GuiTypes.h:61
@ kClientMessage
Definition GuiTypes.h:63
@ kEnterNotify
Definition GuiTypes.h:61
@ kSelectionRequest
Definition GuiTypes.h:63
@ kKeyRelease
Definition GuiTypes.h:60
@ kLeaveNotify
Definition GuiTypes.h:61
const Mask_t kWAOverrideRedirect
Definition GuiTypes.h:149
ECursor
Definition GuiTypes.h:372
@ kRightSide
Definition GuiTypes.h:373
@ kBottomSide
Definition GuiTypes.h:373
@ kTopLeft
Definition GuiTypes.h:372
@ kBottomRight
Definition GuiTypes.h:372
@ kTopSide
Definition GuiTypes.h:373
@ kLeftSide
Definition GuiTypes.h:373
@ kMove
Definition GuiTypes.h:374
@ kTopRight
Definition GuiTypes.h:372
@ kBottomLeft
Definition GuiTypes.h:372
@ kCross
Definition GuiTypes.h:374
@ kPointer
Definition GuiTypes.h:375
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kWASaveUnder
Definition GuiTypes.h:150
const Mask_t kKeyPressMask
Definition GuiTypes.h:159
const Mask_t kButton1Mask
Definition GuiTypes.h:203
const Mask_t kKeyShiftMask
Definition GuiTypes.h:195
@ kRaisedFrame
Definition GuiTypes.h:384
@ kTempFrame
Definition GuiTypes.h:393
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
const Mask_t kKeyControlMask
Definition GuiTypes.h:197
const Mask_t kButton3Mask
Definition GuiTypes.h:205
const Mask_t kButton2Mask
Definition GuiTypes.h:204
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton3
Definition GuiTypes.h:214
@ kButton1
Definition GuiTypes.h:214
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
EKeySym
Definition KeySymbols.h:25
@ kKey_Right
Definition KeySymbols.h:42
@ kKey_Down
Definition KeySymbols.h:43
@ kKey_G
Definition KeySymbols.h:132
@ kKey_Space
Definition KeySymbols.h:93
@ kKey_B
Definition KeySymbols.h:127
@ kKey_L
Definition KeySymbols.h:137
@ kKey_N
Definition KeySymbols.h:139
@ kKey_Up
Definition KeySymbols.h:41
@ kKey_Return
Definition KeySymbols.h:30
@ kKey_C
Definition KeySymbols.h:128
@ kKey_Delete
Definition KeySymbols.h:33
@ kKey_O
Definition KeySymbols.h:140
@ kKey_Left
Definition KeySymbols.h:40
@ kKey_Backspace
Definition KeySymbols.h:29
@ kKey_X
Definition KeySymbols.h:149
@ kKey_S
Definition KeySymbols.h:144
@ kKey_Enter
Definition KeySymbols.h:31
@ kKey_H
Definition KeySymbols.h:133
@ kKey_R
Definition KeySymbols.h:143
@ kKey_V
Definition KeySymbols.h:147
int main()
Definition Prototype.cxx:12
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:75
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassImp(name)
Definition Rtypes.h:382
@ kIsEnum
Definition TDictionary.h:68
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
Definition TError.cxx:90
#define gClient
Definition TGClient.h:157
@ kFDOpen
@ kFDSave
static const char * gSaveMacroTypes[]
Definition TGFrame.cxx:134
@ kMWMDecorResizeH
Definition TGFrame.h:65
@ kMWMFuncAll
Definition TGFrame.h:49
@ kMWMFuncResize
Definition TGFrame.h:50
@ kMWMDecorMaximize
Definition TGFrame.h:69
@ kMWMDecorMinimize
Definition TGFrame.h:68
@ kMWMDecorMenu
Definition TGFrame.h:67
@ kMWMDecorAll
Definition TGFrame.h:63
@ kMWMInputFullApplicationModal
Definition TGFrame.h:60
@ kMWMFuncMaximize
Definition TGFrame.h:53
@ kMWMInputModeless
Definition TGFrame.h:57
@ kMWMFuncMinimize
Definition TGFrame.h:52
@ kDeepCleanup
Definition TGFrame.h:42
@ kIsMapped
Definition TGFrame.h:34
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsCenterX
Definition TGLayout.h:25
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
@ kMBRetry
Definition TGMsgBox.h:35
@ kMBCancel
Definition TGMsgBox.h:37
@ kMBIconExclamation
Definition TGMsgBox.h:24
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h prop
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetMWMHints
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetWMPosition
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t grab
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t SetWMSizeHints
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
char name[80]
Definition TGX11.cxx:110
static Bool_t containBaseClass(const char *somestring, TClass *cl)
Helper.
static TString CreateArgumentTitle(TMethodArg *argument)
Create a string describing method argument.
static UInt_t gGridStep
static const char * gSaveMacroTypes[]
static Window_t GetWindowFromPoint(Int_t x, Int_t y)
Helper. Return a window located at point x,y (in screen coordinates)
static TGuiBldDragManager * gGuiBldDragManager
static TGuiBldMenuDialog * gMenuDialog
static TString FindMenuIconName(TString &in)
Return a name of icon.
static void GuiBldErrorHandler(Int_t, Bool_t, const char *, const char *)
Our own error handler (not used yet)
static const char * gImageTypes[]
static void layoutFrame(TGFrame *frame)
Helper to layout.
static Bool_t IsParentOfGrab(Window_t id, const TGWindow *grab)
Helper for IsPointVisible.
@ kLayUpAct
@ kCloneAct
@ kEditableAct
@ kDropAct
@ kEndEditAct
@ kLayoutHAct
@ kSwitchLayoutAct
@ kCompactAct
@ kReplaceAct
@ kBreakLayoutAct
@ kCutAct
@ kPropertyAct
@ kLeftAct
@ kLayoutVAct
@ kLayDownAct
@ kToggleMenuAct
@ kMethodMenuAct
@ kDownAct
@ kSaveAct
@ kGrabAct
@ kPasteAct
@ kNewAct
@ kDeleteAct
@ kNoneAct
@ kCopyAct
@ kGridAct
@ kCompactGlobalAct
@ kSaveFrameAct
@ kRightAct
@ kOpenAct
@ kCropAct
R__EXTERN TInterpreter * gCling
EMenuItemKind
Definition TMethod.h:31
@ kMenuSubMenu
Definition TMethod.h:35
@ kMenuDialog
Definition TMethod.h:33
@ kMenuToggle
Definition TMethod.h:34
#define gROOT
Definition TROOT.h:406
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
@ kGUIBLD_FILE_STOP
@ kGUIBLD_FILE_START
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
@ kDragLink
@ kDragNone
@ kDragLasso
@ kDragResize
@ kDragMove
@ kDragCopy
R__EXTERN TVirtualDragManager * gDragManager
#define gVirtualX
Definition TVirtualX.h:337
R__EXTERN Atom_t gROOT_MESSAGE
Definition TVirtualX.h:40
R__EXTERN Atom_t gWM_DELETE_WINDOW
Definition TVirtualX.h:38
#define snprintf
Definition civetweb.c:1540
Each class (see TClass) has a linked list of its base class(es).
Definition TBaseClass.h:33
TClass * GetClassPointer(Bool_t load=kTRUE)
Get pointer to the base class TClass.
Describes one element of the context menu associated to a class The menu item may describe.
virtual const char * GetArgs() const
const char * GetTitle() const override
Returns title of object.
virtual const char * GetFunctionName() const
virtual Int_t GetType() const
virtual Bool_t IsToggle() const
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
TList * GetMenuList() const
Return the list of menu items associated with the class.
Definition TClass.cxx:4410
TMethod * GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
Definition TClass.cxx:4525
TList * GetListOfMethods(Bool_t load=kTRUE)
Return list containing the TMethods of a class.
Definition TClass.cxx:3881
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition TClass.cxx:3705
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
Definition TClass.cxx:6167
void GetMenuItems(TList *listitems)
Returns list of methods accessible by context menu.
Definition TClass.cxx:3943
TClass * IsA() const override
Definition TClass.h:619
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:3037
virtual Int_t GetEntries() const
virtual Bool_t IsEmpty() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
static ULong_t RGB2Pixel(Int_t r, Int_t g, Int_t b)
Convert r,g,b to graphics system dependent pixel value.
Definition TColor.cxx:2476
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition TColor.cxx:2438
All ROOT classes may have RTTI (run time type identification) support added.
Definition TDataMember.h:31
Basic data type descriptor (datatype information is obtained from CINT).
Definition TDataType.h:44
Int_t GetType() const
Definition TDataType.h:68
TString GetTypeName()
Get basic type of typedef, e,g.: "class TDirectory*" -> "TDirectory".
const char * GetSignature()
Return signature of function.
A button abstract base class.
Definition TGButton.h:68
GContext_t GetNormGC() const
Definition TGButton.h:131
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
virtual void SetContainer(TGFrame *f)
Definition TGCanvas.h:222
TGFrame * GetContainer() const
Definition TGCanvas.h:216
TGVScrollBar * GetVScrollbar() const
Definition TGCanvas.h:219
TGViewPort * GetViewPort() const
Definition TGCanvas.h:217
void MapSubwindows() override
Map all canvas sub windows.
TGHScrollBar * GetHScrollbar() const
Definition TGCanvas.h:218
static TClass * Class()
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:234
Bool_t IsEditable() const
Definition TGClient.h:89
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:224
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition TGClient.cxx:746
void ResetWaitFor(TGWindow *w)
reset waiting
Definition TGClient.cxx:772
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
TList * GetListOfPopups() const
Definition TGClient.h:150
void WaitFor(TGWindow *w)
Wait for window to be destroyed.
Definition TGClient.cxx:718
TGWindow * GetWindowById(Window_t sw) const
Find a TGWindow via its handle. If window is not found return 0.
Definition TGClient.cxx:603
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
Bool_t GetColorByName(const char *name, Pixel_t &pixel) const
Get a color by name.
Definition TGClient.cxx:404
void SetRoot(TGWindow *root=nullptr)
Sets the current root (i.e.
Definition TGClient.cxx:244
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:381
EGEventType GetWaitForEvent() const
Definition TGClient.h:114
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:317
void UnregisterWindow(TGWindow *w)
Remove a TGWindow from the list of windows.
Definition TGClient.cxx:532
A full featured color selection dialog.
virtual void SetCurrentColor(Pixel_t col)
Change current color.
TGColorPalette * GetCustomPalette() const
void SetColor(Int_t ix, Pixel_t color)
Set color at index ix of color entries.
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual TGLBEntry * GetSelectedEntry() const
Definition TGComboBox.h:115
virtual TGTextEntry * GetTextEntry() const
Definition TGComboBox.h:111
virtual TGListBox * GetListBox() const
Definition TGComboBox.h:110
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:316
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
UInt_t GetDefaultWidth() const override
Definition TGFrame.h:312
virtual TGLayoutManager * GetLayoutManager() const
Definition TGFrame.h:338
Bool_t HandleDragEnter(TGFrame *) override
Handle drag enter event.
Definition TGFrame.cxx:1365
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:314
virtual Bool_t TranslateCoordinates(TGFrame *child, Int_t x, Int_t y, Int_t &fx, Int_t &fy)
Translate coordinates to child frame.
Definition TGFrame.cxx:1332
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1257
Bool_t IsEditable() const override
Return kTRUE if frame is being edited.
Definition TGFrame.cxx:927
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1072
Bool_t IsLayoutBroken() const override
Definition TGFrame.h:357
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1149
void SetEditable(Bool_t on=kTRUE) override
Switch ON/OFF edit mode.
Definition TGFrame.cxx:948
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1022
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1043
static TClass * Class()
void SetLayoutBroken(Bool_t on=kTRUE) override
Set broken layout. No Layout method is called.
Definition TGFrame.cxx:1012
static TClass * Class()
TGUndockedFrame * GetUndocked() const
Bool_t IsUndocked() const
This class creates a file selection dialog.
char * fFilename
selected file name
const char ** fFileTypes
file types used to filter selectable files
char * fIniDir
on input: initial directory, on output: new directory
Bool_t fOverwrite
if true overwrite the file with existing name on save
void SetIniDir(const char *inidir)
Set directory name.
Font selection dialog, allowing to select one in the list of available fonts in the system.
virtual void SetAlign(Int_t align)
Set align.
virtual void SetFont(TGFont *font)
Set font.
virtual void EnableAlign(Bool_t on=kTRUE)
Enable/disable align combobox.
virtual void SetColor(Pixel_t color)
Set color.
TGFont * FindFont(FontStruct_t font) const
Find font based on its font struct. Returns 0 if font is not found.
Definition TGFont.cxx:1744
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
TGLayoutHints * fLayout
Definition TGLayout.h:114
TGFrame * fFrame
Definition TGLayout.h:112
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:321
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.cxx:584
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:339
Bool_t IsEditable() const override
Definition TGFrame.h:213
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:629
virtual Bool_t IsLayoutBroken() const
Definition TGFrame.h:216
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:735
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
Int_t GetBorderWidth() const
Definition TGFrame.h:233
virtual Bool_t HandleDragLeave(TGFrame *)
Definition TGFrame.h:173
virtual void SetX(Int_t x)
Definition TGFrame.h:244
virtual Bool_t HandleKey(Event_t *)
Definition TGFrame.h:165
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:709
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:190
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
void ReparentWindow(const TGWindow *p, Int_t x=0, Int_t y=0) override
Reparent window, make p the new parent and position the window at position (x,y) in new parent.
Definition TGFrame.h:202
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:312
void MapWindow() override
map window
Definition TGFrame.h:204
TGFrameElement * GetFrameElement() const
Definition TGFrame.h:235
virtual void SetLayoutBroken(Bool_t=kTRUE)
Definition TGFrame.h:215
virtual Bool_t HandleDragMotion(TGFrame *)
Definition TGFrame.h:174
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:593
TClass * IsA() const override
Definition TGFrame.h:283
Int_t GetX() const
Definition TGFrame.h:231
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:276
virtual UInt_t GetOptions() const
Definition TGFrame.h:197
void UnmapWindow() override
unmap window
Definition TGFrame.h:206
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:765
virtual Bool_t HandleButton(Event_t *)
Definition TGFrame.h:161
void SetFrameElement(TGFrameElement *fe)
Definition TGFrame.h:236
UInt_t GetHeight() const
Definition TGFrame.h:225
virtual void SetCleanup(Int_t=kLocalCleanup)
Definition TGFrame.h:217
void MapSubwindows() override
map sub windows
Definition TGFrame.h:200
Int_t GetY() const
Definition TGFrame.h:232
virtual void Layout()
Definition TGFrame.h:199
virtual Pixel_t GetBackground() const
Definition TGFrame.h:192
virtual void SetY(Int_t y)
Definition TGFrame.h:245
virtual Bool_t HandleDragDrop(TGFrame *, Int_t, Int_t, TGLayoutHints *)
Definition TGFrame.h:175
UInt_t GetWidth() const
Definition TGFrame.h:224
static TClass * Class()
void SetEditable(Bool_t) override
Definition TGFrame.h:214
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:775
void MapRaised() override
map raised
Definition TGFrame.h:205
TGGC * FindGC(const TGGC *gc)
Find graphics context. Returns 0 in case gc is not found.
Definition TGGC.cxx:951
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
GContext_t GetGC() const
Definition TGGC.h:41
void SetForeground(Pixel_t v)
Set foreground color.
Definition TGGC.cxx:278
TGGrabRect(Int_t type)
ctor.
~TGGrabRect() override
Bool_t HandleButton(Event_t *ev) override
Handle button press event.
ECursor GetType() const
A composite frame with a border and a title.
Definition TGFrame.h:522
FontStruct_t GetFontStruct() const
Definition TGFrame.h:569
GContext_t GetNormGC() const
Definition TGFrame.h:568
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
static TClass * Class()
static TClass * Class()
This class handles GUI icons.
Definition TGIcon.h:22
virtual void SetImage(const char *img)
Set icon image.
Definition TGIcon.cxx:89
virtual void SetImagePath(const char *path)
Set directory where image is located.
Definition TGIcon.cxx:190
Basic listbox entries.
Definition TGListBox.h:24
This class handles GUI labels.
Definition TGLabel.h:24
FontStruct_t GetFontStruct() const
Definition TGLabel.h:109
Int_t GetTextJustify() const
Definition TGLabel.h:82
GContext_t GetNormGC() const
Definition TGLabel.h:108
static TClass * Class()
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Frame layout manager.
Definition TGLayout.h:135
TClass * IsA() const override
Definition TGLayout.h:149
virtual void Layout()=0
A listbox is a box, possibly with scrollbar, containing entries.
Definition TGListBox.h:221
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:397
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1801
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
Definition TGFrame.cxx:1893
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
Definition TGFrame.cxx:1881
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1788
static TClass * Class()
This file contains all different MDI frame decoration classes.
static TClass * Class()
TGMdiTitleBar * GetTitleBar() const
void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h) override
Move the MDI window at position x, y and set size to w, h.
This file contains the TGMdiFrame class.
Definition TGMdiFrame.h:42
static TClass * Class()
Bool_t SetCurrent(TGMdiFrameList *newcurrent)
Set current (active) MDI child window (by frame list).
TGMdiFrame * GetCurrent() const
Return pointer on current (active) MDI child window.
This class contains all information about a menu entry.
Definition TGMenu.h:57
TGPopupMenu * GetPopup() const
Definition TGMenu.h:88
void * GetUserData() const
Definition TGMenu.h:96
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
Yield an action as soon as it is clicked.
Definition TGButton.h:228
virtual void SetPicture(const TGPicture *new_pic)
Change a picture in a picture button.
const TGPicture * GetDisabledPicture() const
Definition TGButton.h:257
const TGPicture * GetPicture() const
Definition TGButton.h:256
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
This class creates a popup menu object.
Definition TGMenu.h:110
virtual void AddLabel(TGHotString *s, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu label to the menu.
Definition TGMenu.cxx:1095
virtual TGMenuEntry * GetEntry(Int_t id)
Find entry with specified id.
Definition TGMenu.cxx:1897
virtual void CheckEntryByData(void *user_data)
Check a menu entry (i.e.
Definition TGMenu.cxx:1795
virtual void AddPopup(TGHotString *s, TGPopupMenu *popup, TGMenuEntry *before=nullptr, const TGPicture *p=nullptr)
Add a (cascading) popup menu to a popup menu.
Definition TGMenu.cxx:1152
virtual Int_t EndMenu(void *&userData)
Close menu and return ID of selected menu item.
Definition TGMenu.cxx:1289
virtual TGMenuEntry * GetCurrent() const
Definition TGMenu.h:198
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1060
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=nullptr, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu entry.
Definition TGMenu.cxx:990
virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
Popup a popup menu.
Definition TGMenu.cxx:1241
The classes in this file implement progress bars.
Pixel_t GetBarColor() const
GContext_t GetNormGC() const
TGFontPool * GetFontPool() const
TGGCPool * GetGCPool() const
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
UInt_t GetBufferLength() const
UInt_t GetTextLength() const
Yield an action as soon as it is clicked.
Definition TGButton.h:142
FontStruct_t GetFontStruct() const
Definition TGButton.h:219
Int_t GetTextJustify() const
Definition TGButton.h:193
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
static TClass * Class()
TGTextBuffer * GetBuffer() const
const char * GetText() const
FontStruct_t GetFontStruct() const
Pixel_t GetTextColor() const
Defines transient windows that typically are used for dialogs windows.
Definition TGFrame.h:498
const TGWindow * fMain
Definition TGFrame.h:501
static TClass * Class()
static TClass * Class()
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:152
virtual UInt_t GetEditDisabled() const
Definition TGWindow.h:112
virtual void SetBackgroundPixmap(Pixmap_t pixmap)
set background pixmap
Definition TGWindow.cxx:248
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:232
virtual void SetName(const char *name)
Definition TGWindow.h:121
virtual void SetEditable(Bool_t on=kTRUE)
Definition TGWindow.h:114
@ kEditDisableBtnEnable
window can handle mouse button events
Definition TGWindow.h:64
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
@ kEditDisableKeyEnable
window can handle keyboard events
Definition TGWindow.h:65
virtual void DestroyWindow()
destroy window
Definition TGWindow.cxx:192
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:129
const TGWindow * GetParent() const
Definition TGWindow.h:83
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:295
virtual void Resize(UInt_t w, UInt_t h)
Resize the window.
Definition TGWindow.cxx:279
virtual void SetBackgroundColor(Pixel_t color)
set background color
Definition TGWindow.cxx:240
TString fName
name of the window used in SavePrimitive()
Definition TGWindow.h:30
virtual void RaiseWindow()
raise window
Definition TGWindow.cxx:208
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
TGLayoutHints * fHints
Definition TGuiBuilder.h:32
void SetStep(UInt_t step)
Set the grid step.
TGuiBldDragManagerGrid()
Create a grid background for the selected window.
void Draw()
Draw grid over edited frame.
void InitPixmap()
Create grid background pixmap.
void InitBgnd()
Create grid background.
TGuiBldDragManagerGrid * fGrid
TGuiBldDragManagerPimpl(TGuiBldDragManager *m)
TGuiBldDragManager * fManager
Bool_t Notify() override
This method must be overridden to handle object notification (the base implementation is no-op).
TGuiBldDragManagerRepeatTimer(TGuiBldDragManager *m, Long_t ms)
Drag and drop manager used by the ROOT GUI Builder.
TGFrame * GetEditableParent(TGFrame *f)
Return the parent frame which can be edited.
void ChangeSelected(TGFrame *f)
Inform outside wold that selected frame was changed.
Bool_t HandleEvent(Event_t *) override
Handle all events.
Bool_t EndDrag() override
End dragging.
void HandleAction(Int_t act)
Main handler of actions.
Bool_t IsFixedH(TGWindow *f) const
void DoDialogCancel()
Process dialog Cancel button pressed.
void DeleteMenuDialog()
Delete dialog and trash.
void SetCursorType(Int_t cur)
Set cursor for selected/grabbed frame.
void SwitchLayout()
Switch Horizontal/Vertical layout of selected/grabbed composite frame.
void ChangeImage(TGIcon *)
Invoke file dialog to assign a new image.
void DoClassMenu(Int_t)
Process a method chosen via frame context menu.
Bool_t IsMoveWaiting() const
Waits for either the mouse move from the given initial ButtonPress location or for the mouse button t...
void ChangeTextFont(TGGroupFrame *)
Change text font via font selection dialog.
Bool_t CheckDragResize(Event_t *event)
Check resize type event.
void SelectFrame(TGFrame *frame, Bool_t add=kFALSE)
Grab/Select frame.
TGFrame * InEditable(Window_t id)
Return a pointer to the parent window (which is being edited)
Bool_t CanChangeLayoutOrder(TGWindow *w) const
kTRUE - if it's possible to change layout order in the parent's layout of window w
Bool_t Cancel(Bool_t delSrc) override
Do cancel action.
void HandlePaste()
Handle paste action.
void Snap2Grid()
Draw grid on editable frame and restore background on previously edited one.
Bool_t IsPointVisible(Int_t x, Int_t y)
Helper function for IsSelectedWindow method.
void PutToCanvas(TGCompositeFrame *cont)
Create a new TGCanvas and place container into it.
void CheckTargetUnderGrab()
Look for the drop target under grabbed/selected frame while moving.
void HideGrabRectangles()
Hide/Unmap grab rectangles.
Int_t GetEndDragX() const override
Return the current X coordinate of the dragged frame.
void CreatePropertyEditor()
Create widget property editor (it could be located outside of guibuilder)
void SetGridStep(UInt_t step)
Set the grid step.
friend class TGuiBldMenuDialog
Bool_t HandleButton(Event_t *) override
Handle button event occurred in some ROOT frame.
void Compact(Bool_t global=kTRUE)
Layout and Resize frame.
void DrawLasso()
Draw lasso for allocation new object.
void Menu4Frame(TGFrame *, Int_t x, Int_t y)
Create and place context menu for selected frame.
friend class TGuiBldDragManagerRepeatTimer
void RaiseMdiFrame(TGFrame *in)
Raise guibuilder's mdi frame.
void DeleteFrame(TGFrame *frame)
Delete frame.
void DoDialogApply()
Process dialog Apply button pressed.
void DoMove()
Handle move.
Bool_t IgnoreEvent(Event_t *e) override
Return kTRUE if event is rejected for processing by drag manager.
void ChangeBarColor(TGProgressBar *)
Set progress bar color via TGColorDialog.
void HandleDelete(Bool_t crop=kFALSE)
Handle delete or crop action.
void Menu4Lasso(Int_t x, Int_t y)
Create context menu for lasso actions.
Int_t GetEndDragY() const override
Returns the current Y coordinate of the dragged frame.
void ReparentFrames(TGFrame *newfr, TGCompositeFrame *oldfr)
Reparent frames.
Bool_t HandleExpose(Event_t *) override
Handle repaint event.
void HandleLayoutOrder(Bool_t forward=kTRUE)
Change layout order.
void CloneEditable()
Create a frame which is the same as currently edited frame.
void HandleReplace()
Handle replace.
void DoDialogOK()
Process dialog OK button pressed.
TList * GetFramesInside(Int_t x0, Int_t y0, Int_t x, Int_t y)
Return the list of frames inside of some area.
void DoResize()
handle resize
Int_t GetStrartDragX() const override
Return the X coordinate where drag started.
Int_t GetStrartDragY() const override
Return the Y coordinate where drag started.
TGCompositeFrame * FindCompositeFrame(Window_t id)
Find the first composite parent of window.
Bool_t HandleButtonPress(Event_t *)
Handle button press event.
void HandleButon3Pressed(Event_t *, TGFrame *frame=nullptr)
Handle 3d mouse pressed (popup context menu)
void TimerEvent(Event_t *ev)
void HandleAlignment(Int_t to, Bool_t lineup=kFALSE)
Align frames located inside lasso area.
Bool_t SaveFrame(const char *file=nullptr)
Save composite frame as macro.
void SwitchEditable(TGFrame *frame)
Switch editable.
void DrawGrabRect(Int_t i, Int_t x, Int_t y)
Helper method to draw grab rectangle at position x,y.
void SetEditable(Bool_t on=kTRUE) override
Grab server.
void UnmapAllPopups()
Unmap all popups.
void ChangePicture(TGPictureButton *)
Invoke file dialog to assign a new picture.
Bool_t IsEditDisabled(TGWindow *f) const
TGFrame * FindMdiFrame(TGFrame *in)
Return a pointer to the parent mdi frame.
Bool_t HandleTimerEvent(Event_t *ev, TTimer *t) override
Handle timer events or events coming from the recorder.
void ChangeBackgroundColor(TGListBox *)
Set background color for list box entries.
Bool_t HandleSelectionRequest(Event_t *) override
not used yet.
TGuiBldDragManagerPimpl * fPimpl
Bool_t CanCompact(TGWindow *w) const
kTRUE is frame could be compacted/"laid out"
void CloseMenus()
Helper to close all menus.
void GrabFrame(TGFrame *frame)
grab frame (see SelectFrame)
void AddClassMenuMethods(TGPopupMenu *menu, TObject *object)
Add entries with class //*MENU* methods.
void HandleCopy(Bool_t brk_layout=kTRUE)
Handle copy.
void ToGrid(Int_t &x, Int_t &y)
Return grid coordinates which are close to given.
void CreateListOfDialogs()
Create a list of dialog methods.
static TGFontDialog * fgGlobalFontDialog
void SetLassoDrawn(Bool_t on)
Set lasso drawn flag.
Bool_t IsFixedW(TGWindow *f) const
void HandleCut()
Handle cut action.
TGWindow * GetResizableParent(TGWindow *p)
Find parent frame which can be resized.
Bool_t Drop() override
Drop grabbed frame.
static void MapGlobalDialog(TGMainFrame *dialog, TGFrame *fr)
Map dialog and place it relative to selected frame.
void HandleReturn(Bool_t on=kFALSE)
Handling of return/enter key pressing.
UInt_t GetGridStep()
Return the grid step.
Bool_t HandleButtonRelease(Event_t *)
Handle button release event.
static TGFontDialog * GetGlobalFontDialog()
Create global font dialog.
void Reset1()
Reset some parameters.
Bool_t HandleDestroyNotify(Event_t *)
Handle destroy notify.
Bool_t HandleClientMessage(Event_t *) override
Handle client message.
Bool_t HandleSelection(Event_t *) override
not used yet.
void PlaceFrame(TGFrame *, TGLayoutHints *)
Put created frame at position of the last mouse click.
Bool_t IsFixedLayout(TGWindow *f) const
Bool_t HandleTimer(TTimer *) override
The main event loop is originated here It repeatedly queries pointer state and position on the screen...
void SetPropertyEditor(TGuiBldEditor *e)
Helper method.
Bool_t CheckTargetAtPoint(Int_t x, Int_t y)
Helper. Look for the drop target under grabbed/selected frame while moving.
TGFrame * GetMovableParent(TGWindow *p)
Find parent frame which can be dragged.
Bool_t HandleMotion(Event_t *) override
Handle motion event.
void DrawGrabRectangles(TGWindow *win=nullptr)
Draw small grab rectangles around grabbed/selected/frame.
static TGColorDialog * fgGlobalColorDialog
void DoRedraw() override
Redraw the edited window.
Bool_t IsFixedSize(TGWindow *f) const
~TGuiBldDragManager() override
Destructor.
void HighlightCompositeFrame(Window_t)
Raise composite frame when mouse is moving over it.
Bool_t HandleConfigureNotify(Event_t *) override
Resize events.
void DoReplace(TGFrame *frame)
Replace frame (doesn't work yet properly)
Bool_t StartDrag(TGFrame *src, Int_t x, Int_t y) override
Start dragging.
void HandleGrid()
Switch on/of grid drawn.
Bool_t CanChangeLayout(TGWindow *w) const
kTRUE - if it's possible to switch disable/enable layout
Bool_t Save(const char *file="")
Save an edited frame to the file.
void BreakLayout()
Disable/Enable layout for selected/grabbed composite frame.
Bool_t IsPasteFrameExist()
Return kTRUE if paste frame exist.
void UngrabFrame()
Ungrab/Unselect selected/grabbed frame.
Bool_t HandleKey(Event_t *) override
Handle key event.
TRootGuiBuilder * fBuilder
void DropCanvas(TGCanvas *canvas)
Drop canvas container.
TGuiBldEditor * fEditor
void ChangeProperties(TGLabel *)
Edit properties via font selection dialog.
Bool_t IsEventsDisabled(TGWindow *f) const
void AddDialogMethods(TGPopupMenu *menu, TObject *object)
Add DIALOG entries to the selected frame popup menu.
Bool_t IsSelectedVisible()
Return kTRUE if grabbed/selected frame is not overlapped by other windows.
Bool_t RecognizeGesture(Event_t *, TGFrame *frame=nullptr)
Recognize what was done when mouse button pressed.
void DeletePropertyEditor()
Delete widget property editor.
static TGColorDialog * GetGlobalColorDialog(Bool_t create=kTRUE)
Return pointer to global color dialog.
TGCompositeFrame * FindLayoutFrame(TGFrame *f)
Helper to find a frame which can be laid out.
TGFrame * GetBtnEnableParent(TGFrame *fr)
Return a parent which can handle button events.
TGFrame * GetSelected() const
Return the current grabbed/selected frame.
void HandleUpdateSelected(TGFrame *)
When selected frame was changed by guibuilder editor -> update its appearance.
Bool_t IsGrabDisabled(TGWindow *f) const
void ChangeTextColor(TGGroupFrame *)
Change text color via color selection dialog.
Bool_t HandleDoubleClick(Event_t *) override
Mouse double click handler (never should happen)
The property editor.
void ChangeSelected(TGFrame *)
Change selected frame.
void RemoveFrame(TGFrame *) override
Remove a frame.
Bool_t IsEmbedded() const
TGuiBldMenuDialog(const TGWindow *main, TObject *obj, TMethod *method)
ctor.
void Popup()
Popup dialog.
void ConnectButtonSignals()
Connect buttons signals.
~TGuiBldMenuDialog() override
dtor.
void CloseWindow() override
Close window.
void Add(const char *argname, const char *value, const char *type)
Add a label and text input field.
void Build()
Build dialog.
void ApplyMethod()
execute method for object with input args
const char * GetParameters()
Return input parameters as single string.
TGuiBldAction * GetAction() const
Definition TGuiBuilder.h:56
static TGuiBuilder * Instance()
return an instance of TGuiBuilder object
virtual void SetAction(TGuiBldAction *act)
Definition TGuiBuilder.h:55
virtual Bool_t IsExecutable() const
Definition TGuiBuilder.h:57
An abstract interface to image processing library.
Definition TImage.h:29
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition TImage.cxx:118
static TImage * Create()
Create an image.
Definition TImage.cxx:35
virtual void FromWindow(Drawable_t, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition TImage.h:244
virtual Longptr_t Calc(const char *line, EErrorCode *error=nullptr)=0
void Reset()
A doubly linked list.
Definition TList.h:38
void AddAfter(const TObject *after, TObject *obj) override
Insert object after object after in the list.
Definition TList.cxx:248
TObject * After(const TObject *obj) const override
Returns the object after object obj.
Definition TList.cxx:328
TObject * Before(const TObject *obj) const override
Returns the object before object obj.
Definition TList.cxx:369
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:820
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:691
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:657
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:468
TClass * IsA() const override
Definition TList.h:110
Each ROOT method (see TMethod) has a linked list of its arguments.
Definition TMethodArg.h:36
const char * GetDefault() const
Get default value of method argument.
const char * GetTypeName() const
Get type of method argument, e.g.: "class TDirectory*" -> "TDirectory" Result needs to be used or cop...
TDataMember * GetDataMember() const
Returns TDataMember pointed by this methodarg.
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
virtual const char * GetCommentString()
Returns a comment string from the class declaration.
Definition TMethod.cxx:107
virtual TDataMember * FindDataMember()
Tries to guess DataMember from comment string and Method's name <==(only if 1 Argument!...
Definition TMethod.cxx:134
TClass * GetClass() const
Definition TMethod.h:55
EMenuItemKind IsMenuItem() const
Definition TMethod.h:56
virtual TList * GetListOfMethodArgs()
Returns methodarg list and additionally updates fDataMember in TMethod by calling FindDataMember();.
Definition TMethod.cxx:307
TClass * IsA() const override
Definition TMethod.h:68
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
Collectable string class.
Definition TObjString.h:28
const TString & GetString() const
Definition TObjString.h:46
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:225
virtual void Execute(const char *method, const char *params, Int_t *error=nullptr)
Execute method on this object with the given parameter string, e.g.
Definition TObject.cxx:376
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:542
virtual TClass * IsA() const
Definition TObject.h:243
Long_t fValue
Data member to which this option belongs.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:869
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
Definition TRandom.cxx:361
virtual Bool_t SaveProject(Event_t *event=nullptr)
Save selected project.
virtual void AddMacro(const char *macro, TImage *img)
Add macro to "User's Macros" section Input img must be static - do not delete it.
TGMdiFrame * FindEditableMdiFrame(const TGWindow *win)
Find the editable frame.
TGMdiMainFrame * GetMdiMain() const
virtual void UpdateStatusBar(const char *text=nullptr)
Update information shown on the status bar.
static TGGC * GetPopupHlghtGC()
Return background GC for highlighted popup menu entry.
void EnableEditButtons(Bool_t on=kTRUE)
Enable/disable toolbar buttons according to the selected frame.
static TGPopupMenu * CreatePopup()
Return style popup menu.
virtual void ChangeSelected(TGFrame *f)
Set selected frame.
void EnableLassoButtons(Bool_t on=kTRUE)
Enable toolbar buttons for alignment.
TGuiBldEditor * GetEditor() const
TGFrame * ExecuteAction() override
Execute an action.
void CloseWindow() override
Close GUI builder via window manager "Close" button.
virtual void HandleMenu(Int_t id)
Handle menu items.
TGDockableFrame * GetToolDock() const
virtual void Update()
Update gui builder.
virtual Bool_t NewProject(TString type="")
Create a new project.
virtual Bool_t OpenProject(Event_t *event=nullptr)
Open new gui builder project.
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2244
const char * Data() const
Definition TString.h:376
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:651
virtual int GetPid()
Get process id.
Definition TSystem.cxx:707
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition TSystem.cxx:1071
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
Definition TSystem.cxx:463
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1296
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1063
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:471
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:934
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1032
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1381
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition TSystem.cxx:1482
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:159
void SetTime(Long_t milliSec)
Definition TTimer.h:91
void Remove() override
Definition TTimer.h:86
This class defines toggling facility for both - object's method or variables.
Definition TToggle.h:47
virtual void Toggle()
Toggles the Values and State of this object and connected data!
Definition TToggle.cxx:112
virtual void SetOnValue(Long_t lon)
Definition TToggle.h:78
virtual void SetToggledObject(TObject *obj, TMethod *anymethod)
Initializes it to toggle an object's datamember using this object's method.
Definition TToggle.cxx:135
virtual Bool_t GetState()
Returns the state of Toggle according to its current value and fOnValue, returns true if they match.
Definition TToggle.cxx:69
EDragType fDragType
dragging type
TGFrame * fSource
frame being dragged
Bool_t fMoveWaiting
kTRUE if source is clicked but not moved
Bool_t fDragging
in dragging mode?
TGFrame * fTarget
drop target
Bool_t fPasting
paste action is in progress
virtual void Init()
Initialization.
TGFrame * fFrameUnder
frame under drag
virtual void SetEditable(Bool_t)
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Int_t fXRoot
Definition GuiTypes.h:179
Handle_t fHandle
general resource handle (used for atoms or windows)
Definition GuiTypes.h:185
Int_t fFormat
Next fields only used by kClientMessageEvent.
Definition GuiTypes.h:186
Int_t fCount
if non-zero, at least this many more exposes
Definition GuiTypes.h:183
Window_t fWindow
window reported event is relative to
Definition GuiTypes.h:176
UInt_t fState
key or button mask
Definition GuiTypes.h:181
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:179
Int_t fX
Definition GuiTypes.h:178
Time_t fTime
time event event occurred in ms
Definition GuiTypes.h:177
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Longptr_t fUser[5]
5 longs can be used by client message events NOTE: only [0], [1] and [2] may be used.
Definition GuiTypes.h:187
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:93
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4