ListIconGadget

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

ListIconGadget

Post by jamirokwai »

Hi there,

I'd like to ask for two new commands for ListIconGadget and such.
On Windows, you may use API-commands, but I don't use Windows anymore.
All functions should be cross platform :-)

GetGadgetColumnCount(GadgetID) ; Count the Columns of a ListIconGadget
CountGadgetSelectedItems(GadgetID) ; Count the selected Lines (!) of a ListIconGadget

We can do both using PB already, but it would be great to have these commands.
Example for GetGadgetColumnCount (yes, could do better, but I needed the names of the columns :-)

Code: Select all

j = 0
  Repeat
    temp$ = GetGadgetItemText(GadgetID,-1,j) 
    If temp$ <> ""
      j + 1
    EndIf
  Until temp$ = ""
The count of columns in this ListIconGadget would be set in variable 'j'.
Regards,
JamiroKwai
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 575
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Re: ListIconGadget

Post by bembulak »

Good idea! +1
cheers,

bembulak
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: ListIconGadget

Post by Tenaja »

Sounds good! +1

There are quite a few ListIcon functions that would be very helpful, but must be done manually.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: ListIconGadget

Post by Andre »

+1

Furthermore sorting the ListIcon contents by selecting a column should be possible.
And showing a specific (selected) item of the ListIcon.
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: ListIconGadget

Post by Tenaja »

Andre wrote:+1

Furthermore sorting the ListIcon contents by selecting a column should be possible.
And showing a specific (selected) item of the ListIcon.
I would be happy with a Gadget Event when the column heading was clicked. That would allow us to perform a sort, or any other number of actions.
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: ListIconGadget

Post by Michael Vogel »

+1

I would also like to have a PB command instead of using SendMessage_(Gadget,#LVM_GETSELECTEDCOUNT,0,0)
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: ListIconGadget

Post by PB »

> GetGadgetColumnCount(GadgetID) ; Count the Columns of a ListIconGadget

A command for this isn't needed because you created them, so
you already know how many there are. You kept the number in
a variable, right? ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
wombats
Enthusiast
Enthusiast
Posts: 716
Joined: Thu Dec 29, 2011 5:03 pm

Re: ListIconGadget

Post by wombats »

PB wrote:> GetGadgetColumnCount(GadgetID) ; Count the Columns of a ListIconGadget

A command for this isn't needed because you created them, so
you already know how many there are. You kept the number in
a variable, right? ;)
One could say the same for CountGadgetItems(). :P
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: ListIconGadget

Post by Michael Vogel »

wombats wrote:
PB wrote:> GetGadgetColumnCount(GadgetID) ; Count the Columns of a ListIconGadget

A command for this isn't needed because you created them, so
you already know how many there are. You kept the number in
a variable, right? ;)
One could say the same for CountGadgetItems(). :P
...and for GadgetState and ... and ...

...but why not implementing something like CountGadgetSelectedRows() ?
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: ListIconGadget

Post by STARGÅTE »

CountGadgetItems(#Gadget[, Flags)]

With flags:
  • #PB_ListIcon_Columns
  • #PB_ListIcon_Selected
  • #PB_ListIcon_Checked
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: ListIconGadget

Post by PB »

> One could say the same for CountGadgetItems()

Counting gadget items is dynamic. Creating a gadget is a one-off job.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: ListIconGadget

Post by BorisTheOld »

PB wrote:> GetGadgetColumnCount(GadgetID) ; Count the Columns of a ListIconGadget

A command for this isn't needed because you created them, so
you already know how many there are. You kept the number in
a variable, right? ;)
Using one's own variables to track the application's status is very basic stuff.

Structures, arrays, lists and maps, can be used to hold such information and are far more useful than any command PB might provide.

Sigh.....Do people write real programs any more? :? :wink:
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: ListIconGadget

Post by Michael Vogel »

Another brilliant idea to keep things twice in memory, in an array/list and the dialog structures :D

Certainly it's possible to create our own functions to get the needed results or to use system functions of Windows. Eventually, we shouldn't ask for new functions but think about which PB functions could be eliminated in the next PB releases, starting with functions, like GadgetID(), WinID, ImageID() etc. :wink:

Maybe “real programs“ are using [>,+_.] solely :twisted:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: ListIconGadget

Post by PB »

> think about which PB functions could be eliminated in the next PB releases,
> starting with functions, like GadgetID(), WinID, ImageID()

Hehehe. :) For the record, I don't even use GadgetID() and such, but my own
variable with the return value of its creation, which is, yep, the gadget ID. ;)

Using GadgetID() in your code over and over actually makes it run a tad slower
than just referencing a variable, because of the constant runtime evaluation.
The speed difference is very minimal, but still, it's there and it bothers me.

Code: Select all

OpenWindow(0,100,100,100,100,"")
bg=ButtonGadget(0,10,10,80,80,"")

start=ElapsedMilliseconds()
For a=1 To 20000000 : b+GadgetID(0) : Next
Debug ElapsedMilliseconds()-start ; 2632 ms

start=ElapsedMilliseconds()
For a=1 To 20000000 : b+bg : Next
Debug ElapsedMilliseconds()-start ; 2196 ms
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: ListIconGadget

Post by Michael Vogel »

PB wrote: Hehehe. :) For the record, I don't even use GadgetID() and such, but my own
variable with the return value of its creation, which is, yep, the gadget ID. ;)
That's what I do as well (as for windows and image ID's), but it's fine that those ID functions exist :wink:

Back to a feature for which was asked for -- I would think, that an internal (OS independent) PB function for retrieving the number of selected list items is not only more comfortable but also faster than any self made code (wether variables are used or not) -- wouldn't you think so?
Post Reply