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