| View previous topic :: View next topic |
| Author |
Message |
P_G Member
Joined: 14 Jun 2004 Posts: 21 Location: Germany
|
Posted: 25/01/05 10:34 Post subject: Multiple pages in SimpleGraph |
|
|
Hello there,
I was looking for a way to have multiple pages in a SimpleGraph. Of course this could be a feature for future releases ***hint, hint***
Or does anyone have a workaround for splitting the contents of a SimpleGraph to several pages of a PrintPreview?
BTW - Kambiz, are you still programming I think I read something about you stopping the development of freeware components (But I might be wrong). This would be really sad...
P_G |
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 414 Location: Tehran, Iran
|
Posted: 27/01/05 10:16 Post subject: |
|
|
As a workaround, you can get metafile of the graph, and then print on each page one part of the image.
I'm still programming because it's my profession. I hope one day I find my interest back to continue freeware component development. |
|
| Back to top |
|
 |
Stefan Junior Member
Joined: 27 Sep 2004 Posts: 61 Location: Netherlands
|
Posted: 27/01/05 15:11 Post subject: |
|
|
Hey,
I really like the idea of splitting up the Graph into pages in the runtime-design state. I'll put it on my "i-wish-i-had-more-time"-list
Any thoughts on the subject; on how to implement or how it should "look" are more than very welcome...
Cheers,
Stefan |
|
| Back to top |
|
 |
P_G Member
Joined: 14 Jun 2004 Posts: 21 Location: Germany
|
Posted: 29/01/05 20:43 Post subject: |
|
|
I really love this forum! What more can I say ...?
I hope, one day you find back your interest in programming freeware components, Kambiz. Your components rock !!!
With best regards, P_G |
|
| Back to top |
|
 |
MeW Member
Joined: 17 Feb 2005 Posts: 6 Location: Netherlands
|
Posted: 17/02/05 18:41 Post subject: |
|
|
I've developed a multipage printing routine for TSimpleGraph and TPrintPreview. It's quite simple once you get the hang of it. From my Preview form I can adjust the scale of the Diagram from 10% to 200% using a Trackbar. Upon changing this bar the callback routine is triggered to re-generate the printer document.
Here comes the code:
| Code: | procedure TMainFrm.Printgraph(aPrintPreview: TPrintPreview; aScale: real);
var
R: TRect;
ImageSize, PrintSize: TPoint;
x, y: integer;
begin
aPrintPreview.BeginDoc;
R := aPrintPreview.PrinterPageBounds;
PrintSize.X := R.Right-R.Left;
PrintSize.Y := R.Bottom-R.Top;
ImageSize.X := Trunc(PrintSize.X * aScale); { aScale is [0.1 - 2] }
ImageSize.Y := Trunc(PrintSize.Y * aScale);
if (ImageSize.X > PrintSize.X) or
(ImageSize.Y > PrintSize.Y) then
begin
{ multipage printing }
x := 0;
y := 0;
while (x < ImageSize.X) and (y < ImageSize.Y) do
begin
R := Rect(0, 0, ImageSize.X, ImageSize.Y);
OffsetRect(R, -x, -y);
FGraph.Print(aPrintPreview.Canvas, R); { or some other stretched drawing thing }
{ step horizontally }
if (x + PrintSize.X < ImageSize.X) then
begin
Inc(x, PrintSize.X);
aPrintPreview.NewPage;
end
else
begin
x := 0;
Inc(y, PrintSize.Y);
{ step vertically }
if (y < ImageSize.Y) then
begin
aPrintPreview.NewPage;
end
else
begin
y := 0;
Break;
end;
end;
end;
end
else
begin
{ centered single page printing }
InflateRect(R,
-(PrintSize.X - ImageSize.X) div 2,
-(PrintSize.Y - ImageSize.Y) div 2);
FGraph.Print(aPrintPreview.Canvas, R);
end;
aPrintPreview.EndDoc;
end;
|
Works like magic if you don't mind me saying so. |
|
| Back to top |
|
 |
MeW Member
Joined: 17 Feb 2005 Posts: 6 Location: Netherlands
|
Posted: 19/02/05 20:10 Post subject: Centering and Overlap |
|
|
I've extended the previous code post with a centering option (works for single and multipage) and an overlap % for multipage. Have fun.
| Code: |
procedure TMainFrm.Printgraph(
aPrintPreview: TPrintPreview;
aScale: real;
aCenter: boolean;
aOverlapMultipage: real);
var
R: TRect;
ImageSize, PrintSize: TPoint;
Centering: TPoint;
x, y: integer;
begin
aPrintPreview.BeginDoc;
R := aPrintPreview.PrinterPageBounds;
PrintSize.X := R.Right-R.Left;
PrintSize.Y := R.Bottom-R.Top;
ImageSize.X := Trunc(PrintSize.X * aScale);
ImageSize.Y := Trunc(PrintSize.Y * aScale);
FillChar(Centering, SizeOf(Centering), #0);
if (ImageSize.X > PrintSize.X) or
(ImageSize.Y > PrintSize.Y) then
begin
{ multipage printing }
if (aOverlapMultipage < 0) then aOverlapMultipage := 0;
if (aOverlapMultipage > 0.5) then aOverlapMultipage := 0.5;
if (aCenter) then
begin
Centering.X := (PrintSize.X - (ImageSize.X mod PrintSize.X)) div 2;
Centering.Y := (PrintSize.Y - (ImageSize.Y mod PrintSize.Y)) div 2;
end;
x := 0;
y := 0;
while (x < ImageSize.X) and (y < ImageSize.Y) do
begin
R := Rect(0, 0, ImageSize.X, ImageSize.Y);
OffsetRect(R, -x + Centering.X, -y + Centering.Y);
FGraph.Print(aPrintPreview.Canvas, R);
{ step horizontally }
if (x + PrintSize.X < ImageSize.X) then
begin
Inc(x, trunc(PrintSize.X * (1-aOverlapMultiPage)));
aPrintPreview.NewPage;
end
else
begin
x := 0;
Inc(y, trunc(PrintSize.Y * (1-aOverlapMultipage)));
{ step vertically }
if (y < ImageSize.Y) then
begin
aPrintPreview.NewPage;
end;
end;
end;
end
else
begin
{ single page printing }
InflateRect(R,
-(PrintSize.X - ImageSize.X) div 2,
-(PrintSize.Y - ImageSize.Y) div 2);
if (not aCenter) then
OffsetRect(R,
-(PrintSize.X - ImageSize.X) div 2,
-(PrintSize.Y - ImageSize.Y) div 2);
FGraph.Print(aPrintPreview.Canvas, R);
end;
aPrintPreview.EndDoc;
end;
|
|
|
| Back to top |
|
 |
|