TLink.cxx

Go to the documentation of this file.
00001 // @(#)root/graf:$Id: TLink.cxx 35530 2010-09-21 12:41:48Z brun $
00002 // Author: Rene Brun   05/03/95
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 #include <stdio.h>
00013 
00014 #include "TVirtualPad.h"
00015 #include "TClass.h"
00016 #include "TLink.h"
00017 
00018 ClassImp(TLink)
00019 
00020 
00021 //______________________________________________________________________________
00022 //
00023 // Special TText object used to show hyperlinks.
00024 // In the example below created by TObject::Inspect, TLinks are used
00025 // to show pointers to other objects.
00026 // Clicking on one link, inspect the corresponding object.
00027 //Begin_Html
00028 /*
00029 <img src="gif/link.gif">
00030 */
00031 //End_Html
00032 //
00033 
00034 
00035 //______________________________________________________________________________
00036 TLink::TLink() : TText()
00037 {
00038    // Link default constructor.
00039 
00040    fLink  = 0;
00041 }
00042 
00043 
00044 //______________________________________________________________________________
00045 TLink::TLink(Double_t x, Double_t y, void *pointer)
00046            : TText(x, y, "")
00047 {
00048    // Constructor to define a link object.
00049    //
00050    // pointer points to any kind of object.
00051 
00052    fLink  = pointer;
00053    static char line[16];
00054    snprintf(line,16,"->%lx ", (Long_t)pointer);
00055    SetTitle(line);
00056 }
00057 
00058 
00059 //______________________________________________________________________________
00060 TLink::~TLink()
00061 {
00062    // Link default destructor.
00063 }
00064 
00065 
00066 //______________________________________________________________________________
00067 void TLink::ExecuteEvent(Int_t event, Int_t, Int_t)
00068 {
00069    // Execute action corresponding to one event.
00070    //
00071    //  This member function is called when a link is clicked with the locator
00072    //
00073    //  If mouse is clicked on a link text, the object pointed by the link
00074    //  is Inspected
00075 
00076    if (event == kMouseMotion)
00077       gPad->SetCursor(kHand);
00078 
00079    if (event != kButton1Up) return;
00080 
00081    if (TestBit(kIsStarStar)) return;
00082    TObject *idcur = (TObject*)fLink;
00083    if (!idcur) return;
00084    TClass *cl = TClass::GetClass(GetName());
00085    if (!cl) return;
00086 
00087    // check if link points to a TObject
00088    TClass *c1 = (TClass*)cl->GetBaseClass("TObject");
00089    if (!c1) return;
00090 
00091    idcur->Inspect();
00092 }

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