trichview.support
DrawText to Canvas and Font Settings |
Author |
Message |
Wayne Edward |
Posted: 01/07/2003 15:08:12 I'm trying to take advantage of the TRVStyle.OnDrawParaBack to apply some custom text-based formatting for fixed with reports. My problem is when I draw the borders I am not getting the same font style as my paragraph. The reports have to use a fixed width font (courier) and a set maxtextwidth of 60 characters. The border for this example uses the equal sign (=) for both top and bottom for the length of the line. However, the border text is getting written out using a more compressed font and does not match the spacing for the normal text. I have included some simple sample code below. Am I missing something? RichViewEdit1.LeftMargin and RightMargin = 0 filler:= '========== ... 60 equal signs ------ procedure TForm1.FormCreate(Sender:Object); begin RichViewEdit1.Clear; // Setting Line Width to 60 Characters RichViewEdit1.MaxTextWidth:= RichViewEdit1.Canvas.TextWidth(filler); // Opening one line space above and below paragraph for border RVStyle1.ParaStyles[0].SpaceBefore:= RichViewEdit1.Canvas.TextHeight('ABC'); RVStyle1.ParaStyles[0].SpaceAfter:= RVStyle1.SpaceBefore; // Add Test Text (using 60 character length) RichViewEdit1.AddNL('111111111 222222222 333333333 444444444 555555555 6666666666,0,0); RichViewEdit1.Format; end; ----- procedure TForm1.RVStyle1DrawParaBack(Sender: RVStyle; Canvas: TCanvas ParaNo: Integer; ARect: TRect; var DoDefault: Boolean); var r1: TRect; s: String; begin doDefault:= False; // Setting canvas font Canvas.Font.Size:= sender.TextStyles[0].Size; Canvas.Font.Name:= sender.TextStyles[0].FontName;
s:= '=============== ... <- 60 equal spaces
// Set rectangle to cover space above and below r1.left:= ARect.left; r1.top:= ARect.top - sender.ParaStyles[0].SpaceBefore; r1.right:= ARect.Right; r1.bottom:= ARect.bottom + sender.ParaStyles[0].SpaceAfter; // output text that is used for top and bottom border DrawText(canvas.Handle, pChar(s), -1, r1, DT_TOP or DT_SINGLELINE); DrawText(canvas.Handle, pChar(s), -1, r1, DT_BOTTOM or DT_SINGLELINE); end; |
Powered by ABC Amber Outlook Express Converter