diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 305da6f6b3..390fbf2d20 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -92,7 +92,11 @@ void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event ) DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ) : DIALOG_PAGES_SETTINGS_BASE( parent ), - m_initialized( false ) + m_initialized( false ), + m_customSizeX( parent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false, + MIN_PAGE_SIZE * IU_PER_MILS, MAX_PAGE_SIZE * IU_PER_MILS ), + m_customSizeY( parent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false, + MIN_PAGE_SIZE * IU_PER_MILS, MAX_PAGE_SIZE * IU_PER_MILS ) { m_parent = parent; m_screen = m_parent->GetScreen(); @@ -122,8 +126,6 @@ DIALOG_PAGES_SETTINGS::~DIALOG_PAGES_SETTINGS() void DIALOG_PAGES_SETTINGS::initDialog() { wxString msg; - double customSizeX; - double customSizeY; // initialize page format choice box and page format list. // The first shows translated strings, the second contains not translated strings @@ -160,41 +162,15 @@ void DIALOG_PAGES_SETTINGS::initDialog() wxCommandEvent dummy; OnPaperSizeChoice( dummy ); - if( m_customFmt) // The custom value is defined by the page size + if( m_customFmt ) { - customSizeX = m_pageInfo.GetWidthMils(); - customSizeY = m_pageInfo.GetHeightMils(); + m_customSizeX.SetValue( m_pageInfo.GetWidthMils() * IU_PER_MILS ); + m_customSizeY.SetValue( m_pageInfo.GetHeightMils() * IU_PER_MILS ); } - else // The custom value is set to a default value, or the last defined value + else { - customSizeX = m_pageInfo.GetCustomWidthMils(); - customSizeY = m_pageInfo.GetCustomHeightMils(); - } - - switch( g_UserUnit ) - { - case MILLIMETRES: - customSizeX *= 25.4e-3; - customSizeY *= 25.4e-3; - - msg.Printf( wxT( "%.2f" ), customSizeX ); - m_TextUserSizeX->SetValue( msg ); - - msg.Printf( wxT( "%.2f" ), customSizeY ); - m_TextUserSizeY->SetValue( msg ); - break; - - default: - case INCHES: - customSizeX /= 1000.0; - customSizeY /= 1000.0; - - msg.Printf( wxT( "%.3f" ), customSizeX ); - m_TextUserSizeX->SetValue( msg ); - - msg.Printf( wxT( "%.3f" ), customSizeY ); - m_TextUserSizeY->SetValue( msg ); - break; + m_customSizeX.SetValue( m_pageInfo.GetCustomWidthMils() * IU_PER_MILS ); + m_customSizeY.SetValue( m_pageInfo.GetCustomHeightMils() * IU_PER_MILS ); } m_TextRevision->SetValue( m_tb.GetRevision() ); @@ -255,8 +231,8 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event ) if( paperType.Contains( PAGE_INFO::Custom ) ) { m_orientationComboBox->Enable( false ); - m_TextUserSizeX->Enable( true ); - m_TextUserSizeY->Enable( true ); + m_customSizeX.Enable( true ); + m_customSizeY.Enable( true ); m_customFmt = true; } else @@ -272,8 +248,8 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event ) m_orientationComboBox->Enable( false ); } #endif - m_TextUserSizeX->Enable( false ); - m_TextUserSizeY->Enable( false ); + m_customSizeX.Enable( false ); + m_customSizeY.Enable( false ); m_customFmt = false; } @@ -284,7 +260,7 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event ) void DIALOG_PAGES_SETTINGS::OnUserPageSizeXTextUpdated( wxCommandEvent& event ) { - if( m_initialized && m_TextUserSizeX->IsModified() ) + if( m_initialized ) { GetPageLayoutInfoFromDialog(); UpdatePageLayoutExample(); @@ -294,7 +270,7 @@ void DIALOG_PAGES_SETTINGS::OnUserPageSizeXTextUpdated( wxCommandEvent& event ) void DIALOG_PAGES_SETTINGS::OnUserPageSizeYTextUpdated( wxCommandEvent& event ) { - if( m_initialized && m_TextUserSizeY->IsModified() ) + if( m_initialized ) { GetPageLayoutInfoFromDialog(); UpdatePageLayoutExample(); @@ -423,20 +399,15 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings() if( fileName != BASE_SCREEN::m_PageLayoutDescrFileName ) { - wxString fullFileName = - WORKSHEET_LAYOUT::MakeFullFileName( fileName, m_projectPath ); + wxString fullFileName = WORKSHEET_LAYOUT::MakeFullFileName( fileName, m_projectPath ); - if( !fullFileName.IsEmpty() ) + if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) ) { - - if( !wxFileExists( fullFileName ) ) - { - wxString msg; - msg.Printf( _("Page layout description file \"%s\" not found. Abort"), - GetChars( fullFileName ) ); - wxMessageBox( msg ); - return false; - } + wxString msg; + msg.Printf( _( "Page layout description file \"%s\" not found." ), + GetChars( fullFileName ) ); + wxMessageBox( msg ); + return false; } BASE_SCREEN::m_PageLayoutDescrFileName = fileName; @@ -445,11 +416,7 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings() m_localPrjConfigChanged = true; } - int idx = m_paperSizeComboBox->GetSelection(); - - if( idx < 0 ) - idx = 0; - + int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 ); const wxString paperType = m_pageFmt[idx]; if( paperType.Contains( PAGE_INFO::Custom ) ) @@ -460,26 +427,8 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings() if( retSuccess ) { - if( m_layout_size.x < MIN_PAGE_SIZE || m_layout_size.y < MIN_PAGE_SIZE || - m_layout_size.x > MAX_PAGE_SIZE || m_layout_size.y > MAX_PAGE_SIZE ) - { - wxString msg = wxString::Format( _( "Selected custom paper size\n" - "is out of the permissible limits\n" - "%.1f - %.1f %s!\nSelect another custom " - "paper size?" ), - g_UserUnit == INCHES ? MIN_PAGE_SIZE / 1000. : MIN_PAGE_SIZE * 25.4 / 1000, - g_UserUnit == INCHES ? MAX_PAGE_SIZE / 1000. : MAX_PAGE_SIZE * 25.4 / 1000, - g_UserUnit == INCHES ? _( "inches" ) : _( "mm" ) ); - - if( wxMessageBox( msg, _( "Warning!" ), - wxYES_NO | wxICON_EXCLAMATION, this ) == wxYES ) - { - return false; - } - - m_layout_size.x = Clamp( MIN_PAGE_SIZE, m_layout_size.x, MAX_PAGE_SIZE ); - m_layout_size.y = Clamp( MIN_PAGE_SIZE, m_layout_size.y, MAX_PAGE_SIZE ); - } + if( !m_customSizeX.Validate( true ) || !m_customSizeY.Validate( true ) ) + return false; PAGE_INFO::SetCustomWidthMils( m_layout_size.x ); PAGE_INFO::SetCustomHeightMils( m_layout_size.y ); @@ -702,11 +651,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog() { - int idx = m_paperSizeComboBox->GetSelection(); - - if( idx < 0 ) - idx = 0; - + int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 ); const wxString paperType = m_pageFmt[idx]; // here we assume translators will keep original paper size spellings @@ -772,28 +717,8 @@ void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog() void DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog() { - double customSizeX; - double customSizeY; - wxString msg; - - msg = m_TextUserSizeX->GetValue(); - msg.ToDouble( &customSizeX ); - - msg = m_TextUserSizeY->GetValue(); - msg.ToDouble( &customSizeY ); - - switch( g_UserUnit ) - { - case MILLIMETRES: - customSizeX *= 1000. / 25.4; - customSizeY *= 1000. / 25.4; - break; - - default: - case INCHES: - customSizeX *= 1000.; - customSizeY *= 1000.; - } + double customSizeX = (double) m_customSizeX.GetValue() / IU_PER_MILS; + double customSizeY = (double) m_customSizeY.GetValue() / IU_PER_MILS; // Prepare to painless double -> int conversion. customSizeX = Clamp( double( INT_MIN ), customSizeX, double( INT_MAX ) ); diff --git a/common/dialogs/dialog_page_settings.h b/common/dialogs/dialog_page_settings.h index d5e891b2e9..c202dd29c1 100644 --- a/common/dialogs/dialog_page_settings.h +++ b/common/dialogs/dialog_page_settings.h @@ -24,6 +24,8 @@ #ifndef _DIALOG_PAGES_SETTINGS_H_ #define _DIALOG_PAGES_SETTINGS_H_ +#include + #include #define MAX_PAGE_EXAMPLE_SIZE 200 @@ -48,6 +50,8 @@ private: TITLE_BLOCK m_tb; /// Temporary title block (basic inscriptions). WORKSHEET_LAYOUT *m_pagelayout; // the alternate and temporary page layout shown by the dialog // when the initial one is replaced by a new one + UNIT_BINDER m_customSizeX; + UNIT_BINDER m_customSizeY; public: DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ); diff --git a/common/dialogs/dialog_page_settings_base.cpp b/common/dialogs/dialog_page_settings_base.cpp index 0b749020b5..29e3ff0151 100644 --- a/common/dialogs/dialog_page_settings_base.cpp +++ b/common/dialogs/dialog_page_settings_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -49,65 +49,63 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind m_orientationComboBox->SetSelection( 0 ); bleftSizer->Add( m_orientationComboBox, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_staticTextCustSize = new wxStaticText( this, wxID_ANY, _("Custom Size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextCustSize = new wxStaticText( this, wxID_ANY, _("Custom paper size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextCustSize->Wrap( -1 ); bleftSizer->Add( m_staticTextCustSize, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - wxBoxSizer* bSizerCustSize; - bSizerCustSize = new wxBoxSizer( wxHORIZONTAL ); + wxFlexGridSizer* fgSizer1; + fgSizer1 = new wxFlexGridSizer( 0, 3, 0, 0 ); + fgSizer1->SetFlexibleDirection( wxBOTH ); + fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - wxBoxSizer* bSizercustHeight; - bSizercustHeight = new wxBoxSizer( wxVERTICAL ); + m_userSizeYLabel = new wxStaticText( this, wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_userSizeYLabel->Wrap( -1 ); + fgSizer1->Add( m_userSizeYLabel, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - m_staticTextHeight = new wxStaticText( this, wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextHeight->Wrap( -1 ); - bSizercustHeight->Add( m_staticTextHeight, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_TextUserSizeY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_LEFT ); + m_userSizeYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_LEFT ); #ifdef __WXGTK__ - if ( !m_TextUserSizeY->HasFlag( wxTE_MULTILINE ) ) + if ( !m_userSizeYCtrl->HasFlag( wxTE_MULTILINE ) ) { - m_TextUserSizeY->SetMaxLength( 6 ); + m_userSizeYCtrl->SetMaxLength( -1 ); } #else - m_TextUserSizeY->SetMaxLength( 6 ); + m_userSizeYCtrl->SetMaxLength( -1 ); #endif - m_TextUserSizeY->SetToolTip( _("Custom paper height.") ); + m_userSizeYCtrl->SetToolTip( _("Custom paper height.") ); - bSizercustHeight->Add( m_TextUserSizeY, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizer1->Add( m_userSizeYCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + m_userSizeYUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_userSizeYUnits->Wrap( -1 ); + fgSizer1->Add( m_userSizeYUnits, 0, wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); - bSizerCustSize->Add( bSizercustHeight, 1, wxEXPAND, 5 ); + m_userSizeXLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_userSizeXLabel->Wrap( -1 ); + fgSizer1->Add( m_userSizeXLabel, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - wxBoxSizer* bSizercustWidth; - bSizercustWidth = new wxBoxSizer( wxVERTICAL ); - - m_staticTextWidth = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextWidth->Wrap( -1 ); - bSizercustWidth->Add( m_staticTextWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_TextUserSizeX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_LEFT ); + m_userSizeXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_LEFT ); #ifdef __WXGTK__ - if ( !m_TextUserSizeX->HasFlag( wxTE_MULTILINE ) ) + if ( !m_userSizeXCtrl->HasFlag( wxTE_MULTILINE ) ) { - m_TextUserSizeX->SetMaxLength( 6 ); + m_userSizeXCtrl->SetMaxLength( -1 ); } #else - m_TextUserSizeX->SetMaxLength( 6 ); + m_userSizeXCtrl->SetMaxLength( -1 ); #endif - m_TextUserSizeX->SetToolTip( _("Custom paper width.") ); + m_userSizeXCtrl->SetToolTip( _("Custom paper width.") ); - bSizercustWidth->Add( m_TextUserSizeX, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizer1->Add( m_userSizeXCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_userSizeXUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_userSizeXUnits->Wrap( -1 ); + fgSizer1->Add( m_userSizeXUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 ); - bSizerCustSize->Add( bSizercustWidth, 1, wxEXPAND, 5 ); - - - bleftSizer->Add( bSizerCustSize, 0, wxEXPAND, 5 ); + bleftSizer->Add( fgSizer1, 0, wxEXPAND|wxBOTTOM, 5 ); m_staticTextPreview = new wxStaticText( this, wxID_ANY, _("Layout Preview"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextPreview->Wrap( -1 ); - bleftSizer->Add( m_staticTextPreview, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + bleftSizer->Add( m_staticTextPreview, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT, 10 ); m_PageLayoutExampleBitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxFULL_REPAINT_ON_RESIZE|wxSIMPLE_BORDER ); m_PageLayoutExampleBitmap->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); @@ -116,10 +114,7 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind bleftSizer->Add( m_PageLayoutExampleBitmap, 1, wxALL|wxEXPAND, 5 ); - bUpperSizerH->Add( bleftSizer, 0, wxEXPAND, 5 ); - - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); - bUpperSizerH->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); + bUpperSizerH->Add( bleftSizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bSizerRight; bSizerRight = new wxBoxSizer( wxVERTICAL ); @@ -146,7 +141,7 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind SheetInfoSizer->Add( m_TextSheetNumber, 0, wxALL, 5 ); - bSizerRight->Add( SheetInfoSizer, 0, 0, 5 ); + bSizerRight->Add( SheetInfoSizer, 0, wxLEFT, 5 ); wxBoxSizer* bSizerDate; bSizerDate = new wxBoxSizer( wxVERTICAL ); @@ -359,7 +354,7 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind m_textCtrlFilePicker = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizerfileSelection->Add( m_textCtrlFilePicker, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - m_buttonBrowse = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); + m_buttonBrowse = new wxButton( this, wxID_ANY, _("Browse..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); bSizerfileSelection->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); @@ -369,10 +364,10 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind bSizerRight->Add( bSizerFilename, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - bUpperSizerH->Add( bSizerRight, 1, wxEXPAND, 5 ); + bUpperSizerH->Add( bSizerRight, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - bMainSizer->Add( bUpperSizerH, 1, wxEXPAND, 5 ); + bMainSizer->Add( bUpperSizerH, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); @@ -391,8 +386,8 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind // Connect Events m_paperSizeComboBox->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnPaperSizeChoice ), NULL, this ); m_orientationComboBox->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnPageOrientationChoice ), NULL, this ); - m_TextUserSizeY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeYTextUpdated ), NULL, this ); - m_TextUserSizeX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeXTextUpdated ), NULL, this ); + m_userSizeYCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeYTextUpdated ), NULL, this ); + m_userSizeXCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeXTextUpdated ), NULL, this ); m_TextDate->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnDateTextUpdated ), NULL, this ); m_ApplyDate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnDateApplyClick ), NULL, this ); m_TextRevision->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnRevisionTextUpdated ), NULL, this ); @@ -412,8 +407,8 @@ DIALOG_PAGES_SETTINGS_BASE::~DIALOG_PAGES_SETTINGS_BASE() // Disconnect Events m_paperSizeComboBox->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnPaperSizeChoice ), NULL, this ); m_orientationComboBox->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnPageOrientationChoice ), NULL, this ); - m_TextUserSizeY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeYTextUpdated ), NULL, this ); - m_TextUserSizeX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeXTextUpdated ), NULL, this ); + m_userSizeYCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeYTextUpdated ), NULL, this ); + m_userSizeXCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnUserPageSizeXTextUpdated ), NULL, this ); m_TextDate->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnDateTextUpdated ), NULL, this ); m_ApplyDate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnDateApplyClick ), NULL, this ); m_TextRevision->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnRevisionTextUpdated ), NULL, this ); diff --git a/common/dialogs/dialog_page_settings_base.fbp b/common/dialogs/dialog_page_settings_base.fbp index 453988012a..4fe84d8330 100644 --- a/common/dialogs/dialog_page_settings_base.fbp +++ b/common/dialogs/dialog_page_settings_base.fbp @@ -95,7 +95,7 @@ none 5 - wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT 1 @@ -104,7 +104,7 @@ none 5 - wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT 0 @@ -649,7 +649,7 @@ 0 0 wxID_ANY - Custom Size: + Custom paper size: 0 @@ -702,388 +702,539 @@ 5 - wxEXPAND + wxEXPAND|wxBOTTOM 0 - + + 3 + wxBOTH + + + 0 - bSizerCustSize - wxHORIZONTAL + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED none + 0 + 0 5 - wxEXPAND - 1 - + wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Height: + + 0 + + + 0 - bSizercustHeight - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Height: - - 0 - - - 0 - - 1 - m_staticTextHeight - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 6 - - 0 - - 1 - m_TextUserSizeY - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_LEFT - - 0 - Custom paper height. - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnUserPageSizeYTextUpdated - - - - - - + 1 + m_userSizeYLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + -1 + + 0 + + 1 + m_userSizeYCtrl + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_LEFT + + 0 + Custom paper height. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnUserPageSizeYTextUpdated + + + + 5 - wxEXPAND - 1 - + wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + + 0 + + + 0 - bSizercustWidth - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Width: - - 0 - - - 0 - - 1 - m_staticTextWidth - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 6 - - 0 - - 1 - m_TextUserSizeX - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_LEFT - - 0 - Custom paper width. - - wxFILTER_NONE - wxTextValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnUserPageSizeXTextUpdated - - - - - - + 1 + m_userSizeYUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Width: + + 0 + + + 0 + + 1 + m_userSizeXLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + -1 + + 0 + + 1 + m_userSizeXCtrl + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_LEFT + + 0 + Custom paper width. + + wxFILTER_NONE + wxTextValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnUserPageSizeXTextUpdated + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + + 0 + + + 0 + + 1 + m_userSizeXUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL + 10 + wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -1249,88 +1400,7 @@ 5 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline1 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_VERTICAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT 1 @@ -1503,7 +1573,7 @@ 5 - + wxLEFT 0 @@ -4359,7 +4429,7 @@ 0 0 wxID_ANY - Browse + Browse... 0 diff --git a/common/dialogs/dialog_page_settings_base.h b/common/dialogs/dialog_page_settings_base.h index 2c5eb1626c..56be4e8036 100644 --- a/common/dialogs/dialog_page_settings_base.h +++ b/common/dialogs/dialog_page_settings_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -21,8 +21,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -51,13 +51,14 @@ class DIALOG_PAGES_SETTINGS_BASE : public DIALOG_SHIM wxStaticText* m_staticTextOrient; wxChoice* m_orientationComboBox; wxStaticText* m_staticTextCustSize; - wxStaticText* m_staticTextHeight; - wxTextCtrl* m_TextUserSizeY; - wxStaticText* m_staticTextWidth; - wxTextCtrl* m_TextUserSizeX; + wxStaticText* m_userSizeYLabel; + wxTextCtrl* m_userSizeYCtrl; + wxStaticText* m_userSizeYUnits; + wxStaticText* m_userSizeXLabel; + wxTextCtrl* m_userSizeXCtrl; + wxStaticText* m_userSizeXUnits; wxStaticText* m_staticTextPreview; wxStaticBitmap* m_PageLayoutExampleBitmap; - wxStaticLine* m_staticline1; wxStaticText* m_staticTexttbprm; wxStaticLine* m_staticline3; wxStaticText* m_TextSheetCount; diff --git a/common/preview_items/arc_assistant.cpp b/common/preview_items/arc_assistant.cpp index 7331b9d189..0f9f3aaef5 100644 --- a/common/preview_items/arc_assistant.cpp +++ b/common/preview_items/arc_assistant.cpp @@ -33,9 +33,10 @@ using namespace KIGFX::PREVIEW; -ARC_ASSISTANT::ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager ) : +ARC_ASSISTANT::ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager, EDA_UNITS_T aUnits ) : EDA_ITEM( NOT_USED ), - m_constructMan( aManager ) + m_constructMan( aManager ), + m_units( aUnits ) { } @@ -49,8 +50,8 @@ const BOX2I ARC_ASSISTANT::ViewBBox() const return tmp; // just enclose the whle circular area - auto origin = m_constructMan.GetOrigin(); - auto radius = m_constructMan.GetRadius(); + auto origin = m_constructMan.GetOrigin(); + auto radius = m_constructMan.GetRadius(); VECTOR2D rVec( radius, radius ); tmp.SetOrigin( origin + rVec ); @@ -172,7 +173,7 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const double degs = getNormDeciDegFromRad( initAngle ); - cursorStrings.push_back( DimensionLabel( "r", m_constructMan.GetRadius(), g_UserUnit ) ); + cursorStrings.push_back( DimensionLabel( "r", m_constructMan.GetRadius(), m_units ) ); cursorStrings.push_back( DimensionLabel( "θ", degs, DEGREES ) ); } else @@ -197,8 +198,7 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const // FIXME: spaces choke OpenGL lp:1668455 for( auto& str : cursorStrings ) { - str.erase( std::remove( str.begin(), str.end(), ' ' ), - str.end() ); + str.erase( std::remove( str.begin(), str.end(), ' ' ), str.end() ); } // place the text next to cursor, on opposite side from radius diff --git a/common/tool/context_menu.cpp b/common/tool/context_menu.cpp index 0f40797591..e59fe5a637 100644 --- a/common/tool/context_menu.cpp +++ b/common/tool/context_menu.cpp @@ -275,7 +275,7 @@ CONTEXT_MENU* CONTEXT_MENU::create() const } -TOOL_MANAGER* CONTEXT_MENU::getToolManager() +TOOL_MANAGER* CONTEXT_MENU::getToolManager() const { wxASSERT( m_tool ); return m_tool ? m_tool->GetManager() : nullptr; diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index ef71bb0a59..102d0c8b63 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -140,7 +140,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT m_cmp = aComponent; m_part = GetParent()->GetLibPart( m_cmp->GetLibId(), true ); - m_fields = new FIELDS_GRID_TABLE( false, g_UserUnit, m_part ); + m_fields = new FIELDS_GRID_TABLE( false, GetUserUnits(), m_part ); m_delayedFocusRow = REFERENCE; m_delayedFocusColumn = FDC_VALUE; diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index 386463303e..d566aad116 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -123,7 +123,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( LIB_EDIT m_parent = aParent; m_libEntry = aLibEntry; - m_fields = new FIELDS_GRID_TABLE( true, g_UserUnit, m_libEntry ); + m_fields = new FIELDS_GRID_TABLE( true, GetUserUnits(), m_libEntry ); m_delayedFocusRow = REFERENCE; m_delayedFocusColumn = FDC_VALUE; diff --git a/eeschema/dialogs/dialog_edit_line_style.cpp b/eeschema/dialogs/dialog_edit_line_style.cpp index 05e6e32df3..d5b1f3c445 100644 --- a/eeschema/dialogs/dialog_edit_line_style.cpp +++ b/eeschema/dialogs/dialog_edit_line_style.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Seth Hillbrand - * Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2014-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,31 +23,45 @@ */ #include +#include +#include #include #include const int BUTT_COLOR_MINSIZE_X = 32; const int BUTT_COLOR_MINSIZE_Y = 20; -DIALOG_EDIT_LINE_STYLE::DIALOG_EDIT_LINE_STYLE( wxWindow* parent ) : - DIALOG_EDIT_LINE_STYLE_BASE( parent ) +DIALOG_EDIT_LINE_STYLE::DIALOG_EDIT_LINE_STYLE( SCH_EDIT_FRAME* aParent, SCH_LINE* aLine ) : + DIALOG_EDIT_LINE_STYLE_BASE( aParent ), + m_frame( aParent ), + m_line( aLine ), + m_width( aParent, m_staticTextWidth, m_lineWidth, m_staticWidthUnits, true, 0 ) { m_sdbSizerApply->SetLabel( _( "Default" ) ); - m_lineStyle->SetSelection( 0 ); - m_lineWidth->SetFocus(); - - m_defaultStyle = 0; wxBitmap bitmap( std::max( m_colorButton->GetSize().x, BUTT_COLOR_MINSIZE_X ), std::max( m_colorButton->GetSize().y, BUTT_COLOR_MINSIZE_Y ) ); m_colorButton->SetBitmap( bitmap ); + SetInitialFocus( m_lineWidth ); + m_sdbSizerOK->SetDefault(); // Now all widgets have the size fixed, call FinishDialogSettings FinishDialogSettings(); } + +bool DIALOG_EDIT_LINE_STYLE::TransferDataToWindow() +{ + m_width.SetValue( m_line->GetPenSize() ); + setColor( m_line->GetLineColor() ); + m_lineStyle->SetSelection( m_line->GetLineStyle() ); + + return true; +} + + void DIALOG_EDIT_LINE_STYLE::onColorButtonClicked( wxCommandEvent& event ) { COLOR4D newColor = COLOR4D::UNSPECIFIED; @@ -59,7 +73,7 @@ void DIALOG_EDIT_LINE_STYLE::onColorButtonClicked( wxCommandEvent& event ) if( newColor == COLOR4D::UNSPECIFIED || m_selectedColor == newColor ) return; - SetColor( newColor, true ); + setColor( newColor ); } @@ -87,37 +101,29 @@ void DIALOG_EDIT_LINE_STYLE::updateColorButton( COLOR4D& aColor ) void DIALOG_EDIT_LINE_STYLE::resetDefaults( wxCommandEvent& event ) { - SetStyle( m_defaultStyle ); - SetWidth( m_defaultWidth ); - SetColor( m_defaultColor, true ); + m_width.SetValue( m_line->GetDefaultWidth() ); + setColor( m_line->GetDefaultColor() ); + m_lineStyle->SetSelection( m_line->GetDefaultStyle() ); Refresh(); } -void DIALOG_EDIT_LINE_STYLE::SetColor( const COLOR4D& aColor, bool aRefresh ) +void DIALOG_EDIT_LINE_STYLE::setColor( const COLOR4D& aColor ) { m_selectedColor = aColor; - - if( aRefresh ) - updateColorButton( m_selectedColor ); + updateColorButton( m_selectedColor ); } -void DIALOG_EDIT_LINE_STYLE::SetDefaultColor( const COLOR4D& aColor ) +bool DIALOG_EDIT_LINE_STYLE::TransferDataFromWindow() { - m_defaultColor = aColor; -} + m_frame->SaveCopyInUndoList( m_line, UR_CHANGED ); + m_line->SetLineWidth( m_width.GetValue() ); + m_line->SetLineStyle( m_lineStyle->GetSelection() ); + m_line->SetLineColor( m_selectedColor ); -void DIALOG_EDIT_LINE_STYLE::SetStyle( const int aStyle ) -{ - wxASSERT( aStyle >= 0 && aStyle < 4 ); + m_frame->OnModify(); - m_lineStyle->SetSelection( aStyle ); -} - - -int DIALOG_EDIT_LINE_STYLE::GetStyle() -{ - return m_lineStyle->GetSelection(); -} + return true; +} \ No newline at end of file diff --git a/eeschema/dialogs/dialog_edit_line_style.h b/eeschema/dialogs/dialog_edit_line_style.h index 8fc20f5376..5823493e10 100644 --- a/eeschema/dialogs/dialog_edit_line_style.h +++ b/eeschema/dialogs/dialog_edit_line_style.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Seth Hillbrand - * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2014-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,45 +25,33 @@ #ifndef __dialog_edit_line_style__ #define __dialog_edit_line_style__ - -/** - * @file dialog_edit_line_style.h - * @brief Subclass of DIALOG_EDIT_LINE_STYLE_BASE, which is generated by wxFormBuilder. - */ - #include -#include +#include + + +class SCH_EDIT_FRAME; +class SCH_LINE; + class DIALOG_EDIT_LINE_STYLE : public DIALOG_EDIT_LINE_STYLE_BASE { public: - DIALOG_EDIT_LINE_STYLE( wxWindow* parent ); + DIALOG_EDIT_LINE_STYLE( SCH_EDIT_FRAME* aParent, SCH_LINE* aLine ); - void SetWidth( const wxString& aWidth ) { m_lineWidth->SetValue( aWidth ); } - void SetDefaultWidth( const wxString& aWidth ) { m_defaultWidth = aWidth; } - wxString GetWidth() const { return m_lineWidth->GetValue(); } - - COLOR4D GetColor() const { return m_selectedColor; } - void SetColor( const COLOR4D& aColor, bool aRefresh ); - void SetDefaultColor( const COLOR4D& aColor ); - - void SetStyle( const int aStyle ); - void SetDefaultStyle( const int aStyle ) { m_defaultStyle = aStyle; } - int GetStyle(); - - void SetLineWidthUnits(const wxString& aUnits) - { - m_staticWidthUnits->SetLabel( aUnits ); - } + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; private: - int m_defaultStyle; - wxString m_defaultWidth; - COLOR4D m_defaultColor; - COLOR4D m_selectedColor; + SCH_EDIT_FRAME* m_frame; + SCH_LINE* m_line; + + UNIT_BINDER m_width; + COLOR4D m_selectedColor; void resetDefaults( wxCommandEvent& event ) override; void onColorButtonClicked( wxCommandEvent& aEvent ) override; + + void setColor( const COLOR4D& aColor ); void updateColorButton( COLOR4D& aColor ); }; diff --git a/eeschema/dialogs/dialog_lib_edit_draw_item.cpp b/eeschema/dialogs/dialog_lib_edit_draw_item.cpp index 710268a274..fcb8db9dd9 100644 --- a/eeschema/dialogs/dialog_lib_edit_draw_item.cpp +++ b/eeschema/dialogs/dialog_lib_edit_draw_item.cpp @@ -25,14 +25,20 @@ * @file dialog_lib_edit_draw_item.cpp */ +#include #include +#include -DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( wxWindow* parent, - const wxString& itemName ) : - DIALOG_LIB_EDIT_DRAW_ITEM_BASE( parent ) +DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( LIB_EDIT_FRAME* aParent, LIB_ITEM* aItem ) : + DIALOG_LIB_EDIT_DRAW_ITEM_BASE( aParent ), + m_frame( aParent ), + m_item( aItem ), + m_lineWidth( aParent, m_widthLabel, m_widthCtrl, m_widthUnits, true, 0 ) { - SetTitle( itemName + wxT( " " ) + GetTitle() ); + SetTitle( aItem->GetTypeName() + wxT( " " ) + GetTitle() ); + + SetInitialFocus( m_widthCtrl ); // Required under wxGTK if we want to dismiss the dialog with the ESC key SetFocus(); @@ -43,87 +49,52 @@ DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( wxWindow* parent, } -void DIALOG_LIB_EDIT_DRAW_ITEM::SetWidth( const wxString& width ) +bool DIALOG_LIB_EDIT_DRAW_ITEM::TransferDataToWindow() { - m_textWidth->SetValue( width ); + LIB_PART* symbol = m_item->GetParent(); + + m_lineWidth.SetValue( m_item->GetWidth() ); + m_checkApplyToAllUnits->SetValue( m_item->GetUnit() == 0 ); + m_checkApplyToAllUnits->Enable( symbol && symbol->GetUnitCount() > 1 ); + m_checkApplyToAllConversions->SetValue( symbol && symbol->HasConversion() ); + + bool enblConvOptStyle = symbol && symbol->HasConversion(); + // if a symbol contains no graphic items, symbol->HasConversion() returns false. + // but when creating a new symbol, with DeMorgan option set, the ApplyToAllConversions + // must be enabled even if symbol->HasConversion() returns false in order to be able + // to create graphic items shared by all body styles + if( m_frame->GetShowDeMorgan() ) + enblConvOptStyle = true; + + m_checkApplyToAllConversions->Enable( enblConvOptStyle ); + + m_fillCtrl->SetSelection( m_item->GetFillMode() ); + m_fillCtrl->Enable( m_item->IsFillable() ); + + return true; } -wxString DIALOG_LIB_EDIT_DRAW_ITEM::GetWidth( void ) +int DIALOG_LIB_EDIT_DRAW_ITEM::GetWidth() { - return m_textWidth->GetValue(); + return m_lineWidth.GetValue(); } -bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllConversions( void ) +bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllConversions() { return m_checkApplyToAllConversions->IsChecked(); } -void DIALOG_LIB_EDIT_DRAW_ITEM::SetApplyToAllConversions( bool applyToAll ) -{ - m_checkApplyToAllConversions->SetValue( applyToAll ); -} - - -void DIALOG_LIB_EDIT_DRAW_ITEM::EnableApplyToAllConversions( bool enable ) -{ - m_checkApplyToAllConversions->Enable( enable ); -} - - -bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllUnits( void ) +bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllUnits() { return m_checkApplyToAllUnits->IsChecked(); } -void DIALOG_LIB_EDIT_DRAW_ITEM::SetApplyToAllUnits( bool applyToAll ) -{ - m_checkApplyToAllUnits->SetValue( applyToAll ); -} - - -void DIALOG_LIB_EDIT_DRAW_ITEM::EnableApplyToAllUnits( bool enable ) -{ - m_checkApplyToAllUnits->Enable( enable ); -} - - int DIALOG_LIB_EDIT_DRAW_ITEM::GetFillStyle( void ) { - if( m_radioFillNone->GetValue() ) - return 0; - if( m_radioFillForeground->GetValue() ) - return 1; - if( m_radioFillBackground->GetValue() ) - return 2; - - return 0; + return std::max( m_fillCtrl->GetSelection(), 0 ); } - -void DIALOG_LIB_EDIT_DRAW_ITEM::SetFillStyle( int fillStyle ) -{ - if( fillStyle == 1 ) - m_radioFillForeground->SetValue( true ); - else if( fillStyle == 2 ) - m_radioFillBackground->SetValue( true ); - else - m_radioFillNone->SetValue( true ); -} - - -void DIALOG_LIB_EDIT_DRAW_ITEM::EnableFillStyle( bool enable ) -{ - m_radioFillNone->Enable( enable ); - m_radioFillForeground->Enable( enable ); - m_radioFillBackground->Enable( enable ); -} - - -void DIALOG_LIB_EDIT_DRAW_ITEM::SetWidthUnits( const wxString& units ) -{ - m_staticWidthUnits->SetLabel( units ); -} diff --git a/eeschema/dialogs/dialog_lib_edit_draw_item.fbp b/eeschema/dialogs/dialog_lib_edit_draw_item.fbp index 99cc619697..b0ad349309 100644 --- a/eeschema/dialogs/dialog_lib_edit_draw_item.fbp +++ b/eeschema/dialogs/dialog_lib_edit_draw_item.fbp @@ -14,7 +14,6 @@ dialog_lib_edit_draw_item_base 1000 none - 1 dialog_lib_edit_draw_item @@ -95,7 +94,7 @@ wxHORIZONTAL none - 12 + 10 wxALL|wxEXPAND 1 @@ -104,107 +103,14 @@ wxVERTICAL none - 3 - wxALIGN_LEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,92,-1,70,0 - 0 - 0 - wxID_ANY - General: - - 0 - - - 0 - - 1 - m_staticText1 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND + 10 + wxEXPAND|wxBOTTOM 0 bSizer3 wxHORIZONTAL none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - 3 wxALIGN_CENTER_VERTICAL|wxALL @@ -237,7 +143,7 @@ 0 0 wxID_ANY - &Width: + Line Width: 0 @@ -245,7 +151,7 @@ 0 1 - m_staticWidth + m_widthLabel 1 @@ -288,20 +194,10 @@ - - 3 - wxEXPAND - 1 - - 0 - protected - 0 - - 3 wxALIGN_CENTER_VERTICAL|wxALL - 0 + 1 1 1 @@ -338,7 +234,7 @@ 0 1 - m_textWidth + m_widthCtrl 1 @@ -391,7 +287,7 @@ 3 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT 0 1 @@ -429,7 +325,7 @@ 0 1 - m_staticWidthUnits + m_widthUnits 1 @@ -475,10 +371,10 @@ - 5 - wxTOP|wxBOTTOM + 3 + wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -492,6 +388,7 @@ 1 0 + 0 1 1 @@ -502,322 +399,11 @@ 1 1 - ,90,92,-1,70,0 - 0 - 0 - ID_M_STATICTEXTSHARING - Sharing: - - 0 - - - 0 - - 1 - m_staticTextSharing - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer4 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all &units in component - - 0 - - - 0 - - 1 - m_checkApplyToAllUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxEXPAND - 0 - - - bSizer5 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all body &styles (DeMorgan) - - 0 - - - 0 - - 1 - m_checkApplyToAllConversions - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10 - wxALL|wxEXPAND - 0 - - 0 - protected - 0 - - - - 3 - wxALIGN_LEFT|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,92,-1,70,0 + 0 0 wxID_ANY - Fill Style: + Common to all &units in component 0 @@ -825,7 +411,7 @@ 0 1 - m_staticText4 + m_checkApplyToAllUnits 1 @@ -839,11 +425,15 @@ 0 + + wxFILTER_NONE + wxDefaultValidator + - -1 + @@ -869,304 +459,96 @@ - 0 - wxALL|wxEXPAND - 1 - + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all body &styles (DeMorgan) + + 0 + + + 0 - bSizer6 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 0 - wxEXPAND - 0 - - - bSizer7 - wxVERTICAL - none - - 3 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Do &not fill - - 0 - - - 0 - - 1 - m_radioFillNone - 1 - - - protected - 1 - - Resizable - 1 - - wxRB_GROUP - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Fill &foreground - - 0 - - - 0 - - 1 - m_radioFillForeground - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Fill &background - - 0 - - - 0 - - 1 - m_radioFillBackground - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 1 + m_checkApplyToAllConversions + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + - 10 - wxALL|wxEXPAND + 5 + wxEXPAND|wxTOP 0 0 @@ -1174,6 +556,96 @@ 0 + + 5 + wxEXPAND|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Do not fill" "Fill foreground" "Fill background" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Fill Style + 1 + + 0 + + + 0 + + 1 + m_fillCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 wxALL|wxEXPAND diff --git a/eeschema/dialogs/dialog_lib_edit_draw_item.h b/eeschema/dialogs/dialog_lib_edit_draw_item.h index 3680a1fb7f..df57a71f82 100644 --- a/eeschema/dialogs/dialog_lib_edit_draw_item.h +++ b/eeschema/dialogs/dialog_lib_edit_draw_item.h @@ -25,17 +25,13 @@ #ifndef __dialog_lib_edit_draw_item__ #define __dialog_lib_edit_draw_item__ -/** - * @file - * Subclass of DIALOG_LIB_EDIT_DRAW_ITEM_BASE, which is generated by - * wxFormBuilder. - */ -class LIB_DRAW_ITEM; +class LIB_ITEM; +class LIB_EDIT_FRAME; #include - +#include /** * Dialog to edit library component graphic items. @@ -44,24 +40,19 @@ class DIALOG_LIB_EDIT_DRAW_ITEM : public DIALOG_LIB_EDIT_DRAW_ITEM_BASE { public: /** Constructor */ - DIALOG_LIB_EDIT_DRAW_ITEM( wxWindow* parent, const wxString& itemName ); + DIALOG_LIB_EDIT_DRAW_ITEM( LIB_EDIT_FRAME* parent, LIB_ITEM* aItem ); - wxString GetWidth( void ); - void SetWidth( const wxString& width ); + bool TransferDataToWindow() override; - bool GetApplyToAllConversions( void ); - void SetApplyToAllConversions( bool applyToAll ); - void EnableApplyToAllConversions( bool enable = true ); + int GetWidth(); + bool GetApplyToAllConversions(); + bool GetApplyToAllUnits(); + int GetFillStyle(); - bool GetApplyToAllUnits( void ); - void SetApplyToAllUnits( bool applyToAll ); - void EnableApplyToAllUnits( bool enable = true ); - - int GetFillStyle( void ); - void SetFillStyle( int fillStyle ); - void EnableFillStyle( bool enable = true ); - - void SetWidthUnits( const wxString& units ); +private: + LIB_EDIT_FRAME* m_frame; + LIB_ITEM* m_item; + UNIT_BINDER m_lineWidth; }; #endif // __dialog_lib_edit_draw_item__ diff --git a/eeschema/dialogs/dialog_lib_edit_draw_item_base.cpp b/eeschema/dialogs/dialog_lib_edit_draw_item_base.cpp index 5b678b3e07..ff4dcc8c09 100644 --- a/eeschema/dialogs/dialog_lib_edit_draw_item_base.cpp +++ b/eeschema/dialogs/dialog_lib_edit_draw_item_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -19,101 +19,37 @@ DIALOG_LIB_EDIT_DRAW_ITEM_BASE::DIALOG_LIB_EDIT_DRAW_ITEM_BASE( wxWindow* parent wxBoxSizer* dlgBorderSizer; dlgBorderSizer = new wxBoxSizer( wxVERTICAL ); - m_staticText1 = new wxStaticText( this, wxID_ANY, _("General:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText1->Wrap( -1 ); - m_staticText1->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); - - dlgBorderSizer->Add( m_staticText1, 0, wxALIGN_LEFT, 3 ); - wxBoxSizer* bSizer3; bSizer3 = new wxBoxSizer( wxHORIZONTAL ); + m_widthLabel = new wxStaticText( this, wxID_ANY, _("Line Width:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_widthLabel->Wrap( -1 ); + bSizer3->Add( m_widthLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - bSizer3->Add( 12, 0, 0, wxEXPAND, 3 ); + m_widthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer3->Add( m_widthCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - m_staticWidth = new wxStaticText( this, wxID_ANY, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticWidth->Wrap( -1 ); - bSizer3->Add( m_staticWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_widthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_widthUnits->Wrap( -1 ); + bSizer3->Add( m_widthUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 3 ); - bSizer3->Add( 0, 0, 1, wxEXPAND, 3 ); - - m_textWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer3->Add( m_textWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - m_staticWidthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticWidthUnits->Wrap( -1 ); - bSizer3->Add( m_staticWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - dlgBorderSizer->Add( bSizer3, 0, wxALL|wxEXPAND, 0 ); - - m_staticTextSharing = new wxStaticText( this, ID_M_STATICTEXTSHARING, _("Sharing:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextSharing->Wrap( -1 ); - m_staticTextSharing->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); - - dlgBorderSizer->Add( m_staticTextSharing, 0, wxTOP|wxBOTTOM, 5 ); - - wxBoxSizer* bSizer4; - bSizer4 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer4->Add( 12, 0, 0, wxEXPAND, 3 ); + dlgBorderSizer->Add( bSizer3, 0, wxEXPAND|wxBOTTOM, 10 ); m_checkApplyToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all &units in component"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer4->Add( m_checkApplyToAllUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - dlgBorderSizer->Add( bSizer4, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer5; - bSizer5 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer5->Add( 12, 0, 0, wxEXPAND, 3 ); + dlgBorderSizer->Add( m_checkApplyToAllUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_checkApplyToAllConversions = new wxCheckBox( this, wxID_ANY, _("Common to all body &styles (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer5->Add( m_checkApplyToAllConversions, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + dlgBorderSizer->Add( m_checkApplyToAllConversions, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - dlgBorderSizer->Add( bSizer5, 0, wxEXPAND, 3 ); + dlgBorderSizer->Add( 0, 0, 0, wxEXPAND|wxTOP, 5 ); - - dlgBorderSizer->Add( 0, 0, 0, wxALL|wxEXPAND, 10 ); - - m_staticText4 = new wxStaticText( this, wxID_ANY, _("Fill Style:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText4->Wrap( -1 ); - m_staticText4->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); - - dlgBorderSizer->Add( m_staticText4, 0, wxALIGN_LEFT|wxBOTTOM, 3 ); - - wxBoxSizer* bSizer6; - bSizer6 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer6->Add( 12, 0, 0, wxEXPAND, 3 ); - - wxBoxSizer* bSizer7; - bSizer7 = new wxBoxSizer( wxVERTICAL ); - - m_radioFillNone = new wxRadioButton( this, wxID_ANY, _("Do ¬ fill"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); - m_radioFillNone->SetValue( true ); - bSizer7->Add( m_radioFillNone, 0, wxALL, 3 ); - - m_radioFillForeground = new wxRadioButton( this, wxID_ANY, _("Fill &foreground"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer7->Add( m_radioFillForeground, 0, wxALL, 3 ); - - m_radioFillBackground = new wxRadioButton( this, wxID_ANY, _("Fill &background"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer7->Add( m_radioFillBackground, 0, wxALL, 3 ); - - - bSizer6->Add( bSizer7, 0, wxEXPAND, 0 ); - - - dlgBorderSizer->Add( bSizer6, 1, wxALL|wxEXPAND, 0 ); - - - dlgBorderSizer->Add( 0, 0, 0, wxALL|wxEXPAND, 10 ); + wxString m_fillCtrlChoices[] = { _("Do not fill"), _("Fill foreground"), _("Fill background") }; + int m_fillCtrlNChoices = sizeof( m_fillCtrlChoices ) / sizeof( wxString ); + m_fillCtrl = new wxRadioBox( this, wxID_ANY, _("Fill Style"), wxDefaultPosition, wxDefaultSize, m_fillCtrlNChoices, m_fillCtrlChoices, 1, wxRA_SPECIFY_COLS ); + m_fillCtrl->SetSelection( 0 ); + dlgBorderSizer->Add( m_fillCtrl, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); @@ -125,7 +61,7 @@ DIALOG_LIB_EDIT_DRAW_ITEM_BASE::DIALOG_LIB_EDIT_DRAW_ITEM_BASE( wxWindow* parent dlgBorderSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 0 ); - mainSizer->Add( dlgBorderSizer, 1, wxALL|wxEXPAND, 12 ); + mainSizer->Add( dlgBorderSizer, 1, wxALL|wxEXPAND, 10 ); this->SetSizer( mainSizer ); diff --git a/eeschema/dialogs/dialog_lib_edit_draw_item_base.h b/eeschema/dialogs/dialog_lib_edit_draw_item_base.h index 264b205269..9b5bb7e85e 100644 --- a/eeschema/dialogs/dialog_lib_edit_draw_item_base.h +++ b/eeschema/dialogs/dialog_lib_edit_draw_item_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -35,22 +35,12 @@ class DIALOG_LIB_EDIT_DRAW_ITEM_BASE : public DIALOG_SHIM private: protected: - enum - { - ID_M_STATICTEXTSHARING = 1000 - }; - - wxStaticText* m_staticText1; - wxStaticText* m_staticWidth; - wxTextCtrl* m_textWidth; - wxStaticText* m_staticWidthUnits; - wxStaticText* m_staticTextSharing; + wxStaticText* m_widthLabel; + wxTextCtrl* m_widthCtrl; + wxStaticText* m_widthUnits; wxCheckBox* m_checkApplyToAllUnits; wxCheckBox* m_checkApplyToAllConversions; - wxStaticText* m_staticText4; - wxRadioButton* m_radioFillNone; - wxRadioButton* m_radioFillForeground; - wxRadioButton* m_radioFillBackground; + wxRadioBox* m_fillCtrl; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 8469c28494..c1c821dab7 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -789,42 +789,13 @@ int SCH_EDIT_FRAME::EditLine( SCH_LINE* aLine, bool aRedraw ) if( aLine->GetLayer() != LAYER_NOTES ) return wxID_CANCEL; - DIALOG_EDIT_LINE_STYLE dlg( this ); - wxString units = GetAbbreviatedUnitsLabel( g_UserUnit ); - int old_style = aLine->GetLineStyle(); - int old_width = aLine->GetPenSize(); - COLOR4D old_color = aLine->GetLineColor(); + DIALOG_EDIT_LINE_STYLE dlg( this, aLine ); - dlg.SetDefaultStyle( aLine->GetDefaultStyle() ); - dlg.SetDefaultWidth( StringFromValue( g_UserUnit, aLine->GetDefaultWidth(), false ) ); - dlg.SetDefaultColor( aLine->GetDefaultColor() ); - - dlg.SetWidth( StringFromValue( g_UserUnit, old_width, false ) ); - dlg.SetStyle( old_style ); - dlg.SetLineWidthUnits( units ); - dlg.SetColor( old_color, true ); - - dlg.Layout(); - dlg.Fit(); - dlg.SetMinSize( dlg.GetSize() ); if( dlg.ShowModal() == wxID_CANCEL ) return wxID_CANCEL; - int new_width = std::max( 1, ValueFromString( m_UserUnits, dlg.GetWidth() ) ); - int new_style = dlg.GetStyle(); - COLOR4D new_color = dlg.GetColor(); - - if( new_width != old_width || new_style != old_style || new_color != old_color ) - { - SaveCopyInUndoList( (SCH_ITEM*) aLine, UR_CHANGED ); - aLine->SetLineWidth( new_width ); - aLine->SetLineStyle( new_style ); - aLine->SetLineColor( new_color ); - - OnModify(); - if( aRedraw ) - m_canvas->Refresh(); - } + if( aRedraw ) + m_canvas->Refresh(); return wxID_OK; } diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index 1e86ba3de4..7fc15df712 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -57,35 +57,13 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ) if( DrawItem == NULL ) return; - LIB_PART* symbol = DrawItem->GetParent(); - - DIALOG_LIB_EDIT_DRAW_ITEM dialog( this, DrawItem->GetTypeName() ); - - dialog.SetWidthUnits( ReturnUnitSymbol( g_UserUnit ) ); - - wxString val = StringFromValue( g_UserUnit, DrawItem->GetWidth() ); - dialog.SetWidth( val ); - dialog.SetApplyToAllUnits( DrawItem->GetUnit() == 0 ); - dialog.EnableApplyToAllUnits( symbol && symbol->GetUnitCount() > 1 ); - dialog.SetApplyToAllConversions( DrawItem->GetConvert() == 0 ); - bool enblConvOptStyle = symbol && symbol->HasConversion(); - // if a symbol contains no graphic items, symbol->HasConversion() returns false. - // but when creating a new symbol, with DeMorgan option set, the ApplyToAllConversions - // must be enabled even if symbol->HasConversion() returns false in order to be able - // to create graphic items shared by all body styles - if( GetShowDeMorgan() ) - enblConvOptStyle = true; - - dialog.EnableApplyToAllConversions( enblConvOptStyle ); - dialog.SetFillStyle( DrawItem->GetFillMode() ); - dialog.EnableFillStyle( DrawItem->IsFillable() ); + DIALOG_LIB_EDIT_DRAW_ITEM dialog( this, DrawItem ); if( dialog.ShowModal() == wxID_CANCEL ) return; // Init default values (used to create a new draw item) - val = dialog.GetWidth(); - m_drawLineWidth = ValueFromString( g_UserUnit, val ); + m_drawLineWidth = dialog.GetWidth(); m_drawSpecificConvert = !dialog.GetApplyToAllConversions(); m_drawSpecificUnit = !dialog.GetApplyToAllUnits(); diff --git a/gerbview/tools/gerbview_control.cpp b/gerbview/tools/gerbview_control.cpp index 38f48f39ed..71661d4d30 100644 --- a/gerbview/tools/gerbview_control.cpp +++ b/gerbview/tools/gerbview_control.cpp @@ -238,7 +238,7 @@ int GERBVIEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent ) // TODO: Refactor to share with pcbnew wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); - if( g_UserUnit == INCHES ) + if( m_frame->GetUserUnits() == INCHES ) evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM ); else evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH ); diff --git a/include/preview_items/arc_assistant.h b/include/preview_items/arc_assistant.h index 9c3c411ae8..7dbf7fd174 100644 --- a/include/preview_items/arc_assistant.h +++ b/include/preview_items/arc_assistant.h @@ -39,7 +39,7 @@ class ARC_ASSISTANT : public EDA_ITEM { public: - ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager ); + ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager, EDA_UNITS_T aUnits ); const BOX2I ViewBBox() const override; @@ -52,7 +52,6 @@ public: void Show( int x, std::ostream& st ) const override { } - #endif /** @@ -67,6 +66,7 @@ public: private: const ARC_GEOM_MANAGER& m_constructMan; + EDA_UNITS_T m_units; }; } // PREVIEW } // KIGFX diff --git a/include/tool/context_menu.h b/include/tool/context_menu.h index 8f8e7b7681..d9dae24a10 100644 --- a/include/tool/context_menu.h +++ b/include/tool/context_menu.h @@ -149,7 +149,7 @@ protected: virtual CONTEXT_MENU* create() const; ///> Returns an instance of TOOL_MANAGER class. - TOOL_MANAGER* getToolManager(); + TOOL_MANAGER* getToolManager() const; ///> Returns the corresponding wxMenuItem identifier for a TOOL_ACTION object. static inline int getMenuId( const TOOL_ACTION& aAction ) diff --git a/pagelayout_editor/pl_editor.cpp b/pagelayout_editor/pl_editor.cpp index 9d1a6b300d..a2ec8bce43 100644 --- a/pagelayout_editor/pl_editor.cpp +++ b/pagelayout_editor/pl_editor.cpp @@ -124,8 +124,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) // display the real hotkeys in menus or tool tips ReadHotkeyConfig( PL_EDITOR_FRAME_NAME, PlEditorHokeysDescr ); - g_UserUnit = MILLIMETRES; - return true; } @@ -150,8 +148,6 @@ bool MYFACE::OnKifaceStart( PGM_BASE* aProgram ) return false; } - g_UserUnit = MILLIMETRES; - // read current setup and reopen last directory if no filename to open in // command line bool reopenLastUsedDirectory = argc == 1; diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index fe42254222..5c27f3b6d4 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -56,6 +56,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME ) { + m_UserUnits = MILLIMETRES; m_zoomLevelCoeff = 290.0; // Adjusted to roughly displays zoom level = 1 // when the screen shows a 1:1 image // obviously depends on the monitor, @@ -438,14 +439,14 @@ void PL_EDITOR_FRAME::UpdateStatusBar() // Display absolute coordinates: wxPoint coord = GetCrossHairPosition() - originCoord; - double dXpos = To_User_Unit( g_UserUnit, coord.x*Xsign ); - double dYpos = To_User_Unit( g_UserUnit, coord.y*Ysign ); + double dXpos = To_User_Unit( GetUserUnits(), coord.x*Xsign ); + double dYpos = To_User_Unit( GetUserUnits(), coord.y*Ysign ); wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" ); wxString absformatter = wxT( "X %.4g Y %.4g" ); wxString locformatter = wxT( "dx %.4g dy %.4g" ); - switch( g_UserUnit ) + switch( GetUserUnits() ) { case INCHES: // Should not be used in page layout editor SetStatusText( _("inches"), 5 ); @@ -480,8 +481,8 @@ void PL_EDITOR_FRAME::UpdateStatusBar() // Display relative coordinates: int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x; int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y; - dXpos = To_User_Unit( g_UserUnit, dx * Xsign ); - dYpos = To_User_Unit( g_UserUnit, dy * Ysign ); + dXpos = To_User_Unit( GetUserUnits(), dx * Xsign ); + dYpos = To_User_Unit( GetUserUnits(), dy * Ysign ); line.Printf( locformatter, dXpos, dYpos ); SetStatusText( line, 3 ); diff --git a/pcbnew/dialogs/dialog_create_array.cpp b/pcbnew/dialogs/dialog_create_array.cpp index e822f5930a..63a13bb9c4 100644 --- a/pcbnew/dialogs/dialog_create_array.cpp +++ b/pcbnew/dialogs/dialog_create_array.cpp @@ -24,11 +24,8 @@ #include #include -#include #include #include - -#include #include #include @@ -39,19 +36,25 @@ DIALOG_CREATE_ARRAY::CREATE_ARRAY_DIALOG_ENTRIES DIALOG_CREATE_ARRAY::m_options; -DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( PCB_BASE_FRAME* aParent, - bool enableNumbering, +DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( PCB_BASE_FRAME* aParent, bool enableNumbering, wxPoint aOrigPos ) : DIALOG_CREATE_ARRAY_BASE( aParent ), CONFIG_SAVE_RESTORE_WINDOW( m_options.m_optionsSet ), m_settings( NULL ), + m_hSpacing( aParent, m_labelDx, m_entryDx, m_unitLabelDx, true ), + m_vSpacing( aParent, m_labelDy, m_entryDy, m_unitLabelDy, true ), + m_hOffset( aParent, m_labelOffsetX, m_entryOffsetX, m_unitLabelOffsetX, true ), + m_vOffset( aParent, m_labelOffsetY, m_entryOffsetY, m_unitLabelOffsetY, true ), + m_hCentre( aParent, m_labelCentreX, m_entryCentreX, m_unitLabelCentreX, true ), + m_vCentre( aParent, m_labelCentreY, m_entryCentreY, m_unitLabelCentreY, true ), + m_circRadius( aParent, m_labelCircRadius, m_valueCircRadius, m_unitLabelCircRadius, true ), m_originalItemPosition( aOrigPos ), m_numberingEnabled(enableNumbering) { // Set up numbering scheme drop downs // // character set - // NOTE: do not change the order of this relative to the ARRAY_NUMBERING_TYPE_T enum + // NOTE: do not change the order of this relative to the NUMBERING_TYPE_T enum const wxString charSetDescriptions[] = { _( "Numerals (0,1,2,...,9,10)" ), @@ -97,18 +100,6 @@ DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( PCB_BASE_FRAME* aParent, RestoreConfigToControls(); - // Load units into labels - { - const wxString lengthUnit = GetAbbreviatedUnitsLabel( g_UserUnit ); - - m_unitLabelCentreX->SetLabelText( lengthUnit ); - m_unitLabelCentreY->SetLabelText( lengthUnit ); - m_unitLabelDx->SetLabelText( lengthUnit ); - m_unitLabelDy->SetLabelText( lengthUnit ); - m_unitLabelOffsetX->SetLabelText( lengthUnit ); - m_unitLabelOffsetY->SetLabelText( lengthUnit ); - } - // Run the callbacks once to process the dialog contents setControlEnablement(); calculateCircularArrayProperties(); @@ -133,8 +124,7 @@ void DIALOG_CREATE_ARRAY::OnParameterChanged( wxCommandEvent& event ) } -static const wxString& alphabetFromNumberingScheme( - DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T type ) +static const wxString& alphabetFromNumberingScheme( DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T type ) { static const wxString alphaNumeric = "0123456789"; static const wxString alphaHex = "0123456789ABCDEF"; @@ -144,20 +134,11 @@ static const wxString& alphabetFromNumberingScheme( switch( type ) { default: - case DIALOG_CREATE_ARRAY::NUMBERING_NUMERIC: - break; - - case DIALOG_CREATE_ARRAY::NUMBERING_HEX: - return alphaHex; - - case DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_NO_IOSQXZ: - return alphaNoIOSQXZ; - - case DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_FULL: - return alphaFull; + case DIALOG_CREATE_ARRAY::NUMBERING_NUMERIC: return alphaNumeric; + case DIALOG_CREATE_ARRAY::NUMBERING_HEX: return alphaHex; + case DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_NO_IOSQXZ: return alphaNoIOSQXZ; + case DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_FULL: return alphaFull; } - - return alphaNumeric; } @@ -165,16 +146,15 @@ static const wxString& alphabetFromNumberingScheme( * @return False for schemes like 0,1...9,10 * True for schemes like A,B..Z,AA (where the tens column starts with char 0) */ -static bool schemeNonUnitColsStartAt0( DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T type ) +static bool schemeNonUnitColsStartAt0( DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T type ) { return type == DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_FULL || type == DIALOG_CREATE_ARRAY::NUMBERING_ALPHA_NO_IOSQXZ; } -static bool getNumberingOffset( const wxString& str, - DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T type, - int& offsetToFill ) +static bool getNumberingOffset( const wxString& str, DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T type, + int& offsetToFill ) { const wxString& alphabet = alphabetFromNumberingScheme( type ); @@ -215,9 +195,8 @@ static bool getNumberingOffset( const wxString& str, */ static bool validateNumberingTypeAndOffset( const wxTextCtrl& offsetEntry, const wxChoice& typeEntry, - DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T& type, - int& offset, - wxArrayString& errors ) + DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T& type, + int& offset, wxArrayString& errors ) { const int typeVal = typeEntry.GetSelection(); // mind undefined casts to enums (should not be able to happen) @@ -225,7 +204,7 @@ static bool validateNumberingTypeAndOffset( const wxTextCtrl& offsetEntry, if( ok ) { - type = (DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T) typeVal; + type = (DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T) typeVal; } else { @@ -263,10 +242,8 @@ static bool validateNumberingTypeAndOffset( const wxTextCtrl& offsetEntry, * @param errors a list of errors to add any error to * @return valid */ -static bool validateLongEntry( const wxTextEntry& entry, - long& dest, - const wxString& description, - wxArrayString& errors ) +static bool validateLongEntry( const wxTextEntry& entry, long& dest, const wxString& description, + wxArrayString& errors ) { bool ok = true; @@ -284,10 +261,8 @@ static bool validateLongEntry( const wxTextEntry& entry, bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() { - ARRAY_OPTIONS* newSettings = NULL; - - wxArrayString errorStrs; - + ARRAY_OPTIONS* newSettings = NULL; + wxArrayString errors; const wxWindow* page = m_gridTypeNotebook->GetCurrentPage(); if( page == m_gridPanel ) @@ -296,20 +271,16 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() bool ok = true; // ints - ok = ok && validateLongEntry(*m_entryNx, newGrid->m_nx, _("horizontal count"), - errorStrs); - ok = ok && validateLongEntry(*m_entryNy, newGrid->m_ny, _("vertical count"), - errorStrs); + ok = ok && validateLongEntry(*m_entryNx, newGrid->m_nx, _("horizontal count"), errors); + ok = ok && validateLongEntry(*m_entryNy, newGrid->m_ny, _("vertical count"), errors); + newGrid->m_delta.x = m_hSpacing.GetValue(); + newGrid->m_delta.y = m_vSpacing.GetValue(); - newGrid->m_delta.x = DoubleValueFromString( g_UserUnit, m_entryDx->GetValue() ); - newGrid->m_delta.y = DoubleValueFromString( g_UserUnit, m_entryDy->GetValue() ); + newGrid->m_offset.x = m_hOffset.GetValue(); + newGrid->m_offset.y = m_vOffset.GetValue(); - newGrid->m_offset.x = DoubleValueFromString( g_UserUnit, m_entryOffsetX->GetValue() ); - newGrid->m_offset.y = DoubleValueFromString( g_UserUnit, m_entryOffsetY->GetValue() ); - - ok = ok && validateLongEntry(*m_entryStagger, newGrid->m_stagger, _("stagger"), - errorStrs); + ok = ok && validateLongEntry(*m_entryStagger, newGrid->m_stagger, _("stagger"), errors); newGrid->m_stagger_rows = m_radioBoxGridStaggerType->GetSelection() == 0; @@ -323,16 +294,16 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() newGrid->m_2dArrayNumbering = m_radioBoxGridNumberingScheme->GetSelection() != 0; bool numOk = validateNumberingTypeAndOffset( - *m_entryGridPriNumberingOffset, *m_choicePriAxisNumbering, - newGrid->m_priAxisNumType, newGrid->m_numberingOffsetX, - errorStrs ); + *m_entryGridPriNumberingOffset, *m_choicePriAxisNumbering, + newGrid->m_priAxisNumType, newGrid->m_numberingOffsetX, + errors ); if( newGrid->m_2dArrayNumbering ) { numOk = validateNumberingTypeAndOffset( - *m_entryGridSecNumberingOffset, *m_choiceSecAxisNumbering, - newGrid->m_secAxisNumType, newGrid->m_numberingOffsetY, - errorStrs ) && numOk; + *m_entryGridSecNumberingOffset, *m_choiceSecAxisNumbering, + newGrid->m_secAxisNumType, newGrid->m_numberingOffsetY, + errors ) && numOk; } ok = ok && numOk; @@ -351,16 +322,13 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() ARRAY_CIRCULAR_OPTIONS* newCirc = new ARRAY_CIRCULAR_OPTIONS(); bool ok = true; - newCirc->m_centre.x = DoubleValueFromString( g_UserUnit, m_entryCentreX->GetValue() ); - newCirc->m_centre.y = DoubleValueFromString( g_UserUnit, m_entryCentreY->GetValue() ); - + newCirc->m_centre.x = m_hCentre.GetValue(); + newCirc->m_centre.y = m_vCentre.GetValue(); newCirc->m_angle = DoubleValueFromString( DEGREES, m_entryCircAngle->GetValue() ); - ok = ok && validateLongEntry(*m_entryCircCount, newCirc->m_nPts, - _("point count"), errorStrs); + ok = ok && validateLongEntry(*m_entryCircCount, newCirc->m_nPts, _("point count"), errors); newCirc->m_rotateItems = m_entryRotateItemsCb->GetValue(); - newCirc->m_shouldNumber = m_numberingEnabled; if ( m_numberingEnabled ) @@ -368,9 +336,8 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() newCirc->m_numberingStartIsSpecified = m_rbCircStartNumberingOpt->GetSelection() == 1; newCirc->m_numberingType = NUMBERING_NUMERIC; - ok = ok && validateLongEntry(*m_entryCircNumberingStart, - newCirc->m_numberingOffset, - _("numbering start"), errorStrs); + ok = ok && validateLongEntry(*m_entryCircNumberingStart, newCirc->m_numberingOffset, + _("numbering start"), errors); } // Only use settings if all values are good @@ -395,10 +362,10 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() { wxString errorStr; - if( errorStrs.IsEmpty() ) + if( errors.IsEmpty() ) errorStr = _("Bad parameters"); else - errorStr = boost::algorithm::join( errorStrs, "\n" ); + errorStr = boost::algorithm::join( errors, "\n" ); wxMessageBox( errorStr ); return false; @@ -453,23 +420,20 @@ void DIALOG_CREATE_ARRAY::setControlEnablement() void DIALOG_CREATE_ARRAY::calculateCircularArrayProperties() { - wxPoint centre; - - centre.x = DoubleValueFromString( g_UserUnit, m_entryCentreX->GetValue() ); - centre.y = DoubleValueFromString( g_UserUnit, m_entryCentreY->GetValue() ); + wxPoint centre( m_hCentre.GetValue(), m_vCentre.GetValue() ); // Find the radius, etc of the circle centre -= m_originalItemPosition; const double radius = VECTOR2I(centre.x, centre.y).EuclideanNorm(); - m_labelCircRadiusValue->SetLabelText( StringFromValue( g_UserUnit, int(radius), true ) ); + m_circRadius.SetValue( int( radius ) ); } // ARRAY OPTION implementation functions -------------------------------------- wxString DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::getCoordinateNumber( int n, - ARRAY_NUMBERING_TYPE_T type ) + NUMBERING_TYPE_T type ) { wxString itemNum; const wxString& alphabet = alphabetFromNumberingScheme( type ); diff --git a/pcbnew/dialogs/dialog_create_array.h b/pcbnew/dialogs/dialog_create_array.h index aaced2a845..50450fa83c 100644 --- a/pcbnew/dialogs/dialog_create_array.h +++ b/pcbnew/dialogs/dialog_create_array.h @@ -32,6 +32,7 @@ #include #include +#include class CONFIG_SAVE_RESTORE_WINDOW { @@ -182,7 +183,7 @@ public: }; // NOTE: do not change order relative to charSetDescriptions - enum ARRAY_NUMBERING_TYPE_T + enum NUMBERING_TYPE_T { NUMBERING_NUMERIC = 0, ///< Arabic numerals: 0,1,2,3,4,5,6,7,8,9,10,11... NUMBERING_HEX, @@ -245,7 +246,7 @@ public: } protected: - static wxString getCoordinateNumber( int n, ARRAY_NUMBERING_TYPE_T type ); + static wxString getCoordinateNumber( int n, NUMBERING_TYPE_T type ); // allow the dialog to set directly friend class DIALOG_CREATE_ARRAY; @@ -282,7 +283,7 @@ public: bool m_stagger_rows; bool m_2dArrayNumbering; int m_numberingOffsetX, m_numberingOffsetY; - ARRAY_NUMBERING_TYPE_T m_priAxisNumType, m_secAxisNumType; + NUMBERING_TYPE_T m_priAxisNumType, m_secAxisNumType; void TransformItem( int n, BOARD_ITEM* item, const wxPoint& rotPoint ) const override; int GetArraySize() const override; @@ -307,7 +308,7 @@ private: double m_angle; wxPoint m_centre; bool m_rotateItems; - ARRAY_NUMBERING_TYPE_T m_numberingType; + NUMBERING_TYPE_T m_numberingType; long m_numberingOffset; void TransformItem( int n, BOARD_ITEM* item, const wxPoint& rotPoint ) const override; @@ -338,6 +339,11 @@ private: */ ARRAY_OPTIONS* m_settings; + UNIT_BINDER m_hSpacing, m_vSpacing; + UNIT_BINDER m_hOffset, m_vOffset; + UNIT_BINDER m_hCentre, m_vCentre; + UNIT_BINDER m_circRadius; + /* * The position of the original item(s), used for finding radius, etc */ diff --git a/pcbnew/dialogs/dialog_create_array_base.cpp b/pcbnew/dialogs/dialog_create_array_base.cpp index 96ccde39b3..f5456057b6 100644 --- a/pcbnew/dialogs/dialog_create_array_base.cpp +++ b/pcbnew/dialogs/dialog_create_array_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -213,9 +213,13 @@ DIALOG_CREATE_ARRAY_BASE::DIALOG_CREATE_ARRAY_BASE( wxWindow* parent, wxWindowID m_labelCircRadius->Wrap( -1 ); gbSizer2->Add( m_labelCircRadius, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - m_labelCircRadiusValue = new wxStaticText( m_circularPanel, wxID_ANY, _("0 mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_labelCircRadiusValue->Wrap( -1 ); - gbSizer2->Add( m_labelCircRadiusValue, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); + m_valueCircRadius = new wxStaticText( m_circularPanel, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + m_valueCircRadius->Wrap( -1 ); + gbSizer2->Add( m_valueCircRadius, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); + + m_unitLabelCircRadius = new wxStaticText( m_circularPanel, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_unitLabelCircRadius->Wrap( -1 ); + gbSizer2->Add( m_unitLabelCircRadius, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxTOP|wxBOTTOM|wxRIGHT, 5 ); m_labelCircAngle = new wxStaticText( m_circularPanel, wxID_ANY, _("Angle:"), wxDefaultPosition, wxDefaultSize, 0 ); m_labelCircAngle->Wrap( -1 ); diff --git a/pcbnew/dialogs/dialog_create_array_base.fbp b/pcbnew/dialogs/dialog_create_array_base.fbp index 739b1fe377..cbf6e50b58 100644 --- a/pcbnew/dialogs/dialog_create_array_base.fbp +++ b/pcbnew/dialogs/dialog_create_array_base.fbp @@ -14,7 +14,6 @@ dialog_create_array_base 1000 none - 1 DIALOG_CREATE_ARRAY_BASE @@ -3724,7 +3723,7 @@ 0 0 wxID_ANY - 0 mm + 0 0 @@ -3732,7 +3731,7 @@ 0 1 - m_labelCircRadiusValue + m_valueCircRadius 1 @@ -3775,6 +3774,92 @@ + + 5 + 1 + 2 + wxTOP|wxBOTTOM|wxRIGHT + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + + 0 + + + 0 + + 1 + m_unitLabelCircRadius + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + 5 1 diff --git a/pcbnew/dialogs/dialog_create_array_base.h b/pcbnew/dialogs/dialog_create_array_base.h index 66000addfb..7b72775eaf 100644 --- a/pcbnew/dialogs/dialog_create_array_base.h +++ b/pcbnew/dialogs/dialog_create_array_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -88,7 +88,8 @@ class DIALOG_CREATE_ARRAY_BASE : public DIALOG_SHIM TEXT_CTRL_EVAL* m_entryCentreY; wxStaticText* m_unitLabelCentreY; wxStaticText* m_labelCircRadius; - wxStaticText* m_labelCircRadiusValue; + wxStaticText* m_valueCircRadius; + wxStaticText* m_unitLabelCircRadius; wxStaticText* m_labelCircAngle; TEXT_CTRL_EVAL* m_entryCircAngle; wxStaticText* m_unitLabelCircAngle; diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 33dc8abd01..133f3c9f11 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -28,14 +28,10 @@ #include #include #include -#include -#include #include #include #include - #include -#include #include #include #include diff --git a/pcbnew/dialogs/dialog_target_properties_base.cpp b/pcbnew/dialogs/dialog_target_properties_base.cpp index 45d07e8db3..b43751c95f 100644 --- a/pcbnew/dialogs/dialog_target_properties_base.cpp +++ b/pcbnew/dialogs/dialog_target_properties_base.cpp @@ -1,15 +1,15 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 21 2016) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "dialog_target_properties_base.h" /////////////////////////////////////////////////////////////////////////// -TARGET_PROPERTIES_DIALOG_EDITOR_BASE::TARGET_PROPERTIES_DIALOG_EDITOR_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_TARGET_PROPERTIES_BASE::DIALOG_TARGET_PROPERTIES_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( wxDefaultSize, wxDefaultSize ); @@ -25,27 +25,27 @@ TARGET_PROPERTIES_DIALOG_EDITOR_BASE::TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWi fgSizer->SetFlexibleDirection( wxBOTH ); fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_staticTextSize = new wxStaticText( this, wxID_ANY, _("Size:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextSize->Wrap( -1 ); - fgSizer->Add( m_staticTextSize, 0, wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + m_sizeLabel = new wxStaticText( this, wxID_ANY, _("Size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sizeLabel->Wrap( -1 ); + fgSizer->Add( m_sizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_TargetSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer->Add( m_TargetSizeCtrl, 0, wxALL|wxEXPAND, 5 ); + m_sizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer->Add( m_sizeCtrl, 0, wxALL|wxEXPAND, 5 ); - m_staticTextSizeUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextSizeUnits->Wrap( -1 ); - fgSizer->Add( m_staticTextSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + m_sizeUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sizeUnits->Wrap( -1 ); + fgSizer->Add( m_sizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); - m_staticTextThickness = new wxStaticText( this, wxID_ANY, _("Thickness:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextThickness->Wrap( -1 ); - fgSizer->Add( m_staticTextThickness, 0, wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + m_thicknessLabel = new wxStaticText( this, wxID_ANY, _("Thickness:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_thicknessLabel->Wrap( -1 ); + fgSizer->Add( m_thicknessLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_TargetThicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer->Add( m_TargetThicknessCtrl, 0, wxEXPAND|wxALL, 5 ); + m_thicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer->Add( m_thicknessCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_staticTextThicknessUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextThicknessUnits->Wrap( -1 ); - fgSizer->Add( m_staticTextThicknessUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + m_thicknessUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_thicknessUnits->Wrap( -1 ); + fgSizer->Add( m_thicknessUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); m_staticTextShape = new wxStaticText( this, wxID_ANY, _("Shape:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextShape->Wrap( -1 ); @@ -64,10 +64,10 @@ TARGET_PROPERTIES_DIALOG_EDITOR_BASE::TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWi bSizerUpper->Add( fgSizer, 1, wxEXPAND, 5 ); - bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 ); + bSizerMain->Add( bSizerUpper, 1, wxALL|wxEXPAND, 5 ); m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizerMain->Add( m_staticline, 0, wxEXPAND | wxALL, 5 ); + bSizerMain->Add( m_staticline, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); m_sdbSizerButts = new wxStdDialogButtonSizer(); m_sdbSizerButtsOK = new wxButton( this, wxID_OK ); @@ -76,7 +76,7 @@ TARGET_PROPERTIES_DIALOG_EDITOR_BASE::TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWi m_sdbSizerButts->AddButton( m_sdbSizerButtsCancel ); m_sdbSizerButts->Realize(); - bSizerMain->Add( m_sdbSizerButts, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizerMain->Add( m_sdbSizerButts, 0, wxEXPAND|wxALL, 5 ); this->SetSizer( bSizerMain ); @@ -84,16 +84,8 @@ TARGET_PROPERTIES_DIALOG_EDITOR_BASE::TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWi bSizerMain->Fit( this ); this->Centre( wxBOTH ); - - // Connect Events - m_sdbSizerButtsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TARGET_PROPERTIES_DIALOG_EDITOR_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerButtsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TARGET_PROPERTIES_DIALOG_EDITOR_BASE::OnOkClick ), NULL, this ); } -TARGET_PROPERTIES_DIALOG_EDITOR_BASE::~TARGET_PROPERTIES_DIALOG_EDITOR_BASE() +DIALOG_TARGET_PROPERTIES_BASE::~DIALOG_TARGET_PROPERTIES_BASE() { - // Disconnect Events - m_sdbSizerButtsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TARGET_PROPERTIES_DIALOG_EDITOR_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerButtsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( TARGET_PROPERTIES_DIALOG_EDITOR_BASE::OnOkClick ), NULL, this ); - } diff --git a/pcbnew/dialogs/dialog_target_properties_base.fbp b/pcbnew/dialogs/dialog_target_properties_base.fbp index 216ab073fc..72b565163d 100644 --- a/pcbnew/dialogs/dialog_target_properties_base.fbp +++ b/pcbnew/dialogs/dialog_target_properties_base.fbp @@ -42,7 +42,7 @@ wxID_ANY - TARGET_PROPERTIES_DIALOG_EDITOR_BASE + DIALOG_TARGET_PROPERTIES_BASE -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER @@ -95,7 +95,7 @@ none 5 - wxEXPAND + wxALL|wxEXPAND 1 @@ -120,7 +120,7 @@ 0 5 - wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxALL 0 1 @@ -158,7 +158,7 @@ 0 1 - m_staticTextSize + m_sizeLabel 1 @@ -241,7 +241,7 @@ 0 1 - m_TargetSizeCtrl + m_sizeCtrl 1 @@ -332,7 +332,7 @@ 0 1 - m_staticTextSizeUnits + m_sizeUnits 1 @@ -377,7 +377,7 @@ 5 - wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -415,7 +415,7 @@ 0 1 - m_staticTextThickness + m_thicknessLabel 1 @@ -460,7 +460,7 @@ 5 - wxEXPAND|wxALL + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -498,7 +498,7 @@ 0 1 - m_TargetThicknessCtrl + m_thicknessCtrl 1 @@ -551,7 +551,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -589,7 +589,7 @@ 0 1 - m_staticTextThicknessUnits + m_thicknessUnits 1 @@ -818,8 +818,8 @@ - 5 - wxEXPAND | wxALL + 10 + wxEXPAND|wxRIGHT|wxLEFT 0 1 @@ -900,7 +900,7 @@ 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + wxEXPAND|wxALL 0 0 @@ -915,11 +915,11 @@ m_sdbSizerButts protected - OnCancelClick + - OnOkClick + diff --git a/pcbnew/dialogs/dialog_target_properties_base.h b/pcbnew/dialogs/dialog_target_properties_base.h index 03a36775c3..1096f9873e 100644 --- a/pcbnew/dialogs/dialog_target_properties_base.h +++ b/pcbnew/dialogs/dialog_target_properties_base.h @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 21 2016) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __DIALOG_TARGET_PROPERTIES_BASE_H__ @@ -11,8 +11,6 @@ #include #include #include -class DIALOG_SHIM; - #include "dialog_shim.h" #include #include @@ -31,35 +29,30 @@ class DIALOG_SHIM; /////////////////////////////////////////////////////////////////////////////// -/// Class TARGET_PROPERTIES_DIALOG_EDITOR_BASE +/// Class DIALOG_TARGET_PROPERTIES_BASE /////////////////////////////////////////////////////////////////////////////// -class TARGET_PROPERTIES_DIALOG_EDITOR_BASE : public DIALOG_SHIM +class DIALOG_TARGET_PROPERTIES_BASE : public DIALOG_SHIM { private: protected: - wxStaticText* m_staticTextSize; - wxTextCtrl* m_TargetSizeCtrl; - wxStaticText* m_staticTextSizeUnits; - wxStaticText* m_staticTextThickness; - wxTextCtrl* m_TargetThicknessCtrl; - wxStaticText* m_staticTextThicknessUnits; + wxStaticText* m_sizeLabel; + wxTextCtrl* m_sizeCtrl; + wxStaticText* m_sizeUnits; + wxStaticText* m_thicknessLabel; + wxTextCtrl* m_thicknessCtrl; + wxStaticText* m_thicknessUnits; wxStaticText* m_staticTextShape; wxChoice* m_TargetShape; wxStaticLine* m_staticline; wxStdDialogButtonSizer* m_sdbSizerButts; wxButton* m_sdbSizerButtsOK; wxButton* m_sdbSizerButtsCancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } - public: - TARGET_PROPERTIES_DIALOG_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Target Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~TARGET_PROPERTIES_DIALOG_EDITOR_BASE(); + DIALOG_TARGET_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Target Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_TARGET_PROPERTIES_BASE(); }; diff --git a/pcbnew/hotkeys_footprint_editor.cpp b/pcbnew/hotkeys_footprint_editor.cpp index 78dd3a9124..bca1de3360 100644 --- a/pcbnew/hotkeys_footprint_editor.cpp +++ b/pcbnew/hotkeys_footprint_editor.cpp @@ -116,8 +116,8 @@ bool FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPos break; case HK_SWITCH_UNITS: - cmd.SetId( (g_UserUnit == INCHES) ? - ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH ); + cmd.SetId( (GetUserUnits() == INCHES) ? ID_TB_OPTIONS_SELECT_UNIT_MM + : ID_TB_OPTIONS_SELECT_UNIT_INCH ); GetEventHandler()->ProcessEvent( cmd ); break; diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 4eb3a60535..f7f2cf6f0f 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -856,7 +856,7 @@ void PCB_BASE_FRAME::UpdateStatusBar() ro = hypot( dx, dy ); wxString formatter; - switch( g_UserUnit ) + switch( GetUserUnits() ) { case INCHES: formatter = wxT( "r %.6f theta %.1f" ); @@ -875,19 +875,19 @@ void PCB_BASE_FRAME::UpdateStatusBar() break; } - line.Printf( formatter, To_User_Unit( g_UserUnit, ro ), theta ); + line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta ); SetStatusText( line, 3 ); } // Display absolute coordinates: - dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x ); - dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y ); + dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x ); + dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y ); // The following sadly is an if Eeschema/if Pcbnew wxString absformatter; - switch( g_UserUnit ) + switch( GetUserUnits() ) { case INCHES: absformatter = wxT( "X %.6f Y %.6f" ); @@ -917,8 +917,8 @@ void PCB_BASE_FRAME::UpdateStatusBar() // Display relative coordinates: dx = GetCrossHairPosition().x - screen->m_O_Curseur.x; dy = GetCrossHairPosition().y - screen->m_O_Curseur.y; - dXpos = To_User_Unit( g_UserUnit, dx ); - dYpos = To_User_Unit( g_UserUnit, dy ); + dXpos = To_User_Unit( GetUserUnits(), dx ); + dYpos = To_User_Unit( GetUserUnits(), dy ); // We already decided the formatter above line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) ); @@ -979,7 +979,7 @@ void PCB_BASE_FRAME::SaveSettings( wxConfigBase* aCfg ) aCfg->Write( baseCfgName + UserGridSizeXEntry, To_User_Unit( m_UserUnits, m_UserGridSize.x ) ); aCfg->Write( baseCfgName + UserGridSizeYEntry, To_User_Unit( m_UserUnits, m_UserGridSize.y ) ); - aCfg->Write( baseCfgName + UserGridUnitsEntry, ( long )g_UserUnit ); + aCfg->Write( baseCfgName + UserGridUnitsEntry, ( long )m_UserUnits ); aCfg->Write( baseCfgName + DisplayPadFillEntry, m_DisplayOptions.m_DisplayPadFill ); aCfg->Write( baseCfgName + DisplayViaFillEntry, m_DisplayOptions.m_DisplayViaFill ); aCfg->Write( baseCfgName + DisplayPadNumberEntry, m_DisplayOptions.m_DisplayPadNum ); @@ -1020,7 +1020,7 @@ void PCB_BASE_FRAME::updateGridSelectBox() // Update grid values with the current units setting. m_gridSelectBox->Clear(); wxArrayString gridsList; - int icurr = GetScreen()->BuildGridsChoiceList( gridsList, g_UserUnit != INCHES ); + int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES ); for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ ) { diff --git a/pcbnew/target_edit.cpp b/pcbnew/target_edit.cpp index 91a92b64fb..9a4490d026 100644 --- a/pcbnew/target_edit.cpp +++ b/pcbnew/target_edit.cpp @@ -41,7 +41,7 @@ #include #include - +#include // Routines Locales static void AbortMoveAndEditTarget( EDA_DRAW_PANEL* Panel, wxDC* DC ); @@ -59,73 +59,68 @@ static PCB_TARGET s_TargetCopy( NULL ); /* Used to store "old" values of the * cancel operations) */ -/*****************************************/ -/* class TARGET_PROPERTIES_DIALOG_EDITOR */ -/*****************************************/ +/**********************************/ +/* class DIALOG_TARGET_PROPERTIES */ +/**********************************/ -class TARGET_PROPERTIES_DIALOG_EDITOR : public TARGET_PROPERTIES_DIALOG_EDITOR_BASE +class DIALOG_TARGET_PROPERTIES : public DIALOG_TARGET_PROPERTIES_BASE { private: PCB_EDIT_FRAME* m_Parent; wxDC* m_DC; PCB_TARGET* m_Target; + UNIT_BINDER m_Size; + UNIT_BINDER m_Thickness; + public: - TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME* parent, PCB_TARGET* Mire, wxDC* DC ); - ~TARGET_PROPERTIES_DIALOG_EDITOR() { } + DIALOG_TARGET_PROPERTIES( PCB_EDIT_FRAME* aParent, PCB_TARGET* aTarget, wxDC* aDC ); + ~DIALOG_TARGET_PROPERTIES() { } private: - void OnOkClick( wxCommandEvent& event ) override; - void OnCancelClick( wxCommandEvent& event ) override; + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; }; void PCB_EDIT_FRAME::ShowTargetOptionsDialog( PCB_TARGET* aTarget, wxDC* DC ) { - TARGET_PROPERTIES_DIALOG_EDITOR* frame = - new TARGET_PROPERTIES_DIALOG_EDITOR( this, aTarget, DC ); + DIALOG_TARGET_PROPERTIES dialog( this, aTarget, DC ); - frame->ShowModal(); - frame->Destroy(); + dialog.ShowModal(); } -TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME* parent, - PCB_TARGET* aTarget, wxDC* DC ) : - TARGET_PROPERTIES_DIALOG_EDITOR_BASE( parent ) +DIALOG_TARGET_PROPERTIES::DIALOG_TARGET_PROPERTIES( PCB_EDIT_FRAME* aParent, PCB_TARGET* aTarget, + wxDC* aDC ) : + DIALOG_TARGET_PROPERTIES_BASE( aParent ), + m_Parent( aParent ), + m_DC( aDC ), + m_Target( aTarget ), + m_Size( aParent, m_sizeLabel, m_sizeCtrl, m_sizeUnits, true, 0 ), + m_Thickness( aParent, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true, 0 ) { - m_Parent = parent; - m_DC = DC; - m_Target = aTarget; + m_sdbSizerButtsOK->SetDefault(); - // Size: - m_staticTextSizeUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); - m_TargetSizeCtrl->SetValue( StringFromValue( g_UserUnit, m_Target->GetSize() ) ); - - // Thickness: - m_staticTextThicknessUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); - m_TargetThicknessCtrl->SetValue( StringFromValue( g_UserUnit, m_Target->GetWidth() ) ); - - // Shape - m_TargetShape->SetSelection( m_Target->GetShape() ? 1 : 0 ); - - // OK button on return key. - SetDefaultItem( m_sdbSizerButtsOK ); + SetInitialFocus( m_sizeCtrl ); // Now all widgets have the size fixed, call FinishDialogSettings FinishDialogSettings(); } -void TARGET_PROPERTIES_DIALOG_EDITOR::OnCancelClick( wxCommandEvent& event ) +bool DIALOG_TARGET_PROPERTIES::TransferDataToWindow() { - EndModal( -1 ); + m_Size.SetValue( m_Target->GetSize() ); + m_Thickness.SetValue( m_Target->GetWidth() ); + + m_TargetShape->SetSelection( m_Target->GetShape() ? 1 : 0 ); + + return true; } -/* Updates the different parameters for the component being edited - */ -void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event ) +bool DIALOG_TARGET_PROPERTIES::TransferDataFromWindow() { BOARD_COMMIT commit( m_Parent ); commit.Modify( m_Target ); @@ -138,14 +133,10 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event ) if( m_Target->GetFlags() != 0 ) // other edition in progress (MOVE, NEW ..) m_Target->SetFlags( IN_EDIT ); // set flag in edit to force - // undo/redo/abort proper operation - - int tmp = ValueFromString( g_UserUnit, m_TargetThicknessCtrl->GetValue() ); - m_Target->SetWidth( tmp ); - - MireDefaultSize = ValueFromString( g_UserUnit, m_TargetSizeCtrl->GetValue() ); - m_Target->SetSize( MireDefaultSize ); + // undo/redo/abort proper operation + m_Target->SetWidth( m_Thickness.GetValue() ); + m_Target->SetSize( m_Size.GetValue() ); m_Target->SetShape( m_TargetShape->GetSelection() ? 1 : 0 ); if( m_DC ) @@ -154,7 +145,7 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event ) if( pushCommit ) commit.Push( _( "Modified alignment target" ) ); - EndModal( 1 ); + return true; } diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index e1cda010ba..9f09bebf32 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1179,7 +1179,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) KIGFX::PREVIEW::ARC_GEOM_MANAGER arcManager; // Arc drawing assistant overlay - KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager ); + KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() ); // Add a VIEW_GROUP that serves as a preview for the new item SELECTION preview; diff --git a/pcbnew/tools/size_menu.cpp b/pcbnew/tools/size_menu.cpp index a68578db33..20a3c9d893 100644 --- a/pcbnew/tools/size_menu.cpp +++ b/pcbnew/tools/size_menu.cpp @@ -21,7 +21,9 @@ #include "size_menu.h" +#include #include +#include #include #include @@ -124,7 +126,9 @@ void TRACK_VIA_SIZE_MENU::update() wxString TRACK_VIA_SIZE_MENU::getTrackDescription( unsigned int aIndex ) const { - wxString desc; + wxString desc; + auto frame = dynamic_cast( getToolManager()->GetEditFrame() ); + EDA_UNITS_T userUnits = frame->GetUserUnits(); if( m_vias ) // == if( m_tracks && m_vias ) desc = _( "Track "); @@ -132,7 +136,7 @@ wxString TRACK_VIA_SIZE_MENU::getTrackDescription( unsigned int aIndex ) const if( aIndex == 0 ) desc << _( "net class width" ); else - desc << StringFromValue( g_UserUnit, m_designSettings->m_TrackWidthList[aIndex], true ); + desc << StringFromValue( userUnits, m_designSettings->m_TrackWidthList[aIndex], true ); return desc; } @@ -140,7 +144,10 @@ wxString TRACK_VIA_SIZE_MENU::getTrackDescription( unsigned int aIndex ) const wxString TRACK_VIA_SIZE_MENU::getViaDescription( unsigned int aIndex ) const { - wxString desc; + wxString desc; + auto frame = dynamic_cast( getToolManager()->GetEditFrame() ); + EDA_UNITS_T userUnits = frame->GetUserUnits(); + VIA_DIMENSION viaDimension = m_designSettings->m_ViasDimensionsList[ aIndex ]; if( m_tracks ) // == if( m_tracks && m_vias ) desc = _( "Via " ); @@ -151,18 +158,12 @@ wxString TRACK_VIA_SIZE_MENU::getViaDescription( unsigned int aIndex ) const } else { - desc << StringFromValue( g_UserUnit, - m_designSettings->m_ViasDimensionsList[aIndex].m_Diameter, true ); + desc << StringFromValue( userUnits, viaDimension.m_Diameter, true ); if( m_designSettings->m_ViasDimensionsList[aIndex].m_Drill <= 0 ) - { desc << _( ", drill: default" ); - } else - { - desc << _( ", drill: " ) << StringFromValue( g_UserUnit, - m_designSettings->m_ViasDimensionsList[aIndex].m_Drill, true ); - } + desc << _( ", drill: " ) << StringFromValue( userUnits, viaDimension.m_Drill, true ); } return desc;