PureLVSORT library : sorting ListIconGadgets (and more)

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

Moderator: gnozal

User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by chi »

Thanks for pointing that out, gnozal!
I already use Demivec´s StableMergeSort routine for sorting the listview... http://www.purebasic.fr/english/viewtop ... 12&t=41068

cheers, chi
Et cetera is my worst enemy
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by c4s »

Is it possible to use the standard system sort icons for #PureLVSORT_ShowClickedHeader_Icon?
Example: http://www.thebitguru.com/site_media/up ... g_Icon.jpg

I just saw there is the PureLVSORT_SetUserIcons() function. Could you make it possible to assign the system icons here, maybe via a constant or just by default?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

c4s wrote:I just saw there is the PureLVSORT_SetUserIcons() function. Could you make it possible to assign the system icons here, maybe via a constant or just by default?
I don't know about system icons for ListView headers.
How do you get them ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by c4s »

gnozal wrote:I don't know about system icons for ListView headers.
How do you get them ?
I'm not fully sure either but I found this article about it:
http://www.thebitguru.com/articles/16-H ... %20in%20C#
It is about using the HDITEM structure with HDF_SORTDOWN and HDF_SORTUP flags:
http://msdn.microsoft.com/en-us/library/ms671802.aspx

Can you do something with this?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

c4s wrote:I'm not fully sure either but I found this article about it:
http://www.thebitguru.com/articles/16-H ... %20in%20C#It is about using the HDITEM structure with HDF_SORTDOWN and HDF_SORTUP flags:
http://msdn.microsoft.com/en-us/library/ms671802.aspx
Can you do something with this?
I use this in PureLVSORT.
I still have to provide an image : I can't use #HDF_SORTDOWN/#HDF_SORTUP to draw the 'system' icons because they are only available for Windows >= XP.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by c4s »

gnozal wrote:I use this in PureLVSORT.
I still have to provide an image : I can't use #HDF_SORTDOWN/#HDF_SORTUP to draw the 'system' icons because they are only available for Windows >= XP.
Seriously who is still using something under XP? Or which developer focuses on windows 98?
Anyway that's why meant that you could add this as on optional flag. Or you could check if XP or higher is available and otherwise still draw these internal ones...I hope I was able to convince you. ;)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

c4s wrote:Anyway that's why meant that you could add this as on optional flag. Or you could check if XP or higher is available and otherwise still draw these internal ones...I hope I was able to convince you. ;)
I may release a new version with an extra flag, when I have some more time.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by c4s »

Thank you gnozal.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

c4s wrote:Thank you gnozal.
I just had a look, it should be easy (not too much code to change).
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:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

Update Version 4.48 (PB4.5x version only)

Changes :
- new function : PureLVSORT_UseNativeWindowsIcons() : enable or disable 'native' windows sorting icons.
  . this feature requires Windows XP minimum with themes enabled and 'XP skin support' checked in compiler options ;
  . the 'native' icon is always to the right ;
  . if PureLVSORT doesn't detect themes support, it will use its own default icons.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by c4s »

Thanks again gnozal, works perfectly!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
linkerstorm
User
User
Posts: 47
Joined: Sun Feb 18, 2007 11:57 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by linkerstorm »

Hi gnozal.

Have a problem to get the actual sorted column.

Scenario :
- a grid displays one column not sorted with datas like B, A and C;
- the user sort this column asc : A, B and C;
- the app reloads the grid : B, A and C but the sort arrow is displayed yet; the app can't retrieve the actual sort column (neither the sort direction).

I have used PureLVSORT_GetClickedColumn (always returns -1) and PureLVSORT_GetSortingDirection (always returns zero) with no success.

How do I get the current sorted column ans the current sort direction ?

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

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

linkerstorm wrote:Have a problem to get the actual sorted column.
Scenario :
- a grid displays one column not sorted with datas like B, A and C;
- the user sort this column asc : A, B and C;
- the app reloads the grid : B, A and C but the sort arrow is displayed yet; the app can't retrieve the actual sort column (neither the sort direction).
I have used PureLVSORT_GetClickedColumn (always returns -1) and PureLVSORT_GetSortingDirection (always returns zero) with no success.
How do I get the current sorted column ans the current sort direction ?
Without code to demonstrate the issue, it's hard to tell.
Did you use PureLVSORT_SortListIconNow() to sort the gadget after "the app reloads the grid" ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
linkerstorm
User
User
Posts: 47
Joined: Sun Feb 18, 2007 11:57 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by linkerstorm »

But I nned the current sorted column and the sort direction in order to use the PureLVSORT_SortListIconNow() function !
That's my goal.

Consider this piece of code :

Code: Select all

#WindowTimbres = 0
#ListIconTimbres = 0
#ButtonReload = 1

Procedure OpenWindow_WindowTimbres()
    If OpenWindow(#WindowTimbres, 120, 229, 1024, 529, "Timbres", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
        ButtonGadget(#ButtonReload, 905, 60, 115, 30, "Reload")
        ListIconGadget(#ListIconTimbres, 5, 60, 895, 465, "Pays", 200, #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines)
        PureCOLOR_SetWindowColor(#WindowTimbres, $FFFFF3)
        PureLVSORT_SelectGadgetToSort(#ListIconTimbres, #PureLVSORT_ShowClickedHeader_IconLeft)
    EndIf
EndProcedure

Procedure LoadGrid()
    ClearGadgetItems(#ListIconTimbres)
    AddGadgetItem(#ListIconTimbres, -1, "B")
    AddGadgetItem(#ListIconTimbres, -1, "A")
    AddGadgetItem(#ListIconTimbres, -1, "C")
    MessageRequester("LVSORTTest", "PureLVSORT_GetClickedColumn :" + Str(PureLVSORT_GetClickedColumn(#ListIconTimbres)))
    MessageRequester("LVSORTTest", "PureLVSORT_GetSortingDirection :" + Str(PureLVSORT_GetSortingDirection(#ListIconTimbres)))
EndProcedure

OpenWindow_WindowTimbres()
LoadGrid()

Repeat
    ev = WaitWindowEvent()
    If ev = #PB_Event_Gadget
        If EventGadget() = #ButtonReload
            LoadGrid()
        EndIf
    EndIf
Until ev = #PB_Event_CloseWindow
- Run it.
- Sort the column.
- Reload the grid by clicking the button.
- The two functions returns, respectively, -1 and zero : why ?

EDIT : I just found the answer : I must call the two functions BEFORE the ClearGadgetItems function...

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

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by gnozal »

linkerstorm wrote:EDIT : I just found the answer : I must call the two functions BEFORE the ClearGadgetItems function...
Yes, #LVM_DELETEALLITEMS clears the information.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply