40 class TBrowserTimer :
public TTimer {
47 TBrowserTimer(TBrowser *b, Long_t ms = 1000)
48 : TTimer(ms, kTRUE), fBrowser(b), fActivate(kFALSE) { }
57 class TBrowserObject :
public TNamed
62 TBrowserObject(
void *obj, TClass *cl,
const char *brname);
65 void Browse(TBrowser* b);
66 Bool_t IsFolder()
const;
67 TClass *IsA()
const {
return fClass; }
84 TBrowser::TBrowser(
const char *name,
const char *title, TBrowserImp *extimp,
86 : TNamed(name, title), fLastSelectedObject(0), fImp(extimp), fTimer(0),
87 fContextMenu(0), fNeedRefresh(kFALSE)
90 TApplication::NeedGraphicsLibs();
91 gApplication->InitializeGraphics();
92 if (TClass::IsCallingNew() != TClass::kRealNew) {
95 Float_t cx = gStyle->GetScreenFactor();
96 UInt_t w = UInt_t(cx*800);
97 UInt_t h = UInt_t(cx*500);
98 if (!fImp) fImp = gGuiFactory->CreateBrowserImp(
this, title, w, h, opt);
106 TBrowser::TBrowser(
const char *name,
const char *title, UInt_t width,
107 UInt_t height, TBrowserImp *extimp, Option_t *opt)
108 : TNamed(name, title), fLastSelectedObject(0), fImp(extimp), fTimer(0), fContextMenu(0),
112 TApplication::NeedGraphicsLibs();
113 gApplication->InitializeGraphics();
114 if (!fImp) fImp = gGuiFactory->CreateBrowserImp(
this, title, width, height, opt);
121 TBrowser::TBrowser(
const char *name,
const char *title, Int_t x, Int_t y,
122 UInt_t width, UInt_t height, TBrowserImp *extimp, Option_t *opt)
123 : TNamed(name, title), fLastSelectedObject(0), fImp(extimp), fTimer(0), fContextMenu(0),
127 TApplication::NeedGraphicsLibs();
128 gApplication->InitializeGraphics();
129 fImp = gGuiFactory->CreateBrowserImp(
this, title, x, y, width, height, opt);
136 TBrowser::TBrowser(
const char *name, TObject *obj,
const char *title, Option_t *opt)
137 : TNamed(name, title), fLastSelectedObject(0), fImp(0), fTimer(0), fContextMenu(0),
141 TApplication::NeedGraphicsLibs();
142 gApplication->InitializeGraphics();
143 Float_t cx = gStyle->GetScreenFactor();
144 UInt_t w = UInt_t(cx*800);
145 UInt_t h = UInt_t(cx*500);
147 if (!fImp) fImp = gGuiFactory->CreateBrowserImp(
this, title, w, h, opt);
154 TBrowser::TBrowser(
const char *name, TObject *obj,
const char *title,
155 UInt_t width, UInt_t height, Option_t *opt)
156 : TNamed(name, title), fLastSelectedObject(0), fTimer(0), fContextMenu(0),
160 TApplication::NeedGraphicsLibs();
161 gApplication->InitializeGraphics();
162 fImp = gGuiFactory->CreateBrowserImp(
this, title, width, height, opt);
169 TBrowser::TBrowser(
const char *name, TObject *obj,
const char *title,
171 UInt_t width, UInt_t height, Option_t *opt)
172 : TNamed(name, title), fLastSelectedObject(0), fTimer(0), fContextMenu(0),
176 TApplication::NeedGraphicsLibs();
177 gApplication->InitializeGraphics();
178 fImp = gGuiFactory->CreateBrowserImp(
this, title, x, y, width, height, opt);
185 TBrowser::TBrowser(
const char *name,
void *obj, TClass *cl,
186 const char *objname,
const char *title, Option_t *opt)
187 : TNamed(name, title), fLastSelectedObject(0), fTimer(0), fContextMenu(0),
191 TApplication::NeedGraphicsLibs();
192 gApplication->InitializeGraphics();
193 Float_t cx = gStyle->GetScreenFactor();
194 UInt_t w = UInt_t(cx*800);
195 UInt_t h = UInt_t(cx*500);
197 fImp = gGuiFactory->CreateBrowserImp(
this, title, w, h, opt);
199 Create(
new TBrowserObject(obj,cl,objname));
205 TBrowser::TBrowser(
const char *name,
void *obj, TClass *cl,
206 const char *objname,
const char *title,
207 UInt_t width, UInt_t height, Option_t *opt)
208 : TNamed(name, title), fLastSelectedObject(0), fTimer(0), fContextMenu(0),
212 TApplication::NeedGraphicsLibs();
213 gApplication->InitializeGraphics();
214 fImp = gGuiFactory->CreateBrowserImp(
this, title, width, height, opt);
215 Create(
new TBrowserObject(obj,cl,objname));
221 TBrowser::TBrowser(
const char *name,
void *obj, TClass *cl,
222 const char *objname,
const char *title,
224 UInt_t width, UInt_t height, Option_t *opt)
225 : TNamed(name, title), fLastSelectedObject(0), fTimer(0), fContextMenu(0),
229 TApplication::NeedGraphicsLibs();
230 gApplication->InitializeGraphics();
231 fImp = gGuiFactory->CreateBrowserImp(
this, title, x, y, width, height, opt);
232 Create(
new TBrowserObject(obj,cl,objname));
238 TBrowser::~TBrowser()
246 void TBrowser::Destructor()
248 if (fImp) fImp->CloseTabs();
249 R__LOCKGUARD(gROOTMutex);
250 gROOT->GetListOfBrowsers()->Remove(
this);
253 if (fImp)
delete fImp;
261 void TBrowser::Add(TObject *obj,
const char *name, Int_t check)
264 fImp->Add(obj, name, check);
265 obj->SetBit(kMustCleanup);
280 void TBrowser::Add(
void *obj, TClass *cl,
const char *name, Int_t check)
282 if (!obj || !cl)
return;
284 if (cl->IsTObject()) to = (TObject*)cl->DynamicCast(TObject::Class(),obj,kTRUE);
285 else to =
new TBrowserObject(obj,cl,name);
294 void TBrowser::AddCheckBox(TObject *obj, Bool_t check)
297 fImp->AddCheckBox(obj, check);
304 void TBrowser::CheckObjectItem(TObject *obj, Bool_t check)
307 fImp->CheckObjectItem(obj, check);
314 void TBrowser::RemoveCheckBox(TObject *obj)
317 fImp->RemoveCheckBox(obj);
324 void TBrowser::Create(TObject *obj)
326 fNeedRefresh = kFALSE;
328 fTimer =
new TBrowserTimer(
this);
329 gSystem->AddTimer(fTimer);
331 R__LOCKGUARD(gROOTMutex);
332 gROOT->GetListOfBrowsers()->Add(
this);
335 gROOT->GetListOfGlobals(kTRUE);
336 gROOT->GetListOfGlobalFunctions(kTRUE);
338 fContextMenu =
new TContextMenu(
"BrowserContextMenu") ;
343 if (fImp) fImp->BrowseObj(obj);
346 fImp->BrowseObj(gROOT);
357 void TBrowser::ExecuteDefaultAction(TObject *obj)
360 fImp->ExecuteDefaultAction(obj);
366 void TBrowser::RecursiveRemove(TObject *obj)
369 fImp->RecursiveRemove(obj);
370 fNeedRefresh = kTRUE;
377 void TBrowser::Refresh()
379 fNeedRefresh = kTRUE;
380 if (fImp) fImp->Refresh();
381 fNeedRefresh = kFALSE;
387 void TBrowser::SetSelected(TObject *clickedObject)
389 fLastSelectedObject = clickedObject;
396 Bool_t TBrowserTimer::Notify()
399 if (fBrowser->GetRefreshFlag()) {
400 fBrowser->SetRefreshFlag(kFALSE);
402 }
else if (fActivate) {
420 TBrowserObject::TBrowserObject(
void *obj, TClass *cl,
const char *brname)
421 : TNamed(brname, cl ? cl->GetName() :
""), fObj(obj), fClass(cl)
423 if (cl==0) Fatal(
"Constructor",
"Class parameter should not be null");
430 Bool_t TBrowserObject::IsFolder()
const
432 return fClass->IsFolder(fObj);
438 void TBrowserObject::Browse(TBrowser* b)
440 fClass->Browse(fObj, b);