Page 1 of 1

Extension to ListIconGadget

Posted: Wed Jan 17, 2024 3:34 pm
by Axolotl
Wouldn't this be a nice extension?
1. Change the Separator
---Count Columns <- already implemented
3. Get the entire item separated by separator (#LS$)

Code: Select all

; NEW 
; #PB_ListIcon_Separator 	; to change the Separator to '|' or others 
; 
; SetGadgetAttribute(Gadget, Attribute, Value) 
SetGadgetAttribute(#GADGET_ListIcon, #PB_ListIcon_Separator, #LS)  ; set to default 

; possible usage of one new procedure feature based on the Help example 
; 
; --- 

Procedure.s NEW_GetGadgetItemText(Gadget, Position, Column) 
  Protected result.s, col 

  If Column = -1 
    For col = 0 To GetGadgetAttribute(Gadget, #PB_ListIcon_ColumnCount) - 1 
      result + GetGadgetItemText(Gadget, Position, col) + #LF$ 
    Next col 

    result = RTrim(result, #LF$) 
  Else 
    result = GetGadgetItemText(Gadget, Position, Column) 
  EndIf 
  ProcedureReturn result 
EndProcedure  



 If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
   AddGadgetColumn(0, 1, "Address", 250)
   AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
   AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")

    ; new 
  Debug "column= = -1 -> " + NEW_GetGadgetItemText(0, 1, -1) 
  Debug "column= =  0 -> " + GetGadgetItemText(0, 1, 0) 
  Debug "column= =  1 -> " + GetGadgetItemText(0, 1, 1) 

   Repeat
     Event = WaitWindowEvent()
   Until Event = #PB_Event_CloseWindow
 EndIf

Re: Extension to ListIconGadget

Posted: Wed Jan 17, 2024 3:55 pm
by Fred
There is already #PB_ListIcon_ColumnCount or I miss something ?

Re: Extension to ListIconGadget

Posted: Wed Jan 17, 2024 4:11 pm
by Axolotl
Sorry, you are right.
A little overmotivated.
Changed my first post.

Re: Extension to ListIconGadget

Posted: Wed Jan 17, 2024 4:59 pm
by Fred
:lol: