PB v6.00-b7: ListViewGadget and ListIconGadget (Discussion)

Post bugreports for the Mac OSX version here
User avatar
mk-soft
Addict
Addict
Posts: 3709
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

PB v6.00-b7: ListViewGadget and ListIconGadget (Discussion)

Post by mk-soft »

Hello Fred,

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()
Last edited by mk-soft on Sat May 14, 2022 2:07 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
mk-soft
Addict
Addict
Posts: 3709
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PB v6.00-b7: ListViewGadget and ListIconGadget (Summary)

Post by mk-soft »

This work with TreeGadget (WITHOUT IMAGES)
I thing its pb intern PBIconTextCell of beta 6

PB v6.00-b6

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, OutLineView.I, Cell.I ,Column.I, Item.I)
  ;Debug DumpObjectMethods(Cell)
  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)
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)
    
    TreeGadget(0, 10, 10, dx - 20, dy - 20, #PB_Tree_CheckBoxes)
    
    ; Set big row height for test
    RowHeight = 44
    CocoaMessage(0, GadgetID(0), "setRowHeight:@", @RowHeight)
    
    ; Fix cells ***
    class_addMethod_(DelegateClass, sel_registerName_("outlineView:willDisplayCell:forTableColumn:item:"), @WillDisplayCell(), "v@:@@@@")
    CocoaMessage(0, GadgetID(0), "setDelegate:", AppDelegate)
    ; *************
    
    CocoaMessage(0, GadgetID(0), "setUsesAlternatingRowBackgroundColors:", #YES)
    
    For i = 0 To 25
      If i % 3 = 0 
        AddGadgetItem(0, -1, "Item " + i, 0, 0)
      Else
        AddGadgetItem(0, -1, "Sub Item " + i, 0, 1)
      EndIf
    Next
    
    BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), 0)
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
          
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
mk-soft
Addict
Addict
Posts: 3709
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PB v6.00-b7: ListViewGadget and ListIconGadget (Discussion)

Post by mk-soft »

The function PBIconTextCell has only one error.
It draws over the rect of a column and draws on the next column.

Then everything should be fine ... but we can't change any like background, editing, etc
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply