📄 tseditor.pas
字号:
RowComboDefault: TPersistent = nil;
DesignActivatesFirstTime: Boolean = True;
PrevLeft: Integer = 0;
PrevTop: Integer = 0;
PrevWidth: Integer = 0;
PrevHeight: Integer = 0;
PrevState: TWindowState = wsNormal;
implementation
type
TtsBaseGrid_ = class(TtsBaseGrid) end;
TtsCustomGrid_ = class(TtsCustomGrid) end;
TtsCustomDBGrid_ = class(TtsCustomDBGrid) end;
{$R *.DFM}
{TtsDesignInfo}
constructor TtsDesignInfo.Create(BaseGrid: TtsBaseGrid);
begin
inherited Create;
FBaseGrid := BaseGrid;
end;
function TtsDesignInfo.GetSelectedRows: TtsSelection;
begin
result := TtsBaseGrid_(FBaseGrid).FSelectedRows;
end;
function TtsDesignInfo.GetSelectedCells: TRect;
begin
result := TtsBaseGrid_(FBaseGrid).FSelectedCells;
end;
function TtsDesignInfo.GetCurrentDataRow: Variant;
begin
result := TtsBaseGrid_(FBaseGrid).GetCurrentDataRow;
end;
procedure TtsDesignInfo.SetCurrentDataRow(Value: Variant);
begin
TtsBaseGrid_(FBaseGrid).SetCurrentDataRow(Value);
end;
function TtsDesignInfo.GetRowControlType(DataRow: Variant): TtsControlType;
begin
result := TtsBaseGrid_(FBaseGrid).RowControlType[DataRow];
end;
function TtsDesignInfo.GetCellControlType(DataCol: LongInt; DataRow: Variant): TtsControlType;
begin
result := TtsBaseGrid_(FBaseGrid).CellControlType[DataCol, DataRow];
end;
function TtsDesignInfo.GetCellButtonType(DataCol: LongInt; DataRow: Variant): TtsButtonType;
begin
result := TtsBaseGrid_(FBaseGrid).CellButtonType[DataCol, DataRow];
end;
function TtsDesignInfo.GetRowButtonType(DataRow: Variant): TtsButtonType;
begin
result := TtsBaseGrid_(FBaseGrid).RowButtonType[DataRow];
end;
function TtsDesignInfo.GetRowCombo(DataRow: Variant): TtsCombo;
begin
result := TtsBaseGrid_(FBaseGrid).RowCombo[DataRow];
end;
procedure TtsDesignInfo.SetRowCombo(DataRow: Variant; Value: TtsCombo);
begin
TtsBaseGrid_(FBaseGrid).RowCombo[DataRow] := Value;
end;
function TtsDesignInfo.GetCellCombo(DataCol: LongInt; DataRow: Variant): TtsCombo;
begin
result := TtsBaseGrid_(FBaseGrid).CellCombo[DataCol, DataRow];
end;
procedure TtsDesignInfo.SetCellCombo(DataCol: LongInt; DataRow: Variant; Value: TtsCombo);
begin
TtsBaseGrid_(FBaseGrid).CellCombo[DataCol, DataRow] := Value;
end;
function TtsDesignInfo.GetCombo: TtsCombo;
begin
result := TtsBaseGrid_(FBaseGrid).Combo;
end;
procedure TtsDesignInfo.GetFirstSelectedCell(var DataCol: integer; var DataRow: Variant; StatusSet: TtsGridStats);
begin
with TtsBaseGrid_(FBaseGrid) do
begin
if not (GridStatus in StatusSet) then
begin
DataCol := -1;
DataRow := -1;
exit;
end;
case GridStatus of
grNormal:
begin
DataCol := CurrentCell.DataCol;
DataRow := CurrentCell.DataRow;
end;
grRowSelect:
begin
DataCol := GetFirstVisibleCol;
DataRow := DataRownr[SelectedRows.First];
end;
grColSelect:
begin
DataCol := DataColnr[SelectedCols.First];
DataRow := GetFirstVisibleRow;
end;
grCellSelect:
begin
DataCol := DataColnr[SelectedCells.Left];
DataRow := DataRownr[SelectedCells.Top];
end;
end;
end;
end;
procedure TtsDesignInfo.GetNextSelectedCell(var DataCol: integer; var DataRow: Variant; StatusSet: TtsGridStats);
var
DisplayCol, DisplayRow: integer;
begin
with TtsBaseGrid_(FBaseGrid) do
begin
if not (GridStatus in StatusSet) then
begin
DataCol := -1;
DataRow := -1;
exit;
end;
case GridStatus of
grNormal:
begin
DataCol := -1;
DataRow := -1;
end;
grColSelect:
begin
DisplayCol := SelectedCols.Next(DisplayColnr[DataCol]);
if DisplayCol <> -1 then
DataCol := DataColnr[DisplayCol]
else
begin
DisplayRow := DisplayRowNr[DataRow];
repeat
DisplayRow := DisplayRow + 1;
if DisplayRow > Rows then
break;
until RowVisible[DisplayRow];
if DisplayRow > Rows then
begin
DataCol := -1;
DataRow := -1;
end
else
begin
DataCol := DataColnr[SelectedCols.First];
DataRow := DataRowNr[DisplayRow];
end;
end;
end;
grRowSelect:
begin
DataCol := GetNextVisibleCol(DataCol);
if DataCol = -1 then
begin
DisplayRow := SelectedRows.Next(DisplayRowNr[DataRow]);
if DisplayRow = -1 then
begin
DataRow := -1;
DataCol := -1;
end
else
begin
DataCol := GetFirstVisibleCol;
DataRow := DataRowNr[DisplayRow];
end;
end;
end;
grCellSelect:
begin
DataCol := GetNextVisibleCol(DataCol);
if DataCol <> -1 then
if DisplayColnr[DataCol] > SelectedCells.Right then
DataCol := -1;
if DataCol = -1 then
begin
DataRow := GetNextVisibleRow(DataRow);
if DataRow <> -1 then
if DisplayRownr[DataRow] > SelectedCells.Bottom then
DataRow := -1;
if DataRow = -1 then
DataCol := -1
else
DataCol := DataColnr[SelectedCells.Left];
end;
end;
end;
end;
end;
function TtsDesignInfo.CellSelected(DataCol: integer; DataRow: Variant; StatusSet: TtsGridStats): Boolean;
begin
with TtsBaseGrid_(FBaseGrid) do
begin
if not (GridStatus in StatusSet) then
result := False
else if (DataCol = CurrentCell.DataCol) and (DataRow = CurrentCell.DataRow) and (DataCol <> -1) and (DataRow <> -1) and (GridStatus = grNormal) then
result := True
else
result := CellSelected(DisplayColnr[DataCol], DisplayRownr[DataRow]);
end;
end;
function TtsDesignInfo.CellSelectedCount(StatusSet: TtsGridStats): integer;
begin
with TtsBaseGrid_(FBaseGrid) do
begin
if not (GridStatus in StatusSet) then
begin
result := 0;
exit;
end;
case GridStatus of
grNormal:
result := 1;
grRowSelect:
result := FVisibleCols.Count * SelectedRows.Count;
grColSelect:
result := FVisibleRows.Count * SelectedCols.Count;
grCellSelect:
with SelectedCells do
result := (Bottom - Top) * (Right - Left);
else
result := 0;
end;
end;
end;
function TtsDesignInfo.GetFirstVisibleCol: integer;
var
DisplayCol: integer;
begin
with TtsBaseGrid_(FBaseGrid) do
begin
DisplayCol := 1;
while DisplayCol <= Cols do
begin
if Col[DataColnr[DisplayCol]].Visible then
break;
DisplayCol := DisplayCol + 1;
end;
if DisplayCol <= Cols then
result := DataColnr[DisplayCol]
else
result := -1;
end;
end;
function TtsDesignInfo.GetNextVisibleCol(DataCol: integer): integer;
var
DisplayCol: integer;
begin
with TtsBaseGrid_(FBaseGrid) do
begin
DisplayCol := DisplayColnr[DataCol] + 1;
while DisplayCol <= Cols do
begin
if Col[DataColnr[DisplayCol]].Visible then
break;
DisplayCol := DisplayCol + 1;
end;
if DisplayCol <= Cols then
result := DataColnr[DisplayCol]
else
result := -1;
end;
end;
function TtsDesignInfo.GetFirstVisibleRow: Variant;
var
DisplayRow: integer;
begin
with TtsBaseGrid_(FBaseGrid) do
begin
DisplayRow := 1;
while DisplayRow <= Rows do
begin
if RowVisible[DataRownr[DisplayRow]] then
break;
DisplayRow := DisplayRow + 1;
end;
if DisplayRow <= Rows then
result := DataRownr[DisplayRow]
else
result := -1;
end;
end;
function TtsDesignInfo.GetNextVisibleRow(DataRow: Variant): Variant;
var
DisplayRow: integer;
begin
with TtsBaseGrid_(FBaseGrid) do
begin
DisplayRow := DisplayRownr[DataRow] + 1;
while DisplayRow <= Rows do
begin
if RowVisible[DataRownr[DisplayRow]] then
break;
DisplayRow := DisplayRow + 1;
end;
if DisplayRow <= Rows then
result := DataRownr[DisplayRow]
else
result := -1;
end;
end;
function TtsDesignInfo.GetVisibleColCount: integer;
var
DataCol: integer;
begin
with TtsBaseGrid_(FBaseGrid) do
begin
result := 0;
for DataCol := 1 to Cols do
if Col[DataCol].Visible then
result := result + 1;
end;
end;
function TtsDesignInfo.GetVisibleRowCount(FromRow, ToRow: Variant): integer;
var
DataRow: integer;
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -