Logo ROOT  
Reference Guide
TVirtualPad.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Rene Brun 05/12/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 "TVirtualPad.h"
13#include "TBuffer.h"
14#include "TThreadSlots.h"
15
16/** \class TVirtualPad
17\ingroup Base
18
19TVirtualPad is an abstract base class for the Pad and Canvas classes.
20*/
21
22Int_t (*gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret) = nullptr;
23
24
25/** \class TVirtualPad::TContext
26\ingroup Base
27
28Small helper class to preserve gPad, which will be restored when TContext object is destroyed
29*/
30
31
32////////////////////////////////////////////////////////////////////////////////
33/// Constructor which just store gPad
34/// @param _interactive defines how gPad will be restored: with cd() call (kTRUE) or just by assign gPad back
35
37{
38 fInteractive = _interactive;
39 fSaved = gPad;
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor which stores gPad and set it to new value
44/// @param interactive defines how gPad will be restored: with cd() call (kTRUE) or just by assign gPad back
45/// @param not_null allows to set only pad which is not null
46
48{
49 fInteractive = interactive;
50 fSaved = gPad;
51 if (fInteractive && gpad)
52 gpad->cd();
53 else if (!not_null || gpad)
54 gPad = gpad;
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// Destructor
59/// Restores previous value of gPad
60
62{
63 if (!fInteractive || !fSaved)
64 gPad = fSaved;
65 else
66 fSaved->cd();
67}
68
69
70////////////////////////////////////////////////////////////////////////////////
71/// Return the current pad for the current thread.
72
74{
75 static TVirtualPad *currentPad = nullptr;
76 if (!gThreadTsd)
77 return currentPad;
78 else
79 return *(TVirtualPad**)(*gThreadTsd)(&currentPad,ROOT::kPadThreadSlot);
80}
81
83
84////////////////////////////////////////////////////////////////////////////////
85/// VirtualPad default constructor
86
88{
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// VirtualPad constructor
94
95TVirtualPad::TVirtualPad(const char *, const char *, Double_t,
97 : TAttPad()
98{
100
101 SetFillColor(color);
102 SetFillStyle(1001);
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// VirtualPad destructor
107
109{
110}
111
112////////////////////////////////////////////////////////////////////////////////
113/// Stream an object of class TVirtualPad.
114
116{
117 if (R__b.IsReading()) {
118 UInt_t R__s, R__c;
119 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
120 if (R__v > 1) {
121 R__b.ReadClassBuffer(TVirtualPad::Class(), this, R__v, R__s, R__c);
122 return;
123 }
124 //====process old versions before automatic schema evolution
125 TObject::Streamer(R__b);
126 TAttLine::Streamer(R__b);
127 TAttFill::Streamer(R__b);
128 TAttPad::Streamer(R__b);
129 //====end of old versions
130
131 } else {
133 }
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Should always return false unless you have non-standard picking.
138
140{
141 return kFALSE;
142}
143
144////////////////////////////////////////////////////////////////////////////////
145/// Should always return false, unless you can highlight selected object in pad.
146
148{
149 return kFALSE;
150}
151
152////////////////////////////////////////////////////////////////////////////////
153/// Does nothing, unless you implement your own picking.
154/// When complex object containing sub-objects (which can be picked)
155/// is painted in a pad, this "top-level" object is pushed into
156/// the selectables stack.
157
159{
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Does nothing, unless you implement your own picking.
164/// "Complete" object, or part of complex object, which
165/// can be picked.
166
168{
169}
170
171////////////////////////////////////////////////////////////////////////////////
172/// Does nothing, unless you implement your own picking.
173/// Remove top level selectable and all its' children.
174
176{
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Scope-guards ctor, pushe the object on stack.
181
183{
184 gPad->PushTopLevelSelectable(obj);
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Guard does out of scope, pop object from stack.
189
191{
192 gPad->PopTopLevelSelectable();
193}
int Int_t
Definition: RtypesCore.h:45
short Color_t
Definition: RtypesCore.h:92
short Version_t
Definition: RtypesCore.h:65
const Bool_t kFALSE
Definition: RtypesCore.h:101
short Short_t
Definition: RtypesCore.h:39
#define ClassImp(name)
Definition: Rtypes.h:375
R__EXTERN void **(* gThreadTsd)(void *, Int_t)
Definition: TThreadSlots.h:42
Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
Definition: TVirtualPad.cxx:22
#define gPad
Definition: TVirtualPad.h:302
virtual void Streamer(TBuffer &)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual void Streamer(TBuffer &)
Manages default Pad attributes.
Definition: TAttPad.h:19
virtual void Streamer(TBuffer &)
Stream an object of class TAttPad.
Definition: TAttPad.cxx:150
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition: TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Mother of all ROOT objects.
Definition: TObject.h:41
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition: TObject.cxx:882
~TPickerStackGuard()
Guard does out of scope, pop object from stack.
TPickerStackGuard(TObject *obj)
Scope-guards ctor, pushe the object on stack.
~TContext()
Destructor Restores previous value of gPad.
Definition: TVirtualPad.cxx:61
TContext(Bool_t _interactive=kFALSE)
Constructor which just store gPad.
Definition: TVirtualPad.cxx:36
TVirtualPad * fSaved
Definition: TVirtualPad.h:63
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51
virtual Bool_t PadInHighlightMode() const
Should always return false, unless you can highlight selected object in pad.
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual ~TVirtualPad()
VirtualPad destructor.
virtual Bool_t PadInSelectionMode() const
Should always return false unless you have non-standard picking.
virtual void PushTopLevelSelectable(TObject *top)
Does nothing, unless you implement your own picking.
void Streamer(TBuffer &) override
Stream an object of class TVirtualPad.
virtual void PushSelectableObject(TObject *obj)
Does nothing, unless you implement your own picking.
static TClass * Class()
TVirtualPad()
VirtualPad default constructor.
Definition: TVirtualPad.cxx:87
static TVirtualPad *& Pad()
Return the current pad for the current thread.
Definition: TVirtualPad.cxx:73
Bool_t fResizing
Definition: TVirtualPad.h:54
virtual void PopTopLevelSelectable()
Does nothing, unless you implement your own picking.
@ kPadThreadSlot
Definition: TThreadSlots.h:29