Logo ROOT   6.10/00
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 
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  delete this;
706 }
707 
708 ////////////////////////////////////////////////////////////////////////////////
709 /// In case window is closed via WM we get here.
710 
712 {
713  DeleteWindow();
714 }
715 
716 ////////////////////////////////////////////////////////////////////////////////
717 /// Return width of canvas container.
718 
720 {
721  return fCanvasContainer->GetWidth();
722 }
723 
724 ////////////////////////////////////////////////////////////////////////////////
725 /// Return height of canvas container.
726 
728 {
729  return fCanvasContainer->GetHeight();
730 }
731 
732 ////////////////////////////////////////////////////////////////////////////////
733 /// Gets the size and position of the window containing the canvas. This
734 /// size includes the menubar and borders.
735 
737 {
738  gVirtualX->GetWindowSize(fId, x, y, w, h);
739 
740  Window_t childdum;
741  gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(),
742  0, 0, x, y, childdum);
743  if (!fCanvas->GetShowEditor()) return 0;
744  return fEditorFrame->GetWidth();
745 }
746 
747 ////////////////////////////////////////////////////////////////////////////////
748 /// Set text in status bar.
749 
750 void TRootCanvas::SetStatusText(const char *txt, Int_t partidx)
751 {
752  fStatusBar->SetText(txt, partidx);
753 }
754 
755 ////////////////////////////////////////////////////////////////////////////////
756 /// Handle menu and other command generated by the user.
757 
759 {
760  TRootHelpDialog *hd;
761  TList *lc;
762 
763  switch (GET_MSG(msg)) {
764 
765  case kC_COMMAND:
766 
767  switch (GET_SUBMSG(msg)) {
768 
769  case kCM_BUTTON:
770  case kCM_MENU:
771 
772  switch (parm1) {
773  // Handle toolbar items...
774  case kToolModify:
775  gROOT->SetEditorMode();
776  break;
777  case kToolArc:
778  gROOT->SetEditorMode("Arc");
779  break;
780  case kToolLine:
781  gROOT->SetEditorMode("Line");
782  break;
783  case kToolArrow:
784  gROOT->SetEditorMode("Arrow");
785  break;
786  case kToolDiamond:
787  gROOT->SetEditorMode("Diamond");
788  break;
789  case kToolEllipse:
790  gROOT->SetEditorMode("Ellipse");
791  break;
792  case kToolPad:
793  gROOT->SetEditorMode("Pad");
794  break;
795  case kToolPave:
796  gROOT->SetEditorMode("Pave");
797  break;
798  case kToolPLabel:
799  gROOT->SetEditorMode("PaveLabel");
800  break;
801  case kToolPText:
802  gROOT->SetEditorMode("PaveText");
803  break;
804  case kToolPsText:
805  gROOT->SetEditorMode("PavesText");
806  break;
807  case kToolGraph:
808  gROOT->SetEditorMode("PolyLine");
809  break;
810  case kToolCurlyLine:
811  gROOT->SetEditorMode("CurlyLine");
812  break;
813  case kToolCurlyArc:
814  gROOT->SetEditorMode("CurlyArc");
815  break;
816  case kToolLatex:
817  gROOT->SetEditorMode("Text");
818  break;
819  case kToolMarker:
820  gROOT->SetEditorMode("Marker");
821  break;
822  case kToolCutG:
823  gROOT->SetEditorMode("CutG");
824  break;
825 
826  // Handle File menu items...
827  case kFileNewCanvas:
828  gROOT->MakeDefCanvas();
829  break;
830  case kFileOpen:
831  {
832  static TString dir(".");
833  TGFileInfo fi;
834  fi.fFileTypes = gOpenTypes;
835  fi.fIniDir = StrDup(dir);
836  new TGFileDialog(fClient->GetDefaultRoot(), this, kFDOpen,&fi);
837  if (!fi.fFilename) return kTRUE;
838  dir = fi.fIniDir;
839  new TFile(fi.fFilename, "update");
840  }
841  break;
842  case kFileSaveAs:
843  {
844  TString workdir = gSystem->WorkingDirectory();
845  static TString dir(".");
846  static Int_t typeidx = 0;
847  static Bool_t overwr = kFALSE;
848  TGFileInfo fi;
849  TString defaultType = gEnv->GetValue("Canvas.SaveAsDefaultType", ".pdf");
850  if (typeidx == 0) {
851  for (int i=1;gSaveAsTypes[i];i+=2) {
852  TString ftype = gSaveAsTypes[i];
853  if (ftype.EndsWith(defaultType.Data())) {
854  typeidx = i-1;
855  break;
856  }
857  }
858  }
860  fi.fIniDir = StrDup(dir);
861  fi.fFileTypeIdx = typeidx;
862  fi.fOverwrite = overwr;
863  new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi);
864  gSystem->ChangeDirectory(workdir.Data());
865  if (!fi.fFilename) return kTRUE;
866  Bool_t appendedType = kFALSE;
867  TString fn = fi.fFilename;
868  TString ft = fi.fFileTypes[fi.fFileTypeIdx+1];
869  dir = fi.fIniDir;
870  typeidx = fi.fFileTypeIdx;
871  overwr = fi.fOverwrite;
872 again:
873  if (fn.EndsWith(".root") ||
874  fn.EndsWith(".ps") ||
875  fn.EndsWith(".eps") ||
876  fn.EndsWith(".pdf") ||
877  fn.EndsWith(".svg") ||
878  fn.EndsWith(".tex") ||
879  fn.EndsWith(".gif") ||
880  fn.EndsWith(".xml") ||
881  fn.EndsWith(".xpm") ||
882  fn.EndsWith(".jpg") ||
883  fn.EndsWith(".png") ||
884  fn.EndsWith(".xcf") ||
885  fn.EndsWith(".tiff")) {
886  fCanvas->SaveAs(fn);
887  } else if (fn.EndsWith(".C"))
888  fCanvas->SaveSource(fn);
889  else {
890  if (!appendedType) {
891  if (ft.Index(".") != kNPOS) {
892  fn += ft(ft.Index("."), ft.Length());
893  appendedType = kTRUE;
894  goto again;
895  }
896  }
897  Warning("ProcessMessage", "file %s cannot be saved with this extension", fi.fFilename);
898  }
899  for (int i=1;gSaveAsTypes[i];i+=2) {
900  TString ftype = gSaveAsTypes[i];
901  ftype.ReplaceAll("*.", ".");
902  if (fn.EndsWith(ftype.Data())) {
903  typeidx = i-1;
904  break;
905  }
906  }
907  }
908  break;
909  case kFileSaveAsRoot:
910  fCanvas->SaveAs(".root");
911  break;
912  case kFileSaveAsC:
913  fCanvas->SaveSource();
914  break;
915  case kFileSaveAsPS:
916  fCanvas->SaveAs();
917  break;
918  case kFileSaveAsEPS:
919  fCanvas->SaveAs(".eps");
920  break;
921  case kFileSaveAsPDF:
922  fCanvas->SaveAs(".pdf");
923  break;
924  case kFileSaveAsGIF:
925  fCanvas->SaveAs(".gif");
926  break;
927  case kFileSaveAsJPG:
928  fCanvas->SaveAs(".jpg");
929  break;
930  case kFileSaveAsPNG:
931  fCanvas->SaveAs(".png");
932  break;
933  case kFileSaveAsTEX:
934  fCanvas->SaveAs(".tex");
935  break;
936  case kFilePrint:
937  PrintCanvas();
938  break;
939  case kFileCloseCanvas:
941  break;
942  case kFileQuit:
943  if (!gApplication->ReturnFromRun()) {
947  }
950  if (TClass::GetClass("TStyleManager"))
951  gROOT->ProcessLine("TStyleManager::Terminate()");
953  break;
954 
955  // Handle Edit menu items...
956  case kEditStyle:
957  if (!TClass::GetClass("TStyleManager"))
958  gSystem->Load("libGed");
959  gROOT->ProcessLine("TStyleManager::Show()");
960  break;
961  case kEditCut:
962  // still noop
963  break;
964  case kEditCopy:
965  // still noop
966  break;
967  case kEditPaste:
968  // still noop
969  break;
970  case kEditUndo:
971  // noop
972  break;
973  case kEditRedo:
974  // noop
975  break;
976  case kEditClearPad:
977  gPad->Clear();
978  gPad->Modified();
979  gPad->Update();
980  break;
981  case kEditClearCanvas:
982  fCanvas->Clear();
983  fCanvas->Modified();
984  fCanvas->Update();
985  break;
986 
987  // Handle View menu items...
988  case kViewEditor:
990  break;
991  case kViewToolbar:
993  break;
994  case kViewEventStatus:
996  break;
997  case kViewToolTips:
999  break;
1000  case kViewColors:
1001  {
1002  TVirtualPad *padsav = gPad->GetCanvas();
1003  //This was the code with the old color table
1004  // TCanvas *m = new TCanvas("colors","Color Table");
1005  // TPad::DrawColorTable();
1006  // m->Update();
1007  TColorWheel *wheel = new TColorWheel();
1008  wheel->Draw();
1009 
1010  //tp: with Cocoa, window is visible (and repainted)
1011  //before wheel->Draw() was called and you can see "empty"
1012  //canvas.
1013  gPad->Update();
1014  //
1015  if (padsav) padsav->cd();
1016  }
1017  break;
1018  case kViewFonts:
1019  // noop
1020  break;
1021  case kViewMarkers:
1022  {
1023  TVirtualPad *padsav = gPad->GetCanvas();
1024  TCanvas *m = new TCanvas("markers","Marker Types",600,200);
1026  m->Update();
1027  if (padsav) padsav->cd();
1028  }
1029  break;
1030  case kViewIconify:
1031  Iconify();
1032  break;
1033  case kViewX3D:
1034  gPad->GetViewer3D("x3d");
1035  break;
1036  case kViewOpenGL:
1037  gPad->GetViewer3D("ogl");
1038  break;
1039 
1040  // Handle Option menu items...
1041  case kOptionAutoExec:
1043  if (fCanvas->GetAutoExec()) {
1045  } else {
1047  }
1048  break;
1049  case kOptionAutoResize:
1050  {
1051  fAutoFit = fAutoFit ? kFALSE : kTRUE;
1052  int opt = fCanvasContainer->GetOptions();
1053  if (fAutoFit) {
1054  opt &= ~kFixedSize;
1056  } else {
1057  opt |= kFixedSize;
1059  }
1060  fCanvasContainer->ChangeOptions(opt);
1061  // in case of autofit this will generate a configure
1062  // event for the container and this will force the
1063  // update of the TCanvas
1064  //Layout();
1065  }
1066  Layout();
1067  break;
1068  case kOptionResizeCanvas:
1069  FitCanvas();
1070  break;
1071  case kOptionMoveOpaque:
1072  if (fCanvas->OpaqueMoving()) {
1073  fCanvas->MoveOpaque(0);
1075  } else {
1076  fCanvas->MoveOpaque(1);
1078  }
1079  break;
1080  case kOptionResizeOpaque:
1081  if (fCanvas->OpaqueResizing()) {
1082  fCanvas->ResizeOpaque(0);
1084  } else {
1085  fCanvas->ResizeOpaque(1);
1087  }
1088  break;
1089  case kOptionInterrupt:
1090  gROOT->SetInterrupt();
1091  break;
1092  case kOptionRefresh:
1093  fCanvas->Paint();
1094  fCanvas->Update();
1095  break;
1096  case kOptionStatistics:
1097  if (gStyle->GetOptStat()) {
1098  gStyle->SetOptStat(0);
1099  delete gPad->FindObject("stats");
1101  } else {
1102  gStyle->SetOptStat(1);
1104  }
1105  gPad->Modified();
1106  fCanvas->Update();
1107  break;
1108  case kOptionHistTitle:
1109  if (gStyle->GetOptTitle()) {
1110  gStyle->SetOptTitle(0);
1111  delete gPad->FindObject("title");
1113  } else {
1114  gStyle->SetOptTitle(1);
1116  }
1117  gPad->Modified();
1118  fCanvas->Update();
1119  break;
1120  case kOptionFitParams:
1121  if (gStyle->GetOptFit()) {
1122  gStyle->SetOptFit(0);
1124  } else {
1125  gStyle->SetOptFit(1);
1127  }
1128  gPad->Modified();
1129  fCanvas->Update();
1130  break;
1131  case kOptionCanEdit:
1132  if (gROOT->GetEditHistograms()) {
1133  gROOT->SetEditHistograms(kFALSE);
1135  } else {
1136  gROOT->SetEditHistograms(kTRUE);
1138  }
1139  break;
1140 
1141  // Handle Tools menu items...
1142  case kInspectRoot:
1143  fCanvas->cd();
1144  gROOT->Inspect();
1145  fCanvas->Update();
1146  break;
1147  case kToolsBrowser:
1148  new TBrowser("browser");
1149  break;
1150  case kToolsBuilder:
1152  break;
1153  case kToolsRecorder:
1154  gROOT->ProcessLine("new TGRecorder()");
1155  break;
1156 
1157  // Handle Tools menu items...
1158  case kClassesTree:
1159  {
1160  TString cdef;
1161  lc = (TList*)gROOT->GetListOfCanvases();
1162  if (lc->FindObject("ClassTree")) {
1163  cdef = TString::Format("ClassTree_%d", lc->GetSize()+1);
1164  } else {
1165  cdef = "ClassTree";
1166  }
1167  new TClassTree(cdef.Data(), "TObject");
1168  fCanvas->Update();
1169  }
1170  break;
1171 
1172  case kFitPanel:
1173  {
1174  // use plugin manager to create instance of TFitEditor
1175  TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
1176  if (handler && handler->LoadPlugin() != -1) {
1177  if (handler->ExecPlugin(2, fCanvas, 0) == 0)
1178  Error("FitPanel", "Unable to crate the FitPanel");
1179  }
1180  else
1181  Error("FitPanel", "Unable to find the FitPanel plug-in");
1182  }
1183  break;
1184 
1185  // Handle Help menu items...
1186  case kHelpAbout:
1187  {
1188 #ifdef R__UNIX
1189  TString rootx = TROOT::GetBinDir() + "/root -a &";
1190  gSystem->Exec(rootx);
1191 #else
1192 #ifdef WIN32
1194 #else
1195 
1196  char str[32];
1197  sprintf(str, "About ROOT %s...", gROOT->GetVersion());
1198  hd = new TRootHelpDialog(this, str, 600, 400);
1199  hd->SetText(gHelpAbout);
1200  hd->Popup();
1201 #endif
1202 #endif
1203  }
1204  break;
1205  case kHelpOnCanvas:
1206  hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1207  hd->SetText(gHelpCanvas);
1208  hd->Popup();
1209  break;
1210  case kHelpOnMenus:
1211  hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1213  hd->Popup();
1214  break;
1215  case kHelpOnGraphicsEd:
1216  hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1218  hd->Popup();
1219  break;
1220  case kHelpOnBrowser:
1221  hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1222  hd->SetText(gHelpBrowser);
1223  hd->Popup();
1224  break;
1225  case kHelpOnObjects:
1226  hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
1227  hd->SetText(gHelpObjects);
1228  hd->Popup();
1229  break;
1230  case kHelpOnPS:
1231  hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
1232  hd->SetText(gHelpPostscript);
1233  hd->Popup();
1234  break;
1235  }
1236  default:
1237  break;
1238  }
1239  default:
1240  break;
1241  }
1242  return kTRUE;
1243 }
1244 
1245 ////////////////////////////////////////////////////////////////////////////////
1246 /// Called by TCanvas ctor to get window indetifier.
1247 
1249 {
1250  if (fCanvas->OpaqueMoving())
1252  if (fCanvas->OpaqueResizing())
1254 
1255  return fCanvasID;
1256 }
1257 
1258 ////////////////////////////////////////////////////////////////////////////////
1259 /// Set size of canvas container. Units in pixels.
1260 
1262 {
1263  // turn off autofit, we want to stay at the given size
1264  fAutoFit = kFALSE;
1266  int opt = fCanvasContainer->GetOptions();
1267  opt |= kFixedSize; // turn on fixed size mode
1268  fCanvasContainer->ChangeOptions(opt);
1269  fCanvasContainer->SetWidth(w);
1270  fCanvasContainer->SetHeight(h);
1271  Layout(); // force layout (will update container to given size)
1272  fCanvas->Resize();
1273  fCanvas->Update();
1274 }
1275 
1276 ////////////////////////////////////////////////////////////////////////////////
1277 /// Set canvas position (units in pixels).
1278 
1280 {
1281  Move(x, y);
1282 }
1283 
1284 ////////////////////////////////////////////////////////////////////////////////
1285 /// Set size of canvas (units in pixels).
1286 
1288 {
1289  Resize(w, h);
1290 
1291  // Make sure the change of size is really done.
1292  if (!gThreadXAR) {
1294  gSystem->Sleep(10);
1296  }
1297 }
1298 
1299 ////////////////////////////////////////////////////////////////////////////////
1300 /// Put canvas window on top of the window stack.
1301 
1303 {
1304  gVirtualX->RaiseWindow(GetId());
1305 }
1306 
1307 ////////////////////////////////////////////////////////////////////////////////
1308 /// Change title on window.
1309 
1310 void TRootCanvas::SetWindowTitle(const char *title)
1311 {
1312  SetWindowName(title);
1313  SetIconName(title);
1314  fToolDock->SetWindowName(Form("ToolBar: %s", title));
1315 }
1316 
1317 ////////////////////////////////////////////////////////////////////////////////
1318 /// Fit canvas container to current window size.
1319 
1321 {
1322  if (!fAutoFit) {
1323  int opt = fCanvasContainer->GetOptions();
1324  int oopt = opt;
1325  opt &= ~kFixedSize; // turn off fixed size mode
1326  fCanvasContainer->ChangeOptions(opt);
1327  Layout(); // force layout
1328  fCanvas->Resize();
1329  fCanvas->Update();
1330  fCanvasContainer->ChangeOptions(oopt);
1331  }
1332 }
1333 
1334 ////////////////////////////////////////////////////////////////////////////////
1335 /// Print the canvas.
1336 
1338 {
1339  Int_t ret = 0;
1340  Bool_t pname = kTRUE;
1341  char *printer, *printCmd;
1342  static TString sprinter, sprintCmd;
1343 
1344  if (sprinter == "")
1345  printer = StrDup(gEnv->GetValue("Print.Printer", ""));
1346  else
1347  printer = StrDup(sprinter);
1348  if (sprintCmd == "")
1349 #ifndef WIN32
1350  printCmd = StrDup(gEnv->GetValue("Print.Command", ""));
1351 #else
1352  printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p"));
1353 #endif
1354  else
1355  printCmd = StrDup(sprintCmd);
1356 
1357  new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
1358  &printer, &printCmd, &ret);
1359  if (ret) {
1360  sprinter = printer;
1361  sprintCmd = printCmd;
1362 
1363  if (sprinter == "")
1364  pname = kFALSE;
1365 
1366  TString fn = "rootprint";
1367  FILE *f = gSystem->TempFileName(fn, gEnv->GetValue("Print.Directory", gSystem->TempDirectory()));
1368  if (f) fclose(f);
1369  fn += TString::Format(".%s",gEnv->GetValue("Print.FileType", "pdf"));
1370  fCanvas->Print(fn);
1371 
1372  TString cmd = sprintCmd;
1373  if (cmd.Contains("%p"))
1374  cmd.ReplaceAll("%p", sprinter);
1375  else if (pname) {
1376  cmd += " "; cmd += sprinter; cmd += " ";
1377  }
1378 
1379  if (cmd.Contains("%f"))
1380  cmd.ReplaceAll("%f", fn);
1381  else {
1382  cmd += " "; cmd += fn; cmd += " ";
1383  }
1384 
1385  gSystem->Exec(cmd);
1386 #ifndef WIN32
1387  gSystem->Unlink(fn);
1388 #endif
1389  }
1390  delete [] printer;
1391  delete [] printCmd;
1392 }
1393 
1394 ////////////////////////////////////////////////////////////////////////////////
1395 /// Display a tooltip with infos about the primitive below the cursor.
1396 
1397 void TRootCanvas::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
1398 {
1399  fToolTip->Hide();
1400  if (!fCanvas->GetShowToolTips() || selected == 0 ||
1401  event != kMouseMotion || fButton != 0)
1402  return;
1403  TString tipInfo;
1404  TString objInfo = selected->GetObjectInfo(px, py);
1405  if (objInfo.BeginsWith("-")) {
1406  // if the string begins with '-', display only the object info
1407  objInfo.Remove(TString::kLeading, '-');
1408  tipInfo = objInfo;
1409  }
1410  else {
1411  const char *title = selected->GetTitle();
1412  tipInfo += TString::Format("%s::%s", selected->ClassName(),
1413  selected->GetName());
1414  if (title && strlen(title))
1415  tipInfo += TString::Format("\n%s", selected->GetTitle());
1416  tipInfo += TString::Format("\n%d, %d", px, py);
1417  if (!objInfo.IsNull())
1418  tipInfo += TString::Format("\n%s", objInfo.Data());
1419  }
1420  fToolTip->SetText(tipInfo.Data());
1421  fToolTip->SetPosition(px+15, py+15);
1422  fToolTip->Reset();
1423 }
1424 
1425 ////////////////////////////////////////////////////////////////////////////////
1426 /// Show or hide menubar.
1427 
1429 {
1430  if (show) ShowFrame(fMenuBar);
1431  else HideFrame(fMenuBar);
1432 }
1433 
1434 ////////////////////////////////////////////////////////////////////////////////
1435 /// Show or hide statusbar.
1436 
1438 {
1440  UInt_t ch = fCanvas->GetWindowHeight();
1441 
1442  UInt_t h = GetHeight();
1443  UInt_t sh = fStatusBar->GetHeight()+2;
1444 
1445  if (show) {
1448  if (dh - ch >= sh) h = h + sh;
1449  else h = ch;
1450  } else {
1453  if (dh - ch < sh) h = ch;
1454  else h = h - sh;
1455  }
1456  Resize(GetWidth(), h);
1457 }
1458 
1459 ////////////////////////////////////////////////////////////////////////////////
1460 /// Show or hide side frame.
1461 
1463 {
1464  TVirtualPad *savedPad = 0;
1465  savedPad = (TVirtualPad *) gPad;
1466  gPad = Canvas();
1467 
1468  UInt_t w = GetWidth();
1470  UInt_t h = GetHeight();
1471  UInt_t s = fHorizontal1->GetHeight();
1472 
1473  if (fParent && fParent != fClient->GetDefaultRoot()) {
1476  if (main && main->InheritsFrom("TRootBrowser")) {
1477  TRootBrowser *browser = (TRootBrowser *)main;
1478  if (!fEmbedded)
1479  browser->GetTabRight()->Connect("Selected(Int_t)", "TRootCanvas",
1480  this, "Activated(Int_t)");
1481  fEmbedded = kTRUE;
1482  if (show && (!fEditor || !((TGedEditor *)fEditor)->IsMapped())) {
1483  if (!browser->GetTabLeft()->GetTabTab("Pad Editor")) {
1484  if (browser->GetActFrame()) { //already in edit mode
1485  TTimer::SingleShot(200, "TRootCanvas", this, "ShowEditor(=kTRUE)");
1486  } else {
1488  if (!fEditor)
1490  else {
1491  ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot());
1492  ((TGedEditor *)fEditor)->MapWindow();
1493  }
1494  browser->StopEmbedding("Pad Editor");
1495  if (fEditor) {
1497  gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor);
1498  ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
1499  ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
1500  }
1501  }
1502  }
1503  else
1505  }
1506  if (show) browser->GetTabLeft()->SetTab("Pad Editor");
1507  }
1508  }
1509  else {
1510  if (show) {
1511  if (!fEditor) CreateEditor();
1513  if(gged && gged->GetCanvas() == fCanvas){
1514  gged->Hide();
1515  }
1518  h = h + s;
1519  }
1521  fEditor->Show();
1523  w = w + e;
1524  } else {
1527  h = h - s;
1528  }
1529  if (fEditor) fEditor->Hide();
1532  w = w - e;
1533  }
1534  Resize(w, h);
1535  }
1536  if (savedPad) gPad = savedPad;
1537 }
1538 
1539 ////////////////////////////////////////////////////////////////////////////////
1540 /// Create embedded editor.
1541 
1543 {
1546  gPad = Canvas();
1547  // next two lines are related to the old editor
1548  Int_t show = gEnv->GetValue("Canvas.ShowEditor", 0);
1549  gEnv->SetValue("Canvas.ShowEditor","true");
1554 
1555  // next line is related to the old editor
1556  if (show == 0) gEnv->SetValue("Canvas.ShowEditor","false");
1557 }
1558 
1559 ////////////////////////////////////////////////////////////////////////////////
1560 /// Show or hide toolbar.
1561 
1563 {
1564  if (show && !fToolBar) {
1565 
1566  fToolBar = new TGToolBar(fToolDock, 60, 20, kHorizontalFrame);
1568 
1569  Int_t spacing = 6, i;
1570  for (i = 0; gToolBarData[i].fPixmap; i++) {
1571  if (strlen(gToolBarData[i].fPixmap) == 0) {
1572  spacing = 6;
1573  continue;
1574  }
1575  fToolBar->AddButton(this, &gToolBarData[i], spacing);
1576  spacing = 0;
1577  }
1584 
1585  spacing = 6;
1586  for (i = 0; gToolBarData1[i].fPixmap; i++) {
1587  if (strlen(gToolBarData1[i].fPixmap) == 0) {
1588  spacing = 6;
1589  continue;
1590  }
1591  fToolBar->AddButton(this, &gToolBarData1[i], spacing);
1592  spacing = 0;
1593  }
1595  fToolDock->Layout();
1596  fToolDock->SetWindowName(Form("ToolBar: %s", GetWindowName()));
1597  fToolDock->Connect("Docked()", "TRootCanvas", this, "AdjustSize()");
1598  fToolDock->Connect("Undocked()", "TRootCanvas", this, "AdjustSize()");
1599  }
1600 
1601  if (!fToolBar) return;
1602 
1603  UInt_t h = GetHeight();
1604  UInt_t sh = fToolBarSep->GetHeight();
1605  UInt_t dh = fToolBar->GetHeight();
1606 
1607  if (show) {
1611  h = h + sh;
1612  }
1615  h = h + dh + sh;
1616  } else {
1617  if (fToolDock->IsUndocked()) {
1619  h = h + 2*sh;
1620  } else h = h - dh;
1621 
1625  h = h - sh;
1626  }
1628  h = h - sh;
1630  }
1631  Resize(GetWidth(), h);
1632 }
1633 
1634 ////////////////////////////////////////////////////////////////////////////////
1635 /// Enable or disable tooltip info.
1636 
1638 {
1639  if (show)
1641  else
1643 }
1644 
1645 ////////////////////////////////////////////////////////////////////////////////
1646 /// Returns kTRUE if the editor is shown.
1647 
1649 {
1651 }
1652 
1653 ////////////////////////////////////////////////////////////////////////////////
1654 /// Returns kTRUE if the menu bar is shown.
1655 
1657 {
1658  return (fMenuBar) && fMenuBar->IsMapped();
1659 }
1660 
1661 ////////////////////////////////////////////////////////////////////////////////
1662 /// Returns kTRUE if the status bar is shown.
1663 
1665 {
1666  return (fStatusBar) && fStatusBar->IsMapped();
1667 }
1668 
1669 ////////////////////////////////////////////////////////////////////////////////
1670 /// Returns kTRUE if the tool bar is shown.
1671 
1673 {
1674  return (fToolBar) && fToolBar->IsMapped();
1675 }
1676 
1677 ////////////////////////////////////////////////////////////////////////////////
1678 /// Returns kTRUE if the tooltips are enabled.
1679 
1681 {
1682  return (fCanvas) && fCanvas->GetShowToolTips();
1683 }
1684 
1685 ////////////////////////////////////////////////////////////////////////////////
1686 /// Keep the same canvas size while docking/undocking toolbar.
1687 
1689 {
1690  UInt_t h = GetHeight();
1691  UInt_t dh = fToolBar->GetHeight();
1692  UInt_t sh = fHorizontal1->GetHeight();
1693 
1694  if (fToolDock->IsUndocked()) {
1697  h = h - sh;
1698  }
1700  h = h - dh - sh;
1701  } else {
1704  h = h + sh;
1705  }
1707  h = h + dh + sh;
1708  }
1709  Resize(GetWidth(), h);
1710 }
1711 
1712 ////////////////////////////////////////////////////////////////////////////////
1713 /// Handle mouse button events in the canvas container.
1714 
1716 {
1717  Int_t button = event->fCode;
1718  Int_t x = event->fX;
1719  Int_t y = event->fY;
1720 
1721  if (event->fType == kButtonPress) {
1722  if (fToolTip && fCanvas->GetShowToolTips()) {
1723  fToolTip->Hide();
1724  gVirtualX->UpdateWindow(0);
1726  }
1727  fButton = button;
1728  if (button == kButton1) {
1729  if (event->fState & kKeyShiftMask)
1731  else
1733  }
1734  if (button == kButton2)
1736  if (button == kButton3) {
1738  fButton = 0; // button up is consumed by TContextMenu
1739  }
1740 
1741  } else if (event->fType == kButtonRelease) {
1742  if (button == kButton4)
1743  fCanvas->HandleInput(kWheelUp, x, y);
1744  if (button == kButton5)
1745  fCanvas->HandleInput(kWheelDown, x, y);
1746  if (button == kButton1)
1747  fCanvas->HandleInput(kButton1Up, x, y);
1748  if (button == kButton2)
1749  fCanvas->HandleInput(kButton2Up, x, y);
1750  if (button == kButton3)
1751  fCanvas->HandleInput(kButton3Up, x, y);
1752 
1753  fButton = 0;
1754  }
1755 
1756  return kTRUE;
1757 }
1758 
1759 ////////////////////////////////////////////////////////////////////////////////
1760 /// Handle mouse button double click events in the canvas container.
1761 
1763 {
1764  Int_t button = event->fCode;
1765  Int_t x = event->fX;
1766  Int_t y = event->fY;
1767 
1768  if (button == kButton1)
1770  if (button == kButton2)
1772  if (button == kButton3)
1774 
1775  return kTRUE;
1776 }
1777 
1778 ////////////////////////////////////////////////////////////////////////////////
1779 /// Handle configure (i.e. resize) event.
1780 
1782 {
1783  if (fAutoFit) {
1784  fCanvas->Resize();
1785  fCanvas->Update();
1786  }
1787 
1788  if (fCanvas->HasFixedAspectRatio()) {
1789  // get menu height
1790  static Int_t dh = 0;
1791  if (!dh)
1792  dh = GetHeight() - fCanvasContainer->GetHeight();
1793  UInt_t h = TMath::Nint(fCanvasContainer->GetWidth()/
1794  fCanvas->GetAspectRatio()) + dh;
1795  SetWindowSize(GetWidth(), h);
1796  }
1797  return kTRUE;
1798 }
1799 
1800 ////////////////////////////////////////////////////////////////////////////////
1801 /// Handle keyboard events in the canvas container.
1802 
1804 {
1805  static EGEventType previous_event = kOtherEvent;
1806  static UInt_t previous_keysym = 0;
1807 
1808  if (event->fType == kGKeyPress) {
1809  fButton = event->fCode;
1810  UInt_t keysym;
1811  char str[2];
1812  gVirtualX->LookupString(event, str, sizeof(str), keysym);
1813 
1814  if (str[0] == kESC){ // ESC sets the escape flag
1815  gROOT->SetEscape();
1816  fCanvas->HandleInput(kButton1Up, 0, 0);
1818  gPad->Modified();
1819  return kTRUE;
1820  }
1821  if (str[0] == 3) // ctrl-c sets the interrupt flag
1822  gROOT->SetInterrupt();
1823 
1824  // handle arrow keys
1825  if (keysym > 0x1011 && keysym < 0x1016) {
1826  Window_t dum1, dum2, wid;
1827  UInt_t mask = 0;
1828  Int_t mx, my, tx, ty;
1829  wid = gVirtualX->GetDefaultRootWindow();
1830  gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1831  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1832  fCanvasContainer->GetId(),
1833  mx, my, tx, ty, dum1);
1835  // handle case where we got consecutive same keypressed events coming
1836  // from auto-repeat on Windows (as it fires only successive keydown events)
1837  if ((previous_keysym == keysym) && (previous_event == kGKeyPress)) {
1838  switch (keysym) {
1839  case 0x1012: // left
1840  gVirtualX->Warp(--mx, my, wid); --tx;
1841  break;
1842  case 0x1013: // up
1843  gVirtualX->Warp(mx, --my, wid); --ty;
1844  break;
1845  case 0x1014: // right
1846  gVirtualX->Warp(++mx, my, wid); ++tx;
1847  break;
1848  case 0x1015: // down
1849  gVirtualX->Warp(mx, ++my, wid); ++ty;
1850  break;
1851  default:
1852  break;
1853  }
1855  }
1856  previous_keysym = keysym;
1857  }
1858  else {
1859  fCanvas->HandleInput(kKeyPress, str[0], keysym);
1860  }
1861  } else if (event->fType == kKeyRelease) {
1862  UInt_t keysym;
1863  char str[2];
1864  gVirtualX->LookupString(event, str, sizeof(str), keysym);
1865 
1866  if (keysym > 0x1011 && keysym < 0x1016) {
1867  Window_t dum1, dum2, wid;
1868  UInt_t mask = 0;
1869  Int_t mx, my, tx, ty;
1870  wid = gVirtualX->GetDefaultRootWindow();
1871  gVirtualX->QueryPointer(wid, dum1, dum2, mx, my, mx, my, mask);
1872  switch (keysym) {
1873  case 0x1012: // left
1874  gVirtualX->Warp(--mx, my, wid);
1875  break;
1876  case 0x1013: // up
1877  gVirtualX->Warp(mx, --my, wid);
1878  break;
1879  case 0x1014: // right
1880  gVirtualX->Warp(++mx, my, wid);
1881  break;
1882  case 0x1015: // down
1883  gVirtualX->Warp(mx, ++my, wid);
1884  break;
1885  default:
1886  break;
1887  }
1888  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(),
1889  fCanvasContainer->GetId(),
1890  mx, my, tx, ty, dum1);
1892  previous_keysym = keysym;
1893  }
1894  fButton = 0;
1895  }
1896  previous_event = event->fType;
1897  return kTRUE;
1898 }
1899 
1900 ////////////////////////////////////////////////////////////////////////////////
1901 /// Handle mouse motion event in the canvas container.
1902 
1904 {
1905  Int_t x = event->fX;
1906  Int_t y = event->fY;
1907 
1908  if (fButton == 0)
1910  if (fButton == kButton1) {
1911  if (event->fState & kKeyShiftMask)
1912  fCanvas->HandleInput(EEventType(8), x, y);
1913  else
1915  }
1916  if (fButton == kButton2)
1918 
1919  return kTRUE;
1920 }
1921 
1922 ////////////////////////////////////////////////////////////////////////////////
1923 /// Handle expose events.
1924 
1926 {
1927  if (event->fCount == 0) {
1928  fCanvas->Flush();
1929  }
1930 
1931  return kTRUE;
1932 }
1933 
1934 ////////////////////////////////////////////////////////////////////////////////
1935 /// Handle enter/leave events. Only leave is activated at the moment.
1936 
1938 {
1939  Int_t x = event->fX;
1940  Int_t y = event->fY;
1941 
1942  // pointer grabs create also an enter and leave event but with fCode
1943  // either kNotifyGrab or kNotifyUngrab, don't propagate these events
1944  if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
1946 
1947  return kTRUE;
1948 }
1949 
1950 ////////////////////////////////////////////////////////////////////////////////
1951 /// Handle drop events.
1952 
1954 {
1955  static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
1956  static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
1957 
1958  if (data->fDataType == rootObj) {
1959  TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
1960  buf.SetReadMode();
1961  TObject *obj = (TObject *)buf.ReadObjectAny(TObject::Class());
1962  if (!obj) return kTRUE;
1963  gPad->Clear();
1964  if (obj->InheritsFrom("TKey")) {
1965  TObject *object = (TObject *)gROOT->ProcessLine(Form("((TKey *)0x%lx)->ReadObj();", (ULong_t)obj));
1966  if (!object) return kTRUE;
1967  if (object->InheritsFrom("TGraph"))
1968  object->Draw("ALP");
1969  else if (object->InheritsFrom("TImage"))
1970  object->Draw("x");
1971  else if (object->IsA()->GetMethodAllAny("Draw"))
1972  object->Draw();
1973  }
1974  else if (obj->InheritsFrom("TGraph"))
1975  obj->Draw("ALP");
1976  else if (obj->IsA()->GetMethodAllAny("Draw"))
1977  obj->Draw();
1978  gPad->Modified();
1979  gPad->Update();
1980  return kTRUE;
1981  }
1982  else if (data->fDataType == uriObj) {
1983  TString sfname((char *)data->fData);
1984  if (sfname.Length() > 7) {
1985  sfname.ReplaceAll("\r\n", "");
1986  TUrl uri(sfname.Data());
1987  if (sfname.EndsWith(".bmp") ||
1988  sfname.EndsWith(".gif") ||
1989  sfname.EndsWith(".jpg") ||
1990  sfname.EndsWith(".png") ||
1991  sfname.EndsWith(".ps") ||
1992  sfname.EndsWith(".eps") ||
1993  sfname.EndsWith(".pdf") ||
1994  sfname.EndsWith(".tiff") ||
1995  sfname.EndsWith(".xpm")) {
1996  TImage *img = TImage::Open(uri.GetFile());
1997  if (img) {
1998  img->Draw("x");
1999  img->SetEditable(kTRUE);
2000  }
2001  }
2002  gPad->Modified();
2003  gPad->Update();
2004  }
2005  }
2006  return kFALSE;
2007 }
2008 
2009 ////////////////////////////////////////////////////////////////////////////////
2010 /// Handle dragging position events.
2011 
2013  Int_t /*xroot*/, Int_t /*yroot*/)
2014 {
2015  TPad *pad = fCanvas->Pick(x, y, 0);
2016  if (pad) {
2017  pad->cd();
2018  gROOT->SetSelectedPad(pad);
2019  // make sure the pad is highlighted (on Windows)
2020  pad->Update();
2021  }
2022  return action;
2023 }
2024 
2025 ////////////////////////////////////////////////////////////////////////////////
2026 /// Handle drag enter events.
2027 
2029 {
2030  static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
2031  static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
2032  Atom_t ret = kNone;
2033  for (int i = 0; typelist[i] != kNone; ++i) {
2034  if (typelist[i] == rootObj)
2035  ret = rootObj;
2036  if (typelist[i] == uriObj)
2037  ret = uriObj;
2038  }
2039  return ret;
2040 }
2041 
2042 ////////////////////////////////////////////////////////////////////////////////
2043 /// Handle drag leave events.
2044 
2046 {
2047  return kTRUE;
2048 }
2049 
2050 ////////////////////////////////////////////////////////////////////////////////
2051 /// Slot handling tab switching in the browser, to properly set the canvas
2052 /// and the model to the editor.
2053 
2055 {
2056  if (fEmbedded) {
2057  TGTab *sender = (TGTab *)gTQSender;
2058  if (sender) {
2059  TGCompositeFrame *cont = sender->GetTabContainer(id);
2060  if (cont == fParent) {
2061  if (!fEditor)
2063  if (fEditor && ((TGedEditor *)fEditor)->IsMapped()) {
2064  ((TGedEditor *)fEditor)->SetCanvas(fCanvas);
2065  ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down);
2066  }
2067  }
2068  }
2069  }
2070 }
2071 
2072 ////////////////////////////////////////////////////////////////////////////////
2073 /// Save a canvas container as a C++ statement(s) on output stream out.
2074 
2075 void TRootContainer::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
2076 {
2077  out << std::endl << " // canvas container" << std::endl;
2078  out << " Int_t canvasID = gVirtualX->InitWindow((ULong_t)"
2079  << GetParent()->GetParent()->GetName() << "->GetId());" << std::endl;
2080  out << " Window_t winC = gVirtualX->GetWindowID(canvasID);" << std::endl;
2081  out << " TGCompositeFrame *";
2082  out << GetName() << " = new TGCompositeFrame(gClient,winC"
2083  << "," << GetParent()->GetName() << ");" << std::endl;
2084 }
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
const Mask_t kKeyReleaseMask
Definition: GuiTypes.h:159
std::string GetName(const std::string &scope_name)
Definition: Cppyy.cxx:145
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
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
Bool_t GetAutoExec() const
Definition: TCanvas.h:158
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 &quot;pos&quot; and tab element &quot;subpos&quot;.
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:1451
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
Bool_t UseGL() const
Definition: TCanvas.h:226
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:2147
virtual Bool_t HandleButton(Event_t *)
Definition: TGFrame.h:383
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:868
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class &quot;classname&quot;.
Definition: TObject.cxx:436
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
Ssiz_t Length() const
Definition: TString.h:385
virtual Bool_t HandleDoubleClick(Event_t *)
Definition: TGFrame.h:384
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: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 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:636
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.
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:140
UInt_t GetWidth() const
Definition: TGFrame.h:271
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 &amp; pad.
Definition: TCanvas.cxx:678
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
Bool_t HasFixedAspectRatio() const
Definition: TPad.h:261
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
Double_t GetAspectRatio() const
Definition: TPad.h:219
const TGPicture * SetIconPixmap(const char *iconName)
Set window icon pixmap by name.
Definition: TGFrame.cxx:1774
#define gROOT
Definition: TROOT.h:375
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:2180
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1825
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition: TSystem.cxx:1454
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:2782
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
ERootCanvasCommands
Definition: TRootCanvas.cxx:78
Int_t GetOptStat() const
Definition: TStyle.h:229
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 TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:501
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
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:4574
UInt_t GetHeight() const
Definition: TGFrame.h:272
UInt_t GetWindowHeight() const
Definition: TCanvas.h:168
UInt_t GetCwidth() const
Return width of canvas container.
TGPopupMenu * fToolsMenu
Definition: TRootCanvas.h:57
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:1073
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:559
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
Bool_t ReturnFromRun() const
Definition: TApplication.h:148
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 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
Bool_t HasToolBar() const
Returns kTRUE if the tool bar is shown.
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:162
TGPopupMenu * fViewMenu
Definition: TRootCanvas.h:54
const char * Data() const
Definition: TString.h:344
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.
TCanvas * Canvas() const
Definition: TCanvasImp.h:51
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:1353
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:563
Double_t x[n]
Definition: legend1.C:17
virtual void Paint(Option_t *option="")
Paint canvas.
Definition: TCanvas.cxx:1459
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:1551
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
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
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
Bool_t fAutoFit
Definition: TRootCanvas.h:87
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save Pad contents in a file in one of various formats.
Definition: TPad.cxx:5461
TGCompositeFrame(const TGCompositeFrame &)
void Clear(Option_t *option="")
Remove all primitives from the canvas.
Definition: TCanvas.cxx:697
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
virtual Bool_t HandleExpose(Event_t *event)
Definition: TGWindow.h:101
const char * GetWindowName() const
Definition: TGFrame.h:544
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()
TGVertical3DLine * fVertical1
Definition: TRootCanvas.h:73
Bool_t OpaqueMoving() const
Is pad moving in opaque mode ?
Definition: TCanvas.h:183
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:873
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:49
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition: TCanvas.cxx:1699
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.
TGPopupMenu * fViewWithMenu
Definition: TRootCanvas.h:55
Int_t GetOptFit() const
Definition: TStyle.h:228
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
Definition: TVirtualPad.h:286
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
Bool_t HasEditor() const
Returns kTRUE if the editor is shown.
Int_t GetOptTitle() const
Definition: TStyle.h:230
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
TGCompositeFrame * fMainFrame
Definition: TRootCanvas.h:68
const Mask_t kKeyPressMask
Definition: GuiTypes.h:158
virtual Int_t MustCleanup() const
Definition: TGFrame.h:420
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.
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:47
virtual void ToggleToolBar()
Toggle toolbar.
Definition: TCanvas.cxx:2158
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:2231
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition: TCanvas.cxx:1635
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
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:482
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:135
virtual void Associate(const TGWindow *w)
Definition: TGMenu.h:219
const Mask_t kExposureMask
Definition: GuiTypes.h:164
Bool_t GetShowToolTips() const
Definition: TCanvas.h:157
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
char * Form(const char *fmt,...)
const Handle_t kNone
Definition: GuiTypes.h:87
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
Bool_t OpaqueResizing() const
Is pad resizing in opaque mode ?
Definition: TCanvas.h:184
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:660
virtual void ToggleEditor()
Toggle editor.
Definition: TCanvas.cxx:2169
Bool_t HandleDNDLeave()
Handle drag leave events.
Bool_t IsNull() const
Definition: TString.h:382
Atom_t fDataType
Definition: TGDNDManager.h:75
Bool_t HandleDNDDrop(TDNDData *data)
Handle drop events.
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition: TCanvas.cxx:2138
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[]
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 const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
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
TGFrame * GetActFrame() const
Definition: TRootBrowser.h:137
TString & Remove(Ssiz_t pos)
Definition: TString.h:617
long Long_t
Definition: RtypesCore.h:50
The Canvas class.
Definition: TCanvas.h:31
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:232
virtual Int_t GetSize() const
Definition: TCollection.h:89
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
Bool_t GetShowEditor() const
Definition: TCanvas.h:156
#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[]
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:364
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:161
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
UInt_t GetCheight() const
Return height of canvas container.
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 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.
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
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
Handle_t fId
Definition: TGObject.h:36
Mother of all ROOT objects.
Definition: TObject.h:37
Atom_t HandleDNDEnter(Atom_t *typelist)
Handle drag enter events.
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
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:568
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: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
#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 HasToolTips() const
Returns kTRUE if the tooltips are enabled.
virtual TGDimension GetDefaultSize() const
std::cout &lt;&lt; fWidth &lt;&lt; &quot;x&quot; &lt;&lt; fHeight &lt;&lt; std::endl;
Definition: TGFrame.h:375
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition: TCanvas.cxx:1156
static TImage * Create()
Create an image.
Definition: TImage.cxx:36
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:2205
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:583
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 void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
Definition: Buttons.h:22
TGLayoutHints * fToolBarLayout
Definition: TRootCanvas.h:69
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:408
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
Handle_t GetId() const
Definition: TGObject.h:48
TGTab * GetTabRight() const
Definition: TRootBrowser.h:141
TCanvas * fCanvas
Definition: TCanvasImp.h:34
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
int main(int argc, char **argv)
char name[80]
Definition: TGX11.cxx:109
virtual Bool_t HandleCrossing(Event_t *)
Definition: TGFrame.h:385
void SetWindowTitle(const char *newTitle)
Change title on window.
Bool_t fEmbedded
Definition: TRootCanvas.h:85
Draw inheritance tree and their relations for a list of classes.
Definition: TClassTree.h:21
char * fIniDir
Definition: TGFileDialog.h:62
virtual void SetGlobal(Bool_t)
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:227
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:859
TGLayoutHints * fCanvasLayout
Definition: TRootCanvas.h:62