It is currently Mon Jan 25, 2021 2:14 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 439 posts ]  Go to page 1, 2, 3, 4, 5 ... 30  Next
Author Message
 Post subject: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Sat Nov 27, 2004 11:00 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
PureLVSORT library - PB5.1x : V4.51/4.51c (MAR 27th 2013)

Purpose
Code:
Automatically sorts listicon gadgets after a LVN_COLUMNCLICK event (click on column header) or a PureLVSORT_SortListIconNow() function call, and more...


Functions
PB4.xx : http://gnozal.ucoz.com/PureLVSORT_.htm

Example
Code:
#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 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)
      AddGadgetItem(#ListIcon_0, -1, "ABCDE" + Chr(10) + "514" + Chr(10) + "0.9" + Chr(10) + "31/12/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")
      AddGadgetItem(#ListIcon_0, -1, "ZABCD" + Chr(10) + "-414" + Chr(10) + "7.0" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003")
      AddGadgetItem(#ListIcon_0, -1, "DEFGH" + Chr(10) + "524" + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001")
    EndIf
  EndIf
EndProcedure
Open_Window_0()
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_Icon) = #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)
EndIf
;
Repeat
  Event = WaitWindowEvent()
  If EventType() = #PB_EventType_LeftDoubleClick
    PureLVSORT_ClearGadget(#ListIcon_0)
  EndIf
Until Event = #PB_EventCloseWindow
End


Download
Only available for Purebasic Windows x86
PB3.94 : http://gnozal.ucoz.com/PureLVSORT.zip
PB4.0x : http://gnozal.ucoz.com/PureLVSORT_.zip
There are two versions in the archive : PureLVSORT (standard) and PureLVSORT-Plus ; the plus version adds some basic listicon editing functions.
PB4.1x : http://gnozal.ucoz.com/PureLVSORT__.zip
There are two versions in the archive : PureLVSORT (standard) and PureLVSORT-Plus ; the plus version adds some basic listicon editing functions.
PB4.2x : http://gnozal.ucoz.com/PureLVSORT___.zip
There are two versions in the archive : PureLVSORT (standard) and PureLVSORT-Plus ; the plus version adds some basic listicon editing functions.
PB4.3x : http://gnozal.ucoz.com/PureLVSORT_430.zip
There are two versions in the archive : PureLVSORT (standard) and PureLVSORT-Plus ; the plus version adds some basic listicon editing functions.
PB4.4x : http://gnozal.ucoz.com/PureLVSORT_440.zip
There are two versions in the archive : PureLVSORT (standard) and PureLVSORT-Plus ; the plus version adds some basic listicon editing functions.
PB4.5x : http://gnozal.ucoz.com/PureLVSORT_450.zip
There are two versions in the archive : PureLVSORT (standard) and PureLVSORT-Plus ; the plus version adds some basic listicon editing functions.
PB4.6x : http://gnozal.ucoz.com/PureLVSORT_460.zip
There are two versions in the archive : PureLVSORT (standard) and PureLVSORT-Plus ; the plus version adds some basic listicon editing functions.
PB5.0x : http://gnozal.ucoz.com/PureLVSORT_500.zip
There are two versions in the archive : PureLVSORT (standard) and PureLVSORT-Plus ; the plus version adds some basic listicon editing functions.
PB5.1x : http://gnozal.ucoz.com/PureLVSORT_510.zip
There are two versions in the archive : PureLVSORT (standard) and PureLVSORT-Plus ; the plus version adds some basic listicon editing functions.

Notes :
1. The PureLVSORT sorting functions are designed for a multicolumn gadget. If your listicongadget has only one column, add a zero length column or use the #LVS_SORT* styles.
2. PureLVSORT uses the Windows #LVM_SORTITEMS message to sort the listicongadget, and this implies using LV_ITEM\lParam (so the sorting is not compatible with Set/GetGadgetItemData(), or the other way round : the Purebasic listicongadget is not 100% Windows API compatible : it's not a simple SysListView32).

_________________
For tools, jaPBe plugins and libs, visit http://gnozal.ucoz.com/


Last edited by gnozal on Tue Aug 18, 2009 11:50 am, edited 55 times in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 30, 2004 3:31 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Apr 25, 2003 11:08 pm
Posts: 467
gnozal,

Your library is GREAT! I've been trying (unsuccessfully) to do this for a while.

Can I make a suggestion? Please consider changing the column sort indicator from "<< HEADER >>" and ">> HEADER <<" to something with up and down arrows, like "HEADER ^" and "HEADER v". I think this makes it easier to understand the sort direction.

Regards,
Eric


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 30, 2004 3:47 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 25, 2004 2:15 pm
Posts: 727
Location: Spain
8O 8O 8O Great library!!!

A suggestion, can you add an option to it so that it does not order a column? (will be:
Code:
PureLVSORT_LockColumn(#ListIcon_0, Num_Col_Locked)


See This "ListIcon" :oops:
Code:
SERVER | BackupName    | State |
----------------------------------------
 Serv1  | S1_WeekA      | Ok    |
       | S1_DailyA     | Ok    |
       | S1_DailyB     | Fail  |
       | S1_DailyC     | Ok    |


I want to maintain "Serv1" (Col "SERVER") always in the first row.


Thank you!


PD: Sorry for my bad bad english
:?

_________________
PB 5.7x, PureVision User.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 30, 2004 4:37 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
ebs wrote:
Can I make a suggestion? Please consider changing the column sort indicator from "<< HEADER >>" and ">> HEADER <<" to something with up and down arrows, like "HEADER ^" and "HEADER v". I think this makes it easier to understand the sort direction.


I will have this in mind for the next version (it will be optional)

Quote:
A suggestion, can you add an option to it so that it does not order a column? (will be: PureLVSORT_LockColumn(#ListIcon_0, Num_Col_Locked)


I will take a look how to do this for the next version.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 06, 2004 9:17 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Library update

- new options for PureLVSORT_SelectGadgetToSort(GadgetNumber.l, ShowClickedHeader.l)
Code:
ShowClickedHeader :   #PureLVSORT_ShowClickedHeader_No
                      #PureLVSORT_ShowClickedHeader_Text
                      #PureLVSORT_ShowClickedHeader_Icon

- new flag for PureLVSORT_SetColumnType(GadgetNumber.l, Column.l, ColumnType.b)
Code:
#PureLVSORT_NoSorting ; column is locked (no sorting after a LVN_COLUMNCLICK event)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 06, 2004 6:34 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Apr 25, 2003 11:08 pm
Posts: 467
gnozal,

I just tried your new version - thanks for the fast turnaround!

The sort direction icon looks good. A few more requests, if I'm not being too pushy: Consider making the up/down icons user-defined, so I can use different icons. Also, allowing the user to specify that the icon should appear before or after the header text would be handy.

The #PureLVSORT_NoSorting sort option seems to be missing from the resident file. It does prevent the specified column from being sorted when its header is clicked. However, I think that zikitrake was asking for a column that would always stay the same, no matter which column header was clicked. Let me know if I've got it wrong.

Regards,
Eric


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 07, 2004 8:53 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
@ebs : thanks, I will see for the next version.
A column that would always stay the same, no matter which column header was clicked : I don't think it's logical :?:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 07, 2004 11:27 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 25, 2004 2:15 pm
Posts: 727
Location: Spain
ebs wrote:
gnozal,
... However, I think that zikitrake was asking for a column that would always stay the same, no matter which column header was clicked. Let me know if I've got it wrong.
Regards,
Eric


It is as ebs says

Yes!, gnozal, I know that it can seem illogical, but for my project I need that it is thus.

:oops: :oops: Sorry for my bad english

_________________
PB 5.7x, PureVision User.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 07, 2004 3:36 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:51 pm
Posts: 2809
Location: Portugal, Lisbon
BUG!!!

Seems that you must define further images with values bigger than 1 or you'll corrupt the internal icons from PureLVSORT_SelectGadgetToSort(#Gadget_main_ListIcon8, #PureLVSORT_ShowClickedHeader_Icon) ...

Here's an example!

Code:
;/ Created with PureVisionXP v2.03
;/ Tue, 07 Dec 2004 14:00:35
;/ by Rui Carvalho


;-Global Variables and Constants
Global BubbleTipStyle.l:BubbleTipStyle=0
#PB_Image_BorderRaised =$1

;-Window Constants
Enumeration 1
  #Window_main
EndEnumeration
#WindowIndex=#PB_Compiler_EnumerationValue


;-Gadget Constants
Enumeration 1
  ;Window_main
 
  #Gadget_main_Panel2
  #Gadget_main_Tab
  #Gadget_main_ListIcon8
 
EndEnumeration

#Image_main_Tab=0 ;<-- 0 or 1 will make

#GadgetIndex=#PB_Compiler_EnumerationValue

If CreateImage(#Image_main_Tab,16,16)
  StartDrawing(ImageOutput())
  For a=1 To 200
    Plot(Random(16),Random(16))
  Next
EndIf

;-StatusBar Constants
Enumeration 1
  #StatusBar_main
  #StatusBar_main_info1 =0
  #StatusBar_main_info2 =1
EndEnumeration
#StatusBarIndex=#PB_Compiler_EnumerationValue


Procedure.l Window_main()
  If OpenWindow(#Window_main,118,110,614,294,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible,"example")
  If CreateGadgetList(WindowID(#Window_main))
      PanelGadget(#Gadget_main_Panel2,0,5,615,250)
      AddGadgetItem(#Gadget_main_Panel2,-1,"<empty>",UseImage(#Image_main_Tab))
      ListIconGadget(#Gadget_main_ListIcon8,0,10,610,215,"client #",100,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
      AddGadgetColumn(#Gadget_main_ListIcon8,1,"reference #",200)
      AddGadgetColumn(#Gadget_main_ListIcon8,2,"invoice #",90)
      AddGadgetColumn(#Gadget_main_ListIcon8,3,"value",110)
      AddGadgetColumn(#Gadget_main_ListIcon8,4,"date",80)
      CloseGadgetList()
      CreateStatusBar(#StatusBar_main,WindowID(#Window_main))
      AddStatusBarField(200)
      AddStatusBarField(300)
      HideWindow(#Window_main,0)
      ProcedureReturn WindowID()
    EndIf
  EndIf
EndProcedure

Global Color1.l, Color2.l, Tab_Count.l

Color1=RGB(224,235,255)
Color2=RGB(255,255,255)


Procedure WindowCallBack(WindowId,Message,wParam,lParam)
  ReturnValue=#PB_ProcessPureBasicEvents
 
  ReturnValue = PureLVSORT_CallBack(WindowId, Message, wParam, lParam, ReturnValue)
  ReturnValue = PureCOLOR_CallBack(WindowId, Message, wParam, lParam, ReturnValue)
 
  ProcedureReturn ReturnValue
EndProcedure

;-Main Loop
If Window_main()
 
  PureCOLOR_SetGadgetColorEx(#Gadget_main_ListIcon8, RGB(0,0,0), Color1, Color2, #PureCOLOR_LV_AlternateColors)
 
  If PureLVSORT_SelectGadgetToSort(#Gadget_main_ListIcon8, #PureLVSORT_ShowClickedHeader_Icon) = #PureLVSORT_Ok
    PureLVSORT_SetColumnType(#Gadget_main_ListIcon8, 0, #PureLVSORT_Numeric)
    PureLVSORT_SetColumnType(#Gadget_main_ListIcon8, 1, #PureLVSORT_Numeric)
    PureLVSORT_SetColumnType(#Gadget_main_ListIcon8, 2, #PureLVSORT_Numeric)
    PureLVSORT_SetColumnType(#Gadget_main_ListIcon8, 3, #PureLVSORT_String)
    PureLVSORT_SetColumnType(#Gadget_main_ListIcon8, 4, #PureLVSORT_DateDDMMYYYY)
  EndIf
 
  SetWindowCallback(@WindowCallBack())

  For a=1 To 100
    AddGadgetItem(#Gadget_main_ListIcon8,-1,Str(Random(150000)))
  Next
 
  quitmain=0
  Repeat
    EventID=WaitWindowEvent()
    Select EventID
      Case #PB_Event_CloseWindow
        If EventWindowID()=#Window_main
          quitmain=1
        EndIf
       
      Case #PB_Event_Menu
       
      Case #PB_Event_Gadget
        Select EventGadgetID()
          Case #Gadget_main_Tab
          Case #Gadget_main_ListIcon8
            Select EventType()
              Case #PB_EventType_LeftDoubleClick
              Case #PB_EventType_RightDoubleClick
              Case #PB_EventType_RightClick
              Default
            EndSelect
        EndSelect
       
    EndSelect
  Until quitmain
  CloseWindow(#Window_main)
EndIf
End

_________________
Elevator Maintenance: http://central-elevadores.pt
Good web hosting![/size]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 07, 2004 5:00 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Sorry :oops:
I forgot about this : the icons are images #0 and #1.
I will see what I can do to not interfere with the main program


Last edited by gnozal on Wed Dec 08, 2004 5:06 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 07, 2004 8:23 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Apr 25, 2003 11:08 pm
Posts: 467
gnozal,
Quote:
I forgot about this : the icons are images #0 and #1.

I realize you don't want to interfere with the main program, but having known image numbers would allow me to use my own up/down icons. If you do change it to use #PB_Any (or some other method), consider either providing the image ID numbers or a function call that I can use to change the images.

Regards,
Eric


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 08, 2004 8:39 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Library update

- fixed : missing constants in resident file
- fixed : image number problem
- added : flags #PureLVSORT_ShowClickedHeader_IconLeft and #PureLVSORT_ShowClickedHeader_IconRight

To do :
- user defined icons
- locked column


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 08, 2004 10:15 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:51 pm
Posts: 2809
Location: Portugal, Lisbon
Hurray!!!

:lol:

_________________
Elevator Maintenance: http://central-elevadores.pt
Good web hosting![/size]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 08, 2004 12:17 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1542
Location: In a long distant galaxy
thanx a lot for your two libs. i make great use of them !

just a little bug :

when you specified a center or right alignment in the LV, then,
the sorting process of your lib reset the alignment to the left by default.

_________________
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 09, 2004 2:20 am 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1542
Location: In a long distant galaxy
i think you have to read and store the listview 'styles' before processing it with your code...

_________________
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 439 posts ]  Go to page 1, 2, 3, 4, 5 ... 30  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye