+void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
+{
+#ifdef __WXMSW__
+ wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
+#else
+ wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
+#endif
+ wxPrinter printer;
+ wxLayoutPrintout printout( m_lwin->GetLayoutList(),"Printout from wxLayout");
+ if (! printer.Print(this, &printout, TRUE))
+ wxMessageBox(
+ "There was a problem printing.\nPerhaps your current printer is not set correctly?",
+ "Printing", wxOK);
+}
+
+void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
+{
+ wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
+
+#ifdef OS_UNIX
+ wxPostScriptPrinter printer;
+ wxLayoutPrintout printout( m_lwin->GetLayoutList(),"My printout");
+ printer.Print(this, &printout, TRUE);
+#endif
+}
+
+void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
+{
+#ifdef __WXMSW__
+ wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
+#else
+ wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
+#endif
+ wxPrintData printData;
+
+ // Pass two printout objects: for preview, and possible printing.
+ wxPrintPreview *preview = new wxPrintPreview(new
+ wxLayoutPrintout(
+ m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);
+ if (!preview->Ok())
+ {
+ delete preview;
+ wxMessageBox("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", wxOK);
+ return;
+ }
+
+ wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
+ frame->Centre(wxBOTH);
+ frame->Initialize();
+ frame->Show(TRUE);
+}
+
+void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
+{
+ wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
+
+ wxPrintData printData;
+
+ // Pass two printout objects: for preview, and possible printing.
+ wxPrintPreview *preview = new wxPrintPreview(new wxLayoutPrintout( m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);
+ wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
+ frame->Centre(wxBOTH);
+ frame->Initialize();
+ frame->Show(TRUE);
+}
+
+void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
+{
+#ifdef OS_WIN
+ wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
+#else
+ wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
+#endif
+ wxPrintDialog printerDialog(this, & m_PrintData);
+ printerDialog.ShowModal();
+}
+
+void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
+{
+#ifdef __WXMSW__
+ wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
+#else
+ wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
+#endif
+ wxPageSetupData data;
+
+#ifdef __WXMSW__
+ wxPageSetupDialog pageSetupDialog(this, & data);
+#else
+ wxGenericPageSetupDialog pageSetupDialog(this, & data);
+#endif
+ pageSetupDialog.ShowModal();
+
+ data = pageSetupDialog.GetPageSetupData();
+}
+
+void MyFrame::OnPrintSetupPS(wxCommandEvent& WXUNUSED(event))
+{
+ wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
+
+ wxPrintData data;
+
+#ifdef __WXMSW__
+ wxPrintDialog printerDialog(this, & data);
+#else
+ wxGenericPrintDialog printerDialog(this, & data);
+#endif
+ printerDialog.ShowModal();
+}
+
+void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event))
+{
+ wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
+
+ wxPageSetupData data;
+#ifdef __WXMSW__
+ wxPageSetupDialog pageSetupDialog(this, & data);
+#else
+ wxGenericPageSetupDialog pageSetupDialog(this, & data);
+#endif
+ pageSetupDialog.ShowModal();
+}
+