Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TRootCanvas.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id: b4c21444ab4f787f65b2b44199fc0440c3c2ce81 $
2// Author: Fons Rademakers 15/01/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, 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/** \class TRootCanvas
14 \ingroup guiwidgets
15
16This class creates a main window with menubar, scrollbars and a
17drawing area. The widgets used are the new native ROOT GUI widgets.
18
19*/
20
21
22#include "RConfigure.h"
23
24#include "TRootCanvas.h"
25#include "TRootApplication.h"
26#include "TRootHelpDialog.h"
27#include "TGClient.h"
28#include "TGCanvas.h"
29#include "TGMenu.h"
30#include "TGWidget.h"
31#include "TGFileBrowser.h"
32#include "TGFileDialog.h"
33#include "TGStatusBar.h"
34#include "TGTextEditDialogs.h"
35#include "TROOT.h"
36#include "TClass.h"
37#include "TSystem.h"
38#include "TCanvas.h"
39#include "TBrowser.h"
40#include "TClassTree.h"
41#include "TMarker.h"
42#include "TStyle.h"
43#include "TColorWheel.h"
44#include "TVirtualX.h"
45#include "TApplication.h"
46#include "TFile.h"
47#include "TInterpreter.h"
48#include "TEnv.h"
49#include "TMath.h"
50#include <iostream>
51#include "TGDockableFrame.h"
52
53#include "TG3DLine.h"
54#include "TGToolBar.h"
55#include "TGToolTip.h"
56#include "TVirtualPadEditor.h"
57#include "TRootControlBar.h"
58#include "TGuiBuilder.h"
59#include "TImage.h"
60#include "TError.h"
61#include "TGDNDManager.h"
62#include "TBufferFile.h"
63#include "TRootBrowser.h"
64#include "TGTab.h"
65#include "TGedEditor.h"
66
67#include "TPluginManager.h"
68#include "TVirtualGL.h"
69
70#ifdef WIN32
71#include "TWin32SplashThread.h"
72#endif
73
74#include "HelpText.h"
75
76namespace {
77
79{
80 static TClass *geoVolumeClass = TClass::GetClass("TGeoVolume");
81 static TClass *geoShapeClass = TClass::GetClass("TGeoShape");
82 static TClass *geoOverlapClass = TClass::GetClass("TGeoOverlap");
83 static TClass *geoTrackClass = TClass::GetClass("TGeoTrack");
84
85 if (!obj)
86 return false;
87
88 return (geoVolumeClass && obj->InheritsFrom(geoVolumeClass)) ||
92}
93
95{
96 if (!pad)
97 return false;
98
99 TList *primitives = pad->GetListOfPrimitives();
100 if (!primitives)
101 return false;
102
103 TIter next(primitives);
104 while (TObject *obj = next()) {
105 if (IsGeometryPrimitive(obj))
106 return true;
107 if (obj->InheritsFrom(TVirtualPad::Class()) && PadHasGeometryContent(static_cast<TVirtualPad *>(obj)))
108 return true;
109 }
110
111 return false;
112}
113
114} // namespace
115
116// Canvas menu command ids
202// clang-format off
203static const char *gOpenTypes[] = { "ROOT files", "*.root",
204 "All files", "*",
205 0, 0 };
206
207static const char *gSaveAsTypes[] = { "PDF", "*.pdf",
208 "SVG", "*.svg",
209 "TeX", "*.tex",
210 "PostScript", "*.ps",
211 "Encapsulated PostScript", "*.eps",
212 "PNG", "*.png",
213 "JPEG", "*.jpg",
214 "GIF", "*.gif",
215 "BMP", "*.bmp",
216 "ROOT macros", "*.C",
217 "ROOT files", "*.root",
218 "XML", "*.xml",
219 "XPM", "*.xpm",
220 "TIFF", "*.tiff",
221 "XCF", "*.xcf",
222 "All files", "*",
223 0, 0 };
224
226 // { filename, tooltip, staydown, id, button}
227 { "newcanvas.xpm", "New", kFALSE, kFileNewCanvas, 0 },
228 { "open.xpm", "Open", kFALSE, kFileOpen, 0 },
229 { "save.xpm", "Save As", kFALSE, kFileSaveAs, 0 },
230 { "printer.xpm", "Print", kFALSE, kFilePrint, 0 },
231 { "", "", kFALSE, -1, 0 },
232 { "interrupt.xpm", "Interrupt", kFALSE, kOptionInterrupt,0 },
233 { "refresh2.xpm", "Refresh", kFALSE, kOptionRefresh, 0 },
234 { "", "", kFALSE, -1, 0 },
235 { "inspect.xpm", "Inspect", kFALSE, kInspectRoot, 0 },
236 { "browser.xpm", "Browser", kFALSE, kToolsBrowser, 0 },
237 { 0, 0, kFALSE, 0, 0 }
238};
239
241 { "pointer.xpm", "Modify", kFALSE, kToolModify, 0 },
242 { "arc.xpm", "Arc", kFALSE, kToolArc, 0 },
243 { "line.xpm", "Line", kFALSE, kToolLine, 0 },
244 { "arrow.xpm", "Arrow", kFALSE, kToolArrow, 0 },
245 { "diamond.xpm", "Diamond", kFALSE, kToolDiamond, 0 },
246 { "ellipse.xpm", "Ellipse", kFALSE, kToolEllipse, 0 },
247 { "pad.xpm", "Pad", kFALSE, kToolPad, 0 },
248 { "pave.xpm", "Pave", kFALSE, kToolPave, 0 },
249 { "pavelabel.xpm", "Pave Label", kFALSE, kToolPLabel, 0 },
250 { "pavetext.xpm", "Pave Text", kFALSE, kToolPText, 0 },
251 { "pavestext.xpm", "Paves Text", kFALSE, kToolPsText, 0 },
252 { "graph.xpm", "Graph", kFALSE, kToolGraph, 0 },
253 { "curlyline.xpm", "Curly Line", kFALSE, kToolCurlyLine, 0 },
254 { "curlyarc.xpm", "Curly Arc", kFALSE, kToolCurlyArc, 0 },
255 { "latex.xpm", "Text/Latex", kFALSE, kToolLatex, 0 },
256 { "marker.xpm", "Marker", kFALSE, kToolMarker, 0 },
257 { "cut.xpm", "Graphical Cut", kFALSE, kToolCutG, 0 },
258 { 0, 0, kFALSE, 0, 0 }
259};
260// clang-format on
261
262//////////////////////////////////////////////////////////////////////////
263// //
264// TRootContainer //
265// //
266// Utility class used by TRootCanvas. The TRootContainer is the frame //
267// embedded in the TGCanvas widget. The ROOT graphics goes into this //
268// frame. This class is used to enable input events on this graphics //
269// frame and forward the events to the TRootCanvas handlers. //
270// //
271//////////////////////////////////////////////////////////////////////////
272
274private:
275 TRootCanvas *fCanvas; // pointer back to canvas imp
276public:
277 TRootContainer(TRootCanvas *c, Window_t id, const TGWindow *parent);
278
279 Bool_t HandleButton(Event_t *ev) override;
286 { return fCanvas->HandleContainerKey(ev); }
293 void SavePrimitive(std::ostream &out, Option_t * = "") override;
294 void SetEditable(Bool_t) override { }
295};
296
297////////////////////////////////////////////////////////////////////////////////
298/// Create a canvas container.
299
314
315////////////////////////////////////////////////////////////////////////////////
316/// Directly handle scroll mouse buttons (4 and 5), only pass buttons
317/// 1, 2 and 3 on to the TCanvas.
318
320{
322 UInt_t page = vp->GetHeight()/4;
324
325 gVirtualX->SetInputFocus(GetMainFrame()->GetId());
326
327 if (event->fCode == kButton4) {
328 //scroll up
330 if (newpos < 0) newpos = 0;
332// return kTRUE;
333 }
334 if (event->fCode == kButton5) {
335 // scroll down
338// return kTRUE;
339 }
340 return fCanvas->HandleContainerButton(event);
341}
342
343
344////////////////////////////////////////////////////////////////////////////////
345/// Create a basic ROOT canvas.
346
357
358////////////////////////////////////////////////////////////////////////////////
359/// Create a basic ROOT canvas.
360
372
373////////////////////////////////////////////////////////////////////////////////
374/// Create the actual canvas.
375
377{
378 fButton = 0;
379 fAutoFit = kTRUE; // check also menu entry
380 fEditor = 0;
382
383 // Create menus
391
392 static Int_t img = 0;
393
394 if (!img) {
398 img = itmp ? 1 : -1;
399 if (itmp) {
400 delete itmp;
401 itmp=NULL;
402 }
404 }
405 if (img > 0) {
409 }
410
413
415 fFileMenu->AddEntry("&New Canvas", kFileNewCanvas);
416 fFileMenu->AddEntry("&Open...", kFileOpen);
417 fFileMenu->AddEntry("&Close Canvas", kFileCloseCanvas);
420 fFileMenu->AddEntry("Save &As...", kFileSaveAs);
422 fFileMenu->AddEntry("&Print...", kFilePrint);
424 fFileMenu->AddEntry("&Quit ROOT", kFileQuit);
425
429
431 fEditMenu->AddEntry("&Style...", kEditStyle);
433 fEditMenu->AddEntry("Cu&t", kEditCut);
434 fEditMenu->AddEntry("&Copy", kEditCopy);
435 fEditMenu->AddEntry("&Paste", kEditPaste);
439 fEditMenu->AddEntry("&Undo", kEditUndo);
440 fEditMenu->AddEntry("&Redo", kEditRedo);
441
447
451
453 fViewMenu->AddEntry("&Editor", kViewEditor);
454 fViewMenu->AddEntry("&Toolbar", kViewToolbar);
455 fViewMenu->AddEntry("Event &Statusbar", kViewEventStatus);
456 fViewMenu->AddEntry("T&oolTip Info", kViewToolTips);
458 fViewMenu->AddEntry("&Colors", kViewColors);
459 fViewMenu->AddEntry("&Fonts", kViewFonts);
460 fViewMenu->AddEntry("&Markers", kViewMarkers);
462 fViewMenu->AddEntry("&Iconify", kViewIconify);
464 fViewMenu->AddPopup("&View With", fViewWithMenu);
465
467
469 fOptionMenu->AddEntry("&Auto Resize Canvas", kOptionAutoResize);
470 fOptionMenu->AddEntry("&Resize Canvas", kOptionResizeCanvas);
471 fOptionMenu->AddEntry("&Move Opaque", kOptionMoveOpaque);
472 fOptionMenu->AddEntry("Resize &Opaque", kOptionResizeOpaque);
474 fOptionMenu->AddEntry("&Interrupt", kOptionInterrupt);
475 fOptionMenu->AddEntry("R&efresh", kOptionRefresh);
477 fOptionMenu->AddEntry("&Pad Auto Exec", kOptionAutoExec);
479 fOptionMenu->AddEntry("&Statistics", kOptionStatistics);
480 fOptionMenu->AddEntry("Histogram &Title", kOptionHistTitle);
481 fOptionMenu->AddEntry("&Fit Parameters", kOptionFitParams);
482 fOptionMenu->AddEntry("Can Edit &Histograms", kOptionCanEdit);
483
484 // Opaque options initialized in InitWindow()
486 if (gStyle->GetOptStat())
488 if (gStyle->GetOptTitle())
490 if (gStyle->GetOptFit())
492 if (gROOT->GetEditHistograms())
494
496 fToolsMenu->AddEntry("&Inspect ROOT", kInspectRoot);
497 fToolsMenu->AddEntry("&Class Tree", kClassesTree);
498 fToolsMenu->AddEntry("&Fit Panel", kFitPanel);
499 fToolsMenu->AddEntry("&Start Browser", kToolsBrowser);
500 fToolsMenu->AddEntry("&Gui Builder", kToolsBuilder);
501 fToolsMenu->AddEntry("&Event Recorder", kToolsRecorder);
502
504 fHelpMenu->AddLabel("Basic Help On...");
506 fHelpMenu->AddEntry("&Canvas", kHelpOnCanvas);
507 fHelpMenu->AddEntry("&Menus", kHelpOnMenus);
508 fHelpMenu->AddEntry("&Graphics Editor", kHelpOnGraphicsEd);
509 fHelpMenu->AddEntry("&Browser", kHelpOnBrowser);
510 fHelpMenu->AddEntry("&Objects", kHelpOnObjects);
511 fHelpMenu->AddEntry("&PostScript", kHelpOnPS);
513 fHelpMenu->AddEntry("&About ROOT...", kHelpAbout);
514
515 // This main frame will process the menu commands
516 fFileMenu->Associate(this);
518 fEditMenu->Associate(this);
520 fViewMenu->Associate(this);
522 fViewWithMenu->Connect("PoppedUp()", "TRootCanvas", this, "UpdateViewWithMenu()");
523 fOptionMenu->Associate(this);
524 fToolsMenu->Associate(this);
525 fHelpMenu->Associate(this);
526
527 // Create menubar layout hints
531
532 // Create menubar
533 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
540
542
546
547 // Create toolbar dock
548 fToolDock = new TGDockableFrame(this);
552
553 // will allocate it later
554 fToolBar = 0;
555 fVertical1 = 0;
556 fVertical2 = 0;
559
563
564 fMainFrame = new TGCompositeFrame(this, GetWidth() + 4, GetHeight() + 4,
567
568 // Create editor frame that will host the pad editor
572
573 // Create canvas and canvas container that will host the ROOT graphics
576
577 fCanvasID = -1;
578
579 if (fCanvas->UseGL()) {
581 //first, initialize GL (if not yet)
582 if (!gGLManager) {
583 TString x = "win32";
584 if (gVirtualX->InheritsFrom("TGX11"))
585 x = "x11";
586 else if (gVirtualX->InheritsFrom("TGCocoa"))
587 x = "osx";
588
589 TPluginHandler *ph = gROOT->GetPluginManager()->FindHandler("TGLManager", x);
590
591 if (ph && ph->LoadPlugin() != -1) {
592 if (!ph->ExecPlugin(0))
593 Error("CreateCanvas", "GL manager plugin failed");
594 }
595 }
596
597 if (gGLManager) {
599 if (fCanvasID != -1) {
600 //Create gl context.
601 const Int_t glCtx = gGLManager->CreateGLContext(fCanvasID);
602 if (glCtx != -1) {
604 fCanvas->SetGLDevice(glCtx);//Now, fCanvas is responsible for context deletion!
605 } else
606 Error("CreateCanvas", "GL context creation failed.");
607 } else
608 Error("CreateCanvas", "GL window creation failed\n");
609 }
610 }
611
612 if (fCanvasID == -1)
614
615 Window_t win = gVirtualX->GetWindowID(fCanvasID);
619
622
623 // create the tooltip with a timeout of 250 ms
625
626 fCanvas->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
627 "TRootCanvas", this,
628 "EventInfo(Int_t, Int_t, Int_t, TObject*)");
629
630 // Create status bar
631 int parts[] = { 33, 10, 10, 47 };
632 fStatusBar = new TGStatusBar(this, 10, 10);
634
636
638
639 // Misc
642 fIconPic = SetIconPixmap("macro_s.xpm");
643 SetClassHints("ROOT", "Canvas");
644
647
648 // by default status bar, tool bar and pad editor are hidden
653
656
657 // we need to use GetDefaultSize() to initialize the layout algorithm...
659
660 gVirtualX->SetDNDAware(fId, fDNDTypeList);
662}
663
664////////////////////////////////////////////////////////////////////////////////
665/// Delete ROOT basic canvas. Order is significant. Delete in reverse
666/// order of creation.
667
669{
670 delete fToolTip;
671 if (fIconPic) gClient->FreePicture(fIconPic);
672 if (fEditor && !fEmbedded) delete fEditor;
673 if (fToolBar) {
674 Disconnect(fToolDock, "Docked()", this, "AdjustSize()");
675 Disconnect(fToolDock, "Undocked()", this, "AdjustSize()");
676 fToolBar->Cleanup();
677 delete fToolBar;
678 }
679
680 if (!MustCleanup()) {
681 delete fStatusBar;
682 delete fStatusBarLayout;
683 delete fCanvasContainer;
684 delete fCanvasWindow;
685
686 delete fEditorFrame;
687 delete fEditorLayout;
688 delete fMainFrame;
689 delete fMainFrameLayout;
690 delete fToolBarSep;
691 delete fToolDock;
692 delete fToolBarLayout;
693 delete fHorizontal1;
694 delete fHorizontal1Layout;
695
696 delete fMenuBar;
697 delete fMenuBarLayout;
698 delete fMenuBarItemLayout;
699 delete fMenuBarHelpLayout;
700 delete fCanvasLayout;
701 delete fDockLayout;
702 }
703
704 delete fFileMenu;
705 delete fFileSaveMenu;
706 delete fEditMenu;
707 delete fEditClearMenu;
708 delete fViewMenu;
709 delete fViewWithMenu;
710 delete fOptionMenu;
711 delete fToolsMenu;
712 delete fHelpMenu;
713}
714
715////////////////////////////////////////////////////////////////////////////////
716/// Called via TCanvasImp interface by TCanvas.
717
719{
721 if(gged && gged->GetCanvas() == fCanvas) {
722 if (fEmbedded) {
723 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
724 ((TGedEditor *)gged)->SetCanvas(0);
725 }
726 else gged->Hide();
727 }
728
729 gVirtualX->CloseWindow();
730}
731
732////////////////////////////////////////////////////////////////////////////////
733/// Really delete the canvas and this GUI.
734
736{
738 if(gged && gged->GetCanvas() == fCanvas) {
739 if (fEmbedded) {
740 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
741 ((TGedEditor *)gged)->SetCanvas(0);
742 }
743 else gged->Hide();
744 }
745
746 fToolTip->Hide();
747 Disconnect(fCanvas, "ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
748 this, "EventInfo(Int_t, Int_t, Int_t, TObject*)");
749
751 fCanvas->Clear();
752 fCanvas->SetName("");
753 if (gPad && gPad->GetCanvas() == fCanvas)
754 gPad = nullptr;
755 delete this;
756}
757
758////////////////////////////////////////////////////////////////////////////////
759/// In case window is closed via WM we get here.
760
765
766////////////////////////////////////////////////////////////////////////////////
767/// Return width of canvas container.
768
773
774////////////////////////////////////////////////////////////////////////////////
775/// Return height of canvas container.
776
781
782////////////////////////////////////////////////////////////////////////////////
783/// Gets the size and position of the window containing the canvas. This
784/// size includes the menubar and borders.
785
787{
788 gVirtualX->GetWindowSize(fId, x, y, w, h);
789
791 gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(),
792 0, 0, x, y, childdum);
793 if (!fCanvas->GetShowEditor()) return 0;
794 return fEditorFrame->GetWidth();
795}
796
797////////////////////////////////////////////////////////////////////////////////
798/// Set text in status bar.
799
804
805////////////////////////////////////////////////////////////////////////////////
806/// Handle menu and other command generated by the user.
807
809{
811 TList *lc;
812
813 switch (GET_MSG(msg)) {
814
815 case kC_COMMAND:
816
817 switch (GET_SUBMSG(msg)) {
818
819 case kCM_BUTTON:
820 case kCM_MENU:
821
822 switch (parm1) {
823 // Handle toolbar items...
824 case kToolModify:
825 gROOT->SetEditorMode();
826 break;
827 case kToolArc:
828 gROOT->SetEditorMode("Arc");
829 break;
830 case kToolLine:
831 gROOT->SetEditorMode("Line");
832 break;
833 case kToolArrow:
834 gROOT->SetEditorMode("Arrow");
835 break;
836 case kToolDiamond:
837 gROOT->SetEditorMode("Diamond");
838 break;
839 case kToolEllipse:
840 gROOT->SetEditorMode("Ellipse");
841 break;
842 case kToolPad:
843 gROOT->SetEditorMode("Pad");
844 break;
845 case kToolPave:
846 gROOT->SetEditorMode("Pave");
847 break;
848 case kToolPLabel:
849 gROOT->SetEditorMode("PaveLabel");
850 break;
851 case kToolPText:
852 gROOT->SetEditorMode("PaveText");
853 break;
854 case kToolPsText:
855 gROOT->SetEditorMode("PavesText");
856 break;
857 case kToolGraph:
858 gROOT->SetEditorMode("PolyLine");
859 break;
860 case kToolCurlyLine:
861 gROOT->SetEditorMode("CurlyLine");
862 break;
863 case kToolCurlyArc:
864 gROOT->SetEditorMode("CurlyArc");
865 break;
866 case kToolLatex:
867 gROOT->SetEditorMode("Text");
868 break;
869 case kToolMarker:
870 gROOT->SetEditorMode("Marker");
871 break;
872 case kToolCutG:
873 gROOT->SetEditorMode("CutG");
874 break;
875
876 // Handle File menu items...
877 case kFileNewCanvas:
878 gROOT->MakeDefCanvas();
879 break;
880 case kFileOpen:
881 {
882 static TString dir(".");
884 fi.fFileTypes = gOpenTypes;
885 fi.SetIniDir(dir);
887 if (!fi.fFilename) return kTRUE;
888 dir = fi.fIniDir;
889 TFile::Open(fi.fFilename, "update");
890 TIter next(gROOT->GetListOfBrowsers());
891 TBrowser *b;
892 while ((b = (TBrowser *)next())) {
893 TRootBrowser *rb = dynamic_cast<TRootBrowser *>(b->GetBrowserImp());
894 if (rb) {
895 TGFileBrowser *fb = dynamic_cast<TGFileBrowser *>(rb->GetActBrowser());
896 if (fb)
897 fb->Selected(0);
898 }
899 }
900 gROOT->RefreshBrowsers();
901 }
902 break;
903 case kFileSaveAs:
904 {
906 static TString dir(".");
907 static Int_t typeidx = 0;
908 static Bool_t overwr = kFALSE;
910 TString defaultType = gEnv->GetValue("Canvas.SaveAsDefaultType", ".pdf");
911 if (typeidx == 0) {
912 for (int i=1;gSaveAsTypes[i];i+=2) {
913 TString ftype = gSaveAsTypes[i];
914 if (ftype.EndsWith(defaultType.Data())) {
915 typeidx = i-1;
916 break;
917 }
918 }
919 }
920 fi.fFileTypes = gSaveAsTypes;
921 fi.SetIniDir(dir);
922 fi.fFileTypeIdx = typeidx;
923 fi.fOverwrite = overwr;
926 if (!fi.fFilename) return kTRUE;
928 TString fn = fi.fFilename;
929 TString ft = fi.fFileTypes[fi.fFileTypeIdx+1];
930 // clang-format off
931 dir = fi.fIniDir;
932 typeidx = fi.fFileTypeIdx;
933 overwr = fi.fOverwrite;
934again:
935 if (fn.EndsWith(".root") ||
936 fn.EndsWith(".ps") ||
937 fn.EndsWith(".eps") ||
938 fn.EndsWith(".pdf") ||
939 fn.EndsWith(".svg") ||
940 fn.EndsWith(".tex") ||
941 fn.EndsWith(".gif") ||
942 fn.EndsWith(".bmp") ||
943 fn.EndsWith(".xml") ||
944 fn.EndsWith(".xpm") ||
945 fn.EndsWith(".jpg") ||
946 fn.EndsWith(".png") ||
947 fn.EndsWith(".xcf") ||
948 fn.EndsWith(".tiff")) {
949 fCanvas->SaveAs(fn);
950 } else if (fn.EndsWith(".C"))
952 else {
953 if (!appendedType) {
954 if (ft.Index(".") != kNPOS) {
955 fn += ft(ft.Index("."), ft.Length());
957 goto again;
958 }
959 }
960 Warning("ProcessMessage", "file %s cannot be saved with this extension", fi.fFilename);
961 }
962 for (int i = 1; gSaveAsTypes[i]; i += 2) {
963 TString ftype = gSaveAsTypes[i];
964 ftype.ReplaceAll("*.", ".");
965 if (fn.EndsWith(ftype.Data())) {
966 typeidx = i - 1;
967 break;
968 }
969 }
970 }
971 break;
972 case kFileSaveAsRoot:
973 fCanvas->SaveAs(".root");
974 break;
975 case kFileSaveAsC:
977 break;
978 case kFileSaveAsPS:
979 fCanvas->SaveAs();
980 break;
981 case kFileSaveAsEPS:
982 fCanvas->SaveAs(".eps");
983 break;
984 case kFileSaveAsPDF:
985 fCanvas->SaveAs(".pdf");
986 break;
987 case kFileSaveAsSVG:
988 fCanvas->SaveAs(".svg");
989 break;
990 case kFileSaveAsGIF:
991 fCanvas->SaveAs(".gif");
992 break;
993 case kFileSaveAsJPG:
994 fCanvas->SaveAs(".jpg");
995 break;
996 case kFileSaveAsPNG:
997 fCanvas->SaveAs(".png");
998 break;
999 case kFileSaveAsBMP:
1000 fCanvas->SaveAs(".bmp");
1001 break;
1002 case kFileSaveAsTEX:
1003 fCanvas->SaveAs(".tex");
1004 break;
1005 case kFilePrint:
1006 PrintCanvas();
1007 break;
1008 case kFileCloseCanvas:
1010 break;
1011 case kFileQuit:
1012 if (!gApplication->ReturnFromRun()) {
1016 }
1019 if (TClass::GetClass("TStyleManager", kFALSE, kTRUE))
1020 gROOT->ProcessLine("TStyleManager::Terminate()");
1022 break;
1023
1024 // Handle Edit menu items...
1025 case kEditStyle:
1026 if (!TClass::GetClass("TStyleManager"))
1027 gSystem->Load("libGed");
1028 gROOT->ProcessLine("TStyleManager::Show()");
1029 break;
1030 case kEditCut:
1031 // still noop
1032 break;
1033 case kEditCopy:
1034 // still noop
1035 break;
1036 case kEditPaste:
1037 // still noop
1038 break;
1039 case kEditUndo:
1040 // noop
1041 break;
1042 case kEditRedo:
1043 // noop
1044 break;
1045 case kEditClearPad:
1046 gPad->Clear();
1047 gPad->Modified();
1048 gPad->Update();
1049 break;
1050 case kEditClearCanvas:
1051 fCanvas->Clear();
1052 fCanvas->Modified();
1053 fCanvas->Update();
1054 break;
1055
1056 // Handle View menu items...
1057 case kViewEditor:
1059 break;
1060 case kViewToolbar:
1062 break;
1063 case kViewEventStatus:
1065 break;
1066 case kViewToolTips:
1068 break;
1069 case kViewColors:
1070 {
1071 TVirtualPad *padsav = gPad->GetCanvas();
1072 //This was the code with the old color table
1073 // TCanvas *m = new TCanvas("colors","Color Table");
1074 // TPad::DrawColorTable();
1075 // m->Update();
1076 TColorWheel *wheel = new TColorWheel();
1077 wheel->Draw();
1078
1079 //tp: with Cocoa, window is visible (and repainted)
1080 //before wheel->Draw() was called and you can see "empty"
1081 //canvas.
1082 gPad->Update();
1083 //
1084 if (padsav) padsav->cd();
1085 }
1086 break;
1087 case kViewFonts:
1088 // noop
1089 break;
1090 case kViewMarkers:
1091 {
1092 TVirtualPad *padsav = gPad ? gPad->GetCanvas() : nullptr;
1093 TCanvas *m = new TCanvas("markers","Marker Types",600,200);
1095 m->Update();
1096 if (padsav) padsav->cd();
1097 }
1098 break;
1099 case kViewIconify:
1100 Iconify();
1101 break;
1102 case kViewX3D: {
1103 TVirtualPad *pad = gPad ? gPad : (fCanvas ? fCanvas->GetSelectedPad() : nullptr);
1104 if (!pad)
1105 pad = fCanvas;
1107 pad->GetViewer3D("x3d");
1108 break;
1109 }
1110 case kViewOpenGL:
1111 gPad->GetViewer3D("ogl");
1112 break;
1113
1114 // Handle Option menu items...
1115 case kOptionAutoExec:
1117 if (fCanvas->GetAutoExec()) {
1119 } else {
1121 }
1122 break;
1123 case kOptionAutoResize:
1124 {
1126 int opt = fCanvasContainer->GetOptions();
1127 if (fAutoFit) {
1128 opt &= ~kFixedSize;
1130 } else {
1131 opt |= kFixedSize;
1133 }
1135 // in case of autofit this will generate a configure
1136 // event for the container and this will force the
1137 // update of the TCanvas
1138 //Layout();
1139 }
1140 Layout();
1141 break;
1143 FitCanvas();
1144 break;
1145 case kOptionMoveOpaque:
1146 if (fCanvas->OpaqueMoving()) {
1147 fCanvas->MoveOpaque(0);
1149 } else {
1150 fCanvas->MoveOpaque(1);
1152 }
1153 break;
1155 if (fCanvas->OpaqueResizing()) {
1158 } else {
1161 }
1162 break;
1163 case kOptionInterrupt:
1164 gROOT->SetInterrupt();
1165 break;
1166 case kOptionRefresh:
1167 fCanvas->Paint();
1168 fCanvas->Update();
1169 break;
1170 case kOptionStatistics:
1171 if (gStyle->GetOptStat()) {
1172 gStyle->SetOptStat(0);
1173 delete gPad->FindObject("stats");
1175 } else {
1176 gStyle->SetOptStat(1);
1178 }
1179 gPad->Modified();
1180 fCanvas->Update();
1181 break;
1182 case kOptionHistTitle:
1183 if (gStyle->GetOptTitle()) {
1184 gStyle->SetOptTitle(0);
1185 delete gPad->FindObject("title");
1187 } else {
1188 gStyle->SetOptTitle(1);
1190 }
1191 gPad->Modified();
1192 fCanvas->Update();
1193 break;
1194 case kOptionFitParams:
1195 if (gStyle->GetOptFit()) {
1196 gStyle->SetOptFit(0);
1198 } else {
1199 gStyle->SetOptFit(1);
1201 }
1202 gPad->Modified();
1203 fCanvas->Update();
1204 break;
1205 case kOptionCanEdit:
1206 if (gROOT->GetEditHistograms()) {
1207 gROOT->SetEditHistograms(kFALSE);
1209 } else {
1210 gROOT->SetEditHistograms(kTRUE);
1212 }
1213 break;
1214
1215 // Handle Tools menu items...
1216 case kInspectRoot:
1217 fCanvas->cd();
1218 gROOT->Inspect();
1219 fCanvas->Update();
1220 break;
1221 case kToolsBrowser:
1222 new TBrowser("browser");
1223 break;
1224 case kToolsBuilder:
1226 break;
1227 case kToolsRecorder:
1228 gROOT->ProcessLine("new TGRecorder()");
1229 break;
1230
1231 // Handle Tools menu items...
1232 case kClassesTree:
1233 {
1234 TString cdef;
1235 lc = (TList*)gROOT->GetListOfCanvases();
1236 if (lc->FindObject("ClassTree")) {
1237 cdef = TString::Format("ClassTree_%d", lc->GetSize()+1);
1238 } else {
1239 cdef = "ClassTree";
1240 }
1241 new TClassTree(cdef.Data(), "TObject");
1242 fCanvas->Update();
1243 }
1244 break;
1245
1246 case kFitPanel:
1247 {
1248 // use plugin manager to create instance of TFitEditor
1249 TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
1250 if (handler && handler->LoadPlugin() != -1) {
1251 if (handler->ExecPlugin(2, fCanvas, 0) == 0)
1252 Error("FitPanel", "Unable to crate the FitPanel");
1253 }
1254 else
1255 Error("FitPanel", "Unable to find the FitPanel plug-in");
1256 }
1257 break;
1258
1259 // Handle Help menu items...
1260 case kHelpAbout:
1261 {
1262#ifdef WIN32
1264#else
1265
1266 char str[32];
1267 snprintf(str, 32, "About ROOT %s...", gROOT->GetVersion());
1268 hd = new TRootHelpDialog(this, str, 600, 400);
1269 hd->SetText(gHelpAbout);
1270 hd->Popup();
1271#endif
1272 }
1273 break;
1274 case kHelpOnCanvas:
1275 hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1276 hd->SetText(gHelpCanvas);
1277 hd->Popup();
1278 break;
1279 case kHelpOnMenus:
1280 hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1281 hd->SetText(gHelpPullDownMenus);
1282 hd->Popup();
1283 break;
1284 case kHelpOnGraphicsEd:
1285 hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1286 hd->SetText(gHelpGraphicsEditor);
1287 hd->Popup();
1288 break;
1289 case kHelpOnBrowser:
1290 hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1291 hd->SetText(gHelpBrowser);
1292 hd->Popup();
1293 break;
1294 case kHelpOnObjects:
1295 hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
1296 hd->SetText(gHelpObjects);
1297 hd->Popup();
1298 break;
1299 case kHelpOnPS:
1300 hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
1301 hd->SetText(gHelpPostscript);
1302 hd->Popup();
1303 break;
1304 // clang-format on
1305 }
1306 default:
1307 break;
1308 }
1309 default:
1310 break;
1311 }
1312 return kTRUE;
1313}
1314
1315////////////////////////////////////////////////////////////////////////////////
1316/// Called by TCanvas ctor to get window indetifier.
1317
1327
1328////////////////////////////////////////////////////////////////////////////////
1329/// Set size of canvas container. Units in pixels.
1330/// If w==0 and h==0, set autofit mode
1331
1333{
1334 // turn off autofit, we want to stay at the given size
1335 int opt = fCanvasContainer->GetOptions();
1336 if (!w && !h) {
1337 fAutoFit = kTRUE;
1339 opt &= ~kFixedSize; // turn off fixed size mode
1340 } else {
1341 fAutoFit = kFALSE;
1343 opt |= kFixedSize; // turn on fixed size mode
1344 }
1348 Layout(); // force layout (will update container to given size)
1349 fCanvas->Resize();
1350 fCanvas->Update();
1351}
1352
1353////////////////////////////////////////////////////////////////////////////////
1354/// Set canvas position (units in pixels).
1355
1360
1361////////////////////////////////////////////////////////////////////////////////
1362/// Set size of canvas (units in pixels).
1363
1365{
1366 Resize(w, h);
1367
1368 // Make sure the change of size is really done.
1369 gVirtualX->Update(1);
1370 if (!gThreadXAR) {
1371 gSystem->Sleep(100);
1373 gSystem->Sleep(10);
1375 }
1376}
1377
1378////////////////////////////////////////////////////////////////////////////////
1379/// Put canvas window on top of the window stack.
1380
1382{
1383 gVirtualX->RaiseWindow(GetId());
1384}
1385
1386////////////////////////////////////////////////////////////////////////////////
1387/// Change title on window.
1388
1389void TRootCanvas::SetWindowTitle(const char *title)
1390{
1391 SetWindowName(title);
1392 SetIconName(title);
1393 fToolDock->SetWindowName(TString::Format("ToolBar: %s", title));
1394}
1395
1396////////////////////////////////////////////////////////////////////////////////
1397/// Fit canvas container to current window size.
1398
1400{
1401 if (!fAutoFit) {
1402 int opt = fCanvasContainer->GetOptions();
1403 int oopt = opt;
1404 opt &= ~kFixedSize; // turn off fixed size mode
1406 Layout(); // force layout
1407 fCanvas->Resize();
1408 fCanvas->Update();
1410 }
1411}
1412
1413////////////////////////////////////////////////////////////////////////////////
1414/// Print the canvas.
1415
1417{
1418 Int_t ret = 0;
1419 Bool_t pname = kTRUE;
1420 char *printer, *printCmd;
1421 static TString sprinter, sprintCmd;
1422
1423 if (sprinter == "")
1424 printer = StrDup(gEnv->GetValue("Print.Printer", ""));
1425 else
1427 if (sprintCmd == "")
1428#ifndef WIN32
1429 printCmd = StrDup(gEnv->GetValue("Print.Command", ""));
1430#else
1431 printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p"));
1432#endif
1433 else
1435
1436 new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
1437 &printer, &printCmd, &ret);
1438 if (ret) {
1439 sprinter = printer;
1441
1442 if (sprinter == "")
1443 pname = kFALSE;
1444
1445 TString fn = "rootprint";
1446 FILE *f = gSystem->TempFileName(fn, gEnv->GetValue("Print.Directory", gSystem->TempDirectory()));
1447 if (f) fclose(f);
1448 fn += TString::Format(".%s",gEnv->GetValue("Print.FileType", "pdf"));
1449 fCanvas->Print(fn);
1450
1452 if (cmd.Contains("%p"))
1453 cmd.ReplaceAll("%p", sprinter);
1454 else if (pname) {
1455 cmd += " "; cmd += sprinter; cmd += " ";
1456 }
1457
1458 if (cmd.Contains("%f"))
1459 cmd.ReplaceAll("%f", fn);
1460 else {
1461 cmd += " "; cmd += fn; cmd += " ";
1462 }
1463
1464 gSystem->Exec(cmd);
1465#ifndef WIN32
1466 gSystem->Unlink(fn);
1467#endif
1468 }
1469 delete [] printer;
1470 delete [] printCmd;
1471}
1472
1473////////////////////////////////////////////////////////////////////////////////
1474/// Display a tooltip with infos about the primitive below the cursor.
1475
1476void TRootCanvas::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
1477{
1478 fToolTip->Hide();
1479 if (!fCanvas->GetShowToolTips() || selected == 0 ||
1480 event != kMouseMotion || fButton != 0)
1481 return;
1483 TString objInfo = selected->GetObjectInfo(px, py);
1484 if (objInfo.BeginsWith("-")) {
1485 // if the string begins with '-', display only the object info
1486 objInfo.Remove(TString::kLeading, '-');
1487 tipInfo = objInfo;
1488 }
1489 else {
1490 const char *title = selected->GetTitle();
1491 tipInfo += TString::Format("%s::%s", selected->ClassName(),
1492 selected->GetName());
1493 if (title && strlen(title))
1494 tipInfo += TString::Format("\n%s", selected->GetTitle());
1495 tipInfo += TString::Format("\n%d, %d", px, py);
1496 if (!objInfo.IsNull())
1497 tipInfo += TString::Format("\n%s", objInfo.Data());
1498 }
1499 fToolTip->SetText(tipInfo.Data());
1500 fToolTip->SetPosition(px+15, py+15);
1501 fToolTip->Reset();
1502}
1503
1504////////////////////////////////////////////////////////////////////////////////
1505/// Show or hide menubar.
1506
1512
1513////////////////////////////////////////////////////////////////////////////////
1514/// Show or hide statusbar.
1515
1517{
1520
1521 UInt_t h = GetHeight();
1523
1524 if (show) {
1527 if (dh - ch >= sh) h = h + sh;
1528 else h = ch;
1529 } else {
1532 if (dh - ch < sh) h = ch;
1533 else h = h - sh;
1534 }
1535 Resize(GetWidth(), h);
1536}
1537
1538////////////////////////////////////////////////////////////////////////////////
1539/// Show or hide side frame.
1540
1542{
1544
1545 UInt_t w = GetWidth();
1547 UInt_t h = GetHeight();
1549
1550 auto lambda_show = [&, this]() {
1551 if (show) {
1552 if (!fEditor)
1553 CreateEditor();
1555 if (gged && gged->GetCanvas() == fCanvas) {
1556 gged->Hide();
1557 }
1560 h += s;
1561 }
1563 fEditor->Show();
1565 w += e;
1566 } else {
1569 h -= s;
1570 }
1571 if (fEditor)
1572 fEditor->Hide();
1575 w -= e;
1576 }
1577 };
1578
1579 if (fParent && fParent != fClient->GetDefaultRoot()) {
1580 TGMainFrame *main = (TGMainFrame *)fParent->GetMainFrame();
1582 if (main && main->InheritsFrom("TRootBrowser")) {
1584 if (!fEmbedded)
1585 browser->GetTabRight()->Connect("Selected(Int_t)", "TRootCanvas",
1586 this, "Activated(Int_t)");
1587 fEmbedded = kTRUE;
1588 if (show && (!fEditor || !((TGedEditor *)fEditor)->IsMapped())) {
1589 if (!browser->GetTabLeft()->GetTabTab("Pad Editor")) {
1590 if (browser->GetActFrame()) { //already in edit mode
1591 TTimer::SingleShot(200, "TRootCanvas", this, "ShowEditor(=kTRUE)");
1592 } else {
1593 browser->StartEmbedding(TRootBrowser::kLeft);
1594 if (!fEditor)
1596 else {
1597 ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot());
1598 ((TGedEditor *)fEditor)->MapWindow();
1599 }
1600 browser->StopEmbedding("Pad Editor");
1601 if (fEditor) {
1603 gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor);
1604 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
1605 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
1606 }
1607 }
1608 }
1609 else
1611 }
1612 if (show) browser->GetTabLeft()->SetTab("Pad Editor");
1613 } else {
1614 lambda_show();
1615 main->Layout();
1616 }
1617 }
1618 else {
1619 lambda_show();
1620 Resize(w, h);
1621 }
1622}
1623
1624////////////////////////////////////////////////////////////////////////////////
1625/// Create embedded editor.
1626
1628{
1631 gPad = Canvas();
1632 // next two lines are related to the old editor
1633 Int_t show = gEnv->GetValue("Canvas.ShowEditor", 0);
1634 gEnv->SetValue("Canvas.ShowEditor","true");
1639
1640 // next line is related to the old editor
1641 if (show == 0) gEnv->SetValue("Canvas.ShowEditor","false");
1642}
1643
1644////////////////////////////////////////////////////////////////////////////////
1645/// Show or hide toolbar.
1646
1648{
1649 if (show && !fToolBar) {
1650
1653
1654 Int_t spacing = 6, i;
1655 for (i = 0; gToolBarData[i].fPixmap; i++) {
1656 if (strlen(gToolBarData[i].fPixmap) == 0) {
1657 spacing = 6;
1658 continue;
1659 }
1661 spacing = 0;
1662 }
1669
1670 spacing = 6;
1671 for (i = 0; gToolBarData1[i].fPixmap; i++) {
1672 if (strlen(gToolBarData1[i].fPixmap) == 0) {
1673 spacing = 6;
1674 continue;
1675 }
1677 spacing = 0;
1678 }
1680 fToolDock->Layout();
1682 fToolDock->Connect("Docked()", "TRootCanvas", this, "AdjustSize()");
1683 fToolDock->Connect("Undocked()", "TRootCanvas", this, "AdjustSize()");
1684 }
1685
1686 if (!fToolBar) return;
1687
1688 UInt_t h = GetHeight();
1691
1692 if (show) {
1696 h = h + sh;
1697 }
1700 h = h + dh + sh;
1701 } else {
1702 if (fToolDock->IsUndocked()) {
1704 h = h + 2*sh;
1705 } else h = h - dh;
1706
1710 h = h - sh;
1711 }
1713 h = h - sh;
1715 }
1716 Resize(GetWidth(), h);
1717}
1718
1719////////////////////////////////////////////////////////////////////////////////
1720/// Enable or disable tooltip info.
1721
1729
1730////////////////////////////////////////////////////////////////////////////////
1731/// Returns kTRUE if the editor is shown.
1732
1737
1738////////////////////////////////////////////////////////////////////////////////
1739/// Returns kTRUE if the menu bar is shown.
1740
1742{
1743 return (fMenuBar) && fMenuBar->IsMapped();
1744}
1745
1746////////////////////////////////////////////////////////////////////////////////
1747/// Returns kTRUE if the status bar is shown.
1748
1750{
1751 return (fStatusBar) && fStatusBar->IsMapped();
1752}
1753
1754////////////////////////////////////////////////////////////////////////////////
1755/// Returns kTRUE if the tool bar is shown.
1756
1758{
1759 return (fToolBar) && fToolBar->IsMapped();
1760}
1761
1762////////////////////////////////////////////////////////////////////////////////
1763/// Returns kTRUE if the tooltips are enabled.
1764
1766{
1767 return (fCanvas) && fCanvas->GetShowToolTips();
1768}
1769
1770////////////////////////////////////////////////////////////////////////////////
1771/// Keep the same canvas size while docking/undocking toolbar.
1772
1774{
1775 UInt_t h = GetHeight();
1778
1779 if (fToolDock->IsUndocked()) {
1782 h = h - sh;
1783 }
1785 h = h - dh - sh;
1786 } else {
1789 h = h + sh;
1790 }
1792 h = h + dh + sh;
1793 }
1794 Resize(GetWidth(), h);
1795}
1796
1797////////////////////////////////////////////////////////////////////////////////
1798/// Handle mouse button events in the canvas container.
1799
1801{
1802 Int_t button = event->fCode;
1803 Int_t x = event->fX;
1804 Int_t y = event->fY;
1805
1806 if (event->fType == kButtonPress) {
1807 if (fToolTip && fCanvas->GetShowToolTips()) {
1808 fToolTip->Hide();
1809 gVirtualX->UpdateWindowW(gVirtualX->GetWindowContext(fCanvasID), 0);
1811 }
1812 fButton = button;
1813 if (button == kButton1) {
1814 if (event->fState & kKeyShiftMask)
1816 else
1818 }
1819 if (button == kButton2)
1821 if (button == kButton3) {
1823 fButton = 0; // button up is consumed by TContextMenu
1824 }
1825
1826 } else if (event->fType == kButtonRelease) {
1827 if (button == kButton4)
1829 if (button == kButton5)
1831 if (button == kButton1)
1833 if (button == kButton2)
1835 if (button == kButton3)
1837
1838 fButton = 0;
1839 }
1840
1841 return kTRUE;
1842}
1843
1844////////////////////////////////////////////////////////////////////////////////
1845/// Handle mouse button double click events in the canvas container.
1846
1848{
1849 Int_t button = event->fCode;
1850 Int_t x = event->fX;
1851 Int_t y = event->fY;
1852
1853 if (button == kButton1)
1855 if (button == kButton2)
1857 if (button == kButton3)
1859
1860 return kTRUE;
1861}
1862
1863////////////////////////////////////////////////////////////////////////////////
1864/// Handle configure (i.e. resize) event.
1865
1867{
1868 if (fAutoFit) {
1869 fCanvas->Resize();
1870 fCanvas->Update();
1871 }
1872
1874 // get menu height
1875 static Int_t dh = 0;
1876 if (!dh)
1881 }
1882 return kTRUE;
1883}
1884
1885////////////////////////////////////////////////////////////////////////////////
1886/// Handle keyboard events in the canvas container.
1887
1889{
1891 static UInt_t previous_keysym = 0;
1892
1893 if (event->fType == kGKeyPress) {
1894 fButton = event->fCode;
1895 UInt_t keysym;
1896 char str[2];
1897 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1898
1899 if (str[0] == kESC){ // ESC sets the escape flag
1900 gROOT->SetEscape();
1903 gPad->Modified();
1904 return kTRUE;
1905 }
1906 if (str[0] == 3) // ctrl-c sets the interrupt flag
1907 gROOT->SetInterrupt();
1908
1909 // handle arrow keys
1910 if (keysym > 0x1011 && keysym < 0x1016) {
1912 UInt_t mask = 0;
1913 Int_t mx, my, tx, ty;
1914 wid = gVirtualX->GetDefaultRootWindow();
1915 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1916 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1918 mx, my, tx, ty, dum1);
1920 // handle case where we got consecutive same keypressed events coming
1921 // from auto-repeat on Windows (as it fires only successive keydown events)
1923 switch (keysym) {
1924 case 0x1012: // left
1925 gVirtualX->Warp(--mx, my, wid); --tx;
1926 break;
1927 case 0x1013: // up
1928 gVirtualX->Warp(mx, --my, wid); --ty;
1929 break;
1930 case 0x1014: // right
1931 gVirtualX->Warp(++mx, my, wid); ++tx;
1932 break;
1933 case 0x1015: // down
1934 gVirtualX->Warp(mx, ++my, wid); ++ty;
1935 break;
1936 default:
1937 break;
1938 }
1940 }
1942 }
1943 else {
1945 }
1946 } else if (event->fType == kKeyRelease) {
1947 UInt_t keysym;
1948 char str[2];
1949 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1950
1951 if (keysym > 0x1011 && keysym < 0x1016) {
1953 UInt_t mask = 0;
1954 Int_t mx, my, tx, ty;
1955 wid = gVirtualX->GetDefaultRootWindow();
1956 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1957 switch (keysym) {
1958 case 0x1012: // left
1959 gVirtualX->Warp(--mx, my, wid);
1960 break;
1961 case 0x1013: // up
1962 gVirtualX->Warp(mx, --my, wid);
1963 break;
1964 case 0x1014: // right
1965 gVirtualX->Warp(++mx, my, wid);
1966 break;
1967 case 0x1015: // down
1968 gVirtualX->Warp(mx, ++my, wid);
1969 break;
1970 default:
1971 break;
1972 }
1973 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1975 mx, my, tx, ty, dum1);
1978 }
1979 fButton = 0;
1980 }
1981 previous_event = event->fType;
1982 return kTRUE;
1983}
1984
1985////////////////////////////////////////////////////////////////////////////////
1986/// Handle mouse motion event in the canvas container.
1987
1989{
1990 Int_t x = event->fX;
1991 Int_t y = event->fY;
1992
1993 if (fButton == 0)
1995 if (fButton == kButton1) {
1996 if (event->fState & kKeyShiftMask)
1998 else
2000 }
2001 if (fButton == kButton2)
2003
2004 return kTRUE;
2005}
2006
2007////////////////////////////////////////////////////////////////////////////////
2008/// Handle expose events.
2009
2011{
2012 if (event->fCount == 0) {
2013 fCanvas->Flush();
2014 }
2015
2016 return kTRUE;
2017}
2018
2019////////////////////////////////////////////////////////////////////////////////
2020/// Handle enter/leave events. Only leave is activated at the moment.
2021
2023{
2024 Int_t x = event->fX;
2025 Int_t y = event->fY;
2026
2027 // pointer grabs create also an enter and leave event but with fCode
2028 // either kNotifyGrab or kNotifyUngrab, don't propagate these events
2029 if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
2031
2032 if (event->fType == kEnterNotify && event->fCode == kNotifyNormal)
2034
2035 return kTRUE;
2036}
2037
2038////////////////////////////////////////////////////////////////////////////////
2039/// Handle drop events.
2040
2042{
2043 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2044 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2045
2046 if (data->fDataType == rootObj) {
2047 TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
2048 buf.SetReadMode();
2050 if (!obj) return kTRUE;
2051 gPad->Clear();
2052 if (obj->InheritsFrom("TKey")) {
2053 TObject *object = (TObject *)gROOT->ProcessLine(TString::Format("((TKey *)0x%zx)->ReadObj();", (size_t)obj));
2054 if (!object) return kTRUE;
2055 if (object->InheritsFrom("TGraph"))
2056 object->Draw("ALP");
2057 else if (object->InheritsFrom("TImage"))
2058 object->Draw("x");
2059 else if (object->IsA()->GetMethodAllAny("Draw"))
2060 object->Draw();
2061 }
2062 else if (obj->InheritsFrom("TGraph"))
2063 obj->Draw("ALP");
2064 else if (obj->IsA()->GetMethodAllAny("Draw"))
2065 obj->Draw();
2066 gPad->Modified();
2067 gPad->Update();
2068 return kTRUE;
2069 }
2070 else if (data->fDataType == uriObj) {
2071 TString sfname((char *)data->fData);
2072 if (sfname.Length() > 7) {
2073 sfname.ReplaceAll("\r\n", "");
2074 TUrl uri(sfname.Data());
2075 if (sfname.EndsWith(".bmp") ||
2076 sfname.EndsWith(".gif") ||
2077 sfname.EndsWith(".jpg") ||
2078 sfname.EndsWith(".png") ||
2079 sfname.EndsWith(".ps") ||
2080 sfname.EndsWith(".eps") ||
2081 sfname.EndsWith(".pdf") ||
2082 sfname.EndsWith(".tiff") ||
2083 sfname.EndsWith(".xpm")) {
2084 TImage *img = TImage::Open(uri.GetFile());
2085 if (img) {
2086 img->Draw("x");
2087 img->SetEditable(kTRUE);
2088 }
2089 }
2090 gPad->Modified();
2091 gPad->Update();
2092 }
2093 }
2094 return kFALSE;
2095}
2096
2097////////////////////////////////////////////////////////////////////////////////
2098/// Handle dragging position events.
2099
2101 Int_t /*xroot*/, Int_t /*yroot*/)
2102{
2103 TPad *pad = fCanvas->Pick(x, y, 0);
2104 if (pad) {
2105 pad->cd();
2106 gROOT->SetSelectedPad(pad);
2107 // make sure the pad is highlighted (on Windows)
2108 pad->Update();
2109 }
2110 return action;
2111}
2112
2113////////////////////////////////////////////////////////////////////////////////
2114/// Handle drag enter events.
2115
2117{
2118 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2119 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2120 Atom_t ret = kNone;
2121 for (int i = 0; typelist[i] != kNone; ++i) {
2122 if (typelist[i] == rootObj)
2123 ret = rootObj;
2124 if (typelist[i] == uriObj)
2125 ret = uriObj;
2126 }
2127 return ret;
2128}
2129
2130////////////////////////////////////////////////////////////////////////////////
2131/// Handle drag leave events.
2132
2134{
2135 return kTRUE;
2136}
2137
2138////////////////////////////////////////////////////////////////////////////////
2139/// Slot handling tab switching in the browser, to properly set the canvas
2140/// and the model to the editor.
2141
2143{
2144 if (fEmbedded) {
2146 if (sender) {
2147 TGCompositeFrame *cont = sender->GetTabContainer(id);
2148 if (cont == fParent) {
2149 if (!fEditor)
2151 if (fEditor && ((TGedEditor *)fEditor)->IsMapped()) {
2152 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
2153 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
2154 }
2155 }
2156 }
2157 }
2158}
2159
2160////////////////////////////////////////////////////////////////////////////////
2161/// Update the "View With" submenu based on the currently selected pad content.
2162
2164{
2165 TVirtualPad *pad = fCanvas ? fCanvas->GetSelectedPad() : nullptr;
2166 if (!pad)
2167 pad = fCanvas;
2168
2171 else
2173}
2174
2175////////////////////////////////////////////////////////////////////////////////
2176/// Save a canvas container as a C++ statement(s) on output stream out.
2177
2178void TRootContainer::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
2179{
2180 out << "\n // canvas container\n";
2181 out << " Int_t canvasID = gVirtualX->InitWindow((ULongptr_t)" << GetParent()->GetParent()->GetName()
2182 << "->GetId());\n";
2183 out << " Window_t winC = gVirtualX->GetWindowID(canvasID);\n";
2184 out << " TGCompositeFrame *" << GetName() << " = new TGCompositeFrame(gClient, winC, " << GetParent()->GetName()
2185 << ");\n";
2186}
EEventType
Definition Buttons.h:15
@ kMouseMotion
Definition Buttons.h:23
@ kWheelUp
Definition Buttons.h:18
@ kButton3Up
Definition Buttons.h:19
@ kButton2Motion
Definition Buttons.h:20
@ kButton3Down
Definition Buttons.h:17
@ kButton2Down
Definition Buttons.h:17
@ kKeyPress
Definition Buttons.h:20
@ kButton2Double
Definition Buttons.h:24
@ kArrowKeyRelease
Definition Buttons.h:21
@ kButton1Double
Definition Buttons.h:24
@ kButton3Double
Definition Buttons.h:24
@ kButton1Shift
Definition Buttons.h:18
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
@ kWheelDown
Definition Buttons.h:18
@ kArrowKeyPress
Definition Buttons.h:21
@ kButton2Up
Definition Buttons.h:19
@ kMouseLeave
Definition Buttons.h:23
@ kButton1Down
Definition Buttons.h:17
@ kESC
Definition Buttons.h:22
@ kMouseEnter
Definition Buttons.h:23
Handle_t Atom_t
WM token.
Definition GuiTypes.h:38
EGEventType
Definition GuiTypes.h:60
@ kGKeyPress
Definition GuiTypes.h:61
@ kButtonRelease
Definition GuiTypes.h:61
@ kButtonPress
Definition GuiTypes.h:61
@ kEnterNotify
Definition GuiTypes.h:62
@ kOtherEvent
Definition GuiTypes.h:65
@ kKeyRelease
Definition GuiTypes.h:61
@ kLeaveNotify
Definition GuiTypes.h:62
const Mask_t kButtonPressMask
Definition GuiTypes.h:162
@ kNotifyNormal
Definition GuiTypes.h:220
const Mask_t kExposureMask
Definition GuiTypes.h:166
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kKeyReleaseMask
Definition GuiTypes.h:161
const Mask_t kAnyModifier
Definition GuiTypes.h:211
const Mask_t kKeyPressMask
Definition GuiTypes.h:160
const Mask_t kPointerMotionMask
Definition GuiTypes.h:164
const Mask_t kKeyShiftMask
Definition GuiTypes.h:196
@ kSunkenFrame
Definition GuiTypes.h:384
@ kDoubleBorder
Definition GuiTypes.h:386
@ kFixedWidth
Definition GuiTypes.h:388
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kFixedSize
Definition GuiTypes.h:391
const Handle_t kNone
Definition GuiTypes.h:89
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:169
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:167
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:163
const Mask_t kEnterWindowMask
Definition GuiTypes.h:168
@ kButton4
Definition GuiTypes.h:216
@ kButton2
Definition GuiTypes.h:215
@ kButton5
Definition GuiTypes.h:216
@ kButton3
Definition GuiTypes.h:215
@ kButton1
Definition GuiTypes.h:215
@ kAnyButton
Definition GuiTypes.h:215
R__EXTERN const char gHelpObjects[]
Definition HelpText.h:26
R__EXTERN const char gHelpPullDownMenus[]
Definition HelpText.h:24
R__EXTERN const char gHelpAbout[]
Definition HelpText.h:17
R__EXTERN const char gHelpGraphicsEditor[]
Definition HelpText.h:23
R__EXTERN const char gHelpCanvas[]
Definition HelpText.h:25
R__EXTERN const char gHelpBrowser[]
Definition HelpText.h:18
R__EXTERN const char gHelpPostscript[]
Definition HelpText.h:21
int main()
Definition Prototype.cxx:12
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
constexpr Int_t kFatal
Definition TError.h:50
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
Int_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
Definition TError.cxx:33
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
#define gClient
Definition TGClient.h:157
@ kFDOpen
@ kFDSave
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
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 mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetIconPixmap
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
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 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 UChar_t Atom_t typelist
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 height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t button
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 mx
char name[80]
Definition TGX11.cxx:148
R__EXTERN void * gTQSender
Definition TQObject.h:46
#define gROOT
Definition TROOT.h:426
@ kFilePrint
@ kHelpOnCanvas
@ kFileSaveAs
@ kFileQuit
@ kHelpOnGraphicsEd
@ kFileNewCanvas
@ kHelpOnObjects
@ kHelpOnBrowser
@ kHelpOnMenus
@ kHelpOnPS
@ kHelpAbout
@ kFileOpen
static ToolBarData_t gToolBarData[]
static const char * gOpenTypes[]
ERootCanvasCommands
@ kOptionInterrupt
@ kToolLatex
@ kFitPanel
@ kToolsBuilder
@ kToolPLabel
@ kEditStyle
@ kOptionCanEdit
@ kOptionResizeOpaque
@ kEditClearCanvas
@ kToolPad
@ kFilePrint
@ kViewOpenGL
@ kEditRedo
@ kHelpOnCanvas
@ kToolDiamond
@ kToolCurlyLine
@ kViewFonts
@ kToolLine
@ kFileSaveAsPDF
@ kViewIconify
@ kFileCloseCanvas
@ kViewX3D
@ kFileSaveAs
@ kToolEllipse
@ kToolPsText
@ kToolModify
@ kFileSaveAsGIF
@ kFileQuit
@ kToolArrow
@ kToolArc
@ kToolsRecorder
@ kToolsBrowser
@ kOptionResizeCanvas
@ kToolPave
@ kHelpOnGraphicsEd
@ kFileNewCanvas
@ kOptionFitParams
@ kOptionRefresh
@ kHelpOnObjects
@ kEditCopy
@ kFileSaveAsEPS
@ kInspectRoot
@ kViewToolTips
@ kOptionMoveOpaque
@ kViewEditor
@ kHelpOnBrowser
@ kClassesTree
@ kToolPText
@ kViewToolbar
@ kOptionAutoExec
@ kHelpOnMenus
@ kEditUndo
@ kHelpOnPS
@ kFileSaveAsPNG
@ kViewMarkers
@ kEditClearPad
@ kToolCurlyArc
@ kEditCut
@ kFileSaveAsC
@ kViewColors
@ kToolGraph
@ kViewEventStatus
@ kFileSaveAsBMP
@ kFileSaveAsPS
@ kOptionStatistics
@ kFileSaveAsJPG
@ kOptionHistTitle
@ kFileSaveAsSVG
@ kFileSaveAsTEX
@ kHelpAbout
@ kToolCutG
@ kToolMarker
@ kFileSaveAsRoot
@ kFileOpen
@ kEditPaste
@ kOptionAutoResize
static const char * gSaveAsTypes[]
static ToolBarData_t gToolBarData1[]
static ToolBarData_t gToolBarData[]
static const char * gOpenTypes[]
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2563
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define gGLManager
Definition TVirtualGL.h:159
#define gPad
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
#define gVirtualX
Definition TVirtualX.h:368
Int_t GET_MSG(Long_t val)
@ kCM_MENU
@ kC_COMMAND
@ kCM_BUTTON
Int_t GET_SUBMSG(Long_t val)
#define snprintf
Definition civetweb.c:1579
Bool_t ReturnFromRun() const
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition TBufferFile.h:47
void * ReadObjectAny(const TClass *cast) override
Read object from I/O buffer.
@ kRead
Definition TBuffer.h:73
void SetReadMode()
Set buffer in read mode.
Definition TBuffer.cxx:301
ABC describing GUI independent main window (with menubar, scrollbars and a drawing area).
Definition TCanvasImp.h:30
TCanvas * Canvas() const
Definition TCanvasImp.h:58
TCanvas * fCanvas
Definition TCanvasImp.h:34
friend class TCanvas
Definition TCanvasImp.h:31
The Canvas class.
Definition TCanvas.h:23
UInt_t GetWindowHeight() const
Definition TCanvas.h:166
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition TCanvas.cxx:2417
virtual void ToggleToolTips()
Toggle tooltip display.
Definition TCanvas.cxx:2459
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition TCanvas.cxx:734
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition TCanvas.cxx:2426
void SetSupportGL(Bool_t support)
Definition TCanvas.h:233
TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj) override
Search for an object at pixel position px,py.
Definition TCanvas.h:187
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition TCanvas.cxx:1661
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition TCanvas.cxx:1807
void SetCanvasImp(TCanvasImp *i)
Set canvas implementation If web-based implementation provided, some internal fields also initialized...
Definition TCanvas.cxx:2156
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition TCanvas.cxx:1228
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition TCanvas.cxx:716
Bool_t GetShowEditor() const
Definition TCanvas.h:154
Bool_t GetAutoExec() const
Definition TCanvas.h:156
virtual void ToggleEditor()
Toggle editor.
Definition TCanvas.cxx:2448
TVirtualPad * GetSelectedPad() const override
Definition TCanvas.h:150
Bool_t GetShowToolTips() const
Definition TCanvas.h:155
void SetName(const char *name="") override
Set canvas name.
Definition TCanvas.cxx:2018
void Paint(Option_t *option="") override
Paint canvas.
Definition TCanvas.cxx:1536
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2486
Bool_t OpaqueMoving() const override
Definition TCanvas.h:184
void Flush()
Flush canvas buffers.
Definition TCanvas.cxx:1141
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition TCanvas.cxx:1528
Bool_t UseGL() const
Definition TCanvas.h:232
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition TCanvas.cxx:1754
virtual void ToggleToolBar()
Toggle toolbar.
Definition TCanvas.cxx:2437
Bool_t OpaqueResizing() const override
Definition TCanvas.h:185
Draw inheritance tree and their relations for a list of classes.
Definition TClassTree.h:22
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
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:2994
Draw the ROOT Color Wheel.
Definition TColorWheel.h:23
Drag and drop data container.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:503
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.
Definition TEnv.cxx:744
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:3787
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
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
virtual Int_t GetVsbPosition() const
Get position of vertical scrollbar.
TGViewPort * GetViewPort() const
Definition TGCanvas.h:217
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:223
UInt_t GetDisplayHeight() const
Get display height.
Definition TGClient.cxx:274
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
Int_t MustCleanup() const override
Definition TGFrame.h:362
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
TGCompositeFrame(const TGCompositeFrame &)=delete
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1249
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1196
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1064
void SetEditable(Bool_t on=kTRUE) override
Switch ON/OFF edit mode.
Definition TGFrame.cxx:940
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1014
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1035
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1182
A frame with handles that allow it to be undocked (i.e.
void DockContainer(Int_t del=kTRUE)
Dock container back to TGDockableFrame.
void AddFrame(TGFrame *f, TGLayoutHints *hints) override
Add frame to dockable frame container. Frame and hints are NOT adopted.
void SetWindowName(const char *name) override
Set window name so it appear as title of the undock window.
void EnableHide(Bool_t onoff)
Enable hiding.
Bool_t IsUndocked() const
System file browser, used as TRootBrowser plug-in.
void Selected(char *)
A ROOT File has been selected in TGHtmlBrowser.
This class creates a file selection dialog.
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:331
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:621
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition TGFrame.cxx:435
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:585
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:268
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
UInt_t GetHeight() const
Definition TGFrame.h:227
virtual void SetWidth(UInt_t w)
Definition TGFrame.h:248
void SetDNDTarget(Bool_t onoff)
Definition TGFrame.h:272
UInt_t GetWidth() const
Definition TGFrame.h:226
virtual void SetHeight(UInt_t h)
Definition TGFrame.h:249
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition TG3DLine.h:18
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
Atom_t * fDNDTypeList
handles DND types
Definition TGFrame.h:415
virtual void SendCloseMessage()
Send close message to self.
Definition TGFrame.cxx:1736
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition TGFrame.cxx:1850
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1793
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1780
const char * GetWindowName() const
Definition TGFrame.h:478
The TGMenu.h header contains all different menu classes.
Definition TGMenu.h:282
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=nullptr)
Add popup menu to menu bar.
Definition TGMenu.cxx:414
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
This class creates a popup menu object.
Definition TGMenu.h:110
virtual void AddLabel(TGHotString *s, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu label to the menu.
Definition TGMenu.cxx:1091
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition TGMenu.cxx:1841
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:1148
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition TGMenu.cxx:1778
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1720
virtual void EnableEntry(Int_t id)
Enable entry. By default entries are enabled.
Definition TGMenu.cxx:1701
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition TGMenu.cxx:1803
virtual void Associate(const TGWindow *w)
Definition TGMenu.h:206
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1056
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=nullptr, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu entry.
Definition TGMenu.cxx:986
Provides a StatusBar widget.
Definition TGStatusBar.h:21
virtual void SetText(TGString *text, Int_t partidx=0)
Set text in partition partidx in status bar.
virtual void SetParts(Int_t npart)
Divide the status bar in npart equal sized parts.
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
Definition TGTab.h:46
A toolbar is a composite frame that contains TGPictureButtons.
Definition TGToolBar.h:33
virtual TGButton * AddButton(const TGWindow *w, ToolBarData_t *button, Int_t spacing=0)
Add button to toolbar.
Definition TGToolBar.cxx:91
void Cleanup() override
Cleanup and delete all objects contained in this composite frame.
A tooltip can be a one or multiple lines help text that is displayed in a window when the mouse curso...
Definition TGToolTip.h:24
void Hide()
Hide tool tip window.
void SetPosition(Int_t x, Int_t y)
Set popup position within specified frame (as specified in the ctor).
void SetText(const char *new_text)
Set new tool tip text.
void Reset()
Reset tool tip popup delay timer.
A vertical 3D line is a line that can be used to separate groups of widgets.
Definition TG3DLine.h:33
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:150
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
@ kEditEnable
allow edit of this window
Definition TGWindow.h:56
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
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:293
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
static TGuiBuilder * Instance()
return an instance of TGuiBuilder object
An abstract interface to image processing library.
Definition TImage.h:29
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition TImage.cxx:117
static TImage * Create()
Create an image.
Definition TImage.cxx:34
A doubly linked list.
Definition TList.h:38
static void DisplayMarkerTypes()
Display the table of markers with their numbers.
Definition TMarker.cxx:102
Mother of all ROOT objects.
Definition TObject.h:42
virtual void Inspect() const
Dump contents of this object in a graphics canvas.
Definition TObject.cxx:567
static TClass * Class()
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:546
virtual TClass * IsA() const
Definition TObject.h:248
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:290
The most important graphics class in the ROOT system.
Definition TPad.h:28
Double_t GetAspectRatio() const override
Definition TPad.h:224
void Modified(Bool_t flag=true) override
Mark pad modified Will be repainted when TCanvas::Update() will be called next time.
Definition TPad.cxx:7306
Bool_t HasFixedAspectRatio() const override
Definition TPad.h:270
virtual void SetGLDevice(Int_t dev)
Definition TPad.h:370
void SaveAs(const char *filename="", Option_t *option="") const override
Save the pad content in a file.
Definition TPad.cxx:5753
void Print(const char *filename="") const override
This method is equivalent to SaveAs("filename"). See TPad::SaveAs for details.
Definition TPad.cxx:4763
Longptr_t ExecPlugin(int nargs)
Int_t LoadPlugin()
Load the plugin library for this handler.
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.
This class creates a ROOT object browser, constituted by three main tabs.
This class creates a main window with menubar, scrollbars and a drawing area.
Definition TRootCanvas.h:34
TGToolBar * fToolBar
icon button toolbar
Definition TRootCanvas.h:62
UInt_t GetCwidth() const
Return width of canvas container.
void AdjustSize()
Keep the same canvas size while docking/undocking toolbar.
Bool_t fAutoFit
when true canvas container keeps same size as canvas
Definition TRootCanvas.h:79
TGPopupMenu * fEditMenu
edit menu
Definition TRootCanvas.h:44
friend class TRootContainer
Definition TRootCanvas.h:36
void CreateEditor()
Create embedded editor.
Bool_t HasEditor() const override
Returns kTRUE if the editor is shown.
Bool_t HandleContainerKey(Event_t *ev)
Handle keyboard events in the canvas container.
UInt_t GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h) override
Gets the size and position of the window containing the canvas.
void Close() override
Called via TCanvasImp interface by TCanvas.
Bool_t HandleDNDDrop(TDNDData *data) override
Handle drop events.
void Iconify() override
void SetStatusText(const char *txt=nullptr, Int_t partidx=0) override
Set text in status bar.
TGLayoutHints * fMainFrameLayout
layout for main frame
Definition TRootCanvas.h:64
Bool_t HandleContainerButton(Event_t *ev)
Handle mouse button events in the canvas container.
Bool_t HandleContainerCrossing(Event_t *ev)
Handle enter/leave events. Only leave is activated at the moment.
UInt_t GetCheight() const
Return height of canvas container.
TGDockableFrame * fToolDock
dockable frame holding the toolbar
Definition TRootCanvas.h:71
void RaiseWindow() override
Put canvas window on top of the window stack.
void ShowEditor(Bool_t show=kTRUE) override
Show or hide side frame.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Handle menu and other command generated by the user.
void ReallyDelete() override
Really delete the canvas and this GUI.
void ShowMenuBar(Bool_t show=kTRUE) override
Show or hide menubar.
Atom_t HandleDNDEnter(Atom_t *typelist) override
Handle drag enter events.
void ShowStatusBar(Bool_t show=kTRUE) override
Show or hide statusbar.
TGHorizontal3DLine * fHorizontal1
toolbar separator
Definition TRootCanvas.h:67
TGLayoutHints * fEditorLayout
layout for editor frame
Definition TRootCanvas.h:59
TGPopupMenu * fToolsMenu
tools menu
Definition TRootCanvas.h:49
TGLayoutHints * fMenuBarItemLayout
layout hints for menu in menubar
Definition TRootCanvas.h:52
Int_t fCanvasID
index in fWindows array of TGX11
Definition TRootCanvas.h:78
const TGPicture * fIconPic
icon picture
Definition TRootCanvas.h:73
void SetCanvasSize(UInt_t w, UInt_t h) override
Set size of canvas container.
void SetWindowSize(UInt_t w, UInt_t h) override
Set size of canvas (units in pixels).
void PrintCanvas()
Print the canvas.
TRootCanvas(const TRootCanvas &)=delete
void ShowToolBar(Bool_t show=kTRUE) override
Show or hide toolbar.
Bool_t HasToolBar() const override
Returns kTRUE if the tool bar is shown.
void Activated(Int_t id)
Slot handling tab switching in the browser, to properly set the canvas and the model to the editor.
TGHorizontal3DLine * fToolBarSep
toolbar separator
Definition TRootCanvas.h:63
TGPopupMenu * fViewWithMenu
view with... cascade submenu
Definition TRootCanvas.h:47
TGPopupMenu * fEditClearMenu
clear cascade submenu
Definition TRootCanvas.h:45
void ShowToolTips(Bool_t show=kTRUE) override
Enable or disable tooltip info.
Bool_t HasToolTips() const override
Returns kTRUE if the tooltips are enabled.
TRootContainer * fCanvasContainer
container in canvas widget
Definition TRootCanvas.h:40
Bool_t fEmbedded
true if embedded in any other frame (e.g. in the browser)
Definition TRootCanvas.h:77
Bool_t HandleContainerDoubleClick(Event_t *ev)
Handle mouse button double click events in the canvas container.
TGLayoutHints * fHorizontal1Layout
layout hints for separator
Definition TRootCanvas.h:70
TGVertical3DLine * fVertical2
toolbar vertical separator
Definition TRootCanvas.h:66
TGLayoutHints * fMenuBarLayout
menubar layout hints
Definition TRootCanvas.h:51
void FitCanvas()
Fit canvas container to current window size.
Bool_t HandleContainerMotion(Event_t *ev)
Handle mouse motion event in the canvas container.
TGCanvas * fCanvasWindow
canvas widget
Definition TRootCanvas.h:39
TGLayoutHints * fMenuBarHelpLayout
layout hint for help menu in menubar
Definition TRootCanvas.h:53
TGPopupMenu * fViewMenu
view menu
Definition TRootCanvas.h:46
TGStatusBar * fStatusBar
statusbar widget
Definition TRootCanvas.h:55
TGPopupMenu * fOptionMenu
option menu
Definition TRootCanvas.h:48
TGLayoutHints * fDockLayout
layout hints for dockable frame widget
Definition TRootCanvas.h:72
TGPopupMenu * fHelpMenu
help menu
Definition TRootCanvas.h:50
void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
Display a tooltip with infos about the primitive below the cursor.
void CreateCanvas(const char *name)
Create the actual canvas.
TGLayoutHints * fVertical1Layout
layout hints for separator
Definition TRootCanvas.h:68
Bool_t HasStatusBar() const override
Returns kTRUE if the status bar is shown.
Bool_t HandleContainerConfigure(Event_t *ev)
Handle configure (i.e. resize) event.
Bool_t HasMenuBar() const override
Returns kTRUE if the menu bar is shown.
TGCompositeFrame * fMainFrame
main frame containing canvas and side frame
Definition TRootCanvas.h:60
Int_t InitWindow() override
Called by TCanvas ctor to get window indetifier.
void UpdateViewWithMenu()
Update the "View With" submenu based on the currently selected pad content.
TGLayoutHints * fVertical2Layout
layout hints for separator
Definition TRootCanvas.h:69
TVirtualPadEditor * fEditor
pointer to currently loaded pad editor
Definition TRootCanvas.h:76
TGMenuBar * fMenuBar
menubar
Definition TRootCanvas.h:41
void SetWindowPosition(Int_t x, Int_t y) override
Set canvas position (units in pixels).
Bool_t HandleContainerExpose(Event_t *ev)
Handle expose events.
TGLayoutHints * fCanvasLayout
layout for canvas widget
Definition TRootCanvas.h:54
TGLayoutHints * fToolBarLayout
layout for toolbar widget
Definition TRootCanvas.h:61
Bool_t HandleDNDLeave() override
Handle drag leave events.
TGCompositeFrame * fEditorFrame
side frame for current pad editor
Definition TRootCanvas.h:58
~TRootCanvas() override
Delete ROOT basic canvas.
TGToolTip * fToolTip
tooltip for object info
Definition TRootCanvas.h:74
TGPopupMenu * fFileMenu
file menu
Definition TRootCanvas.h:42
TGPopupMenu * fFileSaveMenu
save cascade submenu
Definition TRootCanvas.h:43
Atom_t HandleDNDPosition(Int_t x, Int_t y, Atom_t action, Int_t xroot, Int_t yroot) override
Handle dragging position events.
void SetWindowTitle(const char *newTitle) override
Change title on window.
void CloseWindow() override
In case window is closed via WM we get here.
Int_t fButton
currently pressed button
Definition TRootCanvas.h:80
TGLayoutHints * fStatusBarLayout
layout hints for statusbar
Definition TRootCanvas.h:56
TGVertical3DLine * fVertical1
toolbar vertical separator
Definition TRootCanvas.h:65
Bool_t HandleCrossing(Event_t *ev) override
void SetEditable(Bool_t) override
Switch ON/OFF edit mode.
Bool_t HandleDoubleClick(Event_t *ev) override
TRootContainer(TRootCanvas *c, Window_t id, const TGWindow *parent)
Create a canvas container.
Bool_t HandleMotion(Event_t *ev) override
Bool_t HandleKey(Event_t *ev) override
Bool_t HandleConfigureNotify(Event_t *ev) override
This event is generated when the frame is resized.
Bool_t HandleExpose(Event_t *ev) override
void SavePrimitive(std::ostream &out, Option_t *="") override
Save a canvas container as a C++ statement(s) on output stream out.
TRootCanvas * fCanvas
Bool_t HandleButton(Event_t *ev) override
Directly handle scroll mouse buttons (4 and 5), only pass buttons 1, 2 and 3 on to the TCanvas.
A TRootHelpDialog is used to display help text (or any text in a dialog window).
Basic string class.
Definition TString.h:138
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2250
const char * Data() const
Definition TString.h:384
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:713
@ kLeading
Definition TString.h:284
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2384
Int_t GetOptStat() const
Definition TStyle.h:247
void SetOptTitle(Int_t tit=1)
Definition TStyle.h:338
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition TStyle.cxx:1641
Int_t GetOptTitle() const
Definition TStyle.h:248
Int_t GetOptFit() const
Definition TStyle.h:246
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
Definition TStyle.cxx:1594
virtual FILE * TempFileName(TString &base, const char *dir=nullptr, const char *suffix=nullptr)
Create a secure temporary file by appending a unique 6 letter string to base.
Definition TSystem.cxx:1510
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:651
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1868
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:872
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:435
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:881
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:414
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1392
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition TSystem.cxx:1493
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition TTimer.cxx:261
This class represents a WWW compatible URL.
Definition TUrl.h:33
const char * GetFile() const
Definition TUrl.h:69
Abstract base class used by ROOT graphics editor.
static TVirtualPadEditor * LoadEditor()
Static function returning a pointer to a new pad editor.
virtual void Hide()
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
virtual void SetGlobal(Bool_t)
virtual void Show()
static void Terminate()
Close the global pad editor. Static method.
small helper class to store/restore gPad context in TPad methods
Definition TVirtualPad.h:61
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
static TClass * Class()
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:704
Event structure.
Definition GuiTypes.h:175
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:176
Int_t fCount
if non-zero, at least this many more exposes
Definition GuiTypes.h:184
UInt_t fState
key or button mask
Definition GuiTypes.h:182
UInt_t fCode
key or button code
Definition GuiTypes.h:181
TMarker m
Definition textangle.C:8