X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6adaedf0fc6607ee5bb4e86358396e5e07c6649f..59af5f19d077fa88fad9bf6a01040f5af390da79:/samples/printing/printing.cpp?ds=sidebyside diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index 04d721a4af..0f6b0ccf8d 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -78,14 +78,6 @@ bool MyApp::OnInit(void) g_printData = new wxPrintData; g_pageSetupData = new wxPageSetupDialogData; - - // Compatibility with old system. In fact, we might keep wxThePrintSetupData - // just for useful default values which we can optionally assign to our - // own print data object. - -#if defined(__WXGTK__) || defined(__WXMOTIF__) - (*g_printData) = * wxThePrintSetupData; -#endif // Create the main frame window frame = new MyFrame((wxFrame *) NULL, (char *) "wxWindows Printing Demo", wxPoint(0, 0), wxSize(400, 400)); @@ -104,12 +96,14 @@ bool MyApp::OnInit(void) file_menu->Append(WXPRINT_PAGE_SETUP, "Page Set&up...", "Page setup"); file_menu->Append(WXPRINT_PREVIEW, "Print Pre&view", "Preview"); +#if wxUSE_ACCEL // Accelerators wxAcceleratorEntry entries[1]; entries[0].Set(wxACCEL_CTRL, (int) 'V', WXPRINT_PREVIEW); wxAcceleratorTable accel(1, entries); frame->SetAcceleratorTable(accel); - +#endif + #if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW file_menu->AppendSeparator(); file_menu->Append(WXPRINT_PRINT_PS, "Print PostScript...", "Print (PostScript)"); @@ -190,7 +184,12 @@ void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event)) wxPrinter printer(& printDialogData); MyPrintout printout("My printout"); if (!printer.Print(this, &printout, TRUE)) - wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK); + { + if (wxPrinter::GetLastError() == wxPRINTER_ERROR) + wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK); + else + wxMessageBox("You canceled printing", "Printing", wxOK); + } else { (*g_printData) = printer.GetPrintDialogData().GetPrintData(); @@ -300,11 +299,18 @@ void MyFrame::Draw(wxDC& dc) dc.SetPen(* wxRED_PEN); dc.DrawRectangle(0, 30, 200, 100); - dc.DrawText("Rectangle 200 by 100", 40, 40); + + dc.DrawText( wxT("Rectangle 200 by 100"), 40, 40); dc.DrawEllipse(50, 140, 100, 50); - dc.DrawText("Test message: this is in 10 point text", 10, 180); + dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180); + +#if wxUSE_UNICODE + char *test = "Greek (Ελληνικά) Γειά σας -- Hebrew שלום -- Japanese (日本語)"; + wxString tmp = wxConvUTF8.cMB2WC( test ); + dc.DrawText( tmp, 10, 200 ); +#endif dc.SetPen(* wxBLACK_PEN); dc.DrawLine(0, 0, 200, 200); @@ -358,8 +364,8 @@ bool MyPrintout::OnPrintPage(int page) dc->SetDeviceOrigin(0, 0); dc->SetUserScale(1.0, 1.0); - char buf[200]; - sprintf(buf, "PAGE %d", page); + wxChar buf[200]; + wxSprintf(buf, wxT("PAGE %d"), page); dc->DrawText(buf, 10, 10); return TRUE; @@ -479,7 +485,6 @@ void MyPrintout::DrawPageTwo(wxDC *dc) dc->SetFont(* wxGetApp().m_testFont); dc->SetBackgroundMode(wxTRANSPARENT); - dc->DrawText("Some test text", 200, 200 ); { // GetTextExtent demo: wxString words[7] = {"This ", "is ", "GetTextExtent ", "testing ", "string. ", "Enjoy ", "it!"}; @@ -497,6 +502,8 @@ void MyPrintout::DrawPageTwo(wxDC *dc) dc->SetFont(* wxGetApp().m_testFont); } + dc->DrawText("Some test text", 200, 300 ); + // TESTING int leftMargin = 20;