X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d7657f7562808945c95db96eb50808c4b61af1fe..0f66a9f39d0d48f3e0da6641fa66d1b3db305732:/src/generic/dcpsg.cpp diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 769fe92497..f67a2ec4f8 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -29,6 +29,7 @@ #if wxUSE_POSTSCRIPT +#include "wx/window.h" #include "wx/dcmemory.h" #include "wx/utils.h" #include "wx/intl.h" @@ -250,7 +251,10 @@ wxPostScriptDC::wxPostScriptDC () m_signY = -1; // default y-axis bottom up -> top down // Compatibility only + // HH: Doesn't seem to work for wxMSW... + #ifndef __WXMSW__ m_printData = * wxThePrintSetupData; + #endif } wxPostScriptDC::wxPostScriptDC (const wxString& file, bool interactive, wxWindow *parent) @@ -1003,7 +1007,11 @@ void wxPostScriptDC::SetFont( const wxFont& font ) fprintf( m_pstream, " reencodeISO def\n" ); fprintf( m_pstream, buffer ); fprintf( m_pstream, " findfont\n" ); + #ifdef __WXMSW__ + fprintf( m_pstream, "%d scalefont setfont\n", YLOG2DEVREL(m_font.GetPointSize()) ); + #else fprintf( m_pstream, "%ld scalefont setfont\n", YLOG2DEVREL(m_font.GetPointSize()) ); + #endif } void wxPostScriptDC::SetPen( const wxPen& pen ) @@ -1016,8 +1024,11 @@ void wxPostScriptDC::SetPen( const wxPen& pen ) m_pen = pen; + #ifdef __WXMSW__ + fprintf( m_pstream, "%d setlinewidth\n", XLOG2DEVREL(m_pen.GetWidth()) ); + #else fprintf( m_pstream, "%ld setlinewidth\n", XLOG2DEVREL(m_pen.GetWidth()) ); - + #endif /* Line style - WRONG: 2nd arg is OFFSET @@ -1347,16 +1358,23 @@ void wxPostScriptDC::DoGetSize(int* width, int* height) const if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4); + int w = 595; + int h = 842; if (paper) { - if (width) *width = paper->GetSizeDeviceUnits().x; - if (height) *height = paper->GetSizeDeviceUnits().y; + w = paper->GetSizeDeviceUnits().x; + h = paper->GetSizeDeviceUnits().y; } - else + + if (m_printData.GetOrientation() == wxLANDSCAPE) { - if (width) *width = 595; - if (height) *height = 842; + int tmp = w; + w = h; + h = tmp; } + + if (width) *width = w; + if (height) *height = h; } void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const @@ -1367,16 +1385,23 @@ void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4); + int w = 210; + int h = 297; if (paper) { - if (width) *width = paper->GetWidth() / 10; - if (height) *height = paper->GetHeight() / 10; + w = paper->GetWidth() / 10; + h = paper->GetHeight() / 10; } - else + + if (m_printData.GetOrientation() == wxLANDSCAPE) { - if (width) *width = 210; - if (height) *height = 297; + int tmp = w; + w = h; + h = tmp; } + + if (width) *width = w; + if (height) *height = h; } // Resolution in pixels per logical inch @@ -1449,9 +1474,9 @@ void wxPostScriptDC::EndDoc () m_pstream = fopen( wxConvFile.cWX2MB(header_file) , "w+" ); fprintf( m_pstream, "%%!PS-Adobe-2.0\n" ); // PostScript magic strings - fprintf( m_pstream, "%%%%Title: %s\n", m_title.mb_str() ); - fprintf( m_pstream, "%%%%Creator: %s\n", wxTheApp->argv[0] ); - fprintf( m_pstream, "%%%%CreationDate: %s\n", wxNow().mb_str() ); + fprintf( m_pstream, "%%%%Title: %s\n", (const char *)m_title.mb_str() ); + fprintf( m_pstream, "%%%%Creator: %s\n", (const char*)wxConvCurrent->cWX2MB(wxTheApp->argv[0]) ); + fprintf( m_pstream, "%%%%CreationDate: %s\n", (const char *)wxNow().mb_str() ); wxChar userID[256]; if ( wxGetEmailAddress(userID, sizeof(userID)) ) @@ -1587,6 +1612,7 @@ void wxPostScriptDC::StartPage() fprintf( m_pstream, "%%%%Page: %d\n", wxPageNumber++ ); + // What is this one supposed to do? RR. // *m_pstream << "matrix currentmatrix\n"; // Added by Chris Breeze @@ -1595,11 +1621,6 @@ void wxPostScriptDC::StartPage() // transformation and so we need to reset the origin // (and rotate the page for landscape printing) -/* - m_scaleFactor = 1.0; - m_logicalOriginX = 0; - m_logicalOriginY = 0; -*/ // Output scaling long translate_x, translate_y; double scale_x, scale_y; @@ -1612,16 +1633,17 @@ void wxPostScriptDC::StartPage() if (m_printData.GetOrientation() == wxLANDSCAPE) { -// translate_y -= m_maxY; -// fprintf( m_pstream, "90 rotate\n" ); - - printf( "Hi.\n" ); + int h; + GetSize( (int*) NULL, &h ); + translate_y -= h; + fprintf( m_pstream, "90 rotate\n" ); - fprintf( m_pstream, "90 rotate llx neg ury nef translate\n" ); + // I copied this one from a PostScript tutorial, but to no avail. RR. +// fprintf( m_pstream, "90 rotate llx neg ury nef translate\n" ); } -// fprintf( m_pstream, "%.8f %.8f scale\n", scale_x, scale_y ); -// fprintf( m_pstream, "%ld %ld translate\n", translate_x, translate_y ); + fprintf( m_pstream, "%.8f %.8f scale\n", scale_x, scale_y ); + fprintf( m_pstream, "%ld %ld translate\n", translate_x, translate_y ); } void wxPostScriptDC::EndPage () @@ -1997,7 +2019,7 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, # define PS_VIEWER_PROG "ghostview" #else // Windows ghostscript/ghostview -# define PS_VIEWER_PROG NULL +# define PS_VIEWER_PROG "gsview" #endif wxPrintSetupData *wxThePrintSetupData = (wxPrintSetupData *) NULL; @@ -2369,4 +2391,4 @@ void wxPostScriptModule::OnExit() // wxUSE_POSTSCRIPT #endif - // wxUSE_PRINTING_ARCHITECTURE \ No newline at end of file + // wxUSE_PRINTING_ARCHITECTURE