Extension to ListIconGadget

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Axolotl
Addict
Addict
Posts: 804
Joined: Wed Dec 31, 2008 3:36 pm

Extension to ListIconGadget

Post 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
Last edited by Axolotl on Wed Jan 17, 2024 4:09 pm, edited 1 time in total.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Extension to ListIconGadget

Post by Fred »

There is already #PB_ListIcon_ColumnCount or I miss something ?
Axolotl
Addict
Addict
Posts: 804
Joined: Wed Dec 31, 2008 3:36 pm

Re: Extension to ListIconGadget

Post by Axolotl »

Sorry, you are right.
A little overmotivated.
Changed my first post.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Extension to ListIconGadget

Post by Fred »

:lol:
Post Reply