Beautification
This commit is contained in:
parent
3d73eb6823
commit
1da6b3a407
|
@ -1,4 +1,5 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Name: svg_print.cpp
|
||||
// Purpose:
|
||||
// Author: jean-pierre Charras
|
||||
|
@ -65,24 +66,26 @@ static bool Print_Sheet_Ref = TRUE;
|
|||
static int s_PlotBlackAndWhite = 0;
|
||||
|
||||
|
||||
|
||||
/*******************************************************/
|
||||
void WinEDA_DrawFrame::SVG_Print( wxCommandEvent& event )
|
||||
/*******************************************************/
|
||||
|
||||
/* Prepare les structures de donnees de gestion de l'impression
|
||||
et affiche la fenetre de dialogue de gestion de l'impression des feuilles
|
||||
* et affiche la fenetre de dialogue de gestion de l'impression des feuilles
|
||||
*/
|
||||
{
|
||||
// Arret des commandes en cours
|
||||
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
||||
{
|
||||
wxClientDC dc( DrawPanel );
|
||||
|
||||
DrawPanel->PrepareDC( dc );
|
||||
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
||||
}
|
||||
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
||||
|
||||
WinEDA_PrintSVGFrame frame( this );
|
||||
|
||||
frame.ShowModal();
|
||||
}
|
||||
|
||||
|
@ -120,9 +123,13 @@ WinEDA_PrintSVGFrame::WinEDA_PrintSVGFrame( )
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
WinEDA_PrintSVGFrame::WinEDA_PrintSVGFrame( WinEDA_DrawFrame* parent,
|
||||
wxWindowID id, const wxString& caption, const wxPoint& pos,
|
||||
const wxSize& size, long style )
|
||||
wxWindowID id,
|
||||
const wxString& caption,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style )
|
||||
{
|
||||
m_Parent = parent;
|
||||
m_ImageXSize_mm = 270;
|
||||
|
@ -136,11 +143,17 @@ WinEDA_PrintSVGFrame::WinEDA_PrintSVGFrame( WinEDA_DrawFrame* parent,
|
|||
Create( parent, id, caption, pos, size, style );
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* WinEDA_PrintSVGFrame creator
|
||||
*/
|
||||
|
||||
bool WinEDA_PrintSVGFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
bool WinEDA_PrintSVGFrame::Create( wxWindow* parent,
|
||||
wxWindowID id,
|
||||
const wxString& caption,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style )
|
||||
{
|
||||
////@begin WinEDA_PrintSVGFrame member initialisation
|
||||
m_DialogPenWidthSizer = NULL;
|
||||
|
@ -149,6 +162,7 @@ bool WinEDA_PrintSVGFrame::Create( wxWindow* parent, wxWindowID id, const wxStri
|
|||
m_PagesOption = NULL;
|
||||
m_FileNameCtrl = NULL;
|
||||
m_MessagesBox = NULL;
|
||||
|
||||
////@end WinEDA_PrintSVGFrame member initialisation
|
||||
|
||||
////@begin WinEDA_PrintSVGFrame creation
|
||||
|
@ -161,10 +175,12 @@ bool WinEDA_PrintSVGFrame::Create( wxWindow* parent, wxWindowID id, const wxStri
|
|||
GetSizer()->SetSizeHints( this );
|
||||
}
|
||||
Centre();
|
||||
|
||||
////@end WinEDA_PrintSVGFrame creation
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Control creation for WinEDA_PrintSVGFrame
|
||||
*/
|
||||
|
@ -179,73 +195,116 @@ void WinEDA_PrintSVGFrame::CreateControls()
|
|||
WinEDA_PrintSVGFrame* itemDialog1 = this;
|
||||
|
||||
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
itemDialog1->SetSizer( itemBoxSizer2 );
|
||||
|
||||
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
itemBoxSizer2->Add( itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
|
||||
|
||||
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
||||
|
||||
m_DialogPenWidthSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
itemBoxSizer4->Add( m_DialogPenWidthSizer, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
wxString m_ModeColorOptionStrings[] = {
|
||||
_( "Color" ),
|
||||
_( "Black and White" )
|
||||
};
|
||||
m_ModeColorOption = new wxRadioBox( itemDialog1, ID_RADIOBOX_SETPRINTMODE, _("Print mode"), wxDefaultPosition, wxDefaultSize, 2, m_ModeColorOptionStrings, 1, wxRA_SPECIFY_COLS );
|
||||
m_ModeColorOption = new wxRadioBox( itemDialog1, ID_RADIOBOX_SETPRINTMODE, _(
|
||||
"Print mode" ), wxDefaultPosition, wxDefaultSize, 2,
|
||||
m_ModeColorOptionStrings, 1,
|
||||
wxRA_SPECIFY_COLS );
|
||||
|
||||
m_ModeColorOption->SetSelection( 0 );
|
||||
itemBoxSizer4->Add( m_ModeColorOption, 0, wxALIGN_LEFT | wxALL, 5 );
|
||||
|
||||
m_Print_Sheet_Ref = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Print Sheet Ref"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
||||
m_Print_Sheet_Ref = new wxCheckBox( itemDialog1, ID_CHECKBOX, _(
|
||||
"Print Sheet Ref" ), wxDefaultPosition, wxDefaultSize,
|
||||
wxCHK_2STATE );
|
||||
|
||||
m_Print_Sheet_Ref->SetValue( false );
|
||||
itemBoxSizer4->Add( m_Print_Sheet_Ref, 0, wxALIGN_LEFT | wxALL, 5 );
|
||||
|
||||
itemBoxSizer3->Add( 5, 5, 0, wxALIGN_CENTER_VERTICAL | wxALL, 15 );
|
||||
|
||||
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
||||
|
||||
wxString m_PagesOptionStrings[] = {
|
||||
_( "Current" ),
|
||||
_( "All" )
|
||||
};
|
||||
m_PagesOption = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Page Print:"), wxDefaultPosition, wxDefaultSize, 2, m_PagesOptionStrings, 1, wxRA_SPECIFY_COLS );
|
||||
m_PagesOption = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _(
|
||||
"Page Print:" ), wxDefaultPosition,
|
||||
wxDefaultSize, 2, m_PagesOptionStrings, 1,
|
||||
wxRA_SPECIFY_COLS );
|
||||
|
||||
m_PagesOption->SetSelection( 0 );
|
||||
itemBoxSizer9->Add( m_PagesOption, 0, wxALIGN_LEFT | wxALL, 5 );
|
||||
|
||||
wxButton* itemButton11 = new wxButton( itemDialog1, ID_PRINT_EXECUTE, _("Create &File"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
wxButton* itemButton11 = new wxButton( itemDialog1, ID_PRINT_EXECUTE, _(
|
||||
"Create &File" ), wxDefaultPosition,
|
||||
wxDefaultSize, 0 );
|
||||
|
||||
itemButton11->SetDefault();
|
||||
itemButton11->SetForegroundColour( wxColour( 0, 128, 0 ) );
|
||||
itemBoxSizer9->Add( itemButton11, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
wxButton* itemButton12 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
wxButton* itemButton12 = new wxButton( itemDialog1, wxID_CLOSE, _(
|
||||
"&Close" ), wxDefaultPosition,
|
||||
wxDefaultSize, 0 );
|
||||
|
||||
itemButton12->SetForegroundColour( wxColour( 0, 0, 198 ) );
|
||||
itemBoxSizer9->Add( itemButton12, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemBoxSizer2->Add(itemStaticText13, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
|
||||
wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _(
|
||||
"Filename:" ), wxDefaultPosition,
|
||||
wxDefaultSize, 0 );
|
||||
|
||||
itemBoxSizer2->Add( itemStaticText13,
|
||||
0,
|
||||
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
||||
5 );
|
||||
|
||||
m_FileNameCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(
|
||||
"" ), wxDefaultPosition, wxDefaultSize,
|
||||
0 );
|
||||
|
||||
m_FileNameCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemBoxSizer2->Add( m_FileNameCtrl, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemBoxSizer2->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
|
||||
wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _(
|
||||
"Messages:" ), wxDefaultPosition,
|
||||
wxDefaultSize, 0 );
|
||||
|
||||
itemBoxSizer2->Add( itemStaticText15,
|
||||
0,
|
||||
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
||||
5 );
|
||||
|
||||
m_MessagesBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(
|
||||
"" ), wxDefaultPosition, wxSize( -1,
|
||||
100 ), wxTE_MULTILINE | wxTE_READONLY );
|
||||
|
||||
m_MessagesBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxSize(-1, 100), wxTE_MULTILINE|wxTE_READONLY );
|
||||
itemBoxSizer2->Add( m_MessagesBox, 0, wxGROW | wxALL, 5 );
|
||||
|
||||
// Set validators
|
||||
m_ModeColorOption->SetValidator( wxGenericValidator( &s_PlotBlackAndWhite ) );
|
||||
m_Print_Sheet_Ref->SetValidator( wxGenericValidator( &Print_Sheet_Ref ) );
|
||||
|
||||
////@end WinEDA_PrintSVGFrame content construction
|
||||
|
||||
m_DialogPenWidth = new WinEDA_ValueCtrl(this, _("Pen width mini"), s_SVGPenMinWidth,
|
||||
g_UnitMetric, m_DialogPenWidthSizer, m_Parent->m_InternalUnits);
|
||||
|
||||
m_DialogPenWidth = new WinEDA_ValueCtrl( this, _(
|
||||
"Pen width mini" ), s_SVGPenMinWidth,
|
||||
g_UnitMetric, m_DialogPenWidthSizer,
|
||||
m_Parent->m_InternalUnits );
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Should we show tooltips?
|
||||
*/
|
||||
|
@ -255,6 +314,7 @@ bool WinEDA_PrintSVGFrame::ShowToolTips()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
@ -265,9 +325,11 @@ wxBitmap WinEDA_PrintSVGFrame::GetBitmapResource( const wxString& name )
|
|||
////@begin WinEDA_PrintSVGFrame bitmap retrieval
|
||||
wxUnusedVar( name );
|
||||
return wxNullBitmap;
|
||||
|
||||
////@end WinEDA_PrintSVGFrame bitmap retrieval
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Get icon resources
|
||||
*/
|
||||
|
@ -278,6 +340,7 @@ wxIcon WinEDA_PrintSVGFrame::GetIconResource( const wxString& name )
|
|||
////@begin WinEDA_PrintSVGFrame icon retrieval
|
||||
wxUnusedVar( name );
|
||||
return wxNullIcon;
|
||||
|
||||
////@end WinEDA_PrintSVGFrame icon retrieval
|
||||
}
|
||||
|
||||
|
@ -299,22 +362,25 @@ void WinEDA_PrintSVGFrame::SetPenWidth()
|
|||
/********************************************/
|
||||
{
|
||||
s_SVGPenMinWidth = m_DialogPenWidth->GetValue();
|
||||
|
||||
if( s_SVGPenMinWidth > WIDTH_MAX_VALUE )
|
||||
{
|
||||
s_SVGPenMinWidth = WIDTH_MAX_VALUE;
|
||||
}
|
||||
|
||||
if( s_SVGPenMinWidth < WIDTH_MIN_VALUE )
|
||||
{
|
||||
s_SVGPenMinWidth = WIDTH_MIN_VALUE;
|
||||
}
|
||||
|
||||
m_DialogPenWidth->SetValue( s_SVGPenMinWidth );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************/
|
||||
void WinEDA_PrintSVGFrame::PrintSVGDoc( wxCommandEvent& event )
|
||||
/**************************************************************/
|
||||
|
||||
/* Called on activate "Print CURRENT" button
|
||||
*/
|
||||
{
|
||||
|
@ -335,7 +401,9 @@ BASE_SCREEN * screen = m_Parent->GetScreen();
|
|||
BASE_SCREEN* oldscreen = screen;
|
||||
#ifndef EESCHEMA
|
||||
if( Select_PrintAll )
|
||||
while ( screen->Pback ) screen = (BASE_SCREEN *) screen->Pback;
|
||||
while( screen->Pback )
|
||||
screen = (BASE_SCREEN*) screen->Pback;
|
||||
|
||||
#endif
|
||||
|
||||
if( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) )
|
||||
|
@ -344,10 +412,12 @@ BASE_SCREEN *oldscreen = screen;
|
|||
{
|
||||
m_PrintMaskLayer = 0xFFFFFFFF;
|
||||
}
|
||||
else m_PrintMaskLayer = 1;
|
||||
else
|
||||
m_PrintMaskLayer = 1;
|
||||
}
|
||||
|
||||
if (screen == NULL) return;
|
||||
if( screen == NULL )
|
||||
return;
|
||||
|
||||
#ifdef EESCHEMA
|
||||
if( Select_PrintAll && m_Parent->m_Ident == SCHEMATIC_FRAME )
|
||||
|
@ -362,7 +432,8 @@ BASE_SCREEN *oldscreen = screen;
|
|||
ChangeFileNameExt( FullFileName, wxT( ".svg" ) );
|
||||
bool success = DrawPage( FullFileName, schscreen );
|
||||
msg = _( "Create file " ) + FullFileName;
|
||||
if ( ! success ) msg += _(" error");
|
||||
if( !success )
|
||||
msg += _( " error" );
|
||||
msg += wxT( "\n" );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
}
|
||||
|
@ -371,24 +442,28 @@ BASE_SCREEN *oldscreen = screen;
|
|||
#endif
|
||||
{
|
||||
wxString FullFileName = m_FileNameCtrl->GetValue();
|
||||
if ( FullFileName.IsEmpty() ){
|
||||
if( FullFileName.IsEmpty() )
|
||||
{
|
||||
FullFileName = screen->m_FileName;
|
||||
ChangeFileNameExt( FullFileName, wxT( ".svg" ) );
|
||||
}
|
||||
bool success = DrawPage( FullFileName, screen );
|
||||
msg = _( "Create file " ) + FullFileName;
|
||||
if ( ! success ) msg += _(" error");
|
||||
if( !success )
|
||||
msg += _( " error" );
|
||||
msg += wxT( "\n" );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
}
|
||||
ActiveScreen = oldscreen;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
bool WinEDA_PrintSVGFrame::DrawPage( const wxString& FullFileName, BASE_SCREEN* screen )
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
Routine effective d'impression
|
||||
* Routine effective d'impression
|
||||
*/
|
||||
{
|
||||
int tmpzoom;
|
||||
|
@ -420,7 +495,6 @@ wxSVGFileDC dc(FullFileName, SheetSize.x, SheetSize.y, dpi) ;
|
|||
DisplayError( this, wxT( "SVGprint error: wxSVGFileDC not OK" ) );
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
EDA_Rect tmp = panel->m_ClipBox;
|
||||
|
@ -452,6 +526,7 @@ wxSVGFileDC dc(FullFileName, SheetSize.x, SheetSize.y, dpi) ;
|
|||
return success;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_EXECUTE
|
||||
*/
|
||||
|
@ -461,6 +536,7 @@ void WinEDA_PrintSVGFrame::OnPrintExecuteClick( wxCommandEvent& event )
|
|||
PrintSVGDoc( event );
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
|
||||
*/
|
||||
|
@ -478,6 +554,7 @@ void WinEDA_PrintSVGFrame::OnCloseClick( wxCommandEvent& event )
|
|||
void WinEDA_PrintSVGFrame::OnCloseWindow( wxCloseEvent& event )
|
||||
{
|
||||
wxConfig* Config = m_Parent->m_Parent->m_EDA_Config;
|
||||
|
||||
if( Config )
|
||||
{
|
||||
s_PlotBlackAndWhite = m_ModeColorOption->GetSelection();
|
||||
|
@ -488,8 +565,6 @@ void WinEDA_PrintSVGFrame::OnCloseWindow( wxCloseEvent& event )
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SETPRINTMODE
|
||||
*/
|
||||
|
@ -499,5 +574,3 @@ void WinEDA_PrintSVGFrame::OnRadioboxSetprintmodeSelected( wxCommandEvent& event
|
|||
s_PlotBlackAndWhite = m_ModeColorOption->GetSelection();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue