thank you for the new beta. But the new output from the NSTableView of the cells with 'PBIconTextCell' unfortunately causes a lot of problems. Also for us when we want to adjust the cells ourselves.
I searched for a solution with the PB version Beta 6 to correct the display of the increased row height and the position of the cells of the texts and icons.
Maybe this is the better way
Fix Text and Icon position of ListIconGadget.
Code: Select all
;-TOP
Global AppDelegate.I = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
Global DelegateClass.I = CocoaMessage(0, AppDelegate, "class")
ProcedureC WillDisplayCell(Object.I, Selector.I, TableView.I, Cell.I,*Column, Row.I)
CocoaMessage(0, Cell, "_setVerticallyCentered:", #YES)
EndProcedure
Image = CreateImage(0, 16, 16, 32, #Red)
Procedure UpdateWindow()
Protected dx, dy
dx = WindowWidth(0)
dy = WindowHeight(0)
ResizeGadget(0, 10, 10, dx - 20, dy - 20)
; Tips and Tricks for macOS
CocoaMessage(0, GadgetID(0), "sizeLastColumnToFit")
EndProcedure
Procedure Main()
Protected dx, dy, RowHeight.CGFloat
If OpenWindow(0, 210, 210, 520, 520, "Window", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
dx = WindowWidth(0)
dy = WindowHeight(0)
ListIconGadget(0, 10, 10, dx - 20, dy - 20, "Column 0", 200)
AddGadgetColumn(0, 1, "Comlum 1", 600)
; Set big row height for test
RowHeight = 44
CocoaMessage(0, GadgetID(0), "setRowHeight:@", @RowHeight)
; Fix cells ***
class_addMethod_(DelegateClass, sel_registerName_("tableView:willDisplayCell:forTableColumn:row:"), @WillDisplayCell(), "v@:@@@@")
CocoaMessage(0, GadgetID(0), "setDelegate:", AppDelegate)
; *************
CocoaMessage(0, GadgetID(0), "setUsesAlternatingRowBackgroundColors:", #YES)
For i = 0 To 25
AddGadgetItem(0, -1, "Row Data" + #LF$ + "ListBox Item / ListBox Item / ListBox Item / ListBox Item / ListBox Item / ListBox Item / ListBox Item " + i, ImageID(0))
Next
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
EndProcedure : Main()
Fix vertical scroll bar of ListViewGadget (Same output as windows)
Code: Select all
;-TOP
Global AppDelegate.I = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
Global DelegateClass.I = CocoaMessage(0, AppDelegate, "class")
ProcedureC WillDisplayCell(Object.I, Selector.I, TableView.I, Cell.I,*Column, Row.I)
CocoaMessage(0, Cell, "_setVerticallyCentered:", #YES)
EndProcedure
Procedure UpdateWindow()
Protected dx, dy
dx = WindowWidth(0)
dy = WindowHeight(0)
ResizeGadget(0, 10, 10, dx - 20, dy - 20)
EndProcedure
Procedure Main()
Protected dx, dy, RowHeight.CGFloat
If OpenWindow(0, 210, 210, 520, 520, "Window", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
dx = WindowWidth(0)
dy = WindowHeight(0)
ListViewGadget(0, 10, 10, dx - 20, dy - 20)
RowHeight = 44
CocoaMessage(0, GadgetID(0), "setRowHeight:@", @RowHeight)
; Fix vertical Scrollbar
CocoaMessage(0, GadgetID(0), "sizeLastColumnToFit")
; Fix cells
class_addMethod_(DelegateClass, sel_registerName_("tableView:willDisplayCell:forTableColumn:row:"), @WillDisplayCell(), "v@:@@@@")
CocoaMessage(0, GadgetID(0), "setDelegate:", AppDelegate)
CocoaMessage(0, GadgetID(0), "setUsesAlternatingRowBackgroundColors:", #YES)
;
For i = 0 To 25
AddGadgetItem(0, -1, "ListBox Item / ListBox Item / ListBox Item / ListBox Item / ListBox Item / ListBox Item / ListBox Item " + i)
Next
;Debug DumpObjectMethods(GadgetID(0), 1)
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
EndProcedure : Main()