This is for an X-Platform (Mac/Windows) desktop app.
Maybe there is a way around this in newer versions, but at least in 2019.r1.1 (which I have to stay on for backwards compatibility in this project) the only robust workaround I can see is handling ALL the cell drawing in the CellBackgroundPaint event and not use CellTextPaint at all…
Yes that can be done… I did it in my MergableCell Listbox subclass BUT you need to know the Mac ListboxRow highlight color if if you want to match it to other Xojo Listboxes and to make it general and be aware of ALL possible listbox features that can affect how things are drawn - which is not trivial.
When I wrote my subclass (over 10 years ago!) I did all that…
The reason for this is to draw something that is partially outside the text area (for this app a small icon in the upper lefthand corner of the cell when the data meets certain conditions).
I can’t just use CellAllignmentOffset because the alignment looks odd when there is no icon and screen real-estate is tight for some of the machines this needs to run on, so making the cells larger is not an option and I don’t want to make the font size smaller.
If you draw it CellBackground paint and return false, on a Mac the highlight obliterates what you draw as it draws the highlight after the event, and the Clipped graphic context you get in CelltextPaint does not allow you to draw to the edge of the cell.
That is true even if the listbox is not hierarchical, doesn’t have a row picture or a checkbox. (IIRC in that case the border is 3 pixels - well these days probably points)
OK you say so draw the highlight yourself and then your icon and return true…
But you have to know what that highlight color is … that is where the robustness part comes in IMO…
Xojo does not provide a framework method to get that color for a Mac AFAIK… So one has to rely on declares… which can morph with OS version so it would-be best if the Xojo framework provides it. That way I would only need to compile with the right Xojo version for the target machine if Apple changes the “correct” API…
MANY years ago I put in a feature request to provide that color by my ether having a listbox.HighlightColor method , or setting g.forecolor to the background color for the graphics context passed into CellBackgroundPaint, or just painting the highlight before the event (IIRC that is what happens on Windows)… But it never happened.
So is there a backwards compatible (to 2017r1.1) way to do this without declares that I have missed over all these years?
Thanks for listening to my rant!
-Karen