be truncated in the middle and ellipsis will be displayed. But the underlying
DataBrowser API offers the feature to modify this truncation and let it happen
alternatively at the start, at the end or not at all. Unfortunately truncation at
the start seems to be broken since 2006 and seemingly has not been fixed
until now as this posting in the Apple Mailing Lists documents:
http://lists.apple.com/archives/Carbon- ... 00243.html
So don't blame me if you don't see any difference between "Truncate at the
start" and "Don't truncate": it's a still unfixed bug in MacOS X...

Code: Select all
ImportC ""
GetDataBrowserTableViewColumnProperty(ControlRef.L, ColumnIndex.L, *ColumnPropertyID)
SetDataBrowserPropertyFlags(ControlRef.L, ColumnPropertyID.L, PropertyFlags.L)
EndImport
#kDataBrowserPropertyFlagsOffset = 8
#kDataBrowserDoNotTruncateText = 3 << #kDataBrowserPropertyFlagsOffset
#kDataBrowserTruncateTextAtEnd = 2 << #kDataBrowserPropertyFlagsOffset
#kDataBrowserTruncateTextMiddle = 0 << #kDataBrowserPropertyFlagsOffset
#kDataBrowserTruncateTextAtStart = 1 << #kDataBrowserPropertyFlagsOffset
Define TruncationMode.W
OpenWindow(0, 200, 100, 390, 190, "Modify text truncation in ListIconGadget")
ListIconGadget(0, 5, 5, WindowWidth(0) - 10, 95, "Name", 110)
AddGadgetColumn(0, 1, "Address", 249)
AddGadgetItem(0, -1, "Harry Rannit" + #LF$ + "12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit" + #LF$ + "130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(0, -1, "Didi Foundit"+ #LF$ + "321 Logo Drive, Mouse House, Downtown")
OptionGadget(1, 110, 105, 170, 20, "Don't truncate text")
OptionGadget(2, 110, 125, 170, 20, "Truncate text at start")
OptionGadget(3, 110, 145, 170, 20, "Truncate text in middle")
OptionGadget(4, 110, 165, 170, 20, "Truncate text at end")
SetGadgetState(3, #True)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If GetDataBrowserTableViewColumnProperty(GadgetID(0), 1, @ColumnID) = 0
Select EventGadget()
Case 1
TruncationMode = #kDataBrowserDoNotTruncateText
Case 2
TruncationMode = #kDataBrowserTruncateTextAtStart
Case 3
TruncationMode = #kDataBrowserTruncateTextMiddle
Case 4
TruncationMode = #kDataBrowserTruncateTextAtEnd
EndSelect
SetDataBrowserPropertyFlags(GadgetID(0), ColumnID, TruncationMode)
EndIf
EndSelect
ForEver