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
76
77// Canvas menu command ids
161
162static const char *gOpenTypes[] = { "ROOT files", "*.root",
163 "All files", "*",
164 0, 0 };
165
166static const char *gSaveAsTypes[] = { "PDF", "*.pdf",
167 "SVG", "*.svg",
168 "TeX", "*.tex",
169 "PostScript", "*.ps",
170 "Encapsulated PostScript", "*.eps",
171 "PNG", "*.png",
172 "JPEG", "*.jpg",
173 "GIF", "*.gif",
174 "ROOT macros", "*.C",
175 "ROOT files", "*.root",
176 "XML", "*.xml",
177 "XPM", "*.xpm",
178 "TIFF", "*.tiff",
179 "XCF", "*.xcf",
180 "All files", "*",
181 0, 0 };
182
184 // { filename, tooltip, staydown, id, button}
185 { "newcanvas.xpm", "New", kFALSE, kFileNewCanvas, 0 },
186 { "open.xpm", "Open", kFALSE, kFileOpen, 0 },
187 { "save.xpm", "Save As", kFALSE, kFileSaveAs, 0 },
188 { "printer.xpm", "Print", kFALSE, kFilePrint, 0 },
189 { "", "", kFALSE, -1, 0 },
190 { "interrupt.xpm", "Interrupt", kFALSE, kOptionInterrupt,0 },
191 { "refresh2.xpm", "Refresh", kFALSE, kOptionRefresh, 0 },
192 { "", "", kFALSE, -1, 0 },
193 { "inspect.xpm", "Inspect", kFALSE, kInspectRoot, 0 },
194 { "browser.xpm", "Browser", kFALSE, kToolsBrowser, 0 },
195 { 0, 0, kFALSE, 0, 0 }
196};
197
199 { "pointer.xpm", "Modify", kFALSE, kToolModify, 0 },
200 { "arc.xpm", "Arc", kFALSE, kToolArc, 0 },
201 { "line.xpm", "Line", kFALSE, kToolLine, 0 },
202 { "arrow.xpm", "Arrow", kFALSE, kToolArrow, 0 },
203 { "diamond.xpm", "Diamond", kFALSE, kToolDiamond, 0 },
204 { "ellipse.xpm", "Ellipse", kFALSE, kToolEllipse, 0 },
205 { "pad.xpm", "Pad", kFALSE, kToolPad, 0 },
206 { "pave.xpm", "Pave", kFALSE, kToolPave, 0 },
207 { "pavelabel.xpm", "Pave Label", kFALSE, kToolPLabel, 0 },
208 { "pavetext.xpm", "Pave Text", kFALSE, kToolPText, 0 },
209 { "pavestext.xpm", "Paves Text", kFALSE, kToolPsText, 0 },
210 { "graph.xpm", "Graph", kFALSE, kToolGraph, 0 },
211 { "curlyline.xpm", "Curly Line", kFALSE, kToolCurlyLine, 0 },
212 { "curlyarc.xpm", "Curly Arc", kFALSE, kToolCurlyArc, 0 },
213 { "latex.xpm", "Text/Latex", kFALSE, kToolLatex, 0 },
214 { "marker.xpm", "Marker", kFALSE, kToolMarker, 0 },
215 { "cut.xpm", "Graphical Cut", kFALSE, kToolCutG, 0 },
216 { 0, 0, kFALSE, 0, 0 }
217};
218
219//////////////////////////////////////////////////////////////////////////
220// //
221// TRootContainer //
222// //
223// Utility class used by TRootCanvas. The TRootContainer is the frame //
224// embedded in the TGCanvas widget. The ROOT graphics goes into this //
225// frame. This class is used to enable input events on this graphics //
226// frame and forward the events to the TRootCanvas handlers. //
227// //
228//////////////////////////////////////////////////////////////////////////
229
231private:
232 TRootCanvas *fCanvas; // pointer back to canvas imp
233public:
234 TRootContainer(TRootCanvas *c, Window_t id, const TGWindow *parent);
235
236 Bool_t HandleButton(Event_t *ev) override;
243 { return fCanvas->HandleContainerKey(ev); }
250 void SavePrimitive(std::ostream &out, Option_t * = "") override;
251 void SetEditable(Bool_t) override { }
252};
253
254////////////////////////////////////////////////////////////////////////////////
255/// Create a canvas container.
256
270
271////////////////////////////////////////////////////////////////////////////////
272/// Directly handle scroll mouse buttons (4 and 5), only pass buttons
273/// 1, 2 and 3 on to the TCanvas.
274
276{
278 UInt_t page = vp->GetHeight()/4;
280
281 gVirtualX->SetInputFocus(GetMainFrame()->GetId());
282
283 if (event->fCode == kButton4) {
284 //scroll up
286 if (newpos < 0) newpos = 0;
288// return kTRUE;
289 }
290 if (event->fCode == kButton5) {
291 // scroll down
294// return kTRUE;
295 }
296 return fCanvas->HandleContainerButton(event);
297}
298
299
300////////////////////////////////////////////////////////////////////////////////
301/// Create a basic ROOT canvas.
302
313
314////////////////////////////////////////////////////////////////////////////////
315/// Create a basic ROOT canvas.
316
328
329////////////////////////////////////////////////////////////////////////////////
330/// Create the actual canvas.
331
333{
334 fButton = 0;
335 fAutoFit = kTRUE; // check also menu entry
336 fEditor = 0;
338
339 // Create menus
346
347 static Int_t img = 0;
348
349 if (!img) {
353 img = itmp ? 1 : -1;
354 if (itmp) {
355 delete itmp;
356 itmp=NULL;
357 }
359 }
360 if (img > 0) {
363 }
364
367
369 fFileMenu->AddEntry("&New Canvas", kFileNewCanvas);
370 fFileMenu->AddEntry("&Open...", kFileOpen);
371 fFileMenu->AddEntry("&Close Canvas", kFileCloseCanvas);
374 fFileMenu->AddEntry("Save &As...", kFileSaveAs);
376 fFileMenu->AddEntry("&Print...", kFilePrint);
378 fFileMenu->AddEntry("&Quit ROOT", kFileQuit);
379
383
385 fEditMenu->AddEntry("&Style...", kEditStyle);
387 fEditMenu->AddEntry("Cu&t", kEditCut);
388 fEditMenu->AddEntry("&Copy", kEditCopy);
389 fEditMenu->AddEntry("&Paste", kEditPaste);
393 fEditMenu->AddEntry("&Undo", kEditUndo);
394 fEditMenu->AddEntry("&Redo", kEditRedo);
395
401
405
407 fViewMenu->AddEntry("&Editor", kViewEditor);
408 fViewMenu->AddEntry("&Toolbar", kViewToolbar);
409 fViewMenu->AddEntry("Event &Statusbar", kViewEventStatus);
410 fViewMenu->AddEntry("T&oolTip Info", kViewToolTips);
412 fViewMenu->AddEntry("&Colors", kViewColors);
413 fViewMenu->AddEntry("&Fonts", kViewFonts);
414 fViewMenu->AddEntry("&Markers", kViewMarkers);
416 fViewMenu->AddEntry("&Iconify", kViewIconify);
418 fViewMenu->AddPopup("&View With", fViewWithMenu);
419
421
423 fOptionMenu->AddEntry("&Auto Resize Canvas", kOptionAutoResize);
424 fOptionMenu->AddEntry("&Resize Canvas", kOptionResizeCanvas);
425 fOptionMenu->AddEntry("&Move Opaque", kOptionMoveOpaque);
426 fOptionMenu->AddEntry("Resize &Opaque", kOptionResizeOpaque);
428 fOptionMenu->AddEntry("&Interrupt", kOptionInterrupt);
429 fOptionMenu->AddEntry("R&efresh", kOptionRefresh);
431 fOptionMenu->AddEntry("&Pad Auto Exec", kOptionAutoExec);
433 fOptionMenu->AddEntry("&Statistics", kOptionStatistics);
434 fOptionMenu->AddEntry("Histogram &Title", kOptionHistTitle);
435 fOptionMenu->AddEntry("&Fit Parameters", kOptionFitParams);
436 fOptionMenu->AddEntry("Can Edit &Histograms", kOptionCanEdit);
437
438 // Opaque options initialized in InitWindow()
440 if (gStyle->GetOptStat())
442 if (gStyle->GetOptTitle())
444 if (gStyle->GetOptFit())
446 if (gROOT->GetEditHistograms())
448
450 fToolsMenu->AddEntry("&Inspect ROOT", kInspectRoot);
451 fToolsMenu->AddEntry("&Class Tree", kClassesTree);
452 fToolsMenu->AddEntry("&Fit Panel", kFitPanel);
453 fToolsMenu->AddEntry("&Start Browser", kToolsBrowser);
454 fToolsMenu->AddEntry("&Gui Builder", kToolsBuilder);
455 fToolsMenu->AddEntry("&Event Recorder", kToolsRecorder);
456
458 fHelpMenu->AddLabel("Basic Help On...");
460 fHelpMenu->AddEntry("&Canvas", kHelpOnCanvas);
461 fHelpMenu->AddEntry("&Menus", kHelpOnMenus);
462 fHelpMenu->AddEntry("&Graphics Editor", kHelpOnGraphicsEd);
463 fHelpMenu->AddEntry("&Browser", kHelpOnBrowser);
464 fHelpMenu->AddEntry("&Objects", kHelpOnObjects);
465 fHelpMenu->AddEntry("&PostScript", kHelpOnPS);
467 fHelpMenu->AddEntry("&About ROOT...", kHelpAbout);
468
469 // This main frame will process the menu commands
470 fFileMenu->Associate(this);
472 fEditMenu->Associate(this);
474 fViewMenu->Associate(this);
476 fOptionMenu->Associate(this);
477 fToolsMenu->Associate(this);
478 fHelpMenu->Associate(this);
479
480 // Create menubar layout hints
484
485 // Create menubar
486 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
493
495
499
500 // Create toolbar dock
501 fToolDock = new TGDockableFrame(this);
505
506 // will allocate it later
507 fToolBar = 0;
508 fVertical1 = 0;
509 fVertical2 = 0;
512
516
517 fMainFrame = new TGCompositeFrame(this, GetWidth() + 4, GetHeight() + 4,
520
521 // Create editor frame that will host the pad editor
525
526 // Create canvas and canvas container that will host the ROOT graphics
529
530 fCanvasID = -1;
531
532 if (fCanvas->UseGL()) {
534 //first, initialize GL (if not yet)
535 if (!gGLManager) {
536 TString x = "win32";
537 if (gVirtualX->InheritsFrom("TGX11"))
538 x = "x11";
539 else if (gVirtualX->InheritsFrom("TGCocoa"))
540 x = "osx";
541
542 TPluginHandler *ph = gROOT->GetPluginManager()->FindHandler("TGLManager", x);
543
544 if (ph && ph->LoadPlugin() != -1) {
545 if (!ph->ExecPlugin(0))
546 Error("CreateCanvas", "GL manager plugin failed");
547 }
548 }
549
550 if (gGLManager) {
552 if (fCanvasID != -1) {
553 //Create gl context.
554 const Int_t glCtx = gGLManager->CreateGLContext(fCanvasID);
555 if (glCtx != -1) {
557 fCanvas->SetGLDevice(glCtx);//Now, fCanvas is responsible for context deletion!
558 } else
559 Error("CreateCanvas", "GL context creation failed.");
560 } else
561 Error("CreateCanvas", "GL window creation failed\n");
562 }
563 }
564
565 if (fCanvasID == -1)
567
568 Window_t win = gVirtualX->GetWindowID(fCanvasID);
572
575
576 // create the tooltip with a timeout of 250 ms
578
579 fCanvas->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
580 "TRootCanvas", this,
581 "EventInfo(Int_t, Int_t, Int_t, TObject*)");
582
583 // Create status bar
584 int parts[] = { 33, 10, 10, 47 };
585 fStatusBar = new TGStatusBar(this, 10, 10);
587
589
591
592 // Misc
595 fIconPic = SetIconPixmap("macro_s.xpm");
596 SetClassHints("ROOT", "Canvas");
597
600
601 // by default status bar, tool bar and pad editor are hidden
606
609
610 // we need to use GetDefaultSize() to initialize the layout algorithm...
612
613 gVirtualX->SetDNDAware(fId, fDNDTypeList);
615}
616
617////////////////////////////////////////////////////////////////////////////////
618/// Delete ROOT basic canvas. Order is significant. Delete in reverse
619/// order of creation.
620
622{
623 delete fToolTip;
624 if (fIconPic) gClient->FreePicture(fIconPic);
625 if (fEditor && !fEmbedded) delete fEditor;
626 if (fToolBar) {
627 Disconnect(fToolDock, "Docked()", this, "AdjustSize()");
628 Disconnect(fToolDock, "Undocked()", this, "AdjustSize()");
629 fToolBar->Cleanup();
630 delete fToolBar;
631 }
632
633 if (!MustCleanup()) {
634 delete fStatusBar;
635 delete fStatusBarLayout;
636 delete fCanvasContainer;
637 delete fCanvasWindow;
638
639 delete fEditorFrame;
640 delete fEditorLayout;
641 delete fMainFrame;
642 delete fMainFrameLayout;
643 delete fToolBarSep;
644 delete fToolDock;
645 delete fToolBarLayout;
646 delete fHorizontal1;
647 delete fHorizontal1Layout;
648
649 delete fMenuBar;
650 delete fMenuBarLayout;
651 delete fMenuBarItemLayout;
652 delete fMenuBarHelpLayout;
653 delete fCanvasLayout;
654 delete fDockLayout;
655 }
656
657 delete fFileMenu;
658 delete fFileSaveMenu;
659 delete fEditMenu;
660 delete fEditClearMenu;
661 delete fViewMenu;
662 delete fViewWithMenu;
663 delete fOptionMenu;
664 delete fToolsMenu;
665 delete fHelpMenu;
666}
667
668////////////////////////////////////////////////////////////////////////////////
669/// Called via TCanvasImp interface by TCanvas.
670
672{
674 if(gged && gged->GetCanvas() == fCanvas) {
675 if (fEmbedded) {
676 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
677 ((TGedEditor *)gged)->SetCanvas(0);
678 }
679 else gged->Hide();
680 }
681
682 gVirtualX->CloseWindow();
683}
684
685////////////////////////////////////////////////////////////////////////////////
686/// Really delete the canvas and this GUI.
687
689{
691 if(gged && gged->GetCanvas() == fCanvas) {
692 if (fEmbedded) {
693 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
694 ((TGedEditor *)gged)->SetCanvas(0);
695 }
696 else gged->Hide();
697 }
698
699 fToolTip->Hide();
700 Disconnect(fCanvas, "ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
701 this, "EventInfo(Int_t, Int_t, Int_t, TObject*)");
702
704 fCanvas->Clear();
705 fCanvas->SetName("");
706 if (gPad && gPad->GetCanvas() == fCanvas)
707 gPad = nullptr;
708 delete this;
709}
710
711////////////////////////////////////////////////////////////////////////////////
712/// In case window is closed via WM we get here.
713
718
719////////////////////////////////////////////////////////////////////////////////
720/// Return width of canvas container.
721
726
727////////////////////////////////////////////////////////////////////////////////
728/// Return height of canvas container.
729
734
735////////////////////////////////////////////////////////////////////////////////
736/// Gets the size and position of the window containing the canvas. This
737/// size includes the menubar and borders.
738
740{
741 gVirtualX->GetWindowSize(fId, x, y, w, h);
742
744 gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(),
745 0, 0, x, y, childdum);
746 if (!fCanvas->GetShowEditor()) return 0;
747 return fEditorFrame->GetWidth();
748}
749
750////////////////////////////////////////////////////////////////////////////////
751/// Set text in status bar.
752
757
758////////////////////////////////////////////////////////////////////////////////
759/// Handle menu and other command generated by the user.
760
762{
764 TList *lc;
765
766 switch (GET_MSG(msg)) {
767
768 case kC_COMMAND:
769
770 switch (GET_SUBMSG(msg)) {
771
772 case kCM_BUTTON:
773 case kCM_MENU:
774
775 switch (parm1) {
776 // Handle toolbar items...
777 case kToolModify:
778 gROOT->SetEditorMode();
779 break;
780 case kToolArc:
781 gROOT->SetEditorMode("Arc");
782 break;
783 case kToolLine:
784 gROOT->SetEditorMode("Line");
785 break;
786 case kToolArrow:
787 gROOT->SetEditorMode("Arrow");
788 break;
789 case kToolDiamond:
790 gROOT->SetEditorMode("Diamond");
791 break;
792 case kToolEllipse:
793 gROOT->SetEditorMode("Ellipse");
794 break;
795 case kToolPad:
796 gROOT->SetEditorMode("Pad");
797 break;
798 case kToolPave:
799 gROOT->SetEditorMode("Pave");
800 break;
801 case kToolPLabel:
802 gROOT->SetEditorMode("PaveLabel");
803 break;
804 case kToolPText:
805 gROOT->SetEditorMode("PaveText");
806 break;
807 case kToolPsText:
808 gROOT->SetEditorMode("PavesText");
809 break;
810 case kToolGraph:
811 gROOT->SetEditorMode("PolyLine");
812 break;
813 case kToolCurlyLine:
814 gROOT->SetEditorMode("CurlyLine");
815 break;
816 case kToolCurlyArc:
817 gROOT->SetEditorMode("CurlyArc");
818 break;
819 case kToolLatex:
820 gROOT->SetEditorMode("Text");
821 break;
822 case kToolMarker:
823 gROOT->SetEditorMode("Marker");
824 break;
825 case kToolCutG:
826 gROOT->SetEditorMode("CutG");
827 break;
828
829 // Handle File menu items...
830 case kFileNewCanvas:
831 gROOT->MakeDefCanvas();
832 break;
833 case kFileOpen:
834 {
835 static TString dir(".");
837 fi.fFileTypes = gOpenTypes;
838 fi.SetIniDir(dir);
840 if (!fi.fFilename) return kTRUE;
841 dir = fi.fIniDir;
842 TFile::Open(fi.fFilename, "update");
843 TIter next(gROOT->GetListOfBrowsers());
844 TBrowser *b;
845 while ((b = (TBrowser *)next())) {
846 TRootBrowser *rb = dynamic_cast<TRootBrowser *>(b->GetBrowserImp());
847 if (rb) {
848 TGFileBrowser *fb = dynamic_cast<TGFileBrowser *>(rb->GetActBrowser());
849 if (fb)
850 fb->Selected(0);
851 }
852 }
853 gROOT->RefreshBrowsers();
854 }
855 break;
856 case kFileSaveAs:
857 {
859 static TString dir(".");
860 static Int_t typeidx = 0;
861 static Bool_t overwr = kFALSE;
863 TString defaultType = gEnv->GetValue("Canvas.SaveAsDefaultType", ".pdf");
864 if (typeidx == 0) {
865 for (int i=1;gSaveAsTypes[i];i+=2) {
866 TString ftype = gSaveAsTypes[i];
867 if (ftype.EndsWith(defaultType.Data())) {
868 typeidx = i-1;
869 break;
870 }
871 }
872 }
873 fi.fFileTypes = gSaveAsTypes;
874 fi.SetIniDir(dir);
875 fi.fFileTypeIdx = typeidx;
876 fi.fOverwrite = overwr;
879 if (!fi.fFilename) return kTRUE;
881 TString fn = fi.fFilename;
882 TString ft = fi.fFileTypes[fi.fFileTypeIdx+1];
883 dir = fi.fIniDir;
884 typeidx = fi.fFileTypeIdx;
885 overwr = fi.fOverwrite;
886again:
887 if (fn.EndsWith(".root") ||
888 fn.EndsWith(".ps") ||
889 fn.EndsWith(".eps") ||
890 fn.EndsWith(".pdf") ||
891 fn.EndsWith(".svg") ||
892 fn.EndsWith(".tex") ||
893 fn.EndsWith(".gif") ||
894 fn.EndsWith(".xml") ||
895 fn.EndsWith(".xpm") ||
896 fn.EndsWith(".jpg") ||
897 fn.EndsWith(".png") ||
898 fn.EndsWith(".xcf") ||
899 fn.EndsWith(".tiff")) {
900 fCanvas->SaveAs(fn);
901 } else if (fn.EndsWith(".C"))
903 else {
904 if (!appendedType) {
905 if (ft.Index(".") != kNPOS) {
906 fn += ft(ft.Index("."), ft.Length());
908 goto again;
909 }
910 }
911 Warning("ProcessMessage", "file %s cannot be saved with this extension", fi.fFilename);
912 }
913 for (int i=1;gSaveAsTypes[i];i+=2) {
914 TString ftype = gSaveAsTypes[i];
915 ftype.ReplaceAll("*.", ".");
916 if (fn.EndsWith(ftype.Data())) {
917 typeidx = i-1;
918 break;
919 }
920 }
921 }
922 break;
923 case kFileSaveAsRoot:
924 fCanvas->SaveAs(".root");
925 break;
926 case kFileSaveAsC:
928 break;
929 case kFileSaveAsPS:
930 fCanvas->SaveAs();
931 break;
932 case kFileSaveAsEPS:
933 fCanvas->SaveAs(".eps");
934 break;
935 case kFileSaveAsPDF:
936 fCanvas->SaveAs(".pdf");
937 break;
938 case kFileSaveAsGIF:
939 fCanvas->SaveAs(".gif");
940 break;
941 case kFileSaveAsJPG:
942 fCanvas->SaveAs(".jpg");
943 break;
944 case kFileSaveAsPNG:
945 fCanvas->SaveAs(".png");
946 break;
947 case kFileSaveAsTEX:
948 fCanvas->SaveAs(".tex");
949 break;
950 case kFilePrint:
951 PrintCanvas();
952 break;
953 case kFileCloseCanvas:
955 break;
956 case kFileQuit:
957 if (!gApplication->ReturnFromRun()) {
961 }
964 if (TClass::GetClass("TStyleManager", kFALSE, kTRUE))
965 gROOT->ProcessLine("TStyleManager::Terminate()");
967 break;
968
969 // Handle Edit menu items...
970 case kEditStyle:
971 if (!TClass::GetClass("TStyleManager"))
972 gSystem->Load("libGed");
973 gROOT->ProcessLine("TStyleManager::Show()");
974 break;
975 case kEditCut:
976 // still noop
977 break;
978 case kEditCopy:
979 // still noop
980 break;
981 case kEditPaste:
982 // still noop
983 break;
984 case kEditUndo:
985 // noop
986 break;
987 case kEditRedo:
988 // noop
989 break;
990 case kEditClearPad:
991 gPad->Clear();
992 gPad->Modified();
993 gPad->Update();
994 break;
995 case kEditClearCanvas:
996 fCanvas->Clear();
997 fCanvas->Modified();
998 fCanvas->Update();
999 break;
1000
1001 // Handle View menu items...
1002 case kViewEditor:
1004 break;
1005 case kViewToolbar:
1007 break;
1008 case kViewEventStatus:
1010 break;
1011 case kViewToolTips:
1013 break;
1014 case kViewColors:
1015 {
1016 TVirtualPad *padsav = gPad->GetCanvas();
1017 //This was the code with the old color table
1018 // TCanvas *m = new TCanvas("colors","Color Table");
1019 // TPad::DrawColorTable();
1020 // m->Update();
1021 TColorWheel *wheel = new TColorWheel();
1022 wheel->Draw();
1023
1024 //tp: with Cocoa, window is visible (and repainted)
1025 //before wheel->Draw() was called and you can see "empty"
1026 //canvas.
1027 gPad->Update();
1028 //
1029 if (padsav) padsav->cd();
1030 }
1031 break;
1032 case kViewFonts:
1033 // noop
1034 break;
1035 case kViewMarkers:
1036 {
1037 TVirtualPad *padsav = gPad ? gPad->GetCanvas() : nullptr;
1038 TCanvas *m = new TCanvas("markers","Marker Types",600,200);
1040 m->Update();
1041 if (padsav) padsav->cd();
1042 }
1043 break;
1044 case kViewIconify:
1045 Iconify();
1046 break;
1047 case kViewX3D:
1048 gPad->GetViewer3D("x3d");
1049 break;
1050 case kViewOpenGL:
1051 gPad->GetViewer3D("ogl");
1052 break;
1053
1054 // Handle Option menu items...
1055 case kOptionAutoExec:
1057 if (fCanvas->GetAutoExec()) {
1059 } else {
1061 }
1062 break;
1063 case kOptionAutoResize:
1064 {
1066 int opt = fCanvasContainer->GetOptions();
1067 if (fAutoFit) {
1068 opt &= ~kFixedSize;
1070 } else {
1071 opt |= kFixedSize;
1073 }
1075 // in case of autofit this will generate a configure
1076 // event for the container and this will force the
1077 // update of the TCanvas
1078 //Layout();
1079 }
1080 Layout();
1081 break;
1083 FitCanvas();
1084 break;
1085 case kOptionMoveOpaque:
1086 if (fCanvas->OpaqueMoving()) {
1087 fCanvas->MoveOpaque(0);
1089 } else {
1090 fCanvas->MoveOpaque(1);
1092 }
1093 break;
1095 if (fCanvas->OpaqueResizing()) {
1098 } else {
1101 }
1102 break;
1103 case kOptionInterrupt:
1104 gROOT->SetInterrupt();
1105 break;
1106 case kOptionRefresh:
1107 fCanvas->Paint();
1108 fCanvas->Update();
1109 break;
1110 case kOptionStatistics:
1111 if (gStyle->GetOptStat()) {
1112 gStyle->SetOptStat(0);
1113 delete gPad->FindObject("stats");
1115 } else {
1116 gStyle->SetOptStat(1);
1118 }
1119 gPad->Modified();
1120 fCanvas->Update();
1121 break;
1122 case kOptionHistTitle:
1123 if (gStyle->GetOptTitle()) {
1124 gStyle->SetOptTitle(0);
1125 delete gPad->FindObject("title");
1127 } else {
1128 gStyle->SetOptTitle(1);
1130 }
1131 gPad->Modified();
1132 fCanvas->Update();
1133 break;
1134 case kOptionFitParams:
1135 if (gStyle->GetOptFit()) {
1136 gStyle->SetOptFit(0);
1138 } else {
1139 gStyle->SetOptFit(1);
1141 }
1142 gPad->Modified();
1143 fCanvas->Update();
1144 break;
1145 case kOptionCanEdit:
1146 if (gROOT->GetEditHistograms()) {
1147 gROOT->SetEditHistograms(kFALSE);
1149 } else {
1150 gROOT->SetEditHistograms(kTRUE);
1152 }
1153 break;
1154
1155 // Handle Tools menu items...
1156 case kInspectRoot:
1157 fCanvas->cd();
1158 gROOT->Inspect();
1159 fCanvas->Update();
1160 break;
1161 case kToolsBrowser:
1162 new TBrowser("browser");
1163 break;
1164 case kToolsBuilder:
1166 break;
1167 case kToolsRecorder:
1168 gROOT->ProcessLine("new TGRecorder()");
1169 break;
1170
1171 // Handle Tools menu items...
1172 case kClassesTree:
1173 {
1174 TString cdef;
1175 lc = (TList*)gROOT->GetListOfCanvases();
1176 if (lc->FindObject("ClassTree")) {
1177 cdef = TString::Format("ClassTree_%d", lc->GetSize()+1);
1178 } else {
1179 cdef = "ClassTree";
1180 }
1181 new TClassTree(cdef.Data(), "TObject");
1182 fCanvas->Update();
1183 }
1184 break;
1185
1186 case kFitPanel:
1187 {
1188 // use plugin manager to create instance of TFitEditor
1189 TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
1190 if (handler && handler->LoadPlugin() != -1) {
1191 if (handler->ExecPlugin(2, fCanvas, 0) == 0)
1192 Error("FitPanel", "Unable to crate the FitPanel");
1193 }
1194 else
1195 Error("FitPanel", "Unable to find the FitPanel plug-in");
1196 }
1197 break;
1198
1199 // Handle Help menu items...
1200 case kHelpAbout:
1201 {
1202#ifdef WIN32
1204#else
1205
1206 char str[32];
1207 snprintf(str, 32, "About ROOT %s...", gROOT->GetVersion());
1208 hd = new TRootHelpDialog(this, str, 600, 400);
1209 hd->SetText(gHelpAbout);
1210 hd->Popup();
1211#endif
1212 }
1213 break;
1214 case kHelpOnCanvas:
1215 hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1216 hd->SetText(gHelpCanvas);
1217 hd->Popup();
1218 break;
1219 case kHelpOnMenus:
1220 hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1221 hd->SetText(gHelpPullDownMenus);
1222 hd->Popup();
1223 break;
1224 case kHelpOnGraphicsEd:
1225 hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1226 hd->SetText(gHelpGraphicsEditor);
1227 hd->Popup();
1228 break;
1229 case kHelpOnBrowser:
1230 hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1231 hd->SetText(gHelpBrowser);
1232 hd->Popup();
1233 break;
1234 case kHelpOnObjects:
1235 hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
1236 hd->SetText(gHelpObjects);
1237 hd->Popup();
1238 break;
1239 case kHelpOnPS:
1240 hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
1241 hd->SetText(gHelpPostscript);
1242 hd->Popup();
1243 break;
1244 }
1245 default:
1246 break;
1247 }
1248 default:
1249 break;
1250 }
1251 return kTRUE;
1252}
1253
1254////////////////////////////////////////////////////////////////////////////////
1255/// Called by TCanvas ctor to get window indetifier.
1256
1266
1267////////////////////////////////////////////////////////////////////////////////
1268/// Set size of canvas container. Units in pixels.
1269/// If w==0 and h==0, set autofit mode
1270
1272{
1273 // turn off autofit, we want to stay at the given size
1274 int opt = fCanvasContainer->GetOptions();
1275 if (!w && !h) {
1276 fAutoFit = kTRUE;
1278 opt &= ~kFixedSize; // turn off fixed size mode
1279 } else {
1280 fAutoFit = kFALSE;
1282 opt |= kFixedSize; // turn on fixed size mode
1283 }
1287 Layout(); // force layout (will update container to given size)
1288 fCanvas->Resize();
1289 fCanvas->Update();
1290}
1291
1292////////////////////////////////////////////////////////////////////////////////
1293/// Set canvas position (units in pixels).
1294
1299
1300////////////////////////////////////////////////////////////////////////////////
1301/// Set size of canvas (units in pixels).
1302
1304{
1305 Resize(w, h);
1306
1307 // Make sure the change of size is really done.
1308 gVirtualX->Update(1);
1309 if (!gThreadXAR) {
1310 gSystem->Sleep(100);
1312 gSystem->Sleep(10);
1314 }
1315}
1316
1317////////////////////////////////////////////////////////////////////////////////
1318/// Put canvas window on top of the window stack.
1319
1321{
1322 gVirtualX->RaiseWindow(GetId());
1323}
1324
1325////////////////////////////////////////////////////////////////////////////////
1326/// Change title on window.
1327
1328void TRootCanvas::SetWindowTitle(const char *title)
1329{
1330 SetWindowName(title);
1331 SetIconName(title);
1332 fToolDock->SetWindowName(Form("ToolBar: %s", title));
1333}
1334
1335////////////////////////////////////////////////////////////////////////////////
1336/// Fit canvas container to current window size.
1337
1339{
1340 if (!fAutoFit) {
1341 int opt = fCanvasContainer->GetOptions();
1342 int oopt = opt;
1343 opt &= ~kFixedSize; // turn off fixed size mode
1345 Layout(); // force layout
1346 fCanvas->Resize();
1347 fCanvas->Update();
1349 }
1350}
1351
1352////////////////////////////////////////////////////////////////////////////////
1353/// Print the canvas.
1354
1356{
1357 Int_t ret = 0;
1358 Bool_t pname = kTRUE;
1359 char *printer, *printCmd;
1360 static TString sprinter, sprintCmd;
1361
1362 if (sprinter == "")
1363 printer = StrDup(gEnv->GetValue("Print.Printer", ""));
1364 else
1366 if (sprintCmd == "")
1367#ifndef WIN32
1368 printCmd = StrDup(gEnv->GetValue("Print.Command", ""));
1369#else
1370 printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p"));
1371#endif
1372 else
1374
1375 new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
1376 &printer, &printCmd, &ret);
1377 if (ret) {
1378 sprinter = printer;
1380
1381 if (sprinter == "")
1382 pname = kFALSE;
1383
1384 TString fn = "rootprint";
1385 FILE *f = gSystem->TempFileName(fn, gEnv->GetValue("Print.Directory", gSystem->TempDirectory()));
1386 if (f) fclose(f);
1387 fn += TString::Format(".%s",gEnv->GetValue("Print.FileType", "pdf"));
1388 fCanvas->Print(fn);
1389
1391 if (cmd.Contains("%p"))
1392 cmd.ReplaceAll("%p", sprinter);
1393 else if (pname) {
1394 cmd += " "; cmd += sprinter; cmd += " ";
1395 }
1396
1397 if (cmd.Contains("%f"))
1398 cmd.ReplaceAll("%f", fn);
1399 else {
1400 cmd += " "; cmd += fn; cmd += " ";
1401 }
1402
1403 gSystem->Exec(cmd);
1404#ifndef WIN32
1405 gSystem->Unlink(fn);
1406#endif
1407 }
1408 delete [] printer;
1409 delete [] printCmd;
1410}
1411
1412////////////////////////////////////////////////////////////////////////////////
1413/// Display a tooltip with infos about the primitive below the cursor.
1414
1415void TRootCanvas::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
1416{
1417 fToolTip->Hide();
1418 if (!fCanvas->GetShowToolTips() || selected == 0 ||
1419 event != kMouseMotion || fButton != 0)
1420 return;
1422 TString objInfo = selected->GetObjectInfo(px, py);
1423 if (objInfo.BeginsWith("-")) {
1424 // if the string begins with '-', display only the object info
1425 objInfo.Remove(TString::kLeading, '-');
1426 tipInfo = objInfo;
1427 }
1428 else {
1429 const char *title = selected->GetTitle();
1430 tipInfo += TString::Format("%s::%s", selected->ClassName(),
1431 selected->GetName());
1432 if (title && strlen(title))
1433 tipInfo += TString::Format("\n%s", selected->GetTitle());
1434 tipInfo += TString::Format("\n%d, %d", px, py);
1435 if (!objInfo.IsNull())
1436 tipInfo += TString::Format("\n%s", objInfo.Data());
1437 }
1438 fToolTip->SetText(tipInfo.Data());
1439 fToolTip->SetPosition(px+15, py+15);
1440 fToolTip->Reset();
1441}
1442
1443////////////////////////////////////////////////////////////////////////////////
1444/// Show or hide menubar.
1445
1451
1452////////////////////////////////////////////////////////////////////////////////
1453/// Show or hide statusbar.
1454
1456{
1459
1460 UInt_t h = GetHeight();
1462
1463 if (show) {
1466 if (dh - ch >= sh) h = h + sh;
1467 else h = ch;
1468 } else {
1471 if (dh - ch < sh) h = ch;
1472 else h = h - sh;
1473 }
1474 Resize(GetWidth(), h);
1475}
1476
1477////////////////////////////////////////////////////////////////////////////////
1478/// Show or hide side frame.
1479
1481{
1483
1484 UInt_t w = GetWidth();
1486 UInt_t h = GetHeight();
1488
1489 auto lambda_show = [&, this]() {
1490 if (show) {
1491 if (!fEditor)
1492 CreateEditor();
1494 if (gged && gged->GetCanvas() == fCanvas) {
1495 gged->Hide();
1496 }
1499 h += s;
1500 }
1502 fEditor->Show();
1504 w += e;
1505 } else {
1508 h -= s;
1509 }
1510 if (fEditor)
1511 fEditor->Hide();
1514 w -= e;
1515 }
1516 };
1517
1518 if (fParent && fParent != fClient->GetDefaultRoot()) {
1519 TGMainFrame *main = (TGMainFrame *)fParent->GetMainFrame();
1521 if (main && main->InheritsFrom("TRootBrowser")) {
1523 if (!fEmbedded)
1524 browser->GetTabRight()->Connect("Selected(Int_t)", "TRootCanvas",
1525 this, "Activated(Int_t)");
1526 fEmbedded = kTRUE;
1527 if (show && (!fEditor || !((TGedEditor *)fEditor)->IsMapped())) {
1528 if (!browser->GetTabLeft()->GetTabTab("Pad Editor")) {
1529 if (browser->GetActFrame()) { //already in edit mode
1530 TTimer::SingleShot(200, "TRootCanvas", this, "ShowEditor(=kTRUE)");
1531 } else {
1532 browser->StartEmbedding(TRootBrowser::kLeft);
1533 if (!fEditor)
1535 else {
1536 ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot());
1537 ((TGedEditor *)fEditor)->MapWindow();
1538 }
1539 browser->StopEmbedding("Pad Editor");
1540 if (fEditor) {
1542 gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor);
1543 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
1544 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
1545 }
1546 }
1547 }
1548 else
1550 }
1551 if (show) browser->GetTabLeft()->SetTab("Pad Editor");
1552 } else {
1553 lambda_show();
1554 main->Layout();
1555 }
1556 }
1557 else {
1558 lambda_show();
1559 Resize(w, h);
1560 }
1561}
1562
1563////////////////////////////////////////////////////////////////////////////////
1564/// Create embedded editor.
1565
1567{
1570 gPad = Canvas();
1571 // next two lines are related to the old editor
1572 Int_t show = gEnv->GetValue("Canvas.ShowEditor", 0);
1573 gEnv->SetValue("Canvas.ShowEditor","true");
1578
1579 // next line is related to the old editor
1580 if (show == 0) gEnv->SetValue("Canvas.ShowEditor","false");
1581}
1582
1583////////////////////////////////////////////////////////////////////////////////
1584/// Show or hide toolbar.
1585
1587{
1588 if (show && !fToolBar) {
1589
1592
1593 Int_t spacing = 6, i;
1594 for (i = 0; gToolBarData[i].fPixmap; i++) {
1595 if (strlen(gToolBarData[i].fPixmap) == 0) {
1596 spacing = 6;
1597 continue;
1598 }
1600 spacing = 0;
1601 }
1608
1609 spacing = 6;
1610 for (i = 0; gToolBarData1[i].fPixmap; i++) {
1611 if (strlen(gToolBarData1[i].fPixmap) == 0) {
1612 spacing = 6;
1613 continue;
1614 }
1616 spacing = 0;
1617 }
1619 fToolDock->Layout();
1620 fToolDock->SetWindowName(Form("ToolBar: %s", GetWindowName()));
1621 fToolDock->Connect("Docked()", "TRootCanvas", this, "AdjustSize()");
1622 fToolDock->Connect("Undocked()", "TRootCanvas", this, "AdjustSize()");
1623 }
1624
1625 if (!fToolBar) return;
1626
1627 UInt_t h = GetHeight();
1630
1631 if (show) {
1635 h = h + sh;
1636 }
1639 h = h + dh + sh;
1640 } else {
1641 if (fToolDock->IsUndocked()) {
1643 h = h + 2*sh;
1644 } else h = h - dh;
1645
1649 h = h - sh;
1650 }
1652 h = h - sh;
1654 }
1655 Resize(GetWidth(), h);
1656}
1657
1658////////////////////////////////////////////////////////////////////////////////
1659/// Enable or disable tooltip info.
1660
1668
1669////////////////////////////////////////////////////////////////////////////////
1670/// Returns kTRUE if the editor is shown.
1671
1676
1677////////////////////////////////////////////////////////////////////////////////
1678/// Returns kTRUE if the menu bar is shown.
1679
1681{
1682 return (fMenuBar) && fMenuBar->IsMapped();
1683}
1684
1685////////////////////////////////////////////////////////////////////////////////
1686/// Returns kTRUE if the status bar is shown.
1687
1689{
1690 return (fStatusBar) && fStatusBar->IsMapped();
1691}
1692
1693////////////////////////////////////////////////////////////////////////////////
1694/// Returns kTRUE if the tool bar is shown.
1695
1697{
1698 return (fToolBar) && fToolBar->IsMapped();
1699}
1700
1701////////////////////////////////////////////////////////////////////////////////
1702/// Returns kTRUE if the tooltips are enabled.
1703
1705{
1706 return (fCanvas) && fCanvas->GetShowToolTips();
1707}
1708
1709////////////////////////////////////////////////////////////////////////////////
1710/// Keep the same canvas size while docking/undocking toolbar.
1711
1713{
1714 UInt_t h = GetHeight();
1717
1718 if (fToolDock->IsUndocked()) {
1721 h = h - sh;
1722 }
1724 h = h - dh - sh;
1725 } else {
1728 h = h + sh;
1729 }
1731 h = h + dh + sh;
1732 }
1733 Resize(GetWidth(), h);
1734}
1735
1736////////////////////////////////////////////////////////////////////////////////
1737/// Handle mouse button events in the canvas container.
1738
1740{
1741 Int_t button = event->fCode;
1742 Int_t x = event->fX;
1743 Int_t y = event->fY;
1744
1745 if (event->fType == kButtonPress) {
1746 if (fToolTip && fCanvas->GetShowToolTips()) {
1747 fToolTip->Hide();
1748 gVirtualX->UpdateWindow(0);
1750 }
1751 fButton = button;
1752 if (button == kButton1) {
1753 if (event->fState & kKeyShiftMask)
1755 else
1757 }
1758 if (button == kButton2)
1760 if (button == kButton3) {
1762 fButton = 0; // button up is consumed by TContextMenu
1763 }
1764
1765 } else if (event->fType == kButtonRelease) {
1766 if (button == kButton4)
1768 if (button == kButton5)
1770 if (button == kButton1)
1772 if (button == kButton2)
1774 if (button == kButton3)
1776
1777 fButton = 0;
1778 }
1779
1780 return kTRUE;
1781}
1782
1783////////////////////////////////////////////////////////////////////////////////
1784/// Handle mouse button double click events in the canvas container.
1785
1787{
1788 Int_t button = event->fCode;
1789 Int_t x = event->fX;
1790 Int_t y = event->fY;
1791
1792 if (button == kButton1)
1794 if (button == kButton2)
1796 if (button == kButton3)
1798
1799 return kTRUE;
1800}
1801
1802////////////////////////////////////////////////////////////////////////////////
1803/// Handle configure (i.e. resize) event.
1804
1806{
1807 if (fAutoFit) {
1808 fCanvas->Resize();
1809 fCanvas->Update();
1810 }
1811
1813 // get menu height
1814 static Int_t dh = 0;
1815 if (!dh)
1820 }
1821 return kTRUE;
1822}
1823
1824////////////////////////////////////////////////////////////////////////////////
1825/// Handle keyboard events in the canvas container.
1826
1828{
1830 static UInt_t previous_keysym = 0;
1831
1832 if (event->fType == kGKeyPress) {
1833 fButton = event->fCode;
1834 UInt_t keysym;
1835 char str[2];
1836 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1837
1838 if (str[0] == kESC){ // ESC sets the escape flag
1839 gROOT->SetEscape();
1842 gPad->Modified();
1843 return kTRUE;
1844 }
1845 if (str[0] == 3) // ctrl-c sets the interrupt flag
1846 gROOT->SetInterrupt();
1847
1848 // handle arrow keys
1849 if (keysym > 0x1011 && keysym < 0x1016) {
1851 UInt_t mask = 0;
1852 Int_t mx, my, tx, ty;
1853 wid = gVirtualX->GetDefaultRootWindow();
1854 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1855 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1857 mx, my, tx, ty, dum1);
1859 // handle case where we got consecutive same keypressed events coming
1860 // from auto-repeat on Windows (as it fires only successive keydown events)
1862 switch (keysym) {
1863 case 0x1012: // left
1864 gVirtualX->Warp(--mx, my, wid); --tx;
1865 break;
1866 case 0x1013: // up
1867 gVirtualX->Warp(mx, --my, wid); --ty;
1868 break;
1869 case 0x1014: // right
1870 gVirtualX->Warp(++mx, my, wid); ++tx;
1871 break;
1872 case 0x1015: // down
1873 gVirtualX->Warp(mx, ++my, wid); ++ty;
1874 break;
1875 default:
1876 break;
1877 }
1879 }
1881 }
1882 else {
1884 }
1885 } else if (event->fType == kKeyRelease) {
1886 UInt_t keysym;
1887 char str[2];
1888 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1889
1890 if (keysym > 0x1011 && keysym < 0x1016) {
1892 UInt_t mask = 0;
1893 Int_t mx, my, tx, ty;
1894 wid = gVirtualX->GetDefaultRootWindow();
1895 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1896 switch (keysym) {
1897 case 0x1012: // left
1898 gVirtualX->Warp(--mx, my, wid);
1899 break;
1900 case 0x1013: // up
1901 gVirtualX->Warp(mx, --my, wid);
1902 break;
1903 case 0x1014: // right
1904 gVirtualX->Warp(++mx, my, wid);
1905 break;
1906 case 0x1015: // down
1907 gVirtualX->Warp(mx, ++my, wid);
1908 break;
1909 default:
1910 break;
1911 }
1912 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1914 mx, my, tx, ty, dum1);
1917 }
1918 fButton = 0;
1919 }
1920 previous_event = event->fType;
1921 return kTRUE;
1922}
1923
1924////////////////////////////////////////////////////////////////////////////////
1925/// Handle mouse motion event in the canvas container.
1926
1928{
1929 Int_t x = event->fX;
1930 Int_t y = event->fY;
1931
1932 if (fButton == 0)
1934 if (fButton == kButton1) {
1935 if (event->fState & kKeyShiftMask)
1937 else
1939 }
1940 if (fButton == kButton2)
1942
1943 return kTRUE;
1944}
1945
1946////////////////////////////////////////////////////////////////////////////////
1947/// Handle expose events.
1948
1950{
1951 if (event->fCount == 0) {
1952 fCanvas->Flush();
1953 }
1954
1955 return kTRUE;
1956}
1957
1958////////////////////////////////////////////////////////////////////////////////
1959/// Handle enter/leave events. Only leave is activated at the moment.
1960
1962{
1963 Int_t x = event->fX;
1964 Int_t y = event->fY;
1965
1966 // pointer grabs create also an enter and leave event but with fCode
1967 // either kNotifyGrab or kNotifyUngrab, don't propagate these events
1968 if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
1970
1971 return kTRUE;
1972}
1973
1974////////////////////////////////////////////////////////////////////////////////
1975/// Handle drop events.
1976
1978{
1979 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
1980 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
1981
1982 if (data->fDataType == rootObj) {
1983 TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
1984 buf.SetReadMode();
1986 if (!obj) return kTRUE;
1987 gPad->Clear();
1988 if (obj->InheritsFrom("TKey")) {
1989 TObject *object = (TObject *)gROOT->ProcessLine(Form("((TKey *)0x%zx)->ReadObj();", (size_t)obj));
1990 if (!object) return kTRUE;
1991 if (object->InheritsFrom("TGraph"))
1992 object->Draw("ALP");
1993 else if (object->InheritsFrom("TImage"))
1994 object->Draw("x");
1995 else if (object->IsA()->GetMethodAllAny("Draw"))
1996 object->Draw();
1997 }
1998 else if (obj->InheritsFrom("TGraph"))
1999 obj->Draw("ALP");
2000 else if (obj->IsA()->GetMethodAllAny("Draw"))
2001 obj->Draw();
2002 gPad->Modified();
2003 gPad->Update();
2004 return kTRUE;
2005 }
2006 else if (data->fDataType == uriObj) {
2007 TString sfname((char *)data->fData);
2008 if (sfname.Length() > 7) {
2009 sfname.ReplaceAll("\r\n", "");
2010 TUrl uri(sfname.Data());
2011 if (sfname.EndsWith(".bmp") ||
2012 sfname.EndsWith(".gif") ||
2013 sfname.EndsWith(".jpg") ||
2014 sfname.EndsWith(".png") ||
2015 sfname.EndsWith(".ps") ||
2016 sfname.EndsWith(".eps") ||
2017 sfname.EndsWith(".pdf") ||
2018 sfname.EndsWith(".tiff") ||
2019 sfname.EndsWith(".xpm")) {
2020 TImage *img = TImage::Open(uri.GetFile());
2021 if (img) {
2022 img->Draw("x");
2023 img->SetEditable(kTRUE);
2024 }
2025 }
2026 gPad->Modified();
2027 gPad->Update();
2028 }
2029 }
2030 return kFALSE;
2031}
2032
2033////////////////////////////////////////////////////////////////////////////////
2034/// Handle dragging position events.
2035
2037 Int_t /*xroot*/, Int_t /*yroot*/)
2038{
2039 TPad *pad = fCanvas->Pick(x, y, 0);
2040 if (pad) {
2041 pad->cd();
2042 gROOT->SetSelectedPad(pad);
2043 // make sure the pad is highlighted (on Windows)
2044 pad->Update();
2045 }
2046 return action;
2047}
2048
2049////////////////////////////////////////////////////////////////////////////////
2050/// Handle drag enter events.
2051
2053{
2054 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2055 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2056 Atom_t ret = kNone;
2057 for (int i = 0; typelist[i] != kNone; ++i) {
2058 if (typelist[i] == rootObj)
2059 ret = rootObj;
2060 if (typelist[i] == uriObj)
2061 ret = uriObj;
2062 }
2063 return ret;
2064}
2065
2066////////////////////////////////////////////////////////////////////////////////
2067/// Handle drag leave events.
2068
2070{
2071 return kTRUE;
2072}
2073
2074////////////////////////////////////////////////////////////////////////////////
2075/// Slot handling tab switching in the browser, to properly set the canvas
2076/// and the model to the editor.
2077
2079{
2080 if (fEmbedded) {
2082 if (sender) {
2083 TGCompositeFrame *cont = sender->GetTabContainer(id);
2084 if (cont == fParent) {
2085 if (!fEditor)
2087 if (fEditor && ((TGedEditor *)fEditor)->IsMapped()) {
2088 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
2089 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
2090 }
2091 }
2092 }
2093 }
2094}
2095
2096////////////////////////////////////////////////////////////////////////////////
2097/// Save a canvas container as a C++ statement(s) on output stream out.
2098
2099void TRootContainer::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
2100{
2101 out << "\n // canvas container\n";
2102 out << " Int_t canvasID = gVirtualX->InitWindow((ULongptr_t)" << GetParent()->GetParent()->GetName()
2103 << "->GetId());\n";
2104 out << " Window_t winC = gVirtualX->GetWindowID(canvasID);\n";
2105 out << " TGCompositeFrame *" << GetName() << " = new TGCompositeFrame(gClient, winC, " << GetParent()->GetName()
2106 << ");\n";
2107}
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
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
EGEventType
Definition GuiTypes.h:59
@ kGKeyPress
Definition GuiTypes.h:60
@ kButtonRelease
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
@ kOtherEvent
Definition GuiTypes.h:64
@ kKeyRelease
Definition GuiTypes.h:60
@ kLeaveNotify
Definition GuiTypes.h:61
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
@ kNotifyNormal
Definition GuiTypes.h:219
const Mask_t kExposureMask
Definition GuiTypes.h:165
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kKeyReleaseMask
Definition GuiTypes.h:160
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Mask_t kKeyPressMask
Definition GuiTypes.h:159
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
const Mask_t kKeyShiftMask
Definition GuiTypes.h:195
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kFixedSize
Definition GuiTypes.h:390
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:168
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:166
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
@ kButton4
Definition GuiTypes.h:215
@ kButton2
Definition GuiTypes.h:214
@ kButton5
Definition GuiTypes.h:215
@ kButton3
Definition GuiTypes.h:214
@ kButton1
Definition GuiTypes.h:214
@ kAnyButton
Definition GuiTypes.h:214
R__EXTERN const char gHelpObjects[]
Definition HelpText.h:26
R__EXTERN const char gHelpPullDownMenus[]
Definition HelpText.h:24
R__EXTERN const char gHelpAbout[]
Definition HelpText.h:17
R__EXTERN const char gHelpGraphicsEditor[]
Definition HelpText.h:23
R__EXTERN const char gHelpCanvas[]
Definition HelpText.h:25
R__EXTERN const char gHelpBrowser[]
Definition HelpText.h:18
R__EXTERN const char gHelpPostscript[]
Definition HelpText.h:21
int main()
Definition Prototype.cxx:12
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
constexpr Int_t kFatal
Definition TError.h:50
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
Int_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
Definition TError.cxx:33
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
#define gClient
Definition TGClient.h:157
@ kFDOpen
@ kFDSave
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetIconPixmap
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetWMPosition
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t Atom_t typelist
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t button
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char mx
char name[80]
Definition TGX11.cxx:110
R__EXTERN void * gTQSender
Definition TQObject.h:46
#define gROOT
Definition TROOT.h:411
@ 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
@ kFileSaveAsPS
@ kOptionStatistics
@ kFileSaveAsJPG
@ kOptionHistTitle
@ 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 * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2495
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2563
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#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:337
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:162
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition TCanvas.cxx:2419
virtual void ToggleToolTips()
Toggle tooltip display.
Definition TCanvas.cxx:2461
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition TCanvas.cxx:735
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition TCanvas.cxx:2428
void SetSupportGL(Bool_t support)
Definition TCanvas.h:229
TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj) override
Search for an object at pixel position px,py.
Definition TCanvas.h:183
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition TCanvas.cxx:1666
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition TCanvas.cxx:1810
void SetCanvasImp(TCanvasImp *i)
Set canvas implementation If web-based implementation provided, some internal fields also initialized...
Definition TCanvas.cxx:2158
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition TCanvas.cxx:1232
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition TCanvas.cxx:717
Bool_t GetShowEditor() const
Definition TCanvas.h:150
Bool_t GetAutoExec() const
Definition TCanvas.h:152
virtual void ToggleEditor()
Toggle editor.
Definition TCanvas.cxx:2450
Bool_t GetShowToolTips() const
Definition TCanvas.h:151
void SetName(const char *name="") override
Set canvas name.
Definition TCanvas.cxx:2020
void Paint(Option_t *option="") override
Paint canvas.
Definition TCanvas.cxx:1541
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2486
Bool_t OpaqueMoving() const override
Definition TCanvas.h:180
void Flush()
Flush canvas buffers.
Definition TCanvas.cxx:1143
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition TCanvas.cxx:1533
Bool_t UseGL() const
Definition TCanvas.h:228
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition TCanvas.cxx:1757
virtual void ToggleToolBar()
Toggle toolbar.
Definition TCanvas.cxx:2439
Bool_t OpaqueResizing() const override
Definition TCanvas.h:181
Draw inheritance tree and their relations for a list of classes.
Definition TClassTree.h:22
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:2973
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:490
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:735
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:3764
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
virtual void SetContainer(TGFrame *f)
Definition TGCanvas.h:222
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
virtual Int_t GetVsbPosition() const
Get position of vertical scrollbar.
TGViewPort * GetViewPort() const
Definition TGCanvas.h:217
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:223
UInt_t GetDisplayHeight() const
Get display height.
Definition TGClient.cxx:274
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
Int_t MustCleanup() const override
Definition TGFrame.h:362
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
TGCompositeFrame(const TGCompositeFrame &)=delete
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1249
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1196
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1064
void SetEditable(Bool_t on=kTRUE) override
Switch ON/OFF edit mode.
Definition TGFrame.cxx:940
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1014
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1035
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1182
A frame with handles that allow it to be undocked (i.e.
void DockContainer(Int_t del=kTRUE)
Dock container back to TGDockableFrame.
void AddFrame(TGFrame *f, TGLayoutHints *hints) override
Add frame to dockable frame container. Frame and hints are NOT adopted.
void SetWindowName(const char *name) override
Set window name so it appear as title of the undock window.
void EnableHide(Bool_t onoff)
Enable hiding.
Bool_t IsUndocked() const
System file browser, used as TRootBrowser plug-in.
void Selected(char *)
A ROOT File has been selected in TGHtmlBrowser.
This class creates a file selection dialog.
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:331
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:621
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition TGFrame.cxx:435
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:585
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:268
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
UInt_t GetHeight() const
Definition TGFrame.h:227
virtual void SetWidth(UInt_t w)
Definition TGFrame.h:248
void SetDNDTarget(Bool_t onoff)
Definition TGFrame.h:272
UInt_t GetWidth() const
Definition TGFrame.h:226
virtual void SetHeight(UInt_t h)
Definition TGFrame.h:249
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition TG3DLine.h:18
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
Atom_t * fDNDTypeList
handles DND types
Definition TGFrame.h:415
virtual void SendCloseMessage()
Send close message to self.
Definition TGFrame.cxx:1736
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition TGFrame.cxx:1850
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1793
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1780
const char * GetWindowName() const
Definition TGFrame.h:478
The TGMenu.h header contains all different menu classes.
Definition TGMenu.h:282
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=nullptr)
Add popup menu to menu bar.
Definition TGMenu.cxx:414
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
This class creates a popup menu object.
Definition TGMenu.h:110
virtual void AddLabel(TGHotString *s, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu label to the menu.
Definition TGMenu.cxx:1091
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition TGMenu.cxx:1841
virtual void AddPopup(TGHotString *s, TGPopupMenu *popup, TGMenuEntry *before=nullptr, const TGPicture *p=nullptr)
Add a (cascading) popup menu to a popup menu.
Definition TGMenu.cxx:1148
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition TGMenu.cxx:1778
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1720
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition TGMenu.cxx:1803
virtual void Associate(const TGWindow *w)
Definition TGMenu.h:206
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1056
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=nullptr, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu entry.
Definition TGMenu.cxx:986
Provides a StatusBar widget.
Definition TGStatusBar.h:21
virtual void SetText(TGString *text, Int_t partidx=0)
Set text in partition partidx in status bar.
virtual void SetParts(Int_t npart)
Divide the status bar in npart equal sized parts.
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
Definition TGTab.h:46
A toolbar is a composite frame that contains TGPictureButtons.
Definition TGToolBar.h:33
virtual TGButton * AddButton(const TGWindow *w, ToolBarData_t *button, Int_t spacing=0)
Add button to toolbar.
Definition TGToolBar.cxx:91
void Cleanup() override
Cleanup and delete all objects contained in this composite frame.
A tooltip can be a one or multiple lines help text that is displayed in a window when the mouse curso...
Definition TGToolTip.h:24
void Hide()
Hide tool tip window.
void SetPosition(Int_t x, Int_t y)
Set popup position within specified frame (as specified in the ctor).
void SetText(const char *new_text)
Set new tool tip text.
void Reset()
Reset tool tip popup delay timer.
A vertical 3D line is a line that can be used to separate groups of widgets.
Definition TG3DLine.h:33
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:150
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
@ kEditEnable
allow edit of this window
Definition TGWindow.h:56
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
const TGWindow * GetParent() const
Definition TGWindow.h:83
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:293
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
static TGuiBuilder * Instance()
return an instance of TGuiBuilder object
An abstract interface to image processing library.
Definition TImage.h:29
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition TImage.cxx:117
static TImage * Create()
Create an image.
Definition TImage.cxx:34
A doubly linked list.
Definition TList.h:38
static void DisplayMarkerTypes()
Display the table of markers with their numbers.
Definition TMarker.cxx:102
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Inspect() const
Dump contents of this object in a graphics canvas.
Definition TObject.cxx:564
static TClass * Class()
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
virtual TClass * IsA() const
Definition TObject.h:246
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:225
void Modified(Bool_t flag=true) override
Mark pad modified Will be repainted when TCanvas::Update() will be called next time.
Definition TPad.cxx:7459
Bool_t HasFixedAspectRatio() const override
Definition TPad.h:271
virtual void SetGLDevice(Int_t dev)
Definition TPad.h:367
void SaveAs(const char *filename="", Option_t *option="") const override
Save the pad content in a file.
Definition TPad.cxx:5906
void Print(const char *filename="") const override
This method is equivalent to SaveAs("filename"). See TPad::SaveAs for details.
Definition TPad.cxx:4916
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.
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:712
@ kLeading
Definition TString.h:284
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2384
Int_t GetOptStat() const
Definition TStyle.h:247
void SetOptTitle(Int_t tit=1)
Definition TStyle.h:338
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition TStyle.cxx:1641
Int_t GetOptTitle() const
Definition TStyle.h:248
Int_t GetOptFit() const
Definition TStyle.h:246
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
Definition TStyle.cxx:1594
virtual FILE * TempFileName(TString &base, const char *dir=nullptr, const char *suffix=nullptr)
Create a secure temporary file by appending a unique 6 letter string to base.
Definition TSystem.cxx:1510
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:651
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1868
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:872
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:435
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:881
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:414
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1392
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition TSystem.cxx:1493
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition TTimer.cxx:261
This class represents a WWW compatible URL.
Definition TUrl.h:33
const char * GetFile() const
Definition TUrl.h:69
Abstract base class used by ROOT graphics editor.
static TVirtualPadEditor * LoadEditor()
Static function returning a pointer to a new pad editor.
virtual void Hide()
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
virtual void SetGlobal(Bool_t)
virtual void Show()
static void Terminate()
Close the global pad editor. Static method.
small helper class to store/restore gPad context in TPad methods
Definition TVirtualPad.h:61
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
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:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fCount
if non-zero, at least this many more exposes
Definition GuiTypes.h:183
UInt_t fState
key or button mask
Definition GuiTypes.h:181
UInt_t fCode
key or button code
Definition GuiTypes.h:180
TMarker m
Definition textangle.C:8