lcl: grids: fix scrollbar visibility and MaxTLOffset.

git-svn-id: trunk@52351 -
This commit is contained in:
ondrej 2016-05-23 05:39:30 +00:00
parent 4f22e5e67a
commit 0b9e2259d5

View File

@ -741,7 +741,7 @@ type
FOnSelection: TOnSelectEvent; FOnSelection: TOnSelectEvent;
FOnTopLeftChanged: TNotifyEvent; FOnTopLeftChanged: TNotifyEvent;
FUseXORFeatures: boolean; FUseXORFeatures: boolean;
FVSbVisible, FHSbVisible: boolean; FVSbVisible, FHSbVisible: ShortInt; // state: -1 not initialized, 0 hidden, 1 visible
FDefaultTextStyle: TTextStyle; FDefaultTextStyle: TTextStyle;
FLastWidth: Integer; FLastWidth: Integer;
FTitleFont, FLastFont: TFont; FTitleFont, FLastFont: TFont;
@ -3190,9 +3190,7 @@ begin
{$Ifdef DbgScroll} {$Ifdef DbgScroll}
DebugLn('ScrollbarPosition: Which=',SbToStr(Which), ' Value= ',IntToStr(Value)); DebugLn('ScrollbarPosition: Which=',SbToStr(Which), ' Value= ',IntToStr(Value));
{$endif} {$endif}
if Which = SB_VERT then Vis := FVSbVisible else Vis := ScrollBarIsVisible(Which);
if Which = SB_HORZ then Vis := FHSbVisible
else vis := false;
FillChar(ScrollInfo, SizeOf(ScrollInfo), 0); FillChar(ScrollInfo, SizeOf(ScrollInfo), 0);
ScrollInfo.cbSize := SizeOf(ScrollInfo); ScrollInfo.cbSize := SizeOf(ScrollInfo);
if (Which=SB_HORZ) and Vis and UseRightToLeftAlignment then begin if (Which=SB_HORZ) and Vis and UseRightToLeftAlignment then begin
@ -3214,9 +3212,9 @@ begin
Result:=false; Result:=false;
if HandleAllocated then begin if HandleAllocated then begin
// Don't use GetScrollbarvisible from the widgetset - it sends WM_PAINT message (Gtk2). Issue #30160 // Don't use GetScrollbarvisible from the widgetset - it sends WM_PAINT message (Gtk2). Issue #30160
if Which = SB_VERT then result := FVSbVisible else if Which = SB_VERT then result := (FVSbVisible=1) else
if Which = SB_HORZ then result := FHsbVisible else if Which = SB_HORZ then result := (FHsbVisible=1) else
if Which = SB_BOTH then result := FHsbVisible and FVsbVisible; if Which = SB_BOTH then result := (FVSbVisible=1) and (FHsbVisible=1);
end; end;
end; end;
@ -3242,8 +3240,8 @@ begin
DebugLn('ScrollbarShow: Which=',SbToStr(Which), ' Avalue=',dbgs(AValue)); DebugLn('ScrollbarShow: Which=',SbToStr(Which), ' Avalue=',dbgs(AValue));
{$endif} {$endif}
ShowScrollBar(Handle,Which,aValue); ShowScrollBar(Handle,Which,aValue);
if Which in [SB_BOTH, SB_VERT] then FVSbVisible := AValue else if Which in [SB_BOTH, SB_VERT] then FVSbVisible := Ord(AValue);
if Which in [SB_BOTH, SB_HORZ] then FHSbVisible := AValue; if Which in [SB_BOTH, SB_HORZ] then FHSbVisible := Ord(AValue);
end; end;
end; end;
@ -4568,6 +4566,8 @@ procedure TCustomGrid.CreateWnd;
begin begin
//DebugLn('TCustomGrid.CreateWnd ',DbgSName(Self)); //DebugLn('TCustomGrid.CreateWnd ',DbgSName(Self));
inherited CreateWnd; inherited CreateWnd;
FVSbVisible := -1;
FHSbVisible := -1;
CheckPosition; CheckPosition;
VisualChange; VisualChange;
end; end;
@ -7280,7 +7280,7 @@ begin
DebugLn('TCustomGrid.UpdateHorzScrollbar: Vis=%s Range=%d Page=%d aPos=%d', DebugLn('TCustomGrid.UpdateHorzScrollbar: Vis=%s Range=%d Page=%d aPos=%d',
[dbgs(aVisible),aRange, aPage, aPos]); [dbgs(aVisible),aRange, aPage, aPos]);
{$endif} {$endif}
if ScrollBarIsVisible(SB_HORZ)<>aVisible then if FHSbVisible<>Ord(aVisible) then
ScrollBarShow(SB_HORZ, aVisible); ScrollBarShow(SB_HORZ, aVisible);
if aVisible then if aVisible then
ScrollBarRange(SB_HORZ, aRange, aPage, aPos); ScrollBarRange(SB_HORZ, aRange, aPage, aPos);
@ -7293,7 +7293,7 @@ begin
DebugLn('TCustomGrid.UpdateVertScrollbar: Vis=%s Range=%d Page=%d aPos=%d', DebugLn('TCustomGrid.UpdateVertScrollbar: Vis=%s Range=%d Page=%d aPos=%d',
[dbgs(aVisible),aRange, aPage, aPos]); [dbgs(aVisible),aRange, aPage, aPos]);
{$endif} {$endif}
if ScrollBarIsVisible(SB_Vert)<>aVisible then if FVSbVisible<>Ord(aVisible) then
ScrollBarShow(SB_VERT, aVisible); ScrollBarShow(SB_VERT, aVisible);
if aVisible then if aVisible then
ScrollbarRange(SB_VERT, aRange, aPage, aPos ); ScrollbarRange(SB_VERT, aRange, aPage, aPos );
@ -7428,6 +7428,8 @@ var
W,H: Integer; W,H: Integer;
begin begin
FGCache.MaxTopLeft:=Point(ColCount-1, RowCount-1); FGCache.MaxTopLeft:=Point(ColCount-1, RowCount-1);
FGCache.MaxTLOffset.x:=0;
FGCache.MaxTLOffset.y:=0;
W:=0; W:=0;
for i:=ColCount-1 downto FFixedCols do begin for i:=ColCount-1 downto FFixedCols do begin
W:=W+GetColWidths(i); W:=W+GetColWidths(i);
@ -7439,8 +7441,7 @@ begin
begin begin
FGCache.MaxTopLeft.x:=i; FGCache.MaxTopLeft.x:=i;
FGCache.MaxTLOffset.x:=W-FGCache.ScrollWidth; FGCache.MaxTLOffset.x:=W-FGCache.ScrollWidth;
end else end;
FGCache.MaxTLOffset.x:=0;
Break; Break;
end; end;
end; end;
@ -7455,8 +7456,7 @@ begin
begin begin
FGCache.MaxTopLeft.y:=i; FGCache.MaxTopLeft.y:=i;
FGCache.MaxTLOffset.y:=H-FGCache.ScrollHeight FGCache.MaxTLOffset.y:=H-FGCache.ScrollHeight
end else end;
FGCache.MaxTLOffset.y:=0;
Break; Break;
end; end;
end; end;
@ -8962,6 +8962,9 @@ begin
FGCache.ClickCell := point(-1, -1); FGCache.ClickCell := point(-1, -1);
inherited Create(AOwner); inherited Create(AOwner);
FVSbVisible := -1;
FHSbVisible := -1;
FColumns := CreateColumns; FColumns := CreateColumns;
FTitleFont := TFont.Create; FTitleFont := TFont.Create;