diff --git a/gui/src/TRootBrowser.cxx b/gui/src/TRootBrowser.cxx index 8d6c013feb9024b71b990dfee34ec26ca7b1d5fe..f74ad122977dd6ee6efc1d975f73471d9ff7577c 100644 --- a/gui/src/TRootBrowser.cxx +++ b/gui/src/TRootBrowser.cxx @@ -1,4 +1,4 @@ -// @(#)root/gui:$Name: $:$Id: TRootBrowser.cxx,v 1.4 2000/09/07 00:35:30 rdm Exp $ +// @(#)root/gui:$Name: $:$Id: TRootBrowser.cxx,v 1.5 2000/09/07 11:19:52 rdm Exp $ // Author: Fons Rademakers 27/02/98 /************************************************************************* @@ -132,29 +132,70 @@ static const char *gOpenTypes[] = { "ROOT files", "*.root", 0, 0 }; +//----- Special ROOT object item (this are items in the icon box, see +//----- TRootIconBox) + +class TRootObjItem : public TGFileItem { +public: + TRootObjItem(const TGWindow *p, const TGPicture *bpic, + const TGPicture *spic, TGString *name, + TObject *obj, TClass *cl, EListViewMode viewMode); +}; + +//______________________________________________________________________________ +TRootObjItem::TRootObjItem(const TGWindow *p, const TGPicture *bpic, + const TGPicture *spic, TGString *name, + TObject *obj, TClass *, EListViewMode viewMode) : + TGFileItem(p, bpic, 0, spic, 0, name, 0, 0, 0, 0, viewMode) +{ + // Create an icon box item. + + delete [] fSubnames; + fSubnames = new TGString* [2]; + + fSubnames[0] = new TGString(obj->GetTitle()); + + fSubnames[1] = 0; + + int i; + for (i = 0; fSubnames[i] != 0; ++i) + ; + fCtw = new int[i]; + for (i = 0; fSubnames[i] != 0; ++i) + fCtw[i] = gVirtualX->TextWidth(fFontStruct, fSubnames[i]->GetString(), + fSubnames[i]->GetLength()); +} + //----- Special ROOT object container (this is the icon box on the //----- right side of the browser) class TRootIconBox : public TGFileContainer { - +private: + TGListView *fLV; // list view containing TRootIconBox + Bool_t fCheckHeaders; // if true check headers public: - TRootIconBox(const TGWindow *p, UInt_t w, UInt_t h, + TRootIconBox(const TGWindow *p, TGListView *lv, UInt_t w, UInt_t h, UInt_t options = kSunkenFrame, ULong_t back = fgDefaultFrameBackground); void AddObjItem(const char *name, TObject *obj, TClass *cl); void GetObjPictures(const TGPicture **pic, const TGPicture **spic, TObject *obj, const char *name); + void SetObjHeaders(); void Refresh(); + void RemoveAll(); }; //______________________________________________________________________________ -TRootIconBox::TRootIconBox(const TGWindow *p, UInt_t w, UInt_t h, - UInt_t options, ULong_t back) : +TRootIconBox::TRootIconBox(const TGWindow *p, TGListView *lv, UInt_t w, + UInt_t h, UInt_t options, ULong_t back) : TGFileContainer(p, w, h, options, back) { // Create iconbox containing ROOT objects in browser. + fLV = lv; + fCheckHeaders = kTRUE; + // Don't use timer HERE (timer is set in TBrowser). delete fRefresh; fRefresh = 0; @@ -195,6 +236,11 @@ void TRootIconBox::AddObjItem(const char *name, TObject *obj, TClass *cl) if (obj->IsA() == TSystemFile::Class() || obj->IsA() == TSystemDirectory::Class()) { + if (fCheckHeaders) { + if (strcmp(fLV->GetHeader(1), "Attributes")) + fLV->SetDefaultHeaders(); + fCheckHeaders = kFALSE; + } fi = AddFile(name); if (fi) fi->SetUserData(obj); return; @@ -205,8 +251,12 @@ void TRootIconBox::AddObjItem(const char *name, TObject *obj, TClass *cl) GetObjPictures(&pic, &spic, obj, obj->GetIconName() ? obj->GetIconName() : cl->GetName()); - fi = new TGFileItem(this, pic, 0, spic, 0, new TGString(name), - 0, cl->Size(), 0, 0, fViewMode); + if (fCheckHeaders) { + if (strcmp(fLV->GetHeader(1), "Title")) + SetObjHeaders(); + fCheckHeaders = kFALSE; + } + fi = new TRootObjItem(this, pic, spic, new TGString(name), obj, cl, fViewMode); if (fi) fi->SetUserData(obj); AddItem(fi); @@ -214,6 +264,17 @@ void TRootIconBox::AddObjItem(const char *name, TObject *obj, TClass *cl) fTotal++; } +//______________________________________________________________________________ +void TRootIconBox::SetObjHeaders() +{ + // Set list box headers used to display detailed object iformation. + // Currently this is only "Name" and "Title". + + fLV->SetHeaders(2); + fLV->SetHeader("Name", kTextLeft, kTextLeft, 0); + fLV->SetHeader("Title", kTextLeft, kTextLeft, 1); +} + //______________________________________________________________________________ void TRootIconBox::Refresh() { @@ -230,6 +291,15 @@ void TRootIconBox::Refresh() MapSubwindows(); } +//______________________________________________________________________________ +void TRootIconBox::RemoveAll() +{ + // Reset the fCheckHeaders flag. + + fCheckHeaders = kTRUE; + TGFileContainer::RemoveAll(); +} + ClassImp(TRootBrowser) @@ -466,11 +536,10 @@ void TRootBrowser::CreateBrowser(const char *name) fWidgets->Add(lo); fV1->AddFrame(fTreeView, lo); - // Create list view (icon box) fListView = new TGListView(fV2, 520, 250); - fIconBox = new TRootIconBox(fListView->GetViewPort(), 520, 250, + fIconBox = new TRootIconBox(fListView->GetViewPort(), fListView, 520, 250, kHorizontalFrame, fgWhitePixel); fIconBox->Associate(this);