[Modules] ListEx (all OS / DPI)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

[Modules] ListEx (all OS / DPI)

Post by Thorsten1867 »

ListEx Gadget - Module (all OS / DPI / 64Bit)
  • Gadget: #GridLines / #NoRowHeader / #NumberedColumn (= Column 0 with line numbers)
  • Support of images with/without text or for buttons
  • editable columns (Strings/CheckBoxes/ComboBoxes/DateGadgets)
  • Columns with events (Buttons / Links / Header-Click)
  • Sortable columns (String / Integer / Float / Date / Birthday / Time / Money)
  • Sorted according to German rules (encyclopedia or telephone book)
  • Sort by header click (#SortArrows / #SwitchDirection)
  • Automatically reduces the size of a defined column when the horizontal scroll bar becomes visible
  • Labels for columns for easier query
  • Data (Integer) and ID (String) can be specified for each list line
  • automatic size adjustment to window (#MoveX|#MoveY|#ResizeWidth|#ResizeHeight)
Image

Code: Select all

; ListEx::AddCells()                - adds a new row and insert text in cells with label
; ListEx::AddColumn()               - similar to 'AddGadgetColumn()'
; ListEx::AddComboBoxItems()        - add items to the comboboxes of the column (items seperated by #LF$)
; ListEx::AddItem()                 - similar to 'AddGadgetItem()'
; ListEx::CountItems()              - similar to 'CountGadgetItems()' [#Selected/#Checked/#Inbetween]
; ListEx::ChangeCountrySettings()   - change default settings
; ListEx::ClearComboBoxItems()      - clear items of the comboboxes of the column
; ListEx::ClearItems()              - similar to 'ClearGadgetItems()'
; ListEx::ClipBoard()               - copy selected items to clipboard (CSV)
; ListEx::DisableEditing()          - disable editing for the complete list
; ListEx::DisableReDraw()           - disable redraw
; ListEx::EventColumn()             - column of event (Event: ListEx::#Event_Module)
; ListEx::EventRow()                - row of event    (Event: ListEx::#Event_Module)
; ListEx::EventState()              - returns state   (e.g. CheckBox / DateGadget)
; ListEx::EventValue()              - returns value   (string)
; ListEx::EventID()                 - returns row ID or header label 
; ListEx::ExportCSV()               - export CSV-file from list
; ListEx::Gadget()                  - [#GridLines|#NumberedColumn|#NoRowHeader]
; ListEx::GetAttribute()            - similar to 'GetGadgetAttribute()'
; ListEx::GetCellText()             - similar to 'GetGadgetItemText()' with labels
; ListEx::GetCellState()            - similar to 'GetGadgetItemState()' with labels
; ListEx::GetChangedState()         - check whether entries have been edited
; ListEx::GetColumnAttribute()      - similar to 'GetGadgetItemAttribute()'
; ListEx::GetColumnFromLabel()      - returns column number for this label
; ListEx::GetColumnLabel()          - returns the label of the column
; ListEx::GetColumnState()          - similar to 'GetGadgetItemState()' for a specific column
; ListEx::GetItemData()             - similar to 'GetGadgetItemData()'
; ListEx::GetItemID()               - similar to 'GetGadgetItemData()' but with string data
; ListEx::GetItemState()            - similar to 'GetGadgetItemState()' [#Selected/#Checked/#Inbetween]
; ListEx::GetItemText()             - similar to 'GetGadgetItemText()'
; ListEx::GetRowFromLabel()         - returns row number for this label
; ListEx::GetRowLabel()             - returns the label of the row
; ListEx::GetState(GNum.i)          - similar to 'GetGadgetState()'
; ListEx::Hide()                    - similar to 'HideGadget()', but disables redrawing of the canvas gadget
; ListEx::HideColumn()              - hides a column
; ListEx::ImportCSV()               - import CSV-file to list
; ListEx::Refresh()                 - redraw gadget
; ListEx::RemoveCellFlag()          - removes a flag
; ListEx::RemoveColumn()            - similar to 'RemoveGadgetColumn()'
; ListEx::RemoveColumnFlag()        - removes a column flag
; ListEx::RemoveFlag()              - removes a gadget flag
; ListEx::RemoveItem()              - similar to 'RemoveGadgetItem()'
; ListEx::RemoveItemState()         - removes #Selected / #Checked / #Inbetween
; ListEx::ResetChangedState()       - reset to not edited
; ListEx::SelectItems()             - select all rows [#All/#None]
; ListEx::SetAttribute()            - similar to SetGadgetAttribute()  [#Padding] 
; ListEx::SetAutoResizeColumn()     - column that is reduced when the vertical scrollbar is displayed.
; ListEx::SetAutoResizeFlags()      - [#MoveX|#MoveY|#Width|#Height]
; ListEx::SetCellFlags()            - [#LockCell|#Strings|#ComboBoxes|#Dates]
; ListEx::SetCellState()            - similar to 'SetGadgetItemState()' with labels
; ListEx::SetCellText()             - similar to 'SetGadgetItemText()'  with labels
; ListEx::SetColor()                - similar to 'SetGadgetColor()'
; ListEx::SetColorTheme()           - change the color theme
; ListEx::SetColumnAttribute()      - [#Align/#ColumnWidth/#Font]
; ListEx::SetColumnFlags()          - [#FitColumn | #Left/#Right/#Center]
; ListEx::SetColumnState()          - similar to 'SetGadgetItemState()' for a specific column
; ListEx::SetCurrency()             - 
; ListEx::SetDateMask()             - similar to 'SetGadgetText()' and 'DateGadget()'
; ListEx::SetDateAttribute()        - similar to 'SetGadgetAttribute()' and 'DateGadget()'
; ListEx::SetFlags()                - set gadget flags
; ListEx::SetFont()                 - similar to 'SetGadgetFont()'
; ListEx::SetHeaderAttribute()      - [#Align]
; ListEx::SetHeaderHeight()         - set header height
; ListEx::SetHeaderSort()           - enable sort by header column [#Sort_Ascending|#Sort_Descending|#Sort_NoCase|#Sort_SwitchDirection]
; ListEx::SetItemAttribute()        - similar to 'SetGadgetItemAttribute()'
; ListEx::SetItemColor()            - similar to 'SetGadgetItemColor()'
; ListEx::SetItemData()             - similar to 'SetGadgetItemData()'
; ListEx::SetItemFont()             - change font of row or header [#Header]
; ListEx::SetItemID()               - similar to 'SetGadgetItemData()' but with string data
; ListEx::SetItemImage( )           - add a image at row/column
; ListEx::SetItemState()            - similar to 'SetGadgetItemState()' [#Selected/#Checked/#Inbetween]
; ListEx::SetItemText()             - similar to 'SetGadgetItemText()'
; ListEx::SetProgressBarAttribute() - set minimum or maximum value for progress bars
; ListEx::SetProgressBarFlags()     - set flags for progressbar (#ShowPercent)
; ListEx::SetRowsHeight()           - change height of rows
; ListEx::SetTimeMask()             - change mask for time (sorting)
; ListEx::Sort()                    - sort rows by column [#SortString|#SortNumber|#SortFloat|#SortDate|#SortBirthday|#SortTime|#SortCash / #Deutsch]
Download: ListExModule.pbi
Last edited by Thorsten1867 on Fri Dec 20, 2019 3:24 pm, edited 15 times in total.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
blueb
Addict
Addict
Posts: 1037
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: [Modules] Editable and sortable ListGadget (Beta)

Post by blueb »

Thanks Thorsten.

I'm just in the beginning stages of coding a game that needs to maintain
a grid for player and game stats... this well laid-out List gadget will be a
welcome addition. :D

PS -No problems with Demo using Win 10 Pro (x64) and PB 5.70 (x86)
- It was too lonely at the top.

System : PB 6.10 Beta 7 (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (Beta)

Post by Thorsten1867 »

Added: Resize Handle with autoresize defined column (minWidth/maxWidth)
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [Modules] Editable and sortable ListGadget (Beta)

Post by Little John »

Very useful, many thanks for sharing!
Obviously, this was a lot of work.

One important information is missing in the first post here:
Source code wrote:All OS
:-)

Much appreciated.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

Added: Link with pop-up menu possible
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Cyllceaux
Enthusiast
Enthusiast
Posts: 457
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Cyllceaux »

Really nice Work. :D

But Can't use it, cause of DPI.

Image


(It's the Problem of ALL Canvas-Based Gadgets)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by srod »

Cyllceaux wrote:...It's the Problem of ALL Canvas-Based Gadgets
I don't see that at all. Fonts are automatically scaled so it is just a case of using the current DPI scale factor alongside the available text metric functions to lay out the content appropriately. Aside from a lack of support for per-monitor DPI awareness, there are no real issues with the canvas gadget aside from having to put in a little more effort as PB cannot possibly scale all the content automatically. I have a substantial cross-platform grid control in development and it is behaving itself fine with regards DPI, although PB support for DPI awareness is somewhat limited right now.

@Thorsten : there seems to be massive flicker when dragging a horizontal scrollbar after I resize things to make the scrollbars visible. The client area seems to 'jump' about a bit. If you are editing a cell and move the vertical scrollbar, the string gadget can get left behind. Also, the various child controls occasionally overlay the scrollbars. All 'classic' problems when embedding child controls in a grid control - I should know as I had to contend with all of these problems with my original EsGRID control! :) Win 7x64, PB 5.70.
I may look like a mule, but I'm not a complete ass.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Kwai chang caine »

Really usefull gadget missing in PB :shock:
Thanks a lot for sharing 8)

Do you think it's possible to use it a day, like VirtualListIcon for load very quickly thousand of lines ?
viewtopic.php?p=513256#p513256
The first problem surely is lost the "all OS" side :|

Code: Select all

IncludeFile "ListExModule.pbi"

#Window  = 0

Enumeration 1
 #List
EndEnumeration

If OpenWindow(#Window, 0, 0, 500, 250, "Window", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
 
 HeureDebut = ElapsedMilliseconds() 
 ListEx::Gadget(#List, 10, 10, 400, 230, "", 25, "", ListEx::#GridLines|ListEx::#NumberedColumn) ; ListEx::#NoRowHeader|ListEx::#NumberedColumn|ListEx::#CheckBoxes
 
 ListEx::AddColumn(#List, ListEx::#LastItem, "Lines",    275)
 ListEx::SetHeaderAttribute(#List, ListEx::#Align, ListEx::#Center)
 
 For i = 1 To 1000
  ListEx::AddItem(#List, ListEx::#LastItem, #LF$ + "Line number " + Trim(Str(i)))
 Next 
 
 ListEx::SetRowsHeight(#List, 22)
 TempPasser$ = StrF((ElapsedMilliseconds() - HeureDebut) / 1000) + " secondes"
 MessageRequester("Time elapsed",  TempPasser$)
  
 Repeat
  Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
  
EndIf
ImageThe happiness is a road...
Not a destination
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

  • Bugfixes
  • new flag: #SingleClickEdit
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

Kwai chang caine wrote:Do you think it's possible to use it a day, like VirtualListIcon for load very quickly thousand of lines ?
viewtopic.php?p=513256#p513256
The first problem surely is lost the "all OS" side :|
The reason for developing the module was that I needed a cross-platform solution.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Cyllceaux
Enthusiast
Enthusiast
Posts: 457
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Cyllceaux »

srod wrote:
Cyllceaux wrote:...It's the Problem of ALL Canvas-Based Gadgets
I don't see that at all. Fonts are automatically scaled so it is just a case of using the current DPI scale factor alongside the available text metric functions to lay out the content appropriately. Aside from a lack of support for per-monitor DPI awareness, there are no real issues with the canvas gadget aside from having to put in a little more effort as PB cannot possibly scale all the content automatically. I have a substantial cross-platform grid control in development and it is behaving itself fine with regards DPI, although PB support for DPI awareness is somewhat limited right now.
I don't say it is a bug of Canvas... It is a Problem of Canvas-Based Gadgets.

If I multiply the inner-width with 1.5 (I use a Surface with a 150% dpi scale), than the gadget looks right. Simple problem, simple solution. :wink: :D
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Thorsten1867 »

  • nasty bug fixed
  • added support for 'Tab' & 'Shift-Tab' in editable fields
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2050
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by Andre »

Very good work, and an impressive function-list... and cross-platform, thank you very much for sharing! :D

I still need to test it on MacOS... But on Win10 it works fine here, with one exception: there seems to a canvas drawing error, see the screenshot here: https://cdn1.imggmi.com/uploads/2019/3/ ... 7-full.jpg

Do you plan to make it working in Dialogs (with automatic resizing) too?
If not, it shouldn't be a big problem to use the List (canvas-gadget) as child of an (automatically) resizing container gadget, and react on the resize events... ;)
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
infratec
Always Here
Always Here
Posts: 6810
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by infratec »

Just tested your module: ThumpUp !!!

Then I took a look to avoid the json color files and found,
that in SetColor are some attributes missing.

HeaderFront.i
HeaderBack.i
HeaderGrid.i
ScrollBar.i

They are not inside. Please add these too.

Bernd
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: [Modules] Editable and sortable ListGadget (all OS)

Post by srod »

Still problems with horizontal scrolling. Problems also with combo cells. I am finding that when I edit one and then select another cell, the combo contents often disappear. Cannot reproduce this 100% consistently, though the following seems to do it most often : select the first combo cell and change contents to 'female'. Select another cell. Now double click the first combo cell again, do not change its contents and then double click another cell. The contents of the combo cell seem to be wiped.
I may look like a mule, but I'm not a complete ass.
Post Reply