Logo ROOT   6.10/09
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 
309  ShowToolBar(kFALSE);
310  ShowEditor(kFALSE);
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  if (!gThreadXAR) {
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 
1314 void 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 
1401 void 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 {
1444  UInt_t ch = fCanvas->GetWindowHeight();
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();
1475  UInt_t s = fHorizontal1->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) {
1500  fEditor->SetGlobal(kFALSE);
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 
1570  fToolBar = new TGToolBar(fToolDock, 60, 20, kHorizontalFrame);
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();
1608  UInt_t sh = fToolBarSep->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();
1696  UInt_t sh = fHorizontal1->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)
1747  fCanvas->HandleInput(kWheelUp, x, y);
1748  if (button == kButton5)
1749  fCanvas->HandleInput(kWheelDown, x, y);
1750  if (button == kButton1)
1751  fCanvas->HandleInput(kButton1Up, x, y);
1752  if (button == kButton2)
1753  fCanvas->HandleInput(kButton2Up, x, y);
1754  if (button == kButton3)
1755  fCanvas->HandleInput(kButton3Up, x, y);
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 
1792  if (fCanvas->HasFixedAspectRatio()) {
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;
1799  SetWindowSize(GetWidth(), h);
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();
1820  fCanvas->HandleInput(kButton1Up, 0, 0);
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)
1916  fCanvas->HandleInput(EEventType(8), x, y);
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 
2079 void 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 }
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:423
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:1454
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
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:2150
virtual Bool_t HandleButton(Event_t *)
Definition: TGFrame.h:383
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:868
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:115
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:640
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:679
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:859
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:375
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:587
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:2183
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1825
Basic string class.
Definition: TString.h:129
#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:2786
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:202
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...
#define NULL
Definition: RtypesCore.h:88
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:1076
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition: TObject.cxx:393
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:48
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
Find an object in this list using its name.
Definition: TList.cxx:501
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:727
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:1353
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:565
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:135
Double_t x[n]
Definition: legend1.C:17
virtual void Paint(Option_t *option="")
Paint canvas.
Definition: TCanvas.cxx:1462
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:2345
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:1469
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:1554
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:286
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition: TSystem.cxx:444
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:698
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:101
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:1454
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:1702
virtual void SetGLDevice(Int_t dev)
Definition: TPad.h:354
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:43
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:2161
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:1638
R__EXTERN TSystem * gSystem
Definition: TSystem.h:539
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 Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:482
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:436
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:563
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:1219
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
TMarker * m
Definition: textangle.C:8
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:873
char * Form(const char *fmt,...)
const Handle_t kNone
Definition: GuiTypes.h:87
Ssiz_t Length() const
Definition: TString.h:388
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:271
TGTab * GetTabLeft() const
Definition: TRootBrowser.h:140
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:660
virtual void ToggleEditor()
Toggle editor.
Definition: TCanvas.cxx:2172
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:4581
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition: TCanvas.cxx:2141
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:2524
Int_t GET_MSG(Long_t val)
const Bool_t kFALSE
Definition: RtypesCore.h:92
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:621
long Long_t
Definition: RtypesCore.h:50
The Canvas class.
Definition: TCanvas.h:31
#define ClassImp(name)
Definition: Rtypes.h:336
static const char * gSaveAsTypes[]
double f(double x)
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:170
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:572
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:2885
UInt_t GetDisplayHeight() const
Get display height.
Definition: TGClient.cxx:273
const TGWindow * GetParent() const
Definition: TGWindow.h:81
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:385
Handle_t fId
Definition: TGObject.h:36
TCanvas * Canvas() const
Definition: TCanvasImp.h:51
virtual void SetName(const char *name)
Definition: TPad.h:341
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:408
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:1267
void SetOptTitle(Int_t tit=1)
Definition: TStyle.h:309
UInt_t GetCwidth() const
Return width of canvas container.
#define gPad
Definition: TVirtualPad.h:284
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:2728
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:1159
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:5468
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:2208
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:364
virtual Int_t GetSize() const
Definition: TCollection.h:89
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
void SetCanvasSize(UInt_t w, UInt_t h)
Set size of canvas container. Units in pixels.
const Bool_t kTRUE
Definition: RtypesCore.h:91
Int_t Nint(T x)
Definition: TMath.h:607
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:410
Bool_t HasToolBar() const
Returns kTRUE if the tool bar is shown.
Bool_t HasFixedAspectRatio() const
Definition: TPad.h:261
int main(int argc, char **argv)
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:859
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:347
TGLayoutHints * fCanvasLayout
Definition: TRootCanvas.h:62