Last change
on this file since 415 was 15, checked in by RBRi, 19 years ago |
+ components stuff
|
-
Property svn:eol-style
set to
native
|
File size:
1.8 KB
|
Line | |
---|
1 | Unit RichTextPrintUnit;
|
---|
2 |
|
---|
3 | Interface
|
---|
4 |
|
---|
5 | uses
|
---|
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.
|
---|
12 | Procedure PrintRichText( Text: PChar;
|
---|
13 | Images: TImageList;
|
---|
14 | Settings: TRichTextSettings;
|
---|
15 | var PageY: longint );
|
---|
16 |
|
---|
17 | Implementation
|
---|
18 |
|
---|
19 | uses
|
---|
20 | Classes,
|
---|
21 | Printers,
|
---|
22 | CanvasFontManager,
|
---|
23 | RichTextLayoutUnit, RichTextDisplayUnit, Forms
|
---|
24 | ;
|
---|
25 |
|
---|
26 | Procedure PrintRichText( Text: PChar;
|
---|
27 | Images: TImageList;
|
---|
28 | Settings: TRichTextSettings;
|
---|
29 | var PageY: longint );
|
---|
30 | var
|
---|
31 | Layout: TRichTextLayout;
|
---|
32 | FontManager: TCanvasFontManager;
|
---|
33 | LineIndex: longint;
|
---|
34 | Y: longint;
|
---|
35 | FinishLine: longint;
|
---|
36 | FinishY: longint;
|
---|
37 | Begin
|
---|
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;
|
---|
72 | end;
|
---|
73 |
|
---|
74 | Initialization
|
---|
75 | End.
|
---|
Note:
See
TracBrowser
for help on using the repository browser.