Re: setting icon for TGMainFrame

From: Tom Roberts <tjrob_at_fnal.gov>
Date: Mon, 10 Sep 2007 17:32:36 -0500


Never mind. I had typo-ed my earlier attempt to use an absolute path in SetIconPixmap(). When I spell it correctly that works.

On Mac OS the icons seems to be completely ignored. But then, it only appears in the window title bar (minimizing gives a thumbnail of the window, not its icon). On both Windows and Linux, using the absolute path of the .png file in SetIconPixmap() works; no need to set Gui.IconPath.

I have no idea what's wrong with the code below -- perhaps the underlying window implementation needs to find icons and keeps a separate path which it gets before my code runs?

Tom Roberts

Tom Roberts wrote:
> This is driving me crazy! Here's my code (inside a large macro):
>
> // set Gui.IconPath
> char tmp[1024];
> sprintf(tmp,"%s:%s",getenv("HOME"),
> gEnv->GetValue("Gui.IconPath","."));
> assert(strlen(tmp)<sizeof(tmp)); // snprintf() not available
> gEnv->SetValue("Gui.IconPath",tmp);
> printf("Gui.IconPath='%s'\n",gEnv->GetValue("Gui.IconPath","."));
>
> window = new TGMainFrame(gClient->GetRoot(),200,200,
> kVerticalFrame);
> window->SetIconPixmap("historooticon.png");
>
>
> Here's the output on Linux:
>
> Gui.IconPath='/home/tjrob:/home/tjrob/icons:/home/tjrob/root/icons:.'
> root [1] .!ls -l /home/tjrob/historooticon.png
> -rw-r--r-- 1 tjrob tjrob 591 Sep 10 11:56 /home/tjrob/historooticon.png
>
>
> That output looks fine, BUT I GET THE WRONG ICON (the default X-windows
> "X").
>
>
> If I copy historooticon.png to either /home/tjrob/root/icons or "." then
> I get the correct icon.
>
> What is going on? Why doesn't it use the updated Gui.IconPath?
>
>
> Tom Roberts
>
>
>
> Ilka Antcheva wrote:

>> Hi Tom,
>>
>> Define for your class const TGPicture *fIconPic;
>> In your class constructor use:
>> fIconPic = SetIconPixmap("your_icon.png");
>> In your class destructor (to avoid memory leak):
>> if (fIconPic) gClient->FreePicture(fIconPic);
>>
>> If you need to specify in addition the special path to the icon 
>> directory, you may have a look at 
>> http://root.cern.ch/phpBB2/viewtopic.php?t=5390
>>
>> Cheers, Ilka
>>
>> Tom Roberts wrote:
>>> My Root application is implemented as a TGMainFrame. How can I set 
>>> the icon for this window? The documentation is obscure ("... this is 
>>> typically done via the window manager", but no hint how to do that).
>>>
>>> I need to handle Windows, Linux, and Mac OS X, and have versions of 
>>> my icon in .ico, .png, and .icns formats.
>>>
>>>
>>> Tom Roberts
>>>

>
Received on Tue Sep 11 2007 - 00:36:15 CEST

This archive was generated by hypermail 2.2.0 : Wed Sep 12 2007 - 17:50:02 CEST