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

📄 qm_rconsole.pas

📁 一个管理系统
💻 PAS
📖 第 1 页 / 共 4 页
字号:
          begin
            LineHg := LineHg + R_TitleRowHeights[p];
            inc(p);
          end;
          QRLabel := TQRLabel.Create(QROwner);
          QRLabel.Parent := QRHBand;
          with QRLabel do
          begin
            AutoSize := false;
            WordWrap := False;
            Font.Assign(Columns[j-1].Title.Font);
            Left := LineLft + R_LftMargin;
            Caption := R_Titles[j-1][k];
            iTmp := TextRow(Caption);
            Height := iTmp * QM_TextHeight(Font); //R_TitleTextHg;
            Width := LineWd - 3;
             Top := LineTp + (LineHg - Height) div 2;
            Alignment := Columns[j-1].Title.Alignment;
            Transparent := True;
            if rgTitleBottomLines in Grid.Options then
            begin
              Frame.DrawBottom := True;
              Frame.Color := Columns[j-1].Title.Font.Color;
            end;
            if NeedName then
              Name := QM_UniqueName(QROwner, 'QRLabel');
          end;
        end;
        LineTp := LineTp + R_TitleRowHeights[k];
        inc(k);
      end;
      LineLft := LineLft + Columns[j-1].Width;
    end;
    if rgLines in Grid.Options then
      P_DrawTitleLine();
    Hline.Free;
    Vline.Free;
  end;

  procedure P_DrawSummaryLine;
  var
    i:integer;
  begin
    LineLft := 0;
    if rgColLines in Grid.Options then
    for i := 0 to Columns.Count - 1 do
    begin
      if (R_LRLineWd > 0) or (i > 0) then
      begin
        QRShape := TQRShape.Create(QROwner);
        QRShape.Parent := QRBBand;
        with QRShape do
        begin
          Height := R_FooterHeight + 1;
          Brush.Color := R_LineColor;
          pen.Color := R_LineColor;
          Left := LineLft + R_LftMargin;
          Top := -1;
          if i=0 then Width := R_LineWd else Width := 1;
          if NeedName then
            Name := QM_UniqueName(QROwner, 'QRShape');
        end;
      end;
      LineLft := LineLft + Columns[i].Width;
    end;

    if (R_LRLineWd <> 0) and (rgColLines in Grid.Options) then
    begin
      QRShape := TQRShape.Create(QROwner);
      QRShape.Parent := QRBBand;
      with QRShape do
      begin
        Height := R_FooterHeight + 1;
        Brush.Color := R_LineColor;
        pen.Color := R_LineColor;
        Left := LineLft - R_LineWd + 1 + R_LftMargin;
        Top := -1;
        Width := R_LRLineWd;
        if NeedName then
          Name := QM_UniqueName(QROwner, 'QRShape');
      end;
    end;
    if rgRowLines in Grid.Options then
    for i := 1 to Grid.FooterRowCount - 1 do
    begin
      QRShape := TQRShape.Create(QROwner);
      QRShape.Parent := QRBBand;
      with QRShape do
      begin
        Height := 1;
        Brush.Color := R_LineColor;
        pen.Color := R_LineColor;
        Left := R_LftMargin;
        Top := i*R_DetailHeight - 1;
        Width := R_RepWidth + 1;
        if NeedName then
          Name := QM_UniqueName(QROwner, 'QRShape');
      end;
    end;
  end;

  function P_GetFooterValue(iRow,iCol: Integer): string;
  begin
    if iRow < Columns[iCol].Footers.Count then
      Result := Columns[iCol].Footers[iRow].Caption
    else
      Result := Columns[iCol].Footer.Caption;
  end;

  procedure ColumnScale;
  var
    T_Real: Real;
    i,ReportWidth,R_PageWd,R_ReportWd,T_Val: Integer;
  begin
    ReportWidth := 0;
    for i:=0 to Columns.Count-1 do
      Inc(ReportWidth, Columns[i].Width);
    R_PageWd := QM_FindBand(rbColumnHeader, BGColor).Width;
    QMQuickRep.Bands.HasColumnHeader := False;
    if R_PageWd < 10 then R_PageWd := 10;
    if ReportWidth < 10 then R_ReportWd := R_PageWd
    else R_ReportWd := ReportWidth;
    R_ScaleWL := Scale/100;
    T_Val := Round(R_ReportWd * R_ScaleWL);
    T_Real := Round(R_PageWd/R_ReportWd * 100)/100;
    if rcFitToPageWidth in Options then
    begin
      if (rcAllowExtend in Options) or (T_Val > R_PageWd) then
        if rcScaleWhole in Options then
      begin
        R_ScaleWL := T_Real;
      end else
        R_ScaleWL := T_Real;
    end;
    R_ScaleWL := QM_GetFloatValue(R_ScaleWL, 0.1, 5);
    if (rcCenter in Options) and (T_Val < R_PageWd)
      and ( not ((rcFitToPageWidth in Options) and (rcAllowExtend in Options))) then
      R_LftMargin := (R_PageWd - T_Val) div 2 - 1
    else R_LftMargin := 0;
  end;

begin
  if GridType = gtGrid then
  begin
    Columns := TQMColumns.Create(self, TQMColumn);
    Columns.Assign(Grid.Columns);
    Columns.Grid := Grid;
  end else
    Columns := Grid.Columns;
  if Page.Columns = 1 then
  begin
    R_ScaleWL := ScaleWL;
    R_LftMargin := LftMargin;
  end else ColumnScale();
  if rcBodyFont in Options then
    R_TitleTextHg := QM_TextHeight(Font)
  else R_TitleTextHg := QM_TextHeight(Grid.TitleFont);
  R_TitleTextHg := Round(R_TitleTextHg * ScaleHT);
  if Grid.TitleHeight = 0 then
    R_TBMargin := Round((QM_TextHeight(Grid.TitleFont) + 6)*ScaleHT) -  R_TitleTextHg
  else
    R_TBMargin := Round(Grid.TitleHeight*ScaleHT) - R_TitleTextHg;
  if Grid.RowHeight =0 then
    R_DetailHeight := Round((QM_TextHeight(Grid.Font) + 5)*ScaleHT)
  else
    R_DetailHeight := Round(Grid.RowHeight * ScaleHT);
  if (Columns.Count = 0) or (R_DetailHeight < 5) then Exit;
  B_Titles := (rgTitles in Grid.Options) and (R_TitleTextHg + R_TBMargin >= 5);
  QMQuickRep.DataSet := DataSet;
  R_RepWidth := 0;
  SetLength(R_Titles, Columns.Count);
  for i := 0 to Columns.Count - 1 do
  begin
    R_Titles[i] := TStringList.Create;
    tmpStr := QM_ReplaceStr(Columns[i].Title.Caption, '||', '|');
    if LeftStr(tmpStr,1)='|' then tmpStr := RightStr(tmpStr, Length(tmpStr) - 1);
    if RightStr(tmpStr,1)='|' then tmpStr := LeftStr(tmpStr, Length(tmpStr) - 1);
    R_Titles[i].Add(tmpStr);
    Columns[i].Width := Round(Columns[i].Width * R_ScaleWL);
    Inc(R_RepWidth,Columns[i].Width);
    if rcBodyFont in Options then
    begin
      Columns[i].Title.Font.Assign(Font);
      Columns[i].Font.Assign(Font);
      Columns[i].Footer.Font.Assign(Font);
      for j := 0 to Columns[i].Footers.Count - 1 do
        Columns[i].Footers[j].Font.Assign(Font);
    end;
    Columns[i].Title.Font.Height := Round(Columns[i].Title.Font.Height * ScaleHT);
    Columns[i].Title.Font.Color := QM_PrintColor(self, Columns[i].Title.Font.Color);
    Columns[i].Font.Height := Round(Columns[i].Font.Height*ScaleHT);
    Columns[i].Font.Color := QM_PrintColor(self, Columns[i].Font.Color);
    Columns[i].Footer.Font.Height := Round(Columns[i].Footer.Font.Height * ScaleHT);
    Columns[i].Footer.Font.Color := QM_PrintColor(self, Columns[i].Footer.Font.Color);
    for j := 0 to Columns[i].Footers.Count - 1 do
    begin
      Columns[i].Footers[j].Font.Height := Round(Columns[i].Footers[j].Font.Height * ScaleHT);
      Columns[i].Footers[j].Font.Color := QM_PrintColor(self, Columns[i].Footers[j].Font.Color);
    end;
  end;
  if Grid.TitleMulti then
    R_TitleRowCount := DeCaption()
  else
    R_TitleRowCount := 1;
  R_LineColor := QM_PrintColor(self, LineColor);
  if rgBoldFrame in Grid.Options then R_LineWd := 2 else R_LineWd := 1;
  if not (rgLRLines in Grid.Options) then R_LRLineWd := 0
  else R_LRLineWd := R_LineWd;
  if B_Titles or (rgKeepTitleHeight in Grid.Options) then P_DrawTitle();
  if ((not B_Titles) or ((rgKeepTitleHeight in Grid.Options) and (not B_Titles)))
     and ((rgLines in Grid.Options) and (rgRowLines in Grid.Options)) then
  begin
    QRHBand := QM_FindBand(rbColumnHeader, BGColor);
    QRHBand.Height := QRHBand.Height + R_LineWd + 1;
    QRShape := TQRShape.Create(QROwner);
    QRShape.Parent := QRHBand;
    with QRShape do
    begin
      Height := R_LineWd;
      Brush.Color := R_LineColor;
      pen.Color := R_LineColor;
      Left := R_LftMargin;
      Top := QRHBand.Height - R_LineWd - 1;
      Width := R_RepWidth + 1;
      if NeedName then
        Name := QM_UniqueName(QROwner,'QRShape');
    end;
  end;
  //Draw Detail
  QMQuickRep.Bands.HasDetail := False;
  QRBBand := QM_FindBand(rbDetail, BGColor);
  QRBBand.Height := R_DetailHeight;
  LineLft := 2;
  if HasDataSet then
  begin
    for i := 0 to Columns.Count - 1 do
    begin
      if Columns[i].Width < 6 then
      begin
        LineLft := LineLft + Columns[i].Width;
        Continue;
      end;
      if Columns[i].FieldName <> '' then
      begin
        QRExpr := TQRExpr.Create(QROwner);
        QRExpr.Parent := QRBBand;
        with QRExpr do
        begin
          AutoSize := Columns[i].AutoSize;
          WordWrap := False;
          Transparent := True;
          Font.Assign(Columns[i].Font);
          Width := Columns[i].Width - 3;
          Left := LineLft + R_LftMargin;
          Mask := Columns[i].DisplayFormat;
          if Copy(Columns[i].FieldName,1,1)='=' then
            Expression := Copy(Columns[i].FieldName,2,Length(Columns[i].FieldName) - 1)
          else
          begin
            if Columns[i].HideZero then
              Expression := 'if([' + Columns[i].FieldName + ']=0,'''',[' + Columns[i].FieldName + '])'
            else
              Expression := '[' + Columns[i].FieldName + ']';
          end;
          if (Grid.DetailAlign = alTop) or (R_DetailHeight < QM_TextHeight(Font)) then
            Top := 1
          else if Grid.DetailAlign = alBottom then
            Top := R_DetailHeight - QM_TextHeight(Font) - 2
          else
            Top := (R_DetailHeight - QM_TextHeight(Font)) div 2;
          Alignment := Columns[i].Alignment;
          if NeedName then
            Name := QM_UniqueName(QROwner,'QRExpr');
        end;
      end;
      LineLft := LineLft + Columns[i].Width;
    end;
  end else
  begin
    SetLength(QRLabels, Columns.Count);
    iTmp := 0;
    for i := 0 to Columns.Count - 1 do
    begin
      if Columns[i].Width < 6 then
      begin
        LineLft := LineLft + Columns[i].Width;
        Continue;
      end;
      Inc(iTmp);
      QRLabel := TQRLabel.Create(QROwner);
      QRLabel.Parent := QRBBand;
      QRLabels[i] := QRLabel;
      with QRLabel do
      begin
        AutoSize := Columns[i].AutoSize;
        WordWrap := False;
        Transparent := True;
        Font.Assign(Columns[i].Font);
        Width := Columns[i].Width - 3;
        Left := LineLft + R_LftMargin;
        if (Grid.DetailAlign=alTop) then {or (R_DetailHeight<QM_TextHeight(Font))} 
          Top := 1
        else if Grid.DetailAlign=alBottom then
          Top := R_DetailHeight - QM_TextHeight(Font) - 1
        else
          Top := (R_DetailHeight - QM_TextHeight(Font)) div 2;
        Alignment := Columns[i].Alignment;
        if NeedName then
          Name := QM_UniqueName(QROwner,'QRLabel');
      end;
      LineLft := LineLft + Columns[i].Width;
    end;
    SetLength(QRLabels, iTmp);
    QMQuickRep.OnNeedData := OnNeedData;
  end;
  if rgLines in Grid.Options then
    P_DrawBodyLine();
  //Draw GridFooter
  R_FooterHeight := R_DetailHeight * Grid.FooterRowCount;
  QRBBand := QM_FindBand(rbSummary, BGColor);
  if (rgRowLines in Grid.Options) and (rgLines in Grid.Options) then
  begin
    if QRBBand.Tag = 1 then QRBBand.Height := 1;
    QRShape := TQRShape.Create(QROwner);
    QRShape.Parent := QRBBand;
    with QRShape do
    begin
      if rgBoldFrame in Grid.Options then
        Height :=2
      else Height := 1;
      Brush.Color := R_LineColor;
      pen.Color := R_LineColor;
      Left := R_LftMargin;
      Top := -1;
      Width := R_RepWidth + 1;
      if NeedName then
        Name := QM_UniqueName(QROwner, 'QRShape');
    end;
  end;
  if Grid.FooterRowCount > 0 then
  begin
    QM_SpaceBand(R_FooterHeight, QRBBand);
    for i := 0 to Grid.FooterRowCount - 1 do
    begin
      LineLft := 2;
      for j := 0 to Columns.Count - 1 do
      begin
        if (Trim(P_GetFooterValue(i,j)) = '') or (Columns[j].Width < 6) then
        begin
          LineLft := LineLft + Columns[j].Width;
          Continue;
        end;
        QRLabel := TQRLabel.Create(QROwner);
        QRLabel.Parent := QRBBand;
        with QRLabel do
        begin
          AutoSize := Columns[j].AutoSize;
          WordWrap := False;
          Transparent := True;
          if Columns[j].Footers.Count > i then
          begin
            Font.Assign(Columns[j].Footers[i].Font);
            Alignment := Columns[j].Footers[i].Alignment;
          end else
          begin
            Font.Assign(Columns[j].Footer.Font);
            Alignment := Columns[j].Footer.Alignment;
          end;
          Height := QM_TextHeight(Font);
          Left := LineLft + R_LftMargin;
          Caption := P_GetFooterValue(i,j);
          Width := Columns[j].Width - 3;
          if (Grid.DetailAlign = alTop) or (R_DetailHeight < QM_TextHeight(Font)) then
            Top := i * (R_DetailHeight) + 1
          else if Grid.DetailAlign = alBottom then
            Top := (i + 1) * (R_DetailHeight) - QM_TextHeight(Font) - 1
          else
            Top := i * (R_DetailHeight) + (R_DetailHeight - QM_TextHeight(Font)) div 2;
          if NeedName then
            Name := QM_UniqueName(QROwner, 'QRLabel');
          if i = Grid.FooterRowCount - 1 then SendToBack;
        end;
        LineLft := LineLft + Columns[j].Width;
      end;
    end;
    if rgLines in Grid.Options then
      P_DrawSummaryLine();
  end;
  //Free Memory
  for i := 0 to Columns.Count - 1 do
    R_Titles[i].Free;
  Columns.Clear;
  if GridType = gtGrid then Columns.Free;
end;

end.

⌨️ 快捷键说明

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