Logo ROOT   6.12/07
Reference Guide
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 "TPadPainter.h"
38 #include "TBrowser.h"
39 #include "TClassTree.h"
40 #include "TMarker.h"
41 #include "TStyle.h"
42 #include "TColorWheel.h"
43 #include "TVirtualX.h"
44 #include "TApplication.h"
45 #include "TFile.h"
46 #include "TInterpreter.h"
47 #include "TEnv.h"
48 #include "TMath.h"
49 #include "Riostream.h"
50 #include "TGDockableFrame.h"
51 
52 #include "TG3DLine.h"
53 #include "TGToolBar.h"
54 #include "TGToolTip.h"
55 #include "TVirtualPadEditor.h"
56 #include "TRootControlBar.h"
57 #include "TGLabel.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
94 
103 
114 
126 
133 
141 
159 
160 };
161 
162 static const char *gOpenTypes[] = { "ROOT files", "*.root",
163  "All files", "*",
164  0, 0 };
165 
166 static const char *gSaveAsTypes[] = { "PDF", "*.pdf",
167  "PostScript", "*.ps",
168  "Encapsulated PostScript", "*.eps",
169  "SVG", "*.svg",
170  "TeX", "*.tex",
171  "GIF", "*.gif",
172  "ROOT macros", "*.C",
173  "ROOT files", "*.root",
174  "XML", "*.xml",
175  "PNG", "*.png",
176  "XPM", "*.xpm",
177  "JPEG", "*.jpg",
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 
230 class TRootContainer : public TGCompositeFrame {
231 private:
232  TRootCanvas *fCanvas; // pointer back to canvas imp
233 public:
234  TRootContainer(TRootCanvas *c, Window_t id, const TGWindow *parent);
235 
238  { return fCanvas->HandleContainerDoubleClick(ev); }
241  return fCanvas->HandleContainerConfigure(ev); }
243  { return fCanvas->HandleContainerKey(ev); }
245  { return fCanvas->HandleContainerMotion(ev); }
247  { return fCanvas->HandleContainerExpose(ev); }
249  { return fCanvas->HandleContainerCrossing(ev); }
250  void SavePrimitive(std::ostream &out, Option_t * = "");
251  void SetEditable(Bool_t) { }
252 };
253 
254 ////////////////////////////////////////////////////////////////////////////////
255 /// Create a canvas container.
256 
257 TRootContainer::TRootContainer(TRootCanvas *c, Window_t id, const TGWindow *p)
258  : TGCompositeFrame(gClient, id, p)
259 {
260  fCanvas = c;
261 
262  gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
265 
268  fEditDisabled = kEditDisable;
269 }
270 
271 ////////////////////////////////////////////////////////////////////////////////
272 /// Directly handle scroll mouse buttons (4 and 5), only pass buttons
273 /// 1, 2 and 3 on to the TCanvas.
274 
275 Bool_t TRootContainer::HandleButton(Event_t *event)
276 {
277  TGViewPort *vp = (TGViewPort*)fParent;
278  UInt_t page = vp->GetHeight()/4;
279  Int_t newpos;
280 
281  gVirtualX->SetInputFocus(GetMainFrame()->GetId());
282 
283  if (event->fCode == kButton4) {
284  //scroll up
285  newpos = fCanvas->fCanvasWindow->GetVsbPosition() - page;
286  if (newpos < 0) newpos = 0;
287  fCanvas->fCanvasWindow->SetVsbPosition(newpos);
288 // return kTRUE;
289  }
290  if (event->fCode == kButton5) {
291  // scroll down
292  newpos = fCanvas->fCanvasWindow->GetVsbPosition() + page;
293  fCanvas->fCanvasWindow->SetVsbPosition(newpos);
294 // return kTRUE;
295  }
296  return fCanvas->HandleContainerButton(event);
297 }
298 
300 
301 ////////////////////////////////////////////////////////////////////////////////
302 /// Create a basic ROOT canvas.
303 
304 TRootCanvas::TRootCanvas(TCanvas *c, const char *name, UInt_t width, UInt_t height)
305  : TGMainFrame(gClient->GetRoot(), width, height), TCanvasImp(c)
306 {
307  CreateCanvas(name);
308 
311 
312  Resize(width, height);
313 }
314 
315 ////////////////////////////////////////////////////////////////////////////////
316 /// Create a basic ROOT canvas.
317 
318 TRootCanvas::TRootCanvas(TCanvas *c, const char *name, Int_t x, Int_t y, UInt_t width, UInt_t height)
319  : TGMainFrame(gClient->GetRoot(), width, height), TCanvasImp(c)
320 {
321  CreateCanvas(name);
322 
325 
326  MoveResize(x, y, width, height);
327  SetWMPosition(x, y);
328 }
329 
330 ////////////////////////////////////////////////////////////////////////////////
331 /// Create the actual canvas.
332 
334 {
335  fButton = 0;
336  fAutoFit = kTRUE; // check also menu entry
337  fEditor = 0;
338  fEmbedded = kFALSE;
339 
340  // Create menus
342  fFileSaveMenu->AddEntry(Form("%s.&ps", name), kFileSaveAsPS);
343  fFileSaveMenu->AddEntry(Form("%s.&eps", name), kFileSaveAsEPS);
344  fFileSaveMenu->AddEntry(Form("%s.p&df", name), kFileSaveAsPDF);
345  fFileSaveMenu->AddEntry(Form("%s.&tex", name), kFileSaveAsTEX);
346  fFileSaveMenu->AddEntry(Form("%s.&gif", name), kFileSaveAsGIF);
347 
348  static Int_t img = 0;
349 
350  if (!img) {
351  Int_t sav = gErrorIgnoreLevel;
353  TImage* itmp = TImage::Create();
354  img = itmp ? 1 : -1;
355  if (itmp) {
356  delete itmp;
357  itmp=NULL;
358  }
359  gErrorIgnoreLevel = sav;
360  }
361  if (img > 0) {
362  fFileSaveMenu->AddEntry(Form("%s.&jpg",name), kFileSaveAsJPG);
363  fFileSaveMenu->AddEntry(Form("%s.&png",name), kFileSaveAsPNG);
364  }
365 
366  fFileSaveMenu->AddEntry(Form("%s.&C", name), kFileSaveAsC);
367  fFileSaveMenu->AddEntry(Form("%s.&root",name), kFileSaveAsRoot);
368 
370  fFileMenu->AddEntry("&New Canvas", kFileNewCanvas);
371  fFileMenu->AddEntry("&Open...", kFileOpen);
372  fFileMenu->AddEntry("&Close Canvas", kFileCloseCanvas);
374  fFileMenu->AddPopup("&Save", fFileSaveMenu);
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);
392  fEditMenu->AddPopup("C&lear", fEditClearMenu);
394  fEditMenu->AddEntry("&Undo", kEditUndo);
395  fEditMenu->AddEntry("&Redo", kEditRedo);
396 
402 
404  fViewWithMenu->AddEntry("&X3D", kViewX3D);
405  fViewWithMenu->AddEntry("&OpenGL", kViewOpenGL);
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);
472  fFileSaveMenu->Associate(this);
473  fEditMenu->Associate(this);
474  fEditClearMenu->Associate(this);
475  fViewMenu->Associate(this);
476  fViewWithMenu->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 
497  fHorizontal1 = new TGHorizontal3DLine(this);
500 
501  // Create toolbar dock
502  fToolDock = new TGDockableFrame(this);
506 
507  // will alocate it later
508  fToolBar = 0;
509  fVertical1 = 0;
510  fVertical2 = 0;
511  fVertical1Layout = 0;
512  fVertical2Layout = 0;
513 
514  fToolBarSep = new TGHorizontal3DLine(this);
517 
518  fMainFrame = new TGCompositeFrame(this, GetWidth() + 4, GetHeight() + 4,
521 
522  // Create editor frame that will host the pad editor
525  fMainFrame->AddFrame(fEditorFrame, fEditorLayout);
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) {
552  fCanvasID = gGLManager->InitGLWindow((ULong_t)fCanvasWindow->GetViewPort()->GetId());
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);
587  fStatusBar->SetParts(parts, 4);
588 
590 
592 
593  // Misc
594  SetWindowName(name);
595  SetIconName(name);
596  fIconPic = SetIconPixmap("macro_s.xpm");
597  SetClassHints("ROOT", "Canvas");
598 
600  MapSubwindows();
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 
704  fCanvas->SetCanvasImp(0);
705  fCanvas->Clear();
706  fCanvas->SetName("");
707  if (gPad && gPad->GetCanvas() == fCanvas)
708  gPad = 0;
709  delete this;
710 }
711 
712 ////////////////////////////////////////////////////////////////////////////////
713 /// In case window is closed via WM we get here.
714 
716 {
717  DeleteWindow();
718 }
719 
720 ////////////////////////////////////////////////////////////////////////////////
721 /// Return width of canvas container.
722 
724 {
725  return fCanvasContainer->GetWidth();
726 }
727 
728 ////////////////////////////////////////////////////////////////////////////////
729 /// Return height of canvas container.
730 
732 {
733  return fCanvasContainer->GetHeight();
734 }
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 
744  Window_t childdum;
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 
754 void TRootCanvas::SetStatusText(const char *txt, Int_t partidx)
755 {
756  fStatusBar->SetText(txt, partidx);
757 }
758 
759 ////////////////////////////////////////////////////////////////////////////////
760 /// Handle menu and other command generated by the user.
761 
763 {
764  TRootHelpDialog *hd;
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(".");
837  TGFileInfo fi;
838  fi.fFileTypes = gOpenTypes;
839  fi.fIniDir = StrDup(dir);
840  new TGFileDialog(fClient->GetDefaultRoot(), this, kFDOpen,&fi);
841  if (!fi.fFilename) return kTRUE;
842  dir = fi.fIniDir;
843  new TFile(fi.fFilename, "update");
844  }
845  break;
846  case kFileSaveAs:
847  {
848  TString workdir = gSystem->WorkingDirectory();
849  static TString dir(".");
850  static Int_t typeidx = 0;
851  static Bool_t overwr = kFALSE;
852  TGFileInfo fi;
853  TString defaultType = gEnv->GetValue("Canvas.SaveAsDefaultType", ".pdf");
854  if (typeidx == 0) {
855  for (int i=1;gSaveAsTypes[i];i+=2) {
856  TString ftype = gSaveAsTypes[i];
857  if (ftype.EndsWith(defaultType.Data())) {
858  typeidx = i-1;
859  break;
860  }
861  }
862  }
864  fi.fIniDir = StrDup(dir);
865  fi.fFileTypeIdx = typeidx;
866  fi.fOverwrite = overwr;
867  new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi);
868  gSystem->ChangeDirectory(workdir.Data());
869  if (!fi.fFilename) return kTRUE;
870  Bool_t appendedType = kFALSE;
871  TString fn = fi.fFilename;
872  TString ft = fi.fFileTypes[fi.fFileTypeIdx+1];
873  dir = fi.fIniDir;
874  typeidx = fi.fFileTypeIdx;
875  overwr = fi.fOverwrite;
876 again:
877  if (fn.EndsWith(".root") ||
878  fn.EndsWith(".ps") ||
879  fn.EndsWith(".eps") ||
880  fn.EndsWith(".pdf") ||
881  fn.EndsWith(".svg") ||
882  fn.EndsWith(".tex") ||
883  fn.EndsWith(".gif") ||
884  fn.EndsWith(".xml") ||
885  fn.EndsWith(".xpm") ||
886  fn.EndsWith(".jpg") ||
887  fn.EndsWith(".png") ||
888  fn.EndsWith(".xcf") ||
889  fn.EndsWith(".tiff")) {
890  fCanvas->SaveAs(fn);
891  } else if (fn.EndsWith(".C"))
892  fCanvas->SaveSource(fn);
893  else {
894  if (!appendedType) {
895  if (ft.Index(".") != kNPOS) {
896  fn += ft(ft.Index("."), ft.Length());
897  appendedType = kTRUE;
898  goto again;
899  }
900  }
901  Warning("ProcessMessage", "file %s cannot be saved with this extension", fi.fFilename);
902  }
903  for (int i=1;gSaveAsTypes[i];i+=2) {
904  TString ftype = gSaveAsTypes[i];
905  ftype.ReplaceAll("*.", ".");
906  if (fn.EndsWith(ftype.Data())) {
907  typeidx = i-1;
908  break;
909  }
910  }
911  }
912  break;
913  case kFileSaveAsRoot:
914  fCanvas->SaveAs(".root");
915  break;
916  case kFileSaveAsC:
917  fCanvas->SaveSource();
918  break;
919  case kFileSaveAsPS:
920  fCanvas->SaveAs();
921  break;
922  case kFileSaveAsEPS:
923  fCanvas->SaveAs(".eps");
924  break;
925  case kFileSaveAsPDF:
926  fCanvas->SaveAs(".pdf");
927  break;
928  case kFileSaveAsGIF:
929  fCanvas->SaveAs(".gif");
930  break;
931  case kFileSaveAsJPG:
932  fCanvas->SaveAs(".jpg");
933  break;
934  case kFileSaveAsPNG:
935  fCanvas->SaveAs(".png");
936  break;
937  case kFileSaveAsTEX:
938  fCanvas->SaveAs(".tex");
939  break;
940  case kFilePrint:
941  PrintCanvas();
942  break;
943  case kFileCloseCanvas:
945  break;
946  case kFileQuit:
947  if (!gApplication->ReturnFromRun()) {
951  }
954  if (TClass::GetClass("TStyleManager"))
955  gROOT->ProcessLine("TStyleManager::Terminate()");
957  break;
958 
959  // Handle Edit menu items...
960  case kEditStyle:
961  if (!TClass::GetClass("TStyleManager"))
962  gSystem->Load("libGed");
963  gROOT->ProcessLine("TStyleManager::Show()");
964  break;
965  case kEditCut:
966  // still noop
967  break;
968  case kEditCopy:
969  // still noop
970  break;
971  case kEditPaste:
972  // still noop
973  break;
974  case kEditUndo:
975  // noop
976  break;
977  case kEditRedo:
978  // noop
979  break;
980  case kEditClearPad:
981  gPad->Clear();
982  gPad->Modified();
983  gPad->Update();
984  break;
985  case kEditClearCanvas:
986  fCanvas->Clear();
987  fCanvas->Modified();
988  fCanvas->Update();
989  break;
990 
991  // Handle View menu items...
992  case kViewEditor:
994  break;
995  case kViewToolbar:
997  break;
998  case kViewEventStatus:
1000  break;
1001  case kViewToolTips:
1003  break;
1004  case kViewColors:
1005  {
1006  TVirtualPad *padsav = gPad->GetCanvas();
1007  //This was the code with the old color table
1008  // TCanvas *m = new TCanvas("colors","Color Table");
1009  // TPad::DrawColorTable();
1010  // m->Update();
1011  TColorWheel *wheel = new TColorWheel();
1012  wheel->Draw();
1013 
1014  //tp: with Cocoa, window is visible (and repainted)
1015  //before wheel->Draw() was called and you can see "empty"
1016  //canvas.
1017  gPad->Update();
1018  //
1019  if (padsav) padsav->cd();
1020  }
1021  break;
1022  case kViewFonts:
1023  // noop
1024  break;
1025  case kViewMarkers:
1026  {
1027  TVirtualPad *padsav = gPad->GetCanvas();
1028  TCanvas *m = new TCanvas("markers","Marker Types",600,200);
1030  m->Update();
1031  if (padsav) padsav->cd();
1032  }
1033  break;
1034  case kViewIconify:
1035  Iconify();
1036  break;
1037  case kViewX3D:
1038  gPad->GetViewer3D("x3d");
1039  break;
1040  case kViewOpenGL:
1041  gPad->GetViewer3D("ogl");
1042  break;
1043 
1044  // Handle Option menu items...
1045  case kOptionAutoExec:
1047  if (fCanvas->GetAutoExec()) {
1049  } else {
1051  }
1052  break;
1053  case kOptionAutoResize:
1054  {
1055  fAutoFit = fAutoFit ? kFALSE : kTRUE;
1056  int opt = fCanvasContainer->GetOptions();
1057  if (fAutoFit) {
1058  opt &= ~kFixedSize;
1060  } else {
1061  opt |= kFixedSize;
1063  }
1064  fCanvasContainer->ChangeOptions(opt);
1065  // in case of autofit this will generate a configure
1066  // event for the container and this will force the
1067  // update of the TCanvas
1068  //Layout();
1069  }
1070  Layout();
1071  break;
1072  case kOptionResizeCanvas:
1073  FitCanvas();
1074  break;
1075  case kOptionMoveOpaque:
1076  if (fCanvas->OpaqueMoving()) {
1077  fCanvas->MoveOpaque(0);
1079  } else {
1080  fCanvas->MoveOpaque(1);
1082  }
1083  break;
1084  case kOptionResizeOpaque:
1085  if (fCanvas->OpaqueResizing()) {
1086  fCanvas->ResizeOpaque(0);
1088  } else {
1089  fCanvas->ResizeOpaque(1);
1091  }
1092  break;
1093  case kOptionInterrupt:
1094  gROOT->SetInterrupt();
1095  break;
1096  case kOptionRefresh:
1097  fCanvas->Paint();
1098  fCanvas->Update();
1099  break;
1100  case kOptionStatistics:
1101  if (gStyle->GetOptStat()) {
1102  gStyle->SetOptStat(0);
1103  delete gPad->FindObject("stats");
1105  } else {
1106  gStyle->SetOptStat(1);
1108  }
1109  gPad->Modified();
1110  fCanvas->Update();
1111  break;
1112  case kOptionHistTitle:
1113  if (gStyle->GetOptTitle()) {
1114  gStyle->SetOptTitle(0);
1115  delete gPad->FindObject("title");
1117  } else {
1118  gStyle->SetOptTitle(1);
1120  }
1121  gPad->Modified();
1122  fCanvas->Update();
1123  break;
1124  case kOptionFitParams:
1125  if (gStyle->GetOptFit()) {
1126  gStyle->SetOptFit(0);
1128  } else {
1129  gStyle->SetOptFit(1);
1131  }
1132  gPad->Modified();
1133  fCanvas->Update();
1134  break;
1135  case kOptionCanEdit:
1136  if (gROOT->GetEditHistograms()) {
1137  gROOT->SetEditHistograms(kFALSE);
1139  } else {
1140  gROOT->SetEditHistograms(kTRUE);
1142  }
1143  break;
1144 
1145  // Handle Tools menu items...
1146  case kInspectRoot:
1147  fCanvas->cd();
1148  gROOT->Inspect();
1149  fCanvas->Update();
1150  break;
1151  case kToolsBrowser:
1152  new TBrowser("browser");
1153  break;
1154  case kToolsBuilder:
1156  break;
1157  case kToolsRecorder:
1158  gROOT->ProcessLine("new TGRecorder()");
1159  break;
1160 
1161  // Handle Tools menu items...
1162  case kClassesTree:
1163  {
1164  TString cdef;
1165  lc = (TList*)gROOT->GetListOfCanvases();
1166  if (lc->FindObject("ClassTree")) {
1167  cdef = TString::Format("ClassTree_%d", lc->GetSize()+1);
1168  } else {
1169  cdef = "ClassTree";
1170  }
1171  new TClassTree(cdef.Data(), "TObject");
1172  fCanvas->Update();
1173  }
1174  break;
1175 
1176  case kFitPanel:
1177  {
1178  // use plugin manager to create instance of TFitEditor
1179  TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
1180  if (handler && handler->LoadPlugin() != -1) {
1181  if (handler->ExecPlugin(2, fCanvas, 0) == 0)
1182  Error("FitPanel", "Unable to crate the FitPanel");
1183  }
1184  else
1185  Error("FitPanel", "Unable to find the FitPanel plug-in");
1186  }
1187  break;
1188 
1189  // Handle Help menu items...
1190  case kHelpAbout:
1191  {
1192 #ifdef R__UNIX
1193  TString rootx = TROOT::GetBinDir() + "/root -a &";
1194  gSystem->Exec(rootx);
1195 #else
1196 #ifdef WIN32
1198 #else
1199 
1200  char str[32];
1201  sprintf(str, "About ROOT %s...", gROOT->GetVersion());
1202  hd = new TRootHelpDialog(this, str, 600, 400);
1203  hd->SetText(gHelpAbout);
1204  hd->Popup();
1205 #endif
1206 #endif
1207  }
1208  break;
1209  case kHelpOnCanvas:
1210  hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1211  hd->SetText(gHelpCanvas);
1212  hd->Popup();
1213  break;
1214  case kHelpOnMenus:
1215  hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1217  hd->Popup();
1218  break;
1219  case kHelpOnGraphicsEd:
1220  hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1222  hd->Popup();
1223  break;
1224  case kHelpOnBrowser:
1225  hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1226  hd->SetText(gHelpBrowser);
1227  hd->Popup();
1228  break;
1229  case kHelpOnObjects:
1230  hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
1231  hd->SetText(gHelpObjects);
1232  hd->Popup();
1233  break;
1234  case kHelpOnPS:
1235  hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
1236  hd->SetText(gHelpPostscript);
1237  hd->Popup();
1238  break;
1239  }
1240  default:
1241  break;
1242  }
1243  default:
1244  break;
1245  }
1246  return kTRUE;
1247 }
1248 
1249 ////////////////////////////////////////////////////////////////////////////////
1250 /// Called by TCanvas ctor to get window indetifier.
1251 
1253 {
1254  if (fCanvas->OpaqueMoving())
1256  if (fCanvas->OpaqueResizing())
1258 
1259  return fCanvasID;
1260 }
1261 
1262 ////////////////////////////////////////////////////////////////////////////////
1263 /// Set size of canvas container. Units in pixels.
1264 
1266 {
1267  // turn off autofit, we want to stay at the given size
1268  fAutoFit = kFALSE;
1270  int opt = fCanvasContainer->GetOptions();
1271  opt |= kFixedSize; // turn on fixed size mode
1272  fCanvasContainer->ChangeOptions(opt);
1273  fCanvasContainer->SetWidth(w);
1274  fCanvasContainer->SetHeight(h);
1275  Layout(); // force layout (will update container to given size)
1276  fCanvas->Resize();
1277  fCanvas->Update();
1278 }
1279 
1280 ////////////////////////////////////////////////////////////////////////////////
1281 /// Set canvas position (units in pixels).
1282 
1284 {
1285  Move(x, y);
1286 }
1287 
1288 ////////////////////////////////////////////////////////////////////////////////
1289 /// Set size of canvas (units in pixels).
1290 
1292 {
1293  Resize(w, h);
1294 
1295  // Make sure the change of size is really done.
1296  gVirtualX->Update(1);
1297  if (!gThreadXAR) {
1298  gSystem->Sleep(100);
1300  gSystem->Sleep(10);
1302  }
1303 }
1304 
1305 ////////////////////////////////////////////////////////////////////////////////
1306 /// Put canvas window on top of the window stack.
1307 
1309 {
1310  gVirtualX->RaiseWindow(GetId());
1311 }
1312 
1313 ////////////////////////////////////////////////////////////////////////////////
1314 /// Change title on window.
1315 
1316 void TRootCanvas::SetWindowTitle(const char *title)
1317 {
1318  SetWindowName(title);
1319  SetIconName(title);
1320  fToolDock->SetWindowName(Form("ToolBar: %s", title));
1321 }
1322 
1323 ////////////////////////////////////////////////////////////////////////////////
1324 /// Fit canvas container to current window size.
1325 
1327 {
1328  if (!fAutoFit) {
1329  int opt = fCanvasContainer->GetOptions();
1330  int oopt = opt;
1331  opt &= ~kFixedSize; // turn off fixed size mode
1332  fCanvasContainer->ChangeOptions(opt);
1333  Layout(); // force layout
1334  fCanvas->Resize();
1335  fCanvas->Update();
1336  fCanvasContainer->ChangeOptions(oopt);
1337  }
1338 }
1339 
1340 ////////////////////////////////////////////////////////////////////////////////
1341 /// Print the canvas.
1342 
1344 {
1345  Int_t ret = 0;
1346  Bool_t pname = kTRUE;
1347  char *printer, *printCmd;
1348  static TString sprinter, sprintCmd;
1349 
1350  if (sprinter == "")
1351  printer = StrDup(gEnv->GetValue("Print.Printer", ""));
1352  else
1353  printer = StrDup(sprinter);
1354  if (sprintCmd == "")
1355 #ifndef WIN32
1356  printCmd = StrDup(gEnv->GetValue("Print.Command", ""));
1357 #else
1358  printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p"));
1359 #endif
1360  else
1361  printCmd = StrDup(sprintCmd);
1362 
1363  new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
1364  &printer, &printCmd, &ret);
1365  if (ret) {
1366  sprinter = printer;
1367  sprintCmd = printCmd;
1368 
1369  if (sprinter == "")
1370  pname = kFALSE;
1371 
1372  TString fn = "rootprint";
1373  FILE *f = gSystem->TempFileName(fn, gEnv->GetValue("Print.Directory", gSystem->TempDirectory()));
1374  if (f) fclose(f);
1375  fn += TString::Format(".%s",gEnv->GetValue("Print.FileType", "pdf"));
1376  fCanvas->Print(fn);
1377 
1378  TString cmd = sprintCmd;
1379  if (cmd.Contains("%p"))
1380  cmd.ReplaceAll("%p", sprinter);
1381  else if (pname) {
1382  cmd += " "; cmd += sprinter; cmd += " ";
1383  }
1384 
1385  if (cmd.Contains("%f"))
1386  cmd.ReplaceAll("%f", fn);
1387  else {
1388  cmd += " "; cmd += fn; cmd += " ";
1389  }
1390 
1391  gSystem->Exec(cmd);
1392 #ifndef WIN32
1393  gSystem->Unlink(fn);
1394 #endif
1395  }
1396  delete [] printer;
1397  delete [] printCmd;
1398 }
1399 
1400 ////////////////////////////////////////////////////////////////////////////////
1401 /// Display a tooltip with infos about the primitive below the cursor.
1402 
1403 void TRootCanvas::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
1404 {
1405  fToolTip->Hide();
1406  if (!fCanvas->GetShowToolTips() || selected == 0 ||
1407  event != kMouseMotion || fButton != 0)
1408  return;
1409  TString tipInfo;
1410  TString objInfo = selected->GetObjectInfo(px, py);
1411  if (objInfo.BeginsWith("-")) {
1412  // if the string begins with '-', display only the object info
1413  objInfo.Remove(TString::kLeading, '-');
1414  tipInfo = objInfo;
1415  }
1416  else {
1417  const char *title = selected->GetTitle();
1418  tipInfo += TString::Format("%s::%s", selected->ClassName(),
1419  selected->GetName());
1420  if (title && strlen(title))
1421  tipInfo += TString::Format("\n%s", selected->GetTitle());
1422  tipInfo += TString::Format("\n%d, %d", px, py);
1423  if (!objInfo.IsNull())
1424  tipInfo += TString::Format("\n%s", objInfo.Data());
1425  }
1426  fToolTip->SetText(tipInfo.Data());
1427  fToolTip->SetPosition(px+15, py+15);
1428  fToolTip->Reset();
1429 }
1430 
1431 ////////////////////////////////////////////////////////////////////////////////
1432 /// Show or hide menubar.
1433 
1435 {
1436  if (show) ShowFrame(fMenuBar);
1437  else HideFrame(fMenuBar);
1438 }
1439 
1440 ////////////////////////////////////////////////////////////////////////////////
1441 /// Show or hide statusbar.
1442 
1444 {
1446  UInt_t ch = fCanvas->GetWindowHeight();
1447 
1448  UInt_t h = GetHeight();
1449  UInt_t sh = fStatusBar->GetHeight()+2;
1450 
1451  if (show) {
1454  if (dh - ch >= sh) h = h + sh;
1455  else h = ch;
1456  } else {
1459  if (dh - ch < sh) h = ch;
1460  else h = h - sh;
1461  }
1462  Resize(GetWidth(), h);
1463 }
1464 
1465 ////////////////////////////////////////////////////////////////////////////////
1466 /// Show or hide side frame.
1467 
1469 {
1470  TVirtualPad *savedPad = 0;
1471  savedPad = (TVirtualPad *) gPad;
1472  gPad = Canvas();
1473 
1474  UInt_t w = GetWidth();
1476  UInt_t h = GetHeight();
1478 
1479  if (fParent && fParent != fClient->GetDefaultRoot()) {
1482  if (main && main->InheritsFrom("TRootBrowser")) {
1483  TRootBrowser *browser = (TRootBrowser *)main;
1484  if (!fEmbedded)
1485  browser->GetTabRight()->Connect("Selected(Int_t)", "TRootCanvas",
1486  this, "Activated(Int_t)");
1487  fEmbedded = kTRUE;
1488  if (show && (!fEditor || !((TGedEditor *)fEditor)->IsMapped())) {
1489  if (!browser->GetTabLeft()->GetTabTab("Pad Editor")) {
1490  if (browser->GetActFrame()) { //already in edit mode
1491  TTimer::SingleShot(200, "TRootCanvas", this, "ShowEditor(=kTRUE)");
1492  } else {
1494  if (!fEditor)
1496  else {
1497  ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot());
1498  ((TGedEditor *)fEditor)->MapWindow();
1499  }
1500  browser->StopEmbedding("Pad Editor");
1501  if (fEditor) {
1502  fEditor->SetGlobal(kFALSE);
1503  gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor);
1504  ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
1505  ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
1506  }
1507  }
1508  }
1509  else
1511  }
1512  if (show) browser->GetTabLeft()->SetTab("Pad Editor");
1513  }
1514  }
1515  else {
1516  if (show) {
1517  if (!fEditor) CreateEditor();
1519  if(gged && gged->GetCanvas() == fCanvas){
1520  gged->Hide();
1521  }
1524  h = h + s;
1525  }
1527  fEditor->Show();
1529  w = w + e;
1530  } else {
1533  h = h - s;
1534  }
1535  if (fEditor) fEditor->Hide();
1538  w = w - e;
1539  }
1540  Resize(w, h);
1541  }
1542  if (savedPad) gPad = savedPad;
1543 }
1544 
1545 ////////////////////////////////////////////////////////////////////////////////
1546 /// Create embedded editor.
1547 
1549 {
1552  gPad = Canvas();
1553  // next two lines are related to the old editor
1554  Int_t show = gEnv->GetValue("Canvas.ShowEditor", 0);
1555  gEnv->SetValue("Canvas.ShowEditor","true");
1560 
1561  // next line is related to the old editor
1562  if (show == 0) gEnv->SetValue("Canvas.ShowEditor","false");
1563 }
1564 
1565 ////////////////////////////////////////////////////////////////////////////////
1566 /// Show or hide toolbar.
1567 
1569 {
1570  if (show && !fToolBar) {
1571 
1572  fToolBar = new TGToolBar(fToolDock, 60, 20, kHorizontalFrame);
1574 
1575  Int_t spacing = 6, i;
1576  for (i = 0; gToolBarData[i].fPixmap; i++) {
1577  if (strlen(gToolBarData[i].fPixmap) == 0) {
1578  spacing = 6;
1579  continue;
1580  }
1581  fToolBar->AddButton(this, &gToolBarData[i], spacing);
1582  spacing = 0;
1583  }
1590 
1591  spacing = 6;
1592  for (i = 0; gToolBarData1[i].fPixmap; i++) {
1593  if (strlen(gToolBarData1[i].fPixmap) == 0) {
1594  spacing = 6;
1595  continue;
1596  }
1597  fToolBar->AddButton(this, &gToolBarData1[i], spacing);
1598  spacing = 0;
1599  }
1601  fToolDock->Layout();
1602  fToolDock->SetWindowName(Form("ToolBar: %s", GetWindowName()));
1603  fToolDock->Connect("Docked()", "TRootCanvas", this, "AdjustSize()");
1604  fToolDock->Connect("Undocked()", "TRootCanvas", this, "AdjustSize()");
1605  }
1606 
1607  if (!fToolBar) return;
1608 
1609  UInt_t h = GetHeight();
1610  UInt_t sh = fToolBarSep->GetHeight();
1611  UInt_t dh = fToolBar->GetHeight();
1612 
1613  if (show) {
1617  h = h + sh;
1618  }
1621  h = h + dh + sh;
1622  } else {
1623  if (fToolDock->IsUndocked()) {
1625  h = h + 2*sh;
1626  } else h = h - dh;
1627 
1631  h = h - sh;
1632  }
1634  h = h - sh;
1636  }
1637  Resize(GetWidth(), h);
1638 }
1639 
1640 ////////////////////////////////////////////////////////////////////////////////
1641 /// Enable or disable tooltip info.
1642 
1644 {
1645  if (show)
1647  else
1649 }
1650 
1651 ////////////////////////////////////////////////////////////////////////////////
1652 /// Returns kTRUE if the editor is shown.
1653 
1655 {
1657 }
1658 
1659 ////////////////////////////////////////////////////////////////////////////////
1660 /// Returns kTRUE if the menu bar is shown.
1661 
1663 {
1664  return (fMenuBar) && fMenuBar->IsMapped();
1665 }
1666 
1667 ////////////////////////////////////////////////////////////////////////////////
1668 /// Returns kTRUE if the status bar is shown.
1669 
1671 {
1672  return (fStatusBar) && fStatusBar->IsMapped();
1673 }
1674 
1675 ////////////////////////////////////////////////////////////////////////////////
1676 /// Returns kTRUE if the tool bar is shown.
1677 
1679 {
1680  return (fToolBar) && fToolBar->IsMapped();
1681 }
1682 
1683 ////////////////////////////////////////////////////////////////////////////////
1684 /// Returns kTRUE if the tooltips are enabled.
1685 
1687 {
1688  return (fCanvas) && fCanvas->GetShowToolTips();
1689 }
1690 
1691 ////////////////////////////////////////////////////////////////////////////////
1692 /// Keep the same canvas size while docking/undocking toolbar.
1693 
1695 {
1696  UInt_t h = GetHeight();
1697  UInt_t dh = fToolBar->GetHeight();
1698  UInt_t sh = fHorizontal1->GetHeight();
1699 
1700  if (fToolDock->IsUndocked()) {
1703  h = h - sh;
1704  }
1706  h = h - dh - sh;
1707  } else {
1710  h = h + sh;
1711  }
1713  h = h + dh + sh;
1714  }
1715  Resize(GetWidth(), h);
1716 }
1717 
1718 ////////////////////////////////////////////////////////////////////////////////
1719 /// Handle mouse button events in the canvas container.
1720 
1722 {
1723  Int_t button = event->fCode;
1724  Int_t x = event->fX;
1725  Int_t y = event->fY;
1726 
1727  if (event->fType == kButtonPress) {
1728  if (fToolTip && fCanvas->GetShowToolTips()) {
1729  fToolTip->Hide();
1730  gVirtualX->UpdateWindow(0);
1732  }
1733  fButton = button;
1734  if (button == kButton1) {
1735  if (event->fState & kKeyShiftMask)
1737  else
1739  }
1740  if (button == kButton2)
1742  if (button == kButton3) {
1744  fButton = 0; // button up is consumed by TContextMenu
1745  }
1746 
1747  } else if (event->fType == kButtonRelease) {
1748  if (button == kButton4)
1749  fCanvas->HandleInput(kWheelUp, x, y);
1750  if (button == kButton5)
1751  fCanvas->HandleInput(kWheelDown, x, y);
1752  if (button == kButton1)
1753  fCanvas->HandleInput(kButton1Up, x, y);
1754  if (button == kButton2)
1755  fCanvas->HandleInput(kButton2Up, x, y);
1756  if (button == kButton3)
1757  fCanvas->HandleInput(kButton3Up, x, y);
1758 
1759  fButton = 0;
1760  }
1761 
1762  return kTRUE;
1763 }
1764 
1765 ////////////////////////////////////////////////////////////////////////////////
1766 /// Handle mouse button double click events in the canvas container.
1767 
1769 {
1770  Int_t button = event->fCode;
1771  Int_t x = event->fX;
1772  Int_t y = event->fY;
1773 
1774  if (button == kButton1)
1776  if (button == kButton2)
1778  if (button == kButton3)
1780 
1781  return kTRUE;
1782 }
1783 
1784 ////////////////////////////////////////////////////////////////////////////////
1785 /// Handle configure (i.e. resize) event.
1786 
1788 {
1789  if (fAutoFit) {
1790  fCanvas->Resize();
1791  fCanvas->Update();
1792  }
1793 
1794  if (fCanvas->HasFixedAspectRatio()) {
1795  // get menu height
1796  static Int_t dh = 0;
1797  if (!dh)
1798  dh = GetHeight() - fCanvasContainer->GetHeight();
1799  UInt_t h = TMath::Nint(fCanvasContainer->GetWidth()/
1800  fCanvas->GetAspectRatio()) + dh;
1801  SetWindowSize(GetWidth(), h);
1802  }
1803  return kTRUE;
1804 }
1805 
1806 ////////////////////////////////////////////////////////////////////////////////
1807 /// Handle keyboard events in the canvas container.
1808 
1810 {
1811  static EGEventType previous_event = kOtherEvent;
1812  static UInt_t previous_keysym = 0;
1813 
1814  if (event->fType == kGKeyPress) {
1815  fButton = event->fCode;
1816  UInt_t keysym;
1817  char str[2];
1818  gVirtualX->LookupString(event, str, sizeof(str), keysym);
1819 
1820  if (str[0] == kESC){ // ESC sets the escape flag
1821  gROOT->SetEscape();
1822  fCanvas->HandleInput(kButton1Up, 0, 0);
1824  gPad->Modified();
1825  return kTRUE;
1826  }
1827  if (str[0] == 3) // ctrl-c sets the interrupt flag
1828  gROOT->SetInterrupt();
1829 
1830  // handle arrow keys
1831  if (keysym > 0x1011 && keysym < 0x1016) {
1832  Window_t dum1, dum2, wid;
1833  UInt_t mask = 0;
1834  Int_t mx, my, tx, ty;
1835  wid = gVirtualX->GetDefaultRootWindow();
1836  gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1837  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1838  fCanvasContainer->GetId(),
1839  mx, my, tx, ty, dum1);
1841  // handle case where we got consecutive same keypressed events coming
1842  // from auto-repeat on Windows (as it fires only successive keydown events)
1843  if ((previous_keysym == keysym) && (previous_event == kGKeyPress)) {
1844  switch (keysym) {
1845  case 0x1012: // left
1846  gVirtualX->Warp(--mx, my, wid); --tx;
1847  break;
1848  case 0x1013: // up
1849  gVirtualX->Warp(mx, --my, wid); --ty;
1850  break;
1851  case 0x1014: // right
1852  gVirtualX->Warp(++mx, my, wid); ++tx;
1853  break;
1854  case 0x1015: // down
1855  gVirtualX->Warp(mx, ++my, wid); ++ty;
1856  break;
1857  default:
1858  break;
1859  }
1861  }
1862  previous_keysym = keysym;
1863  }
1864  else {
1865  fCanvas->HandleInput(kKeyPress, str[0], keysym);
1866  }
1867  } else if (event->fType == kKeyRelease) {
1868  UInt_t keysym;
1869  char str[2];
1870  gVirtualX->LookupString(event, str, sizeof(str), keysym);
1871 
1872  if (keysym > 0x1011 && keysym < 0x1016) {
1873  Window_t dum1, dum2, wid;
1874  UInt_t mask = 0;
1875  Int_t mx, my, tx, ty;
1876  wid = gVirtualX->GetDefaultRootWindow();
1877  gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1878  switch (keysym) {
1879  case 0x1012: // left
1880  gVirtualX->Warp(--mx, my, wid);
1881  break;
1882  case 0x1013: // up
1883  gVirtualX->Warp(mx, --my, wid);
1884  break;
1885  case 0x1014: // right
1886  gVirtualX->Warp(++mx, my, wid);
1887  break;
1888  case 0x1015: // down
1889  gVirtualX->Warp(mx, ++my, wid);
1890  break;
1891  default:
1892  break;
1893  }
1894  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1895  fCanvasContainer->GetId(),
1896  mx, my, tx, ty, dum1);
1898  previous_keysym = keysym;
1899  }
1900  fButton = 0;
1901  }
1902  previous_event = event->fType;
1903  return kTRUE;
1904 }
1905 
1906 ////////////////////////////////////////////////////////////////////////////////
1907 /// Handle mouse motion event in the canvas container.
1908 
1910 {
1911  Int_t x = event->fX;
1912  Int_t y = event->fY;
1913 
1914  if (fButton == 0)
1916  if (fButton == kButton1) {
1917  if (event->fState & kKeyShiftMask)
1918  fCanvas->HandleInput(EEventType(8), x, y);
1919  else
1921  }
1922  if (fButton == kButton2)
1924 
1925  return kTRUE;
1926 }
1927 
1928 ////////////////////////////////////////////////////////////////////////////////
1929 /// Handle expose events.
1930 
1932 {
1933  if (event->fCount == 0) {
1934  fCanvas->Flush();
1935  }
1936 
1937  return kTRUE;
1938 }
1939 
1940 ////////////////////////////////////////////////////////////////////////////////
1941 /// Handle enter/leave events. Only leave is activated at the moment.
1942 
1944 {
1945  Int_t x = event->fX;
1946  Int_t y = event->fY;
1947 
1948  // pointer grabs create also an enter and leave event but with fCode
1949  // either kNotifyGrab or kNotifyUngrab, don't propagate these events
1950  if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
1952 
1953  return kTRUE;
1954 }
1955 
1956 ////////////////////////////////////////////////////////////////////////////////
1957 /// Handle drop events.
1958 
1960 {
1961  static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
1962  static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
1963 
1964  if (data->fDataType == rootObj) {
1965  TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
1966  buf.SetReadMode();
1967  TObject *obj = (TObject *)buf.ReadObjectAny(TObject::Class());
1968  if (!obj) return kTRUE;
1969  gPad->Clear();
1970  if (obj->InheritsFrom("TKey")) {
1971  TObject *object = (TObject *)gROOT->ProcessLine(Form("((TKey *)0x%lx)->ReadObj();", (ULong_t)obj));
1972  if (!object) return kTRUE;
1973  if (object->InheritsFrom("TGraph"))
1974  object->Draw("ALP");
1975  else if (object->InheritsFrom("TImage"))
1976  object->Draw("x");
1977  else if (object->IsA()->GetMethodAllAny("Draw"))
1978  object->Draw();
1979  }
1980  else if (obj->InheritsFrom("TGraph"))
1981  obj->Draw("ALP");
1982  else if (obj->IsA()->GetMethodAllAny("Draw"))
1983  obj->Draw();
1984  gPad->Modified();
1985  gPad->Update();
1986  return kTRUE;
1987  }
1988  else if (data->fDataType == uriObj) {
1989  TString sfname((char *)data->fData);
1990  if (sfname.Length() > 7) {
1991  sfname.ReplaceAll("\r\n", "");
1992  TUrl uri(sfname.Data());
1993  if (sfname.EndsWith(".bmp") ||
1994  sfname.EndsWith(".gif") ||
1995  sfname.EndsWith(".jpg") ||
1996  sfname.EndsWith(".png") ||
1997  sfname.EndsWith(".ps") ||
1998  sfname.EndsWith(".eps") ||
1999  sfname.EndsWith(".pdf") ||
2000  sfname.EndsWith(".tiff") ||
2001  sfname.EndsWith(".xpm")) {
2002  TImage *img = TImage::Open(uri.GetFile());
2003  if (img) {
2004  img->Draw("x");
2005  img->SetEditable(kTRUE);
2006  }
2007  }
2008  gPad->Modified();
2009  gPad->Update();
2010  }
2011  }
2012  return kFALSE;
2013 }
2014 
2015 ////////////////////////////////////////////////////////////////////////////////
2016 /// Handle dragging position events.
2017 
2019  Int_t /*xroot*/, Int_t /*yroot*/)
2020 {
2021  TPad *pad = fCanvas->Pick(x, y, 0);
2022  if (pad) {
2023  pad->cd();
2024  gROOT->SetSelectedPad(pad);
2025  // make sure the pad is highlighted (on Windows)
2026  pad->Update();
2027  }
2028  return action;
2029 }
2030 
2031 ////////////////////////////////////////////////////////////////////////////////
2032 /// Handle drag enter events.
2033 
2035 {
2036  static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2037  static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2038  Atom_t ret = kNone;
2039  for (int i = 0; typelist[i] != kNone; ++i) {
2040  if (typelist[i] == rootObj)
2041  ret = rootObj;
2042  if (typelist[i] == uriObj)
2043  ret = uriObj;
2044  }
2045  return ret;
2046 }
2047 
2048 ////////////////////////////////////////////////////////////////////////////////
2049 /// Handle drag leave events.
2050 
2052 {
2053  return kTRUE;
2054 }
2055 
2056 ////////////////////////////////////////////////////////////////////////////////
2057 /// Slot handling tab switching in the browser, to properly set the canvas
2058 /// and the model to the editor.
2059 
2061 {
2062  if (fEmbedded) {
2063  TGTab *sender = (TGTab *)gTQSender;
2064  if (sender) {
2065  TGCompositeFrame *cont = sender->GetTabContainer(id);
2066  if (cont == fParent) {
2067  if (!fEditor)
2069  if (fEditor && ((TGedEditor *)fEditor)->IsMapped()) {
2070  ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
2071  ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
2072  }
2073  }
2074  }
2075  }
2076 }
2077 
2078 ////////////////////////////////////////////////////////////////////////////////
2079 /// Save a canvas container as a C++ statement(s) on output stream out.
2080 
2081 void TRootContainer::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
2082 {
2083  out << std::endl << " // canvas container" << std::endl;
2084  out << " Int_t canvasID = gVirtualX->InitWindow((ULong_t)"
2085  << GetParent()->GetParent()->GetName() << "->GetId());" << std::endl;
2086  out << " Window_t winC = gVirtualX->GetWindowID(canvasID);" << std::endl;
2087  out << " TGCompositeFrame *";
2088  out << GetName() << " = new TGCompositeFrame(gClient,winC"
2089  << "," << GetParent()->GetName() << ");" << std::endl;
2090 }
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
const Mask_t kKeyReleaseMask
Definition: GuiTypes.h:159
const TGWindow * fParent
Definition: TGWindow.h:37
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
void SetCanvasImp(TCanvasImp *i)
Definition: TCanvas.h:205
Bool_t GetShowEditor() const
Definition: TCanvas.h:156
virtual void AddFrame(TGFrame *f, TGLayoutHints *hints)
Add frame to dockable frame container. Frame and hints are NOT adopted.
TGLayoutHints * fMenuBarLayout
Definition: TRootCanvas.h:59
TGLayoutHints * fEditorLayout
Definition: TRootCanvas.h:67
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:424
friend class TCanvas
Definition: TCanvasImp.h:31
virtual void StartEmbedding(Int_t pos=kRight, Int_t subpos=-1)
Start embedding external frame in the tab "pos" and tab element "subpos".
Int_t fDataLength
Definition: TGDNDManager.h:78
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition: TCanvas.cxx:1463
void CreateEditor()
Create embedded editor.
TGPopupMenu * fFileMenu
Definition: TRootCanvas.h:50
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:47
ABC describing GUI independent main window (with menubar, scrollbars and a drawing area)...
Definition: TCanvasImp.h:30
Int_t fCanvasID
Definition: TRootCanvas.h:86
TGMenuBar * fMenuBar
Definition: TRootCanvas.h:49
auto * m
Definition: textangle.C:8
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:611
R__EXTERN const char gHelpPostscript[]
Definition: HelpText.h:18
R__EXTERN Int_t gErrorIgnoreLevel
Definition: TError.h:105
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition: TCanvas.cxx:2190
virtual Bool_t HandleButton(Event_t *)
Definition: TGFrame.h:383
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:869
TGCompositeFrame * GetTabContainer(Int_t tabIndex) const
Return container of tab with index tabIndex.
Definition: TGTab.cxx:563
virtual Bool_t HandleKey(Event_t *)
Definition: TGFrame.h:387
void ShowStatusBar(Bool_t show=kTRUE)
Show or hide statusbar.
TGToolTip * fToolTip
Definition: TRootCanvas.h:82
Definition: TGTab.h:62
virtual Bool_t HandleDoubleClick(Event_t *)
Definition: TGFrame.h:384
void DockContainer(Int_t del=kTRUE)
Dock container back to TGDockableFrame.
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:321
Bool_t HandleContainerConfigure(Event_t *ev)
Handle configure (i.e. resize) event.
TGLayoutHints * fVertical2Layout
Definition: TRootCanvas.h:77
Bool_t fOverwrite
Definition: TGFileDialog.h:65
const char Option_t
Definition: RtypesCore.h:62
Int_t fButton
Definition: TRootCanvas.h:88
const Mask_t kKeyShiftMask
Definition: GuiTypes.h:194
void SetSupportGL(Bool_t support)
Definition: TCanvas.h:227
virtual TGButton * AddButton(const TGWindow *w, ToolBarData_t *button, Int_t spacing=0)
Add button to toolbar.
Definition: TGToolBar.cxx:91
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1746
R__EXTERN void * gTQSender
Definition: TQObject.h:45
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
This class represents a WWW compatible URL.
Definition: TUrl.h:35
void Reset()
Reset tool tip popup delay timer.
Definition: TGToolTip.cxx:259
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:638
Int_t fCount
Definition: GuiTypes.h:182
virtual void Hide()
R__EXTERN TStyle * gStyle
Definition: TStyle.h:402
Bool_t HandleContainerCrossing(Event_t *ev)
Handle enter/leave events. Only leave is activated at the moment.
void SetText(const char *new_text)
Set new tool tip text.
Definition: TGToolTip.cxx:386
void ShowToolBar(Bool_t show=kTRUE)
Show or hide toolbar.
UInt_t GetHeight() const
Definition: TGFrame.h:272
static TVirtualPadEditor * LoadEditor()
Static function returning a pointer to a new pad editor.
TH1 * h
Definition: legend2.C:5
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition: TGMenu.cxx:1714
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:167
EGEventType
Definition: GuiTypes.h:58
Bool_t HandleContainerMotion(Event_t *ev)
Handle mouse motion event in the canvas container.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:688
Bool_t HasMenuBar() const
Returns kTRUE if the menu bar is shown.
TGHorizontal3DLine * fHorizontal1
Definition: TRootCanvas.h:75
R__EXTERN const char gHelpPullDownMenus[]
Definition: HelpText.h:21
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition: TGMenu.cxx:1835
virtual void SetContainer(TGFrame *f)
Definition: TGCanvas.h:232
EEventType
Definition: Buttons.h:15
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition: TSystem.cxx:860
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition: TGMenu.cxx:1797
const TGPicture * SetIconPixmap(const char *iconName)
Set window icon pixmap by name.
Definition: TGFrame.cxx:1774
#define gROOT
Definition: TROOT.h:402
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:585
TGStatusBar * fStatusBar
Definition: TRootCanvas.h:63
Int_t LoadPlugin()
Load the plugin library for this handler.
virtual void ToggleToolTips()
Toggle tooltip display.
Definition: TCanvas.cxx:2223
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1829
Basic string class.
Definition: TString.h:125
#define gClient
Definition: TGClient.h:166
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
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1186
virtual void Update()
Update pad.
Definition: TPad.cxx:2804
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
ERootCanvasCommands
Definition: TRootCanvas.cxx:78
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=0, const TGPicture *p=0, TGMenuEntry *before=0)
Add a menu entry.
Definition: TGMenu.cxx:987
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
virtual void * ReadObjectAny(const TClass *cast)
Read object from I/O buffer.
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:246
An abstract interface to image processing library.
Definition: TImage.h:29
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
R__EXTERN TApplication * gApplication
Definition: TApplication.h:165
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGToolBar.cxx:213
UInt_t GetWidth() const
Definition: TGFrame.h:271
Double_t GetAspectRatio() const
Definition: TPad.h:219
TGPopupMenu * fToolsMenu
Definition: TRootCanvas.h:57
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition: TGFrame.cxx:1759
void Flush()
Flush canvas buffers.
Definition: TCanvas.cxx:1085
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition: TObject.cxx:386
TGHorizontal3DLine * fToolBarSep
Definition: TRootCanvas.h:71
R__EXTERN const char gHelpBrowser[]
Definition: HelpText.h:15
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: TGMenu.cxx:1057
Handle_t GetId() const
Definition: TGObject.h:47
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:14
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
Definition: TList.cxx:574
virtual TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj)
Search for an object at pixel position px,py.
Definition: TCanvas.h:186
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=0)
Set the value of a resource or create a new resource.
Definition: TEnv.cxx:736
void Iconify()
Definition: TRootCanvas.h:122
void SetDNDTarget(Bool_t onoff)
Definition: TGFrame.h:317
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:162
TGPopupMenu * fViewMenu
Definition: TRootCanvas.h:54
TGLayoutHints * fHorizontal1Layout
Definition: TRootCanvas.h:78
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.
void SetText(const char *helpText)
Set help text from helpText buffer in TGTextView.
Bool_t GetShowToolTips() const
Definition: TCanvas.h:157
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
Definition: TSystem.cxx:1357
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:585
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
Double_t x[n]
Definition: legend1.C:17
virtual void Paint(Option_t *option="")
Paint canvas.
Definition: TCanvas.cxx:1471
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:2365
virtual FILE * TempFileName(TString &base, const char *dir=0)
Create a secure temporary file by appending a unique 6 letter string to base.
Definition: TSystem.cxx:1473
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition: TCanvas.cxx:1563
virtual void AddLabel(TGHotString *s, const TGPicture *p=0, TGMenuEntry *before=0)
Add a menu label to the menu.
Definition: TGMenu.cxx:1092
void Class()
Definition: Class.C:29
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
Definition: TVirtualPad.h:287
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition: TSystem.cxx:445
virtual void Draw(Option_t *option="")
Paint the color wheel.
TGPopupMenu * fEditMenu
Definition: TRootCanvas.h:52
TGPopupMenu * fEditClearMenu
Definition: TRootCanvas.h:53
const char ** fFileTypes
Definition: TGFileDialog.h:63
TGDockableFrame * fToolDock
Definition: TRootCanvas.h:79
UInt_t GetWindowHeight() const
Definition: TCanvas.h:168
const Int_t kFatal
Definition: TError.h:42
Atom_t HandleDNDPosition(Int_t x, Int_t y, Atom_t action, Int_t xroot, Int_t yroot)
Handle dragging position events.
Handle_t Atom_t
Definition: GuiTypes.h:36
Int_t GetOptFit() const
Definition: TStyle.h:228
Bool_t fAutoFit
Definition: TRootCanvas.h:87
TGCompositeFrame(const TGCompositeFrame &)
Bool_t HasToolTips() const
Returns kTRUE if the tooltips are enabled.
virtual void SetGlobal(Bool_t global)
Set editor global.
Definition: TGedEditor.cxx:271
void Clear(Option_t *option="")
Remove all primitives from the canvas.
Definition: TCanvas.cxx:707
TGLayoutHints * fDockLayout
Definition: TRootCanvas.h:80
void * fData
Definition: TGDNDManager.h:77
static void DisplayMarkerTypes()
Display the table of markers with their numbers.
Definition: TMarker.cxx:85
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2231
virtual Bool_t HandleExpose(Event_t *event)
Definition: TGWindow.h:105
int main(int argc, char **argv)
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
TGPopupMenu * fFileSaveMenu
Definition: TRootCanvas.h:51
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition: TGFrame.cxx:1814
virtual void Show()
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition: TSystem.cxx:1458
TGVertical3DLine * fVertical1
Definition: TRootCanvas.h:73
virtual void SetText(TGString *text, Int_t partidx=0)
Set text in partition partidx in status bar.
void ReallyDelete()
Really delete the canvas and this GUI.
Bool_t IsUndocked() const
void AdjustSize()
Keep the same canvas size while docking/undocking toolbar.
void SetPosition(Int_t x, Int_t y)
Set popup position within specified frame (as specified in the ctor).
Definition: TGToolTip.cxx:405
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:49
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition: TCanvas.cxx:1711
virtual void SetGLDevice(Int_t dev)
Definition: TPad.h:358
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other command generated by the user.
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:227
TGPopupMenu * fViewWithMenu
Definition: TRootCanvas.h:55
Bool_t OpaqueMoving() const
Is pad moving in opaque mode ?
Definition: TCanvas.h:183
TGLayoutHints * fMenuBarItemLayout
Definition: TRootCanvas.h:60
void RaiseWindow()
Put canvas window on top of the window stack.
friend class TRootContainer
Definition: TRootCanvas.h:44
A doubly linked list.
Definition: TList.h:44
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
TGCompositeFrame * fMainFrame
Definition: TRootCanvas.h:68
const Mask_t kKeyPressMask
Definition: GuiTypes.h:158
TRootCanvas(const TRootCanvas &)
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
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:867
void ShowEditor(Bool_t show=kTRUE)
Show or hide side frame.
void CreateCanvas(const char *name)
Create the actual canvas.
void ShowMenuBar(Bool_t show=kTRUE)
Show or hide menubar.
virtual void SendCloseMessage()
Send close message to self.
Definition: TGFrame.cxx:1702
TGCanvas * fCanvasWindow
Definition: TRootCanvas.h:47
virtual void ToggleToolBar()
Toggle toolbar.
Definition: TCanvas.cxx:2201
Int_t InitWindow()
Called by TCanvas ctor to get window indetifier.
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition: TCanvas.cxx:1647
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
void Popup()
Show help dialog.
EGEventType fType
Definition: GuiTypes.h:174
R__EXTERN const char gHelpCanvas[]
Definition: HelpText.h:22
Bool_t OpaqueResizing() const
Is pad resizing in opaque mode ?
Definition: TCanvas.h:184
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:375
Int_t GET_SUBMSG(Long_t val)
Bool_t HandleContainerButton(Event_t *ev)
Handle mouse button events in the canvas container.
Bool_t HandleContainerExpose(Event_t *ev)
Handle expose events.
Long_t ExecPlugin(int nargs, const T &... params)
virtual void Associate(const TGWindow *w)
Definition: TGMenu.h:219
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:561
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
const Mask_t kExposureMask
Definition: GuiTypes.h:164
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:1218
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:507
unsigned int UInt_t
Definition: RtypesCore.h:42
The most important graphics class in the ROOT system.
Definition: TPad.h:29
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
char * Form(const char *fmt,...)
const Handle_t kNone
Definition: GuiTypes.h:87
Ssiz_t Length() const
Definition: TString.h:386
void ShowToolTips(Bool_t show=kTRUE)
Enable or disable tooltip info.
TVirtualPadEditor * fEditor
Definition: TRootCanvas.h:84
void SetWindowPosition(Int_t x, Int_t y)
Set canvas position (units in pixels).
void SetReadMode()
Set buffer in read mode.
Definition: TBuffer.cxx:281
TGTab * GetTabLeft() const
Definition: TRootBrowser.h:140
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:661
virtual void ToggleEditor()
Toggle editor.
Definition: TCanvas.cxx:2212
Bool_t HandleDNDLeave()
Handle drag leave events.
Atom_t fDataType
Definition: TGDNDManager.h:75
Bool_t HandleDNDDrop(TDNDData *data)
Handle drop events.
UInt_t GetCheight() const
Return height of canvas container.
virtual void Print(const char *filename="") const
Save Pad contents in a file in one of various formats.
Definition: TPad.cxx:4599
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition: TCanvas.cxx:2181
virtual void SetEditable(Bool_t=kTRUE)
Definition: TImage.h:225
TGPopupMenu * fHelpMenu
Definition: TRootCanvas.h:58
#define gVirtualX
Definition: TVirtualX.h:350
R__EXTERN const char gHelpObjects[]
Definition: HelpText.h:23
static ToolBarData_t gToolBarData[]
TGTab * GetTabRight() const
Definition: TRootBrowser.h:141
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition: TGFrame.cxx:575
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2544
Int_t GET_MSG(Long_t val)
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual Bool_t HandleMotion(Event_t *)
Definition: TGFrame.h:386
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition: TGFrame.cxx:425
TString & Remove(Ssiz_t pos)
Definition: TString.h:619
long Long_t
Definition: RtypesCore.h:50
The Canvas class.
Definition: TCanvas.h:31
#define ClassImp(name)
Definition: Rtypes.h:359
static const char * gSaveAsTypes[]
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition: TGFrame.cxx:1004
const Mask_t kStructureNotifyMask
Definition: GuiTypes.h:165
static const char * gOpenTypes[]
Bool_t HandleContainerKey(Event_t *ev)
Handle keyboard events in the canvas container.
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1054
Int_t GetOptStat() const
Definition: TStyle.h:229
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:161
Bool_t HasEditor() const
Returns kTRUE if the editor is shown.
TGLayoutHints * fVertical1Layout
Definition: TRootCanvas.h:76
UInt_t fCode
Definition: GuiTypes.h:179
TGVertical3DLine * fVertical2
Definition: TRootCanvas.h:74
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
unsigned long ULong_t
Definition: RtypesCore.h:51
Int_t fFileTypeIdx
Definition: TGFileDialog.h:64
TGLayoutHints * fStatusBarLayout
Definition: TRootCanvas.h:64
char * fFilename
Definition: TGFileDialog.h:61
Double_t y[n]
Definition: legend1.C:17
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:180
R__EXTERN const char gHelpGraphicsEditor[]
Definition: HelpText.h:20
#define gGLManager
Definition: TVirtualGL.h:162
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:570
static constexpr double s
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1025
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
Abstract base class used by ROOT graphics editor.
TGFrame * GetActFrame() const
Definition: TRootBrowser.h:137
virtual void StopEmbedding(const char *name=0)
Definition: TRootBrowser.h:152
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
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:2887
UInt_t GetDisplayHeight() const
Get display height.
Definition: TGClient.cxx:273
const TGWindow * GetParent() const
Definition: TGWindow.h:85
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:2723
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
const TGPicture * fIconPic
Definition: TRootCanvas.h:81
Bool_t IsNull() const
Definition: TString.h:383
Handle_t fId
Definition: TGObject.h:36
TCanvas * Canvas() const
Definition: TCanvasImp.h:54
virtual void SetName(const char *name)
Definition: TPad.h:345
Mother of all ROOT objects.
Definition: TObject.h:37
Atom_t HandleDNDEnter(Atom_t *typelist)
Handle drag enter events.
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:401
TGPopupMenu * fOptionMenu
Definition: TRootCanvas.h:56
Handle_t Window_t
Definition: GuiTypes.h:28
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
Definition: TGFrame.cxx:1837
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition: TGMenu.cxx:1772
static ToolBarData_t gToolBarData1[]
void Activated(Int_t id)
Slot handling tab switching in the browser, to properly set the canvas and the model to the editor...
static TGuiBuilder * Instance()
return an instance of TGuiBuilder object
TGClient * fClient
Definition: TGObject.h:37
const char * GetWindowName() const
Definition: TGFrame.h:544
void SetStatusText(const char *txt=0, Int_t partidx=0)
Set text in status bar.
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition: TGTab.cxx:612
void Close()
Called via TCanvasImp interface by TCanvas.
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:232
void FitCanvas()
Fit canvas container to current window size.
const char * fPixmap
Definition: TGToolBar.h:33
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:1266
void SetOptTitle(Int_t tit=1)
Definition: TStyle.h:309
UInt_t GetCwidth() const
Return width of canvas container.
#define gPad
Definition: TVirtualPad.h:285
UInt_t fState
Definition: GuiTypes.h:180
void SetWindowSize(UInt_t w, UInt_t h)
Set size of canvas (units in pixels).
TGToolBar * fToolBar
Definition: TRootCanvas.h:70
Atom_t * fDNDTypeList
Definition: TGFrame.h:482
virtual void SetParts(Int_t npart)
Divide the status bar in npart equal sized parts.
void PrintCanvas()
Print the canvas.
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition: TImage.cxx:110
static void Terminate()
Close the global pad editor. Static method.
void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
Display a tooltip with infos about the primitive below the cursor.
TGLayoutHints * fMainFrameLayout
Definition: TRootCanvas.h:72
void SetWindowName(const char *name)
Set window name so it appear as title of the undock window.
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition: TROOT.cxx:2842
virtual void AddPopup(TGHotString *s, TGPopupMenu *popup, TGMenuEntry *before=0, const TGPicture *p=0)
Add a (cascading) popup menu to a popup menu.
Definition: TGMenu.cxx:1149
TGLayoutHints * fMenuBarHelpLayout
Definition: TRootCanvas.h:61
Bool_t ReturnFromRun() const
Definition: TApplication.h:148
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition: TCanvas.cxx:1168
Bool_t UseGL() const
Definition: TCanvas.h:226
static TImage * Create()
Create an image.
Definition: TImage.cxx:36
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save Pad contents in a file in one of various formats.
Definition: TPad.cxx:5486
Bool_t HandleContainerDoubleClick(Event_t *ev)
Handle mouse button double click events in the canvas container.
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2248
TGCompositeFrame * fEditorFrame
Definition: TRootCanvas.h:66
TRootContainer * fCanvasContainer
Definition: TRootCanvas.h:48
virtual void SetEditable(Bool_t on=kTRUE)
Switch ON/OFF edit mode.
Definition: TGFrame.cxx:930
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual Int_t GetSize() const
Definition: TCollection.h:180
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
Definition: Buttons.h:22
TGLayoutHints * fToolBarLayout
Definition: TRootCanvas.h:69
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
void SetCanvasSize(UInt_t w, UInt_t h)
Set size of canvas container. Units in pixels.
const Bool_t kTRUE
Definition: RtypesCore.h:87
Int_t Nint(T x)
Definition: TMath.h:606
TCanvas * fCanvas
Definition: TCanvasImp.h:34
Bool_t HasStatusBar() const
Returns kTRUE if the status bar is shown.
void CloseWindow()
In case window is closed via WM we get here.
virtual ~TRootCanvas()
Delete ROOT basic canvas.
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=0)
Add popup menu to menu bar.
Definition: TGMenu.cxx:415
Draw the ROOT Color Wheel.
Definition: TColorWheel.h:24
void Modified(Bool_t flag=1)
Definition: TPad.h:414
Bool_t HasToolBar() const
Returns kTRUE if the tool bar is shown.
Bool_t HasFixedAspectRatio() const
Definition: TPad.h:265
char name[80]
Definition: TGX11.cxx:109
virtual Bool_t HandleCrossing(Event_t *)
Definition: TGFrame.h:385
void SetWindowTitle(const char *newTitle)
Change title on window.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
Bool_t fEmbedded
Definition: TRootCanvas.h:85
Draw inheritance tree and their relations for a list of classes.
Definition: TClassTree.h:21
Bool_t GetAutoExec() const
Definition: TCanvas.h:158
char * fIniDir
Definition: TGFileDialog.h:62
virtual void SetGlobal(Bool_t)
virtual TCanvas * GetCanvas() const =0
virtual Int_t MustCleanup() const
Definition: TGFrame.h:420
void EnableHide(Bool_t onoff)
Enable hiding.
Int_t GetOptTitle() const
Definition: TStyle.h:230
const char * Data() const
Definition: TString.h:345
TGLayoutHints * fCanvasLayout
Definition: TRootCanvas.h:62