LCL, improved grids TAB-ing, options goTabs or dgTabs, issue #16007

git-svn-id: trunk@27374 -
This commit is contained in:
jesus 2010-09-15 21:37:09 +00:00
parent 3b670b01a2
commit dc4e797f5b
2 changed files with 71 additions and 11 deletions

View File

@ -1962,7 +1962,22 @@ begin
doOnKeyDown;
if Key<>0 then begin
if dgTabs in Options then begin
if ((ssShift in shift) and
(Col<=GetFirstVisibleColumn) and (Row<=GetFirstVisibleRow)) then begin
if EditorKey then
GridFlags := GridFlags + [gfRevEditorTab];
exit;
end;
GetDeltaMoveNext(ssShift in Shift, DeltaCol, DeltaRow);
if (not (ssShift in Shift)) and (Row>=GetLastVisibleRow) and
(DeltaRow>0) and (Col=GetLastVisibleColumn) and
(FDatalink.Editing or not GridCanModify) then begin
exit;
end;
MoveSel(false);
Key := 0;
end;

View File

@ -907,6 +907,10 @@ type
function GetEditMask(ACol, ARow: Longint): string; virtual;
function GetEditText(ACol, ARow: Longint): string; virtual;
function GetFixedcolor: TColor; virtual;
function GetFirstVisibleColumn: Integer;
function GetFirstVisibleRow: Integer;
function GetLastVisibleColumn: Integer;
function GetLastVisibleRow: Integer;
function GetSelectedColor: TColor; virtual;
function GridColumnFromColumnIndex(ColumnIndex: Integer): Integer;
procedure GridMouseWheel(shift: TShiftState; Delta: Integer); virtual;
@ -6103,6 +6107,20 @@ var
Exclude(FGridFlags, gfEditingDone);
Key := 0; { Flag key as handled, even if selected cell did not move }
end;
procedure TabCheckEditorKey;
begin
if FEditorKey then begin
{$IFDEF dbggrid}
DebugLn('Got TAB, shift=',dbgs(sh));
{$endif}
if sh then
GridFlags := GridFlags + [gfRevEditorTab]
else
GridFlags := GridFlags + [gfEditorTab];
end;
end;
const
cBidiMove:array[Boolean] of Integer = (1, -1);
begin
@ -6121,18 +6139,17 @@ begin
if GetDeltaMoveNext(Sh, DeltaCol,DeltaRow) then begin
Sh := False;
MoveSel(True, DeltaCol, DeltaRow);
end;
Key:=0;
end else
if FEditorKey then begin
{$IFDEF dbggrid}
DebugLn('Got TAB, shift=',dbgs(sh));
{$endif}
if sh then
GridFlags := GridFlags + [gfRevEditorTab]
Key:=0;
end else
if (AutoAdvance=aaNone) or
((AutoAdvance=aaDown) and (Row>=GetLastVisibleRow)) or
(sh and (Col<=GetFirstVisibleColumn)) or
((not sh) and (Col>=GetLastVisibleColumn)) then
TabCheckEditorKey
else
GridFlags := GridFlags + [gfEditorTab];
end;
Key := 0;
end else
TabCheckEditorKey;
end;
VK_LEFT:
begin
@ -7567,6 +7584,34 @@ begin
result:=FFixedColor;
end;
function TCustomGrid.GetFirstVisibleColumn: Integer;
begin
result := FixedCols;
while (result<ColCount) and (ColWidths[result]=0) do
inc(result); // extreme case may return colcount
end;
function TCustomGrid.GetFirstVisibleRow: Integer;
begin
result := FixedRows;
while (result<RowCount) and (RowHeights[result]=0) do
inc(result); // ditto
end;
function TCustomGrid.GetLastVisibleColumn: Integer;
begin
result := ColCount-1;
while (result>=0) and (ColWidths[result]=0) do
dec(result); // extreme case may return -1
end;
function TCustomGrid.GetLastVisibleRow: integer;
begin
result := RowCount-1;
while (result>=0) and (RowHeights[result]=0) do
dec(result); // ditto
end;
procedure TCustomGrid.ColWidthsChanged;
begin
//