X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3fc5256f8379dbbd7b9e2ee2ea3d6ced75247a36..6c905cb7fdc856317f1e1db9c6d6aaa93c67920c:/src/common/postscrp.cpp?ds=sidebyside diff --git a/src/common/postscrp.cpp b/src/common/postscrp.cpp index 7d923a520e..2987647f36 100644 --- a/src/common/postscrp.cpp +++ b/src/common/postscrp.cpp @@ -24,12 +24,11 @@ #include "wx/defs.h" -#if USE_POSTSCRIPT +#if wxUSE_POSTSCRIPT #ifndef WX_PRECOMP #include "wx/intl.h" #include "wx/frame.h" -#include "wx/postscrp.h" #include "wx/utils.h" #include "wx/filedlg.h" #include "wx/msgdlg.h" @@ -42,19 +41,24 @@ #include "wx/list.h" #endif +#include "wx/postscrp.h" #include "wx/dcmemory.h" -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #include "wx/msw/private.h" #endif -#if USE_IOSTREAMH +#if wxUSE_IOSTREAMH #include +#include #else #include +#include +# ifdef _MSC_VER + using namespace std; +# endif #endif -#include #include #include #include @@ -62,7 +66,7 @@ #include #include -#ifdef __GTK__ +#ifdef __WXGTK__ #include "gdk/gdkx.h" // GDK_DISPLAY #include "gdk/gdkprivate.h" // XImage @@ -71,7 +75,12 @@ #endif -#ifdef __WINDOWS__ +#ifdef __WXMOTIF__ +#include +#include +#endif + +#ifdef __WXMSW__ #ifdef DrawText #undef DrawText @@ -105,7 +114,7 @@ // SGI's Display Postscript Previewer //# define PS_VIEWER_PROG "dps" # define PS_VIEWER_PROG "xpsview" -#elif defined(__X__) || defined(__GTK__) +#elif defined(__X__) || defined(__WXGTK__) // Front-end to ghostscript # define PS_VIEWER_PROG "ghostview" #else @@ -113,7 +122,16 @@ # define PS_VIEWER_PROG NULL #endif -wxPrintSetupData *wxThePrintSetupData = NULL; +wxPrintSetupData *wxThePrintSetupData = (wxPrintSetupData *) NULL; + +#if !USE_SHARED_LIBRARY +IMPLEMENT_DYNAMIC_CLASS(wxPostScriptModule, wxModule) +IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC) +IMPLEMENT_DYNAMIC_CLASS(wxPrintSetupData, wxObject) +IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject) +#endif + +#ifndef __WXGTK__ // these should move into wxPostscriptDC: double UnderlinePosition = 0.0F; @@ -122,7 +140,7 @@ double UnderlineThickness = 0.0F; #define _MAXPATHLEN 500 /* See "wxspline.inc" and "xfspline.inc" */ -#if USE_XFIG_SPLINE_CODE +#if wxUSE_XFIG_SPLINE_CODE static const char *wxPostScriptHeaderSpline = " \ /DrawSplineSection {\n\ /y3 exch def\n\ @@ -141,9 +159,9 @@ static const char *wxPostScriptHeaderSpline = " \ "; #else // No extra PS header for this spline implementation. -static const char *wxPostScriptHeaderSpline = NULL; +static const char *wxPostScriptHeaderSpline = (char *) NULL; -#endif /* USE_XFIG_SPLINE_CODE */ +#endif /* wxUSE_XFIG_SPLINE_CODE */ // steve, 05.09.94 // VMS has a bug in the ofstream class. @@ -155,14 +173,7 @@ static const char *wxPostScriptHeaderSpline = NULL; static char *fileBuffer = NULL; #endif -#if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC) -IMPLEMENT_DYNAMIC_CLASS(wxPrintSetupData, wxObject) -IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject) -IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList) -#endif - -wxPostScriptDC::wxPostScriptDC (void) +wxPostScriptDC::wxPostScriptDC () { // m_yOrigin = 792; // For EPS output m_yOrigin = 842; // For A4 output @@ -173,9 +184,9 @@ wxPostScriptDC::wxPostScriptDC (void) m_maxY = -1000; m_title = ""; - m_pstream = NULL; + m_pstream = (ofstream *) NULL; -#ifdef __WINDOWS__ +#ifdef __WXMSW__ // Can only send to file in Windows wxThePrintSetupData->SetPrinterMode(PS_FILE); #endif @@ -203,9 +214,9 @@ bool wxPostScriptDC::Create(const wxString& file, bool interactive, wxWindow *pa m_maxY = -1000; m_title = ""; m_filename = file; - m_pstream = NULL; + m_pstream = (ofstream *) NULL; -#ifdef __WINDOWS__ +#ifdef __WXMSW__ // Can only send to file in Windows wxThePrintSetupData->SetPrinterMode(PS_FILE); #endif @@ -226,7 +237,7 @@ bool wxPostScriptDC::Create(const wxString& file, bool interactive, wxWindow *pa return m_ok; } -wxPostScriptDC::~wxPostScriptDC (void) +wxPostScriptDC::~wxPostScriptDC () { if (m_pstream) delete m_pstream; @@ -234,7 +245,7 @@ wxPostScriptDC::~wxPostScriptDC (void) bool wxPostScriptDC::PrinterDialog(wxWindow *parent) { - wxPostScriptPrintDialog dialog (parent, "Printer Settings", wxPoint(150, 150), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL); + wxPostScriptPrintDialog dialog (parent, _("Printer Settings"), wxPoint(150, 150), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL); m_ok = (dialog.ShowModal () == wxID_OK) ; if (!m_ok) @@ -264,7 +275,7 @@ bool wxPostScriptDC::PrinterDialog(wxWindow *parent) } else if ((m_filename == "") && (wxThePrintSetupData->GetPrinterMode() == PS_FILE)) { - char *file = wxSaveFileSelector ("PostScript", "ps"); + char *file = wxSaveFileSelector (_("PostScript"), "ps"); if (!file) { m_ok = FALSE; @@ -289,13 +300,17 @@ void wxPostScriptDC::SetClippingRegion (long cx, long cy, long cw, long ch) *m_pstream << "gsave\n"; *m_pstream << "newpath\n"; *m_pstream << cx << " " << YSCALE (cy) << " moveto\n"; - *m_pstream << cx + cw << " " << YSCALE (cy) << " lineto\n"; + *m_pstream << (cx + cw) << " " << YSCALE (cy) << " lineto\n"; *m_pstream << cx + cw << " " << YSCALE (cy + ch) << " lineto\n"; *m_pstream << cx << " " << YSCALE (cy + ch) << " lineto\n"; *m_pstream << "closepath clip newpath\n"; } -void wxPostScriptDC::DestroyClippingRegion (void) +void wxPostScriptDC::SetClippingRegion( const wxRegion &WXUNUSED(region) ) +{ +} + +void wxPostScriptDC::DestroyClippingRegion () { if (!m_pstream) return; @@ -306,11 +321,11 @@ void wxPostScriptDC::DestroyClippingRegion (void) } } -void wxPostScriptDC::Clear (void) +void wxPostScriptDC::Clear () { } -void wxPostScriptDC::FloodFill (long WXUNUSED(x), long WXUNUSED(y), wxColour * WXUNUSED(col), int WXUNUSED(style)) +void wxPostScriptDC::FloodFill (long WXUNUSED(x), long WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) { } @@ -346,7 +361,7 @@ void wxPostScriptDC::DrawArc (long x1, long y1, long x2, long y2, long xc, long long dx = x1 - xc; long dy = y1 - yc; - long radius = (long) sqrt(dx*dx+dy*dy); + long radius = (long) sqrt((double) (dx*dx+dy*dy)); double alpha1, alpha2; if (x1 == x2 && y1 == y2) { @@ -408,10 +423,10 @@ void wxPostScriptDC::DrawEllipticArc(long x,long y,long w,long h,double sa,doubl { SetBrush (m_brush); - *m_pstream << + *m_pstream << "newpath\n" << - x+w/2 << " " << YSCALE (y+h/2) << " " << - w/2 << " " << h/2 << " " << + (x+w/2) << " " << YSCALE (y+h/2) << " " << + w/2 << " " << (h/2) << " " << int(sa) <<" "<< int(ea)<<" true ellipticarc\n"; CalcBoundingBox (x , (long)YSCALE (y )); @@ -421,10 +436,10 @@ void wxPostScriptDC::DrawEllipticArc(long x,long y,long w,long h,double sa,doubl { SetPen (m_pen); - *m_pstream << + *m_pstream << "newpath\n" << - x+w/2 << " " << YSCALE (y+h/2) << " " << - w/2 << " " << h/2 << " " << + (x+w/2) << " " << YSCALE (y+h/2) << " " << + (w/2) << " " << (h/2) << " " << int(sa) <<" "<< int(ea)<<" false ellipticarc\n"; CalcBoundingBox (x , (long)YSCALE (y )); @@ -540,8 +555,8 @@ void wxPostScriptDC::DrawRectangle (long x, long y, long width, long height) *m_pstream << "newpath\n"; *m_pstream << x << " " << YSCALE (y) << " moveto\n"; - *m_pstream << x + width << " " << YSCALE (y) << " lineto\n"; - *m_pstream << x + width << " " << YSCALE (y + height) << " lineto\n"; + *m_pstream << (x + width) << " " << YSCALE (y) << " lineto\n"; + *m_pstream << (x + width) << " " << YSCALE (y + height) << " lineto\n"; *m_pstream << x << " " << YSCALE (y + height) << " lineto\n"; *m_pstream << "closepath\n"; *m_pstream << "fill\n"; @@ -555,8 +570,8 @@ void wxPostScriptDC::DrawRectangle (long x, long y, long width, long height) *m_pstream << "newpath\n"; *m_pstream << x << " " << YSCALE (y) << " moveto\n"; - *m_pstream << x + width << " " << YSCALE (y) << " lineto\n"; - *m_pstream << x + width << " " << YSCALE (y + height) << " lineto\n"; + *m_pstream << (x + width) << " " << YSCALE (y) << " lineto\n"; + *m_pstream << (x + width) << " " << YSCALE (y + height) << " lineto\n"; *m_pstream << x << " " << YSCALE (y + height) << " lineto\n"; *m_pstream << "closepath\n"; *m_pstream << "stroke\n"; @@ -588,19 +603,19 @@ void wxPostScriptDC::DrawRoundedRectangle (long x, long y, long width, long heig SetBrush (m_brush); // Draw rectangle anticlockwise *m_pstream << "newpath\n"; - *m_pstream << x + radius << " " << YSCALE (y + radius) << " " << radius << " 90 180 arc\n"; + *m_pstream << (x + radius) << " " << YSCALE (y + radius) << " " << radius << " 90 180 arc\n"; *m_pstream << x << " " << YSCALE (y + radius) << " moveto\n"; - *m_pstream << x + radius << " " << YSCALE (y + height - radius) << " " << radius << " 180 270 arc\n"; - *m_pstream << x + width - radius << " " << YSCALE (y + height) << " lineto\n"; + *m_pstream << (x + radius) << " " << YSCALE (y + height - radius) << " " << radius << " 180 270 arc\n"; + *m_pstream << (x + width - radius) << " " << YSCALE (y + height) << " lineto\n"; - *m_pstream << x + width - radius << " " << YSCALE (y + height - radius) << " " << radius << " 270 0 arc\n"; - *m_pstream << x + width << " " << YSCALE (y + radius) << " lineto\n"; + *m_pstream << (x + width - radius) << " " << YSCALE (y + height - radius) << " " << radius << " 270 0 arc\n"; + *m_pstream << (x + width) << " " << YSCALE (y + radius) << " lineto\n"; - *m_pstream << x + width - radius << " " << YSCALE (y + radius) << " " << radius << " 0 90 arc\n"; + *m_pstream << (x + width - radius) << " " << YSCALE (y + radius) << " " << radius << " 0 90 arc\n"; - *m_pstream << x + radius << " " << YSCALE (y) << " lineto\n"; + *m_pstream << (x + radius) << " " << YSCALE (y) << " lineto\n"; *m_pstream << "closepath\n"; @@ -614,19 +629,19 @@ void wxPostScriptDC::DrawRoundedRectangle (long x, long y, long width, long heig SetPen (m_pen); // Draw rectangle anticlockwise *m_pstream << "newpath\n"; - *m_pstream << x + radius << " " << YSCALE (y + radius) << " " << radius << " 90 180 arc\n"; + *m_pstream << (x + radius) << " " << YSCALE (y + radius) << " " << radius << " 90 180 arc\n"; *m_pstream << x << " " << YSCALE (y + height - radius) << " lineto\n"; - *m_pstream << x + radius << " " << YSCALE (y + height - radius) << " " << radius << " 180 270 arc\n"; - *m_pstream << x + width - radius << " " << YSCALE (y + height) << " lineto\n"; + *m_pstream << (x + radius) << " " << YSCALE (y + height - radius) << " " << radius << " 180 270 arc\n"; + *m_pstream << (x + width - radius) << " " << YSCALE (y + height) << " lineto\n"; - *m_pstream << x + width - radius << " " << YSCALE (y + height - radius) << " " << radius << " 270 0 arc\n"; - *m_pstream << x + width << " " << YSCALE (y + radius) << " lineto\n"; + *m_pstream << (x + width - radius) << " " << YSCALE (y + height - radius) << " " << radius << " 270 0 arc\n"; + *m_pstream << (x + width) << " " << YSCALE (y + radius) << " lineto\n"; - *m_pstream << x + width - radius << " " << YSCALE (y + radius) << " " << radius << " 0 90 arc\n"; + *m_pstream << (x + width - radius) << " " << YSCALE (y + radius) << " " << radius << " 0 90 arc\n"; - *m_pstream << x + radius << " " << YSCALE (y) << " lineto\n"; + *m_pstream << (x + radius) << " " << YSCALE (y) << " lineto\n"; *m_pstream << "closepath\n"; @@ -646,8 +661,8 @@ void wxPostScriptDC::DrawEllipse (long x, long y, long width, long height) SetBrush (m_brush); *m_pstream << "newpath\n"; - *m_pstream << x + width / 2 << " " << YSCALE (y + height / 2) << " "; - *m_pstream << width / 2 << " " << height / 2 << " 0 360 ellipse\n"; + *m_pstream << (x + width / 2) << " " << YSCALE (y + height / 2) << " "; + *m_pstream << (width / 2) << " " << (height / 2) << " 0 360 ellipse\n"; *m_pstream << "fill\n"; CalcBoundingBox (x - width, (long)YSCALE (y - height)); @@ -658,8 +673,8 @@ void wxPostScriptDC::DrawEllipse (long x, long y, long width, long height) SetPen (m_pen); *m_pstream << "newpath\n"; - *m_pstream << x + width / 2 << " " << YSCALE (y + height / 2) << " "; - *m_pstream << width / 2 << " " << height / 2 << " 0 360 ellipse\n"; + *m_pstream << (x + width / 2) << " " << YSCALE (y + height / 2) << " "; + *m_pstream << (width / 2) << " " << (height / 2) << " 0 360 ellipse\n"; *m_pstream << "stroke\n"; CalcBoundingBox (x - width, (long)YSCALE (y - height)); @@ -669,13 +684,17 @@ void wxPostScriptDC::DrawEllipse (long x, long y, long width, long height) void wxPostScriptDC::DrawIcon (const wxIcon& icon, long x, long y) { -#if defined(__X__) || defined(__GTK__) +#if defined(__X__) || defined(__WXGTK__) wxMemoryDC memDC; memDC.SelectObject(icon); Blit(x, y, icon.GetWidth(), icon.GetHeight(), &memDC, 0, 0); #endif } +void wxPostScriptDC::DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask ) +{ +} + void wxPostScriptDC::SetFont (const wxFont& the_font) { if (!m_pstream) @@ -690,8 +709,8 @@ void wxPostScriptDC::SetFont (const wxFont& the_font) return; char buf[100]; - char *name; - char *style = ""; + const char *name; + const char *style = ""; int Style = m_font.GetStyle (); int Weight = m_font.GetWeight (); @@ -762,7 +781,7 @@ void wxPostScriptDC::SetFont (const wxFont& the_font) strcpy (buf, name); strcat (buf, style); *m_pstream << buf << " findfont\n"; - *m_pstream << m_font.GetPointSize() * m_scaleFactor << " scalefont setfont\n"; + *m_pstream << (m_font.GetPointSize() * m_scaleFactor) << " scalefont setfont\n"; } void wxPostScriptDC::SetPen (const wxPen& pen) @@ -790,12 +809,12 @@ void wxPostScriptDC::SetPen (const wxPen& pen) will be first black line *2* units long, then space 4 units, then the pattern of *3* units black, 4 units space will be repeated. */ - static char *dotted = "[2 5] 2"; - static char *short_dashed = "[4 4] 2"; - static char *long_dashed = "[4 8] 2"; - static char *dotted_dashed = "[6 6 2 6] 4"; + static const char *dotted = "[2 5] 2"; + static const char *short_dashed = "[4 4] 2"; + static const char *long_dashed = "[4 8] 2"; + static const char *dotted_dashed = "[6 6 2 6] 4"; - char *psdash = NULL; + const char *psdash = (char *) NULL; switch (m_pen.GetStyle ()) { case wxDOT: @@ -971,10 +990,10 @@ void wxPostScriptDC::DrawText (const wxString& text, long x, long y, bool WXUNUS *m_pstream << "gsave " << x << " " << YSCALE (y + size - UnderlinePosition) << " moveto\n" << UnderlineThickness << " setlinewidth " - << x + w << " " << YSCALE (y + size - UnderlinePosition) + << (x + w) << " " << YSCALE (y + size - UnderlinePosition) << " lineto stroke grestore\n"; } - + CalcBoundingBox (x, (long)YSCALE (y + size)); CalcBoundingBox (x + size * strlen ((char *)(const char *)text), (long)YSCALE (y)); } @@ -1051,7 +1070,7 @@ bool wxPostScriptDC::StartDoc (const wxString& message) // VMS is sh*t! m_pstream = new ofstream; if(fileBuffer) delete[] fileBuffer; - fileBuffer = new char[VMS_BUFSIZ]; + fileBuffer = new char[VMS_BUFSIZ]; m_pstream->setbuf(fileBuffer,VMS_BUFSIZ); m_pstream->open(wxThePrintSetupData->GetPrinterFile()); #else @@ -1074,7 +1093,7 @@ bool wxPostScriptDC::StartDoc (const wxString& message) } -void wxPostScriptDC::EndDoc (void) +void wxPostScriptDC::EndDoc () { static char wxPostScriptHeaderReencodeISO1[] = "\n/reencodeISO {\n" @@ -1134,7 +1153,7 @@ void wxPostScriptDC::EndDoc (void) if (m_pstream) { delete m_pstream; - m_pstream = NULL; + m_pstream = (ofstream *) NULL; } // Write header now @@ -1209,9 +1228,9 @@ void wxPostScriptDC::EndDoc (void) // The Adobe specifications call for integers; we round as to make // the bounding larger. *m_pstream << "%%BoundingBox: " - << floor(llx) << " " << floor(lly) << " " - << ceil(urx) << " " << ceil(ury) << "\n"; - *m_pstream << "%%Pages: " << wxPageNumber - 1 << "\n"; + << floor((double)llx) << " " << floor((double)lly) << " " + << ceil((double)urx) << " " << ceil((double)ury) << "\n"; + *m_pstream << "%%Pages: " << (wxPageNumber - 1) << "\n"; *m_pstream << "%%EndComments\n\n"; // To check the correctness of the bounding box, postscript commands @@ -1232,7 +1251,7 @@ void wxPostScriptDC::EndDoc (void) if (wxThePrintSetupData->GetPrinterOrientation() == PS_LANDSCAPE) { real_translate_y -= m_maxY; - // The following line can be used instead of the adjustment to + // The following line can be used instead of the adjustment to // llx and urx above. // real_translate_y -= m_minX; *m_pstream << "90 rotate\n"; @@ -1242,7 +1261,7 @@ void wxPostScriptDC::EndDoc (void) * We should rationalise the scaling code to one place. JACS, October 1995 * Do we take the next 2 lines out or not? */ - + *m_pstream << wx_printer_scale_x << " " << wx_printer_scale_y << " scale\n"; *m_pstream << wx_printer_translate_x << " " << real_translate_y << " translate\n"; #endif @@ -1258,7 +1277,7 @@ void wxPostScriptDC::EndDoc (void) *m_pstream << "%%EndProlog\n"; delete m_pstream; - m_pstream = NULL; + m_pstream = (ofstream *) NULL; #ifdef __VMS__ char *tmp_file = "tmp.ps"; @@ -1272,7 +1291,7 @@ void wxPostScriptDC::EndDoc (void) wxRemoveFile (wxThePrintSetupData->GetPrinterFile()); wxRenameFile(tmp_file, wxThePrintSetupData->GetPrinterFile()); -#if defined(__X__) || defined(__GTK__) +#if defined(__X__) || defined(__WXGTK__) if (m_ok) { switch (wxThePrintSetupData->GetPrinterMode()) { @@ -1281,7 +1300,7 @@ void wxPostScriptDC::EndDoc (void) char *argv[3]; argv[0] = wxThePrintSetupData->GetPrintPreviewCommand(); argv[1] = wxThePrintSetupData->GetPrinterFile(); - argv[2] = NULL; + argv[2] = (char *) NULL; wxExecute (argv, TRUE); wxRemoveFile(wxThePrintSetupData->GetPrinterFile()); } @@ -1298,9 +1317,9 @@ void wxPostScriptDC::EndDoc (void) char * opts = wxThePrintSetupData->GetPrinterOptions(); if (opts && *opts) argv[argc++] = opts; - + argv[argc++] = wxThePrintSetupData->GetPrinterFile(); - argv[argc++] = NULL; + argv[argc++] = (char *) NULL; wxExecute (argv, TRUE); wxRemoveFile(wxThePrintSetupData->GetPrinterFile()); } @@ -1313,11 +1332,11 @@ void wxPostScriptDC::EndDoc (void) #endif } -void wxPostScriptDC::StartPage (void) +void wxPostScriptDC::StartPage () { if (!m_pstream) return; - *m_pstream << "%%Page: " << wxPageNumber++ << "\n"; + *m_pstream << "%%Page: " << (wxPageNumber++) << "\n"; // *m_pstream << "matrix currentmatrix\n"; // Added by Chris Breeze @@ -1345,7 +1364,7 @@ void wxPostScriptDC::StartPage (void) *m_pstream << translate_x << " " << translate_y << " translate\n"; } -void wxPostScriptDC::EndPage (void) +void wxPostScriptDC::EndPage () { if (!m_pstream) return; @@ -1398,24 +1417,22 @@ void wxPostScriptDC::EndPage (void) #endif } -/* MATTHEW: Implement Blit: */ -/* MATTHEW: [4] Re-wrote to use colormap */ bool wxPostScriptDC:: Blit (long xdest, long ydest, long fwidth, long fheight, wxDC *source, long xsrc, long ysrc, int WXUNUSED(rop), bool WXUNUSED(useMask)) { long width, height, x, y; -#if !defined(__X__) && !defined(__GTK__) +#if !defined(__X__) && !defined(__WXGTK__) return FALSE; #endif if (!source->IsKindOf(CLASSINFO(wxPaintDC))) return FALSE; - width = (long)floor(fwidth); - height = (long)floor(fheight); - x = (long)floor(xsrc); - y = (long)floor(ysrc); + width = (long)floor((double)fwidth); + height = (long)floor((double)fheight); + x = (long)floor((double)xsrc); + y = (long)floor((double)ysrc); /* PostScript setup: */ *m_pstream << "gsave\n"; @@ -1428,7 +1445,7 @@ Blit (long xdest, long ydest, long fwidth, long fheight, *m_pstream << " currentfile DataString readhexstring pop\n"; *m_pstream << "} bind image\n"; -#if defined(__X__) || defined(__GTK__) +#if defined(__X__) || defined(__WXGTK__) /* Output data as hex digits: */ Display *d; @@ -1436,25 +1453,28 @@ Blit (long xdest, long ydest, long fwidth, long fheight, XImage *image; long j, i; char s[3]; - -#ifdef __GTK__ + +#ifdef __WXGTK__ d = gdk_display; cm = ((GdkColormapPrivate*)gdk_colormap_get_system())->xcolormap; GdkWindow *gwin = ((wxClientDC*)source)->GetWindow(); image = XGetImage(d, ((GdkWindowPrivate*)gwin)->xwindow, x, y, width, height, AllPlanes, ZPixmap); -#else +#else -#ifdef __MOTIF__ - d = source->display; +#ifdef __WXMOTIF__ + // TODO. for now, use global display + // d = source->display; + d = (Display*) wxGetDisplay(); #else - d = wxGetDisplay(); + d = (Display*) wxGetDisplay(); #endif - cm = wxGetMainColormap(d); - image = XGetImage(d, source->pixmap, x, y, width, height, AllPlanes, ZPixmap); - + cm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) d); + // TODO - implement GetPixmap() and uncomment this line + // image = XGetImage(d, source->GetPixmap(), x, y, width, height, AllPlanes, ZPixmap); + #endif @@ -1484,10 +1504,10 @@ Blit (long xdest, long ydest, long fwidth, long fheight, pixel = cachedest[k]; goto install; } - + cachesrc[cache_pos] = xcol.pixel = spixel; XQueryColor(d, cm, &xcol); - + long r, g, b; r = (long)((double)(xcol.red) / MAX_COLOR); @@ -1497,13 +1517,13 @@ Blit (long xdest, long ydest, long fwidth, long fheight, pixel = (int)(255 * sqrt(((r * r) + (g * g) + (b * b)) / 3)); cachedest[cache_pos] = pixel; - + if (++cache_pos >= CM_CACHE_SIZE) { cache_pos = 0; all_cache = TRUE; } - install: + install: int h, l; h = (pixel >> 4) & 0xF; @@ -1517,7 +1537,7 @@ Blit (long xdest, long ydest, long fwidth, long fheight, s[1] = '0' + l; else s[1] = 'a' + (l - 10); - + *m_pstream << s; } *m_pstream << "\n"; @@ -1534,7 +1554,7 @@ Blit (long xdest, long ydest, long fwidth, long fheight, return TRUE; } -long wxPostScriptDC::GetCharHeight (void) +long wxPostScriptDC::GetCharHeight () { if (m_font.Ok()) return m_font.GetPointSize (); @@ -1570,7 +1590,7 @@ void wxPostScriptDC::GetTextExtent (const wxString& string, long *x, long *y, *externalLeading = 0; #else // +++++ start of contributed code +++++ - + // ************************************************************ // method for calculating string widths in postscript: // read in the AFM (adobe font metrics) file for the @@ -1640,12 +1660,12 @@ void wxPostScriptDC::GetTextExtent (const wxString& string, long *x, long *y, // 1. construct filename ****************************************** /* MATTHEW: [2] Use wxTheFontNameDirectory */ - char *name; + const char *name; // Julian - we'll need to do this a different way now we've removed the // font directory system. Must find Stefan's original code. - name = wxTheFontNameDirectory.GetAFMName(Family, Weight, Style); + name = wxTheFontNameDirectory->GetAFMName(Family, Weight, Style); if (!name) name = "unknown"; @@ -1663,16 +1683,16 @@ void wxPostScriptDC::GetTextExtent (const wxString& string, long *x, long *y, // // C 63 ; WX 444 ; N question ; B 49 -14 395 676 ; // - // that means, we have a character with ascii code 63, and width + // that means, we have a character with ascii code 63, and width // (444/1000 * fontSize) points. // the other data is ignored for now! // // when the font has changed, we read in the right AFM file and store the // character widths in an array, which is processed below (see point 3.). - + // new elements JC Sun Aug 25 23:21:44 MET DST 1996 - + strcat(afmName,name); strcat(afmName,".afm"); FILE *afmFile = fopen(afmName,"r"); @@ -1711,8 +1731,7 @@ void wxPostScriptDC::GetTextExtent (const wxString& string, long *x, long *y, } // JC 2.) check for UnderlineThickness else if(strncmp(line,"UnderlineThickness",18)==0){ - if((sscanf(line,"%s% -f",utString,&UnderlineThickness)!=2) + if((sscanf(line,"%s%lf",utString,&UnderlineThickness)!=2) || (strcmp(utString,"UnderlineThickness")!=0)) { wxDebugMsg("AFM-file '%s': line '%s' has error (bad UnderlineThickness)\n", afmName,line); @@ -1790,7 +1809,7 @@ f",utString,&UnderlineThickness)!=2) if(lastDescender!=INT_MIN){ height += (long)(((-lastDescender)/1000.0F) * Size); /* MATTHEW: forgot scale */ } - + // return size values *x = widthSum; *y = height; @@ -1813,7 +1832,7 @@ f",utString,&UnderlineThickness)!=2) #endif } -void wxPostScriptDC::DrawOpenSpline( wxList *points ) +void wxPostScriptDC::DrawSpline( wxList *points ) { double a, b, c, d, x1, y1, x2, y2, x3, y3; wxPoint *p, *q; @@ -1829,7 +1848,7 @@ void wxPostScriptDC::DrawOpenSpline( wxList *points ) x3 = a = (double)(x1 + c) / 2; y3 = b = (double)(y1 + d) / 2; - *(GetStream()) << "newpath " << x1 << " " << GetYOrigin() - y1 << " moveto " << x3 << " " << GetYOrigin() - y3; + *(GetStream()) << "newpath " << x1 << " " << (GetYOrigin() - y1) << " moveto " << x3 << " " << (GetYOrigin() - y3); *(GetStream()) << " lineto\n"; CalcBoundingBox( (long)x1, (long)(GetYOrigin() - y1)); CalcBoundingBox( (long)x3, (long)(GetYOrigin() - y3)); @@ -1843,20 +1862,20 @@ void wxPostScriptDC::DrawOpenSpline( wxList *points ) c = q->x; d = q->y; x3 = (double)(x2 + c) / 2; y3 = (double)(y2 + d) / 2; - *(GetStream()) << x1 << " " << GetYOrigin() - y1 << " " << x2 << " " << GetYOrigin() - y2 << " "; - *(GetStream()) << x3 << " " << GetYOrigin() - y3 << " DrawSplineSection\n"; + *(GetStream()) << x1 << " " << (GetYOrigin() - y1) << " " << x2 << " " << (GetYOrigin() - y2) << " "; + *(GetStream()) << x3 << " " << (GetYOrigin() - y3) << " DrawSplineSection\n"; CalcBoundingBox( (long)x1, (long)(GetYOrigin() - y1)); CalcBoundingBox( (long)x3, (long)(GetYOrigin() - y3)); } /* - * At this point, (x2,y2) and (c,d) are the position of the + * At this point, (x2,y2) and (c,d) are the position of the * next-to-last and last point respectively, in the point list */ - *(GetStream()) << c << " " << GetYOrigin() - d << " lineto stroke\n"; + *(GetStream()) << c << " " << (GetYOrigin() - d) << " lineto stroke\n"; } -long wxPostScriptDC::GetCharWidth (void) +long wxPostScriptDC::GetCharWidth () { // Chris Breeze: reasonable approximation using wxMODERN/Courier return (long) (GetCharHeight() * 72.0 / 120.0); @@ -1984,13 +2003,13 @@ long wxPostScriptDC::LogicalToDeviceYRel (long y) const void wxPostScriptDC::GetSize(int* width, int* height) const { - char *paperType = wxThePrintSetupData->GetPaperName(); + const char *paperType = wxThePrintSetupData->GetPaperName(); if (!paperType) - paperType = "A4 210 x 297 mm"; + paperType = _("A4 210 x 297 mm"); wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(paperType); if (!paper) - paper = wxThePrintPaperDatabase->FindPaperType("A4 210 x 297 mm"); + paper = wxThePrintPaperDatabase->FindPaperType(_("A4 210 x 297 mm")); if (paper) { *width = paper->widthPixels; @@ -2005,13 +2024,13 @@ void wxPostScriptDC::GetSize(int* width, int* height) const void wxPostScriptDC::GetSizeMM(long *width, long *height) const { - char *paperType = wxThePrintSetupData->GetPaperName(); + const char *paperType = wxThePrintSetupData->GetPaperName(); if (!paperType) - paperType = "A4 210 x 297 mm"; + paperType = _("A4 210 x 297 mm"); wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(paperType); if (!paper) - paper = wxThePrintPaperDatabase->FindPaperType("A4 210 x 297 mm"); + paper = wxThePrintPaperDatabase->FindPaperType(_("A4 210 x 297 mm")); if (paper) { *width = paper->widthMM; @@ -2035,94 +2054,112 @@ void wxPostScriptDC::CalcBoundingBox(long x, long y) if (device_y > m_maxY) m_maxY = device_y; } +#endif + // __WXGTK__ + IMPLEMENT_CLASS(wxPostScriptPrintDialog, wxDialog) wxPostScriptPrintDialog::wxPostScriptPrintDialog (wxWindow *parent, const wxString& title, - const wxPoint& pos, const wxSize& size, const long style): -wxDialog(parent, -1, title, pos, size, style) + const wxPoint& pos, const wxSize& size, long style): + wxDialog(parent, -1, title, pos, size, style) { - wxBeginBusyCursor(); - char buf[100]; + wxBeginBusyCursor(); - wxButton *okBut = new wxButton (this, wxID_OK, _("OK"), wxPoint(5, 5)); - (void) new wxButton (this, wxID_CANCEL, _("Cancel"), wxPoint(40, 5)); - okBut->SetDefault(); + char buf[100]; + int yPos = 40; + wxString + *orientation = new wxString[2], + *print_modes = new wxString[3]; + int features; + long wx_printer_translate_x, wx_printer_translate_y; + double wx_printer_scale_x, wx_printer_scale_y; - int yPos = 30; + orientation[0] = _("Portrait"); + orientation[1] = _("Landscape"); -#ifdef __X__ - (void) new wxStaticText(this, -1, "Printer Command: ", wxPoint(5, yPos)); - wxTextCtrl *text_prt = new wxTextCtrl(this, wxID_PRINTER_COMMAND, wxThePrintSetupData->GetPrinterCommand(), wxPoint(100, yPos), wxSize(100, -1)); + print_modes[0] = _("Send to Printer"); + print_modes[1] = _("Print to File"); + print_modes[2] = _("Preview Only"); - (void) new wxStaticText(this, -1, "Printer Options: ", wxPoint(210, yPos)); - wxTextCtrl *text0 = new wxTextCtrl(this, wxID_PRINTER_OPTIONS, wxThePrintSetupData->GetPrinterOptions(), wxPoint(305, -1), wxSize(150, -1)); - yPos += 25; -#endif + + wxButton *okBut = new wxButton (this, wxID_OK, _("OK"), wxPoint(5, 5)); + (void) new wxButton (this, wxID_CANCEL, _("Cancel"), wxPoint(40, 5)); + okBut->SetDefault(); - wxString orientation[2]; - orientation[0] = "Portrait"; - orientation[1] = "Landscape"; - wxRadioBox *radio0 = new wxRadioBox(this, wxID_PRINTER_ORIENTATION, "Orientation: ", wxPoint(5, yPos), wxSize(-1,-1), - 2,orientation,2,0); - radio0->SetSelection((int)wxThePrintSetupData->GetPrinterOrientation()); +#if defined(__WXGTK__) || defined (__WXMOTIF__) + (void) new wxStaticText( this, -1, _("Printer Command: "), + wxPoint(5, yPos) ); + (void) new wxTextCtrl( this, wxID_PRINTER_COMMAND, wxThePrintSetupData->GetPrinterCommand(), + wxPoint(100, yPos), wxSize(100, -1) ); - // @@@ Configuration hook - if (wxThePrintSetupData->GetPrintPreviewCommand() == NULL) - wxThePrintSetupData->SetPrintPreviewCommand(PS_VIEWER_PROG); + (void) new wxStaticText( this, -1, _("Printer Options: "), + wxPoint(210, yPos) ); + (void) new wxTextCtrl( this, wxID_PRINTER_OPTIONS, wxThePrintSetupData->GetPrinterOptions(), + wxPoint(305, yPos), wxSize(150, -1) ); - wxGetResource ("wxWindows", "PSView", &wxThePrintSetupData->previewCommand); + yPos += 40; +#endif - wxString print_modes[3]; - print_modes[0] = "Send to Printer"; - print_modes[1] = "Print to File"; - print_modes[2] = "Preview Only"; - int features = (wxThePrintSetupData->GetPrintPreviewCommand() && *wxThePrintSetupData->GetPrintPreviewCommand()) ? 3 : 2; - wxRadioBox *radio1 = new wxRadioBox(this, wxID_PRINTER_MODES, "PostScript:", - wxPoint(150, yPos), wxSize(-1,-1), features, print_modes, features, 0); + wxRadioBox *radio0 = new wxRadioBox(this, wxID_PRINTER_ORIENTATION, "Orientation: ", wxPoint(5, yPos), wxSize(-1,-1), + 2,orientation,2,0); + radio0->SetSelection((int)wxThePrintSetupData->GetPrinterOrientation() - 1); -#ifdef __WINDOWS__ - radio1->Enable(0, FALSE); - if (wxThePrintSetupData->GetPrintPreviewCommand() && *wxThePrintSetupData->GetPrintPreviewCommand()) - radio1->Enable(2, FALSE); -#endif + // @@@ Configuration hook + if (wxThePrintSetupData->GetPrintPreviewCommand() == NULL) + wxThePrintSetupData->SetPrintPreviewCommand(PS_VIEWER_PROG); + + wxGetResource ("wxWindows", "PSView", &wxThePrintSetupData->previewCommand); - radio1->SetSelection((int)wxThePrintSetupData->GetPrinterMode()); + features = (wxThePrintSetupData->GetPrintPreviewCommand() && + *wxThePrintSetupData->GetPrintPreviewCommand()) ? 3 : 2; - long wx_printer_translate_x, wx_printer_translate_y; - double wx_printer_scale_x, wx_printer_scale_y; - wxThePrintSetupData->GetPrinterTranslation(&wx_printer_translate_x, &wx_printer_translate_y); - wxThePrintSetupData->GetPrinterScaling(&wx_printer_scale_x, &wx_printer_scale_y); + wxRadioBox *radio1 = new wxRadioBox(this, wxID_PRINTER_MODES, _("PostScript:"), + wxPoint(150, yPos), + wxSize(-1,-1), features, + print_modes, features, 0); + +#ifdef __WXMSW__ + radio1->Enable(0, FALSE); + if (wxThePrintSetupData->GetPrintPreviewCommand() && *wxThePrintSetupData->GetPrintPreviewCommand()) + radio1->Enable(2, FALSE); +#endif - sprintf (buf, "%.2f", wx_printer_scale_x); + radio1->SetSelection((int)wxThePrintSetupData->GetPrinterMode()); + wxThePrintSetupData->GetPrinterTranslation(&wx_printer_translate_x, &wx_printer_translate_y); + wxThePrintSetupData->GetPrinterScaling(&wx_printer_scale_x, &wx_printer_scale_y); - yPos += 60; + sprintf (buf, "%.2f", wx_printer_scale_x); - (void) new wxStaticText(this, -1, "X Scaling", wxPoint(5, yPos)); - /* wxTextCtrl *text1 = */ (void) new wxTextCtrl(this, wxID_PRINTER_X_SCALE, buf, wxPoint(100, -1), wxSize(100, -1)); + yPos += 90; + (void) new wxStaticText(this, -1, _("X Scaling"), wxPoint(5, yPos)); + /* wxTextCtrl *text1 = */ (void) new wxTextCtrl(this, wxID_PRINTER_X_SCALE, buf, wxPoint(100, yPos), wxSize(100, -1)); - sprintf (buf, "%.2f", wx_printer_scale_y); - (void) new wxStaticText(this, -1, "Y Scaling", wxPoint(120, yPos)); - /* wxTextCtrl *text2 = */ (void) new wxTextCtrl(this, wxID_PRINTER_Y_SCALE, buf, wxPoint(230, -1), wxSize(100, -1)); + sprintf (buf, "%.2f", wx_printer_scale_y); + (void) new wxStaticText(this, -1, _("Y Scaling"), wxPoint(220, yPos)); + /* wxTextCtrl *text2 = */ (void) new wxTextCtrl(this, wxID_PRINTER_Y_SCALE, buf, wxPoint(320, yPos), wxSize(100, -1)); - yPos += 25; + yPos += 25; - (void) new wxStaticText(this, -1, "X Translation", wxPoint(5, yPos)); - sprintf (buf, "%.2ld", wx_printer_translate_x); - /* wxTextCtrl *text3 = */ (void) new wxTextCtrl(this, wxID_PRINTER_X_TRANS, buf, wxPoint(100, -1), wxSize(100, -1)); + (void) new wxStaticText(this, -1, _("X Translation"), wxPoint(5, yPos)); + sprintf (buf, "%.2ld", wx_printer_translate_x); + /* wxTextCtrl *text3 = */ (void) new wxTextCtrl(this, wxID_PRINTER_X_TRANS, buf, wxPoint(100, yPos), wxSize(100, -1)); - (void) new wxStaticText(this, -1, "Y Translation", wxPoint(120, yPos)); - sprintf (buf, "%.2ld", wx_printer_translate_y); - /* wxTextCtrl *text4 = */ (void) new wxTextCtrl(this, wxID_PRINTER_Y_TRANS, buf, wxPoint(230, -1), wxSize(100, -1)); + (void) new wxStaticText(this, -1, _("Y Translation"), wxPoint(220, yPos)); + sprintf (buf, "%.2ld", wx_printer_translate_y); + /* wxTextCtrl *text4 = */ (void) new wxTextCtrl(this, wxID_PRINTER_Y_TRANS, buf, wxPoint(320, yPos), wxSize(100, -1)); + + Fit (); - Fit (); + delete[] orientation; + delete[] print_modes; - wxEndBusyCursor(); + wxEndBusyCursor(); } -int wxPostScriptPrintDialog::ShowModal (void) +int wxPostScriptPrintDialog::ShowModal () { if ( wxDialog::ShowModal() == wxID_OK ) { @@ -2141,17 +2178,17 @@ int wxPostScriptPrintDialog::ShowModal (void) StringToLong (WXSTRINGCAST text4->GetValue (), &wxThePrintSetupData->printerTranslateY); #ifdef __X__ - wxThePrintSetupData->SetPrinterOptions(WXSTRINGCAST text0->GetValue ()); - wxThePrintSetupData->SetPrinterCommand(WXSTRINGCAST text_prt->GetValue ()); + // wxThePrintSetupData->SetPrinterOptions(WXSTRINGCAST text0->GetValue ()); + // wxThePrintSetupData->SetPrinterCommand(WXSTRINGCAST text_prt->GetValue ()); #endif - wxThePrintSetupData->SetPrinterOrientation((radio0->GetSelection() == PS_LANDSCAPE ? PS_LANDSCAPE : PS_PORTRAIT)); + wxThePrintSetupData->SetPrinterOrientation((radio0->GetSelection() == 1 ? PS_LANDSCAPE : PS_PORTRAIT)); // C++ wants this switch ( radio1->GetSelection() ) { - case PS_PREVIEW: wxThePrintSetupData->SetPrinterMode(PS_PREVIEW); break; - case PS_FILE: wxThePrintSetupData->SetPrinterMode(PS_FILE); break; - case PS_PRINTER: wxThePrintSetupData->SetPrinterMode(PS_PRINTER); break; + case 0: wxThePrintSetupData->SetPrinterMode(PS_PRINTER); break; + case 1: wxThePrintSetupData->SetPrinterMode(PS_FILE); break; + case 2: wxThePrintSetupData->SetPrinterMode(PS_PREVIEW); break; } return wxID_OK; } @@ -2160,22 +2197,22 @@ int wxPostScriptPrintDialog::ShowModal (void) // PostScript printer settings // RETAINED FOR BACKWARD COMPATIBILITY -void wxSetPrinterCommand(char *cmd) +void wxSetPrinterCommand(const char *cmd) { wxThePrintSetupData->SetPrinterCommand(cmd); } -void wxSetPrintPreviewCommand(char *cmd) +void wxSetPrintPreviewCommand(const char *cmd) { wxThePrintSetupData->SetPrintPreviewCommand(cmd); } -void wxSetPrinterOptions(char *flags) +void wxSetPrinterOptions(const char *flags) { wxThePrintSetupData->SetPrinterOptions(flags); } -void wxSetPrinterFile(char *f) +void wxSetPrinterFile(const char *f) { wxThePrintSetupData->SetPrinterFile(f); } @@ -2201,33 +2238,33 @@ void wxSetPrinterMode(int mode) wxThePrintSetupData->SetPrinterMode(mode); } -void wxSetAFMPath(char *f) +void wxSetAFMPath(const char *f) { wxThePrintSetupData->SetAFMPath(f); } // Get current values -char *wxGetPrinterCommand(void) +char *wxGetPrinterCommand() { return wxThePrintSetupData->GetPrinterCommand(); } -char *wxGetPrintPreviewCommand(void) +char *wxGetPrintPreviewCommand() { return wxThePrintSetupData->GetPrintPreviewCommand(); } -char *wxGetPrinterOptions(void) +char *wxGetPrinterOptions() { return wxThePrintSetupData->GetPrinterOptions(); } -char *wxGetPrinterFile(void) +char *wxGetPrinterFile() { return wxThePrintSetupData->GetPrinterFile(); } -int wxGetPrinterOrientation(void) +int wxGetPrinterOrientation() { return wxThePrintSetupData->GetPrinterOrientation(); } @@ -2242,12 +2279,12 @@ void wxGetPrinterTranslation(long *x, long *y) wxThePrintSetupData->GetPrinterTranslation(x, y); } -int wxGetPrinterMode(void) +int wxGetPrinterMode() { return wxThePrintSetupData->GetPrinterMode(); } -char *wxGetAFMPath(void) +char *wxGetAFMPath() { return wxThePrintSetupData->GetAFMPath(); } @@ -2256,11 +2293,11 @@ char *wxGetAFMPath(void) * Print setup data */ -wxPrintSetupData::wxPrintSetupData(void) +wxPrintSetupData::wxPrintSetupData() { - printerCommand = NULL; - previewCommand = NULL; - printerFlags = NULL; + printerCommand = (char *) NULL; + previewCommand = (char *) NULL; + printerFlags = (char *) NULL; printerOrient = PS_PORTRAIT; printerScaleX = (double)1.0; printerScaleY = (double)1.0; @@ -2268,13 +2305,13 @@ wxPrintSetupData::wxPrintSetupData(void) printerTranslateY = 0; // 1 = Preview, 2 = print to file, 3 = send to printer printerMode = 3; - afmPath = NULL; - paperName = NULL; + afmPath = (char *) NULL; + paperName = (char *) NULL; printColour = TRUE; - printerFile = NULL; + printerFile = (char *) NULL; } -wxPrintSetupData::~wxPrintSetupData(void) +wxPrintSetupData::~wxPrintSetupData() { if (printerCommand) delete[] printerCommand; @@ -2290,7 +2327,7 @@ wxPrintSetupData::~wxPrintSetupData(void) delete[] printerFile; } -void wxPrintSetupData::SetPrinterCommand(char *cmd) +void wxPrintSetupData::SetPrinterCommand(const char *cmd) { if (cmd == printerCommand) return; @@ -2300,23 +2337,23 @@ void wxPrintSetupData::SetPrinterCommand(char *cmd) if (cmd) printerCommand = copystring(cmd); else - printerCommand = NULL; + printerCommand = (char *) NULL; } -void wxPrintSetupData::SetPrintPreviewCommand(char *cmd) +void wxPrintSetupData::SetPrintPreviewCommand(const char *cmd) { if (cmd == previewCommand) return; - + if (previewCommand) delete[] previewCommand; if (cmd) previewCommand = copystring(cmd); else - previewCommand = NULL; + previewCommand = (char *) NULL; } -void wxPrintSetupData::SetPaperName(char *name) +void wxPrintSetupData::SetPaperName(const char *name) { if (name == paperName) return; @@ -2326,33 +2363,33 @@ void wxPrintSetupData::SetPaperName(char *name) if (name) paperName = copystring(name); else - paperName = NULL; + paperName = (char *) NULL; } -void wxPrintSetupData::SetPrinterOptions(char *flags) +void wxPrintSetupData::SetPrinterOptions(const char *flags) { if (printerFlags == flags) return; - + if (printerFlags) delete[] printerFlags; if (flags) printerFlags = copystring(flags); else - printerFlags = NULL; + printerFlags = (char *) NULL; } -void wxPrintSetupData::SetPrinterFile(char *f) +void wxPrintSetupData::SetPrinterFile(const char *f) { if (f == printerFile) return; - + if (printerFile) delete[] printerFile; if (f) printerFile = copystring(f); else - printerFile = NULL; + printerFile = (char *) NULL; } void wxPrintSetupData::SetPrinterOrientation(int orient) @@ -2378,17 +2415,17 @@ void wxPrintSetupData::SetPrinterMode(int mode) printerMode = mode; } -void wxPrintSetupData::SetAFMPath(char *f) +void wxPrintSetupData::SetAFMPath(const char *f) { if (f == afmPath) return; - + if (afmPath) delete[] afmPath; if (f) afmPath = copystring(f); else - afmPath = NULL; + afmPath = (char *) NULL; } void wxPrintSetupData::SetColour(bool col) @@ -2397,32 +2434,32 @@ void wxPrintSetupData::SetColour(bool col) } // Get current values -char *wxPrintSetupData::GetPrinterCommand(void) +char *wxPrintSetupData::GetPrinterCommand() { return printerCommand; } -char *wxPrintSetupData::GetPrintPreviewCommand(void) +char *wxPrintSetupData::GetPrintPreviewCommand() { return previewCommand; } -char *wxPrintSetupData::GetPrinterOptions(void) +char *wxPrintSetupData::GetPrinterOptions() { return printerFlags; } -char *wxPrintSetupData::GetPrinterFile(void) +char *wxPrintSetupData::GetPrinterFile() { return printerFile; } -char *wxPrintSetupData::GetPaperName(void) +char *wxPrintSetupData::GetPaperName() { return paperName; } -int wxPrintSetupData::GetPrinterOrientation(void) +int wxPrintSetupData::GetPrinterOrientation() { return printerOrient; } @@ -2439,17 +2476,17 @@ void wxPrintSetupData::GetPrinterTranslation(long *x, long *y) *y = printerTranslateY; } -int wxPrintSetupData::GetPrinterMode(void) +int wxPrintSetupData::GetPrinterMode() { return printerMode; } -char *wxPrintSetupData::GetAFMPath(void) +char *wxPrintSetupData::GetAFMPath() { return afmPath; } -bool wxPrintSetupData::GetColour(void) +bool wxPrintSetupData::GetColour() { return printColour; } @@ -2483,7 +2520,7 @@ void wxInitializePrintSetupData(bool init) wxThePrintSetupData->SetPrintPreviewCommand(PS_VIEWER_PROG); wxThePrintSetupData->SetPrinterOrientation(PS_PORTRAIT); wxThePrintSetupData->SetPrinterMode(PS_PREVIEW); - wxThePrintSetupData->SetPaperName("A4 210 x 297 mm"); + wxThePrintSetupData->SetPaperName(_("A4 210 x 297 mm")); // Could have a .ini file to read in some defaults // - and/or use environment variables, e.g. WXWIN @@ -2492,22 +2529,22 @@ void wxInitializePrintSetupData(bool init) wxThePrintSetupData->SetPrinterOptions("/nonotify/queue=psqueue"); wxThePrintSetupData->SetAFMPath("sys$ps_font_metrics:"); #endif -#ifdef __WINDOWS__ +#ifdef __WXMSW__ wxThePrintSetupData->SetPrinterCommand("print"); wxThePrintSetupData->SetAFMPath("c:\\windows\\system\\"); wxThePrintSetupData->SetPrinterOptions(NULL); #endif -#if !defined(__VMS__) && !defined(__WINDOWS__) +#if !defined(__VMS__) && !defined(__WXMSW__) wxThePrintSetupData->SetPrinterCommand("lpr"); - wxThePrintSetupData->SetPrinterOptions(NULL); - wxThePrintSetupData->SetAFMPath(NULL); + wxThePrintSetupData->SetPrinterOptions((char *) NULL); + wxThePrintSetupData->SetAFMPath((char *) NULL); #endif } else { if (wxThePrintSetupData) delete wxThePrintSetupData; - wxThePrintSetupData = NULL; + wxThePrintSetupData = (wxPrintSetupData *) NULL; } } @@ -2515,7 +2552,7 @@ void wxInitializePrintSetupData(bool init) * Paper size database for PostScript */ -wxPrintPaperType::wxPrintPaperType(char *name, int wmm, int hmm, int wp, int hp) +wxPrintPaperType::wxPrintPaperType(const char *name, int wmm, int hmm, int wp, int hp) { widthMM = wmm; heightMM = hmm; @@ -2524,21 +2561,29 @@ wxPrintPaperType::wxPrintPaperType(char *name, int wmm, int hmm, int wp, int hp) pageName = copystring(name); } -wxPrintPaperType::~wxPrintPaperType(void) +wxPrintPaperType::~wxPrintPaperType() { delete[] pageName; } -wxPrintPaperDatabase::wxPrintPaperDatabase(void):wxList(wxKEY_STRING) +/* + * Print paper database for PostScript + */ + +#if !USE_SHARED_LIBRARIES +IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList) +#endif + +wxPrintPaperDatabase::wxPrintPaperDatabase():wxList(wxKEY_STRING) { DeleteContents(TRUE); } -wxPrintPaperDatabase::~wxPrintPaperDatabase(void) +wxPrintPaperDatabase::~wxPrintPaperDatabase() { } -void wxPrintPaperDatabase::CreateDatabase(void) +void wxPrintPaperDatabase::CreateDatabase() { // Need correct values for page size in pixels. // Each unit is one 'point' = 1/72 of an inch. @@ -2549,30 +2594,60 @@ void wxPrintPaperDatabase::CreateDatabase(void) // Can't remember where the PostScript origin is by default. // Heck, someone will know how to make it hunky-dory... // JACS 25/5/95 + + AddPaperType(_("A4 210 x 297 mm"), 210, 297, 595, 842); + AddPaperType(_("A3 297 x 420 mm"), 297, 420, 842, 1191); + AddPaperType(_("Letter 8 1/2 x 11 in"), 216, 279, 612, 791); + AddPaperType(_("Legal 8 1/2 x 14 in"), 216, 356, 612, 1009); - AddPaperType("A4 210 x 297 mm", 210, 297, 595, 842); - AddPaperType("A3 297 x 420 mm", 297, 420, 842, 1191); - AddPaperType("Letter 8 1/2 x 11 in", 216, 279, 612, 791); - AddPaperType("Legal 8 1/2 x 14 in", 216, 356, 612, 1009); +/* + This is for 100 ppi + + AddPaperType(_("A4 210 x 297 mm"), 210, 297, 210*4, 297*4 ); + AddPaperType(_("A3 297 x 420 mm"), 297, 420, 297*4, 420*4 ); + AddPaperType(_("Letter 8 1/2 x 11 in"), 216, 279, 216*4, 279*4 ); + AddPaperType(_("Legal 8 1/2 x 14 in"), 216, 356, 216*4, 356*4 ); +*/ } -void wxPrintPaperDatabase::ClearDatabase(void) +void wxPrintPaperDatabase::ClearDatabase() { Clear(); } -void wxPrintPaperDatabase::AddPaperType(char *name, int wmm, int hmm, int wp, int hp) +void wxPrintPaperDatabase::AddPaperType(const char *name, int wmm, int hmm, int wp, int hp) { Append(name, new wxPrintPaperType(name, wmm, hmm, wp, hp)); } -wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(char *name) +wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const char *name) { wxNode *node = Find(name); if (node) return (wxPrintPaperType *)node->Data(); else - return NULL; + return (wxPrintPaperType *) NULL; } +/* + * Initialization/cleanup module + */ + +bool wxPostScriptModule::OnInit() +{ + wxInitializePrintSetupData(); + wxThePrintPaperDatabase = new wxPrintPaperDatabase; + wxThePrintPaperDatabase->CreateDatabase(); + + return TRUE; +} + +void wxPostScriptModule::OnExit() +{ + wxInitializePrintSetupData(FALSE); + delete wxThePrintPaperDatabase; + wxThePrintPaperDatabase = NULL; +} + + #endif