jvcllaz: Fix occasional incomplete painting of images in TJvImagesViewer (issue #34104, patch by Michal Gawrycki).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6610 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-08-18 14:22:09 +00:00
parent 0113387c6f
commit 2f70876213

View File

@ -292,6 +292,8 @@ type
function DoItemHint(Index: Integer; var HintInfo: THintInfo): Boolean; virtual; function DoItemHint(Index: Integer; var HintInfo: THintInfo): Boolean; virtual;
procedure CustomSort(Compare:TListSortCompare);virtual; procedure CustomSort(Compare:TListSortCompare);virtual;
function ClientDisplayRect: TRect;
property TopLeftIndex: Integer read FTopLeftIndex; property TopLeftIndex: Integer read FTopLeftIndex;
property BottomRightIndex: Integer read FBottomRightIndex; property BottomRightIndex: Integer read FBottomRightIndex;
property UpdateCount: Integer read FUpdateCount; property UpdateCount: Integer read FUpdateCount;
@ -926,7 +928,7 @@ begin
if (I >= 0) and (I < Count) then if (I >= 0) and (I < Count) then
begin begin
Delete(I); Delete(I);
InvalidateClipRect(ClientRect); InvalidateClipRect(ClientDisplayRect);
end; end;
end; end;
@ -1205,7 +1207,7 @@ end;
procedure TJvCustomItemViewer.InvalidateClipRect(R: TRect); procedure TJvCustomItemViewer.InvalidateClipRect(R: TRect);
begin begin
if IsRectEmpty(R) then if IsRectEmpty(R) then
R := Canvas.ClipRect; R := ClientDisplayRect;
LCLIntf.InvalidateRect(Handle, @R, True); LCLIntf.InvalidateRect(Handle, @R, True);
end; end;
@ -1329,9 +1331,9 @@ var
I: Integer; I: Integer;
AItemRect, TextRect, AClientRect: TRect; AItemRect, TextRect, AClientRect: TRect;
function IsRectVisible(const R: TRect): Boolean; function IsRectVisible(const R, TR: TRect): Boolean;
begin begin
Result := (R.Top + FTopLeft.Y < AClientRect.Bottom) and (R.Bottom + FTopLeft.Y > AClientRect.Top) and Result := (R.Top + FTopLeft.Y < AClientRect.Bottom) and (R.Bottom + FTopLeft.Y + TR.Height > AClientRect.Top) and
(R.Left + FTopLeft.X < AClientRect.Right) and (R.Right + FTopLeft.X > AClientRect.Left) (R.Left + FTopLeft.X < AClientRect.Right) and (R.Right + FTopLeft.X > AClientRect.Left)
end; end;
@ -1362,7 +1364,7 @@ begin
for I := 0 to Count - 1 do for I := 0 to Count - 1 do
if not Items[I].Deleting then if not Items[I].Deleting then
begin begin
if not Options.LazyRead or IsRectVisible(AItemRect) then if not Options.LazyRead or IsRectVisible(AItemRect, TextRect) then
DrawItem(I, GetItemState(I), Canvas, AItemRect, TextRect); DrawItem(I, GetItemState(I), Canvas, AItemRect, TextRect);
if (I + 1) mod FCols = 0 then if (I + 1) mod FCols = 0 then
begin begin
@ -1451,7 +1453,7 @@ begin
EndUpdate; EndUpdate;
UpdateAll; UpdateAll;
if HandleAllocated then if HandleAllocated then
InvalidateClipRect(Canvas.ClipRect); InvalidateClipRect(ClientDisplayRect);
end; end;
end; end;
end; end;
@ -1677,7 +1679,7 @@ procedure TJvCustomItemViewer.WMHScroll(var Msg: TLMessage);
begin begin
inherited; inherited;
UpdateAll; UpdateAll;
InvalidateClipRect(ClientRect); InvalidateClipRect(ClientDisplayRect);
if Assigned(FOnScroll) then if Assigned(FOnScroll) then
FOnScroll(Self); FOnScroll(Self);
end; end;
@ -1762,7 +1764,7 @@ procedure TJvCustomItemViewer.WMVScroll(var Msg: TLMessage);
begin begin
inherited; inherited;
UpdateAll; UpdateAll;
InvalidateClipRect(ClientRect); InvalidateClipRect(ClientDisplayRect);
if Assigned(FOnScroll) then if Assigned(FOnScroll) then
FOnScroll(Self); FOnScroll(Self);
end; end;
@ -1787,7 +1789,7 @@ procedure TJvCustomItemViewer.BoundsChanged;
begin begin
UpdateAll; UpdateAll;
if HandleAllocated then if HandleAllocated then
InvalidateClipRect(ClientRect); InvalidateClipRect(ClientDisplayRect);
inherited BoundsChanged; inherited BoundsChanged;
end; end;
@ -1799,7 +1801,7 @@ begin
UpdateAll; UpdateAll;
if not Options.MultiSelect then if not Options.MultiSelect then
DoUnSelectItems(SelectedIndex); DoUnSelectItems(SelectedIndex);
InvalidateClipRect(ClientRect); InvalidateClipRect(ClientDisplayRect);
end; end;
end; end;
@ -1999,6 +2001,12 @@ begin
FItems.Sort(Compare); FItems.Sort(Compare);
end; end;
function TJvCustomItemViewer.ClientDisplayRect: TRect;
begin
Result := ClientRect;
OffsetRect(Result, HorzScrollBar.Position, VertScrollBar.Position);
end;
//=== { TViewerDrawImageList } =============================================== //=== { TViewerDrawImageList } ===============================================
procedure TViewerDrawImageList.Initialize; procedure TViewerDrawImageList.Initialize;