TRootCanvas.cxx

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TRootCanvas.cxx 35327 2010-09-16 10:43:04Z bellenot $
00002 // Author: Fons Rademakers   15/01/98
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TRootCanvas                                                          //
00015 //                                                                      //
00016 // This class creates a main window with menubar, scrollbars and a      //
00017 // drawing area. The widgets used are the new native ROOT GUI widgets.  //
00018 //                                                                      //
00019 //////////////////////////////////////////////////////////////////////////
00020 
00021 #include "RConfigure.h"
00022 
00023 #include "TRootCanvas.h"
00024 #include "TRootApplication.h"
00025 #include "TRootHelpDialog.h"
00026 #include "TGClient.h"
00027 #include "TGCanvas.h"
00028 #include "TGMenu.h"
00029 #include "TGWidget.h"
00030 #include "TGFileDialog.h"
00031 #include "TGStatusBar.h"
00032 #include "TGTextEditDialogs.h"
00033 #include "TROOT.h"
00034 #include "TClass.h"
00035 #include "TSystem.h"
00036 #include "TCanvas.h"
00037 #include "TPadPainter.h"
00038 #include "TBrowser.h"
00039 #include "TClassTree.h"
00040 #include "TMarker.h"
00041 #include "TStyle.h"
00042 #include "TColorWheel.h"
00043 #include "TVirtualX.h"
00044 #include "TApplication.h"
00045 #include "TFile.h"
00046 #include "TInterpreter.h"
00047 #include "TEnv.h"
00048 #include "TMath.h"
00049 #include "Riostream.h"
00050 #include "TGDockableFrame.h"
00051 
00052 #include "TG3DLine.h"
00053 #include "TGToolBar.h"
00054 #include "TGToolTip.h"
00055 #include "TVirtualPadEditor.h"
00056 #include "TRootControlBar.h"
00057 #include "TGLabel.h"
00058 #include "TGuiBuilder.h"
00059 #include "TImage.h"
00060 #include "TError.h"
00061 #include "TGDNDManager.h"
00062 #include "TBufferFile.h"
00063 
00064 #include "TPluginManager.h"
00065 #include "TVirtualGL.h"
00066 
00067 #ifdef WIN32
00068 #include "TWin32SplashThread.h"
00069 #endif
00070 
00071 #include "HelpText.h"
00072 
00073 
00074 // Canvas menu command ids
00075 enum ERootCanvasCommands {
00076    kFileNewCanvas,
00077    kFileOpen,
00078    kFileSaveAs,
00079    kFileSaveAsRoot,
00080    kFileSaveAsC,
00081    kFileSaveAsPS,
00082    kFileSaveAsEPS,
00083    kFileSaveAsPDF,
00084    kFileSaveAsGIF,
00085    kFileSaveAsJPG,
00086    kFileSaveAsPNG,
00087    kFilePrint,
00088    kFileCloseCanvas,
00089    kFileQuit,
00090 
00091    kEditStyle,
00092    kEditCut,
00093    kEditCopy,
00094    kEditPaste,
00095    kEditClearPad,
00096    kEditClearCanvas,
00097    kEditUndo,
00098    kEditRedo,
00099 
00100    kViewEditor,
00101    kViewToolbar,
00102    kViewEventStatus,
00103    kViewToolTips,
00104    kViewColors,
00105    kViewFonts,
00106    kViewMarkers,
00107    kViewIconify,
00108    kViewX3D,
00109    kViewOpenGL,
00110 
00111    kOptionAutoResize,
00112    kOptionResizeCanvas,
00113    kOptionMoveOpaque,
00114    kOptionResizeOpaque,
00115    kOptionInterrupt,
00116    kOptionRefresh,
00117    kOptionAutoExec,
00118    kOptionStatistics,
00119    kOptionHistTitle,
00120    kOptionFitParams,
00121    kOptionCanEdit,
00122 
00123    kInspectRoot,
00124    kClassesTree,
00125    kFitPanel,
00126    kToolsBrowser,
00127    kToolsBuilder,
00128    kToolsRecorder,
00129 
00130    kHelpAbout,
00131    kHelpOnCanvas,
00132    kHelpOnMenus,
00133    kHelpOnGraphicsEd,
00134    kHelpOnBrowser,
00135    kHelpOnObjects,
00136    kHelpOnPS,
00137 
00138    kToolModify,
00139    kToolArc,
00140    kToolLine,
00141    kToolArrow,
00142    kToolDiamond,
00143    kToolEllipse,
00144    kToolPad,
00145    kToolPave,
00146    kToolPLabel,
00147    kToolPText,
00148    kToolPsText,
00149    kToolGraph,
00150    kToolCurlyLine,
00151    kToolCurlyArc,
00152    kToolLatex,
00153    kToolMarker,
00154    kToolCutG
00155 
00156 };
00157 
00158 static const char *gOpenTypes[] = { "ROOT files",   "*.root",
00159                                     "All files",    "*",
00160                                     0,              0 };
00161 
00162 static const char *gSaveAsTypes[] = { "PostScript",   "*.ps",
00163                                       "Encapsulated PostScript", "*.eps",
00164                                       "PDF",          "*.pdf",
00165                                       "SVG",          "*.svg",
00166                                       "GIF",          "*.gif",
00167                                       "ROOT macros",  "*.C",
00168                                       "ROOT files",   "*.root",
00169                                       "XML",          "*.xml",
00170                                       "PNG",          "*.png",
00171                                       "XPM",          "*.xpm",
00172                                       "JPEG",         "*.jpg",
00173                                       "TIFF",         "*.tiff",
00174                                       "XCF",          "*.xcf",
00175                                       "All files",    "*",
00176                                       0,              0 };
00177 
00178 static ToolBarData_t gToolBarData[] = {
00179    // { filename,      tooltip,            staydown,  id,              button}
00180    { "newcanvas.xpm",  "New",              kFALSE,    kFileNewCanvas,  0 },
00181    { "open.xpm",       "Open",             kFALSE,    kFileOpen,       0 },
00182    { "save.xpm",       "Save As",          kFALSE,    kFileSaveAs,     0 },
00183    { "printer.xpm",    "Print",            kFALSE,    kFilePrint,      0 },
00184    { "",               "",                 kFALSE,    -1,              0 },
00185    { "interrupt.xpm",  "Interrupt",        kFALSE,    kOptionInterrupt,0 },
00186    { "refresh2.xpm",   "Refresh",          kFALSE,    kOptionRefresh,  0 },
00187    { "",               "",                 kFALSE,    -1,              0 },
00188    { "inspect.xpm",    "Inspect",          kFALSE,    kInspectRoot,    0 },
00189    { "browser.xpm",    "Browser",          kFALSE,    kToolsBrowser, 0 },
00190    { 0,                0,                  kFALSE,    0,               0 }
00191 };
00192 
00193 static ToolBarData_t gToolBarData1[] = {
00194    { "pointer.xpm",    "Modify",           kFALSE,    kToolModify,     0 },
00195    { "arc.xpm",        "Arc",              kFALSE,    kToolArc,        0 },
00196    { "line.xpm",       "Line",             kFALSE,    kToolLine,       0 },
00197    { "arrow.xpm",      "Arrow",            kFALSE,    kToolArrow,      0 },
00198    { "diamond.xpm",    "Diamond",          kFALSE,    kToolDiamond,    0 },
00199    { "ellipse.xpm",    "Ellipse",          kFALSE,    kToolEllipse,    0 },
00200    { "pad.xpm",        "Pad",              kFALSE,    kToolPad,        0 },
00201    { "pave.xpm",       "Pave",             kFALSE,    kToolPave,       0 },
00202    { "pavelabel.xpm",  "Pave Label",       kFALSE,    kToolPLabel,     0 },
00203    { "pavetext.xpm",   "Pave Text",        kFALSE,    kToolPText,      0 },
00204    { "pavestext.xpm",  "Paves Text",       kFALSE,    kToolPsText,     0 },
00205    { "graph.xpm",      "Graph",            kFALSE,    kToolGraph,      0 },
00206    { "curlyline.xpm",  "Curly Line",       kFALSE,    kToolCurlyLine,  0 },
00207    { "curlyarc.xpm",   "Curly Arc",        kFALSE,    kToolCurlyArc,   0 },
00208    { "latex.xpm",      "Text/Latex",       kFALSE,    kToolLatex,      0 },
00209    { "marker.xpm",     "Marker",           kFALSE,    kToolMarker,     0 },
00210    { "cut.xpm",        "Graphical Cut",    kFALSE,    kToolCutG,       0 },
00211    { 0,                0,                  kFALSE,    0,               0 }
00212 };
00213 
00214 //////////////////////////////////////////////////////////////////////////
00215 //                                                                      //
00216 // TRootContainer                                                       //
00217 //                                                                      //
00218 // Utility class used by TRootCanvas. The TRootContainer is the frame   //
00219 // embedded in the TGCanvas widget. The ROOT graphics goes into this    //
00220 // frame. This class is used to enable input events on this graphics    //
00221 // frame and forward the events to the TRootCanvas handlers.            //
00222 //                                                                      //
00223 //////////////////////////////////////////////////////////////////////////
00224 
00225 class TRootContainer : public TGCompositeFrame {
00226 private:
00227    TRootCanvas  *fCanvas;    // pointer back to canvas imp
00228 public:
00229    TRootContainer(TRootCanvas *c, Window_t id, const TGWindow *parent);
00230 
00231    Bool_t  HandleButton(Event_t *ev);
00232    Bool_t  HandleDoubleClick(Event_t *ev)
00233                { return fCanvas->HandleContainerDoubleClick(ev); }
00234    Bool_t  HandleConfigureNotify(Event_t *ev)
00235                { TGFrame::HandleConfigureNotify(ev);
00236                   return fCanvas->HandleContainerConfigure(ev); }
00237    Bool_t  HandleKey(Event_t *ev)
00238                { return fCanvas->HandleContainerKey(ev); }
00239    Bool_t  HandleMotion(Event_t *ev)
00240                { return fCanvas->HandleContainerMotion(ev); }
00241    Bool_t  HandleExpose(Event_t *ev)
00242                { return fCanvas->HandleContainerExpose(ev); }
00243    Bool_t  HandleCrossing(Event_t *ev)
00244                { return fCanvas->HandleContainerCrossing(ev); }
00245    void    SavePrimitive(ostream &out, Option_t * = "");
00246    void    SetEditable(Bool_t) { }
00247 };
00248 
00249 //______________________________________________________________________________
00250 TRootContainer::TRootContainer(TRootCanvas *c, Window_t id, const TGWindow *p)
00251    : TGCompositeFrame(gClient, id, p)
00252 {
00253    // Create a canvas container.
00254 
00255    fCanvas = c;
00256 
00257    gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
00258                          kButtonPressMask | kButtonReleaseMask |
00259                          kPointerMotionMask, kNone, kNone);
00260 
00261    AddInput(kKeyPressMask | kKeyReleaseMask | kPointerMotionMask |
00262             kExposureMask | kStructureNotifyMask | kLeaveWindowMask);
00263    fEditDisabled = kEditDisable;
00264 }
00265 
00266 //______________________________________________________________________________
00267 Bool_t TRootContainer::HandleButton(Event_t *event)
00268 {
00269    // Directly handle scroll mouse buttons (4 and 5), only pass buttons
00270    // 1, 2 and 3 on to the TCanvas.
00271 
00272    TGViewPort *vp = (TGViewPort*)fParent;
00273    UInt_t page = vp->GetHeight()/4;
00274    Int_t newpos;
00275 
00276    gVirtualX->SetInputFocus(GetMainFrame()->GetId());
00277 
00278    if (event->fCode == kButton4) {
00279       //scroll up
00280       newpos = fCanvas->fCanvasWindow->GetVsbPosition() - page;
00281       if (newpos < 0) newpos = 0;
00282       fCanvas->fCanvasWindow->SetVsbPosition(newpos);
00283 //      return kTRUE;
00284    }
00285    if (event->fCode == kButton5) {
00286       // scroll down
00287       newpos = fCanvas->fCanvasWindow->GetVsbPosition() + page;
00288       fCanvas->fCanvasWindow->SetVsbPosition(newpos);
00289 //      return kTRUE;
00290    }
00291    return fCanvas->HandleContainerButton(event);
00292 }
00293 
00294 ClassImp(TRootCanvas)
00295 
00296 //______________________________________________________________________________
00297 TRootCanvas::TRootCanvas(TCanvas *c, const char *name, UInt_t width, UInt_t height)
00298    : TGMainFrame(gClient->GetRoot(), width, height), TCanvasImp(c)
00299 {
00300    // Create a basic ROOT canvas.
00301    CreateCanvas(name);
00302 
00303    ShowToolBar(kFALSE);
00304    ShowEditor(kFALSE);
00305 
00306    Resize(width, height);
00307 }
00308 
00309 //______________________________________________________________________________
00310 TRootCanvas::TRootCanvas(TCanvas *c, const char *name, Int_t x, Int_t y, UInt_t width, UInt_t height)
00311    : TGMainFrame(gClient->GetRoot(), width, height), TCanvasImp(c)
00312 {
00313    // Create a basic ROOT canvas.
00314    CreateCanvas(name);
00315 
00316    ShowToolBar(kFALSE);
00317    ShowEditor(kFALSE);
00318 
00319    MoveResize(x, y, width, height);
00320    SetWMPosition(x, y);
00321 }
00322 
00323 //______________________________________________________________________________
00324 void TRootCanvas::CreateCanvas(const char *name)
00325 {
00326    // Create the actual canvas.
00327 
00328    fButton    = 0;
00329    fAutoFit   = kTRUE;   // check also menu entry
00330    fEditor    = 0;
00331 
00332    // Create menus
00333    fFileSaveMenu = new TGPopupMenu(fClient->GetDefaultRoot());
00334    fFileSaveMenu->AddEntry(Form("%s.&ps",  name), kFileSaveAsPS);
00335    fFileSaveMenu->AddEntry(Form("%s.&eps", name), kFileSaveAsEPS);
00336    fFileSaveMenu->AddEntry(Form("%s.p&df", name), kFileSaveAsPDF);
00337    fFileSaveMenu->AddEntry(Form("%s.&gif", name), kFileSaveAsGIF);
00338 
00339    static Int_t img = 0;
00340 
00341    if (!img) {
00342       Int_t sav = gErrorIgnoreLevel;
00343       gErrorIgnoreLevel = kFatal;
00344       img = TImage::Create() ? 1 : -1;
00345       gErrorIgnoreLevel = sav;
00346    }
00347    if (img > 0) {
00348       fFileSaveMenu->AddEntry(Form("%s.&jpg",name),  kFileSaveAsJPG);
00349       fFileSaveMenu->AddEntry(Form("%s.&png",name),  kFileSaveAsPNG);
00350    }
00351 
00352    fFileSaveMenu->AddEntry(Form("%s.&C",   name), kFileSaveAsC);
00353    fFileSaveMenu->AddEntry(Form("%s.&root",name), kFileSaveAsRoot);
00354 
00355    fFileMenu = new TGPopupMenu(fClient->GetDefaultRoot());
00356    fFileMenu->AddEntry("&New Canvas",   kFileNewCanvas);
00357    fFileMenu->AddEntry("&Open...",      kFileOpen);
00358    fFileMenu->AddEntry("&Close Canvas", kFileCloseCanvas);
00359    fFileMenu->AddSeparator();
00360    fFileMenu->AddPopup("&Save",         fFileSaveMenu);
00361    fFileMenu->AddEntry("Save &As...",   kFileSaveAs);
00362    fFileMenu->AddSeparator();
00363    fFileMenu->AddEntry("&Print...",     kFilePrint);
00364    fFileMenu->AddSeparator();
00365    fFileMenu->AddEntry("&Quit ROOT",    kFileQuit);
00366 
00367    fEditClearMenu = new TGPopupMenu(fClient->GetDefaultRoot());
00368    fEditClearMenu->AddEntry("&Pad",     kEditClearPad);
00369    fEditClearMenu->AddEntry("&Canvas",  kEditClearCanvas);
00370 
00371    fEditMenu = new TGPopupMenu(fClient->GetDefaultRoot());
00372    fEditMenu->AddEntry("&Style...",     kEditStyle);
00373    fEditMenu->AddSeparator();
00374    fEditMenu->AddEntry("Cu&t",          kEditCut);
00375    fEditMenu->AddEntry("&Copy",         kEditCopy);
00376    fEditMenu->AddEntry("&Paste",        kEditPaste);
00377    fEditMenu->AddSeparator();
00378    fEditMenu->AddPopup("C&lear",        fEditClearMenu);
00379    fEditMenu->AddSeparator();
00380    fEditMenu->AddEntry("&Undo",         kEditUndo);
00381    fEditMenu->AddEntry("&Redo",         kEditRedo);
00382 
00383    fEditMenu->DisableEntry(kEditCut);
00384    fEditMenu->DisableEntry(kEditCopy);
00385    fEditMenu->DisableEntry(kEditPaste);
00386    fEditMenu->DisableEntry(kEditUndo);
00387    fEditMenu->DisableEntry(kEditRedo);
00388 
00389    fViewWithMenu = new TGPopupMenu(fClient->GetDefaultRoot());
00390    fViewWithMenu->AddEntry("&X3D",      kViewX3D);
00391    fViewWithMenu->AddEntry("&OpenGL",   kViewOpenGL);
00392 
00393    fViewMenu = new TGPopupMenu(fClient->GetDefaultRoot());
00394    fViewMenu->AddEntry("&Editor",       kViewEditor);
00395    fViewMenu->AddEntry("&Toolbar",      kViewToolbar);
00396    fViewMenu->AddEntry("Event &Statusbar", kViewEventStatus);
00397    fViewMenu->AddEntry("T&oolTip Info", kViewToolTips);
00398    fViewMenu->AddSeparator();
00399    fViewMenu->AddEntry("&Colors",       kViewColors);
00400    fViewMenu->AddEntry("&Fonts",        kViewFonts);
00401    fViewMenu->AddEntry("&Markers",      kViewMarkers);
00402    fViewMenu->AddSeparator();
00403    fViewMenu->AddEntry("&Iconify",      kViewIconify);
00404    fViewMenu->AddSeparator();
00405    fViewMenu->AddPopup("&View With",    fViewWithMenu);
00406 
00407    fViewMenu->DisableEntry(kViewFonts);
00408 
00409    fOptionMenu = new TGPopupMenu(fClient->GetDefaultRoot());
00410    fOptionMenu->AddEntry("&Auto Resize Canvas",  kOptionAutoResize);
00411    fOptionMenu->AddEntry("&Resize Canvas",       kOptionResizeCanvas);
00412    fOptionMenu->AddEntry("&Move Opaque",         kOptionMoveOpaque);
00413    fOptionMenu->AddEntry("Resize &Opaque",       kOptionResizeOpaque);
00414    fOptionMenu->AddSeparator();
00415    fOptionMenu->AddEntry("&Interrupt",           kOptionInterrupt);
00416    fOptionMenu->AddEntry("R&efresh",             kOptionRefresh);
00417    fOptionMenu->AddSeparator();
00418    fOptionMenu->AddEntry("&Pad Auto Exec",       kOptionAutoExec);
00419    fOptionMenu->AddSeparator();
00420    fOptionMenu->AddEntry("&Statistics",          kOptionStatistics);
00421    fOptionMenu->AddEntry("Histogram &Title",     kOptionHistTitle);
00422    fOptionMenu->AddEntry("&Fit Parameters",      kOptionFitParams);
00423    fOptionMenu->AddEntry("Can Edit &Histograms", kOptionCanEdit);
00424 
00425    // Opaque options initialized in InitWindow()
00426    fOptionMenu->CheckEntry(kOptionAutoResize);
00427    if (gStyle->GetOptStat())
00428       fOptionMenu->CheckEntry(kOptionStatistics);
00429    if (gStyle->GetOptTitle())
00430       fOptionMenu->CheckEntry(kOptionHistTitle);
00431    if (gStyle->GetOptFit())
00432       fOptionMenu->CheckEntry(kOptionFitParams);
00433    if (gROOT->GetEditHistograms())
00434       fOptionMenu->CheckEntry(kOptionCanEdit);
00435 
00436    fToolsMenu = new TGPopupMenu(fClient->GetDefaultRoot());
00437    fToolsMenu->AddEntry("&Inspect ROOT",   kInspectRoot);
00438    fToolsMenu->AddEntry("&Class Tree",     kClassesTree);
00439    fToolsMenu->AddEntry("&Fit Panel",      kFitPanel);
00440    fToolsMenu->AddEntry("&Start Browser",  kToolsBrowser);
00441    fToolsMenu->AddEntry("&Gui Builder",    kToolsBuilder);
00442    fToolsMenu->AddEntry("&Event Recorder", kToolsRecorder);
00443 
00444    fHelpMenu = new TGPopupMenu(fClient->GetDefaultRoot());
00445    fHelpMenu->AddLabel("Basic Help On...");
00446    fHelpMenu->AddSeparator();
00447    fHelpMenu->AddEntry("&Canvas",          kHelpOnCanvas);
00448    fHelpMenu->AddEntry("&Menus",           kHelpOnMenus);
00449    fHelpMenu->AddEntry("&Graphics Editor", kHelpOnGraphicsEd);
00450    fHelpMenu->AddEntry("&Browser",         kHelpOnBrowser);
00451    fHelpMenu->AddEntry("&Objects",         kHelpOnObjects);
00452    fHelpMenu->AddEntry("&PostScript",      kHelpOnPS);
00453    fHelpMenu->AddSeparator();
00454    fHelpMenu->AddEntry("&About ROOT...",   kHelpAbout);
00455 
00456    // This main frame will process the menu commands
00457    fFileMenu->Associate(this);
00458    fFileSaveMenu->Associate(this);
00459    fEditMenu->Associate(this);
00460    fEditClearMenu->Associate(this);
00461    fViewMenu->Associate(this);
00462    fViewWithMenu->Associate(this);
00463    fOptionMenu->Associate(this);
00464    fToolsMenu->Associate(this);
00465    fHelpMenu->Associate(this);
00466 
00467    // Create menubar layout hints
00468    fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1);
00469    fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
00470    fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
00471 
00472    // Create menubar
00473    fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
00474    fMenuBar->AddPopup("&File",    fFileMenu,    fMenuBarItemLayout);
00475    fMenuBar->AddPopup("&Edit",    fEditMenu,    fMenuBarItemLayout);
00476    fMenuBar->AddPopup("&View",    fViewMenu,    fMenuBarItemLayout);
00477    fMenuBar->AddPopup("&Options", fOptionMenu,  fMenuBarItemLayout);
00478    fMenuBar->AddPopup("&Tools",   fToolsMenu,   fMenuBarItemLayout);
00479    fMenuBar->AddPopup("&Help",    fHelpMenu,    fMenuBarHelpLayout);
00480 
00481    AddFrame(fMenuBar, fMenuBarLayout);
00482 
00483    fHorizontal1 = new TGHorizontal3DLine(this);
00484    fHorizontal1Layout = new TGLayoutHints(kLHintsTop | kLHintsExpandX);
00485    AddFrame(fHorizontal1, fHorizontal1Layout);
00486 
00487    // Create toolbar dock
00488    fToolDock = new TGDockableFrame(this);
00489    fToolDock->EnableHide(kFALSE);
00490    AddFrame(fToolDock, fDockLayout = new TGLayoutHints(kLHintsExpandX));
00491 
00492    // will alocate it later
00493    fToolBar = 0;
00494    fVertical1 = 0;
00495    fVertical2 = 0;
00496    fVertical1Layout = 0;
00497    fVertical2Layout = 0;
00498 
00499    fToolBarSep = new TGHorizontal3DLine(this);
00500    fToolBarLayout = new TGLayoutHints(kLHintsTop |  kLHintsExpandX);
00501    AddFrame(fToolBarSep, fToolBarLayout);
00502 
00503    fMainFrame = new TGCompositeFrame(this, GetWidth() + 4, GetHeight() + 4,
00504                                       kHorizontalFrame);
00505    fMainFrameLayout = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
00506 
00507    // Create editor frame that will host the pad editor
00508    fEditorFrame = new TGCompositeFrame(fMainFrame, 175, fMainFrame->GetHeight()+4, kFixedWidth);
00509    fEditorLayout = new TGLayoutHints(kLHintsExpandY | kLHintsLeft);
00510    fMainFrame->AddFrame(fEditorFrame, fEditorLayout);
00511 
00512    // Create canvas and canvas container that will host the ROOT graphics
00513    fCanvasWindow = new TGCanvas(fMainFrame, GetWidth()+4, GetHeight()+4,
00514                                 kSunkenFrame | kDoubleBorder);
00515 
00516    fCanvasID = -1;
00517 
00518    if (fCanvas->UseGL()) {
00519       fCanvas->SetSupportGL(kFALSE);
00520       //first, initialize GL (if not yet)
00521       if (!gGLManager) {
00522          TString x = "win32";
00523          if (gVirtualX->InheritsFrom("TGX11"))
00524             x = "x11";
00525 
00526          TPluginHandler *ph = gROOT->GetPluginManager()->FindHandler("TGLManager", x);
00527 
00528          if (ph && ph->LoadPlugin() != -1) {
00529             if (!ph->ExecPlugin(0))
00530                Error("CreateCanvas", "GL manager plugin failed");
00531          }
00532       }
00533 
00534       if (gGLManager) {
00535          fCanvasID = gGLManager->InitGLWindow((ULong_t)fCanvasWindow->GetViewPort()->GetId());
00536          if (fCanvasID != -1) {
00537             //Create gl context.
00538             const Int_t glCtx = gGLManager->CreateGLContext(fCanvasID);
00539             if (glCtx != -1) {
00540                fCanvas->SetSupportGL(kTRUE);
00541                fCanvas->SetGLDevice(glCtx);//Now, fCanvas is responsible for context deletion!
00542             } else
00543                Error("CreateCanvas", "GL context creation failed.");
00544          } else
00545             Error("CreateCanvas", "GL window creation failed\n");
00546       }
00547    }
00548 
00549    if (fCanvasID == -1)
00550       fCanvasID = gVirtualX->InitWindow((ULong_t)fCanvasWindow->GetViewPort()->GetId());
00551 
00552    Window_t win = gVirtualX->GetWindowID(fCanvasID);
00553    fCanvasContainer = new TRootContainer(this, win, fCanvasWindow->GetViewPort());
00554    fCanvasWindow->SetContainer(fCanvasContainer);
00555    fCanvasLayout = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY | kLHintsRight);
00556 
00557    fMainFrame->AddFrame(fCanvasWindow, fCanvasLayout);
00558    AddFrame(fMainFrame, fMainFrameLayout);
00559 
00560    // create the tooltip with a timeout of 250 ms
00561    fToolTip = new TGToolTip(fClient->GetDefaultRoot(), fCanvasWindow, "", 250);
00562 
00563    fCanvas->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
00564                     "TRootCanvas", this,
00565                     "EventInfo(Int_t, Int_t, Int_t, TObject*)");
00566 
00567    // Create status bar
00568    int parts[] = { 33, 10, 10, 47 };
00569    fStatusBar = new TGStatusBar(this, 10, 10);
00570    fStatusBar->SetParts(parts, 4);
00571 
00572    fStatusBarLayout = new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1);
00573 
00574    AddFrame(fStatusBar, fStatusBarLayout);
00575 
00576    // Misc
00577    SetWindowName(name);
00578    SetIconName(name);
00579    fIconPic = SetIconPixmap("macro_s.xpm");
00580    SetClassHints("Canvas", "Canvas");
00581 
00582    SetEditDisabled(kEditDisable);
00583    MapSubwindows();
00584 
00585    // by default status bar, tool bar and pad editor are hidden
00586    HideFrame(fStatusBar);
00587    HideFrame(fToolDock);
00588    HideFrame(fToolBarSep);
00589    HideFrame(fHorizontal1);
00590 
00591    ShowToolBar(kFALSE);
00592    ShowEditor(kFALSE);
00593 
00594    // we need to use GetDefaultSize() to initialize the layout algorithm...
00595    Resize(GetDefaultSize());
00596 
00597    gVirtualX->SetDNDAware(fId, fDNDTypeList);
00598    SetDNDTarget(kTRUE);
00599 }
00600 
00601 //______________________________________________________________________________
00602 TRootCanvas::~TRootCanvas()
00603 {
00604    // Delete ROOT basic canvas. Order is significant. Delete in reverse
00605    // order of creation.
00606 
00607    delete fToolTip;
00608    if (fIconPic) gClient->FreePicture(fIconPic);
00609    if (fEditor) delete fEditor;
00610    if (fToolBar) {
00611       Disconnect(fToolDock, "Docked()",   this, "AdjustSize()");
00612       Disconnect(fToolDock, "Undocked()", this, "AdjustSize()");
00613       fToolBar->Cleanup();
00614       delete fToolBar;
00615    }
00616 
00617    if (!MustCleanup()) {
00618       delete fStatusBar;
00619       delete fStatusBarLayout;
00620       delete fCanvasContainer;
00621       delete fCanvasWindow;
00622 
00623       delete fEditorFrame;
00624       delete fEditorLayout;
00625       delete fMainFrame;
00626       delete fMainFrameLayout;
00627       delete fToolBarSep;
00628       delete fToolDock;
00629       delete fToolBarLayout;
00630       delete fHorizontal1;
00631       delete fHorizontal1Layout;
00632 
00633       delete fMenuBar;
00634       delete fMenuBarLayout;
00635       delete fMenuBarItemLayout;
00636       delete fMenuBarHelpLayout;
00637       delete fCanvasLayout;
00638       delete fDockLayout;
00639    }
00640 
00641    delete fFileMenu;
00642    delete fFileSaveMenu;
00643    delete fEditMenu;
00644    delete fEditClearMenu;
00645    delete fViewMenu;
00646    delete fViewWithMenu;
00647    delete fOptionMenu;
00648    delete fToolsMenu;
00649    delete fHelpMenu;
00650 }
00651 
00652 //______________________________________________________________________________
00653 void TRootCanvas::Close()
00654 {
00655    // Called via TCanvasImp interface by TCanvas.
00656    TVirtualPadEditor* gged = TVirtualPadEditor::GetPadEditor(kFALSE);
00657    if(gged && gged->GetCanvas() == fCanvas)
00658       gged->Hide();
00659 
00660    gVirtualX->CloseWindow();
00661 }
00662 
00663 //______________________________________________________________________________
00664 void TRootCanvas::ReallyDelete()
00665 {
00666    // Really delete the canvas and this GUI.
00667 
00668    TVirtualPadEditor* gged = TVirtualPadEditor::GetPadEditor(kFALSE);
00669    if(gged && gged->GetCanvas() == fCanvas)
00670       gged->Hide();
00671 
00672    fToolTip->Hide();
00673    Disconnect(fCanvas, "ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
00674               this, "EventInfo(Int_t, Int_t, Int_t, TObject*)");
00675 
00676    TVirtualPad *savepad = gPad;
00677    gPad = 0;        // hide gPad from CINT
00678    gInterpreter->DeleteGlobal(fCanvas);
00679    gPad = savepad;  // restore gPad for ROOT
00680    delete fCanvas;  // will in turn delete this object
00681 }
00682 
00683 //______________________________________________________________________________
00684 void TRootCanvas::CloseWindow()
00685 {
00686    // In case window is closed via WM we get here.
00687 
00688    DeleteWindow();
00689 }
00690 
00691 //______________________________________________________________________________
00692 UInt_t TRootCanvas::GetCwidth() const
00693 {
00694    // Return width of canvas container.
00695 
00696    return fCanvasContainer->GetWidth();
00697 }
00698 
00699 //______________________________________________________________________________
00700 UInt_t TRootCanvas::GetCheight() const
00701 {
00702    // Return height of canvas container.
00703 
00704    return fCanvasContainer->GetHeight();
00705 }
00706 
00707 //______________________________________________________________________________
00708 UInt_t TRootCanvas::GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
00709 {
00710    // Gets the size and position of the window containing the canvas. This
00711    // size includes the menubar and borders.
00712 
00713    gVirtualX->GetWindowSize(fId, x, y, w, h);
00714 
00715    Window_t childdum;
00716    gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(),
00717                                    0, 0, x, y, childdum);
00718    if (!fCanvas->GetShowEditor()) return 0;
00719    return fEditorFrame->GetWidth();
00720 }
00721 
00722 //______________________________________________________________________________
00723 void TRootCanvas::SetStatusText(const char *txt, Int_t partidx)
00724 {
00725    // Set text in status bar.
00726 
00727    fStatusBar->SetText(txt, partidx);
00728 }
00729 
00730 //______________________________________________________________________________
00731 Bool_t TRootCanvas::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
00732 {
00733    // Handle menu and other command generated by the user.
00734 
00735    TRootHelpDialog *hd;
00736    TList *lc;
00737 
00738    switch (GET_MSG(msg)) {
00739 
00740       case kC_COMMAND:
00741 
00742          switch (GET_SUBMSG(msg)) {
00743 
00744             case kCM_BUTTON:
00745             case kCM_MENU:
00746 
00747                switch (parm1) {
00748                   // Handle toolbar items...
00749                   case kToolModify:
00750                      gROOT->SetEditorMode();
00751                      break;
00752                   case kToolArc:
00753                      gROOT->SetEditorMode("Arc");
00754                      break;
00755                   case kToolLine:
00756                      gROOT->SetEditorMode("Line");
00757                      break;
00758                   case kToolArrow:
00759                      gROOT->SetEditorMode("Arrow");
00760                      break;
00761                   case kToolDiamond:
00762                      gROOT->SetEditorMode("Diamond");
00763                      break;
00764                   case kToolEllipse:
00765                      gROOT->SetEditorMode("Ellipse");
00766                      break;
00767                   case kToolPad:
00768                      gROOT->SetEditorMode("Pad");
00769                      break;
00770                   case kToolPave:
00771                      gROOT->SetEditorMode("Pave");
00772                      break;
00773                   case kToolPLabel:
00774                      gROOT->SetEditorMode("PaveLabel");
00775                      break;
00776                   case kToolPText:
00777                      gROOT->SetEditorMode("PaveText");
00778                      break;
00779                   case kToolPsText:
00780                      gROOT->SetEditorMode("PavesText");
00781                      break;
00782                   case kToolGraph:
00783                      gROOT->SetEditorMode("PolyLine");
00784                      break;
00785                   case kToolCurlyLine:
00786                      gROOT->SetEditorMode("CurlyLine");
00787                      break;
00788                   case kToolCurlyArc:
00789                      gROOT->SetEditorMode("CurlyArc");
00790                      break;
00791                   case kToolLatex:
00792                      gROOT->SetEditorMode("Text");
00793                      break;
00794                   case kToolMarker:
00795                      gROOT->SetEditorMode("Marker");
00796                      break;
00797                   case kToolCutG:
00798                      gROOT->SetEditorMode("CutG");
00799                      break;
00800 
00801                   // Handle File menu items...
00802                   case kFileNewCanvas:
00803                      gROOT->MakeDefCanvas();
00804                      break;
00805                   case kFileOpen:
00806                      {
00807                         static TString dir(".");
00808                         TGFileInfo fi;
00809                         fi.fFileTypes = gOpenTypes;
00810                         fi.fIniDir    = StrDup(dir);
00811                         new TGFileDialog(fClient->GetDefaultRoot(), this, kFDOpen,&fi);
00812                         if (!fi.fFilename) return kTRUE;
00813                         dir = fi.fIniDir;
00814                         new TFile(fi.fFilename, "update");
00815                      }
00816                      break;
00817                   case kFileSaveAs:
00818                      {
00819                         static TString dir(".");
00820                         static Int_t typeidx = 0;
00821                         static Bool_t overwr = kFALSE;
00822                         TGFileInfo fi;
00823                         fi.fFileTypes   = gSaveAsTypes;
00824                         fi.fIniDir      = StrDup(dir);
00825                         fi.fFileTypeIdx = typeidx;
00826                         fi.fOverwrite = overwr;
00827                         new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi);
00828                         if (!fi.fFilename) return kTRUE;
00829                         Bool_t  appendedType = kFALSE;
00830                         TString fn = fi.fFilename;
00831                         TString ft = fi.fFileTypes[fi.fFileTypeIdx+1];
00832                         dir     = fi.fIniDir;
00833                         typeidx = fi.fFileTypeIdx;
00834                         overwr  = fi.fOverwrite;
00835 again:
00836                         if (fn.EndsWith(".root") ||
00837                             fn.EndsWith(".ps")   ||
00838                             fn.EndsWith(".eps")  ||
00839                             fn.EndsWith(".pdf")  ||
00840                             fn.EndsWith(".svg")  ||
00841                             fn.EndsWith(".gif")  ||
00842                             fn.EndsWith(".xml")  ||
00843                             fn.EndsWith(".xpm")  ||
00844                             fn.EndsWith(".jpg")  ||
00845                             fn.EndsWith(".png")  ||
00846                             fn.EndsWith(".xcf")  ||
00847                             fn.EndsWith(".tiff")) {
00848                            fCanvas->SaveAs(fn);
00849                         } else if (fn.EndsWith(".C"))
00850                            fCanvas->SaveSource(fn);
00851                         else {
00852                            if (!appendedType) {
00853                               if (ft.Index(".") != kNPOS) {
00854                                  fn += ft(ft.Index("."), ft.Length());
00855                                  appendedType = kTRUE;
00856                                  goto again;
00857                               }
00858                            }
00859                            Warning("ProcessMessage", "file %s cannot be saved with this extension", fi.fFilename);
00860                         }
00861                      }
00862                      break;
00863                   case kFileSaveAsRoot:
00864                      fCanvas->SaveAs(".root");
00865                      break;
00866                   case kFileSaveAsC:
00867                      fCanvas->SaveSource();
00868                      break;
00869                   case kFileSaveAsPS:
00870                      fCanvas->SaveAs();
00871                      break;
00872                   case kFileSaveAsEPS:
00873                      fCanvas->SaveAs(".eps");
00874                      break;
00875                   case kFileSaveAsPDF:
00876                      fCanvas->SaveAs(".pdf");
00877                      break;
00878                   case kFileSaveAsGIF:
00879                      fCanvas->SaveAs(".gif");
00880                      break;
00881                   case kFileSaveAsJPG:
00882                      fCanvas->SaveAs(".jpg");
00883                      break;
00884                   case kFileSaveAsPNG:
00885                      fCanvas->SaveAs(".png");
00886                      break;
00887                   case kFilePrint:
00888                      PrintCanvas();
00889                      break;
00890                   case kFileCloseCanvas:
00891                      SendCloseMessage();
00892                      break;
00893                   case kFileQuit:
00894                      if (!gApplication->ReturnFromRun()) {
00895                         if ((TVirtualPadEditor::GetPadEditor(kFALSE) != 0))
00896                            TVirtualPadEditor::Terminate();
00897                         delete this;
00898                      }
00899                      if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
00900                         TVirtualPadEditor::Terminate();
00901                      if (TClass::GetClass("TStyleManager"))
00902                         gROOT->ProcessLine("TStyleManager::Terminate()");
00903                      gApplication->Terminate(0);
00904                      break;
00905 
00906                   // Handle Edit menu items...
00907                   case kEditStyle:
00908                      if (!TClass::GetClass("TStyleManager"))
00909                         gSystem->Load("libGed");
00910                      gROOT->ProcessLine("TStyleManager::Show()");
00911                      break;
00912                   case kEditCut:
00913                      // still noop
00914                      break;
00915                   case kEditCopy:
00916                      // still noop
00917                      break;
00918                   case kEditPaste:
00919                      // still noop
00920                      break;
00921                   case kEditUndo:
00922                      // noop
00923                      break;
00924                   case kEditRedo:
00925                      // noop
00926                      break;
00927                   case kEditClearPad:
00928                      gPad->Clear();
00929                      gPad->Modified();
00930                      gPad->Update();
00931                      break;
00932                   case kEditClearCanvas:
00933                      fCanvas->Clear();
00934                      fCanvas->Modified();
00935                      fCanvas->Update();
00936                      break;
00937 
00938                   // Handle View menu items...
00939                   case kViewEditor:
00940                      fCanvas->ToggleEditor();
00941                      break;
00942                   case kViewToolbar:
00943                      fCanvas->ToggleToolBar();
00944                      break;
00945                   case kViewEventStatus:
00946                      fCanvas->ToggleEventStatus();
00947                      break;
00948                   case kViewToolTips:
00949                      fCanvas->ToggleToolTips();
00950                      break;
00951                   case kViewColors:
00952                      {
00953                         TVirtualPad *padsav = gPad->GetCanvas();
00954                         //This was the code with the old color table
00955                         //   TCanvas *m = new TCanvas("colors","Color Table");
00956                         //   TPad::DrawColorTable();
00957                         //   m->Update();
00958                         TColorWheel *wheel = new TColorWheel();
00959                         wheel->Draw();
00960                         padsav->cd();
00961                      }
00962                      break;
00963                   case kViewFonts:
00964                      // noop
00965                      break;
00966                   case kViewMarkers:
00967                      {
00968                         TVirtualPad *padsav = gPad->GetCanvas();
00969                         TCanvas *m = new TCanvas("markers","Marker Types",600,200);
00970                         TMarker::DisplayMarkerTypes();
00971                         m->Update();
00972                         padsav->cd();
00973                      }
00974                      break;
00975                   case kViewIconify:
00976                      Iconify();
00977                      break;
00978                   case kViewX3D:
00979                      gPad->GetViewer3D("x3d");
00980                      break;
00981                   case kViewOpenGL:
00982                      gPad->GetViewer3D("ogl");
00983                      break;
00984 
00985                   // Handle Option menu items...
00986                   case kOptionAutoExec:
00987                      fCanvas->ToggleAutoExec();
00988                      if (fCanvas->GetAutoExec()) {
00989                         fOptionMenu->CheckEntry(kOptionAutoExec);
00990                      } else {
00991                         fOptionMenu->UnCheckEntry(kOptionAutoExec);
00992                      }
00993                      break;
00994                   case kOptionAutoResize:
00995                      {
00996                         fAutoFit = fAutoFit ? kFALSE : kTRUE;
00997                         int opt = fCanvasContainer->GetOptions();
00998                         if (fAutoFit) {
00999                            opt &= ~kFixedSize;
01000                            fOptionMenu->CheckEntry(kOptionAutoResize);
01001                         } else {
01002                            opt |= kFixedSize;
01003                            fOptionMenu->UnCheckEntry(kOptionAutoResize);
01004                         }
01005                         fCanvasContainer->ChangeOptions(opt);
01006                         // in case of autofit this will generate a configure
01007                         // event for the container and this will force the
01008                         // update of the TCanvas
01009                         //Layout();
01010                      }
01011                      Layout();
01012                      break;
01013                   case kOptionResizeCanvas:
01014                      FitCanvas();
01015                      break;
01016                   case kOptionMoveOpaque:
01017                      if (fCanvas->OpaqueMoving()) {
01018                         fCanvas->MoveOpaque(0);
01019                         fOptionMenu->UnCheckEntry(kOptionMoveOpaque);
01020                      } else {
01021                         fCanvas->MoveOpaque(1);
01022                         fOptionMenu->CheckEntry(kOptionMoveOpaque);
01023                      }
01024                      break;
01025                   case kOptionResizeOpaque:
01026                      if (fCanvas->OpaqueResizing()) {
01027                         fCanvas->ResizeOpaque(0);
01028                         fOptionMenu->UnCheckEntry(kOptionResizeOpaque);
01029                      } else {
01030                         fCanvas->ResizeOpaque(1);
01031                         fOptionMenu->CheckEntry(kOptionResizeOpaque);
01032                      }
01033                      break;
01034                   case kOptionInterrupt:
01035                      gROOT->SetInterrupt();
01036                      break;
01037                   case kOptionRefresh:
01038                      fCanvas->Paint();
01039                      fCanvas->Update();
01040                      break;
01041                   case kOptionStatistics:
01042                      if (gStyle->GetOptStat()) {
01043                         gStyle->SetOptStat(0);
01044                         delete gPad->FindObject("stats");
01045                         fOptionMenu->UnCheckEntry(kOptionStatistics);
01046                      } else {
01047                         gStyle->SetOptStat(1);
01048                         fOptionMenu->CheckEntry(kOptionStatistics);
01049                      }
01050                      gPad->Modified();
01051                      fCanvas->Update();
01052                      break;
01053                   case kOptionHistTitle:
01054                      if (gStyle->GetOptTitle()) {
01055                         gStyle->SetOptTitle(0);
01056                         delete gPad->FindObject("title");
01057                         fOptionMenu->UnCheckEntry(kOptionHistTitle);
01058                      } else {
01059                         gStyle->SetOptTitle(1);
01060                         fOptionMenu->CheckEntry(kOptionHistTitle);
01061                      }
01062                      gPad->Modified();
01063                      fCanvas->Update();
01064                      break;
01065                   case kOptionFitParams:
01066                      if (gStyle->GetOptFit()) {
01067                         gStyle->SetOptFit(0);
01068                         fOptionMenu->UnCheckEntry(kOptionFitParams);
01069                      } else {
01070                         gStyle->SetOptFit(1);
01071                         fOptionMenu->CheckEntry(kOptionFitParams);
01072                      }
01073                      gPad->Modified();
01074                      fCanvas->Update();
01075                      break;
01076                   case kOptionCanEdit:
01077                      if (gROOT->GetEditHistograms()) {
01078                         gROOT->SetEditHistograms(kFALSE);
01079                         fOptionMenu->UnCheckEntry(kOptionCanEdit);
01080                      } else {
01081                         gROOT->SetEditHistograms(kTRUE);
01082                         fOptionMenu->CheckEntry(kOptionCanEdit);
01083                      }
01084                      break;
01085 
01086                   // Handle Tools menu items...
01087                   case kInspectRoot:
01088                      fCanvas->cd();
01089                      gROOT->Inspect();
01090                      fCanvas->Update();
01091                      break;
01092                   case kToolsBrowser:
01093                      new TBrowser("browser");
01094                      break;
01095                   case kToolsBuilder:
01096                      TGuiBuilder::Instance();
01097                      break;
01098                   case kToolsRecorder:
01099                      gROOT->ProcessLine("new TGRecorder()");
01100                      break;
01101 
01102                   // Handle Tools menu items...
01103                   case kClassesTree:
01104                      {
01105                         TString cdef;
01106                         lc = (TList*)gROOT->GetListOfCanvases();
01107                         if (lc->FindObject("ClassTree")) {
01108                            cdef = TString::Format("ClassTree_%d", lc->GetSize()+1);
01109                         } else {
01110                            cdef = "ClassTree";
01111                         }
01112                         new TClassTree(cdef.Data(), "TObject");
01113                         fCanvas->Update();
01114                      }
01115                      break;
01116 
01117                case kFitPanel:
01118                      {
01119                         // use plugin manager to create instance of TFitEditor
01120                         TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
01121                         if (handler && handler->LoadPlugin() != -1) {
01122                            if (handler->ExecPlugin(2, fCanvas, 0) == 0)
01123                               Error("FitPanel", "Unable to crate the FitPanel");
01124                         }
01125                         else
01126                            Error("FitPanel", "Unable to find the FitPanel plug-in");
01127                      }
01128                      break;
01129 
01130                   // Handle Help menu items...
01131                   case kHelpAbout:
01132                      {
01133 #ifdef R__UNIX
01134                         TString rootx;
01135 # ifdef ROOTBINDIR
01136                         rootx = ROOTBINDIR;
01137 # else
01138                         rootx = gSystem->Getenv("ROOTSYS");
01139                         if (!rootx.IsNull()) rootx += "/bin";
01140 # endif
01141                         rootx += "/root -a &";
01142                         gSystem->Exec(rootx);
01143 #else
01144 #ifdef WIN32
01145                         new TWin32SplashThread(kTRUE);
01146 #else
01147 
01148                         char str[32];
01149                         sprintf(str, "About ROOT %s...", gROOT->GetVersion());
01150                         hd = new TRootHelpDialog(this, str, 600, 400);
01151                         hd->SetText(gHelpAbout);
01152                         hd->Popup();
01153 #endif
01154 #endif
01155                      }
01156                      break;
01157                   case kHelpOnCanvas:
01158                      hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
01159                      hd->SetText(gHelpCanvas);
01160                      hd->Popup();
01161                      break;
01162                   case kHelpOnMenus:
01163                      hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
01164                      hd->SetText(gHelpPullDownMenus);
01165                      hd->Popup();
01166                      break;
01167                   case kHelpOnGraphicsEd:
01168                      hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
01169                      hd->SetText(gHelpGraphicsEditor);
01170                      hd->Popup();
01171                      break;
01172                   case kHelpOnBrowser:
01173                      hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
01174                      hd->SetText(gHelpBrowser);
01175                      hd->Popup();
01176                      break;
01177                   case kHelpOnObjects:
01178                      hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
01179                      hd->SetText(gHelpObjects);
01180                      hd->Popup();
01181                      break;
01182                   case kHelpOnPS:
01183                      hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
01184                      hd->SetText(gHelpPostscript);
01185                      hd->Popup();
01186                      break;
01187                }
01188             default:
01189                break;
01190          }
01191       default:
01192          break;
01193    }
01194    return kTRUE;
01195 }
01196 
01197 //______________________________________________________________________________
01198 Int_t TRootCanvas::InitWindow()
01199 {
01200    // Called by TCanvas ctor to get window indetifier.
01201 
01202    if (fCanvas->OpaqueMoving())
01203       fOptionMenu->CheckEntry(kOptionMoveOpaque);
01204    if (fCanvas->OpaqueResizing())
01205       fOptionMenu->CheckEntry(kOptionResizeOpaque);
01206 
01207    return fCanvasID;
01208 }
01209 
01210 //______________________________________________________________________________
01211 void TRootCanvas::SetCanvasSize(UInt_t w, UInt_t h)
01212 {
01213    // Set size of canvas container. Units in pixels.
01214 
01215    // turn off autofit, we want to stay at the given size
01216    fAutoFit = kFALSE;
01217    fOptionMenu->UnCheckEntry(kOptionAutoResize);
01218    int opt = fCanvasContainer->GetOptions();
01219    opt |= kFixedSize;    // turn on fixed size mode
01220    fCanvasContainer->ChangeOptions(opt);
01221    fCanvasContainer->SetWidth(w);
01222    fCanvasContainer->SetHeight(h);
01223    Layout();  // force layout (will update container to given size)
01224    fCanvas->Resize();
01225    fCanvas->Update();
01226 }
01227 
01228 //______________________________________________________________________________
01229 void TRootCanvas::SetWindowPosition(Int_t x, Int_t y)
01230 {
01231    // Set canvas position (units in pixels).
01232 
01233    Move(x, y);
01234 }
01235 
01236 //______________________________________________________________________________
01237 void TRootCanvas::SetWindowSize(UInt_t w, UInt_t h)
01238 {
01239    // Set size of canvas (units in pixels).
01240 
01241    Resize(w, h);
01242 
01243    // Make sure the change of size is really done.
01244    if (!gThreadXAR) {
01245       gSystem->ProcessEvents();
01246       gSystem->Sleep(10);
01247       gSystem->ProcessEvents();
01248    }
01249 }
01250 
01251 //______________________________________________________________________________
01252 void TRootCanvas::RaiseWindow()
01253 {
01254    // Put canvas window on top of the window stack.
01255 
01256    gVirtualX->RaiseWindow(GetId());
01257 }
01258 
01259 //______________________________________________________________________________
01260 void TRootCanvas::SetWindowTitle(const char *title)
01261 {
01262    // Change title on window.
01263 
01264    SetWindowName(title);
01265    SetIconName(title);
01266    fToolDock->SetWindowName(Form("ToolBar: %s", title));
01267 }
01268 
01269 //______________________________________________________________________________
01270 void TRootCanvas::FitCanvas()
01271 {
01272    // Fit canvas container to current window size.
01273 
01274    if (!fAutoFit) {
01275       int opt = fCanvasContainer->GetOptions();
01276       int oopt = opt;
01277       opt &= ~kFixedSize;   // turn off fixed size mode
01278       fCanvasContainer->ChangeOptions(opt);
01279       Layout();  // force layout
01280       fCanvas->Resize();
01281       fCanvas->Update();
01282       fCanvasContainer->ChangeOptions(oopt);
01283    }
01284 }
01285 
01286 
01287  //______________________________________________________________________________
01288 void TRootCanvas::PrintCanvas()
01289 {
01290    // Print the canvas.
01291 
01292    Int_t ret = 0;
01293    Bool_t pname = kTRUE;
01294    char *printer, *printCmd;
01295    static TString sprinter, sprintCmd;
01296 
01297    if (sprinter == "")
01298       printer = StrDup(gEnv->GetValue("Print.Printer", ""));
01299    else
01300       printer = StrDup(sprinter);
01301    if (sprintCmd == "")
01302 #ifndef WIN32
01303       printCmd = StrDup(gEnv->GetValue("Print.Command", ""));
01304 #else
01305       printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p"));
01306 #endif
01307    else
01308       printCmd = StrDup(sprintCmd);
01309 
01310    new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
01311                      &printer, &printCmd, &ret);
01312    if (ret) {
01313       sprinter  = printer;
01314       sprintCmd = printCmd;
01315 
01316       if (sprinter == "")
01317          pname = kFALSE;
01318 
01319       TString fn = "rootprint";
01320       FILE *f = gSystem->TempFileName(fn, gEnv->GetValue("Print.Directory", gSystem->TempDirectory()));
01321       fclose(f);
01322       fn += TString::Format(".%s",gEnv->GetValue("Print.FileType", "pdf"));
01323       fCanvas->Print(fn);
01324 
01325       TString cmd = sprintCmd;
01326       if (cmd.Contains("%p"))
01327          cmd.ReplaceAll("%p", sprinter);
01328       else if (pname) {
01329          cmd += " "; cmd += sprinter; cmd += " ";
01330       }
01331 
01332       if (cmd.Contains("%f"))
01333          cmd.ReplaceAll("%f", fn);
01334       else {
01335          cmd += " "; cmd += fn; cmd += " ";
01336       }
01337 
01338       gSystem->Exec(cmd);
01339 #ifndef WIN32
01340       gSystem->Unlink(fn);
01341 #endif
01342    }
01343    delete [] printer;
01344    delete [] printCmd;
01345 }
01346 
01347 //______________________________________________________________________________
01348 void TRootCanvas::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
01349 {
01350    // Display a tooltip with infos about the primitive below the cursor.
01351 
01352    fToolTip->Hide();
01353    if (!fCanvas->GetShowToolTips() || selected == 0 ||
01354        event != kMouseMotion || fButton != 0)
01355       return;
01356    TString tipInfo;
01357    TString objInfo = selected->GetObjectInfo(px, py);
01358    if (objInfo.BeginsWith("-")) {
01359       // if the string begins with '-', display only the object info
01360       objInfo.Remove(TString::kLeading, '-');
01361       tipInfo = objInfo;
01362    }
01363    else {
01364       const char *title = selected->GetTitle();
01365       tipInfo += TString::Format("%s::%s", selected->ClassName(),
01366                                  selected->GetName());
01367       if (title && strlen(title))
01368          tipInfo += TString::Format("\n%s", selected->GetTitle());
01369       tipInfo += TString::Format("\n%d, %d", px, py);
01370       if (!objInfo.IsNull())
01371          tipInfo += TString::Format("\n%s", objInfo.Data());
01372    }
01373    fToolTip->SetText(tipInfo.Data());
01374    fToolTip->SetPosition(px+15, py+15);
01375    fToolTip->Reset();
01376 }
01377 
01378 //______________________________________________________________________________
01379 void TRootCanvas::ShowMenuBar(Bool_t show)
01380 {
01381    // Show or hide menubar.
01382 
01383    if (show)  ShowFrame(fMenuBar);
01384    else       HideFrame(fMenuBar);
01385 }
01386 
01387 //______________________________________________________________________________
01388 void TRootCanvas::ShowStatusBar(Bool_t show)
01389 {
01390    // Show or hide statusbar.
01391 
01392    UInt_t dh = fClient->GetDisplayHeight();
01393    UInt_t ch = fCanvas->GetWindowHeight();
01394 
01395    UInt_t h = GetHeight();
01396    UInt_t sh = fStatusBar->GetHeight()+2;
01397 
01398    if (show) {
01399       ShowFrame(fStatusBar);
01400       fViewMenu->CheckEntry(kViewEventStatus);
01401       if (dh - ch >= sh) h = h + sh;
01402       else h = ch;
01403    } else {
01404       HideFrame(fStatusBar);
01405       fViewMenu->UnCheckEntry(kViewEventStatus);
01406       if (dh - ch < sh) h = ch;
01407       else h = h - sh;
01408    }
01409    Resize(GetWidth(), h);
01410 }
01411 
01412 //______________________________________________________________________________
01413 void TRootCanvas::ShowEditor(Bool_t show)
01414 {
01415    // Show or hide side frame.
01416 
01417    TVirtualPad *savedPad = 0;
01418    savedPad = (TVirtualPad *) gPad;
01419    gPad = Canvas();
01420 
01421    UInt_t w = GetWidth();
01422    UInt_t e = fEditorFrame->GetWidth();
01423    UInt_t h = GetHeight();
01424    UInt_t s = fHorizontal1->GetHeight();
01425 
01426    if (show) {
01427       if (!fEditor) CreateEditor();
01428       TVirtualPadEditor* gged = TVirtualPadEditor::GetPadEditor(kFALSE);
01429       if(gged && gged->GetCanvas() == fCanvas){
01430          gged->Hide();
01431       }
01432       if (!fViewMenu->IsEntryChecked(kViewToolbar) || fToolDock->IsUndocked()) {
01433          ShowFrame(fHorizontal1);
01434          h = h + s;
01435       }
01436       fMainFrame->ShowFrame(fEditorFrame);
01437       fEditor->Show();
01438       fViewMenu->CheckEntry(kViewEditor);
01439       w = w + e;
01440    } else {
01441       if (!fViewMenu->IsEntryChecked(kViewToolbar) || fToolDock->IsUndocked()) {
01442          HideFrame(fHorizontal1);
01443          h = h - s;
01444       }
01445       if (fEditor) fEditor->Hide();
01446       fMainFrame->HideFrame(fEditorFrame);
01447       fViewMenu->UnCheckEntry(kViewEditor);
01448       w = w - e;
01449    }
01450    Resize(w, h);
01451 
01452    if (savedPad) gPad = savedPad;
01453 }
01454 
01455 //______________________________________________________________________________
01456 void TRootCanvas::CreateEditor()
01457 {
01458    // Create embedded editor.
01459 
01460    fEditorFrame->SetEditDisabled(kEditEnable);
01461    fEditorFrame->SetEditable();
01462    gPad = Canvas();
01463    // next two lines are related to the old editor
01464    Int_t show = gEnv->GetValue("Canvas.ShowEditor", 0);
01465    gEnv->SetValue("Canvas.ShowEditor","true");
01466    fEditor = TVirtualPadEditor::LoadEditor();
01467    fEditor->SetGlobal(kFALSE);
01468    fEditorFrame->SetEditable(kEditDisable);
01469    fEditorFrame->SetEditable(kFALSE);
01470 
01471    // next line is related to the old editor
01472    if (show == 0) gEnv->SetValue("Canvas.ShowEditor","false");
01473 }
01474 
01475 //______________________________________________________________________________
01476 void TRootCanvas::ShowToolBar(Bool_t show)
01477 {
01478    // Show or hide toolbar.
01479 
01480    if (show && !fToolBar) {
01481 
01482       fToolBar = new TGToolBar(fToolDock, 60, 20, kHorizontalFrame);
01483       fToolDock->AddFrame(fToolBar, fHorizontal1Layout);
01484 
01485       Int_t spacing = 6, i;
01486       for (i = 0; gToolBarData[i].fPixmap; i++) {
01487          if (strlen(gToolBarData[i].fPixmap) == 0) {
01488             spacing = 6;
01489             continue;
01490          }
01491          fToolBar->AddButton(this, &gToolBarData[i], spacing);
01492          spacing = 0;
01493       }
01494       fVertical1 = new TGVertical3DLine(fToolBar);
01495       fVertical2 = new TGVertical3DLine(fToolBar);
01496       fVertical1Layout = new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 4,2,0,0);
01497       fVertical2Layout = new TGLayoutHints(kLHintsLeft | kLHintsExpandY);
01498       fToolBar->AddFrame(fVertical1, fVertical1Layout);
01499       fToolBar->AddFrame(fVertical2, fVertical2Layout);
01500 
01501       spacing = 6;
01502       for (i = 0; gToolBarData1[i].fPixmap; i++) {
01503          if (strlen(gToolBarData1[i].fPixmap) == 0) {
01504             spacing = 6;
01505             continue;
01506          }
01507          fToolBar->AddButton(this, &gToolBarData1[i], spacing);
01508          spacing = 0;
01509       }
01510       fToolDock->MapSubwindows();
01511       fToolDock->Layout();
01512       fToolDock->SetWindowName(Form("ToolBar: %s", GetWindowName()));
01513       fToolDock->Connect("Docked()", "TRootCanvas", this, "AdjustSize()");
01514       fToolDock->Connect("Undocked()", "TRootCanvas", this, "AdjustSize()");
01515    }
01516 
01517    if (!fToolBar) return;
01518 
01519    UInt_t h = GetHeight();
01520    UInt_t sh = fToolBarSep->GetHeight();
01521    UInt_t dh = fToolBar->GetHeight();
01522 
01523    if (show) {
01524       ShowFrame(fToolDock);
01525       if (!fViewMenu->IsEntryChecked(kViewEditor)) {
01526          ShowFrame(fHorizontal1);
01527          h = h + sh;
01528       }
01529       ShowFrame(fToolBarSep);
01530       fViewMenu->CheckEntry(kViewToolbar);
01531       h = h + dh + sh;
01532    } else {
01533       if (fToolDock->IsUndocked()) {
01534          fToolDock->DockContainer();
01535          h = h + 2*sh;
01536       } else h = h - dh;
01537 
01538       HideFrame(fToolDock);
01539       if (!fViewMenu->IsEntryChecked(kViewEditor)) {
01540          HideFrame(fHorizontal1);
01541          h = h - sh;
01542       }
01543       HideFrame(fToolBarSep);
01544       h = h - sh;
01545       fViewMenu->UnCheckEntry(kViewToolbar);
01546    }
01547    Resize(GetWidth(), h);
01548 }
01549 
01550 //______________________________________________________________________________
01551 void TRootCanvas::ShowToolTips(Bool_t show)
01552 {
01553    // Enable or disable tooltip info.
01554 
01555    if (show)
01556       fViewMenu->CheckEntry(kViewToolTips);
01557    else
01558       fViewMenu->UnCheckEntry(kViewToolTips);
01559 }
01560 
01561 //______________________________________________________________________________
01562 Bool_t TRootCanvas::HasEditor() const
01563 {
01564    // Returns kTRUE if the editor is shown.
01565 
01566    return (fEditor) && fViewMenu->IsEntryChecked(kViewEditor);
01567 }
01568 
01569 //______________________________________________________________________________
01570 Bool_t TRootCanvas::HasMenuBar() const
01571 {
01572    // Returns kTRUE if the menu bar is shown.
01573 
01574    return (fMenuBar) && fMenuBar->IsMapped();
01575 }
01576 
01577 //______________________________________________________________________________
01578 Bool_t TRootCanvas::HasStatusBar() const
01579 {
01580    // Returns kTRUE if the status bar is shown.
01581 
01582    return (fStatusBar) && fStatusBar->IsMapped();
01583 }
01584 
01585 //______________________________________________________________________________
01586 Bool_t TRootCanvas::HasToolBar() const
01587 {
01588    // Returns kTRUE if the tool bar is shown.
01589 
01590    return (fToolBar) && fToolBar->IsMapped();
01591 }
01592 
01593 //______________________________________________________________________________
01594 Bool_t TRootCanvas::HasToolTips() const
01595 {
01596    // Returns kTRUE if the tooltips are enabled.
01597 
01598    return (fCanvas) && fCanvas->GetShowToolTips();
01599 }
01600 
01601 //______________________________________________________________________________
01602 void TRootCanvas::AdjustSize()
01603 {
01604    // Keep the same canvas size while docking/undocking toolbar.
01605 
01606    UInt_t h = GetHeight();
01607    UInt_t dh = fToolBar->GetHeight();
01608    UInt_t sh = fHorizontal1->GetHeight();
01609 
01610    if (fToolDock->IsUndocked()) {
01611       if (!fViewMenu->IsEntryChecked(kViewEditor)) {
01612          HideFrame(fHorizontal1);
01613          h = h - sh;
01614       }
01615       HideFrame(fToolBarSep);
01616       h = h - dh - sh;
01617    } else {
01618       if (!fViewMenu->IsEntryChecked(kViewEditor)) {
01619          ShowFrame(fHorizontal1);
01620          h = h + sh;
01621       }
01622       ShowFrame(fToolBarSep);
01623       h = h + dh + sh;
01624    }
01625    Resize(GetWidth(), h);
01626 }
01627 
01628 //______________________________________________________________________________
01629 Bool_t TRootCanvas::HandleContainerButton(Event_t *event)
01630 {
01631    // Handle mouse button events in the canvas container.
01632 
01633    Int_t button = event->fCode;
01634    Int_t x = event->fX;
01635    Int_t y = event->fY;
01636 
01637    if (event->fType == kButtonPress) {
01638       if (fToolTip && fCanvas->GetShowToolTips()) {
01639          fToolTip->Hide();
01640          gVirtualX->UpdateWindow(0);
01641          gSystem->ProcessEvents();
01642       }
01643       fButton = button;
01644       if (button == kButton1) {
01645          if (event->fState & kKeyShiftMask)
01646             fCanvas->HandleInput(kButton1Shift, x, y);
01647          else
01648             fCanvas->HandleInput(kButton1Down, x, y);
01649       }
01650       if (button == kButton2)
01651          fCanvas->HandleInput(kButton2Down, x, y);
01652       if (button == kButton3) {
01653          fCanvas->HandleInput(kButton3Down, x, y);
01654          fButton = 0;  // button up is consumed by TContextMenu
01655       }
01656 
01657    } else if (event->fType == kButtonRelease) {
01658       if (button == kButton4)
01659          fCanvas->HandleInput(kWheelUp, x, y);
01660       if (button == kButton5)
01661          fCanvas->HandleInput(kWheelDown, x, y);
01662       if (button == kButton1)
01663          fCanvas->HandleInput(kButton1Up, x, y);
01664       if (button == kButton2)
01665          fCanvas->HandleInput(kButton2Up, x, y);
01666       if (button == kButton3)
01667          fCanvas->HandleInput(kButton3Up, x, y);
01668 
01669       fButton = 0;
01670    }
01671 
01672    return kTRUE;
01673 }
01674 
01675 //______________________________________________________________________________
01676 Bool_t TRootCanvas::HandleContainerDoubleClick(Event_t *event)
01677 {
01678    // Handle mouse button double click events in the canvas container.
01679 
01680    Int_t button = event->fCode;
01681    Int_t x = event->fX;
01682    Int_t y = event->fY;
01683 
01684    if (button == kButton1)
01685       fCanvas->HandleInput(kButton1Double, x, y);
01686    if (button == kButton2)
01687       fCanvas->HandleInput(kButton2Double, x, y);
01688    if (button == kButton3)
01689       fCanvas->HandleInput(kButton3Double, x, y);
01690 
01691    return kTRUE;
01692 }
01693 
01694 //______________________________________________________________________________
01695 Bool_t TRootCanvas::HandleContainerConfigure(Event_t *)
01696 {
01697    // Handle configure (i.e. resize) event.
01698    if (fAutoFit) {
01699       fCanvas->Resize();
01700       fCanvas->Update();
01701    }
01702 
01703    if (fCanvas->HasFixedAspectRatio()) {
01704       // get menu height
01705       static Int_t dh = 0;
01706       if (!dh)
01707          dh = GetHeight() - fCanvasContainer->GetHeight();
01708       UInt_t h = TMath::Nint(fCanvasContainer->GetWidth()/
01709                              fCanvas->GetAspectRatio()) + dh;
01710       SetWindowSize(GetWidth(), h);
01711    }
01712    return kTRUE;
01713 }
01714 
01715 //______________________________________________________________________________
01716 Bool_t TRootCanvas::HandleContainerKey(Event_t *event)
01717 {
01718    // Handle keyboard events in the canvas container.
01719 
01720    if (event->fType == kGKeyPress) {
01721       fButton = event->fCode;
01722       UInt_t keysym;
01723       char str[2];
01724       gVirtualX->LookupString(event, str, sizeof(str), keysym);
01725 
01726       if (str[0] == kESC){   // ESC sets the escape flag
01727          gROOT->SetEscape();
01728          fCanvas->HandleInput(kButton1Up, 0, 0);
01729          fCanvas->HandleInput(kMouseMotion, 0, 0);
01730          gPad->Modified();
01731          return kTRUE;
01732       }
01733 
01734       if (str[0] == 3)   // ctrl-c sets the interrupt flag
01735          gROOT->SetInterrupt();
01736       fCanvas->HandleInput(kKeyPress, str[0], keysym);
01737    } else if (event->fType == kKeyRelease)
01738       fButton = 0;
01739 
01740    return kTRUE;
01741 }
01742 
01743 //______________________________________________________________________________
01744 Bool_t TRootCanvas::HandleContainerMotion(Event_t *event)
01745 {
01746    // Handle mouse motion event in the canvas container.
01747 
01748    Int_t x = event->fX;
01749    Int_t y = event->fY;
01750 
01751    if (fButton == 0)
01752       fCanvas->HandleInput(kMouseMotion, x, y);
01753    if (fButton == kButton1) {
01754       if (event->fState & kKeyShiftMask)
01755          fCanvas->HandleInput(EEventType(8), x, y);
01756       else
01757          fCanvas->HandleInput(kButton1Motion, x, y);
01758    }
01759    if (fButton == kButton2)
01760       fCanvas->HandleInput(kButton2Motion, x, y);
01761 
01762    return kTRUE;
01763 }
01764 
01765 //______________________________________________________________________________
01766 Bool_t TRootCanvas::HandleContainerExpose(Event_t *event)
01767 {
01768    // Handle expose events.
01769 
01770    if (event->fCount == 0) {
01771       fCanvas->Flush();
01772    }
01773 
01774    return kTRUE;
01775 }
01776 
01777 //______________________________________________________________________________
01778 Bool_t TRootCanvas::HandleContainerCrossing(Event_t *event)
01779 {
01780    // Handle enter/leave events. Only leave is activated at the moment.
01781 
01782    Int_t x = event->fX;
01783    Int_t y = event->fY;
01784 
01785    // pointer grabs create also an enter and leave event but with fCode
01786    // either kNotifyGrab or kNotifyUngrab, don't propagate these events
01787    if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
01788       fCanvas->HandleInput(kMouseLeave, x, y);
01789 
01790    return kTRUE;
01791 }
01792 
01793 //______________________________________________________________________________
01794 Bool_t TRootCanvas::HandleDNDDrop(TDNDData *data)
01795 {
01796    // Handle drop events.
01797 
01798    static Atom_t rootObj  = gVirtualX->InternAtom("application/root", kFALSE);
01799    static Atom_t uriObj  = gVirtualX->InternAtom("text/uri-list", kFALSE);
01800 
01801    if (data->fDataType == rootObj) {
01802       TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
01803       buf.SetReadMode();
01804       TObject *obj = (TObject *)buf.ReadObjectAny(TObject::Class());
01805       if (!obj) return kTRUE;
01806       gPad->Clear();
01807       if (obj->InheritsFrom("TKey")) {
01808          TObject *object = (TObject *)gROOT->ProcessLine(Form("((TKey *)0x%lx)->ReadObj();", (ULong_t)obj));
01809          if (!object) return kTRUE;
01810          if (object->InheritsFrom("TGraph"))
01811             object->Draw("ACP");
01812          else if (object->InheritsFrom("TImage"))
01813             object->Draw("x");
01814          else if (object->IsA()->GetMethodAllAny("Draw"))
01815             object->Draw();
01816       }
01817       else if (obj->InheritsFrom("TGraph"))
01818          obj->Draw("ACP");
01819       else if (obj->IsA()->GetMethodAllAny("Draw"))
01820          obj->Draw();
01821       gPad->Modified();
01822       gPad->Update();
01823       return kTRUE;
01824    }
01825    else if (data->fDataType == uriObj) {
01826       TString sfname((char *)data->fData);
01827       if (sfname.Length() > 7) {
01828          sfname.ReplaceAll("\r\n", "");
01829          TUrl uri(sfname.Data());
01830          if (sfname.EndsWith(".bmp") ||
01831             sfname.EndsWith(".gif") ||
01832             sfname.EndsWith(".jpg") ||
01833             sfname.EndsWith(".png") ||
01834             sfname.EndsWith(".ps")  ||
01835             sfname.EndsWith(".eps") ||
01836             sfname.EndsWith(".pdf") ||
01837             sfname.EndsWith(".tiff") ||
01838             sfname.EndsWith(".xpm")) {
01839             TImage *img = TImage::Open(uri.GetFile());
01840             if (img) {
01841                img->Draw("x");
01842                img->SetEditable(kTRUE);
01843             }
01844          }
01845          gPad->Modified();
01846          gPad->Update();
01847       }
01848    }
01849    return kFALSE;
01850 }
01851 
01852 //______________________________________________________________________________
01853 Atom_t TRootCanvas::HandleDNDPosition(Int_t x, Int_t y, Atom_t action,
01854                                       Int_t /*xroot*/, Int_t /*yroot*/)
01855 {
01856    // Handle dragging position events.
01857 
01858    TPad *pad = fCanvas->Pick(x, y, 0);
01859    if (pad) {
01860       pad->cd();
01861       gROOT->SetSelectedPad(pad);
01862       // make sure the pad is highlighted (on Windows)
01863       pad->Update();
01864    }
01865    return action;
01866 }
01867 
01868 //______________________________________________________________________________
01869 Atom_t TRootCanvas::HandleDNDEnter(Atom_t *typelist)
01870 {
01871    // Handle drag enter events.
01872 
01873    static Atom_t rootObj  = gVirtualX->InternAtom("application/root", kFALSE);
01874    static Atom_t uriObj  = gVirtualX->InternAtom("text/uri-list", kFALSE);
01875    Atom_t ret = kNone;
01876    for (int i = 0; typelist[i] != kNone; ++i) {
01877       if (typelist[i] == rootObj)
01878          ret = rootObj;
01879       if (typelist[i] == uriObj)
01880          ret = uriObj;
01881    }
01882    return ret;
01883 }
01884 
01885 //______________________________________________________________________________
01886 Bool_t TRootCanvas::HandleDNDLeave()
01887 {
01888    // Handle drag leave events.
01889 
01890    return kTRUE;
01891 }
01892 
01893 //______________________________________________________________________________
01894 void TRootContainer::SavePrimitive(ostream &out, Option_t * /*= ""*/)
01895 {
01896    // Save a canvas container as a C++ statement(s) on output stream out.
01897 
01898    out << endl << "   // canvas container" << endl;
01899    out << "   Int_t canvasID = gVirtualX->InitWindow((ULong_t)"
01900        << GetParent()->GetParent()->GetName() << "->GetId());" << endl;
01901    out << "   Window_t winC = gVirtualX->GetWindowID(canvasID);" << endl;
01902    out << "   TGCompositeFrame *";
01903    out << GetName() << " = new TGCompositeFrame(gClient,winC"
01904        << "," << GetParent()->GetName() << ");" << endl;
01905 }

Generated on Tue Jul 5 14:22:07 2011 for ROOT_528-00b_version by  doxygen 1.5.1