Page 4 of 30

Posted: Wed Dec 21, 2005 9:42 pm
by Droopy
Thanks a lot :wink:

Posted: Thu Dec 22, 2005 10:39 pm
by Droopy
I need to sort a Listicon (Works).

The content of the ListIcon can change, after a change i want to sort the content.( Doesn't works)

I also want to memorize the SortDirection ( +1 / -1 )

Here's my buggy code :

Code: Select all

;/ PureLVSort 4.0 Test

Enumeration
  #List
  #Button
EndEnumeration

Procedure AddData()
  ClearGadgetItemList(#List)
  AddGadgetItem(#List,-1,"BBB")
  AddGadgetItem(#List,-1,"AAA")
  
  Sort=PureLVSORT_GetSortingDirection(#List)
  If Sort=0
    PureLVSORT_SortListIconNow(#List,0,-1)
  Else
    PureLVSORT_SortListIconNow(#List,0,1)
  EndIf
  
EndProcedure


OpenWindow(0,100,100,230,100,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Pure_LVSort Test")
CreateGadgetList(WindowID())
ListIconGadget(#List,5,5,100,90,"Name",95)
ButtonGadget(#Button,120,5,100,90,"Refresh")
PureLVSORT_SelectGadgetToSort(#List,#PureLVSORT_ShowClickedHeader_IconRight)
AddData()
PureLVSORT_SortListIconNow(#List,0,1)
    
    
Repeat
  EventID = WaitWindowEvent()
  If EventID=#PB_Event_Gadget And  EventGadgetID()=#Button
    AddData()
  EndIf
    
Until EventID = #PB_Event_CloseWindow 

Posted: Thu Dec 22, 2005 11:10 pm
by Droopy
I find a way to fix this :

Code: Select all

;/ PureLVSort 4.0 Test

Enumeration
  #List
  #Button
EndEnumeration

Procedure AddData()
  Static Sort ;/ Store Sort Direction
  
  ClearGadgetItemList(#List)
  AddGadgetItem(#List,-1,"BBB")
  AddGadgetItem(#List,-1,"AAA")

  ;/ Here's the Sort of the List with Direction stored
  Temp=PureLVSORT_GetSortingDirection(#List)
  If Temp <> Sort : Sort=Temp : EndIf ;/ Sort change if Direction change
  If Sort=0 : Sort=1 : EndIf ;/ Sort if first launch
   
  PureLVSORT_ClearGadget(#List)
  PureLVSORT_SelectGadgetToSort(#List,#PureLVSORT_ShowClickedHeader_IconRight)
  
  PureLVSORT_SortListIconNow(#List,0,Sort)
  
EndProcedure


OpenWindow(0,100,100,230,100,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Pure_LVSort Test")
CreateGadgetList(WindowID())
ListIconGadget(#List,5,5,100,90,"Name",95)
ButtonGadget(#Button,120,5,100,90,"Refresh")
AddData()
    
Repeat
  EventID = WaitWindowEvent()
  If EventID=#PB_Event_Gadget And  EventGadgetID()=#Button
    AddData()
  EndIf
    
Until EventID = #PB_Event_CloseWindow 
But is there a simple way ?

Posted: Fri Dec 23, 2005 8:49 am
by gnozal
@Droopy : I don't understand ?

The PureLVSORT_GetSortingDirection() function gets the last sorting direction, even if you have cleared the listicon in between, i.e. it is not cleared after a ClearGadgetItemList() call.
Is this your problem ?
I could set the sorting direction to zero after a ClearGadgetItemList() call.

Posted: Fri Dec 23, 2005 8:59 am
by Droopy
In the first code, the sort function works well the first time.
But after a content change (of the ListIcon) the sort function doesn't works.

Try the first code : When you clik the button, the list si not sorted

Posted: Fri Dec 23, 2005 11:36 am
by gnozal
Droopy wrote:In the first code, the sort function works well the first time.
But after a content change (of the ListIcon) the sort function doesn't works.
Try the first code : When you clik the button, the list si not sorted
I think I understand now. I will take a look

Posted: Fri Dec 23, 2005 11:38 am
by gnozal
Update

Changes :
- Special Droopy fix

@ Droopy : this code seems to work like you expected ?

Code: Select all

Enumeration 
  #List 
  #Button 
EndEnumeration 

Procedure AddData() 
  ClearGadgetItemList(#List) 
  AddGadgetItem(#List,-1,"BBB" + Chr(10) + "1") 
  AddGadgetItem(#List,-1,"AAA" + Chr(10) + "3") 
  AddGadgetItem(#List,-1,"CCC" + Chr(10) + "2") 
  
 Sort = PureLVSORT_GetSortingDirection(#List) 
 If Sort=0 
   PureLVSORT_SortListIconNow(#List,0,-1) 
 Else
   PureLVSORT_SortListIconNow(#List,0, 1) 
 EndIf 

EndProcedure 


OpenWindow(0,100,100,230,100,#PB_Window_SystemMenu|#PB_Window_ScreenCentered | #PB_Window_TitleBar ,"Pure_LVSort Test") 
CreateGadgetList(WindowID()) 
ListIconGadget(#List,5,5,100,90,"A",50)
ButtonGadget(#Button,120,5,100,90,"Refresh") 
AddGadgetColumn(#List, 1, "b", 50)
PureLVSORT_SelectGadgetToSort(#List,#PureLVSORT_ShowClickedHeader_IconRight) 
 AddData() 
PureLVSORT_SortListIconNow(#List,0,1) 
    
Repeat 
  EventID = WaitWindowEvent() 
  If EventID=#PB_Event_Gadget And  EventGadgetID()=#Button
    AddData() 
  EndIf 
  
Until EventID = #PB_Event_CloseWindow

Posted: Fri Dec 23, 2005 2:03 pm
by Droopy
No :cry:

When the program is launched, the column 'A' is well sorted.
But when you click the Refresh button the column is not sorted ! :?

Posted: Fri Dec 23, 2005 2:53 pm
by gnozal
Droopy wrote:No :cry:

When the program is launched, the column 'A' is well sorted.
But when you click the Refresh button the column is not sorted ! :?
I have these results :
> Launch :
column A
AAA
BBB
CCC

The column is sorted [+1], because
AddData() --> Sort=0 --> PureLVSORT_SortListIconNow(#List,0,-1)
PureLVSORT_SortListIconNow(#List,0,1)

> Refresh :
column A
CCC
BBB
AAA

The column is sorted [-1], because
AddData() --> Sort=0 --> PureLVSORT_SortListIconNow(#List,0,-1)


What is wrong ?

Posted: Fri Dec 23, 2005 3:35 pm
by Droopy
Thanks Gnozal, the sort is fixed.
But stay the problem to store the SortDirection.

Here's the code to show my problem. (Launch in Degug mode)

Code: Select all

Enumeration 
  #List 
  #Button 
EndEnumeration 

Procedure AddData() 
  ClearGadgetItemList(#List) 
  AddGadgetItem(#List,-1,"BBB" + Chr(10) + "1") 
  AddGadgetItem(#List,-1,"AAA" + Chr(10) + "3") 
  AddGadgetItem(#List,-1,"CCC" + Chr(10) + "2") 
  
  Sort = PureLVSORT_GetSortingDirection(#List) 
  Debug Sort
  If Sort=-1
    PureLVSORT_SortListIconNow(#List,0,-1) 
  Else 
    PureLVSORT_SortListIconNow(#List,0, 1) 
  EndIf 
  
EndProcedure 


OpenWindow(0,100,100,230,100,#PB_Window_SystemMenu|#PB_Window_ScreenCentered | #PB_Window_TitleBar ,"Pure_LVSort Test") 
CreateGadgetList(WindowID()) 
ListIconGadget(#List,5,5,100,90,"A",50) 
ButtonGadget(#Button,120,5,100,90,"Refresh") 
AddGadgetColumn(#List, 1, "b", 50) 
PureLVSORT_SelectGadgetToSort(#List,#PureLVSORT_ShowClickedHeader_IconRight) 
AddData() 
PureLVSORT_SortListIconNow(#List,0,1) 
    
Repeat 
  EventID = WaitWindowEvent() 
  If EventID=#PB_Event_Gadget And  EventGadgetID()=#Button 
    AddData() 
  EndIf 
  
Until EventID = #PB_Event_CloseWindow
I cant memorize the SortDirection because after a ClearGadgetItemList the function PureLVSORT_GetSortingDirection always return '0'

Posted: Fri Dec 23, 2005 3:42 pm
by gnozal
Droopy wrote:I cant memorize the SortDirection because after a ClearGadgetItemList the function PureLVSORT_GetSortingDirection always return '0'
This is not a bug, it's a feature : after a ClearGadgetItemList() call, PureLVSORT_GetSortingDirection() is set to 0, like it is after ListIconGadget() (you can't sort an empty list, so no sorting direction).

Posted: Fri Dec 23, 2005 5:33 pm
by Droopy
Thanks a lot Gnozal . :D

Posted: Fri Dec 23, 2005 5:46 pm
by Droopy
Here's my fixed code

Code: Select all

;/ PureLVSort 4.0 Test 

Enumeration 
  #List 
  #Button 
EndEnumeration 

Procedure AddData() 
  Static Sort ;/ Memorize Sort Direction 
  
  ;/ Here I Store the Sort Direction ( Because ClearGadgetItem Delete Direction)
  Temp=PureLVSORT_GetSortingDirection(#List)
  If Temp<> 0 : Sort=Temp : EndIf
  If Sort=0 : Sort=1 : EndIf ;/ Sort @ first launch 
  
  
  ;/ Clearing ListIcon and Add Items
  ClearGadgetItemList(#List) 
  AddGadgetItem(#List,-1,"BBB") 
  AddGadgetItem(#List,-1,"AAA") 
  AddGadgetItem(#List,-1,"CCC") 
   
  ;/ Sort the ListIcon ( With Direction Memorized )
  PureLVSORT_ClearGadget(#List) 
  PureLVSORT_SelectGadgetToSort(#List,#PureLVSORT_ShowClickedHeader_IconRight) 
  PureLVSORT_SortListIconNow(#List,0,Sort) 
  
EndProcedure 


OpenWindow(0,100,100,230,100,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Pure_LVSort 4.0 Test") 
CreateGadgetList(WindowID()) 
ListIconGadget(#List,5,5,100,90,"Name",95) 
ButtonGadget(#Button,120,5,100,90,"Refresh") 
AddData() 
    
Repeat 
  EventID = WaitWindowEvent() 
  If EventID=#PB_Event_Gadget And  EventGadgetID()=#Button 
    AddData() 
  EndIf 
  
Until EventID = #PB_Event_CloseWindow 
Thanks again

Posted: Wed Dec 28, 2005 2:29 pm
by gnozal
Update

Changes :
- new function PureLVSORT_SetLastColumnAutoResize() : resize the last column when the ListIcon is resized.

Code: Select all

#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 | #PB_Window_SizeGadget, "PureLVSORT LastColumn AutoResize Test")
    If CreateGadgetList(WindowID())
      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")
      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")
    EndIf
  EndIf
EndProcedure
Open_Window_0()
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_No) = #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_SetLastColumnAutoResize(#ListIcon_0, #True) ; <------ resize the window and compare #True / #False
EndIf
PureRESIZE_SetGadgetResize(#ListIcon_0, #True, #True, #True, #True)
;
Repeat
  Event = WaitWindowEvent()
Until Event = #PB_EventCloseWindow
End

Posted: Tue Apr 25, 2006 7:38 am
by Fangbeast
Gnozal do we have to wait for pb 4 final before there is a release to the sort lib? I could certainly use this library right now.

Regardez, Fang