TListView does not allow setting item height with GTK2 and QT
Original Reporter info from Mantis: JuhaManninen @JuhaManninen
-
Reporter name: Juha Manninen
Original Reporter info from Mantis: JuhaManninen @JuhaManninen
- Reporter name: Juha Manninen
Description:
The 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 information:
Example 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);
var
Comp: TRegisteredComponent;
ARect: TRect;
CurIcon: TCustomBitmap;
begin
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);
end;
end;