PureLVSORT library : sorting ListIconGadgets (and more)

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

Moderator: gnozal

linkerstorm
User
User
Posts: 47
Joined: Sun Feb 18, 2007 11:57 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by linkerstorm »

...but does not clear the UI where the sort arrow remains...
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:...but does not clear the UI where the sort arrow remains...
No, you're right.
I forgot this. Should be fixed in version 4.49 (uploaded).
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 »

Thanx gnozal !
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by Fangbeast »

Gnozal, is it possible to sort on more than one column at a time?

I.e: I have a time and date field and I want the date field to be sorted first and then the time field for each date?
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
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 »

Fangbeast wrote:Gnozal, is it possible to sort on more than one column at a time?
I.e: I have a time and date field and I want the date field to be sorted first and then the time field for each date?
No.
PureLVSORT uses the API LVM_SORTITEMS message, so I don't think it's possible.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by Fangbeast »

Okay, thanks. Pity.

When I first show records from my application, I use SQLite's ability to sort on more than one column and I was hoping to allow users to do the same live when a column was clicked.

Oh well.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by QuimV »

:) Hi Gnozal,
I have a problem with my editing callback function when I need to identify the ListIconNumber that has invoked the editing callback function.
Please, look a this piece of test code:

Code: Select all

;
; PureLVSORT listicon editing example
;
Procedure.l MyEditCallback(Event.l, ListIconNumber.l, Column.l, Row.l, text.s)
   Debug "*** EDITING CALLBACK"
   Select Event
      Case #PureLVSORT_EditStart
         Debug "ListIcon = "   + Str(ListIconNumber)
         Debug "Column = " + Str(Column)
         Debug "Row = " + Str(Row)
         Debug "-> Editing started"
         ;ADDED
         Debug ListIconNumber
         ;
         ; Return   : - 0 to enable stringgadget
         ;                - *string to enable spingadget [the string holds the choice items]
         ;
         ProcedureReturn @"700|800|900|1000"
      Case #PureLVSORT_EditText
         Debug "ListIcon = "   + Str(ListIconNumber)
         Debug "Column = " + Str(Column)
         Debug "Row = " + Str(Row)
         Debug "-> Text = " + text
         ;ADDED
         Debug ListIconNumber
         ;
         ; Return   : - 0 to keep the text
         ;                - *string to change the text [the string holds the changed text]
         ;
         If text = "Change this text"
            ProcedureReturn @"to another text"
         EndIf
      Case #PureLVSORT_EditEnd
         Debug "Editing ended"
         ;ADDED
         Debug ListIconNumber
      Case #PureLVSORT_EditEscape
         Debug "Editing cancelled"
         ;ADDED
         Debug ListIconNumber
   EndSelect
   Debug "******************"
EndProcedure
;
#Window_0   = 0 
#ListIcon_0 = 100 
Procedure Open_Window_0() 
   If OpenWindow(#Window_0, 0, 0, 602, 302, "PureLVSORT Make Editable Test",   #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget | #PB_Window_SizeGadget) 
         ListIconGadget(#ListIcon_0, 5, 5, 590, 255, "String", 100) 
         AddGadgetColumn(#ListIcon_0, 1, "Numeric", 110) 
         AddGadgetColumn(#ListIcon_0, 2, "Float", 110) 
         AddGadgetColumn(#ListIcon_0, 3, "DateDDMMYYYY", 120) 
         AddGadgetColumn(#ListIcon_0, 4, "DateMMDDYYYY", 120) 
         AddGadgetColumn(#ListIcon_0, 5, "DateMMDDYYYY", 120) 
         AddGadgetItem(#ListIcon_0, -1, "ABCDE" + Chr(10) + "514" + Chr(10) + "1000" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004" + Chr(10) + "12/31/2004") 
         AddGadgetItem(#ListIcon_0, -1, "ACDEF" + Chr(10) + "118" + Chr(10) + "700" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004" + Chr(10)+ "12/11/2004") 
         AddGadgetItem(#ListIcon_0, -1, "ZABCD" + Chr(10) + "-414" + Chr(10) + "800" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003" + Chr(10)+ "12/11/2004") 
         For n=1 To 25 
            AddGadgetItem(#ListIcon_0, -1, "DEFGH" + Chr(10) + "extra entry "+Str(n) + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001" + Chr(10)+ "12/11/2004") 
         Next 
   EndIf 
EndProcedure 
Open_Window_0() 
; ListIcon Sort Setup 
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok 
   PureLVSORT_SetColumnFlag(#ListIcon_0, 0, #PureLVSORT_Column_Hidden) ; Hide column 0 
   PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String) 
   PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_Numeric) 
   PureLVSORT_SetColumnType(#ListIcon_0, 2, #PureLVSORT_Float) 
   PureLVSORT_SetColumnType(#ListIcon_0, 3, #PureLVSORT_DateDDMMYYYY) 
   PureLVSORT_SetColumnType(#ListIcon_0, 4, #PureLVSORT_DateMMDDYYYY) 
   PureLVSORT_SetLastColumnAutoResize(#ListIcon_0, #True) 
   PureLVSORT_MakeColumnEditable(#ListIcon_0, 2, #True) ; Column 2 is editable
   PureLVSORT_SetEditingColors(#Red, #White)
   PureLVSORT_SetEditingCallback(@MyEditCallback()) ; Set editing callback
EndIf 
; 
Repeat 
   Event = WaitWindowEvent() 
   Select Event 
      Case #PB_Event_Gadget 
   EndSelect 
Until Event = #PB_Event_CloseWindow 
End 
In the events #PureLVSORT_EditEnd and #PureLVSORT_EditEscape, ListIconNumber is equal to -1.
Is that correct?
I'm using PB4.51 + W7
Thanks in advanced.
QuimV
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 »

QuimV wrote:In the events #PureLVSORT_EditEnd and #PureLVSORT_EditEscape, ListIconNumber is equal to -1.
Is that correct?
Yes, it its.
The #PureLVSORT_EditEnd and #PureLVSORT_EditEscape events do not set any parameters (-> ListIconNumber=-1, Column=-1, Row=-1, text="").
This should no be a problem, as you can only edit one Listicongadget at the time (#PureLVSORT_EditEnd is sent if the Listicongadget looses focus).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by QuimV »

:) OK,
Thanks Gnozal!
QuimV
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by QuimV »

:( Gnozal,
I tried this piece of code and it seems that the #PureLVSORT_EditEnd event is not fired when the ListIcon loses the focus. Is a correct behavior?

Code: Select all

;
; PureLVSORT listicon editing example
;
Procedure.l MyEditCallback(Event.l, ListIconNumber.l, Column.l, Row.l, text.s)
   Debug "*** EDITING CALLBACK"
   Select Event
      Case #PureLVSORT_EditStart
         Debug "ListIcon = "   + Str(ListIconNumber)
         Debug "Column = " + Str(Column)
         Debug "Row = " + Str(Row)
         Debug "-> Editing started"
         ;
         ; Return   : - 0 to enable stringgadget
         ;                - *string to enable spingadget [the string holds the choice items]
         ;
         ProcedureReturn @"700|800|900|1000"
      Case #PureLVSORT_EditText
         Debug "ListIcon = "   + Str(ListIconNumber)
         Debug "Column = " + Str(Column)
         Debug "Row = " + Str(Row)
         Debug "-> Text = " + text
         ;
         ; Return   : - 0 to keep the text
         ;                - *string to change the text [the string holds the changed text]
         ;
         If text = "Change this text"
            ProcedureReturn @"to another text"
         EndIf
      Case #PureLVSORT_EditEnd
         Debug "Editing ended"
      Case #PureLVSORT_EditEscape
         Debug "Editing cancelled"
   EndSelect
   Debug "******************"
EndProcedure
;
#Window_0 = 0 
#ListIcon_0 = 0 
Procedure Open_Window_0() 
   If OpenWindow(#Window_0, 0, 0, 602, 320, "PureLVSORT Make Editable Test",   #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget | #PB_Window_SizeGadget) 
         ListIconGadget(#ListIcon_0, 5, 5, 590, 255, "String", 100) 
         AddGadgetColumn(#ListIcon_0, 1, "Numeric", 110) 
         AddGadgetColumn(#ListIcon_0, 2, "Float", 110) 
         AddGadgetColumn(#ListIcon_0, 3, "DateDDMMYYYY", 120) 
         AddGadgetColumn(#ListIcon_0, 4, "DateMMDDYYYY", 120) 
         AddGadgetColumn(#ListIcon_0, 5, "DateMMDDYYYY", 120) 
         AddGadgetItem(#ListIcon_0, -1, "ABCDE" + Chr(10) + "514" + Chr(10) + "1000" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004" + Chr(10) + "12/31/2004") 
         AddGadgetItem(#ListIcon_0, -1, "ACDEF" + Chr(10) + "118" + Chr(10) + "700" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004" + Chr(10)+ "12/11/2004") 
         AddGadgetItem(#ListIcon_0, -1, "ZABCD" + Chr(10) + "-414" + Chr(10) + "800" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003" + Chr(10)+ "12/11/2004") 
         For n=1 To 25 
            AddGadgetItem(#ListIcon_0, -1, "DEFGH" + Chr(10) + "extra entry "+Str(n) + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001" + Chr(10)+ "12/11/2004") 
         Next 
         ;ADDED 
         ButtonGadget(1000,5,260,590,60,"Click here and ListIcon lose focus, but not abandon the edit state. PureLVSORT_EditEnd is sent if the Listicongadget loses focus?", #PB_Button_MultiLine)
   EndIf


EndProcedure 
Open_Window_0() 
; ListIcon Sort Setup 
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok 
   PureLVSORT_SetColumnFlag(#ListIcon_0, 0, #PureLVSORT_Column_Hidden) ; Hide column 0 
   PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String) 
   PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_Numeric) 
   PureLVSORT_SetColumnType(#ListIcon_0, 2, #PureLVSORT_Float) 
   PureLVSORT_SetColumnType(#ListIcon_0, 3, #PureLVSORT_DateDDMMYYYY) 
   PureLVSORT_SetColumnType(#ListIcon_0, 4, #PureLVSORT_DateMMDDYYYY) 
   PureLVSORT_SetLastColumnAutoResize(#ListIcon_0, #True) 
   PureLVSORT_MakeColumnEditable(#ListIcon_0, 2, #True) ; Column 2 is editable
   PureLVSORT_SetEditingColors(#Red, #White)
   PureLVSORT_SetEditingCallback(@MyEditCallback()) ; Set editing callback
EndIf 
; 
Repeat 
   Event = WaitWindowEvent() 
   Select Event 
      Case #PB_Event_Gadget 
   EndSelect 
Until Event = #PB_Event_CloseWindow 
End 
Thanks in advanced
QuimV
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 »

QuimV wrote:I tried this piece of code and it seems that the #PureLVSORT_EditEnd event is not fired when the ListIcon loses the focus. Is a correct behavior?
Sorry, my statement was incorrect.
I meant it fires a #PureLVSORT_EditEnd event when you click on another cell of the listicon : the edited cell looses the focus, another gains it.
The editing does not end if you click on another gadget.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by QuimV »

:D OK Gnozal,

One question more!
When the user click another gadget and the ListIcon lose the focus, How could I end or cancel the current edition programatically?
Is it possible?
Thanks in advanced.
QuimV
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 »

QuimV wrote:When the user click another gadget and the ListIcon lose the focus, How could I end or cancel the current edition programatically?
Is it possible?
Did you try PureLVSORT_CancelCellEditing() ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by QuimV »

Yes, but what can I do if I need to end accepting the edition?
QuimV
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 (PureLVSORT Plus for PB4.5x)

Changes :
- added PureLVSORT_ExitCellEditing()
  Exit current cell editing (if any) and keep the current cell value.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply