Page 28 of 30
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Thu Apr 12, 2012 7:06 pm
by kosjachok
Hi gnozal
I tried changing callback
Code: Select all
Procedure MyFilterCallback(GadgetNumber.l, FilterString.s, ListIconColumn.l, EventCode.l) ; simple filter example
Shared *ListBuffer
If EventCode = #PureLVSORT_FilterChange
If *ListBuffer
PureLVSORT_LoadListIconFromMem(GadgetNumber, *ListBuffer, FilterString, ListIconColumn, #True)
*ListBuffer = PureLVSORT_SaveListIconToMem(GadgetNumber)
EndIf
EndIf
EndProcedure
this is works on two columns but only on 1 letter
maybe possible to refine this code?
p.s. Sorry for my english .
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Fri Apr 13, 2012 10:51 am
by gnozal
kosjachok wrote:Hi gnozal
I tried changing callback
It won't work like this, you are overwriting the same buffer (*ListBuffer) each time.
You have to use a new buffer each time the filter changes.
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Fri Jun 01, 2012 5:32 am
by Fangbeast
I have a ListIconGadget setup with 3 columns icons in column 0 with text and I issue a PureLVSORT_SortListIconNow after I add an item.
All icons disappear when I do that.
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Fri Jun 01, 2012 8:12 am
by gnozal
Fangbeast wrote:I have a ListIconGadget setup with 3 columns icons in column 0 with text and I issue a PureLVSORT_SortListIconNow after I add an item.
All icons disappear when I do that.
Seems to work here.
Code: Select all
#Window_0 = 0
#ListIcon_0 = 0
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT V2 Test", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "String", 110)
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, "FileSize", 120)
AddGadgetColumn(#ListIcon_0, 6, "NoSorting", 120)
AddGadgetItem(#ListIcon_0, -1, "ABCDE" + Chr(10) + "514" + Chr(10) + "0.9" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004" + Chr(10) + "15.02 MB" + Chr(10) + "0", LoadImage(0, #PB_Compiler_Home + "Examples\Sources\Data\CdPlayer.ico"))
AddGadgetItem(#ListIcon_0, -1, "ACDEF" + Chr(10) + "118" + Chr(10) + "1.9" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004" + Chr(10) + "65 B" + Chr(10) + "1")
AddGadgetItem(#ListIcon_0, -1, "ZABCD" + Chr(10) + "-414" + Chr(10) + "7.0" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003" + Chr(10) + "5.98 GB" + Chr(10) + "3")
AddGadgetItem(#ListIcon_0, -1, "DEFGH" + Chr(10) + "524" + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001" + Chr(10) + "100 KB" + Chr(10) + "A", LoadImage(1, #PB_Compiler_Home + "Examples\Sources\Data\CdPlayer.ico"))
EndIf
EndProcedure
Open_Window_0()
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String) ; default, not necessary
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_SetColumnType(#ListIcon_0, 5, #PureLVSORT_FileSize)
PureLVSORT_SetColumnType(#ListIcon_0, 6, #PureLVSORT_NoSorting)
PureLVSORT_SortListIconNow(#ListIcon_0, 1, -1) ;<------
EndIf
;
PureLVSORT_SetColumnAlignment(#ListIcon_0, 5, #PureLVSORT_Right)
;
Repeat
Debug "ClickedColumn / SortingDirection"
Debug PureLVSORT_GetClickedColumn(#ListIcon_0)
Debug PureLVSORT_GetSortingDirection(#ListIcon_0)
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Fri Jun 01, 2012 1:27 pm
by Fangbeast
Strange. Just one of those things I guess.
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Wed Jun 06, 2012 12:23 am
by falsam
PureLVSORT is awesome and I thank you for this plugin but apparently it is not possible to obtain the number of column / row when testing the event and # # PureLVSORT_EditEnd PureLVSORT_EditEscape.
Code: Select all
;Test PureLVSORT
;PB 4.61
Enumeration
#FontApp
#Mainform
#Table
#TotQte
EndEnumeration
Global TotQte.i
Global Mois.s="Janvier|Février|Mars|Avril|Mai|juin"
Declare.L Edit_Callback(Event.l, ListIconNumber.l, Column.l, Row.l, Text.s)
Declare GetTotalQty()
Declare Open_MainForm()
Procedure.l Edit_Callback(Event.l, ListIconNumber.l, Column.l, Row.l, Text.s)
Select Event
Case #PureLVSORT_EditStart
Debug "#PureLVSORT_EditStart"
Select Column
Case 0 ;Colonne 1 on peut choisir un mois (defilement des fleches)
ProcedureReturn @"Janvier|Février|Mars|Avril|Mai|Juin"
Case 1 ;Quantité de 1 à 10
ProcedureReturn @"1|2|3|4|5|6|7|8|9|10"
Case 2 ;Texte libre
ProcedureReturn 0
EndSelect
Case #PureLVSORT_EditText
Debug "#PureLVSORT_EditText"
Debug "Column :" + Str(Column) + " - " + Str(Column) ;Strange !! Column=-1 Row=-1
If Text = "Change this text"
ProcedureReturn @"to another text"
EndIf
Case #PureLVSORT_EditEnd
Debug "#PureLVSORT_EditEnd"
Debug "Column :" + Str(Column) + " - " + Str(Column) ;Strange !! Column=-1 Row=-1
GetTotalQty()
Case #PureLVSORT_EditEscape
Debug "#PureLVSORT_EditEscape"
Debug "Column :" + Str(Column) + " - " + Str(Column) ;Strange !! Column=-1 Row=-1
ProcedureReturn @Text ; On retourne le texte initiale
EndSelect
EndProcedure
;Recalcul les quantités
Procedure GetTotalQty()
TotQte=0
For i=0 To CountGadgetItems(#Table)-1
TotQte+Val(GetGadgetItemText(#Table,i,1))
Next
SetGadgetText(#TotQte, Str(TotQte))
EndProcedure
;Fenetre principale
Procedure Open_MainForm()
LoadFont(#FontApp,"Arial",11)
SetGadgetFont(#PB_Default,FontID(#FontApp))
OpenWindow(#Mainform, 0, 0, 500, 400, "Test PureLVSORT")
ListIconGadget(#Table, 10,10,480,200,"Mois",100, #PB_ListIcon_FullRowSelect)
AddGadgetColumn(#Table,1,"Qté.",50)
AddGadgetColumn(#Table,2,"Observation.",200)
TextGadget(#PB_Any, 10, 220, 100, 20, "Total Quantité : ")
TextGadget(#TotQte, 110, 220, 50, 22, "0")
;Un peu de remplissage
For row=0 To 5
AddGadgetItem(#Table, -1, StringField(Mois,Row+1,"|") + Chr(10)+Str(Row))
Next
GetTotalQty()
;Utilisation de PureLVSORT
If PureLVSORT_SelectGadgetToSort(#Table, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
PureLVSORT_SetColumnType(#Table, 0, #PureLVSORT_String)
PureLVSORT_SetColumnType(#Table, 1, #PureLVSORT_Float)
PureLVSORT_SetColumnAlignment(#Table, 1, #PureLVSORT_Right)
PureLVSORT_MakeColumnEditable(#Table, 0, #True)
PureLVSORT_MakeColumnEditable(#Table, 1, #True)
PureLVSORT_MakeColumnEditable(#Table, 2, #True)
PureLVSORT_SetEditingColors($DEF4F8, $000000)
PureLVSORT_SetEditingCallback(@Edit_Callback())
EndIf
EndProcedure
Open_MainForm()
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
I hope I understand the operation of this library

Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Wed Jun 06, 2012 9:39 am
by gnozal
falsam wrote:PureLVSORT is awesome and I thank you for this plugin but apparently it is not possible to obtain the number of column / row when testing the events #PureLVSORT_EditEnd or #PureLVSORT_EditEscape.
Yes, there is no current row or column after these events (no selected cell anymore).
If you need this information, use static variables in the callback.
Code: Select all
Procedure.l Edit_Callback(Event.l, ListIconNumber.l, Column.l, Row.l, Text.s)
Static LastColumn = -1, LastRow = -1
If Column <> -1
LastColumn = Column
EndIf
If Row <> -1
LastRow = Row
EndIf
Select Event
Case #PureLVSORT_EditStart
Debug "#PureLVSORT_EditStart"
Select Column
Case 0 ;Colonne 1 on peut choisir un mois (defilement des fleches)
ProcedureReturn @"Janvier|Février|Mars|Avril|Mai|Juin"
Case 1 ;Quantité de 1 à 10
ProcedureReturn @"1|2|3|4|5|6|7|8|9|10"
Case 2 ;Texte libre
ProcedureReturn 0
EndSelect
Case #PureLVSORT_EditText
Debug "#PureLVSORT_EditText"
Debug "Position :" + Str(Column) + " - " + Str(Row)
If Text = "Change this text"
ProcedureReturn @"to another text"
EndIf
Case #PureLVSORT_EditEnd
Debug "#PureLVSORT_EditEnd"
Debug "Position :" + Str(LastColumn) + " - " + Str(LastRow)
GetTotalQty()
Case #PureLVSORT_EditEscape
Debug "#PureLVSORT_EditEscape"
Debug "Position :" + Str(LastColumn) + " - " + Str(LastRow)
ProcedureReturn @Text ; On retourne le texte initiale
EndSelect
EndProcedure
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Wed Jun 06, 2012 8:16 pm
by falsam
Very GooOOOD. thank you very much gnozal.
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Wed Jun 06, 2012 9:31 pm
by falsam
Code: Select all
;Test PureLVSORT
;PB 4.61
Enumeration
#FontApp
#Mainform
#Table
#TotQte
#Status
EndEnumeration
Global TotQte.i, LastBuffer.s
Global Mois.s="Janvier|Février|Mars|Avril|Mai|juin"
Declare.L Edit_Callback(Event.l, ListIconNumber.l, Column.l, Row.l, Text.s)
Declare GetTotalQty()
Declare Open_MainForm()
Procedure.l Edit_Callback(Event.l, ListIconNumber.l, Column.l, Row.l, Text.s)
Static LastColumn = -1, LastRow = -1, LastBuffer.s
If Column <> -1
LastColumn = Column
LastBuffer=Text
EndIf
If Row <> -1
LastRow = Row
EndIf
SetGadgetText(#Status, Str(Column)+"/"+Str(LastRow))
Select Event
Case #PureLVSORT_EditStart
Select LastColumn
Case 0 ;Colonne 1 on peut choisir un mois (defilement des fleches)
ProcedureReturn @"Janvier|Février|Mars|Avril|Mai|Juin"
Case 1 ;Quantité de 1 à 10
ProcedureReturn @"1|2|3|4|5|6|7|8|9|10"
Case 2 ;Texte libre
ProcedureReturn 0
EndSelect
Case #PureLVSORT_EditText
;On transforme le texte en masjuscule en cours d'écriture
Select LastColumn
Case 0
Case 1
Case 2
LastBuffer=UCase(LastBuffer)
ProcedureReturn @LastBuffer
EndSelect
Case #PureLVSORT_EditEnd
;Si une quantité est modifiée on recalcul le cumul de ces quantités
Select LastColumn
Case 0
Case 1
GetTotalQty()
Case 2
EndSelect
Case #PureLVSORT_EditEscape
ProcedureReturn @Text ; On retourne le texte initiale
EndSelect
EndProcedure
;Recalcul les quantités
Procedure GetTotalQty()
TotQte=0
For i=0 To CountGadgetItems(#Table)-1
TotQte+Val(GetGadgetItemText(#Table,i,1))
Next
SetGadgetText(#TotQte, Str(TotQte))
EndProcedure
;Fenetre principale
Procedure Open_MainForm()
LoadFont(#FontApp,"Arial",11)
SetGadgetFont(#PB_Default,FontID(#FontApp))
OpenWindow(#Mainform, 0, 0, 500, 400, "Test PureLVSORT")
ListIconGadget(#Table, 10,10,480,200,"Mois",100, #PB_ListIcon_FullRowSelect)
AddGadgetColumn(#Table,1,"Qté.",50)
AddGadgetColumn(#Table,2,"Observation.",200)
TextGadget(#PB_Any, 10, 220, 100, 20, "Total Quantité : ")
TextGadget(#TotQte, 110, 220, 50, 22, "0")
TextGadget(#Status, 20, 350, 150, 22, "")
;Un peu de remplissage
For row=0 To 5
AddGadgetItem(#Table, -1, StringField(Mois,Row+1,"|") + Chr(10)+Str(Row))
Next
GetTotalQty()
;Utilisation de PureLVSORT
If PureLVSORT_SelectGadgetToSort(#Table, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
PureLVSORT_SetColumnType(#Table, 0, #PureLVSORT_String)
PureLVSORT_SetColumnType(#Table, 1, #PureLVSORT_Float)
PureLVSORT_SetColumnAlignment(#Table, 1, #PureLVSORT_Right)
PureLVSORT_MakeColumnEditable(#Table, 0, #True)
PureLVSORT_MakeColumnEditable(#Table, 1, #True)
PureLVSORT_MakeColumnEditable(#Table, 2, #True)
PureLVSORT_SetEditingColors($DEF4F8, $000000)
PureLVSORT_SetEditingCallback(@Edit_Callback())
EndIf
EndProcedure
Open_MainForm()
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
Maybe a bug? It is possible to modify the header of a column. Click after the last row in this table.
How is it possible not to hear the beep at the end of the edit mode. thank you

Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Thu Jun 07, 2012 8:00 am
by gnozal
falsam wrote:Maybe a bug? It is possible to modify the header of a column. Click after the last row in this table.
I have uploaded a new build.
Should be fixed.
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Thu Jun 07, 2012 1:15 pm
by falsam
gnozal wrote:I have uploaded a new build. Should be fixed.
Yessss ...... Fixed. Thanks.
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Thu Sep 27, 2012 1:43 pm
by bobobo
Hi Gnozal
i appreciate Your splendid libs.
When meeting in real life i pay the beer
One Question to PureLVSort
Maybe i've missed something but
the doubleclick to select a element to switch to editmode is somehow annoying
because it need a mouse (of course) to do so.
Is it possible to switch to a kind of preeditmode , drawing a border around the
actual editable element (left upper if none) and pressing the arrowkeys select the next
editable element in column or row ?
Beginning of typing can enter the real editmode for this element
Pressing a arrowkey or enter exits editmode and switches to the next editable element
('arrow' in the direction it should and 'enter' right or down (set via switch))
I think this is a little (row and col is already known) extension this lib could bare.
maybe is it sufficient to spend a PURELVSORT_EnterEditMode (gadget,row,col).
This combined with editcallback will show the way.
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Fri Sep 28, 2012 10:56 am
by gnozal
bobobo wrote:Maybe i've missed something but the doubleclick to select a element to switch to editmode is somehow annoying
because it need a mouse (of course) to do so.
Yes, a mouse is mandatory to select a cell for editing.
bobobo wrote:Is it possible to switch to a kind of preeditmode , drawing a border around the actual editable element (left upper if none) and pressing the arrowkeys select the next editable element in column or row ?...
This would mean big changes in the cell editing code, and it would probably not be as convenient / powerful as real grid libraries like EsGrid.
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Fri Sep 28, 2012 12:36 pm
by bobobo
Ok .. it is as it is.
a EnterEditMode(gadget,row,col) aint possible either?
Re: PureLVSORT library : sorting ListIconGadgets (and more)
Posted: Fri Sep 28, 2012 2:08 pm
by gnozal
bobobo wrote:a EnterEditMode(gadget,row,col) aint possible either?
I guess you may simulate a mouse event :
Code: Select all
#Window_0 = 0
#ListIcon_0 = 0
Procedure Open_Window_0()
If OpenWindow(#Window_0, 0, 0, 602, 302, "PureLVSORT Test 1", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)
If CreateGadgetList(WindowID(#Window_0))
ListIconGadget(#ListIcon_0, 5, 5, 590, 255, "String", 110)
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) + "0.9" + 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) + "1.9" + 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) + "7.0" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003" + Chr(10)+ "12/11/2004")
AddGadgetItem(#ListIcon_0, -1, "DEFGH" + Chr(10) + "524" + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001" + Chr(10)+ "12/11/2004")
PureRESIZE_SetGadgetResize(#ListIcon_0, 1, 1, 1, 1)
EndIf
EndIf
EndProcedure
Open_Window_0()
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
PureLVSORT_SetColumnType(#ListIcon_0, 0, #_PureLVSORT_String) ; default, not necessary
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)
EndIf
; WM_LBUTTONDBLCLK
; fwKeys = wParam; // key flags
; xPos = LOWORD(lParam); // horizontal position of cursor
; yPos = HIWORD(lParam); // vertical position of cursor
PureLVSORT_MakeColumnEditable(#ListIcon_0, 0, #True)
PostMessage_(GadgetID(#ListIcon_0), #WM_LBUTTONDBLCLK, 0, 12 | (42 <<16)) ;<---- double click on x = 12 y = 42 (mouse coordinates)
;
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
EndSelect
Until Event = #PB_Event_CloseWindow
End