RE: [ROOT] user-defined icons in TBrowser - is it possible?

From: Faine, Valeri (fine@bnl.gov)
Date: Mon Jan 06 2003 - 04:29:47 MET


Hi Pasha,

> Dear Rooters, Happy New Year to all!

Thank you. 
Happy New Year for all ROOTmen and ROOTwomen

> I have a set of subdirectories (subfolders) in ROOT file containing
> good/bad objects - and would like to the corresponding folder
> icons to be displayed by TBrowser in different colors - is there a
> way to do it?

Have you tried to add your class/xpm class combination to
$ROOTSYS/etc/root.mimes

[root/tmuffin]
pattern = TMuffin
icon = muffin_s.xpm muffin_t.xpm

At the moment ROOT uses your class name as a key to find your xpm image.
I think it can be changed to use the GetName() as an option.

I mean at the moment ROOT selects the icon image with the 
statements:

    if (isKey) set = fMimeTypeList->GetIcon(isKey->GetClassName());
    else       set = fMimeTypeList->GetIcon(obj->ClassName());
   
If one would add

 If (!set) set = fMimeTypeList->GetIcon(obj->GetName());

this may have added an extra functionality you probably speaking about.

May be it worth to modify the existent 

   TBrowser::Add(TObject *obj, const char *name = 0); 

 interface like this:

 TBrowser::Add(TObject *obj, const char *name = 0, const char
*iconKey=0);

 And use the "iconKey" to select the user-provided icon first. The logic
to select the appropriated icon may have looked as follow:

    set = 0;
    if (iconKey && iconKey[0]) 
        set = fMimeTypeList->GetIcon(iconKey);
    if (!set) 
        set = fMimeTypeList->GetIcon(obj->GetName());
    if (!set) {
      if (isKey) 
        set = fMimeTypeList->GetIcon(isKey->GetClassName());
      else       
        set = fMimeTypeList->GetIcon(obj->ClassName());
    }

I've added this feature to my Qt-based ROOT version (
http://root.cern.ch ) 

Of course with Qt-based version one can use Qt method
http://doc.trolltech.com/3.1/qiconviewitem.html#setPixmap-2 
also. However this way one may have became Qt addicted ( like me :-)

             Valeri

> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]
> On Behalf Of Pasha Murat 630-840-8237/169G
> Sent: Saturday, January 04, 2003 11:29 PM
> To: roottalk
> Subject: [ROOT] user-defined icons in TBrowser - is it possible?
> 
> Dear Rooters, Happy New Year to all!
> 
> I have a set of subdirectories (subfolders) in ROOT file containing
> good/bad objects - and would like to the coresponding folder
> icons to be displayed by TBrowser in different colors - is there a
> way to do it?
> 					-thanks, Pasha
> 
> P.S. Here is more "generic" example: I have a [user-defined] class,
> say, TMuffin, and would like TBrowser to display it using a
user-defined
> icon muffin.xpm.



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:08 MET