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