mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 02:19:57 +02:00
grids, fixes redraw issues (issue #10659) and correct buffercount in dbgrid
git-svn-id: trunk@13818 -
This commit is contained in:
parent
082aa6dcfd
commit
88b8dd4d57
@ -85,7 +85,7 @@ begin
|
||||
for J := 0 to Src.RowCount - 1 do
|
||||
Dest.Cells[I, J] := Src.Cells[I, J];
|
||||
finally
|
||||
Dest.EndUpdate(uoFull);
|
||||
Dest.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -291,9 +291,6 @@ type
|
||||
FReadOnly: Boolean;
|
||||
FColEnterPending: Boolean;
|
||||
FLayoutChangedCount: integer;
|
||||
//FUseAutoColumns: boolean;
|
||||
//FUseCheckBoxColumn: boolean;
|
||||
FVisualChangeCount: Integer;
|
||||
FSelectionLock: Boolean;
|
||||
FTempText : string;
|
||||
FDrawingActiveRecord: Boolean;
|
||||
@ -342,8 +339,6 @@ type
|
||||
|
||||
procedure UpdateGridColumnSizes;
|
||||
procedure UpdateScrollbarRange;
|
||||
procedure BeginVisualChange;
|
||||
procedure EndVisualChange;
|
||||
procedure DoLayoutChanged;
|
||||
//procedure WriteColumns(Writer: TWriter);
|
||||
|
||||
@ -391,6 +386,7 @@ type
|
||||
function EditorIsReadOnly: boolean; override;
|
||||
procedure EndLayout;
|
||||
function FieldIndexFromGridColumn(Column: Integer): Integer;
|
||||
function GetBufferCount: integer;
|
||||
function GetDefaultColumnAlignment(Column: Integer): TAlignment; override;
|
||||
function GetDefaultColumnWidth(Column: Integer): Integer; override;
|
||||
function GetDefaultColumnReadOnly(Column: Integer): boolean; override;
|
||||
@ -423,7 +419,6 @@ type
|
||||
procedure UpdateActive; virtual;
|
||||
procedure UpdateData; virtual;
|
||||
function UpdateGridCounts: Integer;
|
||||
procedure VisualChange; override;
|
||||
procedure WMVScroll(var Message : TLMVScroll); message LM_VScroll;
|
||||
procedure WndProc(var TheMessage : TLMessage); override;
|
||||
|
||||
@ -986,22 +981,18 @@ procedure TCustomDBGrid.SetThumbTracking(const AValue: boolean);
|
||||
begin
|
||||
BeginUpdate;
|
||||
if Avalue then
|
||||
inherited Options := Inherited Options + [goThumbTracking]
|
||||
inherited Options := inherited Options + [goThumbTracking]
|
||||
else
|
||||
inherited Options := Inherited Options - [goThumbTracking];
|
||||
EndUpdate(uoNone);
|
||||
inherited Options := inherited Options - [goThumbTracking];
|
||||
EndUpdate(false);
|
||||
end;
|
||||
|
||||
procedure TCustomDBGrid.UpdateBufferCount;
|
||||
var
|
||||
BuffCount: Integer;
|
||||
begin
|
||||
if FDataLink.Active then begin
|
||||
BuffCount := GCache.ClientHeight div DefaultRowHeight;
|
||||
if dgTitles in Options then Dec(BuffCount, 1);
|
||||
FDataLink.BufferCount:= BuffCount;
|
||||
FDataLink.BufferCount:= GetBufferCount;
|
||||
{$ifdef dbgDBGrid}
|
||||
DebugLn(ClassName, ' (',name,')', ' FdataLink.BufferCount=' + IntToStr(Fdatalink.BufferCount));
|
||||
DebugLn('%s (%s), FDatalink.BufferCount=%d',[ClassName,Name,FDataLink.BufferCount]);
|
||||
{$endif}
|
||||
end;
|
||||
end;
|
||||
@ -1252,6 +1243,13 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCustomDBGrid.GetBufferCount: integer;
|
||||
begin
|
||||
Result := ClientHeight div DefaultRowHeight;
|
||||
if dgTitles in Options then
|
||||
Dec(Result, 1);
|
||||
end;
|
||||
|
||||
procedure TCustomDBGrid.UpdateGridColumnSizes;
|
||||
var
|
||||
i: Integer;
|
||||
@ -1304,25 +1302,16 @@ begin
|
||||
' aPage=', IntToStr(aPage), ' aPos=', IntToStr(aPos));
|
||||
{$endif}
|
||||
end;
|
||||
procedure TCustomDBGrid.BeginVisualChange;
|
||||
begin
|
||||
inc(FVisualChangeCount);
|
||||
end;
|
||||
|
||||
procedure TCustomDBGrid.EndVisualChange;
|
||||
begin
|
||||
dec(FVisualChangecount);
|
||||
if FVisualChangeCount = 0 then
|
||||
VisualChange;
|
||||
end;
|
||||
|
||||
procedure TCustomDBGrid.doLayoutChanged;
|
||||
begin
|
||||
if csDestroying in ComponentState then
|
||||
exit;
|
||||
{$ifdef dbgDBGrid} DebugLn('doLayoutChanged INIT'); {$endif}
|
||||
BeginUpdate;
|
||||
if UpdateGridCounts=0 then
|
||||
EmptyGrid;
|
||||
EndUpdate;
|
||||
UpdateScrollbarRange;
|
||||
RestoreEditor;
|
||||
{$ifdef dbgDBGrid} DebugLn('doLayoutChanged FIN'); {$endif}
|
||||
@ -1631,7 +1620,7 @@ begin
|
||||
inherited DoOnChangeBounds;
|
||||
if HandleAllocated then
|
||||
LayoutChanged;
|
||||
EndUpdate(False);
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TCustomDBGrid.DoPrepareCanvas(aCol, aRow: Integer;
|
||||
@ -2521,7 +2510,7 @@ begin
|
||||
// there are no visible columns defined or dataset is inactive
|
||||
// or there are no visible fields, ie the grid is blank
|
||||
{$IfDef dbgDBGrid}DebugLn('TCustomDbgrid.UpdateGridCounts INIT');{$endif}
|
||||
BeginVisualChange;
|
||||
BeginUpdate;
|
||||
try
|
||||
Result := GetColumnCount;
|
||||
if Result > 0 then begin
|
||||
@ -2529,7 +2518,7 @@ begin
|
||||
if dgTitles in Options then FRCount := 1 else FRCount := 0;
|
||||
if dgIndicator in Options then FCCount := 1 else FCCount := 0;
|
||||
InternalSetColCount(Result + FCCount);
|
||||
|
||||
|
||||
if FDataLink.Active then begin
|
||||
UpdateBufferCount;
|
||||
RecCount := FDataLink.RecordCount;
|
||||
@ -2538,7 +2527,7 @@ begin
|
||||
end else begin
|
||||
RecCount := 0;
|
||||
if FRCount=0 then
|
||||
// need to be as large enought to hold indicator
|
||||
// need to be large enough to hold indicator
|
||||
// if there is one, and if there are no titles
|
||||
RecCount := FCCount;
|
||||
end;
|
||||
@ -2555,18 +2544,11 @@ begin
|
||||
SetColRow(Col, FixedRows + FDatalink.ActiveRecord);
|
||||
end;
|
||||
finally
|
||||
EndVisualChange;
|
||||
EndUpdate;
|
||||
end;
|
||||
{$IfDef dbgDBGrid}DebugLn('TCustomDbgrid.UpdateGridCounts END');{$endif}
|
||||
end;
|
||||
|
||||
procedure TCustomDBGrid.VisualChange;
|
||||
begin
|
||||
if FVisualChangeCount=0 then begin
|
||||
inherited VisualChange;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCustomDBGrid.Create(AOwner: TComponent);
|
||||
begin
|
||||
FEditingColumn:=-1;
|
||||
|
110
lcl/grids.pas
110
lcl/grids.pas
@ -122,7 +122,6 @@ type
|
||||
TGridZone = (gzNormal, gzFixedCols, gzFixedRows, gzFixedCells, gzInvalid);
|
||||
TGridZoneSet = set of TGridZone;
|
||||
|
||||
TUpdateOption = (uoNone, uoQuick, uoFull);
|
||||
TAutoAdvance = (aaNone,aaDown,aaRight,aaLeft, aaRightDown, aaLeftDown,
|
||||
aaRightUp, aaLeftUp);
|
||||
|
||||
@ -952,9 +951,7 @@ type
|
||||
procedure EditorKeyDown(Sender: TObject; var Key:Word; Shift:TShiftState);
|
||||
procedure EditorKeyPress(Sender: TObject; var Key: Char);
|
||||
procedure EditorKeyUp(Sender: TObject; var key:Word; shift:TShiftState);
|
||||
procedure EndUpdate(UO: TUpdateOption); overload;
|
||||
procedure EndUpdate(FullUpdate: Boolean); overload;
|
||||
procedure EndUpdate; overload;
|
||||
procedure EndUpdate(aRefresh: boolean = true);
|
||||
procedure EraseBackground(DC: HDC); override;
|
||||
|
||||
function IscellVisible(aCol, aRow: Integer): Boolean;
|
||||
@ -1779,18 +1776,20 @@ begin
|
||||
SetRawColWidths(ACol, Avalue);
|
||||
if not (csLoading in ComponentState) then begin
|
||||
|
||||
UpdateSizes;
|
||||
if FUpdateCount=0 then begin
|
||||
UpdateSizes;
|
||||
|
||||
R := CellRect(aCol, 0);
|
||||
R.Bottom := FGCache.MaxClientXY.Y+GetBorderWidth+1;
|
||||
if bigger then
|
||||
R.Right := FGCache.MaxClientXY.X+GetBorderWidth+1
|
||||
else
|
||||
R.Right := FGCache.ClientWidth;
|
||||
if aCol=FTopLeft.x then
|
||||
R.Left := FGCache.FixedWidth;
|
||||
R := CellRect(aCol, 0);
|
||||
R.Bottom := FGCache.MaxClientXY.Y+GetBorderWidth+1;
|
||||
if bigger then
|
||||
R.Right := FGCache.MaxClientXY.X+GetBorderWidth+1
|
||||
else
|
||||
R.Right := FGCache.ClientWidth;
|
||||
if aCol=FTopLeft.x then
|
||||
R.Left := FGCache.FixedWidth;
|
||||
|
||||
InvalidateRect(handle, @R, False);
|
||||
InvalidateRect(handle, @R, False);
|
||||
end;
|
||||
|
||||
if (FEditor<>nil)and(Feditor.Visible)and(ACol<=FCol) then
|
||||
EditorWidthChanged(aCol, aValue);
|
||||
@ -2022,10 +2021,6 @@ procedure TCustomGrid.SetOptions(const AValue: TGridOptions);
|
||||
begin
|
||||
if FOptions=AValue then exit;
|
||||
FOptions:=AValue;
|
||||
{
|
||||
if goRangeSelect in Options then
|
||||
FOptions:=FOptions - [goAlwaysShowEditor];
|
||||
}
|
||||
UpdateSelectionRange;
|
||||
if goAlwaysShowEditor in Options then begin
|
||||
EditorShow(true);
|
||||
@ -2059,18 +2054,20 @@ begin
|
||||
|
||||
FRows[ARow]:=Pointer(PtrInt(AValue));
|
||||
|
||||
UpdateSizes;
|
||||
|
||||
R := CellRect(0, aRow);
|
||||
R.Right := FGCache.MaxClientXY.X+GetBorderWidth+1;
|
||||
if bigger then
|
||||
R.Bottom := FGCache.MaxClientXY.Y+GetBorderWidth+1
|
||||
else
|
||||
R.Bottom := FGCache.ClientHeight;
|
||||
if aRow=FTopLeft.y then
|
||||
R.Top := FGCache.FixedHeight;
|
||||
if FUpdateCount=0 then begin
|
||||
UpdateSizes;
|
||||
|
||||
InvalidateRect(handle, @R, False);
|
||||
R := CellRect(0, aRow);
|
||||
R.Right := FGCache.MaxClientXY.X+GetBorderWidth+1;
|
||||
if bigger then
|
||||
R.Bottom := FGCache.MaxClientXY.Y+GetBorderWidth+1
|
||||
else
|
||||
R.Bottom := FGCache.ClientHeight;
|
||||
if aRow=FTopLeft.y then
|
||||
R.Top := FGCache.FixedHeight;
|
||||
|
||||
InvalidateRect(handle, @R, False);
|
||||
end;
|
||||
|
||||
if (FEditor<>nil)and(Feditor.Visible)and(ARow<=FRow) then EditorPos;
|
||||
RowHeightsChanged;
|
||||
@ -2281,18 +2278,13 @@ begin
|
||||
CheckIndex(not ColSorting, IndxTo);
|
||||
BeginUpdate;
|
||||
QuickSort(IndxFrom, IndxTo);
|
||||
EndUpdate(True);
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TCustomGrid.doTopleftChange(dimChg: Boolean);
|
||||
begin
|
||||
TopLeftChanged;
|
||||
if dimchg then begin
|
||||
VisualChange;
|
||||
end else begin
|
||||
CacheVisibleGrid;
|
||||
Invalidate;
|
||||
end;
|
||||
VisualChange;
|
||||
updateScrollBarPos(ssBoth);
|
||||
end;
|
||||
|
||||
@ -2335,21 +2327,17 @@ end;
|
||||
|
||||
procedure TCustomGrid.VisualChange;
|
||||
begin
|
||||
{$ifdef DbgVisualChange}
|
||||
DebugLn('TCustomGrid.VisualChange INIT ',DbgSName(Self));
|
||||
{$endif}
|
||||
if FUpdateCount<>0 then
|
||||
exit;
|
||||
|
||||
{$ifdef DbgVisualChange}
|
||||
DebugLn('TCustomGrid.VisualChange INIT ',DbgSName(Self));
|
||||
{$endif}
|
||||
|
||||
UpdateSizes;
|
||||
|
||||
Invalidate;
|
||||
{$ifdef DbgVisualChange}
|
||||
with FGCache do begin
|
||||
DebugLn('GWidth=',dbgs(GridWidth),' GHeight=',dbgs(GridHeight));
|
||||
DebugLn('CWidth=',dbgs(ClientWidth),' CHeight=',dbgs(ClientHeight));
|
||||
//DebugLn('HsbVis=',dbgs(HsbVisible),' VSbVis=', dbgs(VSbVisible));
|
||||
end;
|
||||
DebugLn('TCustomGrid.VisualChange END ',DbgSName(Self));
|
||||
{$endif}
|
||||
end;
|
||||
@ -3585,6 +3573,12 @@ begin
|
||||
|
||||
FGCache.ClientWidth := ClientWidth;
|
||||
FGCache.ClientHeight:= ClientHeight;
|
||||
{$ifdef dbgVisualChange}
|
||||
DebugLn('TCustomGrid.updateCachedSizes: ');
|
||||
with FGCache do
|
||||
DebugLn(' GWidth=%d GHeight=%d FWidth=%d FHeight=%d CWidth=%d CHeight=%d',
|
||||
[GridWidth,GridHeight,FixedWidth,FixedHeight,ClientWidth,ClientHeight]);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TCustomGrid.GetSBVisibility(out HsbVisible,VsbVisible:boolean);
|
||||
@ -5585,29 +5579,11 @@ begin
|
||||
Inc(FUpdateCount);
|
||||
end;
|
||||
|
||||
procedure TCustomGrid.EndUpdate(UO: TUpdateOption);
|
||||
procedure TCustomGrid.EndUpdate(aRefresh: boolean = true);
|
||||
begin
|
||||
Dec(FUpdateCount);
|
||||
if FUpdateCount=0 then
|
||||
case UO of
|
||||
uoQuick:
|
||||
Invalidate;
|
||||
uoFull:
|
||||
VisualChange;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomGrid.EndUpdate(FullUpdate: Boolean);
|
||||
begin
|
||||
if FullUpdate then
|
||||
EndUpdate(uoFull)
|
||||
else
|
||||
EndUpdate(uoQuick);
|
||||
end;
|
||||
|
||||
procedure TCustomGrid.EndUpdate;
|
||||
begin
|
||||
EndUpdate(true);
|
||||
if (FUpdateCount=0) and aRefresh then
|
||||
VisualChange;
|
||||
end;
|
||||
|
||||
procedure TCustomGrid.EraseBackground(DC: HDC);
|
||||
@ -6764,7 +6740,7 @@ begin
|
||||
if Version=-1 then raise Exception.Create(rsNotAValidGridFile);
|
||||
BeginUpdate;
|
||||
LoadContent(Cfg, Version);
|
||||
EndUpdate(True);
|
||||
EndUpdate;
|
||||
Finally
|
||||
FreeThenNil(Cfg);
|
||||
end;
|
||||
@ -8089,7 +8065,7 @@ begin
|
||||
for aRow:= StartRow to EndRow do
|
||||
if (CleanOptions=[]) or (CellToGridZone(aCol,aRow) in CleanOptions) then
|
||||
Cells[aCol,aRow] := '';
|
||||
EndUpdate(false);
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user