Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor which stores gPad and set it to new value
44/// @param gpad pointer to current pad
45/// @param interactive defines how gPad will be restored: with cd() call (kTRUE) or just by assign gPad back
46/// @param not_null allows to set only pad which is not null
47
49{
50 fInteractive = interactive;
51 fSaved = gPad;
52 if (fInteractive && gpad)
53 gpad->cd();
54 else if (!not_null || gpad)
55 gPad = gpad;
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// Destructor
60/// Restores previous value of gPad
61
63{
64 if (!fInteractive || !fSaved)
65 gPad = fSaved;
66 else
67 fSaved->cd();
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// Inform context that pad deleted or will be deleted soon
72/// Reference on that pad should be cleared
73
75{
76 if (pad == fSaved)
77 fSaved = nullptr;
78}
79
80////////////////////////////////////////////////////////////////////////////////
81/// Return the current pad for the current thread.
82
84{
85 static TVirtualPad *currentPad = nullptr;
86 if (!gThreadTsd)
87 return currentPad;
88 else
90}
91
93
94////////////////////////////////////////////////////////////////////////////////
95/// VirtualPad default constructor
96
101
102////////////////////////////////////////////////////////////////////////////////
103/// VirtualPad constructor
104
105TVirtualPad::TVirtualPad(const char *, const char *, Double_t,
107 : TAttPad()
108{
110
111 SetFillColor(color);
112 SetFillStyle(1001);
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// VirtualPad destructor
117
121
122////////////////////////////////////////////////////////////////////////////////
123/// Stream an object of class TVirtualPad.
124
126{
127 if (R__b.IsReading()) {
129 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
130 if (R__v > 1) {
131 R__b.ReadClassBuffer(TVirtualPad::Class(), this, R__v, R__s, R__c);
132 return;
133 }
134 //====process old versions before automatic schema evolution
139 //====end of old versions
140
141 } else {
142 R__b.WriteClassBuffer(TVirtualPad::Class(),this);
143 }
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Should always return false unless you have non-standard picking.
148
150{
151 return kFALSE;
152}
153
154////////////////////////////////////////////////////////////////////////////////
155/// Should always return false, unless you can highlight selected object in pad.
156
158{
159 return kFALSE;
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Does nothing, unless you implement your own picking.
164/// When complex object containing sub-objects (which can be picked)
165/// is painted in a pad, this "top-level" object is pushed into
166/// the selectables stack.
167
169{
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// Does nothing, unless you implement your own picking.
174/// "Complete" object, or part of complex object, which
175/// can be picked.
176
178{
179}
180
181////////////////////////////////////////////////////////////////////////////////
182/// Does nothing, unless you implement your own picking.
183/// Remove top level selectable and all its' children.
184
188
189////////////////////////////////////////////////////////////////////////////////
190/// Scope-guards ctor, pushe the object on stack.
191
193{
194 gPad->PushTopLevelSelectable(obj);
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Guard does out of scope, pop object from stack.
199
201{
202 gPad->PopTopLevelSelectable();
203}
int Int_t
Definition RtypesCore.h:45
short Color_t
Definition RtypesCore.h:85
short Version_t
Definition RtypesCore.h:65
short Short_t
Definition RtypesCore.h:39
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
#define ClassImp(name)
Definition Rtypes.h:374
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t SetFillStyle
Option_t Option_t SetFillColor
R__EXTERN void **(* gThreadTsd)(void *, Int_t)
Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
#define gPad
virtual void Streamer(TBuffer &)
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
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:955
~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.
TContext(Bool_t _interactive=kFALSE)
Constructor which just store gPad.
TVirtualPad * fSaved
Definition TVirtualPad.h:63
void PadDeleted(TVirtualPad *pad)
Inform context that pad deleted or will be deleted soon Reference on that pad should be cleared.
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.
static TVirtualPad *& Pad()
Return the current pad for the current thread.
Bool_t fResizing
Definition TVirtualPad.h:54
virtual void PopTopLevelSelectable()
Does nothing, unless you implement your own picking.
@ kPadThreadSlot