make SVG print dialog consistent with print dialog and layers orders in layer manager

This commit is contained in:
charras 2010-03-26 17:18:59 +00:00
parent 5850736ccc
commit ed3dbe8b72
4 changed files with 51 additions and 27 deletions

View File

@ -49,7 +49,7 @@ public:
private:
void OnCloseWindow( wxCloseEvent& event );
void OnInitDialog( wxInitDialogEvent& event );
void initDialog( );
void OnButtonPrintSelectedClick( wxCommandEvent& event );
void OnButtonPrintBoardClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event );
@ -80,10 +80,13 @@ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent ) :
{
m_Parent = (WinEDA_BasePcbFrame*) parent;
m_Config = wxGetApp().m_EDA_Config;
initDialog( );
GetSizer()->SetSizeHints( this );
Centre();
}
void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
void DIALOG_SVG_PRINT::initDialog( )
{
SetFocus(); // Make ESC key working
@ -103,12 +106,29 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
// Create layers list
BOARD* board = m_Parent->GetBoard();
int mask = 1;
for( int layer = 0; layer<NB_LAYERS; layer++, mask <<= 1 )
int layer;
for( layer = 0; layer < NB_LAYERS; ++layer )
{
m_BoxSelectLayer[layer] =
new wxCheckBox( this, -1, board->GetLayerName( layer ) );
if( !board->IsLayerEnabled( layer ) )
m_BoxSelectLayer[layer] = NULL;
else
m_BoxSelectLayer[layer] =
new wxCheckBox( this, -1, board->GetLayerName( layer ) );
}
// Add wxCheckBoxes in layers lists dialog
// List layers in same order than in setup layers dialog
// (Front or Top to Back or Bottom)
DECLARE_LAYERS_ORDER_LIST(layersOrder);
for( int layer_idx = 0; layer_idx < NB_LAYERS; ++layer_idx )
{
layer = layersOrder[layer_idx];
wxASSERT(layer < NB_LAYERS);
if( m_BoxSelectLayer[layer] == NULL )
continue;
long mask = 1 << layer;
if( mask & s_SelectedLayers )
m_BoxSelectLayer[layer]->SetValue( true );
@ -131,18 +151,14 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
for( int layer = 0; layer<NB_LAYERS; ++layer )
{
bool option;
if ( m_BoxSelectLayer[layer] == NULL )
continue;
layerKey.Printf( OPTKEY_LAYERBASE, layer );
if( m_Config->Read( layerKey, &option ) )
m_BoxSelectLayer[layer]->SetValue( option );
}
}
if( GetSizer() )
{
GetSizer()->SetSizeHints( this );
}
}
@ -179,9 +195,19 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref )
if( aPrintAll )
m_PrintMaskLayer = 0xFFFFFFFF;
else
m_PrintMaskLayer = 0;
if( m_PrintBoardEdgesCtrl->IsChecked() )
m_PrintMaskLayer |= EDGE_LAYER;
else
m_PrintMaskLayer &= ~EDGE_LAYER;
for( int layer = 0; layer<NB_LAYERS; layer++ )
{
if ( m_BoxSelectLayer[layer] == NULL )
continue;
if( !aPrintAll && !m_BoxSelectLayer[layer]->GetValue() )
continue;
@ -253,7 +279,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
GRResetPenAndBrush( &dc );
s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth,
m_Parent->m_InternalUnits );
GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? FALSE : true );
GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? false : true );
s_Parameters.m_DrillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE;
@ -263,14 +289,13 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
screen->m_IsPrinting = true;
SetLocaleTo_C_standard(); // Switch the locale to standard C (needed
// to print floating point numbers like
// 1.3)
// to print floating point numbers like 1.3)
m_Parent->PrintPage( &dc, aPrint_Frame_Ref, m_PrintMaskLayer, false, &s_Parameters);
SetLocaleTo_Default(); // revert to the current locale
screen->m_IsPrinting = false;
panel->m_ClipBox = tmp;
GRForceBlackPen( FALSE );
GRForceBlackPen( false );
screen->m_StartVisu = tmp_startvisu;
screen->m_DrawOrg = old_org;
@ -308,8 +333,10 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
{
m_Config->Write( PLOTSVGMODECOLOR_KEY, s_Parameters.m_Print_Black_and_White );
wxString layerKey;
for( int layer = 0; layer<NB_LAYERS; ++layer )
for( int layer = 0; layer<NB_LAYERS; ++layer )
{
if( m_BoxSelectLayer[layer] == NULL )
continue;
layerKey.Printf( OPTKEY_LAYERBASE, layer );
m_Config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() );
}

View File

@ -72,13 +72,13 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
bButtonsSizer = new wxBoxSizer( wxVERTICAL );
m_buttonPrintSelected = new wxButton( this, wxID_PRINT_CURRENT, _("Print Selected"), wxDefaultPosition, wxDefaultSize, 0 );
bButtonsSizer->Add( m_buttonPrintSelected, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
bButtonsSizer->Add( m_buttonPrintSelected, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonBoard = new wxButton( this, wxID_PRINT_BOARD, _("Print Board"), wxDefaultPosition, wxDefaultSize, 0 );
bButtonsSizer->Add( m_buttonBoard, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
bButtonsSizer->Add( m_buttonBoard, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Quit"), wxDefaultPosition, wxDefaultSize, 0 );
bButtonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
bButtonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
bUpperSizer->Add( bButtonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
@ -108,7 +108,6 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) );
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SVG_PRINT_base::OnInitDialog ) );
m_ModeColorOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnSetColorModeSelected ), NULL, this );
m_buttonPrintSelected->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintSelectedClick ), NULL, this );
m_buttonBoard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintBoardClick ), NULL, this );
@ -119,7 +118,6 @@ DIALOG_SVG_PRINT_base::~DIALOG_SVG_PRINT_base()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) );
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SVG_PRINT_base::OnInitDialog ) );
m_ModeColorOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnSetColorModeSelected ), NULL, this );
m_buttonPrintSelected->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintSelectedClick ), NULL, this );
m_buttonBoard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintBoardClick ), NULL, this );

View File

@ -49,7 +49,7 @@
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnInitDialog">OnInitDialog</event>
<event name="OnInitDialog"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
@ -415,7 +415,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
@ -467,7 +467,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
@ -519,7 +519,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>

View File

@ -57,7 +57,6 @@ class DIALOG_SVG_PRINT_base : public wxDialog
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); }
virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); }
virtual void OnSetColorModeSelected( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonPrintSelectedClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonPrintBoardClick( wxCommandEvent& event ){ event.Skip(); }