Cannot set Header text Of first column In listicongadget

Mac OSX specific forum
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Cannot set Header text Of first column In listicongadget

Post by collectordave »

When Checkboxes are used in the list icon the header text of column zero does not change but the header text of column 1 does. Seems there is a column -1! That does not change either.

Code: Select all

 If OpenWindow(0, 0, 0, 700, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

    ListIconGadget(1,  10, 120, 330, 70, "Column 1", 100, #PB_ListIcon_CheckBoxes)  ; ListIcon with checkbox
    SetGadgetItemText(1, -1,"Item 1",0)

    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Cannot set Header text Of first column In listicongadget

Post by mk-soft »

In macOS the first column is that of the CheckBoxes, so the column '0' starts in the second column.

No Bug...
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
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Cannot set Header text Of first column In listicongadget

Post by collectordave »

Thanks Saw that so how to set the header of the checkbox column?

The example works ok on windows.

While trying this cam across something else weird.

Code: Select all

OpenWindow(0, 0, 0, 700, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

     ListIconGadget(1,  10, 120, 330, 70, "Column 1", 100) 
     AddGadgetColumn(1, 1, "Address", 280)  
     ButtonGadget(2, 10, WindowHeight(0) - 30, 150, 25, "Set Header")
     
 ;   SetGadgetItemText(1, -1,"Header 1",0) ; Sets Ok Here
    
  Repeat
  Select WaitWindowEvent()
      
    Case #PB_Event_CloseWindow
      End
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 2  
          SetGadgetItemText(1, -1,"Header 1",0) ;But Not Here

      EndSelect
  EndSelect
  
      ForEver
Similar thing no checkboxes.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Cannot set Header text Of first column In listicongadget

Post by mk-soft »

Link: viewtopic.php?p=491692#p491692

Code: Select all

Procedure ListIconGadgetColumnTitle(gadget.i,index.i,title.s)
  Protected column = CocoaMessage(0,CocoaMessage(0,GadgetID(gadget),"tableColumns"),"objectAtIndex:",index)
  If column
    CocoaMessage(0,column,"setTitle:$",@title)
  EndIf
EndProcedure

If OpenWindow(0, 0, 0, 700, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  ListIconGadget(1,  10, 120, 330, 70, "Column 1", 100, #PB_ListIcon_CheckBoxes)  ; ListIcon with checkbox
  SetGadgetItemText(1, -1,"Item 1",0)
  ListIconGadgetColumnTitle(1, 0, "Ch")
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
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
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Cannot set Header text Of first column In listicongadget

Post by mk-soft »

Update Header over Button is a Bug
Is not redraw header :!:

Edit

Bugfix for ListIconGadget

Code: Select all

CocoaMessage(0, GadgetID(1), "reloadData")

Code: Select all

OpenWindow(0, 0, 0, 700, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListIconGadget(1,  10, 120, 330, 70, "Column 1", 100) 
AddGadgetColumn(1, 1, "Address", 280)  
ButtonGadget(2, 10, WindowHeight(0) - 30, 150, 25, "Set Header")

Repeat
  Select WaitWindowEvent()
      
    Case #PB_Event_CloseWindow
      End
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 2  
          SetGadgetItemText(1, -1,"Header 1",0) ;But Not Here
          CocoaMessage(0, GadgetID(1), "reloadData")
      EndSelect
  EndSelect
  
ForEver
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
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Cannot set Header text Of first column In listicongadget

Post by collectordave »

Thanks mk-soft works well.

Still cannot set the header text on the checkbox column as per the help file though.

Regards

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Cannot set Header text Of first column In listicongadget

Post by mk-soft »

In macOS the CheckBox is a separate column and therefore Column 0 is the pure text column.

In Windows it is a single column and therefore column 0 is the check box and the text.
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
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Cannot set Header text Of first column In listicongadget

Post by collectordave »

So just an omission from the documentation then. Not the same on windows and mac.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
Shardik
Addict
Addict
Posts: 1991
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Cannot set Header text Of first column In listicongadget

Post by Shardik »

collectordave wrote:Thanks Saw that so how to set the header of the checkbox column?
The following example demonstrates how to use Cocoa API methods to set the header text of a CheckBox column and increase the width of the column (tested successfully with PB 5.46 x64 in ASCII mode and with PB 5.71 x64):

Image

Code: Select all

EnableExplicit

Procedure SetCheckBoxColumnHeaderText(ListIconID.I, Title.S,
  ColumnWidth.CGFloat)
  Protected *Column

  *Column = CocoaMessage(0, CocoaMessage(0, GadgetID(ListIconID),
    "tableColumns"), "objectAtIndex:", 0)

  ; ----- Check whether column 0 contains checkboxes
  If PeekS(CocoaMessage(0, CocoaMessage(0, *Column, "identifier"),
    "UTF8String"), -1, #PB_UTF8) = "CheckBox"
    ; ----- Increase width of column
    CocoaMessage(0, *Column, "setWidth:@", @ColumnWidth)

    ; ----- Set header text of column 0 
    CocoaMessage(0, CocoaMessage(0, *Column, "headerCell"),
      "setTitle:$", @Title)
  EndIf
EndProcedure

OpenWindow(0, 200, 100, 490, 104, "ListIcon Example")
ListIconGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20,
  "Name", 110, #PB_ListIcon_GridLines | #PB_ListIcon_CheckBoxes)
AddGadgetColumn(0, 1, "Address", GadgetWidth(0) - GetGadgetItemAttribute(0, 0,
  #PB_ListIcon_ColumnWidth) - 51)
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")

SetCheckBoxColumnHeaderText(0, "Select", 40)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Cannot set Header text Of first column In listicongadget

Post by mk-soft »

Nice :D
I wanted to do the same, but didn't use CGFloat for setWith.
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
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Cannot set Header text Of first column In listicongadget

Post by collectordave »

Very nice,

Now my application looks almost the same in windows and MAC.

Should I ask for the documentation to be corrected?

Thankyou

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply