Page 1 of 1

ListIcon GetGadgetText etc

Posted: Sun Jul 16, 2017 12:28 am
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$?

Re: ListIcon GetGadgetText etc

Posted: Sun Jul 16, 2017 7:10 am
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

Re: ListIcon GetGadgetText etc

Posted: Sun Jul 16, 2017 10:56 am
by davido
Looks good. So.....

+1

Re: ListIcon GetGadgetText etc

Posted: Sun Jul 16, 2017 11:02 am
by Mijikai
+1 for GetGadgetText()

Re: ListIcon GetGadgetText etc

Posted: Sun Jul 16, 2017 11:10 am
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

Re: ListIcon GetGadgetText etc

Posted: Sun Jul 16, 2017 11:57 am
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

Re: ListIcon GetGadgetText etc

Posted: Sun Jul 16, 2017 12:13 pm
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.

Re: ListIcon GetGadgetText etc

Posted: Sun Jul 16, 2017 12:33 pm
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.

Re: ListIcon GetGadgetText etc

Posted: Sun Jul 16, 2017 12:43 pm
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

Re: ListIcon GetGadgetText etc

Posted: Sun Jul 16, 2017 1:21 pm
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 :)