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

📄 rm_pwwgrid.pas

📁 report machine 2.3 功能强大
💻 PAS
📖 第 1 页 / 共 2 页
字号:
      TRMPictureView(liView).PPictureRatio := TRUE;
    end
{      else if Uppercase(Copy(str, 1, Pos(';', str) - 1)) = 'CHECKBOX' then
      begin
        DBT := TRMCheckBoxView(RMCreateObject(gtAddIn, 'TRMCheckBoxView'));
        DBT.Memo.Text := Format('[%s.%s."%s"]', [TRMDBGrid(DBGrid).DataSource.DataSet.Owner.Name, DBGrid.DataSource.DataSet.Name, DSet.Fields[X].FieldName]);
        DBT.x := DX;
        DBT.y := PageDetailViews.y;
        DBT.dx := DBGrid.ColWidths[Y + DD];
        DBT.dy := PageDetailViews.dy;
        DBT.Flags := (DBT.Flags and not flStretched) + Integer(AutoStretchMemos);
      end
    }else if Uppercase(Copy(str, 1, Pos(';', str) - 1)) = 'RICHEDIT' then
    begin
      liView := TRMwwRichView(RMCreateObject(gtAddIn, 'TRMwwRichView'));
      liView.PStretched := rmgoStretch in aFormReport.ReportOptions;
      TRMwwRichView(liView).RichEdit.Text := Format('[%s.%s."%s"]', [DSet.Owner.Name, DSet.Name, liDBGrid.Columns[aIndex].FieldName]);
    end
    else
    begin
      liView := TRMMemoView(RMCreateObject(gtMemo, ''));
      liView.PStretched := rmgoStretch in aFormReport.ReportOptions;
      aFormReport.AssignFont(TRMMemoView(liView), liDBGrid.Font);
      liView.Memo.Text := Format('[%s.%s."%s"]', [DSet.Owner.Name, DSet.Name, DSet.Fields[aIndex].FieldName]);
      TRMMemoView(liView).PLayout := rmtlCenter;
      TRMMemoView(liView).PWordWrap := rmgoWordWrap in aFormReport.ReportOptions;
      case DSet.Fields[aIndex].Alignment of
        taLeftJustify: TRMMemoView(liView).PAlignment := rmtaLeftJustify;
        taRightJustify: TRMMemoView(liView).PAlignment := rmtaRightJustify;
        taCenter: TRMMemoView(liView).PAlignment := rmtaCenterJustify;
      end;
      THackFormReport(aFormReport).SetMemoViewFormat(TRMMemoView(liView), DSet.Fields[aIndex]);
    end;
    if (rmgoGridLines in aFormReport.ReportOptions) and (dgColLines in liDBGrid.Options) then
      liView.Prop['FrameTyp'] := $F
    else
    	liView.Prop['FrameTyp'] := 0;

    liView.CreateUniqueName;
    liView.x := tmpx;
    liView.y := 0;
    liView.dx := liDBGrid.ColWidths[Y + DD] + 1;
    liView.dy := liDBGrid.DefaultRowHeight + 4;
    if rmgoUseColor in aFormReport.ReportOptions then
      liView.FillColor := liDBGrid.Color;

    liPage.Objects.Add(liView);
    aFormReport.PageDetailViews.Add(liView);
    tmpx := tmpx + liView.dx;
    if Assigned(aFormReport.OnAfterCreateGridObjectEvent) then
			aFormReport.OnAfterCreateGridObjectEvent(Control, DSet.Fields[aIndex].FieldName, liView);

    if rmgoDoubleFrame in aFormReport.ReportOptions then
    begin
      if liFlagFirstColumn then
        liView.LeftFrame.Width := 2;
    end;
    DrawDoubleFrameBottom(liView, aFormReport.ColumnFooterViews);
    liFlagFirstColumn := False;
  end;

  procedure DrawFixedColHeader;
  var
    i, SaveY: Integer;
  begin
		SaveY := Y;    Y := -1;
    for i := 0 to aFormReport.GridFixedCols - 1 do
    begin
      if not DSet.Fields[i].Visible then Continue;
  		if i < DSet.FieldCount then
	      MakeOneHeader(i);
    end;
    Y := SaveY;
  end;

  procedure DrawFixedColDetail;
  var
    i, SaveY: Integer;
  begin
		SaveY := Y;    Y := -1;
    for i := 0 to aFormReport.GridFixedCols - 1 do
    begin
      if not DSet.Fields[i].Visible then Continue;
      if i < DSet.FieldCount then
	      MakeOneDetail(i);
    end;
    Y := SaveY;
  end;

begin
  if aFormReport.DrawOnPageFooter then exit;
  liDBGrid := THackwwDBGrid(Control);
  if (liDBGrid.Datasource = nil) or (liDBGrid.Datasource.Dataset = nil) then Exit;
  if not liDBGrid.Datasource.Dataset.Active then Exit;

  FDBGrid := liDBGrid;
  if (rmgoSelectedRecordsOnly in aFormReport.ReportOptions) and
    (liDBGrid.SelectedList.Count > 0) then //只打印选择的记录
  begin
    AutoFree := False;
    aFormReport.Report.OnBeforePrintBand := OnBeforePrintBandEvent;
  end;

  aFormReport.DrawOnPageFooter := TRUE;
  aFormReport.GridTop := THackFormReport(aFormReport).OffsY + Control.Top;
  aFormReport.GridHeight := Control.Height;
  liGridTitleHeight := 0;
  NextTop := Control.Top + THackFormReport(aFormReport).OffsY;
  aFormReport.ReportDataSet.DataSource := liDBGrid.DataSource;
  aFormReport.Report.DataSet := aFormReport.ReportDataSet;

  if wwDBIGrd.dgIndicator in liDBGrid.Options then DD := 1 else DD := 0;
  DSet := liDBGrid.Datasource.Dataset;
  CTypes := wwGetControlType(DSet);
  tmpx := 0; Y := 0;
  for i := 0 to DSet.FieldCount - 1 do
  begin
    if DSet.Fields[i].Visible then
    begin
      tmpx := tmpx + liDBGrid.ColWidths[Y + DD] + 1;
      Inc(Y);
    end;
  end;

  if (dgTitles in liDBGrid.Options) and (rmgoGridNumber in aFormReport.ReportOptions) then
    tmpx := tmpx + RMCanvasHeight('a', liDBGrid.Font) * aFormReport.GridNumOptions.Number;

  if (aFormReport.PrintControl = Control) or (tmpx > StrToInt(THackFormReport(aFormReport).FormWidth[0])) then
    THackFormReport(aFormReport).FormWidth[0] := IntToStr(tmpx + (THackFormReport(aFormReport).OffsX + Control.Left) * 2);

  if dgTitles in liDBGrid.Options then   //表头
  begin
    liFlagFirstColumn := True;
    liGridTitleHeight := liDBGrid.RowHeights[0] + 4;
    tmpx := Control.Left + THackFormReport(aFormReport).OffsX;
    if rmgoGridNumber in aFormReport.ReportOptions then
    begin
      liView := RMCreateObject(gtMemo, '');
      liView.CreateUniqueName;
      liView.x := tmpx;
      liView.y := NextTop;
      liView.dx := RMCanvasHeight('a', liDBGrid.Font) * aFormReport.GridNumOptions.Number;
      liView.dy := liGridTitleHeight;
      liView.Memo.Add(aFormReport.GridNumOptions.Text);
      TRMMemoView(liView).PLayout := rmtlCenter;
      TRMMemoView(liView).PAlignment := rmtaCenterJustify;
      if (rmgoGridLines in aFormReport.ReportOptions) and (dgColLines in liDBGrid.Options) then
        liView.Prop['FrameTyp'] := $F
      else
      	liView.Prop['FrameTyp'] := 0;
      Page.Objects.Add(liView);
      aFormReport.PageHeaderViews.Add(liView);
      tmpx := tmpx + liView.dx;

      if rmgoDoubleFrame in aFormReport.ReportOptions then
      begin
        if liFlagFirstColumn then
          liView.LeftFrame.Width := 2;
        liView.TopFrame.Width := 2;
      end;
      liFlagFirstColumn := False;
    end;

    liPage := Page; liNum := 0;
    Y := -1; tmpx0 := tmpx;
    for i := 0 to DSet.FieldCount - 1 do
    begin
      if not DSet.Fields[i].Visible then Continue;

      if (aFormReport.ScaleMode.ScaleMode <> rmsmFit) or (not aFormReport.ScaleMode.FitPageWidth) then
      begin
        if (liNum > 0) and (THackFormReport(aFormReport).CalcWidth(tmpx + (liDBGrid.ColWidths[Y + DD] + 1)) > THackFormReport(aFormReport).PageWidth) then // 超宽
        begin
          liNum := 0;
          liFlagFirstColumn := True;
          if rmgoDoubleFrame in aFormReport.ReportOptions then
            liView.RightFrame.Width := 2;

          THackFormReport(aFormReport).FormWidth[THackFormReport(aFormReport).FormWidth.Count - 1] := IntToStr(tmpx);
          THackFormReport(aFormReport).AddPage;
          THackFormReport(aFormReport).FormWidth.Add('0');
          liPage := aFormReport.Report.Pages[aFormReport.Report.Pages.Count - 1];
          tmpx := tmpx0;
          liFlagFirstColumn := True;
          DrawFixedColHeader;
        end;
      end;

      MakeOneHeader(i);
      Inc(liNum);
    end;

    liFlagFirstColumn := True;
    if rmgoDoubleFrame in aFormReport.ReportOptions then
      liView.RightFrame.Width := 2;
  end;

  if aFormReport.Report.Pages.Count > 1 then
    THackFormReport(aFormReport).FormWidth[THackFormReport(aFormReport).FormWidth.Count - 1] := IntToStr(tmpx);

  liPage := Page;  //表体
  tmpx := Control.Left + THackFormReport(aFormReport).OffsX;
  liFlagFirstColumn := True;
  if rmgoGridNumber in aFormReport.ReportOptions then
  begin
    liView := RMCreateObject(gtMemo, '');
    liView.CreateUniqueName;
    liView.x := tmpx;
    liView.y := 0;
    liView.dx := RMCanvasHeight('a', liDBGrid.Font) * aFormReport.GridNumOptions.Number;
    liView.dy := liDBGrid.DefaultRowHeight + 4;
    liView.Memo.Add('[Line#]');
    TRMMemoView(liView).PLayout := rmtlCenter;
    TRMMemoView(liView).PAlignment := rmtaCenterJustify;
    if (rmgoGridLines in aFormReport.ReportOptions) and (dgColLines in liDBGrid.Options) then
      liView.Prop['FrameTyp'] := $F
    else
    	liView.Prop['FrameTyp'] := 0;
    Page.Objects.Add(liView);
    aFormReport.PageDetailViews.Add(liView);
    tmpx := tmpx + liView.dx;

    if rmgoDoubleFrame in aFormReport.ReportOptions then
    begin
      if liFlagFirstColumn then
        liView.LeftFrame.Width := 2;
    end;
    DrawDoubleFrameBottom(liView, aFormReport.ColumnFooterViews);
    liFlagFirstColumn := False;
  end;

  Y := -1; tmpx0 := tmpx;
  liNum := 0; liPageNo := 0;
  for i := 0 to DSet.FieldCount - 1 do
  begin
    if not DSet.Fields[i].Visible then Continue;

    if (aFormReport.ScaleMode.ScaleMode <> rmsmFit) or (not aFormReport.ScaleMode.FitPageWidth) then
    begin
      if (liNum > 0) and (THackFormReport(aFormReport).CalcWidth(tmpx + (liDBGrid.ColWidths[Y + DD] + 1)) > THackFormReport(aFormReport).PageWidth) then // 超宽
      begin
        liNum := 0;
        liFlagFirstColumn := True;
        if rmgoDoubleFrame in aFormReport.ReportOptions then
          liView.RightFrame.Width := 2;

        liFlagFirstColumn := True;
        THackFormReport(aFormReport).FormWidth[liPageNo] := IntToStr(tmpx);
        Inc(liPageNo);
        if liPageNo >= aFormReport.Report.Pages.Count then
        begin
          THackFormReport(aFormReport).AddPage;
          THackFormReport(aFormReport).FormWidth.Add('0');
        end;
        liPage := aFormReport.Report.Pages[liPageNo];
        tmpx := tmpx0;
        liFlagFirstColumn := True;
        DrawFixedColDetail;
      end;
    end;

    MakeOneDetail(i);
    Inc(liNum);
  end;

  if liNum > 0 then
  begin
    liFlagFirstColumn := True;
    if rmgoDoubleFrame in aFormReport.ReportOptions then
      liView.RightFrame.Width := 2;
  end;

  if aFormReport.Report.Pages.Count > 1 then
    THackFormReport(aFormReport).FormWidth[THackFormReport(aFormReport).FormWidth.Count - 1] := IntToStr(tmpx);
end;

initialization
  RMRegisterFormReportControl(TwwCustomRichEdit, TRMPrintwwRichEdit);
  RMRegisterFormReportControl(TwwCustomDBGrid, TRMPrintwwDBGrid);
  RMRegisterFormReportControl(TwwDBCustomEdit, TRMPrintwwSpinEdit);
  RMRegisterFormReportControl(TwwDBCustomCheckBox, TRMPrintwwDBCheckBox);

{$ENDIF}
end.

⌨️ 快捷键说明

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