mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 08:43:14 +02:00
* patch from Jesus Reyes
git-svn-id: trunk@7036 -
This commit is contained in:
parent
fda74205a3
commit
b70bc3d401
331
lcl/dbgrids.pas
331
lcl/dbgrids.pas
@ -67,8 +67,13 @@ type
|
|||||||
dgMultiselect
|
dgMultiselect
|
||||||
);
|
);
|
||||||
TDbGridOptions = set of TDbGridOption;
|
TDbGridOptions = set of TDbGridOption;
|
||||||
|
TDbGridStatusItem = (gsVisibleMove,gsUpdatedData);
|
||||||
|
TDbGridStatus = set of TDbGridStatusItem;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
{ TComponentDataLink }
|
||||||
|
|
||||||
TComponentDataLink=class(TDatalink)
|
TComponentDataLink=class(TDatalink)
|
||||||
private
|
private
|
||||||
FDataSet: TDataSet;
|
FDataSet: TDataSet;
|
||||||
@ -101,8 +106,8 @@ type
|
|||||||
procedure EditingChanged; override;
|
procedure EditingChanged; override;
|
||||||
procedure UpdateData; override;
|
procedure UpdateData; override;
|
||||||
function MoveBy(Distance: Integer): Integer; override;
|
function MoveBy(Distance: Integer): Integer; override;
|
||||||
|
property Modified: Boolean read FModified write FModified;
|
||||||
public
|
public
|
||||||
procedure Modified;
|
|
||||||
Property OnRecordChanged: TFieldNotifyEvent read FOnRecordChanged write FOnRecordChanged;
|
Property OnRecordChanged: TFieldNotifyEvent read FOnRecordChanged write FOnRecordChanged;
|
||||||
Property OnDataSetChanged: TDatasetNotifyEvent read FOnDatasetChanged write FOnDataSetChanged;
|
Property OnDataSetChanged: TDatasetNotifyEvent read FOnDatasetChanged write FOnDataSetChanged;
|
||||||
property OnNewDataSet: TDataSetNotifyEvent read fOnNewDataSet write fOnNewDataSet;
|
property OnNewDataSet: TDataSetNotifyEvent read fOnNewDataSet write fOnNewDataSet;
|
||||||
@ -177,6 +182,7 @@ type
|
|||||||
FEditingColumn: Integer;
|
FEditingColumn: Integer;
|
||||||
FOldPosition: Integer;
|
FOldPosition: Integer;
|
||||||
FDefaultColWidths: boolean;
|
FDefaultColWidths: boolean;
|
||||||
|
FGridStatus: TDbGridStatus;
|
||||||
procedure EmptyGrid;
|
procedure EmptyGrid;
|
||||||
function GetCurrentField: TField;
|
function GetCurrentField: TField;
|
||||||
function GetDataSource: TDataSource;
|
function GetDataSource: TDataSource;
|
||||||
@ -220,6 +226,8 @@ type
|
|||||||
|
|
||||||
procedure RestoreEditor;
|
procedure RestoreEditor;
|
||||||
function ISEOF: boolean;
|
function ISEOF: boolean;
|
||||||
|
function ValidDataSet: boolean;
|
||||||
|
function InsertCancelable: boolean;
|
||||||
protected
|
protected
|
||||||
{$ifdef ver1_0}
|
{$ifdef ver1_0}
|
||||||
property FixedColor;
|
property FixedColor;
|
||||||
@ -234,6 +242,8 @@ type
|
|||||||
procedure DefineProperties(Filer: TFiler); override;
|
procedure DefineProperties(Filer: TFiler); override;
|
||||||
procedure DefaultDrawCell(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState);
|
procedure DefaultDrawCell(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState);
|
||||||
procedure DoExit; override;
|
procedure DoExit; override;
|
||||||
|
function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;
|
||||||
|
function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;
|
||||||
procedure DoOnChangeBounds; override;
|
procedure DoOnChangeBounds; override;
|
||||||
procedure DrawByRows; override;
|
procedure DrawByRows; override;
|
||||||
procedure DrawFocusRect(aCol,aRow:Integer; ARect:TRect); override;
|
procedure DrawFocusRect(aCol,aRow:Integer; ARect:TRect); override;
|
||||||
@ -473,9 +483,13 @@ begin
|
|||||||
if aDataSet=nil then DebugLn('nil)')
|
if aDataSet=nil then DebugLn('nil)')
|
||||||
else DebugLn(aDataSet.Name,')');
|
else DebugLn(aDataSet.Name,')');
|
||||||
{$endif}
|
{$endif}
|
||||||
LayoutChanged;
|
if not (gsVisibleMove in FGridStatus) then
|
||||||
|
LayoutChanged
|
||||||
|
else
|
||||||
|
UpdateScrollBarRange;
|
||||||
|
|
||||||
UpdateActive;
|
UpdateActive;
|
||||||
RestoreEditor;
|
//RestoreEditor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.OnDataSetOpen(aDataSet: TDataSet);
|
procedure TCustomDbGrid.OnDataSetOpen(aDataSet: TDataSet);
|
||||||
@ -503,6 +517,8 @@ begin
|
|||||||
DebugLn('Editing=', BoolToStr(dsEdit = aDataSet.State));
|
DebugLn('Editing=', BoolToStr(dsEdit = aDataSet.State));
|
||||||
DebugLn('Inserting=',BoolToStr(dsInsert = aDataSet.State));
|
DebugLn('Inserting=',BoolToStr(dsInsert = aDataSet.State));
|
||||||
{$endif}
|
{$endif}
|
||||||
|
FDataLink.Modified := False;
|
||||||
|
Exclude(FGridStatus, gsUpdatedData);
|
||||||
UpdateActive;
|
UpdateActive;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -547,8 +563,13 @@ begin
|
|||||||
Debugln('Dataset.RecordCount=',IntToStr(aDataSet.RecordCount));
|
Debugln('Dataset.RecordCount=',IntToStr(aDataSet.RecordCount));
|
||||||
{$endif}
|
{$endif}
|
||||||
UpdateScrollBarRange;
|
UpdateScrollBarRange;
|
||||||
|
// todo: Use a fast interface method to scroll a rectangular section of window
|
||||||
|
// if distance=+, Row[Distance] to Row[RowCount-2] UP
|
||||||
|
// if distance=-, Row[FixedRows+1] to Row[RowCount+Distance] DOWN
|
||||||
|
if Distance<>0 then
|
||||||
|
Invalidate
|
||||||
|
else
|
||||||
UpdateActive;
|
UpdateActive;
|
||||||
if Distance<>0 then Invalidate;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.OnUpdateData(aDataSet: TDataSet);
|
procedure TCustomDbGrid.OnUpdateData(aDataSet: TDataSet);
|
||||||
@ -643,10 +664,12 @@ end;
|
|||||||
|
|
||||||
procedure TCustomDbGrid.SetThumbTracking(const AValue: boolean);
|
procedure TCustomDbGrid.SetThumbTracking(const AValue: boolean);
|
||||||
begin
|
begin
|
||||||
|
BeginUpdate;
|
||||||
if Avalue then
|
if Avalue then
|
||||||
inherited Options := Inherited Options + [goThumbTracking]
|
inherited Options := Inherited Options + [goThumbTracking]
|
||||||
else
|
else
|
||||||
inherited Options := Inherited Options - [goThumbTracking];
|
inherited Options := Inherited Options - [goThumbTracking];
|
||||||
|
EndUpdate(uoNone);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.UpdateBufferCount;
|
procedure TCustomDbGrid.UpdateBufferCount;
|
||||||
@ -668,12 +691,21 @@ var
|
|||||||
selField,edField: TField;
|
selField,edField: TField;
|
||||||
begin
|
begin
|
||||||
// get Editor text and update field content
|
// get Editor text and update field content
|
||||||
if FDatalink.Editing then begin
|
if (FEditingColumn>-1) and FDatalink.Editing then begin
|
||||||
SelField := SelectedField;
|
SelField := SelectedField;
|
||||||
edField := GetFieldFromGridColumn(FEditingColumn);
|
edField := GetFieldFromGridColumn(FEditingColumn);
|
||||||
if (edField<>nil) and (edField = SelField) then
|
if (edField<>nil) and (edField = SelField) then begin
|
||||||
//if (edField<>nil) and (FEditingField=SelField) then
|
//if (edField<>nil) and (FEditingField=SelField) then
|
||||||
|
{$ifdef dbgdbgrid}
|
||||||
|
DebugLn('UpdateData: Field[', edField.Fieldname, ']=', FTempText,' INIT');
|
||||||
|
{$endif}
|
||||||
edField.AsString := FTempText;
|
edField.AsString := FTempText;
|
||||||
|
{$ifdef dbgdbgrid}
|
||||||
|
DebugLn('UpdateData: Chk: Field:=',edField.ASString,' END');
|
||||||
|
{$endif}
|
||||||
|
Include(FGridStatus, gsUpdatedData);
|
||||||
|
EditingColumn(FEditingColumn, False);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -908,7 +940,9 @@ begin
|
|||||||
if aPage<1 then aPage := 1;
|
if aPage<1 then aPage := 1;
|
||||||
if FDatalink.BOF then aPos := 0 else
|
if FDatalink.BOF then aPos := 0 else
|
||||||
if FDatalink.EOF then aPos := aRange
|
if FDatalink.EOF then aPos := aRange
|
||||||
else aPos := FDataLink.DataSet.RecNo - 1; // RecNo is 1 based
|
else
|
||||||
|
aPos := FDataLink.DataSet.RecNo - 1; // RecNo is 1 based
|
||||||
|
if aPos<0 then aPos:=0;
|
||||||
end else begin
|
end else begin
|
||||||
aRange := 6;
|
aRange := 6;
|
||||||
aPage := 2;
|
aPage := 2;
|
||||||
@ -959,9 +993,11 @@ procedure TCustomDbGrid.doLayoutChanged;
|
|||||||
begin
|
begin
|
||||||
if csDestroying in ComponentState then
|
if csDestroying in ComponentState then
|
||||||
exit;
|
exit;
|
||||||
|
{$ifdef dbgdbgrid} DebugLn('doLayoutChanged INIT'); {$endif}
|
||||||
if UpdateGridCounts=0 then
|
if UpdateGridCounts=0 then
|
||||||
EmptyGrid;
|
EmptyGrid;
|
||||||
UpdateScrollBarRange;
|
UpdateScrollBarRange;
|
||||||
|
{$ifdef dbgdbgrid} DebugLn('doLayoutChanged FIN'); {$endif}
|
||||||
end;
|
end;
|
||||||
{
|
{
|
||||||
procedure TCustomDbGrid.WriteColumns(Writer: TWriter);
|
procedure TCustomDbGrid.WriteColumns(Writer: TWriter);
|
||||||
@ -987,6 +1023,17 @@ begin
|
|||||||
Active and DataSet.EOF;
|
Active and DataSet.EOF;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomDbGrid.ValidDataSet: boolean;
|
||||||
|
begin
|
||||||
|
result := FDatalink.Active And (FDatalink.DataSet<>nil)
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomDbGrid.InsertCancelable: boolean;
|
||||||
|
begin
|
||||||
|
with FDatalink.DataSet do
|
||||||
|
Result := (State=dsInsert) and not (Modified or FDataLink.FModified);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.LinkActive(Value: Boolean);
|
procedure TCustomDbGrid.LinkActive(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
LayoutChanged;
|
LayoutChanged;
|
||||||
@ -1126,9 +1173,12 @@ var
|
|||||||
F: TField;
|
F: TField;
|
||||||
begin
|
begin
|
||||||
if gdFixed in aState then begin
|
if gdFixed in aState then begin
|
||||||
if (ACol=0) and FDrawingActiveRecord then
|
if (ACol=0) and FDrawingActiveRecord then begin
|
||||||
DrawArrow(Canvas, aRect, GetDataSetState)
|
DrawArrow(Canvas, aRect, GetDataSetState);
|
||||||
else
|
{$ifdef dbgGridPaint}
|
||||||
|
dbgOut('>');
|
||||||
|
{$endif}
|
||||||
|
end else
|
||||||
if (aRow=0)and(ACol>=FixedCols) then begin
|
if (aRow=0)and(ACol>=FixedCols) then begin
|
||||||
FixRectangle;
|
FixRectangle;
|
||||||
Canvas.TextRect(ARect,ARect.Left,ARect.Top,GetColumnTitle(aCol));
|
Canvas.TextRect(ARect,ARect.Left,ARect.Top,GetColumnTitle(aCol));
|
||||||
@ -1161,22 +1211,14 @@ procedure TCustomDbGrid.BeforeMoveSelection(const DCol,DRow: Integer);
|
|||||||
begin
|
begin
|
||||||
if FSelectionLock then
|
if FSelectionLock then
|
||||||
exit;
|
exit;
|
||||||
|
{$ifdef dbgdbgrid}DebugLn('dbgrid.BefMovSel INIT');{$endif}
|
||||||
inherited BeforeMoveSelection(DCol, DRow);
|
inherited BeforeMoveSelection(DCol, DRow);
|
||||||
if FDataLink.Active then begin
|
|
||||||
if FDataLink.Editing then
|
|
||||||
FDataLink.UpdateData;
|
|
||||||
{
|
|
||||||
if dgCancelOnExit in Options then
|
|
||||||
FDataLink.DataSet.Cancel
|
|
||||||
else
|
|
||||||
FDatalink.UpdateData;
|
|
||||||
}
|
|
||||||
end;
|
|
||||||
if DCol<>Col then begin
|
if DCol<>Col then begin
|
||||||
if assigned(OnColExit) then
|
if assigned(OnColExit) then
|
||||||
OnColExit(Self);
|
OnColExit(Self);
|
||||||
FColEnterPending:=True;
|
FColEnterPending:=True;
|
||||||
end;
|
end;
|
||||||
|
{$ifdef dbgdbgrid}DebugLn('dbgrid.BefMovSel END');{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.HeaderClick(IsColumn: Boolean; index: Integer);
|
procedure TCustomDbGrid.HeaderClick(IsColumn: Boolean; index: Integer);
|
||||||
@ -1191,65 +1233,110 @@ procedure TCustomDbGrid.KeyDown(var Key: Word; Shift: TShiftState);
|
|||||||
if Assigned(OnKeyDown) then
|
if Assigned(OnKeyDown) then
|
||||||
OnKeyDown(Self, Key, Shift);
|
OnKeyDown(Self, Key, Shift);
|
||||||
end;
|
end;
|
||||||
|
procedure DoMoveBy(amount: Integer);
|
||||||
begin
|
begin
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.DoMoveBy(',IntToStr(Amount),')');{$Endif}
|
||||||
|
FDatalink.MoveBy(Amount);
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.DoMoveBy FIN');{$Endif}
|
||||||
|
end;
|
||||||
|
procedure DoMoveBySmall(amount: Integer);
|
||||||
|
begin
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.DoMoveBySmall(',IntToStr(Amount),')');{$Endif}
|
||||||
|
Include(FGridStatus, gsVisibleMove);
|
||||||
|
FDatalink.MoveBy(Amount);
|
||||||
|
Exclude(FGridStatus, gsVisibleMove);
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.doMoveBySmall FIN');{$Endif}
|
||||||
|
end;
|
||||||
|
procedure DoCancel;
|
||||||
|
begin
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.doCancel INIT');{$Endif}
|
||||||
|
if EditorMode then
|
||||||
|
EditorCancelEditing;
|
||||||
|
FDatalink.Dataset.cancel;
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.doCancel FIN');{$Endif}
|
||||||
|
end;
|
||||||
|
procedure DoDelete;
|
||||||
|
begin
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.doDelete INIT');{$Endif}
|
||||||
|
FDatalink.Dataset.Delete;
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.doDelete FIN');{$Endif}
|
||||||
|
end;
|
||||||
|
procedure DoAppend;
|
||||||
|
begin
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.doAppend INIT');{$Endif}
|
||||||
|
FDatalink.Dataset.Append;
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.doAppend FIN');{$Endif}
|
||||||
|
end;
|
||||||
|
procedure DoInsert;
|
||||||
|
begin
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.doInsert INIT');{$Endif}
|
||||||
|
FDatalink.Dataset.Insert;
|
||||||
|
{$IfDef dbgGrid}DebugLn('KeyDown.doInsert FIN');{$Endif}
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
{$IfDef dbgGrid}DebugLn('DbGrid.KeyDown INIT Key= ',IntToStr(Key));{$Endif}
|
||||||
case Key of
|
case Key of
|
||||||
VK_DELETE:
|
VK_DELETE:
|
||||||
if (ssCtrl in Shift) and GridCanModify then begin
|
if (ssCtrl in Shift) and GridCanModify then begin
|
||||||
if not (dgConfirmDelete in Options) or
|
if not (dgConfirmDelete in Options) or
|
||||||
(MessageDlg('Delete record?',mtConfirmation,mbOKCancel,0)<>mrCancel)
|
(MessageDlg('Delete record?',mtConfirmation,mbOKCancel,0)<>mrCancel)
|
||||||
then
|
then
|
||||||
FDatalink.Dataset.Delete;
|
doDelete;
|
||||||
end;
|
end;
|
||||||
VK_DOWN:
|
VK_DOWN:
|
||||||
if FDatalink.DataSet <> nil then
|
if ValidDataSet then
|
||||||
with FDatalink.Dataset do begin
|
with FDatalink.Dataset do begin
|
||||||
DoOnKeyDown;
|
DoOnKeyDown;
|
||||||
Key := 0;
|
Key := 0;
|
||||||
if (State=dsInsert)and not (Modified or FDataLink.FModified) then begin
|
if InsertCancelable then
|
||||||
|
begin
|
||||||
if IsEOF then
|
if IsEOF then
|
||||||
exit
|
//exit
|
||||||
else
|
else
|
||||||
cancel;
|
doCancel;
|
||||||
end else begin
|
end else begin
|
||||||
FDatalink.MoveBy(1);
|
doMoveBySmall(1);
|
||||||
if GridCanModify and FDataLink.EOF then
|
if GridCanModify and FDataLink.EOF then
|
||||||
Append;
|
doAppend;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
VK_UP:
|
VK_UP:
|
||||||
if FDataLink.DataSet <> nil then
|
if ValidDataSet then
|
||||||
with FDataLink.DataSet do begin
|
with FDataLink.DataSet do begin
|
||||||
doOnKeyDown;
|
doOnKeyDown;
|
||||||
if (State=dsInsert) and IsEOF and not (Modified or FDataLink.FModified) then
|
if InsertCancelable and IsEOF then
|
||||||
cancel
|
doCancel
|
||||||
else
|
else
|
||||||
FDatalink.MoveBy(-1);
|
doMoveBySmall(-1);
|
||||||
key := 0;
|
key := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
VK_NEXT:
|
VK_NEXT:
|
||||||
begin
|
begin
|
||||||
doOnKeyDown;
|
doOnKeyDown;
|
||||||
FDatalink.MoveBy( VisibleRowCount );
|
doMoveBy( VisibleRowCount );
|
||||||
Key := 0;
|
Key := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
VK_PRIOR:
|
VK_PRIOR:
|
||||||
begin
|
begin
|
||||||
doOnKeyDown;
|
doOnKeyDown;
|
||||||
FDatalink.MoveBy( -VisibleRowCount );
|
doMoveBy( -VisibleRowCount );
|
||||||
key := 0;
|
key := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
VK_ESCAPE:
|
VK_ESCAPE:
|
||||||
begin
|
begin
|
||||||
doOnKeyDown;
|
doOnKeyDown;
|
||||||
if EditorMode then
|
if EditorMode then begin
|
||||||
EditorCancelEditing
|
EditorCancelEditing;
|
||||||
else
|
if FDatalink.Active and not FDatalink.Dataset.Modified then
|
||||||
|
FDatalink.Modified := False;
|
||||||
|
end else
|
||||||
if FDataLink.Active then
|
if FDataLink.Active then
|
||||||
FDataLink.DataSet.Cancel;
|
doCancel;
|
||||||
Key:=0;
|
Key:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1257,7 +1344,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
doOnKeyDown;
|
doOnKeyDown;
|
||||||
if GridCanModify then
|
if GridCanModify then
|
||||||
FDataLink.DataSet.Insert;
|
doInsert;
|
||||||
Key:=0;
|
Key:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1288,6 +1375,7 @@ begin
|
|||||||
else
|
else
|
||||||
inherited KeyDown(Key, Shift);
|
inherited KeyDown(Key, Shift);
|
||||||
end;
|
end;
|
||||||
|
{$IfDef dbgGrid}DebugLn('DbGrid.KeyDown END Key= ',IntToStr(Key));{$Endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
|
procedure TCustomDbGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
|
||||||
@ -1295,27 +1383,74 @@ procedure TCustomDbGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
|
|||||||
var
|
var
|
||||||
Gz: TGridZone;
|
Gz: TGridZone;
|
||||||
P: TPoint;
|
P: TPoint;
|
||||||
|
procedure doMouseDown;
|
||||||
|
begin
|
||||||
|
if assigned(OnMouseDown) then
|
||||||
|
OnMouseDown(Self, Button, Shift, X, Y);
|
||||||
|
end;
|
||||||
|
procedure doInherited;
|
||||||
|
begin
|
||||||
|
inherited MouseDown(Button, Shift, X, Y);
|
||||||
|
end;
|
||||||
|
procedure doMoveBy;
|
||||||
|
begin
|
||||||
|
{$IfDef dbgGrid} DebugLn('DbGrid.MouseDown MoveBy INIT'); {$Endif}
|
||||||
|
Include(FGridStatus, gsVisibleMove);
|
||||||
|
FDatalink.MoveBy(P.Y - Row);
|
||||||
|
Exclude(FGridStatus, gsVisibleMove);
|
||||||
|
{$IfDef dbgGrid} DebugLn('DbGrid.MouseDown MoveBy END'); {$Endif}
|
||||||
|
end;
|
||||||
|
procedure doMoveToColumn;
|
||||||
|
begin
|
||||||
|
{$IfDef dbgGrid} DebugLn('DbGrid.MouseDown MoveToCol INIT Col=', IntToStr(P.X)); {$Endif}
|
||||||
|
Col := P.X;
|
||||||
|
{$IfDef dbgGrid} DebugLn('DbGrid.MouseDown MoveToCol END'); {$Endif}
|
||||||
|
end;
|
||||||
|
procedure DoCancel;
|
||||||
|
begin
|
||||||
|
{$IfDef dbgGrid}DebugLn('DbGrid.MouseDown Dataset.CANCEL INIT');{$Endif}
|
||||||
|
if EditorMode then
|
||||||
|
EditorCancelEditing;
|
||||||
|
FDatalink.Dataset.cancel;
|
||||||
|
{$IfDef dbgGrid}DebugLn('DbGrid.MouseDown Dataset.CANCEL FIN');{$Endif}
|
||||||
|
end;
|
||||||
|
procedure DoAcceptValue;
|
||||||
|
begin
|
||||||
|
if EditorMode and FDatalink.FModified then
|
||||||
|
EditorMode := False;
|
||||||
|
end;
|
||||||
begin
|
begin
|
||||||
if csDesigning in componentState then Exit;
|
if csDesigning in componentState then Exit;
|
||||||
if not GCache.ValidGrid then Exit;
|
if not GCache.ValidGrid then Exit;
|
||||||
|
if button<>mbLeft then begin
|
||||||
|
doInherited;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$IfDef dbgGrid} DebugLn('DbGrid.MouseDown INIT'); {$Endif}
|
||||||
Gz:=MouseToGridZone(X,Y);
|
Gz:=MouseToGridZone(X,Y);
|
||||||
case Gz of
|
case Gz of
|
||||||
gzFixedRows, gzFixedCols: inherited MouseDown(Button, Shift, X, Y);
|
gzFixedRows, gzFixedCols:
|
||||||
|
doInherited;
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
P:=MouseToCell(Point(X,Y));
|
P:=MouseToCell(Point(X,Y));
|
||||||
if P.Y=Row then inherited MouseDown(Button, Shift, X, Y)
|
if P.Y=Row then begin
|
||||||
else begin
|
//doAcceptValue;
|
||||||
if assigned(OnMouseDown) then OnMouseDown(Self, Button, Shift, X,Y);
|
doInherited
|
||||||
BeginUpdate;
|
end else begin
|
||||||
FDatalink.MoveBy(P.Y - Row);
|
doMouseDown;
|
||||||
Col:=P.X;
|
if ValidDataSet then begin
|
||||||
EndUpdate(uoQuick);
|
if InsertCancelable and IsEOF then
|
||||||
|
doCancel;
|
||||||
|
doMoveBy;
|
||||||
end;
|
end;
|
||||||
|
doMoveToColumn;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
{$IfDef dbgGrid} DebugLn('DbGrid.MouseDown END'); {$Endif}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.PrepareCanvas(aCol, aRow: Integer;
|
procedure TCustomDbGrid.PrepareCanvas(aCol, aRow: Integer;
|
||||||
aState: TGridDrawState);
|
aState: TGridDrawState);
|
||||||
@ -1352,15 +1487,17 @@ end;
|
|||||||
|
|
||||||
procedure TCustomDbGrid.EditingColumn(aCol: Integer; Ok: Boolean);
|
procedure TCustomDbGrid.EditingColumn(aCol: Integer; Ok: Boolean);
|
||||||
begin
|
begin
|
||||||
if Ok then
|
if Ok then begin
|
||||||
FEditingColumn := aCol
|
FEditingColumn := aCol;
|
||||||
|
FDatalink.Modified := True;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
FEditingColumn := -1;
|
FEditingColumn := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.EditorCancelEditing;
|
procedure TCustomDbGrid.EditorCancelEditing;
|
||||||
begin
|
begin
|
||||||
EditingColumn(FEditingColumn, False);
|
EditingColumn(FEditingColumn, False); // prevents updating the value
|
||||||
if EditorMode then begin
|
if EditorMode then begin
|
||||||
EditorMode := False;
|
EditorMode := False;
|
||||||
if dgAlwaysShowEditor in Options then
|
if dgAlwaysShowEditor in Options then
|
||||||
@ -1370,9 +1507,10 @@ end;
|
|||||||
|
|
||||||
procedure TCustomDbGrid.EditorDoGetValue;
|
procedure TCustomDbGrid.EditorDoGetValue;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef dbgdbgrid}DebugLn('dbgrid.EditorDoGetValue INIT');{$endif}
|
||||||
inherited EditordoGetValue;
|
inherited EditordoGetValue;
|
||||||
UpdateData;
|
UpdateData;
|
||||||
EditingColumn(FEditingColumn, False);
|
{$ifdef dbgdbgrid}DebugLn('dbgrid.EditorDoGetValue FIN');{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.CellClick(const aCol, aRow: Integer);
|
procedure TCustomDbGrid.CellClick(const aCol, aRow: Integer);
|
||||||
@ -1433,16 +1571,45 @@ end;
|
|||||||
|
|
||||||
procedure TCustomDbGrid.DoExit;
|
procedure TCustomDbGrid.DoExit;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef dbgdbgrid}DebugLn('DbGrid.DoExit INIT');{$Endif}
|
||||||
if not EditorShowing then begin
|
if not EditorShowing then begin
|
||||||
if FDataLink.Active then begin
|
if ValidDataSet and (dgCancelOnExit in Options) and
|
||||||
if (FDataLink.DataSet.State=dsInsert) and (dgCancelOnExit in Options)
|
InsertCancelable then
|
||||||
then begin
|
begin
|
||||||
FDataLink.DataSet.Cancel;
|
FDataLink.DataSet.Cancel;
|
||||||
EditorCancelEditing;
|
EditorCancelEditing;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
inherited DoExit;
|
inherited DoExit;
|
||||||
|
{$ifdef dbgdbgrid}DebugLn('DbGrid.DoExit FIN');{$Endif}
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomDbGrid.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint
|
||||||
|
): Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if Assigned(OnMouseWheelDown) then
|
||||||
|
OnMouseWheelDown(Self, Shift, MousePos, Result);
|
||||||
|
if not Result and FDatalink.Active then begin
|
||||||
|
Include(FGridStatus, gsVisibleMove);
|
||||||
|
FDatalink.MoveBy(1);
|
||||||
|
Exclude(FGridStatus, gsVisibleMove);
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomDbGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint
|
||||||
|
): Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if Assigned(OnMouseWheelUp) then
|
||||||
|
OnMouseWheelUp(Self, Shift, MousePos, Result);
|
||||||
|
if not Result and FDatalink.Active then begin
|
||||||
|
Include(FGridStatus, gsVisibleMove);
|
||||||
|
FDatalink.MoveBy(-1);
|
||||||
|
Exclude(FGridStatus, gsVisibleMove);
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomDbGrid.GetEditMask(aCol, aRow: Longint): string;
|
function TCustomDbGrid.GetEditMask(aCol, aRow: Longint): string;
|
||||||
@ -1475,11 +1642,6 @@ end;
|
|||||||
|
|
||||||
function TCustomDbGrid.GridCanModify: boolean;
|
function TCustomDbGrid.GridCanModify: boolean;
|
||||||
begin
|
begin
|
||||||
{$ifdef dbgdbgrid}
|
|
||||||
DebugLn(' ReadOnly=', BoolToStr(ReadOnly), ' dgEditing=', BoolToStr(dgEditing in Options));
|
|
||||||
DebugLn(' FDatalink.ReadOnly=', BoolToStr(FDatalink.ReadOnly), ' FDatalink.ACtive=', BooltoStr(FDatalink.ACtive));
|
|
||||||
DebugLn(' ds.CanModify=',BoolToStr(Fdatalink.Dataset.CanModify));
|
|
||||||
{$endif}
|
|
||||||
result := not ReadOnly and (dgEditing in Options) and not FDataLink.ReadOnly
|
result := not ReadOnly and (dgEditing in Options) and not FDataLink.ReadOnly
|
||||||
and FDataLink.Active and FDatalink.DataSet.CanModify;
|
and FDataLink.Active and FDatalink.DataSet.CanModify;
|
||||||
end;
|
end;
|
||||||
@ -1488,29 +1650,27 @@ procedure TCustomDbGrid.MoveSelection;
|
|||||||
begin
|
begin
|
||||||
if FSelectionLock then
|
if FSelectionLock then
|
||||||
exit;
|
exit;
|
||||||
|
{$ifdef dbgdbgrid}DebugLn('DbGrid.MoveSelection INIT');{$Endif}
|
||||||
inherited MoveSelection;
|
inherited MoveSelection;
|
||||||
if FColEnterPending and Assigned(OnColEnter) then begin
|
if FColEnterPending and Assigned(OnColEnter) then begin
|
||||||
OnColEnter(Self);
|
OnColEnter(Self);
|
||||||
end;
|
end;
|
||||||
FColEnterPending:=False;
|
FColEnterPending:=False;
|
||||||
UpdateActive;
|
UpdateActive;
|
||||||
|
{$ifdef dbgdbgrid}DebugLn('DbGrid.MoveSelection FIN');{$Endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.DrawByRows;
|
procedure TCustomDbGrid.DrawByRows;
|
||||||
var
|
var
|
||||||
CurActiveRecord: Integer;
|
CurActiveRecord: Integer;
|
||||||
begin
|
begin
|
||||||
//CheckBrowse;
|
|
||||||
if FDataLink.Active then begin
|
if FDataLink.Active then begin
|
||||||
//if FCanBrowse then begin
|
|
||||||
CurActiveRecord:=FDataLink.ActiveRecord;
|
CurActiveRecord:=FDataLink.ActiveRecord;
|
||||||
//PrimerRecord:=FDataLink.FirstRecord;
|
|
||||||
end;
|
end;
|
||||||
try
|
try
|
||||||
inherited DrawByRows;
|
inherited DrawByRows;
|
||||||
finally
|
finally
|
||||||
if FDataLink.Active then
|
if FDataLink.Active then
|
||||||
//if FCanBrowse then
|
|
||||||
FDataLink.ActiveRecord:=CurActiveRecord;
|
FDataLink.ActiveRecord:=CurActiveRecord;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1535,13 +1695,25 @@ begin
|
|||||||
FDrawingActiveRecord := ARow = Row;
|
FDrawingActiveRecord := ARow = Row;
|
||||||
end else
|
end else
|
||||||
FDrawingActiveRecord := False;
|
FDrawingActiveRecord := False;
|
||||||
|
{$ifdef dbgGridPaint}
|
||||||
|
DbgOut('DrawRow Row=', IntToStr(ARow), ' Act=', Copy(BoolToStr(FDrawingActiveRecord),1,1));
|
||||||
|
{$endif}
|
||||||
inherited DrawRow(ARow);
|
inherited DrawRow(ARow);
|
||||||
|
{$ifdef dbgGridPaint}
|
||||||
|
DebugLn('End Row')
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.DrawCell(aCol, aRow: Integer; aRect: TRect;
|
procedure TCustomDbGrid.DrawCell(aCol, aRow: Integer; aRect: TRect;
|
||||||
aState: TGridDrawState);
|
aState: TGridDrawState);
|
||||||
begin
|
begin
|
||||||
inherited DrawCell(aCol, aRow, aRect, aState);
|
inherited DrawCell(aCol, aRow, aRect, aState);
|
||||||
|
{$ifdef dbgGridPaint}
|
||||||
|
DbgOut(' ',IntToStr(aCol));
|
||||||
|
if gdSelected in aState then DbgOut('S');
|
||||||
|
if gdFocused in aState then DbgOut('*');
|
||||||
|
if gdFixed in aState then DbgOut('F');
|
||||||
|
{$endif dbgGridPaint}
|
||||||
if Assigned(OnDrawColumnCell) and not(CsDesigning in ComponentState) then
|
if Assigned(OnDrawColumnCell) and not(CsDesigning in ComponentState) then
|
||||||
OnDrawColumnCell(Self, aRect, aCol, TColumn(ColumnFromGridColumn(aCol)), aState)
|
OnDrawColumnCell(Self, aRect, aCol, TColumn(ColumnFromGridColumn(aCol)), aState)
|
||||||
else
|
else
|
||||||
@ -1556,7 +1728,8 @@ begin
|
|||||||
if FDataLink.Active then begin
|
if FDataLink.Active then begin
|
||||||
aField := SelectedField;
|
aField := SelectedField;
|
||||||
if aField<>nil then begin
|
if aField<>nil then begin
|
||||||
Result := aField.IsValidChar(Ch);
|
Result := aField.IsValidChar(Ch) and not aField.Calculated and
|
||||||
|
(aField.DataType<>ftAutoInc);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1585,20 +1758,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDbGrid.UpdateActive;
|
procedure TCustomDbGrid.UpdateActive;
|
||||||
|
var
|
||||||
|
PrevRow: Integer;
|
||||||
begin
|
begin
|
||||||
with FDataLink do begin
|
if not FDatalink.Active then
|
||||||
if not Active then exit;
|
exit;
|
||||||
{$IfDef dbgdbgrid}
|
{$IfDef dbgdbgrid}
|
||||||
DebugLn(Name,'.UpdateActive: ActiveRecord=', dbgs(ActiveRecord),
|
DebugLn(Name,'.UpdateActive: ActiveRecord=', dbgs(FDataLink.ActiveRecord),
|
||||||
' FixedRows=',dbgs(FixedRows), ' Row=', dbgs(Row));
|
' FixedRows=',dbgs(FixedRows), ' Row=', dbgs(Row));
|
||||||
{$endif}
|
{$endif}
|
||||||
if FixedRows + ActiveRecord <> Row then begin
|
PrevRow := Row;
|
||||||
InvalidateRow(Row);
|
Row:= FixedRows + FDataLink.ActiveRecord;
|
||||||
EditingColumn(Col, false);
|
if PrevRow<>Row then
|
||||||
end;
|
InvalidateCell(0, PrevRow);//(InvalidateRow(PrevRow);
|
||||||
Row:= FixedRows + ActiveRecord;
|
|
||||||
end;
|
|
||||||
//Invalidate;
|
|
||||||
InvalidateRow(Row);
|
InvalidateRow(Row);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1889,14 +2061,6 @@ begin
|
|||||||
*)
|
*)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentDataLink.Modified;
|
|
||||||
begin
|
|
||||||
{$ifdef dbgdbgrid}
|
|
||||||
DebugLn(ClassName,'.Modified');
|
|
||||||
{$Endif}
|
|
||||||
FModified:=True;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDbGridColumns }
|
{ TDbGridColumns }
|
||||||
|
|
||||||
function TDbGridColumns.GetColumn(Index: Integer): TColumn;
|
function TDbGridColumns.GetColumn(Index: Integer): TColumn;
|
||||||
@ -2051,6 +2215,9 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.38 2005/03/29 21:56:02 marc
|
||||||
|
* patch from Jesus Reyes
|
||||||
|
|
||||||
Revision 1.37 2005/03/24 09:50:03 mattias
|
Revision 1.37 2005/03/24 09:50:03 mattias
|
||||||
checking HandleAllocated for dbgrid from Jesus
|
checking HandleAllocated for dbgrid from Jesus
|
||||||
|
|
||||||
|
@ -1092,6 +1092,7 @@ type
|
|||||||
procedure Clean(StartCol,StartRow,EndCol,EndRow: integer; CleanOptions: TCleanOptions); overload;
|
procedure Clean(StartCol,StartRow,EndCol,EndRow: integer; CleanOptions: TCleanOptions); overload;
|
||||||
property Cells[ACol, ARow: Integer]: string read GetCells write SetCells;
|
property Cells[ACol, ARow: Integer]: string read GetCells write SetCells;
|
||||||
property Cols[index: Integer]: TStrings read GetCols write SetCols;
|
property Cols[index: Integer]: TStrings read GetCols write SetCols;
|
||||||
|
property ExtendedSelect;
|
||||||
property Objects[ACol, ARow: Integer]: TObject read GetObjects write SetObjects;
|
property Objects[ACol, ARow: Integer]: TObject read GetObjects write SetObjects;
|
||||||
property Rows[index: Integer]: TStrings read GetRows write SetRows;
|
property Rows[index: Integer]: TStrings read GetRows write SetRows;
|
||||||
property UseXORFeatures;
|
property UseXORFeatures;
|
||||||
@ -1282,6 +1283,7 @@ begin
|
|||||||
CM_CONTROLCHANGE: DebugLn(Hex, 'CM_CONTROLCHANGE');
|
CM_CONTROLCHANGE: DebugLn(Hex, 'CM_CONTROLCHANGE');
|
||||||
CM_SHOWINGCHANGED: DebugLn(Hex, 'CM_SHOWINGCHANGED');
|
CM_SHOWINGCHANGED: DebugLn(Hex, 'CM_SHOWINGCHANGED');
|
||||||
CM_VISIBLECHANGED: DebugLn(Hex, 'CM_VISIBLECHANGED');
|
CM_VISIBLECHANGED: DebugLn(Hex, 'CM_VISIBLECHANGED');
|
||||||
|
CM_HITTEST: ;//DebugLn(HEx, 'CM_HITTEST');
|
||||||
else DebugLn(Hex, 'CM_BASE + ', IntToStr(Msg - CM_BASE));
|
else DebugLn(Hex, 'CM_BASE + ', IntToStr(Msg - CM_BASE));
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
@ -1306,9 +1308,9 @@ begin
|
|||||||
LM_WINDOWPOSCHANGED: DebugLn(hex, 'LM_WINDOWPOSCHANGED');
|
LM_WINDOWPOSCHANGED: DebugLn(hex, 'LM_WINDOWPOSCHANGED');
|
||||||
LM_HSCROLL: DebugLn(hex, 'LM_HSCROLL');
|
LM_HSCROLL: DebugLn(hex, 'LM_HSCROLL');
|
||||||
LM_VSCROLL: DebugLn(hex, 'LM_VSCROLL');
|
LM_VSCROLL: DebugLn(hex, 'LM_VSCROLL');
|
||||||
|
|
||||||
LM_MOUSEMOVE: ;//DebugLn(hex, 'LM_MOUSEMOVE');
|
LM_MOUSEMOVE: ;//DebugLn(hex, 'LM_MOUSEMOVE');
|
||||||
LM_MOUSEWHEEL: DebugLn(Hex, 'LM_MOUSEWHEEL');
|
LM_MOUSEWHEEL: DebugLn(Hex, 'LM_MOUSEWHEEL');
|
||||||
|
1105: ;//DebugLn(hex, '?EM_SETWORDBREAKPROCEX?');
|
||||||
else DebugLn(hex, GetMessageName(Msg));
|
else DebugLn(hex, GetMessageName(Msg));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -3667,6 +3669,7 @@ procedure TCustomGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
|
|||||||
var
|
var
|
||||||
Gz: TGridZone;
|
Gz: TGridZone;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
|
WasFocused: boolean;
|
||||||
begin
|
begin
|
||||||
inherited MouseDown(Button, Shift, X, Y);
|
inherited MouseDown(Button, Shift, X, Y);
|
||||||
|
|
||||||
@ -3674,7 +3677,7 @@ begin
|
|||||||
if not (ssLeft in Shift) then Exit;
|
if not (ssLeft in Shift) then Exit;
|
||||||
if csDesigning in componentState then Exit;
|
if csDesigning in componentState then Exit;
|
||||||
|
|
||||||
{$IfDef dbgFocus} DebugLn('MouseDown INIT'); {$Endif}
|
{$IfDef dbgGrid} DebugLn('MouseDown INIT'); {$Endif}
|
||||||
|
|
||||||
Gz:=MouseToGridZone(X,Y);
|
Gz:=MouseToGridZone(X,Y);
|
||||||
case Gz of
|
case Gz of
|
||||||
@ -3717,7 +3720,10 @@ begin
|
|||||||
// normal selecting
|
// normal selecting
|
||||||
fGridState:=gsSelecting;
|
fGridState:=gsSelecting;
|
||||||
FSplitter:=MouseToCell(Point(X,Y));
|
FSplitter:=MouseToCell(Point(X,Y));
|
||||||
if not Focused then setFocus;
|
|
||||||
|
WasFocused := Focused;
|
||||||
|
if not WasFocused then
|
||||||
|
SetFocus;
|
||||||
|
|
||||||
if not (goEditing in Options) or
|
if not (goEditing in Options) or
|
||||||
(ExtendedSelect and not EditorAlwaysShown) then begin
|
(ExtendedSelect and not EditorAlwaysShown) then begin
|
||||||
@ -3746,7 +3752,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$ifDef dbgFocus} DebugLn('MouseDown END'); {$Endif}
|
{$ifDef dbgGrid} DebugLn('MouseDown END'); {$Endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TCustomGrid.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
@ -3782,7 +3788,7 @@ var
|
|||||||
begin
|
begin
|
||||||
inherited MouseUp(Button, Shift, X, Y);
|
inherited MouseUp(Button, Shift, X, Y);
|
||||||
if not FGCache.ValidGrid then Exit;
|
if not FGCache.ValidGrid then Exit;
|
||||||
{$IfDef dbgFocus}DebugLn('MouseUP INIT');{$Endif}
|
{$IfDef dbgGrid}DebugLn('MouseUP INIT');{$Endif}
|
||||||
Cur:=MouseToCell(Point(x,y));
|
Cur:=MouseToCell(Point(x,y));
|
||||||
case fGridState of
|
case fGridState of
|
||||||
gsNormal:
|
gsNormal:
|
||||||
@ -3842,7 +3848,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
fGridState:=gsNormal;
|
fGridState:=gsNormal;
|
||||||
{$IfDef dbgFocus}DebugLn('MouseUP END RND=', FloatToStr(Random));{$Endif}
|
{$IfDef dbgGrid}DebugLn('MouseUP END RND=', FloatToStr(Random));{$Endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.DblClick;
|
procedure TCustomGrid.DblClick;
|
||||||
@ -3982,10 +3988,10 @@ end;
|
|||||||
procedure TCustomGrid.doExit;
|
procedure TCustomGrid.doExit;
|
||||||
begin
|
begin
|
||||||
if FEditorShowing then begin
|
if FEditorShowing then begin
|
||||||
{$IfDef dbgFocus}DebugLn('DoExit - EditorShowing');{$Endif}
|
{$IfDef dbgGrid}DebugLn('DoExit - EditorShowing');{$Endif}
|
||||||
end else begin
|
end else begin
|
||||||
{$IfDef dbgFocus}DebugLn('DoExit - Ext');{$Endif}
|
{$IfDef dbgGrid}DebugLn('DoExit - Ext');{$Endif}
|
||||||
Invalidate;
|
//Invalidate;
|
||||||
end;
|
end;
|
||||||
inherited DoExit;
|
inherited DoExit;
|
||||||
end;
|
end;
|
||||||
@ -3994,23 +4000,26 @@ procedure TCustomGrid.DoEnter;
|
|||||||
begin
|
begin
|
||||||
inherited DoEnter;
|
inherited DoEnter;
|
||||||
if FEditorHiding then begin
|
if FEditorHiding then begin
|
||||||
{$IfDef dbgFocus}DebugLn('DoEnter - EditorHiding');{$Endif}
|
{$IfDef dbgGrid}DebugLn('DoEnter - EditorHiding');{$Endif}
|
||||||
end else begin
|
end else begin
|
||||||
{$IfDef dbgFocus}DebugLn('DoEnter - Ext');{$Endif}
|
{$IfDef dbgGrid}DebugLn('DoEnter - Ext');{$Endif}
|
||||||
//exit;
|
//exit;
|
||||||
if EditorAlwaysShown then begin
|
if EditorAlwaysShown then begin
|
||||||
SelectEditor;
|
SelectEditor;
|
||||||
if Feditor=nil then Invalidate
|
if Feditor=nil then
|
||||||
|
//Invalidate
|
||||||
else begin
|
else begin
|
||||||
EditorShow(true);
|
EditorShow(true);
|
||||||
end;
|
end;
|
||||||
end else Invalidate;
|
end else
|
||||||
|
//Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGrid.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint
|
function TCustomGrid.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint
|
||||||
): Boolean;
|
): Boolean;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef dbgGrid}DebugLn('doMouseWheelDown INIT');{$endif}
|
||||||
Result:=inherited DoMouseWheelDown(Shift, MousePos);
|
Result:=inherited DoMouseWheelDown(Shift, MousePos);
|
||||||
if not result then begin
|
if not result then begin
|
||||||
// event wasn't handled by the user
|
// event wasn't handled by the user
|
||||||
@ -4018,12 +4027,15 @@ begin
|
|||||||
MoveExtend(true, 1, 0)
|
MoveExtend(true, 1, 0)
|
||||||
else
|
else
|
||||||
MoveExtend(true, 0, 1);
|
MoveExtend(true, 0, 1);
|
||||||
|
Result := true;
|
||||||
end;
|
end;
|
||||||
|
{$ifdef dbgGrid}DebugLn('doMouseWheelDown FIN');{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint
|
function TCustomGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint
|
||||||
): Boolean;
|
): Boolean;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef dbgGrid}DebugLn('doMouseWheelUP INIT');{$endif}
|
||||||
Result:=inherited DoMouseWheelUp(Shift, MousePos);
|
Result:=inherited DoMouseWheelUp(Shift, MousePos);
|
||||||
if not result then begin
|
if not result then begin
|
||||||
// event wasn't handled by the user
|
// event wasn't handled by the user
|
||||||
@ -4031,7 +4043,9 @@ begin
|
|||||||
MoveExtend(true, -1, 0)
|
MoveExtend(true, -1, 0)
|
||||||
else
|
else
|
||||||
MoveExtend(true, 0, -1);
|
MoveExtend(true, 0, -1);
|
||||||
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
{$ifdef dbgGrid}DebugLn('doMouseWheelUP FIN');{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.KeyDown(var Key: Word; Shift: TShiftState);
|
procedure TCustomGrid.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
@ -4052,6 +4066,7 @@ var
|
|||||||
Relaxed: Boolean;
|
Relaxed: Boolean;
|
||||||
//PF: TCustomForm;
|
//PF: TCustomForm;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef dbgGrid}DebugLn('Grid.KeyDown INIT Key=',IntToStr(Key));{$endif}
|
||||||
inherited KeyDown(Key, Shift);
|
inherited KeyDown(Key, Shift);
|
||||||
if not FGCache.ValidGrid then Exit;
|
if not FGCache.ValidGrid then Exit;
|
||||||
Sh:=(ssShift in Shift);
|
Sh:=(ssShift in Shift);
|
||||||
@ -4167,11 +4182,8 @@ begin
|
|||||||
doCutToClipboard;
|
doCutToClipboard;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IfDef Dbg}
|
|
||||||
else DebugLn(ClassName,'.KeyDown: ', Key);
|
|
||||||
{$Endif}
|
|
||||||
end;
|
end;
|
||||||
|
{$ifdef dbgGrid}DebugLn('Grid.KeyDown FIN Key=',IntToStr(Key));{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -4229,7 +4241,7 @@ procedure TCustomGrid.InvalidateCol(ACol: Integer);
|
|||||||
var
|
var
|
||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
{$ifdef dbg} DebugLn('InvalidateCol Col=',aCol); {$Endif}
|
{$ifdef dbgPaint} DebugLn('InvalidateCol Col=',IntToStr(aCol)); {$Endif}
|
||||||
R:=CellRect(aCol, FTopLeft.y);
|
R:=CellRect(aCol, FTopLeft.y);
|
||||||
R.Top:=0; // Full Column
|
R.Top:=0; // Full Column
|
||||||
R.Bottom:=FGCache.MaxClientXY.Y;
|
R.Bottom:=FGCache.MaxClientXY.Y;
|
||||||
@ -4240,7 +4252,7 @@ procedure TCustomGrid.InvalidateFromCol(ACol: Integer);
|
|||||||
var
|
var
|
||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
{$IFDEF dbg} DebugLn('InvalidateFromCol Col=',aCol); {$ENDIF}
|
{$IFDEF dbgPaint} DebugLn('InvalidateFromCol Col=',IntToStr(aCol)); {$Endif}
|
||||||
R:=CellRect(aCol, FTopLeft.y);
|
R:=CellRect(aCol, FTopLeft.y);
|
||||||
R.Top:=0; // Full Column
|
R.Top:=0; // Full Column
|
||||||
R.BottomRight := FGCache.MaxClientXY;
|
R.BottomRight := FGCache.MaxClientXY;
|
||||||
@ -4251,7 +4263,7 @@ procedure TCustomGrid.InvalidateRow(ARow: Integer);
|
|||||||
var
|
var
|
||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
{$ifdef dbg} DebugLn('InvalidateRow Row=',aRow); {$Endif}
|
{$ifdef DbgPaint} DebugLn('InvalidateRow Row=',IntToStr(aRow)); {$Endif}
|
||||||
R:=CellRect(fTopLeft.x, aRow);
|
R:=CellRect(fTopLeft.x, aRow);
|
||||||
R.Left:=0; // Full row
|
R.Left:=0; // Full row
|
||||||
R.Right:=FGCache.MaxClientXY.X;
|
R.Right:=FGCache.MaxClientXY.X;
|
||||||
@ -4261,17 +4273,18 @@ end;
|
|||||||
function TCustomGrid.MoveExtend(Relative: Boolean; DCol, DRow: Integer): Boolean;
|
function TCustomGrid.MoveExtend(Relative: Boolean; DCol, DRow: Integer): Boolean;
|
||||||
var
|
var
|
||||||
InvalidateAll: Boolean;
|
InvalidateAll: Boolean;
|
||||||
LastEditor: TWinControl;
|
//LastEditor: TWinControl;
|
||||||
WasVis: Boolean;
|
//WasVis: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=TryMoveSelection(Relative,DCol,DRow);
|
Result:=TryMoveSelection(Relative,DCol,DRow);
|
||||||
if (not Result) then Exit;
|
if (not Result) then Exit;
|
||||||
|
|
||||||
|
{$IfDef dbgGrid}DebugLn(' MoveExtend INIT FCol= ',IntToStr(FCol), ' FRow= ',IntToStr(FRow));{$Endif}
|
||||||
BeforeMoveSelection(DCol,DRow);
|
BeforeMoveSelection(DCol,DRow);
|
||||||
{$IfDef dbgFocus}DebugLn(' MoveExtend INIT FCol= ',IntToStr(FCol), ' FRow= ',IntToStr(FRow));{$Endif}
|
|
||||||
|
|
||||||
LastEditor:=Editor;
|
//LastEditor:=Editor;
|
||||||
WasVis:=(LastEditor<>nil)and(LastEditor.Visible);
|
//WasVis:=(LastEditor<>nil)and(LastEditor.Visible);
|
||||||
|
EditorGetValue;
|
||||||
|
|
||||||
InvalidateAll:=False;
|
InvalidateAll:=False;
|
||||||
// default range
|
// default range
|
||||||
@ -4316,9 +4329,12 @@ begin
|
|||||||
MoveSelection;
|
MoveSelection;
|
||||||
SelectEditor;
|
SelectEditor;
|
||||||
|
|
||||||
ProcessEditor(LastEditor,DCol,DRow,WasVis);
|
if (FEditor<>nil) and EditorAlwaysShown then
|
||||||
|
EditorShow(true);
|
||||||
|
|
||||||
|
//ProcessEditor(LastEditor,DCol,DRow,WasVis);
|
||||||
|
|
||||||
{$IfDef dbgFocus}DebugLn(' MoveExtend FIN FCol= ',IntToStr(FCol), ' FRow= ',IntToStr(FRow));{$Endif}
|
{$IfDef dbgGrid}DebugLn(' MoveExtend FIN FCol= ',IntToStr(FCol), ' FRow= ',IntToStr(FRow));{$Endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGrid.MoveNextAuto: boolean;
|
function TCustomGrid.MoveNextAuto: boolean;
|
||||||
@ -4436,7 +4452,7 @@ var
|
|||||||
WillVis: Boolean;
|
WillVis: Boolean;
|
||||||
begin
|
begin
|
||||||
WillVis:=(FEditor<>nil)and EditorAlwaysShown;
|
WillVis:=(FEditor<>nil)and EditorAlwaysShown;
|
||||||
{$ifdef DbgFocus}
|
{$ifdef dbgGrid}
|
||||||
DebugLn(' ProcessEditor INIT WasVis=', BoolToStr(WasVis),' WillVis=', BoolToStr(WillVis));
|
DebugLn(' ProcessEditor INIT WasVis=', BoolToStr(WasVis),' WillVis=', BoolToStr(WillVis));
|
||||||
{$endif}
|
{$endif}
|
||||||
if WillVis or WasVis then begin
|
if WillVis or WasVis then begin
|
||||||
@ -4447,7 +4463,7 @@ begin
|
|||||||
EditorShow(EditorAlwaysShown);
|
EditorShow(EditorAlwaysShown);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$ifdef DbgFocus}
|
{$ifdef dbgGrid}
|
||||||
DebugLn(' ProcessEditor FIN');
|
DebugLn(' ProcessEditor FIN');
|
||||||
{$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
@ -4555,7 +4571,8 @@ var
|
|||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
{$IfDef dbgPaint}
|
{$IfDef dbgPaint}
|
||||||
DebugLn('InvalidateCell Col=',aCol, ' Row=',aRow,' Redraw=',Redraw);
|
DebugLn('InvalidateCell Col=',IntToStr(aCol),
|
||||||
|
' Row=',IntToStr(aRow),' Redraw=', BoolToStr(Redraw));
|
||||||
{$Endif}
|
{$Endif}
|
||||||
R:=CellRect(aCol, aRow);
|
R:=CellRect(aCol, aRow);
|
||||||
InvalidateRect(Handle, @R, Redraw);
|
InvalidateRect(Handle, @R, Redraw);
|
||||||
@ -4568,9 +4585,11 @@ end;
|
|||||||
|
|
||||||
procedure TCustomGrid.Invalidate;
|
procedure TCustomGrid.Invalidate;
|
||||||
begin
|
begin
|
||||||
if FUpdateCount=0 then
|
if FUpdateCount=0 then begin
|
||||||
|
{$IfDef dbgPaint} DebugLn('Invalidate');{$Endif}
|
||||||
inherited Invalidate;
|
inherited Invalidate;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.EditorGetValue;
|
procedure TCustomGrid.EditorGetValue;
|
||||||
begin
|
begin
|
||||||
@ -4594,11 +4613,11 @@ begin
|
|||||||
and Editor.Visible then
|
and Editor.Visible then
|
||||||
begin
|
begin
|
||||||
FEditorMode:=False;
|
FEditorMode:=False;
|
||||||
{$IfDef dbgFocus} DebugLn('EditorHide [',Editor.ClassName,'] INIT FCol=',IntToStr(FCol),' FRow=',IntToStr(FRow));{$Endif}
|
{$IfDef dbgGrid} DebugLn('EditorHide [',Editor.ClassName,'] INIT FCol=',IntToStr(FCol),' FRow=',IntToStr(FRow));{$Endif}
|
||||||
FEditorHiding:=True;
|
FEditorHiding:=True;
|
||||||
DoEditorHide;
|
DoEditorHide;
|
||||||
FEditorHiding:=False;
|
FEditorHiding:=False;
|
||||||
{$IfDef dbgFocus} DebugLn('EditorHide FIN'); {$Endif}
|
{$IfDef dbgGrid} DebugLn('EditorHide FIN'); {$Endif}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4611,12 +4630,12 @@ begin
|
|||||||
if (goEditing in Options) and
|
if (goEditing in Options) and
|
||||||
not FEditorShowing and (Editor<>nil) and not Editor.Visible then
|
not FEditorShowing and (Editor<>nil) and not Editor.Visible then
|
||||||
begin
|
begin
|
||||||
{$IfDef dbgFocus} DebugLn('EditorShow [',Editor.ClassName,']INIT FCol=',IntToStr(FCol),' FRow=',IntToStr(FRow));{$Endif}
|
{$IfDef dbgGrid} DebugLn('EditorShow [',Editor.ClassName,']INIT FCol=',IntToStr(FCol),' FRow=',IntToStr(FRow));{$Endif}
|
||||||
FEditorMode:=True;
|
FEditorMode:=True;
|
||||||
FEditorShowing:=True;
|
FEditorShowing:=True;
|
||||||
doEditorShow;
|
doEditorShow;
|
||||||
FEditorShowing:=False;
|
FEditorShowing:=False;
|
||||||
{$IfDef dbgFocus} DebugLn('EditorShow FIN');{$Endif}
|
{$IfDef dbgGrid} DebugLn('EditorShow FIN');{$Endif}
|
||||||
if SelAll then
|
if SelAll then
|
||||||
EditorSelectAll;
|
EditorSelectAll;
|
||||||
end;
|
end;
|
||||||
@ -4732,17 +4751,18 @@ end;
|
|||||||
procedure TCustomGrid.EditorExit(Sender: TObject);
|
procedure TCustomGrid.EditorExit(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if not FEditorHiding then begin
|
if not FEditorHiding then begin
|
||||||
{$IfDef dbgFocus} DebugLn('EditorExit INIT');{$Endif}
|
{$IfDef dbgGrid} DebugLn('EditorExit INIT');{$Endif}
|
||||||
FEditorMode:=False;
|
FEditorMode:=False;
|
||||||
FEditorHiding:=True;
|
FEditorHiding:=True;
|
||||||
EditorGetValue;
|
EditorGetValue;
|
||||||
|
|
||||||
if Editor<>nil then begin
|
if Editor<>nil then begin
|
||||||
Editor.Visible:=False;
|
Editor.Visible:=False;
|
||||||
Editor.Parent:=nil;
|
Editor.Parent:=nil;
|
||||||
//InvalidateCell(FCol,FRow, True);
|
//InvalidateCell(FCol,FRow, True);
|
||||||
end;
|
end;
|
||||||
FEditorHiding:=False;
|
FEditorHiding:=False;
|
||||||
{$IfDef dbgFocus} DebugLn('EditorExit FIN'); {$Endif}
|
{$IfDef dbgGrid} DebugLn('EditorExit FIN'); {$Endif}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user