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
19
20/** \class TLink
21\ingroup BasicGraphics
22
23Special TText object used to show hyperlinks.
24
25In the example below created by TObject::Inspect, TLinks are used
26to show pointers to other objects.
27Clicking on one link, inspect the corresponding object.
28*/
29
30////////////////////////////////////////////////////////////////////////////////
31/// Link default constructor.
32
34{
35}
36
37////////////////////////////////////////////////////////////////////////////////
38/// Constructor to define a link object.
39///
40/// pointer points to any kind of object.
41
43 : TText(x, y, "")
44{
45 fLink = pointer;
46 static char line[16];
47 snprintf(line,16,"->%zx ", (size_t)pointer);
49}
50
51////////////////////////////////////////////////////////////////////////////////
52/// Link default destructor.
53
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
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;
77 if (!idcur) return;
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
Definition Buttons.h:23
@ kButton1Up
Definition Buttons.h:19
@ kHand
Definition GuiTypes.h:374
#define gPad
#define snprintf
Definition civetweb.c:1579
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
TClass * GetBaseClass(const char *classname)
Return pointer to the base class "classname".
Definition TClass.cxx:2660
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
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
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