ROOT
master
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
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
}
36
37
////////////////////////////////////////////////////////////////////////////////
38
/// Constructor to define a link object.
39
///
40
/// pointer points to any kind of object.
41
42
TLink::TLink
(
Double_t
x
,
Double_t
y
,
void
*pointer)
43
:
TText
(
x
,
y
,
""
)
44
{
45
fLink
= pointer;
46
static
char
line
[16];
47
snprintf
(
line
,16,
"->%zx "
, (
size_t
)pointer);
48
SetTitle
(
line
);
49
}
50
51
////////////////////////////////////////////////////////////////////////////////
52
/// Link default destructor.
53
54
TLink::~TLink
()
55
{
56
}
57
58
////////////////////////////////////////////////////////////////////////////////
59
/// Execute action corresponding to one event.
60
///
61
/// This member function is called when a link is clicked with the locator
62
///
63
/// If mouse is clicked on a link text, the object pointed by the link
64
/// is Inspected
65
66
void
TLink::ExecuteEvent
(
Int_t
event,
Int_t
,
Int_t
)
67
{
68
if
(!
gPad
)
return
;
69
70
if
(event ==
kMouseMotion
)
71
gPad
->SetCursor(
kHand
);
72
73
if
(event !=
kButton1Up
)
return
;
74
75
if
(
TestBit
(
kIsStarStar
))
return
;
76
TObject
*
idcur
= (
TObject
*)
fLink
;
77
if
(!
idcur
)
return
;
78
TClass
*cl =
TClass::GetClass
(
GetName
());
79
if
(!cl)
return
;
80
81
// check if link points to a TObject
82
TClass
*
c1
= (
TClass
*)cl->
GetBaseClass
(
"TObject"
);
83
if
(!
c1
)
return
;
84
85
idcur
->Inspect();
86
}
kMouseMotion
@ kMouseMotion
Definition
Buttons.h:23
kButton1Up
@ kButton1Up
Definition
Buttons.h:19
kHand
@ kHand
Definition
GuiTypes.h:374
TClass.h
TLink.h
TVirtualPad.h
gPad
#define gPad
Definition
TVirtualPad.h:308
snprintf
#define snprintf
Definition
civetweb.c:1579
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition
TClass.h:84
TClass::GetBaseClass
TClass * GetBaseClass(const char *classname)
Return pointer to the base class "classname".
Definition
TClass.cxx:2660
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:2973
TLink::ExecuteEvent
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition
TLink.cxx:66
TLink::~TLink
~TLink() override
Link default destructor.
Definition
TLink.cxx:54
TLink::fLink
void * fLink
pointer to object
Definition
TLink.h:21
TLink::TLink
TLink()
Link default constructor.
Definition
TLink.cxx:33
TLink::kIsStarStar
@ kIsStarStar
Definition
TLink.h:24
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition
TNamed.cxx:173
TNamed::GetName
const char * GetName() const override
Returns name of object.
Definition
TNamed.h:49
TObject
Mother of all ROOT objects.
Definition
TObject.h:41
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition
TObject.h:202
TText
Base class for several text objects.
Definition
TText.h:22
double
int
line
TLine * line
Definition
entrylistblock_figure1.C:235
y
Double_t y[n]
Definition
legend1.C:17
c1
return c1
Definition
legend1.C:41
x
Double_t x[n]
Definition
legend1.C:17
graf2d
graf
src
TLink.cxx
ROOT master - Reference Guide Generated on Wed Sep 24 2025 04:33:13 (GVA Time) using Doxygen 1.10.0