The code seems not combatible with icons. Add this two lines before the Forever-Loop:
Code: Select all
EnableExplicit
#justifyLeft = 0
#justifyCenter = 1
#justifyRight = 2
Define app.i = CocoaMessage(0,0,"NSApplication sharedApplication")
Define appDelegate.i = CocoaMessage(0,app,"delegate")
Define delegateClass.i = CocoaMessage(0,appDelegate,"class")
ProcedureC CellDisplayCallback(Object.I,Selector.I,TableView.I,Cell.I,*Column,Row.I)
Protected LineFrame.NSRect
Protected RowFrame.NSRect
Protected TextSize.NSSize
Protected CellFrame.NSRect
Protected BoldFontSize.CGFloat = 15.0
Protected FontSize.CGFloat = 13.0
Protected Column.i = CocoaMessage(0,CocoaMessage(0,TableView,"tableColumns"),"indexOfObject:",*Column)
Protected Gadget.i = CocoaMessage(0,TableView,"tag")
Protected CellText.s = GetGadgetItemText(Gadget,Row,Column)
Select Column
Case 0
CocoaMessage(0,Cell,"setAlignment:",#justifyCenter)
Case 1
CocoaMessage(0,Cell,"setAlignment:",#justifyRight)
EndSelect
CocoaMessage(0,Cell,"setStringValue:$",@CellText)
EndProcedure
OpenWindow(0,0,0,400,300,"ListIconGadget - centered text",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ListIconGadget(0,10,10,380,280,"Column A",100)
AddGadgetColumn(0,1,"Column B",100)
AddGadgetItem(0,-1,"Test 1" + Chr(10) + "Test 2")
AddGadgetItem(0,-1,"Test 3" + Chr(10) + "Test 4")
class_addMethod_(delegateClass,sel_registerName_("tableView:willDisplayCell:forTableColumn:row:"),@CellDisplayCallback(),"v@:@@@@")
CocoaMessage(0,GadgetID(0),"setDelegate:",appDelegate)
LoadImage(0, #PB_Compiler_Home+"Examples/Sources/Data/File.bmp")
SetGadgetItemImage(0, 0, ImageID(0))
Repeat
Define Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 0
Debug "Gadget"
If EventType() = #PB_EventType_Change
Debug "Changed"
EndIf
EndSelect
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver