KiCad PCB EDA Suite
dialogs_for_printing.cpp File Reference
#include <base_units.h>
#include <gr_basic.h>
#include <drawing_sheet/ds_data_item.h>
#include <drawing_sheet/ds_data_model.h>
#include <drawing_sheet/ds_painter.h>
#include <dialogs/dialog_page_settings.h>
#include "invoke_pl_editor_dialog.h"
#include "pl_editor_frame.h"
#include "pl_editor_id.h"
#include <wx/msgdlg.h>
#include <wx/print.h>

Go to the source code of this file.

Classes

class  PLEDITOR_PRINTOUT
 Custom print out for printing schematics. More...
 
class  PLEDITOR_PREVIEW_FRAME
 Custom print preview frame. More...
 

Functions

int InvokeDialogPrint (PL_EDITOR_FRAME *aCaller, wxPrintData *aPrintData, wxPageSetupDialogData *aPageSetupData)
 Create and show a print dialog returns 1 if OK, 0 , there is a problem. More...
 
int InvokeDialogPrintPreview (PL_EDITOR_FRAME *aCaller, wxPrintData *aPrintData)
 Create and show a print preview dialog returns 1 if OK, 0 , there is a problem. More...
 

Function Documentation

◆ InvokeDialogPrint()

int InvokeDialogPrint ( PL_EDITOR_FRAME aCaller,
wxPrintData *  aPrintData,
wxPageSetupDialogData *  aPageSetupData 
)

Create and show a print dialog returns 1 if OK, 0 , there is a problem.

Definition at line 222 of file dialogs_for_printing.cpp.

224{
225 int pageCount = 2;
226
227 wxPrintDialogData printDialogData( *aPrintData );
228 printDialogData.SetMaxPage( pageCount );
229
230 if( pageCount > 1 )
231 printDialogData.EnablePageNumbers( true );
232
233 wxPrinter printer( &printDialogData );
234 PLEDITOR_PRINTOUT printout( aCaller, _( "Print Drawing Sheet" ) );
235
236 if( !printer.Print( aCaller, &printout, true ) )
237 {
238 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
239 wxMessageBox( _( "An error occurred attempting to print the drawing sheet." ),
240 _( "Printing" ), wxOK );
241 return 0;
242 }
243
244 *aPageSetupData = printer.GetPrintDialogData().GetPrintData();
245
246 return 1;
247}
Custom print out for printing schematics.
#define _(s)

References _.

Referenced by PL_EDITOR_FRAME::ToPrinter().

◆ InvokeDialogPrintPreview()

int InvokeDialogPrintPreview ( PL_EDITOR_FRAME aCaller,
wxPrintData *  aPrintData 
)

Create and show a print preview dialog returns 1 if OK, 0 , there is a problem.

Definition at line 250 of file dialogs_for_printing.cpp.

251{
252 // Pass two printout objects: for preview, and possible printing.
253 wxString title = _( "Preview" );
254 wxPrintPreview* preview = new wxPrintPreview( new PLEDITOR_PRINTOUT( aCaller, title ),
255 new PLEDITOR_PRINTOUT( aCaller, title ),
256 aPrintData );
257
258 preview->SetZoom( 70 );
259
260 PLEDITOR_PREVIEW_FRAME* frame = new PLEDITOR_PREVIEW_FRAME( preview, aCaller, title );
261
262 frame->Initialize();
263 frame->Show( true );
264
265 return 1;
266}
Custom print preview frame.
bool Show(bool show) override

References _, PLEDITOR_PREVIEW_FRAME::PLEDITOR_PREVIEW_FRAME(), and PLEDITOR_PREVIEW_FRAME::Show().

Referenced by PL_EDITOR_FRAME::ToPrinter().