报表处理组件 BY DELPHI(2)

2008-04-10 02:58:27来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折


}
if AText = '''''''' then Exit;

ColorRef := ColorToRGB(ACanvas.Brush.Color);
DitheredFlag := //(ACanvas = Printer.Canvas) or
(Windows.GetNearestColor(ACanvas.Handle, ColorRef) <> ColorRef);

if DitheredFlag then
begin
with DrawBitmap,ARect do { Use offscreen bitmap to eliminate flicker and }
begin { brush origin tics in painting / scrolling. }
Width := Max(Width, Right - Left);
Height := Max(Height, Bottom - Top);
Canvas.Font := ACanvas.Font;
Canvas.Brush := ACanvas.Brush;
Canvas.Brush.Style := bsSolid;
TempRect := Rect(0, 0, Right - Left, Bottom - Top);
Windows.ExtTextOut(Canvas.Handle,0,0,{ETO_OPAQUE or }ETO_CLIPPED,@TempRect, Nil,0,Nil)
end;
end;

{Prepare parameters for below process}
case Direction of
tdVertChinese:
begin
{More special,use the equivalent width font}
ACanvas.Font.Pitch := fpFixed;
Scaler := 1;
MaxExtent := ARect.Bottom - ARect.Top ;
end;
0:{Horizontal}
begin
Scaler := 1;
MaxExtent := ARect.Right - ARect.Left ;
end;
1..45:
begin
SetLogicFont;
Scaler := Cos(Direction * Pi / 180);
MaxExtent := Floor((ARect.Right - ARect.Left)/Scaler);
end;
46..90:
begin
SetLogicFont;
Scaler := Sin(Direction * Pi / 180);
MaxExtent := Floor((ARect.Bottom - ARect.Top)/ Scaler);
end;
-90..-46:
begin
SetLogicFont;
Scaler := Sin(-Direction * Pi / 180);
MaxExtent := Floor((ARect.Bottom - ARect.Top)/ Scaler);
end;
-45..-1:
begin
SetLogicFont;
Scaler := Cos(-Direction * Pi / 180);
MaxExtent := Floor((ARect.Right - ARect.Left)/Scaler);
end;
end;

{Get control text}
case Control of
tcWordBreak:
begin
J := 0;
X := 0;
TempStr := WideString(AText);
for I := 1 to Length(WideString(AText)) do
begin
S := WideString(AText)[I];
if (S = #13) or (S = #10) then
J := 0
else begin
Windows.GetTextExtentPoint32(ACanvas.Handle, PChar(S), Length(S), TempExtent);
//TempExtent := ACanvas.TextExtent(S);
if Direction = tdVertChinese then
begin
Inc(J,TempExtent.CY);
if J > MaxExtent then
begin
J := TempExtent.CY;
Insert(#13#10,TempStr,I X); {Soft return}
Inc(X,2);
end;
end else
begin
Inc(J,TempExtent.CX);
if J > MaxExtent then
begin
J := TempExtent.CX;
Insert(#13#10,TempStr,I X); {Soft return}
Inc(X,2);
end;
end;
end;
end;
Texts.Text := TempStr;
end;
tcSelfAdapt:
begin
Texts.Text := AText;
if Direction = tdVertChinese then
begin
//J := 0;
//X := Length(WideString(Texts[0]));
//TempStr := WideString(Texts[0]);
TempStr := '''''''';
for I := 0 to Texts.Count - 1 do
begin
if Length(TempStr) < Length(WideString(Texts[I])) then
TempStr := WideString(Texts[I]);
//if X < Length(WideString(Texts[I])) then
//begin
// X := Length(WideString(Texts[I]));
// J := I;
//end;
end;
//TempStr := WideString(Texts[J]);
if Length(TempStr) <> 0 then
begin
J := Floor(MaxExtent / Length(TempStr));
for I := ACanvas.Font.Size-1 downto 5 do
begin
Windows.GetTextMetrics(ACanvas.Handle,TextMetric);
if TextMetric.tmHeight < J then Break
else ACanvas.Font.Size := I;
end;
// if -ACanvas.Font.Height > J then
// SetLogicFont(0,0);
// else
end;
end else begin
J := 0;
S := '''''''';
for I := 0 to Texts.Count - 1 do
begin
Windows.GetTextExtentPoint32(ACanvas.Handle, PChar(Texts[I]), Length(Texts[I]), TempExtent);
if J < TempExtent.CX then
begin
S := Texts[I];
J := TempExtent.CX;
end;
end;

{for I := ACanvas.Font.Size-1 downto 5 do
begin
Windows.GetTextExtentPoint32(ACanvas.Handle, PChar(S), Length(S), TempExtent);
if TempExtent.CX < MaxExtent then Break
else ACanvas.Font.Size := I;
end;}
Windows.GetTextExtentPoint32(ACanvas.Handle, PChar(S), Length(S), TempExtent);
if TempExtent.CX > MaxExtent then
for I := -ACanvas.Font.Height downto 1 do

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Delphi 程序员代码编写标准指南

下一篇:用DELPHI设计代理服务器程序