bool DIALOG_PRINT_USING_PRINTER::TransferDataFromWindow() { SCH_EDIT_FRAME* parent = GetParent(); GetPrintOptions(); wxPrintDialogData printDialogData( parent->GetPageSetupData().GetPrintData() ); printDialogData.SetMaxPage( g_RootSheet->CountSheets() ); if( g_RootSheet->CountSheets() > 1 ) printDialogData.EnablePageNumbers( true ); wxPrinter printer( &printDialogData ); SCH_PRINTOUT printout( parent, _( "Print Schematic" ) ); // Disable 'Print' button to prevent issuing another print // command before the previous one is finished (causes problems on Windows) m_sdbSizer1OK->Enable( false ); if( !printer.Print( this, &printout, true ) ) { if( wxPrinter::GetLastError() == wxPRINTER_ERROR ) wxMessageBox( _( "An error occurred attempting to print the schematic." ), _( "Printing" ), wxOK ); } else { parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData(); } return true; }
void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) { SCH_EDIT_FRAME* parent = GetParent(); GetPrintOptions(); wxPrintDialogData printDialogData( parent->GetPageSetupData().GetPrintData() ); printDialogData.SetMaxPage( g_RootSheet->CountSheets() ); if( g_RootSheet->CountSheets() > 1 ) printDialogData.EnablePageNumbers( true ); wxPrinter printer( &printDialogData ); SCH_PRINTOUT printout( parent, _( "Print Schematic" ) ); if( !printer.Print( this, &printout, true ) ) { if( wxPrinter::GetLastError() == wxPRINTER_ERROR ) wxMessageBox( _( "An error occurred attempting to print the schematic." ), _( "Printing" ), wxOK ); } else { parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData(); } }
/* Open a dialog box for printer setup (printer options, page size ...) */ void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event ) { SCH_EDIT_FRAME* parent = GetParent(); wxPageSetupDialog pageSetupDialog( this, &parent->GetPageSetupData() ); pageSetupDialog.ShowModal(); parent->GetPageSetupData() = pageSetupDialog.GetPageSetupDialogData(); }
bool SCH_PRINTOUT::OnBeginDocument( int startPage, int endPage ) { if( !wxPrintout::OnBeginDocument( startPage, endPage ) ) return false; #ifdef __WXDEBUG__ wxLogDebug( wxT( "Printer name: " ) + m_parent->GetPageSetupData().GetPrintData().GetPrinterName() ); wxLogDebug( wxT( "Paper ID: %d" ), m_parent->GetPageSetupData().GetPrintData().GetPaperId() ); wxLogDebug( wxT( "Color: %d" ), (int)m_parent->GetPageSetupData().GetPrintData().GetColour() ); wxLogDebug( wxT( "Monochrome: %d" ), m_parent->GetPrintMonochrome() ); wxLogDebug( wxT( "Orientation: %d:" ), m_parent->GetPageSetupData().GetPrintData().GetOrientation() ); wxLogDebug( wxT( "Quality: %d"), m_parent->GetPageSetupData().GetPrintData().GetQuality() ); #endif return true; }
/* Open and display a previewer frame for printing */ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) { SCH_EDIT_FRAME* parent = GetParent(); GetPrintOptions(); // Pass two printout objects: for preview, and possible printing. wxString title = _( "Preview" ); wxPrintPreview* preview = new wxPrintPreview( new SCH_PRINTOUT( parent, title ), new SCH_PRINTOUT( parent, title ), &parent->GetPageSetupData().GetPrintData() ); if( preview == NULL ) { DisplayError( this, _( "Print preview error!" ) ); return; } preview->SetZoom( 100 ); SCH_PREVIEW_FRAME* frame = new SCH_PREVIEW_FRAME( preview, this, title ); frame->SetMinSize( wxSize( 550, 350 ) ); // on first invocation in this runtime session, set to 2/3 size of my parent, // but will be changed in Show() if not first time as will position. frame->SetSize( (parent->GetSize() * 2) / 3 ); frame->Center(); // On wxGTK, set the flag wxTOPLEVEL_EX_DIALOG is mandatory, if we want // close the frame using the X box in caption, when the preview frame is run // from a dialog frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG ); // We use here wxPreviewFrame_WindowModal option to make the wxPrintPreview frame // modal for its caller only. // An other reason is the fact when closing the frame without this option, // all top level frames are reenabled. // With this option, only the parent is reenabled. // Reenabling all top level frames should be made by the parent dialog. frame->InitializeWithModality( wxPreviewFrame_WindowModal ); frame->Raise(); // Needed on Ubuntu/Unity to display the frame frame->Show( true ); }
bool DIALOG_PRINT_USING_PRINTER::TransferDataToWindow() { SCH_EDIT_FRAME* parent = GetParent(); // Initialize page specific print setup dialog settings. const PAGE_INFO& pageInfo = parent->GetScreen()->GetPageSettings(); wxPageSetupDialogData& pageSetupDialogData = parent->GetPageSetupData(); pageSetupDialogData.SetPaperId( pageInfo.GetPaperId() ); if( pageInfo.IsCustom() ) { if( pageInfo.IsPortrait() ) pageSetupDialogData.SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ), Mils2mm( pageInfo.GetHeightMils() ) ) ); else pageSetupDialogData.SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ), Mils2mm( pageInfo.GetWidthMils() ) ) ); } pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.GetWxOrientation() ); return true; }
void DIALOG_PRINT_USING_PRINTER::initDialog() { SCH_EDIT_FRAME* parent = GetParent(); // Initialize page specific print setup dialog settings. const PAGE_INFO& pageInfo = parent->GetScreen()->GetPageSettings(); wxPageSetupDialogData& pageSetupDialogData = parent->GetPageSetupData(); pageSetupDialogData.SetPaperId( pageInfo.GetPaperId() ); if( pageInfo.IsCustom() ) { if( pageInfo.IsPortrait() ) pageSetupDialogData.SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ), Mils2mm( pageInfo.GetHeightMils() ) ) ); else pageSetupDialogData.SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ), Mils2mm( pageInfo.GetWidthMils() ) ) ); } pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.GetWxOrientation() ); if ( GetSizer() ) GetSizer()->SetSizeHints( this ); // Rely on the policy in class DIALOG_SHIM, which centers the dialog // initially during a runtime session but gives user the ability to move it in // that session. // This dialog may get moved and resized in Show(), but in case this is // the first time, center it for starters. Center(); m_buttonPrint->SetDefault(); // on linux, this is inadequate to determine // what ENTER does. Must also SetFocus(). m_buttonPrint->SetFocus(); }