It looks indeed like a bug.
together with their node text. For your convenience I have taken that example and modified it to match your example and the vertical alignment of the node text now seems to look as you would like it (tested with MacOS 10.6.8 'Snow Leopard' and PB 5.44 x86):
Code: Select all
EnableExplicit
#NSSwitchButton = 3
Define i.I
Define Indentation.CGFloat = 25
Dim ButtonCell.I(0)
ProcedureC CellDisplayCallback(Object.I, Selector.I, OutlineView.I,
TableColumn.I, Item.I)
Shared ButtonCell.I()
Protected Row.I = CocoaMessage(0, GadgetID(0), "rowForItem:", Item)
If ButtonCell(Row) <> 0
ProcedureReturn ButtonCell(Row)
EndIf
EndProcedure
Procedure SetGadgetCallback(GadgetID.I, GadgetCallback.I, Method.S)
Protected AppDelegate.I
Protected DelegateClass.I
Protected PlaceholderList.S
PlaceholderList = LSet("@:", CountString(Method, ":"), "@")
AppDelegate = CocoaMessage(0, CocoaMessage(0, 0,
"NSApplication sharedApplication"), "delegate")
DelegateClass = CocoaMessage(0, AppDelegate, "class")
class_addMethod_(DelegateClass, sel_registerName_(Method), GadgetCallback,
PlaceholderList)
CocoaMessage(0, GadgetID(GadgetID), "setDelegate:", AppDelegate)
EndProcedure
Procedure AddImageToTreeRow(ImageID.I, Row.I)
Shared ButtonCell.I()
Protected ItemText.S
Protected TableColumn.I
TableColumn = CocoaMessage(0, CocoaMessage(0, GadgetID(0), "tableColumns"),
"objectAtIndex:", 0)
ButtonCell(Row) = CocoaMessage(0, 0, "NSButtonCell new")
CocoaMessage(0, ButtonCell(Row), "setButtonType:", #NSSwitchButton)
CocoaMessage(0, ButtonCell(Row), "setImage:", ImageID(ImageID))
ItemText = GetGadgetItemText(0, Row)
CocoaMessage(0, ButtonCell(Row), "setTitle:$", @ItemText)
EndProcedure
CreateImage(0, 16, 16)
If StartDrawing(ImageOutput(0))
Box(0, 0, OutputWidth(), OutputHeight(), $CC3299)
StopDrawing()
EndIf
CreateImage(1, 16, 16)
If StartDrawing(ImageOutput(1))
Box(0, 0, OutputWidth(), OutputHeight(), $7A96E9)
StopDrawing()
EndIf
LoadFont(0, "Verdana", 12)
OpenWindow(0, 270, 100, 140, 100, "Tree")
TreeGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20)
SetGadgetFont(0, FontID(0))
AddGadgetItem(0, -1, "Item", ImageID(0))
AddGadgetItem(0, -1, "Subitem", ImageID(1), 1)
SetGadgetItemState(0, 0, #PB_Tree_Expanded)
; ----- Setup callback for TreeGadget
SetGadgetCallback(0, @CellDisplayCallback(),
"outlineView:dataCellForTableColumn:item:")
; ----- Add images to specified rows
ReDim ButtonCell(CountGadgetItems(0) - 1)
AddImageToTreeRow(0, 0)
AddImageToTreeRow(1, 1)
; ----- Don't indent indentation marker along with cell contents
CocoaMessage(0, GadgetID(0), "setIndentationMarkerFollowsCell:", #NO)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
; ----- Release NSButtonCell objects
For i = 0 To CountGadgetItems(0) - 1
If ButtonCell(i) <> 0
CocoaMessage(0, ButtonCell(i), "release")
EndIf
Next i