PureLVSORT library : sorting ListIconGadgets (and more)

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

Moderator: gnozal

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

Post by gnozal »

byo wrote:Hmm... Will every lib made for 4.02 have to be changed for PB 4.10?
Not necessarily. Only some internal functions may change (for example, PureRESIZE seems to work).
I haven't tested all libs yet ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

@Gnozal: do you have also a PureLVSORT_SetColumnType() for DateTime
like this: "24.12.2007 12:00:00" ?

Or better, is it possible to change the DateTime mask?

And which image id to you use for #PureLVSORT_ShowClickedHeader_Icon?
coz, I see my own icon id = 55 and not the arrow
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

dige wrote:do you have also a PureLVSORT_SetColumnType() for DateTime
like this: "24.12.2007 12:00:00" ?
Looks like column type #PureLVSORT_DateDDMMYYYYHHMMSS ?
dige wrote:Or better, is it possible to change the DateTime mask?
No, but you can use your own sorting procedure with #PureLVSORT_UserCallback
dige wrote:And which image id to you use for #PureLVSORT_ShowClickedHeader_Icon?
coz, I see my own icon id = 55 and not the arrow
I use #PB_Any at library initialization

Code: Select all

PureLVSORT_IconArrowUp = ImageID(CatchImage(#PB_Any, ?IconArrowUp))
And the image (or icon) is added to an image list

Code: Select all

AddToImageList(PureLVSORT_IconArrowUp)
created with ImageList_Create_().
The image list is assigned to the listicon with #HDM_SETIMAGELIST when you use PureLVSORT_SelectGadgetToSort().
The header image is then defined with #HDM_SETITEM using the iImage member (image index).
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 (PB4.02 / PB4.10 libs only)

Changes :
- new function PureLVSORT_Disabled() : disable or enable PureLVSORT functions. This may be handy when you have to add / remove a lot of data to / from a listicongadget : it's faster if PureLVSORT is disabled.

There are two versions in the archive : PureLVSORT (standard) and PureLVSORT-Plus ; the plus version adds some basic listicon editing functions.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

Muchas gracias! Works great :D
Amnesty
User
User
Posts: 54
Joined: Wed Jul 04, 2007 4:34 pm
Location: Germany

Post by Amnesty »

Hi Gnozal,

it's not working with V 4.20, but I think, you 've already heard it somewhere.

BTW

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

Post by gnozal »

Amnesty wrote:it's not working with V 4.20, ...
Library recompiled with PB4.20 beta 1 : http://freenet-homepage.de/gnozal/PureLVSORT___.zip (not tested).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Amnesty
User
User
Posts: 54
Joined: Wed Jul 04, 2007 4:34 pm
Location: Germany

Post by Amnesty »

Works fine... ! Thanx
nicolaus
Enthusiast
Enthusiast
Posts: 456
Joined: Tue Aug 05, 2003 11:30 pm
Contact:

Post by nicolaus »

Your libs are very nice but i have one prob if i want install the libs.
Your installer is not so nice for users wat have installet more then one version of PB.
I have installet PB 4.02, PB 4.10 and PB 4.20 beta. If i want install e.g. PureSMTP to PB 4.02 i cant set the path to PB 4.02 in your Setup and so all the times the installer of PureSMTP want install the lib to PB 4.10.

Please can you at a option into the installer so that i can select or change the install path?

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

Post by gnozal »

nicolaus wrote:Your libs are very nice but i have one prob if i want install the libs.
Your installer is not so nice for users wat have installet more then one version of PB
You can open the installer like a zip file and then extract the files where you want.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Vladi
User
User
Posts: 33
Joined: Sun Sep 10, 2006 3:09 pm

Post by Vladi »

@gnozal: I had a look at your filter procedure, which seems quite suitable for me, however I found it nasty that you do not save (and restore) the gadget item data to memory. Is it possible to add this?

Looking at the callback it would prefer to have a callback that just lets me decide whether to add a row or not, based on the filter and the row contents. So that I am not forced to filter just based on the beginning of the column.
Vladi
User
User
Posts: 33
Joined: Sun Sep 10, 2006 3:09 pm

Post by Vladi »

And another issue: Any idea why sorting is not working here?

Code: Select all

#Window_0 = 0 
#ListIcon_0 = 0 
;
Procedure Open_Window_0() 
  If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT Test",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered) 
    If CreateGadgetList(WindowID(#Window_0)) 
      ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "String", 110) 
      AddGadgetItem(#ListIcon_0, -1, "ABCDE" ) 
      AddGadgetItem(#ListIcon_0, -1, "ACDEF" ) 
      AddGadgetItem(#ListIcon_0, -1, "ZABCD" ) 
      AddGadgetItem(#ListIcon_0, -1, "DEFGH" )
      AddGadgetItem(#ListIcon_0, -1, "AFFGH" ) 
      AddGadgetItem(#ListIcon_0, -1, "ZSFZI" ) 
      AddGadgetItem(#ListIcon_0, -1, "ZEKZH" ) 
      AddGadgetItem(#ListIcon_0, -1, "ZFFGH" ) 
      AddGadgetItem(#ListIcon_0, -1, "AZFHI" ) 
      AddGadgetItem(#ListIcon_0, -1, "AEZGH" ) 
      AddGadgetItem(#ListIcon_0, -1, "DZFKH" ) 
      AddGadgetItem(#ListIcon_0, -1, "DEFGI" ) 
      AddGadgetItem(#ListIcon_0, -1, "DSFKH" ) 
    EndIf 
  EndIf 
EndProcedure 
;
Open_Window_0() 
;
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok 
  PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String) ; default, not necessary 
EndIf 

; 
Repeat 
  Event = WaitWindowEvent() 
Until Event = #PB_Event_CloseWindow 
Width 2 or more columns it is working.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Vladi wrote:And another issue: Any idea why sorting is not working here?
Yes, you need 2 or more columns.
With 1 column, use the #LVS_SORTASCENDING or #LVS_SORTDESCENDING flag when you create the listicon.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

gnozal - thanks for this library. It's usefulness increased many-fold when I discovered the PureLVSORT_SaveListIconToMem() and PureLVSORT_LoadListIconFromMem() functions :)

Now I have filtering question. Would it be difficult to add some functionality to the filtering part? It would be awesome if the user had the ability to control how a column is filtered. For example, the developer may want to change the behavior for a date column so that rather than filtering for an exact date, they include the line if the date is greater than or equal to the specified date.

So, for example, the list contains item purchased and date purchased. A filter bar is enabled for the list. The user types in 1/1/2007 in the filter bar for the date purchased. Rather than only showing the items purchased on 1/1/2007, the list shows items purchased on or after 1/1/2007.

I was thinking maybe an additional function (that the user has to enable for specialized filtering) that is called during the filtering process. Give the developer access to the Gadget number, the column index and the filter string. If the procedure returns 0, discard the line. If the procedure returns anything else, include it. That way it's up to the developer to handle the filtering logic.

Also, what about the ability to do something like SetActiveFilterColumn() so that a specific filter bar column could be given keyboard focus?

Thanks for listening!

EDIT: Also (and I may have missed this in the postings) is there any thoughts on including a lvsort specific Get/SetItemData() function to replace the PB version when someone is using this library?

EDIT2: In regards to this above EDIT. What about looping through the items when SelectGadgetToSort() is called. Store any item data values in your own library for use. Then, when/if the user disables sorting, you could enumerate through your internal list and do a setgadgetitemdata for the items?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Xombie wrote:Now I have filtering question. Would it be difficult to add some functionality to the filtering part? It would be awesome if the user had the ability to control how a column is filtered.
Did you try the filtering callback set with PureLVSORT_DefineFilterCallback() ?

Code: Select all

PureLVSORT_DefineFilterCallback(*UserCallbackAddress) 

Define user filtering callback for #HDN_FILTERCHANGE or #HDN_FILTERBTNCLICK events.
The callback is a procedure called when a listicon header filter changes (#HDN_FILTERCHANGE) or a header button is pressed (#HDN_FILTERBTNCLICK).
The filter mode is activated with the PureLVSORT_SetFilter() function.

The callback procedure is like this :

Procedure MyFilterCallback(GadgetNumber.l, FilterString.s, ListIconColumn.l, EventID.l)
  ; ...
EndProcedure

declared like that :

PureLVSORT_DefineFilterCallback(@MyFilterCallback())

where :

GadgetNumber is the purebasic gadget ID
FilterString is the header filter text
ListIconColumn is the header column
EventID is the trigger event (#PureLVSORT_FilterBtnClick or #PureLVSORT_FilterChange)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply