ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
183 static ToolBarData_t gToolBarData[] = {
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 
198 static ToolBarData_t gToolBarData1[] = {
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  TVirtualPad *savepad = gPad;
705  gPad = 0; // hide gPad from CINT
706  gInterpreter->DeleteGlobal(fCanvas);
707  gPad = savepad; // restore gPad for ROOT
708  if (fCanvas->IsOnHeap())
709  delete fCanvas; // will in turn delete this object
710  else
711  fCanvas->Destructor(); // will in turn delete this object
712 }
713 
714 ////////////////////////////////////////////////////////////////////////////////
715 /// In case window is closed via WM we get here.
716 
718 {
719  DeleteWindow();
720 }
721 
722 ////////////////////////////////////////////////////////////////////////////////
723 /// Return width of canvas container.
724 
726 {
727  return fCanvasContainer->GetWidth();
728 }
729 
730 ////////////////////////////////////////////////////////////////////////////////
731 /// Return height of canvas container.
732 
734 {
735  return fCanvasContainer->GetHeight();
736 }
737 
738 ////////////////////////////////////////////////////////////////////////////////
739 /// Gets the size and position of the window containing the canvas. This
740 /// size includes the menubar and borders.
741 
743 {
744  gVirtualX->GetWindowSize(fId, x, y, w, h);
745 
746  Window_t childdum;
747  gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(),
748  0, 0, x, y, childdum);
749  if (!fCanvas->GetShowEditor()) return 0;
750  return fEditorFrame->GetWidth();
751 }
752 
753 ////////////////////////////////////////////////////////////////////////////////
754 /// Set text in status bar.
755 
756 void TRootCanvas::SetStatusText(const char *txt, Int_t partidx)
757 {
758  fStatusBar->SetText(txt, partidx);
759 }
760 
761 ////////////////////////////////////////////////////////////////////////////////
762 /// Handle menu and other command generated by the user.
763 
765 {
766  TRootHelpDialog *hd;
767  TList *lc;
768 
769  switch (GET_MSG(msg)) {
770 
771  case kC_COMMAND:
772 
773  switch (GET_SUBMSG(msg)) {
774 
775  case kCM_BUTTON:
776  case kCM_MENU:
777 
778  switch (parm1) {
779  // Handle toolbar items...
780  case kToolModify:
781  gROOT->SetEditorMode();
782  break;
783  case kToolArc:
784  gROOT->SetEditorMode("Arc");
785  break;
786  case kToolLine:
787  gROOT->SetEditorMode("Line");
788  break;
789  case kToolArrow:
790  gROOT->SetEditorMode("Arrow");
791  break;
792  case kToolDiamond:
793  gROOT->SetEditorMode("Diamond");
794  break;
795  case kToolEllipse:
796  gROOT->SetEditorMode("Ellipse");
797  break;
798  case kToolPad:
799  gROOT->SetEditorMode("Pad");
800  break;
801  case kToolPave:
802  gROOT->SetEditorMode("Pave");
803  break;
804  case kToolPLabel:
805  gROOT->SetEditorMode("PaveLabel");
806  break;
807  case kToolPText:
808  gROOT->SetEditorMode("PaveText");
809  break;
810  case kToolPsText:
811  gROOT->SetEditorMode("PavesText");
812  break;
813  case kToolGraph:
814  gROOT->SetEditorMode("PolyLine");
815  break;
816  case kToolCurlyLine:
817  gROOT->SetEditorMode("CurlyLine");
818  break;
819  case kToolCurlyArc:
820  gROOT->SetEditorMode("CurlyArc");
821  break;
822  case kToolLatex:
823  gROOT->SetEditorMode("Text");
824  break;
825  case kToolMarker:
826  gROOT->SetEditorMode("Marker");
827  break;
828  case kToolCutG:
829  gROOT->SetEditorMode("CutG");
830  break;
831 
832  // Handle File menu items...
833  case kFileNewCanvas:
834  gROOT->MakeDefCanvas();
835  break;
836  case kFileOpen:
837  {
838  static TString dir(".");
839  TGFileInfo fi;
840  fi.fFileTypes = gOpenTypes;
841  fi.fIniDir = StrDup(dir);
842  new TGFileDialog(fClient->GetDefaultRoot(), this, kFDOpen,&fi);
843  if (!fi.fFilename) return kTRUE;
844  dir = fi.fIniDir;
845  new TFile(fi.fFilename, "update");
846  }
847  break;
848  case kFileSaveAs:
849  {
851  static TString dir(".");
852  static Int_t typeidx = 0;
853  static Bool_t overwr = kFALSE;
854  TGFileInfo fi;
855  TString defaultType = gEnv->GetValue("Canvas.SaveAsDefaultType", ".pdf");
856  if (typeidx == 0) {
857  for (int i=1;gSaveAsTypes[i];i+=2) {
858  TString ftype = gSaveAsTypes[i];
859  if (ftype.EndsWith(defaultType.Data())) {
860  typeidx = i-1;
861  break;
862  }
863  }
864  }
866  fi.fIniDir = StrDup(dir);
867  fi.fFileTypeIdx = typeidx;
868  fi.fOverwrite = overwr;
869  new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi);
870  gSystem->ChangeDirectory(workdir.Data());
871  if (!fi.fFilename) return kTRUE;
872  Bool_t appendedType = kFALSE;
873  TString fn = fi.fFilename;
874  TString ft = fi.fFileTypes[fi.fFileTypeIdx+1];
875  dir = fi.fIniDir;
876  typeidx = fi.fFileTypeIdx;
877  overwr = fi.fOverwrite;
878 again:
879  if (fn.EndsWith(".root") ||
880  fn.EndsWith(".ps") ||
881  fn.EndsWith(".eps") ||
882  fn.EndsWith(".pdf") ||
883  fn.EndsWith(".svg") ||
884  fn.EndsWith(".tex") ||
885  fn.EndsWith(".gif") ||
886  fn.EndsWith(".xml") ||
887  fn.EndsWith(".xpm") ||
888  fn.EndsWith(".jpg") ||
889  fn.EndsWith(".png") ||
890  fn.EndsWith(".xcf") ||
891  fn.EndsWith(".tiff")) {
892  fCanvas->SaveAs(fn);
893  } else if (fn.EndsWith(".C"))
894  fCanvas->SaveSource(fn);
895  else {
896  if (!appendedType) {
897  if (ft.Index(".") != kNPOS) {
898  fn += ft(ft.Index("."), ft.Length());
899  appendedType = kTRUE;
900  goto again;
901  }
902  }
903  Warning("ProcessMessage", "file %s cannot be saved with this extension", fi.fFilename);
904  }
905  for (int i=1;gSaveAsTypes[i];i+=2) {
906  TString ftype = gSaveAsTypes[i];
907  ftype.ReplaceAll("*.", ".");
908  if (fn.EndsWith(ftype.Data())) {
909  typeidx = i-1;
910  break;
911  }
912  }
913  }
914  break;
915  case kFileSaveAsRoot:
916  fCanvas->SaveAs(".root");
917  break;
918  case kFileSaveAsC:
919  fCanvas->SaveSource();
920  break;
921  case kFileSaveAsPS:
922  fCanvas->SaveAs();
923  break;
924  case kFileSaveAsEPS:
925  fCanvas->SaveAs(".eps");
926  break;
927  case kFileSaveAsPDF:
928  fCanvas->SaveAs(".pdf");
929  break;
930  case kFileSaveAsGIF:
931  fCanvas->SaveAs(".gif");
932  break;
933  case kFileSaveAsJPG:
934  fCanvas->SaveAs(".jpg");
935  break;
936  case kFileSaveAsPNG:
937  fCanvas->SaveAs(".png");
938  break;
939  case kFileSaveAsTEX:
940  fCanvas->SaveAs(".tex");
941  break;
942  case kFilePrint:
943  PrintCanvas();
944  break;
945  case kFileCloseCanvas:
947  break;
948  case kFileQuit:
949  if (!gApplication->ReturnFromRun()) {
953  }
956  if (TClass::GetClass("TStyleManager"))
957  gROOT->ProcessLine("TStyleManager::Terminate()");
959  break;
960 
961  // Handle Edit menu items...
962  case kEditStyle:
963  if (!TClass::GetClass("TStyleManager"))
964  gSystem->Load("libGed");
965  gROOT->ProcessLine("TStyleManager::Show()");
966  break;
967  case kEditCut:
968  // still noop
969  break;
970  case kEditCopy:
971  // still noop
972  break;
973  case kEditPaste:
974  // still noop
975  break;
976  case kEditUndo:
977  // noop
978  break;
979  case kEditRedo:
980  // noop
981  break;
982  case kEditClearPad:
983  gPad->Clear();
984  gPad->Modified();
985  gPad->Update();
986  break;
987  case kEditClearCanvas:
988  fCanvas->Clear();
989  fCanvas->Modified();
990  fCanvas->Update();
991  break;
992 
993  // Handle View menu items...
994  case kViewEditor:
996  break;
997  case kViewToolbar:
999  break;
1000  case kViewEventStatus:
1002  break;
1003  case kViewToolTips:
1005  break;
1006  case kViewColors:
1007  {
1008  TVirtualPad *padsav = gPad->GetCanvas();
1009  //This was the code with the old color table
1010  // TCanvas *m = new TCanvas("colors","Color Table");
1011  // TPad::DrawColorTable();
1012  // m->Update();
1013  TColorWheel *wheel = new TColorWheel();
1014  wheel->Draw();
1015 
1016  //tp: with Cocoa, window is visible (and repainted)
1017  //before wheel->Draw() was called and you can see "empty"
1018  //canvas.
1019  gPad->Update();
1020  //
1021  if (padsav) padsav->cd();
1022  }
1023  break;
1024  case kViewFonts:
1025  // noop
1026  break;
1027  case kViewMarkers:
1028  {
1029  TVirtualPad *padsav = gPad->GetCanvas();
1030  TCanvas *m = new TCanvas("markers","Marker Types",600,200);
1032  m->Update();
1033  if (padsav) padsav->cd();
1034  }
1035  break;
1036  case kViewIconify:
1037  Iconify();
1038  break;
1039  case kViewX3D:
1040  gPad->GetViewer3D("x3d");
1041  break;
1042  case kViewOpenGL:
1043  gPad->GetViewer3D("ogl");
1044  break;
1045 
1046  // Handle Option menu items...
1047  case kOptionAutoExec:
1049  if (fCanvas->GetAutoExec()) {
1051  } else {
1053  }
1054  break;
1055  case kOptionAutoResize:
1056  {
1057  fAutoFit = fAutoFit ? kFALSE : kTRUE;
1058  int opt = fCanvasContainer->GetOptions();
1059  if (fAutoFit) {
1060  opt &= ~kFixedSize;
1062  } else {
1063  opt |= kFixedSize;
1065  }
1066  fCanvasContainer->ChangeOptions(opt);
1067  // in case of autofit this will generate a configure
1068  // event for the container and this will force the
1069  // update of the TCanvas
1070  //Layout();
1071  }
1072  Layout();
1073  break;
1074  case kOptionResizeCanvas:
1075  FitCanvas();
1076  break;
1077  case kOptionMoveOpaque:
1078  if (fCanvas->OpaqueMoving()) {
1079  fCanvas->MoveOpaque(0);
1081  } else {
1082  fCanvas->MoveOpaque(1);
1084  }
1085  break;
1086  case kOptionResizeOpaque:
1087  if (fCanvas->OpaqueResizing()) {
1088  fCanvas->ResizeOpaque(0);
1090  } else {
1091  fCanvas->ResizeOpaque(1);
1093  }
1094  break;
1095  case kOptionInterrupt:
1096  gROOT->SetInterrupt();
1097  break;
1098  case kOptionRefresh:
1099  fCanvas->Paint();
1100  fCanvas->Update();
1101  break;
1102  case kOptionStatistics:
1103  if (gStyle->GetOptStat()) {
1104  gStyle->SetOptStat(0);
1105  delete gPad->FindObject("stats");
1107  } else {
1108  gStyle->SetOptStat(1);
1110  }
1111  gPad->Modified();
1112  fCanvas->Update();
1113  break;
1114  case kOptionHistTitle:
1115  if (gStyle->GetOptTitle()) {
1116  gStyle->SetOptTitle(0);
1117  delete gPad->FindObject("title");
1119  } else {
1120  gStyle->SetOptTitle(1);
1122  }
1123  gPad->Modified();
1124  fCanvas->Update();
1125  break;
1126  case kOptionFitParams:
1127  if (gStyle->GetOptFit()) {
1128  gStyle->SetOptFit(0);
1130  } else {
1131  gStyle->SetOptFit(1);
1133  }
1134  gPad->Modified();
1135  fCanvas->Update();
1136  break;
1137  case kOptionCanEdit:
1138  if (gROOT->GetEditHistograms()) {
1139  gROOT->SetEditHistograms(kFALSE);
1141  } else {
1142  gROOT->SetEditHistograms(kTRUE);
1144  }
1145  break;
1146 
1147  // Handle Tools menu items...
1148  case kInspectRoot:
1149  fCanvas->cd();
1150  gROOT->Inspect();
1151  fCanvas->Update();
1152  break;
1153  case kToolsBrowser:
1154  new TBrowser("browser");
1155  break;
1156  case kToolsBuilder:
1158  break;
1159  case kToolsRecorder:
1160  gROOT->ProcessLine("new TGRecorder()");
1161  break;
1162 
1163  // Handle Tools menu items...
1164  case kClassesTree:
1165  {
1166  TString cdef;
1167  lc = (TList*)gROOT->GetListOfCanvases();
1168  if (lc->FindObject("ClassTree")) {
1169  cdef = TString::Format("ClassTree_%d", lc->GetSize()+1);
1170  } else {
1171  cdef = "ClassTree";
1172  }
1173  new TClassTree(cdef.Data(), "TObject");
1174  fCanvas->Update();
1175  }
1176  break;
1177 
1178  case kFitPanel:
1179  {
1180  // use plugin manager to create instance of TFitEditor
1181  TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
1182  if (handler && handler->LoadPlugin() != -1) {
1183  if (handler->ExecPlugin(2, fCanvas, 0) == 0)
1184  Error("FitPanel", "Unable to crate the FitPanel");
1185  }
1186  else
1187  Error("FitPanel", "Unable to find the FitPanel plug-in");
1188  }
1189  break;
1190 
1191  // Handle Help menu items...
1192  case kHelpAbout:
1193  {
1194 #ifdef R__UNIX
1195  TString rootx;
1196 # ifdef ROOTBINDIR
1197  rootx = ROOTBINDIR;
1198 # else
1199  rootx = gSystem->Getenv("ROOTSYS");
1200  if (!rootx.IsNull()) rootx += "/bin";
1201 # endif
1202  rootx += "/root -a &";
1203  gSystem->Exec(rootx);
1204 #else
1205 #ifdef WIN32
1207 #else
1208 
1209  char str[32];
1210  sprintf(str, "About ROOT %s...", gROOT->GetVersion());
1211  hd = new TRootHelpDialog(this, str, 600, 400);
1212  hd->SetText(gHelpAbout);
1213  hd->Popup();
1214 #endif
1215 #endif
1216  }
1217  break;
1218  case kHelpOnCanvas:
1219  hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1220  hd->SetText(gHelpCanvas);
1221  hd->Popup();
1222  break;
1223  case kHelpOnMenus:
1224  hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1226  hd->Popup();
1227  break;
1228  case kHelpOnGraphicsEd:
1229  hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1231  hd->Popup();
1232  break;
1233  case kHelpOnBrowser:
1234  hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1235  hd->SetText(gHelpBrowser);
1236  hd->Popup();
1237  break;
1238  case kHelpOnObjects:
1239  hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
1240  hd->SetText(gHelpObjects);
1241  hd->Popup();
1242  break;
1243  case kHelpOnPS:
1244  hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
1245  hd->SetText(gHelpPostscript);
1246  hd->Popup();
1247  break;
1248  }
1249  default:
1250  break;
1251  }
1252  default:
1253  break;
1254  }
1255  return kTRUE;
1256 }
1257 
1258 ////////////////////////////////////////////////////////////////////////////////
1259 /// Called by TCanvas ctor to get window indetifier.
1260 
1262 {
1263  if (fCanvas->OpaqueMoving())
1265  if (fCanvas->OpaqueResizing())
1267 
1268  return fCanvasID;
1269 }
1270 
1271 ////////////////////////////////////////////////////////////////////////////////
1272 /// Set size of canvas container. Units in pixels.
1273 
1275 {
1276  // turn off autofit, we want to stay at the given size
1277  fAutoFit = kFALSE;
1279  int opt = fCanvasContainer->GetOptions();
1280  opt |= kFixedSize; // turn on fixed size mode
1281  fCanvasContainer->ChangeOptions(opt);
1282  fCanvasContainer->SetWidth(w);
1283  fCanvasContainer->SetHeight(h);
1284  Layout(); // force layout (will update container to given size)
1285  fCanvas->Resize();
1286  fCanvas->Update();
1287 }
1288 
1289 ////////////////////////////////////////////////////////////////////////////////
1290 /// Set canvas position (units in pixels).
1291 
1293 {
1294  Move(x, y);
1295 }
1296 
1297 ////////////////////////////////////////////////////////////////////////////////
1298 /// Set size of canvas (units in pixels).
1299 
1301 {
1302  Resize(w, h);
1303 
1304  // Make sure the change of size is really done.
1305  if (!gThreadXAR) {
1307  gSystem->Sleep(10);
1309  }
1310 }
1311 
1312 ////////////////////////////////////////////////////////////////////////////////
1313 /// Put canvas window on top of the window stack.
1314 
1316 {
1317  gVirtualX->RaiseWindow(GetId());
1318 }
1319 
1320 ////////////////////////////////////////////////////////////////////////////////
1321 /// Change title on window.
1322 
1324 {
1325  SetWindowName(title);
1326  SetIconName(title);
1327  fToolDock->SetWindowName(Form("ToolBar: %s", title));
1328 }
1329 
1330 ////////////////////////////////////////////////////////////////////////////////
1331 /// Fit canvas container to current window size.
1332 
1334 {
1335  if (!fAutoFit) {
1336  int opt = fCanvasContainer->GetOptions();
1337  int oopt = opt;
1338  opt &= ~kFixedSize; // turn off fixed size mode
1339  fCanvasContainer->ChangeOptions(opt);
1340  Layout(); // force layout
1341  fCanvas->Resize();
1342  fCanvas->Update();
1343  fCanvasContainer->ChangeOptions(oopt);
1344  }
1345 }
1346 
1347 ////////////////////////////////////////////////////////////////////////////////
1348 /// Print the canvas.
1349 
1351 {
1352  Int_t ret = 0;
1353  Bool_t pname = kTRUE;
1354  char *printer, *printCmd;
1355  static TString sprinter, sprintCmd;
1356 
1357  if (sprinter == "")
1358  printer = StrDup(gEnv->GetValue("Print.Printer", ""));
1359  else
1360  printer = StrDup(sprinter);
1361  if (sprintCmd == "")
1362 #ifndef WIN32
1363  printCmd = StrDup(gEnv->GetValue("Print.Command", ""));
1364 #else
1365  printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p"));
1366 #endif
1367  else
1368  printCmd = StrDup(sprintCmd);
1369 
1370  new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
1371  &printer, &printCmd, &ret);
1372  if (ret) {
1373  sprinter = printer;
1374  sprintCmd = printCmd;
1375 
1376  if (sprinter == "")
1377  pname = kFALSE;
1378 
1379  TString fn = "rootprint";
1380  FILE *f = gSystem->TempFileName(fn, gEnv->GetValue("Print.Directory", gSystem->TempDirectory()));
1381  if (f) fclose(f);
1382  fn += TString::Format(".%s",gEnv->GetValue("Print.FileType", "pdf"));
1383  fCanvas->Print(fn);
1384 
1385  TString cmd = sprintCmd;
1386  if (cmd.Contains("%p"))
1387  cmd.ReplaceAll("%p", sprinter);
1388  else if (pname) {
1389  cmd += " "; cmd += sprinter; cmd += " ";
1390  }
1391 
1392  if (cmd.Contains("%f"))
1393  cmd.ReplaceAll("%f", fn);
1394  else {
1395  cmd += " "; cmd += fn; cmd += " ";
1396  }
1397 
1398  gSystem->Exec(cmd);
1399 #ifndef WIN32
1400  gSystem->Unlink(fn);
1401 #endif
1402  }
1403  delete [] printer;
1404  delete [] printCmd;
1405 }
1406 
1407 ////////////////////////////////////////////////////////////////////////////////
1408 /// Display a tooltip with infos about the primitive below the cursor.
1409 
1411 {
1412  fToolTip->Hide();
1413  if (!fCanvas->GetShowToolTips() || selected == 0 ||
1414  event != kMouseMotion || fButton != 0)
1415  return;
1416  TString tipInfo;
1417  TString objInfo = selected->GetObjectInfo(px, py);
1418  if (objInfo.BeginsWith("-")) {
1419  // if the string begins with '-', display only the object info
1420  objInfo.Remove(TString::kLeading, '-');
1421  tipInfo = objInfo;
1422  }
1423  else {
1424  const char *title = selected->GetTitle();
1425  tipInfo += TString::Format("%s::%s", selected->ClassName(),
1426  selected->GetName());
1427  if (title && strlen(title))
1428  tipInfo += TString::Format("\n%s", selected->GetTitle());
1429  tipInfo += TString::Format("\n%d, %d", px, py);
1430  if (!objInfo.IsNull())
1431  tipInfo += TString::Format("\n%s", objInfo.Data());
1432  }
1433  fToolTip->SetText(tipInfo.Data());
1434  fToolTip->SetPosition(px+15, py+15);
1435  fToolTip->Reset();
1436 }
1437 
1438 ////////////////////////////////////////////////////////////////////////////////
1439 /// Show or hide menubar.
1440 
1442 {
1443  if (show) ShowFrame(fMenuBar);
1444  else HideFrame(fMenuBar);
1445 }
1446 
1447 ////////////////////////////////////////////////////////////////////////////////
1448 /// Show or hide statusbar.
1449 
1451 {
1453  UInt_t ch = fCanvas->GetWindowHeight();
1454 
1455  UInt_t h = GetHeight();
1456  UInt_t sh = fStatusBar->GetHeight()+2;
1457 
1458  if (show) {
1461  if (dh - ch >= sh) h = h + sh;
1462  else h = ch;
1463  } else {
1466  if (dh - ch < sh) h = ch;
1467  else h = h - sh;
1468  }
1469  Resize(GetWidth(), h);
1470 }
1471 
1472 ////////////////////////////////////////////////////////////////////////////////
1473 /// Show or hide side frame.
1474 
1476 {
1477  TVirtualPad *savedPad = 0;
1478  savedPad = (TVirtualPad *) gPad;
1479  gPad = Canvas();
1480 
1481  UInt_t w = GetWidth();
1482  UInt_t e = fEditorFrame->GetWidth();
1483  UInt_t h = GetHeight();
1484  UInt_t s = fHorizontal1->GetHeight();
1485 
1486  if (fParent && fParent != fClient->GetDefaultRoot()) {
1489  if (main && main->InheritsFrom("TRootBrowser")) {
1490  TRootBrowser *browser = (TRootBrowser *)main;
1491  if (!fEmbedded)
1492  browser->GetTabRight()->Connect("Selected(Int_t)", "TRootCanvas",
1493  this, "Activated(Int_t)");
1494  fEmbedded = kTRUE;
1495  if (show && (!fEditor || !((TGedEditor *)fEditor)->IsMapped())) {
1496  if (!browser->GetTabLeft()->GetTabTab("Pad Editor")) {
1497  if (browser->GetActFrame()) { //already in edit mode
1498  TTimer::SingleShot(200, "TRootCanvas", this, "ShowEditor(=kTRUE)");
1499  } else {
1501  if (!fEditor)
1503  else {
1504  ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot());
1505  ((TGedEditor *)fEditor)->MapWindow();
1506  }
1507  browser->StopEmbedding("Pad Editor");
1508  if (fEditor) {
1510  gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor);
1511  ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
1512  ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
1513  }
1514  }
1515  }
1516  else
1518  }
1519  if (show) browser->GetTabLeft()->SetTab("Pad Editor");
1520  }
1521  }
1522  else {
1523  if (show) {
1524  if (!fEditor) CreateEditor();
1526  if(gged && gged->GetCanvas() == fCanvas){
1527  gged->Hide();
1528  }
1531  h = h + s;
1532  }
1534  fEditor->Show();
1536  w = w + e;
1537  } else {
1540  h = h - s;
1541  }
1542  if (fEditor) fEditor->Hide();
1545  w = w - e;
1546  }
1547  Resize(w, h);
1548  }
1549  if (savedPad) gPad = savedPad;
1550 }
1551 
1552 ////////////////////////////////////////////////////////////////////////////////
1553 /// Create embedded editor.
1554 
1556 {
1559  gPad = Canvas();
1560  // next two lines are related to the old editor
1561  Int_t show = gEnv->GetValue("Canvas.ShowEditor", 0);
1562  gEnv->SetValue("Canvas.ShowEditor","true");
1567 
1568  // next line is related to the old editor
1569  if (show == 0) gEnv->SetValue("Canvas.ShowEditor","false");
1570 }
1571 
1572 ////////////////////////////////////////////////////////////////////////////////
1573 /// Show or hide toolbar.
1574 
1576 {
1577  if (show && !fToolBar) {
1578 
1579  fToolBar = new TGToolBar(fToolDock, 60, 20, kHorizontalFrame);
1581 
1582  Int_t spacing = 6, i;
1583  for (i = 0; gToolBarData[i].fPixmap; i++) {
1584  if (strlen(gToolBarData[i].fPixmap) == 0) {
1585  spacing = 6;
1586  continue;
1587  }
1588  fToolBar->AddButton(this, &gToolBarData[i], spacing);
1589  spacing = 0;
1590  }
1597 
1598  spacing = 6;
1599  for (i = 0; gToolBarData1[i].fPixmap; i++) {
1600  if (strlen(gToolBarData1[i].fPixmap) == 0) {
1601  spacing = 6;
1602  continue;
1603  }
1604  fToolBar->AddButton(this, &gToolBarData1[i], spacing);
1605  spacing = 0;
1606  }
1608  fToolDock->Layout();
1609  fToolDock->SetWindowName(Form("ToolBar: %s", GetWindowName()));
1610  fToolDock->Connect("Docked()", "TRootCanvas", this, "AdjustSize()");
1611  fToolDock->Connect("Undocked()", "TRootCanvas", this, "AdjustSize()");
1612  }
1613 
1614  if (!fToolBar) return;
1615 
1616  UInt_t h = GetHeight();
1617  UInt_t sh = fToolBarSep->GetHeight();
1618  UInt_t dh = fToolBar->GetHeight();
1619 
1620  if (show) {
1624  h = h + sh;
1625  }
1628  h = h + dh + sh;
1629  } else {
1630  if (fToolDock->IsUndocked()) {
1632  h = h + 2*sh;
1633  } else h = h - dh;
1634 
1638  h = h - sh;
1639  }
1641  h = h - sh;
1643  }
1644  Resize(GetWidth(), h);
1645 }
1646 
1647 ////////////////////////////////////////////////////////////////////////////////
1648 /// Enable or disable tooltip info.
1649 
1651 {
1652  if (show)
1654  else
1656 }
1657 
1658 ////////////////////////////////////////////////////////////////////////////////
1659 /// Returns kTRUE if the editor is shown.
1660 
1662 {
1664 }
1665 
1666 ////////////////////////////////////////////////////////////////////////////////
1667 /// Returns kTRUE if the menu bar is shown.
1668 
1670 {
1671  return (fMenuBar) && fMenuBar->IsMapped();
1672 }
1673 
1674 ////////////////////////////////////////////////////////////////////////////////
1675 /// Returns kTRUE if the status bar is shown.
1676 
1678 {
1679  return (fStatusBar) && fStatusBar->IsMapped();
1680 }
1681 
1682 ////////////////////////////////////////////////////////////////////////////////
1683 /// Returns kTRUE if the tool bar is shown.
1684 
1686 {
1687  return (fToolBar) && fToolBar->IsMapped();
1688 }
1689 
1690 ////////////////////////////////////////////////////////////////////////////////
1691 /// Returns kTRUE if the tooltips are enabled.
1692 
1694 {
1695  return (fCanvas) && fCanvas->GetShowToolTips();
1696 }
1697 
1698 ////////////////////////////////////////////////////////////////////////////////
1699 /// Keep the same canvas size while docking/undocking toolbar.
1700 
1702 {
1703  UInt_t h = GetHeight();
1704  UInt_t dh = fToolBar->GetHeight();
1705  UInt_t sh = fHorizontal1->GetHeight();
1706 
1707  if (fToolDock->IsUndocked()) {
1710  h = h - sh;
1711  }
1713  h = h - dh - sh;
1714  } else {
1717  h = h + sh;
1718  }
1720  h = h + dh + sh;
1721  }
1722  Resize(GetWidth(), h);
1723 }
1724 
1725 ////////////////////////////////////////////////////////////////////////////////
1726 /// Handle mouse button events in the canvas container.
1727 
1729 {
1730  Int_t button = event->fCode;
1731  Int_t x = event->fX;
1732  Int_t y = event->fY;
1733 
1734  if (event->fType == kButtonPress) {
1735  if (fToolTip && fCanvas->GetShowToolTips()) {
1736  fToolTip->Hide();
1737  gVirtualX->UpdateWindow(0);
1739  }
1740  fButton = button;
1741  if (button == kButton1) {
1742  if (event->fState & kKeyShiftMask)
1744  else
1746  }
1747  if (button == kButton2)
1749  if (button == kButton3) {
1751  fButton = 0; // button up is consumed by TContextMenu
1752  }
1753 
1754  } else if (event->fType == kButtonRelease) {
1755  if (button == kButton4)
1756  fCanvas->HandleInput(kWheelUp, x, y);
1757  if (button == kButton5)
1758  fCanvas->HandleInput(kWheelDown, x, y);
1759  if (button == kButton1)
1760  fCanvas->HandleInput(kButton1Up, x, y);
1761  if (button == kButton2)
1762  fCanvas->HandleInput(kButton2Up, x, y);
1763  if (button == kButton3)
1764  fCanvas->HandleInput(kButton3Up, x, y);
1765 
1766  fButton = 0;
1767  }
1768 
1769  return kTRUE;
1770 }
1771 
1772 ////////////////////////////////////////////////////////////////////////////////
1773 /// Handle mouse button double click events in the canvas container.
1774 
1776 {
1777  Int_t button = event->fCode;
1778  Int_t x = event->fX;
1779  Int_t y = event->fY;
1780 
1781  if (button == kButton1)
1783  if (button == kButton2)
1785  if (button == kButton3)
1787 
1788  return kTRUE;
1789 }
1790 
1791 ////////////////////////////////////////////////////////////////////////////////
1792 /// Handle configure (i.e. resize) event.
1793 
1795 {
1796  if (fAutoFit) {
1797  fCanvas->Resize();
1798  fCanvas->Update();
1799  }
1800 
1801  if (fCanvas->HasFixedAspectRatio()) {
1802  // get menu height
1803  static Int_t dh = 0;
1804  if (!dh)
1805  dh = GetHeight() - fCanvasContainer->GetHeight();
1806  UInt_t h = TMath::Nint(fCanvasContainer->GetWidth()/
1807  fCanvas->GetAspectRatio()) + dh;
1808  SetWindowSize(GetWidth(), h);
1809  }
1810  return kTRUE;
1811 }
1812 
1813 ////////////////////////////////////////////////////////////////////////////////
1814 /// Handle keyboard events in the canvas container.
1815 
1817 {
1818  static EGEventType previous_event = kOtherEvent;
1819  static UInt_t previous_keysym = 0;
1820 
1821  if (event->fType == kGKeyPress) {
1822  fButton = event->fCode;
1823  UInt_t keysym;
1824  char str[2];
1825  gVirtualX->LookupString(event, str, sizeof(str), keysym);
1826 
1827  if (str[0] == kESC){ // ESC sets the escape flag
1828  gROOT->SetEscape();
1829  fCanvas->HandleInput(kButton1Up, 0, 0);
1831  gPad->Modified();
1832  return kTRUE;
1833  }
1834  if (str[0] == 3) // ctrl-c sets the interrupt flag
1835  gROOT->SetInterrupt();
1836 
1837  // handle arrow keys
1838  if (keysym > 0x1011 && keysym < 0x1016) {
1839  Window_t dum1, dum2, wid;
1840  UInt_t mask = 0;
1841  Int_t mx, my, tx, ty;
1842  wid = gVirtualX->GetDefaultRootWindow();
1843  gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1844  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1845  fCanvasContainer->GetId(),
1846  mx, my, tx, ty, dum1);
1848  // handle case where we got consecutive same keypressed events coming
1849  // from auto-repeat on Windows (as it fires only successive keydown events)
1850  if ((previous_keysym == keysym) && (previous_event == kGKeyPress)) {
1851  switch (keysym) {
1852  case 0x1012: // left
1853  gVirtualX->Warp(--mx, my, wid); --tx;
1854  break;
1855  case 0x1013: // up
1856  gVirtualX->Warp(mx, --my, wid); --ty;
1857  break;
1858  case 0x1014: // right
1859  gVirtualX->Warp(++mx, my, wid); ++tx;
1860  break;
1861  case 0x1015: // down
1862  gVirtualX->Warp(mx, ++my, wid); ++ty;
1863  break;
1864  default:
1865  break;
1866  }
1868  }
1869  previous_keysym = keysym;
1870  }
1871  else {
1872  fCanvas->HandleInput(kKeyPress, str[0], keysym);
1873  }
1874  } else if (event->fType == kKeyRelease) {
1875  UInt_t keysym;
1876  char str[2];
1877  gVirtualX->LookupString(event, str, sizeof(str), keysym);
1878 
1879  if (keysym > 0x1011 && keysym < 0x1016) {
1880  Window_t dum1, dum2, wid;
1881  UInt_t mask = 0;
1882  Int_t mx, my, tx, ty;
1883  wid = gVirtualX->GetDefaultRootWindow();
1884  gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1885  switch (keysym) {
1886  case 0x1012: // left
1887  gVirtualX->Warp(--mx, my, wid);
1888  break;
1889  case 0x1013: // up
1890  gVirtualX->Warp(mx, --my, wid);
1891  break;
1892  case 0x1014: // right
1893  gVirtualX->Warp(++mx, my, wid);
1894  break;
1895  case 0x1015: // down
1896  gVirtualX->Warp(mx, ++my, wid);
1897  break;
1898  default:
1899  break;
1900  }
1901  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1902  fCanvasContainer->GetId(),
1903  mx, my, tx, ty, dum1);
1905  previous_keysym = keysym;
1906  }
1907  fButton = 0;
1908  }
1909  previous_event = event->fType;
1910  return kTRUE;
1911 }
1912 
1913 ////////////////////////////////////////////////////////////////////////////////
1914 /// Handle mouse motion event in the canvas container.
1915 
1917 {
1918  Int_t x = event->fX;
1919  Int_t y = event->fY;
1920 
1921  if (fButton == 0)
1923  if (fButton == kButton1) {
1924  if (event->fState & kKeyShiftMask)
1925  fCanvas->HandleInput(EEventType(8), x, y);
1926  else
1928  }
1929  if (fButton == kButton2)
1931 
1932  return kTRUE;
1933 }
1934 
1935 ////////////////////////////////////////////////////////////////////////////////
1936 /// Handle expose events.
1937 
1939 {
1940  if (event->fCount == 0) {
1941  fCanvas->Flush();
1942  }
1943 
1944  return kTRUE;
1945 }
1946 
1947 ////////////////////////////////////////////////////////////////////////////////
1948 /// Handle enter/leave events. Only leave is activated at the moment.
1949 
1951 {
1952  Int_t x = event->fX;
1953  Int_t y = event->fY;
1954 
1955  // pointer grabs create also an enter and leave event but with fCode
1956  // either kNotifyGrab or kNotifyUngrab, don't propagate these events
1957  if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
1959 
1960  return kTRUE;
1961 }
1962 
1963 ////////////////////////////////////////////////////////////////////////////////
1964 /// Handle drop events.
1965 
1967 {
1968  static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
1969  static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
1970 
1971  if (data->fDataType == rootObj) {
1972  TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
1973  buf.SetReadMode();
1975  if (!obj) return kTRUE;
1976  gPad->Clear();
1977  if (obj->InheritsFrom("TKey")) {
1978  TObject *object = (TObject *)gROOT->ProcessLine(Form("((TKey *)0x%lx)->ReadObj();", (ULong_t)obj));
1979  if (!object) return kTRUE;
1980  if (object->InheritsFrom("TGraph"))
1981  object->Draw("ALP");
1982  else if (object->InheritsFrom("TImage"))
1983  object->Draw("x");
1984  else if (object->IsA()->GetMethodAllAny("Draw"))
1985  object->Draw();
1986  }
1987  else if (obj->InheritsFrom("TGraph"))
1988  obj->Draw("ALP");
1989  else if (obj->IsA()->GetMethodAllAny("Draw"))
1990  obj->Draw();
1991  gPad->Modified();
1992  gPad->Update();
1993  return kTRUE;
1994  }
1995  else if (data->fDataType == uriObj) {
1996  TString sfname((char *)data->fData);
1997  if (sfname.Length() > 7) {
1998  sfname.ReplaceAll("\r\n", "");
1999  TUrl uri(sfname.Data());
2000  if (sfname.EndsWith(".bmp") ||
2001  sfname.EndsWith(".gif") ||
2002  sfname.EndsWith(".jpg") ||
2003  sfname.EndsWith(".png") ||
2004  sfname.EndsWith(".ps") ||
2005  sfname.EndsWith(".eps") ||
2006  sfname.EndsWith(".pdf") ||
2007  sfname.EndsWith(".tiff") ||
2008  sfname.EndsWith(".xpm")) {
2009  TImage *img = TImage::Open(uri.GetFile());
2010  if (img) {
2011  img->Draw("x");
2012  img->SetEditable(kTRUE);
2013  }
2014  }
2015  gPad->Modified();
2016  gPad->Update();
2017  }
2018  }
2019  return kFALSE;
2020 }
2021 
2022 ////////////////////////////////////////////////////////////////////////////////
2023 /// Handle dragging position events.
2024 
2026  Int_t /*xroot*/, Int_t /*yroot*/)
2027 {
2028  TPad *pad = fCanvas->Pick(x, y, 0);
2029  if (pad) {
2030  pad->cd();
2031  gROOT->SetSelectedPad(pad);
2032  // make sure the pad is highlighted (on Windows)
2033  pad->Update();
2034  }
2035  return action;
2036 }
2037 
2038 ////////////////////////////////////////////////////////////////////////////////
2039 /// Handle drag enter events.
2040 
2042 {
2043  static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2044  static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2045  Atom_t ret = kNone;
2046  for (int i = 0; typelist[i] != kNone; ++i) {
2047  if (typelist[i] == rootObj)
2048  ret = rootObj;
2049  if (typelist[i] == uriObj)
2050  ret = uriObj;
2051  }
2052  return ret;
2053 }
2054 
2055 ////////////////////////////////////////////////////////////////////////////////
2056 /// Handle drag leave events.
2057 
2059 {
2060  return kTRUE;
2061 }
2062 
2063 ////////////////////////////////////////////////////////////////////////////////
2064 /// Slot handling tab switching in the browser, to properly set the canvas
2065 /// and the model to the editor.
2066 
2068 {
2069  if (fEmbedded) {
2070  TGTab *sender = (TGTab *)gTQSender;
2071  if (sender) {
2072  TGCompositeFrame *cont = sender->GetTabContainer(id);
2073  if (cont == fParent) {
2074  if (!fEditor)
2076  if (fEditor && ((TGedEditor *)fEditor)->IsMapped()) {
2077  ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
2078  ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
2079  }
2080  }
2081  }
2082  }
2083 }
2084 
2085 ////////////////////////////////////////////////////////////////////////////////
2086 /// Save a canvas container as a C++ statement(s) on output stream out.
2087 
2088 void TRootContainer::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
2089 {
2090  out << std::endl << " // canvas container" << std::endl;
2091  out << " Int_t canvasID = gVirtualX->InitWindow((ULong_t)"
2092  << GetParent()->GetParent()->GetName() << "->GetId());" << std::endl;
2093  out << " Window_t winC = gVirtualX->GetWindowID(canvasID);" << std::endl;
2094  out << " TGCompositeFrame *";
2095  out << GetName() << " = new TGCompositeFrame(gClient,winC"
2096  << "," << GetParent()->GetName() << ");" << std::endl;
2097 }
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
const Mask_t kKeyReleaseMask
Definition: GuiTypes.h:161
const TGWindow * fParent
Definition: TGWindow.h:43
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void AddFrame(TGFrame *f, TGLayoutHints *hints)
Add frame to dockable frame container. Frame and hints are NOT adopted.
TGLayoutHints * fMenuBarLayout
Definition: TRootCanvas.h:63
Bool_t GetAutoExec() const
Definition: TCanvas.h:175
TGLayoutHints * fEditorLayout
Definition: TRootCanvas.h:71
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:420
friend class TCanvas
Definition: TCanvasImp.h:33
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:80
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition: TCanvas.cxx:1432
void CreateEditor()
Create embedded editor.
Bool_t IsOnHeap() const
Definition: TObject.h:140
TGPopupMenu * fFileMenu
Definition: TRootCanvas.h:54
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:51
Bool_t UseGL() const
Definition: TCanvas.h:242
ABC describing GUI independent main window (with menubar, scrollbars and a drawing area)...
Definition: TCanvasImp.h:32
Int_t fCanvasID
Definition: TRootCanvas.h:90
TGMenuBar * fMenuBar
Definition: TRootCanvas.h:53
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:20
R__EXTERN Int_t gErrorIgnoreLevel
Definition: TError.h:107
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition: TCanvas.cxx:2124
virtual Bool_t HandleButton(Event_t *)
Definition: TGFrame.h:399
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:865
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
virtual Bool_t HandleKey(Event_t *)
Definition: TGFrame.h:403
void ShowStatusBar(Bool_t show=kTRUE)
Show or hide statusbar.
TGToolTip * fToolTip
Definition: TRootCanvas.h:86
Definition: TGTab.h:66
Ssiz_t Length() const
Definition: TString.h:390
virtual Bool_t HandleDoubleClick(Event_t *)
Definition: TGFrame.h:400
void DockContainer(Int_t del=kTRUE)
Dock container back to TGDockableFrame.
Bool_t HandleContainerConfigure(Event_t *ev)
Handle configure (i.e. resize) event.
TGLayoutHints * fVertical2Layout
Definition: TRootCanvas.h:81
Bool_t fOverwrite
Definition: TGFileDialog.h:67
return c
const char Option_t
Definition: RtypesCore.h:62
Int_t fButton
Definition: TRootCanvas.h:92
const Mask_t kKeyShiftMask
Definition: GuiTypes.h:196
void SetSupportGL(Bool_t support)
Definition: TCanvas.h:243
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:49
This class represents a WWW compatible URL.
Definition: TUrl.h:41
void Reset()
Reset tool tip popup delay timer.
Definition: TGToolTip.cxx:259
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
Int_t fCount
Definition: GuiTypes.h:184
virtual void Hide()
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
Bool_t HandleContainerCrossing(Event_t *ev)
Handle enter/leave events. Only leave is activated at the moment.
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
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.
static TVirtualPadEditor * LoadEditor()
Static function returning a pointer to a new pad editor.
TH1 * h
Definition: legend2.C:5
TGTab * GetTabLeft() const
Definition: TRootBrowser.h:144
UInt_t GetWidth() const
Definition: TGFrame.h:287
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition: TGMenu.cxx:1712
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:169
EGEventType
Definition: GuiTypes.h:60
tuple pname
Definition: tree.py:131
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:45
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
TGHorizontal3DLine * fHorizontal1
Definition: TRootCanvas.h:79
R__EXTERN const char gHelpPullDownMenus[]
Definition: HelpText.h:23
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition: TGMenu.cxx:1833
Bool_t HasFixedAspectRatio() const
Definition: TPad.h:265
virtual void SetContainer(TGFrame *f)
Definition: TGCanvas.h:234
EEventType
Definition: Buttons.h:15
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition: TSystem.cxx:856
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition: TGMenu.cxx:1795
Double_t GetAspectRatio() const
Definition: TPad.h:223
const TGPicture * SetIconPixmap(const char *iconName)
Set window icon pixmap by name.
Definition: TGFrame.cxx:1774
#define gROOT
Definition: TROOT.h:344
TGStatusBar * fStatusBar
Definition: TRootCanvas.h:67
Int_t LoadPlugin()
Load the plugin library for this handler.
virtual void ToggleToolTips()
Toggle tooltip display.
Definition: TCanvas.cxx:2157
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1766
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition: TSystem.cxx:1395
Basic string class.
Definition: TString.h:137
#define gClient
Definition: TGClient.h:174
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:254
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1186
virtual void Update()
Update pad.
Definition: TPad.cxx:2721
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
ERootCanvasCommands
Definition: TRootCanvas.cxx:78
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t GetOptStat() const
Definition: TStyle.h:253
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:985
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:254
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:497
#define gInterpreter
Definition: TInterpreter.h:502
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:45
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:171
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGToolBar.cxx:213
TGCompositeFrame * GetTabContainer(Int_t tabIndex) const
Return container of tab with index tabIndex.
Definition: TGTab.cxx:563
virtual void Print(const char *filename="") const
Save Pad contents in a file in one of various formats.
Definition: TPad.cxx:4134
Float_t py
Definition: hprod.C:33
UInt_t GetHeight() const
Definition: TGFrame.h:288
UInt_t GetWindowHeight() const
Definition: TCanvas.h:185
UInt_t GetCwidth() const
Return width of canvas container.
TGPopupMenu * fToolsMenu
Definition: TRootCanvas.h:61
Long_t ExecPlugin(int nargs, const T &...params)
Bool_t HasStatusBar() const
Returns kTRUE if the status bar is shown.
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:1053
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:558
TGHorizontal3DLine * fToolBarSep
Definition: TRootCanvas.h:75
R__EXTERN const char gHelpBrowser[]
Definition: HelpText.h:17
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: TGMenu.cxx:1055
Bool_t ReturnFromRun() const
Definition: TApplication.h:154
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:16
TFile * f
virtual TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj)
Search for an object at pixel position px,py.
Definition: TCanvas.h:203
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:749
void Iconify()
Definition: TRootCanvas.h:126
void SetDNDTarget(Bool_t onoff)
Definition: TGFrame.h:333
Bool_t HasToolBar() const
Returns kTRUE if the tool bar is shown.
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:164
TGPopupMenu * fViewMenu
Definition: TRootCanvas.h:58
const char * Data() const
Definition: TString.h:349
TGLayoutHints * fHorizontal1Layout
Definition: TRootCanvas.h:82
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.
TCanvas * Canvas() const
Definition: TCanvasImp.h:53
void SetText(const char *helpText)
Set help text from helpText buffer in TGTextView.
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
Definition: TSystem.cxx:1294
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:514
Double_t x[n]
Definition: legend1.C:17
virtual void Paint(Option_t *option="")
Paint canvas.
Definition: TCanvas.cxx:1440
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:2321
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:1410
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:1532
virtual void AddLabel(TGHotString *s, const TGPicture *p=0, TGMenuEntry *before=0)
Add a menu label to the menu.
Definition: TGMenu.cxx:1090
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition: TSystem.cxx:441
virtual void Draw(Option_t *option="")
Paint the color wheel.
TGPopupMenu * fEditMenu
Definition: TRootCanvas.h:56
TGPopupMenu * fEditClearMenu
Definition: TRootCanvas.h:57
void Class()
Definition: Class.C:29
const char ** fFileTypes
Definition: TGFileDialog.h:65
TGDockableFrame * fToolDock
Definition: TRootCanvas.h:83
const Int_t kFatal
Definition: TError.h:44
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:38
Bool_t fAutoFit
Definition: TRootCanvas.h:91
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save Pad contents in a file in one of various formats.
Definition: TPad.cxx:5005
TGCompositeFrame(const TGCompositeFrame &)
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1575
void Clear(Option_t *option="")
Remove all primitives from the canvas.
Definition: TCanvas.cxx:678
TGLayoutHints * fDockLayout
Definition: TRootCanvas.h:84
void * fData
Definition: TGDNDManager.h:79
static void DisplayMarkerTypes()
Display the table of markers with their numbers.
Definition: TMarker.cxx:85
virtual Bool_t HandleExpose(Event_t *event)
Definition: TGWindow.h:107
const char * GetWindowName() const
Definition: TGFrame.h:560
TGPopupMenu * fFileSaveMenu
Definition: TRootCanvas.h:55
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition: TGFrame.cxx:1814
virtual void Show()
TGVertical3DLine * fVertical1
Definition: TRootCanvas.h:77
Bool_t OpaqueMoving() const
Is pad moving in opaque mode ?
Definition: TCanvas.h:200
virtual void SetText(TGString *text, Int_t partidx=0)
Set text in partition partidx in status bar.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
ClassImp(TRootCanvas) TRootCanvas
Create a basic ROOT canvas.
void ReallyDelete()
Really delete the canvas and this GUI.
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:59
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition: TCanvas.cxx:1680
virtual void SetGLDevice(Int_t dev)
Definition: TPad.h:357
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other command generated by the user.
TGPopupMenu * fViewWithMenu
Definition: TRootCanvas.h:59
Int_t GetOptFit() const
Definition: TStyle.h:252
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
Definition: TVirtualPad.h:290
TGLayoutHints * fMenuBarItemLayout
Definition: TRootCanvas.h:64
void RaiseWindow()
Put canvas window on top of the window stack.
friend class TRootContainer
Definition: TRootCanvas.h:48
A doubly linked list.
Definition: TList.h:47
Bool_t HasEditor() const
Returns kTRUE if the editor is shown.
Int_t GetOptTitle() const
Definition: TStyle.h:254
const Mask_t kButtonPressMask
Definition: GuiTypes.h:162
TGCompositeFrame * fMainFrame
Definition: TRootCanvas.h:72
const char Int_t const char TProof Int_t const char * workdir
Definition: TXSlave.cxx:46
const Mask_t kKeyPressMask
Definition: GuiTypes.h:160
virtual Int_t MustCleanup() const
Definition: TGFrame.h:436
TRootCanvas(const TRootCanvas &)
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
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:1135
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.
Bool_t HasMenuBar() const
Returns kTRUE if the menu bar is shown.
virtual void SendCloseMessage()
Send close message to self.
Definition: TGFrame.cxx:1702
TGCanvas * fCanvasWindow
Definition: TRootCanvas.h:51
virtual void ToggleToolBar()
Toggle toolbar.
Definition: TCanvas.cxx:2135
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition: TGTab.cxx:612
Int_t InitWindow()
Called by TCanvas ctor to get window indetifier.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2207
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition: TCanvas.cxx:1616
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
void Popup()
Show help dialog.
EGEventType fType
Definition: GuiTypes.h:176
tuple main
Definition: hsum.py:20
R__EXTERN const char gHelpCanvas[]
Definition: HelpText.h:24
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
Int_t GET_SUBMSG(Long_t val)
Bool_t HandleContainerButton(Event_t *ev)
Handle mouse button events in the canvas container.
UInt_t GetDisplayHeight() const
Get display height.
Definition: TGClient.cxx:273
Bool_t HandleContainerExpose(Event_t *ev)
Handle expose events.
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:494
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:187
virtual void Associate(const TGWindow *w)
Definition: TGMenu.h:227
const Mask_t kExposureMask
Definition: GuiTypes.h:166
Bool_t GetShowToolTips() const
Definition: TCanvas.h:174
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:1204
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:46
TMarker * m
Definition: textangle.C:8
char * Form(const char *fmt,...)
const Handle_t kNone
Definition: GuiTypes.h:89
void ShowToolTips(Bool_t show=kTRUE)
Enable or disable tooltip info.
TVirtualPadEditor * fEditor
Definition: TRootCanvas.h:88
tuple w
Definition: qtexample.py:51
void SetWindowPosition(Int_t x, Int_t y)
Set canvas position (units in pixels).
void SetReadMode()
Set buffer in read mode.
Definition: TBuffer.cxx:269
Bool_t OpaqueResizing() const
Is pad resizing in opaque mode ?
Definition: TCanvas.h:201
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:657
virtual void ToggleEditor()
Toggle editor.
Definition: TCanvas.cxx:2146
Bool_t HandleDNDLeave()
Handle drag leave events.
Bool_t IsNull() const
Definition: TString.h:387
tuple pad
Definition: first.py:38
Atom_t fDataType
Definition: TGDNDManager.h:77
Bool_t HandleDNDDrop(TDNDData *data)
Handle drop events.
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition: TCanvas.cxx:2115
virtual void SetEditable(Bool_t=kTRUE)
Definition: TImage.h:241
TGPopupMenu * fHelpMenu
Definition: TRootCanvas.h:62
void Destructor()
Actual canvas destructor.
Definition: TCanvas.cxx:635
#define gVirtualX
Definition: TVirtualX.h:362
R__EXTERN const char gHelpObjects[]
Definition: HelpText.h:25
static TImage * Create()
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:2500
Int_t GET_MSG(Long_t val)
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
virtual Bool_t HandleMotion(Event_t *)
Definition: TGFrame.h:402
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition: TGFrame.cxx:425
TGFrame * GetActFrame() const
Definition: TRootBrowser.h:141
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
long Long_t
Definition: RtypesCore.h:50
The Canvas class.
Definition: TCanvas.h:48
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:232
virtual Int_t GetSize() const
Definition: TCollection.h:95
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition: TObject.cxx:444
Bool_t GetShowEditor() const
Definition: TCanvas.h:173
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:167
static const char * gOpenTypes[]
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
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
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:163
TGLayoutHints * fVertical1Layout
Definition: TRootCanvas.h:80
UInt_t fCode
Definition: GuiTypes.h:181
TGVertical3DLine * fVertical2
Definition: TRootCanvas.h:78
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
void dir(char *path=0)
Definition: rootalias.C:30
UInt_t GetCheight() const
Return height of canvas container.
unsigned long ULong_t
Definition: RtypesCore.h:51
Int_t fFileTypeIdx
Definition: TGFileDialog.h:66
TGLayoutHints * fStatusBarLayout
Definition: TRootCanvas.h:68
char * fFilename
Definition: TGFileDialog.h:63
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:22
#define gGLManager
Definition: TVirtualGL.h:168
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:1293
Abstract base class used by ROOT graphics editor.
virtual void StopEmbedding(const char *name=0)
Definition: TRootBrowser.h:156
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:2801
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:85
Handle_t fId
Definition: TGObject.h:40
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
Atom_t HandleDNDEnter(Atom_t *typelist)
Handle drag enter events.
Float_t px
Definition: hprod.C:33
TGPopupMenu * fOptionMenu
Definition: TRootCanvas.h:60
Handle_t Window_t
Definition: GuiTypes.h:30
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:1770
void Activated(Int_t id)
Slot handling tab switching in the browser, to properly set the canvas and the model to the editor...
const Ssiz_t kNPOS
Definition: Rtypes.h:115
static TGuiBuilder * Instance()
return an instance of TGuiBuilder object
TGClient * fClient
Definition: TGObject.h:41
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
void SetStatusText(const char *txt=0, Int_t partidx=0)
Set text in status bar.
void Close()
Called via TCanvasImp interface by TCanvas.
void FitCanvas()
Fit canvas container to current window size.
const char * fPixmap
Definition: TGToolBar.h:35
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:1252
void SetOptTitle(Int_t tit=1)
Definition: TStyle.h:330
#define NULL
Definition: Rtypes.h:82
#define gPad
Definition: TVirtualPad.h:288
UInt_t fState
Definition: GuiTypes.h:182
void SetWindowSize(UInt_t w, UInt_t h)
Set size of canvas (units in pixels).
TGToolBar * fToolBar
Definition: TRootCanvas.h:74
Atom_t * fDNDTypeList
Definition: TGFrame.h:498
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:76
void SetWindowName(const char *name)
Set window name so it appear as title of the undock window.
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:1147
TGLayoutHints * fMenuBarHelpLayout
Definition: TRootCanvas.h:65
Bool_t HasToolTips() const
Returns kTRUE if the tooltips are enabled.
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:391
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition: TCanvas.cxx:1136
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:2179
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
TGCompositeFrame * fEditorFrame
Definition: TRootCanvas.h:70
TRootContainer * fCanvasContainer
Definition: TRootCanvas.h:52
virtual void SetEditable(Bool_t on=kTRUE)
Switch ON/OFF edit mode.
Definition: TGFrame.cxx:930
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
const Bool_t kTRUE
Definition: Rtypes.h:91
Definition: Buttons.h:22
TGLayoutHints * fToolBarLayout
Definition: TRootCanvas.h:73
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:459
const Mask_t kAnyModifier
Definition: GuiTypes.h:211
TObject * obj
void SetCanvasSize(UInt_t w, UInt_t h)
Set size of canvas container. Units in pixels.
Int_t Nint(T x)
Definition: TMath.h:480
Handle_t GetId() const
Definition: TGObject.h:52
TGTab * GetTabRight() const
Definition: TRootBrowser.h:145
TCanvas * fCanvas
Definition: TCanvasImp.h:36
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:34
void Modified(Bool_t flag=1)
Definition: TPad.h:407
virtual Bool_t HandleCrossing(Event_t *)
Definition: TGFrame.h:401
void SetWindowTitle(const char *newTitle)
Change title on window.
Bool_t fEmbedded
Definition: TRootCanvas.h:89
Draw inheritance tree and their relations for a list of classes.
Definition: TClassTree.h:31
char * fIniDir
Definition: TGFileDialog.h:64
virtual void SetGlobal(Bool_t)
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:229
virtual TCanvas * GetCanvas() const =0
void EnableHide(Bool_t onoff)
Enable hiding.
Bool_t IsUndocked() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904
TGLayoutHints * fCanvasLayout
Definition: TRootCanvas.h:66