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// //
14// TRootCanvas //
15// //
16// This class creates a main window with menubar, scrollbars and a //
17// drawing area. The widgets used are the new native ROOT GUI widgets. //
18// //
19//////////////////////////////////////////////////////////////////////////
20
21#include "RConfigure.h"
22
23#include "TRootCanvas.h"
24#include "TRootApplication.h"
25#include "TRootHelpDialog.h"
26#include "TGClient.h"
27#include "TGCanvas.h"
28#include "TGMenu.h"
29#include "TGWidget.h"
30#include "TGFileDialog.h"
31#include "TGStatusBar.h"
32#include "TGTextEditDialogs.h"
33#include "TROOT.h"
34#include "TClass.h"
35#include "TSystem.h"
36#include "TCanvas.h"
37#include "TBrowser.h"
38#include "TClassTree.h"
39#include "TMarker.h"
40#include "TStyle.h"
41#include "TColorWheel.h"
42#include "TVirtualX.h"
43#include "TApplication.h"
44#include "TFile.h"
45#include "TInterpreter.h"
46#include "TEnv.h"
47#include "TMath.h"
48#include <iostream>
49#include "TGDockableFrame.h"
50
51#include "TG3DLine.h"
52#include "TGToolBar.h"
53#include "TGToolTip.h"
54#include "TVirtualPadEditor.h"
55#include "TRootControlBar.h"
56#include "TGuiBuilder.h"
57#include "TImage.h"
58#include "TError.h"
59#include "TGDNDManager.h"
60#include "TBufferFile.h"
61#include "TRootBrowser.h"
62#include "TGTab.h"
63#include "TGedEditor.h"
64
65#include "TPluginManager.h"
66#include "TVirtualGL.h"
67
68#ifdef WIN32
69#include "TWin32SplashThread.h"
70#endif
71
72#include "HelpText.h"
73
74
75// Canvas menu command ids
92
101
112
124
131
139
157
159
160static const char *gOpenTypes[] = { "ROOT files", "*.root",
161 "All files", "*",
162 0, 0 };
163
164static const char *gSaveAsTypes[] = { "PDF", "*.pdf",
165 "PostScript", "*.ps",
166 "Encapsulated PostScript", "*.eps",
167 "SVG", "*.svg",
168 "TeX", "*.tex",
169 "GIF", "*.gif",
170 "ROOT macros", "*.C",
171 "ROOT files", "*.root",
172 "XML", "*.xml",
173 "PNG", "*.png",
174 "XPM", "*.xpm",
175 "JPEG", "*.jpg",
176 "TIFF", "*.tiff",
177 "XCF", "*.xcf",
178 "All files", "*",
179 0, 0 };
180
182 // { filename, tooltip, staydown, id, button}
183 { "newcanvas.xpm", "New", kFALSE, kFileNewCanvas, 0 },
184 { "open.xpm", "Open", kFALSE, kFileOpen, 0 },
185 { "save.xpm", "Save As", kFALSE, kFileSaveAs, 0 },
186 { "printer.xpm", "Print", kFALSE, kFilePrint, 0 },
187 { "", "", kFALSE, -1, 0 },
188 { "interrupt.xpm", "Interrupt", kFALSE, kOptionInterrupt,0 },
189 { "refresh2.xpm", "Refresh", kFALSE, kOptionRefresh, 0 },
190 { "", "", kFALSE, -1, 0 },
191 { "inspect.xpm", "Inspect", kFALSE, kInspectRoot, 0 },
192 { "browser.xpm", "Browser", kFALSE, kToolsBrowser, 0 },
193 { 0, 0, kFALSE, 0, 0 }
194};
195
197 { "pointer.xpm", "Modify", kFALSE, kToolModify, 0 },
198 { "arc.xpm", "Arc", kFALSE, kToolArc, 0 },
199 { "line.xpm", "Line", kFALSE, kToolLine, 0 },
200 { "arrow.xpm", "Arrow", kFALSE, kToolArrow, 0 },
201 { "diamond.xpm", "Diamond", kFALSE, kToolDiamond, 0 },
202 { "ellipse.xpm", "Ellipse", kFALSE, kToolEllipse, 0 },
203 { "pad.xpm", "Pad", kFALSE, kToolPad, 0 },
204 { "pave.xpm", "Pave", kFALSE, kToolPave, 0 },
205 { "pavelabel.xpm", "Pave Label", kFALSE, kToolPLabel, 0 },
206 { "pavetext.xpm", "Pave Text", kFALSE, kToolPText, 0 },
207 { "pavestext.xpm", "Paves Text", kFALSE, kToolPsText, 0 },
208 { "graph.xpm", "Graph", kFALSE, kToolGraph, 0 },
209 { "curlyline.xpm", "Curly Line", kFALSE, kToolCurlyLine, 0 },
210 { "curlyarc.xpm", "Curly Arc", kFALSE, kToolCurlyArc, 0 },
211 { "latex.xpm", "Text/Latex", kFALSE, kToolLatex, 0 },
212 { "marker.xpm", "Marker", kFALSE, kToolMarker, 0 },
213 { "cut.xpm", "Graphical Cut", kFALSE, kToolCutG, 0 },
214 { 0, 0, kFALSE, 0, 0 }
215};
216
217//////////////////////////////////////////////////////////////////////////
218// //
219// TRootContainer //
220// //
221// Utility class used by TRootCanvas. The TRootContainer is the frame //
222// embedded in the TGCanvas widget. The ROOT graphics goes into this //
223// frame. This class is used to enable input events on this graphics //
224// frame and forward the events to the TRootCanvas handlers. //
225// //
226//////////////////////////////////////////////////////////////////////////
227
228class TRootContainer : public TGCompositeFrame {
229private:
230 TRootCanvas *fCanvas; // pointer back to canvas imp
231public:
232 TRootContainer(TRootCanvas *c, Window_t id, const TGWindow *parent);
233
236 { return fCanvas->HandleContainerDoubleClick(ev); }
239 return fCanvas->HandleContainerConfigure(ev); }
241 { return fCanvas->HandleContainerKey(ev); }
243 { return fCanvas->HandleContainerMotion(ev); }
245 { return fCanvas->HandleContainerExpose(ev); }
247 { return fCanvas->HandleContainerCrossing(ev); }
248 void SavePrimitive(std::ostream &out, Option_t * = "");
249 void SetEditable(Bool_t) { }
250};
251
252////////////////////////////////////////////////////////////////////////////////
253/// Create a canvas container.
254
255TRootContainer::TRootContainer(TRootCanvas *c, Window_t id, const TGWindow *p)
257{
258 fCanvas = c;
259
260 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
263
266 fEditDisabled = kEditDisable;
267}
268
269////////////////////////////////////////////////////////////////////////////////
270/// Directly handle scroll mouse buttons (4 and 5), only pass buttons
271/// 1, 2 and 3 on to the TCanvas.
272
273Bool_t TRootContainer::HandleButton(Event_t *event)
274{
275 TGViewPort *vp = (TGViewPort*)fParent;
276 UInt_t page = vp->GetHeight()/4;
277 Int_t newpos;
278
279 gVirtualX->SetInputFocus(GetMainFrame()->GetId());
280
281 if (event->fCode == kButton4) {
282 //scroll up
283 newpos = fCanvas->fCanvasWindow->GetVsbPosition() - page;
284 if (newpos < 0) newpos = 0;
285 fCanvas->fCanvasWindow->SetVsbPosition(newpos);
286// return kTRUE;
287 }
288 if (event->fCode == kButton5) {
289 // scroll down
290 newpos = fCanvas->fCanvasWindow->GetVsbPosition() + page;
291 fCanvas->fCanvasWindow->SetVsbPosition(newpos);
292// return kTRUE;
293 }
294 return fCanvas->HandleContainerButton(event);
295}
296
298
299////////////////////////////////////////////////////////////////////////////////
300/// Create a basic ROOT canvas.
301
303 : TGMainFrame(gClient->GetRoot(), width, height), TCanvasImp(c)
304{
306
309
310 Resize(width, height);
311}
312
313////////////////////////////////////////////////////////////////////////////////
314/// Create a basic ROOT canvas.
315
317 : TGMainFrame(gClient->GetRoot(), width, height), TCanvasImp(c)
318{
320
323
324 MoveResize(x, y, width, height);
325 SetWMPosition(x, y);
326}
327
328////////////////////////////////////////////////////////////////////////////////
329/// Create the actual canvas.
330
332{
333 fButton = 0;
334 fAutoFit = kTRUE; // check also menu entry
335 fEditor = 0;
337
338 // Create menus
345
346 static Int_t img = 0;
347
348 if (!img) {
351 TImage* itmp = TImage::Create();
352 img = itmp ? 1 : -1;
353 if (itmp) {
354 delete itmp;
355 itmp=NULL;
356 }
357 gErrorIgnoreLevel = sav;
358 }
359 if (img > 0) {
362 }
363
366
368 fFileMenu->AddEntry("&New Canvas", kFileNewCanvas);
369 fFileMenu->AddEntry("&Open...", kFileOpen);
370 fFileMenu->AddEntry("&Close Canvas", kFileCloseCanvas);
373 fFileMenu->AddEntry("Save &As...", kFileSaveAs);
375 fFileMenu->AddEntry("&Print...", kFilePrint);
377 fFileMenu->AddEntry("&Quit ROOT", kFileQuit);
378
382
384 fEditMenu->AddEntry("&Style...", kEditStyle);
386 fEditMenu->AddEntry("Cu&t", kEditCut);
387 fEditMenu->AddEntry("&Copy", kEditCopy);
388 fEditMenu->AddEntry("&Paste", kEditPaste);
392 fEditMenu->AddEntry("&Undo", kEditUndo);
393 fEditMenu->AddEntry("&Redo", kEditRedo);
394
400
404
406 fViewMenu->AddEntry("&Editor", kViewEditor);
407 fViewMenu->AddEntry("&Toolbar", kViewToolbar);
408 fViewMenu->AddEntry("Event &Statusbar", kViewEventStatus);
409 fViewMenu->AddEntry("T&oolTip Info", kViewToolTips);
411 fViewMenu->AddEntry("&Colors", kViewColors);
412 fViewMenu->AddEntry("&Fonts", kViewFonts);
413 fViewMenu->AddEntry("&Markers", kViewMarkers);
415 fViewMenu->AddEntry("&Iconify", kViewIconify);
417 fViewMenu->AddPopup("&View With", fViewWithMenu);
418
420
422 fOptionMenu->AddEntry("&Auto Resize Canvas", kOptionAutoResize);
423 fOptionMenu->AddEntry("&Resize Canvas", kOptionResizeCanvas);
424 fOptionMenu->AddEntry("&Move Opaque", kOptionMoveOpaque);
425 fOptionMenu->AddEntry("Resize &Opaque", kOptionResizeOpaque);
427 fOptionMenu->AddEntry("&Interrupt", kOptionInterrupt);
428 fOptionMenu->AddEntry("R&efresh", kOptionRefresh);
430 fOptionMenu->AddEntry("&Pad Auto Exec", kOptionAutoExec);
432 fOptionMenu->AddEntry("&Statistics", kOptionStatistics);
433 fOptionMenu->AddEntry("Histogram &Title", kOptionHistTitle);
434 fOptionMenu->AddEntry("&Fit Parameters", kOptionFitParams);
435 fOptionMenu->AddEntry("Can Edit &Histograms", kOptionCanEdit);
436
437 // Opaque options initialized in InitWindow()
439 if (gStyle->GetOptStat())
441 if (gStyle->GetOptTitle())
443 if (gStyle->GetOptFit())
445 if (gROOT->GetEditHistograms())
447
449 fToolsMenu->AddEntry("&Inspect ROOT", kInspectRoot);
450 fToolsMenu->AddEntry("&Class Tree", kClassesTree);
451 fToolsMenu->AddEntry("&Fit Panel", kFitPanel);
452 fToolsMenu->AddEntry("&Start Browser", kToolsBrowser);
453 fToolsMenu->AddEntry("&Gui Builder", kToolsBuilder);
454 fToolsMenu->AddEntry("&Event Recorder", kToolsRecorder);
455
457 fHelpMenu->AddLabel("Basic Help On...");
459 fHelpMenu->AddEntry("&Canvas", kHelpOnCanvas);
460 fHelpMenu->AddEntry("&Menus", kHelpOnMenus);
461 fHelpMenu->AddEntry("&Graphics Editor", kHelpOnGraphicsEd);
462 fHelpMenu->AddEntry("&Browser", kHelpOnBrowser);
463 fHelpMenu->AddEntry("&Objects", kHelpOnObjects);
464 fHelpMenu->AddEntry("&PostScript", kHelpOnPS);
466 fHelpMenu->AddEntry("&About ROOT...", kHelpAbout);
467
468 // This main frame will process the menu commands
469 fFileMenu->Associate(this);
471 fEditMenu->Associate(this);
473 fViewMenu->Associate(this);
475 fOptionMenu->Associate(this);
476 fToolsMenu->Associate(this);
477 fHelpMenu->Associate(this);
478
479 // Create menubar layout hints
483
484 // Create menubar
485 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
492
494
498
499 // Create toolbar dock
500 fToolDock = new TGDockableFrame(this);
504
505 // will alocate it later
506 fToolBar = 0;
507 fVertical1 = 0;
508 fVertical2 = 0;
511
515
516 fMainFrame = new TGCompositeFrame(this, GetWidth() + 4, GetHeight() + 4,
519
520 // Create editor frame that will host the pad editor
524
525 // Create canvas and canvas container that will host the ROOT graphics
528
529 fCanvasID = -1;
530
531 if (fCanvas->UseGL()) {
533 //first, initialize GL (if not yet)
534 if (!gGLManager) {
535 TString x = "win32";
536 if (gVirtualX->InheritsFrom("TGX11"))
537 x = "x11";
538 else if (gVirtualX->InheritsFrom("TGCocoa"))
539 x = "osx";
540
541 TPluginHandler *ph = gROOT->GetPluginManager()->FindHandler("TGLManager", x);
542
543 if (ph && ph->LoadPlugin() != -1) {
544 if (!ph->ExecPlugin(0))
545 Error("CreateCanvas", "GL manager plugin failed");
546 }
547 }
548
549 if (gGLManager) {
551 if (fCanvasID != -1) {
552 //Create gl context.
553 const Int_t glCtx = gGLManager->CreateGLContext(fCanvasID);
554 if (glCtx != -1) {
556 fCanvas->SetGLDevice(glCtx);//Now, fCanvas is responsible for context deletion!
557 } else
558 Error("CreateCanvas", "GL context creation failed.");
559 } else
560 Error("CreateCanvas", "GL window creation failed\n");
561 }
562 }
563
564 if (fCanvasID == -1)
566
567 Window_t win = gVirtualX->GetWindowID(fCanvasID);
571
574
575 // create the tooltip with a timeout of 250 ms
577
578 fCanvas->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
579 "TRootCanvas", this,
580 "EventInfo(Int_t, Int_t, Int_t, TObject*)");
581
582 // Create status bar
583 int parts[] = { 33, 10, 10, 47 };
584 fStatusBar = new TGStatusBar(this, 10, 10);
585 fStatusBar->SetParts(parts, 4);
586
588
590
591 // Misc
594 fIconPic = SetIconPixmap("macro_s.xpm");
595 SetClassHints("ROOT", "Canvas");
596
599
600 // by default status bar, tool bar and pad editor are hidden
605
608
609 // we need to use GetDefaultSize() to initialize the layout algorithm...
611
612 gVirtualX->SetDNDAware(fId, fDNDTypeList);
614}
615
616////////////////////////////////////////////////////////////////////////////////
617/// Delete ROOT basic canvas. Order is significant. Delete in reverse
618/// order of creation.
619
621{
622 delete fToolTip;
623 if (fIconPic) gClient->FreePicture(fIconPic);
624 if (fEditor && !fEmbedded) delete fEditor;
625 if (fToolBar) {
626 Disconnect(fToolDock, "Docked()", this, "AdjustSize()");
627 Disconnect(fToolDock, "Undocked()", this, "AdjustSize()");
628 fToolBar->Cleanup();
629 delete fToolBar;
630 }
631
632 if (!MustCleanup()) {
633 delete fStatusBar;
634 delete fStatusBarLayout;
635 delete fCanvasContainer;
636 delete fCanvasWindow;
637
638 delete fEditorFrame;
639 delete fEditorLayout;
640 delete fMainFrame;
641 delete fMainFrameLayout;
642 delete fToolBarSep;
643 delete fToolDock;
644 delete fToolBarLayout;
645 delete fHorizontal1;
646 delete fHorizontal1Layout;
647
648 delete fMenuBar;
649 delete fMenuBarLayout;
650 delete fMenuBarItemLayout;
651 delete fMenuBarHelpLayout;
652 delete fCanvasLayout;
653 delete fDockLayout;
654 }
655
656 delete fFileMenu;
657 delete fFileSaveMenu;
658 delete fEditMenu;
659 delete fEditClearMenu;
660 delete fViewMenu;
661 delete fViewWithMenu;
662 delete fOptionMenu;
663 delete fToolsMenu;
664 delete fHelpMenu;
665}
666
667////////////////////////////////////////////////////////////////////////////////
668/// Called via TCanvasImp interface by TCanvas.
669
671{
673 if(gged && gged->GetCanvas() == fCanvas) {
674 if (fEmbedded) {
675 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
676 ((TGedEditor *)gged)->SetCanvas(0);
677 }
678 else gged->Hide();
679 }
680
681 gVirtualX->CloseWindow();
682}
683
684////////////////////////////////////////////////////////////////////////////////
685/// Really delete the canvas and this GUI.
686
688{
690 if(gged && gged->GetCanvas() == fCanvas) {
691 if (fEmbedded) {
692 ((TGedEditor *)gged)->SetModel(0, 0, kButton1Down);
693 ((TGedEditor *)gged)->SetCanvas(0);
694 }
695 else gged->Hide();
696 }
697
698 fToolTip->Hide();
699 Disconnect(fCanvas, "ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
700 this, "EventInfo(Int_t, Int_t, Int_t, TObject*)");
701
703 fCanvas->Clear();
704 fCanvas->SetName("");
705 if (gPad && gPad->GetCanvas() == fCanvas)
706 gPad = 0;
707 delete this;
708}
709
710////////////////////////////////////////////////////////////////////////////////
711/// In case window is closed via WM we get here.
712
714{
715 DeleteWindow();
716}
717
718////////////////////////////////////////////////////////////////////////////////
719/// Return width of canvas container.
720
722{
723 return fCanvasContainer->GetWidth();
724}
725
726////////////////////////////////////////////////////////////////////////////////
727/// Return height of canvas container.
728
730{
731 return fCanvasContainer->GetHeight();
732}
733
734////////////////////////////////////////////////////////////////////////////////
735/// Gets the size and position of the window containing the canvas. This
736/// size includes the menubar and borders.
737
739{
740 gVirtualX->GetWindowSize(fId, x, y, w, h);
741
742 Window_t childdum;
743 gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(),
744 0, 0, x, y, childdum);
745 if (!fCanvas->GetShowEditor()) return 0;
746 return fEditorFrame->GetWidth();
747}
748
749////////////////////////////////////////////////////////////////////////////////
750/// Set text in status bar.
751
752void TRootCanvas::SetStatusText(const char *txt, Int_t partidx)
753{
754 fStatusBar->SetText(txt, partidx);
755}
756
757////////////////////////////////////////////////////////////////////////////////
758/// Handle menu and other command generated by the user.
759
761{
762 TRootHelpDialog *hd;
763 TList *lc;
764
765 switch (GET_MSG(msg)) {
766
767 case kC_COMMAND:
768
769 switch (GET_SUBMSG(msg)) {
770
771 case kCM_BUTTON:
772 case kCM_MENU:
773
774 switch (parm1) {
775 // Handle toolbar items...
776 case kToolModify:
777 gROOT->SetEditorMode();
778 break;
779 case kToolArc:
780 gROOT->SetEditorMode("Arc");
781 break;
782 case kToolLine:
783 gROOT->SetEditorMode("Line");
784 break;
785 case kToolArrow:
786 gROOT->SetEditorMode("Arrow");
787 break;
788 case kToolDiamond:
789 gROOT->SetEditorMode("Diamond");
790 break;
791 case kToolEllipse:
792 gROOT->SetEditorMode("Ellipse");
793 break;
794 case kToolPad:
795 gROOT->SetEditorMode("Pad");
796 break;
797 case kToolPave:
798 gROOT->SetEditorMode("Pave");
799 break;
800 case kToolPLabel:
801 gROOT->SetEditorMode("PaveLabel");
802 break;
803 case kToolPText:
804 gROOT->SetEditorMode("PaveText");
805 break;
806 case kToolPsText:
807 gROOT->SetEditorMode("PavesText");
808 break;
809 case kToolGraph:
810 gROOT->SetEditorMode("PolyLine");
811 break;
812 case kToolCurlyLine:
813 gROOT->SetEditorMode("CurlyLine");
814 break;
815 case kToolCurlyArc:
816 gROOT->SetEditorMode("CurlyArc");
817 break;
818 case kToolLatex:
819 gROOT->SetEditorMode("Text");
820 break;
821 case kToolMarker:
822 gROOT->SetEditorMode("Marker");
823 break;
824 case kToolCutG:
825 gROOT->SetEditorMode("CutG");
826 break;
827
828 // Handle File menu items...
829 case kFileNewCanvas:
830 gROOT->MakeDefCanvas();
831 break;
832 case kFileOpen:
833 {
834 static TString dir(".");
835 TGFileInfo fi;
837 fi.SetIniDir(dir);
838 new TGFileDialog(fClient->GetDefaultRoot(), this, kFDOpen,&fi);
839 if (!fi.fFilename) return kTRUE;
840 dir = fi.fIniDir;
841 new TFile(fi.fFilename, "update");
842 }
843 break;
844 case kFileSaveAs:
845 {
846 TString workdir = gSystem->WorkingDirectory();
847 static TString dir(".");
848 static Int_t typeidx = 0;
849 static Bool_t overwr = kFALSE;
850 TGFileInfo fi;
851 TString defaultType = gEnv->GetValue("Canvas.SaveAsDefaultType", ".pdf");
852 if (typeidx == 0) {
853 for (int i=1;gSaveAsTypes[i];i+=2) {
854 TString ftype = gSaveAsTypes[i];
855 if (ftype.EndsWith(defaultType.Data())) {
856 typeidx = i-1;
857 break;
858 }
859 }
860 }
862 fi.SetIniDir(dir);
863 fi.fFileTypeIdx = typeidx;
864 fi.fOverwrite = overwr;
865 new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi);
866 gSystem->ChangeDirectory(workdir.Data());
867 if (!fi.fFilename) return kTRUE;
868 Bool_t appendedType = kFALSE;
869 TString fn = fi.fFilename;
870 TString ft = fi.fFileTypes[fi.fFileTypeIdx+1];
871 dir = fi.fIniDir;
872 typeidx = fi.fFileTypeIdx;
873 overwr = fi.fOverwrite;
874again:
875 if (fn.EndsWith(".root") ||
876 fn.EndsWith(".ps") ||
877 fn.EndsWith(".eps") ||
878 fn.EndsWith(".pdf") ||
879 fn.EndsWith(".svg") ||
880 fn.EndsWith(".tex") ||
881 fn.EndsWith(".gif") ||
882 fn.EndsWith(".xml") ||
883 fn.EndsWith(".xpm") ||
884 fn.EndsWith(".jpg") ||
885 fn.EndsWith(".png") ||
886 fn.EndsWith(".xcf") ||
887 fn.EndsWith(".tiff")) {
888 fCanvas->SaveAs(fn);
889 } else if (fn.EndsWith(".C"))
890 fCanvas->SaveSource(fn);
891 else {
892 if (!appendedType) {
893 if (ft.Index(".") != kNPOS) {
894 fn += ft(ft.Index("."), ft.Length());
895 appendedType = kTRUE;
896 goto again;
897 }
898 }
899 Warning("ProcessMessage", "file %s cannot be saved with this extension", fi.fFilename);
900 }
901 for (int i=1;gSaveAsTypes[i];i+=2) {
902 TString ftype = gSaveAsTypes[i];
903 ftype.ReplaceAll("*.", ".");
904 if (fn.EndsWith(ftype.Data())) {
905 typeidx = i-1;
906 break;
907 }
908 }
909 }
910 break;
911 case kFileSaveAsRoot:
912 fCanvas->SaveAs(".root");
913 break;
914 case kFileSaveAsC:
916 break;
917 case kFileSaveAsPS:
918 fCanvas->SaveAs();
919 break;
920 case kFileSaveAsEPS:
921 fCanvas->SaveAs(".eps");
922 break;
923 case kFileSaveAsPDF:
924 fCanvas->SaveAs(".pdf");
925 break;
926 case kFileSaveAsGIF:
927 fCanvas->SaveAs(".gif");
928 break;
929 case kFileSaveAsJPG:
930 fCanvas->SaveAs(".jpg");
931 break;
932 case kFileSaveAsPNG:
933 fCanvas->SaveAs(".png");
934 break;
935 case kFileSaveAsTEX:
936 fCanvas->SaveAs(".tex");
937 break;
938 case kFilePrint:
939 PrintCanvas();
940 break;
941 case kFileCloseCanvas:
943 break;
944 case kFileQuit:
945 if (!gApplication->ReturnFromRun()) {
949 }
952 if (TClass::GetClass("TStyleManager"))
953 gROOT->ProcessLine("TStyleManager::Terminate()");
955 break;
956
957 // Handle Edit menu items...
958 case kEditStyle:
959 if (!TClass::GetClass("TStyleManager"))
960 gSystem->Load("libGed");
961 gROOT->ProcessLine("TStyleManager::Show()");
962 break;
963 case kEditCut:
964 // still noop
965 break;
966 case kEditCopy:
967 // still noop
968 break;
969 case kEditPaste:
970 // still noop
971 break;
972 case kEditUndo:
973 // noop
974 break;
975 case kEditRedo:
976 // noop
977 break;
978 case kEditClearPad:
979 gPad->Clear();
980 gPad->Modified();
981 gPad->Update();
982 break;
983 case kEditClearCanvas:
984 fCanvas->Clear();
985 fCanvas->Modified();
986 fCanvas->Update();
987 break;
988
989 // Handle View menu items...
990 case kViewEditor:
992 break;
993 case kViewToolbar:
995 break;
996 case kViewEventStatus:
998 break;
999 case kViewToolTips:
1001 break;
1002 case kViewColors:
1003 {
1004 TVirtualPad *padsav = gPad->GetCanvas();
1005 //This was the code with the old color table
1006 // TCanvas *m = new TCanvas("colors","Color Table");
1007 // TPad::DrawColorTable();
1008 // m->Update();
1009 TColorWheel *wheel = new TColorWheel();
1010 wheel->Draw();
1011
1012 //tp: with Cocoa, window is visible (and repainted)
1013 //before wheel->Draw() was called and you can see "empty"
1014 //canvas.
1015 gPad->Update();
1016 //
1017 if (padsav) padsav->cd();
1018 }
1019 break;
1020 case kViewFonts:
1021 // noop
1022 break;
1023 case kViewMarkers:
1024 {
1025 TVirtualPad *padsav = gPad->GetCanvas();
1026 TCanvas *m = new TCanvas("markers","Marker Types",600,200);
1028 m->Update();
1029 if (padsav) padsav->cd();
1030 }
1031 break;
1032 case kViewIconify:
1033 Iconify();
1034 break;
1035 case kViewX3D:
1036 gPad->GetViewer3D("x3d");
1037 break;
1038 case kViewOpenGL:
1039 gPad->GetViewer3D("ogl");
1040 break;
1041
1042 // Handle Option menu items...
1043 case kOptionAutoExec:
1045 if (fCanvas->GetAutoExec()) {
1047 } else {
1049 }
1050 break;
1051 case kOptionAutoResize:
1052 {
1054 int opt = fCanvasContainer->GetOptions();
1055 if (fAutoFit) {
1056 opt &= ~kFixedSize;
1058 } else {
1059 opt |= kFixedSize;
1061 }
1062 fCanvasContainer->ChangeOptions(opt);
1063 // in case of autofit this will generate a configure
1064 // event for the container and this will force the
1065 // update of the TCanvas
1066 //Layout();
1067 }
1068 Layout();
1069 break;
1071 FitCanvas();
1072 break;
1073 case kOptionMoveOpaque:
1074 if (fCanvas->OpaqueMoving()) {
1075 fCanvas->MoveOpaque(0);
1077 } else {
1078 fCanvas->MoveOpaque(1);
1080 }
1081 break;
1083 if (fCanvas->OpaqueResizing()) {
1086 } else {
1089 }
1090 break;
1091 case kOptionInterrupt:
1092 gROOT->SetInterrupt();
1093 break;
1094 case kOptionRefresh:
1095 fCanvas->Paint();
1096 fCanvas->Update();
1097 break;
1098 case kOptionStatistics:
1099 if (gStyle->GetOptStat()) {
1100 gStyle->SetOptStat(0);
1101 delete gPad->FindObject("stats");
1103 } else {
1104 gStyle->SetOptStat(1);
1106 }
1107 gPad->Modified();
1108 fCanvas->Update();
1109 break;
1110 case kOptionHistTitle:
1111 if (gStyle->GetOptTitle()) {
1112 gStyle->SetOptTitle(0);
1113 delete gPad->FindObject("title");
1115 } else {
1116 gStyle->SetOptTitle(1);
1118 }
1119 gPad->Modified();
1120 fCanvas->Update();
1121 break;
1122 case kOptionFitParams:
1123 if (gStyle->GetOptFit()) {
1124 gStyle->SetOptFit(0);
1126 } else {
1127 gStyle->SetOptFit(1);
1129 }
1130 gPad->Modified();
1131 fCanvas->Update();
1132 break;
1133 case kOptionCanEdit:
1134 if (gROOT->GetEditHistograms()) {
1135 gROOT->SetEditHistograms(kFALSE);
1137 } else {
1138 gROOT->SetEditHistograms(kTRUE);
1140 }
1141 break;
1142
1143 // Handle Tools menu items...
1144 case kInspectRoot:
1145 fCanvas->cd();
1146 gROOT->Inspect();
1147 fCanvas->Update();
1148 break;
1149 case kToolsBrowser:
1150 new TBrowser("browser");
1151 break;
1152 case kToolsBuilder:
1154 break;
1155 case kToolsRecorder:
1156 gROOT->ProcessLine("new TGRecorder()");
1157 break;
1158
1159 // Handle Tools menu items...
1160 case kClassesTree:
1161 {
1162 TString cdef;
1163 lc = (TList*)gROOT->GetListOfCanvases();
1164 if (lc->FindObject("ClassTree")) {
1165 cdef = TString::Format("ClassTree_%d", lc->GetSize()+1);
1166 } else {
1167 cdef = "ClassTree";
1168 }
1169 new TClassTree(cdef.Data(), "TObject");
1170 fCanvas->Update();
1171 }
1172 break;
1173
1174 case kFitPanel:
1175 {
1176 // use plugin manager to create instance of TFitEditor
1177 TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
1178 if (handler && handler->LoadPlugin() != -1) {
1179 if (handler->ExecPlugin(2, fCanvas, 0) == 0)
1180 Error("FitPanel", "Unable to crate the FitPanel");
1181 }
1182 else
1183 Error("FitPanel", "Unable to find the FitPanel plug-in");
1184 }
1185 break;
1186
1187 // Handle Help menu items...
1188 case kHelpAbout:
1189 {
1190#ifdef R__UNIX
1191 TString rootx = TROOT::GetBinDir() + "/root -a &";
1192 gSystem->Exec(rootx);
1193#else
1194#ifdef WIN32
1196#else
1197
1198 char str[32];
1199 sprintf(str, "About ROOT %s...", gROOT->GetVersion());
1200 hd = new TRootHelpDialog(this, str, 600, 400);
1201 hd->SetText(gHelpAbout);
1202 hd->Popup();
1203#endif
1204#endif
1205 }
1206 break;
1207 case kHelpOnCanvas:
1208 hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1209 hd->SetText(gHelpCanvas);
1210 hd->Popup();
1211 break;
1212 case kHelpOnMenus:
1213 hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1215 hd->Popup();
1216 break;
1217 case kHelpOnGraphicsEd:
1218 hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1220 hd->Popup();
1221 break;
1222 case kHelpOnBrowser:
1223 hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1224 hd->SetText(gHelpBrowser);
1225 hd->Popup();
1226 break;
1227 case kHelpOnObjects:
1228 hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
1229 hd->SetText(gHelpObjects);
1230 hd->Popup();
1231 break;
1232 case kHelpOnPS:
1233 hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
1235 hd->Popup();
1236 break;
1237 }
1238 default:
1239 break;
1240 }
1241 default:
1242 break;
1243 }
1244 return kTRUE;
1245}
1246
1247////////////////////////////////////////////////////////////////////////////////
1248/// Called by TCanvas ctor to get window indetifier.
1249
1251{
1252 if (fCanvas->OpaqueMoving())
1254 if (fCanvas->OpaqueResizing())
1256
1257 return fCanvasID;
1258}
1259
1260////////////////////////////////////////////////////////////////////////////////
1261/// Set size of canvas container. Units in pixels.
1262
1264{
1265 // turn off autofit, we want to stay at the given size
1266 fAutoFit = kFALSE;
1268 int opt = fCanvasContainer->GetOptions();
1269 opt |= kFixedSize; // turn on fixed size mode
1270 fCanvasContainer->ChangeOptions(opt);
1271 fCanvasContainer->SetWidth(w);
1272 fCanvasContainer->SetHeight(h);
1273 Layout(); // force layout (will update container to given size)
1274 fCanvas->Resize();
1275 fCanvas->Update();
1276}
1277
1278////////////////////////////////////////////////////////////////////////////////
1279/// Set canvas position (units in pixels).
1280
1282{
1283 Move(x, y);
1284}
1285
1286////////////////////////////////////////////////////////////////////////////////
1287/// Set size of canvas (units in pixels).
1288
1290{
1291 Resize(w, h);
1292
1293 // Make sure the change of size is really done.
1294 gVirtualX->Update(1);
1295 if (!gThreadXAR) {
1296 gSystem->Sleep(100);
1298 gSystem->Sleep(10);
1300 }
1301}
1302
1303////////////////////////////////////////////////////////////////////////////////
1304/// Put canvas window on top of the window stack.
1305
1307{
1308 gVirtualX->RaiseWindow(GetId());
1309}
1310
1311////////////////////////////////////////////////////////////////////////////////
1312/// Change title on window.
1313
1314void TRootCanvas::SetWindowTitle(const char *title)
1315{
1316 SetWindowName(title);
1317 SetIconName(title);
1318 fToolDock->SetWindowName(Form("ToolBar: %s", title));
1319}
1320
1321////////////////////////////////////////////////////////////////////////////////
1322/// Fit canvas container to current window size.
1323
1325{
1326 if (!fAutoFit) {
1327 int opt = fCanvasContainer->GetOptions();
1328 int oopt = opt;
1329 opt &= ~kFixedSize; // turn off fixed size mode
1330 fCanvasContainer->ChangeOptions(opt);
1331 Layout(); // force layout
1332 fCanvas->Resize();
1333 fCanvas->Update();
1334 fCanvasContainer->ChangeOptions(oopt);
1335 }
1336}
1337
1338////////////////////////////////////////////////////////////////////////////////
1339/// Print the canvas.
1340
1342{
1343 Int_t ret = 0;
1344 Bool_t pname = kTRUE;
1345 char *printer, *printCmd;
1346 static TString sprinter, sprintCmd;
1347
1348 if (sprinter == "")
1349 printer = StrDup(gEnv->GetValue("Print.Printer", ""));
1350 else
1351 printer = StrDup(sprinter);
1352 if (sprintCmd == "")
1353#ifndef WIN32
1354 printCmd = StrDup(gEnv->GetValue("Print.Command", ""));
1355#else
1356 printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p"));
1357#endif
1358 else
1359 printCmd = StrDup(sprintCmd);
1360
1361 new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
1362 &printer, &printCmd, &ret);
1363 if (ret) {
1364 sprinter = printer;
1365 sprintCmd = printCmd;
1366
1367 if (sprinter == "")
1368 pname = kFALSE;
1369
1370 TString fn = "rootprint";
1371 FILE *f = gSystem->TempFileName(fn, gEnv->GetValue("Print.Directory", gSystem->TempDirectory()));
1372 if (f) fclose(f);
1373 fn += TString::Format(".%s",gEnv->GetValue("Print.FileType", "pdf"));
1374 fCanvas->Print(fn);
1375
1376 TString cmd = sprintCmd;
1377 if (cmd.Contains("%p"))
1378 cmd.ReplaceAll("%p", sprinter);
1379 else if (pname) {
1380 cmd += " "; cmd += sprinter; cmd += " ";
1381 }
1382
1383 if (cmd.Contains("%f"))
1384 cmd.ReplaceAll("%f", fn);
1385 else {
1386 cmd += " "; cmd += fn; cmd += " ";
1387 }
1388
1389 gSystem->Exec(cmd);
1390#ifndef WIN32
1391 gSystem->Unlink(fn);
1392#endif
1393 }
1394 delete [] printer;
1395 delete [] printCmd;
1396}
1397
1398////////////////////////////////////////////////////////////////////////////////
1399/// Display a tooltip with infos about the primitive below the cursor.
1400
1401void TRootCanvas::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
1402{
1403 fToolTip->Hide();
1404 if (!fCanvas->GetShowToolTips() || selected == 0 ||
1405 event != kMouseMotion || fButton != 0)
1406 return;
1407 TString tipInfo;
1408 TString objInfo = selected->GetObjectInfo(px, py);
1409 if (objInfo.BeginsWith("-")) {
1410 // if the string begins with '-', display only the object info
1411 objInfo.Remove(TString::kLeading, '-');
1412 tipInfo = objInfo;
1413 }
1414 else {
1415 const char *title = selected->GetTitle();
1416 tipInfo += TString::Format("%s::%s", selected->ClassName(),
1417 selected->GetName());
1418 if (title && strlen(title))
1419 tipInfo += TString::Format("\n%s", selected->GetTitle());
1420 tipInfo += TString::Format("\n%d, %d", px, py);
1421 if (!objInfo.IsNull())
1422 tipInfo += TString::Format("\n%s", objInfo.Data());
1423 }
1424 fToolTip->SetText(tipInfo.Data());
1425 fToolTip->SetPosition(px+15, py+15);
1426 fToolTip->Reset();
1427}
1428
1429////////////////////////////////////////////////////////////////////////////////
1430/// Show or hide menubar.
1431
1433{
1434 if (show) ShowFrame(fMenuBar);
1435 else HideFrame(fMenuBar);
1436}
1437
1438////////////////////////////////////////////////////////////////////////////////
1439/// Show or hide statusbar.
1440
1442{
1445
1446 UInt_t h = GetHeight();
1447 UInt_t sh = fStatusBar->GetHeight()+2;
1448
1449 if (show) {
1452 if (dh - ch >= sh) h = h + sh;
1453 else h = ch;
1454 } else {
1457 if (dh - ch < sh) h = ch;
1458 else h = h - sh;
1459 }
1460 Resize(GetWidth(), h);
1461}
1462
1463////////////////////////////////////////////////////////////////////////////////
1464/// Show or hide side frame.
1465
1467{
1468 TVirtualPad *savedPad = 0;
1469 savedPad = (TVirtualPad *) gPad;
1470 gPad = Canvas();
1471
1472 UInt_t w = GetWidth();
1474 UInt_t h = GetHeight();
1476
1477 if (fParent && fParent != fClient->GetDefaultRoot()) {
1480 if (main && main->InheritsFrom("TRootBrowser")) {
1481 TRootBrowser *browser = (TRootBrowser *)main;
1482 if (!fEmbedded)
1483 browser->GetTabRight()->Connect("Selected(Int_t)", "TRootCanvas",
1484 this, "Activated(Int_t)");
1485 fEmbedded = kTRUE;
1486 if (show && (!fEditor || !((TGedEditor *)fEditor)->IsMapped())) {
1487 if (!browser->GetTabLeft()->GetTabTab("Pad Editor")) {
1488 if (browser->GetActFrame()) { //already in edit mode
1489 TTimer::SingleShot(200, "TRootCanvas", this, "ShowEditor(=kTRUE)");
1490 } else {
1492 if (!fEditor)
1494 else {
1495 ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot());
1496 ((TGedEditor *)fEditor)->MapWindow();
1497 }
1498 browser->StopEmbedding("Pad Editor");
1499 if (fEditor) {
1501 gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor);
1502 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
1503 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
1504 }
1505 }
1506 }
1507 else
1509 }
1510 if (show) browser->GetTabLeft()->SetTab("Pad Editor");
1511 }
1512 }
1513 else {
1514 if (show) {
1515 if (!fEditor) CreateEditor();
1517 if(gged && gged->GetCanvas() == fCanvas){
1518 gged->Hide();
1519 }
1522 h = h + s;
1523 }
1525 fEditor->Show();
1527 w = w + e;
1528 } else {
1531 h = h - s;
1532 }
1533 if (fEditor) fEditor->Hide();
1536 w = w - e;
1537 }
1538 Resize(w, h);
1539 }
1540 if (savedPad) gPad = savedPad;
1541}
1542
1543////////////////////////////////////////////////////////////////////////////////
1544/// Create embedded editor.
1545
1547{
1550 gPad = Canvas();
1551 // next two lines are related to the old editor
1552 Int_t show = gEnv->GetValue("Canvas.ShowEditor", 0);
1553 gEnv->SetValue("Canvas.ShowEditor","true");
1558
1559 // next line is related to the old editor
1560 if (show == 0) gEnv->SetValue("Canvas.ShowEditor","false");
1561}
1562
1563////////////////////////////////////////////////////////////////////////////////
1564/// Show or hide toolbar.
1565
1567{
1568 if (show && !fToolBar) {
1569
1572
1573 Int_t spacing = 6, i;
1574 for (i = 0; gToolBarData[i].fPixmap; i++) {
1575 if (strlen(gToolBarData[i].fPixmap) == 0) {
1576 spacing = 6;
1577 continue;
1578 }
1579 fToolBar->AddButton(this, &gToolBarData[i], spacing);
1580 spacing = 0;
1581 }
1588
1589 spacing = 6;
1590 for (i = 0; gToolBarData1[i].fPixmap; i++) {
1591 if (strlen(gToolBarData1[i].fPixmap) == 0) {
1592 spacing = 6;
1593 continue;
1594 }
1595 fToolBar->AddButton(this, &gToolBarData1[i], spacing);
1596 spacing = 0;
1597 }
1599 fToolDock->Layout();
1600 fToolDock->SetWindowName(Form("ToolBar: %s", GetWindowName()));
1601 fToolDock->Connect("Docked()", "TRootCanvas", this, "AdjustSize()");
1602 fToolDock->Connect("Undocked()", "TRootCanvas", this, "AdjustSize()");
1603 }
1604
1605 if (!fToolBar) return;
1606
1607 UInt_t h = GetHeight();
1609 UInt_t dh = fToolBar->GetHeight();
1610
1611 if (show) {
1615 h = h + sh;
1616 }
1619 h = h + dh + sh;
1620 } else {
1621 if (fToolDock->IsUndocked()) {
1623 h = h + 2*sh;
1624 } else h = h - dh;
1625
1629 h = h - sh;
1630 }
1632 h = h - sh;
1634 }
1635 Resize(GetWidth(), h);
1636}
1637
1638////////////////////////////////////////////////////////////////////////////////
1639/// Enable or disable tooltip info.
1640
1642{
1643 if (show)
1645 else
1647}
1648
1649////////////////////////////////////////////////////////////////////////////////
1650/// Returns kTRUE if the editor is shown.
1651
1653{
1655}
1656
1657////////////////////////////////////////////////////////////////////////////////
1658/// Returns kTRUE if the menu bar is shown.
1659
1661{
1662 return (fMenuBar) && fMenuBar->IsMapped();
1663}
1664
1665////////////////////////////////////////////////////////////////////////////////
1666/// Returns kTRUE if the status bar is shown.
1667
1669{
1670 return (fStatusBar) && fStatusBar->IsMapped();
1671}
1672
1673////////////////////////////////////////////////////////////////////////////////
1674/// Returns kTRUE if the tool bar is shown.
1675
1677{
1678 return (fToolBar) && fToolBar->IsMapped();
1679}
1680
1681////////////////////////////////////////////////////////////////////////////////
1682/// Returns kTRUE if the tooltips are enabled.
1683
1685{
1686 return (fCanvas) && fCanvas->GetShowToolTips();
1687}
1688
1689////////////////////////////////////////////////////////////////////////////////
1690/// Keep the same canvas size while docking/undocking toolbar.
1691
1693{
1694 UInt_t h = GetHeight();
1695 UInt_t dh = fToolBar->GetHeight();
1697
1698 if (fToolDock->IsUndocked()) {
1701 h = h - sh;
1702 }
1704 h = h - dh - sh;
1705 } else {
1708 h = h + sh;
1709 }
1711 h = h + dh + sh;
1712 }
1713 Resize(GetWidth(), h);
1714}
1715
1716////////////////////////////////////////////////////////////////////////////////
1717/// Handle mouse button events in the canvas container.
1718
1720{
1721 Int_t button = event->fCode;
1722 Int_t x = event->fX;
1723 Int_t y = event->fY;
1724
1725 if (event->fType == kButtonPress) {
1726 if (fToolTip && fCanvas->GetShowToolTips()) {
1727 fToolTip->Hide();
1728 gVirtualX->UpdateWindow(0);
1730 }
1731 fButton = button;
1732 if (button == kButton1) {
1733 if (event->fState & kKeyShiftMask)
1735 else
1737 }
1738 if (button == kButton2)
1740 if (button == kButton3) {
1742 fButton = 0; // button up is consumed by TContextMenu
1743 }
1744
1745 } else if (event->fType == kButtonRelease) {
1746 if (button == kButton4)
1748 if (button == kButton5)
1750 if (button == kButton1)
1752 if (button == kButton2)
1754 if (button == kButton3)
1756
1757 fButton = 0;
1758 }
1759
1760 return kTRUE;
1761}
1762
1763////////////////////////////////////////////////////////////////////////////////
1764/// Handle mouse button double click events in the canvas container.
1765
1767{
1768 Int_t button = event->fCode;
1769 Int_t x = event->fX;
1770 Int_t y = event->fY;
1771
1772 if (button == kButton1)
1774 if (button == kButton2)
1776 if (button == kButton3)
1778
1779 return kTRUE;
1780}
1781
1782////////////////////////////////////////////////////////////////////////////////
1783/// Handle configure (i.e. resize) event.
1784
1786{
1787 if (fAutoFit) {
1788 fCanvas->Resize();
1789 fCanvas->Update();
1790 }
1791
1793 // get menu height
1794 static Int_t dh = 0;
1795 if (!dh)
1796 dh = GetHeight() - fCanvasContainer->GetHeight();
1797 UInt_t h = TMath::Nint(fCanvasContainer->GetWidth()/
1798 fCanvas->GetAspectRatio()) + dh;
1800 }
1801 return kTRUE;
1802}
1803
1804////////////////////////////////////////////////////////////////////////////////
1805/// Handle keyboard events in the canvas container.
1806
1808{
1809 static EGEventType previous_event = kOtherEvent;
1810 static UInt_t previous_keysym = 0;
1811
1812 if (event->fType == kGKeyPress) {
1813 fButton = event->fCode;
1814 UInt_t keysym;
1815 char str[2];
1816 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1817
1818 if (str[0] == kESC){ // ESC sets the escape flag
1819 gROOT->SetEscape();
1822 gPad->Modified();
1823 return kTRUE;
1824 }
1825 if (str[0] == 3) // ctrl-c sets the interrupt flag
1826 gROOT->SetInterrupt();
1827
1828 // handle arrow keys
1829 if (keysym > 0x1011 && keysym < 0x1016) {
1830 Window_t dum1, dum2, wid;
1831 UInt_t mask = 0;
1832 Int_t mx, my, tx, ty;
1833 wid = gVirtualX->GetDefaultRootWindow();
1834 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1835 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1836 fCanvasContainer->GetId(),
1837 mx, my, tx, ty, dum1);
1839 // handle case where we got consecutive same keypressed events coming
1840 // from auto-repeat on Windows (as it fires only successive keydown events)
1841 if ((previous_keysym == keysym) && (previous_event == kGKeyPress)) {
1842 switch (keysym) {
1843 case 0x1012: // left
1844 gVirtualX->Warp(--mx, my, wid); --tx;
1845 break;
1846 case 0x1013: // up
1847 gVirtualX->Warp(mx, --my, wid); --ty;
1848 break;
1849 case 0x1014: // right
1850 gVirtualX->Warp(++mx, my, wid); ++tx;
1851 break;
1852 case 0x1015: // down
1853 gVirtualX->Warp(mx, ++my, wid); ++ty;
1854 break;
1855 default:
1856 break;
1857 }
1859 }
1860 previous_keysym = keysym;
1861 }
1862 else {
1863 fCanvas->HandleInput(kKeyPress, str[0], keysym);
1864 }
1865 } else if (event->fType == kKeyRelease) {
1866 UInt_t keysym;
1867 char str[2];
1868 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1869
1870 if (keysym > 0x1011 && keysym < 0x1016) {
1871 Window_t dum1, dum2, wid;
1872 UInt_t mask = 0;
1873 Int_t mx, my, tx, ty;
1874 wid = gVirtualX->GetDefaultRootWindow();
1875 gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1876 switch (keysym) {
1877 case 0x1012: // left
1878 gVirtualX->Warp(--mx, my, wid);
1879 break;
1880 case 0x1013: // up
1881 gVirtualX->Warp(mx, --my, wid);
1882 break;
1883 case 0x1014: // right
1884 gVirtualX->Warp(++mx, my, wid);
1885 break;
1886 case 0x1015: // down
1887 gVirtualX->Warp(mx, ++my, wid);
1888 break;
1889 default:
1890 break;
1891 }
1892 gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1893 fCanvasContainer->GetId(),
1894 mx, my, tx, ty, dum1);
1896 previous_keysym = keysym;
1897 }
1898 fButton = 0;
1899 }
1900 previous_event = event->fType;
1901 return kTRUE;
1902}
1903
1904////////////////////////////////////////////////////////////////////////////////
1905/// Handle mouse motion event in the canvas container.
1906
1908{
1909 Int_t x = event->fX;
1910 Int_t y = event->fY;
1911
1912 if (fButton == 0)
1914 if (fButton == kButton1) {
1915 if (event->fState & kKeyShiftMask)
1917 else
1919 }
1920 if (fButton == kButton2)
1922
1923 return kTRUE;
1924}
1925
1926////////////////////////////////////////////////////////////////////////////////
1927/// Handle expose events.
1928
1930{
1931 if (event->fCount == 0) {
1932 fCanvas->Flush();
1933 }
1934
1935 return kTRUE;
1936}
1937
1938////////////////////////////////////////////////////////////////////////////////
1939/// Handle enter/leave events. Only leave is activated at the moment.
1940
1942{
1943 Int_t x = event->fX;
1944 Int_t y = event->fY;
1945
1946 // pointer grabs create also an enter and leave event but with fCode
1947 // either kNotifyGrab or kNotifyUngrab, don't propagate these events
1948 if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
1950
1951 return kTRUE;
1952}
1953
1954////////////////////////////////////////////////////////////////////////////////
1955/// Handle drop events.
1956
1958{
1959 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
1960 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
1961
1962 if (data->fDataType == rootObj) {
1963 TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
1964 buf.SetReadMode();
1965 TObject *obj = (TObject *)buf.ReadObjectAny(TObject::Class());
1966 if (!obj) return kTRUE;
1967 gPad->Clear();
1968 if (obj->InheritsFrom("TKey")) {
1969 TObject *object = (TObject *)gROOT->ProcessLine(Form("((TKey *)0x%lx)->ReadObj();", (ULong_t)obj));
1970 if (!object) return kTRUE;
1971 if (object->InheritsFrom("TGraph"))
1972 object->Draw("ALP");
1973 else if (object->InheritsFrom("TImage"))
1974 object->Draw("x");
1975 else if (object->IsA()->GetMethodAllAny("Draw"))
1976 object->Draw();
1977 }
1978 else if (obj->InheritsFrom("TGraph"))
1979 obj->Draw("ALP");
1980 else if (obj->IsA()->GetMethodAllAny("Draw"))
1981 obj->Draw();
1982 gPad->Modified();
1983 gPad->Update();
1984 return kTRUE;
1985 }
1986 else if (data->fDataType == uriObj) {
1987 TString sfname((char *)data->fData);
1988 if (sfname.Length() > 7) {
1989 sfname.ReplaceAll("\r\n", "");
1990 TUrl uri(sfname.Data());
1991 if (sfname.EndsWith(".bmp") ||
1992 sfname.EndsWith(".gif") ||
1993 sfname.EndsWith(".jpg") ||
1994 sfname.EndsWith(".png") ||
1995 sfname.EndsWith(".ps") ||
1996 sfname.EndsWith(".eps") ||
1997 sfname.EndsWith(".pdf") ||
1998 sfname.EndsWith(".tiff") ||
1999 sfname.EndsWith(".xpm")) {
2000 TImage *img = TImage::Open(uri.GetFile());
2001 if (img) {
2002 img->Draw("x");
2003 img->SetEditable(kTRUE);
2004 }
2005 }
2006 gPad->Modified();
2007 gPad->Update();
2008 }
2009 }
2010 return kFALSE;
2011}
2012
2013////////////////////////////////////////////////////////////////////////////////
2014/// Handle dragging position events.
2015
2017 Int_t /*xroot*/, Int_t /*yroot*/)
2018{
2019 TPad *pad = fCanvas->Pick(x, y, 0);
2020 if (pad) {
2021 pad->cd();
2022 gROOT->SetSelectedPad(pad);
2023 // make sure the pad is highlighted (on Windows)
2024 pad->Update();
2025 }
2026 return action;
2027}
2028
2029////////////////////////////////////////////////////////////////////////////////
2030/// Handle drag enter events.
2031
2033{
2034 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2035 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2036 Atom_t ret = kNone;
2037 for (int i = 0; typelist[i] != kNone; ++i) {
2038 if (typelist[i] == rootObj)
2039 ret = rootObj;
2040 if (typelist[i] == uriObj)
2041 ret = uriObj;
2042 }
2043 return ret;
2044}
2045
2046////////////////////////////////////////////////////////////////////////////////
2047/// Handle drag leave events.
2048
2050{
2051 return kTRUE;
2052}
2053
2054////////////////////////////////////////////////////////////////////////////////
2055/// Slot handling tab switching in the browser, to properly set the canvas
2056/// and the model to the editor.
2057
2059{
2060 if (fEmbedded) {
2061 TGTab *sender = (TGTab *)gTQSender;
2062 if (sender) {
2063 TGCompositeFrame *cont = sender->GetTabContainer(id);
2064 if (cont == fParent) {
2065 if (!fEditor)
2067 if (fEditor && ((TGedEditor *)fEditor)->IsMapped()) {
2068 ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
2069 ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
2070 }
2071 }
2072 }
2073 }
2074}
2075
2076////////////////////////////////////////////////////////////////////////////////
2077/// Save a canvas container as a C++ statement(s) on output stream out.
2078
2079void TRootContainer::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
2080{
2081 out << std::endl << " // canvas container" << std::endl;
2082 out << " Int_t canvasID = gVirtualX->InitWindow((ULong_t)"
2083 << GetParent()->GetParent()->GetName() << "->GetId());" << std::endl;
2084 out << " Window_t winC = gVirtualX->GetWindowID(canvasID);" << std::endl;
2085 out << " TGCompositeFrame *";
2086 out << GetName() << " = new TGCompositeFrame(gClient,winC"
2087 << "," << GetParent()->GetName() << ");" << std::endl;
2088}
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
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
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
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
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
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
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
#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
const Ssiz_t kNPOS
Definition RtypesCore.h:115
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
const Bool_t kFALSE
Definition RtypesCore.h:92
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
R__EXTERN TApplication * gApplication
include TDocParser_001 C image html pict1_TDocParser_001 png width
R__EXTERN TEnv * gEnv
Definition TEnv.h:171
const Int_t kFatal
Definition TError.h:51
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:187
R__EXTERN Int_t gErrorIgnoreLevel
Definition TError.h:129
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:231
#define gClient
Definition TGClient.h:166
@ kFDOpen
@ kFDSave
@ kLHintsRight
Definition TGLayout.h:33
@ kLHintsExpandY
Definition TGLayout.h:38
@ kLHintsLeft
Definition TGLayout.h:31
@ kLHintsBottom
Definition TGLayout.h:36
@ kLHintsTop
Definition TGLayout.h:34
@ kLHintsExpandX
Definition TGLayout.h:37
XFontStruct * id
Definition TGX11.cxx:109
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,...)
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2510
R__EXTERN TStyle * gStyle
Definition TStyle.h:412
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
#define gGLManager
Definition TVirtualGL.h:162
#define gPad
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
#define gVirtualX
Definition TVirtualX.h:338
Int_t GET_MSG(Long_t val)
@ kCM_MENU
@ kC_COMMAND
@ kCM_BUTTON
Int_t GET_SUBMSG(Long_t val)
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:55
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:160
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition TCanvas.cxx:2437
virtual void ToggleToolTips()
Toggle tooltip display.
Definition TCanvas.cxx:2479
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition TCanvas.cxx:727
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition TCanvas.cxx:2446
void SetSupportGL(Bool_t support)
Definition TCanvas.h:224
TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj) override
Search for an object at pixel position px,py.
Definition TCanvas.h:180
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition TCanvas.cxx:1670
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition TCanvas.cxx:1828
void SetCanvasImp(TCanvasImp *i)
Definition TCanvas.h:201
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition TCanvas.cxx:1225
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition TCanvas.cxx:708
Bool_t GetShowEditor() const
Definition TCanvas.h:148
Bool_t GetAutoExec() const
Definition TCanvas.h:150
virtual void ToggleEditor()
Toggle editor.
Definition TCanvas.cxx:2468
Bool_t GetShowToolTips() const
Definition TCanvas.h:149
void SetName(const char *name="") override
Set canvas name. In case name is an empty string, a default name is set.
Definition TCanvas.cxx:2064
void Paint(Option_t *option="") override
Paint canvas.
Definition TCanvas.cxx:1545
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2504
Bool_t OpaqueMoving() const override
Definition TCanvas.h:177
void Flush()
Flush canvas buffers.
Definition TCanvas.cxx:1134
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition TCanvas.cxx:1537
Bool_t UseGL() const
Definition TCanvas.h:223
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition TCanvas.cxx:1764
virtual void ToggleToolBar()
Toggle toolbar.
Definition TCanvas.cxx:2457
Bool_t OpaqueResizing() const override
Definition TCanvas.h:178
Draw inheritance tree and their relations for a list of classes.
Definition TClassTree.h:21
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:2957
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Draw the ROOT Color Wheel.
Definition TColorWheel.h:23
virtual void Draw(Option_t *option="")
Paint the color wheel.
Atom_t fDataType
Int_t fDataLength
void * fData
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
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition TFile.h:54
virtual void SetContainer(TGFrame *f)
Definition TGCanvas.h:232
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:227
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
virtual Bool_t HandleCrossing(Event_t *)
Definition TGFrame.h:362
virtual Bool_t HandleButton(Event_t *)
Definition TGFrame.h:360
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual void SetEditable(Bool_t on=kTRUE)
Switch ON/OFF edit mode.
Definition TGFrame.cxx:933
virtual void Layout()
Layout the elements of the composite frame.
Definition TGFrame.cxx:1242
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1057
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:352
virtual Int_t MustCleanup() const
Definition TGFrame.h:397
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1149
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1189
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1007
virtual Bool_t HandleDoubleClick(Event_t *)
Definition TGFrame.h:361
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a composite frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:2728
virtual Bool_t HandleMotion(Event_t *)
Definition TGFrame.h:363
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1175
virtual Bool_t HandleKey(Event_t *)
Definition TGFrame.h:364
void DockContainer(Int_t del=kTRUE)
Dock container back to TGDockableFrame.
virtual void AddFrame(TGFrame *f, TGLayoutHints *hints)
Add frame to dockable frame container. Frame and hints are NOT adopted.
void SetWindowName(const char *name)
Set window name so it appear as title of the undock window.
void EnableHide(Bool_t onoff)
Enable hiding.
Bool_t IsUndocked() const
char * fFilename
Int_t fFileTypeIdx
const char ** fFileTypes
char * fIniDir
Bool_t fOverwrite
void SetIniDir(const char *inidir)
Set directory name.
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition TGFrame.cxx:428
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:261
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition TGFrame.cxx:578
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
UInt_t GetHeight() const
Definition TGFrame.h:249
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition TGFrame.cxx:614
void SetDNDTarget(Bool_t onoff)
Definition TGFrame.h:294
UInt_t GetWidth() const
Definition TGFrame.h:248
Atom_t * fDNDTypeList
Definition TGFrame.h:459
virtual void SendCloseMessage()
Send close message to self.
Definition TGFrame.cxx:1705
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition TGFrame.cxx:1817
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1762
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
Definition TGFrame.cxx:1840
const char * GetWindowName() const
Definition TGFrame.h:521
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1749
const TGPicture * SetIconPixmap(const char *iconName)
Set window icon pixmap by name.
Definition TGFrame.cxx:1777
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=0)
Add popup menu to menu bar.
Definition TGMenu.cxx:417
TGClient * fClient
Definition TGObject.h:37
Handle_t GetId() const
Definition TGObject.h:47
Handle_t fId
Definition TGObject.h:36
virtual void AddLabel(TGHotString *s, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu label to the menu.
Definition TGMenu.cxx:1094
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition TGMenu.cxx:1844
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:1151
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition TGMenu.cxx:1781
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1723
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition TGMenu.cxx:1806
virtual void Associate(const TGWindow *w)
Definition TGMenu.h:219
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1059
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:989
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.
Definition TGTab.h:62
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition TGTab.cxx:614
virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit=kTRUE)
Brings the composite frame with the index tabIndex to the front and generate the following event if t...
Definition TGTab.cxx:509
TGCompositeFrame * GetTabContainer(Int_t tabIndex) const
Return container of tab with index tabIndex.
Definition TGTab.cxx:565
virtual TGButton * AddButton(const TGWindow *w, ToolBarData_t *button, Int_t spacing=0)
Add button to toolbar.
Definition TGToolBar.cxx:91
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
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.
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:151
virtual Bool_t HandleExpose(Event_t *event)
Definition TGWindow.h:102
const TGWindow * fParent
Definition TGWindow.h:36
@ kEditEnable
Definition TGWindow.h:57
@ kEditDisable
Definition TGWindow.h:58
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:294
static TGuiBuilder * Instance()
return an instance of TGuiBuilder object
An abstract interface to image processing library.
Definition TImage.h:29
virtual void SetEditable(Bool_t=kTRUE)
Definition TImage.h:225
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:44
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition TList.cxx:578
static void DisplayMarkerTypes()
Display the table of markers with their numbers.
Definition TMarker.cxx:85
Mother of all ROOT objects.
Definition TObject.h:37
virtual void Inspect() const
Dump contents of this object in a graphics canvas.
Definition TObject.cxx:466
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:359
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:130
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition TObject.cxx:388
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:445
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:403
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:197
The most important graphics class in the ROOT system.
Definition TPad.h:26
Double_t GetAspectRatio() const override
Definition TPad.h:218
void Update() override
Update pad.
Definition TPad.cxx:2855
void Modified(Bool_t flag=1) override
Definition TPad.h:414
Bool_t HasFixedAspectRatio() const override
Definition TPad.h:264
virtual void SetGLDevice(Int_t dev)
Definition TPad.h:358
void SaveAs(const char *filename="", Option_t *option="") const override
Save Pad contents in a file in one of various formats.
Definition TPad.cxx:5635
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition TPad.cxx:603
void Print(const char *filename="") const override
Save Pad contents in a file in one of various formats.
Definition TPad.cxx:4692
Long_t ExecPlugin(int nargs, const T &... params)
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:866
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition TROOT.cxx:2917
TGTab * GetTabLeft() const
void StartEmbedding(Int_t pos=kRight, Int_t subpos=-1) override
Start embedding external frame in the tab "pos" and tab element "subpos".
void StopEmbedding(const char *name=nullptr) override
TGFrame * GetActFrame() const
TGTab * GetTabRight() const
TGToolBar * fToolBar
Definition TRootCanvas.h:70
void Close()
Called via TCanvasImp interface by TCanvas.
UInt_t GetCwidth() const
Return width of canvas container.
void AdjustSize()
Keep the same canvas size while docking/undocking toolbar.
Bool_t HasToolTips() const
Returns kTRUE if the tooltips are enabled.
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other command generated by the user.
Bool_t HasMenuBar() const
Returns kTRUE if the menu bar is shown.
Bool_t fAutoFit
Definition TRootCanvas.h:87
Bool_t HandleDNDDrop(TDNDData *data)
Handle drop events.
TGPopupMenu * fEditMenu
Definition TRootCanvas.h:52
friend class TRootContainer
Definition TRootCanvas.h:44
void CreateEditor()
Create embedded editor.
void Iconify()
Bool_t HandleContainerKey(Event_t *ev)
Handle keyboard events in the canvas container.
Bool_t HasEditor() const
Returns kTRUE if the editor is shown.
virtual ~TRootCanvas()
Delete ROOT basic canvas.
TGLayoutHints * fMainFrameLayout
Definition TRootCanvas.h:72
void SetCanvasSize(UInt_t w, UInt_t h)
Set size of canvas container. Units in pixels.
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
Definition TRootCanvas.h:79
void SetWindowSize(UInt_t w, UInt_t h)
Set size of canvas (units in pixels).
TGHorizontal3DLine * fHorizontal1
Definition TRootCanvas.h:75
Bool_t HasToolBar() const
Returns kTRUE if the tool bar is shown.
void CloseWindow()
In case window is closed via WM we get here.
Int_t InitWindow()
Called by TCanvas ctor to get window indetifier.
Atom_t HandleDNDEnter(Atom_t *typelist)
Handle drag enter events.
TGLayoutHints * fEditorLayout
Definition TRootCanvas.h:67
TGPopupMenu * fToolsMenu
Definition TRootCanvas.h:57
void ShowEditor(Bool_t show=kTRUE)
Show or hide side frame.
TGLayoutHints * fMenuBarItemLayout
Definition TRootCanvas.h:60
Int_t fCanvasID
Definition TRootCanvas.h:86
const TGPicture * fIconPic
Definition TRootCanvas.h:81
void PrintCanvas()
Print the canvas.
TRootCanvas(const TRootCanvas &)=delete
void ShowStatusBar(Bool_t show=kTRUE)
Show or hide statusbar.
Atom_t HandleDNDPosition(Int_t x, Int_t y, Atom_t action, Int_t xroot, Int_t yroot)
Handle dragging position events.
void SetWindowTitle(const char *newTitle)
Change title on window.
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
Definition TRootCanvas.h:71
TGPopupMenu * fViewWithMenu
Definition TRootCanvas.h:55
TGPopupMenu * fEditClearMenu
Definition TRootCanvas.h:53
TRootContainer * fCanvasContainer
Definition TRootCanvas.h:48
Bool_t HasStatusBar() const
Returns kTRUE if the status bar is shown.
Bool_t fEmbedded
Definition TRootCanvas.h:85
Bool_t HandleContainerDoubleClick(Event_t *ev)
Handle mouse button double click events in the canvas container.
TGLayoutHints * fHorizontal1Layout
Definition TRootCanvas.h:78
TGVertical3DLine * fVertical2
Definition TRootCanvas.h:74
TGLayoutHints * fMenuBarLayout
Definition TRootCanvas.h:59
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
Definition TRootCanvas.h:47
void ShowMenuBar(Bool_t show=kTRUE)
Show or hide menubar.
void ShowToolBar(Bool_t show=kTRUE)
Show or hide toolbar.
TGLayoutHints * fMenuBarHelpLayout
Definition TRootCanvas.h:61
TGPopupMenu * fViewMenu
Definition TRootCanvas.h:54
TGStatusBar * fStatusBar
Definition TRootCanvas.h:63
TGPopupMenu * fOptionMenu
Definition TRootCanvas.h:56
void RaiseWindow()
Put canvas window on top of the window stack.
TGLayoutHints * fDockLayout
Definition TRootCanvas.h:80
void SetWindowPosition(Int_t x, Int_t y)
Set canvas position (units in pixels).
void ShowToolTips(Bool_t show=kTRUE)
Enable or disable tooltip info.
Bool_t HandleDNDLeave()
Handle drag leave events.
TGPopupMenu * fHelpMenu
Definition TRootCanvas.h:58
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
Definition TRootCanvas.h:76
UInt_t GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Gets the size and position of the window containing the canvas.
Bool_t HandleContainerConfigure(Event_t *ev)
Handle configure (i.e. resize) event.
TGCompositeFrame * fMainFrame
Definition TRootCanvas.h:68
TGLayoutHints * fVertical2Layout
Definition TRootCanvas.h:77
TVirtualPadEditor * fEditor
Definition TRootCanvas.h:84
TGMenuBar * fMenuBar
Definition TRootCanvas.h:49
Bool_t HandleContainerExpose(Event_t *ev)
Handle expose events.
void SetStatusText(const char *txt=0, Int_t partidx=0)
Set text in status bar.
TGLayoutHints * fCanvasLayout
Definition TRootCanvas.h:62
TGLayoutHints * fToolBarLayout
Definition TRootCanvas.h:69
TGCompositeFrame * fEditorFrame
Definition TRootCanvas.h:66
TGToolTip * fToolTip
Definition TRootCanvas.h:82
TGPopupMenu * fFileMenu
Definition TRootCanvas.h:50
TGPopupMenu * fFileSaveMenu
Definition TRootCanvas.h:51
void ReallyDelete()
Really delete the canvas and this GUI.
Int_t fButton
Definition TRootCanvas.h:88
TGLayoutHints * fStatusBarLayout
Definition TRootCanvas.h:64
TGVertical3DLine * fVertical1
Definition TRootCanvas.h:73
void SetText(const char *helpText)
Set help text from helpText buffer in TGTextView.
void Popup()
Show help dialog.
Basic string class.
Definition TString.h:136
Ssiz_t Length() const
Definition TString.h:410
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2197
const char * Data() const
Definition TString.h:369
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:692
@ kLeading
Definition TString.h:267
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:615
Bool_t IsNull() const
Definition TString.h:407
TString & Remove(Ssiz_t pos)
Definition TString.h:673
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:2331
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:624
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:639
Int_t GetOptStat() const
Definition TStyle.h:236
void SetOptTitle(Int_t tit=1)
Definition TStyle.h:318
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:1589
Int_t GetOptTitle() const
Definition TStyle.h:237
Int_t GetOptFit() const
Definition TStyle.h:235
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:1541
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:654
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1853
virtual FILE * TempFileName(TString &base, const char *dir=nullptr)
Create a secure temporary file by appending a unique 6 letter string to base.
Definition TSystem.cxx:1495
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:861
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:438
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:870
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:417
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1379
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition TSystem.cxx:1480
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:256
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.
virtual TCanvas * GetCanvas() const =0
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.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual TCanvas * GetCanvas() const =0
int main()
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:713
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
const char * fPixmap
Definition TGToolBar.h:33
auto * m
Definition textangle.C:8