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 fPasteFileName = TString::Format("RootGuiBldClipboard%d.C", gSystem->GetPid());
920
921
922 fTmpBuildFile = TString::Format("RootGuiBldTmpFile%d.C", gSystem->GetPid());
924
925 fName = "Gui Builder Drag Manager";
927
928 // let's try to solve the problems by myself
930
932}
933
934////////////////////////////////////////////////////////////////////////////////
935/// Destructor
936
938{
940
941 delete fPimpl;
942
943 delete fBuilder;
944 fBuilder = 0;
945
946// delete fEditor;
947// fEditor = 0;
948
949 delete fFrameMenu;
950 fFrameMenu =0;
951
952 delete fLassoMenu;
953 fLassoMenu = 0;
954
957 }
958
959 delete fListOfDialogs;
960
962}
963
964////////////////////////////////////////////////////////////////////////////////
965/// Reset some parameters
966
974
975////////////////////////////////////////////////////////////////////////////////
976/// Create a list of dialog methods
977
979{
980 fListOfDialogs = new TList();
981
983 TIter next(methodList);
984 TString str;
986
987 while ((method = (TMethod*) next())) {
988 str = method->GetCommentString();
989 if (str.Contains("*DIALOG")) {
991 }
992 }
993}
994
995////////////////////////////////////////////////////////////////////////////////
996/// Draw grid on editable frame and restore background on previously edited one
997
999{
1000 if (fStop) {
1001 return;
1002 }
1003
1004 delete fPimpl->fGrid;
1005
1007 fPimpl->fGrid->Draw();
1008}
1009
1010////////////////////////////////////////////////////////////////////////////////
1011/// Return the grid step
1012
1017
1018////////////////////////////////////////////////////////////////////////////////
1019/// Set the grid step
1020
1022{
1023 fPimpl->fGrid->SetStep(step);
1024}
1025
1026////////////////////////////////////////////////////////////////////////////////
1027/// Return kTRUE if event is rejected for processing by drag manager
1028
1030{
1031 if (fStop || !fClient || !fClient->IsEditable()) return kTRUE;
1032 if (event->fType == kClientMessage) return kFALSE;
1033 if (event->fType == kDestroyNotify) return kFALSE;
1034
1036
1037 if (w) {
1038 if (IsEditDisabled(w)) {
1040 return !w;
1041 }
1042 } else {
1043 return kTRUE;
1044 }
1045 return kFALSE;
1046}
1047
1048////////////////////////////////////////////////////////////////////////////////
1049/// Return a pointer to the parent window (which is being edited)
1050
1052{
1053 if (fStop || !id) {
1054 return 0;
1055 }
1056
1058 Window_t parent = (Window_t)gVirtualX->GetParent(id);
1059
1060 while (!parent || (parent != fClient->GetDefaultRoot()->GetId())) {
1061 if (parent == fClient->GetRoot()->GetId()) {
1063 return (w ? (TGFrame*)w : 0);
1064 }
1065 preparent = parent;
1066 parent = gVirtualX->GetParent(parent);
1067 }
1068 return 0;
1069}
1070
1071////////////////////////////////////////////////////////////////////////////////
1072/// Find the first composite parent of window
1073
1075{
1076 if (fStop || !id) {
1077 return 0;
1078 }
1079
1080 Window_t parent = id;
1081
1082 while (!parent || (parent != fClient->GetDefaultRoot()->GetId())) {
1083 TGWindow *w = fClient->GetWindowById(parent);
1084 if (w) {
1085 if (w->InheritsFrom(TGCompositeFrame::Class())) {
1086 return (TGCompositeFrame*)w;
1087 }
1088 }
1089 parent = gVirtualX->GetParent(parent);
1090 }
1091 return 0;
1092}
1093
1094////////////////////////////////////////////////////////////////////////////////
1095/// Set cursor for selected/grabbed frame.
1096
1098{
1099 if (fStop) {
1100 return;
1101 }
1102
1103 static UInt_t gid = 0;
1104 static UInt_t rid = 0;
1105
1106 if (fPimpl->fGrab && (gid != fPimpl->fGrab->GetId())) {
1107 gVirtualX->SetCursor(fPimpl->fGrab->GetId(),
1108 gVirtualX->CreateCursor((ECursor)cur));
1109 gid = fPimpl->fGrab->GetId();
1110 }
1111 if (fClient->IsEditable() && (rid != fClient->GetRoot()->GetId())) {
1112 gVirtualX->SetCursor(fClient->GetRoot()->GetId(),
1113 gVirtualX->CreateCursor((ECursor)cur));
1114 rid = fClient->GetRoot()->GetId();
1115 }
1116}
1117
1118////////////////////////////////////////////////////////////////////////////////
1119/// Check resize type event.
1120
1122{
1123 if (fStop) {
1124 return kFALSE;
1125 }
1126
1127 Bool_t ret = kFALSE;
1129
1130 for (int i = 0; i < 8; i++) {
1131 if (fPimpl->fGrabRect[i]->GetId() == event->fWindow) {
1133 ret = kTRUE;
1134 }
1135 }
1136
1137 if ((event->fType == kButtonPress) && (fPimpl->fResizeType != kPointer)) {
1139 ret = kTRUE;
1140 }
1141
1143 return ret;
1144}
1145
1146////////////////////////////////////////////////////////////////////////////////
1147/// Redraw the edited window
1148
1150{
1151 if (fStop || !fClient || !fClient->IsEditable()) {
1152 return;
1153 }
1154
1155 TGWindow *root = (TGWindow*)fClient->GetRoot();
1156
1157 fClient->NeedRedraw(root, kTRUE);
1158
1159 if (fBuilder) {
1161 }
1162}
1163
1164////////////////////////////////////////////////////////////////////////////////
1165/// Switch editable
1166
1168{
1169 if (fStop || !frame) {
1170 return;
1171 }
1172
1174
1175 if (frame->InheritsFrom(TGCompositeFrame::Class()) && CanChangeLayout(frame)) {
1176 comp = (TGCompositeFrame *)frame;
1177 } else if (frame->GetParent()->InheritsFrom(TGCompositeFrame::Class())) {
1178 comp = (TGCompositeFrame *)frame->GetParent();
1179 }
1180
1181 if (!comp) {
1182 return;
1183 }
1184
1185 TString str = comp->ClassName();
1186 str += "::";
1187 str += comp->GetName();
1188
1189 if (IsEditDisabled(comp)) {
1190 if (fBuilder) {
1191 str += " cannot be edited.";
1192 fBuilder->UpdateStatusBar(str.Data());
1193 }
1194 return;
1195 }
1196
1197 if (frame != comp) {
1198 SelectFrame(frame);
1199 }
1200
1201 if (comp->IsEditable()) {
1202 return;
1203 }
1204
1206 comp->SetEditable(kTRUE);
1207}
1208
1209////////////////////////////////////////////////////////////////////////////////
1210/// Grab/Select frame
1211
1213{
1214 if (fStop || !frame || (frame->GetParent() == fClient->GetDefaultRoot()) ||
1215 !fClient->IsEditable()) {
1216 return;
1217 }
1218
1219 TString str = frame->ClassName();
1220 str += "::";
1221 str += frame->GetName();
1222
1223 if (IsGrabDisabled(frame)) {
1224 if (fBuilder) {
1225 str += "can not be selected";
1226 fBuilder->UpdateStatusBar(str.Data());
1227 }
1228 return;
1229 }
1230
1231 // do not grab mdi frames (quick hack)
1232 if (fBuilder && frame->InheritsFrom(TGMdiFrame::Class())) {
1233 return;
1234 }
1235
1236
1237 static Int_t x, x0, y, y0, xx, yy;
1238 Window_t c;
1239
1241 frame->MapRaised();
1242
1243 if (!add) {
1244
1246
1247 gVirtualX->TranslateCoordinates(frame->GetId(),
1248 fClient->GetDefaultRoot()->GetId(),
1249 0, 0, x0, y0, c);
1250
1251 x = x0 + frame->GetWidth();
1252 y = y0 + frame->GetHeight();
1253
1254 if (fBuilder) {
1255 str += " selected";
1256 str += (IsEditDisabled(frame) || IsFixedLayout(frame) ? ". This frame cannot be edited." :
1257 " ");
1258 str += " Press SpaceBar to unselect the frame.";
1259 if (IsFixedSize(frame)) str += " This frame cannot be resized.";
1260
1261 fBuilder->UpdateStatusBar(str.Data());
1262 }
1263
1264 } else { //shift mask is on
1265
1266 gVirtualX->TranslateCoordinates(frame->GetId(),
1267 fClient->GetDefaultRoot()->GetId(),
1268 0, 0, xx, yy, c);
1269
1271 fPimpl->fX0 = x0 = std::min(x0, xx);
1272 fPimpl->fX = x = std::max(x, xx + (Int_t)frame->GetWidth());
1273 fPimpl->fY0 = y0 = std::min(y0, yy);
1274 fPimpl->fY = y = std::max(y, yy + (Int_t)frame->GetHeight());
1275
1276 DrawLasso();
1277 }
1278
1279 fFrameUnder = fPimpl->fGrab = frame;
1281
1282 // quick hack. the special case for TGCanvases
1283 if (frame->InheritsFrom(TGCanvas::Class())) {
1284 fSelected = ((TGCanvas*)frame)->GetContainer();
1285
1286 if (!IsEditDisabled(fSelected)) {
1288 if (fBuilder && fBuilder->GetAction()) {
1290 }
1291 }
1292 } else {
1294 }
1296
1298
1301}
1302
1303////////////////////////////////////////////////////////////////////////////////
1304/// Inform outside wold that selected frame was changed
1305
1307{
1308 if (fStop) {
1309 return;
1310 }
1311
1312 TGFrame *sel = fr;
1313
1314 if (fBuilder && (sel == fBuilder->GetMdiMain()->GetCurrent())) {
1315 sel = 0;
1316 }
1317
1318 if (!fr) {
1319 UngrabFrame();
1320 }
1321
1322 if (fEditor) {
1324 }
1325
1326 if (fBuilder) {
1328 //fBuilder->Update();
1329 }
1330}
1331
1332////////////////////////////////////////////////////////////////////////////////
1333/// grab frame (see SelectFrame)
1334
1336{
1337 if (fStop || !frame || !fClient->IsEditable()) {
1338 return;
1339 }
1340
1341 fPimpl->fGrabParent = frame->GetParent();
1342 fPimpl->fGrabX = frame->GetX();
1343 fPimpl->fGrabY = frame->GetY();
1344
1345 Window_t c;
1346
1347 gVirtualX->TranslateCoordinates(frame->GetId(),
1348 fClient->GetDefaultRoot()->GetId(),
1349 0, 0, fPimpl->fX0, fPimpl->fY0, c);
1350
1351 fPimpl->fX = fPimpl->fX0;
1352 fPimpl->fY = fPimpl->fY0;
1353
1354 if (frame->GetFrameElement() && frame->GetFrameElement()->fLayout) {
1356 }
1357
1358 if (fPimpl->fGrabParent && frame->GetFrameElement() &&
1359 fPimpl->fGrabParent->InheritsFrom(TGCompositeFrame::Class())) {
1360 TList *li = ((TGCompositeFrame*)fPimpl->fGrabParent)->GetList();
1362 ((TGCompositeFrame*)fPimpl->fGrabParent)->RemoveFrame(frame);
1363 }
1364
1367 attr.fOverrideRedirect = kTRUE;
1368 attr.fSaveUnder = kTRUE;
1369
1370 gVirtualX->ChangeWindowAttributes(frame->GetId(), &attr);
1371
1372 frame->UnmapWindow();
1374 gVirtualX->Update(1);
1375 frame->Move(fPimpl->fX0, fPimpl->fY0);
1376 frame->MapRaised();
1377
1378 if (fBuilder) {
1379 //fBuilder->Update();
1380 TString str = frame->ClassName();
1381 str += "::";
1382 str += frame->GetName();
1383 str += " is grabbed";
1384
1385 fBuilder->UpdateStatusBar(str.Data());
1386 }
1387}
1388
1389////////////////////////////////////////////////////////////////////////////////
1390/// Ungrab/Unselect selected/grabbed frame.
1391
1393{
1394 if (fStop || !fPimpl->fGrab) {
1395 return;
1396 }
1397
1400
1401 DoRedraw();
1402
1403 if (fBuilder) {
1404 //fBuilder->Update();
1405 TString str = fPimpl->fGrab->ClassName();
1406 str += "::";
1407 str += fPimpl->fGrab->GetName();
1408 str += " ungrabbed";
1409 fBuilder->UpdateStatusBar(str.Data());
1410 }
1411 fSelected = fPimpl->fGrab = 0;
1412}
1413
1414////////////////////////////////////////////////////////////////////////////////
1415/// Helper for IsPointVisible
1416
1418{
1419 const TGWindow *parent = grab;
1420
1421 while (parent && (parent != gClient->GetDefaultRoot())) {
1422 if (parent->GetId() == id) {
1423 return kTRUE;
1424 }
1425 parent = parent->GetParent();
1426 }
1427
1428 return kFALSE;
1429}
1430
1431////////////////////////////////////////////////////////////////////////////////
1432/// Helper function for IsSelectedWindow method
1433
1435{
1436 Window_t w = gVirtualX->GetDefaultRootWindow();
1438 Int_t x = xi;
1439 Int_t y = yi;
1440 Bool_t ret = kFALSE;
1441
1442 gVirtualX->TranslateCoordinates(fPimpl->fGrab->GetId(), w, x, y, x, y, child);
1443
1444 dst = src = child = w;
1445
1446 while (child) {
1447 src = dst;
1448 dst = child;
1449 gVirtualX->TranslateCoordinates(src, dst, x, y, x, y, child);
1450
1452 return kTRUE;
1453 }
1454 }
1455
1456 return ret;
1457}
1458
1459////////////////////////////////////////////////////////////////////////////////
1460/// Return kTRUE if grabbed/selected frame is not overlapped by other windows.
1461
1463{
1464 if (fStop || !fPimpl->fGrab || !fClient->IsEditable()) {
1465 return kFALSE;
1466 }
1467
1468 if (fBuilder) {
1470 if (mdi && (mdi != fBuilder->GetMdiMain()->GetCurrent())) {
1471 return kFALSE;
1472 }
1473 }
1474
1475 // popup menu was placed
1476 if (fPimpl->fPlacePopup) {
1477 return kTRUE;
1478 }
1479
1480 static Long64_t was = gSystem->Now();
1481 static Bool_t visible = kFALSE;
1482
1483 Long64_t now = gSystem->Now();
1484
1485 if (now-was < 100) {
1486 return visible;
1487 }
1488 was = now;
1489
1490 visible = kFALSE;
1491
1492 if (!IsPointVisible(2, 2)) {
1493 return visible;
1494 }
1495
1496 if (!IsPointVisible(2, fPimpl->fGrab->GetHeight()-2)) {
1497 return visible;
1498 }
1499
1500 if (!IsPointVisible(fPimpl->fGrab->GetWidth()-2, 2)) {
1501 return visible;
1502 }
1503
1505 fPimpl->fGrab->GetHeight()-2)) {
1506 return visible;
1507 }
1508
1509 visible = kTRUE;
1510
1511 return visible;
1512}
1513
1514////////////////////////////////////////////////////////////////////////////////
1515/// Draw small grab rectangles around grabbed/selected/frame
1516
1518{
1519 if (fStop) {
1520 return;
1521 }
1522
1523 TGFrame *frame = win ? (TGFrame *)win : fPimpl->fGrab;
1524
1525 if (!frame || !fClient->IsEditable() || fPimpl->fPlacePopup) {
1526 return;
1527 }
1528
1529 Window_t w = gVirtualX->GetDefaultRootWindow();
1530 Window_t c; Int_t x, y;
1531
1532 gVirtualX->TranslateCoordinates(frame->GetId(), w, 0, 0, x, y, c);
1533
1534 if (frame->InheritsFrom(TGCompositeFrame::Class()) &&
1535 CanChangeLayout(frame) && !frame->IsLayoutBroken()) {
1536 fPimpl->fAroundFrame[0]->MoveResize(x-3, y-3, frame->GetWidth()+6, 2);
1538 fPimpl->fAroundFrame[1]->MoveResize(x+frame->GetWidth()+3, y-3, 2, frame->GetHeight()+6);
1540 fPimpl->fAroundFrame[2]->MoveResize(x-3, y+frame->GetHeight()+2, frame->GetWidth()+6, 2);
1542 fPimpl->fAroundFrame[3]->MoveResize(x-3, y-3, 2, frame->GetHeight()+6);
1544 } else {
1545 for (int i = 0; i < 4; i++) fPimpl->fAroundFrame[i]->UnmapWindow();
1546 }
1547
1548 // draw rectangles
1549 DrawGrabRect(0, x - 6, y - 6);
1550 DrawGrabRect(1, x + frame->GetWidth()/2 - 3, y - 6);
1551 DrawGrabRect(2, x + frame->GetWidth(), y - 6);
1552 DrawGrabRect(3, x - 6, y + frame->GetHeight());
1553 DrawGrabRect(4, x - 6, y + frame->GetHeight()/2 - 3);
1554 DrawGrabRect(5, x + frame->GetWidth(), y + frame->GetHeight()/2 - 3);
1555 DrawGrabRect(6, x + frame->GetWidth()/2 - 3, y + frame->GetHeight());
1556 DrawGrabRect(7, x + frame->GetWidth(), y + frame->GetHeight());
1557
1559}
1560
1561////////////////////////////////////////////////////////////////////////////////
1562/// Helper method to draw grab rectangle at position x,y
1563
1565{
1566 if (fStop) {
1567 return;
1568 }
1569
1570 fPimpl->fGrabRect[i]->Move(x, y);
1571 fPimpl->fGrabRect[i]->MapRaised();
1572}
1573
1574////////////////////////////////////////////////////////////////////////////////
1575/// Raise composite frame when mouse is moving over it.
1576/// That allows to highlight position of "plain" composite frames.
1577
1579{
1580 static Window_t gw = 0;
1581
1582 if (fStop || !win || (win == gw)) {
1583 return;
1584 }
1585
1587
1588 if (!w || (w == fPimpl->fPlane) || w->GetEditDisabled() || w->IsEditable() ||
1589 !w->InheritsFrom(TGCompositeFrame::Class())) {
1590 return;
1591 }
1592
1593 TGFrame *frame = (TGFrame*)w;
1594 UInt_t opt = frame->GetOptions();
1595
1596 if ((opt & kRaisedFrame) || (opt & kSunkenFrame)) {
1597 return;
1598 }
1599
1600 gw = win;
1601 if (fPimpl->fPlane) {
1604 }
1605 fPimpl->fPlane = frame;
1608
1609 if (fBuilder) {
1610 TString str = frame->ClassName();
1611 str += "::";
1612 str += frame->GetName();
1613 fBuilder->UpdateStatusBar(str.Data());
1614 }
1615}
1616
1617////////////////////////////////////////////////////////////////////////////////
1618/// The main event loop is originated here
1619/// It repeatedly queries pointer state and position on the screen.
1620/// From this info an Event_t structure is built.
1621
1626
1627////////////////////////////////////////////////////////////////////////////////
1628/// Handle timer events or events coming from the recorder.
1629
1631{
1632 static Int_t gy = 0;
1633 static Int_t gx = 0;
1634 static UInt_t gstate = 0;
1635 static Window_t gw = 0;
1636
1637 Bool_t ret = kTRUE;
1638
1639 // if nothing is edited stop timer and reset everything
1640 if (!fClient || !fClient->IsEditable()) {
1642 return kFALSE;
1643 }
1644 if (!IsSelectedVisible()) {
1646 }
1647 if (e) {
1648 if (fPimpl->fRepeatTimer) {
1649 // we are replaying events from the recorder...
1652 }
1653 if (e->fType == kButtonPress)
1654 return HandleButtonPress(e);
1655 else if (e->fType == kButtonRelease)
1656 return HandleButtonRelease(e);
1657 else if (e->fState & kButton1Mask)
1658 return HandleMotion(e);
1659 return kTRUE;
1660 }
1661 Window_t dum;
1662 Event_t ev;
1663 ev.fCode = kButton1;
1664 ev.fType = kMotionNotify;
1665 ev.fState = 0;
1666
1667 gVirtualX->QueryPointer(gVirtualX->GetDefaultRootWindow(), dum, dum,
1668 ev.fXRoot, ev.fYRoot, ev.fX, ev.fY, ev.fState);
1669
1670 ev.fWindow = GetWindowFromPoint(ev.fXRoot, ev.fYRoot);
1671
1672 if (ev.fWindow && (gw == ev.fWindow) && (gstate == ev.fState) &&
1673 (ev.fYRoot == gy) && (ev.fXRoot == gx)) {
1674 return kFALSE;
1675 }
1676
1677 gw = ev.fWindow;
1678 gstate = ev.fState;
1679 ev.fState &= ~16; // ignore "num lock" pressed
1680 ev.fState &= ~2; // ignore "caps lock" pressed
1681
1683 ((ev.fState == kButton1Mask) || (ev.fState == kButton3Mask) ||
1684 (ev.fState == (kButton1Mask | kKeyShiftMask)) ||
1685 (ev.fState == (kButton1Mask | kKeyControlMask)))) {
1686
1687 if (ev.fState & kButton1Mask) ev.fCode = kButton1;
1688 if (ev.fState & kButton3Mask) ev.fCode = kButton3;
1689
1690 ev.fType = kButtonPress;
1691 t->SetTime(40);
1692
1696 } else {
1697 fPimpl->fPlane = 0;
1698 }
1699
1701 TimerEvent(&ev);
1702 return ret;
1703 }
1704
1705 if ((fDragging || fMoveWaiting) && (!ev.fState || (ev.fState == kKeyShiftMask)) &&
1707
1708 ev.fType = kButtonRelease;
1709 t->SetTime(100);
1710
1712 TimerEvent(&ev);
1713 return ret;
1714 }
1715
1716 fPimpl->fButtonPressed = (ev.fState & kButton1Mask) ||
1717 (ev.fState & kButton2Mask) ||
1718 (ev.fState & kButton3Mask);
1719
1720 if ((ev.fYRoot == gy) && (ev.fXRoot == gx)) return kFALSE;
1721
1722 gy = ev.fYRoot;
1723 gx = ev.fXRoot;
1724
1725 if (!fMoveWaiting && !fDragging && !ev.fState) {
1726 if (!CheckDragResize(&ev) && fClient->GetWindowById(ev.fWindow)) {
1727 HighlightCompositeFrame(ev.fWindow);
1728 }
1729 } else if (ev.fState & kButton1Mask) {
1730 HandleMotion(&ev);
1731 TimerEvent(&ev);
1732 }
1733 return ret;
1734}
1735
1736////////////////////////////////////////////////////////////////////////////////
1737/// Recognize what was done when mouse button pressed
1738
1740{
1741 if (fStop) {
1742 return kFALSE;
1743 }
1744
1745 if (((event->fCode != kButton1) && (event->fCode != kButton3)) ||
1746 !frame || !fClient->IsEditable()) {
1747 return kFALSE;
1748 }
1749
1750 TGFrame *context_fr = 0;
1751 Bool_t mdi = kFALSE;
1752
1753 // hack for editable mdi frames
1754 if (frame->IsEditable() && frame->InheritsFrom(TGMdiFrame::Class())) {
1755 context_fr = frame;
1756 mdi = kTRUE;
1757 }
1758
1759 // handle context menu
1760 if (event->fCode == kButton3) {
1761 if (!fPimpl->fSpacePressedFrame) {
1762 if (!mdi) {
1763 SelectFrame(frame);
1765 }
1766 } else {
1768 }
1769
1771 return kTRUE;
1772 }
1773
1775
1776 if (!fSelectionIsOn) {
1777 fPimpl->fX0 = event->fXRoot;
1778 fPimpl->fY0 = event->fYRoot;
1779 }
1780
1781 //HideGrabRectangles();
1782 fPimpl->fClickFrame = frame;
1783
1784 if (fBuilder && fBuilder->IsExecutable() &&
1786 UngrabFrame();
1787 frame->SetEditable(kTRUE);
1788 fSource = 0;
1790 goto out;
1791 }
1792
1793 if (event->fState & kKeyShiftMask) {
1794 // drag grabbed frame with shift key pressed should create a copy of grabbed frame
1795 // move a copy of editable and selected frame
1796 if (frame == fPimpl->fGrab) {
1797 fSource = frame;
1799 gVirtualX->SetCursor(frame->GetId(), gVirtualX->CreateCursor(kMove));
1800 goto out;
1801 }
1802
1803 // otherwise do lasso selection
1804 if (!fSelectionIsOn) {
1806 } else {
1807 fPimpl->fX = event->fXRoot;
1808 fPimpl->fY = event->fYRoot;
1810 DrawLasso();
1811 return kTRUE;
1812 }
1813 }
1814
1815 CheckDragResize(event);
1816
1817 if (frame->IsEditable()) {
1818 fSource = 0;
1819
1820 if (fDragType != kDragResize) {
1821
1822 // move editable and selected frame
1823 if (frame == fPimpl->fGrab) {
1824 fSource = frame;
1826 gVirtualX->SetCursor(frame->GetId(), gVirtualX->CreateCursor(kMove));
1827 goto out;
1828 }
1829
1831 }
1832 } else if ((fDragType != kDragResize) && !fPimpl->fSpacePressedFrame) {
1833
1834 // special case of TGCanvas
1835 if (!fPimpl->fGrab && frame->InheritsFrom(TGCanvas::Class())) {
1836 TGFrame *cont = ((TGCanvas*)frame)->GetContainer();
1837
1838 if (!cont->IsEditable()) {
1839 cont->SetEditable(kTRUE);
1841 goto out;
1842 }
1843 }
1844
1845 fSource = frame;
1846 SelectFrame(frame, event->fState & kKeyShiftMask);
1847 }
1848
1850 SwitchEditable(frame);
1851 fSource = 0;
1852
1853 // try again
1854 CheckDragResize(event);
1855
1856 if (fDragType == kDragNone) {
1857 return kFALSE;
1858 }
1859 }
1860
1861out:
1862 Window_t c;
1863
1864 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
1865 frame->GetId(),
1866 event->fXRoot, event->fYRoot,
1867 fPimpl->fXf, fPimpl->fYf, c);
1868 fPimpl->fX = event->fXRoot;
1869 fPimpl->fY = event->fYRoot;
1870
1872 DoRedraw();
1873
1874 return kTRUE;
1875}
1876
1877////////////////////////////////////////////////////////////////////////////////
1878/// Handle 3d mouse pressed (popup context menu)
1879
1881{
1882 if (fStop || !frame) {
1883 return;
1884 }
1885
1887 return;
1888 }
1889
1890 if (frame == fSelected) {
1891 Menu4Frame(frame, event->fXRoot, event->fYRoot);
1892 } else if (frame->IsEditable()) {
1893 if (fLassoDrawn) {
1894 Menu4Lasso(event->fXRoot, event->fYRoot);
1895 } else {
1896 Menu4Frame(frame, event->fXRoot, event->fYRoot);
1897 }
1898 } else {
1899 TGFrame *base = InEditable(frame->GetId());
1900 if (base) {
1901 //SelectFrame(base);
1902 Menu4Frame(base, event->fXRoot, event->fYRoot);
1903 } else {
1904 Menu4Frame(frame, event->fXRoot, event->fYRoot);
1905 }
1906 }
1907}
1908
1909////////////////////////////////////////////////////////////////////////////////
1910/// Handle button event occurred in some ROOT frame
1911
1913{
1914 if (fStop) {
1915 return kFALSE;
1916 }
1917
1918 if (event->fCode != kButton3) {
1919 CloseMenus();
1920 }
1921
1922 if (event->fType == kButtonPress) {
1923 return HandleButtonPress(event);
1924 } else {
1925 return HandleButtonRelease(event);
1926 }
1927}
1928
1929////////////////////////////////////////////////////////////////////////////////
1930/// Resize events
1931
1933{
1934 if (fStop) {
1935 return kFALSE;
1936 }
1937
1939
1940 if (!w) {
1941 return kFALSE;
1942 }
1943
1945 return kFALSE;
1946}
1947
1948////////////////////////////////////////////////////////////////////////////////
1949/// Handle repaint event
1950
1952{
1953 if (fStop) {
1954 return kFALSE;
1955 }
1956
1957 static Long64_t was = gSystem->Now();
1958 static Window_t win = 0;
1959 Long64_t now = gSystem->Now();
1960
1961 if (event->fCount || (win == event->fWindow) || (now-was < 50) || fDragging) {
1962 if (fDragging) {
1964 }
1965 return kFALSE;
1966 }
1967
1968 if (gMenuDialog) {
1970 gMenuDialog->RaiseWindow();
1971 return kFALSE;
1972 }
1973
1974 if (fLassoDrawn) {
1975 DrawLasso();
1976 } else {
1977 if (IsSelectedVisible()) {
1979 }
1980 }
1981
1982 win = event->fWindow;
1983 was = now;
1984
1985 return kFALSE;
1986}
1987
1988////////////////////////////////////////////////////////////////////////////////
1989/// Handle all events.
1990
1992{
1993 if (fStop) {
1994 return kFALSE;
1995 }
1996
1997 if (IgnoreEvent(event)) {
1998 return kFALSE;
1999 }
2000
2001 switch (event->fType) {
2002
2003 case kExpose:
2004 return HandleExpose(event);
2005
2006 case kConfigureNotify:
2007 while (gVirtualX->CheckEvent(fId, kConfigureNotify, *event))
2008 ;
2009 return HandleConfigureNotify(event);
2010
2011 case kGKeyPress:
2012 case kKeyRelease:
2013 return HandleKey(event);
2014
2015 case kFocusIn:
2016 case kFocusOut:
2017 //HandleFocusChange(event);
2018 break;
2019
2020 case kButtonPress:
2021 {
2023
2024 static Window_t gDbw = 0;
2025 static Long_t gLastClick = 0;
2026 static UInt_t gLastButton = 0;
2027 static Int_t gDbx = 0;
2028 static Int_t gDby = 0;
2029
2030 if ((event->fTime - gLastClick < 350) &&
2031 (event->fCode == gLastButton) &&
2032 (std::abs(event->fXRoot - gDbx) < 6) &&
2033 (std::abs(event->fYRoot - gDby) < 6) &&
2034 (event->fWindow == gDbw)) {
2035 dbl_clk = kTRUE;
2036 }
2037
2038 if (dbl_clk) {
2039 if (event->fState & kKeyControlMask) {
2041 return kTRUE;
2042 } else if (!(event->fState & 0xFF)) {
2044
2045 if (w && (w->GetEditDisabled() & kEditDisableBtnEnable)) {
2046 return w->HandleDoubleClick(event);
2047 }
2048 if (SaveFrame(fTmpBuildFile.Data())) {
2049 gROOT->Macro(fTmpBuildFile.Data());
2050 }
2051 // an easy way to start editting
2053 return kTRUE;
2054 }
2055 } else {
2056 gDbw = event->fWindow;
2057 gLastClick = event->fTime;
2058 gLastButton = event->fCode;
2059 gDbx = event->fXRoot;
2060 gDby = event->fYRoot;
2061
2062 Bool_t ret = HandleButtonPress(event);
2063 return ret;
2064 }
2065
2066 return kFALSE;
2067 }
2068
2069 case kButtonRelease:
2070 return HandleButtonRelease(event);
2071
2072 case kEnterNotify:
2073 case kLeaveNotify:
2074 //HandleCrossing(event);
2075 break;
2076
2077 case kMotionNotify:
2078 while (gVirtualX->CheckEvent(fId, kMotionNotify, *event))
2079 ;
2080 return HandleMotion(event);
2081
2082 case kClientMessage:
2083 return HandleClientMessage(event);
2084
2085 case kDestroyNotify:
2086 return HandleDestroyNotify(event);
2087
2088 case kSelectionNotify:
2089 //HandleSelection(event);
2090 break;
2091
2092 case kSelectionRequest:
2093 //HandleSelectionRequest(event);
2094 break;
2095
2096 case kSelectionClear:
2097 //HandleSelectionClear(event);
2098 break;
2099
2100 case kColormapNotify:
2101 //HandleColormapChange(event);
2102 break;
2103
2104 default:
2105 //Warning("HandleEvent", "unknown event (%#x) for (%#x)", event->fType, fId);
2106 break;
2107 }
2108
2109 return kFALSE;
2110}
2111
2112////////////////////////////////////////////////////////////////////////////////
2113/// Mouse double click handler (never should happen)
2114
2116{
2117 if (fStop) {
2118 return kFALSE;
2119 }
2120
2121 return kFALSE;
2122}
2123
2124////////////////////////////////////////////////////////////////////////////////
2125/// Return a parent which can handle button events.
2126
2128{
2129 TGWindow *parent = fr;
2130
2131 while (parent && (parent != fClient->GetDefaultRoot())) {
2132 if (parent->GetEditDisabled() & kEditDisableBtnEnable) {
2133 return (TGFrame*)parent;
2134 }
2135 parent = (TGWindow*)parent->GetParent();
2136 }
2137 return 0;
2138}
2139
2140////////////////////////////////////////////////////////////////////////////////
2141/// Unmap all popups
2142
2144{
2146 if (!li->GetEntries()) {
2147 return;
2148 }
2149
2151 TIter next(li);
2152
2153 while ((pup = (TGPopupMenu*)next())) {
2154 pup->UnmapWindow();
2156 }
2157 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
2158}
2159
2160////////////////////////////////////////////////////////////////////////////////
2161/// Handle button press event
2162
2164{
2165 if (fStop) {
2166 return kFALSE;
2167 }
2168
2171
2172 if (fPimpl->fPlane) {
2175 }
2176
2177 if (gMenuDialog) { // keep editor on the top
2178 gMenuDialog->RaiseWindow();
2179 }
2180
2181 // keep undocked toolbar on the top
2182 //(but under win32 key handling will be broken : todo)
2183 if (gVirtualX->InheritsFrom("TGX11") && fBuilder &&
2186 }
2187
2188 // keep color dialog on the top
2189 if (fgGlobalColorDialog && fgGlobalColorDialog->IsMapped()) {
2190 fgGlobalColorDialog->RaiseWindow();
2191 return kFALSE;
2192 }
2193
2194 if ( ((event->fCode != kButton1) && (event->fCode != kButton3)) ||
2195 (event->fType != kButtonPress) || IgnoreEvent(event)) {
2196 return kFALSE;
2197 }
2198
2199 Reset1();
2200 //HideGrabRectangles();
2201
2202 Window_t w = GetWindowFromPoint(event->fXRoot, event->fYRoot);
2203 TGFrame *fr = 0;
2204
2205 if (w) {
2206 fr = (TGFrame*)fClient->GetWindowById(w);
2207 if (!fr) {
2208 return kFALSE;
2209 }
2210
2211 //fr->HandleButton(event);
2212 if (!IsEventsDisabled(fr)) {
2214 if (btnframe) {
2215 event->fUser[0] = fr->GetId();
2216 btnframe->HandleButton(event);
2217 }
2218 }
2219
2220 if (IsGrabDisabled(fr)) {
2221 fr = GetEditableParent(fr);
2222 }
2223
2224 if (!fr) {
2225 return kFALSE;
2226 }
2227 } else {
2228 return kFALSE;
2229 }
2230
2231 return RecognizeGesture(event, fr);
2232}
2233
2234////////////////////////////////////////////////////////////////////////////////
2235/// Handle button release event
2236
2238{
2239 if (fStop) {
2240 return kFALSE;
2241 }
2242
2243 // unmap all waiting popups
2246 }
2247
2249
2250 if (w && !IsEventsDisabled(w)) {
2252 if (btnframe) {
2253 event->fUser[0] = w->GetId();
2254 btnframe->HandleButton(event);
2255 }
2256 }
2257
2259 gVirtualX->SetCursor(fClient->GetRoot()->GetId(), gVirtualX->CreateCursor(kPointer));
2260 EndDrag();
2261 fSelectionIsOn &= (event->fState & kKeyShiftMask);
2262
2263 if (fLassoDrawn) {
2264 DrawLasso();
2265 return kTRUE;
2266 }
2267
2269
2270 // make editable the clicked frame if no lasso was drawn
2271 if ((fPimpl->fClickFrame == fPimpl->fGrab) && (fSelected == fPimpl->fGrab) &&
2272 !fPimpl->fGrab->IsEditable()) {
2274 return kTRUE;
2275
2276 // select/grab clicked frame if there was no grab frame
2277 } else if (!fPimpl->fGrab || ((fPimpl->fClickFrame != fPimpl->fGrab) &&
2278 (fPimpl->fClickFrame != fSelected))) {
2280 return kTRUE;
2281 }
2282
2283 }
2284
2286
2287 return kTRUE;
2288}
2289
2290////////////////////////////////////////////////////////////////////////////////
2291/// Handle key event
2292
2294{
2295 if (fStop) {
2296 return kFALSE;
2297 }
2298
2299 char tmp[10];
2300 UInt_t keysym;
2301 Bool_t ret = kFALSE;
2302 TGFileInfo fi;
2303 static TString dir(".");
2304 static Bool_t overwr = kFALSE;
2305 TString fname;
2306
2308
2309 if (!w || !fPimpl) {
2310 return kFALSE;
2311 }
2312
2313 if (w->GetEditDisabled() & kEditDisableKeyEnable) {
2314 return ((TGFrame*)w)->HandleKey(event);
2315 }
2316
2317 if (event->fType != kGKeyPress) {
2318 return kFALSE;
2319 }
2320
2321 if (IsEditDisabled(w)) {
2322 TGFrame *parent = GetEditableParent((TGFrame*)w);
2323 if (parent) {
2324 event->fWindow = parent->GetId();
2325 parent->HandleKey(event);
2326 } else {
2327 return ((TGFrame*)w)->HandleKey(event);
2328 }
2329 }
2330
2332
2333 if (fPimpl->fPlane) {
2336 }
2337
2338 CloseMenus();
2339
2340 fi.fFileTypes = gSaveMacroTypes;
2341 fi.SetIniDir(dir);
2342 fi.fOverwrite = overwr;
2343
2344 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
2345
2346 if (event->fState & kKeyControlMask) {
2347
2348 switch ((EKeySym)keysym & ~0x20) {
2349 case kKey_Return:
2350 case kKey_Enter:
2352 ret = kTRUE;
2353 break;
2354 case kKey_X:
2355 HandleCut();
2356 ret = kTRUE;
2357 break;
2358 case kKey_C:
2359 HandleCopy();
2360 ret = kTRUE;
2361 break;
2362 case kKey_V:
2365 }
2366 HandlePaste();
2367 ret = kTRUE;
2368 break;
2369 case kKey_B:
2370 {
2371 if (fPimpl->fGrab ) {
2372 BreakLayout();
2373 }
2374 ret = kTRUE;
2375 break;
2376 }
2377 case kKey_L:
2378 {
2379 if (fPimpl->fGrab && (fPimpl->fClickFrame != fClient->GetRoot())) {
2380 Compact(kFALSE);
2381 } else {
2382 Compact(kTRUE);
2383 }
2384 ret = kTRUE;
2385 break;
2386 }
2387 case kKey_R:
2388 HandleReplace();
2389 ret = kTRUE;
2390 break;
2391 case kKey_S:
2392 Save();
2393 ret = kTRUE;
2394 break;
2395 case kKey_G:
2396 HandleGrid();
2397 ret = kTRUE;
2398 break;
2399 case kKey_H:
2400 SwitchLayout();
2401 ret = kTRUE;
2402 break;
2403 case kKey_N:
2404 if (fBuilder) {
2406 } else {
2407 TGMainFrame *main = new TGMainFrame(fClient->GetDefaultRoot(), 300, 300);
2408 main->MapRaised();
2409 main->SetEditable(kTRUE);
2410 }
2411 ret = kTRUE;
2412 break;
2413 case kKey_O:
2414 if (fBuilder) {
2416 } else {
2417 TGMainFrame *main = new TGMainFrame(fClient->GetDefaultRoot(), 300, 300);
2418 main->MapRaised();
2419 main->SetEditable(kTRUE);
2420 }
2421 new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi);
2422
2423 if (!fi.fFilename) return kTRUE;
2424 dir = fi.fIniDir;
2425 overwr = fi.fOverwrite;
2426 fname = gSystem->BaseName(gSystem->UnixPathName(fi.fFilename));
2427
2428 if (fname.EndsWith(".C")) {
2429 gROOT->Macro(fname.Data());
2430 } else {
2431 Int_t retval;
2432 new TGMsgBox(fClient->GetDefaultRoot(), this, "Error...",
2433 TString::Format("file (%s) must have extension .C", fname.Data()),
2435 if (retval == kMBRetry) {
2436 HandleKey(event);
2437 }
2438 }
2439 ret = kTRUE;
2440 break;
2441 default:
2442 break;
2443 }
2444 } else {
2445 switch ((EKeySym)keysym) {
2446 case kKey_Delete:
2447 case kKey_Backspace:
2449 ret = kTRUE;
2450 break;
2451 case kKey_Return:
2452 case kKey_Enter:
2453 //UnmapAllPopups();
2455 ret = kTRUE;
2456 break;
2457 case kKey_Left:
2458 case kKey_Right:
2459 case kKey_Up:
2460 case kKey_Down:
2461 if (fLassoDrawn) {
2463 } else if (fPimpl->fGrab) {
2465 }
2466 ret = kTRUE;
2467 break;
2468 case kKey_Space:
2469 //UnmapAllPopups();
2470 if (fPimpl->fGrab) {
2472
2474
2475 if (p) {
2476 if (fBuilder && p == fBuilder->GetMdiMain()->GetCurrent()) {
2477 UngrabFrame();
2478 } else {
2479 SelectFrame(p);
2481 }
2482 }
2483 }
2484 ret = kTRUE;
2485 break;
2486 default:
2487 break;
2488 }
2489 }
2490 if (fBuilder) {
2491 fBuilder->SetAction(0);
2492 //fBuilder->Update();
2493 }
2494
2495 if (fLassoDrawn) {
2496 DrawLasso();
2497 }
2498
2499 return ret;
2500}
2501
2502////////////////////////////////////////////////////////////////////////////////
2503/// Reparent frames
2504
2506{
2507 if (fStop || !fClient->IsEditable() || (newfr == fClient->GetDefaultRoot())) {
2508 return;
2509 }
2510
2511 Int_t x0, y0, xx, yy;
2512 Window_t c;
2513 static TGLayoutHints *hints = new TGLayoutHints(kLHintsNormal, 2, 2, 2, 2);
2514
2515 if (!newfr || !newfr->GetId() || !oldfr || !oldfr->GetId()) return;
2516
2517 gVirtualX->TranslateCoordinates(newfr->GetId(), oldfr->GetId(),
2518 0, 0, x0, y0, c);
2519
2520 x0 = x0 < 0 ? 0 : x0;
2521 y0 = y0 < 0 ? 0 : y0;
2522 Int_t x = x0 + newfr->GetWidth();
2523 Int_t y = y0 + newfr->GetHeight();
2524
2526
2527 if (newfr->InheritsFrom(TGCompositeFrame::Class())) {
2529 comp->SetLayoutBroken();
2530 }
2531
2532 TIter next(oldfr->GetList());
2534
2535 while ((el = (TGFrameElement*)next())) {
2536 TGFrame *frame = el->fFrame;
2537
2538 if ((frame->GetX() >= x0) && (frame->GetY() >= y0) &&
2539 (frame->GetX() + (Int_t)frame->GetWidth() <= x) &&
2540 (frame->GetY() + (Int_t)frame->GetHeight() <= y)) {
2541
2542 if (frame == fPimpl->fGrab) {
2543 UngrabFrame();
2544 }
2545
2546 oldfr->RemoveFrame(frame);
2547
2548 gVirtualX->TranslateCoordinates(oldfr->GetId(), newfr->GetId(),
2549 frame->GetX(), frame->GetY(), xx, yy, c);
2550
2551 frame->ReparentWindow(newfr, xx, yy);
2552
2553 if (comp) {
2554 comp->AddFrame(frame, hints); // el->fLayout);
2555 }
2556 }
2557 }
2558}
2559
2560////////////////////////////////////////////////////////////////////////////////
2561/// Return the list of frames inside of some area
2562
2564{
2565 if (fStop) {
2566 return 0;
2567 }
2568
2569 Int_t xx, yy;
2570
2571 if (!fClient->GetRoot()->InheritsFrom(TGCompositeFrame::Class())) {
2572 return 0;
2573 }
2574
2575 TList *list = new TList();
2576
2577 xx = x0; yy = y0;
2578 x0 = std::min(xx, x); x = std::max(xx, x);
2579 y0 = std::min(yy, y); y = std::max(yy, y);
2580
2581 TIter next(((TGCompositeFrame*)fClient->GetRoot())->GetList());
2583
2584 while ((el = (TGFrameElement*)next())) {
2585 if ((el->fFrame->GetX() >= x0) && (el->fFrame->GetY() >= y0) &&
2586 (el->fFrame->GetX() + (Int_t)el->fFrame->GetWidth() <= x) &&
2587 (el->fFrame->GetY() + (Int_t)el->fFrame->GetHeight() <= y)) {
2588 list->Add(el->fFrame);
2589 }
2590 }
2591 if (list->IsEmpty()) {
2592 delete list;
2593 return 0;
2594 }
2595 return list;
2596}
2597
2598////////////////////////////////////////////////////////////////////////////////
2599/// Drop canvas container
2600
2602{
2603 if (fStop) {
2604 return;
2605 }
2606
2608 comp->SetEditable(kTRUE);
2609
2611 Int_t x = canvas->GetX();
2612 Int_t y = canvas->GetY();
2613
2614 cont->SetEditDisabled(cont->GetEditDisabled() & ~kEditDisableGrab);
2615 cont->ReparentWindow(comp, x, y);
2616 canvas->SetContainer(0);
2617 comp->AddFrame(cont);
2618 DeleteFrame(canvas);
2619
2620 if (fBuilder) {
2621 TString str = cont->ClassName();
2622 str += "::";
2623 str += cont->GetName();
2624 str += " dropped.";
2625 fBuilder->UpdateStatusBar(str.Data());
2626 }
2628}
2629
2630////////////////////////////////////////////////////////////////////////////////
2631/// Create a new TGCanvas and place container into it
2632
2634{
2635 if (fStop || !cont) {
2636 return;
2637 }
2638
2639 TGCompositeFrame *comp = (TGCompositeFrame*)cont->GetParent();
2640 comp->SetEditable(kTRUE);
2641
2642 UInt_t w = cont->GetWidth()/2;
2643 UInt_t h = cont->GetHeight()/2;
2644
2645 w = w < 100 ? 100 : w;
2646 h = h < 100 ? 100 : h;
2647
2648 TGCanvas *canvas = new TGCanvas(comp, w, h);
2649 canvas->Move(cont->GetX(), cont->GetY());
2650 comp->RemoveFrame(cont);
2651 comp->AddFrame(canvas);
2652 cont->ReparentWindow(canvas->GetViewPort());
2653 canvas->SetContainer(cont);
2654 cont->SetCleanup(kDeepCleanup);
2655 canvas->MapSubwindows();
2656 canvas->MapWindow();
2657 SelectFrame(canvas);
2658
2659 if (fBuilder) {
2660 fBuilder->UpdateStatusBar("Grab action performed. Press Cntrl-Return to Drop grabbed frame.");
2661 }
2662}
2663
2664////////////////////////////////////////////////////////////////////////////////
2665/// Handling of return/enter key pressing
2666///
2667/// If on is kFALSE:
2668/// If Return or Enter key was pressed - Grab Act
2669/// If lasso is drawn - new composite frame is created and
2670/// all frames inside lasso adopted as children.
2671/// If lasso is not drawn and selected frame is composite one,
2672/// - new TGCanvas widget is created and selected frame became
2673/// container for this canvas.
2674///
2675/// If on is kTRUE:
2676/// If Return or Enter key was pressed with Control Key - Drop Act,
2677/// The opposite action to the Grab Act.
2678/// If selected/grabbed frame is not a TGCanvas widget -
2679/// all frames inside the grabbed/selected frame are "dropped" into
2680/// the underlying frame and the grabbed frame is deleted.
2681///
2682/// If selected/grabbed frame is a TGCanvas widget -
2683/// container frame "dropped" to editable frame
2684
2686{
2687 if (fStop) {
2688 return;
2689 }
2690
2691 Int_t x0, y0, x, y, xx, yy;
2692 Window_t c;
2693 TGCompositeFrame *parent = 0;
2694 TList *li = 0;
2695
2696 if (!fClient->GetRoot()->InheritsFrom(TGCompositeFrame::Class()) ||
2697 !fClient->IsEditable()) {
2698 return;
2699 }
2700
2701 // if grabbed frame is editable - we need to switch edit to parent
2702 if (fPimpl->fGrab && fPimpl->fGrab->IsEditable()) {
2704 }
2705
2706 if (fPimpl->fGrab && !fLassoDrawn) {
2707 if (!on) {
2714 return;
2715 }
2716 } else {
2717
2718 if ((fPimpl->fGrab->IsA() == TGCanvas::Class()) &&
2719 !((TGCanvas*)fPimpl->fGrab)->GetContainer()->InheritsFrom(TGContainer::Class()) &&
2722 return;
2723 }
2724 }
2725 }
2726
2728
2729 if (fLassoDrawn) {
2730
2731 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2732 fClient->GetRoot()->GetId(),
2733 fPimpl->fX, fPimpl->fY, x, y, c);
2734 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2735 fClient->GetRoot()->GetId(),
2736 fPimpl->fX0, fPimpl->fY0, x0, y0, c);
2737
2738 xx = x0; yy = y0;
2739 x0 = std::min(xx, x); x = std::max(xx, x);
2740 y0 = std::min(yy, y); y = std::max(yy, y);
2741
2742 li = GetFramesInside(x0, y0, x, y);
2743
2744 if (!on && li) {
2745 parent = new TGCompositeFrame(comp, x - x0, y - y0);
2746 parent->MoveResize(x0, y0, x - x0, y - y0);
2747 ReparentFrames(parent, comp);
2748
2749 comp->AddFrame(parent);
2750 parent->MapWindow();
2752 SelectFrame(parent);
2753
2754 if (fBuilder) {
2755 TString str = "Grab action performed.";
2756 str += " Press Cntrl-Return to Drop grabbed frames.";
2757 str += " Press Return for TCanvas Grab";
2758 fBuilder->UpdateStatusBar(str.Data());
2759 }
2760 }
2761 } else if (on && fPimpl->fGrab) {
2762
2763 // check if it is forbidden
2764 if (!CanChangeLayout(fPimpl->fGrab) ||
2766 if (fBuilder) {
2767 fBuilder->UpdateStatusBar("Drop action disabled");
2768 }
2769 return;
2770 }
2771
2773 parent = (TGCompositeFrame*)fPimpl->fGrab;
2774 } else {
2775 //parent = (TGCompositeFrame*)fPimpl->fGrab->GetParent();
2776 }
2777 if (parent) {
2778 ReparentFrames(comp, parent);
2780 UngrabFrame();
2781 ChangeSelected(0); //update editors
2782
2783 if (fBuilder) {
2784 fBuilder->UpdateStatusBar("Drop action performed");
2785 }
2786 }
2787 }
2788 delete li;
2789}
2790
2791////////////////////////////////////////////////////////////////////////////////
2792/// Align frames located inside lasso area.
2793
2795{
2796 if (fStop) {
2797 return;
2798 }
2799
2800 Int_t x0, y0, x, y, xx, yy;
2801 Window_t c;
2803
2804 if (!fClient->GetRoot()->InheritsFrom(TGCompositeFrame::Class()) ||
2805 !fClient->IsEditable()) {
2806 return;
2807 }
2808
2809 if (fLassoDrawn) {
2810 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2811 fClient->GetRoot()->GetId(),
2812 fPimpl->fX, fPimpl->fY, x, y, c);
2813 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2814 fClient->GetRoot()->GetId(),
2815 fPimpl->fX0, fPimpl->fY0, x0, y0, c);
2816
2817 xx = x0; yy = y0;
2818 x0 = std::min(xx, x); x = std::max(xx, x);
2819 y0 = std::min(yy, y); y = std::max(yy, y);
2820
2822
2823 ToGrid(x, y);
2824 ToGrid(x0, y0);
2825
2826 TIter next(comp->GetList());
2828 TGFrame *prev = 0;
2829
2830 while ((el = (TGFrameElement*)next())) {
2831 TGFrame *fr = el->fFrame;
2832
2833 if ((fr->GetX() >= x0) && (fr->GetY() >= y0) &&
2834 (fr->GetX() + (Int_t)fr->GetWidth() <= x) &&
2835 (fr->GetY() + (Int_t)fr->GetHeight() <= y)) {
2836
2837 switch ((EKeySym)to) {
2838 case kKey_Left:
2839 fr->Move(x0, fr->GetY());
2840 if (lineup) {
2841 // coverity[dead_error_line]
2842 if (prev) fr->Move(fr->GetX(), prev->GetY() + prev->GetHeight());
2843 else fr->Move(x0, y0);
2844 }
2845 break;
2846 case kKey_Right:
2847 fr->Move(x - fr->GetWidth(), fr->GetY());
2848 if (lineup) {
2849 if (prev) fr->Move(fr->GetX(), prev->GetY() + prev->GetHeight());
2850 else fr->Move(x - fr->GetWidth(), y0);
2851 }
2852 break;
2853 case kKey_Up:
2854 fr->Move(fr->GetX(), y0);
2855 if (lineup) {
2856 if (prev) fr->Move(prev->GetX() + prev->GetWidth(), fr->GetY());
2857 else fr->Move(x0, y0);
2858 }
2859 break;
2860 case kKey_Down:
2861 fr->Move(fr->GetX(), y - fr->GetHeight());
2862 if (lineup) {
2863 if (prev) fr->Move(prev->GetX() + prev->GetWidth(), fr->GetY());
2864 else fr->Move(x0, y - fr->GetHeight());
2865 }
2866 break;
2867 default:
2868 break;
2869 }
2870 prev = fr;
2871 }
2872 }
2873 }
2874 if (fLassoDrawn) {
2875 DrawLasso();
2876 }
2877}
2878
2879////////////////////////////////////////////////////////////////////////////////
2880/// Handle delete or crop action
2881///
2882/// crop is kFALSE - delete action
2883/// - if lasso is drawn -> all frames inside lasso area are deleted
2884/// - if frame is grabbed/selected -> the frame is deleted
2885/// crop is kTRUE - crop action
2886/// - if lasso is drawn -> all frames outside of lasso area are deleted
2887/// - if frame is grabbed/selected -> all frames except the grabbed frame are deleted
2888/// In both cases the main frame is shrunk to the size of crop area.
2889
2891{
2892 if (fStop) {
2893 return;
2894 }
2895
2896 Int_t x0, y0, x, y, xx, yy, w, h;
2897 Window_t c;
2898
2899 if (!fClient->GetRoot()->InheritsFrom(TGCompositeFrame::Class()) ||
2900 !fClient->IsEditable()) {
2901 return;
2902 }
2903
2906 TGFrame *frame = fPimpl->fGrab;
2907
2908 if (fBuilder && crop) {
2910 } else {
2912 }
2913
2914 if (frame && !CanChangeLayout((TGWindow*)frame->GetParent())) {
2915 frame = GetMovableParent(frame);
2916
2917 if (!frame) {
2918 TString str = fPimpl->fGrab->ClassName();
2919 str += "::";
2920 str += fPimpl->fGrab->GetName();
2921 str += " cannot be deleted";
2922
2923 if (fBuilder) {
2924 fBuilder->UpdateStatusBar(str.Data());
2925 }
2926 return;
2927 }
2928 }
2929
2930 // prepare to crop grabbed frame
2931 if (frame && !fLassoDrawn && crop) {
2932 gVirtualX->TranslateCoordinates(frame->GetId(),
2933 fClient->GetDefaultRoot()->GetId(),
2934 -2, -2,
2935 fPimpl->fX0, fPimpl->fY0, c);
2936
2937 fPimpl->fX = fPimpl->fX0 + frame->GetWidth()+4;
2938 fPimpl->fY = fPimpl->fY0 + frame->GetHeight()+4;
2939 fromGrab = kTRUE;
2940 }
2941
2942 x0 = fPimpl->fX0; y0 = fPimpl->fY0;
2943 x = fPimpl->fX; y = fPimpl->fY;
2944 if (comp) {
2945 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2946 comp->GetId(),
2947 fPimpl->fX, fPimpl->fY, x, y, c);
2948 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
2949 comp->GetId(),
2950 fPimpl->fX0, fPimpl->fY0, x0, y0, c);
2951 }
2952
2953 xx = x0; yy = y0;
2954 x0 = std::min(xx, x); x = std::max(xx, x);
2955 y0 = std::min(yy, y); y = std::max(yy, y);
2956 w = x - x0;
2957 h = y - y0;
2958
2959 if (fLassoDrawn || fromGrab) {
2960 if (comp) {
2961 TIter next(comp->GetList());
2963
2964 while ((el = (TGFrameElement*)next())) {
2965 TGFrame *fr = el->fFrame;
2966
2967 if ((fr->GetX() >= x0) && (fr->GetY() >= y0) &&
2968 (fr->GetX() + (Int_t)fr->GetWidth() <= x) &&
2969 (fr->GetY() + (Int_t)fr->GetHeight() <= y)) {
2970 if (!crop) {
2971 DeleteFrame(fr);
2972 } else {
2973 fr->Move(fr->GetX() - x0, fr->GetY() - y0);
2974 }
2975 } else {
2976 if (crop) {
2977 DeleteFrame(fr);
2978 }
2979 }
2980 }
2981 if (crop && comp) {
2982 gVirtualX->TranslateCoordinates(comp->GetId(), comp->GetParent()->GetId(),
2983 x0, y0, xx, yy, c);
2984
2985 comp->MoveResize(xx, yy, w, h);
2986
2987 if (comp->GetParent()->InheritsFrom(TGMdiDecorFrame::Class())) {
2988 TGMdiDecorFrame *decor = (TGMdiDecorFrame *)comp->GetParent();
2989
2990 gVirtualX->TranslateCoordinates(decor->GetId(), decor->GetParent()->GetId(),
2991 xx, yy, xx, yy, c);
2992
2993 Int_t b = 2 * decor->GetBorderWidth();
2994 decor->MoveResize(xx, yy, comp->GetWidth() + b,
2995 comp->GetHeight() + b + decor->GetTitleBar()->GetDefaultHeight());
2996 }
2997 }
2998 }
2999 } else { // no lasso drawn -> delete selected frame
3000 if (frame)
3001 DeleteFrame(frame);
3002 UngrabFrame();
3003 ChangeSelected(0); //update editors
3004 }
3006
3007 if (fBuilder) {
3008 //fBuilder->Update();
3009 fBuilder->UpdateStatusBar(crop ? "Crop action performed" : "Delete action performed");
3010 }
3011}
3012
3013////////////////////////////////////////////////////////////////////////////////
3014/// Delete frame
3015
3017{
3018 if (fStop || !frame) {
3019 return;
3020 }
3021
3022 // remove the frame from the list tree and reset the editor...
3023 fEditor->RemoveFrame(frame);
3024
3025 frame->UnmapWindow();
3026
3028
3029 if (frame->GetParent()->InheritsFrom(TGCompositeFrame::Class())) {
3030 comp = (TGCompositeFrame*)frame->GetParent();
3031 }
3032
3033 if (comp) {
3034 comp->RemoveFrame(frame);
3035 }
3036
3037 if (frame == fPimpl->fGrab) {
3038 UngrabFrame();
3039 }
3040
3041 fClient->UnregisterWindow(frame);
3042
3043 // mem.leak paid for robustness (with possibility "undelete")
3045}
3046
3047////////////////////////////////////////////////////////////////////////////////
3048/// Handle cut action
3049
3051{
3052 if (fStop || !fPimpl->fGrab) {
3053 return;
3054 }
3055
3056 //
3058 HandleCopy();
3060 ChangeSelected(0); //update editors
3061}
3062
3063////////////////////////////////////////////////////////////////////////////////
3064/// Handle copy. This method is also used by SaveFrame method.
3065/// In later case brk_layout == kFALSE
3066
3068{
3069 if (fStop || !fPimpl->fGrab) {
3070 return;
3071 }
3072
3074 fPimpl->fGrab->GetWidth(),
3075 fPimpl->fGrab->GetHeight());
3076
3077 // save coordinates
3078 Int_t x0 = fPimpl->fGrab->GetX();
3079 Int_t y0 = fPimpl->fGrab->GetY();
3080
3081 // save parent name
3082 TString name = fPimpl->fGrab->GetParent()->GetName();
3083
3084 ((TGWindow*)fPimpl->fGrab->GetParent())->SetName(tmp->GetName());
3085
3086 fPimpl->fGrab->SetX(0);
3087 fPimpl->fGrab->SetY(0);
3088
3090
3091 if (fe) {
3092 tmp->GetList()->Add(fe);
3093 }
3094
3095 tmp->SetLayoutBroken(brk_layout);
3096
3097 if (!brk_layout) { //save frame
3099 tmp->SetWMSize(tmp->GetWidth(), tmp->GetHeight());
3100 tmp->SetWMSizeHints(tmp->GetDefaultWidth(), tmp->GetDefaultHeight(), 10000, 10000, 0, 0);
3101 const char *short_name = gSystem->BaseName(fPasteFileName.Data());
3102 tmp->SetWindowName(short_name);
3103 tmp->SetIconName(short_name);
3104 tmp->SetClassHints(short_name, short_name);
3105 // some problems here under win32
3106 if (gVirtualX->InheritsFrom("TGX11")) tmp->SetIconPixmap("bld_rgb.xpm");
3107 }
3109 tmp->SaveSource(fPasteFileName.Data(), quite ? "keep_names quiet" : "keep_names");
3110 tmp->GetList()->Remove(fe);
3111
3112 fPimpl->fGrab->SetX(x0);
3113 fPimpl->fGrab->SetY(y0);
3114
3115 ((TGWindow*)fPimpl->fGrab->GetParent())->SetName(name.Data());
3116
3117 if (fBuilder) {
3118 TString str = fPimpl->fGrab->ClassName();
3119 str += "::";
3120 str += fPimpl->fGrab->GetName();
3121 str += " copied to clipboard";
3122 fBuilder->UpdateStatusBar(str.Data());
3123 }
3124
3125 delete tmp;
3126}
3127
3128////////////////////////////////////////////////////////////////////////////////
3129/// Handle paste action.
3130
3132{
3133 if (fStop) {
3134 return;
3135 }
3136
3137 Int_t xp = 0;
3138 Int_t yp = 0;
3139
3141 return;
3142 }
3143
3144 fPasting = kTRUE;
3145 gROOT->Macro(fPasteFileName.Data());
3146
3147 Window_t c;
3148 TGFrame *root = (TGFrame*)fClient->GetRoot();
3149
3150 if (!fPimpl->fReplaceOn) {
3151 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
3152 root->GetId(),
3153 fPimpl->fX0, fPimpl->fY0, xp, yp, c);
3154 ToGrid(xp, yp);
3155
3156 // fPasteFrame is defined in TVirtualDragManager.h
3157 // fPasteFrame is a TGMainFrame consisting "the frame to paste"
3158 // into the editable frame (aka fClient->GetRoot())
3159
3160 if (fPasteFrame) {
3162 TGFrame *paste = ((TGFrameElement*)main->GetList()->First())->fFrame;
3163
3164 UInt_t w = paste->GetWidth();
3165 UInt_t h = paste->GetHeight();
3166
3167 if (xp + w > root->GetWidth()) {
3168 w = root->GetWidth() - xp -1;
3169 }
3170 if (yp + h > root->GetHeight()) {
3171 h = root->GetHeight() - yp -1;
3172 }
3173
3174 paste->Resize(w, h);
3175 fPasteFrame->Move(xp, yp);
3177 HandleReturn(1); // drop
3178 }
3179 }
3180
3181 fPasting = kFALSE;
3182
3183 if (fBuilder) {
3184 fBuilder->UpdateStatusBar("Paste action performed");
3185 }
3186}
3187
3188////////////////////////////////////////////////////////////////////////////////
3189/// Replace frame (doesn't work yet properly)
3190
3192{
3193 if (fStop || !frame || !fPimpl->fGrab || !fPimpl->fReplaceOn) {
3194 return;
3195 }
3196
3197 Int_t w = fPimpl->fGrab->GetWidth();
3199 Int_t x = fPimpl->fGrab->GetX();
3200 Int_t y = fPimpl->fGrab->GetY();
3201
3202 if (fBuilder) {
3203 TString str = fPimpl->fGrab->ClassName();
3204 str += "::";
3205 str += fPimpl->fGrab->GetName();
3206 str += " replaced by ";
3207 str += frame->ClassName();
3208 str += "::";
3209 str += frame->GetName();
3210 fBuilder->UpdateStatusBar(str.Data());
3211 }
3212
3214
3215 if (fe) {
3216 fe->fFrame = 0;
3218 delete fPimpl->fGrab;
3219 fPimpl->fGrab = 0;
3220
3221 fe->fFrame = frame;
3222 frame->MoveResize(x, y, w, h);
3223 frame->MapRaised();
3224 frame->SetFrameElement(fe);
3225 }
3226
3227 SelectFrame(frame);
3229
3230 TGWindow *root = (TGWindow *)fClient->GetRoot();
3231 root->SetEditable(kFALSE);
3232 DoRedraw();
3233 root->SetEditable(kTRUE);
3234}
3235
3236////////////////////////////////////////////////////////////////////////////////
3237/// Handle replace
3238
3240{
3241 if (fStop || !fPimpl->fGrab) {
3242 return;
3243 }
3244
3246 TGFrame *frame = 0;
3247
3248 if (fBuilder && fBuilder->IsExecutable()) {
3249 frame = (TGFrame *)fBuilder->ExecuteAction();
3250 } else {
3251 HandlePaste();
3252 frame = fPasteFrame;
3253 }
3254 DoReplace(frame);
3256}
3257
3258////////////////////////////////////////////////////////////////////////////////
3259/// Create a frame which is the same as currently edited frame
3260
3262{
3263 if (fStop) {
3264 return;
3265 }
3266
3268 TString temp;
3269 temp.Form("tmp%d.C", gRandom->Integer(100));
3270 const char *s = gSystem->PrependPathName(tmpfile, temp);
3271 Save(s);
3272 gROOT->Macro(s);
3273 gSystem->Unlink(s);
3274
3275 if (fClient->GetRoot()->InheritsFrom(TGFrame::Class())) {
3276 TGFrame *f = (TGFrame *)fClient->GetRoot();
3277 f->Resize(f->GetWidth() + 10, f->GetHeight() + 10);
3278 }
3279}
3280
3281////////////////////////////////////////////////////////////////////////////////
3282/// Save an edited frame to the file
3283
3285{
3286 if (fStop || !fClient->GetRoot() || !fClient->IsEditable()) {
3287 return kFALSE;
3288 }
3289
3290 TGMainFrame *main = (TGMainFrame*)fClient->GetRoot()->GetMainFrame();
3291 TGWindow *root = (TGWindow*)fClient->GetRoot();
3292 TString fname = file;
3293
3294 root->SetEditable(kFALSE);
3295
3296 static TImage *img = 0;
3297
3298 if (!img) {
3299 img = TImage::Create();
3300 }
3301 img->FromWindow(main->GetId());
3302
3303 if (!file || !file[0]) {
3304 static TString dir(".");
3305 static Bool_t overwr = kFALSE;
3306 TGFileInfo fi;
3307
3308 fi.fFileTypes = gSaveMacroTypes;
3309 fi.SetIniDir(dir);
3310 fi.fOverwrite = overwr;
3311 new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi);
3312
3313 if (!fi.fFilename) goto out;
3314 dir = fi.fIniDir;
3315 overwr = fi.fOverwrite;
3316 fname = gSystem->BaseName(gSystem->UnixPathName(fi.fFilename));
3317 }
3318
3319 if (fname.EndsWith(".C")) {
3321 main->SetWMSize(main->GetWidth(), main->GetHeight());
3322 main->SetWMSizeHints(main->GetDefaultWidth(), main->GetDefaultHeight(), 10000, 10000, 0, 0);
3323 main->SetWindowName(fname.Data());
3324 main->SetIconName(fname.Data());
3325 main->SetClassHints(fname.Data(), fname.Data());
3326 // some problems here under win32
3327 if (gVirtualX->InheritsFrom("TGX11")) main->SetIconPixmap("bld_rgb.xpm");
3328 main->SaveSource(fname.Data(), file ? "keep_names quiet" : "keep_names");
3329
3330 if (fBuilder)
3331 fBuilder->AddMacro(fname.Data(), img);
3332
3333 } else {
3334 Int_t retval;
3335 TString msg = TString::Format("file (%s) must have extension .C", fname.Data());
3336
3337 new TGMsgBox(fClient->GetDefaultRoot(), main, "Error...", msg.Data(),
3339
3340 if (retval == kMBRetry) {
3341 return Save();
3342 }
3343 }
3344
3345out:
3346 main->RaiseWindow();
3347 return kTRUE;
3348}
3349
3350////////////////////////////////////////////////////////////////////////////////
3351/// Save composite frame as macro
3352
3354{
3355 if (fStop || !fClient->GetRoot() || !fClient->IsEditable() ||
3357 return kFALSE;
3358 }
3359
3360 TString fname = file;
3361
3362 TGFrame *frame = fPimpl->fGrab;
3364
3365 static TImage *img = 0;
3366
3367 if (!img) {
3368 img = TImage::Create();
3369 }
3370 img->FromWindow(frame->GetId());
3371
3372 static TString dir(".");
3373 static Bool_t overwr = kFALSE;
3374
3376
3377 if (!file) {
3378 TGFileInfo fi;
3379
3380 fi.fFileTypes = gSaveMacroTypes;
3381 fi.SetIniDir(dir);
3382 fi.fOverwrite = overwr;
3383 new TGFileDialog(fClient->GetDefaultRoot(), frame, kFDSave, &fi);
3384
3385 if (!fi.fFilename) {
3386 goto out;
3387 }
3388
3389 dir = fi.fIniDir;
3390 overwr = fi.fOverwrite;
3391 fname = gSystem->BaseName(gSystem->UnixPathName(fi.fFilename));
3392 }
3393
3394 if (fname.EndsWith(".C")) {
3396 fPimpl->fGrab = frame;
3397 fStop = kFALSE;
3398 TGFrameElement *fe = frame->GetFrameElement();
3399
3400 if (!fe) { // should never happen
3401 fe = new TGFrameElement();
3402 fe->fFrame = frame;
3403 fe->fState = kIsMapped;
3404 frame->SetFrameElement(fe);
3406 comp->GetList()->Add(fe);
3407 }
3408 delete fe->fLayout;
3410
3412 fStop = kTRUE;
3413
3414 fBuilder->AddMacro(fname.Data(), img);
3415 } else {
3416 Int_t retval;
3417 TString msg = TString::Format("file (%s) must have extension .C", fname.Data());
3418
3419 new TGMsgBox(fClient->GetDefaultRoot(), frame, "Error...", msg.Data(),
3421
3422 if (retval == kMBRetry) {
3423 return SaveFrame();
3424 }
3425 }
3426
3427out:
3429 return kTRUE;
3430}
3431/*
3432////////////////////////////////////////////////////////////////////////////////
3433/// Not used yet. Return 0 if all child frames are inside area x,y, w,h
3434
3435static Int_t canResize(TGFrame *frame, Int_t x, Int_t y, UInt_t &w, UInt_t &h)
3436{
3437 if (frame->InheritsFrom(TGCompositeFrame::Class())) return 0;
3438
3439 TGCompositeFrame *comp = (TGCompositeFrame*)frame;
3440
3441 TIter next(comp->GetList());
3442 TGFrameElement *fe;
3443 Int_t d = gGuiBldDragManager->GetGridStep();
3444 Int_t ret = 0;
3445
3446 while ((fe = (TGFrameElement*)next())) {
3447 if (x + fe->fFrame->GetX() + fe->fFrame->GetWidth() > w) {
3448 w = fe->fFrame->GetX() + x + fe->fFrame->GetWidth();
3449 ret |= 4;
3450 }
3451 if (y + fe->fFrame->GetY() + fe->fFrame->GetHeight() > h) {
3452 h = fe->fFrame->GetY() + y + fe->fFrame->GetHeight();
3453 ret |= 8;
3454 }
3455 }
3456 return ret;
3457}
3458*/
3459
3460////////////////////////////////////////////////////////////////////////////////
3461/// handle resize
3462
3464{
3465 if (fStop || !fClient->IsEditable()) {
3466 return;
3467 }
3468
3469 TGFrame *fr = fPimpl->fGrab;
3470
3471 if (!fr || IsFixedSize(fr) ||
3472 IsFixedLayout((TGWindow*)fr->GetParent())) {
3473
3474 fr = (TGFrame*)GetResizableParent(fr);
3475
3476 if (!fr ) {
3477 return;
3478 }
3479 }
3480
3482
3484 comp = (TGCompositeFrame*)fr;
3485 }
3486
3487 Window_t c;
3488 Int_t x = fPimpl->fX;
3489 Int_t y = fPimpl->fY;
3490 UInt_t w = 0;
3491 UInt_t h = 0;
3492 UInt_t wp = ((TGFrame*)fr->GetParent())->GetWidth() - 2;
3493 UInt_t hp = ((TGFrame*)fr->GetParent())->GetHeight() - 2;
3494
3495 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
3496 fr->GetId(), x, y, x, y, c);
3497
3498 ToGrid(x, y);
3499 HighlightCompositeFrame(fr->GetParent()->GetId());
3500
3501 switch (fPimpl->fResizeType) {
3502 case kTopLeft:
3503 if ((((int)fr->GetWidth() > x) || (x < 0)) &&
3504 (((int)fr->GetHeight() > y) || (y < 0))) {
3505
3506 if (fr->GetY() + y < 2) {
3507 y = 2 - fr->GetY();
3508 }
3509 if (fr->GetX() + x < 2) {
3510 x = 2 - fr->GetX();
3511 }
3512 h = fr->GetHeight() - y;
3513 w = fr->GetWidth() - x;
3514 x = fr->GetX() + x;
3515 y = fr->GetY() + y;
3516
3517 if (!IsFixedH(fr) && !IsFixedW(fr)) {
3518 fr->MoveResize(x, y, w, h);
3519 break;
3520 }
3521 if (IsFixedH(fr)) {
3522 fr->MoveResize(x, fr->GetY(), w, fr->GetDefaultHeight());
3523 break;
3524 }
3525 if (IsFixedW(fr)) {
3526 fr->MoveResize(fr->GetX(), y, fr->GetDefaultWidth(), h);
3527 break;
3528 }
3529 }
3530 break;
3531 case kTopRight:
3532 if ((x > 0) && (((int)fr->GetHeight() > y) || (y < 0))) {
3533
3534 if (fr->GetY() + y < 2) {
3535 y = 2 - fr->GetY();
3536 }
3537 h = fr->GetHeight() - y;
3538
3539 if (IsFixedW(fr)) {
3540 w = fr->GetDefaultWidth();
3541 } else {
3542 w = fr->GetX() + x > Int_t(wp) ? wp - fr->GetX() : UInt_t(x);
3543 }
3544 x = fr->GetX();
3545 y = fr->GetY() + y;
3546
3547 if (!IsFixedH(fr)) {
3548 fr->MoveResize(x, y, w, h);
3549 } else {
3550 fr->Resize(x, fr->GetDefaultHeight());
3551 }
3552 }
3553 break;
3554 case kTopSide:
3555 if (((int)fr->GetHeight() > y) || (y < 0)) {
3556 if (IsFixedH(fr)) {
3557 break;
3558 }
3559
3560 if (fr->GetY() + y < 2) {
3561 y = 2 - fr->GetY();
3562 }
3563 h = fr->GetHeight() - y;
3564 w = fr->GetWidth();
3565 x = fr->GetX();
3566 y = fr->GetY() + y;
3567
3568 fr->MoveResize(x, y, w, h);
3569 }
3570 break;
3571 case kBottomLeft:
3572 if ((((int)fr->GetWidth() > x) || (x < 0)) && (y > 0)) {
3573
3574 if (fr->GetX() + x < 2) {
3575 x = 2 - fr->GetX();
3576 }
3577 h = fr->GetY() + y > Int_t(hp) ? hp - fr->GetY() : UInt_t(y);
3578 w = fr->GetWidth() - x;
3579 x = fr->GetX() + x;
3580
3581 if (!IsFixedH(fr) && !IsFixedW(fr)) {
3582 fr->MoveResize(x, fr->GetY(), w, h);
3583 break;
3584 }
3585 if (IsFixedH(fr)) {
3586 fr->MoveResize(x, fr->GetY(), w, fr->GetDefaultHeight());
3587 break;
3588 }
3589 if (IsFixedW(fr)) {
3590 fr->MoveResize(fr->GetX(), fr->GetY(),
3591 fr->GetDefaultWidth(), h);
3592 break;
3593 }
3594 }
3595 break;
3596 case kBottomRight:
3597 if ((x > 0) && (y > 0)) {
3598 w = !IsFixedW(fr) ? UInt_t(x) : fr->GetDefaultWidth();
3599 h = !IsFixedH(fr) ? UInt_t(y) : fr->GetDefaultHeight();
3600
3601 h = fr->GetY() + h > hp ? hp - fr->GetY() : h;
3602 w = fr->GetX() + w > wp ? wp - fr->GetX() : w;
3603
3604 //canResize(comp, 0, 0, w, h);
3605 fr->Resize(w, h);
3606 }
3607 break;
3608 case kBottomSide:
3609 if (y > 0) {
3610 if (IsFixedH(fr)) {
3611 break;
3612 }
3613
3614 w = fr->GetWidth();
3615 h = fr->GetY() + y > (Int_t)hp ? hp - fr->GetY() : UInt_t(y);
3616
3617 //canResize(comp, 0, 0, w, h);
3618 fr->Resize(w, h);
3619 }
3620 break;
3621 case kLeftSide:
3622 if ((int)fr->GetWidth() > x ) {
3623 if (IsFixedW(fr)) {
3624 break;
3625 }
3626
3627 if (fr->GetX() + x < 2) {
3628 x = 2 - fr->GetX();
3629 }
3630 w = fr->GetWidth() - x;
3631 h = fr->GetHeight();
3632 y = fr->GetY();
3633 x = fr->GetX() + x;
3634
3635 //canResize(comp, x, y, w, h);
3636 fr->MoveResize(x, y, w, h);
3637 }
3638 break;
3639 case kRightSide:
3640 if (x > 0) {
3641 if (IsFixedW(fr)) {
3642 break;
3643 }
3644
3645 h = fr->GetHeight();
3646 w = fr->GetX() + x > (Int_t)wp ? wp - fr->GetX() : UInt_t(x);
3647 //canResize(comp, 0, 0, w, h);
3648 fr->Resize(w, h);
3649 }
3650 break;
3651 default:
3652 break;
3653 }
3654 if (comp && (!comp->IsLayoutBroken() || IsFixedLayout(comp))) {
3656 }
3657
3658 gVirtualX->SetCursor(fClient->GetRoot()->GetId(),
3659 gVirtualX->CreateCursor(fPimpl->fResizeType));
3660 w = fr->GetWidth();
3661 h = fr->GetHeight();
3662
3663 if (fBuilder) {
3664 TString str = fr->ClassName();
3665 str += "::";
3666 str += fr->GetName();
3667 str += " resized ";
3668 str += TString::Format("(%d x %d)", w, h);
3669 fBuilder->UpdateStatusBar(str.Data());
3670 }
3671
3672 fClient->NeedRedraw(fr, kTRUE);
3673 DoRedraw();
3674 fEditor->ChangeSelected(fr); //to update the geometry frame after drag resize
3675}
3676
3677////////////////////////////////////////////////////////////////////////////////
3678/// Handle move
3679
3681{
3682 if (fStop || !fPimpl->fGrab || !fClient->IsEditable()) {
3683 return;
3684 }
3685
3686 TGWindow *parent = (TGWindow*)fPimpl->fGrab->GetParent();
3687
3688 // do not remove frame from fixed layout or non-editable parent
3689 if (IsFixedLayout(parent) || IsEditDisabled(parent)) {
3690 return;
3691 }
3692
3693 Int_t x = fPimpl->fX - fPimpl->fXf;
3694 Int_t y = fPimpl->fY - fPimpl->fYf;
3695
3696 static Int_t qq;
3697 static UInt_t w = 0;
3698 static UInt_t h = 0;
3699
3700 if (w == 0) {
3701 gVirtualX->GetWindowSize(gVirtualX->GetDefaultRootWindow(), qq, qq, w, h);
3702 }
3703
3704 //
3705 Bool_t move = (x > 0) && (y > 0) && ((x + fPimpl->fGrab->GetWidth()) < (w - 0)) &&
3706 ((y + fPimpl->fGrab->GetHeight()) < (h - 30));
3707
3708
3709 // we are out of "win32 world"
3710 if (!move && !gVirtualX->InheritsFrom("TGX11")) {
3711 EndDrag();
3712 return;
3713 }
3714
3715 fPimpl->fGrab->Move(x, y);
3716
3717 if (fBuilder) {
3718 //fBuilder->Update();
3719 TString str = fPimpl->fGrab->ClassName();
3720 str += "::";
3721 str += fPimpl->fGrab->GetName();
3722 str += " is moved to absolute position ";
3723 str += TString::Format("(%d , %d)", x, y);
3724 fBuilder->UpdateStatusBar(str.Data());
3725 }
3726
3728}
3729
3730////////////////////////////////////////////////////////////////////////////////
3731/// Return a pointer to the parent mdi frame
3732
3734{
3735 if (fStop || !in) {
3736 return 0;
3737 }
3738
3739 TGFrame *p = in;
3740
3741 while (p && (p != fClient->GetDefaultRoot()) &&
3742 !p->InheritsFrom(TGMainFrame::Class())) {
3743 if (p->InheritsFrom(TGMdiFrame::Class())) {
3744 return p;
3745 }
3746 p = (TGFrame*)p->GetParent();
3747 }
3748 return 0;
3749}
3750
3751////////////////////////////////////////////////////////////////////////////////
3752/// Raise guibuilder's mdi frame.
3753
3755{
3756 if (fStop || !comp) {
3757 return;
3758 }
3759
3760 if (comp && comp->InheritsFrom(TGMdiFrame::Class()) && fBuilder) {
3762 if (mdi) {
3763 // dragged frame is taken from some main frame
3764 //if (fPimpl->fGrab && fClient->GetRoot()->InheritsFrom(TGMainFrame::Class())) {
3765 // fBuilder->MapRaised();
3766 //}
3767 }
3768 if (fBuilder->GetMdiMain()->GetCurrent() != comp) {
3770 }
3771 }
3772}
3773
3774////////////////////////////////////////////////////////////////////////////////
3775/// Look for the drop target under grabbed/selected frame while moving
3776
3778{
3779 if (fStop || !fPimpl->fGrab ) {
3780 return;
3781 }
3782
3783 Int_t x = fPimpl->fGrab->GetX();
3784 Int_t y = fPimpl->fGrab->GetY();
3787
3788 Bool_t ok = CheckTargetAtPoint(x - 1, y - 1);
3789
3790 if (!ok) {
3791 ok = CheckTargetAtPoint(x + w + 1, y + h + 1);
3792 }
3793
3794 if (!ok) {
3795 ok = CheckTargetAtPoint(x + w + 1, y - 1);
3796 }
3797
3798 if (!ok) {
3799 CheckTargetAtPoint(x - 1, y + h + 1);
3800 }
3801}
3802
3803////////////////////////////////////////////////////////////////////////////////
3804/// Helper. Look for the drop target under grabbed/selected frame while moving.
3805
3807{
3808 if (fStop || !fPimpl->fGrab) {
3809 return kFALSE;
3810 }
3811
3812 UInt_t ww = fPimpl->fGrab->GetWidth();
3814 Bool_t ret = kFALSE;
3815 Window_t c;
3816 TGWindow *win = 0;
3817
3819
3820 if (w && (w != gVirtualX->GetDefaultRootWindow())) {
3823
3824 if (!win) {
3825 goto out;
3826 }
3827
3828 if (win->InheritsFrom(TGCompositeFrame::Class())) {
3830 } else if (win->GetParent() != fClient->GetDefaultRoot()) {
3831 comp = (TGCompositeFrame *)win->GetParent();
3832 }
3833
3834 if (comp) {
3835 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
3836 comp->GetId(), x, y, x, y, c);
3837
3839
3840 if ((comp != fPimpl->fGrab) && (x >= 0) && (y >= 0) &&
3841 (x + ww <= comp->GetWidth()) &&
3842 (y + hh <= comp->GetHeight())) {
3843
3844 if (comp != fTarget) {
3845 comp->HandleDragEnter(fPimpl->fGrab);
3846
3848
3849 else Snap2Grid();
3850 } else {
3851 if (fTarget) {
3853 }
3854 }
3855
3856 fTarget = comp;
3857 fTargetId = comp->GetId();
3858 ret = kTRUE;
3859 return ret;
3860
3861 } else {
3862 if (fTarget) {
3864 }
3865 fTarget = 0;
3866 fTargetId = 0;
3867 }
3868 }
3869 }
3870
3871out:
3872 if (fTarget) {
3874 }
3875
3876 if (!w || !win) {
3877 fTarget = 0;
3878 fTargetId = 0;
3879 }
3880 return ret;
3881}
3882
3883////////////////////////////////////////////////////////////////////////////////
3884/// Handle motion event
3885
3887{
3888 if (fStop) {
3889 return kFALSE;
3890 }
3891
3892 static Long64_t was = gSystem->Now();
3893 static Int_t gy = event->fYRoot;
3894 static Int_t gx = event->fXRoot;
3895
3896 Long64_t now = gSystem->Now();
3897
3898 if ((now-was < 100) || !(event->fState & kButton1Mask) ||
3899 ((event->fYRoot == gy) && (event->fXRoot == gx))) {
3900 return kFALSE;
3901 }
3902
3903 was = now;
3904 gy = event->fYRoot;
3905 gx = event->fXRoot;
3906
3907 if (!fDragging) {
3908 if (fMoveWaiting && ((std::abs(fPimpl->fX - event->fXRoot) > 10) ||
3909 (std::abs(fPimpl->fY - event->fYRoot) > 10))) {
3910
3911 return StartDrag(fSource, event->fXRoot, event->fYRoot);
3912 }
3913 } else {
3914 fPimpl->fX = event->fXRoot;
3915 fPimpl->fY = event->fYRoot;
3916
3917 switch (fDragType) {
3918 case kDragLasso:
3919 DrawLasso();
3920 fSelectionIsOn = event->fState & kKeyShiftMask;
3921 break;
3922 case kDragMove:
3923 case kDragCopy:
3924 case kDragLink:
3925 DoMove();
3926 break;
3927 case kDragResize:
3928 DoResize();
3929 break;
3930 default:
3931 break;
3932 }
3933 }
3935 return kTRUE;
3936}
3937
3938////////////////////////////////////////////////////////////////////////////////
3939/// Put created frame at position of the last mouse click
3940
3942{
3943 Int_t x0, y0, x, y;
3944 Window_t c;
3945
3946 if (fStop || !frame || !fClient->IsEditable()) {
3947 return;
3948 }
3949
3950 frame->MapSubwindows();
3951 TGFrame *root = (TGFrame*)fClient->GetRoot();
3952
3953 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
3954 root->GetId(),
3955 fPimpl->fX0 , fPimpl->fY0, x0, y0, c);
3956 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
3957 root->GetId(),
3958 fPimpl->fX , fPimpl->fY, x, y, c);
3959
3960 ToGrid(x, y);
3961 ToGrid(x0, y0);
3962
3963 UInt_t w = std::abs(x - x0);
3964 UInt_t h = std::abs(y - y0);
3965 x = x > x0 ? x0 : x;
3966 y = y > y0 ? y0 : y;
3967
3968 // do not create frame with size smaller when default size
3969 w = w < frame->GetDefaultWidth() + 2 ? frame->GetDefaultWidth() + 2 : w;
3970 h = h < frame->GetDefaultHeight() + 2 ? frame->GetDefaultHeight() + 2 : h;
3971
3972 // do not create frame out of editable space
3973 x = x + w > root->GetWidth() ? Int_t(root->GetWidth() - w) : x;
3974 y = y + h > root->GetHeight() ? Int_t(root->GetHeight() - h) : y;
3975
3976 frame->Move(x, y);
3977
3979
3980 if (IsFixedW(frame) || IsFixedH(frame) || IsFixedSize(frame)) {
3981 w = IsFixedW(frame) ? frame->GetDefaultWidth() : w;
3982 h = IsFixedH(frame) ? frame->GetDefaultHeight() : h;
3983 frame->Resize(w < grid ? grid : w, h < grid ? grid : h);
3984 } else {
3985 if (frame->InheritsFrom(TGVerticalFrame::Class())) {
3986 frame->Resize(w < grid ? 15*grid : w, h < grid ? 30*grid : h);
3987 } else if (frame->InheritsFrom(TGHorizontalFrame::Class())) {
3988 frame->Resize(w < grid ? 30*grid : w, h < grid ? 15*grid : h);
3989 }
3990 else frame->Resize(w < 2*grid ? 2*grid : w, h < 2*grid ? 2*grid : h);
3991 }
3992
3993 frame->MapRaised();
3994 frame->SetCleanup(kDeepCleanup);
3995 frame->AddInput(kButtonPressMask);
3996
3997 if (fClient->GetRoot()->InheritsFrom(TGCompositeFrame::Class())) {
3999 edit->SetCleanup(kDeepCleanup);
4000 ReparentFrames(frame, edit);
4001 frame->MapRaised();
4002 //edit->SetLayoutBroken();
4003 UInt_t g = 2;
4004 // temporary hack for status bar
4005 if (frame->InheritsFrom("TGStatusBar")) {
4006 edit->AddFrame(frame, new TGLayoutHints(kLHintsBottom | kLHintsExpandX));
4007 }
4008 else {
4009 edit->AddFrame(frame, hints ? hints : new TGLayoutHints(kLHintsNormal, g, g, g, g));
4010 }
4011
4012 if (hints && !edit->IsLayoutBroken()) {
4013 edit->GetLayoutManager()->Layout();
4014 } else {
4015 edit->Layout();
4016 }
4017 }
4018 if (fBuilder) {
4019 TString str = frame->ClassName();
4020 str += "::";
4021 str += frame->GetName();
4022 str += " created";
4023 fBuilder->UpdateStatusBar(str.Data());
4024 }
4025
4026 if (frame->InheritsFrom(TGCanvas::Class())) {
4027 frame = ((TGCanvas*)frame)->GetContainer();
4028 }
4029
4030 SelectFrame(frame);
4031
4032}
4033////////////////////////////////////////////////////////////////////////////////
4034/// Draw lasso for allocation new object
4035
4037{
4038 if (fStop || !fClient->IsEditable()) {
4039 return;
4040 }
4041
4042 UngrabFrame();
4043
4044 Int_t x0, y0, x, y;
4045 Window_t c;
4046 TGFrame *root = (TGFrame*)fClient->GetRoot();
4047
4048 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(), root->GetId(),
4049 fPimpl->fX0 , fPimpl->fY0, x0, y0, c);
4050 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(), root->GetId(),
4051 fPimpl->fX , fPimpl->fY, x, y, c);
4052
4053 UInt_t w, h;
4056
4057 // check limits
4058
4059 if ((x == x0) || ( y==y0 )) return; //lasso is not rectangle -> do not draw it
4060
4061 if (x > x0) {
4062 x0 = x0 < 0 ? 0 : x0;
4063 w = x - x0;
4064 } else {
4065 x = x < 0 ? 0 : x;
4066 w = x0 - x;
4067 x0 = x;
4068 xswap = kTRUE;
4069 }
4070
4071 if (y > y0) {
4072 y0 = y0 < 0 ? 0 : y0;
4073 h = y - y0;
4074 } else {
4075 y = y < 0 ? 0 : y;
4076 h = y0 - y;
4077 y0 = y;
4078 yswap = kTRUE;
4079 }
4080
4081 w = x0 + w > root->GetWidth() ? root->GetWidth() - x0 : w;
4082 h = y0 + h > root->GetHeight() ? root->GetHeight() - y0 : h;
4083 x = x0 + w;
4084 y = y0 + h;
4085
4086 ToGrid(x, y);
4087 ToGrid(x0, y0);
4088
4089 // correct fPimpl->fX0 , fPimpl->fY0 , fPimpl->fX , fPimpl->fY
4090 gVirtualX->TranslateCoordinates(root->GetId(), fClient->GetDefaultRoot()->GetId(),
4091 xswap ? x : x0, yswap ? y : y0,
4092 fPimpl->fX0 , fPimpl->fY0, c);
4093 gVirtualX->TranslateCoordinates(root->GetId(), fClient->GetDefaultRoot()->GetId(),
4094 xswap ? x0 : x, yswap ? y0 : y,
4095 fPimpl->fX , fPimpl->fY, c);
4096 DoRedraw();
4097
4098 gVirtualX->DrawRectangle(fClient->GetRoot()->GetId(),
4099 GetBlackGC()(), x0, y0, w, h);
4100 gVirtualX->DrawRectangle(fClient->GetRoot()->GetId(),
4101 GetBlackGC()(), x0+1, y0+1, w-2, h-2);
4102
4103 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kCross));
4104 gVirtualX->SetCursor(fClient->GetRoot()->GetId(), gVirtualX->CreateCursor(kCross));
4105
4107 root->RequestFocus();
4108
4109 if (fBuilder) {
4110 TString str = "Lasso drawn. Align frames inside or press Return key to grab frames.";
4111 fBuilder->UpdateStatusBar(str.Data());
4112 }
4113}
4114
4115////////////////////////////////////////////////////////////////////////////////
4116/// Handle client message
4117
4119{
4120 if (fStop) {
4121 return kFALSE;
4122 }
4123
4124 if ((event->fFormat == 32) && ((Atom_t)event->fUser[0] == gWM_DELETE_WINDOW) &&
4125 (event->fHandle != gROOT_MESSAGE)) {
4126
4127 if (fPimpl->fPlane && (fPimpl->fPlane->GetId() == event->fWindow)) {
4128 fPimpl->fPlane = 0;
4129 }
4130
4131 TGWindow *root = (TGWindow*)fClient->GetRoot();
4132 if (!root || (root == fClient->GetDefaultRoot())) {
4134 return kTRUE;
4135 }
4137
4138 if (event->fWindow == main->GetId()) {
4139 if (main != fBuilder) {
4140 if (fEditor && !fEditor->IsEmbedded()) {
4141 delete fEditor;
4142 fEditor = 0;
4143 }
4144
4146 return kTRUE;
4147 }
4148
4149 delete fFrameMenu;
4150 fFrameMenu =0;
4151
4152 delete fLassoMenu;
4153 fLassoMenu = 0;
4154
4155 delete fPimpl->fGrid;
4156 fPimpl->fGrid = 0;
4157 Reset1();
4158
4159 } else if (fBuilder && (event->fWindow == fBuilder->GetId())) {
4161
4162 } else if (fEditor && (event->fWindow == fEditor->GetMainFrame()->GetId())) {
4164 fEditor = 0;
4165 }
4166
4167 // to avoid segv. stop editting
4169 }
4170
4171 return kFALSE;
4172}
4173
4174////////////////////////////////////////////////////////////////////////////////
4175/// Handle destroy notify
4176
4178{
4179 if (fPimpl->fPlane && (fPimpl->fPlane->GetId() == event->fWindow)) {
4180 fPimpl->fPlane = 0;
4181 }
4182
4183 return kFALSE;
4184}
4185
4186
4187////////////////////////////////////////////////////////////////////////////////
4188/// not used yet.
4189
4191{
4192 if (fStop) {
4193 return kFALSE;
4194 }
4195
4196 return kFALSE;
4197}
4198
4199////////////////////////////////////////////////////////////////////////////////
4200/// not used yet.
4201
4203{
4204 if (fStop) {
4205 return kFALSE;
4206 }
4207
4208 return kFALSE;
4209}
4210
4211////////////////////////////////////////////////////////////////////////////////
4212/// Find parent frame which can be dragged
4213
4215{
4216 if (fStop) {
4217 return 0;
4218 }
4219
4220 TGFrame *ret = (TGFrame*)p;
4221 TGWindow *parent = (TGWindow*)ret->GetParent();
4222
4223 while (parent && (parent != fClient->GetDefaultRoot())) {
4224 if (!IsFixedLayout(parent) && !IsEditDisabled(parent)) {
4225 return ret;
4226 }
4227 ret = (TGFrame*)parent;
4228 parent = (TGWindow*)ret->GetParent();
4229 }
4230
4231 return 0;
4232}
4233
4234////////////////////////////////////////////////////////////////////////////////
4235/// Find parent frame which can be resized
4236
4238{
4239 if (fStop) {
4240 return 0;
4241 }
4242
4243 TGWindow *parent = p;
4244
4245 while (parent && (parent != fClient->GetDefaultRoot())) {
4246 if (!IsFixedSize(parent) &&
4247 !IsFixedLayout((TGWindow*)parent->GetParent()) &&
4248 !IsEditDisabled((TGWindow*)parent->GetParent())) {
4249 return parent;
4250 }
4251 parent = (TGWindow*)parent->GetParent();
4252 }
4253
4254 return 0;
4255}
4256
4257////////////////////////////////////////////////////////////////////////////////
4258/// Start dragging.
4259
4261{
4262 if (fStop || fDragging) {
4263 return kFALSE;
4264 }
4265
4266 TGFrame *mov = src;
4267
4268 // special case when frame was grabbed via spacebar pressing
4270 if (fDragType == kDragNone) {
4273 } else {
4275 }
4276 }
4277
4278 TGWindow *parent = (TGWindow*)(mov ? mov->GetParent() : 0);
4279
4280 // do not remove frame from fixed layout or non-editable parent
4281 // try to drag "draggable parent"
4282 if (parent && (IsFixedLayout(parent) || IsEditDisabled(parent))) {
4283 mov = GetMovableParent(parent);
4284 if (!mov) {
4285 return kFALSE;
4286 }
4287 }
4288
4289 SetEditable(kTRUE); // grab server
4290
4291 fPimpl->fX = x;
4292 fPimpl->fY = y;
4294
4297
4299 fDragging = kTRUE;
4300 if (src) gVirtualX->SetCursor(src->GetId(), gVirtualX->CreateCursor(kMove));
4301
4302 switch (fDragType) {
4303 case kDragCopy:
4304 HandleCopy();
4305 HandlePaste();
4307 break;
4308 case kDragMove:
4309 fPimpl->fGrab = mov;
4311 break;
4312 default:
4313 //fPimpl->fGrab = 0;
4314 break;
4315 }
4316
4317 return kTRUE;
4318}
4319
4320////////////////////////////////////////////////////////////////////////////////
4321/// End dragging.
4322
4324{
4325 TGFrame *frame = 0;
4326 Bool_t ret = kFALSE;
4327
4328 if (fStop) {
4329 return kFALSE;
4330 }
4331
4332 fMoveWaiting = kFALSE; // for sanity check
4333
4334 if (fPimpl->fGrab && (fDragType >= kDragMove) && (fDragType <= kDragLink)) {
4335
4336 ret = Drop();
4337
4338 } else if (fBuilder && fBuilder->IsExecutable() &&
4340
4341 frame = (TGFrame*)fBuilder->ExecuteAction();
4342 PlaceFrame(frame, fBuilder->GetAction()->fHints);
4344 ret = kTRUE;
4345 //return ret;
4346 } else if ((fDragType == kDragLasso) && fSelectionIsOn) {
4347
4349 ret = kTRUE;
4350 }
4351
4352 if (!fLassoDrawn) {
4353 DoRedraw();
4354 }
4355
4356 Reset1();
4358
4359 if (fBuilder) {
4360 fBuilder->SetAction(0);
4361 }
4362
4363 return ret;
4364}
4365
4366////////////////////////////////////////////////////////////////////////////////
4367/// Do cancel action.
4368
4370{
4371 if (fStop) {
4372 return kFALSE;
4373 }
4374
4375 fTarget = 0;
4376 EndDrag();
4377 return kTRUE;
4378}
4379
4380////////////////////////////////////////////////////////////////////////////////
4381/// Drop grabbed frame
4382
4384{
4385 if (fStop || !fDragging || !fPimpl->fGrab ||
4386 !((fDragType >= kDragMove) && (fDragType <= kDragLink))) {
4387 return kFALSE;
4388 }
4389
4391 TGFrame *frame = 0;
4392 TGFrame *parent = 0;
4393 Int_t x, y;
4394 Window_t c;
4395
4396 switch (fDragType) {
4397 case kDragCopy:
4398 case kDragMove:
4399 frame = (TGFrame*)fPimpl->fGrab;
4400 break;
4401 default:
4402 break;
4403 }
4404
4406
4407 if (fTarget && fPimpl->fGrab && (w == fTarget) && w &&
4408 (w != fClient->GetDefaultRoot())) {
4409 parent = fTarget;
4410
4411 gVirtualX->TranslateCoordinates(fClient->GetDefaultRoot()->GetId(),
4412 fTarget->GetId(),
4413 fPimpl->fGrab->GetX(),
4414 fPimpl->fGrab->GetY(), x, y, c);
4416 } else {
4417 parent = (TGFrame*)fPimpl->fGrabParent;
4418 x = fPimpl->fGrabX;
4419 y = fPimpl->fGrabY;
4420 }
4421
4422 //reject move if layout is on
4423 if (parent && !parent->IsLayoutBroken() && (parent == fPimpl->fGrabParent) ) {
4424 fDropStatus = 0;
4425 } else if (parent && frame && (parent != fClient->GetDefaultRoot()) ) {
4426 ToGrid(x, y);
4427 fDropStatus = parent->HandleDragDrop(frame, x, y, fPimpl->fGrabLayout);
4428
4429 // drop was rejected
4430 if (!fDropStatus) {
4431 if (fDragType == kDragMove) { // return dragged frame to initial position
4432 parent = (TGFrame*)fPimpl->fGrabParent;
4433 x = fPimpl->fGrabX;
4434 y = fPimpl->fGrabY;
4435 frame = fPimpl->fGrab;
4436
4437 if (parent && frame && (parent != fClient->GetDefaultRoot())) {
4438 fDropStatus = parent->HandleDragDrop(frame, x, y, fPimpl->fGrabLayout);
4439 }
4440 } else { // (fDragType == kDragCopy) - delete it
4441 DeleteFrame(frame);
4442 }
4443 }
4444 }
4445
4446 if (fDropStatus) {
4447 //do not break layout of the new parent if layout there is enabled
4448 if (parent && !parent->IsLayoutBroken()) {
4449 parent->Layout();
4450 }
4451
4452 if (fBuilder) {
4453 TString str = frame->ClassName();
4454 str += "::";
4455 str += frame->GetName();
4456 str += " dropped into ";
4457 str += parent->ClassName();
4458 str += "::";
4459 str += parent->GetName();
4460 str += " at position ";
4461 str += TString::Format("(%d , %d)", x, y);
4462 fBuilder->UpdateStatusBar(str.Data());
4463 }
4464 fTarget = 0;
4465 fTargetId = 0;
4466
4467 if (parent && (parent == fPimpl->fGrabParent) && fPimpl->fGrabListPosition &&
4468 frame && parent->InheritsFrom(TGCompositeFrame::Class())) {
4469
4470 TList *li = ((TGCompositeFrame*)parent)->GetList();
4471 li->Remove(frame->GetFrameElement());
4472 li->AddAfter(fPimpl->fGrabListPosition, frame->GetFrameElement());
4473 }
4474 } else { // grab frame cannot be dropped
4475// if (fDragType == kDragCopy) { // doesn't work (point is not reached ???)
4476// HandleDelete(kFALSE);
4477// }
4478
4479 if (fPimpl->fGrab && fPimpl->fGrabParent) {
4482 }
4483 }
4484
4485 fPimpl->fGrabParent = 0;
4486 fPimpl->fGrabX = 0;
4487 fPimpl->fGrabY = 0;
4489
4490 return fDropStatus;
4491}
4492
4493////////////////////////////////////////////////////////////////////////////////
4494/// Waits for either the mouse move from the given initial ButtonPress location
4495/// or for the mouse button to be released. If mouse moves away from the initial
4496/// ButtonPress location before the mouse button is released "IsMoveWaiting"
4497/// returns kTRUE. If the mouse button released before the mose moved from the
4498/// initial ButtonPress location, "IsMoveWaiting" returns kFALSE.
4499
4504
4505////////////////////////////////////////////////////////////////////////////////
4506/// Layout and Resize frame.
4507/// If global is kFALSE - compact selected frame
4508/// If global is kFALSE - compact main frame of selected frame
4509
4511{
4514
4515 if (fStop || !fClient || !fClient->IsEditable() || !fPimpl->fGrab) {
4516 return;
4517 }
4518
4519 TGWindow *parent = (TGWindow*)fPimpl->fGrab->GetParent();
4520
4521 if (global) {
4522 if (!fBuilder) {
4523 comp = (TGCompositeFrame*)fClient->GetRoot()->GetMainFrame();
4524 } else {
4526 if (!comp) {
4527 comp = (TGCompositeFrame*)fClient->GetRoot()->GetMainFrame();
4528 }
4529 }
4530 } else {
4531 if (fPimpl->fGrab &&
4534 } else {
4535 comp = (TGCompositeFrame*)parent;
4536 }
4537 }
4538
4539 if (!comp || IsFixedLayout(comp) || IsFixedLayout(parent) ||
4540 IsFixedSize(comp) || IsFixedH(comp) || IsFixedW(comp)) return;
4541
4542 comp->SetLayoutBroken(kFALSE);
4543
4544 TIter next(comp->GetList());
4545
4546 TGFrame *root = (TGFrame *)fClient->GetRoot();
4547 root->SetEditable(kFALSE);
4548
4549 TGDimension d;
4550
4551 if (global) {
4552 while ((fe = (TGFrameElement*)next())) {
4553 if (IsFixedLayout(fe->fFrame) || IsFixedSize(fe->fFrame) ||
4554 IsFixedH(fe->fFrame) || IsFixedW(fe->fFrame)) continue;
4555
4556 fe->fFrame->SetLayoutBroken(kFALSE);
4557 d = fe->fFrame->GetDefaultSize();
4558
4559 // avoid "to point" resizing
4560 if ((d.fWidth > 10) && (d.fHeight > 10)) {
4561 fe->fFrame->Resize();
4562 } else if (d.fWidth > 10) {
4563 fe->fFrame->Resize(d.fWidth, 10);
4564 } else if (d.fHeight > 10) {
4565 fe->fFrame->Resize(10, d.fHeight);
4566 } else {
4567 fe->fFrame->Resize(10, 10);
4568 }
4569 fClient->NeedRedraw(fe->fFrame);
4570 }
4571 if (!IsFixedLayout(root)) {
4572 root->SetLayoutBroken(kFALSE);
4573 }
4575 }
4576
4577 if (!IsFixedLayout(comp)) {
4578 comp->SetLayoutBroken(kFALSE);
4579 d = comp->GetDefaultSize();
4580
4581 // avoid "to point" resizing
4582 if ((d.fWidth > 10) && (d.fHeight > 10)) {
4583 comp->Resize();
4584 } else if (d.fWidth > 10) {
4585 comp->Resize(d.fWidth, 10);
4586 } else if (d.fHeight > 10) {
4587 comp->Resize(10, d.fHeight);
4588 } else {
4589 comp->Resize(10, 10);
4590 }
4592 }
4593
4594 if (comp->GetParent()->InheritsFrom(TGMdiDecorFrame::Class())) {
4595 TGMdiDecorFrame *decor = (TGMdiDecorFrame *)comp->GetParent();
4596 Int_t b = 2 * decor->GetBorderWidth();
4597 decor->MoveResize(decor->GetX(), decor->GetY(), comp->GetDefaultWidth() + b,
4598 comp->GetDefaultHeight() + b + decor->GetTitleBar()->GetDefaultHeight());
4599 }
4600
4601 root->SetEditable(kTRUE);
4602
4605 DoRedraw();
4606}
4607
4608////////////////////////////////////////////////////////////////////////////////
4609/// Grab server.
4610
4612{
4613 static Bool_t gon = kFALSE;
4614 static const TGWindow *gw = 0;
4615
4616 if ((gon == on) && (fClient->GetRoot() == gw)) {
4617 return;
4618 }
4619
4620 gon = on; gw = fClient->GetRoot();
4621
4622 if (on) {
4623 fStop = kFALSE;
4624
4625 if (fPimpl->fRepeatTimer) {
4627 } else {
4629 }
4632
4633 Snap2Grid();
4634 } else {
4636
4637 if (fPimpl->fRepeatTimer) {
4639 }
4640
4641 fSelected = fPimpl->fGrab = 0;
4642
4643 delete fPimpl->fGrid;
4644 fPimpl->fGrid = 0;
4645
4647
4648 TGWindow *root = (TGWindow*)fClient->GetRoot();
4649 if (root) {
4650 fClient->SetRoot(0);
4651 }
4652
4655 }
4656
4659 }
4660
4661 if (fBuilder) {
4662 fBuilder->Update();
4663 }
4664 //CloseMenus();
4665
4666 fStop = kTRUE;
4667 }
4668
4669 if (on && fClient->IsEditable()) {
4670 gVirtualX->SetCursor(fClient->GetRoot()->GetId(),
4671 gVirtualX->CreateCursor(kPointer));
4672 }
4673}
4674
4675////////////////////////////////////////////////////////////////////////////////
4676/// Return grid coordinates which are close to given
4677
4679{
4680 UInt_t step = GetGridStep();
4681 x = x - x%step;
4682 y = y - y%step;
4683}
4684
4685////////////////////////////////////////////////////////////////////////////////
4686/// Main handler of actions
4687
4689{
4691
4692 switch ((EActionType)act) {
4693 case kPropertyAct:
4695 break;
4696 case kEditableAct:
4698 if (fBuilder) {
4700 }
4701 break;
4702 case kCutAct:
4703 HandleCut();
4704 break;
4705 case kCopyAct:
4706 HandleCopy();
4707 break;
4708 case kPasteAct:
4709 HandlePaste();
4710 break;
4711 case kCropAct:
4713 break;
4714 case kCompactAct:
4715 Compact(kFALSE);
4716 break;
4717 case kCompactGlobalAct:
4718 Compact(kTRUE);
4719 break;
4720 case kDropAct:
4722 break;
4723 case kLayUpAct:
4725 break;
4726 case kLayDownAct:
4728 break;
4729 case kCloneAct:
4730 CloneEditable();
4731 break;
4732 case kGrabAct:
4734 break;
4735 case kDeleteAct:
4737 break;
4738 case kLeftAct:
4740 break;
4741 case kRightAct:
4743 break;
4744 case kUpAct:
4746 break;
4747 case kDownAct:
4749 break;
4750 case kEndEditAct:
4751 if (fBuilder) {
4753 }
4755 break;
4756 case kReplaceAct:
4757 HandleReplace();
4758 break;
4759 case kGridAct:
4760 HandleGrid();
4761 break;
4762 case kBreakLayoutAct:
4763 BreakLayout();
4764 break;
4765 case kSwitchLayoutAct:
4766 case kLayoutVAct:
4767 case kLayoutHAct:
4768 SwitchLayout();
4769 break;
4770 case kNewAct:
4771 if (fBuilder) {
4773 } else {
4774 TGMainFrame *main = new TGMainFrame(fClient->GetDefaultRoot(), 300, 300);
4775 main->MapRaised();
4776 main->SetEditable(kTRUE);
4777 }
4778 break;
4779 case kOpenAct:
4780 if (fBuilder) {
4782 } else {
4783 TGMainFrame *main = new TGMainFrame(fClient->GetDefaultRoot(), 300, 300);
4784 main->MapRaised();
4785 main->SetEditable(kTRUE);
4786 }
4787 break;
4788 case kSaveAct:
4789 if (fBuilder) {
4793 } else {
4794 Save();
4795 }
4796 } else {
4797 Save();
4798 }
4799 break;
4800 case kSaveFrameAct:
4801 SaveFrame();
4802 break;
4803 default:
4804 break;
4805 }
4806
4808
4809 if (fBuilder) {
4810 fBuilder->SetAction(0);
4811 //fBuilder->Update();
4812 }
4813
4814 if (fPimpl->fSaveGrab) {
4816 }
4817
4818 DoRedraw();
4819}
4820
4821////////////////////////////////////////////////////////////////////////////////
4822/// kTRUE - if it's possible to switch disable/enable layout
4823
4825{
4826 return (!(w->GetEditDisabled() & kEditDisable) &&
4827 !IsFixedLayout(w) && w->InheritsFrom(TGCompositeFrame::Class()));
4828}
4829
4830////////////////////////////////////////////////////////////////////////////////
4831/// kTRUE - if it's possible to change layout order in the parent's layout of window w
4832
4834{
4835 return (w->GetParent()->InheritsFrom(TGCompositeFrame::Class()) &&
4836 !((TGCompositeFrame*)w->GetParent())->IsLayoutBroken() &&
4837 !IsFixedLayout((TGWindow*)w->GetParent()));
4838}
4839
4840////////////////////////////////////////////////////////////////////////////////
4841/// kTRUE is frame could be compacted/"laid out"
4842
4844{
4845 return CanChangeLayout(w);
4846/*
4847 return (!IsFixedLayout(w) &&
4848 w->InheritsFrom(TGCompositeFrame::Class()) &&
4849 ((TGCompositeFrame*)w)->IsLayoutBroken() &&
4850 !IsEditDisabled((TGWindow*)w->GetParent()) &&
4851 !IsFixedLayout((TGWindow*)w->GetParent()));
4852*/
4853}
4854
4855////////////////////////////////////////////////////////////////////////////////
4856/// Create widget property editor (it could be located outside of guibuilder)
4857
4859{
4860// if (!fPimpl->fClickFrame) return;
4861
4862 TGWindow *root = (TGWindow*)fClient->GetRoot();
4863 root->SetEditable(kFALSE);
4864
4866
4870
4871 root->SetEditable(kTRUE);
4872}
4873
4874////////////////////////////////////////////////////////////////////////////////
4875/// Helper method
4876
4878{
4879 fEditor = e;
4880
4881 if (!fEditor) {
4882 return;
4883 }
4884
4886 fEditor->Connect("UpdateSelected(TGFrame*)", "TGuiBldDragManager", this,
4887 "HandleUpdateSelected(TGFrame*)");
4888}
4889
4890////////////////////////////////////////////////////////////////////////////////
4891/// Change layout order
4892
4894{
4895 if (fStop || !fPimpl->fGrab || !fPimpl->fGrab->GetFrameElement() ||
4897 return;
4898 }
4899
4901 TList *li = comp->GetList();
4903
4904 if (!fe) { // sanity check
4905 return;
4906 }
4907
4908 TGFrame *frame;
4910
4911 if (forward) {
4912 el = (TGFrameElement *)li->After(fe);
4913 if (!el) return;
4914 frame = el->fFrame;
4915
4916 el->fFrame = fPimpl->fGrab;
4918 fe->fFrame = frame;
4919 frame->SetFrameElement(fe);
4920 } else {
4921 el = (TGFrameElement *)li->Before(fe);
4922
4923 if (!el) {
4924 return;
4925 }
4926 frame = el->fFrame;
4927
4928 el->fFrame = fPimpl->fGrab;
4930 fe->fFrame = frame;
4931 frame->SetFrameElement(fe);
4932 }
4933
4934 Bool_t sav = comp->IsLayoutBroken();
4935 comp->SetLayoutBroken(kFALSE);
4936 TGWindow *root = (TGWindow *)fClient->GetRoot();
4937 root->SetEditable(kFALSE);
4938 comp->Layout();
4939 DoRedraw();
4940 root->SetEditable(kTRUE);
4941
4942 if (sav) {
4943 comp->SetLayoutBroken(kTRUE);
4944 }
4945 SelectFrame(el->fFrame);
4946}
4947
4948////////////////////////////////////////////////////////////////////////////////
4949/// Switch on/of grid drawn.
4950
4952{
4953 if (fStop) {
4954 return;
4955 }
4956
4957 TGWindow *root = (TGWindow*)fClient->GetRoot();
4958
4959 if (!root || (root == fClient->GetDefaultRoot())) {
4960 return;
4961 }
4962
4963 if (fPimpl->fGrid->fgStep > 1) {
4964 fPimpl->fGrid->SetStep(1);
4965 if (fBuilder) {
4966 fBuilder->UpdateStatusBar("Grid switched OFF");
4967 }
4968 } else {
4970
4971 if (fBuilder) {
4972 fBuilder->UpdateStatusBar("Grid switched ON");
4973 }
4974
4977 TIter next(comp->GetList());
4979 Int_t x, y, w, h;
4980
4981 while ((fe = (TGFrameElement*)next())) {
4982 x = fe->fFrame->GetX();
4983 y = fe->fFrame->GetY();
4984 w = fe->fFrame->GetWidth();
4985 h = fe->fFrame->GetHeight();
4986 ToGrid(x, y);
4987 ToGrid(w, h);
4988 fe->fFrame->MoveResize(x, y, w, h);
4989 }
4990 }
4991 }
4992
4993 Snap2Grid();
4995}
4996
4997////////////////////////////////////////////////////////////////////////////////
4998/// Helper to find a frame which can be laid out
4999
5001{
5002 if (fStop || !f) {
5003 return 0;
5004 }
5005
5006 const TGWindow *parent = f->GetParent();
5007 TGCompositeFrame *ret = 0;
5008
5009 while (parent && (parent != fClient->GetDefaultRoot())) {
5010 ret = (TGCompositeFrame*)parent;
5011 if (parent->InheritsFrom(TGMdiFrame::Class())) return ret;
5012 parent = parent->GetParent();
5013 }
5014 return ret;
5015}
5016
5017////////////////////////////////////////////////////////////////////////////////
5018/// When selected frame was changed by guibuilder editor -> update its appearance
5019
5021{
5022 if (fStop || !f) {
5023 return;
5024 }
5025
5026 TGCompositeFrame *parent = 0;
5027 if (f->GetParent() &&
5028 f->GetParent()->InheritsFrom(TGCompositeFrame::Class())) {
5029 parent = (TGCompositeFrame*)f->GetParent();
5030 }
5031
5032 if (!parent || !CanChangeLayout(parent)) {
5033 return;
5034 }
5035
5036 Bool_t sav = parent->IsLayoutBroken();
5037 parent->SetLayoutBroken(kFALSE);
5038
5039 if ((parent->GetWidth() < parent->GetDefaultWidth()) ||
5040 (parent->GetHeight() < parent->GetDefaultHeight())) {
5041 parent->Resize(parent->GetDefaultSize());
5042 } else {
5043 parent->Layout();
5044 if (f->InheritsFrom(TGCompositeFrame::Class())) {
5045 layoutFrame(f);
5046 }
5047 }
5048 fClient->NeedRedraw(parent, kTRUE);
5050
5051 if (sav) parent->SetLayoutBroken(kTRUE);
5052
5053 SelectFrame(f);
5054}
5055
5056////////////////////////////////////////////////////////////////////////////////
5057/// Hide/Unmap grab rectangles.
5058
5060{
5061 static Bool_t first = kFALSE;
5062
5063 if (fPimpl->fGrabRectHidden) {
5064 return;
5065 }
5066 // skip very first event
5067 if (!first) {
5068 first = kTRUE;
5069 return;
5070 }
5071 int i = 0;
5072 for (i = 0; i < 8; i++) fPimpl->fGrabRect[i]->UnmapWindow();
5073 for (i = 0; i < 4; i++) fPimpl->fAroundFrame[i]->UnmapWindow();
5075}
5076
5077////////////////////////////////////////////////////////////////////////////////
5078/// Delete widget property editor.
5079
5081{
5082 if (fStop || !fEditor) {
5083 return;
5084 }
5085
5087
5088 delete fEditor;
5089 fEditor = 0;
5090}
5091
5092////////////////////////////////////////////////////////////////////////////////
5093/// Return the X coordinate where drag started
5094
5096{
5097 return fPimpl->fX0;
5098}
5099
5100////////////////////////////////////////////////////////////////////////////////
5101/// Return the Y coordinate where drag started
5102
5104{
5105 return fPimpl->fY0;
5106}
5107
5108////////////////////////////////////////////////////////////////////////////////
5109/// Return the current X coordinate of the dragged frame
5110
5112{
5113 return fPimpl->fY;
5114}
5115
5116////////////////////////////////////////////////////////////////////////////////
5117/// Returns the current Y coordinate of the dragged frame
5118
5120{
5121 return fPimpl->fY;
5122}
5123
5124////////////////////////////////////////////////////////////////////////////////
5125/// Disable/Enable layout for selected/grabbed composite frame.
5126
5128{
5129 if (fStop) {
5130 return;
5131 }
5132
5133 TGFrame *frame = fSelected;
5134
5135 if (!frame) {
5136 return;
5137 }
5138
5139 TString str = frame->ClassName();
5140 str += "::";
5141 str += frame->GetName();
5142
5143 if (IsFixedLayout(frame)) {
5144 if (fBuilder) {
5145 str += " layout cannot be broken";
5146 fBuilder->UpdateStatusBar(str.Data());
5147 }
5148 return;
5149 }
5150
5151 frame->SetLayoutBroken(!frame->IsLayoutBroken());
5153
5154 if (fBuilder) {
5155 str += (frame->IsLayoutBroken() ? " Disable Layout" : " Enable Layout");
5156 fBuilder->UpdateStatusBar(str.Data());
5157 }
5158 if (fPimpl->fGrab && (fPimpl->fGrab->IsA() == TGCanvas::Class())) {
5159 fPimpl->fGrab->Layout();
5160 }
5161}
5162
5163////////////////////////////////////////////////////////////////////////////////
5164/// Switch Horizontal/Vertical layout of selected/grabbed composite frame
5165
5167{
5168 if (fStop || !fPimpl->fGrab) {
5169 return;
5170 }
5171
5173
5174 comp->SetLayoutBroken(kFALSE);
5175
5176 UInt_t opt = comp->GetOptions();
5177 TGLayoutManager *m = comp->GetLayoutManager();
5178
5179 if (!m) {
5180 return;
5181 }
5182
5184 opt &= ~kHorizontalFrame;
5185 opt |= kVerticalFrame;
5186
5187 if (fBuilder) {
5188 TString str = comp->ClassName();
5189 str += "::";
5190 str += comp->GetName();
5191 str += " Vertical Layout ON";
5192 fBuilder->UpdateStatusBar(str.Data());
5193 }
5194 } else if (m->InheritsFrom(TGVerticalLayout::Class())) {
5195 opt &= ~kVerticalFrame;
5196 opt |= kHorizontalFrame;
5197
5198 if (fBuilder) {
5199 TString str = comp->ClassName();
5200 str += "::";
5201 str += comp->GetName();
5202 str += " Horizontal Layout ON";
5203 fBuilder->UpdateStatusBar(str.Data());
5204 }
5205 }
5206
5207 comp->ChangeOptions(opt);
5208 if (!IsFixedSize(comp)) {
5209 comp->Resize();
5210 }
5211
5212 if (fPimpl->fGrab && (fPimpl->fGrab->IsA() == TGCanvas::Class())) {
5213 fPimpl->fGrab->Layout();
5214 }
5215
5218}
5219
5220////////////////////////////////////////////////////////////////////////////////
5221/// Return the current grabbed/selected frame.
5222
5224{
5225 return fSelected;
5226}
5227
5228////////////////////////////////////////////////////////////////////////////////
5229/// Helper to close all menus
5230
5232{
5233 void *ud;
5234
5235 if (fFrameMenu) {
5237 }
5238 if (fLassoMenu) {
5240 }
5241 //UnmapAllPopups();
5242}
5243
5244////////////////////////////////////////////////////////////////////////////////
5245/// Return the parent frame which can be edited.
5246
5248{
5249 if (!fr || (fr == fClient->GetDefaultRoot())) {
5250 return 0;
5251 }
5252
5253 TGWindow *parent = (TGWindow*)fr->GetParent();
5254
5255 while (parent && (parent != fClient->GetDefaultRoot())) {
5256 if (!IsEditDisabled(parent) && !IsGrabDisabled(parent)) {
5257 return (TGFrame*)parent;
5258 }
5259 parent = (TGWindow*)parent->GetParent();
5260 }
5261 return 0;
5262}
5263
5264////////////////////////////////////////////////////////////////////////////////
5265/// Return a name of icon
5266
5268{
5269 Int_t p1 = in.Index("*icon=", 1);
5270 if (p1 == kNPOS) return "";
5271 p1 += 6;
5272 Int_t p2 = in.Index("*", p1);
5273
5274 if (p2 == kNPOS) return "";
5275
5276 return in(p1, p2-p1);
5277}
5278
5279////////////////////////////////////////////////////////////////////////////////
5280/// Helper
5281
5283{
5284 TString str = somestring;
5285
5286 if (str.Contains(cl->GetName())) {
5287 return kTRUE;
5288 }
5289
5291 TBaseClass *bc;
5292
5293 while ((bc = (TBaseClass*)nextBaseClass())) {
5294 if (!bc->GetClassPointer()) {
5295 continue;
5296 }
5297 if (containBaseClass(somestring, bc->GetClassPointer())) {
5298 return kTRUE;
5299 }
5300 }
5301
5302 return kFALSE;
5303}
5304
5305////////////////////////////////////////////////////////////////////////////////
5306/// Add DIALOG entries to the selected frame popup menu
5307
5309{
5310 if (!menu || !object) {
5311 return;
5312 }
5313
5314 TMethod *method;
5315 TIter next(fListOfDialogs);
5316 TString str;
5317 TString pname;
5318 const TGPicture *pic;
5319 TClass *cl = object->IsA();
5320 TString ename;
5321
5322 while ((method = (TMethod*) next())) {
5323 ename = method->GetName();
5324 ename += "...";
5325 if (menu->GetEntry(ename.Data())) {
5326 continue;
5327 }
5328 if (!containBaseClass(method->GetSignature(), cl)) {
5329 continue;
5330 }
5331
5332 str = method->GetCommentString();
5333 pname = FindMenuIconName(str);
5334 pic = fClient->GetPicture(pname.Data());
5335 menu->AddEntry(ename.Data(), kMethodMenuAct, method, pic);
5336 }
5337 menu->AddSeparator();
5338}
5339
5340////////////////////////////////////////////////////////////////////////////////
5341/// Add entries with class //*MENU* methods
5342
5344{
5345 if (!menu || !object) {
5346 return;
5347 }
5348
5351 TString str;
5352 TString pname;
5353 const TGPicture *pic;
5354 TMethod *method;
5355 TClass *classPtr = 0;
5358 TDataMember *m;
5359
5360 AddDialogMethods(menu, object);
5361
5362 menuItemList = object->IsA()->GetMenuList();
5364
5365 fPimpl->fMenuObject = (TGFrame*)object;
5366 nextItem.Reset();
5367
5368 while ((menuItem = (TClassMenuItem*) nextItem())) {
5369 switch (menuItem->GetType()) {
5371 {
5372 // Standard list of class methods. Rebuild from scratch.
5373 // Get linked list of objects menu items (i.e. member functions
5374 // with the token *MENU in their comment fields.
5375 methodList = new TList;
5376 object->IsA()->GetMenuItems(methodList);
5377
5378 TIter next(methodList);
5379
5380 while ((method = (TMethod*) next())) {
5381 if (classPtr != method->GetClass()) {
5382// menu->AddSeparator();
5383 classPtr = method->GetClass();
5384 }
5385
5386 menuKind = method->IsMenuItem();
5387
5388 switch (menuKind) {
5389 case kMenuDialog:
5390 {
5391 str = method->GetCommentString();
5392 pname = FindMenuIconName(str);
5393 pic = fClient->GetPicture(pname.Data());
5394 menu->AddEntry(method->GetName(), kMethodMenuAct, method, pic);
5395 break;
5396 }
5397
5398 case kMenuSubMenu:
5399 if ((m = method->FindDataMember())) {
5400 if (m->GetterMethod()) {
5402 menu->AddPopup(method->GetName(), r);
5404 TIter nxt(m->GetOptions());
5405 TOptionListItem *it;
5406
5407 while ((it = (TOptionListItem*) nxt())) {
5408 const char *name = it->fOptName;
5409 Long_t val = it->fValue;
5410
5411 TToggle *t = new TToggle;
5412 t->SetToggledObject(object, method);
5413 t->SetOnValue(val);
5415
5416 //r->AddSeparator();
5417 r->AddEntry(name, kToggleMenuAct, t);
5418 if (t->GetState()) r->CheckEntryByData(t);
5419 }
5420 } else {
5421 menu->AddEntry(method->GetName(), kMethodMenuAct, method);
5422 }
5423 }
5424 break;
5425
5426 case kMenuToggle:
5427 {
5428 TToggle *t = new TToggle;
5429 t->SetToggledObject(object, method);
5430 t->SetOnValue(1);
5432 menu->AddEntry(method->GetName(), kToggleMenuAct, t);
5433 if (t->GetState()) menu->CheckEntryByData(t);
5434 }
5435 break;
5436
5437 default:
5438 break;
5439 }
5440 }
5441 delete methodList;
5442 }
5443 break;
5445 {
5446 if (menuItem->IsToggle()) {
5447 TMethod* method2 =
5448 object->IsA()->GetMethodWithPrototype(menuItem->GetFunctionName(),
5449 menuItem->GetArgs());
5450 if (method2) {
5451 TToggle *t = new TToggle;
5452 t->SetToggledObject(object, method2);
5453 t->SetOnValue(1);
5455
5456 menu->AddEntry(method2->GetName(), kToggleMenuAct, t);
5457 if (t->GetState()) menu->CheckEntryByData(t);
5458 }
5459 } else {
5460 const char* menuItemTitle = menuItem->GetTitle();
5461 if (strlen(menuItemTitle)==0) menuItemTitle = menuItem->GetFunctionName();
5463 }
5464 }
5465
5466 break;
5467 default:
5468 break;
5469 }
5470 }
5471}
5472
5473////////////////////////////////////////////////////////////////////////////////
5474/// Process a method chosen via frame context menu
5475
5477{
5478 if (!fFrameMenu || ((id != kMethodMenuAct) && (id != kToggleMenuAct))) {
5479 return;
5480 }
5481
5482 TGMenuEntry *me = 0;
5483
5484 if (id == kMethodMenuAct) {
5485 delete gMenuDialog;
5486 me = fFrameMenu->GetCurrent();
5487
5488 if (!me || !fPimpl->fMenuObject) {
5489 return;
5490 }
5491 TMethod *method = (TMethod*)me->GetUserData();
5492 TString str = method->GetCommentString();
5493
5494 if (str.Contains("*DIALOG")) {
5495 TString str2;
5496 str2.Form("((TGuiBldDragManager*)0x%zx)->%s((%s*)0x%zx)", (size_t)this, method->GetName(),
5498 gCling->Calc((char *)str2.Data());
5499 //delete fFrameMenu; // suicide (BB)?
5500 //fFrameMenu = 0;
5501 return;
5502 }
5504 gMenuDialog->Popup();
5505
5506 } else if (id == kToggleMenuAct) {
5507 me = fFrameMenu->GetCurrent();
5508 if (!me) {
5509 return;
5510 }
5511 TGPopupMenu *menu = me->GetPopup();
5512 TToggle *toggle = 0;
5513
5514 if (menu) { //process submenu
5515 toggle = (TToggle*)menu->GetCurrent()->GetUserData();
5516 } else { //process check entry
5517 toggle = (TToggle*)fFrameMenu->GetCurrent()->GetUserData();
5518 }
5519 if (toggle) {
5520 toggle->Toggle();
5521 }
5522 }
5523}
5524
5525////////////////////////////////////////////////////////////////////////////////
5526/// Delete dialog and trash
5527
5529{
5531 gMenuDialog->DeleteWindow();
5532 gMenuDialog = 0;
5533 fPimpl->fMenuObject = 0;
5534}
5535
5536////////////////////////////////////////////////////////////////////////////////
5537/// Process dialog OK button pressed
5538
5540{
5541 gMenuDialog->ApplyMethod();
5542 DoRedraw();
5544 gMenuDialog = 0;
5545}
5546
5547////////////////////////////////////////////////////////////////////////////////
5548/// Process dialog Apply button pressed
5549
5551{
5552 gMenuDialog->ApplyMethod();
5553}
5554
5555////////////////////////////////////////////////////////////////////////////////
5556/// Process dialog Cancel button pressed
5557
5563
5564////////////////////////////////////////////////////////////////////////////////
5565/// Create and place context menu for selected frame
5566
5568{
5569 if (fStop) {
5570 return;
5571 }
5572
5574 fPimpl->fX0 = x;
5575 fPimpl->fY0 = y;
5576 fPimpl->fClickFrame = frame;
5577
5579 Bool_t compar = frame->GetParent()->InheritsFrom(TGCompositeFrame::Class());
5580
5581 TGCompositeFrame *cfr = 0;
5583 TGLayoutManager *lm = 0;
5584
5585 if (composite) {
5586 cfr = (TGCompositeFrame *)frame;
5587 lm = cfr->GetLayoutManager();
5588 }
5589 if (compar) {
5590 cfrp = (TGCompositeFrame *)frame->GetParent();
5591 }
5592
5593 delete fFrameMenu;
5594
5596 fFrameMenu->Connect("Activated(Int_t)", "TGuiBldDragManager", this, "DoClassMenu(Int_t)");
5597
5598 TString title = frame->ClassName();
5599 title += "::";
5600 title += frame->GetName();
5601 fFrameMenu->AddLabel(title.Data());
5603
5604 // special case - menu for editable Mdi frame
5605 if (fBuilder && (frame == fBuilder->GetMdiMain()->GetCurrent())) {
5607 fFrameMenu->AddEntry("Paste\tCtrl+V", kPasteAct,
5608 0, fClient->GetPicture("bld_paste.png"));
5609 }
5610 fFrameMenu->AddEntry("Compact\tCtrl+L", kCompactAct,
5611 0, fClient->GetPicture("bld_compact.png"));
5612 fFrameMenu->AddEntry("Grid On/Off\tCtrl+G", kGridAct,
5613 0, fClient->GetPicture("bld_grid.png"));
5614 fFrameMenu->AddEntry("Save As ...\tCtrl+S", kSaveAct,
5615 0, fClient->GetPicture("bld_save.png"));
5616 fFrameMenu->AddEntry("End Edit\tCtrl+DblClick", kEndEditAct,
5617 0, fClient->GetPicture("bld_stop.png"));
5618 goto out;
5619 }
5620
5622
5623 if (!fBuilder) {
5624 fFrameMenu->AddEntry("Gui Builder", kPropertyAct);
5626 }
5627/*
5628 if (!frame->IsEditable() && !InEditable(frame->GetId())) {
5629 fPimpl->fSaveGrab = frame;
5630 goto out;
5631 }
5632*/
5633 if (!IsEditDisabled(cfrp)) {
5635
5636 if (composite && !IsFixedLayout(frame) && cfr->GetList()->GetEntries()) {
5637 fFrameMenu->AddEntry("Drop\tCtrl+Return", kDropAct);
5638 }
5639
5640 if (!IsFixedLayout(cfrp)) {
5641 fFrameMenu->AddEntry("Cut\tCtrl+X", kCutAct,
5642 0, fClient->GetPicture("bld_cut.png"));
5643 }
5644 //
5645 fFrameMenu->AddEntry("Copy\tCtrl+C", kCopyAct,
5646 0, fClient->GetPicture("bld_copy.png"));
5647
5648 if (frame->IsEditable() && !IsFixedLayout(frame) &&
5650 fFrameMenu->AddEntry("Paste\tCtrl+V", kPasteAct,
5651 0, fClient->GetPicture("bld_paste.png"));
5652 }
5653
5654 if (!IsFixedLayout(cfrp)) {
5655 fFrameMenu->AddEntry("Delete\tDel", kDeleteAct,
5656 0, fClient->GetPicture("bld_delete.png"));
5657 }
5658
5659 if (!IsFixedLayout(cfrp)) {
5660 fFrameMenu->AddEntry("Crop\tShift+Del", kCropAct,
5661 0, fClient->GetPicture("bld_crop.png"));
5662 }
5663
5664// if (!IsFixedLayout(cfrp) && !gSystem->AccessPathName(fPasteFileName.Data())) {
5665// fFrameMenu->AddEntry("Replace\tCtrl+R", kReplaceAct,
5666// 0, fClient->GetPicture("bld_paste_into.png"));
5667// }
5668
5670 } else {
5672 fFrameMenu->AddEntry("Paste\tCtrl+V", kPasteAct,
5673 0, fClient->GetPicture("bld_paste.png"));
5674 }
5675 if (frame->GetMainFrame() == frame) {
5676 fFrameMenu->AddEntry("Clone\tCtrl+A", kCloneAct);
5677 }
5679 }
5680
5681 if (CanChangeLayout(frame)) {
5682 const char *label = (frame->IsLayoutBroken() ? "Allow Layout\tCtrl+B" :
5683 "Break Layout\tCtrl+B");
5685 0, fClient->GetPicture("bld_break.png"));
5686 }
5687
5688 if (composite && !cfr->GetList()->IsEmpty()) {
5689 if (CanCompact(frame)) {
5690 if (!frame->IsEditable()) {
5691 fFrameMenu->AddEntry("Compact\tCtrl+L", kCompactAct,
5692 0, fClient->GetPicture("bld_compact.png"));
5693 } else {
5694 fFrameMenu->AddEntry("Compact\tCtrl+L", kCompactGlobalAct,
5695 0, fClient->GetPicture("bld_compact.png"));
5696 }
5697 }
5698
5699 if (lm && ((lm->IsA() == TGVerticalLayout::Class()) ||
5700 (lm->IsA() == TGHorizontalLayout::Class())) && !IsFixedLayout(frame)) {
5701
5702 if (lm->IsA() == TGVerticalLayout::Class()) {
5703 fFrameMenu->AddEntry("Horizontal\tCtrl+H", kSwitchLayoutAct,
5704 0, fClient->GetPicture("bld_hbox.png"));
5705 } else if (lm->IsA() == TGHorizontalLayout::Class()) {
5706 fFrameMenu->AddEntry("Vertical\tCtrl+H", kSwitchLayoutAct,
5707 0, fClient->GetPicture("bld_vbox.png"));
5708 }
5709 }
5710 }
5711
5712 if (compar && (cfrp->GetList()->GetSize() > 1) && CanChangeLayoutOrder(frame)) {
5713 if (cfrp->GetList()->First() != frame->GetFrameElement()) {
5714 fFrameMenu->AddEntry("Lay Up\tUp/Left", kLayUpAct);
5715 }
5716 if (cfrp->GetList()->Last() != frame->GetFrameElement()) {
5717 fFrameMenu->AddEntry("Lay Down\tDown/Right", kLayDownAct);
5718 }
5720 }
5721
5722 if (frame->IsEditable()) {
5723 fFrameMenu->AddEntry("Grid On/Off\tCtrl+G", kGridAct,
5724 0, fClient->GetPicture("bld_grid.png"));
5725 }
5726 if (composite && !cfr->GetList()->IsEmpty()) {
5727 fPimpl->fSaveGrab = frame;
5728 fFrameMenu->AddEntry("Save As ... ", kSaveFrameAct,
5729 0, fClient->GetPicture("bld_save.png"));
5730 }
5731
5732out:
5733 fFrameMenu->Connect("Activated(Int_t)", "TGuiBldDragManager", this, "HandleAction(Int_t)");
5734
5737
5739}
5740
5741////////////////////////////////////////////////////////////////////////////////
5742/// Create context menu for lasso actions.
5743
5745{
5746 if (fStop || !fLassoDrawn) {
5747 return;
5748 }
5749
5750 DrawLasso();
5751
5752 delete fLassoMenu;
5753
5755 fLassoMenu->AddLabel("Edit actions");
5757 fLassoMenu->AddEntry("Grab\tReturn", kGrabAct);
5759 fLassoMenu->AddEntry("Delete\tDelete", kDeleteAct,
5760 0, fClient->GetPicture("bld_delete.png"));
5761 fLassoMenu->AddEntry("Crop\tShift+Delete", kCropAct,
5762 0, fClient->GetPicture("bld_crop.png"));
5764 fLassoMenu->AddEntry("Align Left\tLeft Key", kLeftAct,
5765 0, fClient->GetPicture("bld_AlignLeft.png"));
5766 fLassoMenu->AddEntry("Align Right\tRight Key", kRightAct,
5767 0, fClient->GetPicture("bld_AlignRight.png"));
5768 fLassoMenu->AddEntry("Align Up\tUp Key", kUpAct,
5769 0, fClient->GetPicture("bld_AlignTop.png"));
5770 fLassoMenu->AddEntry("Align Down\tDown Key", kDownAct,
5771 0, fClient->GetPicture("bld_AlignBtm.png"));
5772
5773 fLassoMenu->Connect("Activated(Int_t)", "TGuiBldDragManager", this, "HandleAction(Int_t)");
5774
5778}
5779
5780////////////////////////////////////////////////////////////////////////////////
5781/// Return kTRUE if paste frame exist.
5782
5787
5788////////////////////////////////////////////////////////////////////////////////
5789/// Return pointer to global color dialog. If dialog is not yet created
5790/// and input parameter is kTRUE - the dialog will be created.
5791
5793{
5794 static Int_t retc;
5795 static Pixel_t color;
5796
5797 if (!fgGlobalColorDialog && create) {
5798 fgGlobalColorDialog = new TGColorDialog(gClient->GetDefaultRoot(), 0,
5799 &retc, &color, kFALSE);
5800 int i = 0;
5801 for (i = 0; i < 10; i++) {
5802 fgGlobalColorDialog->GetCustomPalette()->SetColor(i, TColor::Number2Pixel(i));
5803 }
5804 for (i = 0; i < 10; i++) {
5805 fgGlobalColorDialog->GetCustomPalette()->SetColor(10+i, TColor::Number2Pixel(180+i));
5806 }
5807 }
5808 return fgGlobalColorDialog;
5809}
5810
5811////////////////////////////////////////////////////////////////////////////////
5812/// Create global font dialog.
5813
5815{
5817
5818 if (!fgGlobalFontDialog) {
5819 fgGlobalFontDialog = new TGFontDialog(gClient->GetDefaultRoot(), 0, &prop, "", 0, kFALSE);
5820 }
5821 return fgGlobalFontDialog;
5822}
5823
5824////////////////////////////////////////////////////////////////////////////////
5825/// Map dialog and place it relative to selected frame.
5826
5828{
5829 Int_t x = 0, y = 0;
5831 UInt_t dw = gClient->GetDisplayWidth() - 20;
5832 UInt_t dh = gClient->GetDisplayHeight() - 50;
5833
5834 TGFrame *parent = (TGFrame*)fr->GetParent();
5835 gVirtualX->TranslateCoordinates(parent->GetId(), gClient->GetDefaultRoot()->GetId(),
5836 fr->GetX() + fr->GetWidth(),
5837 fr->GetY() + fr->GetHeight(), x, y, wdummy);
5838
5839 if (x + dialog->GetWidth() > dw) {
5840 x = dw - dialog->GetWidth();
5841 }
5842
5843 if (y + dialog->GetHeight() > dh) {
5844 y = dh - dialog->GetHeight();
5845 }
5846
5847 dialog->Move(x, y);
5848 dialog->SetWMPosition(x, y);
5849 dialog->MapRaised();
5850}
5851
5852////////////////////////////////////////////////////////////////////////////////
5853/// Change background color via context menu.
5854
5856{
5858 cd->SetCurrentColor(fr->GetBackground());
5859 cd->Connect("ColorSelected(Pixel_t)", "TGFrame", fr, "ChangeBackground(Pixel_t)");
5860 MapGlobalDialog(cd, fr);
5861 fClient->WaitForUnmap(cd);
5863}
5864
5865////////////////////////////////////////////////////////////////////////////////
5866/// Change background color via context menu for this frame and all subframes.
5867/// This method is activated via context menu during guibuilding.
5868
5870{
5872 cd->SetCurrentColor(fr->GetBackground());
5873 cd->Connect("ColorSelected(Pixel_t)", "TGCompositeFrame", fr,
5874 "ChangeSubframesBackground(Pixel_t)");
5875 MapGlobalDialog(cd, fr);
5876 fClient->WaitForUnmap(cd);
5878}
5879
5880////////////////////////////////////////////////////////////////////////////////
5881/// Change text color via color selection dialog. This method is activated
5882/// via context menu during guibuilding.
5883
5885{
5886 TGGC *gc = fClient->GetResourcePool()->GetGCPool()->FindGC(fr->GetNormGC());
5887
5888 if (!gc) {
5889 return;
5890 }
5891 ULong_t color = gc->GetForeground();
5892
5894 cd->SetCurrentColor(color);
5895 cd->Connect("ColorSelected(Pixel_t)", "TGGroupFrame", fr, "SetTextColor(Pixel_t)");
5896 MapGlobalDialog(cd, fr);
5897 fClient->WaitForUnmap(cd);
5899}
5900
5901////////////////////////////////////////////////////////////////////////////////
5902/// Change text font via font selection dialog. This method is activated
5903/// via context menu during guibuilding.
5904
5906{
5908
5909 TGGC *gc = fClient->GetResourcePool()->GetGCPool()->FindGC(fr->GetNormGC());
5910
5911 if (!gc) {
5912 return;
5913 }
5914
5915 TGFont *font = fClient->GetResourcePool()->GetFontPool()->FindFont(fr->GetFontStruct());
5916
5917 if (!font) {
5918 return;
5919 }
5920 fd->SetColor(gc->GetForeground());
5921 fd->SetFont(font);
5922 fd->EnableAlign(kFALSE);
5923 fd->Connect("FontSelected(char*)", "TGGroupFrame", fr, "SetTextFont(char*)");
5924 fd->Connect("ColorSelected(Pixel_t)", "TGGroupFrame", fr, "SetTextColor(Pixel_t)");
5925
5926 MapGlobalDialog(fd, fr);
5927 fClient->WaitForUnmap(fd);
5929}
5930
5931////////////////////////////////////////////////////////////////////////////////
5932/// Edit properties via font selection dialog. This method is activated
5933/// via context menu during guibuilding.
5934
5936{
5938
5939 TGGC *gc = fClient->GetResourcePool()->GetGCPool()->FindGC(fr->GetNormGC());
5940 if (!gc) {
5941 return;
5942 }
5943
5944 TGFont *font = fClient->GetResourcePool()->GetFontPool()->FindFont(fr->GetFontStruct());
5945
5946 if (!font) {
5947 return;
5948 }
5949 fd->SetColor(gc->GetForeground());
5950 fd->SetFont(font);
5951 fd->SetAlign(fr->GetTextJustify());
5952
5953 fd->Connect("FontSelected(char*)", "TGTextButton", fr, "SetFont(char*)");
5954 fd->Connect("ColorSelected(Pixel_t)", "TGTextButton", fr, "SetTextColor(Pixel_t)");
5955 fd->Connect("AlignSelected(Int_t)", "TGTextButton", fr, "SetTextJustify(Int_t)");
5956
5957 MapGlobalDialog(fd, fr);
5958 fClient->WaitForUnmap(fd);
5960}
5961
5962////////////////////////////////////////////////////////////////////////////////
5963/// Change text color via color selection dialog. This method is activated
5964/// via context menu during guibuilding.
5965
5967{
5968 TGGC *gc = gClient->GetResourcePool()->GetGCPool()->FindGC(fr->GetNormGC());
5969
5970 if (!gc) {
5971 return;
5972 }
5973 ULong_t color = gc->GetForeground();
5974
5976 cd->SetCurrentColor(color);
5977 cd->Connect("ColorSelected(Pixel_t)", "TGTextButton", fr, "SetTextColor(Pixel_t)");
5978
5979 MapGlobalDialog(cd, fr);
5980 fClient->WaitForUnmap(cd);
5982}
5983
5984////////////////////////////////////////////////////////////////////////////////
5985/// Invoke file dialog to assign a new picture.
5986/// This method is activated via context menu during guibuilding.
5987
5989{
5990 static TGFileInfo fi;
5991 static TString dir(".");
5992 static Bool_t overwr = kFALSE;
5993 TString fname;
5994
5995 fi.fFileTypes = gImageTypes;
5996 fi.SetIniDir(dir);
5997 fi.fOverwrite = overwr;
5998
5999 TGWindow *root = (TGWindow*)fClient->GetRoot();
6001
6003
6004 if (!fi.fFilename) {
6005 root->SetEditable(kTRUE);
6007 return;
6008 }
6009
6010 dir = fi.fIniDir;
6011 overwr = fi.fOverwrite;
6012 fname = fi.fFilename;
6013
6014 const TGPicture *pic = fClient->GetPicture(fname.Data());
6015
6016 if (!pic) {
6017 Int_t retval;
6018 new TGMsgBox(fClient->GetDefaultRoot(), fr, "Error...",
6019 TString::Format("Cannot read image file (%s)", fname.Data()),
6021
6022 if (retval == kMBRetry) {
6023 ChangePicture(fr);
6024 }
6025 } else {
6026 const TGPicture *tmp = fr->GetPicture();
6027 if (tmp) fClient->FreePicture(tmp);
6028
6029 fr->SetPicture(pic);
6030
6031 // not clear how to do at this point
6032 tmp = fr->GetDisabledPicture();
6033 if (tmp) fClient->FreePicture(tmp);
6034 }
6035 root->SetEditable(kTRUE);
6037}
6038
6039////////////////////////////////////////////////////////////////////////////////
6040/// Change background color via context menu
6041
6043{
6045 cd->SetCurrentColor(fr->GetBackground());
6046 cd->Connect("ColorSelected(Pixel_t)", "TGFrame", fr, "ChangeBackground(Pixel_t)");
6047 cd->Connect("ColorSelected(Pixel_t)", "TGScrollBar", fr->GetHScrollbar(), "ChangeBackground(Pixel_t)");
6048 cd->Connect("ColorSelected(Pixel_t)", "TGScrollBar", fr->GetVScrollbar(), "ChangeBackground(Pixel_t)");
6049
6050 MapGlobalDialog(cd, fr);
6051 fClient->WaitForUnmap(cd);
6053}
6054
6055////////////////////////////////////////////////////////////////////////////////
6056/// Change background color for list box entries. This method is invoked
6057/// via context menu during guibuilding.
6058
6060{
6062
6064 cd->SetCurrentColor(color);
6065
6066 cd->Connect("ColorSelected(Pixel_t)", "TGListBox", fr->GetListBox(),
6067 "ChangeBackground(Pixel_t)");
6068
6069 TGLBEntry *se = fr->GetSelectedEntry();
6070
6071 if (se) {
6072 cd->Connect("ColorSelected(Pixel_t)", "TGLBEntry", se,
6073 "SetBackgroundColor(Pixel_t)");
6074 }
6075
6076 TGTextEntry *te = fr->GetTextEntry();
6077
6078 if (te) {
6079 cd->Connect("ColorSelected(Pixel_t)", "TGTextEntry", te,
6080 "SetBackgroundColor(Pixel_t)");
6081 }
6082
6083 MapGlobalDialog(cd, fr);
6084 fClient->WaitForUnmap(cd);
6086
6087 if (se) {
6088 fClient->NeedRedraw(se, kTRUE); // force redraw
6089 }
6090
6091 if (te) {
6093 }
6094}
6095
6096////////////////////////////////////////////////////////////////////////////////
6097/// Edit properties via font selection dialog. This method is activated
6098/// via context menu during guibuilding.
6099
6101{
6103
6104 TGGC *gc = fClient->GetResourcePool()->GetGCPool()->FindGC(fr->GetNormGC());
6105
6106 if (!gc) {
6107 return;
6108 }
6109
6110 TGFont *font = fClient->GetResourcePool()->GetFontPool()->FindFont(fr->GetFontStruct());
6111
6112 if (!font) {
6113 return;
6114 }
6115
6116 fd->SetColor(gc->GetForeground());
6117 fd->SetFont(font);
6118 fd->SetAlign(fr->GetTextJustify());
6119
6120 fd->Connect("FontSelected(char*)", "TGLabel", fr, "SetTextFont(char*)");
6121 fd->Connect("ColorSelected(Pixel_t)", "TGLabel", fr, "SetTextColor(Pixel_t)");
6122 fd->Connect("AlignSelected(Int_t)", "TGLabel", fr, "SetTextJustify(Int_t)");
6123
6124 MapGlobalDialog(fd, fr);
6125 fClient->WaitForUnmap(fd);
6127}
6128
6129////////////////////////////////////////////////////////////////////////////////
6130/// Change text color via color selection dialog. This method is activated
6131/// via context menu during guibuilding.
6132
6134{
6135 TGGC *gc = gClient->GetResourcePool()->GetGCPool()->FindGC(fr->GetNormGC());
6136
6137 if (!gc) {
6138 return;
6139 }
6140
6141 ULong_t color = gc->GetForeground();
6142
6144 cd->SetCurrentColor(color);
6145 cd->Connect("ColorSelected(Pixel_t)", "TGLabel", fr, "SetTextColor(Pixel_t)");
6146
6147 MapGlobalDialog(cd, fr);
6148 fClient->WaitForUnmap(cd);
6150}
6151
6152////////////////////////////////////////////////////////////////////////////////
6153/// Set background color for list box entries. This method is invoked
6154/// via context menu during guibuilding.
6155
6157{
6159
6161 cd->SetCurrentColor(color);
6162 cd->Connect("ColorSelected(Pixel_t)", "TGListBox", fr, "ChangeBackground(Pixel_t)");
6163
6164 MapGlobalDialog(cd, fr);
6165 fClient->WaitForUnmap(cd);
6167}
6168
6169////////////////////////////////////////////////////////////////////////////////
6170/// Set progress bar color via TGColorDialog.
6171/// This method is activated via context menu during guibuilding.
6172
6174{
6175 ULong_t color = fr->GetBarColor();
6176
6178
6179 cd->SetCurrentColor(color);
6180 cd->Connect("ColorSelected(Pixel_t)", "TGProgressBar", fr, "SetBarColor(Pixel_t)");
6181
6182 MapGlobalDialog(cd, fr);
6183 fClient->WaitForUnmap(cd);
6185}
6186
6187////////////////////////////////////////////////////////////////////////////////
6188/// Change text color which displays position.
6189
6191{
6192 TGGC *gc = gClient->GetResourcePool()->GetGCPool()->FindGC(fr->GetNormGC());
6193
6194 if (!gc) {
6195 return;
6196 }
6197
6198 Pixel_t pixel = gc->GetForeground();
6200
6202 cd->Connect("ColorSelected(Pixel_t)", "TGProgressBar", fr,
6203 "SetForegroundColor(Pixel_t)");
6204
6205 MapGlobalDialog(cd, fr);
6206 fClient->WaitForUnmap(cd);
6208}
6209
6210////////////////////////////////////////////////////////////////////////////////
6211/// Set text color. This method is invoked
6212/// via context menu during guibuilding.
6213
6215{
6216 Pixel_t color = fr->GetTextColor();
6217
6219 cd->SetCurrentColor(color);
6220 cd->Connect("ColorSelected(Pixel_t)", "TGTextEntry", fr, "SetTextColor(Pixel_t)");
6221
6222 MapGlobalDialog(cd, fr);
6223 fClient->WaitForUnmap(cd);
6225}
6226
6227////////////////////////////////////////////////////////////////////////////////
6228/// Change text font via font selection dialog. This method is activated
6229/// via context menu during guibuilding.
6230
6232{
6234
6235 fd->SetColor(fr->GetTextColor());
6237 TGFont *font = fClient->GetResourcePool()->GetFontPool()->FindFont(fs);
6238
6239 if (font) {
6240 fd->SetFont(font);
6241 }
6242
6243 fd->EnableAlign(kFALSE);
6244 fd->Connect("FontSelected(char*)", "TGTextEntry", fr, "SetFont(char*)");
6245 fd->Connect("ColorSelected(Pixel_t)", "TGTextEntry", fr, "SetTextColor(Pixel_t)");
6246
6247 MapGlobalDialog(fd, fr);
6248 fClient->WaitForUnmap(fd);
6250
6252 tw = gVirtualX->TextWidth(fs, fr->GetText(), fr->GetBuffer()->GetTextLength());
6253
6254 if (tw < 1) {
6255 TString dummy('w', fr->GetBuffer()->GetBufferLength());
6256 tw = gVirtualX->TextWidth(fs, dummy.Data(), dummy.Length());
6257 }
6258
6259 gVirtualX->GetFontProperties(fs, max_ascent, max_descent);
6260 fr->Resize(tw + 8, max_ascent + max_descent + 7);
6261}
6262
6263////////////////////////////////////////////////////////////////////////////////
6264/// Invoke file dialog to assign a new image.
6265/// This method is activated via context menu during guibuilding.
6266
6268{
6269 static TGFileInfo fi;
6270 static TString dir(".");
6271 static Bool_t overwr = kFALSE;
6272 TString fname;
6273
6274 fi.fFileTypes = gImageTypes;
6275 fi.SetIniDir(dir);
6276 fi.fOverwrite = overwr;
6277
6278 TGWindow *root = (TGWindow*)fClient->GetRoot();
6280
6282
6283 if (!fi.fFilename) {
6284 root->SetEditable(kTRUE);
6286 return;
6287 }
6288
6289 dir = fi.fIniDir;
6290 overwr = fi.fOverwrite;
6291 fname = fi.fFilename;
6292
6293 TImage *img = TImage::Open(fname.Data());
6294
6295 if (!img) {
6296 Int_t retval;
6297 new TGMsgBox(fClient->GetDefaultRoot(), fr, "Error...",
6298 TString::Format("Cannot read image file (%s)", fname.Data()),
6300
6301 if (retval == kMBRetry) {
6302 ChangeImage(fr);
6303 }
6304 } else {
6305 fr->SetImage(img);
6306 fr->SetImagePath(gSystem->GetDirName(fname.Data()));
6307 }
6308
6309 root->SetEditable(kTRUE);
6311}
6312
6313////////////////////////////////////////////////////////////////////////////////
6314/// Set lasso drawn flag
6315
6317{
6318 if (fLassoDrawn == on) {
6319 return;
6320 }
6321
6322 fLassoDrawn = on;
6323
6324 if (fBuilder) {
6325 if (on) {
6327 }
6328
6330 }
6331}
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:188
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
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2362
virtual int GetPid()
Get process id.
Definition TSystem.cxx:716
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
Definition TSystem.cxx:461
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1092
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