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