PureLVSORT library : sorting ListIconGadgets (and more)

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

Moderator: gnozal

User avatar
bobobo
Enthusiast
Enthusiast
Posts: 202
Joined: Mon Jun 09, 2003 8:30 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by bobobo »

that's cool :D

thank you

now i have to look to receive the coords of each listiconfield
사십 둘 .
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by IdeasVacuum »

Hi gnozal

Using:
SendMessage_(GadgetID(#MyListIcon), #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_GRIDLINES, #LVS_EX_GRIDLINES)

Over-rules the PB attribute:
SetGadgetColor(#MyListIcon,#PB_Gadget_LineColor,RGB(127,157,185))

So, could we have:
PureCOLOR_SetGadgetLineColor(#MyListIcon,RGB(127,157,185))

or:
PureLVSORT_LineColor(#MyListIcon,RGB(127,157,185))

The default MS Windows line colour is almost impossible to see (for some of us at least) :)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
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 »

IdeasVacuum wrote:...
So, could we have:
PureCOLOR_SetGadgetLineColor(#MyListIcon,RGB(127,157,185))
or:
PureLVSORT_LineColor(#MyListIcon,RGB(127,157,185))
The default MS Windows line colour is almost impossible to see (for some of us at least) :)
I am afraid that is not going to happen, as these libraries do not "ownerdraw" the listicon like pb does.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
bobobo
Enthusiast
Enthusiast
Posts: 202
Joined: Mon Jun 09, 2003 8:30 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by bobobo »

there is on eissue concerning the editingmode.
Maybe a kind of bug.

In my efforts to incorporate a keyboardcontrolling to a ListIconGadget
a stumbled on this.
Editing with DEL-KEY does not update the TEXT in the callback at once
like other editinputs do.
This is a little bit annoying because i have to manage the editstate when exiting
the editmode with up or down arrow to switch to the next field.
I need the correct edited value to write it immediately into a database when changed
(left and right-arrow are not considered)

Here some code to test. Arrowing up and down in editmode does work.
The recognition of changed values (when up or down) depends on the last editinput.
DEL is not recognized.
Leaving the EditMode with ENTER is ok in this case.

Code: Select all

;
; List
EnableExplicit

Enumeration ;window
  #win
EndEnumeration

Enumeration ;gadgets
  #b_Get
  #b_Quit
  #Li  
EndEnumeration


Enumeration ;shortcuts menu
  #sk_down
  #sk_up
  
EndEnumeration

Global.l celly, cellx, cellheight, celltop, cellleft, cellmaxrow, celledited, celleditmode
Global.s celltextedit, celltext

Procedure LvFilterCallback(LV.l, Filterstring.s, Column.l, Event.l) ; simple search example
  Protected itemNumber.l, I.l
  If Filterstring
    itemNumber = -1
    If IsGadget(LV)
      For I = 0 To CountGadgetItems(LV) - 1 
        If FindString(UCase(GetGadgetItemText(LV, I, Column)), UCase(FilterString),0) 
          itemNumber = I
          Break
        EndIf
      Next 
      If itemNumber <> -1 ; if string found, scroll to row
        PureLVSORT_ScrollToRow(LV, itemNumber)
        PureCOLOR_SetCellColor(LV, itemnumber,Column,#Blue,$FFDEAD)
      EndIf
    EndIf
  EndIf
EndProcedure

Procedure.l LvEditCallback(Event.l, ListIconNumber.l, Column.l, Row.l, Text.s)
  Select Event
    Case #PureLVSORT_EditStart
      Debug "Edit Start"
      celltext=GetGadgetItemText(ListIconNumber,row,column)
      Debug "edt_start :"+celltext
      celleditmode=1
      ; Return  :	- 0 to enable stringgadget (default)
      ; 		- *string to enable a spingadget [the string holds the choice items (separator = '|']
    Case #PureLVSORT_EditText
      Debug "Edit Text"
      celltextedit=text
      celledited+1
      Debug "edt_edit :"+celltextedit
      ;Debug "im callback "+celltextedit
      ;         ; Return  :	- 0 to keep the text (default)
      ;         ; 		- *string to change the text [the string holds the changed text]
    Case #PureLVSORT_EditEnd
      Debug "Edit End"
      If celledited
        If celltext<>celltextedit
          Debug "-----------------"
          Debug "     down before :"+celltext
          Debug "     down after:"+celltextedit
          Debug "     Ok can be written"
          Debug "-----------------"
        EndIf
        
        celledited=0
        celltextedit=""
        celltext=""
        celleditmode=0
      EndIf
      
    Case #PureLVSORT_EditEscape
      Debug "Edit ESC"
      celleditmode=0
  EndSelect
EndProcedure

Procedure reload()
  Define cols=5,c, r, rows=10 , i , tmp.s, out.s
  HideGadget(#Li,1)
  ClearGadgetItems(#Li)
  
  While GetGadgetItemText(#Li, -1); , 0)
    RemoveGadgetColumn(#Li,0)
  Wend
  RemoveGadgetColumn(#Li,0)
  
  For c=0 To cols
    tmp="Column "+Str(c)
    AddGadgetColumn(#li,c,tmp,20)
  Next c
  tmp=""
  
  For r=0 To rows
    For c=0 To cols
      For i=1 To 5
        tmp+Chr(Random(25)+97)
      Next i
      out+tmp+Chr(10)
      tmp=""
    Next c
    AddGadgetItem(#Li,-1,out)
    out=""
  Next r
  
  PureLVSORT_SelectGadgetToSort(#Li,#PureLVSORT_ShowClickedHeader_No)
  PureLVSORT_DefineFilterCallback(@LvFilterCallback())
  PureLVSORT_SetFilterTimeOut(100)
  PureLVSORT_SetFilter(#Li)
  
  For c=0 To 10
    PureLVSORT_SetColumnWidth(#Li,c,#PureLVSORT_UseHeader)
  Next c
  
  PureLVSORT_SetFilter(#Li)
  
  PureLVSORT_SetFilterTimeOut(25)
  PureLVSORT_DefineFilterCallback(@LvFilterCallback())
  For c=0 To 10-1
    PureLVSORT_MakeColumnEditable(#Li,c,#True)
  Next c
  
  PureLVSORT_SetEditingCallback(@LvEditCallback())
  PureLVSORT_SetEditingColors(RGB(255,222,192),#PureCOLOR_SystemColor)
  HideGadget(#Li,0)
  cellmaxrow=CountGadgetItems(#Li)-1
EndProcedure

Procedure LvMouseClick(GId.i, *vP.Point)
  
  Define vID=GadgetID(GId)
  
  Protected pLVH.LVHITTESTINFO
  
  GetCursorPos_   (*vP)  ;wo ist Maus 
  MapWindowPoints_(0, vID, *vP, 1)
  pLVH\pt\x = *vP\x
  pLVH\pt\y = *vP\y
  SendMessage_(vID, #LVM_SUBITEMHITTEST, 0, pLVH)                
  *vP\y = pLVH\iItem      ;row ab 0
  *vP\x = pLVH\iSubItem   ;col ab 0
  celly=*vP\y
  cellx=*vP\x
  ; --- Ergänzung
  Protected rec.RECT , i
  SendMessage_(vid, #LVM_GETSUBITEMRECT, *vp\y, rec)
  rec\left=0
  rec\right=rec\left+GetGadgetItemAttribute(GId,-1,#PB_ListIcon_ColumnWidth,0)
  If *vP\x >0
    For i=1 To *vP\x
      rec\left+GetGadgetItemAttribute(GId,-1,#PB_ListIcon_ColumnWidth, i-1)
      rec\right=rec\left+GetGadgetItemAttribute(GId,-1,#PB_ListIcon_ColumnWidth,i)
    Next
  EndIf
  
  cellheight= rec\bottom-rec\top
  celltop  = rec\top+1
  cellleft = rec\left+1
EndProcedure

ExamineDesktops()
;window, gadgets
Define.l dw=DesktopWidth(0)
Define.l dh=DesktopHeight(0)
Define.l wx,ww,wy,wh
Define.l c
Define p.Point

;events
Define.l event,eventtype,gadget,Menu

Define.l quit

ww=500
wh=500
wx=100;dw/2-ww/2
wy=100;dh/2-wh/2

OpenWindow(#win,wx,wy,ww,wh,"Schaumerma",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget)
ButtonGadget(#b_Get,0,0,50,20,"reload")
ListIconGadget(#Li,0,20,ww,wh-20,"this",20,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
HideGadget(#Li,1)

AddKeyboardShortcut(#Win,#PB_Shortcut_Down,#sk_down)
AddKeyboardShortcut(#Win,#PB_Shortcut_Up,#sk_up)

reload()
Define.s Info.s= "Enter Editingmode by doubleclicking (L) one field."+#CRLF$
Info+"Typing on the keyboard will change the TEXT in the Callback accordingly"+#CRLF$
Info+"Only DEL has some kind of ''delay''"+#CRLF$+#CRLF$
Info+" Run in IDE with debug on"

MessageRequester("",Info)

Repeat
  event=WaitWindowEvent()
  eventtype=EventType()
  menu=EventMenu()
  gadget=EventGadget()
  
  Select event
      
    Case #PB_Event_Gadget
      Select gadget
        Case #b_get
          reload()
        Case #Li
          Select eventtype
            Case #PB_EventType_LeftDoubleClick
              LvMouseClick(#Li, p)
              Debug "Mouse celltop "+Str(celltop)
              Debug "Mouse cellheight "+Str(cellheight)
              Debug "Mouse Col "+Str(cellx)
              Debug "Mouse Row "+Str(celly)
              
          EndSelect
      EndSelect
      
    Case #PB_Event_Menu
      
      Select menu
        Case #sk_down
          ;one down
          If celleditmode
            If celledited
              If celltext<>celltextedit
                Debug "-----------------"
                Debug "     down before :"+celltext
                Debug "     down after:"+celltextedit
                Debug "     Ok can be written"
                Debug "-----------------"
              EndIf
              
              celledited=0
              celltextedit=""
              celltext=""
            EndIf
            If celly <= cellmaxrow-1  
              celltop+cellheight
              celly+1
              Debug "celltop "+Str(celltop)+" cellheight "+Str(cellheight)+" Col "+Str(cellx)+" Row "+Str(celly)
              PostMessage_(GadgetID(#Li), #WM_LBUTTONDBLCLK, 0, cellleft| (celltop <<16)) ;<---- double click on x = 12 y = 42 (mouse coordinates)
              
            EndIf
          EndIf
        Case #sk_up
          ;up one up
          If celleditmode
            If celledited
              If celltext<>celltextedit
                Debug "-----------------"
                Debug "     down before :"+celltext
                Debug "     down after:"+celltextedit
                Debug "     Ok can be written"
                Debug "-----------------"
              EndIf
              celledited=0
              celltextedit=""
              celltext=""
            EndIf
            
            If celly >=0+1
              
              celltop-cellheight
              celly-1
              Debug "celltop "+Str(celltop)+" cellheight "+Str(cellheight)+" Col "+Str(cellx)+" Row "+Str(celly)
              
              PostMessage_(GadgetID(#Li), #WM_LBUTTONDBLCLK, 0, cellleft| (celltop <<16)) ;<---- double click on x = 12 y = 42 (mouse coordinates)
            EndIf
          EndIf
          
      EndSelect
      
    Case #PB_Event_CloseWindow
      quit+1
  EndSelect
  
Until quit

End
사십 둘 .
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 »

bobobo wrote:there is on eissue concerning the editingmode.
Maybe a kind of bug.
Hi,
I have uploaded a new library version : http://gnozal.ucoz.com/PureLVSORT_460.zip
Could you test it ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
bobobo
Enthusiast
Enthusiast
Posts: 202
Joined: Mon Jun 09, 2003 8:30 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by bobobo »

i will check it tomorrow , thanks :-)
사십 둘 .
User avatar
bobobo
Enthusiast
Enthusiast
Posts: 202
Joined: Mon Jun 09, 2003 8:30 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by bobobo »

:D it works now

the code in http://www.purebasic.fr/english/viewtop ... 73#p394573
is working now

So somekind of Keyboard-controlling with Your PureLVSort enhanced-Lib can be done.

Splendid !!!
사십 둘 .
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 »

Library updated for PB5.1x
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
bobobo
Enthusiast
Enthusiast
Posts: 202
Joined: Mon Jun 09, 2003 8:30 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by bobobo »

yipee :lol:
사십 둘 .
loulou
User
User
Posts: 38
Joined: Tue Dec 08, 2009 7:42 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by loulou »

Hi all,
There is a problem with PB 5.20 and library misc . Is there a new version ?
Thanks on advance
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by davido »

The commands are all still available but have been moved to more appropriate places.

ElapsedMilliseconds() has been moved to System, for instance.

So you should still be able to find them all.
DE AA EB
karu
Enthusiast
Enthusiast
Posts: 255
Joined: Fri Jan 13, 2006 12:14 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by karu »

Hi, can some tell me, how i can select whole text in cell after i double clicked on it, if i use PureLVSORT_MakeColumnEditable function.

Thanks
Karu
karu
Enthusiast
Enthusiast
Posts: 255
Joined: Fri Jan 13, 2006 12:14 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by karu »

karu wrote:Hi, can some tell me, how i can select whole text in cell after i double clicked on it, if i use PureLVSORT_MakeColumnEditable function.

Thanks
Karu
Anybody?
AMpos
Enthusiast
Enthusiast
Posts: 128
Joined: Fri Jun 05, 2020 12:47 am

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by AMpos »

I need this library :o but it seems the server is gone... :(

Does some one has it? Would it work in current PB version?
User avatar
leonhardt
Enthusiast
Enthusiast
Posts: 220
Joined: Wed Dec 23, 2009 3:26 pm

Re: PureLVSORT library : sorting ListIconGadgets (and more)

Post by leonhardt »

AMpos wrote:I need this library :o but it seems the server is gone... :(

Does some one has it? Would it work in current PB version?
https://www.rsbasic.de/backups/,Hey AMpos,take a look at this. But it seems doesn't work on PB5.7+
poor English...

PureBasic & Delphi & VBA
Post Reply