73 #include "RConfigure.h"
87 static const char *gOpenFileTypes[] = {
88 "ROOT files",
"*.root",
93 static const char *gPluginFileTypes[] = {
106 ClassImp(TRootBrowser);
111 TRootBrowser::TRootBrowser(TBrowser *b,
const char *name, UInt_t width,
112 UInt_t height, Option_t *opt, Bool_t initshow) :
113 TGMainFrame(gClient->GetDefaultRoot(), width, height), TBrowserImp(b)
115 fShowCloseTab = kTRUE;
119 Resize(width, height);
124 TQObject::Connect(
"TCanvas",
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
125 "TRootBrowser",
this,
126 "EventInfo(Int_t, Int_t, Int_t, TObject*)");
127 gVirtualX->SetInputFocus(GetId());
133 TRootBrowser::TRootBrowser(TBrowser *b,
const char *name, Int_t x, Int_t y,
134 UInt_t width, UInt_t height, Option_t *opt,
136 TGMainFrame(gClient->GetDefaultRoot(), width, height), TBrowserImp(b)
138 fShowCloseTab = kTRUE;
142 MoveResize(x, y, width, height);
148 TQObject::Connect(
"TCanvas",
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
149 "TRootBrowser",
this,
150 "EventInfo(Int_t, Int_t, Int_t, TObject*)");
151 gVirtualX->SetInputFocus(GetId());
157 void TRootBrowser::CreateBrowser(
const char *name)
161 fVf =
new TGVerticalFrame(
this, 100, 100);
163 fLH0 =
new TGLayoutHints(kLHintsNormal);
164 fLH1 =
new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
165 fLH2 =
new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 1, 1);
166 fLH3 =
new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX);
167 fLH4 =
new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX | kLHintsExpandY,2,2,2,2);
168 fLH5 =
new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX | kLHintsExpandY);
169 fLH6 =
new TGLayoutHints(kLHintsBottom | kLHintsExpandX);
170 fLH7 =
new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandY);
173 fTopMenuFrame =
new TGHorizontalFrame(fVf, 100, 20);
175 fPreMenuFrame =
new TGHorizontalFrame(fTopMenuFrame, 0, 20, kRaisedFrame);
176 fMenuBar =
new TGMenuBar(fPreMenuFrame, 10, 10, kHorizontalFrame);
177 fMenuFile =
new TGPopupMenu(gClient->GetDefaultRoot());
178 fMenuFile->AddEntry(
"&Browse...\tCtrl+B", kBrowse);
179 fMenuFile->AddEntry(
"&Open...\tCtrl+O", kOpenFile);
180 fMenuFile->AddSeparator();
182 fMenuHelp =
new TGPopupMenu(fClient->GetRoot());
183 fMenuHelp->AddEntry(
"&About ROOT...", kHelpAbout);
184 fMenuHelp->AddSeparator();
185 fMenuHelp->AddEntry(
"Help On Browser...", kHelpOnBrowser);
186 fMenuHelp->AddEntry(
"Help On Canvas...", kHelpOnCanvas);
187 fMenuHelp->AddEntry(
"Help On Menus...", kHelpOnMenus);
188 fMenuHelp->AddEntry(
"Help On Graphics Editor...", kHelpOnGraphicsEd);
189 fMenuHelp->AddEntry(
"Help On Objects...", kHelpOnObjects);
190 fMenuHelp->AddEntry(
"Help On PostScript...", kHelpOnPS);
191 fMenuHelp->AddEntry(
"Help On Remote Session...", kHelpOnRemote);
192 fMenuFile->AddPopup(
"Browser Help...", fMenuHelp);
194 fMenuFile->AddSeparator();
195 fMenuFile->AddEntry(
"&Clone\tCtrl+N", kClone);
196 fMenuFile->AddSeparator();
197 fMenuFile->AddEntry(
"New &Editor\tCtrl+E", kNewEditor);
198 fMenuFile->AddEntry(
"New &Canvas\tCtrl+C", kNewCanvas);
199 fMenuFile->AddEntry(
"New &HTML\tCtrl+H", kNewHtml);
200 fMenuFile->AddSeparator();
201 fMenuExecPlugin =
new TGPopupMenu(fClient->GetRoot());
202 fMenuExecPlugin->AddEntry(
"&Macro...", kExecPluginMacro);
203 fMenuExecPlugin->AddEntry(
"&Command...", kExecPluginCmd);
204 fMenuFile->AddPopup(
"Execute &Plugin...", fMenuExecPlugin);
205 fMenuFile->AddSeparator();
206 fMenuFile->AddEntry(
"Close &Tab\tCtrl+T", kCloseTab);
207 fMenuFile->AddEntry(
"Close &Window\tCtrl+W", kCloseWindow);
208 fMenuFile->AddSeparator();
209 fMenuFile->AddEntry(
"&Quit Root\tCtrl+Q", kQuitRoot);
210 fMenuBar->AddPopup(
"&Browser", fMenuFile, fLH1);
211 fMenuFile->Connect(
"Activated(Int_t)",
"TRootBrowser",
this,
212 "HandleMenu(Int_t)");
213 fPreMenuFrame->AddFrame(fMenuBar, fLH2);
214 fTopMenuFrame->AddFrame(fPreMenuFrame, fLH0);
216 if (!TClass::GetClass(
"TGHtmlBrowser"))
217 fMenuFile->DisableEntry(kNewHtml);
219 fMenuFrame =
new TGHorizontalFrame(fTopMenuFrame, 100, 20, kRaisedFrame);
220 fTopMenuFrame->AddFrame(fMenuFrame, fLH5);
222 fVf->AddFrame(fTopMenuFrame, fLH3);
223 fActMenuBar = fMenuBar;
226 fToolbarFrame =
new TGHorizontalFrame(fVf, 100, 20, kHorizontalFrame |
228 fVf->AddFrame(fToolbarFrame, fLH3);
230 fHf =
new TGHorizontalFrame(fVf, 100, 100);
232 #if defined(R__HAS_COCOA)
233 fV1 =
new TGVerticalFrame(fHf, 252, 100, kFixedWidth);
235 fV1 =
new TGVerticalFrame(fHf, 250, 100, kFixedWidth);
237 fV2 =
new TGVerticalFrame(fHf, 600, 100);
238 fH1 =
new TGHorizontalFrame(fV2, 100, 100);
239 fH2 =
new TGHorizontalFrame(fV2, 100, 100, kFixedHeight);
242 fTabLeft =
new TGTab(fV1,100,100);
244 fTabLeft->Resize(fTabLeft->GetDefaultSize());
245 fV1->AddFrame(fTabLeft, fLH4);
248 fVSplitter =
new TGVSplitter(fHf, 4, 4);
249 fVSplitter->SetFrame(fV1, kTRUE);
250 fHf->AddFrame(fV1, fLH7);
251 fHf->AddFrame(fVSplitter, fLH7);
254 fTabRight =
new TGTab(fH1, 500, 100);
256 fTabRight->Resize(fTabRight->GetDefaultSize());
257 fH1->AddFrame(fTabRight, fLH5);
258 fTabRight->Connect(
"Selected(Int_t)",
"TRootBrowser",
this,
"DoTab(Int_t)");
259 fTabRight->Connect(
"CloseTab(Int_t)",
"TRootBrowser",
this,
"CloseTab(Int_t)");
260 fV2->AddFrame(fH1, fLH4);
263 fHSplitter =
new TGHSplitter(fV2, 4, 4);
264 fV2->AddFrame(fHSplitter, fLH3);
267 fTabBottom =
new TGTab(fH2, 100, 100);
269 fH2->AddFrame(fTabBottom, fLH4);
270 fV2->AddFrame(fH2, fLH3);
272 fHSplitter->SetFrame(fH2, kFALSE);
273 fHf->AddFrame(fV2, fLH5);
274 fVf->AddFrame(fHf, fLH5);
278 fStatusBar =
new TGStatusBar(
this, 400, 20);
279 int parts[] = { 33, 10, 10, 47 };
280 fStatusBar->SetParts(parts, 4);
281 AddFrame(fStatusBar, fLH6);
288 fNbTab[0] = fNbTab[1] = fNbTab[2] = 0;
289 fCrTab[0] = fCrTab[1] = fCrTab[2] = -1;
294 fIconPic = SetIconPixmap(
"rootdb_s.xpm");
295 SetClassHints(
"ROOT",
"Browser");
297 if (!strcmp(gROOT->GetDefCanvasName(),
"c1"))
298 gROOT->SetDefCanvasName(
"Canvas_1");
300 SetWMSizeHints(600, 350, 10000, 10000, 2, 2);
302 Resize(GetDefaultSize());
303 AddInput(kKeyPressMask | kKeyReleaseMask);
305 fVf->HideFrame(fToolbarFrame);
311 TRootBrowser::~TRootBrowser()
313 if (fIconPic) gClient->FreePicture(fIconPic);
323 delete fMenuExecPlugin;
327 delete fPreMenuFrame;
328 delete fTopMenuFrame;
329 delete fToolbarFrame;
350 void TRootBrowser::Add(TObject *obj,
const char *name, Int_t check)
352 if (obj->InheritsFrom(
"TObjectSpy"))
355 fActBrowser->Add(obj, name, check);
363 void TRootBrowser::BrowseObj(TObject *obj)
366 fActBrowser->BrowseObj(obj);
367 Emit(
"BrowseObj(TObject*)", (Long_t)obj);
374 void TRootBrowser::CloneBrowser()
377 TBrowserPlugin *plugin = 0;
378 TBrowser *b =
new TBrowser();
379 TIter next(&fPlugins);
380 while ((plugin = (TBrowserPlugin *)next())) {
381 if (loop > fNbInitPlugins)
382 b->ExecPlugin(plugin->GetName(),
"", plugin->fCommand.Data(), plugin->fTab,
391 void TRootBrowser::CloseTab(Int_t
id)
393 RemoveTab(kRight,
id);
399 void TRootBrowser::CloseTabs()
402 TGCompositeFrame *container;
404 TQObject::Disconnect(
"TCanvas",
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
405 this,
"EventInfo(Int_t, Int_t, Int_t, TObject*)");
406 Disconnect(fMenuFile,
"Activated(Int_t)",
this,
"HandleMenu(Int_t)");
407 Disconnect(fTabRight,
"Selected(Int_t)",
this,
"DoTab(Int_t)");
408 if (fPlugins.IsEmpty())
return;
410 for (i=0;i<fTabLeft->GetNumberOfTabs();i++) {
411 container = fTabLeft->GetTabContainer(i);
412 if (!container)
continue;
413 el = (TGFrameElement *)container->GetList()->First();
414 if (el && el->fFrame) {
415 el->fFrame->SetFrameElement(0);
416 if (el->fFrame->InheritsFrom(
"TVirtualPadEditor")) {
417 TVirtualPadEditor::Terminate();
419 else if (el->fFrame->InheritsFrom(
"TGMainFrame")) {
420 el->fFrame->UnmapWindow();
421 ((TGMainFrame *)el->fFrame)->CloseWindow();
422 gSystem->ProcessEvents();
427 if (el->fLayout && (el->fLayout != fgDefaultHints) &&
428 (el->fLayout->References() > 0)) {
429 el->fLayout->RemoveReference();
430 if (!el->fLayout->References()) {
434 container->GetList()->Remove(el);
438 for (i=0;i<fTabRight->GetNumberOfTabs();i++) {
439 container = fTabRight->GetTabContainer(i);
440 if (!container)
continue;
441 el = (TGFrameElement *)container->GetList()->First();
442 if (el && el->fFrame) {
443 el->fFrame->SetFrameElement(0);
444 if (el->fFrame->InheritsFrom(
"TGMainFrame")) {
445 el->fFrame->UnmapWindow();
446 Bool_t sleep = (el->fFrame->InheritsFrom(
"TRootCanvas")) ? kTRUE : kFALSE;
449 ((TGMainFrame *)el->fFrame)->CloseWindow();
452 gSystem->ProcessEvents();
457 if (el->fLayout && (el->fLayout != fgDefaultHints) &&
458 (el->fLayout->References() > 0)) {
459 el->fLayout->RemoveReference();
460 if (!el->fLayout->References()) {
464 container->GetList()->Remove(el);
468 for (i=0;i<fTabBottom->GetNumberOfTabs();i++) {
469 container = fTabBottom->GetTabContainer(i);
470 if (!container)
continue;
471 el = (TGFrameElement *)container->GetList()->First();
472 if (el && el->fFrame) {
473 el->fFrame->SetFrameElement(0);
474 if (el->fFrame->InheritsFrom(
"TGMainFrame")) {
475 el->fFrame->UnmapWindow();
476 ((TGMainFrame *)el->fFrame)->CloseWindow();
478 gSystem->ProcessEvents();
483 if (el->fLayout && (el->fLayout != fgDefaultHints) &&
484 (el->fLayout->References() > 0)) {
485 el->fLayout->RemoveReference();
486 if (!el->fLayout->References()) {
490 container->GetList()->Remove(el);
495 Emit(
"CloseWindow()");
501 void TRootBrowser::CloseWindow()
503 TQObject::Disconnect(
"TCanvas",
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
504 this,
"EventInfo(Int_t, Int_t, Int_t, TObject*)");
512 void TRootBrowser::DoTab(Int_t
id)
514 TGTab *sender = (TGTab *)gTQSender;
515 if ((sender) && (sender == fTabRight)) {
516 SwitchMenus(sender->GetTabContainer(
id));
523 void TRootBrowser::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
525 const Int_t kTMAX=256;
526 static char atext[kTMAX];
527 if (selected == 0 || event == kMouseLeave) {
528 SetStatusText(
"", 0);
529 SetStatusText(
"", 1);
530 SetStatusText(
"", 2);
531 SetStatusText(
"", 3);
534 SetStatusText(selected->GetTitle(), 0);
535 SetStatusText(selected->GetName(), 1);
536 if (event == kKeyPress)
537 snprintf(atext, kTMAX,
"%c", (
char) px);
539 snprintf(atext, kTMAX,
"%d,%d", px, py);
540 SetStatusText(atext, 2);
541 SetStatusText(selected->GetObjectInfo(px,py), 3);
548 Long_t TRootBrowser::ExecPlugin(
const char *name,
const char *fname,
549 const char *cmd, Int_t pos, Int_t subpos)
553 TString command, pname;
554 if (cmd && strlen(cmd)) {
556 if (name) pname = name;
557 else pname = TString::Format(
"Plugin %d", fPlugins.GetSize());
558 p =
new TBrowserPlugin(pname.Data(), command.Data(), pos, subpos);
560 else if (fname && strlen(fname)) {
561 pname = name ? name : gSystem->BaseName(fname);
562 Ssiz_t t = pname.Last(
'.');
563 if (t > 0) pname.Remove(t);
564 command.Form(
"gROOT->Macro(\"%s\");", gSystem->UnixPathName(fname));
565 p =
new TBrowserPlugin(pname.Data(), command.Data(), pos, subpos);
568 if (IsWebGUI() && command.Contains(
"new TCanvas"))
569 return gROOT->ProcessLine(command.Data());
570 StartEmbedding(pos, subpos);
572 retval = gROOT->ProcessLine(command.Data());
573 if (command.Contains(
"new TCanvas")) {
574 pname = gPad->GetName();
575 p->SetName(pname.Data());
577 SetTabTitle(pname.Data(), pos, subpos);
585 Option_t *TRootBrowser::GetDrawOption()
const
588 return fActBrowser->GetDrawOption();
595 TGTab* TRootBrowser::GetTab(Int_t pos)
const
598 case kLeft:
return fTabLeft;
599 case kRight:
return fTabRight;
600 case kBottom:
return fTabBottom;
608 Bool_t TRootBrowser::HandleKey(Event_t *event)
613 if (event->fType == kGKeyPress) {
614 gVirtualX->LookupString(event, input,
sizeof(input), keysym);
616 if (!event->fState && (EKeySym)keysym == kKey_F5) {
620 switch ((EKeySym)keysym) {
627 case kKey_ScrollLock:
632 if (event->fState & kKeyControlMask) {
633 switch ((EKeySym)keysym & ~0x20) {
635 fMenuFile->Activated(kBrowse);
638 fMenuFile->Activated(kOpenFile);
641 fMenuFile->Activated(kNewEditor);
644 fMenuFile->Activated(kNewCanvas);
647 fMenuFile->Activated(kNewHtml);
650 fMenuFile->Activated(kClone);
653 fMenuFile->Activated(kCloseTab);
656 fMenuFile->Activated(kCloseWindow);
659 fMenuFile->Activated(kQuitRoot);
666 return TGMainFrame::HandleKey(event);
672 void TRootBrowser::HandleMenu(Int_t
id)
676 static Int_t eNr = 1;
677 TGPopupMenu *sender = (TGPopupMenu *)gTQSender;
678 if (sender != fMenuFile)
686 Bool_t newfile = kFALSE;
687 static TString dir(
".");
689 fi.fFileTypes = gOpenFileTypes;
690 fi.fIniDir = StrDup(dir);
691 new TGFileDialog(gClient->GetDefaultRoot(),
this,
694 if (fi.fMultipleSelection && fi.fFileNamesList) {
696 TIter next(fi.fFileNamesList);
697 while ((el = (TObjString *) next())) {
698 gROOT->ProcessLine(Form(
"new TFile(\"%s\");",
699 gSystem->UnixPathName(el->GetString())));
703 else if (fi.fFilename) {
704 gROOT->ProcessLine(Form(
"new TFile(\"%s\");",
705 gSystem->UnixPathName(fi.fFilename)));
708 if (fActBrowser && newfile) {
709 TGFileBrowser *fb =
dynamic_cast<TGFileBrowser *
>(fActBrowser);
710 if (fb) fb->Selected(0);
718 TString rootx = TROOT::GetBinDir() +
"/root -a &";
719 gSystem->Exec(rootx);
722 new TWin32SplashThread(kTRUE);
725 sprintf(str,
"About ROOT %s...", gROOT->GetVersion());
726 hd =
new TRootHelpDialog(
this, str, 600, 400);
727 hd->SetText(gHelpAbout);
734 hd =
new TRootHelpDialog(
this,
"Help on Canvas...", 600, 400);
735 hd->SetText(gHelpCanvas);
739 hd =
new TRootHelpDialog(
this,
"Help on Menus...", 600, 400);
740 hd->SetText(gHelpPullDownMenus);
743 case kHelpOnGraphicsEd:
744 hd =
new TRootHelpDialog(
this,
"Help on Graphics Editor...", 600, 400);
745 hd->SetText(gHelpGraphicsEditor);
749 hd =
new TRootHelpDialog(
this,
"Help on Browser...", 600, 400);
750 hd->SetText(gHelpBrowser);
754 hd =
new TRootHelpDialog(
this,
"Help on Objects...", 600, 400);
755 hd->SetText(gHelpObjects);
759 hd =
new TRootHelpDialog(
this,
"Help on PostScript...", 600, 400);
760 hd->SetText(gHelpPostscript);
764 hd =
new TRootHelpDialog(
this,
"Help on Browser...", 600, 400);
765 hd->SetText(gHelpRemote);
772 cmd.Form(
"new TGTextEditor((const char *)0, gClient->GetRoot())");
774 ExecPlugin(Form(
"Editor %d", eNr),
"", cmd.Data(), 1);
778 gROOT->ProcessLine(
"new TCanvas()");
780 ExecPlugin(
"",
"",
"new TCanvas()", 1);
783 cmd.Form(
"new TGHtmlBrowser(\"%s\", gClient->GetRoot())",
784 gEnv->GetValue(
"Browser.StartUrl",
"http://root.cern.ch"));
785 ExecPlugin(
"HTML",
"", cmd.Data(), 1);
787 case kExecPluginMacro:
789 static TString dir(
".");
791 fi.fFileTypes = gPluginFileTypes;
792 fi.fIniDir = StrDup(dir);
793 new TGFileDialog(gClient->GetDefaultRoot(),
this,
797 ExecPlugin(0, fi.fFilename, 0, kRight);
804 strlcpy(command,
"new TGLSAViewer(gClient->GetRoot(), 0);",
806 new TGInputDialog(gClient->GetRoot(),
this,
807 "Enter plugin command line:",
809 if (strcmp(command,
"")) {
810 ExecPlugin(
"User", 0, command, kRight);
815 CloseTab(fTabRight->GetCurrent());
822 gApplication->Terminate(0);
839 void TRootBrowser::InitPlugins(Option_t *opt)
843 if ((opt == 0) || (!opt[0]))
848 if (strchr(opt,
'F')) {
849 cmd.Form(
"new TGFileBrowser(gClient->GetRoot(), (TBrowser *)0x%lx, 200, 500);", (ULong_t)fBrowser);
850 ExecPlugin(
"Files", 0, cmd.Data(), 0);
856 Int_t i, len = strlen(opt);
857 for (i=0; i<len; ++i) {
860 cmd.Form(
"new TGTextEditor((const char *)0, gClient->GetRoot());");
861 ExecPlugin(
"Editor 1", 0, cmd.Data(), 1);
867 if (gSystem->Load(
"libGuiHtml") >= 0) {
868 cmd.Form(
"new TGHtmlBrowser(\"%s\", gClient->GetRoot());",
869 gEnv->GetValue(
"Browser.StartUrl",
870 "http://root.cern.ch/root/html/ClassIndex.html"));
871 ExecPlugin(
"HTML", 0, cmd.Data(), 1);
877 if ((opt[i] ==
'C') && !IsWebGUI()) {
878 cmd.Form(
"new TCanvas();");
879 ExecPlugin(
"c1", 0, cmd.Data(), 1);
885 cmd.Form(
"new TGLSAViewer(gClient->GetRoot(), 0);");
886 ExecPlugin(
"OpenGL", 0, cmd.Data(), 1);
892 cmd.Form(
"new TSessionViewer();");
893 ExecPlugin(
"PROOF", 0, cmd.Data(), 1);
900 if (strchr(opt,
'I')) {
901 cmd.Form(
"new TGCommandPlugin(gClient->GetRoot(), 700, 300);");
902 ExecPlugin(
"Command", 0, cmd.Data(), 2);
915 Bool_t TRootBrowser::IsWebGUI()
917 TString factory = gEnv->GetValue(
"Gui.Factory",
"native");
918 return (factory.Contains(
"web", TString::kIgnoreCase));
924 void TRootBrowser::ReallyDelete()
926 if (fBrowser) fBrowser->SetBrowserImp(0);
933 void TRootBrowser::RecursiveRemove(TObject *obj)
936 fActBrowser->RecursiveRemove(obj);
942 void TRootBrowser::RecursiveReparent(TGPopupMenu *popup)
944 TGMenuEntry *entry = 0;
945 TIter next(popup->GetListOfEntries());
946 while ((entry = (TGMenuEntry *)next())) {
947 if (entry->GetPopup()) {
948 RecursiveReparent(entry->GetPopup());
951 popup->ReparentWindow(gClient->GetDefaultRoot());
957 void TRootBrowser::Refresh(Bool_t force)
960 fActBrowser->Refresh(force);
966 void TRootBrowser::RemoveTab(Int_t pos, Int_t subpos)
975 fMenuFrame->HideFrame(fActMenuBar);
976 fMenuFrame->GetList()->Remove(fActMenuBar);
983 if (!edit || !edit->GetTabTab(subpos))
985 const char *tabName = edit->GetTabTab(subpos)->GetString();
987 if ((obj = fPlugins.FindObject(tabName))) {
988 fPlugins.Remove(obj);
990 TGFrameElement *el = 0;
991 if (edit->GetTabContainer(subpos))
992 el = (TGFrameElement *)edit->GetTabContainer(subpos)->GetList()->First();
993 if (el && el->fFrame) {
994 el->fFrame->Disconnect(
"ProcessedConfigure(Event_t*)");
995 el->fFrame->SetFrameElement(0);
996 if (el->fFrame->InheritsFrom(
"TGMainFrame")) {
997 Bool_t sleep = (el->fFrame->InheritsFrom(
"TRootCanvas")) ? kTRUE : kFALSE;
998 ((TGMainFrame *)el->fFrame)->CloseWindow();
1000 gSystem->Sleep(150);
1001 gSystem->ProcessEvents();
1006 if (el->fLayout && (el->fLayout != fgDefaultHints) &&
1007 (el->fLayout->References() > 0)) {
1008 el->fLayout->RemoveReference();
1009 if (!el->fLayout->References()) {
1013 edit->GetTabContainer(subpos)->GetList()->Remove(el);
1017 edit->RemoveTab(subpos);
1018 SwitchMenus(edit->GetTabContainer(edit->GetCurrent()));
1024 void TRootBrowser::SetTab(Int_t pos, Int_t subpos)
1026 TGTab *tab = GetTab(pos);
1028 subpos = fCrTab[pos];
1030 if (tab && tab->SetTab(subpos, kFALSE)) {
1032 SwitchMenus(tab->GetTabContainer(subpos));
1040 void TRootBrowser::SetTabTitle(
const char *title, Int_t pos, Int_t subpos)
1042 TBrowserPlugin *p = 0;
1043 TGTab *edit = GetTab(pos);
1046 subpos = fCrTab[pos];
1048 TGTabElement *el = edit->GetTabTab(subpos);
1050 el->SetText(
new TGString(title));
1052 if ((p = (TBrowserPlugin *)fPlugins.FindObject(title)))
1060 void TRootBrowser::SetStatusText(
const char* txt, Int_t col)
1062 fStatusBar->SetText(txt, col);
1068 void TRootBrowser::ShowMenu(TGCompositeFrame *menu)
1070 TGFrameElement *el = 0;
1073 fBindList->Delete();
1074 TIter nextm(fMenuBar->GetList());
1075 while ((el = (TGFrameElement *) nextm())) {
1076 TGMenuTitle *t = (TGMenuTitle *) el->fFrame;
1077 Int_t code = t->GetHotKeyCode();
1078 BindKey(fMenuBar, code, kKeyMod1Mask);
1079 BindKey(fMenuBar, code, kKeyMod1Mask | kKeyShiftMask);
1080 BindKey(fMenuBar, code, kKeyMod1Mask | kKeyLockMask);
1081 BindKey(fMenuBar, code, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
1082 BindKey(fMenuBar, code, kKeyMod1Mask | kKeyMod2Mask);
1083 BindKey(fMenuBar, code, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
1084 BindKey(fMenuBar, code, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
1085 BindKey(fMenuBar, code, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask | kKeyLockMask);
1087 fMenuFrame->HideFrame(fActMenuBar);
1088 fMenuFrame->ShowFrame(menu);
1090 fMenuFrame->Layout();
1097 void TRootBrowser::StartEmbedding(Int_t pos, Int_t subpos)
1099 fEditTab = GetTab(pos);
1100 if (!fEditTab)
return;
1102 fEditSubPos = subpos;
1104 if (fEditFrame == 0) {
1106 fCrTab[pos] = fNbTab[pos]++;
1107 fEditFrame = fEditTab->AddTab(Form(
"Tab %d",fNbTab[pos]));
1108 fEditSubPos = fEditTab->GetNumberOfTabs()-1;
1109 fEditFrame->MapWindow();
1110 TGTabElement *tabel = fEditTab->GetTabTab(fEditSubPos);
1113 if (fShowCloseTab && (pos == 1))
1116 fEditTab->SetTab(fEditTab->GetNumberOfTabs()-1);
1120 fCrTab[pos] = subpos;
1121 fEditFrame = fEditTab->GetTabContainer(subpos);
1122 fEditTab->SetTab(subpos);
1124 if (fEditFrame) fEditFrame->SetEditable();
1131 void TRootBrowser::StopEmbedding(
const char *name, TGLayoutHints *layout)
1133 if (fEditFrame != 0) {
1134 fEditFrame->SetEditable(kFALSE);
1135 TGFrameElement *el = (TGFrameElement*) fEditFrame->GetList()->First();
1136 if (el && el->fFrame) {
1139 el->fFrame->Connect(
"ProcessedConfigure(Event_t*)",
"TGCompositeFrame",
1140 fEditFrame,
"Layout()");
1143 el = (TGFrameElement*) fEditFrame->GetList()->Last();
1145 if (el) el->fLayout = layout;
1147 fEditFrame->Layout();
1148 if (fEditTab == fTabRight)
1149 SwitchMenus(fEditFrame);
1151 if (name && strlen(name)) {
1152 SetTabTitle(name, fEditPos, fEditSubPos);
1154 if (fEditTab) fEditTab->Selected(fEditSubPos);
1155 fEditFrame = fEditTab = 0;
1156 fEditPos = fEditSubPos = -1;
1163 void TRootBrowser::SwitchMenus(TGCompositeFrame *from)
1167 TGFrameElement *fe = (TGFrameElement *)from->GetList()->First();
1169 if (fActMenuBar != fMenuBar)
1173 TGCompositeFrame *embed = (TGCompositeFrame *)fe->fFrame;
1174 TGFrameElement *el = 0;
1175 if (embed && embed->GetList()) {
1176 TIter next(embed->GetList());
1177 while ((el = (TGFrameElement *)next())) {
1178 if (el->fFrame->InheritsFrom(
"TGMenuBar")) {
1179 TGMenuBar *menu = (TGMenuBar *)el->fFrame;
1180 if (fActMenuBar == menu)
1183 TIter nel(fMenuFrame->GetList());
1184 while ((nw = (TGFrameElement *) nel())) {
1185 if (nw->fFrame == menu) {
1190 ((TGCompositeFrame *)menu->GetParent())->HideFrame(menu);
1191 ((TGCompositeFrame *)menu->GetParent())->SetCleanup(kNoCleanup);
1192 menu->ReparentWindow(fMenuFrame);
1193 fMenuFrame->AddFrame(menu, fLH2);
1194 TGFrameElement *mel;
1195 TIter mnext(menu->GetList());
1196 while ((mel = (TGFrameElement *) mnext())) {
1197 TGMenuTitle *t = (TGMenuTitle *) mel->fFrame;
1198 TGPopupMenu *popup = menu->GetPopup(t->GetName());
1200 RecursiveReparent(popup);
1201 if (popup->GetEntry(
"Close Canvas")) {
1202 TGMenuEntry *exit = popup->GetEntry(
"Close Canvas");
1203 popup->HideEntry(exit->GetEntryId());
1205 if (popup->GetEntry(
"Close Viewer")) {
1206 TGMenuEntry *exit = popup->GetEntry(
"Close Viewer");
1207 popup->HideEntry(exit->GetEntryId());
1209 if (popup->GetEntry(
"Quit ROOT")) {
1210 TGMenuEntry *exit = popup->GetEntry(
"Quit ROOT");
1211 popup->HideEntry(exit->GetEntryId());
1213 if (popup->GetEntry(
"Exit")) {
1214 TGMenuEntry *exit = popup->GetEntry(
"Exit");
1215 popup->HideEntry(exit->GetEntryId());
1224 if (fActMenuBar != fMenuBar)
1231 void TRootBrowser::DoubleClicked(TObject *obj)
1233 Emit(
"DoubleClicked(TObject*)", (Long_t)obj);
1239 void TRootBrowser::Checked(TObject *obj, Bool_t checked)
1243 args[0] = (Long_t)obj;
1246 Emit(
"Checked(TObject*,Bool_t)", args);
1252 void TRootBrowser::ExecuteDefaultAction(TObject *obj)
1254 Emit(
"ExecuteDefaultAction(TObject*)", (Long_t)obj);
1262 TBrowserImp *TRootBrowser::NewBrowser(TBrowser *b,
const char *title,
1263 UInt_t width, UInt_t height,
1266 TRootBrowser *browser =
new TRootBrowser(b, title, width, height, opt);
1267 return (TBrowserImp *)browser;
1274 TBrowserImp *TRootBrowser::NewBrowser(TBrowser *b,
const char *title, Int_t x,
1275 Int_t y, UInt_t width, UInt_t height,
1278 TRootBrowser *browser =
new TRootBrowser(b, title, x, y, width, height, opt);
1279 return (TBrowserImp *)browser;