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 »

Flype wrote:hello gnozal,
i like the #PureLVSORT_DateDDMMYYYY flag.
i use it very very often but i need a little bit more powerful flag.
in fact, i need to display in a column a datetime like this :
DD/MM/YYYY HH:MM:SS or DD.MM.YY HH:MM
So is it possible to add DATETIME and TIME sorting ?
regards.
Ok, for next version.
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

New column types :
- #PureLVSORT_DateDDMMYYYYHHMMSS ; example : "31/12/2003 12:31:21"
- #PureLVSORT_DateDDMMYYHHMM ; example : "31/12/2003 12:31"
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

a man on whom whe can rely on.
thank you very much :twisted:

[EDIT]
but i think you forget a very little small thing but important one : the update doesn't include the new constante file...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

I'll check it out at home undoubtly!
This will be useful for many developers around.
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Flype wrote:i think you forget a very little small thing but important
one : the update doesn't include the new constante file...
Are you sure ?
I have just downloaded it and the PureLVSORT.res file has the 2 new constants (PureLVSORT.res 746 bytes 24/08/2005 09:39)

Code: Select all

ERUP    3SERTCRS    TSNCÎ  PureLVSORT_AutoSize  ÿÿÿÿPureLVSORT_Center     PureLVSORT_DateDDMMYYHHMM  	   PureLVSORT_DateDDMMYYYY     PureLVSORT_DateDDMMYYYYHHMMSS     PureLVSORT_DateMMDDYYYY     PureLVSORT_FileSize     PureLVSORT_Float     PureLVSORT_Left      PureLVSORT_MemoryAllocationProblem     PureLVSORT_NoSorting     PureLVSORT_NotAGadget     PureLVSORT_Numeric     PureLVSORT_Ok     PureLVSORT_Right     PureLVSORT_ShowClickedHeader_Icon     PureLVSORT_ShowClickedHeader_IconLeft     PureLVSORT_ShowClickedHeader_IconRight     PureLVSORT_ShowClickedHeader_No      PureLVSORT_ShowClickedHeader_Text     PureLVSORT_String      PureLVSORT_String_CaseSensitive     PureLVSORT_UndefinedGadget     PureLVSORT_UseHeader  þÿÿÿ
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

i have re-downloaded the file and now it's ok - you're right.
i don't understand but nevermind. and thanx again.
:wink:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Post by Pantcho!! »

Is there a way in the commands to sort it on the fly as i wish? like a timer?

like that if i have a listicon that changes all the time and each 5 min i want to sort it, is it possible to send a command for it to be sorted?

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

Post by gnozal »

Pantcho!! wrote:is it possible to send a command for it to be sorted?
Yes, you can use the PureLVSORT_SortListIconNow() function to sort a listicon when you want (without a user click on a column header).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
halinux
New User
New User
Posts: 1
Joined: Wed Jun 01, 2005 2:50 pm

accent

Post by halinux »

Hi Gnozal!

It's a really great library!

But it would be really important for other languages to create a function
where I can redefine the alphabetic order.

If I sort in hungarian ascending.

a, b .... z, a', e' ...

In my ascii table z is 122 and a' is 225, maybe this is the reason why.

If I should be redefine the alphabet with a function!

Every non-english user would thank you for this feature!

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

Post by gnozal »

halinux wrote:In my ascii table z is 122 and a' is 225, maybe this is the reason why.
Yes, the sorting is done according to ASCII/ANSI code.
halinux wrote:If I should be redefine the alphabet with a function!
Every non-english user would thank you for this feature!
I am also a non-english user (I am french) :wink:
I will see what I can do for the next version.
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 »

Library update

Changes :
- new function PureLVSORT_DefineAlphabeticOrder() for defining the sorting order for the 256 ASCII codes
- new flag for PureLVSORT_SetColumnType() : #PureLVSORT_Alphabetic_User

Code: Select all

Procedure.l WindowCallBack(WindowId.l, message.l, wParam.l, lParam.l) 
  ReturnValue.l = #PB_ProcessPureBasicEvents
  ;
  ReturnValue = PureLVSORT_CallBack(WindowId, message, wParam, lParam, ReturnValue)
  ;
  ProcedureReturn ReturnValue 
EndProcedure
;
#Window_0 = 0
#ListIcon_0 = 0
Procedure Open_Window_0()
  If OpenWindow(#Window_0, 216, 0, 602, 302,  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "PureLVSORT User Array Test")
    If CreateGadgetList(WindowID())
      ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "User", 110)
      AddGadgetColumn(#ListIcon_0, 1, "DateDDMMYYYYHHMMSS", 130)
      AddGadgetColumn(#ListIcon_0, 2, "DateDDMMYYHHMM", 130)
      AddGadgetColumn(#ListIcon_0, 3, "DateDDMMYYYY", 120)
      AddGadgetColumn(#ListIcon_0, 4, "DateMMDDYYYY", 120)
      AddGadgetColumn(#ListIcon_0, 5, "FileSize", 120)
      AddGadgetColumn(#ListIcon_0, 6, "NoSorting", 120)
      AddGadgetItem(#ListIcon_0, -1, "éseza" + Chr(10) + "12/05/2001 06:41:30" + Chr(10) + "19/07/66 06:41" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004" + Chr(10) + "15.02 MB" + Chr(10) + "0")
      AddGadgetItem(#ListIcon_0, -1, "zssdd" + Chr(10) + "05/07/2004 09:21:30" + Chr(10) + "12/05/01 07:50" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004"  + Chr(10) + "65 B" + Chr(10) + "1")
      AddGadgetItem(#ListIcon_0, -1, "tdeed" + Chr(10) + "19/11/2003 07:18:31" + Chr(10) + "13/08/03 06:41" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003" + Chr(10) + "5.98 GB" + Chr(10) + "3")
      AddGadgetItem(#ListIcon_0, -1, "ùdsdd" + Chr(10) + "19/11/2003 06:21:30" + Chr(10) + "12/05/01 06:41" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001" + Chr(10) + "100 KB" + Chr(10) + "A")
      AddGadgetItem(#ListIcon_0, -1, "cdgdd" + Chr(10) + "19/11/2003 16:21:30" + Chr(10) + "12/05/01 06:41" + Chr(10) + "10/08/2001" + Chr(10) + "16/11/2001" + Chr(10) + "800 KB" + Chr(10) + "9")
      AddGadgetItem(#ListIcon_0, -1, "âdsdg" + Chr(10) + "19/11/2003 06:21:31" + Chr(10) + "12/05/01 06:41" + Chr(10) + "10/06/2004" + Chr(10) + "06/10/2004" + Chr(10) + "101 KB" + Chr(10) + "z")
      AddGadgetItem(#ListIcon_0, -1, "fdsdd" + Chr(10) + "19/11/2003 06:21:30" + Chr(10) + "12/05/01 06:41" + Chr(10) + "10/04/2001" + Chr(10) + "07/08/2004" + Chr(10) + "1000 B" + Chr(10) + "A")
    EndIf
  EndIf
EndProcedure
Open_Window_0()
SetWindowCallback(@WindowCallBack())
; define alphabetic order user array
Structure Array256
  Byte.b[256]
EndStructure
UserArray.Array256
; standard ASCII values
For i = 0 To 255
  UserArray\Byte[i] = i
Next
; change some values
UserArray\Byte[Asc("à")] = 'a'
UserArray\Byte[Asc("â")] = 'a'
UserArray\Byte[Asc("ù")] = 'u'
UserArray\Byte[Asc("û")] = 'u'
UserArray\Byte[Asc("ü")] = 'u'
UserArray\Byte[Asc("é")] = 'e'
UserArray\Byte[Asc("è")] = 'e'
UserArray\Byte[Asc("ê")] = 'e'
; declare user array (before using #PureLVSORT_Alphabetic_User !)
PureLVSORT_DefineAlphabeticOrder(@UserArray)
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
  ;PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String)
  PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_Alphabetic_User)
  PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_DateDDMMYYYYHHMMSS)
  PureLVSORT_SetColumnType(#ListIcon_0, 2, #PureLVSORT_DateDDMMYYHHMM)
  PureLVSORT_SetColumnType(#ListIcon_0, 3, #PureLVSORT_DateDDMMYYYY)
  PureLVSORT_SetColumnType(#ListIcon_0, 4, #PureLVSORT_DateMMDDYYYY)
  PureLVSORT_SetColumnType(#ListIcon_0, 5, #PureLVSORT_FileSize)
  PureLVSORT_SetColumnType(#ListIcon_0, 6, #PureLVSORT_NoSorting)
  PureLVSORT_SortListIconNow(#ListIcon_0, 1, -1)
EndIf
;
Repeat
  Event = WaitWindowEvent()
Until Event = #PB_EventCloseWindow
End
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

Changes
- new function PureLVSORT_GetClickedCellColumn() : Get the listicon clicked cell column after a click event.
- new function PureLVSORT_GetClickedCellRow() : Get the listicon clicked cell row after a click event.

Code: Select all

Procedure.l WindowCallBack(WindowId.l, message.l, wParam.l, lParam.l) 
  ReturnValue.l = #PB_ProcessPureBasicEvents
  ;
  ReturnValue = PureLVSORT_CallBack(WindowId, message, wParam, lParam, ReturnValue)
  ;
  ProcedureReturn ReturnValue 
EndProcedure
; Create Window
OpenWindow(0, 100, 300, 420, 170, #PB_Window_SystemMenu, "PureLVSORT test : get clicked cells coordinates") 
If CreateGadgetList(WindowID()) 
  ListIconGadget(1, 1, 1, 250, 160, "0", 50, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
  AddGadgetColumn(1, 1, "1", 50)
  AddGadgetColumn(1, 2, "2", 50)
  AddGadgetColumn(1, 3, "3", 50)
  AddGadgetColumn(1, 4, "4", 50)
  AddGadgetColumn(1, 5, "5", 50)
  AddGadgetItem(1, -1, " ")
  AddGadgetItem(1, -1, " ")
  AddGadgetItem(1, -1, " ")
  AddGadgetItem(1, -1, " ")
  AddGadgetItem(1, -1, " ")
  AddGadgetItem(1, -1, " ")
  AddGadgetItem(1, -1, " ")
  AddGadgetItem(1, -1, " ")
  AddGadgetItem(1, -1, " ")
  ListIconGadget(2, 260, 1, 150, 160, "0", 50, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
  AddGadgetColumn(2, 1, "1", 50)
  AddGadgetColumn(2, 2, "2", 50)
  AddGadgetItem(2, -1, " ")
  AddGadgetItem(2, -1, " ")
  AddGadgetItem(2, -1, " ")
  AddGadgetItem(2, -1, " ")
  AddGadgetItem(2, -1, " ")
  AddGadgetItem(2, -1, " ")
  AddGadgetItem(2, -1, " ")
  AddGadgetItem(2, -1, " ")
  AddGadgetItem(2, -1, " ")
  AddGadgetItem(2, -1, " ")
  AddGadgetItem(2, -1, " ")
EndIf
SetWindowCallback(@WindowCallBack()) 
Repeat 
  EventID.l = WaitWindowEvent()
  GadgetID.l = EventGadgetID()
  EventType.l = EventType()
  If EventID = #PB_EventGadget
    If GadgetID = 1
      Debug "* ListIconGadget 1 Event"
      If EventType = #PB_EventType_LeftClick
        Debug " Left Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
      ElseIf EventType = #PB_EventType_LeftDoubleClick
        Debug " Left DBL Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
      ElseIf EventType = #PB_EventType_RightClick
        Debug " Right Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
      ElseIf EventType = #PB_EventType_RightDoubleClick
        Debug " Right DBL Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
      EndIf
    EndIf
    If GadgetID = 2
      Debug "* ListIconGadget 2 Event"
      If EventType = #PB_EventType_LeftClick
        Debug "Left Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
      ElseIf EventType = #PB_EventType_LeftDoubleClick
        Debug " Left DBL Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
      ElseIf EventType = #PB_EventType_RightClick
        Debug " Right Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
      ElseIf EventType = #PB_EventType_RightDoubleClick
        Debug " Right DBL Click at ROW:" + Str(PureLVSORT_GetClickedCellRow()) + " COL:" + Str(PureLVSORT_GetClickedCellColumn())
      EndIf
    EndIf
  ElseIf EventID = #PB_EventCloseWindow 
    Break
  EndIf
ForEver
;
End
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

Changes
- new : PureLVSORT_CountColumns(GadgetNumber.l) : Count the columns in a ListIcon.
- new : PureLVSORT_SaveListIcon(GadgetNumber.l, FileName.s) : Save ListIcon content to a file (compressed with JCalG1 algorithm).
- new : PureLVSORT_LoadListIcon(GadgetNumber.l, FileName.s) : Load ListIcon content saved with PureLVSORT_SaveListIcon().
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

Changes
- new : PureLVSORT_ScrollToRow(GadgetNumber.l, Row.l) : Scroll the ListiconGadget to the given row (make it visible at the top of the list).
- new : PureLVSORT_DefineUserCallback(*UserCallbackAddress) : Define user sorting callback.
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

No more Callback needed
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply