Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TLink.cxx
Go to the documentation of this file.
1// @(#)root/graf:$Id$
2// Author: Rene Brun 05/03/95
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#include <cstdio>
13
14#include "TVirtualPad.h"
15#include "TClass.h"
16#include "TLink.h"
17#include "snprintf.h"
18
20
21/** \class TLink
22\ingroup BasicGraphics
23
24Special TText object used to show hyperlinks.
25
26In the example below created by TObject::Inspect, TLinks are used
27to show pointers to other objects.
28Clicking on one link, inspect the corresponding object.
29*/
30
31////////////////////////////////////////////////////////////////////////////////
32/// Link default constructor.
33
35{
36}
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor to define a link object.
40///
41/// pointer points to any kind of object.
42
44 : TText(x, y, "")
45{
46 fLink = pointer;
47 static char line[16];
48 snprintf(line,16,"->%zx ", (size_t)pointer);
50}
51
52////////////////////////////////////////////////////////////////////////////////
53/// Link default destructor.
54
56{
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Execute action corresponding to one event.
61///
62/// This member function is called when a link is clicked with the locator
63///
64/// If mouse is clicked on a link text, the object pointed by the link
65/// is Inspected
66
68{
69 if (!gPad) return;
70
71 if (event == kMouseMotion)
72 gPad->SetCursor(kHand);
73
74 if (event != kButton1Up) return;
75
76 if (TestBit(kIsStarStar)) return;
77 TObject *idcur = (TObject*)fLink;
78 if (!idcur) return;
80 if (!cl) return;
81
82 // check if link points to a TObject
83 TClass *c1 = (TClass*)cl->GetBaseClass("TObject");
84 if (!c1) return;
85
86 idcur->Inspect();
87}
@ kMouseMotion
Definition Buttons.h:23
@ kButton1Up
Definition Buttons.h:19
@ kHand
Definition GuiTypes.h:374
#define ClassImp(name)
Definition Rtypes.h:382
#define gPad
#define snprintf
Definition civetweb.c:1540
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
TClass * GetBaseClass(const char *classname)
Return pointer to the base class "classname".
Definition TClass.cxx:2724
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:3037
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Inspect() const
Dump contents of this object in a graphics canvas.
Definition TObject.cxx:563
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
Base class for several text objects.
Definition TText.h:22
TLine * line
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17