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

📄 tseditor.pas

📁 企业进销存管理系统
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        begin
            frmInspector.Left := PrevLeft;
            frmInspector.Top := PrevTop;
            CurDisplayModeName := PrevDisplayModeName;
        end;

        CurGrid := TtsBaseGrid(Component);
        ShowMessage('ShowModal');
        frmInspector.ShowModal;

        PrevState := frmInspector.WindowState;
        if PrevState = wsNormal then
        begin
            PrevLeft := frmInspector.Left;
            PrevTop := frmInspector.Top;
            PrevWidth := frmInspector.Width;
            PrevHeight := frmInspector.Height;
        end;

        PrevDisplayModeName := frmInspector.grdInspector.DisplayModeName;

        if SaveResult then
        begin
            frmInspector.ShowAlwaysStateGrid := True;
            frmInspector.ApplyShowDesignValueGrid;
            frmInspector.CheckInsertRow(GridEditor.grdExample);
            CurGrid.Assign(GridEditor.grdExample);
            CurGrid.Name := CurGridName;
            CurGrid.Width := CurGridWidth;
            CurGrid.Height := CurGridHeight;
            CurGrid.Visible := CurGridVisible;
            TsDesign.Designer.Modified;
        end;
    finally
        TsDesign.Designer := nil;
        frmInspector.FreeActualValuesGrid;
        frmInspector.FreeAll;
        FreeNil(TObject(frmInspector));

        Screen.Cursor := crDefault;
    end;
end;

function TtsGridEditor.GetVerbCount: Integer;
begin
    result := 1;
end;

function TtsGridEditor.GetVerb(Index: integer): string;
begin
    result := '&TopGrid Editor'
end;

procedure TtsGridEditor.ExecuteVerb(Index: integer);
begin
    Edit;
end;

{TGridValues}

constructor TGridValues.Create(Cols, Rows: integer);
begin
    inherited Create;

    FCols := Cols;
    FRows := Rows;

    GridData := nil;
    CurRowsInGridData := 0;
end;

destructor TGridValues.Destroy;
var
    i, j: integer;

begin
    for i := 0 to CurRowsInGridData - 1 do
    begin
        for j := 0 to CurColsInRowData[i] - 1 do
            GridData[i][j] := Unassigned;

        ReAllocMem(GridData[i], 0);
    end;
    ReAllocMem(GridData, 0);
    ReAllocMem(CurColsInRowData, 0);

    inherited Destroy;
end;

function TGridValues.GetValue(DataCol, DataRow: Integer): Variant;
begin
    if DataRow > CurRowsInGridData then
        result := Unassigned
    else if DataCol > CurColsInRowData[DataRow - 1] then
        result := Unassigned
    else
        result := GridData[DataRow - 1][DataCol - 1];
end;

procedure TGridValues.SetValue(DataCol, DataRow: Integer; Value: Variant);
var
    Row: integer;
    AllocRows: integer;
    AllocCols: integer;

begin
    if DataRow > CurRowsInGridData then
    begin
        if DataRow < FRows then
            AllocRows := FRows
        else
            AllocRows := DataRow + 10;

        ReAllocMem(GridData, AllocRows * SizeOf(PRowData));
        ReAllocMem(CurColsInRowData, AllocRows * SizeOf(integer));
        for Row := CurRowsInGridData + 1 to AllocRows do
        begin
            GridData[Row - 1] := nil;
            CurColsInRowData[Row - 1] := 0;
        end;
        CurRowsInGridData := AllocRows;
    end;

    if DataCol > CurColsInRowData[DataRow - 1] then
    begin
        if DataCol < FCols then
            AllocCols := FCols
        else
            AllocCols := DataCol + 10;

        ReAllocMem(GridData[DataRow - 1], AllocCols * SizeOf(Variant));
        ZeroMemory(@(GridData[DataRow - 1][CurColsInRowData[DataRow - 1]]), (AllocCols - CurColsInRowData[DataRow - 1]) * SizeOf(Variant));
        CurColsInRowData[DataRow - 1] := AllocCols;
    end;

    GridData[DataRow - 1][DataCol - 1] := Value;
end;

procedure TGridValues.DeleteRows(FromRow, ToRow: integer);
var
    Row, Col, NrOfRows: integer;

begin
    if ToRow < FromRow then
        exit;

    if FromRow > CurRowsInGridData then
        exit;

    if ToRow > CurRowsInGridData then
        ToRow := CurRowsInGridData;

    for Row := ToRow downto FromRow do
    begin
        for Col := 1 to CurColsInRowData[Row - 1] do
            GridData[Row - 1][Col - 1] := Unassigned;

        ReAllocMem(GridData[Row - 1], 0);
    end;

    NrOfRows := ToRow - FromRow + 1;
    for Row := FromRow to CurRowsInGridData - NrOfRows do
    begin
        GridData[Row - 1] := GridData[Row + NrOfRows - 1];
        CurColsInRowData[Row - 1] := CurColsInRowData[Row + NrOfRows - 1];
    end;

    CurRowsInGridData := CurRowsInGridData - NrOfRows;

    ReAllocMem(GridData, CurRowsInGridData * SizeOf(PRowData));
    ReAllocMem(CurColsInRowData, CurRowsInGridData * SizeOf(integer));
end;

procedure TGridValues.DeleteCols(FromCol, ToCol: integer);
var
    Row, RowToCol, NrOfCols, Col: integer;

begin
    if ToCol < FromCol then
        exit;

    for Row := 1 to CurRowsInGridData do
    begin
        if FromCol <= CurColsInRowData[Row - 1] then
        begin
            if ToCol > CurColsInRowData[Row - 1] then
                RowToCol := CurColsInRowData[Row - 1]
            else
                RowToCol := ToCol;

            NrOfCols := RowToCol - FromCol + 1;
            for Col := FromCol to CurColsInRowData[Row - 1] - NrOfCols do
                GridData[Row - 1][Col - 1] := GridData[Row - 1][Col + NrOfCols - 1];

            for Col := CurColsInRowData[Row - 1] - NrOfCols + 1 to CurColsInRowData[Row - 1] do
                GridData[Row - 1][Col - 1] := Unassigned;

            CurColsInRowData[Row - 1] := CurColsInRowData[Row - 1] - NrOfCols;

            ReAllocMem(GridData[Row - 1], CurColsInRowData[Row - 1] * SizeOf(Variant));
        end;
    end;
end;
// End GridValues Implementation

// Start TEditor

constructor TEditor.Create(grdClass : TtsBaseGridClass; ComboGrid: Boolean);
begin
    inherited Create;

    FComboGrid := ComboGrid;
    FDesignInfo := nil;
    grdExampleClass := grdClass;
    grdExample := nil;
    FirstEditorCell := nil;
    NextEditorCell := nil;
    IdEditorCell := nil;
    FirstEditorRow := nil;
    NextEditorRow := nil;
    IdEditorRow := nil;
    FCellPropList := nil;
    UseCellPropList := False;
    CellPropListIndex := -1;
    ExampleKeyIsDown := False;
    ExampleMouseIsDown := False;
    UpdateComponentsOnUp := False;
    InColResize := False;
    ValColumns := TGridValues.Create(2, 20);
    FTabInfo := nil;
    FTabInfoCount := 0;
    CurrentTab := 0;
    FieldNames := nil;

    SetGrdExample;
end;

destructor  TEditor.Destroy;
begin
    FDesignInfo.Free;
    FDesignInfo := nil;

    ResetTabInfo;
    ReAllocMem(FTabInfo, 0);

    FirstEditorCell.Free;
    FirstEditorCell := nil;
    NextEditorCell.Free;
    NextEditorCell := nil;
    IdEditorCell.Free;
    IdEditorCell := nil;
    FirstEditorRow.Free;
    FirstEditorRow := nil;
    NextEditorRow.Free;
    NextEditorRow := nil;
    IdEditorRow.Free;
    IdEditorRow := nil;
    FieldNames.Free;
    FieldNames := nil;
    ValColumns.Free;

    inherited Destroy;
end;

function TEditor.GetDesignInfo: TtsDesignInfo;
begin
    if FDesignInfo = nil then
    begin
        if grdExample is TtsCustomGrid then
            FDesignInfo := TtsDesignInfo.Create(grdExample as TtsCustomGrid)
        else
            FDesignInfo := TtsDBDesignInfo.Create(grdExample as TtsCustomDBGrid);
    end;
    result := FDesignInfo;
end;

procedure TEditor.GetFieldNames;
begin
    FieldNames.Free;
    FieldNames := TStringList.Create;

    if DataBound then
    begin
        try
            if TtsCustomDBGrid_(grdExample as TtsCustomDBGrid).DataSource.DataSet <> nil then
            begin
                try
                    TtsCustomDBGrid_(grdExample as TtsCustomDBGrid).DataSource.DataSet.GetFieldNames(FieldNames);
                except
                end;
            end;
        finally
            frmInspector.grdDatafields.Rows := FieldNames.Count;
        end;
    end;
end;

function  TEditor.GetCellPropList: TtsSetList;
begin
    if FCellPropList = nil then
        FCellPropList := grdExample.GetCellPropSet.List;

    result := FCellPropList;
end;

function  TEditor.GetTabInfo: PtsTabList;
begin
    if FTabInfo = nil then
        CreateTabInfo;

    result := FTabInfo;
end;

procedure TEditor.CreateTabInfo;
var
    i: integer;

begin
    with frmInspector do
    begin
        FTabInfoCount := tabInspector.PageCount;
        ReAllocMem(FTabInfo, tabInspector.PageCount * SizeOf(TtsTabElement));
        ZeroMemory(FTabInfo, tabInspector.PageCount * SizeOf(TtsTabElement));

        for i := 0 to tabInspector.PageCount - 1 do
        begin
            with FTabInfo[i] do
            begin
                TopRow := 2;
                CurRow := 2;
                DisplayModeName := '';
                NumberofToggleValues := 0;
                NumberofInvisibleValues := 0;
                if TtsBaseGrid_(grdExample).FAsCombo then
                begin
                    if tabinspector.pages[i] = tabGridProperties then
                        ComponentEditor := ceComboGrid
                    else if tabinspector.pages[i] = tabColumnProperties then
                        ComponentEditor := ceComboColumn
                    else if tabinspector.pages[i] = tabRowProperties then
                        ComponentEditor := ceComboRow
                    else if tabinspector.pages[i] = tabCellProperties then
                        ComponentEditor := ceComboCell
                    else
                        ComponentEditor := nil;
                end
                else
                begin
                    if tabinspector.pages[i] = tabGridProperties then
                        ComponentEditor := ceGrid
                    else if tabinspector.pages[i] = tabColumnProperties then
                        ComponentEditor := ceColumn
                    else if tabinspector.pages[i] = tabRowProperties then
                        ComponentEditor := ceRow
                    else if tabinspector.pages[i] = tabCellProperties then
                        ComponentEditor := ceCell
   

⌨️ 快捷键说明

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