ROOT
6.14/05
Reference Guide
graf2d
graf
src
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 <stdio.h>
13
14
#include "
TVirtualPad.h
"
15
#include "
TClass.h
"
16
#include "
TLink.h
"
17
18
ClassImp
(
TLink
);
19
20
/** \class TLink
21
\ingroup BasicGraphics
22
23
Special TText object used to show hyperlinks.
24
25
In the example below created by TObject::Inspect, TLinks are used
26
to show pointers to other objects.
27
Clicking on one link, inspect the corresponding object.
28
*/
29
30
////////////////////////////////////////////////////////////////////////////////
31
/// Link default constructor.
32
33
TLink::TLink
() :
TText
()
34
{
35
fLink
= 0;
36
}
37
38
////////////////////////////////////////////////////////////////////////////////
39
/// Constructor to define a link object.
40
///
41
/// pointer points to any kind of object.
42
43
TLink::TLink
(
Double_t
x
,
Double_t
y
,
void
*pointer)
44
:
TText
(x, y,
""
)
45
{
46
fLink
= pointer;
47
static
char
line
[16];
48
snprintf
(line,16,
"->%lx "
, (
Long_t
)pointer);
49
SetTitle
(line);
50
}
51
52
////////////////////////////////////////////////////////////////////////////////
53
/// Link default destructor.
54
55
TLink::~TLink
()
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
67
void
TLink::ExecuteEvent
(
Int_t
event,
Int_t
,
Int_t
)
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
;
79
TClass
*cl =
TClass::GetClass
(
GetName
());
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
}
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition:
TNamed.h:47
TClass.h
line
TLine * line
Definition:
entrylistblock_figure1.C:235
c1
return c1
Definition:
legend1.C:41
TLink::ExecuteEvent
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition:
TLink.cxx:67
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition:
TObject.h:172
TLink::fLink
void * fLink
pointer to object
Definition:
TLink.h:22
kButton1Up
Definition:
Buttons.h:19
Int_t
int Int_t
Definition:
RtypesCore.h:41
x
Double_t x[n]
Definition:
legend1.C:17
TLink::~TLink
virtual ~TLink()
Link default destructor.
Definition:
TLink.cxx:55
TText
Base class for several text objects.
Definition:
TText.h:23
kMouseMotion
Definition:
Buttons.h:23
TVirtualPad.h
TClass::GetBaseClass
TClass * GetBaseClass(const char *classname)
Return pointer to the base class "classname".
Definition:
TClass.cxx:2574
TLink::kIsStarStar
Definition:
TLink.h:25
TObject::Inspect
virtual void Inspect() const
Dump contents of this object in a graphics canvas.
Definition:
TObject.cxx:464
TClass
The ROOT global object gROOT contains a list of all defined classes.
Definition:
TClass.h:75
Long_t
long Long_t
Definition:
RtypesCore.h:50
ClassImp
#define ClassImp(name)
Definition:
Rtypes.h:359
TLink::TLink
TLink()
Link default constructor.
Definition:
TLink.cxx:33
Double_t
double Double_t
Definition:
RtypesCore.h:55
y
Double_t y[n]
Definition:
legend1.C:17
TLink.h
TClass::GetClass
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:2887
TObject
Mother of all ROOT objects.
Definition:
TObject.h:37
snprintf
#define snprintf
Definition:
civetweb.c:1351
kHand
Definition:
TVirtualX.h:46
gPad
#define gPad
Definition:
TVirtualPad.h:285
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition:
TNamed.cxx:164
TLink
Special TText object used to show hyperlinks.
Definition:
TLink.h:18