X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e86d366cab7235fa0ce1c4df3eb3e7ca55350d35..1ee17e1c421b64b3a356fee82f454ab4b43ab50c:/src/common/postscrp.cpp diff --git a/src/common/postscrp.cpp b/src/common/postscrp.cpp index 2660eddec9..0400cc25b3 100644 --- a/src/common/postscrp.cpp +++ b/src/common/postscrp.cpp @@ -29,7 +29,6 @@ #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,6 +41,7 @@ #include "wx/list.h" #endif +#include "wx/postscrp.h" #include "wx/dcmemory.h" #ifdef __WXMSW__ @@ -50,11 +50,15 @@ #if wxUSE_IOSTREAMH #include +#include #else #include +#include +# ifdef _MSC_VER + using namespace std; +# endif #endif -#include #include #include #include @@ -120,6 +124,15 @@ 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 + +#if !defined(__WXGTK__) && !defined(__WXMOTIF__) + // these should move into wxPostscriptDC: double UnderlinePosition = 0.0F; double UnderlineThickness = 0.0F; @@ -160,15 +173,7 @@ static const char *wxPostScriptHeaderSpline = (char *) NULL; static char *fileBuffer = NULL; #endif -#if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxPostScriptModule, wxModule) -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 @@ -232,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; @@ -301,7 +306,11 @@ void wxPostScriptDC::SetClippingRegion (long cx, long cy, long cw, long ch) *m_pstream << "closepath clip newpath\n"; } -void wxPostScriptDC::DestroyClippingRegion (void) +void wxPostScriptDC::SetClippingRegion( const wxRegion &WXUNUSED(region) ) +{ +} + +void wxPostScriptDC::DestroyClippingRegion () { if (!m_pstream) return; @@ -312,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)) { } @@ -682,6 +691,10 @@ void wxPostScriptDC::DrawIcon (const wxIcon& icon, long x, long y) #endif } +void wxPostScriptDC::DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask ) +{ +} + void wxPostScriptDC::SetFont (const wxFont& the_font) { if (!m_pstream) @@ -1080,7 +1093,7 @@ bool wxPostScriptDC::StartDoc (const wxString& message) } -void wxPostScriptDC::EndDoc (void) +void wxPostScriptDC::EndDoc () { static char wxPostScriptHeaderReencodeISO1[] = "\n/reencodeISO {\n" @@ -1319,7 +1332,7 @@ void wxPostScriptDC::EndDoc (void) #endif } -void wxPostScriptDC::StartPage (void) +void wxPostScriptDC::StartPage () { if (!m_pstream) return; @@ -1351,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; @@ -1541,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 (); @@ -1862,7 +1875,7 @@ void wxPostScriptDC::DrawSpline( wxList *points ) *(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); @@ -2041,98 +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, long style): -wxDialog(parent, -1, title, pos, size, style) + wxDialog(parent, -1, title, pos, size, style) { - wxBeginBusyCursor(); - char buf[100]; + wxBeginBusyCursor(); + + 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; + + orientation[0] = _("Portrait"); + orientation[1] = _("Landscape"); + + print_modes[0] = _("Send to Printer"); + print_modes[1] = _("Print to File"); + print_modes[2] = _("Preview Only"); - wxButton *okBut = new wxButton (this, wxID_OK, _("OK"), wxPoint(5, 5)); - (void) new wxButton (this, wxID_CANCEL, _("Cancel"), wxPoint(40, 5)); - okBut->SetDefault(); - int yPos = 40; + + wxButton *okBut = new wxButton (this, wxID_OK, _("OK"), wxPoint(5, 5)); + (void) new wxButton (this, wxID_CANCEL, _("Cancel"), wxPoint(40, 5)); + okBut->SetDefault(); + #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) ); + (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) ); - (void) 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; + yPos += 40; #endif - 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() - 1); + wxRadioBox *radio0 = new wxRadioBox(this, wxID_PRINTER_ORIENTATION, "Orientation: ", wxPoint(5, yPos), wxSize(-1,-1), + 2,orientation,2,wxRA_SPECIFY_ROWS); + radio0->SetSelection((int)wxThePrintSetupData->GetPrinterOrientation() - 1); // @@@ Configuration hook - if (wxThePrintSetupData->GetPrintPreviewCommand() == NULL) - wxThePrintSetupData->SetPrintPreviewCommand(PS_VIEWER_PROG); - - wxGetResource ("wxWindows", "PSView", &wxThePrintSetupData->previewCommand); + if (wxThePrintSetupData->GetPrintPreviewCommand() == NULL) + wxThePrintSetupData->SetPrintPreviewCommand(PS_VIEWER_PROG); - wxString print_modes[3]; - print_modes[0] = _("Send to Printer"); - print_modes[1] = _("Print to File"); - print_modes[2] = _("Preview Only"); + wxGetResource ("wxWindows", "PSView", &wxThePrintSetupData->previewCommand); - 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); + 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, wxRA_SPECIFY_ROWS); #ifdef __WXMSW__ - radio1->Enable(0, FALSE); - if (wxThePrintSetupData->GetPrintPreviewCommand() && *wxThePrintSetupData->GetPrintPreviewCommand()) - radio1->Enable(2, FALSE); + radio1->Enable(0, FALSE); + if (wxThePrintSetupData->GetPrintPreviewCommand() && *wxThePrintSetupData->GetPrintPreviewCommand()) + radio1->Enable(2, FALSE); #endif - radio1->SetSelection((int)wxThePrintSetupData->GetPrinterMode()); + 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); - 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); - - sprintf (buf, "%.2f", wx_printer_scale_x); - - yPos += 90; + 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, yPos), 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(220, yPos)); - /* wxTextCtrl *text2 = */ (void) new wxTextCtrl(this, wxID_PRINTER_Y_SCALE, buf, wxPoint(320, yPos), 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, yPos), 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(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)); + (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 ) { @@ -2217,27 +2244,27 @@ void wxSetAFMPath(const char *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(); } @@ -2252,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(); } @@ -2266,7 +2293,7 @@ char *wxGetAFMPath(void) * Print setup data */ -wxPrintSetupData::wxPrintSetupData(void) +wxPrintSetupData::wxPrintSetupData() { printerCommand = (char *) NULL; previewCommand = (char *) NULL; @@ -2284,7 +2311,7 @@ wxPrintSetupData::wxPrintSetupData(void) printerFile = (char *) NULL; } -wxPrintSetupData::~wxPrintSetupData(void) +wxPrintSetupData::~wxPrintSetupData() { if (printerCommand) delete[] printerCommand; @@ -2407,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; } @@ -2449,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; } @@ -2534,21 +2561,29 @@ wxPrintPaperType::wxPrintPaperType(const char *name, int wmm, int hmm, int wp, i 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. @@ -2564,9 +2599,18 @@ void wxPrintPaperDatabase::CreateDatabase(void) 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(); }