X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8826f46f0d755eba7996920da2aee45946bc6144..678d9f2a42faa84cf934bbb75a5b4414a094012e:/src/generic/prntdlgg.cpp diff --git a/src/generic/prntdlgg.cpp b/src/generic/prntdlgg.cpp index c5ea11ae15..665c7ce812 100644 --- a/src/generic/prntdlgg.cpp +++ b/src/generic/prntdlgg.cpp @@ -30,6 +30,8 @@ #include "wx/defs.h" +#if wxUSE_PRINTING_ARCHITECTURE + #ifndef WX_PRECOMP #include "wx/utils.h" #include "wx/dc.h" @@ -65,18 +67,21 @@ // wxWin macros // ---------------------------------------------------------------------------- +#if !USE_SHARED_LIBRARY + #if wxUSE_POSTSCRIPT -#if !USE_SHARED_LIBRARY IMPLEMENT_CLASS(wxGenericPrintDialog, wxDialog) IMPLEMENT_CLASS(wxGenericPrintSetupDialog, wxDialog) - IMPLEMENT_CLASS(wxGenericPageSetupDialog, wxDialog) BEGIN_EVENT_TABLE(wxGenericPrintDialog, wxDialog) EVT_BUTTON(wxID_OK, wxGenericPrintDialog::OnOK) EVT_BUTTON(wxPRINTID_SETUP, wxGenericPrintDialog::OnSetup) EVT_RADIOBOX(wxPRINTID_RANGE, wxGenericPrintDialog::OnRange) END_EVENT_TABLE() +#endif + + IMPLEMENT_CLASS(wxGenericPageSetupDialog, wxDialog) BEGIN_EVENT_TABLE(wxGenericPageSetupDialog, wxDialog) EVT_BUTTON(wxPRINTID_SETUP, wxGenericPageSetupDialog::OnPrinter) @@ -89,6 +94,8 @@ extern wxPrintPaperDatabase *wxThePrintPaperDatabase; +#if wxUSE_POSTSCRIPT + // ============================================================================ // implementation // ============================================================================ @@ -113,6 +120,11 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxPrintData* data) + : wxDialog(parent, -1, _("Print"), + wxPoint(0, 0), wxSize(600, 600), + wxDEFAULT_DIALOG_STYLE | + wxDIALOG_MODAL | + wxTAB_TRAVERSAL) { if ( data ) m_printDialogData = *data; @@ -120,10 +132,10 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, Init(parent); } -void wxGenericPrintDialog::Init(wxWindow *parent) +void wxGenericPrintDialog::Init(wxWindow * WXUNUSED(parent)) { - wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600), - wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL); + // wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600), + // wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL); (void)new wxStaticBox( this, -1, _( "Printer options" ), wxPoint( 5, 5), wxSize( 300, 60 ) ); @@ -136,7 +148,9 @@ void wxGenericPrintDialog::Init(wxWindow *parent) choices[1] = _("Pages"); m_fromText = (wxTextCtrl*)NULL; - + m_toText = (wxTextCtrl*)NULL; + m_rangeRadioBox = (wxRadioBox *)NULL; + if (m_printDialogData.GetFromPage() != 0) { m_rangeRadioBox = new wxRadioBox(this, wxPRINTID_RANGE, _("Print Range"), @@ -161,8 +175,8 @@ void wxGenericPrintDialog::Init(wxWindow *parent) m_noCopiesText = new wxTextCtrl(this, wxPRINTID_COPIES, "", wxPoint(252, 130), wxSize(40, -1)); - wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(40, 180), wxSize(100, -1)); - (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(180, 180), wxSize(100, -1)); + wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(40, 180), wxSize(80, -1)); + (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(180, 180), wxSize(80, -1)); okButton->SetDefault(); okButton->SetFocus(); @@ -227,7 +241,7 @@ void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event)) wxString f = wxFileSelector(_("PostScript file"), wxPathOnly(wxThePrintSetupData->GetPrinterFile()), wxFileNameFromPath(wxThePrintSetupData->GetPrinterFile()), - "ps", "*.ps", 0, this); + _T("ps"), _T("*.ps"), 0, this); if ( f.IsEmpty() ) return; @@ -235,7 +249,10 @@ void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event)) wxThePrintSetupData->SetPrinterFile(f); } else + { + m_printDialogData.GetPrintData().SetPrintMode(wxPRINT_MODE_PRINTER); wxThePrintSetupData->SetPrinterMode(wxPRINT_MODE_PRINTER); + } EndModal(wxID_OK); } @@ -258,6 +275,7 @@ void wxGenericPrintDialog::OnRange(wxCommandEvent& event) void wxGenericPrintDialog::OnSetup(wxCommandEvent& WXUNUSED(event)) { + *wxThePrintSetupData = m_printDialogData.GetPrintData(); wxGenericPrintSetupDialog *genericPrintSetupDialog = new wxGenericPrintSetupDialog(this, wxThePrintSetupData); int ret = genericPrintSetupDialog->ShowModal(); @@ -276,28 +294,33 @@ bool wxGenericPrintDialog::TransferDataToWindow() if(m_printDialogData.GetFromPage() != 0) { - if (m_printDialogData.GetEnablePageNumbers()) - { - m_fromText->Enable(TRUE); - m_toText->Enable(TRUE); - - sprintf(buf, "%d", m_printDialogData.GetFromPage()); - m_fromText->SetValue(buf); - sprintf(buf, "%d", m_printDialogData.GetToPage()); - m_toText->SetValue(buf); - - if (m_printDialogData.GetAllPages()) + if(m_fromText) + { + if (m_printDialogData.GetEnablePageNumbers()) + { + m_fromText->Enable(TRUE); + m_toText->Enable(TRUE); + sprintf(buf, "%d", m_printDialogData.GetFromPage()); + m_fromText->SetValue(buf); + sprintf(buf, "%d", m_printDialogData.GetToPage()); + m_toText->SetValue(buf); + if(m_rangeRadioBox) + if (m_printDialogData.GetAllPages()) + m_rangeRadioBox->SetSelection(0); + else + m_rangeRadioBox->SetSelection(1); + } + else + { + m_fromText->Enable(FALSE); + m_toText->Enable(FALSE); + if(m_rangeRadioBox) + { m_rangeRadioBox->SetSelection(0); - else - m_rangeRadioBox->SetSelection(1); - } - else - { - m_fromText->Enable(FALSE); - m_toText->Enable(FALSE); - m_rangeRadioBox->SetSelection(0); - m_rangeRadioBox->wxRadioBox::Enable(1, FALSE); - } + m_rangeRadioBox->wxRadioBox::Enable(1, FALSE); + } + } + } } sprintf(buf, "%d", m_printDialogData.GetNoCopies()); m_noCopiesText->SetValue(buf); @@ -313,20 +336,23 @@ bool wxGenericPrintDialog::TransferDataFromWindow() { if (m_printDialogData.GetEnablePageNumbers()) { - m_printDialogData.SetFromPage(atoi(m_fromText->GetValue())); - m_printDialogData.SetToPage(atoi(m_toText->GetValue())); + if(m_fromText) m_printDialogData.SetFromPage(wxAtoi(m_fromText->GetValue())); + if(m_toText) m_printDialogData.SetToPage(wxAtoi(m_toText->GetValue())); + } + if(m_rangeRadioBox) + { + if (m_rangeRadioBox->GetSelection() == 0) + m_printDialogData.SetAllPages(TRUE); + else + m_printDialogData.SetAllPages(FALSE); } - if (m_rangeRadioBox->GetSelection() == 0) - m_printDialogData.SetAllPages(TRUE); - else - m_printDialogData.SetAllPages(FALSE); } else { // continuous printing m_printDialogData.SetFromPage(1); m_printDialogData.SetToPage(32000); } - m_printDialogData.SetNoCopies(atoi(m_noCopiesText->GetValue())); + m_printDialogData.SetNoCopies(wxAtoi(m_noCopiesText->GetValue())); m_printDialogData.SetPrintToFile(m_printToFileCheckBox->GetValue()); return TRUE; @@ -339,7 +365,8 @@ TODO: collate and noCopies should be duplicated across dialog data and print dat wxDC *wxGenericPrintDialog::GetPrintDC() { - return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL); + // return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL); + return new wxPostScriptDC(GetPrintDialogData().GetPrintData()); } // ---------------------------------------------------------------------------- @@ -406,8 +433,8 @@ void wxGenericPrintSetupDialog::Init(wxPrintData* data) m_printerOptionsText = new wxTextCtrl(this, wxPRINTID_OPTIONS, "", wxPoint(360, 135), wxSize(150, -1)); - wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(130, 200), wxSize(100, -1)); - (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(320, 200), wxSize(100, -1)); + wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(130, 200), wxSize(80, -1)); + (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(320, 200), wxSize(80, -1)); okButton->SetDefault(); okButton->SetFocus(); @@ -675,9 +702,9 @@ bool wxGenericPageSetupDialog::TransferDataToWindow() bool wxGenericPageSetupDialog::TransferDataFromWindow() { if (m_marginLeftText && m_marginTopText) - m_pageData.SetMarginTopLeft(wxPoint(atoi((const char *)m_marginLeftText->GetValue()),atoi((const char *)m_marginTopText->GetValue()))); + m_pageData.SetMarginTopLeft(wxPoint(wxAtoi((const wxChar *)m_marginLeftText->GetValue()),wxAtoi((const wxChar *)m_marginTopText->GetValue()))); if (m_marginRightText && m_marginBottomText) - m_pageData.SetMarginBottomRight(wxPoint(atoi((const char *)m_marginRightText->GetValue()),atoi((const char *)m_marginBottomText->GetValue()))); + m_pageData.SetMarginBottomRight(wxPoint(wxAtoi((const wxChar *)m_marginRightText->GetValue()),wxAtoi((const wxChar *)m_marginBottomText->GetValue()))); if (m_orientationRadioBox) { @@ -745,3 +772,4 @@ wxChoice *wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x, int *y) return choice; } +#endif