⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tseditor.pas

📁 企业进销存管理系统
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    with TtsBaseGrid_(FBaseGrid) do
    begin
        result := 0;
        for DataRow := FromRow to ToRow do
            if RowVisible[DataRow] then
                result := result + 1;
    end;
end;

{End TtsDesignInfo}

{TtsDBDesignInfo}

function  TtsDBDesignInfo.GetCustomDBGrid: TtsCustomDBGrid;
begin
    result := TtsCustomDBGrid(FBaseGrid);
end;

procedure TtsDBDesignInfo.SetCustomDBGrid(CustomDBGrid: TtsCustomDBGrid);
begin
    FBaseGrid := CustomDBGrid;
end;

function  TtsDBDesignInfo.GetDataBound: Boolean;
begin
    result := TtsCustomDBGrid_(Grid).FDataBound;
end;

function  TtsDBDesignInfo.GetFieldState: TtsFieldState;
begin
    result := TtsCustomDBGrid_(Grid).GetFieldState;
end;

procedure TtsDBDesignInfo.SetFieldState(Value: TtsFieldState);
begin
    TtsCustomDBGrid_(Grid).SetFieldState(Value);
end;

function  TtsDBDesignInfo.GetCurrentDataRow: Variant;
begin
    result := TtsCustomDBGrid_(Grid).CurrentDataRow;
end;

procedure TtsDBDesignInfo.SetCurrentDataRow(Value: Variant);
begin
    TtsCustomDBGrid_(Grid).CurrentDataRow := Value;
end;

function  TtsDBDesignInfo.GetCurrentCell: TtsDBCurrentCell;
begin
    result := TtsCustomDBGrid_(Grid).CurrentCell;
end;

function  TtsDBDesignInfo.GetCellButtonType(DataCol: LongInt; DataRow: Variant): TtsButtonType;
begin
    result := TtsCustomDBGrid_(Grid).CellButtonType[DataCol, DataRow];
end;

function  TtsDBDesignInfo.GetCellControlType(DataCol: LongInt; DataRow: Variant): TtsControlType;
begin
    result := TtsCustomDBGrid_(Grid).CellControlType[DataCol, DataRow];
end;

function  TtsDBDesignInfo.GetRowControlType(DataRow: Variant): TtsControlType;
begin
    result := TtsCustomDBGrid_(Grid).RowControlType[DataRow];
end;

function  TtsDBDesignInfo.GetRowButtonType(DataRow: Variant): TtsButtonType;
begin
    result := TtsCustomDBGrid_(Grid).RowButtonType[DataRow];
end;

function  TtsDBDesignInfo.GetRowCombo(DataRow: Variant): TtsCombo;
begin
    result := TtsCombo(TtsCustomDBGrid_(Grid).RowCombo[DataRow]);
end;

procedure TtsDBDesignInfo.SetRowCombo(DataRow: Variant; Value: TtsCombo);
begin
    TtsCustomDBGrid_(Grid).RowCombo[DataRow] := TtsDBCombo(Value);
end;

function  TtsDBDesignInfo.GetCellCombo(DataCol: LongInt; DataRow: Variant): TtsCombo;
begin
    result := TtsCombo(TtsCustomDBGrid_(Grid).CellCombo[DataCol, DataRow]);
end;

procedure TtsDBDesignInfo.SetCellCombo(DataCol: LongInt; DataRow: Variant; Value: TtsCombo);
begin
    TtsCustomDBGrid_(Grid).CellCombo[DataCol, DataRow] := TtsDBCombo(Value);
end;

function  TtsDBDesignInfo.GetDataSource: TDataSource;
begin
    result := TtsCustomDBGrid_(Grid).DataSource;
end;

procedure TtsDBDesignInfo.SetDataSource(Value: TDataSource);
begin
    TtsCustomDBGrid_(Grid).DataSource := Value;
end;

procedure TtsDBDesignInfo.GetFirstSelectedCell(var DataCol: integer; var DataRow: Variant; StatusSet: TtsGridStats);
begin
    if not TtsCustomDBGrid_(Grid).DataBound then begin inherited GetFirstSelectedCell(DataCol, DataRow, StatusSet); Exit end;

    with TtsCustomDBGrid_(Grid) do
    begin
        if not (GridStatus in StatusSet) then
        begin
            DataCol := -1;
            DataRow := UnAssigned;
            exit;
        end;

        case GridStatus of
            grNormal:
            begin
                DataCol := CurrentCell.DataCol;
                DataRow := CurrentCell.DataRow;
            end;
            grRowSelect:
            begin
                DataCol := GetFirstVisibleCol;
                DataRow := SelectedRows.First;
            end;
            grColSelect:
            begin
                DataCol := DataColnr[SelectedCols.First];
                DataRow := GetFirstVisibleRow;
            end;
            grCellSelect:
            begin
                DataCol := DataColnr[SelectedCells.Left];
                DataRow := SelectedCells.Top;
            end;
        end;
    end;
end;

procedure TtsDBDesignInfo.GetNextSelectedCell(var DataCol: integer; var DataRow: Variant; StatusSet: TtsGridStats);
var
    DisplayCol: integer;
    strDataRow, strBottom: string;
begin
    if not TtsCustomDBGrid_(Grid).DataBound then begin inherited GetNextSelectedCell(DataCol, DataRow, StatusSet); Exit end;

    with TtsCustomDBGrid_(Grid) do
    begin
        if not (GridStatus in StatusSet) then
        begin
            DataCol := -1;
            DataRow := UnAssigned;
            exit;
        end;

        case GridStatus of
            grNormal:
            begin
                DataCol := -1;
                DataRow := UnAssigned;
            end;
            grColSelect:
            begin
                DisplayCol := SelectedCols.Next(DisplayColnr[DataCol]);
                if DisplayCol <> -1 then
                    DataCol := DataColnr[DisplayCol]
                else
                begin
                    DataRow := GetNextVisibleRow(DataRow);
                    if VarIsEmpty(DataRow) then
                        DataCol := -1
                    else
                        DataCol := DataColnr[SelectedCols.First];
                end;
            end;
            grRowSelect:
            begin
                DataCol := GetNextVisibleCol(DataCol);
                if DataCol = -1 then
                begin
                    DataRow := SelectedRows.Next(DataRow);

                    if VarIsEmpty(DataRow) then
                        DataCol := -1
                    else
                        DataCol := GetFirstVisibleCol;
                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 not VarIsEmpty(DataRow) then
                    begin
                        strDataRow := DataRow;
                        strBottom := SelectedCells.Bottom;
                        if CompareBkm(strDataRow, strBottom) = 1 then
                            DataRow := UnAssigned;
                    end;

                    if VarIsEmpty(DataRow) then
                        DataCol := -1
                    else
                        DataCol := DataColnr[SelectedCells.Left];
                end;
            end;
        end;
    end;
end;

function TtsDBDesignInfo.CellSelected(DataCol: integer; DataRow: Variant; StatusSet: TtsGridStats): Boolean;
begin
    if not TtsCustomDBGrid_(Grid).DataBound then begin result := inherited CellSelected(DataCol, DataRow, StatusSet); Exit end;

    with TtsCustomDBGrid_(Grid) 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], DataRow);
    end;
end;

function TtsDBDesignInfo.CellSelectedCount(StatusSet: TtsGridStats): integer;
var
    FirstRow, LastRow: Variant;
begin
    if not TtsCustomDBGrid_(Grid).DataBound then begin result := inherited CellSelectedCount(StatusSet); Exit end;

    with TtsCustomDBGrid_(Grid) do
    begin
        if not (GridStatus in StatusSet) then
        begin
            result := 0;
            exit;
        end;

        case GridStatus of
            grNormal:
                result := 1;
            grRowSelect:
                result := GetVisibleColCount * SelectedRows.Count;
            grColSelect:
                begin
                    DataSource.DataSet.First;
                    FirstRow := DataSource.DataSet.Bookmark;
                    DataSource.DataSet.Last;
                    LastRow := DataSource.DataSet.Bookmark;
                    result := Self.GetVisibleRowCount(FirstRow, LastRow) * SelectedCols.Count;
                end;
            grCellSelect:
                with SelectedCells do
                    result := Self.GetVisibleRowCount(Top, Bottom) * (Right - Left);
            else
                result := 0;
        end;
    end;
end;

function TtsDBDesignInfo.GetVisibleRowCount(FromRow, ToRow: Variant): integer;
var
    strCurrentRow, strToRow: string;
begin
    if not TtsCustomDBGrid_(Grid).DataBound then begin result := inherited GetVisibleRowCount(FromRow, ToRow); Exit end;

    result := 0;
    DataSource.DataSet.Bookmark := FromRow;
    strToRow := ToRow;
    while not DataSource.DataSet.EOF do
    begin
        result := result + 1;

        strCurrentRow := DataSource.DataSet.Bookmark;
        if TtsCustomDBGrid_(Grid).CompareBkm(strCurrentRow, strToRow) <= 0 then
            break;

        DataSource.DataSet.Next;
    end;
end;

function TtsDBDesignInfo.GetFirstVisibleRow: Variant;
begin
    if not TtsCustomDBGrid_(Grid).DataBound then begin result := inherited GetFirstVisibleRow; Exit end;

    DataSource.DataSet.First;
    result := DataSource.DataSet.Bookmark;
end;

function TtsDBDesignInfo.GetNextVisibleRow(DataRow: Variant): Variant;
var
    strCurrentBookmark, strDataRow: string;
begin
    if not TtsCustomDBGrid_(Grid).DataBound then begin result := inherited GetNextVisibleRow(DataRow); Exit end;

    strCurrentBookmark := DataSource.DataSet.Bookmark;
    strDataRow := DataRow;
    if TtsCustomDBGrid_(Grid).CompareBkm(strDataRow, strCurrentBookmark) <> 0 then
        DataSource.DataSet.Bookmark := DataRow;

    DataSource.DataSet.Next;
    if DataSource.DataSet.EOF then
        result := DataSource.DataSet.Bookmark
    else
        result := UnAssigned;
end;


{TtsGridEditor}

procedure TtsGridEditor.Edit;
begin
    ShowMessage('Edit');
    StartedFromDesigntime := True;
    FirstActivate := True;
    TsDesign.Designer := Designer;
    Screen.Cursor := crHourglass;
    try
        ShowMessage('TfrmInspector.Create');
        frmInspector := TfrmInspector.Create(Application);
    except
        Screen.Cursor := crDefault;
        frmInspector.Free;
        frmInspector := nil;
        raise;
    end;

    try
{$IFDEF TSVER_V6}
        frmInspector.pnlGrdExample.Font := TForm(Designer.Root).Font;
        frmInspector.Caption := TForm(Designer.Root).Name + '.' + Component.Name + ' - TopGrid Editor';
{$ELSE}
        frmInspector.pnlGrdExample.Font := Designer.Form.Font;
        frmInspector.Caption := Designer.Form.Name + '.' + Component.Name + ' - TopGrid Editor';
{$ENDIF}
        ShowMessage('DesignActivatesFirstTime');
        if DesignActivatesFirstTime then
        begin
            frmInspector.Left := Trunc((Screen.Width - frmInspector.Width)/2);
            frmInspector.Top := Trunc((Screen.Height - frmInspector.Height)/2);
            CurDisplayModeName := 'Structured';

            PrevLeft := frmInspector.Left;
            PrevTop := frmInspector.Top;
            PrevWidth := frmInspector.Width;
            PrevHeight := frmInspector.Height;

            DesignActivatesFirstTime := False;
        end
        else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -