PureLVSORT library : sorting ListIconGadgets (and more)

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

Hi Gnozal,

tried your new lib but it did not solve the problem.

First run is normal like in screenshot 1.

And on the second run the list isn´t updated any more :

Image

Regards Klaus

PS : i edited my example a little bit (delete Button)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

ABBKlaus wrote:Hi Gnozal,

tried your new lib but it did not solve the problem.

First run is normal like in screenshot 1.

And on the second run the list isn´t updated any more :


Regards Klaus

PS : i edited my example a little bit (delete Button)
Sorry for this, this subclassing stuff is a bit tricky ...
Please try the beta again.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
klaver
Enthusiast
Enthusiast
Posts: 147
Joined: Wed Jun 28, 2006 6:55 pm
Location: Schröttersburg

Post by klaver »

gnozal wrote:my code doesn't work with bitmaps, your code also doesn't work if the bitmap is loaded with CatchImage().
Or am I missing something ?
I'm afraid your bitmaps are not 16x16...
If you want to use 12x12 bitmaps, you have to change the parameters in ImageList_Create.

Code: Select all

hImgList = ImageList_Create_(12, 12, #ILC_MASK | #ILC_COLOR32, 1, 1)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

klaver wrote:
gnozal wrote:my code doesn't work with bitmaps, your code also doesn't work if the bitmap is loaded with CatchImage().
Or am I missing something ?
I'm afraid your bitmaps are not 16x16...
Yes !!!
I forgot this, the images are included as data ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

thanks Gnozal,

the beta lib works fine now :D

Image

and the second run is even faster :wink:

Regards Klaus
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (both libs)

Changes :
- fixed performance problem posted by ABBKlaus [both libs]
- PureLVSORT_SetUserIcons() now also accepts icons (12x12 bmp or ico) [PB4.0x lib only] Thanks klaver.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

gnozal, is there a way to assign different userdefined-sorting-callbacks to different columns/listicons or am I stupid?

BTW, I must sort a column containing the amount of players on a game server:
12/32 (twelve of 32 players are online), 16/16 (16 of 16 are online), 0/12 (nobody), and so on.

Which sorting type do you recommend? PureLVSORT_DateMMDDYYYY :?:
I'm already using a userdefined-sorting-callback, but in another listicon. AFAIK, you allow only one callback for all columns/gadgets...
PB 4.30

Code: Select all

onErrorGoto(?Fred)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

AND51 wrote:is there a way to assign different userdefined-sorting-callbacks to different columns/listicons
No.
But in the user defined sorting callback you get the following information :
ListIconNumber.l, ListIconColumn.l, Item1.s, Item2.s where
ListIconNumber is the purebasic gadget ID
ListIconColumn is the sorted column
Item1 and Item2 are the items to sort.
So you could do something like that :

Code: Select all

Procedure MySortingCallback(ListIconNumber.l, ListIconColumn.l, Item1.s, Item2.s)
  Select ListIconNumber
    Case #My1stListIcon
      Select ListIconColumn
        Case #My1stListIcon_Column0
          ; user defined sorting for 1st Listicon Column 0
        Case #My1stListIcon_Column1
          ; user defined sorting for 1st Listicon Column 1
          
          ; etc ...
      EndSelect
    Case #My2ndListIcon
      Select ListIconColumn
        Case #My2ndListIcon_Column0
          ; user defined sorting for 2nd Listicon Column 0
        Case #My2ndListIcon_Column1
          ; user defined sorting for 2nd Listicon Column 1
          
          ; etc ...
      EndSelect
  EndSelect
EndProcedure
AND51 wrote:BTW, I must sort a column containing the amount of players on a game server:
12/32 (twelve of 32 players are online), 16/16 (16 of 16 are online), 0/12 (nobody), and so on.
Which sorting type do you recommend? PureLVSORT_DateMMDDYYYY :?:
I'm already using a userdefined-sorting-callback, but in another listicon. AFAIK, you allow only one callback for all columns/gadgets...
I would use a user defined callback, like the one described in the first part of this post. The default setting (string) would also work if you rset the number of players (05/10 instead of 5/10)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Thx for your reply.

The information
> But in the user defined sorting callback you get the following information : ListIconNumber.l, ListIconColumn.l, Item1.s, Item2.s
is very, very useful!

However, it's annoying if you've got a mix of listicons that have to be userdefined-sorted and some that have to be String/Numeric-sorted. Maybe you can add/edit this feature in the next lib version? (This is just a suggestion.)
PB 4.30

Code: Select all

onErrorGoto(?Fred)
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Bug found!

Create a normal window + listicongadget. Set the last column to "AutoResize when listicongadget is resized".

Now: Maximize and restore the window. A horizontal scrollbar appears (when XP skin off AND on)!!
Obviously, you make the last column some pixels too expanded.
Moreover, you forget to calculate a possible (vertical) scrollbar, I think.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Bug found!

You know, that you can double click between two headers to resize the specified column depending on its content.

Iif you use the double click method, the last column is not being auto-resized.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

AND51 wrote:Create a normal window + listicongadget. Set the last column to "AutoResize when listicongadget is resized".

Now: Maximize and restore the window. A horizontal scrollbar appears (when XP skin off AND on)!!
Obviously, you make the last column some pixels too expanded.
Moreover, you forget to calculate a possible (vertical) scrollbar, I think.
Ok, will see
AND51 wrote:You know, that you can double click between two headers to resize the specified column depending on its content.
Iif you use the double click method, the last column is not being auto-resized.
I did not know ... Will see what I can do
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (Both lib versions)

Changes :
- fixed (hopefully) some 'Last Column Autoresize' glitches
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Hello gnozal!

I have the slightly feeling that your library is not compatible with set/GetGadgetItemData().

When I scan a directory, I list all found files in a LinkedList and in a ListIconGadget.

Each entry is being assigned a unique number. Then I know, which entry belongs to which LinkedList-Element.

If I sort the ListIcon now with your lib, you just move the entries, but the Data remains at the entry.

Example:
Before sorting

Code: Select all

Entry            Data
picture.jpg      1
apple.gif        2
pure.pb          3
Now, I sort by string, for exmaple:
After sorting:

Code: Select all

Entry            Data
apple.gif        1
picture.jpg      2
pure.pb          3
Can you correct this? Do you know what I mean?
PB 4.30

Code: Select all

onErrorGoto(?Fred)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

AND51 wrote:I have the slightly feeling that your library is not compatible with Set/GetGadgetItemData().
You are right.
AND51 wrote:Can you correct this?
No.
PureLVSORT uses the Windows #LVM_SORTITEMS message to sort the listicongadget, and this implies using LV_ITEM\lParam (so it is not compatible with Set/GetGadgetItemData(), or the other way round : the Purebasic listicongadget is not 100% Windows API compatible : it's not a simple SysListView32).

Information added to help file.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply