Commit 45021493 authored by Dick Hollenbeck's avatar Dick Hollenbeck

switch to comboboxes on page size dialogs, fix PLUGIN header

parents 286c62d8 2c84a28f
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -29,22 +30,28 @@ const wxString PAGE_INFO::Custom( wxT( "User" ) );
// Standard page sizes in mils, all constants
#if defined(KICAD_GOST)
const PAGE_INFO PAGE_INFO::pageA4( wxSize( 8283, 11700 ), wxT( "A4" ) );
const PAGE_INFO PAGE_INFO::pageA4( wxSize( 8268, 11700 ), wxT( "A4" ) );
#else
const PAGE_INFO PAGE_INFO::pageA4( wxSize( 11700, 8267 ), wxT( "A4" ) );
const PAGE_INFO PAGE_INFO::pageA4( wxSize( 11700, 8268 ), wxT( "A4" ) );
#endif
const PAGE_INFO PAGE_INFO::pageA3( wxSize( 16535, 11700 ), wxT( "A3" ) );
const PAGE_INFO PAGE_INFO::pageA2( wxSize( 23400, 16535 ), wxT( "A2" ) );
const PAGE_INFO PAGE_INFO::pageA1( wxSize( 33070, 23400 ), wxT( "A1" ) );
const PAGE_INFO PAGE_INFO::pageA0( wxSize( 46800, 33070 ), wxT( "A0" ) );
const PAGE_INFO PAGE_INFO::pageA( wxSize( 11000, 8500 ), wxT( "A" ) );
const PAGE_INFO PAGE_INFO::pageB( wxSize( 17000, 11000 ), wxT( "B" ) );
const PAGE_INFO PAGE_INFO::pageC( wxSize( 22000, 17000 ), wxT( "C" ) );
const PAGE_INFO PAGE_INFO::pageD( wxSize( 34000, 22000 ), wxT( "D" ) );
const PAGE_INFO PAGE_INFO::pageE( wxSize( 44000, 34000 ), wxT( "E" ) );
const PAGE_INFO PAGE_INFO::pageGERBER(wxSize( 32000, 32000 ), wxT( "GERBER" ) );
const PAGE_INFO PAGE_INFO::pageUser( wxSize( 17000, 11000 ), Custom );
const PAGE_INFO PAGE_INFO::pageA3( wxSize( 16535, 11700 ), wxT( "A3" ) );
const PAGE_INFO PAGE_INFO::pageA2( wxSize( 23400, 16535 ), wxT( "A2" ) );
const PAGE_INFO PAGE_INFO::pageA1( wxSize( 33070, 23400 ), wxT( "A1" ) );
const PAGE_INFO PAGE_INFO::pageA0( wxSize( 46800, 33070 ), wxT( "A0" ) );
const PAGE_INFO PAGE_INFO::pageA( wxSize( 11000, 8500 ), wxT( "A" ) );
const PAGE_INFO PAGE_INFO::pageB( wxSize( 17000, 11000 ), wxT( "B" ) );
const PAGE_INFO PAGE_INFO::pageC( wxSize( 22000, 17000 ), wxT( "C" ) );
const PAGE_INFO PAGE_INFO::pageD( wxSize( 34000, 22000 ), wxT( "D" ) );
const PAGE_INFO PAGE_INFO::pageE( wxSize( 44000, 34000 ), wxT( "E" ) );
const PAGE_INFO PAGE_INFO::pageGERBER( wxSize( 32000, 32000 ), wxT( "GERBER" ) );
const PAGE_INFO PAGE_INFO::pageUser( wxSize( 17000, 11000 ), Custom );
// US paper sizes
const PAGE_INFO PAGE_INFO::pageUSLetter( wxSize( 11000, 8500 ), wxT( "USLetter" ) );
const PAGE_INFO PAGE_INFO::pageUSLegal( wxSize( 14000, 8500 ), wxT( "USLegal" ) );
const PAGE_INFO PAGE_INFO::pageUSLedger( wxSize( 17000, 11000 ), wxT( "USLedger" ) );
// Custom paper size for next instantiation of type "User"
int PAGE_INFO::s_user_width = 17000;
int PAGE_INFO::s_user_height = 11000;
......@@ -65,6 +72,9 @@ wxArrayString PAGE_INFO::GetStandardSizes()
&pageD,
&pageE,
// &pageGERBER, // standard?
&pageUSLetter,
&pageUSLegal,
&pageUSLedger,
&pageUser,
};
......@@ -122,6 +132,12 @@ bool PAGE_INFO::SetType( const wxString& aType )
*this = pageE;
else if( aType == pageGERBER.GetType() )
*this = pageGERBER;
else if( aType == pageUSLetter.GetType() )
*this = pageUSLetter;
else if( aType == pageUSLegal.GetType() )
*this = pageUSLegal;
else if( aType == pageUSLedger.GetType() )
*this = pageUSLedger;
else if( aType == pageUser.GetType() )
{
// pageUser is const, and may not and does not hold the custom size,
......@@ -201,4 +217,3 @@ void PAGE_INFO::SetHeightMils( int aHeightInMils )
{
m_size.y = clampHeight( aHeightInMils );
}
......@@ -75,12 +75,14 @@ void DIALOG_PAGES_SETTINGS::initDialog()
const PAGE_INFO& pageInfo = m_Parent->GetPageSettings();
if( !pageInfo.IsCustom() )
m_landscapeCheckbox->SetValue( !pageInfo.IsPortrait() );
m_orientationComboBox->SetSelection( pageInfo.IsPortrait() );
setCurrentPageSizeSelection( pageInfo.GetType() );
// only a click fires the radiobutton selected event, so have to fabricate this check
onRadioButtonSelected();
// only a click fires the selection changed event, so have to fabricate this check
wxCommandEvent junk;
onPaperSizeChoice( junk );
switch( g_UserUnit )
{
......@@ -175,25 +177,19 @@ void DIALOG_PAGES_SETTINGS::OnCancelClick( wxCommandEvent& event )
}
void DIALOG_PAGES_SETTINGS::onRadioButtonSelected()
void DIALOG_PAGES_SETTINGS::onPaperSizeChoice( wxCommandEvent& event )
{
if( PAGE_INFO::Custom == m_PageSizeBox->GetStringSelection() )
if( m_paperSizeComboBox->GetStringSelection().Contains( PAGE_INFO::Custom ) )
{
m_landscapeCheckbox->Enable( false );
m_orientationComboBox->Enable( false );
}
else
{
m_landscapeCheckbox->Enable( true );
m_orientationComboBox->Enable( true );
}
}
void DIALOG_PAGES_SETTINGS::onRadioButtonSelected( wxCommandEvent& event )
{
onRadioButtonSelected(); // no event arg
}
void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
{
wxString msg;
......@@ -238,19 +234,27 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
*/
}
int radioSelection = m_PageSizeBox->GetSelection();
if( radioSelection < 0 )
radioSelection = 0;
// wxFormBuilder must use "A4", "A3", etc for choices, in all languages/translations
wxString paperType = m_PageSizeBox->GetString( radioSelection );
wxString paperType = m_paperSizeComboBox->GetStringSelection();
// construct pageInfo _after_ user settings have been established in case the
// paperType is custom, otherwise User width and height will not go into effect right away.
PAGE_INFO pageInfo( paperType );
PAGE_INFO pageInfo;
if( paperType.Contains( PAGE_INFO::Custom ) )
{
pageInfo.SetType( PAGE_INFO::Custom );
}
else
{
pageInfo.SetPortrait( m_orientationComboBox->GetSelection() );
if( PAGE_INFO::Custom != paperType )
pageInfo.SetPortrait( !m_landscapeCheckbox->IsChecked() );
// here we assume translators will keep original paper size spellings
if( !pageInfo.SetType( paperType ) )
{
wxASSERT_MSG( FALSE, wxT( "the translation for paper size must preserve original spellings" ) );
}
}
m_Parent->SetPageSettings( pageInfo );
......@@ -305,19 +309,19 @@ void DIALOG_PAGES_SETTINGS::setCurrentPageSizeSelection( const wxString& aPaperS
// use wxFormBuilder to store the sheet type in the wxRadioButton's label
// i.e. "A4", "A3", etc, anywhere within the text of the label.
D(printf("m_PageSizeBox->GetCount() = %d\n", (int) m_PageSizeBox->GetCount() );)
D(printf("m_paperSizeComboBox->GetCount() = %d\n", (int) m_paperSizeComboBox->GetCount() );)
// search all the child wxRadioButtons for a label containing our paper type
for( unsigned i = 0; i < m_PageSizeBox->GetCount(); ++i )
for( unsigned i = 0; i < m_paperSizeComboBox->GetCount(); ++i )
{
// parse each label looking for aPaperSize within it
wxStringTokenizer st( m_PageSizeBox->GetString( i ) );
wxStringTokenizer st( m_paperSizeComboBox->GetString( i ) );
while( st.HasMoreTokens() )
{
if( st.GetNextToken() == aPaperSize )
{
m_PageSizeBox->SetSelection( i );
m_paperSizeComboBox->SetSelection( i );
return;
}
}
......
......@@ -36,14 +36,11 @@ private:
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
void OnCancelClick( wxCommandEvent& event );
/// wxEVT_COMMAND_RADIOBOX_SELECTED
void onRadioButtonSelected( wxCommandEvent& event );
void setCurrentPageSizeSelection( const wxString& aPaperSize );
void SavePageSettings(wxCommandEvent& event);
void ReturnSizeSelected(wxCommandEvent& event);
void onRadioButtonSelected();
void onPaperSizeChoice( wxCommandEvent& event );
};
#endif // _DIALOG_PAGES_SETTINGS_H_
......@@ -21,62 +21,62 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
wxFlexGridSizer* LeftColumnSizer;
LeftColumnSizer = new wxFlexGridSizer( 6, 1, 0, 0 );
LeftColumnSizer->AddGrowableRow( 0 );
LeftColumnSizer->AddGrowableRow( 1 );
LeftColumnSizer->AddGrowableRow( 3 );
LeftColumnSizer->AddGrowableRow( 4 );
LeftColumnSizer->AddGrowableRow( 5 );
LeftColumnSizer->AddGrowableRow( 2 );
LeftColumnSizer->SetFlexibleDirection( wxBOTH );
LeftColumnSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxString m_PageSizeBoxChoices[] = { _("A4"), _("A3"), _("A2"), _("A1"), _("A0"), _("A"), _("B"), _("C"), _("D"), _("E"), _("User") };
int m_PageSizeBoxNChoices = sizeof( m_PageSizeBoxChoices ) / sizeof( wxString );
m_PageSizeBox = new wxRadioBox( this, wxID_ANY, _("Page Size:"), wxDefaultPosition, wxDefaultSize, m_PageSizeBoxNChoices, m_PageSizeBoxChoices, 1, wxRA_SPECIFY_COLS );
m_PageSizeBox->SetSelection( 9 );
LeftColumnSizer->Add( m_PageSizeBox, 0, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer9;
sbSizer9 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Paper Size:") ), wxVERTICAL );
wxString m_paperSizeComboBoxChoices[] = { _("A4"), _("A3"), _("A2"), _("A1"), _("A0"), _("A"), _("B"), _("C"), _("D"), _("E"), _("USLetter"), _("USLegal"), _("USLedger"), _("User (Custom)") };
int m_paperSizeComboBoxNChoices = sizeof( m_paperSizeComboBoxChoices ) / sizeof( wxString );
m_paperSizeComboBox = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_paperSizeComboBoxNChoices, m_paperSizeComboBoxChoices, 0 );
m_paperSizeComboBox->SetSelection( 0 );
sbSizer9->Add( m_paperSizeComboBox, 0, wxALL|wxEXPAND, 5 );
LeftColumnSizer->Add( 5, 0, 1, wxEXPAND, 5 );
LeftColumnSizer->Add( sbSizer9, 0, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer8;
sbSizer8 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Orientation:") ), wxVERTICAL );
m_landscapeCheckbox = new wxCheckBox( this, wxID_ANY, _("Landscape"), wxDefaultPosition, wxDefaultSize, 0 );
m_landscapeCheckbox->SetValue(true);
m_landscapeCheckbox->SetToolTip( _("Check for landscape, uncheck for portrait") );
wxString m_orientationComboBoxChoices[] = { _("Landscape"), _("Portrait") };
int m_orientationComboBoxNChoices = sizeof( m_orientationComboBoxChoices ) / sizeof( wxString );
m_orientationComboBox = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_orientationComboBoxNChoices, m_orientationComboBoxChoices, 0 );
m_orientationComboBox->SetSelection( 0 );
sbSizer8->Add( m_orientationComboBox, 0, wxALL|wxEXPAND, 5 );
sbSizer8->Add( m_landscapeCheckbox, 0, wxALL|wxEXPAND, 5 );
LeftColumnSizer->Add( sbSizer8, 0, wxALL|wxEXPAND, 5 );
LeftColumnSizer->Add( sbSizer8, 1, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer10;
sbSizer10 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Custom Page Size:") ), wxVERTICAL );
wxBoxSizer* bSizerXsize;
bSizerXsize = new wxBoxSizer( wxVERTICAL );
UserPageSizeX = new wxStaticText( this, wxID_ANY, _("User Page Size X: "), wxDefaultPosition, wxDefaultSize, 0 );
UserPageSizeX = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
UserPageSizeX->Wrap( -1 );
bSizerXsize->Add( UserPageSizeX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TextUserSizeX = new wxTextCtrl( this, ID_TEXTCTRL_USER_PAGE_SIZE_X, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerXsize->Add( m_TextUserSizeX, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerXsize->Add( m_TextUserSizeX, 0, wxALIGN_LEFT|wxALIGN_TOP|wxALL|wxEXPAND, 5 );
LeftColumnSizer->Add( bSizerXsize, 1, wxEXPAND, 5 );
sbSizer10->Add( bSizerXsize, 1, wxALIGN_TOP|wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizerYsize;
bSizerYsize = new wxBoxSizer( wxVERTICAL );
UserPageSizeY = new wxStaticText( this, wxID_ANY, _("User Page Size Y: "), wxDefaultPosition, wxDefaultSize, 0 );
UserPageSizeY = new wxStaticText( this, wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 );
UserPageSizeY->Wrap( -1 );
bSizerYsize->Add( UserPageSizeY, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerYsize->Add( UserPageSizeY, 0, wxALIGN_TOP|wxALL, 5 );
m_TextUserSizeY = new wxTextCtrl( this, ID_TEXTCTRL_USER_PAGE_SIZE_Y, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerYsize->Add( m_TextUserSizeY, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerYsize->Add( m_TextUserSizeY, 0, wxALIGN_TOP|wxALL|wxEXPAND, 5 );
LeftColumnSizer->Add( bSizerYsize, 1, wxEXPAND, 5 );
sbSizer10->Add( bSizerYsize, 1, wxALIGN_TOP|wxALL|wxEXPAND, 5 );
LeftColumnSizer->Add( 5, 5, 1, wxEXPAND, 5 );
LeftColumnSizer->Add( 5, 5, 1, wxEXPAND, 5 );
LeftColumnSizer->Add( sbSizer10, 1, wxALL|wxEXPAND, 5 );
bUpperSizerH->Add( LeftColumnSizer, 0, wxEXPAND, 5 );
......@@ -219,7 +219,7 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCloseWindow ) );
m_PageSizeBox->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::onRadioButtonSelected ), NULL, this );
m_paperSizeComboBox->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::onPaperSizeChoice ), NULL, this );
m_TextUserSizeX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeXTextUpdated ), NULL, this );
m_TextUserSizeY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeYTextUpdated ), NULL, this );
m_TitleExport->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCheckboxTitleClick ), NULL, this );
......@@ -231,7 +231,7 @@ DIALOG_PAGES_SETTINGS_BASE::~DIALOG_PAGES_SETTINGS_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCloseWindow ) );
m_PageSizeBox->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::onRadioButtonSelected ), NULL, this );
m_paperSizeComboBox->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::onPaperSizeChoice ), NULL, this );
m_TextUserSizeX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeXTextUpdated ), NULL, this );
m_TextUserSizeY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeYTextUpdated ), NULL, this );
m_TitleExport->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCheckboxTitleClick ), NULL, this );
......
......@@ -11,16 +11,16 @@
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/radiobox.h>
#include <wx/choice.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/dialog.h>
......@@ -50,15 +50,12 @@ class DIALOG_PAGES_SETTINGS_BASE : public wxDialog
private:
protected:
wxRadioBox* m_PageSizeBox;
wxCheckBox* m_landscapeCheckbox;
wxChoice* m_paperSizeComboBox;
wxChoice* m_orientationComboBox;
wxStaticText* UserPageSizeX;
wxTextCtrl* m_TextUserSizeX;
wxStaticText* UserPageSizeY;
wxTextCtrl* m_TextUserSizeY;
wxStaticText* m_TextSheetCount;
wxStaticText* m_TextSheetNumber;
......@@ -82,7 +79,7 @@ class DIALOG_PAGES_SETTINGS_BASE : public wxDialog
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void onRadioButtonSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void onPaperSizeChoice( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTextctrlUserPageSizeXTextUpdated( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTextctrlUserPageSizeYTextUpdated( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCheckboxTitleClick( wxCommandEvent& event ) { event.Skip(); }
......
......@@ -247,6 +247,11 @@ private:
static const PAGE_INFO pageD;
static const PAGE_INFO pageE;
static const PAGE_INFO pageGERBER;
static const PAGE_INFO pageUSLetter;
static const PAGE_INFO pageUSLegal;
static const PAGE_INFO pageUSLedger;
static const PAGE_INFO pageUser;
// all dimensions here are in mils
......
......@@ -478,8 +478,8 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
{
wxString header = wxString::Format(
wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s\n\n" ),
BOARD_FILE_VERSION, TO_UTF8( DateAndTime() ),
TO_UTF8( GetBuildVersion() ) );
BOARD_FILE_VERSION, DateAndTime().GetData(),
GetBuildVersion().GetData() );
PROPERTIES props;
......
......@@ -2654,8 +2654,9 @@ void KICAD_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* a
if( m_props )
{
wxString header = (*m_props)["header"];
// save a file header, if caller provided one (with trailing \n hopefully).
fprintf( m_fp, "%s", TO_UTF8( (*m_props)["header"] ) );
fprintf( m_fp, "%s", TO_UTF8( header ) );
}
saveAllSections();
......
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