📄 qm_rconsole.pas
字号:
AutoSize := False;
WordWrap := False;
Left := rcLRMargin;
Width := R_LblWd;
if (rcRepWidth in Options) and (Page.Columns = 1) then
begin
Width := Round(Width * FScaleWL);
Left := Left + FLftMargin;
end;
Caption := cCaption;
if isStored then Font.Assign(R_Font);
Transparent := True;
Alignment := TAlignment(iAlign);
Top := i * (rcLblSpace + T_TextHg) + iTop;
if FNeedName then
Name := QM_UniqueName(QROwner, 'QRLabel');
if iType=1 then Tag := 9;
end;
if iType=1 then R_HasPageCount := True;
end else
begin
C_QRExpr := TQRExpr.Create(QROwner);
C_QRExpr.Parent := R_QRBand;
with C_QRExpr do
begin
AutoSize := False;
WordWrap := False;
Left := rcLRMargin;
Width := R_LblWd;
if (rcRepWidth in Options) and (Page.Columns = 1) then
begin
Width := Round(Width * FScaleWL);
Left := Left + FLftMargin;
end;
Expression := cCaption;
if isStored then Font.Assign(R_Font);
Transparent := True;
Alignment := TAlignment(iAlign);
Top := i * (rcLblSpace + T_TextHg) + iTop;
if FNeedName then
Name := QM_UniqueName(QROwner, 'QRExpr');
if iType=3 then Tag := 9;
end;
if iType=3 then R_HasPageCount := True;
end;
end;
end;
procedure chkBand(lnkBand: TQMLinkBand; DflHg: Integer);
begin
case lnkBand of
rtPageHeader : R_QRBand := QM_FindBand(rbPageHeader, BGColor);
rtTitle : R_QRBand := QM_FindBand(rbTitle, BGColor);
rtSummary : R_QRBand := QM_FindBand(rbSummary, BGColor);
else R_QRBand := QM_FindBand(rbPageFooter, BGColor);
end;
if R_QRBand.Tag = 1 then R_QRBand.Height := DflHg;
end;
procedure DrawLogo(iLeft: Integer);
var
QRImage:TQRImage;
begin
QRImage := TQRImage.Create(QROwner);
QRImage.Parent := R_QRBand;
with QRImage do
begin
AutoSize := False;
Center := False;
QRImage.Picture := Logo.Picture;
Top := Logo.Top;
Left := Round(iLeft * ScaleWL);
if ScaleWL = ScaleHT then
begin
Stretch := True;
Width := Round(Logo.Picture.Width * ScaleWL);
Height := Round(Logo.Picture.Height * ScaleHT);
end else if ScaleWL <> 1 then
begin
Width := Logo.Picture.Width;
Height := Logo.Picture.Height;
Left := Left + Round(Logo.Picture.Width * ScaleWL) - Logo.Picture.Width;
end else
begin
Width := Logo.Picture.Width;
Height := Logo.Picture.Height;
end;
if NeedName then
Name := QM_UniqueName(QROwner,'QRImage');
SendToBack;
end;
end;
begin
R_HasPageCount := false;
QMQuickRep.Bands.HasPageHeader := False;
QMQuickRep.Bands.HasSummary := False;
QMQuickRep.Bands.HasPageFooter := False;
QMQuickRep.Bands.HasTitle := False;
R_Font := TFont.Create;
R_RepFont := TFont.Create;
R_RepFont.Assign(Font);
R_RepFont.Color := QM_PrintColor(self, R_RepFont.Color);
R_RepFont.Height := Round(R_RepFont.Height * FScaleHT);
QMQuickRep.Font.Assign(R_RepFont);
if rcRepWidth in Options then
R_LblWd := R_ReportWd - rcLRMargin * 2 + 2
else R_LblWd := R_PageWd - rcLRMargin * 2 + 2;
R_TitleHg := 0;
R_TtlHg :=0;
R_TitleMargin := Round(ReportTitle.VertAdjust * FScaleHT);
if ReportTitle.Text.Count > 0 then
begin
R_Font.Assign(ReportTitle.Font);
R_Font.Height := Round(R_Font.Height * FScaleHT);
R_TitleHg := ReportTitle.Text.Count * (QM_TextHeight(R_Font) + rcLblSpace) - rcLblSpace + R_TitleMargin;
if ReportTitle.SubTitle.Text.Count > 0 then
begin
T_Val := Round(ReportTitle.SubTitle.VertAdjust * FScaleHT);
R_TtlHg := R_TitleHg - R_TitleMargin + T_Val;
R_Font.Assign(ReportTitle.SubTitle.Font);
R_Font.Height := Round(R_Font.Height * FScaleHT);
R_TitleHg := R_TitleHg + ReportTitle.SubTitle.Text.Count * (QM_TextHeight(R_Font) + rcLblSpace) - rcLblSpace + T_Val;
end;
end;
R_TitleTop := 0;
//pageheader
T_Cnt := Max(PageHeader.LeftText.Count, PageHeader.CenterText.Count, PageHeader.RightText.Count);
if T_Cnt>0 then
begin
R_QRBand := QM_FindBand(rbPageHeader, BGColor);
//if rcBodyFont in Options then R_Font.Assign(Font) else
if PageHeader.IsFontStored then
begin
R_Font.Assign(PageHeader.Font);
R_Font.Color := QM_PrintColor(self, R_Font.Color);
R_Font.Height := Round(R_Font.Height * FScaleHT);
R_QRBand.Font.Assign(R_Font);
T_TextHg := QM_TextHeight(R_Font);
end else T_TextHg := QM_TextHeight(R_RepFont);
R_QRBand.Height := T_Cnt * (T_TextHg + rcLblSpace) - rcLblSpace + rcTBMargin;
T_Val := 0;
R_LineTop := R_QRBand.Height - rcTBMargin + 2;
if PageHeader.LineType = rltDouble then R_QRBand.Height := R_QRBand.Height + 1;
if (R_TitleHg > 0) and (ReportTitle.LinkBand = rtPageHeader) then
begin
if (ReportTitle.TitlePos = psTop) or (ReportTitle.TitlePos = psAuto) then
begin
T_Val := R_TitleHg;
R_LineTop := R_LineTop + R_TitleHg;
end
else R_TitleTop := R_QRBand.Height + R_TitleMargin - rcTBMargin;
R_QRBand.Height := R_QRBand.Height + R_TitleHg;
end;
DrawBand(PageHeader.LeftText, 0, T_Val, false);
DrawBand(PageHeader.CenterText, 2, T_Val, false);
DrawBand(PageHeader.RightText, 1, T_Val, false);
DrawLine(PageHeader.LineType, R_LineTop);
end;
//title
T_Cnt := Max(Title.LeftText.Count,Title.CenterText.Count,Title.RightText.Count);
if T_Cnt>0 then
begin
R_QRBand := QM_FindBand(rbTitle, BGColor);
if Title.IsFontStored then
begin
R_Font.Assign(Title.Font);
R_Font.Color := QM_PrintColor(self, R_Font.Color);
R_Font.Height := Round(R_Font.Height * FScaleHT);
R_QRBand.Font.Assign(R_Font);
T_TextHg := QM_TextHeight(R_Font);
end else T_TextHg := QM_TextHeight(R_RepFont);
R_QRBand.Height := T_Cnt * (T_TextHg + rcLblSpace) - rcLblSpace + rcTBMargin;
T_Val := 0;
R_LineTop := R_QRBand.Height - rcTBMargin + 2;
if PageHeader.LineType = rltDouble then R_QRBand.Height := R_QRBand.Height + 1;
if (R_TitleHg > 0) and (ReportTitle.LinkBand = rtTitle) then
begin
if (ReportTitle.TitlePos = psTop) or (ReportTitle.TitlePos = psAuto) then
begin
T_Val := R_TitleHg;
R_LineTop := R_LineTop + R_TitleHg;
end
else R_TitleTop := R_QRBand.Height + R_TitleMargin - rcTBMargin;
R_QRBand.Height := R_QRBand.Height + R_TitleHg;
end;
DrawBand(Title.LeftText, 0, T_Val, false);
DrawBand(Title.CenterText, 2, T_Val, false);
DrawBand(Title.RightText, 1, T_Val, false);
DrawLine(Title.LineType, R_LineTop);
end;
//summary
T_Cnt := Max(Summary.LeftText.Count, Summary.CenterText.Count, Summary.RightText.Count);
if T_Cnt>0 then
begin
R_QRBand := QM_FindBand(rbSummary, BGColor);
if Summary.IsFontStored then
begin
R_Font.Assign(Summary.Font);
R_Font.Color := QM_PrintColor(self, R_Font.Color);
R_Font.Height := Round(R_Font.Height * FScaleHT);
R_QRBand.Font.Assign(R_Font);
T_TextHg := QM_TextHeight(R_Font);
end else T_TextHg := QM_TextHeight(R_RepFont);
R_QRBand.Height := T_Cnt * (T_TextHg + rcLblSpace) - rcLblSpace + rcTBMargin;
T_Val := rcTBMargin + 1;
if Summary.LineType = rltDouble then
begin
R_QRBand.Height := R_QRBand.Height + 3;
Inc(T_Val, 3);
end;
if (R_TitleHg > 0) and (ReportTitle.LinkBand = rtSummary) then
begin
if ReportTitle.TitlePos = psTop then
T_Val := R_TitleHg + rcTBMargin
else R_TitleTop := R_QRBand.Height + R_TitleMargin;
R_QRBand.Height := R_QRBand.Height + R_TitleHg;
end;
DrawBand(Summary.LeftText, 0, T_Val, false);
DrawBand(Summary.CenterText, 2, T_Val, false);
DrawBand(Summary.RightText, 1, T_Val, false);
DrawLine(Summary.LineType, 2);
end;
//pagefooter
T_Cnt := Max(PageFooter.LeftText.Count, PageFooter.CenterText.Count, PageFooter.RightText.Count);
if T_Cnt>0 then
begin
R_QRBand := QM_FindBand(rbPageFooter, BGColor);
if PageFooter.IsFontStored then
begin
R_Font.Assign(PageFooter.Font);
R_Font.Color := QM_PrintColor(self, R_Font.Color);
R_Font.Height := Round(R_Font.Height * FScaleHT);
R_QRBand.Font.Assign(R_Font);
T_TextHg := QM_TextHeight(R_Font);
end else T_TextHg := QM_TextHeight(R_RepFont);
R_QRBand.Height := T_Cnt * (T_TextHg + rcLblSpace) - rcLblSpace + rcTBMargin;
T_Val := rcTBMargin;
if PageFooter.LineType = rltDouble then
begin
R_QRBand.Height := R_QRBand.Height + 3;
Inc(T_Val, 3);
end;
if (R_TitleHg > 0) and (ReportTitle.LinkBand = rtPageFooter) then
begin
if ReportTitle.TitlePos = psTop then
T_Val := R_TitleHg + rcTBMargin
else R_TitleTop := R_QRBand.Height + R_TitleMargin;
R_QRBand.Height := R_QRBand.Height + R_TitleHg;
end;
DrawBand(PageFooter.LeftText, 0, T_Val, false);
DrawBand(PageFooter.CenterText, 2, T_Val, false);
DrawBand(PageFooter.RightText, 1, T_Val, false);
DrawLine(PageFooter.LineType, 2);
end;
//reporttitle
if R_TitleHg > 0 then
begin
chkBand(ReportTitle.LinkBand, R_TitleHg);
R_Font.Assign(ReportTitle.Font);
R_Font.Color := QM_PrintColor(self, R_Font.Color);
R_Font.Height := Round(R_Font.Height * FScaleHT);
T_TextHg := QM_TextHeight(R_Font);
DrawBand(ReportTitle.Text, Integer(ReportTitle.Alignment), R_TitleTop, True);
if R_TtlHg > 0 then
begin
R_Font.Assign(ReportTitle.SubTitle.Font);
R_Font.Color := QM_PrintColor(self, R_Font.Color);
R_Font.Height := Round(R_Font.Height * FScaleHT);
T_TextHg := QM_TextHeight(R_Font);
DrawBand(ReportTitle.SubTitle.Text, Integer(ReportTitle.SubTitle.Alignment), R_TitleTop + R_TtlHg, True);
end;
end;
R_RepFont.Free;
R_Font.Free;
//logo
if Logo.Picture.Graphic <> nil then
begin
chkBand(Logo.LinkBand, Logo.Picture.Height);
case Logo.Alignment of
taLeftJustify : T_Val := Logo.HoriAdjust;
taCenter : T_Val := Logo.HoriAdjust + (R_LblWd + rcLRMargin * 2 - 2 - Logo.Picture.Width) div 2;
else T_Val := Logo.HoriAdjust + (R_LblWd - Logo.Picture.Width + rcLRMargin * 2 - 2);
end;
DrawLogo(T_Val);
end;
end;
function TQMReportConsole.PageSetup: Boolean;
begin
Result := QM_PageSetup(self, True);
end;
procedure TQMReportConsole.DrawTo(QuickRep: TObject);
var
i: Integer;
begin
if (QuickRep <> nil) and (not (QuickRep is TQuickRep)) then Exit;
if QuickRep = nil then
begin
if Owner <> nil then
for i:=Owner.ComponentCount-1 downto 0 do
if Owner.Components[i] is TQuickRep then
begin
QuickRep := TQuickRep(Owner.Components[i]);
Break;
end;
if QuickRep = nil then Exit;
end;
QMQuickRep := TQuickRep(QuickRep);
FNeedName := True;
QM_ApplySetting(self);
DrawReport();
if R_HasPageCount then QM_ChkPageCount();
end;
procedure TQMReportConsole.ReDraw;
begin
if QMQuickRep = nil then Exit;
QM_ApplySetting(self);
FNeedName := False;
DrawReport();
if R_HasPageCount then QM_ChkPageCount();
end;
procedure TQMReportConsole.SetLogo(const Value: TQMLogo);
begin
FLogo.Assign(Value);
end;
function TQMReportConsole.GetRecordCount: Integer;
begin
Result := 0;
end;
function TQMReportConsole.GetDocumentTitle: String;
begin
if FDocumentTitle <> '' then
Result := FDocumentTitle
else if ReportTitle.Text.Count > 0 then
Result :=QM_GetQMString(self, ReportTitle.Text[0]);
//else Result := 'QReport Maker';
end;
procedure TQMReportConsole.SetSection(const Value: String);
begin
if Trim(Value) ='' then
FSection := ClassName + FormatDateTime('mmsszzz', time)
else FSection := Trim(Value);
end;
{ TQMDataReport }
constructor TQMDataReport.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
case GridType of
gtEhGrid : FGrid := TQMEhGrid.Create(self, Font);
gtDBGrid : FGrid := TQMDBGrid.Create(self, Font);
gtStringGrid : FGrid := TQMStringGrid.Create(self, Font);
else FGrid := TQMGrid.Create(self, Font);
end;
end;
destructor TQMDataReport.Destroy;
begin
FGrid.Free;
inherited Destroy;
end;
procedure TQMDataReport.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FDataSet) then FDataSet := nil;
end;
procedure TQMDataReport.SetDataSet(const Value: TDataSet);
begin
FDataSet := Value;
if Value <> nil then Value.FreeNotification(Self);
end;
function TQMDataReport.GetData(ACol: Integer): string;
begin
Result := '';
end;
var
QRLabels: array of TQRLabel;
procedure TQMDataReport.OnNeedData(Sender: TObject; var MoreData: Boolean);
var
i: Integer;
begin
MoreData := (FCurrentIndex <= FDataRowCount);
if MoreData then
begin
for i:=0 to Length(QRLabels) - 1 do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -