Drawing NSImage in CellTextPaint of Listbox

I was wondering if someone can point me in the right direction here. I’m trying to use this code in my Listbox’s CellTextPaint event to draw an image in every row of column 0 in my listbox, but I get nothing.

[code]Function CellTextPaint(g As Graphics, row As Integer, column As Integer, x as Integer, y as Integer) As Boolean
If Column = 0 then

Dim image As Ptr = MyNSImage.StatusAvailableImageRef

If image <> Nil Then
  Const NSCompositeSourceOver = 2
  Dim opacity As Double = 1.0
  Dim point As NSPoint
  Dim zeroRect As NSRect
  point.x = x
  point.y = y
  Declare Sub drawAtPoint Lib CocoaLib selector "drawAtPoint:fromRect:operation:fraction:" (obj_id As Ptr, point As NSPoint, fromRect As NSRect, op As Integer, delta As Single)
  drawAtPoint(image, point, zeroRect, NSCompositeSourceOver, CType(opacity, Single))
End If

end if
End Function


I’m not totally sure, but I think you would need to subclass the Listbox-NSView in the Objective C Runtime and override drawRect:.
In drawRect: you can then use a message like NSImage’s drawAtPoint:fromRect:operation:fraction:.

you would need to set current graphics port to be the right one for the graphics object you get.
let me see if I can get it with MBS plugins…

Seems like the graphics object you get has no CGContextRef behind.
Probably because it’s a clipped graphics object? or one for only drawing to some tile cache?

for an image in column 0 you can use

me.RowPicture(row) = mypicture // your picture

[quote=157877:@Axel Schneider]for an image in column 0 you can use

me.RowPicture(row) = mypicture // your picture

I’m looking to show the retina version of a system image. RowPicture is not retina ready.