printing added

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@312 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1998-07-20 08:43:47 +00:00
parent 86bb7d4825
commit 9480f5d151
2 changed files with 60 additions and 10 deletions

View File

@@ -25,6 +25,10 @@
#include "wxllist.h" #include "wxllist.h"
#include "iostream" #include "iostream"
#include <wx/dc.h>
#include <wx/postscrp.h>
#include <wx/print.h>
#define BASELINESTRETCH 12 #define BASELINESTRETCH 12
#define VAR(x) cerr << #x"=" << x << endl; #define VAR(x) cerr << #x"=" << x << endl;
@@ -272,6 +276,40 @@ wxLayoutList::Draw(wxDC &dc, bool findObject, wxPoint const &findCoords)
// used temporarily // used temporarily
wxLayoutObjectText *tobj = NULL; wxLayoutObjectText *tobj = NULL;
// this is needed for printing to a printer:
// only interesting for printer/PS output
int pageWidth, pageHeight; //GetSize() still needs int at the moment
struct
{
int top, bottom, left, right;
} margins;
if(
#ifdef __WXMSW__
dc.IsKindOf(CLASSINFO(wxPrinterDC)) ||
#endif
dc.IsKindOf(CLASSINFO(wxPostScriptDC)))
{
VAR(wxThePrintSetupData);
dc.GetSize(&pageWidth, &pageHeight);
dc.StartDoc(_("Printing..."));
dc.StartPage();
margins.top = (1*pageHeight)/10; // 10%
margins.bottom = (9*pageHeight)/10; // 90%
margins.left = (1*pageWidth)/10;
margins.right = (9*pageWidth)/10;
}
else
{
margins.top = 0; margins.left = 0;
margins.right = -1;
margins.bottom = -1;
}
position.y = margins.right;
position.x = margins.left;
VAR(findObject); VAR(findCoords.x); VAR(findCoords.y); VAR(findObject); VAR(findCoords.x); VAR(findCoords.y);
// if the cursorobject is a cmd, we need to find the first // if the cursorobject is a cmd, we need to find the first
// printable object: // printable object:
@@ -379,7 +417,16 @@ wxLayoutList::Draw(wxDC &dc, bool findObject, wxPoint const &findCoords)
} }
if(! draw) // finished calculating sizes if(! draw) // finished calculating sizes
{ // do this line again, this time drawing it {
// if the this line needs to go onto a new page, we need
// to change pages before drawing it:
if(margins.bottom != -1 && position.y > margins.bottom)
{
dc.EndPage();
position_HeadOfLine.y = margins.top;
dc.StartPage();
}
// do this line again, this time drawing it
position = position_HeadOfLine; position = position_HeadOfLine;
draw = true; draw = true;
i = headOfLine; i = headOfLine;
@@ -394,7 +441,7 @@ wxLayoutList::Draw(wxDC &dc, bool findObject, wxPoint const &findCoords)
// is it a linebreak? // is it a linebreak?
if(type == WXLO_TYPE_LINEBREAK || i == tail()) if(type == WXLO_TYPE_LINEBREAK || i == tail())
{ {
position.x = 0; position.x = margins.left;
position.y += baseLineSkip; position.y += baseLineSkip;
baseLine = m_FontPtSize; baseLine = m_FontPtSize;
objBaseLine = baseLine; // not all objects set it objBaseLine = baseLine; // not all objects set it
@@ -405,6 +452,7 @@ wxLayoutList::Draw(wxDC &dc, bool findObject, wxPoint const &findCoords)
} }
i++; i++;
} }
dc.EndDoc();
m_MaxY = position.y; m_MaxY = position.y;
return foundObject; return foundObject;
} }

View File

@@ -141,6 +141,8 @@ wxLayoutWindow::UpdateScrollbars(void)
void void
wxLayoutWindow::Print(void) wxLayoutWindow::Print(void)
{ {
VAR(wxThePrintSetupData);
wxPostScriptDC dc("layout.ps",true,this); wxPostScriptDC dc("layout.ps",true,this);
if (dc.Ok() && dc.StartDoc((char *)_("Printing message..."))) if (dc.Ok() && dc.StartDoc((char *)_("Printing message...")))
{ {