diff --git a/pcbnew/dialogs/dialog_imported_layers.cpp b/pcbnew/dialogs/dialog_imported_layers.cpp index 6d6f04aec0..8f40fe97f9 100644 --- a/pcbnew/dialogs/dialog_imported_layers.cpp +++ b/pcbnew/dialogs/dialog_imported_layers.cpp @@ -29,9 +29,8 @@ PCB_LAYER_ID DIALOG_IMPORTED_LAYERS::GetSelectedLayerID() wxString selectedKiCadLayerName; long itemIndex = -1; - if( ( itemIndex = m_kicad_layers_list->GetNextItem( - itemIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ) ) - != wxNOT_FOUND ) + if( ( itemIndex = m_kicad_layers_list->GetNextItem( itemIndex, wxLIST_NEXT_ALL, + wxLIST_STATE_SELECTED ) ) != wxNOT_FOUND ) { selectedKiCadLayerName = m_kicad_layers_list->GetItemText( itemIndex ); } @@ -41,10 +40,9 @@ PCB_LAYER_ID DIALOG_IMPORTED_LAYERS::GetSelectedLayerID() } // There should only be one selected (or none) as the list is set with wxLC_SINGLE_SEL style - wxASSERT_MSG( ( m_kicad_layers_list->GetNextItem( - itemIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ) ) - == wxNOT_FOUND, - "There are more than one KiCad layer selected (unexpected)" ); + wxASSERT_MSG( ( m_kicad_layers_list->GetNextItem( itemIndex, wxLIST_NEXT_ALL, + wxLIST_STATE_SELECTED ) ) == wxNOT_FOUND, + "There are more than one KiCad layer selected (unexpected)" ); for( LAYER_NUM layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer ) { @@ -79,8 +77,8 @@ void DIALOG_IMPORTED_LAYERS::AddMappings() int itemIndex = -1; wxArrayInt rowsToDelete; - while( ( itemIndex = m_unmatched_layers_list->GetNextItem( - itemIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ) ) + while( ( itemIndex = m_unmatched_layers_list->GetNextItem( itemIndex, wxLIST_NEXT_ALL, + wxLIST_STATE_SELECTED ) ) != wxNOT_FOUND ) { wxString selectedLayerName = m_unmatched_layers_list->GetItemText( itemIndex ); @@ -150,8 +148,8 @@ void DIALOG_IMPORTED_LAYERS::OnAutoMatchLayersClicked( wxCommandEvent& event ) int itemIndex = -1; wxArrayInt rowsToDelete; - while( ( itemIndex = m_unmatched_layers_list->GetNextItem( - itemIndex, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE ) ) + while( ( itemIndex = m_unmatched_layers_list->GetNextItem( itemIndex, wxLIST_NEXT_ALL, + wxLIST_STATE_DONTCARE ) ) != wxNOT_FOUND ) { wxString layerName = m_unmatched_layers_list->GetItemText( itemIndex ); @@ -187,8 +185,8 @@ void DIALOG_IMPORTED_LAYERS::OnAutoMatchLayersClicked( wxCommandEvent& event ) DIALOG_IMPORTED_LAYERS::DIALOG_IMPORTED_LAYERS( wxWindow* aParent, - const std::vector& aLayerDesc ) - : DIALOG_IMPORTED_LAYERS_BASE( aParent ) + const std::vector& aLayerDesc ) : + DIALOG_IMPORTED_LAYERS_BASE( aParent ) { LSET kiCadLayers; @@ -200,25 +198,32 @@ DIALOG_IMPORTED_LAYERS::DIALOG_IMPORTED_LAYERS( wxWindow* aParent, kiCadLayers |= inLayer.PermittedLayers; } + int maxTextWidth = 0; + + for( const INPUT_LAYER_DESC& layer : m_input_layers ) + maxTextWidth = std::max( maxTextWidth, GetTextExtent( layer.Name ).x ); // Initialize columns in the wxListCtrl elements: wxListItem importedLayersHeader; importedLayersHeader.SetId( 0 ); importedLayersHeader.SetText( _( "Imported Layer" ) ); - importedLayersHeader.SetWidth( 200 ); + importedLayersHeader.SetWidth( maxTextWidth + 15 ); m_unmatched_layers_list->InsertColumn( 0, importedLayersHeader ); + int kicadMaxTextWidth = GetTextExtent( wxT( "User.Drawings" ) ).x; + wxListItem kicadLayersHeader; kicadLayersHeader.SetId( 0 ); kicadLayersHeader.SetText( _( "KiCad Layer" ) ); - kicadLayersHeader.SetWidth( 100 ); + kicadLayersHeader.SetWidth( kicadMaxTextWidth + 5 ); m_kicad_layers_list->InsertColumn( 0, kicadLayersHeader ); kicadLayersHeader.SetId( 1 ); + importedLayersHeader.SetWidth( maxTextWidth + 15 ); + kicadLayersHeader.SetWidth( kicadMaxTextWidth + 5 ); m_matched_layers_list->InsertColumn( 0, importedLayersHeader ); m_matched_layers_list->InsertColumn( 1, kicadLayersHeader ); - // Load the input layer list to unmatched layers int row = 0; @@ -248,6 +253,7 @@ DIALOG_IMPORTED_LAYERS::DIALOG_IMPORTED_LAYERS( wxWindow* aParent, m_sdbSizerOK->SetDefault(); + Fit(); FinishDialogSettings(); } @@ -266,7 +272,7 @@ LAYER_MAP DIALOG_IMPORTED_LAYERS::GetMapModal( wxWindow* aParent, { wxMessageBox( _( "All layers must be matched. Please click on 'Auto-Matched Layers' " "to automatically match the remaining layers." ), - _( "Unmatched Layers" ), wxICON_ERROR | wxOK ); + _( "Unmatched Layers" ), wxICON_ERROR | wxOK ); } else { diff --git a/pcbnew/dialogs/dialog_imported_layers_base.cpp b/pcbnew/dialogs/dialog_imported_layers_base.cpp index cff6ae9ca9..9d9a8c1cf3 100644 --- a/pcbnew/dialogs/dialog_imported_layers_base.cpp +++ b/pcbnew/dialogs/dialog_imported_layers_base.cpp @@ -11,7 +11,7 @@ DIALOG_IMPORTED_LAYERS_BASE::DIALOG_IMPORTED_LAYERS_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( wxSize( 600,350 ), wxDefaultSize ); + this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); bSizerMain = new wxBoxSizer( wxVERTICAL ); @@ -21,69 +21,67 @@ DIALOG_IMPORTED_LAYERS_BASE::DIALOG_IMPORTED_LAYERS_BASE( wxWindow* parent, wxWi wxStaticBoxSizer* sbSizer1; sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Unmatched Layers") ), wxHORIZONTAL ); - wxBoxSizer* bSizerUnmatched; - bSizerUnmatched = new wxBoxSizer( wxVERTICAL ); + wxFlexGridSizer* fgSizer1; + fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 ); + fgSizer1->AddGrowableCol( 0 ); + fgSizer1->AddGrowableCol( 1 ); + fgSizer1->AddGrowableRow( 1 ); + fgSizer1->SetFlexibleDirection( wxVERTICAL ); + fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_staticText1 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Imported Layers"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText1->Wrap( -1 ); - bSizerUnmatched->Add( m_staticText1, 0, wxALL, 5 ); + m_lblImportedLayers = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Imported Layers"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblImportedLayers->Wrap( -1 ); + fgSizer1->Add( m_lblImportedLayers, 0, wxALL, 5 ); - m_unmatched_layers_list = new wxListCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( 200,-1 ), wxLC_NO_HEADER|wxLC_REPORT ); - m_unmatched_layers_list->SetMaxSize( wxSize( 300,-1 ) ); + m_lblKicadLayers = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("KiCad Layers"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblKicadLayers->Wrap( -1 ); + fgSizer1->Add( m_lblKicadLayers, 0, wxALL, 5 ); - bSizerUnmatched->Add( m_unmatched_layers_list, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + m_unmatched_layers_list = new wxListCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxLC_NO_HEADER|wxLC_REPORT ); + m_unmatched_layers_list->SetMinSize( wxSize( 120,-1 ) ); + fgSizer1->Add( m_unmatched_layers_list, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - sbSizer1->Add( bSizerUnmatched, 1, wxEXPAND, 5 ); - - wxBoxSizer* bSizerKiCad; - bSizerKiCad = new wxBoxSizer( wxVERTICAL ); - - m_staticText2 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("KiCad Layers"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText2->Wrap( -1 ); - bSizerKiCad->Add( m_staticText2, 0, wxALL, 5 ); - - m_kicad_layers_list = new wxListCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( 120,-1 ), wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL ); + m_kicad_layers_list = new wxListCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL ); m_kicad_layers_list->SetMinSize( wxSize( 120,-1 ) ); - m_kicad_layers_list->SetMaxSize( wxSize( 150,-1 ) ); - bSizerKiCad->Add( m_kicad_layers_list, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + fgSizer1->Add( m_kicad_layers_list, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - sbSizer1->Add( bSizerKiCad, 0, wxEXPAND, 5 ); + sbSizer1->Add( fgSizer1, 1, wxEXPAND, 5 ); bSizerTop->Add( sbSizer1, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - wxStaticBoxSizer* sbSizer2; - sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); + wxBoxSizer* bSizer6; + bSizer6 = new wxBoxSizer( wxVERTICAL ); - m_button_add = new wxButton( sbSizer2->GetStaticBox(), wxID_ANY, _(">"), wxDefaultPosition, wxSize( 30,100 ), 0 ); + m_button_add = new wxButton( this, wxID_ANY, _(">"), wxDefaultPosition, wxSize( 36,100 ), 0 ); m_button_add->SetFont( wxFont( 9, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); m_button_add->SetToolTip( _("Add selected layers to matched layers list.") ); - sbSizer2->Add( m_button_add, 0, wxALL, 5 ); + bSizer6->Add( m_button_add, 0, wxALL, 5 ); - m_button_remove = new wxButton( sbSizer2->GetStaticBox(), wxID_ANY, _("<"), wxDefaultPosition, wxSize( 30,100 ), 0 ); + m_button_remove = new wxButton( this, wxID_ANY, _("<"), wxDefaultPosition, wxSize( 36,100 ), 0 ); m_button_remove->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); m_button_remove->SetToolTip( _("Remove selected layers from matched layers list.") ); - sbSizer2->Add( m_button_remove, 0, wxALL, 5 ); + bSizer6->Add( m_button_remove, 0, wxALL, 5 ); - m_button_removeall = new wxButton( sbSizer2->GetStaticBox(), wxID_ANY, _("<<"), wxDefaultPosition, wxSize( 30,50 ), 0 ); + m_button_removeall = new wxButton( this, wxID_ANY, _("<<"), wxDefaultPosition, wxSize( 36,50 ), 0 ); m_button_removeall->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); m_button_removeall->SetToolTip( _("Remove all matched layers.") ); - sbSizer2->Add( m_button_removeall, 0, wxALL, 5 ); + bSizer6->Add( m_button_removeall, 0, wxALL, 5 ); - bSizerTop->Add( sbSizer2, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); + bSizerTop->Add( bSizer6, 0, wxEXPAND|wxTOP, 10 ); wxStaticBoxSizer* sbSizer3; sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Matched Layers") ), wxHORIZONTAL ); - m_matched_layers_list = new wxListCtrl( sbSizer3->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( 300,-1 ), wxLC_REPORT ); - m_matched_layers_list->SetMaxSize( wxSize( 500,-1 ) ); + m_matched_layers_list = new wxListCtrl( sbSizer3->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxLC_REPORT ); + m_matched_layers_list->SetMinSize( wxSize( 120,-1 ) ); sbSizer3->Add( m_matched_layers_list, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); @@ -106,14 +104,15 @@ DIALOG_IMPORTED_LAYERS_BASE::DIALOG_IMPORTED_LAYERS_BASE( wxWindow* parent, wxWi m_sdbSizer->AddButton( m_sdbSizerOK ); m_sdbSizer->Realize(); - bSizerBottom->Add( m_sdbSizer, 1, wxALL|wxEXPAND, 5 ); + bSizerBottom->Add( m_sdbSizer, 1, wxEXPAND, 5 ); - bSizerMain->Add( bSizerBottom, 0, wxEXPAND|wxLEFT, 5 ); + bSizerMain->Add( bSizerBottom, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); this->SetSizer( bSizerMain ); this->Layout(); + bSizerMain->Fit( this ); // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_IMPORTED_LAYERS_BASE::OnClose ) ); diff --git a/pcbnew/dialogs/dialog_imported_layers_base.fbp b/pcbnew/dialogs/dialog_imported_layers_base.fbp index 8389875b06..07c64e5f3d 100644 --- a/pcbnew/dialogs/dialog_imported_layers_base.fbp +++ b/pcbnew/dialogs/dialog_imported_layers_base.fbp @@ -42,10 +42,10 @@ 0 wxID_ANY - 600,350 + -1,-1 DIALOG_IMPORTED_LAYERS_BASE - 795,476 + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Edit Mapping of Imported Layers @@ -85,16 +85,23 @@ 5 wxEXPAND 1 - + + 2 + wxVERTICAL + 0,1 + 1 + 0 - bSizerUnmatched - wxVERTICAL + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED none - + 0 + 0 + 5 wxALL 0 - + 1 1 1 @@ -131,7 +138,7 @@ 0 1 - m_staticText1 + m_lblImportedLayers 1 @@ -151,11 +158,11 @@ -1 - + 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 1 - + wxALL + 0 + 1 1 1 @@ -183,14 +190,16 @@ 0 0 wxID_ANY + KiCad Layers + 0 0 - 300,-1 + -1,-1 0 1 - m_unmatched_layers_list + m_lblKicadLayers 1 @@ -199,37 +208,22 @@ Resizable 1 - 200,-1 - wxLC_NO_HEADER|wxLC_REPORT + + ; ; forward_declare 0 - - wxFILTER_NONE - wxDefaultValidator - - OnUnMatchedDoubleClick + -1 - - - - 5 - wxEXPAND - 0 - - - bSizerKiCad - wxVERTICAL - none - + 5 - wxALL - 0 - + wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 1 + 1 1 1 @@ -257,16 +251,14 @@ 0 0 wxID_ANY - KiCad Layers - 0 0 -1,-1 0 - + 120,-1 1 - m_staticText2 + m_unmatched_layers_list 1 @@ -275,22 +267,26 @@ Resizable 1 - - + -1,-1 + wxLC_NO_HEADER|wxLC_REPORT ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - -1 + OnUnMatchedDoubleClick - + 5 wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT 1 - + 1 1 1 @@ -320,7 +316,7 @@ wxID_ANY 0 - 150,-1 + -1,-1 0 120,-1 @@ -334,7 +330,7 @@ Resizable 1 - 120,-1 + -1,-1 wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL ; ; forward_declare 0 @@ -354,16 +350,13 @@ - 5 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + 10 + wxEXPAND|wxTOP 0 - - wxID_ANY - + - sbSizer2 + bSizer6 wxVERTICAL - 1 none 5 @@ -423,7 +416,7 @@ Resizable 1 - 30,100 + 36,100 ; ; forward_declare 0 @@ -496,7 +489,7 @@ Resizable 1 - 30,100 + 36,100 ; ; forward_declare 0 @@ -569,7 +562,7 @@ Resizable 1 - 30,50 + 36,50 ; ; forward_declare 0 @@ -632,10 +625,10 @@ wxID_ANY 0 - 500,-1 + -1,-1 0 - + 120,-1 1 m_matched_layers_list 1 @@ -646,7 +639,7 @@ Resizable 1 - 300,-1 + -1,-1 wxLC_REPORT ; ; forward_declare 0 @@ -667,7 +660,7 @@ 5 - wxEXPAND|wxLEFT + wxBOTTOM|wxEXPAND|wxLEFT|wxTOP 0 @@ -749,7 +742,7 @@ 5 - wxALL|wxEXPAND + wxEXPAND 1 0 diff --git a/pcbnew/dialogs/dialog_imported_layers_base.h b/pcbnew/dialogs/dialog_imported_layers_base.h index 3f05afddf7..6d02d38de3 100644 --- a/pcbnew/dialogs/dialog_imported_layers_base.h +++ b/pcbnew/dialogs/dialog_imported_layers_base.h @@ -37,9 +37,9 @@ class DIALOG_IMPORTED_LAYERS_BASE : public DIALOG_SHIM protected: wxBoxSizer* bSizerMain; - wxStaticText* m_staticText1; + wxStaticText* m_lblImportedLayers; + wxStaticText* m_lblKicadLayers; wxListCtrl* m_unmatched_layers_list; - wxStaticText* m_staticText2; wxListCtrl* m_kicad_layers_list; wxButton* m_button_add; wxButton* m_button_remove; @@ -62,7 +62,7 @@ class DIALOG_IMPORTED_LAYERS_BASE : public DIALOG_SHIM public: - DIALOG_IMPORTED_LAYERS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Edit Mapping of Imported Layers"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 795,476 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_IMPORTED_LAYERS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Edit Mapping of Imported Layers"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_IMPORTED_LAYERS_BASE(); }; diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp index dac6b9db36..35f8836d65 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp @@ -697,7 +697,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryPads( const SYMDEF_PCB& aComponent, wxASSERT_MSG( true, "Unknown Pad type" ); } - pad->SetName( csPad.Identifier.IsEmpty() ? wxString::Format( wxT( "%i" ), csPad.ID ) : + pad->SetName( csPad.Identifier.IsEmpty() ? wxString::Format( wxT( "%ld" ), csPad.ID ) : csPad.Identifier ); pad->SetPos0( getKiCadPoint( csPad.Position ) - aModule->GetPosition() ); @@ -2486,7 +2486,7 @@ NETINFO_ITEM* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadNet( const NET_ID& aCadstarNet MODULE* m = getModuleFromCadstarID( firstPin.ComponentID ); newName = wxT( "Net-(" ); newName << m->Reference().GetText(); - newName << "-Pad" << wxString::Format( "%i", firstPin.PadID ) << ")"; + newName << "-Pad" << wxString::Format( "%ld", firstPin.PadID ) << ")"; } else {