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
203// clang-format off
204static const char *gOpenTypes[] = { "ROOT files", "*.root",
205 "All files", "*",
206 0, 0 };
207
208static const char *gSaveAsTypes[] = { "PDF", "*.pdf",
209 "SVG", "*.svg",
210 "TeX", "*.tex",
211 "PostScript", "*.ps",
212 "Encapsulated PostScript", "*.eps",
213 "PNG", "*.png",
214 "JPEG", "*.jpg",
215 "GIF", "*.gif",
216 "BMP", "*.bmp",
217 "ROOT macros", "*.C",
218 "ROOT files", "*.root",
219 "XML", "*.xml",
220 "HTML", "*.html",
221 "XPM", "*.xpm",
222 "TIFF", "*.tiff",
223 "XCF", "*.xcf",
224 "All files", "*",
225 0, 0 };
226
228 // { filename, tooltip, staydown, id, button}
229 { "newcanvas.xpm", "New", kFALSE, kFileNewCanvas, 0 },
230 { "open.xpm", "Open", kFALSE, kFileOpen, 0 },
231 { "save.xpm", "Save As", kFALSE, kFileSaveAs, 0 },
232 { "printer.xpm", "Print", kFALSE, kFilePrint, 0 },
233 { "", "", kFALSE, -1, 0 },
234 { "interrupt.xpm", "Interrupt", kFALSE, kOptionInterrupt,0 },
235 { "refresh2.xpm", "Refresh", kFALSE, kOptionRefresh, 0 },
236 { "", "", kFALSE, -1, 0 },
237 { "inspect.xpm", "Inspect", kFALSE, kInspectRoot, 0 },
238 { "browser.xpm", "Browser", kFALSE, kToolsBrowser, 0 },
239 { 0, 0, kFALSE, 0, 0 }
240};
241
243 { "pointer.xpm", "Modify", kFALSE, kToolModify, 0 },
244 { "arc.xpm", "Arc", kFALSE, kToolArc, 0 },
245 { "line.xpm", "Line", kFALSE, kToolLine, 0 },
246 { "arrow.xpm", "Arrow", kFALSE, kToolArrow, 0 },
247 { "diamond.xpm", "Diamond", kFALSE, kToolDiamond, 0 },
248 { "ellipse.xpm", "Ellipse", kFALSE, kToolEllipse, 0 },
249 { "pad.xpm", "Pad", kFALSE, kToolPad, 0 },
250 { "pave.xpm", "Pave", kFALSE, kToolPave, 0 },
251 { "pavelabel.xpm", "Pave Label", kFALSE, kToolPLabel, 0 },
252 { "pavetext.xpm", "Pave Text", kFALSE, kToolPText, 0 },
253 { "pavestext.xpm", "Paves Text", kFALSE, kToolPsText, 0 },
254 { "graph.xpm", "Graph", kFALSE, kToolGraph, 0 },
255 { "curlyline.xpm", "Curly Line", kFALSE, kToolCurlyLine, 0 },
256 { "curlyarc.xpm", "Curly Arc", kFALSE, kToolCurlyArc, 0 },
257 { "latex.xpm", "Text/Latex", kFALSE, kToolLatex, 0 },
258 { "marker.xpm", "Marker", kFALSE, kToolMarker, 0 },
259 { "cut.xpm", "Graphical Cut", kFALSE, kToolCutG, 0 },
260 { 0, 0, kFALSE, 0, 0 }
261};
262// clang-format on
263
264//////////////////////////////////////////////////////////////////////////
265// //
266// TRootContainer //
267// //
268// Utility class used by TRootCanvas. The TRootContainer is the frame //
269// embedded in the TGCanvas widget. The ROOT graphics goes into this //
270// frame. This class is used to enable input events on this graphics //
271// frame and forward the events to the TRootCanvas handlers. //
272// //
273//////////////////////////////////////////////////////////////////////////
274
276private:
277 TRootCanvas *fCanvas; // pointer back to canvas imp
278public:
279 TRootContainer(TRootCanvas *c, Window_t id, const TGWindow *parent);
280
281 Bool_t HandleButton(Event_t *ev) override;
288 { return fCanvas->HandleContainerKey(ev); }
295 void SavePrimitive(std::ostream &out, Option_t * = "") override;
296 void SetEditable(Bool_t) override { }
297};
298
299////////////////////////////////////////////////////////////////////////////////
300/// Create a canvas container.
301
316
317////////////////////////////////////////////////////////////////////////////////
318/// Directly handle scroll mouse buttons (4 and 5), only pass buttons
319/// 1, 2 and 3 on to the TCanvas.
320
322{
324 UInt_t page = vp->GetHeight()/4;
326
327 gVirtualX->SetInputFocus(GetMainFrame()->GetId());
328
329 if (event->fCode == kButton4) {
330 //scroll up
332 if (newpos < 0) newpos = 0;
334// return kTRUE;
335 }
336 if (event->fCode == kButton5) {
337 // scroll down
340// return kTRUE;
341 }
342 return fCanvas->HandleContainerButton(event);
343}
344
345
346////////////////////////////////////////////////////////////////////////////////
347/// Create a basic ROOT canvas.
348
359
360////////////////////////////////////////////////////////////////////////////////
361/// Create a basic ROOT canvas.
362
374
375////////////////////////////////////////////////////////////////////////////////
376/// Create the actual canvas.
377
379{
380 fButton = 0;
381 fAutoFit = kTRUE; // check also menu entry
382 fEditor = 0;
384
385 // Create menus
394
395 static Int_t img = 0;
396
397 if (!img) {
401 img = itmp ? 1 : -1;
402 if (itmp) {
403 delete itmp;
404 itmp=NULL;
405 }
407 }
408 if (img > 0) {
412 }
413
416
418 fFileMenu->AddEntry("&New Canvas", kFileNewCanvas);
419 fFileMenu->AddEntry("&Open...", kFileOpen);
420 fFileMenu->AddEntry("&Close Canvas", kFileCloseCanvas);
423 fFileMenu->AddEntry("Save &As...", kFileSaveAs);
425 fFileMenu->AddEntry("&Print...", kFilePrint);
427 fFileMenu->AddEntry("&Quit ROOT", kFileQuit);
428
432
434 fEditMenu->AddEntry("&Style...", kEditStyle);
436 fEditMenu->AddEntry("Cu&t", kEditCut);
437 fEditMenu->AddEntry("&Copy", kEditCopy);
438 fEditMenu->AddEntry("&Paste", kEditPaste);
442 fEditMenu->AddEntry("&Undo", kEditUndo);
443 fEditMenu->AddEntry("&Redo", kEditRedo);
444
450
454
456 fViewMenu->AddEntry("&Editor", kViewEditor);
457 fViewMenu->AddEntry("&Toolbar", kViewToolbar);
458 fViewMenu->AddEntry("Event &Statusbar", kViewEventStatus);
459 fViewMenu->AddEntry("T&oolTip Info", kViewToolTips);
461 fViewMenu->AddEntry("&Colors", kViewColors);
462 fViewMenu->AddEntry("&Fonts", kViewFonts);
463 fViewMenu->AddEntry("&Markers", kViewMarkers);
465 fViewMenu->AddEntry("&Iconify", kViewIconify);
467 fViewMenu->AddPopup("&View With", fViewWithMenu);
468
470
472 fOptionMenu->AddEntry("&Auto Resize Canvas", kOptionAutoResize);
473 fOptionMenu->AddEntry("&Resize Canvas", kOptionResizeCanvas);
474 fOptionMenu->AddEntry("&Move Opaque", kOptionMoveOpaque);
475 fOptionMenu->AddEntry("Resize &Opaque", kOptionResizeOpaque);
477 fOptionMenu->AddEntry("&Interrupt", kOptionInterrupt);
478 fOptionMenu->AddEntry("R&efresh", kOptionRefresh);
480 fOptionMenu->AddEntry("&Pad Auto Exec", kOptionAutoExec);
482 fOptionMenu->AddEntry("&Statistics", kOptionStatistics);
483 fOptionMenu->AddEntry("Histogram &Title", kOptionHistTitle);
484 fOptionMenu->AddEntry("&Fit Parameters", kOptionFitParams);
485 fOptionMenu->AddEntry("Can Edit &Histograms", kOptionCanEdit);
486
487 // Opaque options initialized in InitWindow()
489 if (gStyle->GetOptStat())
491 if (gStyle->GetOptTitle())
493 if (gStyle->GetOptFit())
495 if (gROOT->GetEditHistograms())
497
499 fToolsMenu->AddEntry("&Inspect ROOT", kInspectRoot);
500 fToolsMenu->AddEntry("&Class Tree", kClassesTree);
501 fToolsMenu->AddEntry("&Fit Panel", kFitPanel);
502 fToolsMenu->AddEntry("&Start Browser", kToolsBrowser);
503 fToolsMenu->AddEntry("&Gui Builder", kToolsBuilder);
504 fToolsMenu->AddEntry("&Event Recorder", kToolsRecorder);
505
507 fHelpMenu->AddLabel("Basic Help On...");
509 fHelpMenu->AddEntry("&Canvas", kHelpOnCanvas);
510 fHelpMenu->AddEntry("&Menus", kHelpOnMenus);
511 fHelpMenu->AddEntry("&Graphics Editor", kHelpOnGraphicsEd);
512 fHelpMenu->AddEntry("&Browser", kHelpOnBrowser);
513 fHelpMenu->AddEntry("&Objects", kHelpOnObjects);
514 fHelpMenu->AddEntry("&PostScript", kHelpOnPS);
516 fHelpMenu->AddEntry("&About ROOT...", kHelpAbout);
517
518 // This main frame will process the menu commands
519 fFileMenu->Associate(this);
521 fEditMenu->Associate(this);
523 fViewMenu->Associate(this);
525 fViewWithMenu->Connect("PoppedUp()", "TRootCanvas", this, "UpdateViewWithMenu()");
526 fOptionMenu->Associate(this);
527 fToolsMenu->Associate(this);
528 fHelpMenu->Associate(this);
529
530 // Create menubar layout hints
534
535 // Create menubar
536 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
543
545
549
550 // Create toolbar dock
551 fToolDock = new TGDockableFrame(this);
555
556 // will allocate it later
557 fToolBar = 0;
558 fVertical1 = 0;
559 fVertical2 = 0;
562
566
567 fMainFrame = new TGCompositeFrame(this, GetWidth() + 4, GetHeight() + 4,
570
571 // Create editor frame that will host the pad editor
575
576 // Create canvas and canvas container that will host the ROOT graphics
579
580 fCanvasID = -1;
581
582 if (fCanvas->UseGL()) {
584 //first, initialize GL (if not yet)
585 if (!gGLManager) {
586 TString x = "win32";
587 if (gVirtualX->InheritsFrom("TGX11"))
588 x = "x11";
589 else if (gVirtualX->InheritsFrom("TGCocoa"))
590 x = "osx";
591
592 TPluginHandler *ph = gROOT->GetPluginManager()->FindHandler("TGLManager", x);
593
594 if (ph && ph->LoadPlugin() != -1) {
595 if (!ph->ExecPlugin(0))
596 Error("CreateCanvas", "GL manager plugin failed");
597 }
598 }
599
600 if (gGLManager) {
602 if (fCanvasID != -1) {
603 //Create gl context.
604 const Int_t glCtx = gGLManager->CreateGLContext(fCanvasID);
605 if (glCtx != -1) {
607 fCanvas->SetGLDevice(glCtx);//Now, fCanvas is responsible for context deletion!
608 } else
609 Error("CreateCanvas", "GL context creation failed.");
610 } else
611 Error("CreateCanvas", "GL window creation failed\n");
612 }
613 }
614
615 if (fCanvasID == -1)
617
618 Window_t win = gVirtualX->GetWindowID(fCanvasID);
622
625
626 // create the tooltip with a timeout of 250 ms
628
629 fCanvas->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
630 "TRootCanvas", this,
631 "EventInfo(Int_t, Int_t, Int_t, TObject*)");
632
633 // Create status bar
634 int parts[] = { 33, 10, 10, 47 };
635 fStatusBar = new TGStatusBar(this, 10, 10);
637
639
641
642 // Misc
645 fIconPic = SetIconPixmap("macro_s.xpm");
646 SetClassHints("ROOT", "Canvas");
647
650
651 // by default status bar, tool bar and pad editor are hidden
656
659
660 // we need to use GetDefaultSize() to initialize the layout algorithm...
662
663 gVirtualX->SetDNDAware(fId, fDNDTypeList);
665}
666
667////////////////////////////////////////////////////////////////////////////////
668/// Delete ROOT basic canvas. Order is significant. Delete in reverse
669/// order of creation.
670
672{
673 delete fToolTip;
674 if (fIconPic) gClient->FreePicture(fIconPic);
675 if (fEditor && !fEmbedded) delete fEditor;
676 if (fToolBar) {
677 Disconnect(fToolDock, "Docked()", this, "AdjustSize()");
678 Disconnect(fToolDock, "Undocked()", this, "AdjustSize()");
679 fToolBar->Cleanup();
680 delete fToolBar;
681 }
682
683 if (!MustCleanup()) {
684 delete fStatusBar;
685 delete fStatusBarLayout;
686 delete fCanvasContainer;
687 delete fCanvasWindow;
688
689 delete fEditorFrame;
690 delete fEditorLayout;
691 delete fMainFrame;
692 delete fMainFrameLayout;
693 delete fToolBarSep;
694 delete fToolDock;
695 delete fToolBarLayout;
696 delete fHorizontal1;
697 delete fHorizontal1Layout;
698
699 delete fMenuBar;
700 delete fMenuBarLayout;
701 delete fMenuBarItemLayout;
702 delete fMenuBarHelpLayout;
703 delete fCanvasLayout;
704 delete fDockLayout;
705 }
706
707 delete fFileMenu;
708 delete fFileSaveMenu;
709 delete fEditMenu;
710 delete fEditClearMenu;
711 delete fViewMenu;
712 delete fViewWithMenu;
713 delete fOptionMenu;
714 delete fToolsMenu;
715 delete fHelpMenu;
716}
717
718////////////////////////////////////////////////////////////////////////////////
719/// Called via TCanvasImp interface by TCanvas.
720
722{
724 if(gged && gged->GetCanvas() == fCanvas) {
725 if (fEmbedded) {
726 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
727 ((TGedEditor *)gged)->SetCanvas(0);
728 }
729 else gged->Hide();
730 }
731
732 gVirtualX->CloseWindow();
733}
734
735////////////////////////////////////////////////////////////////////////////////
736/// Really delete the canvas and this GUI.
737
739{
741 if(gged && gged->GetCanvas() == fCanvas) {
742 if (fEmbedded) {
743 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
744 ((TGedEditor *)gged)->SetCanvas(0);
745 }
746 else gged->Hide();
747 }
748
749 fToolTip->Hide();
750 Disconnect(fCanvas, "ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
751 this, "EventInfo(Int_t, Int_t, Int_t, TObject*)");
752
754 fCanvas->Clear();
755 fCanvas->SetName("");
756 if (gPad && gPad->GetCanvas() == fCanvas)
757 gPad = nullptr;
758 delete this;
759}
760
761////////////////////////////////////////////////////////////////////////////////
762/// In case window is closed via WM we get here.
763
768
769////////////////////////////////////////////////////////////////////////////////
770/// Return width of canvas container.
771
776
777////////////////////////////////////////////////////////////////////////////////
778/// Return height of canvas container.
779
784
785////////////////////////////////////////////////////////////////////////////////
786/// Gets the size and position of the window containing the canvas. This
787/// size includes the menubar and borders.
788
790{
791 gVirtualX->GetWindowSize(fId, x, y, w, h);
792
794 gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(),
795 0, 0, x, y, childdum);
796 if (!fCanvas->GetShowEditor()) return 0;
797 return fEditorFrame->GetWidth();
798}
799
800////////////////////////////////////////////////////////////////////////////////
801/// Set text in status bar.
802
807
808////////////////////////////////////////////////////////////////////////////////
809/// Handle menu and other command generated by the user.
810
812{
814 TList *lc;
815
816 switch (GET_MSG(msg)) {
817
818 case kC_COMMAND:
819
820 switch (GET_SUBMSG(msg)) {
821
822 case kCM_BUTTON:
823 case kCM_MENU:
824
825 switch (parm1) {
826 // Handle toolbar items...
827 case kToolModify:
828 gROOT->SetEditorMode();
829 break;
830 case kToolArc:
831 gROOT->SetEditorMode("Arc");
832 break;
833 case kToolLine:
834 gROOT->SetEditorMode("Line");
835 break;
836 case kToolArrow:
837 gROOT->SetEditorMode("Arrow");
838 break;
839 case kToolDiamond:
840 gROOT->SetEditorMode("Diamond");
841 break;
842 case kToolEllipse:
843 gROOT->SetEditorMode("Ellipse");
844 break;
845 case kToolPad:
846 gROOT->SetEditorMode("Pad");
847 break;
848 case kToolPave:
849 gROOT->SetEditorMode("Pave");
850 break;
851 case kToolPLabel:
852 gROOT->SetEditorMode("PaveLabel");
853 break;
854 case kToolPText:
855 gROOT->SetEditorMode("PaveText");
856 break;
857 case kToolPsText:
858 gROOT->SetEditorMode("PavesText");
859 break;
860 case kToolGraph:
861 gROOT->SetEditorMode("PolyLine");
862 break;
863 case kToolCurlyLine:
864 gROOT->SetEditorMode("CurlyLine");
865 break;
866 case kToolCurlyArc:
867 gROOT->SetEditorMode("CurlyArc");
868 break;
869 case kToolLatex:
870 gROOT->SetEditorMode("Text");
871 break;
872 case kToolMarker:
873 gROOT->SetEditorMode("Marker");
874 break;
875 case kToolCutG:
876 gROOT->SetEditorMode("CutG");
877 break;
878
879 // Handle File menu items...
880 case kFileNewCanvas:
881 gROOT->MakeDefCanvas();
882 break;
883 case kFileOpen:
884 {
885 static TString dir(".");
887 fi.fFileTypes = gOpenTypes;
888 fi.SetIniDir(dir);
890 if (!fi.fFilename) return kTRUE;
891 dir = fi.fIniDir;
892 TFile::Open(fi.fFilename, "update");
893 TIter next(gROOT->GetListOfBrowsers());
894 TBrowser *b;
895 while ((b = (TBrowser *)next())) {
896 TRootBrowser *rb = dynamic_cast<TRootBrowser *>(b->GetBrowserImp());
897 if (rb) {
898 TGFileBrowser *fb = dynamic_cast<TGFileBrowser *>(rb->GetActBrowser());
899 if (fb)
900 fb->Selected(0);
901 }
902 }
903 gROOT->RefreshBrowsers();
904 }
905 break;
906 case kFileSaveAs:
907 {
909 static TString dir(".");
910 static Int_t typeidx = 0;
911 static Bool_t overwr = kFALSE;
913 TString defaultType = gEnv->GetValue("Canvas.SaveAsDefaultType", ".pdf");
914 if (typeidx == 0) {
915 for (int i=1;gSaveAsTypes[i];i+=2) {
916 TString ftype = gSaveAsTypes[i];
917 if (ftype.EndsWith(defaultType.Data())) {
918 typeidx = i-1;
919 break;
920 }
921 }
922 }
923 fi.fFileTypes = gSaveAsTypes;
924 fi.SetIniDir(dir);
925 fi.fFileTypeIdx = typeidx;
926 fi.fOverwrite = overwr;
929 if (!fi.fFilename) return kTRUE;
931 TString fn = fi.fFilename;
932 TString ft = fi.fFileTypes[fi.fFileTypeIdx+1];
933 // clang-format off
934 dir = fi.fIniDir;
935 typeidx = fi.fFileTypeIdx;
936 overwr = fi.fOverwrite;
937again:
938 if (fn.EndsWith(".root") ||
939 fn.EndsWith(".ps") ||
940 fn.EndsWith(".eps") ||
941 fn.EndsWith(".pdf") ||
942 fn.EndsWith(".html") ||
943 fn.EndsWith(".svg") ||
944 fn.EndsWith(".tex") ||
945 fn.EndsWith(".gif") ||
946 fn.EndsWith(".bmp") ||
947 fn.EndsWith(".xml") ||
948 fn.EndsWith(".xpm") ||
949 fn.EndsWith(".jpg") ||
950 fn.EndsWith(".png") ||
951 fn.EndsWith(".xcf") ||
952 fn.EndsWith(".tiff")) {
953 fCanvas->SaveAs(fn);
954 } else if (fn.EndsWith(".C"))
956 else {
957 if (!appendedType) {
958 if (ft.Index(".") != kNPOS) {
959 fn += ft(ft.Index("."), ft.Length());
961 goto again;
962 }
963 }
964 Warning("ProcessMessage", "file %s cannot be saved with this extension", fi.fFilename);
965 }
966 for (int i = 1; gSaveAsTypes[i]; i += 2) {
967 TString ftype = gSaveAsTypes[i];
968 ftype.ReplaceAll("*.", ".");
969 if (fn.EndsWith(ftype.Data())) {
970 typeidx = i - 1;
971 break;
972 }
973 }
974 }
975 break;
976 case kFileSaveAsRoot:
977 fCanvas->SaveAs(".root");
978 break;
979 case kFileSaveAsC:
981 break;
982 case kFileSaveAsPS:
983 fCanvas->SaveAs();
984 break;
985 case kFileSaveAsEPS:
986 fCanvas->SaveAs(".eps");
987 break;
988 case kFileSaveAsPDF:
989 fCanvas->SaveAs(".pdf");
990 break;
991 case kFileSaveAsHTML:
992 fCanvas->SaveAs(".html");
993 break;
994 case kFileSaveAsSVG:
995 fCanvas->SaveAs(".svg");
996 break;
997 case kFileSaveAsGIF:
998 fCanvas->SaveAs(".gif");
999 break;
1000 case kFileSaveAsJPG:
1001 fCanvas->SaveAs(".jpg");
1002 break;
1003 case kFileSaveAsPNG:
1004 fCanvas->SaveAs(".png");
1005 break;
1006 case kFileSaveAsBMP:
1007 fCanvas->SaveAs(".bmp");
1008 break;
1009 case kFileSaveAsTEX:
1010 fCanvas->SaveAs(".tex");
1011 break;
1012 case kFilePrint:
1013 PrintCanvas();
1014 break;
1015 case kFileCloseCanvas:
1017 break;
1018 case kFileQuit:
1019 if (!gApplication->ReturnFromRun()) {
1023 }
1026 if (TClass::GetClass("TStyleManager", kFALSE, kTRUE))
1027 gROOT->ProcessLine("TStyleManager::Terminate()");
1029 break;
1030
1031 // Handle Edit menu items...
1032 case kEditStyle:
1033 if (!TClass::GetClass("TStyleManager"))
1034 gSystem->Load("libGed");
1035 gROOT->ProcessLine("TStyleManager::Show()");
1036 break;
1037 case kEditCut:
1038 // still noop
1039 break;
1040 case kEditCopy:
1041 // still noop
1042 break;
1043 case kEditPaste:
1044 // still noop
1045 break;
1046 case kEditUndo:
1047 // noop
1048 break;
1049 case kEditRedo:
1050 // noop
1051 break;
1052 case kEditClearPad:
1053 gPad->Clear();
1054 gPad->Modified();
1055 gPad->Update();
1056 break;
1057 case kEditClearCanvas:
1058 fCanvas->Clear();
1059 fCanvas->Modified();
1060 fCanvas->Update();
1061 break;
1062
1063 // Handle View menu items...
1064 case kViewEditor:
1066 break;
1067 case kViewToolbar:
1069 break;
1070 case kViewEventStatus:
1072 break;
1073 case kViewToolTips:
1075 break;
1076 case kViewColors:
1077 {
1078 TVirtualPad *padsav = gPad->GetCanvas();
1079 //This was the code with the old color table
1080 // TCanvas *m = new TCanvas("colors","Color Table");
1081 // TPad::DrawColorTable();
1082 // m->Update();
1083 TColorWheel *wheel = new TColorWheel();
1084 wheel->Draw();
1085
1086 //tp: with Cocoa, window is visible (and repainted)
1087 //before wheel->Draw() was called and you can see "empty"
1088 //canvas.
1089 gPad->Update();
1090 //
1091 if (padsav) padsav->cd();
1092 }
1093 break;
1094 case kViewFonts:
1095 // noop
1096 break;
1097 case kViewMarkers:
1098 {
1099 TVirtualPad *padsav = gPad ? gPad->GetCanvas() : nullptr;
1100 TCanvas *m = new TCanvas("markers","Marker Types",600,200);
1102 m->Update();
1103 if (padsav) padsav->cd();
1104 }
1105 break;
1106 case kViewIconify:
1107 Iconify();
1108 break;
1109 case kViewX3D: {
1110 TVirtualPad *pad = gPad ? gPad : (fCanvas ? fCanvas->GetSelectedPad() : nullptr);
1111 if (!pad)
1112 pad = fCanvas;
1114 pad->GetViewer3D("x3d");
1115 break;
1116 }
1117 case kViewOpenGL:
1118 gPad->GetViewer3D("ogl");
1119 break;
1120
1121 // Handle Option menu items...
1122 case kOptionAutoExec:
1124 if (fCanvas->GetAutoExec()) {
1126 } else {
1128 }
1129 break;
1130 case kOptionAutoResize:
1131 {
1133 int opt = fCanvasContainer->GetOptions();
1134 if (fAutoFit) {
1135 opt &= ~kFixedSize;
1137 } else {
1138 opt |= kFixedSize;
1140 }
1142 // in case of autofit this will generate a configure
1143 // event for the container and this will force the
1144 // update of the TCanvas
1145 //Layout();
1146 }
1147 Layout();
1148 break;
1150 FitCanvas();
1151 break;
1152 case kOptionMoveOpaque:
1153 if (fCanvas->OpaqueMoving()) {
1154 fCanvas->MoveOpaque(0);
1156 } else {
1157 fCanvas->MoveOpaque(1);
1159 }
1160 break;
1162 if (fCanvas->OpaqueResizing()) {
1165 } else {
1168 }
1169 break;
1170 case kOptionInterrupt:
1171 gROOT->SetInterrupt();
1172 break;
1173 case kOptionRefresh:
1174 fCanvas->Paint();
1175 fCanvas->Update();
1176 break;
1177 case kOptionStatistics:
1178 if (gStyle->GetOptStat()) {
1179 gStyle->SetOptStat(0);
1180 delete gPad->FindObject("stats");
1182 } else {
1183 gStyle->SetOptStat(1);
1185 }
1186 gPad->Modified();
1187 fCanvas->Update();
1188 break;
1189 case kOptionHistTitle:
1190 if (gStyle->GetOptTitle()) {
1191 gStyle->SetOptTitle(0);
1192 delete gPad->FindObject("title");
1194 } else {
1195 gStyle->SetOptTitle(1);
1197 }
1198 gPad->Modified();
1199 fCanvas->Update();
1200 break;
1201 case kOptionFitParams:
1202 if (gStyle->GetOptFit()) {
1203 gStyle->SetOptFit(0);
1205 } else {
1206 gStyle->SetOptFit(1);
1208 }
1209 gPad->Modified();
1210 fCanvas->Update();
1211 break;
1212 case kOptionCanEdit:
1213 if (gROOT->GetEditHistograms()) {
1214 gROOT->SetEditHistograms(kFALSE);
1216 } else {
1217 gROOT->SetEditHistograms(kTRUE);
1219 }
1220 break;
1221
1222 // Handle Tools menu items...
1223 case kInspectRoot:
1224 fCanvas->cd();
1225 gROOT->Inspect();
1226 fCanvas->Update();
1227 break;
1228 case kToolsBrowser:
1229 new TBrowser("browser");
1230 break;
1231 case kToolsBuilder:
1233 break;
1234 case kToolsRecorder:
1235 gROOT->ProcessLine("new TGRecorder()");
1236 break;
1237
1238 // Handle Tools menu items...
1239 case kClassesTree:
1240 {
1241 TString cdef;
1242 lc = (TList*)gROOT->GetListOfCanvases();
1243 if (lc->FindObject("ClassTree")) {
1244 cdef = TString::Format("ClassTree_%d", lc->GetSize()+1);
1245 } else {
1246 cdef = "ClassTree";
1247 }
1248 new TClassTree(cdef.Data(), "TObject");
1249 fCanvas->Update();
1250 }
1251 break;
1252
1253 case kFitPanel:
1254 {
1255 // use plugin manager to create instance of TFitEditor
1256 TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
1257 if (handler && handler->LoadPlugin() != -1) {
1258 if (handler->ExecPlugin(2, fCanvas, 0) == 0)
1259 Error("FitPanel", "Unable to crate the FitPanel");
1260 }
1261 else
1262 Error("FitPanel", "Unable to find the FitPanel plug-in");
1263 }
1264 break;
1265
1266 // Handle Help menu items...
1267 case kHelpAbout:
1268 {
1269#ifdef WIN32
1271#else
1272
1273 char str[32];
1274 snprintf(str, 32, "About ROOT %s...", gROOT->GetVersion());
1275 hd = new TRootHelpDialog(this, str, 600, 400);
1276 hd->SetText(gHelpAbout);
1277 hd->Popup();
1278#endif
1279 }
1280 break;
1281 case kHelpOnCanvas:
1282 hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1283 hd->SetText(gHelpCanvas);
1284 hd->Popup();
1285 break;
1286 case kHelpOnMenus:
1287 hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1288 hd->SetText(gHelpPullDownMenus);
1289 hd->Popup();
1290 break;
1291 case kHelpOnGraphicsEd:
1292 hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1293 hd->SetText(gHelpGraphicsEditor);
1294 hd->Popup();
1295 break;
1296 case kHelpOnBrowser:
1297 hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1298 hd->SetText(gHelpBrowser);
1299 hd->Popup();
1300 break;
1301 case kHelpOnObjects:
1302 hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
1303 hd->SetText(gHelpObjects);
1304 hd->Popup();
1305 break;
1306 case kHelpOnPS:
1307 hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
1308 hd->SetText(gHelpPostscript);
1309 hd->Popup();
1310 break;
1311 // clang-format on
1312 }
1313 default:
1314 break;
1315 }
1316 default:
1317 break;
1318 }
1319 return kTRUE;
1320}
1321
1322////////////////////////////////////////////////////////////////////////////////
1323/// Called by TCanvas ctor to get window indetifier.
1324
1334
1335////////////////////////////////////////////////////////////////////////////////
1336/// Set size of canvas container. Units in pixels.
1337/// If w==0 and h==0, set autofit mode
1338
1340{
1341 // turn off autofit, we want to stay at the given size
1342 int opt = fCanvasContainer->GetOptions();
1343 if (!w && !h) {
1344 fAutoFit = kTRUE;
1346 opt &= ~kFixedSize; // turn off fixed size mode
1347 } else {
1348 fAutoFit = kFALSE;
1350 opt |= kFixedSize; // turn on fixed size mode
1351 }
1355 Layout(); // force layout (will update container to given size)
1356 fCanvas->Resize();
1357 fCanvas->Update();
1358}
1359
1360////////////////////////////////////////////////////////////////////////////////
1361/// Set canvas position (units in pixels).
1362
1367
1368////////////////////////////////////////////////////////////////////////////////
1369/// Set size of canvas (units in pixels).
1370
1372{
1373 Resize(w, h);
1374
1375 // Make sure the change of size is really done.
1376 gVirtualX->Update(1);
1377 if (!gThreadXAR) {
1378 gSystem->Sleep(100);
1380 gSystem->Sleep(10);
1382 }
1383}
1384
1385////////////////////////////////////////////////////////////////////////////////
1386/// Put canvas window on top of the window stack.
1387
1389{
1390 gVirtualX->RaiseWindow(GetId());
1391}
1392
1393////////////////////////////////////////////////////////////////////////////////
1394/// Change title on window.
1395
1396void TRootCanvas::SetWindowTitle(const char *title)
1397{
1398 SetWindowName(title);
1399 SetIconName(title);
1400 fToolDock->SetWindowName(TString::Format("ToolBar: %s", title));
1401}
1402
1403////////////////////////////////////////////////////////////////////////////////
1404/// Fit canvas container to current window size.
1405
1407{
1408 if (!fAutoFit) {
1409 int opt = fCanvasContainer->GetOptions();
1410 int oopt = opt;
1411 opt &= ~kFixedSize; // turn off fixed size mode
1413 Layout(); // force layout
1414 fCanvas->Resize();
1415 fCanvas->Update();
1417 }
1418}
1419
1420////////////////////////////////////////////////////////////////////////////////
1421/// Print the canvas.
1422
1424{
1425 Int_t ret = 0;
1426 Bool_t pname = kTRUE;
1427 char *printer, *printCmd;
1428 static TString sprinter, sprintCmd;
1429
1430 if (sprinter == "")
1431 printer = StrDup(gEnv->GetValue("Print.Printer", ""));
1432 else
1434 if (sprintCmd == "")
1435#ifndef WIN32
1436 printCmd = StrDup(gEnv->GetValue("Print.Command", ""));
1437#else
1438 printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p"));
1439#endif
1440 else
1442
1443 new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
1444 &printer, &printCmd, &ret);
1445 if (ret) {
1446 sprinter = printer;
1448
1449 if (sprinter == "")
1450 pname = kFALSE;
1451
1452 TString fn = "rootprint";
1453 FILE *f = gSystem->TempFileName(fn, gEnv->GetValue("Print.Directory", gSystem->TempDirectory()));
1454 if (f) fclose(f);
1455 fn += TString::Format(".%s",gEnv->GetValue("Print.FileType", "pdf"));
1456 fCanvas->Print(fn);
1457
1459 if (cmd.Contains("%p"))
1460 cmd.ReplaceAll("%p", sprinter);
1461 else if (pname) {
1462 cmd += " "; cmd += sprinter; cmd += " ";
1463 }
1464
1465 if (cmd.Contains("%f"))
1466 cmd.ReplaceAll("%f", fn);
1467 else {
1468 cmd += " "; cmd += fn; cmd += " ";
1469 }
1470
1471 gSystem->Exec(cmd);
1472#ifndef WIN32
1473 gSystem->Unlink(fn);
1474#endif
1475 }
1476 delete [] printer;
1477 delete [] printCmd;
1478}
1479
1480////////////////////////////////////////////////////////////////////////////////
1481/// Display a tooltip with infos about the primitive below the cursor.
1482
1483void TRootCanvas::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
1484{
1485 fToolTip->Hide();
1486 if (!fCanvas->GetShowToolTips() || selected == 0 ||
1487 event != kMouseMotion || fButton != 0)
1488 return;
1490 TString objInfo = selected->GetObjectInfo(px, py);
1491 if (objInfo.BeginsWith("-")) {
1492 // if the string begins with '-', display only the object info
1493 objInfo.Remove(TString::kLeading, '-');
1494 tipInfo = objInfo;
1495 }
1496 else {
1497 const char *title = selected->GetTitle();
1498 tipInfo += TString::Format("%s::%s", selected->ClassName(),
1499 selected->GetName());
1500 if (title && strlen(title))
1501 tipInfo += TString::Format("\n%s", selected->GetTitle());
1502 tipInfo += TString::Format("\n%d, %d", px, py);
1503 if (!objInfo.IsNull())
1504 tipInfo += TString::Format("\n%s", objInfo.Data());
1505 }
1506 fToolTip->SetText(tipInfo.Data());
1507 fToolTip->SetPosition(px+15, py+15);
1508 fToolTip->Reset();
1509}
1510
1511////////////////////////////////////////////////////////////////////////////////
1512/// Show or hide menubar.
1513
1519
1520////////////////////////////////////////////////////////////////////////////////
1521/// Show or hide statusbar.
1522
1524{
1527
1528 UInt_t h = GetHeight();
1530
1531 if (show) {
1534 if (dh - ch >= sh) h = h + sh;
1535 else h = ch;
1536 } else {
1539 if (dh - ch < sh) h = ch;
1540 else h = h - sh;
1541 }
1542 Resize(GetWidth(), h);
1543}
1544
1545////////////////////////////////////////////////////////////////////////////////
1546/// Show or hide side frame.
1547
1549{
1551
1552 UInt_t w = GetWidth();
1554 UInt_t h = GetHeight();
1556
1557 auto lambda_show = [&, this]() {
1558 if (show) {
1559 if (!fEditor)
1560 CreateEditor();
1562 if (gged && gged->GetCanvas() == fCanvas) {
1563 gged->Hide();
1564 }
1567 h += s;
1568 }
1570 fEditor->Show();
1572 w += e;
1573 } else {
1576 h -= s;
1577 }
1578 if (fEditor)
1579 fEditor->Hide();
1582 w -= e;
1583 }
1584 };
1585
1586 if (fParent && fParent != fClient->GetDefaultRoot()) {
1587 TGMainFrame *main = (TGMainFrame *)fParent->GetMainFrame();
1589 if (main && main->InheritsFrom("TRootBrowser")) {
1591 if (!fEmbedded)
1592 browser->GetTabRight()->Connect("Selected(Int_t)", "TRootCanvas",
1593 this, "Activated(Int_t)");
1594 fEmbedded = kTRUE;
1595 if (show && (!fEditor || !((TGedEditor *)fEditor)->IsMapped())) {
1596 if (!browser->GetTabLeft()->GetTabTab("Pad Editor")) {
1597 if (browser->GetActFrame()) { //already in edit mode
1598 TTimer::SingleShot(200, "TRootCanvas", this, "ShowEditor(=kTRUE)");
1599 } else {
1600 browser->StartEmbedding(TRootBrowser::kLeft);
1601 if (!fEditor)
1603 else {
1604 ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot());
1605 ((TGedEditor *)fEditor)->MapWindow();
1606 }
1607 browser->StopEmbedding("Pad Editor");
1608 if (fEditor) {
1610 gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor);
1611 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
1612 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
1613 }
1614 }
1615 }
1616 else
1618 }
1619 if (show) browser->GetTabLeft()->SetTab("Pad Editor");
1620 } else {
1621 lambda_show();
1622 main->Layout();
1623 }
1624 }
1625 else {
1626 lambda_show();
1627 Resize(w, h);
1628 }
1629}
1630
1631////////////////////////////////////////////////////////////////////////////////
1632/// Create embedded editor.
1633
1635{
1638 gPad = Canvas();
1639 // next two lines are related to the old editor
1640 Int_t show = gEnv->GetValue("Canvas.ShowEditor", 0);
1641 gEnv->SetValue("Canvas.ShowEditor","true");
1646
1647 // next line is related to the old editor
1648 if (show == 0) gEnv->SetValue("Canvas.ShowEditor","false");
1649}
1650
1651////////////////////////////////////////////////////////////////////////////////
1652/// Show or hide toolbar.
1653
1655{
1656 if (show && !fToolBar) {
1657
1660
1661 Int_t spacing = 6, i;
1662 for (i = 0; gToolBarData[i].fPixmap; i++) {
1663 if (strlen(gToolBarData[i].fPixmap) == 0) {
1664 spacing = 6;
1665 continue;
1666 }
1668 spacing = 0;
1669 }
1676
1677 spacing = 6;
1678 for (i = 0; gToolBarData1[i].fPixmap; i++) {
1679 if (strlen(gToolBarData1[i].fPixmap) == 0) {
1680 spacing = 6;
1681 continue;
1682 }
1684 spacing = 0;
1685 }
1687 fToolDock->Layout();
1689 fToolDock->Connect("Docked()", "TRootCanvas", this, "AdjustSize()");
1690 fToolDock->Connect("Undocked()", "TRootCanvas", this, "AdjustSize()");
1691 }
1692
1693 if (!fToolBar) return;
1694
1695 UInt_t h = GetHeight();
1698
1699 if (show) {
1703 h = h + sh;
1704 }
1707 h = h + dh + sh;
1708 } else {
1709 if (fToolDock->IsUndocked()) {
1711 h = h + 2*sh;
1712 } else h = h - dh;
1713
1717 h = h - sh;
1718 }
1720 h = h - sh;
1722 }
1723 Resize(GetWidth(), h);
1724}
1725
1726////////////////////////////////////////////////////////////////////////////////
1727/// Enable or disable tooltip info.
1728
1736
1737////////////////////////////////////////////////////////////////////////////////
1738/// Returns kTRUE if the editor is shown.
1739
1744
1745////////////////////////////////////////////////////////////////////////////////
1746/// Returns kTRUE if the menu bar is shown.
1747
1749{
1750 return (fMenuBar) && fMenuBar->IsMapped();
1751}
1752
1753////////////////////////////////////////////////////////////////////////////////
1754/// Returns kTRUE if the status bar is shown.
1755
1757{
1758 return (fStatusBar) && fStatusBar->IsMapped();
1759}
1760
1761////////////////////////////////////////////////////////////////////////////////
1762/// Returns kTRUE if the tool bar is shown.
1763
1765{
1766 return (fToolBar) && fToolBar->IsMapped();
1767}
1768
1769////////////////////////////////////////////////////////////////////////////////
1770/// Returns kTRUE if the tooltips are enabled.
1771
1773{
1774 return (fCanvas) && fCanvas->GetShowToolTips();
1775}
1776
1777////////////////////////////////////////////////////////////////////////////////
1778/// Keep the same canvas size while docking/undocking toolbar.
1779
1781{
1782 UInt_t h = GetHeight();
1785
1786 if (fToolDock->IsUndocked()) {
1789 h = h - sh;
1790 }
1792 h = h - dh - sh;
1793 } else {
1796 h = h + sh;
1797 }
1799 h = h + dh + sh;
1800 }
1801 Resize(GetWidth(), h);
1802}
1803
1804////////////////////////////////////////////////////////////////////////////////
1805/// Handle mouse button events in the canvas container.
1806
1808{
1809 Int_t button = event->fCode;
1810 Int_t x = event->fX;
1811 Int_t y = event->fY;
1812
1813 if (event->fType == kButtonPress) {
1814 if (fToolTip && fCanvas->GetShowToolTips()) {
1815 fToolTip->Hide();
1816 gVirtualX->UpdateWindowW(gVirtualX->GetWindowContext(fCanvasID), 0);
1818 }
1819 fButton = button;
1820 if (button == kButton1) {
1821 if (event->fState & kKeyShiftMask)
1823 else
1825 }
1826 if (button == kButton2)
1828 if (button == kButton3) {
1830 fButton = 0; // button up is consumed by TContextMenu
1831 }
1832
1833 } else if (event->fType == kButtonRelease) {
1834 if (button == kButton4)
1836 if (button == kButton5)
1838 if (button == kButton1)
1840 if (button == kButton2)
1842 if (button == kButton3)
1844
1845 fButton = 0;
1846 }
1847
1848 return kTRUE;
1849}
1850
1851////////////////////////////////////////////////////////////////////////////////
1852/// Handle mouse button double click events in the canvas container.
1853
1855{
1856 Int_t button = event->fCode;
1857 Int_t x = event->fX;
1858 Int_t y = event->fY;
1859
1860 if (button == kButton1)
1862 if (button == kButton2)
1864 if (button == kButton3)
1866
1867 return kTRUE;
1868}
1869
1870////////////////////////////////////////////////////////////////////////////////
1871/// Handle configure (i.e. resize) event.
1872
1874{
1875 if (fAutoFit) {
1876 fCanvas->Resize();
1877 fCanvas->Update();
1878 }
1879
1881 // get menu height
1882 static Int_t dh = 0;
1883 if (!dh)
1888 }
1889 return kTRUE;
1890}
1891
1892////////////////////////////////////////////////////////////////////////////////
1893/// Handle keyboard events in the canvas container.
1894
1896{
1898 static UInt_t previous_keysym = 0;
1899
1900 if (event->fType == kGKeyPress) {
1901 fButton = event->fCode;
1902 UInt_t keysym;
1903 char str[2];
1904 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1905
1906 if (str[0] == kESC){ // ESC sets the escape flag
1907 gROOT->SetEscape();
1910 gPad->Modified();
1911 return kTRUE;
1912 }
1913 if (str[0] == 3) // ctrl-c sets the interrupt flag
1914 gROOT->SetInterrupt();
1915
1916 // handle arrow keys
1917 if (keysym > 0x1011 && keysym < 0x1016) {
1919 UInt_t mask = 0;
1920 Int_t mx, my, tx, ty;
1921 wid = gVirtualX->GetDefaultRootWindow();
1922 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1923 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1925 mx, my, tx, ty, dum1);
1927 // handle case where we got consecutive same keypressed events coming
1928 // from auto-repeat on Windows (as it fires only successive keydown events)
1930 switch (keysym) {
1931 case 0x1012: // left
1932 gVirtualX->Warp(--mx, my, wid); --tx;
1933 break;
1934 case 0x1013: // up
1935 gVirtualX->Warp(mx, --my, wid); --ty;
1936 break;
1937 case 0x1014: // right
1938 gVirtualX->Warp(++mx, my, wid); ++tx;
1939 break;
1940 case 0x1015: // down
1941 gVirtualX->Warp(mx, ++my, wid); ++ty;
1942 break;
1943 default:
1944 break;
1945 }
1947 }
1949 }
1950 else {
1952 }
1953 } else if (event->fType == kKeyRelease) {
1954 UInt_t keysym;
1955 char str[2];
1956 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1957
1958 if (keysym > 0x1011 && keysym < 0x1016) {
1960 UInt_t mask = 0;
1961 Int_t mx, my, tx, ty;
1962 wid = gVirtualX->GetDefaultRootWindow();
1963 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1964 switch (keysym) {
1965 case 0x1012: // left
1966 gVirtualX->Warp(--mx, my, wid);
1967 break;
1968 case 0x1013: // up
1969 gVirtualX->Warp(mx, --my, wid);
1970 break;
1971 case 0x1014: // right
1972 gVirtualX->Warp(++mx, my, wid);
1973 break;
1974 case 0x1015: // down
1975 gVirtualX->Warp(mx, ++my, wid);
1976 break;
1977 default:
1978 break;
1979 }
1980 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1982 mx, my, tx, ty, dum1);
1985 }
1986 fButton = 0;
1987 }
1988 previous_event = event->fType;
1989 return kTRUE;
1990}
1991
1992////////////////////////////////////////////////////////////////////////////////
1993/// Handle mouse motion event in the canvas container.
1994
1996{
1997 Int_t x = event->fX;
1998 Int_t y = event->fY;
1999
2000 if (fButton == 0)
2002 if (fButton == kButton1) {
2003 if (event->fState & kKeyShiftMask)
2005 else
2007 }
2008 if (fButton == kButton2)
2010
2011 return kTRUE;
2012}
2013
2014////////////////////////////////////////////////////////////////////////////////
2015/// Handle expose events.
2016
2018{
2019 if (event->fCount == 0) {
2020 fCanvas->Flush();
2021 }
2022
2023 return kTRUE;
2024}
2025
2026////////////////////////////////////////////////////////////////////////////////
2027/// Handle enter/leave events. Only leave is activated at the moment.
2028
2030{
2031 Int_t x = event->fX;
2032 Int_t y = event->fY;
2033
2034 // pointer grabs create also an enter and leave event but with fCode
2035 // either kNotifyGrab or kNotifyUngrab, don't propagate these events
2036 if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
2038
2039 if (event->fType == kEnterNotify && event->fCode == kNotifyNormal)
2041
2042 return kTRUE;
2043}
2044
2045////////////////////////////////////////////////////////////////////////////////
2046/// Handle drop events.
2047
2049{
2050 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2051 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2052
2053 if (data->fDataType == rootObj) {
2054 TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
2055 buf.SetReadMode();
2057 if (!obj) return kTRUE;
2058 gPad->Clear();
2059 if (obj->InheritsFrom("TKey")) {
2060 TObject *object = (TObject *)gROOT->ProcessLine(TString::Format("((TKey *)0x%zx)->ReadObj();", (size_t)obj));
2061 if (!object) return kTRUE;
2062 if (object->InheritsFrom("TGraph"))
2063 object->Draw("ALP");
2064 else if (object->InheritsFrom("TImage"))
2065 object->Draw("x");
2066 else if (object->IsA()->GetMethodAllAny("Draw"))
2067 object->Draw();
2068 }
2069 else if (obj->InheritsFrom("TGraph"))
2070 obj->Draw("ALP");
2071 else if (obj->IsA()->GetMethodAllAny("Draw"))
2072 obj->Draw();
2073 gPad->Modified();
2074 gPad->Update();
2075 return kTRUE;
2076 }
2077 else if (data->fDataType == uriObj) {
2078 TString sfname((char *)data->fData);
2079 if (sfname.Length() > 7) {
2080 sfname.ReplaceAll("\r\n", "");
2081 TUrl uri(sfname.Data());
2082 if (sfname.EndsWith(".bmp") ||
2083 sfname.EndsWith(".gif") ||
2084 sfname.EndsWith(".jpg") ||
2085 sfname.EndsWith(".png") ||
2086 sfname.EndsWith(".ps") ||
2087 sfname.EndsWith(".eps") ||
2088 sfname.EndsWith(".pdf") ||
2089 sfname.EndsWith(".tiff") ||
2090 sfname.EndsWith(".xpm")) {
2091 TImage *img = TImage::Open(uri.GetFile());
2092 if (img) {
2093 img->Draw("x");
2094 img->SetEditable(kTRUE);
2095 }
2096 }
2097 gPad->Modified();
2098 gPad->Update();
2099 }
2100 }
2101 return kFALSE;
2102}
2103
2104////////////////////////////////////////////////////////////////////////////////
2105/// Handle dragging position events.
2106
2108 Int_t /*xroot*/, Int_t /*yroot*/)
2109{
2110 TPad *pad = fCanvas->Pick(x, y, 0);
2111 if (pad) {
2112 pad->cd();
2113 gROOT->SetSelectedPad(pad);
2114 // make sure the pad is highlighted (on Windows)
2115 pad->Update();
2116 }
2117 return action;
2118}
2119
2120////////////////////////////////////////////////////////////////////////////////
2121/// Handle drag enter events.
2122
2124{
2125 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2126 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2127 Atom_t ret = kNone;
2128 for (int i = 0; typelist[i] != kNone; ++i) {
2129 if (typelist[i] == rootObj)
2130 ret = rootObj;
2131 if (typelist[i] == uriObj)
2132 ret = uriObj;
2133 }
2134 return ret;
2135}
2136
2137////////////////////////////////////////////////////////////////////////////////
2138/// Handle drag leave events.
2139
2141{
2142 return kTRUE;
2143}
2144
2145////////////////////////////////////////////////////////////////////////////////
2146/// Slot handling tab switching in the browser, to properly set the canvas
2147/// and the model to the editor.
2148
2150{
2151 if (fEmbedded) {
2153 if (sender) {
2154 TGCompositeFrame *cont = sender->GetTabContainer(id);
2155 if (cont == fParent) {
2156 if (!fEditor)
2158 if (fEditor && ((TGedEditor *)fEditor)->IsMapped()) {
2159 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
2160 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
2161 }
2162 }
2163 }
2164 }
2165}
2166
2167////////////////////////////////////////////////////////////////////////////////
2168/// Update the "View With" submenu based on the currently selected pad content.
2169
2171{
2172 TVirtualPad *pad = fCanvas ? fCanvas->GetSelectedPad() : nullptr;
2173 if (!pad)
2174 pad = fCanvas;
2175
2178 else
2180}
2181
2182////////////////////////////////////////////////////////////////////////////////
2183/// Save a canvas container as a C++ statement(s) on output stream out.
2184
2185void TRootContainer::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
2186{
2187 out << "\n // canvas container\n";
2188 out << " Int_t canvasID = gVirtualX->InitWindow((ULongptr_t)" << GetParent()->GetParent()->GetName()
2189 << "->GetId());\n";
2190 out << " Window_t winC = gVirtualX->GetWindowID(canvasID);\n";
2191 out << " TGCompositeFrame *" << GetName() << " = new TGCompositeFrame(gClient, winC, " << GetParent()->GetName()
2192 << ");\n";
2193}
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:90
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:91
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:132
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
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:126
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:417
@ 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
@ kFileSaveAsHTML
@ 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:2638
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:377
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:2433
virtual void ToggleToolTips()
Toggle tooltip display.
Definition TCanvas.cxx:2475
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition TCanvas.cxx:744
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition TCanvas.cxx:2442
void SetSupportGL(Bool_t support)
Definition TCanvas.h:235
TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj) override
Search for an object at pixel position px,py.
Definition TCanvas.h:189
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition TCanvas.cxx:1671
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition TCanvas.cxx:1817
void SetCanvasImp(TCanvasImp *i)
Set canvas implementation If web-based implementation provided, some internal fields also initialized...
Definition TCanvas.cxx:2166
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition TCanvas.cxx:1238
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition TCanvas.cxx:726
Bool_t GetShowEditor() const
Definition TCanvas.h:154
Bool_t GetAutoExec() const
Definition TCanvas.h:156
virtual void ToggleEditor()
Toggle editor.
Definition TCanvas.cxx:2464
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:2028
void Paint(Option_t *option="") override
Paint canvas.
Definition TCanvas.cxx:1546
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2502
Bool_t OpaqueMoving() const override
Definition TCanvas.h:186
void Flush()
Flush canvas buffers.
Definition TCanvas.cxx:1151
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition TCanvas.cxx:1538
Bool_t UseGL() const
Definition TCanvas.h:234
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition TCanvas.cxx:1764
virtual void ToggleToolBar()
Toggle toolbar.
Definition TCanvas.cxx:2453
Bool_t OpaqueResizing() const override
Definition TCanvas.h:187
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:511
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:752
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:3797
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:1110
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:1157
TGCompositeFrame(const TGCompositeFrame &)=delete
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1250
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1197
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1065
void SetEditable(Bool_t on=kTRUE) override
Switch ON/OFF edit mode.
Definition TGFrame.cxx:941
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1015
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1036
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1183
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 TGFileBrowser.
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:332
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:622
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition TGFrame.cxx:436
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:598
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:586
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:269
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:1739
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition TGFrame.cxx:1853
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1796
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1783
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:1092
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition TGMenu.cxx:1842
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 void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition TGMenu.cxx:1779
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1721
virtual void EnableEntry(Int_t id)
Enable entry. By default entries are enabled.
Definition TGMenu.cxx:1702
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition TGMenu.cxx:1804
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: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
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:570
static TClass * Class()
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:549
virtual TClass * IsA() const
Definition TObject.h:248
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:293
The most important graphics class in the ROOT system.
Definition TPad.h:28
Double_t GetAspectRatio() const override
Definition TPad.h:226
void Modified(Bool_t flag=true) override
Mark pad modified Will be repainted when TCanvas::Update() will be called next time.
Definition TPad.cxx:7353
Bool_t HasFixedAspectRatio() const override
Definition TPad.h:272
virtual void SetGLDevice(Int_t dev)
Definition TPad.h:372
void SaveAs(const char *filename="", Option_t *option="") const override
Save the pad content in a file.
Definition TPad.cxx:5807
void Print(const char *filename="") const override
This method is equivalent to SaveAs("filename"). See TPad::SaveAs for details.
Definition TPad.cxx:4800
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:2324
const char * Data() const
Definition TString.h:386
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:715
@ 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:2459
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:1514
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:655
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1872
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:876
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:439
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:885
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:418
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1396
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition TSystem.cxx:1497
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