I am trying without success to define the icon of my TApplication program. On linux, this is very strait forward, I just have to use TGFrame::SetIconPixmap() and its working.
On mac this is not working. I tried to convert my icon to the macos icns format, and defining the the icon of a bundle application, but without success… The only icon that is shown is the ROOT logo, but if my mac is able to find the ROOT logo, it should be possible to find my own logo no ?
If you look at the code of this function it seems it takes $ROOTSYS/icons/Root6Icon.png has application icons. I guess if you change this picture it will change the icon of your Application ?
Looks like SetIconPixmap sets an icon for a window, not an app (in case of macOS you have app icon in a doc which can differ from an icon for some particular window). Application icon can be set using NSApplicaion.sharedApplication and its property applicationIconImage.
For a window it’s less trivial it would appear and actually assumes a proper use of AppKit and following Apples HIG. But here is how it can be done (quote from SO):
If I replace the icon $ROOTSYS/icons/Root6Icon.png by mine, it does exactly what I wanted to. But how can I do this in my code ? What is the programation language used in TGCocoa.mm and how to integrate it in my c++ program ?
Ok so I succeeded to fix the issue. This is the first time I see Objective-C++ so this is probably not the best way to do, but it works. I had to do a wrapper class:
Important thing, this has to be done after the first graphical call to TGCocoa::SetApplicationIcon() to be taken into account or it will be ignored
Then to be able to compile, I had to add the following steps in my CMakelist.txt:
adding: CocoaWrapper.mm to the list of sources of my application
adding: “-framework Cocoa” to the library links
but now it works
Thanks for your help. Let me know if you see a simpler way to do it. Even if the easiest would have been in root to define the icon as a variable and not hardcoded, that could be changed by the user.