Commit c8ed3280 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: Fix many minor issues in print dialog, mainly in modedit.

parent 742e1a7e
...@@ -151,30 +151,12 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event ) ...@@ -151,30 +151,12 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
if ( GetSizer() ) if ( GetSizer() )
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
#if 0 // Rely on the policy in class DIALOG_SHIM, which centers the dialog
Does not work on a two monitor system when the 2nd monitor is not attached, // initially during a runtime session but gives user the ability to move it in
and when the coords were saved to disk when the playground was bigger while the // that session.
2nd monitor was attached.
Simply 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.
if( parent->GetPrintDialogPosition() == wxDefaultPosition &&
parent->GetPrintDialogSize() == wxDefaultSize )
{
Center();
}
else
{
SetPosition( parent->GetPrintDialogPosition() );
SetSize( parent->GetPrintDialogSize() );
}
#else
// This dialog may get moved and resized in Show(), but in case this is // This dialog may get moved and resized in Show(), but in case this is
// the first time, center it for starters. // the first time, center it for starters.
Center(); Center();
#endif
m_buttonPrint->SetDefault(); // on linux, this is inadequate to determine m_buttonPrint->SetDefault(); // on linux, this is inadequate to determine
// what ENTER does. Must also SetFocus(). // what ENTER does. Must also SetFocus().
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// Set this to 1 if you want to test PostScript printing under MSW. // Set this to 1 if you want to test PostScript printing under MSW.
#define wxTEST_POSTSCRIPT_IN_MSW 1 //#define wxTEST_POSTSCRIPT_IN_MSW 1
#include <fctsys.h> #include <fctsys.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
...@@ -43,7 +43,7 @@ private: ...@@ -43,7 +43,7 @@ private:
void OnCloseWindow( wxCloseEvent& event ); void OnCloseWindow( wxCloseEvent& event );
/// Open a dialog box for printer setup (printer options, page size ...) /// Open a dialog box for printer setup (printer options, page size ...)
void OnPrintSetup( wxCommandEvent& event ); void OnPageSetup( wxCommandEvent& event );
void OnPrintPreview( wxCommandEvent& event ); void OnPrintPreview( wxCommandEvent& event );
...@@ -57,6 +57,8 @@ private: ...@@ -57,6 +57,8 @@ private:
void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event ) void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
{ {
const PAGE_INFO& pageInfo = GetPageSettings();
if( s_PrintData == NULL ) // First print if( s_PrintData == NULL ) // First print
{ {
s_PrintData = new wxPrintData(); s_PrintData = new wxPrintData();
...@@ -68,7 +70,15 @@ void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event ) ...@@ -68,7 +70,15 @@ void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT; s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT;
} }
s_PrintData->SetOrientation( GetPageSettings().IsPortrait() ? wxPORTRAIT : wxLANDSCAPE ); if( s_pageSetupData == NULL )
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
s_PrintData->SetOrientation( pageInfo.GetWxOrientation() );
*s_PrintData = s_pageSetupData->GetPrintData();
s_Parameters.m_PageSetupData = s_pageSetupData;
DIALOG_PRINT_FOR_MODEDIT dlg( this ); DIALOG_PRINT_FOR_MODEDIT dlg( this );
...@@ -91,17 +101,6 @@ DIALOG_PRINT_FOR_MODEDIT::DIALOG_PRINT_FOR_MODEDIT( PCB_BASE_FRAME* parent ) : ...@@ -91,17 +101,6 @@ DIALOG_PRINT_FOR_MODEDIT::DIALOG_PRINT_FOR_MODEDIT( PCB_BASE_FRAME* parent ) :
void DIALOG_PRINT_FOR_MODEDIT::InitValues( ) void DIALOG_PRINT_FOR_MODEDIT::InitValues( )
{ {
if( s_pageSetupData == NULL )
{
s_pageSetupData = new wxPageSetupDialogData;
// Set initial page margins.
// Margins are already set in Pcbnew, so we cans use 0
s_pageSetupData->SetMarginTopLeft(wxPoint(0, 0));
s_pageSetupData->SetMarginBottomRight(wxPoint(0, 0));
}
s_Parameters.m_PageSetupData = s_pageSetupData;
// Read the scale adjust option // Read the scale adjust option
int scale_Select = 3; // default selected scale = ScaleList[3] = 1 int scale_Select = 3; // default selected scale = ScaleList[3] = 1
if( m_config ) if( m_config )
...@@ -130,19 +129,13 @@ void DIALOG_PRINT_FOR_MODEDIT::OnCloseWindow( wxCloseEvent& event ) ...@@ -130,19 +129,13 @@ void DIALOG_PRINT_FOR_MODEDIT::OnCloseWindow( wxCloseEvent& event )
} }
void DIALOG_PRINT_FOR_MODEDIT::OnPageSetup( wxCommandEvent& event )
void DIALOG_PRINT_FOR_MODEDIT::OnPrintSetup( wxCommandEvent& event )
{ {
wxPrintDialogData printDialogData( *s_PrintData ); wxPageSetupDialog pageSetupDialog( this, s_pageSetupData );
pageSetupDialog.ShowModal();
if( printDialogData.Ok() ) (*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
{ (*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
wxPrintDialog printerDialog( this, &printDialogData );
printerDialog.ShowModal();
*s_PrintData = printerDialog.GetPrintDialogData().GetPrintData();
}
else
DisplayError( this, _( "Printer Problem!" ) );
} }
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 19 2012) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include "dialog_print_for_modedit_base.h" #include "dialog_print_for_modedit_base.h"
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
DIALOG_PRINT_FOR_MODEDIT_BASE::DIALOG_PRINT_FOR_MODEDIT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) DIALOG_PRINT_FOR_MODEDIT_BASE::DIALOG_PRINT_FOR_MODEDIT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{ {
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
wxBoxSizer* bMainSizer; wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxHORIZONTAL ); bMainSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bmiddleLeftSizer; wxBoxSizer* bmiddleLeftSizer;
bmiddleLeftSizer = new wxBoxSizer( wxVERTICAL ); bmiddleLeftSizer = new wxBoxSizer( wxVERTICAL );
wxString m_ScaleOptionChoices[] = { _("fit in page"), _("Scale 0.5"), _("Scale 0.7"), _("Scale 1"), _("Scale 1.4"), _("Scale 2"), _("Scale 3"), _("Scale 4"), _("Scale 8"), _("Scale 16") }; wxString m_ScaleOptionChoices[] = { _("fit in page"), _("Scale 0.5"), _("Scale 0.7"), _("Scale 1"), _("Scale 1.4"), _("Scale 2"), _("Scale 3"), _("Scale 4"), _("Scale 8"), _("Scale 16") };
int m_ScaleOptionNChoices = sizeof( m_ScaleOptionChoices ) / sizeof( wxString ); int m_ScaleOptionNChoices = sizeof( m_ScaleOptionChoices ) / sizeof( wxString );
m_ScaleOption = new wxRadioBox( this, wxID_ANY, _("Approx. Scale:"), wxDefaultPosition, wxDefaultSize, m_ScaleOptionNChoices, m_ScaleOptionChoices, 1, wxRA_SPECIFY_COLS ); m_ScaleOption = new wxRadioBox( this, wxID_ANY, _("Approx. Scale:"), wxDefaultPosition, wxDefaultSize, m_ScaleOptionNChoices, m_ScaleOptionChoices, 1, wxRA_SPECIFY_COLS );
m_ScaleOption->SetSelection( 3 ); m_ScaleOption->SetSelection( 3 );
bmiddleLeftSizer->Add( m_ScaleOption, 0, wxALL, 5 ); bmiddleLeftSizer->Add( m_ScaleOption, 0, wxALL, 5 );
bMainSizer->Add( bmiddleLeftSizer, 0, wxEXPAND, 5 ); bMainSizer->Add( bmiddleLeftSizer, 0, wxEXPAND, 5 );
wxBoxSizer* bmiddleRightSizer; wxBoxSizer* bmiddleRightSizer;
bmiddleRightSizer = new wxBoxSizer( wxVERTICAL ); bmiddleRightSizer = new wxBoxSizer( wxVERTICAL );
wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and white") }; wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and white") };
int m_ModeColorOptionNChoices = sizeof( m_ModeColorOptionChoices ) / sizeof( wxString ); int m_ModeColorOptionNChoices = sizeof( m_ModeColorOptionChoices ) / sizeof( wxString );
m_ModeColorOption = new wxRadioBox( this, wxID_PRINT_MODE, _("Print Mode"), wxDefaultPosition, wxDefaultSize, m_ModeColorOptionNChoices, m_ModeColorOptionChoices, 1, wxRA_SPECIFY_COLS ); m_ModeColorOption = new wxRadioBox( this, wxID_PRINT_MODE, _("Print Mode"), wxDefaultPosition, wxDefaultSize, m_ModeColorOptionNChoices, m_ModeColorOptionChoices, 1, wxRA_SPECIFY_COLS );
m_ModeColorOption->SetSelection( 1 ); m_ModeColorOption->SetSelection( 1 );
m_ModeColorOption->SetToolTip( _("Choose if you want to draw the sheet like it appears on screen,\nor in black and white mode, better to print it when using black and white printers") ); m_ModeColorOption->SetToolTip( _("Choose if you want to draw the sheet like it appears on screen,\nor in black and white mode, better to print it when using black and white printers") );
bmiddleRightSizer->Add( m_ModeColorOption, 0, wxALL|wxEXPAND, 5 ); bmiddleRightSizer->Add( m_ModeColorOption, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( bmiddleRightSizer, 1, 0, 5 ); bMainSizer->Add( bmiddleRightSizer, 1, 0, 5 );
wxBoxSizer* bbuttonsSizer; wxBoxSizer* bbuttonsSizer;
bbuttonsSizer = new wxBoxSizer( wxVERTICAL ); bbuttonsSizer = new wxBoxSizer( wxVERTICAL );
m_buttonOption = new wxButton( this, wxID_PRINT_OPTIONS, _("Page Options"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonOption = new wxButton( this, wxID_PRINT_OPTIONS, _("Page Options"), wxDefaultPosition, wxDefaultSize, 0 );
bbuttonsSizer->Add( m_buttonOption, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); bbuttonsSizer->Add( m_buttonOption, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonPreview = new wxButton( this, wxID_PREVIEW, _("Preview"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonPreview = new wxButton( this, wxID_PREVIEW, _("Preview"), wxDefaultPosition, wxDefaultSize, 0 );
bbuttonsSizer->Add( m_buttonPreview, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); bbuttonsSizer->Add( m_buttonPreview, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonPrint = new wxButton( this, wxID_PRINT_ALL, _("Print"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonPrint = new wxButton( this, wxID_PRINT_ALL, _("Print"), wxDefaultPosition, wxDefaultSize, 0 );
bbuttonsSizer->Add( m_buttonPrint, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); bbuttonsSizer->Add( m_buttonPrint, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
bbuttonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); bbuttonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
bMainSizer->Add( bbuttonsSizer, 0, 0, 5 ); bMainSizer->Add( bbuttonsSizer, 0, 0, 5 );
this->SetSizer( bMainSizer ); this->SetSizer( bMainSizer );
this->Layout(); this->Layout();
bMainSizer->Fit( this ); bMainSizer->Fit( this );
this->Centre( wxBOTH ); this->Centre( wxBOTH );
// Connect Events // Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnCloseWindow ) ); this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnCloseWindow ) );
m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintSetup ), NULL, this ); m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPageSetup ), NULL, this );
m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintPreview ), NULL, this ); m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintPreview ), NULL, this );
m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintButtonClick ), NULL, this ); m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintButtonClick ), NULL, this );
m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnButtonCancelClick ), NULL, this ); m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnButtonCancelClick ), NULL, this );
} }
DIALOG_PRINT_FOR_MODEDIT_BASE::~DIALOG_PRINT_FOR_MODEDIT_BASE() DIALOG_PRINT_FOR_MODEDIT_BASE::~DIALOG_PRINT_FOR_MODEDIT_BASE()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnCloseWindow ) ); this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnCloseWindow ) );
m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintSetup ), NULL, this ); m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPageSetup ), NULL, this );
m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintPreview ), NULL, this ); m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintPreview ), NULL, this );
m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintButtonClick ), NULL, this ); m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintButtonClick ), NULL, this );
m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnButtonCancelClick ), NULL, this ); m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnButtonCancelClick ), NULL, this );
} }
...@@ -364,7 +364,7 @@ ...@@ -364,7 +364,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnButtonClick">OnPrintSetup</event> <event name="OnButtonClick">OnPageSetup</event>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 19 2012) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_PRINT_FOR_MODEDIT_BASE_H__ #ifndef __DIALOG_PRINT_FOR_MODEDIT_BASE_H__
#define __DIALOG_PRINT_FOR_MODEDIT_BASE_H__ #define __DIALOG_PRINT_FOR_MODEDIT_BASE_H__
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
#include "dialog_shim.h" class DIALOG_SHIM;
#include <wx/string.h>
#include <wx/radiobox.h> #include "dialog_shim.h"
#include <wx/gdicmn.h> #include <wx/string.h>
#include <wx/font.h> #include <wx/radiobox.h>
#include <wx/colour.h> #include <wx/gdicmn.h>
#include <wx/settings.h> #include <wx/font.h>
#include <wx/sizer.h> #include <wx/colour.h>
#include <wx/button.h> #include <wx/settings.h>
#include <wx/dialog.h> #include <wx/sizer.h>
#include <wx/button.h>
/////////////////////////////////////////////////////////////////////////// #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/// Class DIALOG_PRINT_FOR_MODEDIT_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class DIALOG_PRINT_FOR_MODEDIT_BASE : public DIALOG_SHIM /// Class DIALOG_PRINT_FOR_MODEDIT_BASE
{ ///////////////////////////////////////////////////////////////////////////////
private: class DIALOG_PRINT_FOR_MODEDIT_BASE : public DIALOG_SHIM
{
protected: private:
enum
{ protected:
wxID_PRINT_MODE = 1000, enum
wxID_PRINT_OPTIONS, {
wxID_PRINT_ALL wxID_PRINT_MODE = 1000,
}; wxID_PRINT_OPTIONS,
wxID_PRINT_ALL
wxRadioBox* m_ScaleOption; };
wxRadioBox* m_ModeColorOption;
wxButton* m_buttonOption; wxRadioBox* m_ScaleOption;
wxButton* m_buttonPreview; wxRadioBox* m_ModeColorOption;
wxButton* m_buttonPrint; wxButton* m_buttonOption;
wxButton* m_buttonQuit; wxButton* m_buttonPreview;
wxButton* m_buttonPrint;
// Virtual event handlers, overide them in your derived class wxButton* m_buttonQuit;
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void OnPrintSetup( wxCommandEvent& event ) { event.Skip(); } // Virtual event handlers, overide them in your derived class
virtual void OnPrintPreview( wxCommandEvent& event ) { event.Skip(); } virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void OnPrintButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnPageSetup( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnPrintPreview( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPrintButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_PRINT_FOR_MODEDIT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); public:
~DIALOG_PRINT_FOR_MODEDIT_BASE();
DIALOG_PRINT_FOR_MODEDIT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
}; ~DIALOG_PRINT_FOR_MODEDIT_BASE();
#endif //__DIALOG_PRINT_FOR_MODEDIT_BASE_H__ };
#endif //__DIALOG_PRINT_FOR_MODEDIT_BASE_H__
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/****************************************/ /****************************************/
// Set this to 1 if you want to test PostScript printing under MSW. // Set this to 1 if you want to test PostScript printing under MSW.
#define wxTEST_POSTSCRIPT_IN_MSW 1 //#define wxTEST_POSTSCRIPT_IN_MSW 1
#include <fctsys.h> #include <fctsys.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
...@@ -100,6 +100,7 @@ void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event ) ...@@ -100,6 +100,7 @@ void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData ); s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() ); s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
if( pageInfo.IsCustom() ) if( pageInfo.IsCustom() )
{ {
...@@ -111,10 +112,6 @@ void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event ) ...@@ -111,10 +112,6 @@ void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
Mils2mm( pageInfo.GetWidthMils() ) ) ); Mils2mm( pageInfo.GetWidthMils() ) ) );
} }
s_pageSetupData->SetMarginTopLeft( wxPoint( 0, 0 ) );
s_pageSetupData->SetMarginBottomRight( wxPoint( 0, 0 ) );
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
*s_PrintData = s_pageSetupData->GetPrintData(); *s_PrintData = s_pageSetupData->GetPrintData();
DIALOG_PRINT_USING_PRINTER dlg( this ); DIALOG_PRINT_USING_PRINTER dlg( this );
...@@ -454,10 +451,11 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) ...@@ -454,10 +451,11 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
} }
// Uses the parent position and size. // Uses the parent position and size.
// @todo uses last position and size ans store them when exit in m_config
wxPoint WPos = m_parent->GetPosition(); wxPoint WPos = m_parent->GetPosition();
wxSize WSize = m_parent->GetSize(); wxSize WSize = m_parent->GetSize();
preview->SetZoom( 100 );
wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, WPos, WSize ); wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, WPos, WSize );
frame->Initialize(); frame->Initialize();
......
...@@ -198,6 +198,10 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent ) : ...@@ -198,6 +198,10 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent ) :
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
// In modedit, set the default paper size to A4:
// this should be OK for all footprint to plot/print
SetPageSettings( PAGE_INFO::A4 );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
......
...@@ -59,8 +59,8 @@ static const wxString tracePrinting( wxT( "KicadPrinting" ) ); ...@@ -59,8 +59,8 @@ static const wxString tracePrinting( wxT( "KicadPrinting" ) );
PRINT_PARAMETERS::PRINT_PARAMETERS() PRINT_PARAMETERS::PRINT_PARAMETERS()
{ {
m_PenDefaultSize = 50; // A reasonable minimal value to draw items m_PenDefaultSize = Millimeter2iu( 0.2 ); // A reasonable defualt value to draw items
// mainly that do not have a specified line width // which do not have a specified line width
m_PrintScale = 1.0; m_PrintScale = 1.0;
m_XScaleAdjust = 1.0; m_XScaleAdjust = 1.0;
m_YScaleAdjust = 1.0; m_YScaleAdjust = 1.0;
...@@ -159,6 +159,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -159,6 +159,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
wxDC* dc = GetDC(); wxDC* dc = GetDC();
BASE_SCREEN* screen = m_Parent->GetScreen(); BASE_SCREEN* screen = m_Parent->GetScreen();
bool printMirror = m_PrintParams.m_PrintMirror; bool printMirror = m_PrintParams.m_PrintMirror;
wxSize pageSizeIU = m_Parent->GetPageSizeIU();
wxBusyCursor dummy; wxBusyCursor dummy;
...@@ -171,16 +172,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -171,16 +172,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
// Use the page size as the drawing area when the board is shown or the user scale // Use the page size as the drawing area when the board is shown or the user scale
// is less than 1. // is less than 1.
if( m_PrintParams.PrintBorderAndTitleBlock() ) if( m_PrintParams.PrintBorderAndTitleBlock() )
boardBoundingBox = EDA_RECT( wxPoint( 0, 0 ), m_Parent->GetPageSizeIU() ); boardBoundingBox = EDA_RECT( wxPoint( 0, 0 ), pageSizeIU );
// In module editor, the module is located at 0,0 but for printing
// it is moved to pageSizeIU.x/2, pageSizeIU.y/2.
// So the equivalent board must be moved:
if( m_Parent->IsType( MODULE_EDITOR_FRAME_TYPE ) )
{
boardBoundingBox.Move( wxPoint( boardBoundingBox.GetWidth()/2,
boardBoundingBox.GetHeight()/2 ) );
}
wxLogTrace( tracePrinting, wxT( "Drawing bounding box: x=%d, y=%d, w=%d, h=%d" ), wxLogTrace( tracePrinting, wxT( "Drawing bounding box: x=%d, y=%d, w=%d, h=%d" ),
boardBoundingBox.GetX(), boardBoundingBox.GetY(), boardBoundingBox.GetX(), boardBoundingBox.GetY(),
...@@ -191,14 +183,23 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -191,14 +183,23 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
if( m_PrintParams.m_PrintScale == 0 ) // fit in page option if( m_PrintParams.m_PrintScale == 0 ) // fit in page option
{ {
// TODO: a better way to calculate the userscale if(boardBoundingBox.GetWidth() && boardBoundingBox.GetHeight())
userscale = 1.0; {
int margin = Millimeter2iu( 10.0 ); // add a margin around the drawings
double scaleX = (double)(pageSizeIU.x - (2 * margin)) /
boardBoundingBox.GetWidth();
double scaleY = (double)(pageSizeIU.y - (2 * margin)) /
boardBoundingBox.GetHeight();
userscale = (scaleX < scaleY) ? scaleX : scaleY;
}
else
userscale = 1.0;
} }
wxSize scaledPageSize = m_Parent->GetPageSizeIU(); wxSize scaledPageSize = pageSizeIU;
drawRect.SetSize( scaledPageSize ); drawRect.SetSize( scaledPageSize );
scaledPageSize.x = wxRound( (double) scaledPageSize.x / userscale ); scaledPageSize.x = wxRound( scaledPageSize.x / userscale );
scaledPageSize.y = wxRound( (double) scaledPageSize.y / userscale ); scaledPageSize.y = wxRound( scaledPageSize.y / userscale );
if( m_PrintParams.m_PageSetupData ) if( m_PrintParams.m_PageSetupData )
...@@ -213,12 +214,13 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -213,12 +214,13 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
// Compute Accurate scale 1 // Compute Accurate scale 1
if( m_PrintParams.m_PrintScale == 1.0 ) if( m_PrintParams.m_PrintScale == 1.0 )
{ {
// We want a 1:1 scale and margins for printing // We want a 1:1 scale, regardless the page setup
MapScreenSizeToPaper(); // like page size, margin ...
MapScreenSizeToPaper(); // set best scale and offset (scale is not used)
int w, h; int w, h;
GetPPIPrinter( &w, &h ); GetPPIPrinter( &w, &h );
double accurate_Xscale = ( (double) ( w ) ) / (IU_PER_MILS*1000); double accurate_Xscale = (double) w / (IU_PER_MILS*1000);
double accurate_Yscale = ( (double) ( h ) ) / (IU_PER_MILS*1000); double accurate_Yscale = (double) h / (IU_PER_MILS*1000);
if( IsPreview() ) // Scale must take in account the DC size in Preview if( IsPreview() ) // Scale must take in account the DC size in Preview
{ {
...@@ -226,16 +228,14 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -226,16 +228,14 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
wxSize PlotAreaSize; wxSize PlotAreaSize;
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y ); dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y );
GetPageSizePixels( &w, &h ); GetPageSizePixels( &w, &h );
accurate_Xscale *= PlotAreaSize.x; accurate_Xscale *= (double)PlotAreaSize.x / w;
accurate_Xscale /= (double) w; accurate_Yscale *= (double)PlotAreaSize.y / h;
accurate_Yscale *= PlotAreaSize.y;
accurate_Yscale /= (double) h;
} }
// Fine scale adjust
accurate_Xscale *= m_PrintParams.m_XScaleAdjust; accurate_Xscale *= m_PrintParams.m_XScaleAdjust;
accurate_Yscale *= m_PrintParams.m_YScaleAdjust; accurate_Yscale *= m_PrintParams.m_YScaleAdjust;
// Fine scale adjust // Set print scale for 1:1 exact scale
dc->SetUserScale( accurate_Xscale, accurate_Yscale ); dc->SetUserScale( accurate_Xscale, accurate_Yscale );
} }
...@@ -255,6 +255,14 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -255,6 +255,14 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
wxLogTrace( tracePrinting, wxT( "Scaled plot area in user units: x=%d, y=%d" ), wxLogTrace( tracePrinting, wxT( "Scaled plot area in user units: x=%d, y=%d" ),
PlotAreaSizeInUserUnits.x, PlotAreaSizeInUserUnits.y ); PlotAreaSizeInUserUnits.x, PlotAreaSizeInUserUnits.y );
// In module editor, the module is located at 0,0 but for printing
// it is moved to pageSizeIU.x/2, pageSizeIU.y/2.
// So the equivalent board must be moved to the center of the page:
if( m_Parent->IsType( MODULE_EDITOR_FRAME_TYPE ) )
{
boardBoundingBox.Move( wxPoint( pageSizeIU.x/2, pageSizeIU.y/2 ) );
}
// In some cases the plot origin is the centre of the board outline rather than the center // In some cases the plot origin is the centre of the board outline rather than the center
// of the selected paper size. // of the selected paper size.
if( m_PrintParams.CenterOnBoardOutline() ) if( m_PrintParams.CenterOnBoardOutline() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment