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
300
301////////////////////////////////////////////////////////////////////////////////
302/// Create a basic ROOT canvas.
303
314
315////////////////////////////////////////////////////////////////////////////////
316/// Create a basic ROOT canvas.
317
329
330////////////////////////////////////////////////////////////////////////////////
331/// Create the actual canvas.
332
334{
335 fButton = 0;
336 fAutoFit = kTRUE; // check also menu entry
337 fEditor = 0;
339
340 // Create menus
347
348 static Int_t img = 0;
349
350 if (!img) {
354 img = itmp ? 1 : -1;
355 if (itmp) {
356 delete itmp;
357 itmp=NULL;
358 }
360 }
361 if (img > 0) {
364 }
365
368
370 fFileMenu->AddEntry("&New Canvas", kFileNewCanvas);
371 fFileMenu->AddEntry("&Open...", kFileOpen);
372 fFileMenu->AddEntry("&Close Canvas", kFileCloseCanvas);
375 fFileMenu->AddEntry("Save &As...", kFileSaveAs);
377 fFileMenu->AddEntry("&Print...", kFilePrint);
379 fFileMenu->AddEntry("&Quit ROOT", kFileQuit);
380
384
386 fEditMenu->AddEntry("&Style...", kEditStyle);
388 fEditMenu->AddEntry("Cu&t", kEditCut);
389 fEditMenu->AddEntry("&Copy", kEditCopy);
390 fEditMenu->AddEntry("&Paste", kEditPaste);
394 fEditMenu->AddEntry("&Undo", kEditUndo);
395 fEditMenu->AddEntry("&Redo", kEditRedo);
396
402
406
408 fViewMenu->AddEntry("&Editor", kViewEditor);
409 fViewMenu->AddEntry("&Toolbar", kViewToolbar);
410 fViewMenu->AddEntry("Event &Statusbar", kViewEventStatus);
411 fViewMenu->AddEntry("T&oolTip Info", kViewToolTips);
413 fViewMenu->AddEntry("&Colors", kViewColors);
414 fViewMenu->AddEntry("&Fonts", kViewFonts);
415 fViewMenu->AddEntry("&Markers", kViewMarkers);
417 fViewMenu->AddEntry("&Iconify", kViewIconify);
419 fViewMenu->AddPopup("&View With", fViewWithMenu);
420
422
424 fOptionMenu->AddEntry("&Auto Resize Canvas", kOptionAutoResize);
425 fOptionMenu->AddEntry("&Resize Canvas", kOptionResizeCanvas);
426 fOptionMenu->AddEntry("&Move Opaque", kOptionMoveOpaque);
427 fOptionMenu->AddEntry("Resize &Opaque", kOptionResizeOpaque);
429 fOptionMenu->AddEntry("&Interrupt", kOptionInterrupt);
430 fOptionMenu->AddEntry("R&efresh", kOptionRefresh);
432 fOptionMenu->AddEntry("&Pad Auto Exec", kOptionAutoExec);
434 fOptionMenu->AddEntry("&Statistics", kOptionStatistics);
435 fOptionMenu->AddEntry("Histogram &Title", kOptionHistTitle);
436 fOptionMenu->AddEntry("&Fit Parameters", kOptionFitParams);
437 fOptionMenu->AddEntry("Can Edit &Histograms", kOptionCanEdit);
438
439 // Opaque options initialized in InitWindow()
441 if (gStyle->GetOptStat())
443 if (gStyle->GetOptTitle())
445 if (gStyle->GetOptFit())
447 if (gROOT->GetEditHistograms())
449
451 fToolsMenu->AddEntry("&Inspect ROOT", kInspectRoot);
452 fToolsMenu->AddEntry("&Class Tree", kClassesTree);
453 fToolsMenu->AddEntry("&Fit Panel", kFitPanel);
454 fToolsMenu->AddEntry("&Start Browser", kToolsBrowser);
455 fToolsMenu->AddEntry("&Gui Builder", kToolsBuilder);
456 fToolsMenu->AddEntry("&Event Recorder", kToolsRecorder);
457
459 fHelpMenu->AddLabel("Basic Help On...");
461 fHelpMenu->AddEntry("&Canvas", kHelpOnCanvas);
462 fHelpMenu->AddEntry("&Menus", kHelpOnMenus);
463 fHelpMenu->AddEntry("&Graphics Editor", kHelpOnGraphicsEd);
464 fHelpMenu->AddEntry("&Browser", kHelpOnBrowser);
465 fHelpMenu->AddEntry("&Objects", kHelpOnObjects);
466 fHelpMenu->AddEntry("&PostScript", kHelpOnPS);
468 fHelpMenu->AddEntry("&About ROOT...", kHelpAbout);
469
470 // This main frame will process the menu commands
471 fFileMenu->Associate(this);
473 fEditMenu->Associate(this);
475 fViewMenu->Associate(this);
477 fOptionMenu->Associate(this);
478 fToolsMenu->Associate(this);
479 fHelpMenu->Associate(this);
480
481 // Create menubar layout hints
485
486 // Create menubar
487 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
494
496
500
501 // Create toolbar dock
502 fToolDock = new TGDockableFrame(this);
506
507 // will allocate it later
508 fToolBar = 0;
509 fVertical1 = 0;
510 fVertical2 = 0;
513
517
518 fMainFrame = new TGCompositeFrame(this, GetWidth() + 4, GetHeight() + 4,
521
522 // Create editor frame that will host the pad editor
526
527 // Create canvas and canvas container that will host the ROOT graphics
530
531 fCanvasID = -1;
532
533 if (fCanvas->UseGL()) {
535 //first, initialize GL (if not yet)
536 if (!gGLManager) {
537 TString x = "win32";
538 if (gVirtualX->InheritsFrom("TGX11"))
539 x = "x11";
540 else if (gVirtualX->InheritsFrom("TGCocoa"))
541 x = "osx";
542
543 TPluginHandler *ph = gROOT->GetPluginManager()->FindHandler("TGLManager", x);
544
545 if (ph && ph->LoadPlugin() != -1) {
546 if (!ph->ExecPlugin(0))
547 Error("CreateCanvas", "GL manager plugin failed");
548 }
549 }
550
551 if (gGLManager) {
553 if (fCanvasID != -1) {
554 //Create gl context.
555 const Int_t glCtx = gGLManager->CreateGLContext(fCanvasID);
556 if (glCtx != -1) {
558 fCanvas->SetGLDevice(glCtx);//Now, fCanvas is responsible for context deletion!
559 } else
560 Error("CreateCanvas", "GL context creation failed.");
561 } else
562 Error("CreateCanvas", "GL window creation failed\n");
563 }
564 }
565
566 if (fCanvasID == -1)
568
569 Window_t win = gVirtualX->GetWindowID(fCanvasID);
573
576
577 // create the tooltip with a timeout of 250 ms
579
580 fCanvas->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
581 "TRootCanvas", this,
582 "EventInfo(Int_t, Int_t, Int_t, TObject*)");
583
584 // Create status bar
585 int parts[] = { 33, 10, 10, 47 };
586 fStatusBar = new TGStatusBar(this, 10, 10);
588
590
592
593 // Misc
596 fIconPic = SetIconPixmap("macro_s.xpm");
597 SetClassHints("ROOT", "Canvas");
598
601
602 // by default status bar, tool bar and pad editor are hidden
607
610
611 // we need to use GetDefaultSize() to initialize the layout algorithm...
613
614 gVirtualX->SetDNDAware(fId, fDNDTypeList);
616}
617
618////////////////////////////////////////////////////////////////////////////////
619/// Delete ROOT basic canvas. Order is significant. Delete in reverse
620/// order of creation.
621
623{
624 delete fToolTip;
625 if (fIconPic) gClient->FreePicture(fIconPic);
626 if (fEditor && !fEmbedded) delete fEditor;
627 if (fToolBar) {
628 Disconnect(fToolDock, "Docked()", this, "AdjustSize()");
629 Disconnect(fToolDock, "Undocked()", this, "AdjustSize()");
630 fToolBar->Cleanup();
631 delete fToolBar;
632 }
633
634 if (!MustCleanup()) {
635 delete fStatusBar;
636 delete fStatusBarLayout;
637 delete fCanvasContainer;
638 delete fCanvasWindow;
639
640 delete fEditorFrame;
641 delete fEditorLayout;
642 delete fMainFrame;
643 delete fMainFrameLayout;
644 delete fToolBarSep;
645 delete fToolDock;
646 delete fToolBarLayout;
647 delete fHorizontal1;
648 delete fHorizontal1Layout;
649
650 delete fMenuBar;
651 delete fMenuBarLayout;
652 delete fMenuBarItemLayout;
653 delete fMenuBarHelpLayout;
654 delete fCanvasLayout;
655 delete fDockLayout;
656 }
657
658 delete fFileMenu;
659 delete fFileSaveMenu;
660 delete fEditMenu;
661 delete fEditClearMenu;
662 delete fViewMenu;
663 delete fViewWithMenu;
664 delete fOptionMenu;
665 delete fToolsMenu;
666 delete fHelpMenu;
667}
668
669////////////////////////////////////////////////////////////////////////////////
670/// Called via TCanvasImp interface by TCanvas.
671
673{
675 if(gged && gged->GetCanvas() == fCanvas) {
676 if (fEmbedded) {
677 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
678 ((TGedEditor *)gged)->SetCanvas(0);
679 }
680 else gged->Hide();
681 }
682
683 gVirtualX->CloseWindow();
684}
685
686////////////////////////////////////////////////////////////////////////////////
687/// Really delete the canvas and this GUI.
688
690{
692 if(gged && gged->GetCanvas() == fCanvas) {
693 if (fEmbedded) {
694 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
695 ((TGedEditor *)gged)->SetCanvas(0);
696 }
697 else gged->Hide();
698 }
699
700 fToolTip->Hide();
701 Disconnect(fCanvas, "ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
702 this, "EventInfo(Int_t, Int_t, Int_t, TObject*)");
703
705 fCanvas->Clear();
706 fCanvas->SetName("");
707 if (gPad && gPad->GetCanvas() == fCanvas)
708 gPad = nullptr;
709 delete this;
710}
711
712////////////////////////////////////////////////////////////////////////////////
713/// In case window is closed via WM we get here.
714
719
720////////////////////////////////////////////////////////////////////////////////
721/// Return width of canvas container.
722
727
728////////////////////////////////////////////////////////////////////////////////
729/// Return height of canvas container.
730
735
736////////////////////////////////////////////////////////////////////////////////
737/// Gets the size and position of the window containing the canvas. This
738/// size includes the menubar and borders.
739
741{
742 gVirtualX->GetWindowSize(fId, x, y, w, h);
743
745 gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(),
746 0, 0, x, y, childdum);
747 if (!fCanvas->GetShowEditor()) return 0;
748 return fEditorFrame->GetWidth();
749}
750
751////////////////////////////////////////////////////////////////////////////////
752/// Set text in status bar.
753
758
759////////////////////////////////////////////////////////////////////////////////
760/// Handle menu and other command generated by the user.
761
763{
765 TList *lc;
766
767 switch (GET_MSG(msg)) {
768
769 case kC_COMMAND:
770
771 switch (GET_SUBMSG(msg)) {
772
773 case kCM_BUTTON:
774 case kCM_MENU:
775
776 switch (parm1) {
777 // Handle toolbar items...
778 case kToolModify:
779 gROOT->SetEditorMode();
780 break;
781 case kToolArc:
782 gROOT->SetEditorMode("Arc");
783 break;
784 case kToolLine:
785 gROOT->SetEditorMode("Line");
786 break;
787 case kToolArrow:
788 gROOT->SetEditorMode("Arrow");
789 break;
790 case kToolDiamond:
791 gROOT->SetEditorMode("Diamond");
792 break;
793 case kToolEllipse:
794 gROOT->SetEditorMode("Ellipse");
795 break;
796 case kToolPad:
797 gROOT->SetEditorMode("Pad");
798 break;
799 case kToolPave:
800 gROOT->SetEditorMode("Pave");
801 break;
802 case kToolPLabel:
803 gROOT->SetEditorMode("PaveLabel");
804 break;
805 case kToolPText:
806 gROOT->SetEditorMode("PaveText");
807 break;
808 case kToolPsText:
809 gROOT->SetEditorMode("PavesText");
810 break;
811 case kToolGraph:
812 gROOT->SetEditorMode("PolyLine");
813 break;
814 case kToolCurlyLine:
815 gROOT->SetEditorMode("CurlyLine");
816 break;
817 case kToolCurlyArc:
818 gROOT->SetEditorMode("CurlyArc");
819 break;
820 case kToolLatex:
821 gROOT->SetEditorMode("Text");
822 break;
823 case kToolMarker:
824 gROOT->SetEditorMode("Marker");
825 break;
826 case kToolCutG:
827 gROOT->SetEditorMode("CutG");
828 break;
829
830 // Handle File menu items...
831 case kFileNewCanvas:
832 gROOT->MakeDefCanvas();
833 break;
834 case kFileOpen:
835 {
836 static TString dir(".");
838 fi.fFileTypes = gOpenTypes;
839 fi.SetIniDir(dir);
841 if (!fi.fFilename) return kTRUE;
842 dir = fi.fIniDir;
843 TFile::Open(fi.fFilename, "update");
844 TIter next(gROOT->GetListOfBrowsers());
845 TBrowser *b;
846 while ((b = (TBrowser *)next())) {
847 TRootBrowser *rb = dynamic_cast<TRootBrowser *>(b->GetBrowserImp());
848 if (rb) {
849 TGFileBrowser *fb = dynamic_cast<TGFileBrowser *>(rb->GetActBrowser());
850 if (fb)
851 fb->Selected(0);
852 }
853 }
854 gROOT->RefreshBrowsers();
855 }
856 break;
857 case kFileSaveAs:
858 {
860 static TString dir(".");
861 static Int_t typeidx = 0;
862 static Bool_t overwr = kFALSE;
864 TString defaultType = gEnv->GetValue("Canvas.SaveAsDefaultType", ".pdf");
865 if (typeidx == 0) {
866 for (int i=1;gSaveAsTypes[i];i+=2) {
867 TString ftype = gSaveAsTypes[i];
868 if (ftype.EndsWith(defaultType.Data())) {
869 typeidx = i-1;
870 break;
871 }
872 }
873 }
874 fi.fFileTypes = gSaveAsTypes;
875 fi.SetIniDir(dir);
876 fi.fFileTypeIdx = typeidx;
877 fi.fOverwrite = overwr;
880 if (!fi.fFilename) return kTRUE;
882 TString fn = fi.fFilename;
883 TString ft = fi.fFileTypes[fi.fFileTypeIdx+1];
884 dir = fi.fIniDir;
885 typeidx = fi.fFileTypeIdx;
886 overwr = fi.fOverwrite;
887again:
888 if (fn.EndsWith(".root") ||
889 fn.EndsWith(".ps") ||
890 fn.EndsWith(".eps") ||
891 fn.EndsWith(".pdf") ||
892 fn.EndsWith(".svg") ||
893 fn.EndsWith(".tex") ||
894 fn.EndsWith(".gif") ||
895 fn.EndsWith(".xml") ||
896 fn.EndsWith(".xpm") ||
897 fn.EndsWith(".jpg") ||
898 fn.EndsWith(".png") ||
899 fn.EndsWith(".xcf") ||
900 fn.EndsWith(".tiff")) {
901 fCanvas->SaveAs(fn);
902 } else if (fn.EndsWith(".C"))
904 else {
905 if (!appendedType) {
906 if (ft.Index(".") != kNPOS) {
907 fn += ft(ft.Index("."), ft.Length());
909 goto again;
910 }
911 }
912 Warning("ProcessMessage", "file %s cannot be saved with this extension", fi.fFilename);
913 }
914 for (int i=1;gSaveAsTypes[i];i+=2) {
915 TString ftype = gSaveAsTypes[i];
916 ftype.ReplaceAll("*.", ".");
917 if (fn.EndsWith(ftype.Data())) {
918 typeidx = i-1;
919 break;
920 }
921 }
922 }
923 break;
924 case kFileSaveAsRoot:
925 fCanvas->SaveAs(".root");
926 break;
927 case kFileSaveAsC:
929 break;
930 case kFileSaveAsPS:
931 fCanvas->SaveAs();
932 break;
933 case kFileSaveAsEPS:
934 fCanvas->SaveAs(".eps");
935 break;
936 case kFileSaveAsPDF:
937 fCanvas->SaveAs(".pdf");
938 break;
939 case kFileSaveAsGIF:
940 fCanvas->SaveAs(".gif");
941 break;
942 case kFileSaveAsJPG:
943 fCanvas->SaveAs(".jpg");
944 break;
945 case kFileSaveAsPNG:
946 fCanvas->SaveAs(".png");
947 break;
948 case kFileSaveAsTEX:
949 fCanvas->SaveAs(".tex");
950 break;
951 case kFilePrint:
952 PrintCanvas();
953 break;
954 case kFileCloseCanvas:
956 break;
957 case kFileQuit:
958 if (!gApplication->ReturnFromRun()) {
962 }
965 if (TClass::GetClass("TStyleManager", kFALSE, kTRUE))
966 gROOT->ProcessLine("TStyleManager::Terminate()");
968 break;
969
970 // Handle Edit menu items...
971 case kEditStyle:
972 if (!TClass::GetClass("TStyleManager"))
973 gSystem->Load("libGed");
974 gROOT->ProcessLine("TStyleManager::Show()");
975 break;
976 case kEditCut:
977 // still noop
978 break;
979 case kEditCopy:
980 // still noop
981 break;
982 case kEditPaste:
983 // still noop
984 break;
985 case kEditUndo:
986 // noop
987 break;
988 case kEditRedo:
989 // noop
990 break;
991 case kEditClearPad:
992 gPad->Clear();
993 gPad->Modified();
994 gPad->Update();
995 break;
996 case kEditClearCanvas:
997 fCanvas->Clear();
998 fCanvas->Modified();
999 fCanvas->Update();
1000 break;
1001
1002 // Handle View menu items...
1003 case kViewEditor:
1005 break;
1006 case kViewToolbar:
1008 break;
1009 case kViewEventStatus:
1011 break;
1012 case kViewToolTips:
1014 break;
1015 case kViewColors:
1016 {
1017 TVirtualPad *padsav = gPad->GetCanvas();
1018 //This was the code with the old color table
1019 // TCanvas *m = new TCanvas("colors","Color Table");
1020 // TPad::DrawColorTable();
1021 // m->Update();
1022 TColorWheel *wheel = new TColorWheel();
1023 wheel->Draw();
1024
1025 //tp: with Cocoa, window is visible (and repainted)
1026 //before wheel->Draw() was called and you can see "empty"
1027 //canvas.
1028 gPad->Update();
1029 //
1030 if (padsav) padsav->cd();
1031 }
1032 break;
1033 case kViewFonts:
1034 // noop
1035 break;
1036 case kViewMarkers:
1037 {
1038 TVirtualPad *padsav = gPad ? gPad->GetCanvas() : nullptr;
1039 TCanvas *m = new TCanvas("markers","Marker Types",600,200);
1041 m->Update();
1042 if (padsav) padsav->cd();
1043 }
1044 break;
1045 case kViewIconify:
1046 Iconify();
1047 break;
1048 case kViewX3D:
1049 gPad->GetViewer3D("x3d");
1050 break;
1051 case kViewOpenGL:
1052 gPad->GetViewer3D("ogl");
1053 break;
1054
1055 // Handle Option menu items...
1056 case kOptionAutoExec:
1058 if (fCanvas->GetAutoExec()) {
1060 } else {
1062 }
1063 break;
1064 case kOptionAutoResize:
1065 {
1067 int opt = fCanvasContainer->GetOptions();
1068 if (fAutoFit) {
1069 opt &= ~kFixedSize;
1071 } else {
1072 opt |= kFixedSize;
1074 }
1076 // in case of autofit this will generate a configure
1077 // event for the container and this will force the
1078 // update of the TCanvas
1079 //Layout();
1080 }
1081 Layout();
1082 break;
1084 FitCanvas();
1085 break;
1086 case kOptionMoveOpaque:
1087 if (fCanvas->OpaqueMoving()) {
1088 fCanvas->MoveOpaque(0);
1090 } else {
1091 fCanvas->MoveOpaque(1);
1093 }
1094 break;
1096 if (fCanvas->OpaqueResizing()) {
1099 } else {
1102 }
1103 break;
1104 case kOptionInterrupt:
1105 gROOT->SetInterrupt();
1106 break;
1107 case kOptionRefresh:
1108 fCanvas->Paint();
1109 fCanvas->Update();
1110 break;
1111 case kOptionStatistics:
1112 if (gStyle->GetOptStat()) {
1113 gStyle->SetOptStat(0);
1114 delete gPad->FindObject("stats");
1116 } else {
1117 gStyle->SetOptStat(1);
1119 }
1120 gPad->Modified();
1121 fCanvas->Update();
1122 break;
1123 case kOptionHistTitle:
1124 if (gStyle->GetOptTitle()) {
1125 gStyle->SetOptTitle(0);
1126 delete gPad->FindObject("title");
1128 } else {
1129 gStyle->SetOptTitle(1);
1131 }
1132 gPad->Modified();
1133 fCanvas->Update();
1134 break;
1135 case kOptionFitParams:
1136 if (gStyle->GetOptFit()) {
1137 gStyle->SetOptFit(0);
1139 } else {
1140 gStyle->SetOptFit(1);
1142 }
1143 gPad->Modified();
1144 fCanvas->Update();
1145 break;
1146 case kOptionCanEdit:
1147 if (gROOT->GetEditHistograms()) {
1148 gROOT->SetEditHistograms(kFALSE);
1150 } else {
1151 gROOT->SetEditHistograms(kTRUE);
1153 }
1154 break;
1155
1156 // Handle Tools menu items...
1157 case kInspectRoot:
1158 fCanvas->cd();
1159 gROOT->Inspect();
1160 fCanvas->Update();
1161 break;
1162 case kToolsBrowser:
1163 new TBrowser("browser");
1164 break;
1165 case kToolsBuilder:
1167 break;
1168 case kToolsRecorder:
1169 gROOT->ProcessLine("new TGRecorder()");
1170 break;
1171
1172 // Handle Tools menu items...
1173 case kClassesTree:
1174 {
1175 TString cdef;
1176 lc = (TList*)gROOT->GetListOfCanvases();
1177 if (lc->FindObject("ClassTree")) {
1178 cdef = TString::Format("ClassTree_%d", lc->GetSize()+1);
1179 } else {
1180 cdef = "ClassTree";
1181 }
1182 new TClassTree(cdef.Data(), "TObject");
1183 fCanvas->Update();
1184 }
1185 break;
1186
1187 case kFitPanel:
1188 {
1189 // use plugin manager to create instance of TFitEditor
1190 TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
1191 if (handler && handler->LoadPlugin() != -1) {
1192 if (handler->ExecPlugin(2, fCanvas, 0) == 0)
1193 Error("FitPanel", "Unable to crate the FitPanel");
1194 }
1195 else
1196 Error("FitPanel", "Unable to find the FitPanel plug-in");
1197 }
1198 break;
1199
1200 // Handle Help menu items...
1201 case kHelpAbout:
1202 {
1203#ifdef WIN32
1205#else
1206
1207 char str[32];
1208 snprintf(str, 32, "About ROOT %s...", gROOT->GetVersion());
1209 hd = new TRootHelpDialog(this, str, 600, 400);
1210 hd->SetText(gHelpAbout);
1211 hd->Popup();
1212#endif
1213 }
1214 break;
1215 case kHelpOnCanvas:
1216 hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1217 hd->SetText(gHelpCanvas);
1218 hd->Popup();
1219 break;
1220 case kHelpOnMenus:
1221 hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1222 hd->SetText(gHelpPullDownMenus);
1223 hd->Popup();
1224 break;
1225 case kHelpOnGraphicsEd:
1226 hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1227 hd->SetText(gHelpGraphicsEditor);
1228 hd->Popup();
1229 break;
1230 case kHelpOnBrowser:
1231 hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1232 hd->SetText(gHelpBrowser);
1233 hd->Popup();
1234 break;
1235 case kHelpOnObjects:
1236 hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
1237 hd->SetText(gHelpObjects);
1238 hd->Popup();
1239 break;
1240 case kHelpOnPS:
1241 hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
1242 hd->SetText(gHelpPostscript);
1243 hd->Popup();
1244 break;
1245 }
1246 default:
1247 break;
1248 }
1249 default:
1250 break;
1251 }
1252 return kTRUE;
1253}
1254
1255////////////////////////////////////////////////////////////////////////////////
1256/// Called by TCanvas ctor to get window indetifier.
1257
1267
1268////////////////////////////////////////////////////////////////////////////////
1269/// Set size of canvas container. Units in pixels.
1270/// If w==0 and h==0, set autofit mode
1271
1273{
1274 // turn off autofit, we want to stay at the given size
1275 int opt = fCanvasContainer->GetOptions();
1276 if (!w && !h) {
1277 fAutoFit = kTRUE;
1279 opt &= ~kFixedSize; // turn off fixed size mode
1280 } else {
1281 fAutoFit = kFALSE;
1283 opt |= kFixedSize; // turn on fixed size mode
1284 }
1288 Layout(); // force layout (will update container to given size)
1289 fCanvas->Resize();
1290 fCanvas->Update();
1291}
1292
1293////////////////////////////////////////////////////////////////////////////////
1294/// Set canvas position (units in pixels).
1295
1300
1301////////////////////////////////////////////////////////////////////////////////
1302/// Set size of canvas (units in pixels).
1303
1305{
1306 Resize(w, h);
1307
1308 // Make sure the change of size is really done.
1309 gVirtualX->Update(1);
1310 if (!gThreadXAR) {
1311 gSystem->Sleep(100);
1313 gSystem->Sleep(10);
1315 }
1316}
1317
1318////////////////////////////////////////////////////////////////////////////////
1319/// Put canvas window on top of the window stack.
1320
1322{
1323 gVirtualX->RaiseWindow(GetId());
1324}
1325
1326////////////////////////////////////////////////////////////////////////////////
1327/// Change title on window.
1328
1329void TRootCanvas::SetWindowTitle(const char *title)
1330{
1331 SetWindowName(title);
1332 SetIconName(title);
1333 fToolDock->SetWindowName(Form("ToolBar: %s", title));
1334}
1335
1336////////////////////////////////////////////////////////////////////////////////
1337/// Fit canvas container to current window size.
1338
1340{
1341 if (!fAutoFit) {
1342 int opt = fCanvasContainer->GetOptions();
1343 int oopt = opt;
1344 opt &= ~kFixedSize; // turn off fixed size mode
1346 Layout(); // force layout
1347 fCanvas->Resize();
1348 fCanvas->Update();
1350 }
1351}
1352
1353////////////////////////////////////////////////////////////////////////////////
1354/// Print the canvas.
1355
1357{
1358 Int_t ret = 0;
1359 Bool_t pname = kTRUE;
1360 char *printer, *printCmd;
1361 static TString sprinter, sprintCmd;
1362
1363 if (sprinter == "")
1364 printer = StrDup(gEnv->GetValue("Print.Printer", ""));
1365 else
1367 if (sprintCmd == "")
1368#ifndef WIN32
1369 printCmd = StrDup(gEnv->GetValue("Print.Command", ""));
1370#else
1371 printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p"));
1372#endif
1373 else
1375
1376 new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
1377 &printer, &printCmd, &ret);
1378 if (ret) {
1379 sprinter = printer;
1381
1382 if (sprinter == "")
1383 pname = kFALSE;
1384
1385 TString fn = "rootprint";
1386 FILE *f = gSystem->TempFileName(fn, gEnv->GetValue("Print.Directory", gSystem->TempDirectory()));
1387 if (f) fclose(f);
1388 fn += TString::Format(".%s",gEnv->GetValue("Print.FileType", "pdf"));
1389 fCanvas->Print(fn);
1390
1392 if (cmd.Contains("%p"))
1393 cmd.ReplaceAll("%p", sprinter);
1394 else if (pname) {
1395 cmd += " "; cmd += sprinter; cmd += " ";
1396 }
1397
1398 if (cmd.Contains("%f"))
1399 cmd.ReplaceAll("%f", fn);
1400 else {
1401 cmd += " "; cmd += fn; cmd += " ";
1402 }
1403
1404 gSystem->Exec(cmd);
1405#ifndef WIN32
1406 gSystem->Unlink(fn);
1407#endif
1408 }
1409 delete [] printer;
1410 delete [] printCmd;
1411}
1412
1413////////////////////////////////////////////////////////////////////////////////
1414/// Display a tooltip with infos about the primitive below the cursor.
1415
1417{
1418 fToolTip->Hide();
1419 if (!fCanvas->GetShowToolTips() || selected == 0 ||
1420 event != kMouseMotion || fButton != 0)
1421 return;
1423 TString objInfo = selected->GetObjectInfo(px, py);
1424 if (objInfo.BeginsWith("-")) {
1425 // if the string begins with '-', display only the object info
1426 objInfo.Remove(TString::kLeading, '-');
1427 tipInfo = objInfo;
1428 }
1429 else {
1430 const char *title = selected->GetTitle();
1431 tipInfo += TString::Format("%s::%s", selected->ClassName(),
1432 selected->GetName());
1433 if (title && strlen(title))
1434 tipInfo += TString::Format("\n%s", selected->GetTitle());
1435 tipInfo += TString::Format("\n%d, %d", px, py);
1436 if (!objInfo.IsNull())
1437 tipInfo += TString::Format("\n%s", objInfo.Data());
1438 }
1439 fToolTip->SetText(tipInfo.Data());
1440 fToolTip->SetPosition(px+15, py+15);
1441 fToolTip->Reset();
1442}
1443
1444////////////////////////////////////////////////////////////////////////////////
1445/// Show or hide menubar.
1446
1452
1453////////////////////////////////////////////////////////////////////////////////
1454/// Show or hide statusbar.
1455
1457{
1460
1461 UInt_t h = GetHeight();
1462 UInt_t sh = fStatusBar->GetHeight()+2;
1463
1464 if (show) {
1467 if (dh - ch >= sh) h = h + sh;
1468 else h = ch;
1469 } else {
1472 if (dh - ch < sh) h = ch;
1473 else h = h - sh;
1474 }
1475 Resize(GetWidth(), h);
1476}
1477
1478////////////////////////////////////////////////////////////////////////////////
1479/// Show or hide side frame.
1480
1482{
1484
1485 UInt_t w = GetWidth();
1487 UInt_t h = GetHeight();
1489
1490 auto lambda_show = [&, this]() {
1491 if (show) {
1492 if (!fEditor)
1493 CreateEditor();
1495 if (gged && gged->GetCanvas() == fCanvas) {
1496 gged->Hide();
1497 }
1500 h += s;
1501 }
1503 fEditor->Show();
1505 w += e;
1506 } else {
1509 h -= s;
1510 }
1511 if (fEditor)
1512 fEditor->Hide();
1515 w -= e;
1516 }
1517 };
1518
1519 if (fParent && fParent != fClient->GetDefaultRoot()) {
1520 TGMainFrame *main = (TGMainFrame *)fParent->GetMainFrame();
1522 if (main && main->InheritsFrom("TRootBrowser")) {
1524 if (!fEmbedded)
1525 browser->GetTabRight()->Connect("Selected(Int_t)", "TRootCanvas",
1526 this, "Activated(Int_t)");
1527 fEmbedded = kTRUE;
1528 if (show && (!fEditor || !((TGedEditor *)fEditor)->IsMapped())) {
1529 if (!browser->GetTabLeft()->GetTabTab("Pad Editor")) {
1530 if (browser->GetActFrame()) { //already in edit mode
1531 TTimer::SingleShot(200, "TRootCanvas", this, "ShowEditor(=kTRUE)");
1532 } else {
1533 browser->StartEmbedding(TRootBrowser::kLeft);
1534 if (!fEditor)
1536 else {
1537 ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot());
1538 ((TGedEditor *)fEditor)->MapWindow();
1539 }
1540 browser->StopEmbedding("Pad Editor");
1541 if (fEditor) {
1543 gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor);
1544 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
1545 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
1546 }
1547 }
1548 }
1549 else
1551 }
1552 if (show) browser->GetTabLeft()->SetTab("Pad Editor");
1553 } else {
1554 lambda_show();
1555 main->Layout();
1556 }
1557 }
1558 else {
1559 lambda_show();
1560 Resize(w, h);
1561 }
1562}
1563
1564////////////////////////////////////////////////////////////////////////////////
1565/// Create embedded editor.
1566
1568{
1571 gPad = Canvas();
1572 // next two lines are related to the old editor
1573 Int_t show = gEnv->GetValue("Canvas.ShowEditor", 0);
1574 gEnv->SetValue("Canvas.ShowEditor","true");
1579
1580 // next line is related to the old editor
1581 if (show == 0) gEnv->SetValue("Canvas.ShowEditor","false");
1582}
1583
1584////////////////////////////////////////////////////////////////////////////////
1585/// Show or hide toolbar.
1586
1588{
1589 if (show && !fToolBar) {
1590
1593
1594 Int_t spacing = 6, i;
1595 for (i = 0; gToolBarData[i].fPixmap; i++) {
1596 if (strlen(gToolBarData[i].fPixmap) == 0) {
1597 spacing = 6;
1598 continue;
1599 }
1601 spacing = 0;
1602 }
1609
1610 spacing = 6;
1611 for (i = 0; gToolBarData1[i].fPixmap; i++) {
1612 if (strlen(gToolBarData1[i].fPixmap) == 0) {
1613 spacing = 6;
1614 continue;
1615 }
1617 spacing = 0;
1618 }
1620 fToolDock->Layout();
1621 fToolDock->SetWindowName(Form("ToolBar: %s", GetWindowName()));
1622 fToolDock->Connect("Docked()", "TRootCanvas", this, "AdjustSize()");
1623 fToolDock->Connect("Undocked()", "TRootCanvas", this, "AdjustSize()");
1624 }
1625
1626 if (!fToolBar) return;
1627
1628 UInt_t h = GetHeight();
1631
1632 if (show) {
1636 h = h + sh;
1637 }
1640 h = h + dh + sh;
1641 } else {
1642 if (fToolDock->IsUndocked()) {
1644 h = h + 2*sh;
1645 } else h = h - dh;
1646
1650 h = h - sh;
1651 }
1653 h = h - sh;
1655 }
1656 Resize(GetWidth(), h);
1657}
1658
1659////////////////////////////////////////////////////////////////////////////////
1660/// Enable or disable tooltip info.
1661
1669
1670////////////////////////////////////////////////////////////////////////////////
1671/// Returns kTRUE if the editor is shown.
1672
1677
1678////////////////////////////////////////////////////////////////////////////////
1679/// Returns kTRUE if the menu bar is shown.
1680
1682{
1683 return (fMenuBar) && fMenuBar->IsMapped();
1684}
1685
1686////////////////////////////////////////////////////////////////////////////////
1687/// Returns kTRUE if the status bar is shown.
1688
1690{
1691 return (fStatusBar) && fStatusBar->IsMapped();
1692}
1693
1694////////////////////////////////////////////////////////////////////////////////
1695/// Returns kTRUE if the tool bar is shown.
1696
1698{
1699 return (fToolBar) && fToolBar->IsMapped();
1700}
1701
1702////////////////////////////////////////////////////////////////////////////////
1703/// Returns kTRUE if the tooltips are enabled.
1704
1706{
1707 return (fCanvas) && fCanvas->GetShowToolTips();
1708}
1709
1710////////////////////////////////////////////////////////////////////////////////
1711/// Keep the same canvas size while docking/undocking toolbar.
1712
1714{
1715 UInt_t h = GetHeight();
1718
1719 if (fToolDock->IsUndocked()) {
1722 h = h - sh;
1723 }
1725 h = h - dh - sh;
1726 } else {
1729 h = h + sh;
1730 }
1732 h = h + dh + sh;
1733 }
1734 Resize(GetWidth(), h);
1735}
1736
1737////////////////////////////////////////////////////////////////////////////////
1738/// Handle mouse button events in the canvas container.
1739
1741{
1742 Int_t button = event->fCode;
1743 Int_t x = event->fX;
1744 Int_t y = event->fY;
1745
1746 if (event->fType == kButtonPress) {
1747 if (fToolTip && fCanvas->GetShowToolTips()) {
1748 fToolTip->Hide();
1749 gVirtualX->UpdateWindow(0);
1751 }
1752 fButton = button;
1753 if (button == kButton1) {
1754 if (event->fState & kKeyShiftMask)
1756 else
1758 }
1759 if (button == kButton2)
1761 if (button == kButton3) {
1763 fButton = 0; // button up is consumed by TContextMenu
1764 }
1765
1766 } else if (event->fType == kButtonRelease) {
1767 if (button == kButton4)
1769 if (button == kButton5)
1771 if (button == kButton1)
1773 if (button == kButton2)
1775 if (button == kButton3)
1777
1778 fButton = 0;
1779 }
1780
1781 return kTRUE;
1782}
1783
1784////////////////////////////////////////////////////////////////////////////////
1785/// Handle mouse button double click events in the canvas container.
1786
1788{
1789 Int_t button = event->fCode;
1790 Int_t x = event->fX;
1791 Int_t y = event->fY;
1792
1793 if (button == kButton1)
1795 if (button == kButton2)
1797 if (button == kButton3)
1799
1800 return kTRUE;
1801}
1802
1803////////////////////////////////////////////////////////////////////////////////
1804/// Handle configure (i.e. resize) event.
1805
1807{
1808 if (fAutoFit) {
1809 fCanvas->Resize();
1810 fCanvas->Update();
1811 }
1812
1814 // get menu height
1815 static Int_t dh = 0;
1816 if (!dh)
1821 }
1822 return kTRUE;
1823}
1824
1825////////////////////////////////////////////////////////////////////////////////
1826/// Handle keyboard events in the canvas container.
1827
1829{
1831 static UInt_t previous_keysym = 0;
1832
1833 if (event->fType == kGKeyPress) {
1834 fButton = event->fCode;
1835 UInt_t keysym;
1836 char str[2];
1837 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1838
1839 if (str[0] == kESC){ // ESC sets the escape flag
1840 gROOT->SetEscape();
1843 gPad->Modified();
1844 return kTRUE;
1845 }
1846 if (str[0] == 3) // ctrl-c sets the interrupt flag
1847 gROOT->SetInterrupt();
1848
1849 // handle arrow keys
1850 if (keysym > 0x1011 && keysym < 0x1016) {
1852 UInt_t mask = 0;
1853 Int_t mx, my, tx, ty;
1854 wid = gVirtualX->GetDefaultRootWindow();
1855 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1856 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1858 mx, my, tx, ty, dum1);
1860 // handle case where we got consecutive same keypressed events coming
1861 // from auto-repeat on Windows (as it fires only successive keydown events)
1863 switch (keysym) {
1864 case 0x1012: // left
1865 gVirtualX->Warp(--mx, my, wid); --tx;
1866 break;
1867 case 0x1013: // up
1868 gVirtualX->Warp(mx, --my, wid); --ty;
1869 break;
1870 case 0x1014: // right
1871 gVirtualX->Warp(++mx, my, wid); ++tx;
1872 break;
1873 case 0x1015: // down
1874 gVirtualX->Warp(mx, ++my, wid); ++ty;
1875 break;
1876 default:
1877 break;
1878 }
1880 }
1882 }
1883 else {
1885 }
1886 } else if (event->fType == kKeyRelease) {
1887 UInt_t keysym;
1888 char str[2];
1889 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1890
1891 if (keysym > 0x1011 && keysym < 0x1016) {
1893 UInt_t mask = 0;
1894 Int_t mx, my, tx, ty;
1895 wid = gVirtualX->GetDefaultRootWindow();
1896 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1897 switch (keysym) {
1898 case 0x1012: // left
1899 gVirtualX->Warp(--mx, my, wid);
1900 break;
1901 case 0x1013: // up
1902 gVirtualX->Warp(mx, --my, wid);
1903 break;
1904 case 0x1014: // right
1905 gVirtualX->Warp(++mx, my, wid);
1906 break;
1907 case 0x1015: // down
1908 gVirtualX->Warp(mx, ++my, wid);
1909 break;
1910 default:
1911 break;
1912 }
1913 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1915 mx, my, tx, ty, dum1);
1918 }
1919 fButton = 0;
1920 }
1921 previous_event = event->fType;
1922 return kTRUE;
1923}
1924
1925////////////////////////////////////////////////////////////////////////////////
1926/// Handle mouse motion event in the canvas container.
1927
1929{
1930 Int_t x = event->fX;
1931 Int_t y = event->fY;
1932
1933 if (fButton == 0)
1935 if (fButton == kButton1) {
1936 if (event->fState & kKeyShiftMask)
1938 else
1940 }
1941 if (fButton == kButton2)
1943
1944 return kTRUE;
1945}
1946
1947////////////////////////////////////////////////////////////////////////////////
1948/// Handle expose events.
1949
1951{
1952 if (event->fCount == 0) {
1953 fCanvas->Flush();
1954 }
1955
1956 return kTRUE;
1957}
1958
1959////////////////////////////////////////////////////////////////////////////////
1960/// Handle enter/leave events. Only leave is activated at the moment.
1961
1963{
1964 Int_t x = event->fX;
1965 Int_t y = event->fY;
1966
1967 // pointer grabs create also an enter and leave event but with fCode
1968 // either kNotifyGrab or kNotifyUngrab, don't propagate these events
1969 if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
1971
1972 return kTRUE;
1973}
1974
1975////////////////////////////////////////////////////////////////////////////////
1976/// Handle drop events.
1977
1979{
1980 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
1981 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
1982
1983 if (data->fDataType == rootObj) {
1984 TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
1985 buf.SetReadMode();
1987 if (!obj) return kTRUE;
1988 gPad->Clear();
1989 if (obj->InheritsFrom("TKey")) {
1990 TObject *object = (TObject *)gROOT->ProcessLine(Form("((TKey *)0x%zx)->ReadObj();", (size_t)obj));
1991 if (!object) return kTRUE;
1992 if (object->InheritsFrom("TGraph"))
1993 object->Draw("ALP");
1994 else if (object->InheritsFrom("TImage"))
1995 object->Draw("x");
1996 else if (object->IsA()->GetMethodAllAny("Draw"))
1997 object->Draw();
1998 }
1999 else if (obj->InheritsFrom("TGraph"))
2000 obj->Draw("ALP");
2001 else if (obj->IsA()->GetMethodAllAny("Draw"))
2002 obj->Draw();
2003 gPad->Modified();
2004 gPad->Update();
2005 return kTRUE;
2006 }
2007 else if (data->fDataType == uriObj) {
2008 TString sfname((char *)data->fData);
2009 if (sfname.Length() > 7) {
2010 sfname.ReplaceAll("\r\n", "");
2011 TUrl uri(sfname.Data());
2012 if (sfname.EndsWith(".bmp") ||
2013 sfname.EndsWith(".gif") ||
2014 sfname.EndsWith(".jpg") ||
2015 sfname.EndsWith(".png") ||
2016 sfname.EndsWith(".ps") ||
2017 sfname.EndsWith(".eps") ||
2018 sfname.EndsWith(".pdf") ||
2019 sfname.EndsWith(".tiff") ||
2020 sfname.EndsWith(".xpm")) {
2021 TImage *img = TImage::Open(uri.GetFile());
2022 if (img) {
2023 img->Draw("x");
2024 img->SetEditable(kTRUE);
2025 }
2026 }
2027 gPad->Modified();
2028 gPad->Update();
2029 }
2030 }
2031 return kFALSE;
2032}
2033
2034////////////////////////////////////////////////////////////////////////////////
2035/// Handle dragging position events.
2036
2038 Int_t /*xroot*/, Int_t /*yroot*/)
2039{
2040 TPad *pad = fCanvas->Pick(x, y, 0);
2041 if (pad) {
2042 pad->cd();
2043 gROOT->SetSelectedPad(pad);
2044 // make sure the pad is highlighted (on Windows)
2045 pad->Update();
2046 }
2047 return action;
2048}
2049
2050////////////////////////////////////////////////////////////////////////////////
2051/// Handle drag enter events.
2052
2054{
2055 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2056 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2057 Atom_t ret = kNone;
2058 for (int i = 0; typelist[i] != kNone; ++i) {
2059 if (typelist[i] == rootObj)
2060 ret = rootObj;
2061 if (typelist[i] == uriObj)
2062 ret = uriObj;
2063 }
2064 return ret;
2065}
2066
2067////////////////////////////////////////////////////////////////////////////////
2068/// Handle drag leave events.
2069
2071{
2072 return kTRUE;
2073}
2074
2075////////////////////////////////////////////////////////////////////////////////
2076/// Slot handling tab switching in the browser, to properly set the canvas
2077/// and the model to the editor.
2078
2080{
2081 if (fEmbedded) {
2083 if (sender) {
2084 TGCompositeFrame *cont = sender->GetTabContainer(id);
2085 if (cont == fParent) {
2086 if (!fEditor)
2088 if (fEditor && ((TGedEditor *)fEditor)->IsMapped()) {
2089 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
2090 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
2091 }
2092 }
2093 }
2094 }
2095}
2096
2097////////////////////////////////////////////////////////////////////////////////
2098/// Save a canvas container as a C++ statement(s) on output stream out.
2099
2100void TRootContainer::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
2101{
2102 out << std::endl << " // canvas container" << std::endl;
2103 out << " Int_t canvasID = gVirtualX->InitWindow((ULongptr_t)"
2104 << GetParent()->GetParent()->GetName() << "->GetId());" << std::endl;
2105 out << " Window_t winC = gVirtualX->GetWindowID(canvasID);" << std::endl;
2106 out << " TGCompositeFrame *";
2107 out << GetName() << " = new TGCompositeFrame(gClient,winC"
2108 << "," << GetParent()->GetName() << ");" << std::endl;
2109}
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
Definition RtypesCore.h:75
unsigned long ULongptr_t
Definition RtypesCore.h:76
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
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:185
Int_t gErrorIgnoreLevel
Error handling routines.
Definition TError.cxx:31
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
#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:406
@ 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:2489
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2557
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:1540
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:302
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:2422
virtual void ToggleToolTips()
Toggle tooltip display.
Definition TCanvas.cxx:2464
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition TCanvas.cxx:737
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition TCanvas.cxx:2431
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:1668
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition TCanvas.cxx:1822
void SetCanvasImp(TCanvasImp *i)
Definition TCanvas.h:205
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition TCanvas.cxx:1234
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition TCanvas.cxx:719
Bool_t GetShowEditor() const
Definition TCanvas.h:150
Bool_t GetAutoExec() const
Definition TCanvas.h:152
virtual void ToggleEditor()
Toggle editor.
Definition TCanvas.cxx:2453
Bool_t GetShowToolTips() const
Definition TCanvas.h:151
void SetName(const char *name="") override
Set canvas name.
Definition TCanvas.cxx:2047
void Paint(Option_t *option="") override
Paint canvas.
Definition TCanvas.cxx:1543
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2489
Bool_t OpaqueMoving() const override
Definition TCanvas.h:180
void Flush()
Flush canvas buffers.
Definition TCanvas.cxx:1145
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition TCanvas.cxx:1535
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:1759
virtual void ToggleToolBar()
Toggle toolbar.
Definition TCanvas.cxx:2442
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:3069
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:491
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:736
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:4130
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:234
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:224
UInt_t GetDisplayHeight() const
Get display height.
Definition TGClient.cxx:275
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:316
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
Int_t MustCleanup() const override
Definition TGFrame.h:360
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
TGCompositeFrame(const TGCompositeFrame &)=delete
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1257
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1204
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1072
void SetEditable(Bool_t on=kTRUE) override
Switch ON/OFF edit mode.
Definition TGFrame.cxx:948
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1022
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1043
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1190
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:339
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:629
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition TGFrame.cxx:443
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:593
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:276
virtual UInt_t GetOptions() const
Definition TGFrame.h:197
UInt_t GetHeight() const
Definition TGFrame.h:225
virtual void SetWidth(UInt_t w)
Definition TGFrame.h:246
void SetDNDTarget(Bool_t onoff)
Definition TGFrame.h:270
UInt_t GetWidth() const
Definition TGFrame.h:224
virtual void SetHeight(UInt_t h)
Definition TGFrame.h:247
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:397
Atom_t * fDNDTypeList
handles DND types
Definition TGFrame.h:413
virtual void SendCloseMessage()
Send close message to self.
Definition TGFrame.cxx:1744
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition TGFrame.cxx:1858
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1801
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1788
const char * GetWindowName() const
Definition TGFrame.h:476
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:418
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:1095
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition TGMenu.cxx:1845
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:1152
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition TGMenu.cxx:1782
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1724
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition TGMenu.cxx:1807
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:1060
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:990
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:92
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:152
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:295
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
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:118
static TImage * Create()
Create an image.
Definition TImage.cxx:35
A doubly linked list.
Definition TList.h:38
static void DisplayMarkerTypes()
Display the table of markers with their numbers.
Definition TMarker.cxx:103
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:563
static TClass * Class()
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:542
virtual TClass * IsA() const
Definition TObject.h:245
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:292
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:7388
Bool_t HasFixedAspectRatio() const override
Definition TPad.h:270
virtual void SetGLDevice(Int_t dev)
Definition TPad.h:366
void SaveAs(const char *filename="", Option_t *option="") const override
Save the pad content in a file.
Definition TPad.cxx:5784
void Print(const char *filename="") const override
This method is equivalent to SaveAs("filename"). See TPad::SaveAs for details.
Definition TPad.cxx:4798
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:869
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:139
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2244
const char * Data() const
Definition TString.h:376
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
@ kLeading
Definition TString.h:276
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:2378
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:1642
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:1595
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:1499
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:653
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1857
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:862
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:437
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:871
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:416
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1381
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition TSystem.cxx:1482
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:258
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:697
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