From 198981bc820aefa7338183cb520059ba4dc4e532 Mon Sep 17 00:00:00 2001 From: wp Date: Sun, 4 Nov 2018 13:27:55 +0000 Subject: [PATCH] VirtualTreeView: Fix incorrect positioning of node checkboxes if node and state images are turned off git-svn-id: trunk@59446 - --- components/virtualtreeview/VirtualTrees.pas | 30 ++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/components/virtualtreeview/VirtualTrees.pas b/components/virtualtreeview/VirtualTrees.pas index 2abac66547..7adcca55c4 100644 --- a/components/virtualtreeview/VirtualTrees.pas +++ b/components/virtualtreeview/VirtualTrees.pas @@ -3053,6 +3053,7 @@ type procedure SetCustomCheckImagesWidth(const Value: Integer); protected { multi-resolution imagelist support } + function GetImagesWidth(Images: TCustomImageList): Integer; property ImagesWidth: Integer read FImagesWidth write SetImagesWidth default 0; property StateImagesWidth: Integer read FStateImagesWidth write SetStateImagesWidth default 0; property CustomCheckImagesWidth: Integer read FCustomCheckImagesWidth write SetCustomCheckImagesWidth default 0; @@ -18096,8 +18097,19 @@ procedure TBaseVirtualTree.AdjustImageBorder(Images: TCustomImageList; BidiMode: // Depending on the width of the image list as well as the given bidi mode R must be adjusted. +var + W, H: Integer; begin - AdjustImageBorder(GetRealImagesWidth, GetRealImagesHeight, BidiMode, VAlign, R, ImageInfo); + {$IF LCL_FullVersion >= 2000000} + with Images.ResolutionForPPI[GetImagesWidth(Images), Font.PixelsPerInch, GetCanvasScaleFactor] do + {$ELSE} + with Images do + {$IFEND} + begin + W := Width; + H := Height; + end; + AdjustImageBorder(W, H, BidiMode, VAlign, R, ImageInfo); end; //---------------------------------------------------------------------------------------------------------------------- @@ -21956,6 +21968,22 @@ end; //---------------------------------------------------------------------------------------------------------------------- +{$IF LCL_FullVersion >= 2000000} +function TBaseVirtualTree.GetImagesWidth(Images: TCustomImageList): Integer; +begin + if Images = FImages then + Result := FImagesWidth + else if Images = FStateImages then + Result := FStateImagesWidth + else if Images = FCheckImages then + Result := FCheckImagesWidth + else + Result := 0; +end; +{$IFEND} + +//---------------------------------------------------------------------------------------------------------------------- + function TBaseVirtualTree.IsEmpty: Boolean; begin Result := (Self.ChildCount[nil] = 0);