kicad/share/dialog_print.cpp

333 lines
10 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: dialog_print.cpp
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 28/02/2006 18:30:16
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 28/02/2006 18:30:16
////@begin includes
////@end includes
#include "dialog_print.h"
////@begin XPM images
////@end XPM images
/*!
* WinEDA_PrintFrame type definition
*/
IMPLEMENT_DYNAMIC_CLASS( WinEDA_PrintFrame, wxDialog )
/*!
* WinEDA_PrintFrame event table definition
*/
BEGIN_EVENT_TABLE( WinEDA_PrintFrame, wxDialog )
////@begin WinEDA_PrintFrame event table entries
EVT_RADIOBOX( ID_SET_PRINT_SCALE, WinEDA_PrintFrame::OnSetPrintScaleSelected )
EVT_RADIOBOX( ID_SET_BW, WinEDA_PrintFrame::OnSetBwSelected )
EVT_BUTTON( ID_PRINT_SETUP, WinEDA_PrintFrame::OnPrintSetupClick )
EVT_BUTTON( ID_PRINT_PREVIEW, WinEDA_PrintFrame::OnPrintPreviewClick )
EVT_BUTTON( ID_PRINT_EXECUTE, WinEDA_PrintFrame::OnPrintExecuteClick )
EVT_BUTTON( wxID_CLOSE, WinEDA_PrintFrame::OnCloseClick )
////@end WinEDA_PrintFrame event table entries
END_EVENT_TABLE()
/*!
* WinEDA_PrintFrame constructors
*/
WinEDA_PrintFrame::WinEDA_PrintFrame( )
{
}
WinEDA_PrintFrame::WinEDA_PrintFrame( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
m_Parent = parent;
m_XScaleAdjust = m_YScaleAdjust = 1.0;
m_PagesOption = NULL;
wxConfig * Config = m_Parent->m_Parent->m_EDA_Config;
if ( Config )
{
Config->Read(wxT("PrintPenWidth"), &s_PrintPenMinWidth);
}
Create(parent, id, caption, pos, size, style);
}
/*!
* WinEDA_PrintFrame creator
*/
bool WinEDA_PrintFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin WinEDA_PrintFrame member initialisation
m_CopperLayersBoxSizer = NULL;
m_TechLayersBoxSizer = NULL;
m_ScaleOption = NULL;
m_FineAdjustXscaleTitle = NULL;
m_FineAdjustXscaleOpt = NULL;
m_FineAdjustYscaleTitle = NULL;
m_FineAdjustYscaleOpt = NULL;
m_DialogPenWidthSizer = NULL;
m_Print_Sheet_Ref = NULL;
m_Print_Mirror = NULL;
m_ColorOption = NULL;
m_PagesOptionPcb = NULL;
m_PagesOptionEeschema = NULL;
////@end WinEDA_PrintFrame member initialisation
////@begin WinEDA_PrintFrame creation
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
if (GetSizer())
{
GetSizer()->SetSizeHints(this);
}
Centre();
////@end WinEDA_PrintFrame creation
return true;
}
/*!
* Control creation for WinEDA_PrintFrame
*/
void WinEDA_PrintFrame::CreateControls()
{
SetFont(*g_DialogFont);
////@begin WinEDA_PrintFrame content construction
// Generated by DialogBlocks, 24/01/2007 16:36:31 (unregistered)
WinEDA_PrintFrame* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
itemDialog1->SetSizer(itemBoxSizer2);
m_CopperLayersBoxSizer = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(m_CopperLayersBoxSizer, 0, wxALIGN_TOP|wxALL, 5);
m_TechLayersBoxSizer = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(m_TechLayersBoxSizer, 0, wxALIGN_TOP|wxALL, 5);
wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer5, 0, wxGROW|wxALL, 5);
wxString m_ScaleOptionStrings[] = {
_("fit in page"),
_("Scale 0.5"),
_("Scale 0.7"),
_("Approx. Scale 1"),
_("Accurate Scale 1"),
_("Scale 1.4"),
_("Scale 2"),
_("Scale 3"),
_("Scale 4")
};
m_ScaleOption = new wxRadioBox( itemDialog1, ID_SET_PRINT_SCALE, _("Approx. Scale:"), wxDefaultPosition, wxDefaultSize, 9, m_ScaleOptionStrings, 1, wxRA_SPECIFY_COLS );
m_ScaleOption->SetSelection(0);
itemBoxSizer5->Add(m_ScaleOption, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
m_FineAdjustXscaleTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("X Scale Adjust"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer5->Add(m_FineAdjustXscaleTitle, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_FineAdjustXscaleOpt = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer5->Add(m_FineAdjustXscaleOpt, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_FineAdjustYscaleTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Y Scale Adjust"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer5->Add(m_FineAdjustYscaleTitle, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_FineAdjustYscaleOpt = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer5->Add(m_FineAdjustYscaleOpt, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer12, 0, wxGROW|wxALL, 5);
wxStaticBox* itemStaticBoxSizer13Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options:"));
wxStaticBoxSizer* itemStaticBoxSizer13 = new wxStaticBoxSizer(itemStaticBoxSizer13Static, wxVERTICAL);
itemBoxSizer12->Add(itemStaticBoxSizer13, 0, wxGROW|wxALL, 5);
m_DialogPenWidthSizer = new wxBoxSizer(wxVERTICAL);
itemStaticBoxSizer13->Add(m_DialogPenWidthSizer, 0, wxGROW|wxALL, 5);
m_Print_Sheet_Ref = new wxCheckBox( itemDialog1, ID_PRINT_REF, _("Print Sheet Ref"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_Print_Sheet_Ref->SetValue(false);
itemStaticBoxSizer13->Add(m_Print_Sheet_Ref, 0, wxGROW|wxALL, 5);
m_Print_Mirror = new wxCheckBox( itemDialog1, ID_CHECK_PRINT_MIROR, _("Mirror"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_Print_Mirror->SetValue(false);
itemStaticBoxSizer13->Add(m_Print_Mirror, 0, wxGROW|wxALL, 5);
wxString m_ColorOptionStrings[] = {
_("Color"),
_("Black")
};
m_ColorOption = new wxRadioBox( itemDialog1, ID_SET_BW, _("Color Print:"), wxDefaultPosition, wxDefaultSize, 2, m_ColorOptionStrings, 1, wxRA_SPECIFY_COLS );
m_ColorOption->SetSelection(0);
itemBoxSizer12->Add(m_ColorOption, 0, wxGROW|wxALL, 5);
wxString m_PagesOptionPcbStrings[] = {
_("1 page per layer"),
_("Single Page")
};
m_PagesOptionPcb = new wxRadioBox( itemDialog1, ID_PRINT_ALL_IN_ONE, _("Page Print:"), wxDefaultPosition, wxDefaultSize, 2, m_PagesOptionPcbStrings, 1, wxRA_SPECIFY_COLS );
m_PagesOptionPcb->SetSelection(0);
itemBoxSizer12->Add(m_PagesOptionPcb, 0, wxGROW|wxALL, 5);
wxString m_PagesOptionEeschemaStrings[] = {
_("Current"),
_("All")
};
m_PagesOptionEeschema = new wxRadioBox( itemDialog1, ID_PRINT_ALL, _("Page Print:"), wxDefaultPosition, wxDefaultSize, 2, m_PagesOptionEeschemaStrings, 1, wxRA_SPECIFY_COLS );
m_PagesOptionEeschema->SetSelection(0);
itemBoxSizer12->Add(m_PagesOptionEeschema, 0, wxGROW|wxALL, 5);
itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer21 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer21, 0, wxALIGN_TOP|wxALL, 5);
itemBoxSizer21->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxButton* itemButton23 = new wxButton( itemDialog1, ID_PRINT_SETUP, _("Print S&etup"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton23->SetForegroundColour(wxColour(121, 118, 0));
itemBoxSizer21->Add(itemButton23, 0, wxGROW|wxALL, 5);
wxButton* itemButton24 = new wxButton( itemDialog1, ID_PRINT_PREVIEW, _("Pre&view"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton24->SetForegroundColour(wxColour(0, 0, 196));
itemBoxSizer21->Add(itemButton24, 0, wxGROW|wxALL, 5);
wxButton* itemButton25 = new wxButton( itemDialog1, ID_PRINT_EXECUTE, _("&Print"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton25->SetForegroundColour(wxColour(0, 128, 64));
itemBoxSizer21->Add(itemButton25, 0, wxGROW|wxALL, 5);
wxButton* itemButton26 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer21->Add(itemButton26, 0, wxGROW|wxALL, 5);
// Set validators
m_ScaleOption->SetValidator( wxGenericValidator(& s_Scale_Select) );
m_Print_Sheet_Ref->SetValidator( wxGenericValidator(& s_Print_Sheet_Ref) );
m_Print_Mirror->SetValidator( wxGenericValidator(& s_PrintMirror) );
m_PagesOptionPcb->SetValidator( wxGenericValidator(& s_OptionPrintPage) );
m_PagesOptionEeschema->SetValidator( wxGenericValidator(& s_OptionPrintPage) );
////@end WinEDA_PrintFrame content construction
m_DialogPenWidth = new WinEDA_ValueCtrl(this, _("Pen width mini"), s_PrintPenMinWidth,
g_UnitMetric, m_DialogPenWidthSizer, m_Parent->m_InternalUnits);
SetOthersDatas();
}
/*!
* Should we show tooltips?
*/
bool WinEDA_PrintFrame::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap WinEDA_PrintFrame::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WinEDA_PrintFrame bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end WinEDA_PrintFrame bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon WinEDA_PrintFrame::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WinEDA_PrintFrame icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end WinEDA_PrintFrame icon retrieval
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_SETUP
*/
void WinEDA_PrintFrame::OnPrintSetupClick( wxCommandEvent& event )
{
OnPrintSetup(event);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_PREVIEW
*/
void WinEDA_PrintFrame::OnPrintPreviewClick( wxCommandEvent& event )
{
OnPrintPreview(event);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_EXECUTE
*/
void WinEDA_PrintFrame::OnPrintExecuteClick( wxCommandEvent& event )
{
EDA_PrintPage(event);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
*/
void WinEDA_PrintFrame::OnCloseClick( wxCommandEvent& event )
{
OnClosePrintDialog();
}
/*!
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SET_PRINT_SCALE
*/
void WinEDA_PrintFrame::OnSetPrintScaleSelected( wxCommandEvent& event )
{
SetScale(event);
}
/*!
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SET_BW
*/
void WinEDA_PrintFrame::OnSetBwSelected( wxCommandEvent& event )
{
SetColorOrBlack(event);
}