Recent

Author Topic: extending features for TListView  (Read 1106 times)

hennerd

  • Newbie
  • Posts: 6
extending features for TListView
« on: November 20, 2021, 03:25:32 pm »
Hello,

when porting a Delphi application to Lazarus, I was confronted with some missing features in LCL's TListView: Grouping of items was missing and custom drawing behaved differently.

I implemented the features needed for my application, first in Win32 interface, and then when porting the app to MacOS also in Qt5 and Cocoa. The result can be seen in the attached patch (should be applied to Lazarus main branch) and in the attached test application. Also I attach some screenshots of this app under Windows (Win32 and Qt5) and MacOs (Cocoa).

Summary of the changes:
1. Custom Drawing: In Delphi it is possible to change the font and brush of the canvas in OnAdvancedCustomDrawXXXXX events, in the pre-paint stage and return DefaultDraw = True. Then the item (or subitem) is (default)-drawn with the specified font and brush.
With my patch this will work with LCL TCustomListView in Win32, Qt5 and Cocoa for font changes. Brush changes are not fully implemented yet. Before, changing the font and brush had no effect in LCL.

2. Grouping:
I implemented and verified this functionality only for ViewStyle vsReport. On Win32 grouping is managed through the appropriate Win32 API functions similar to Delphi. In Qt5 I mapped the group items to top level items of the QTreeWidget and the actual list items are child items to the group items. Groups can be collapsed and expanded by double-clicks. In Cocoa I needed to activate the view-based NSTableView, the cell-based one did not seem to be flexible enough. The NSTableView will have a flat list of rows, some rows will be group rows. TListItem indexes need to be translated to the absolute table rows and vice versa. I also implemented expanding and collapsing groups by double-clicking (although this will work now only from MacOs 10.11 and above.)

3. Item Indent: Items can be indented on Win32 and Cocoa.

Probably there are still many bugs and things may not work as expected in all possible use cases.
But I hope that this can serve as a base for further development and that one day this could get integrated into LCL.

Henner

hennerd

  • Newbie
  • Posts: 6
Re: extending features for TListView
« Reply #1 on: November 20, 2021, 03:26:45 pm »
and the promised screenshots...

 

TinyPortal © 2005-2018