While working on the TTrayIcon component, I learnt how to convert NSImage to TBitmap, and vice versa.

In addition, I've also learnt how to

 

  1. retrieve the application icon from the application bundle
  2. retrieve the Mac OS status bar's height (The Mac OS status bar is the Windows equivalent of the Taskbar's TrayIcon area). 
  3. convert the VCL and FireMonkey TMenuItem to the Mac OS Cocoa equivalent.
  4. marshal simple events from Cocoa to the FireMonkey/VCL TNotifyEvent.

 

I've created a few class functions as a result, appropriately named as follows:

  1. ConvertTBitmapToNSImage
  2. ConvertNSImageToTBitmap
  3. ApplicationIcon

ConvertTBitmapToNSImage converts a Windows TBitmap to a Mac OS Cocoa NSImage. ConvertNSImageToTBitmap does the reverse.

Apparently, Mac OS's NSImage supported a few image types, including PNG, TIFF and BMP.

So, how does TTrayIcon behave?

When there's no icon assigned, it retrieves the application icon using ApplicationIcon, and then set it as the TrayIcon image. Currently, the TTrayIcon component supports the OnClick and onDblClick events. It also supports the Title property, which is new.

The FireMonkey TTrayIcon component is superior to the VCL TTrayIcon component as Mac OS supports both an icon and text beside the icon. However, on Windows, this requires the text to be drawn as an image.

More to come...