2009-01-17 17:32:20 +00:00
|
|
|
/****************************************/
|
|
|
|
/* File: dialog_print_using_printer.cpp */
|
|
|
|
/****************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "gr_basic.h"
|
2009-01-17 17:32:20 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
2010-02-02 15:01:09 +00:00
|
|
|
#include "eeschema_config.h"
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
#include "dialog_print_using_printer_base.h"
|
|
|
|
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
/**
|
|
|
|
* Print schematic dialog.
|
|
|
|
*
|
|
|
|
* Class derived from DIALOG_PRINT_USING_PRINTER_base created by wxFormBuilder
|
2009-01-17 17:32:20 +00:00
|
|
|
*/
|
2010-02-02 15:01:09 +00:00
|
|
|
class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-02-02 15:01:09 +00:00
|
|
|
DIALOG_PRINT_USING_PRINTER( WinEDA_SchematicFrame* aParent );
|
2009-01-17 17:32:20 +00:00
|
|
|
~DIALOG_PRINT_USING_PRINTER() {};
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
WinEDA_SchematicFrame* GetParent() const;
|
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
private:
|
|
|
|
void OnCloseWindow( wxCloseEvent& event );
|
|
|
|
void OnInitDialog( wxInitDialogEvent& event );
|
2010-02-02 15:01:09 +00:00
|
|
|
void OnPageSetup( wxCommandEvent& event );
|
2009-01-17 17:32:20 +00:00
|
|
|
void OnPrintPreview( wxCommandEvent& event );
|
|
|
|
void OnPrintButtonClick( wxCommandEvent& event );
|
2009-12-02 21:44:03 +00:00
|
|
|
void OnButtonCancelClick( wxCommandEvent& event ){ Close(); }
|
2009-01-17 17:32:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
/**
|
|
|
|
* Custom print out for printing schematics.
|
|
|
|
*/
|
|
|
|
class SCH_PRINTOUT : public wxPrintout
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
private:
|
|
|
|
DIALOG_PRINT_USING_PRINTER* m_Parent;
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
public:
|
2010-02-02 15:01:09 +00:00
|
|
|
SCH_PRINTOUT( DIALOG_PRINT_USING_PRINTER* aParent, const wxString& aTitle ) :
|
2009-01-17 17:32:20 +00:00
|
|
|
wxPrintout( aTitle )
|
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
wxASSERT( aParent != NULL );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
m_Parent = aParent;
|
|
|
|
}
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
bool OnPrintPage( int page );
|
|
|
|
bool HasPage( int page );
|
|
|
|
bool OnBeginDocument( int startPage, int endPage );
|
2010-02-02 15:01:09 +00:00
|
|
|
void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo );
|
2009-01-17 17:32:20 +00:00
|
|
|
void DrawPage();
|
|
|
|
};
|
|
|
|
|
2010-01-18 17:05:31 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
/**
|
|
|
|
* Custom schematic print preview frame.
|
2009-01-17 17:32:20 +00:00
|
|
|
*/
|
2010-02-02 15:01:09 +00:00
|
|
|
class SCH_PREVIEW_FRAME : public wxPreviewFrame
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
public:
|
|
|
|
SCH_PREVIEW_FRAME( wxPrintPreview* aPreview, DIALOG_PRINT_USING_PRINTER* aParent,
|
|
|
|
const wxString& aTitle, const wxPoint& aPos = wxDefaultPosition,
|
|
|
|
const wxSize& aSize = wxDefaultSize ) :
|
|
|
|
wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
}
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
DIALOG_PRINT_USING_PRINTER* GetParent()
|
|
|
|
{
|
|
|
|
return ( DIALOG_PRINT_USING_PRINTER* )wxWindow::GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnCloseWindow( wxCloseEvent& event )
|
|
|
|
{
|
|
|
|
if( !IsIconized() )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
GetParent()->GetParent()->SetPreviewPosition( GetPosition() );
|
|
|
|
GetParent()->GetParent()->SetPreviewSize( GetSize() );
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
2010-02-02 15:01:09 +00:00
|
|
|
|
|
|
|
wxPreviewFrame::OnCloseWindow( event );
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
private:
|
|
|
|
DECLARE_CLASS( SCH_PREVIEW_FRAME )
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
DECLARE_NO_COPY_CLASS( SCH_PREVIEW_FRAME )
|
|
|
|
};
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
IMPLEMENT_CLASS( SCH_PREVIEW_FRAME, wxPreviewFrame )
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
BEGIN_EVENT_TABLE( SCH_PREVIEW_FRAME, wxPreviewFrame )
|
|
|
|
EVT_CLOSE( SCH_PREVIEW_FRAME::OnCloseWindow )
|
|
|
|
END_EVENT_TABLE()
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
void WinEDA_SchematicFrame::OnPrint( wxCommandEvent& event )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
wxFileName fn;
|
|
|
|
DIALOG_PRINT_USING_PRINTER dlg( this );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
dlg.ShowModal();
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-24 15:33:03 +00:00
|
|
|
wxString default_name = NAMELESS_PROJECT;
|
|
|
|
default_name += wxT( ".sch" );
|
|
|
|
if( fn.GetFullName() != default_name )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
|
|
|
|
DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( WinEDA_SchematicFrame* aParent ) :
|
|
|
|
DIALOG_PRINT_USING_PRINTER_BASE( aParent )
|
2010-01-18 17:05:31 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
wxASSERT( aParent != NULL );
|
2010-01-18 17:05:31 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
m_checkReference->SetValue( aParent->GetShowSheetReference() );
|
|
|
|
m_checkMonochrome->SetValue( aParent->GetPrintMonochrome() );
|
|
|
|
}
|
2010-01-18 17:05:31 +00:00
|
|
|
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
WinEDA_SchematicFrame* DIALOG_PRINT_USING_PRINTER::GetParent() const
|
|
|
|
{
|
|
|
|
return ( WinEDA_SchematicFrame* ) wxWindow::GetParent();
|
2010-01-18 17:05:31 +00:00
|
|
|
}
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
|
|
|
|
void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
WinEDA_SchematicFrame* parent = GetParent();
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
if ( GetSizer() )
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
|
|
|
|
if( parent->GetPrintDialogPosition() == wxDefaultPosition &&
|
|
|
|
parent->GetPrintDialogSize() == wxDefaultSize )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
Center();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetPosition( parent->GetPrintDialogPosition() );
|
|
|
|
SetSize( parent->GetPrintDialogSize() );
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
SetFocus();
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
WinEDA_SchematicFrame* parent = GetParent();
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
if( !IsIconized() )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
parent->SetPrintDialogPosition( GetPosition() );
|
|
|
|
parent->SetPrintDialogSize( GetSize() );
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
parent->SetPrintMonochrome( m_checkMonochrome->IsChecked() );
|
|
|
|
parent->SetShowSheetReference( m_checkReference->IsChecked() );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
EndDialog( wxID_CANCEL );
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Open a dialog box for printer setup (printer options, page size ...)
|
|
|
|
*/
|
2010-02-02 15:01:09 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
WinEDA_SchematicFrame* parent = GetParent();
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
wxPageSetupDialog pageSetupDialog( this, &parent->GetPageSetupData() );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
pageSetupDialog.ShowModal();
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
parent->GetPageSetupData() = pageSetupDialog.GetPageSetupDialogData();
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Open and display a previewer frame for printing
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
WinEDA_SchematicFrame* parent = GetParent();
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
parent->SetPrintMonochrome( m_checkMonochrome->IsChecked() );
|
|
|
|
parent->SetShowSheetReference( m_checkReference->IsChecked() );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
// Pass two printout objects: for preview, and possible printing.
|
2010-02-02 15:01:09 +00:00
|
|
|
wxString title = _( "Preview" );
|
|
|
|
wxPrintPreview* preview = new wxPrintPreview( new SCH_PRINTOUT( this, title ),
|
|
|
|
new SCH_PRINTOUT( this, title ),
|
|
|
|
&parent->GetPageSetupData().GetPrintData() );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
if( preview == NULL )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
DisplayError( this, wxT( "Print preview error!" ) );
|
2009-01-17 17:32:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
preview->SetZoom( 100 );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
SCH_PREVIEW_FRAME* frame = new SCH_PREVIEW_FRAME( preview, this, title,
|
|
|
|
parent->GetPreviewPosition(),
|
|
|
|
parent->GetPreviewSize() );
|
2009-01-17 17:32:20 +00:00
|
|
|
frame->Initialize();
|
|
|
|
frame->Show( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
|
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
WinEDA_SchematicFrame* parent = GetParent();
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
parent->SetPrintMonochrome( m_checkMonochrome->IsChecked() );
|
|
|
|
parent->SetShowSheetReference( m_checkReference->IsChecked() );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
wxPrintDialogData printDialogData( parent->GetPageSetupData().GetPrintData() );
|
|
|
|
printDialogData.SetMaxPage( g_RootSheet->CountSheets() );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
if( g_RootSheet->CountSheets() > 1 )
|
|
|
|
printDialogData.EnablePageNumbers( true );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
wxPrinter printer( &printDialogData );
|
|
|
|
SCH_PRINTOUT printout( this, _( "Print Schematic" ) );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
if( !printer.Print( this, &printout, true ) )
|
|
|
|
{
|
|
|
|
if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
|
2010-02-02 15:01:09 +00:00
|
|
|
wxMessageBox( _( "An error occurred attempting to print the schematic." ),
|
|
|
|
_( "Printing" ), wxOK );
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData();
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
bool SCH_PRINTOUT::OnPrintPage( int page )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2010-02-02 15:01:09 +00:00
|
|
|
WinEDA_SchematicFrame* parent = m_Parent->GetParent();
|
2009-01-17 17:32:20 +00:00
|
|
|
msg.Printf( _( "Print page %d" ), page );
|
2010-02-02 15:01:09 +00:00
|
|
|
parent->ClearMsgPanel();
|
|
|
|
parent->AppendMsgPanel( msg, wxEmptyString, CYAN );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
SCH_SCREEN* screen = parent->GetScreen();
|
|
|
|
SCH_SCREEN* oldscreen = screen;
|
|
|
|
SCH_SHEET_PATH* oldsheetpath = parent->GetSheet();
|
|
|
|
SCH_SHEET_PATH list;
|
|
|
|
SCH_SHEET_LIST SheetList( NULL );
|
|
|
|
SCH_SHEET_PATH* sheetpath = SheetList.GetSheet( page - 1 );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
parent->m_CurrentSheet = &list;
|
|
|
|
parent->m_CurrentSheet->UpdateAllScreenReferences();
|
|
|
|
parent->SetSheetNumberAndCount();
|
|
|
|
screen = parent->m_CurrentSheet->LastScreen();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
screen = NULL;
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( screen == NULL )
|
|
|
|
return false;
|
2010-02-02 15:01:09 +00:00
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
ActiveScreen = screen;
|
|
|
|
DrawPage();
|
|
|
|
ActiveScreen = oldscreen;
|
2010-02-02 15:01:09 +00:00
|
|
|
parent->m_CurrentSheet = oldsheetpath;
|
|
|
|
parent->m_CurrentSheet->UpdateAllScreenReferences();
|
|
|
|
parent->SetSheetNumberAndCount();
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
void SCH_PRINTOUT::GetPageInfo( int* minPage, int* maxPage,
|
2009-01-17 17:32:20 +00:00
|
|
|
int* selPageFrom, int* selPageTo )
|
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
*minPage = *selPageFrom = 1;
|
|
|
|
*maxPage = *selPageTo = g_RootSheet->CountSheets();
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
bool SCH_PRINTOUT::HasPage( int pageNum )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
|
|
|
int pageCount;
|
|
|
|
|
|
|
|
pageCount = g_RootSheet->CountSheets();
|
|
|
|
if( pageCount >= pageNum )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
bool SCH_PRINTOUT::OnBeginDocument( int startPage, int endPage )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
|
|
|
if( !wxPrintout::OnBeginDocument( startPage, endPage ) )
|
|
|
|
return false;
|
|
|
|
|
2010-02-16 17:49:17 +00:00
|
|
|
#ifdef __WXDEBUG__
|
2010-02-02 15:01:09 +00:00
|
|
|
WinEDA_SchematicFrame* parent = m_Parent->GetParent();
|
|
|
|
wxLogDebug( wxT( "Printer name: " ) +
|
|
|
|
parent->GetPageSetupData().GetPrintData().GetPrinterName() );
|
|
|
|
wxLogDebug( wxT( "Paper ID: %d" ),
|
|
|
|
parent->GetPageSetupData().GetPrintData().GetPaperId() );
|
|
|
|
wxLogDebug( wxT( "Color: %d" ),
|
|
|
|
(int) parent->GetPageSetupData().GetPrintData().GetColour() );
|
|
|
|
wxLogDebug( wxT( "Monochrome: %d" ), parent->GetPrintMonochrome() );
|
|
|
|
wxLogDebug( wxT( "Orientation: %d:" ),
|
|
|
|
parent->GetPageSetupData().GetPrintData().GetOrientation() );
|
|
|
|
wxLogDebug( wxT( "Quality: %d"),
|
|
|
|
parent->GetPageSetupData().GetPrintData().GetQuality() );
|
2010-09-15 17:50:47 +00:00
|
|
|
#endif
|
2010-02-02 15:01:09 +00:00
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the real print function: print the active screen
|
|
|
|
*/
|
2010-02-02 15:01:09 +00:00
|
|
|
void SCH_PRINTOUT::DrawPage()
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
2010-02-02 15:01:09 +00:00
|
|
|
int oldZoom;
|
|
|
|
wxPoint tmp_startvisu;
|
|
|
|
wxSize SheetSize; // Page size in internal units
|
|
|
|
wxPoint old_org;
|
|
|
|
EDA_Rect oldClipBox;
|
|
|
|
wxRect fitRect;
|
|
|
|
wxDC* dc = GetDC();
|
|
|
|
WinEDA_SchematicFrame* parent = m_Parent->GetParent();
|
|
|
|
WinEDA_DrawPanel* panel = parent->DrawPanel;
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
wxBusyCursor dummy;
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
/* Save current scale factor, offsets, and clip box. */
|
2009-01-17 17:32:20 +00:00
|
|
|
tmp_startvisu = ActiveScreen->m_StartVisu;
|
2010-02-02 15:01:09 +00:00
|
|
|
oldZoom = ActiveScreen->GetZoom();
|
2009-01-17 17:32:20 +00:00
|
|
|
old_org = ActiveScreen->m_DrawOrg;
|
2010-02-02 15:01:09 +00:00
|
|
|
oldClipBox = panel->m_ClipBox;
|
|
|
|
|
|
|
|
/* Change scale factor, offsets, and clip box to print the whole page. */
|
|
|
|
ActiveScreen->SetScalingFactor( 1.0 );
|
2009-01-17 17:32:20 +00:00
|
|
|
ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0;
|
|
|
|
ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0;
|
2010-02-02 15:01:09 +00:00
|
|
|
panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
|
|
|
|
panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
bool printReference = parent->GetShowSheetReference();
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
if( printReference )
|
|
|
|
{
|
|
|
|
/* Draw the page to a memory and let the dc calculate the drawing
|
|
|
|
* limits.
|
|
|
|
*/
|
|
|
|
wxBitmap psuedoBitmap( 1, 1 );
|
|
|
|
wxMemoryDC memDC;
|
|
|
|
memDC.SelectObject( psuedoBitmap );
|
2010-03-18 20:35:29 +00:00
|
|
|
parent->PrintPage( &memDC, true, 0xFFFFFFFF, false );
|
2010-02-02 15:01:09 +00:00
|
|
|
wxLogDebug( wxT( "MinX = %d, MaxX = %d, MinY = %d, MaxY = %d" ),
|
|
|
|
memDC.MinX(), memDC.MaxX(), memDC.MinY(), memDC.MaxY() );
|
|
|
|
|
|
|
|
SheetSize.x = memDC.MaxX() - memDC.MinX();
|
|
|
|
SheetSize.y = memDC.MaxY() - memDC.MinY();
|
|
|
|
|
|
|
|
FitThisSizeToPageMargins( SheetSize, parent->GetPageSetupData() );
|
|
|
|
fitRect = GetLogicalPageMarginsRect( parent->GetPageSetupData() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SheetSize = ActiveScreen->m_CurrentSheetDesc->m_Size;
|
|
|
|
FitThisSizeToPaper( SheetSize );
|
|
|
|
fitRect = GetLogicalPaperRect();
|
|
|
|
}
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
wxLogDebug( wxT( "Fit rectangle: %d, %d, %d, %d" ),
|
|
|
|
fitRect.x, fitRect.y, fitRect.width, fitRect.height );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
GRResetPenAndBrush( dc );
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
if( parent->GetPrintMonochrome() )
|
|
|
|
GRForceBlackPen( true );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
ActiveScreen->m_IsPrinting = true;
|
2009-01-17 17:32:20 +00:00
|
|
|
int bg_color = g_DrawBgColor;
|
|
|
|
|
2010-03-18 20:35:29 +00:00
|
|
|
parent->PrintPage( dc, printReference, 0xFFFFFFFF, false );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
g_DrawBgColor = bg_color;
|
|
|
|
ActiveScreen->m_IsPrinting = false;
|
|
|
|
panel->m_ClipBox = oldClipBox;
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
GRForceBlackPen( false );
|
|
|
|
|
|
|
|
ActiveScreen->m_StartVisu = tmp_startvisu;
|
|
|
|
ActiveScreen->m_DrawOrg = old_org;
|
2010-02-02 15:01:09 +00:00
|
|
|
ActiveScreen->SetZoom( oldZoom );
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|