ListIcon GetGadgetText etc

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

ListIcon GetGadgetText etc

Post by IdeasVacuum »

GetGadgetText() gets the content of column 0 of the selected row. This is redundant, GetGadgetItemText() can do it.

It would be much more useful if GetGadgetText() could get the whole ListIcon as a string, which then could for example be parsed or written to a file or used to rapidly populate another ListIcon with SetGadgetText().

Further, GetGadgetItemText(), which currently gets the content of a single cell, could have an option to collect a whole row.

Concerning the column (cell) separator. I think #LF$ is an awkward choice as it really has to be changed to suit writing to a file. Could we not have a function to set the column separator? Or just change it to a better one such as #TAB$?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: ListIcon GetGadgetText etc

Post by Oma »

+1 for the request for GetGadgetText()
For compatibility, it would be better to introduce an optional parameter for whole lines.
Likewise for the separator (#LF$ can be used as a line break inside a cell in linux (and that's good :wink: ) and could cause a lot of chaos as column separator (and that's not good).

Regards, Charly
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: ListIcon GetGadgetText etc

Post by davido »

Looks good. So.....

+1
DE AA EB
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: ListIcon GetGadgetText etc

Post by Mijikai »

+1 for GetGadgetText()
User avatar
DK_PETER
Addict
Addict
Posts: 898
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: ListIcon GetGadgetText etc

Post by DK_PETER »

Why?
GetgadgetText returns the selected item from column 0, which I find quite useful.
Any reason, why such a small and simple code as this is inadequate?

Code: Select all

Macro cr : Chr(10) : EndMacro
Declare LeftClick()
Declare.s GetListIconFull(GadID.i, Index.i, Delimit.s  = #TAB$)
Global x, y, ev, st.s
OpenWindow(0, 0, 0, 600, 600, "test", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ListIconGadget(0, 0, 0, 610, 600, "C0", 50, #PB_ListIcon_FullRowSelect)
For x = 1 To 10 : AddGadgetColumn(0, x, "C" + Str(x), 50) : Next x
For y = 0 To 100 : For x = 0 To 10 : st + Str(Random(300)) + cr : Next x : AddGadgetItem(0, -1, st) : st = "" : Next y ; fill it with shit..
BindGadgetEvent(0, @LeftClick(), #PB_EventType_LeftClick)

Repeat
  ev = WaitWindowEvent(5)
Until ev = #PB_Event_CloseWindow

Procedure LeftClick()
  Protected ID.i = EventGadget()
  If GetGadgetState(ID) > -1
    Debug GetListIconFull(ID, GetGadgetState(ID), "-")
  EndIf
EndProcedure

Procedure.s GetListIconFull(GadID.i, Index.i, Delimit.s  = #TAB$)
  Protected x, co.i = GetGadgetAttribute(GadID, #PB_ListIcon_ColumnCount) , st.s = ""
  For x = 0 To co
    If x < co : st + GetGadgetItemText(GadID, Index, x) + Delimit : Else : st + GetGadgetItemText(GadID, Index, x) : EndIf
  Next x
  ProcedureReturn Left(st, Len(st)-1)
EndProcedure
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: ListIcon GetGadgetText etc

Post by mk-soft »

@DK_PETER
very nice :wink:
Sorry, small update...

Code: Select all

Procedure.s GetListIconFull(GadID.i, Index.i, Delimit.s  = #TAB$)
  Protected x, co.i = GetGadgetAttribute(GadID, #PB_ListIcon_ColumnCount), st.s = ""
  co - 2
  For x = 0 To co
    st + GetGadgetItemText(GadID, Index, x) + Delimit
  Next x
  st + GetGadgetItemText(GadID, Index, x)
  ProcedureReturn st
EndProcedure
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
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: ListIcon GetGadgetText etc

Post by IdeasVacuum »

Hi DK_PETER
GetgadgetText returns the selected item from column 0, which I find quite useful.
...because GetGadgetItemText() can do the same, for any column.

...and concerning your code snippet (which we all have our own variant of) it's inefficient when heavy data displayed by several ListIcons needs to be handled in a real-world app.

We should be able to use the same delimiter for the data throughout, that's just common sense.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
DK_PETER
Addict
Addict
Posts: 898
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: ListIcon GetGadgetText etc

Post by DK_PETER »

@IdeasVacuum

Well, I have to disagree.
The team would still have to iterate each column.
The code could eaily be modified for several listIcongadgets..

Anyway...
Using GetGadgetText is a -1 from me.
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: ListIcon GetGadgetText etc

Post by mk-soft »

The ListIconGadget (MS ListView) does not support a command to read all SubItem at once.
So always read all the columns themselves
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
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: ListIcon GetGadgetText etc

Post by IdeasVacuum »

mk-soft ...we don't always have to be limited by what Microsoft has provided - and what about the other platforms?

I think it should be possible for the PB team to pluck bulk data from the memory. It's worth looking at.

DK_PETER ...we could have the functionality as dedicated ListIcon commands.
GetListIconText(), SetListIconText()

....GetGadgetText() is currently a misleading function name when applied to ListIcons, because it doesn't do what the name suggests. GetGadgetItemText() is guilty too, since for ListIcons the whole row is the Item. GetGadgetItemText() could be enhanced with a #PB_Whole_Row option or we could have new functions:
GetListIconRow(), GetListIconColumn(), GetListIconCell()

Let's not say "everybody is used to using square wheels". Let's be ambitious and develop round wheels :)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply