source: branches/2.20_branch/Components/RichTextPrintUnit.pas@ 442

Last change on this file since 442 was 15, checked in by RBRi, 19 years ago

+ components stuff

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1Unit RichTextPrintUnit;
2
3Interface
4
5uses
6 Graphics,
7 RichTextStyleUnit;
8
9// Prints the specified rich text, starting at page position PageY.
10// Starts new pages as needed; when done, PageY is the final position used
11// on the final page.
12Procedure PrintRichText( Text: PChar;
13 Images: TImageList;
14 Settings: TRichTextSettings;
15 var PageY: longint );
16
17Implementation
18
19uses
20 Classes,
21 Printers,
22 CanvasFontManager,
23 RichTextLayoutUnit, RichTextDisplayUnit, Forms
24 ;
25
26Procedure PrintRichText( Text: PChar;
27 Images: TImageList;
28 Settings: TRichTextSettings;
29 var PageY: longint );
30var
31 Layout: TRichTextLayout;
32 FontManager: TCanvasFontManager;
33 LineIndex: longint;
34 Y: longint;
35 FinishLine: longint;
36 FinishY: longint;
37Begin
38 FontManager := TCanvasFontManager.Create( Printer.Canvas,
39 false // don't allow bitmap fonts
40 );
41
42 Layout := TRichTextLayout.Create( Text,
43 Images,
44 Settings,
45 FontManager,
46 Printer.PageWidth );
47
48 LineIndex := 0;
49 Y := PageY;
50 repeat
51 PrintRichTextLayout( FontManager,
52 Layout,
53 LineIndex,
54 FinishLine,
55 Y,
56 FinishY );
57 LineIndex := FinishLine;
58 Y := FinishY;
59
60 if LineIndex < Layout.FNumLines then
61 begin
62 // didn't all fit on page, so new page
63 Printer.NewPage;
64 Y := Printer.PageHeight - 1;
65 end;
66
67 until LineIndex >= Layout.FNumLines;
68
69 Layout.Destroy;
70 FontManager.Destroy;
71 PageY := Y;
72end;
73
74Initialization
75End.
Note: See TracBrowser for help on using the repository browser.