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

📄 frxcross.pas

📁 报表源码 FastReport 3 is new generation of the report generators components. It consists of report engin
💻 PAS
📖 第 1 页 / 共 3 页
字号:
end;

function TfrxCustomCrossView.GetRowMemos(Index:Integer):TfrxCustomMemoView;
begin
  Result:= FMatrix.RowMemos[Index];
end;

function TfrxCustomCrossView.GetRowTotalMemos(Index:Integer):TfrxCustomMemoView;
begin
  Result:= FMatrix.RowTotalMemos[Index];
end;

procedure TfrxCustomCrossView.SetCellFunctions(Index:Integer; const Value:TfrxCrossFunction);
begin
  FMatrix.CellFunctions[Index]:= Value;
end;

procedure TfrxCustomCrossView.SetCellFields(const Value:TStrings);
begin
  FCellFields.Assign(Value);
end;

procedure TfrxCustomCrossView.SetColumnFields(const Value:TStrings);
begin
  FColumnFields.Assign(Value);
end;

procedure TfrxCustomCrossView.SetPlainCells(const Value:Boolean);
begin
  FPlainCells:= Value;
  FMatrix.PlainCells:= Value;
end;

procedure TfrxCustomCrossView.SetRowFields(const Value:TStrings);
begin
  FRowFields.Assign(Value);
end;

function TfrxCustomCrossView.GetColumnSort(Index:Integer):TfrxCrossSortOrder;
begin
  Result:= FMatrix.ColumnSort[Index];
end;

function TfrxCustomCrossView.GetRowSort(Index:Integer):TfrxCrossSortOrder;
begin
  Result:= FMatrix.RowSort[Index];
end;

procedure TfrxCustomCrossView.SetColumnSort(Index:Integer; Value:TfrxCrossSortOrder);
begin
  FMatrix.ColumnSort[Index]:= Value;
end;

procedure TfrxCustomCrossView.SetRowSort(Index:Integer; Value:TfrxCrossSortOrder);
begin
  FMatrix.RowSort[Index]:= Value;
end;

function TfrxCustomCrossView.GetShowColumnTotal:Boolean;
begin
  Result:= ColumnTotalMemos[0].Visible;
end;

function TfrxCustomCrossView.GetShowRowTotal:Boolean;
begin
  Result:= RowTotalMemos[0].Visible;
end;

procedure TfrxCustomCrossView.SetShowColumnTotal(const Value:Boolean);
begin
  ColumnTotalMemos[0].Visible:= Value;
end;

procedure TfrxCustomCrossView.SetShowRowTotal(const Value:Boolean);
begin
  RowTotalMemos[0].Visible:= Value;
end;

procedure TfrxCustomCrossView.SetCellLevels(const Value:Integer);
begin
  FCellLevels:= Value;
end;

procedure TfrxCustomCrossView.SetColumnLevels(const Value:Integer);
begin
  FColumnLevels:= Value;
end;

procedure TfrxCustomCrossView.SetRowLevels(const Value:Integer);
begin
  FRowLevels:= Value;
end;

procedure TfrxCustomCrossView.SetDotMatrix(const Value:Boolean);
begin
  FDotMatrix:= Value;
  FMatrix.InitMemos(Value);
  if FDotMatrix then
  begin
    FGapX:= 0;
    FGapY:= 0;
  end;
end;

procedure TfrxCustomCrossView.Draw(Canvas:TCanvas; ScaleX, ScaleY,
  OffsetX, OffsetY:Extended);
begin
  inherited;
  with Canvas do
  begin
    Font.Assign(Self.Font);
    TextOut(FX+2, FY+2, Name);
  end;
end;

procedure TfrxCustomCrossView.BeginMatrix;
begin
  FMatrix.MaxWidth:= FMaxWidth;
  FMatrix.MinWidth:= FMinWidth;
  FMatrix.DefHeight:= FDefHeight;
  FMatrix.GapX:= FGapX;
  FMatrix.GapY:= FGapY;
  FMatrix.Init(FRowLevels, FColumnLevels, FCellLevels);
  FMatrix.ColumnHeader.Visible:= FShowColumnHeader;
  FMatrix.RowHeader.Visible:= FShowRowHeader;
end;

procedure TfrxCustomCrossView.AddValue(const Rows, Columns, Cells:array of Variant);
begin
  FMatrix.AddValue(Rows, Columns, Cells);
end;

procedure TfrxCustomCrossView.EndMatrix;
begin
  FMatrix.CreateHeaders;
  FMatrix.CalcTotals;
  FMatrix.CalcBounds;
end;

procedure TfrxCustomCrossView.FillMatrix;
begin
end;

function TfrxCustomCrossView.ColCount:Integer;
begin
  Result:= FMatrix.ColCount;
end;

function TfrxCustomCrossView.RowCount:Integer;
begin
  Result:= FMatrix.RowCount;
end;

function TfrxCustomCrossView.IsCrossValid:Boolean;
begin
  Result:= True;
end;

function TfrxCustomCrossView.IsGrandTotalColumn(Index:Integer):Boolean;
begin
  Result:= FMatrix.IsGrandTotalColumn(Index);
end;

function TfrxCustomCrossView.IsGrandTotalRow(Index:Integer):Boolean;
begin
  Result:= FMatrix.IsGrandTotalRow(Index);
end;

function TfrxCustomCrossView.IsTotalColumn(Index:Integer):Boolean;
begin
  Result:= FMatrix.IsTotalColumn(Index);
end;

function TfrxCustomCrossView.IsTotalRow(Index:Integer):Boolean;
begin
  Result:= FMatrix.IsTotalRow(Index);
end;

function TfrxCustomCrossView.ColumnHeaderHeight:Extended;
begin
  Result:= FMatrix.ColumnHeader.Height;
  if FMatrix.NoColumns then
    Result:= 0;
end;

function TfrxCustomCrossView.RowHeaderWidth:Extended;
begin
  Result:= FMatrix.RowHeader.Width;
  if FMatrix.NoRows then
    Result:= 0;
end;

procedure TfrxCustomCrossView.DoCalcHeight(Row:Integer; var Height:Extended);
var
  v:Variant;
begin
  if FOnCalcHeight<>'' then
  begin
    v:= VarArrayOf([Row, FMatrix.GetRowIndexes(Row), Height]);
    if Report<>nil then
      Report.DoParamEvent(FOnCalcHeight, v);
    Height:= v[2];
  end;
  if Assigned(FOnBeforeCalcHeight) then
    FOnBeforeCalcHeight(Row, FMatrix.GetRowIndexes(Row), Height);
end;

procedure TfrxCustomCrossView.DoCalcWidth(Column:Integer; var Width:Extended);
var
  v:Variant;
begin
  if FOnCalcWidth<>'' then
  begin
    v:= VarArrayOf([Column, FMatrix.GetColumnIndexes(Column), Width]);
    if Report<>nil then
      Report.DoParamEvent(FOnCalcWidth, v);
    Width:= v[2];
  end;
  if Assigned(FOnBeforeCalcWidth) then
    FOnBeforeCalcWidth(Column, FMatrix.GetColumnIndexes(Column), Width);
end;

procedure TfrxCustomCrossView.DoOnCell(Memo:TfrxCustomMemoView;
  Row, Column, Cell:Integer; const Value:Variant);
var
  v:Variant;
begin
  if FOnPrintCell<>'' then
  begin
    v:= VarArrayOf([Integer(Memo), Row, Column, Cell, FMatrix.GetRowIndexes(Row),
      FMatrix.GetColumnIndexes(Column), Value]);
    if Report<>nil then
      Report.DoParamEvent(FOnPrintCell, v);
  end;
  if Assigned(FOnBeforePrintCell) then
    FOnBeforePrintCell(Memo, Row, Column, Cell, FMatrix.GetRowIndexes(Row),
      FMatrix.GetColumnIndexes(Column), Value);
end;

procedure TfrxCustomCrossView.DoOnColumnHeader(Memo:TfrxCustomMemoView;
  Header:TfrxCrossHeader);
var
  v:Variant;
begin
  if FOnPrintColumnHeader<>'' then
  begin
    v:= VarArrayOf([Integer(Memo), Header.GetIndexes, Header.GetValues, Header.Value]);
    if Report<>nil then
      Report.DoParamEvent(FOnPrintColumnHeader, v);
  end;
  if Assigned(FOnBeforePrintColumnHeader) then
    FOnBeforePrintColumnHeader(Memo, Header.GetIndexes, Header.GetValues, Header.Value);
end;

procedure TfrxCustomCrossView.DoOnRowHeader(Memo:TfrxCustomMemoView;
  Header:TfrxCrossHeader);
var
  v:Variant;
begin
  if FOnPrintRowHeader<>'' then
  begin
    v:= VarArrayOf([Integer(Memo), Header.GetIndexes, Header.GetValues, Header.Value]);
    if Report<>nil then
      Report.DoParamEvent(FOnPrintRowHeader, v);
  end;
  if Assigned(FOnBeforePrintRowHeader) then
    FOnBeforePrintRowHeader(Memo, Header.GetIndexes, Header.GetValues, Header.Value);
end;

procedure TfrxCustomCrossView.BeforePrint;
begin
  inherited;
  BeginMatrix;
end;

procedure TfrxCustomCrossView.GetData;
begin
  inherited;
  Report.SetProgressMessage(frxResources.Get('crFillMx'));
  if IsCrossValid then
    FillMatrix;
  Report.SetProgressMessage(frxResources.Get('crBuildMx'));
  EndMatrix;
  RenderMatrix;
end;

procedure TfrxCustomCrossView.RenderMatrix;
var
  i, j, Page:Integer;
  CurY, AddWidth:Extended;
  Band:TfrxBand;
  ColumnItems:TList;

  function GetCellBand(RowIndex, ColumnIndex:Integer):TfrxBand;
  var
    i, j, iFrom, iTo:Integer;
    Cell:Variant;
    RowItems:TList;
    ColumnItem, RowItem:TfrxCrossHeader;
    m, Memo:TfrxCustomMemoView;
    RowSize, CellSize, CellOffs, LeftMargin, TopMargin:Extended;
  begin
    RowItems:= FMatrix.RowHeader.TerminalItems;
    RowItem:= RowItems[RowIndex];
    RowSize:= RowItem.Bounds.Bottom / CellLevels;

    Result:= TfrxNullBand.Create(Report);
    Result.Height:= RowItem.Bounds.Bottom;

    iFrom:= TfrxBand(FColumnBands[ColumnIndex]).Tag mod 65536;
    iTo:= TfrxBand(FColumnBands[ColumnIndex]).Tag div 65536;
    LeftMargin:= TfrxCrossHeader(ColumnItems[iFrom]).Bounds.Left;
    TopMargin:= RowItem.Bounds.Top;

    for i:= iFrom to iTo do
    begin
      ColumnItem:= ColumnItems[i];

      CellOffs:= 0;
      for j:= 0 to CellLevels-1 do
      begin
        Cell:= FMatrix.GetValue(RowIndex, i, j);

        { which memo to use? }
        if RowItem.IsTotal then
          m:= RowItem.Memo
        else if ColumnItem.IsTotal then
          m:= ColumnItem.Memo
        else
          m:= CellMemos[j];

        Memo:= CreateMemo(Result);
        Memo.Assign(m);
        SetupOriginalComponent(Memo, m);
        if Cell<>Null then
          THackMemoView(Memo).Value:= Cell else
          THackMemoView(Memo).Value:= 0;

        Memo.Text:= Memo.FormatData(Cell, CellMemos[j].DisplayFormat);
        Memo.Rotation:= 0;
        Memo.HAlign:= CellMemos[j].HAlign;
        Memo.Frame:= CellMemos[j].Frame;
        DoOnCell(Memo, RowIndex, i, j, Cell);

        if FBorder then
        begin
          if FMatrix.PlainCells then
          begin
            if RowIndex = 0 then
              Memo.Frame.Typ:= Memo.Frame.Typ+[ftTop];
            if (i = 0) and (j = 0) then
              Memo.Frame.Typ:= Memo.Frame.Typ+[ftLeft];
            if (i = ColumnItems.Count-1) and (j = CellLevels-1) then
              Memo.Frame.Typ:= Memo.Frame.Typ+[ftRight];
            if RowIndex = RowItems.Count-1 then
              Memo.Frame.Typ:= Memo.Frame.Typ+[ftBottom];
          end
          else
          begin
            if (RowIndex = 0) and (j = 0) then
              Memo.Frame.Typ:= Memo.Frame.Typ+[ftTop];
            if i = 0 then
              Memo.Frame.Typ:= Memo.Frame.Typ+[ftLeft];
            if i = ColumnItems.Count-1 then
              Memo.Frame.Typ:= Memo.Frame.Typ+[ftRight];
            if (RowIndex = RowItems.Count-1) and (j = CellLevels-1) then
              Memo.Frame.Typ:= Memo.Frame.Typ+[ftBottom];
          end;
        end;

        if FMatrix.PlainCells then
        begin
          CellSize:= ColumnItem.CellSizes[j];
          Memo.SetBounds(ColumnItem.Bounds.Left-LeftMargin+AddWidth+CellOffs,
            RowItem.Bounds.Top-TopMargin,
            CellSize, RowItem.Bounds.Bottom);
          CellOffs:= CellOffs+CellSize;
        end
        else
          Memo.SetBounds(ColumnItem.Bounds.Left-LeftMargin+AddWidth,
            RowItem.Bounds.Top+j * RowSize-TopMargin,
            ColumnItem.Bounds.Right, RowSize);
        CorrectDMPBounds(Memo);
        Memo.Visible:= (Memo.Width<>0) and (Memo.Height<>0);
      end;
    end;

    RowItems.Free;
  end;

  procedure DoPagination(i, j:Integer);
  var
    k, kFrom, kTo:Integer;
  begin
    if ShowColumnHeader and (FRepeatHeaders or (i = 0)) and not FMatrix.NoColumns then
    begin
      Band:= TfrxBand(FColumnBands[j]);
      Band.Top:= CurY;
      Report.Engine.ShowBand(Band);
    end;

    if ShowRowHeader and (FRepeatHeaders or (j = 0)) and not FMatrix.NoRows then
    begin
      Band:= TfrxBand(FRowBands[i]);
      if j = 0 then
        Band.Left:= Left
      else
        Band.Left:= 0;
      Band.Top:= Band.Top+CurY;
      Report.Engine.ShowBand(Band);
      Band.Top:= Band.Top-CurY;
    end;

    if FRepeatHeaders or (i = 0) then
      Report.Engine.CurY:= CurY+ColumnHeaderHeight else
      Report.Engine.CurY:= CurY;
    if FRepeatHeaders or (j = 0) then
    begin
      AddWidth:= RowHeaderWidth;
      if j = 0 then
        AddWidth:= AddWidth+Left;
    end
    else
      AddWidth:= 0;

    kFrom:= TfrxBand(FRowBands[i]).Tag mod 65536;
    kTo:= TfrxBand(FRowBands[i]).Tag div 65536;

    for k:= kFrom to kTo do
    begin
      Band:= GetCellBand(k, j);
      Band.Top:= Report.Engine.CurY;
      Report.Engine.ShowBand(Band);
      Band.Free;
    end;
  end;

begin
  AddSourceObjects;
  BuildColumnBands;
  BuildRowBands;
  ColumnItems:= FMatrix.ColumnHeader.TerminalItems;
  Page:= Report.PreviewPages.CurPage;
  CurY:= Report.Engine.CurY;

  if FDownThenAcross then
    for i:= 0 to FColumnBands.Count-1 do
    begin
      for j:= 0 to FRowBands.Count-1 do
      begin
        Report.PreviewPages.CurPage:= Page+j;
        DoPagination(j, i);
        if j<>FRowBands.Count-1 then
          Report.Engine.NewPage;
      end;

      if i<>FColumnBands.Count-1 then

⌨️ 快捷键说明

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