KiCad PCB EDA Suite
dialogs_for_printing.cpp File Reference
#include <base_units.h>
#include <dialog_helpers.h>
#include <eda_item.h>
#include <gr_basic.h>
#include <drawing_sheet/ds_draw_item.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>

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 223 of file dialogs_for_printing.cpp.

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

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 251 of file dialogs_for_printing.cpp.

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

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

Referenced by PL_EDITOR_FRAME::ToPrinter().