ListIconGadget Row Height
ListIconGadget Row Height
Is there a way to change this? I don't see anything in the PB docs. I'm using a 12x12 png icon, which is fine, with a 12-point font, but the margins/insets are too big.
Does this gadget map to an NSTableView? Using "setRowSizeStyle:" or "setIntercellSpacing:" doesn't seem to affect it. Once again, the Apple documentation is awful. I can't tell if I need to set it to "custom" somewhere, nor can I find the enum for small, medium, large, etc..
Also, is there a way to center the header cell text? I've tracked it all the way up to NSCell. I got nothing.
Does this gadget map to an NSTableView? Using "setRowSizeStyle:" or "setIntercellSpacing:" doesn't seem to affect it. Once again, the Apple documentation is awful. I can't tell if I need to set it to "custom" somewhere, nor can I find the enum for small, medium, large, etc..
Also, is there a way to center the header cell text? I've tracked it all the way up to NSCell. I got nothing.
Re: ListIconGadget Row Height
I'm not at my Mac right now....
Should work like this
Internally, PB draws the cells using Owner Draw. Unfortunately, this means that some older examples for NSTableView no longer work.
Should work like this
Code: Select all
rowHeigth.d = 32.0
CocoaMessage(0,GadgetID(gadget?), "setRowHeight:@", @rowHeigth)
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
Re: ListIconGadget Row Height
syntonica wrote: Also, is there a way to center the header cell text?
Code: Select all
EnableExplicit
Procedure CenterHeaderText(ListIconID.I, ColumnID.I)
Protected ColumnIDString.S = Str(ColumnID)
Protected ColumnObject.I
Protected HeaderCell.I
; ----- Get HeaderCell
CocoaMessage(@ColumnObject, GadgetID(ListIconID),
"tableColumnWithIdentifier:$", @ColumnIDString)
HeaderCell = CocoaMessage(0, ColumnObject, "headerCell")
; ----- Center text in HeaderCell horizontally
CocoaMessage(0, HeaderCell, "setAlignment:", #NSCenterTextAlignment)
EndProcedure
OpenWindow(0, 200, 100, 450, 122, "ListIcon Example")
ListIconGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20,
"Name", 110, #PB_ListIcon_GridLines)
AddGadgetColumn(0, 1, "Address", 0)
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 Findit" + #LF$ +
"321 Logo Drive, Mouse House, Downtown")
; ----- Autoadjust width of last column
CocoaMessage(0, GadgetID(0), "sizeLastColumnToFit")
; ----- Center text in header of 2nd column
CenterHeaderText(0, 1)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindowCollection of cross-platform examples with API functions to extend PureBasic
Re: ListIconGadget Row Height
That worked a treat. Thanks! I would have never gotten the pass-by-reference since a float should be a primative.mk-soft wrote: Fri Feb 13, 2026 11:44 am I'm not at my Mac right now....
Should work like thisInternally, PB draws the cells using Owner Draw. Unfortunately, this means that some older examples for NSTableView no longer work.Code: Select all
rowHeigth.d = 32.0 CocoaMessage(0,GadgetID(gadget?), "setRowHeight:@", @rowHeigth)
Re: ListIconGadget Row Height
Thanks, Shardik. That worked as well. This is getting embarrassing. I'm not used to having to ask so many questions. Normally, if I can't figure it out, there's something on StackOverflow that can point me in the right direction.
Also, Is there areference for CocoaMessage beyond what's in the manual?
Also, Is there areference for CocoaMessage beyond what's in the manual?
Re: ListIconGadget Row Height
For CocoaMessage -> Objective C, unfortunately you have to search Apple.
Example: https://developer.apple.com/documentati ... guage=objc
The method names are sometimes not entirely correct. Save this as a template.
Link: Dump Object Methods
Example: https://developer.apple.com/documentati ... guage=objc
The method names are sometimes not entirely correct. Save this as a template.
Link: Dump Object Methods
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
Re: ListIconGadget Row Height
Since the type of the parameters can vary, a pointer is passed in CocoaMessage. (Integer values can also be passed directly.)syntonica wrote: Fri Feb 13, 2026 1:38 pmThat worked a treat. Thanks! I would have never gotten the pass-by-reference since a float should be a primative.mk-soft wrote: Fri Feb 13, 2026 11:44 am I'm not at my Mac right now....
Should work like thisInternally, PB draws the cells using Owner Draw. Unfortunately, this means that some older examples for NSTableView no longer work.Code: Select all
rowHeigth.d = 32.0 CocoaMessage(0,GadgetID(gadget?), "setRowHeight:@", @rowHeigth)
"methode:@", Pointer to Parameter, "methode:$", Pointer to String (inter convert to UTF8)
If the return value is not an integer or object, pass a pointer for the result.
Code: Select all
Global rowHeigth.d ; rowHeigth.CGFLoat
CocoaMessage(@rowHeigth, GadgetID(gadget?), "rowHeight")
Debug rowHeigth
rowHeigth.d = 32.0
CocoaMessage(0,GadgetID(gadget?), "setRowHeight:@", @rowHeigth)
Last edited by mk-soft on Fri Feb 13, 2026 3:10 pm, edited 1 time in total.
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
Re: ListIconGadget Row Height
RowHeight should be declared asmk-soft wrote: rowHeigth.d = 32.0
CocoaMessage(0,GadgetID(gadget?), "setRowHeight:@", @rowHeigth)
Code: Select all
RowHeight.CGFloat
For a complete working example that gets and sets row height using a slider you may take a look into this more than 13 year old example (though you have to change Frame3DGadget() to FrameGadget() before trying).
By the way, when looking for MacOS API functions you should at first take a look into this thread where Wilbert collected a lot of links with API extensions for MacOS. Wilbert's list also contains the posted link above.
Collection of cross-platform examples with API functions to extend PureBasic
Re: ListIconGadget Row Height
Wow, ton of usefil info. Thanks everyone.
I'm beginning to remember this from when I wrote some C code to call out to Cocoa, which I don't recommend to anyone. It seems to me that the float special treatment goes back to changes made when Apple transitioned from PPC->Intel in regards to method return values.
I'm beginning to remember this from when I wrote some C code to call out to Cocoa, which I don't recommend to anyone. It seems to me that the float special treatment goes back to changes made when Apple transitioned from PPC->Intel in regards to method return values.


