View Issue Details

IDProjectCategoryView StatusLast Update
0027043LazarusLCLpublic2015-05-30 00:51
ReporterJuha Manninen Assigned ToZeljan Rikalo  
Status closedResolutionfixed 
Product Version1.3 (SVN) 
Summary0027043: TListView does not allow setting item height with GTK2 and QT
DescriptionThe list has icons which are drawn in CustomDrawItem.
It works on Windows by assigning the correct ImageList to SmallImages.
The same system is used in TTreeView. An item's height gets calculated from the icon size.

This does not work with GTK2 and QT on Linux. (I did not test iOS.)
Item height remains too small and parts of icons are cut off.
TCompPaletteOptionsFrame has good example code. The effect can be seen in environment options -> Component palette page.

See Additional Information for code snippets.
Additional InformationExample code from the component palette options :
Initially assigning an ImageList to SmallImages (method TCompPaletteOptionsFrame.Setup) :

  ComponentsListView.SmallImages := IDEImages.Images_24;

The CustomDrawItem handler :

procedure TCompPaletteOptionsFrame.ComponentsListViewCustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
  Comp: TRegisteredComponent;
  ARect: TRect;
  CurIcon: TCustomBitmap;
  Comp := TRegisteredComponent(Item.Data);
  ARect := Item.DisplayRect(drIcon);
  if Comp is TPkgComponent then begin
    CurIcon := TPkgComponent(Comp).Icon;
    if CurIcon<>nil then
      Sender.Canvas.Draw(ARect.Left+(25-CurIcon.Width) div 2,
               ARect.Top+(ARect.Bottom-ARect.Top-CurIcon.Height) div 2, CurIcon);
TagsNo tags attached.
Fixed in Revision46851,46853,47415,47418
WidgetsetGTK 2, QT
Attached Files


related to 0026770 closedZeljan Rikalo TListView: icons are too smaal on QT Linux 
related to 0028212 closedZeljan Rikalo TreeView item width set to -1 and do not show 


Zeljan Rikalo

2014-11-15 10:29

developer   ~0079158

Juha, please test Qt with r46851.

Juha Manninen

2014-11-15 11:14

developer   ~0079159

Works well, thanks.

Zeljan Rikalo

2014-11-15 11:41

developer   ~0079160

Please test and close if ok.
NOTE: IMO, this is not good way to paint TListView in cross platform way.Better would be to set OwnerDraw to true and use OnDrawItem() to completely draw icons and text.

Juha Manninen

2014-11-15 17:47

developer   ~0079164

Last edited: 2014-11-15 17:53

View 3 revisions

Sorry, I have to reopen.
Looking more carefully at the QT ListView, the icon and text are not aligned.
Text is higher than icon.
Also the gap between items is maybe 2 pix bigger than in Windows, and it appears too big. The Windows version is pretty much perfect in this respect.

IMO the GTK2 version did not change at all. Parts of the icons are still chopped off.

I attach screeshots from the 3 widgetsets. I used the Dialogs component page because those icons have a distinctive color occupying the whole area.

I also reverted the commit setting DefaultDraw:=False. Default drawing is needed for the text. Only icon is drawn in the handler. On Windows the text was gone as expected, but with GTK2 or QT it made no difference which is another bug in those widgetsets.

IMO this is a valid way to draw icons in ListView also cross-platform, if only it works with all widgetsets. Conceptually it should be OK as the icon dimensions are known and there is no ambiquity.
The same concept is used in TreeView.

Juha Manninen

2014-11-15 17:55


Dialogs_Windows.png (18,981 bytes)   
Dialogs_Windows.png (18,981 bytes)   

Juha Manninen

2014-11-15 17:56


Dialogs_QT.png (31,939 bytes)   
Dialogs_QT.png (31,939 bytes)   

Juha Manninen

2014-11-15 17:56


Dialogs_GTK2.png (23,138 bytes)   
Dialogs_GTK2.png (23,138 bytes)   

Zeljan Rikalo

2014-11-23 19:17

developer   ~0079315

I'm pretty surprised by your comments. All OnCustomXXXX and OnAdvancedXXX are specialized events for Delphi. So if you expect that it can look on all platforms same like treeview then you're wrong. I've already have solution for that listview: OwnerDraw=TRUE and OnDrawItem() , that should look same on all platforms, just like treeview.
About alignment of text in Qt: I know about it, but couldn't find solution yet.

Juha Manninen

2014-11-23 21:42

developer   ~0079320

Ok, I can try with OwnerDraw later.

Zeljan Rikalo

2014-11-24 08:57

developer   ~0079332

I don't have enough spare time, but it's really not big deal. You have ownerdraw example in examples/listview. btw. you removed DefaultDraw, but look at the code what DefaultDraw does, and how ws eg. gtk2 or qt paints and why DefaultDraw is important.

Zeljan Rikalo

2014-12-04 09:18

developer   ~0079627

We need good example project of such scenario, so then it will be probably fixed.

Zeljan Rikalo

2015-01-18 17:52

developer   ~0080497

Qt text alignment is fixed in 47415

Zeljan Rikalo

2015-01-18 17:53

developer   ~0080498

Gtk2 is still not polished.

Zeljan Rikalo

2015-01-18 21:11

developer   ~0080504

Gtk2 should be fixed too. Please test and close if ok.

Juha Manninen

2015-02-01 09:13

developer   ~0080706

Looks good. Thanks Zeljko.

Issue History

Date Modified Username Field Change
2014-11-14 18:31 Juha Manninen New Issue
2014-11-14 18:31 Juha Manninen Status new => assigned
2014-11-14 18:31 Juha Manninen Assigned To => Zeljan Rikalo
2014-11-14 18:46 Juha Manninen Description Updated View Revisions
2014-11-14 18:47 Juha Manninen Description Updated View Revisions
2014-11-15 08:38 Zeljan Rikalo Relationship added related to 0026770
2014-11-15 10:29 Zeljan Rikalo Note Added: 0079158
2014-11-15 10:29 Zeljan Rikalo Status assigned => feedback
2014-11-15 11:14 Juha Manninen Note Added: 0079159
2014-11-15 11:14 Juha Manninen Status feedback => assigned
2014-11-15 11:41 Zeljan Rikalo Fixed in Revision => 46851,46853
2014-11-15 11:41 Zeljan Rikalo Note Added: 0079160
2014-11-15 11:41 Zeljan Rikalo Status assigned => resolved
2014-11-15 11:41 Zeljan Rikalo Resolution open => fixed
2014-11-15 17:47 Juha Manninen Note Added: 0079164
2014-11-15 17:47 Juha Manninen Status resolved => assigned
2014-11-15 17:47 Juha Manninen Resolution fixed => reopened
2014-11-15 17:48 Juha Manninen Note Edited: 0079164 View Revisions
2014-11-15 17:53 Juha Manninen Note Edited: 0079164 View Revisions
2014-11-15 17:55 Juha Manninen File Added: Dialogs_Windows.png
2014-11-15 17:56 Juha Manninen File Added: Dialogs_QT.png
2014-11-15 17:56 Juha Manninen File Added: Dialogs_GTK2.png
2014-11-23 19:17 Zeljan Rikalo Note Added: 0079315
2014-11-23 21:42 Juha Manninen Note Added: 0079320
2014-11-24 08:57 Zeljan Rikalo Note Added: 0079332
2014-12-04 09:18 Zeljan Rikalo Note Added: 0079627
2015-01-18 17:52 Zeljan Rikalo Fixed in Revision 46851,46853 => 46851,46853,47415
2015-01-18 17:52 Zeljan Rikalo Note Added: 0080497
2015-01-18 17:52 Zeljan Rikalo Status assigned => resolved
2015-01-18 17:52 Zeljan Rikalo Resolution reopened => fixed
2015-01-18 17:53 Zeljan Rikalo Note Added: 0080498
2015-01-18 17:53 Zeljan Rikalo Status resolved => confirmed
2015-01-18 21:11 Zeljan Rikalo Fixed in Revision 46851,46853,47415 => 46851,46853,47415,47418
2015-01-18 21:11 Zeljan Rikalo Note Added: 0080504
2015-01-18 21:11 Zeljan Rikalo Status confirmed => resolved
2015-02-01 09:13 Juha Manninen Note Added: 0080706
2015-02-01 09:13 Juha Manninen Status resolved => closed
2015-05-30 00:51 Juha Manninen Relationship added related to 0028212