X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/26cf69fe72d21e7bae5ac72cbe771221eaac4792..02e8b2f9fbdfcd25080c42082d637da257c20094:/src/common/postscrp.cpp diff --git a/src/common/postscrp.cpp b/src/common/postscrp.cpp index bee66a51cf..99d1baa095 100644 --- a/src/common/postscrp.cpp +++ b/src/common/postscrp.cpp @@ -71,6 +71,11 @@ #endif +#ifdef __WXMOTIF__ +#include +#include +#endif + #ifdef __WXMSW__ #ifdef DrawText @@ -113,7 +118,7 @@ # define PS_VIEWER_PROG NULL #endif -wxPrintSetupData *wxThePrintSetupData = NULL; +wxPrintSetupData *wxThePrintSetupData = (wxPrintSetupData *) NULL; // these should move into wxPostscriptDC: double UnderlinePosition = 0.0F; @@ -141,7 +146,7 @@ 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 */ @@ -173,7 +178,7 @@ wxPostScriptDC::wxPostScriptDC (void) m_maxY = -1000; m_title = ""; - m_pstream = NULL; + m_pstream = (ofstream *) NULL; #ifdef __WXMSW__ // Can only send to file in Windows @@ -203,7 +208,7 @@ 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 __WXMSW__ // Can only send to file in Windows @@ -234,7 +239,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 +269,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; @@ -795,7 +800,7 @@ void wxPostScriptDC::SetPen (const wxPen& pen) static const char *long_dashed = "[4 8] 2"; static const char *dotted_dashed = "[6 6 2 6] 4"; - const char *psdash = NULL; + const char *psdash = (char *) NULL; switch (m_pen.GetStyle ()) { case wxDOT: @@ -1134,7 +1139,7 @@ void wxPostScriptDC::EndDoc (void) if (m_pstream) { delete m_pstream; - m_pstream = NULL; + m_pstream = (ofstream *) NULL; } // Write header now @@ -1258,7 +1263,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"; @@ -1281,7 +1286,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()); } @@ -1300,7 +1305,7 @@ void wxPostScriptDC::EndDoc (void) argv[argc++] = opts; argv[argc++] = wxThePrintSetupData->GetPrinterFile(); - argv[argc++] = NULL; + argv[argc++] = (char *) NULL; wxExecute (argv, TRUE); wxRemoveFile(wxThePrintSetupData->GetPrinterFile()); } @@ -1447,13 +1452,16 @@ Blit (long xdest, long ydest, long fwidth, long fheight, #else #ifdef __WXMOTIF__ - d = source->display; + // 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 @@ -1645,7 +1653,7 @@ void wxPostScriptDC::GetTextExtent (const wxString& string, long *x, long *y, // 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"; @@ -1985,11 +1993,11 @@ void wxPostScriptDC::GetSize(int* width, int* height) const { 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; @@ -2006,11 +2014,11 @@ void wxPostScriptDC::GetSizeMM(long *width, long *height) const { 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; @@ -2050,18 +2058,22 @@ wxDialog(parent, -1, title, pos, size, style) int yPos = 40; #if defined(__WXGTK__) || defined (__WXMOTIF__) - (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)); + (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) ); - (void) new wxStaticText(this, -1, "Printer Options: ", wxPoint(210, yPos)); - wxTextCtrl *text0 = new wxTextCtrl(this, wxID_PRINTER_OPTIONS, wxThePrintSetupData->GetPrinterOptions(), wxPoint(305, yPos), wxSize(150, -1)); + (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) ); yPos += 40; #endif wxString orientation[2]; - orientation[0] = "Portrait"; - orientation[1] = "Landscape"; + 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); @@ -2074,12 +2086,12 @@ wxDialog(parent, -1, title, pos, size, style) wxGetResource ("wxWindows", "PSView", &wxThePrintSetupData->previewCommand); wxString print_modes[3]; - print_modes[0] = "Send to Printer"; - print_modes[1] = "Print to File"; - print_modes[2] = "Preview Only"; + 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:", + wxRadioBox *radio1 = new wxRadioBox(this, wxID_PRINTER_MODES, _("PostScript:"), wxPoint(150, yPos), wxSize(-1,-1), features, print_modes, features, 0); #ifdef __WXMSW__ @@ -2099,20 +2111,20 @@ wxDialog(parent, -1, title, pos, size, style) yPos += 90; - (void) new wxStaticText(this, -1, "X Scaling", wxPoint(5, yPos)); + (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(220, yPos)); + (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; - (void) new wxStaticText(this, -1, "X Translation", wxPoint(5, yPos)); + (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(220, yPos)); + (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)); @@ -2140,8 +2152,8 @@ 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() == 1 ? PS_LANDSCAPE : PS_PORTRAIT)); @@ -2159,22 +2171,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); } @@ -2200,7 +2212,7 @@ void wxSetPrinterMode(int mode) wxThePrintSetupData->SetPrinterMode(mode); } -void wxSetAFMPath(char *f) +void wxSetAFMPath(const char *f) { wxThePrintSetupData->SetAFMPath(f); } @@ -2257,9 +2269,9 @@ char *wxGetAFMPath(void) wxPrintSetupData::wxPrintSetupData(void) { - 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; @@ -2267,10 +2279,10 @@ 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) @@ -2289,7 +2301,7 @@ wxPrintSetupData::~wxPrintSetupData(void) delete[] printerFile; } -void wxPrintSetupData::SetPrinterCommand(char *cmd) +void wxPrintSetupData::SetPrinterCommand(const char *cmd) { if (cmd == printerCommand) return; @@ -2299,10 +2311,10 @@ 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; @@ -2312,10 +2324,10 @@ void wxPrintSetupData::SetPrintPreviewCommand(char *cmd) 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; @@ -2325,10 +2337,10 @@ 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; @@ -2338,10 +2350,10 @@ void wxPrintSetupData::SetPrinterOptions(char *flags) 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; @@ -2351,7 +2363,7 @@ void wxPrintSetupData::SetPrinterFile(char *f) if (f) printerFile = copystring(f); else - printerFile = NULL; + printerFile = (char *) NULL; } void wxPrintSetupData::SetPrinterOrientation(int orient) @@ -2377,7 +2389,7 @@ void wxPrintSetupData::SetPrinterMode(int mode) printerMode = mode; } -void wxPrintSetupData::SetAFMPath(char *f) +void wxPrintSetupData::SetAFMPath(const char *f) { if (f == afmPath) return; @@ -2387,7 +2399,7 @@ void wxPrintSetupData::SetAFMPath(char *f) if (f) afmPath = copystring(f); else - afmPath = NULL; + afmPath = (char *) NULL; } void wxPrintSetupData::SetColour(bool col) @@ -2482,7 +2494,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 @@ -2498,15 +2510,15 @@ void wxInitializePrintSetupData(bool init) #endif #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; } } @@ -2514,7 +2526,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; @@ -2549,10 +2561,10 @@ void wxPrintPaperDatabase::CreateDatabase(void) // 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); } void wxPrintPaperDatabase::ClearDatabase(void) @@ -2560,7 +2572,7 @@ void wxPrintPaperDatabase::ClearDatabase(void) 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)); } @@ -2571,7 +2583,7 @@ wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const char *name) if (node) return (wxPrintPaperType *)node->Data(); else - return NULL; + return (wxPrintPaperType *) NULL; } #endif