if TheHeight<=-Font.height + 4 then //当上下调整高度,如果高度小于字体高度时,就强制最小高度为字体高度;
begin
TheHeight:=-Font.height + 4; height:= -Font.height + 4;
end;
if TheWidth <=Font.Size then //当左右调整宽度,如果宽度小于字体大小时,就强制最小宽度为字体宽度;
begin
TheWidth:=Font.size; width:=Font.Size;
end;
if DisplayMode = piece then // 分片显示
begin
PerDispLines:= theHeight div (-Font.height + 4);
//PerDispLines:= Height div (-Font.height + 4); //计算每片能显示的文本行数
Height := PerDispLines * (-Font.height + 4); //可能因为不能整除,调整显示控件的高度
if PerDispLines=0 then PerDispLines:=1;
DevidePageNum:=(TheText.Lines.Count+1) div PerDispLines; //计算分多少片显示
if (TheText.Lines.Count+1) mod PerDispLines <> 0 then //如100行,每片8行,除为12.5,为12,需要13片显示
Inc(DevidePageNum); //能整除则不需要处理;
end;
if TheText.Lines.Count > 0 then
begin
if DisplayMode = piece then // 分片处理
begin
linebeginPos:=0; //从显示窗口的第0行开始显示
for CurrentLine:=(CurDevPageNum-1)*PerDispLines to CurDevPageNum*PerDispLines-1 do
begin
TextBitmap.Canvas.TextOut(0,linebeginPos*(-Font.height + 4),TheText.Lines[CurrentLine]);
linebeginPos:=linebeginPos+1;
end;
end
else
begin
for CurrentLine := 0 to TheText.Lines.Count - 1 do
begin
TextBitmap.Canvas.TextOut(0,CurrentLine*(-Font.height + 4),
TheText.Lines[CurrentLine]);
end;
end;
end
else //Add Text Element's Title by WY
begin
TextBitmap.width := 100;
TextBitmap.Canvas.Font.Name := '宋体';
TextBitmap.Canvas.Font.Size := 11;
TextBitmap.Canvas.Font.Color := clBlack;
TextBitmap.Canvas.brush.Color := clWhite;
TextBitmap.Canvas.TextOut(1,1,'文本(Text)');
end;
end;