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 if (fCanvasID != -1) {
730 gVirtualX->SelectWindow(fCanvasID);
731 gVirtualX->CloseWindow();
732 fCanvasID = -1;
733 }
734}
735
736////////////////////////////////////////////////////////////////////////////////
737/// Really delete the canvas and this GUI.
738
740{
742 if(gged && gged->GetCanvas() == fCanvas) {
743 if (fEmbedded) {
744 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
745 ((TGedEditor *)gged)->SetCanvas(0);
746 }
747 else gged->Hide();
748 }
749
750 fToolTip->Hide();
751 Disconnect(fCanvas, "ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
752 this, "EventInfo(Int_t, Int_t, Int_t, TObject*)");
753
755 fCanvas->Clear();
756 fCanvas->SetName("");
757 if (gPad && gPad->GetCanvas() == fCanvas)
758 gPad = nullptr;
759 delete this;
760}
761
762////////////////////////////////////////////////////////////////////////////////
763/// In case window is closed via WM we get here.
764
769
770////////////////////////////////////////////////////////////////////////////////
771/// Return width of canvas container.
772
777
778////////////////////////////////////////////////////////////////////////////////
779/// Return height of canvas container.
780
785
786////////////////////////////////////////////////////////////////////////////////
787/// Gets the size and position of the window containing the canvas. This
788/// size includes the menubar and borders.
789
791{
792 gVirtualX->GetWindowSize(fId, x, y, w, h);
793
795 gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(),
796 0, 0, x, y, childdum);
797 if (!fCanvas->GetShowEditor()) return 0;
798 return fEditorFrame->GetWidth();
799}
800
801////////////////////////////////////////////////////////////////////////////////
802/// Set text in status bar.
803
808
809////////////////////////////////////////////////////////////////////////////////
810/// Handle menu and other command generated by the user.
811
813{
815 TList *lc;
816
817 switch (GET_MSG(msg)) {
818
819 case kC_COMMAND:
820
821 switch (GET_SUBMSG(msg)) {
822
823 case kCM_BUTTON:
824 case kCM_MENU:
825
826 switch (parm1) {
827 // Handle toolbar items...
828 case kToolModify:
829 gROOT->SetEditorMode();
830 break;
831 case kToolArc:
832 gROOT->SetEditorMode("Arc");
833 break;
834 case kToolLine:
835 gROOT->SetEditorMode("Line");
836 break;
837 case kToolArrow:
838 gROOT->SetEditorMode("Arrow");
839 break;
840 case kToolDiamond:
841 gROOT->SetEditorMode("Diamond");
842 break;
843 case kToolEllipse:
844 gROOT->SetEditorMode("Ellipse");
845 break;
846 case kToolPad:
847 gROOT->SetEditorMode("Pad");
848 break;
849 case kToolPave:
850 gROOT->SetEditorMode("Pave");
851 break;
852 case kToolPLabel:
853 gROOT->SetEditorMode("PaveLabel");
854 break;
855 case kToolPText:
856 gROOT->SetEditorMode("PaveText");
857 break;
858 case kToolPsText:
859 gROOT->SetEditorMode("PavesText");
860 break;
861 case kToolGraph:
862 gROOT->SetEditorMode("PolyLine");
863 break;
864 case kToolCurlyLine:
865 gROOT->SetEditorMode("CurlyLine");
866 break;
867 case kToolCurlyArc:
868 gROOT->SetEditorMode("CurlyArc");
869 break;
870 case kToolLatex:
871 gROOT->SetEditorMode("Text");
872 break;
873 case kToolMarker:
874 gROOT->SetEditorMode("Marker");
875 break;
876 case kToolCutG:
877 gROOT->SetEditorMode("CutG");
878 break;
879
880 // Handle File menu items...
881 case kFileNewCanvas:
882 gROOT->MakeDefCanvas();
883 break;
884 case kFileOpen:
885 {
886 static TString dir(".");
888 fi.fFileTypes = gOpenTypes;
889 fi.SetIniDir(dir);
891 if (!fi.fFilename) return kTRUE;
892 dir = fi.fIniDir;
893 TFile::Open(fi.fFilename, "update");
894 TIter next(gROOT->GetListOfBrowsers());
895 TBrowser *b;
896 while ((b = (TBrowser *)next())) {
897 TRootBrowser *rb = dynamic_cast<TRootBrowser *>(b->GetBrowserImp());
898 if (rb) {
899 TGFileBrowser *fb = dynamic_cast<TGFileBrowser *>(rb->GetActBrowser());
900 if (fb)
901 fb->Selected(0);
902 }
903 }
904 gROOT->RefreshBrowsers();
905 }
906 break;
907 case kFileSaveAs:
908 {
910 static TString dir(".");
911 static Int_t typeidx = 0;
912 static Bool_t overwr = kFALSE;
914 TString defaultType = gEnv->GetValue("Canvas.SaveAsDefaultType", ".pdf");
915 if (typeidx == 0) {
916 for (int i=1;gSaveAsTypes[i];i+=2) {
917 TString ftype = gSaveAsTypes[i];
918 if (ftype.EndsWith(defaultType.Data())) {
919 typeidx = i-1;
920 break;
921 }
922 }
923 }
924 fi.fFileTypes = gSaveAsTypes;
925 fi.SetIniDir(dir);
926 fi.fFileTypeIdx = typeidx;
927 fi.fOverwrite = overwr;
930 if (!fi.fFilename) return kTRUE;
932 TString fn = fi.fFilename;
933 TString ft = fi.fFileTypes[fi.fFileTypeIdx+1];
934 // clang-format off
935 dir = fi.fIniDir;
936 typeidx = fi.fFileTypeIdx;
937 overwr = fi.fOverwrite;
938again:
939 if (fn.EndsWith(".root") ||
940 fn.EndsWith(".ps") ||
941 fn.EndsWith(".eps") ||
942 fn.EndsWith(".pdf") ||
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 kFileSaveAsSVG:
992 fCanvas->SaveAs(".svg");
993 break;
994 case kFileSaveAsGIF:
995 fCanvas->SaveAs(".gif");
996 break;
997 case kFileSaveAsJPG:
998 fCanvas->SaveAs(".jpg");
999 break;
1000 case kFileSaveAsPNG:
1001 fCanvas->SaveAs(".png");
1002 break;
1003 case kFileSaveAsBMP:
1004 fCanvas->SaveAs(".bmp");
1005 break;
1006 case kFileSaveAsTEX:
1007 fCanvas->SaveAs(".tex");
1008 break;
1009 case kFilePrint:
1010 PrintCanvas();
1011 break;
1012 case kFileCloseCanvas:
1014 break;
1015 case kFileQuit:
1016 if (!gApplication->ReturnFromRun()) {
1020 }
1023 if (TClass::GetClass("TStyleManager", kFALSE, kTRUE))
1024 gROOT->ProcessLine("TStyleManager::Terminate()");
1026 break;
1027
1028 // Handle Edit menu items...
1029 case kEditStyle:
1030 if (!TClass::GetClass("TStyleManager"))
1031 gSystem->Load("libGed");
1032 gROOT->ProcessLine("TStyleManager::Show()");
1033 break;
1034 case kEditCut:
1035 // still noop
1036 break;
1037 case kEditCopy:
1038 // still noop
1039 break;
1040 case kEditPaste:
1041 // still noop
1042 break;
1043 case kEditUndo:
1044 // noop
1045 break;
1046 case kEditRedo:
1047 // noop
1048 break;
1049 case kEditClearPad:
1050 gPad->Clear();
1051 gPad->Modified();
1052 gPad->Update();
1053 break;
1054 case kEditClearCanvas:
1055 fCanvas->Clear();
1056 fCanvas->Modified();
1057 fCanvas->Update();
1058 break;
1059
1060 // Handle View menu items...
1061 case kViewEditor:
1063 break;
1064 case kViewToolbar:
1066 break;
1067 case kViewEventStatus:
1069 break;
1070 case kViewToolTips:
1072 break;
1073 case kViewColors:
1074 {
1075 TVirtualPad *padsav = gPad->GetCanvas();
1076 //This was the code with the old color table
1077 // TCanvas *m = new TCanvas("colors","Color Table");
1078 // TPad::DrawColorTable();
1079 // m->Update();
1080 TColorWheel *wheel = new TColorWheel();
1081 wheel->Draw();
1082
1083 //tp: with Cocoa, window is visible (and repainted)
1084 //before wheel->Draw() was called and you can see "empty"
1085 //canvas.
1086 gPad->Update();
1087 //
1088 if (padsav) padsav->cd();
1089 }
1090 break;
1091 case kViewFonts:
1092 // noop
1093 break;
1094 case kViewMarkers:
1095 {
1096 TVirtualPad *padsav = gPad ? gPad->GetCanvas() : nullptr;
1097 TCanvas *m = new TCanvas("markers","Marker Types",600,200);
1099 m->Update();
1100 if (padsav) padsav->cd();
1101 }
1102 break;
1103 case kViewIconify:
1104 Iconify();
1105 break;
1106 case kViewX3D: {
1107 TVirtualPad *pad = gPad ? gPad : (fCanvas ? fCanvas->GetSelectedPad() : nullptr);
1108 if (!pad)
1109 pad = fCanvas;
1111 pad->GetViewer3D("x3d");
1112 break;
1113 }
1114 case kViewOpenGL:
1115 gPad->GetViewer3D("ogl");
1116 break;
1117
1118 // Handle Option menu items...
1119 case kOptionAutoExec:
1121 if (fCanvas->GetAutoExec()) {
1123 } else {
1125 }
1126 break;
1127 case kOptionAutoResize:
1128 {
1130 int opt = fCanvasContainer->GetOptions();
1131 if (fAutoFit) {
1132 opt &= ~kFixedSize;
1134 } else {
1135 opt |= kFixedSize;
1137 }
1139 // in case of autofit this will generate a configure
1140 // event for the container and this will force the
1141 // update of the TCanvas
1142 //Layout();
1143 }
1144 Layout();
1145 break;
1147 FitCanvas();
1148 break;
1149 case kOptionMoveOpaque:
1150 if (fCanvas->OpaqueMoving()) {
1151 fCanvas->MoveOpaque(0);
1153 } else {
1154 fCanvas->MoveOpaque(1);
1156 }
1157 break;
1159 if (fCanvas->OpaqueResizing()) {
1162 } else {
1165 }
1166 break;
1167 case kOptionInterrupt:
1168 gROOT->SetInterrupt();
1169 break;
1170 case kOptionRefresh:
1171 fCanvas->Paint();
1172 fCanvas->Update();
1173 break;
1174 case kOptionStatistics:
1175 if (gStyle->GetOptStat()) {
1176 gStyle->SetOptStat(0);
1177 delete gPad->FindObject("stats");
1179 } else {
1180 gStyle->SetOptStat(1);
1182 }
1183 gPad->Modified();
1184 fCanvas->Update();
1185 break;
1186 case kOptionHistTitle:
1187 if (gStyle->GetOptTitle()) {
1188 gStyle->SetOptTitle(0);
1189 delete gPad->FindObject("title");
1191 } else {
1192 gStyle->SetOptTitle(1);
1194 }
1195 gPad->Modified();
1196 fCanvas->Update();
1197 break;
1198 case kOptionFitParams:
1199 if (gStyle->GetOptFit()) {
1200 gStyle->SetOptFit(0);
1202 } else {
1203 gStyle->SetOptFit(1);
1205 }
1206 gPad->Modified();
1207 fCanvas->Update();
1208 break;
1209 case kOptionCanEdit:
1210 if (gROOT->GetEditHistograms()) {
1211 gROOT->SetEditHistograms(kFALSE);
1213 } else {
1214 gROOT->SetEditHistograms(kTRUE);
1216 }
1217 break;
1218
1219 // Handle Tools menu items...
1220 case kInspectRoot:
1221 fCanvas->cd();
1222 gROOT->Inspect();
1223 fCanvas->Update();
1224 break;
1225 case kToolsBrowser:
1226 new TBrowser("browser");
1227 break;
1228 case kToolsBuilder:
1230 break;
1231 case kToolsRecorder:
1232 gROOT->ProcessLine("new TGRecorder()");
1233 break;
1234
1235 // Handle Tools menu items...
1236 case kClassesTree:
1237 {
1238 TString cdef;
1239 lc = (TList*)gROOT->GetListOfCanvases();
1240 if (lc->FindObject("ClassTree")) {
1241 cdef = TString::Format("ClassTree_%d", lc->GetSize()+1);
1242 } else {
1243 cdef = "ClassTree";
1244 }
1245 new TClassTree(cdef.Data(), "TObject");
1246 fCanvas->Update();
1247 }
1248 break;
1249
1250 case kFitPanel:
1251 {
1252 // use plugin manager to create instance of TFitEditor
1253 TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
1254 if (handler && handler->LoadPlugin() != -1) {
1255 if (handler->ExecPlugin(2, fCanvas, 0) == 0)
1256 Error("FitPanel", "Unable to crate the FitPanel");
1257 }
1258 else
1259 Error("FitPanel", "Unable to find the FitPanel plug-in");
1260 }
1261 break;
1262
1263 // Handle Help menu items...
1264 case kHelpAbout:
1265 {
1266#ifdef WIN32
1268#else
1269
1270 char str[32];
1271 snprintf(str, 32, "About ROOT %s...", gROOT->GetVersion());
1272 hd = new TRootHelpDialog(this, str, 600, 400);
1273 hd->SetText(gHelpAbout);
1274 hd->Popup();
1275#endif
1276 }
1277 break;
1278 case kHelpOnCanvas:
1279 hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1280 hd->SetText(gHelpCanvas);
1281 hd->Popup();
1282 break;
1283 case kHelpOnMenus:
1284 hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1285 hd->SetText(gHelpPullDownMenus);
1286 hd->Popup();
1287 break;
1288 case kHelpOnGraphicsEd:
1289 hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1290 hd->SetText(gHelpGraphicsEditor);
1291 hd->Popup();
1292 break;
1293 case kHelpOnBrowser:
1294 hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1295 hd->SetText(gHelpBrowser);
1296 hd->Popup();
1297 break;
1298 case kHelpOnObjects:
1299 hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
1300 hd->SetText(gHelpObjects);
1301 hd->Popup();
1302 break;
1303 case kHelpOnPS:
1304 hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
1305 hd->SetText(gHelpPostscript);
1306 hd->Popup();
1307 break;
1308 // clang-format on
1309 }
1310 default:
1311 break;
1312 }
1313 default:
1314 break;
1315 }
1316 return kTRUE;
1317}
1318
1319////////////////////////////////////////////////////////////////////////////////
1320/// Called by TCanvas ctor to get window indetifier.
1321
1331
1332////////////////////////////////////////////////////////////////////////////////
1333/// Set size of canvas container. Units in pixels.
1334/// If w==0 and h==0, set autofit mode
1335
1337{
1338 // turn off autofit, we want to stay at the given size
1339 int opt = fCanvasContainer->GetOptions();
1340 if (!w && !h) {
1341 fAutoFit = kTRUE;
1343 opt &= ~kFixedSize; // turn off fixed size mode
1344 } else {
1345 fAutoFit = kFALSE;
1347 opt |= kFixedSize; // turn on fixed size mode
1348 }
1352 Layout(); // force layout (will update container to given size)
1353 fCanvas->Resize();
1354 fCanvas->Update();
1355}
1356
1357////////////////////////////////////////////////////////////////////////////////
1358/// Set canvas position (units in pixels).
1359
1364
1365////////////////////////////////////////////////////////////////////////////////
1366/// Set size of canvas (units in pixels).
1367
1369{
1370 Resize(w, h);
1371
1372 // Make sure the change of size is really done.
1373 gVirtualX->Update(1);
1374 if (!gThreadXAR) {
1375 gSystem->Sleep(100);
1377 gSystem->Sleep(10);
1379 }
1380}
1381
1382////////////////////////////////////////////////////////////////////////////////
1383/// Put canvas window on top of the window stack.
1384
1386{
1387 gVirtualX->RaiseWindow(GetId());
1388}
1389
1390////////////////////////////////////////////////////////////////////////////////
1391/// Change title on window.
1392
1393void TRootCanvas::SetWindowTitle(const char *title)
1394{
1395 SetWindowName(title);
1396 SetIconName(title);
1397 fToolDock->SetWindowName(TString::Format("ToolBar: %s", title));
1398}
1399
1400////////////////////////////////////////////////////////////////////////////////
1401/// Fit canvas container to current window size.
1402
1404{
1405 if (!fAutoFit) {
1406 int opt = fCanvasContainer->GetOptions();
1407 int oopt = opt;
1408 opt &= ~kFixedSize; // turn off fixed size mode
1410 Layout(); // force layout
1411 fCanvas->Resize();
1412 fCanvas->Update();
1414 }
1415}
1416
1417////////////////////////////////////////////////////////////////////////////////
1418/// Print the canvas.
1419
1421{
1422 Int_t ret = 0;
1423 Bool_t pname = kTRUE;
1424 char *printer, *printCmd;
1425 static TString sprinter, sprintCmd;
1426
1427 if (sprinter == "")
1428 printer = StrDup(gEnv->GetValue("Print.Printer", ""));
1429 else
1431 if (sprintCmd == "")
1432#ifndef WIN32
1433 printCmd = StrDup(gEnv->GetValue("Print.Command", ""));
1434#else
1435 printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p"));
1436#endif
1437 else
1439
1440 new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
1441 &printer, &printCmd, &ret);
1442 if (ret) {
1443 sprinter = printer;
1445
1446 if (sprinter == "")
1447 pname = kFALSE;
1448
1449 TString fn = "rootprint";
1450 FILE *f = gSystem->TempFileName(fn, gEnv->GetValue("Print.Directory", gSystem->TempDirectory()));
1451 if (f) fclose(f);
1452 fn += TString::Format(".%s",gEnv->GetValue("Print.FileType", "pdf"));
1453 fCanvas->Print(fn);
1454
1456 if (cmd.Contains("%p"))
1457 cmd.ReplaceAll("%p", sprinter);
1458 else if (pname) {
1459 cmd += " "; cmd += sprinter; cmd += " ";
1460 }
1461
1462 if (cmd.Contains("%f"))
1463 cmd.ReplaceAll("%f", fn);
1464 else {
1465 cmd += " "; cmd += fn; cmd += " ";
1466 }
1467
1468 gSystem->Exec(cmd);
1469#ifndef WIN32
1470 gSystem->Unlink(fn);
1471#endif
1472 }
1473 delete [] printer;
1474 delete [] printCmd;
1475}
1476
1477////////////////////////////////////////////////////////////////////////////////
1478/// Display a tooltip with infos about the primitive below the cursor.
1479
1480void TRootCanvas::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
1481{
1482 fToolTip->Hide();
1483 if (!fCanvas->GetShowToolTips() || selected == 0 ||
1484 event != kMouseMotion || fButton != 0)
1485 return;
1487 TString objInfo = selected->GetObjectInfo(px, py);
1488 if (objInfo.BeginsWith("-")) {
1489 // if the string begins with '-', display only the object info
1490 objInfo.Remove(TString::kLeading, '-');
1491 tipInfo = objInfo;
1492 }
1493 else {
1494 const char *title = selected->GetTitle();
1495 tipInfo += TString::Format("%s::%s", selected->ClassName(),
1496 selected->GetName());
1497 if (title && strlen(title))
1498 tipInfo += TString::Format("\n%s", selected->GetTitle());
1499 tipInfo += TString::Format("\n%d, %d", px, py);
1500 if (!objInfo.IsNull())
1501 tipInfo += TString::Format("\n%s", objInfo.Data());
1502 }
1503 fToolTip->SetText(tipInfo.Data());
1504 fToolTip->SetPosition(px+15, py+15);
1505 fToolTip->Reset();
1506}
1507
1508////////////////////////////////////////////////////////////////////////////////
1509/// Show or hide menubar.
1510
1516
1517////////////////////////////////////////////////////////////////////////////////
1518/// Show or hide statusbar.
1519
1521{
1524
1525 UInt_t h = GetHeight();
1527
1528 if (show) {
1531 if (dh - ch >= sh) h = h + sh;
1532 else h = ch;
1533 } else {
1536 if (dh - ch < sh) h = ch;
1537 else h = h - sh;
1538 }
1539 Resize(GetWidth(), h);
1540}
1541
1542////////////////////////////////////////////////////////////////////////////////
1543/// Show or hide side frame.
1544
1546{
1548
1549 UInt_t w = GetWidth();
1551 UInt_t h = GetHeight();
1553
1554 auto lambda_show = [&, this]() {
1555 if (show) {
1556 if (!fEditor)
1557 CreateEditor();
1559 if (gged && gged->GetCanvas() == fCanvas) {
1560 gged->Hide();
1561 }
1564 h += s;
1565 }
1567 fEditor->Show();
1569 w += e;
1570 } else {
1573 h -= s;
1574 }
1575 if (fEditor)
1576 fEditor->Hide();
1579 w -= e;
1580 }
1581 };
1582
1583 if (fParent && fParent != fClient->GetDefaultRoot()) {
1584 TGMainFrame *main = (TGMainFrame *)fParent->GetMainFrame();
1586 if (main && main->InheritsFrom("TRootBrowser")) {
1588 if (!fEmbedded)
1589 browser->GetTabRight()->Connect("Selected(Int_t)", "TRootCanvas",
1590 this, "Activated(Int_t)");
1591 fEmbedded = kTRUE;
1592 if (show && (!fEditor || !((TGedEditor *)fEditor)->IsMapped())) {
1593 if (!browser->GetTabLeft()->GetTabTab("Pad Editor")) {
1594 if (browser->GetActFrame()) { //already in edit mode
1595 TTimer::SingleShot(200, "TRootCanvas", this, "ShowEditor(=kTRUE)");
1596 } else {
1597 browser->StartEmbedding(TRootBrowser::kLeft);
1598 if (!fEditor)
1600 else {
1601 ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot());
1602 ((TGedEditor *)fEditor)->MapWindow();
1603 }
1604 browser->StopEmbedding("Pad Editor");
1605 if (fEditor) {
1607 gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor);
1608 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
1609 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
1610 }
1611 }
1612 }
1613 else
1615 }
1616 if (show) browser->GetTabLeft()->SetTab("Pad Editor");
1617 } else {
1618 lambda_show();
1619 main->Layout();
1620 }
1621 }
1622 else {
1623 lambda_show();
1624 Resize(w, h);
1625 }
1626}
1627
1628////////////////////////////////////////////////////////////////////////////////
1629/// Create embedded editor.
1630
1632{
1635 gPad = Canvas();
1636 // next two lines are related to the old editor
1637 Int_t show = gEnv->GetValue("Canvas.ShowEditor", 0);
1638 gEnv->SetValue("Canvas.ShowEditor","true");
1643
1644 // next line is related to the old editor
1645 if (show == 0) gEnv->SetValue("Canvas.ShowEditor","false");
1646}
1647
1648////////////////////////////////////////////////////////////////////////////////
1649/// Show or hide toolbar.
1650
1652{
1653 if (show && !fToolBar) {
1654
1657
1658 Int_t spacing = 6, i;
1659 for (i = 0; gToolBarData[i].fPixmap; i++) {
1660 if (strlen(gToolBarData[i].fPixmap) == 0) {
1661 spacing = 6;
1662 continue;
1663 }
1665 spacing = 0;
1666 }
1673
1674 spacing = 6;
1675 for (i = 0; gToolBarData1[i].fPixmap; i++) {
1676 if (strlen(gToolBarData1[i].fPixmap) == 0) {
1677 spacing = 6;
1678 continue;
1679 }
1681 spacing = 0;
1682 }
1684 fToolDock->Layout();
1686 fToolDock->Connect("Docked()", "TRootCanvas", this, "AdjustSize()");
1687 fToolDock->Connect("Undocked()", "TRootCanvas", this, "AdjustSize()");
1688 }
1689
1690 if (!fToolBar) return;
1691
1692 UInt_t h = GetHeight();
1695
1696 if (show) {
1700 h = h + sh;
1701 }
1704 h = h + dh + sh;
1705 } else {
1706 if (fToolDock->IsUndocked()) {
1708 h = h + 2*sh;
1709 } else h = h - dh;
1710
1714 h = h - sh;
1715 }
1717 h = h - sh;
1719 }
1720 Resize(GetWidth(), h);
1721}
1722
1723////////////////////////////////////////////////////////////////////////////////
1724/// Enable or disable tooltip info.
1725
1733
1734////////////////////////////////////////////////////////////////////////////////
1735/// Returns kTRUE if the editor is shown.
1736
1741
1742////////////////////////////////////////////////////////////////////////////////
1743/// Returns kTRUE if the menu bar is shown.
1744
1746{
1747 return (fMenuBar) && fMenuBar->IsMapped();
1748}
1749
1750////////////////////////////////////////////////////////////////////////////////
1751/// Returns kTRUE if the status bar is shown.
1752
1754{
1755 return (fStatusBar) && fStatusBar->IsMapped();
1756}
1757
1758////////////////////////////////////////////////////////////////////////////////
1759/// Returns kTRUE if the tool bar is shown.
1760
1762{
1763 return (fToolBar) && fToolBar->IsMapped();
1764}
1765
1766////////////////////////////////////////////////////////////////////////////////
1767/// Returns kTRUE if the tooltips are enabled.
1768
1770{
1771 return (fCanvas) && fCanvas->GetShowToolTips();
1772}
1773
1774////////////////////////////////////////////////////////////////////////////////
1775/// Keep the same canvas size while docking/undocking toolbar.
1776
1778{
1779 UInt_t h = GetHeight();
1782
1783 if (fToolDock->IsUndocked()) {
1786 h = h - sh;
1787 }
1789 h = h - dh - sh;
1790 } else {
1793 h = h + sh;
1794 }
1796 h = h + dh + sh;
1797 }
1798 Resize(GetWidth(), h);
1799}
1800
1801////////////////////////////////////////////////////////////////////////////////
1802/// Handle mouse button events in the canvas container.
1803
1805{
1806 Int_t button = event->fCode;
1807 Int_t x = event->fX;
1808 Int_t y = event->fY;
1809
1810 if (event->fType == kButtonPress) {
1811 if (fToolTip && fCanvas->GetShowToolTips()) {
1812 fToolTip->Hide();
1813 gVirtualX->UpdateWindowW(gVirtualX->GetWindowContext(fCanvasID), 0);
1815 }
1816 fButton = button;
1817 if (button == kButton1) {
1818 if (event->fState & kKeyShiftMask)
1820 else
1822 }
1823 if (button == kButton2)
1825 if (button == kButton3) {
1827 fButton = 0; // button up is consumed by TContextMenu
1828 }
1829
1830 } else if (event->fType == kButtonRelease) {
1831 if (button == kButton4)
1833 if (button == kButton5)
1835 if (button == kButton1)
1837 if (button == kButton2)
1839 if (button == kButton3)
1841
1842 fButton = 0;
1843 }
1844
1845 return kTRUE;
1846}
1847
1848////////////////////////////////////////////////////////////////////////////////
1849/// Handle mouse button double click events in the canvas container.
1850
1852{
1853 Int_t button = event->fCode;
1854 Int_t x = event->fX;
1855 Int_t y = event->fY;
1856
1857 if (button == kButton1)
1859 if (button == kButton2)
1861 if (button == kButton3)
1863
1864 return kTRUE;
1865}
1866
1867////////////////////////////////////////////////////////////////////////////////
1868/// Handle configure (i.e. resize) event.
1869
1871{
1872 if (fAutoFit) {
1873 fCanvas->Resize();
1874 fCanvas->Update();
1875 }
1876
1878 // get menu height
1879 static Int_t dh = 0;
1880 if (!dh)
1885 }
1886 return kTRUE;
1887}
1888
1889////////////////////////////////////////////////////////////////////////////////
1890/// Handle keyboard events in the canvas container.
1891
1893{
1895 static UInt_t previous_keysym = 0;
1896
1897 if (event->fType == kGKeyPress) {
1898 fButton = event->fCode;
1899 UInt_t keysym;
1900 char str[2];
1901 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1902
1903 if (str[0] == kESC){ // ESC sets the escape flag
1904 gROOT->SetEscape();
1907 gPad->Modified();
1908 return kTRUE;
1909 }
1910 if (str[0] == 3) // ctrl-c sets the interrupt flag
1911 gROOT->SetInterrupt();
1912
1913 // handle arrow keys
1914 if (keysym > 0x1011 && keysym < 0x1016) {
1916 UInt_t mask = 0;
1917 Int_t mx, my, tx, ty;
1918 wid = gVirtualX->GetDefaultRootWindow();
1919 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1920 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1922 mx, my, tx, ty, dum1);
1924 // handle case where we got consecutive same keypressed events coming
1925 // from auto-repeat on Windows (as it fires only successive keydown events)
1927 switch (keysym) {
1928 case 0x1012: // left
1929 gVirtualX->Warp(--mx, my, wid); --tx;
1930 break;
1931 case 0x1013: // up
1932 gVirtualX->Warp(mx, --my, wid); --ty;
1933 break;
1934 case 0x1014: // right
1935 gVirtualX->Warp(++mx, my, wid); ++tx;
1936 break;
1937 case 0x1015: // down
1938 gVirtualX->Warp(mx, ++my, wid); ++ty;
1939 break;
1940 default:
1941 break;
1942 }
1944 }
1946 }
1947 else {
1949 }
1950 } else if (event->fType == kKeyRelease) {
1951 UInt_t keysym;
1952 char str[2];
1953 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1954
1955 if (keysym > 0x1011 && keysym < 0x1016) {
1957 UInt_t mask = 0;
1958 Int_t mx, my, tx, ty;
1959 wid = gVirtualX->GetDefaultRootWindow();
1960 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1961 switch (keysym) {
1962 case 0x1012: // left
1963 gVirtualX->Warp(--mx, my, wid);
1964 break;
1965 case 0x1013: // up
1966 gVirtualX->Warp(mx, --my, wid);
1967 break;
1968 case 0x1014: // right
1969 gVirtualX->Warp(++mx, my, wid);
1970 break;
1971 case 0x1015: // down
1972 gVirtualX->Warp(mx, ++my, wid);
1973 break;
1974 default:
1975 break;
1976 }
1977 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1979 mx, my, tx, ty, dum1);
1982 }
1983 fButton = 0;
1984 }
1985 previous_event = event->fType;
1986 return kTRUE;
1987}
1988
1989////////////////////////////////////////////////////////////////////////////////
1990/// Handle mouse motion event in the canvas container.
1991
1993{
1994 Int_t x = event->fX;
1995 Int_t y = event->fY;
1996
1997 if (fButton == 0)
1999 if (fButton == kButton1) {
2000 if (event->fState & kKeyShiftMask)
2002 else
2004 }
2005 if (fButton == kButton2)
2007
2008 return kTRUE;
2009}
2010
2011////////////////////////////////////////////////////////////////////////////////
2012/// Handle expose events.
2013
2015{
2016 if (event->fCount == 0) {
2017 fCanvas->Flush();
2018 }
2019
2020 return kTRUE;
2021}
2022
2023////////////////////////////////////////////////////////////////////////////////
2024/// Handle enter/leave events. Only leave is activated at the moment.
2025
2027{
2028 Int_t x = event->fX;
2029 Int_t y = event->fY;
2030
2031 // pointer grabs create also an enter and leave event but with fCode
2032 // either kNotifyGrab or kNotifyUngrab, don't propagate these events
2033 if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
2035
2036 if (event->fType == kEnterNotify && event->fCode == kNotifyNormal)
2038
2039 return kTRUE;
2040}
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Handle drop events.
2044
2046{
2047 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2048 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2049
2050 if (data->fDataType == rootObj) {
2051 TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
2052 buf.SetReadMode();
2054 if (!obj) return kTRUE;
2055 gPad->Clear();
2056 if (obj->InheritsFrom("TKey")) {
2057 TObject *object = (TObject *)gROOT->ProcessLine(TString::Format("((TKey *)0x%zx)->ReadObj();", (size_t)obj));
2058 if (!object) return kTRUE;
2059 if (object->InheritsFrom("TGraph"))
2060 object->Draw("ALP");
2061 else if (object->InheritsFrom("TImage"))
2062 object->Draw("x");
2063 else if (object->IsA()->GetMethodAllAny("Draw"))
2064 object->Draw();
2065 }
2066 else if (obj->InheritsFrom("TGraph"))
2067 obj->Draw("ALP");
2068 else if (obj->IsA()->GetMethodAllAny("Draw"))
2069 obj->Draw();
2070 gPad->Modified();
2071 gPad->Update();
2072 return kTRUE;
2073 }
2074 else if (data->fDataType == uriObj) {
2075 TString sfname((char *)data->fData);
2076 if (sfname.Length() > 7) {
2077 sfname.ReplaceAll("\r\n", "");
2078 TUrl uri(sfname.Data());
2079 if (sfname.EndsWith(".bmp") ||
2080 sfname.EndsWith(".gif") ||
2081 sfname.EndsWith(".jpg") ||
2082 sfname.EndsWith(".png") ||
2083 sfname.EndsWith(".ps") ||
2084 sfname.EndsWith(".eps") ||
2085 sfname.EndsWith(".pdf") ||
2086 sfname.EndsWith(".tiff") ||
2087 sfname.EndsWith(".xpm")) {
2088 TImage *img = TImage::Open(uri.GetFile());
2089 if (img) {
2090 img->Draw("x");
2091 img->SetEditable(kTRUE);
2092 }
2093 }
2094 gPad->Modified();
2095 gPad->Update();
2096 }
2097 }
2098 return kFALSE;
2099}
2100
2101////////////////////////////////////////////////////////////////////////////////
2102/// Handle dragging position events.
2103
2105 Int_t /*xroot*/, Int_t /*yroot*/)
2106{
2107 TPad *pad = fCanvas->Pick(x, y, 0);
2108 if (pad) {
2109 pad->cd();
2110 gROOT->SetSelectedPad(pad);
2111 // make sure the pad is highlighted (on Windows)
2112 pad->Update();
2113 }
2114 return action;
2115}
2116
2117////////////////////////////////////////////////////////////////////////////////
2118/// Handle drag enter events.
2119
2121{
2122 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2123 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2124 Atom_t ret = kNone;
2125 for (int i = 0; typelist[i] != kNone; ++i) {
2126 if (typelist[i] == rootObj)
2127 ret = rootObj;
2128 if (typelist[i] == uriObj)
2129 ret = uriObj;
2130 }
2131 return ret;
2132}
2133
2134////////////////////////////////////////////////////////////////////////////////
2135/// Handle drag leave events.
2136
2138{
2139 return kTRUE;
2140}
2141
2142////////////////////////////////////////////////////////////////////////////////
2143/// Slot handling tab switching in the browser, to properly set the canvas
2144/// and the model to the editor.
2145
2147{
2148 if (fEmbedded) {
2150 if (sender) {
2151 TGCompositeFrame *cont = sender->GetTabContainer(id);
2152 if (cont == fParent) {
2153 if (!fEditor)
2155 if (fEditor && ((TGedEditor *)fEditor)->IsMapped()) {
2156 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
2157 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
2158 }
2159 }
2160 }
2161 }
2162}
2163
2164////////////////////////////////////////////////////////////////////////////////
2165/// Update the "View With" submenu based on the currently selected pad content.
2166
2168{
2169 TVirtualPad *pad = fCanvas ? fCanvas->GetSelectedPad() : nullptr;
2170 if (!pad)
2171 pad = fCanvas;
2172
2175 else
2177}
2178
2179////////////////////////////////////////////////////////////////////////////////
2180/// Save a canvas container as a C++ statement(s) on output stream out.
2181
2182void TRootContainer::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
2183{
2184 out << "\n // canvas container\n";
2185 out << " Int_t canvasID = gVirtualX->InitWindow((ULongptr_t)" << GetParent()->GetParent()->GetName()
2186 << "->GetId());\n";
2187 out << " Window_t winC = gVirtualX->GetWindowID(canvasID);\n";
2188 out << " TGCompositeFrame *" << GetName() << " = new TGCompositeFrame(gClient, winC, " << GetParent()->GetName()
2189 << ");\n";
2190}
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: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:145
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:2564
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:369
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:2421
virtual void ToggleToolTips()
Toggle tooltip display.
Definition TCanvas.cxx:2463
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition TCanvas.cxx:736
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition TCanvas.cxx:2430
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:1659
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition TCanvas.cxx:1805
void SetCanvasImp(TCanvasImp *i)
Set canvas implementation If web-based implementation provided, some internal fields also initialized...
Definition TCanvas.cxx:2154
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition TCanvas.cxx:1226
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition TCanvas.cxx:718
Bool_t GetShowEditor() const
Definition TCanvas.h:154
Bool_t GetAutoExec() const
Definition TCanvas.h:156
virtual void ToggleEditor()
Toggle editor.
Definition TCanvas.cxx:2452
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:2016
void Paint(Option_t *option="") override
Paint canvas.
Definition TCanvas.cxx:1534
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2490
Bool_t OpaqueMoving() const override
Definition TCanvas.h:184
void Flush()
Flush canvas buffers.
Definition TCanvas.cxx:1139
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition TCanvas.cxx:1526
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:1752
virtual void ToggleToolBar()
Toggle toolbar.
Definition TCanvas.cxx:2441
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: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: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: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: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:7316
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:5763
void Print(const char *filename="") const override
This method is equivalent to SaveAs("filename"). See TPad::SaveAs for details.
Definition TPad.cxx:4765
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:2385
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:706
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