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

From: Pasha Murat 630-840-8237/169G (murat@fnal.gov)
Date: Mon Jan 06 2003 - 05:43:58 MET


Hi Valery, 

thanks, I found a workaround for my problem by defining 2 different 
classes - one for the "green" folders, another one - for the "red" 
ones... But I think that having the following interface 

    if (isKey) set = fMimeTypeList->GetIcon(obj->GetIconName());

    if GetIconName() is not defined, then use whatever defaults 
    are foreseen in *mime*.

would be much more flexible and elegant...

					-best, Pasha


"Faine, Valeri" wrote:
> 
> 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



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