I have patched my CellDisplayCallback() to work with PB 6.00 x64 Beta 7 in Light Mode (for Dark Mode you should still adapt the colors). It's also working in pre Beta 7 and PB 5.73. The trick is to not only set the front and back color but also to display the text in each call of the CellDisplayCallback (which wasn't necessary in pre Beta 7):
Code: Select all
EnableExplicit
Define AppDelegate.I = CocoaMessage(0, CocoaMessage(0, 0,
  "NSApplication sharedApplication"), "delegate")
Define DelegateClass.I = CocoaMessage(0, AppDelegate, "class")
Define i.I
Define Selector.I = sel_registerName_("tableView:willDisplayCell:" +
  "forTableColumn:row:")
Dim ListViewCellColor.Q(0)
ProcedureC CellDisplayCallback(Object.I, Selector.I, TableView.I, Cell.I,
  *Column, Row.I)
  Shared ListViewCellColor.Q()
  Protected Alpha.CGFloat
  Protected BackColor.L
  Protected Blue.CGFloat
  Protected CellColor.Q
  Protected CellText.S
  Protected FrontColor.L
  Protected Green.CGFloat
  Protected Red.CGFloat
  CellColor = ListViewCellColor(Row)
  If CellColor = 0
    CocoaMessage(0, Cell, "setDrawsBackground:", #NO)
    CocoaMessage(0, Cell, 
      "setTextColor:", CocoaMessage(0, 0, "NSColor textColor"))
  Else
    BackColor = CellColor & $FFFFFF
    If BackColor = 0
      CocoaMessage(0, Cell, "setDrawsBackground:", #NO)
    Else
      CocoaMessage(0, Cell, "setDrawsBackground:", #YES)
      Alpha = 1
      Red = Red(BackColor) / 255
      Green = Green(BackColor) / 255
      Blue = Blue(BackColor) / 255
      CocoaMessage(0, Cell, "setBackgroundColor:", CocoaMessage(0, 0,
        "NSColor colorWithDeviceRed:@", @Red,
        "green:@", @Green,
        "blue:@", @Blue,
        "alpha:@", @Alpha))
    EndIf
    FrontColor = (CellColor >> 32) & $FFFFFF
    If FrontColor = 0
      CocoaMessage(0, Cell, 
        "setTextColor:", CocoaMessage(0, 0, "NSColor textColor"))
    Else
      Alpha = 1
      Red = Red(FrontColor) / 255
      Green = Green(FrontColor) / 255
      Blue = Blue(FrontColor) / 255
      CocoaMessage(0, Cell, "setTextColor:", CocoaMessage(0, 0,
        "NSColor colorWithDeviceRed:@", @Red,
        "green:@", @Green,
        "blue:@", @Blue,
        "alpha:@", @Alpha))
    EndIf
  EndIf
  CellText = GetGadgetItemText(CocoaMessage(0, TableView, "tag"), Row, 0)
  CocoaMessage(0, Cell, "setStringValue:$", @CellText)
EndProcedure
Procedure SetGadgetItemColorEx(GadgetID.I, Row.I, ColorType.I, Color.I)
  Shared ListViewCellColor.Q()
  Protected CellColor.Q
  Protected RowCount.I
  If ArraySize(ListViewCellColor()) = 0
    RowCount = CocoaMessage(0, GadgetID(GadgetID), "numberOfRows")
    Dim ListViewCellColor(RowCount - 1)
  EndIf
  CellColor = ListViewCellColor(Row)
  Select ColorType
    Case #PB_Gadget_BackColor
      CellColor ! (Color & $FFFFFF)
    Case #PB_Gadget_FrontColor
      CellColor ! ((Color & $FFFFFF) << 32)
  EndSelect
  ListViewCellColor(Row) = CellColor
EndProcedure
Macro SetGadgetItemColor(GadgetID, Row, ColorType, Color)
  SetGadgetItemColorEx(GadgetID, Row, ColorType, Color)
EndMacro
OpenWindow(0, 200, 100, 430, 150,
  "Change color of text and background in single rows")
ListViewGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20)
For i = 1 To 10
  AddGadgetItem(0, -1, "Line " + Str(i))
Next i
class_addMethod_(DelegateClass, Selector, @CellDisplayCallback(), "v@:@@@@")
CocoaMessage(0, GadgetID(0), "setDelegate:", AppDelegate)
; ----- Set background color of line 1 to yellow
SetGadgetItemColor(0, 0, #PB_Gadget_BackColor, $FFFF)
; ----- Set background color of line 5 to X11 color "Aquamarine"
SetGadgetItemColor(0, 4, #PB_Gadget_BackColor, $D4FF7F)
; ----- Set text color of line 3 to blue
SetGadgetItemColor(0, 2, #PB_Gadget_FrontColor, $FF0000)
; ----- Set text color of line 5 to red
SetGadgetItemColor(0, 4, #PB_Gadget_FrontColor, $FF)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow