From 1faa9800dce4282b0b612589bba3d329f98b3e8e Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 19 Jun 2025 14:11:04 +0100 Subject: [PATCH] Row height consistency. Rats. Also got tangled up in another commit which removes some dead code. --- common/dialogs/dialog_configure_paths.cpp | 3 - common/dialogs/dialog_plugin_options.cpp | 31 ++--- .../dialogs/panel_design_block_lib_table.cpp | 89 +------------ common/dialogs/panel_embedded_files.cpp | 67 +++++----- common/dialogs/panel_setup_netclasses.cpp | 69 ++++------ common/dialogs/panel_text_variables.cpp | 7 +- common/widgets/wx_grid.cpp | 54 ++++---- eeschema/dialogs/dialog_label_properties.cpp | 5 +- .../dialogs/dialog_lib_edit_pin_table.cpp | 3 - .../dialogs/dialog_lib_symbol_properties.cpp | 50 +++----- eeschema/dialogs/dialog_pin_properties.cpp | 42 +++--- eeschema/dialogs/dialog_sheet_properties.cpp | 21 ++- .../dialogs/dialog_symbol_fields_table.cpp | 3 - eeschema/dialogs/dialog_symbol_properties.cpp | 4 - .../dialogs/dialog_user_defined_signals.cpp | 4 - eeschema/dialogs/panel_sym_lib_table.cpp | 37 ++---- .../dialog_executecommand_job_settings.cpp | 4 - kicad/dialogs/panel_jobset.cpp | 52 ++++---- .../dialogs/dialog_footprint_properties.cpp | 15 +-- .../dialog_footprint_properties_fp_editor.cpp | 18 +-- pcbnew/dialogs/dialog_swap_layers.cpp | 7 +- pcbnew/dialogs/panel_display_options.cpp | 11 +- .../panel_fp_editor_field_defaults.cpp | 7 +- .../panel_fp_editor_graphics_defaults.cpp | 44 +++---- pcbnew/dialogs/panel_fp_lib_table.cpp | 121 +++--------------- .../dialogs/panel_fp_properties_3d_model.cpp | 15 +-- .../dialogs/panel_setup_text_and_graphics.cpp | 24 ++-- .../panel_setup_time_domain_parameters.cpp | 12 +- .../dialogs/panel_setup_tracks_and_vias.cpp | 12 +- 29 files changed, 260 insertions(+), 571 deletions(-) diff --git a/common/dialogs/dialog_configure_paths.cpp b/common/dialogs/dialog_configure_paths.cpp index d6b23646c4..eb47f66373 100644 --- a/common/dialogs/dialog_configure_paths.cpp +++ b/common/dialogs/dialog_configure_paths.cpp @@ -82,9 +82,6 @@ DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS( wxWindow* aParent ) : attr->SetEditor( new GRID_CELL_PATH_EDITOR( this, m_EnvVars, &m_curdir, wxEmptyString ) ); m_EnvVars->SetColAttr( TV_VALUE_COL, attr ); - // Give a bit more room for combobox editors - m_EnvVars->SetDefaultRowSize( m_EnvVars->GetDefaultRowSize() + FromDIP( 4 ) ); - m_EnvVars->PushEventHandler( new GRID_TRICKS( m_EnvVars, [this]( wxCommandEvent& aEvent ) { diff --git a/common/dialogs/dialog_plugin_options.cpp b/common/dialogs/dialog_plugin_options.cpp index 066546957c..bb7438487d 100644 --- a/common/dialogs/dialog_plugin_options.cpp +++ b/common/dialogs/dialog_plugin_options.cpp @@ -39,22 +39,19 @@ DIALOG_PLUGIN_OPTIONS::DIALOG_PLUGIN_OPTIONS( wxWindow* aParent, - const wxString& aNickname, - const std::map& aPluginOptions, - const wxString& aFormattedOptions, - wxString* aResult ) : - DIALOG_PLUGIN_OPTIONS_BASE( aParent ), - m_callers_options( aFormattedOptions ), - m_result( aResult ), - m_choices( aPluginOptions ), - m_initial_help( INITIAL_HELP ), - m_grid_widths_dirty( true ) + const wxString& aNickname, + const std::map& aPluginOptions, + const wxString& aFormattedOptions, + wxString* aResult ) : + DIALOG_PLUGIN_OPTIONS_BASE( aParent ), + m_callers_options( aFormattedOptions ), + m_result( aResult ), + m_choices( aPluginOptions ), + m_initial_help( INITIAL_HELP ), + m_grid_widths_dirty( true ) { SetTitle( wxString::Format( _( "Options for Library '%s'" ), aNickname ) ); - // Give a bit more room for combobox editors - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); - m_grid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows ); // add Cut, Copy, and Paste to wxGrid @@ -65,8 +62,7 @@ DIALOG_PLUGIN_OPTIONS::DIALOG_PLUGIN_OPTIONS( wxWindow* aParent, { unsigned int row = 0; - for( std::map::const_iterator it = m_choices.begin(); - it != m_choices.end(); ++it, ++row ) + for( std::map::const_iterator it = m_choices.begin(); it != m_choices.end(); ++it, ++row ) { wxString item = From_UTF8( it->first.c_str() ); @@ -111,8 +107,7 @@ bool DIALOG_PLUGIN_OPTIONS::TransferDataToWindow() int row = 0; - for( std::map::const_iterator it = props->begin(); it != props->end(); - ++it, ++row ) + for( std::map::const_iterator it = props->begin(); it != props->end(); ++it, ++row ) { m_grid->SetCellValue( row, 0, From_UTF8( it->first.c_str() ) ); m_grid->SetCellValue( row, 1, it->second ); @@ -142,9 +137,7 @@ bool DIALOG_PLUGIN_OPTIONS::TransferDataFromWindow() UTF8 value = m_grid->GetCellValue( row, 1 ).Trim( false ).Trim(); if( name.size() ) - { props[name] = value; - } } *m_result = LIB_TABLE::FormatOptions( &props ).wx_str(); diff --git a/common/dialogs/panel_design_block_lib_table.cpp b/common/dialogs/panel_design_block_lib_table.cpp index 77a543a7bf..c6e18f734b 100644 --- a/common/dialogs/panel_design_block_lib_table.cpp +++ b/common/dialogs/panel_design_block_lib_table.cpp @@ -65,81 +65,6 @@ #include #include -// clang-format off - -/** - * Container that describes file type info for the add a library options - */ -struct SUPPORTED_FILE_TYPE -{ - wxString m_Description; ///< Description shown in the file picker dialog. - wxString m_FileFilter; ///< Filter used for file pickers if m_IsFile is true. - wxString m_FolderSearchExtension; ///< In case of folders it stands for extensions of files - ///< stored inside. - bool m_IsFile; ///< Whether the library is a folder or a file. - DESIGN_BLOCK_IO_MGR::DESIGN_BLOCK_FILE_T m_Plugin; -}; - -// clang-format on - -/** - * Traverser implementation that looks to find any and all "folder" libraries by looking for files - * with a specific extension inside folders - */ -class LIBRARY_TRAVERSER : public wxDirTraverser -{ -public: - LIBRARY_TRAVERSER( std::vector aSearchExtensions, wxString aInitialDir ) : - m_searchExtensions( aSearchExtensions ), m_currentDir( aInitialDir ) - { - } - - virtual wxDirTraverseResult OnFile( const wxString& aFileName ) override - { - wxFileName file( aFileName ); - - for( const std::string& ext : m_searchExtensions ) - { - if( file.GetExt().IsSameAs( ext, false ) ) - m_foundDirs.insert( { m_currentDir, 1 } ); - } - - return wxDIR_CONTINUE; - } - - virtual wxDirTraverseResult OnOpenError( const wxString& aOpenErrorName ) override - { - m_failedDirs.insert( { aOpenErrorName, 1 } ); - return wxDIR_IGNORE; - } - - bool HasDirectoryOpenFailures() { return m_failedDirs.size() > 0; } - - virtual wxDirTraverseResult OnDir( const wxString& aDirName ) override - { - m_currentDir = aDirName; - return wxDIR_CONTINUE; - } - - void GetPaths( wxArrayString& aPathArray ) - { - for( std::pair& foundDirsPair : m_foundDirs ) - aPathArray.Add( foundDirsPair.first ); - } - - void GetFailedPaths( wxArrayString& aPathArray ) - { - for( std::pair& failedDirsPair : m_failedDirs ) - aPathArray.Add( failedDirsPair.first ); - } - -private: - std::vector m_searchExtensions; - wxString m_currentDir; - std::unordered_map m_foundDirs; - std::unordered_map m_failedDirs; -}; - /** * This class builds a wxGridTableBase by wrapping an #DESIGN_BLOCK_LIB_TABLE object. @@ -299,8 +224,11 @@ PANEL_DESIGN_BLOCK_LIB_TABLE::PANEL_DESIGN_BLOCK_LIB_TABLE( DIALOG_EDIT_LIBRARY_ const wxString& aProjectTblPath, const wxString& aProjectBasePath ) : PANEL_DESIGN_BLOCK_LIB_TABLE_BASE( aParent ), - m_globalTable( aGlobalTable ), m_projectTable( aProjectTable ), m_project( aProject ), - m_projectBasePath( aProjectBasePath ), m_parent( aParent ) + m_globalTable( aGlobalTable ), + m_projectTable( aProjectTable ), + m_project( aProject ), + m_projectBasePath( aProjectBasePath ), + m_parent( aParent ) { m_global_grid->SetTable( new DESIGN_BLOCK_LIB_TABLE_GRID( *aGlobalTable ), true ); @@ -336,9 +264,6 @@ PANEL_DESIGN_BLOCK_LIB_TABLE::PANEL_DESIGN_BLOCK_LIB_TABLE( DIALOG_EDIT_LIBRARY_ auto setupGrid = [&]( WX_GRID* aGrid ) { - // Give a bit more room for wxChoice editors - aGrid->SetDefaultRowSize( aGrid->GetDefaultRowSize() + 4 ); - // add Cut, Copy, and Paste to wxGrids aGrid->PushEventHandler( new DESIGN_BLOCK_GRID_TRICKS( m_parent, aGrid ) ); @@ -1171,10 +1096,6 @@ void PANEL_DESIGN_BLOCK_LIB_TABLE::populateEnvironReadOnlyTable() m_path_subs_grid->SetCellEditor( row, 1, new GRID_CELL_READONLY_TEXT_EDITOR() ); } - // No combobox editors here, but it looks better if its consistent with the other - // grids in the dialog. - m_path_subs_grid->SetDefaultRowSize( m_path_subs_grid->GetDefaultRowSize() + 2 ); - adjustPathSubsGridColumns( m_path_subs_grid->GetRect().GetWidth() ); } diff --git a/common/dialogs/panel_embedded_files.cpp b/common/dialogs/panel_embedded_files.cpp index 55de074d6f..3f65eee0c7 100644 --- a/common/dialogs/panel_embedded_files.cpp +++ b/common/dialogs/panel_embedded_files.cpp @@ -41,7 +41,8 @@ /* ---------- GRID_TRICKS for embedded files grid ---------- */ EMBEDDED_FILES_GRID_TRICKS::EMBEDDED_FILES_GRID_TRICKS( WX_GRID* aGrid ) : - GRID_TRICKS( aGrid ), m_curRow( -1 ) + GRID_TRICKS( aGrid ), + m_curRow( -1 ) { } @@ -89,7 +90,9 @@ void EMBEDDED_FILES_GRID_TRICKS::doPopupSelection( wxCommandEvent& event ) PANEL_EMBEDDED_FILES::PANEL_EMBEDDED_FILES( wxWindow* parent, EMBEDDED_FILES* aFiles ) : - PANEL_EMBEDDED_FILES_BASE( parent ), m_files( aFiles ), m_localFiles( new EMBEDDED_FILES() ) + PANEL_EMBEDDED_FILES_BASE( parent ), + m_files( aFiles ), + m_localFiles( new EMBEDDED_FILES() ) { for( auto& [name, file] : m_files->EmbeddedFileMap() ) { @@ -105,23 +108,24 @@ PANEL_EMBEDDED_FILES::PANEL_EMBEDDED_FILES( wxWindow* parent, EMBEDDED_FILES* aF m_files_grid->PushEventHandler( new EMBEDDED_FILES_GRID_TRICKS( m_files_grid ) ); - m_localFiles->SetFileAddedCallback( [this](EMBEDDED_FILES::EMBEDDED_FILE* file) { - - for( int ii = 0; ii < m_files_grid->GetNumberRows(); ii++ ) - { - if( m_files_grid->GetCellValue( ii, 1 ) == file->GetLink() ) + m_localFiles->SetFileAddedCallback( + [this](EMBEDDED_FILES::EMBEDDED_FILE* file) { - m_files_grid->DeleteRows( ii ); - break; - } - } + for( int ii = 0; ii < m_files_grid->GetNumberRows(); ii++ ) + { + if( m_files_grid->GetCellValue( ii, 1 ) == file->GetLink() ) + { + m_files_grid->DeleteRows( ii ); + break; + } + } - m_files_grid->AppendRows( 1 ); - int ii = m_files_grid->GetNumberRows() - 1; - m_files_grid->SetCellValue( ii, 0, file->name ); - m_files_grid->SetCellValue( ii, 1, file->GetLink() ); + m_files_grid->AppendRows( 1 ); + int ii = m_files_grid->GetNumberRows() - 1; + m_files_grid->SetCellValue( ii, 0, file->name ); + m_files_grid->SetCellValue( ii, 1, file->GetLink() ); - }); + } ); } @@ -166,6 +170,7 @@ bool PANEL_EMBEDDED_FILES::TransferDataToWindow() m_files_grid->DeleteRows( 0, m_files_grid->GetNumberRows() ); int ii = 0; + for( auto& [name, file] : m_localFiles->EmbeddedFileMap() ) { while( m_files_grid->GetNumberRows() < ii + 1 ) @@ -191,11 +196,10 @@ bool PANEL_EMBEDDED_FILES::TransferDataFromWindow() std::vector files; - for( auto it = m_localFiles->EmbeddedFileMap().begin(); - it != m_localFiles->EmbeddedFileMap().end(); it++ ) - files.push_back( it->second ); + for( const auto& [name, file] : m_localFiles->EmbeddedFileMap() ) + files.push_back( file ); - for( auto& file : files ) + for( EMBEDDED_FILES::EMBEDDED_FILE* file : files ) { m_files->AddFile( file ); m_localFiles->RemoveFile( file->name, false ); @@ -237,8 +241,7 @@ void PANEL_EMBEDDED_FILES::onFontEmbedClick( wxCommandEvent& event ) for( KIFONT::OUTLINE_FONT* font : fonts ) { - EMBEDDED_FILES::EMBEDDED_FILE* result = - m_localFiles->AddFile( font->GetFileName(), true ); + EMBEDDED_FILES::EMBEDDED_FILE* result = m_localFiles->AddFile( font->GetFileName(), true ); if( !result ) { @@ -326,7 +329,7 @@ void PANEL_EMBEDDED_FILES::onAddEmbeddedFiles( wxCommandEvent& event ) wxArrayString paths; fileDialog.GetPaths( paths ); - for( wxString path : paths ) + for( const wxString& path : paths ) AddEmbeddedFile( path ); } } @@ -396,11 +399,9 @@ void PANEL_EMBEDDED_FILES::onExportFiles( wxCommandEvent& event ) if( fileName.FileExists() ) { - wxString msg = wxString::Format( _( "File '%s' already exists." ), - fileName.GetFullName() ); + wxString msg = wxString::Format( _( "File '%s' already exists." ), fileName.GetFullName() ); - KIDIALOG errorDlg( m_parent, msg, _( "Confirmation" ), - wxOK | wxCANCEL | wxICON_WARNING ); + KIDIALOG errorDlg( m_parent, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); errorDlg.SetOKCancelLabels( _( "Overwrite" ), _( "Skip" ) ); errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ ); @@ -415,11 +416,9 @@ void PANEL_EMBEDDED_FILES::onExportFiles( wxCommandEvent& event ) if( !fileName.IsDirWritable() ) { #ifndef __WXMAC__ - wxString msg = wxString::Format( _( "Directory '%s' is not writable." ), - fileName.GetFullName() ); + wxString msg = wxString::Format( _( "Directory '%s' is not writable." ), fileName.GetFullName() ); #else - wxString msg = wxString::Format( _( "Folder '%s' is not writable." ), - fileName.GetPath() ); + wxString msg = wxString::Format( _( "Folder '%s' is not writable." ), fileName.GetPath() ); #endif // Don't set a 'do not show again' checkbox for this dialog KIDIALOG errorDlg( m_parent, msg, _( "Error" ), wxYES_NO | wxCANCEL | wxICON_ERROR ); @@ -451,8 +450,7 @@ void PANEL_EMBEDDED_FILES::onExportFiles( wxCommandEvent& event ) if( !out.IsOk() ) { - wxString msg = wxString::Format( _( "Failed to open file '%s'." ), - fileName.GetFullName() ); + wxString msg = wxString::Format( _( "Failed to open file '%s'." ), fileName.GetFullName() ); KIDIALOG errorDlg( m_parent, msg, _( "Error" ), wxOK | wxICON_ERROR ); errorDlg.ShowModal(); @@ -463,8 +461,7 @@ void PANEL_EMBEDDED_FILES::onExportFiles( wxCommandEvent& event ) if( !out.IsOk() || ( out.LastWrite() != file->decompressedData.size() ) ) { - wxString msg = wxString::Format( _( "Failed to write file '%s'." ), - fileName.GetFullName() ); + wxString msg = wxString::Format( _( "Failed to write file '%s'." ), fileName.GetFullName() ); KIDIALOG errorDlg( m_parent, msg, _( "Error" ), wxOK | wxICON_ERROR ); diff --git a/common/dialogs/panel_setup_netclasses.cpp b/common/dialogs/panel_setup_netclasses.cpp index 9a17ff0f29..c3b73f4d5d 100644 --- a/common/dialogs/panel_setup_netclasses.cpp +++ b/common/dialogs/panel_setup_netclasses.cpp @@ -161,14 +161,12 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA wxGridCellAttr* attr = new wxGridCellAttr; attr->SetRenderer( new GRID_CELL_COLOR_RENDERER( PAGED_DIALOG::GetDialog( this ) ) ); - attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( PAGED_DIALOG::GetDialog( this ), - m_netclassGrid ) ); + attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( PAGED_DIALOG::GetDialog( this ), m_netclassGrid ) ); m_netclassGrid->SetColAttr( GRID_SCHEMATIC_COLOR, attr ); attr = new wxGridCellAttr; attr->SetRenderer( new GRID_CELL_COLOR_RENDERER( PAGED_DIALOG::GetDialog( this ) ) ); - attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( PAGED_DIALOG::GetDialog( this ), - m_netclassGrid ) ); + attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( PAGED_DIALOG::GetDialog( this ), m_netclassGrid ) ); m_netclassGrid->SetColAttr( GRID_PCB_COLOR, attr ); attr = new wxGridCellAttr; @@ -182,8 +180,7 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA } else { - m_colorDefaultHelpText->SetLabel( - _( "Set color to transparent to use layer default color." ) ); + m_colorDefaultHelpText->SetLabel( _( "Set color to transparent to use layer default color." ) ); m_colorDefaultHelpText->GetParent()->Layout(); } @@ -204,11 +201,6 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA // Be sure the column labels are readable m_netclassGrid->EnsureColLabelsVisible(); - // Membership combobox editors require a bit more room, so increase the row size of - // all our grids for consistency - m_netclassGrid->SetDefaultRowSize( m_netclassGrid->GetDefaultRowSize() + 4 ); - m_assignmentGrid->SetDefaultRowSize( m_assignmentGrid->GetDefaultRowSize() + 4 ); - m_netclassGrid->PushEventHandler( new GRID_TRICKS( m_netclassGrid ) ); m_assignmentGrid->PushEventHandler( new GRID_TRICKS( m_assignmentGrid ) ); @@ -232,14 +224,13 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA nullptr, this ); // Handle tooltips for grid - m_netclassGrid->GetGridColLabelWindow()->Bind( wxEVT_MOTION, - &PANEL_SETUP_NETCLASSES::OnNetclassGridMouseEvent, + m_netclassGrid->GetGridColLabelWindow()->Bind( wxEVT_MOTION, &PANEL_SETUP_NETCLASSES::OnNetclassGridMouseEvent, this ); // Allow sorting assignments by column - m_assignmentGrid->Connect( - wxEVT_GRID_LABEL_LEFT_CLICK, - wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassAssignmentSort ), nullptr, this ); + m_assignmentGrid->Connect( wxEVT_GRID_LABEL_LEFT_CLICK, + wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassAssignmentSort ), + nullptr, this ); m_frame->Bind( EDA_EVT_UNITS_CHANGED, &PANEL_SETUP_NETCLASSES::onUnitsChanged, this ); @@ -284,9 +275,9 @@ PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES() wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), nullptr, this ); - m_assignmentGrid->Disconnect( - wxEVT_GRID_LABEL_LEFT_CLICK, - wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassAssignmentSort ), nullptr, this ); + m_assignmentGrid->Disconnect( wxEVT_GRID_LABEL_LEFT_CLICK, + wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassAssignmentSort ), + nullptr, this ); m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &PANEL_SETUP_NETCLASSES::onUnitsChanged, this ); } @@ -300,10 +291,8 @@ void PANEL_SETUP_NETCLASSES::loadNetclasses() m_netclassGrid->SetCellValue( aRow, GRID_NAME, nc->GetName() ); m_netclassGrid->SetCellValue( aRow, GRID_DELAY_PROFILE, nc->GetDelayProfile() ); - m_netclassGrid->SetOptionalUnitValue( aRow, GRID_WIREWIDTH, - nc->GetWireWidthOpt() ); - m_netclassGrid->SetOptionalUnitValue( aRow, GRID_BUSWIDTH, - nc->GetBusWidthOpt() ); + m_netclassGrid->SetOptionalUnitValue( aRow, GRID_WIREWIDTH, nc->GetWireWidthOpt() ); + m_netclassGrid->SetOptionalUnitValue( aRow, GRID_BUSWIDTH, nc->GetBusWidthOpt() ); wxString colorAsString = nc->GetSchematicColor().ToCSSString(); m_netclassGrid->SetCellValue( aRow, GRID_SCHEMATIC_COLOR, colorAsString ); @@ -315,28 +304,22 @@ void PANEL_SETUP_NETCLASSES::loadNetclasses() if( lineStyleIdx >= (int) g_lineStyleNames.size() + 1 ) lineStyleIdx = 0; - m_netclassGrid->SetCellValue( aRow, GRID_LINESTYLE, - g_lineStyleNames[lineStyleIdx + 1] ); + m_netclassGrid->SetCellValue( aRow, GRID_LINESTYLE, g_lineStyleNames[lineStyleIdx + 1] ); } else { // line style in list. - m_netclassGrid->SetCellValue( aRow, GRID_LINESTYLE, - g_lineStyleNames[0] ); + m_netclassGrid->SetCellValue( aRow, GRID_LINESTYLE, g_lineStyleNames[0] ); } m_netclassGrid->SetOptionalUnitValue( aRow, GRID_CLEARANCE, nc->GetClearanceOpt() ); - m_netclassGrid->SetOptionalUnitValue( aRow, GRID_TRACKSIZE, - nc->GetTrackWidthOpt() ); + m_netclassGrid->SetOptionalUnitValue( aRow, GRID_TRACKSIZE, nc->GetTrackWidthOpt() ); m_netclassGrid->SetOptionalUnitValue( aRow, GRID_VIASIZE, nc->GetViaDiameterOpt() ); m_netclassGrid->SetOptionalUnitValue( aRow, GRID_VIADRILL, nc->GetViaDrillOpt() ); - m_netclassGrid->SetOptionalUnitValue( aRow, GRID_uVIASIZE, - nc->GetuViaDiameterOpt() ); + m_netclassGrid->SetOptionalUnitValue( aRow, GRID_uVIASIZE, nc->GetuViaDiameterOpt() ); m_netclassGrid->SetOptionalUnitValue( aRow, GRID_uVIADRILL, nc->GetuViaDrillOpt() ); - m_netclassGrid->SetOptionalUnitValue( aRow, GRID_DIFF_PAIR_WIDTH, - nc->GetDiffPairWidthOpt() ); - m_netclassGrid->SetOptionalUnitValue( aRow, GRID_DIFF_PAIR_GAP, - nc->GetDiffPairGapOpt() ); + m_netclassGrid->SetOptionalUnitValue( aRow, GRID_DIFF_PAIR_WIDTH, nc->GetDiffPairWidthOpt() ); + m_netclassGrid->SetOptionalUnitValue( aRow, GRID_DIFF_PAIR_GAP, nc->GetDiffPairGapOpt() ); colorAsString = nc->GetPcbColor().ToCSSString(); m_netclassGrid->SetCellValue( aRow, GRID_PCB_COLOR, colorAsString ); @@ -554,8 +537,7 @@ bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow() // Copy other NetClasses: for( int row = 0; row < m_netclassGrid->GetNumberRows() - 1; ++row ) { - auto nc = - std::make_shared( m_netclassGrid->GetCellValue( row, GRID_NAME ), false ); + auto nc = std::make_shared( m_netclassGrid->GetCellValue( row, GRID_NAME ), false ); gridRowToNetclass( row, nc ); m_netSettings->SetNetclass( nc->GetName(), nc ); } @@ -970,8 +952,7 @@ void PANEL_SETUP_NETCLASSES::OnUpdateUI( wxUpdateUIEvent& event ) { EDA_COMBINED_MATCHER matcher( pattern, CTX_NETCLASS ); - m_matchingNets->Report( wxString::Format( _( "Nets matching '%s':" ), - pattern ) ); + m_matchingNets->Report( wxString::Format( _( "Nets matching '%s':" ), pattern ) ); for( const wxString& net : m_netNames ) { @@ -1051,8 +1032,7 @@ void PANEL_SETUP_NETCLASSES::OnMoveNetclassUpClick( wxCommandEvent& event ) m_netclassGrid->InsertRows( newRowId ); for( int col = 0; col < m_netclassGrid->GetNumberCols(); col++ ) - m_netclassGrid->SetCellValue( newRowId, col, - m_netclassGrid->GetCellValue( newRowId + 2, col ) ); + m_netclassGrid->SetCellValue( newRowId, col, m_netclassGrid->GetCellValue( newRowId + 2, col ) ); // Set the row nullable editors setNetclassRowNullableEditors( newRowId, false ); @@ -1086,16 +1066,15 @@ void PANEL_SETUP_NETCLASSES::OnMoveNetclassDownClick( wxCommandEvent& event ) // Can't move the last row down, nor move the Default netclass if( selectedRows[0] == ( m_netclassGrid->GetNumberRows() - 2 ) || selectedRows[0] == ( m_netclassGrid->GetNumberRows() - 1 ) ) + { return; + } int newRowId = selectedRows[0] + 2; m_netclassGrid->InsertRows( newRowId ); for( int col = 0; col < m_netclassGrid->GetNumberCols(); col++ ) - { - m_netclassGrid->SetCellValue( newRowId, col, - m_netclassGrid->GetCellValue( newRowId - 2, col ) ); - } + m_netclassGrid->SetCellValue( newRowId, col, m_netclassGrid->GetCellValue( newRowId - 2, col ) ); m_netclassGrid->DeleteRows( newRowId - 2, 1 ); m_netclassGrid->MakeCellVisible( newRowId - 1, 0 ); diff --git a/common/dialogs/panel_text_variables.cpp b/common/dialogs/panel_text_variables.cpp index 846e19ae12..e39d2fb0bc 100644 --- a/common/dialogs/panel_text_variables.cpp +++ b/common/dialogs/panel_text_variables.cpp @@ -43,8 +43,11 @@ enum TEXT_VAR_GRID_COLUMNS PANEL_TEXT_VARIABLES::PANEL_TEXT_VARIABLES( wxWindow* aParent, PROJECT* aProject ) : - PANEL_TEXT_VARIABLES_BASE( aParent ), m_project( aProject ), m_lastCheckedTicker( 0 ), - m_errorRow( -1 ), m_errorCol( -1 ) + PANEL_TEXT_VARIABLES_BASE( aParent ), + m_project( aProject ), + m_lastCheckedTicker( 0 ), + m_errorRow( -1 ), + m_errorCol( -1 ) { m_btnAddTextVar->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) ); m_btnDeleteTextVar->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) ); diff --git a/common/widgets/wx_grid.cpp b/common/widgets/wx_grid.cpp index 9e713e46d6..28fe7ef04c 100644 --- a/common/widgets/wx_grid.cpp +++ b/common/widgets/wx_grid.cpp @@ -207,6 +207,10 @@ WX_GRID::WX_GRID( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxS wxGrid( parent, id, pos, size, style, name ), m_weOwnTable( false ) { + // Grids with comboboxes need a bit of extra height; other grids look better if they're + // consistent. + SetDefaultRowSize( GetDefaultRowSize() + FromDIP( 4 ) ); + SetDefaultCellOverflow( false ); // Make sure the GUI font scales properly @@ -214,10 +218,8 @@ WX_GRID::WX_GRID( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxS SetLabelFont( KIUI::GetControlFont( this ) ); Connect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this ); - Connect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, - this ); - Connect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, - this ); + Connect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, this ); + Connect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, this ); } @@ -226,22 +228,18 @@ WX_GRID::~WX_GRID() if( m_weOwnTable ) DestroyTable( GetTable() ); - Disconnect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, - this ); - Disconnect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), - nullptr, this ); - Disconnect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, - this ); + Disconnect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, this ); + Disconnect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, this ); + Disconnect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this ); } void WX_GRID::onDPIChanged(wxDPIChangedEvent& aEvt) { - CallAfter( - [&]() - { - wxGrid::SetColLabelSize( wxGRID_AUTOSIZE ); - } ); + CallAfter( [&]() + { + wxGrid::SetColLabelSize( wxGRID_AUTOSIZE ); + } ); /// This terrible hack is a way to avoid the incredibly disruptive resizing of grids that /// happens on Macs when moving a window between monitors of different DPIs. @@ -301,8 +299,7 @@ void WX_GRID::SetTable( wxGridTableBase* aTable, bool aTakeOwnership ) EnableAlternateRowColors( Pgm().GetCommonSettings()->m_Appearance.grid_striping ); Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this ); - Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, - this ); + Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this ); m_weOwnTable = aTakeOwnership; } @@ -391,11 +388,8 @@ void WX_GRID::onCellEditorHidden( wxGridEvent& aEvent ) if( cellEditor ) { - GRID_CELL_MARK_AS_NULLABLE* nullableCell = - dynamic_cast( cellEditor ); - - if( nullableCell ) - isNullable = nullableCell->IsNullable(); + if( GRID_CELL_MARK_AS_NULLABLE* nullable = dynamic_cast( cellEditor ) ) + isNullable = nullable->IsNullable(); cellEditor->DecRef(); } @@ -419,8 +413,8 @@ void WX_GRID::onCellEditorHidden( wxGridEvent& aEvent ) if( stringValue == UNITS_PROVIDER::NullUiString ) { - val = unitsProvider->OptionalValueFromString( - UNITS_PROVIDER::NullUiString, cellDataType ); + val = unitsProvider->OptionalValueFromString( UNITS_PROVIDER::NullUiString, + cellDataType ); } else { @@ -428,13 +422,11 @@ void WX_GRID::onCellEditorHidden( wxGridEvent& aEvent ) cellDataType ); } - evalValue = unitsProvider->StringFromOptionalValue( val, true, - cellDataType ); + evalValue = unitsProvider->StringFromOptionalValue( val, true, cellDataType ); } else { - int val = unitsProvider->ValueFromString( m_eval->Result(), - cellDataType ); + int val = unitsProvider->ValueFromString( m_eval->Result(), cellDataType ); evalValue = unitsProvider->StringFromValue( val, true, cellDataType ); } @@ -458,8 +450,7 @@ void WX_GRID::DestroyTable( wxGridTableBase* aTable ) CommitPendingChanges( true /* quiet mode */ ); Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this ); - Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, - this ); + Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this ); wxGrid::SetTable( nullptr ); delete aTable; @@ -805,8 +796,7 @@ int WX_GRID::GetVisibleWidth( int aCol, bool aHeader, bool aContents, bool aKeep { EnsureColLabelsVisible(); - size = std::max( size, - int( GetTextExtent( GetColLabelValue( aCol ) + wxS( "M" ) ).x ) ); + size = std::max( size, int( GetTextExtent( GetColLabelValue( aCol ) + wxS( "M" ) ).x ) ); } for( int row = 0; aContents && row < GetNumberRows(); row++ ) diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index f67d88e604..ae8d153259 100644 --- a/eeschema/dialogs/dialog_label_properties.cpp +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -141,12 +141,9 @@ DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break; case SCH_DIRECTIVE_LABEL_T: SetTitle( _( "Directive Label Properties" ) ); break; case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); break; - default: UNIMPLEMENTED_FOR( m_currentLabel->GetClass() ); break; + default: UNIMPLEMENTED_FOR( m_currentLabel->GetClass() ); break; } - // Give a bit more room for combobox editors - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); - m_grid->SetTable( m_fields ); m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this, {}, [&]( wxCommandEvent& aEvent ) diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index 3b2d592965..b3a86c83ef 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -1054,9 +1054,6 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, for( int i = 0; i < COL_COUNT; ++i ) m_originalColWidths[ i ] = m_grid->GetColSize( i ); - // Give a bit more room for combobox editors - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); - m_grid->SetTable( m_dataModel ); m_grid->PushEventHandler( new GRID_TRICKS( m_grid, [this]( wxCommandEvent& aEvent ) { diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index 8075667774..14c0f6eec1 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -58,22 +58,20 @@ DIALOG_LIB_SYMBOL_PROPERTIES::LAST_LAYOUT DIALOG_LIB_SYMBOL_PROPERTIES::m_lastLa DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, LIB_SYMBOL* aLibEntry ) : - DIALOG_LIB_SYMBOL_PROPERTIES_BASE( aParent ), - m_Parent( aParent ), - m_libEntry( aLibEntry ), - m_pinNameOffset( aParent, m_nameOffsetLabel, m_nameOffsetCtrl, m_nameOffsetUnits, true ), - m_delayedFocusCtrl( nullptr ), - m_delayedFocusGrid( nullptr ), - m_delayedFocusRow( -1 ), - m_delayedFocusColumn( -1 ), - m_delayedFocusPage( -1 ), - m_fpFilterTricks( std::make_unique( *this, *m_FootprintFilterListBox ) ) + DIALOG_LIB_SYMBOL_PROPERTIES_BASE( aParent ), + m_Parent( aParent ), + m_libEntry( aLibEntry ), + m_pinNameOffset( aParent, m_nameOffsetLabel, m_nameOffsetCtrl, m_nameOffsetUnits, true ), + m_delayedFocusCtrl( nullptr ), + m_delayedFocusGrid( nullptr ), + m_delayedFocusRow( -1 ), + m_delayedFocusColumn( -1 ), + m_delayedFocusPage( -1 ), + m_fpFilterTricks( std::make_unique( *this, *m_FootprintFilterListBox ) ) { m_embeddedFiles = new PANEL_EMBEDDED_FILES( m_NoteBook, m_libEntry ); m_NoteBook->AddPage( m_embeddedFiles, _( "Embedded Files" ) ); - // Give a bit more room for combobox editors - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_libEntry, { m_embeddedFiles->GetLocalFiles() } ); m_grid->SetTable( m_fields ); @@ -116,8 +114,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* a // wxFormBuilder doesn't include this event... m_grid->Connect( wxEVT_GRID_CELL_CHANGING, - wxGridEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging ), - nullptr, this ); + wxGridEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging ), nullptr, this ); // Forward the delete button to the tricks m_deleteFilterButton->Bind( wxEVT_BUTTON, @@ -167,8 +164,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES::~DIALOG_LIB_SYMBOL_PROPERTIES() m_grid->DestroyTable( m_fields ); m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING, - wxGridEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging ), - nullptr, this ); + wxGridEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging ), nullptr, this ); // Delete the GRID_TRICKS. m_grid->PopEventHandler( true ); @@ -224,8 +220,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow() m_KeywordCtrl->ChangeValue( m_libEntry->GetKeyWords() ); m_SelNumberOfUnits->SetValue( m_libEntry->GetUnitCount() ); - m_OptionPartsInterchangeable->SetValue( !m_libEntry->UnitsLocked() || - m_libEntry->GetUnitCount() == 1 ); + m_OptionPartsInterchangeable->SetValue( !m_libEntry->UnitsLocked() || m_libEntry->GetUnitCount() == 1 ); // If a symbol contains no body-style-specific pins or graphic items, // symbol->HasAlternateBodyStyle() will return false. @@ -513,8 +508,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() m_libEntry->SetName( newName ); m_libEntry->SetKeyWords( m_KeywordCtrl->GetValue() ); m_libEntry->SetUnitCount( m_SelNumberOfUnits->GetValue() ); - m_libEntry->LockUnits( m_libEntry->GetUnitCount() > 1 && - !m_OptionPartsInterchangeable->GetValue() ); + m_libEntry->LockUnits( m_libEntry->GetUnitCount() > 1 && !m_OptionPartsInterchangeable->GetValue() ); m_libEntry->SetHasAlternateBodyStyle( m_hasAlternateBodyStyles->GetValue() ); m_Parent->SetShowDeMorgan( m_hasAlternateBodyStyles->GetValue() ); @@ -608,8 +602,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging( wxGridEvent& event ) if( newName.CmpNoCase( m_grid->GetCellValue( i, FDC_NAME ) ) == 0 ) { - DisplayError( this, wxString::Format( _( "The name '%s' is already in use." ), - newName ) ); + DisplayError( this, wxString::Format( _( "The name '%s' is already in use." ), newName ) ); event.Veto(); m_delayedFocusRow = event.GetRow(); m_delayedFocusColumn = event.GetCol(); @@ -624,10 +617,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging( wxGridEvent& event ) void DIALOG_LIB_SYMBOL_PROPERTIES::OnSymbolNameText( wxCommandEvent& event ) { if( m_OptionPower->IsChecked() ) - { - m_grid->SetCellValue( m_fields->GetFieldRow( FIELD_T::VALUE ), FDC_VALUE, - m_SymbolNameCtrl->GetValue() ); - } + m_grid->SetCellValue( m_fields->GetFieldRow( FIELD_T::VALUE ), FDC_VALUE, m_SymbolNameCtrl->GetValue() ); OnModify(); } @@ -660,8 +650,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event ) return; SYMBOL_EDITOR_SETTINGS* settings = m_Parent->GetSettings(); - SCH_FIELD newField( m_libEntry, FIELD_T::USER, - GetUserFieldName( m_fields->size(), DO_TRANSLATE ) ); + SCH_FIELD newField( m_libEntry, FIELD_T::USER, GetUserFieldName( m_fields->size(), DO_TRANSLATE ) ); newField.SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ), schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) ); @@ -936,8 +925,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) int row = m_grid->GetGridCursorRow(); int col = m_grid->GetGridCursorCol(); - if( row == m_fields->GetFieldRow( FIELD_T::VALUE ) && col == FDC_VALUE - && m_OptionPower->IsChecked() ) + if( row == m_fields->GetFieldRow( FIELD_T::VALUE ) && col == FDC_VALUE && m_OptionPower->IsChecked() ) { wxGridCellEditor* editor = m_grid->GetCellEditor( row, col ); m_SymbolNameCtrl->ChangeValue( editor->GetValue() ); @@ -982,7 +970,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) { m_delayedFocusCtrl->SetFocus(); - if( auto textEntry = dynamic_cast( m_delayedFocusCtrl ) ) + if( wxTextEntry* textEntry = dynamic_cast( m_delayedFocusCtrl ) ) textEntry->SelectAll(); m_delayedFocusCtrl = nullptr; diff --git a/eeschema/dialogs/dialog_pin_properties.cpp b/eeschema/dialogs/dialog_pin_properties.cpp index 95216278f0..407ea08ad8 100644 --- a/eeschema/dialogs/dialog_pin_properties.cpp +++ b/eeschema/dialogs/dialog_pin_properties.cpp @@ -126,17 +126,17 @@ public: DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, SCH_PIN* aPin, bool aFocusPinNumber ) : - DIALOG_PIN_PROPERTIES_BASE( parent ), - m_frame( parent ), - m_pin( aPin ), - m_posX( parent, m_posXLabel, m_posXCtrl, m_posXUnits ), - m_posY( parent, m_posYLabel, m_posYCtrl, m_posYUnits ), - m_pinLength( parent, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits ), - m_nameSize( parent, m_nameSizeLabel, m_nameSizeCtrl, m_nameSizeUnits ), - m_numberSize( parent, m_numberSizeLabel, m_numberSizeCtrl, m_numberSizeUnits ), - m_delayedFocusRow( -1 ), - m_delayedFocusColumn( -1 ), - m_initialized( false ) + DIALOG_PIN_PROPERTIES_BASE( parent ), + m_frame( parent ), + m_pin( aPin ), + m_posX( parent, m_posXLabel, m_posXCtrl, m_posXUnits ), + m_posY( parent, m_posYLabel, m_posYCtrl, m_posYUnits ), + m_pinLength( parent, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits ), + m_nameSize( parent, m_nameSizeLabel, m_nameSizeCtrl, m_nameSizeUnits ), + m_numberSize( parent, m_numberSizeLabel, m_numberSizeCtrl, m_numberSizeUnits ), + m_delayedFocusRow( -1 ), + m_delayedFocusColumn( -1 ), + m_initialized( false ) { // Create a dummy symbol with a single pin for the preview widget: m_dummyParent = new LIB_SYMBOL( *static_cast( m_pin->GetParentSymbol() ) ); @@ -170,10 +170,7 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, SCH_PIN const std::vector& orientationIcons = PinOrientationIcons(); for ( unsigned ii = 0; ii < orientationNames.GetCount(); ii++ ) - { - m_choiceOrientation->Insert( orientationNames[ii], KiBitmapBundle( orientationIcons[ii] ), - ii ); - } + m_choiceOrientation->Insert( orientationNames[ii], KiBitmapBundle( orientationIcons[ii] ), ii ); // We can't set the tab order through wxWidgets due to shortcomings in their mnemonics // implementation on MSW @@ -197,8 +194,7 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, SCH_PIN // Default alternates turndown to whether or not alternates exist, or if we've had it open // before - m_alternatesTurndown->Collapse( m_pin->GetAlternates().size() == 0 - && !s_alternatesTurndownOpen ); + m_alternatesTurndown->Collapse( m_pin->GetAlternates().size() == 0 && !s_alternatesTurndownOpen ); // wxwidgets doesn't call the OnCollapseChange even at init, so we update this value if // the alternates pane defaults to open @@ -211,9 +207,6 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, SCH_PIN for( int i = 0; i < COL_COUNT; ++i ) m_originalColWidths[ i ] = m_alternatesGrid->GetColSize( i ); - // Give a bit more room for combobox editors - m_alternatesGrid->SetDefaultRowSize( m_alternatesGrid->GetDefaultRowSize() + 4 ); - m_alternatesGrid->SetTable( m_alternatesDataModel ); m_alternatesGrid->PushEventHandler( new GRID_TRICKS( m_alternatesGrid, [this]( wxCommandEvent& aEvent ) @@ -291,8 +284,7 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow() m_numberSize.SetValue( m_pin->GetNumberTextSize() ); m_pinLength.SetValue( m_pin->GetLength() ); m_checkApplyToAllParts->Enable( m_pin->GetParentSymbol()->IsMulti() ); - m_checkApplyToAllParts->SetValue( m_pin->GetParentSymbol()->IsMulti() - && m_pin->GetUnit() == 0 ); + m_checkApplyToAllParts->SetValue( m_pin->GetParentSymbol()->IsMulti() && m_pin->GetUnit() == 0 ); m_checkApplyToAllBodyStyles->SetValue( m_pin->GetBodyStyle() == 0 ); m_checkShow->SetValue( m_pin->IsVisible() ); @@ -302,8 +294,7 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow() if( m_frame->m_SyncPinEdit ) { - wxHyperlinkCtrl* button = new wxHyperlinkCtrl( m_infoBar, wxID_ANY, - _( "Exit sync pins mode" ), + wxHyperlinkCtrl* button = new wxHyperlinkCtrl( m_infoBar, wxID_ANY, _( "Exit sync pins mode" ), wxEmptyString ); button->Bind( wxEVT_COMMAND_HYPERLINK, @@ -483,8 +474,7 @@ void DIALOG_PIN_PROPERTIES::adjustGridColumns() m_alternatesGrid->SetColSize( COL_TYPE, m_originalColWidths[COL_TYPE] ); m_alternatesGrid->SetColSize( COL_SHAPE, m_originalColWidths[COL_SHAPE] ); - m_alternatesGrid->SetColSize( COL_NAME, width - m_originalColWidths[COL_TYPE] - - m_originalColWidths[COL_SHAPE] ); + m_alternatesGrid->SetColSize( COL_NAME, width - m_originalColWidths[COL_TYPE] - m_originalColWidths[COL_SHAPE] ); } diff --git a/eeschema/dialogs/dialog_sheet_properties.cpp b/eeschema/dialogs/dialog_sheet_properties.cpp index 5f0a68f4b9..4ef5c2060f 100644 --- a/eeschema/dialogs/dialog_sheet_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_properties.cpp @@ -53,24 +53,21 @@ DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_S bool* aIsUndoable, bool* aClearAnnotationNewItems, bool* aUpdateHierarchyNavigator, wxString* aSourceSheetFilename ) : - DIALOG_SHEET_PROPERTIES_BASE( aParent ), - m_frame( aParent ), - m_isUndoable( aIsUndoable ), - m_clearAnnotationNewItems( aClearAnnotationNewItems ), - m_updateHierarchyNavigator( aUpdateHierarchyNavigator ), - m_sourceSheetFilename( aSourceSheetFilename ), - m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits ), - m_dummySheet( *aSheet ), - m_dummySheetNameField( &m_dummySheet, FIELD_T::SHEET_NAME ) + DIALOG_SHEET_PROPERTIES_BASE( aParent ), + m_frame( aParent ), + m_isUndoable( aIsUndoable ), + m_clearAnnotationNewItems( aClearAnnotationNewItems ), + m_updateHierarchyNavigator( aUpdateHierarchyNavigator ), + m_sourceSheetFilename( aSourceSheetFilename ), + m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits ), + m_dummySheet( *aSheet ), + m_dummySheetNameField( &m_dummySheet, FIELD_T::SHEET_NAME ) { m_sheet = aSheet; m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_sheet ); m_delayedFocusRow = 0; m_delayedFocusColumn = FDC_VALUE; - // Give a bit more room for combobox editors - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); - m_grid->SetTable( m_fields ); m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this, { &aParent->Schematic() }, [&]( wxCommandEvent& aEvent ) diff --git a/eeschema/dialogs/dialog_symbol_fields_table.cpp b/eeschema/dialogs/dialog_symbol_fields_table.cpp index 55865e47d5..e04bfbaf7b 100644 --- a/eeschema/dialogs/dialog_symbol_fields_table.cpp +++ b/eeschema/dialogs/dialog_symbol_fields_table.cpp @@ -282,9 +282,6 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent, m_grid->PushEventHandler( new FIELDS_EDITOR_GRID_TRICKS( this, m_grid, m_fieldsCtrl, m_dataModel, &m_parent->Schematic() ) ); - // give a bit more room for comboboxes - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); - // Load our BOM view presets SetUserBomPresets( m_schSettings.m_BomPresets ); diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index a33b9c5149..eba8d836ce 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -329,10 +329,6 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent, m_fields = new FIELDS_GRID_TABLE( this, aParent, m_fieldsGrid, m_symbol ); - // Give a bit more room for combobox editors - m_fieldsGrid->SetDefaultRowSize( m_fieldsGrid->GetDefaultRowSize() + 4 ); - m_pinGrid->SetDefaultRowSize( m_pinGrid->GetDefaultRowSize() + 4 ); - m_fieldsGrid->SetTable( m_fields ); m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this, { &aParent->Schematic(), m_part }, diff --git a/eeschema/dialogs/dialog_user_defined_signals.cpp b/eeschema/dialogs/dialog_user_defined_signals.cpp index 698f27e4be..c9d8618f63 100644 --- a/eeschema/dialogs/dialog_user_defined_signals.cpp +++ b/eeschema/dialogs/dialog_user_defined_signals.cpp @@ -40,10 +40,6 @@ DIALOG_USER_DEFINED_SIGNALS::DIALOG_USER_DEFINED_SIGNALS( SIMULATOR_FRAME* aPare { m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) ); - // Give a little more room for Scintilla text editor (which otherwise likes to scroll - // on every other keystroke). - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); - wxGridCellAttr* attr = new wxGridCellAttr; attr->SetReadOnly(); m_grid->SetColAttr( 1, attr ); diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index 98cb8d7a4a..5ef523951d 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -322,11 +322,11 @@ PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, P const wxString& aGlobalTablePath, SYMBOL_LIB_TABLE* aProjectTable, const wxString& aProjectTablePath ) : - PANEL_SYM_LIB_TABLE_BASE( aParent ), - m_globalTable( aGlobalTable ), - m_projectTable( aProjectTable ), - m_project( aProject ), - m_parent( aParent ) + PANEL_SYM_LIB_TABLE_BASE( aParent ), + m_globalTable( aGlobalTable ), + m_projectTable( aProjectTable ), + m_project( aProject ), + m_parent( aParent ) { // wxGrid only supports user owned tables if they exist past end of ~wxGrid(), // so make it a grid owned table. @@ -451,9 +451,8 @@ bool PANEL_SYM_LIB_TABLE::verifyTables() wxYES_NO | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT ); badCellDlg.SetExtendedMessage( _( "Empty cells will result in all rows that are " "invalid to be removed from the table." ) ); - badCellDlg.SetYesNoLabels( - wxMessageDialog::ButtonLabel( _( "Remove Invalid Cells" ) ), - wxMessageDialog::ButtonLabel( _( "Cancel Table Update" ) ) ); + badCellDlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Remove Invalid Cells" ) ), + wxMessageDialog::ButtonLabel( _( "Cancel Table Update" ) ) ); wait.reset(); @@ -526,8 +525,8 @@ bool PANEL_SYM_LIB_TABLE::verifyTables() if( nick1 == nick2 ) { - msg = wxString::Format( _( "Multiple libraries cannot share the same " - "nickname ('%s')." ), nick1 ); + msg = wxString::Format( _( "Multiple libraries cannot share the same nickname ('%s')." ), + nick1 ); // show the tabbed panel holding the grid we have flunked: if( model != cur_model() ) @@ -580,8 +579,7 @@ bool PANEL_SYM_LIB_TABLE::verifyTables() wxWindow* topLevelParent = wxGetTopLevelParent( this ); wait.reset(); - wxMessageDialog errdlg( topLevelParent, msg + wxS( "\n" ) + ioe.What(), - _( "Error Loading Library" ) ); + wxMessageDialog errdlg( topLevelParent, msg + wxS( "\n" ) + ioe.What(), _( "Error Loading Library" ) ); errdlg.ShowModal(); return true; @@ -983,11 +981,9 @@ void PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries( wxCommandEvent& event ) std::unique_ptr> props( LIB_TABLE::ParseOptions( options.ToStdString() ) ); - if( SCH_IO_MGR::ConvertLibrary( props.get(), - legacyLib.GetFullPath(), newLib.GetFullPath() ) ) + if( SCH_IO_MGR::ConvertLibrary( props.get(), legacyLib.GetFullPath(), newLib.GetFullPath() ) ) { - relPath = NormalizePath( newLib.GetFullPath(), &Pgm().GetLocalEnvVariables(), - m_project ); + relPath = NormalizePath( newLib.GetFullPath(), &Pgm().GetLocalEnvVariables(), m_project ); // Do not use the project path in the global library table. This will almost // assuredly be wrong for a different project. @@ -1090,10 +1086,6 @@ void PANEL_SYM_LIB_TABLE::populateEnvironReadOnlyTable() m_path_subs_grid->SetCellEditor( row, 1, new GRID_CELL_READONLY_TEXT_EDITOR() ); } - // No combobox editors here, but it looks better if its consistent with the other - // grids in the dialog. - m_path_subs_grid->SetDefaultRowSize( m_path_subs_grid->GetDefaultRowSize() + 2 ); - adjustPathSubsGridColumns( m_path_subs_grid->GetRect().GetWidth() ); } @@ -1164,8 +1156,7 @@ void InvokeSchEditSymbolLibTable( KIWAY* aKiway, wxWindow *aParent ) if( symbolEditor->HasLibModifications() ) { msg = _( "Modifications have been made to one or more symbol libraries.\n" - "Changes must be saved or discarded before the symbol library " - "table can be modified." ); + "Changes must be saved or discarded before the symbol library table can be modified." ); switch( UnsavedChangesDialog( aParent, msg ) ) { @@ -1218,9 +1209,7 @@ void InvokeSchEditSymbolLibTable( KIWAY* aKiway, wxWindow *aParent ) } if( symbolEditor ) - { symbolEditor->ThawLibraryTree(); - } std::string payload = ""; aKiway->ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload ); diff --git a/kicad/dialogs/dialog_executecommand_job_settings.cpp b/kicad/dialogs/dialog_executecommand_job_settings.cpp index d225e8eef3..0e98c72a54 100644 --- a/kicad/dialogs/dialog_executecommand_job_settings.cpp +++ b/kicad/dialogs/dialog_executecommand_job_settings.cpp @@ -160,10 +160,6 @@ void DIALOG_EXECUTECOMMAND_JOB_SETTINGS::populateEnvironReadOnlyTable() m_path_subs_grid->SetCellEditor( row, 1, new GRID_CELL_READONLY_TEXT_EDITOR() ); } - // No combobox editors here, but it looks better if its consistent with the other - // grids in the dialog. - m_path_subs_grid->SetDefaultRowSize( m_path_subs_grid->GetDefaultRowSize() + 2 ); - adjustPathSubsGridColumns( m_path_subs_grid->GetRect().GetWidth() ); } diff --git a/kicad/dialogs/panel_jobset.cpp b/kicad/dialogs/panel_jobset.cpp index 9fbf2492d4..c4df600e8d 100644 --- a/kicad/dialogs/panel_jobset.cpp +++ b/kicad/dialogs/panel_jobset.cpp @@ -149,10 +149,7 @@ public: if( m_destination->m_lastRunReporters.contains( jobId ) ) { - WX_STRING_REPORTER* reporter = - static_cast( m_destination->m_lastRunReporters[jobId] ); - - if( reporter ) + if( auto* reporter = static_cast( m_destination->m_lastRunReporters[jobId] ) ) m_textCtrlOutput->SetValue( reporter->GetMessages() ); } else @@ -253,9 +250,8 @@ public: { wxClientDC dc( this ); int width = GetSize().GetWidth(); - wxString msg = aMsg; - m_pathInfo->SetLabel( wxControl::Ellipsize( msg, dc, wxELLIPSIZE_MIDDLE, width ) ); + m_pathInfo->SetLabel( wxControl::Ellipsize( aMsg, dc, wxELLIPSIZE_MIDDLE, width ) ); } virtual void OnGenerate( wxCommandEvent& event ) override @@ -274,15 +270,14 @@ public: JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile, &project ); - auto* progressReporter = new WX_PROGRESS_REPORTER( m_frame, _( "Run Jobs" ), 1, - PR_NO_ABORT ); + { + WX_PROGRESS_REPORTER progressReporter( m_frame, _( "Run Jobs" ), 1, PR_NO_ABORT ); - if( JOBSET_DESTINATION* destination = GetDestination() ) - jobRunner.RunJobsForDestination( destination ); + if( JOBSET_DESTINATION* destination = GetDestination() ) + jobRunner.RunJobsForDestination( destination ); - UpdateStatus(); - - delete progressReporter; + UpdateStatus(); + } // Bring the Kicad manager frame back to the front m_frame->Raise(); @@ -486,7 +481,6 @@ PANEL_JOBSET::PANEL_JOBSET( wxAuiNotebook* aParent, KICAD_MANAGER_FRAME* aFrame, { m_jobsGrid->PushEventHandler( new JOBS_GRID_TRICKS( this, m_jobsGrid ) ); - m_jobsGrid->SetDefaultRowSize( m_jobsGrid->GetDefaultRowSize() + 4 ); m_jobsGrid->OverrideMinSize( 0.6, 0.3 ); m_jobsGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); @@ -577,10 +571,9 @@ void PANEL_JOBSET::UpdateTitle() tabName = wxS( "*" ) + tabName; int pageIdx = m_parentBook->FindPage( this ); + if( pageIdx >= 0 ) - { m_parentBook->SetPageText( pageIdx, tabName ); - } } @@ -778,7 +771,10 @@ void PANEL_JOBSET::OnJobButtonDelete( wxCommandEvent& aEvent ) m_jobsGrid->ClearSelection(); // Reverse sort so deleting a row doesn't change the indexes of the other rows. - selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } ); + selectedRows.Sort( []( int* first, int* second ) + { + return *second - *first; + } ); int select = selectedRows[0]; @@ -852,7 +848,7 @@ bool PANEL_JOBSET::GetCanClose() if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ), [&]() -> bool { - return m_jobsFile->SaveToFile(wxEmptyString, true); + return m_jobsFile->SaveToFile( wxEmptyString, true ); } ) ) { return false; @@ -987,7 +983,7 @@ void PANEL_JOBSET::OnGenerateAllDestinationsClick( wxCommandEvent& event ) CallAfter( [this]() { - PROJECT& project = m_frame->Kiway().Prj(); + PROJECT& project = m_frame->Kiway().Prj(); EnsurePcbSchFramesOpen(); wxFileName fn = project.GetProjectFullName(); @@ -995,15 +991,14 @@ void PANEL_JOBSET::OnGenerateAllDestinationsClick( wxCommandEvent& event ) JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile.get(), &project ); - auto* progressReporter = new WX_PROGRESS_REPORTER( m_frame, _( "Run Jobs" ), 1, - PR_NO_ABORT ); + { + WX_PROGRESS_REPORTER progressReporter( m_frame, _( "Run Jobs" ), 1, PR_NO_ABORT ); - jobRunner.RunJobsAllDestinations(); + jobRunner.RunJobsAllDestinations(); - for( PANEL_DESTINATION* panel : GetDestinationPanels() ) - panel->UpdateStatus(); - - delete progressReporter; + for( PANEL_DESTINATION* panel : GetDestinationPanels() ) + panel->UpdateStatus(); + } // Bring the Kicad manager frame back to the front m_frame->Raise(); @@ -1013,9 +1008,8 @@ void PANEL_JOBSET::OnGenerateAllDestinationsClick( wxCommandEvent& event ) void PANEL_JOBSET::OnSizeGrid( wxSizeEvent& aEvent ) { - m_jobsGrid->SetColSize( COL_DESCR, m_jobsGrid->GetSize().x - - m_jobsGrid->GetColSize( COL_SOURCE ) - - m_jobsGrid->GetColSize( COL_NUMBER ) ); + m_jobsGrid->SetColSize( COL_DESCR, m_jobsGrid->GetSize().x - m_jobsGrid->GetColSize( COL_SOURCE ) + - m_jobsGrid->GetColSize( COL_NUMBER ) ); // Always propagate for a grid repaint (needed if the height changes, as well as width) aEvent.Skip(); diff --git a/pcbnew/dialogs/dialog_footprint_properties.cpp b/pcbnew/dialogs/dialog_footprint_properties.cpp index fafcede400..7adeccb836 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties.cpp @@ -53,8 +53,7 @@ int DIALOG_FOOTPRINT_PROPERTIES::m_page = 0; // remember the last open page during session -DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParent, - FOOTPRINT* aFootprint ) : +DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParent, FOOTPRINT* aFootprint ) : DIALOG_FOOTPRINT_PROPERTIES_BASE( aParent ), m_frame( aParent ), m_footprint( aFootprint ), @@ -62,12 +61,9 @@ DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParen m_posY( aParent, m_YPosLabel, m_ModPositionY, m_YPosUnit ), m_orientation( aParent, m_orientationLabel, m_orientationCtrl, nullptr ), m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits ), - m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl, - m_SolderMaskMarginUnits ), - m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl, - m_SolderPasteMarginUnits ), - m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl, - m_PasteMarginRatioUnits ), + m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl, m_SolderMaskMarginUnits ), + m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl, m_SolderPasteMarginUnits ), + m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl, m_PasteMarginRatioUnits ), m_returnValue( FP_PROPS_CANCEL ), m_initialized( false ), m_gridSize( 0, 0 ), @@ -101,9 +97,6 @@ DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParen icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) ); SetIcon( icon ); - // Give a bit more room for combobox editors - m_itemsGrid->SetDefaultRowSize( m_itemsGrid->GetDefaultRowSize() + 4 ); - m_itemsGrid->SetTable( m_fields ); m_itemsGrid->PushEventHandler( new GRID_TRICKS( m_itemsGrid ) ); diff --git a/pcbnew/dialogs/dialog_footprint_properties_fp_editor.cpp b/pcbnew/dialogs/dialog_footprint_properties_fp_editor.cpp index 42594604c3..66cb8b4f62 100644 --- a/pcbnew/dialogs/dialog_footprint_properties_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties_fp_editor.cpp @@ -125,20 +125,16 @@ void PRIVATE_LAYERS_GRID_TABLE::SetValueAsLong( int aRow, int aCol, long aValue NOTEBOOK_PAGES DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::m_page = NOTEBOOK_PAGES::PAGE_GENERAL; -DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR( - FOOTPRINT_EDIT_FRAME* aParent, - FOOTPRINT* aFootprint ) : +DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aParent, + FOOTPRINT* aFootprint ) : DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR_BASE( aParent ), m_frame( aParent ), m_footprint( aFootprint ), m_initialized( false ), m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits ), - m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl, - m_SolderMaskMarginUnits ), - m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl, - m_SolderPasteMarginUnits ), - m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl, - m_PasteMarginRatioUnits ), + m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl, m_SolderMaskMarginUnits ), + m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl, m_SolderPasteMarginUnits ), + m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl, m_PasteMarginRatioUnits ), m_gridSize( 0, 0 ), m_lastRequestedSize( 0, 0 ) { @@ -166,10 +162,6 @@ DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR( icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) ); SetIcon( icon ); - // Give a bit more room for combobox editors - m_itemsGrid->SetDefaultRowSize( m_itemsGrid->GetDefaultRowSize() + 4 ); - m_privateLayersGrid->SetDefaultRowSize( m_privateLayersGrid->GetDefaultRowSize() + 4 ); - m_itemsGrid->SetTable( m_fields ); m_privateLayersGrid->SetTable( m_privateLayers ); diff --git a/pcbnew/dialogs/dialog_swap_layers.cpp b/pcbnew/dialogs/dialog_swap_layers.cpp index 4752d3cd1d..8ac1a17dea 100644 --- a/pcbnew/dialogs/dialog_swap_layers.cpp +++ b/pcbnew/dialogs/dialog_swap_layers.cpp @@ -84,14 +84,13 @@ public: DIALOG_SWAP_LAYERS::DIALOG_SWAP_LAYERS( PCB_BASE_EDIT_FRAME* aParent, std::map& aLayerMap ) : - DIALOG_SWAP_LAYERS_BASE( aParent ), - m_parent( aParent ), - m_layerMap( aLayerMap ) + DIALOG_SWAP_LAYERS_BASE( aParent ), + m_parent( aParent ), + m_layerMap( aLayerMap ) { m_gridTable = new LAYER_GRID_TABLE( m_parent->GetBoard()->GetCopperLayerCount() ); m_grid->SetTable( m_gridTable ); m_grid->SetMinSize( FromDIP( m_grid->GetMinSize() ) ); - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + FromDIP( 4 ) ); m_grid->SetCellHighlightROPenWidth( 0 ); m_grid->SetUseNativeColLabels(); diff --git a/pcbnew/dialogs/panel_display_options.cpp b/pcbnew/dialogs/panel_display_options.cpp index 9f6e206d97..fbf62409dc 100644 --- a/pcbnew/dialogs/panel_display_options.cpp +++ b/pcbnew/dialogs/panel_display_options.cpp @@ -155,8 +155,6 @@ PANEL_DISPLAY_OPTIONS::PANEL_DISPLAY_OPTIONS( wxWindow* aParent, APP_SETTINGS_BA m_optionsBook->SetSelection( m_isPCBEdit ? 1 : 0 ); - m_layerNameitemsGrid->SetDefaultRowSize( m_layerNameitemsGrid->GetDefaultRowSize() + 4 ); - m_layerNameitemsGrid->SetTable( new LAYER_NAMES_GRID_TABLE(), true ); m_layerNameitemsGrid->PushEventHandler( new GRID_TRICKS( m_layerNameitemsGrid ) ); m_layerNameitemsGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); @@ -191,9 +189,9 @@ void PANEL_DISPLAY_OPTIONS::loadFPSettings( const FOOTPRINT_EDITOR_SETTINGS* aCf { wxGridTableBase* table = m_layerNameitemsGrid->GetTable(); - for( auto& item : aCfg->m_DesignSettings.m_UserLayerNames ) + for( const auto& [canonicalName, userName] : aCfg->m_DesignSettings.m_UserLayerNames ) { - wxString orig_name = item.first; + wxString orig_name = canonicalName; int layer = LSET::NameToLayer( orig_name ); if( !IsUserLayer( static_cast( layer ) ) ) @@ -202,7 +200,7 @@ void PANEL_DISPLAY_OPTIONS::loadFPSettings( const FOOTPRINT_EDITOR_SETTINGS* aCf int row = m_layerNameitemsGrid->GetNumberRows(); table->AppendRows( 1 ); table->SetValueAsLong( row, 0, layer ); - table->SetValue( row, 1, item.second ); + table->SetValue( row, 1, userName ); } Layout(); @@ -284,8 +282,7 @@ void PANEL_DISPLAY_OPTIONS::onLayerChange( wxGridEvent& event ) for( int i = 0; i < m_layerNameitemsGrid->GetNumberRows(); ++i ) { - if( i != event.GetRow() - && table->GetValueAsLong( i, 0 ) == layer ) + if( i != event.GetRow() && table->GetValueAsLong( i, 0 ) == layer ) { table->SetValueAsLong( event.GetRow(), 0, getNextAvailableLayer() ); return; diff --git a/pcbnew/dialogs/panel_fp_editor_field_defaults.cpp b/pcbnew/dialogs/panel_fp_editor_field_defaults.cpp index 0135b1b600..7667ef0350 100644 --- a/pcbnew/dialogs/panel_fp_editor_field_defaults.cpp +++ b/pcbnew/dialogs/panel_fp_editor_field_defaults.cpp @@ -175,11 +175,10 @@ static FOOTPRINT_EDITOR_SETTINGS& GetPgmSettings() PANEL_FP_EDITOR_FIELD_DEFAULTS::PANEL_FP_EDITOR_FIELD_DEFAULTS( wxWindow* aParent, UNITS_PROVIDER* aUnitsProvider ) : - PANEL_FP_EDITOR_FIELD_DEFAULTS_BASE( aParent ), m_unitProvider( aUnitsProvider ), + PANEL_FP_EDITOR_FIELD_DEFAULTS_BASE( aParent ), + m_unitProvider( aUnitsProvider ), m_designSettings( GetPgmSettings().m_DesignSettings ) { - m_fieldPropsGrid->SetDefaultRowSize( m_fieldPropsGrid->GetDefaultRowSize() + 4 ); - m_fieldPropsGrid->SetTable( new TEXT_ITEMS_GRID_TABLE( true ), true ); m_fieldPropsGrid->PushEventHandler( new GRID_TRICKS( m_fieldPropsGrid ) ); m_fieldPropsGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); @@ -195,8 +194,6 @@ PANEL_FP_EDITOR_FIELD_DEFAULTS::PANEL_FP_EDITOR_FIELD_DEFAULTS( wxWindow* attr->SetEditor( new GRID_CELL_LAYER_SELECTOR( nullptr, {} ) ); m_fieldPropsGrid->SetColAttr( 2, attr ); - m_textItemsGrid->SetDefaultRowSize( m_textItemsGrid->GetDefaultRowSize() + 4 ); - m_textItemsGrid->SetTable( new TEXT_ITEMS_GRID_TABLE( false ), true ); m_textItemsGrid->PushEventHandler( new GRID_TRICKS( m_textItemsGrid ) ); m_textItemsGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); diff --git a/pcbnew/dialogs/panel_fp_editor_graphics_defaults.cpp b/pcbnew/dialogs/panel_fp_editor_graphics_defaults.cpp index 25d2c1e72a..b70f01965b 100644 --- a/pcbnew/dialogs/panel_fp_editor_graphics_defaults.cpp +++ b/pcbnew/dialogs/panel_fp_editor_graphics_defaults.cpp @@ -64,18 +64,18 @@ static FOOTPRINT_EDITOR_SETTINGS& GetPgmSettings() } -PANEL_FP_EDITOR_GRAPHICS_DEFAULTS::PANEL_FP_EDITOR_GRAPHICS_DEFAULTS( - wxWindow* aParent, UNITS_PROVIDER* aUnitsProvider ) : - PANEL_FP_EDITOR_GRAPHICS_DEFAULTS_BASE( aParent ), m_unitProvider( aUnitsProvider ), +PANEL_FP_EDITOR_GRAPHICS_DEFAULTS::PANEL_FP_EDITOR_GRAPHICS_DEFAULTS( wxWindow* aParent, + UNITS_PROVIDER* aUnitsProvider ) : + PANEL_FP_EDITOR_GRAPHICS_DEFAULTS_BASE( aParent ), + m_unitProvider( aUnitsProvider ), m_designSettings( GetPgmSettings().m_DesignSettings ), - m_dimensionsPanel( std::make_unique( this, *m_unitProvider, - m_designSettings ) ) + m_dimensionsPanel( std::make_unique( this, *m_unitProvider, m_designSettings ) ) { m_graphicsGrid->SetUnitsProvider( aUnitsProvider ); - m_graphicsGrid->SetAutoEvalCols( - { COL_LINE_THICKNESS, COL_TEXT_WIDTH, COL_TEXT_HEIGHT, COL_TEXT_THICKNESS } ); - - m_graphicsGrid->SetDefaultRowSize( m_graphicsGrid->GetDefaultRowSize() + 4 ); + m_graphicsGrid->SetAutoEvalCols( { COL_LINE_THICKNESS, + COL_TEXT_WIDTH, + COL_TEXT_HEIGHT, + COL_TEXT_THICKNESS } ); // Work around a bug in wxWidgets where it fails to recalculate the grid height // after changing the default row size @@ -140,13 +140,11 @@ void PANEL_FP_EDITOR_GRAPHICS_DEFAULTS::loadFPSettings( const FOOTPRINT_EDITOR_S for( int col = 0; col < m_graphicsGrid->GetNumberCols(); col++ ) { // Set the minimal width to the column label size. - m_graphicsGrid->SetColMinimalWidth( col, - m_graphicsGrid->GetVisibleWidth( col, true, false ) ); + m_graphicsGrid->SetColMinimalWidth( col, m_graphicsGrid->GetVisibleWidth( col, true, false ) ); // Set the width to see the full contents if( m_graphicsGrid->IsColShown( col ) ) - m_graphicsGrid->SetColSize( col, - m_graphicsGrid->GetVisibleWidth( col, true, true, true ) ); + m_graphicsGrid->SetColSize( col, m_graphicsGrid->GetVisibleWidth( col, true, true, true ) ); } m_graphicsGrid->SetRowLabelSize( m_graphicsGrid->GetVisibleWidth( -1, true, true, true ) ); @@ -225,8 +223,7 @@ bool PANEL_FP_EDITOR_GRAPHICS_DEFAULTS::TransferDataFromWindow() int textHeight = m_graphicsGrid->GetUnitValue( i, COL_TEXT_HEIGHT ); int textThickness = m_graphicsGrid->GetUnitValue( i, COL_TEXT_THICKNESS ); - if( textWidth < minSize || textHeight < minSize || textWidth > maxSize - || textHeight > maxSize ) + if( textWidth < minSize || textHeight < minSize || textWidth > maxSize || textHeight > maxSize ) { if( !errorsMsg.IsEmpty() ) errorsMsg += wxT( "\n\n" ); @@ -249,17 +246,19 @@ bool PANEL_FP_EDITOR_GRAPHICS_DEFAULTS::TransferDataFromWindow() errorsMsg += wxT( "\n\n" ); if( textThickness > textMaxThickness ) - errorsMsg += wxString::Format( - _( "%s: Text thickness is too large.\n" - "It will be truncated to %s" ), - m_graphicsGrid->GetRowLabelValue( i ), - m_unitProvider->StringFromValue( textMaxThickness, true ) ); - + { + errorsMsg += wxString::Format( _( "%s: Text thickness is too large.\n" + "It will be truncated to %s" ), + m_graphicsGrid->GetRowLabelValue( i ), + m_unitProvider->StringFromValue( textMaxThickness, true ) ); + } else if( textThickness < minWidth ) + { errorsMsg += wxString::Format( _( "%s: Text thickness is too small.\n" "It will be truncated to %s" ), m_graphicsGrid->GetRowLabelValue( i ), m_unitProvider->StringFromValue( minWidth, true ) ); + } textThickness = std::min( textThickness, textMaxThickness ); textThickness = std::max( textThickness, minWidth ); @@ -281,8 +280,7 @@ bool PANEL_FP_EDITOR_GRAPHICS_DEFAULTS::TransferDataFromWindow() if( errorsMsg.IsEmpty() ) return true; - KIDIALOG dlg( wxGetTopLevelParent( this ), errorsMsg, KIDIALOG::KD_ERROR, - _( "Parameter error" ) ); + KIDIALOG dlg( wxGetTopLevelParent( this ), errorsMsg, KIDIALOG::KD_ERROR, _( "Parameter error" ) ); dlg.ShowModal(); return false; diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp index ed63bc8b03..d4196a1597 100644 --- a/pcbnew/dialogs/panel_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -75,83 +75,6 @@ #include #include -// clang-format off - -/** - * Container that describes file type info for the add a library options - */ -struct SUPPORTED_FILE_TYPE -{ - wxString m_Description; ///< Description shown in the file picker dialog - wxString m_FileFilter; ///< Filter used for file pickers if m_IsFile is true - wxString m_FolderSearchExtension; ///< In case of folders it stands for extensions of files stored inside - bool m_IsFile; ///< Whether the library is a folder or a file - PCB_IO_MGR::PCB_FILE_T m_Plugin; -}; - -// clang-format on - -/** - * Traverser implementation that looks to find any and all "folder" libraries by looking for files - * with a specific extension inside folders - */ -class LIBRARY_TRAVERSER : public wxDirTraverser -{ -public: - LIBRARY_TRAVERSER( std::vector aSearchExtensions, wxString aInitialDir ) : - m_searchExtensions( aSearchExtensions ), m_currentDir( aInitialDir ) - { - } - - virtual wxDirTraverseResult OnFile( const wxString& aFileName ) override - { - wxFileName file( aFileName ); - - for( const std::string& ext : m_searchExtensions ) - { - if( file.GetExt().IsSameAs( ext, false ) ) - m_foundDirs.insert( { m_currentDir, 1 } ); - } - - return wxDIR_CONTINUE; - } - - virtual wxDirTraverseResult OnOpenError( const wxString& aOpenErrorName ) override - { - m_failedDirs.insert( { aOpenErrorName, 1 } ); - return wxDIR_IGNORE; - } - - bool HasDirectoryOpenFailures() - { - return m_failedDirs.size() > 0; - } - - virtual wxDirTraverseResult OnDir( const wxString& aDirName ) override - { - m_currentDir = aDirName; - return wxDIR_CONTINUE; - } - - void GetPaths( wxArrayString& aPathArray ) - { - for( std::pair& foundDirsPair : m_foundDirs ) - aPathArray.Add( foundDirsPair.first ); - } - - void GetFailedPaths( wxArrayString& aPathArray ) - { - for( std::pair& failedDirsPair : m_failedDirs ) - aPathArray.Add( failedDirsPair.first ); - } - -private: - std::vector m_searchExtensions; - wxString m_currentDir; - std::unordered_map m_foundDirs; - std::unordered_map m_failedDirs; -}; - /** * This class builds a wxGridTableBase by wrapping an #FP_LIB_TABLE object. @@ -394,12 +317,12 @@ PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, PRO FP_LIB_TABLE* aGlobalTable, const wxString& aGlobalTblPath, FP_LIB_TABLE* aProjectTable, const wxString& aProjectTblPath, const wxString& aProjectBasePath ) : - PANEL_FP_LIB_TABLE_BASE( aParent ), - m_globalTable( aGlobalTable ), - m_projectTable( aProjectTable ), - m_project( aProject ), - m_projectBasePath( aProjectBasePath ), - m_parent( aParent ) + PANEL_FP_LIB_TABLE_BASE( aParent ), + m_globalTable( aGlobalTable ), + m_projectTable( aProjectTable ), + m_project( aProject ), + m_projectBasePath( aProjectBasePath ), + m_parent( aParent ) { m_global_grid->SetTable( new FP_LIB_TABLE_GRID( *aGlobalTable ), true ); @@ -484,8 +407,7 @@ PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, PRO if( desc.m_IsFile && !desc.m_FileExtensions.empty() ) { - entryStr << wxString::Format( wxS( " (%s)" ), - joinExts( desc.m_FileExtensions ) ); + entryStr << wxString::Format( wxS( " (%s)" ), joinExts( desc.m_FileExtensions ) ); } else if( !desc.m_IsFile && !desc.m_ExtensionsInDir.empty() ) { @@ -497,8 +419,7 @@ PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, PRO browseMenu->Append( type, entryStr ); - browseMenu->Bind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_FP_LIB_TABLE::browseLibrariesHandler, - this, type ); + browseMenu->Bind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_FP_LIB_TABLE::browseLibrariesHandler, this, type ); } Layout(); @@ -634,8 +555,7 @@ bool PANEL_FP_LIB_TABLE::verifyTables() if( nick1 == nick2 ) { - msg = wxString::Format( _( "Multiple libraries cannot share the same " - "nickname ('%s')." ), + msg = wxString::Format( _( "Multiple libraries cannot share the same nickname ('%s')." ), nick1 ); // show the tabbed panel holding the grid we have flunked: @@ -841,14 +761,12 @@ void PANEL_FP_LIB_TABLE::onMigrateLibraries( wxCommandEvent& event ) { if( rowsToMigrate.size() == 1 ) { - msg.Printf( _( "Save '%s' as current KiCad format " - "and replace entry in table?" ), + msg.Printf( _( "Save '%s' as current KiCad format and replace entry in table?" ), m_cur_grid->GetCellValue( rowsToMigrate[0], COL_NICKNAME ) ); } else { - msg.Printf( _( "Save %d libraries as current KiCad format " - "and replace entries in table?" ), + msg.Printf( _( "Save %d libraries as current KiCad format and replace entries in table?" ), (int) rowsToMigrate.size() ); } @@ -880,8 +798,7 @@ void PANEL_FP_LIB_TABLE::onMigrateLibraries( wxCommandEvent& event ) msg.Printf( _( "Folder '%s' already exists. Do you want overwrite any existing footprints?" ), newLib.GetFullPath() ); - switch( wxMessageBox( msg, _( "Migrate Library" ), - wxYES_NO | wxCANCEL | wxICON_QUESTION, m_parent ) ) + switch( wxMessageBox( msg, _( "Migrate Library" ), wxYES_NO|wxCANCEL|wxICON_QUESTION, m_parent ) ) { case wxYES: break; case wxNO: continue; @@ -892,11 +809,10 @@ void PANEL_FP_LIB_TABLE::onMigrateLibraries( wxCommandEvent& event ) wxString options = m_cur_grid->GetCellValue( row, COL_OPTIONS ); std::unique_ptr> props( LIB_TABLE::ParseOptions( options.ToStdString() ) ); - if( PCB_IO_MGR::ConvertLibrary( props.get(), legacyLib.GetFullPath(), - newLib.GetFullPath(), errorReporter.m_Reporter ) ) + if( PCB_IO_MGR::ConvertLibrary( props.get(), legacyLib.GetFullPath(), newLib.GetFullPath(), + errorReporter.m_Reporter ) ) { - relPath = NormalizePath( newLib.GetFullPath(), &Pgm().GetLocalEnvVariables(), - m_project ); + relPath = NormalizePath( newLib.GetFullPath(), &Pgm().GetLocalEnvVariables(), m_project ); // Do not use the project path in the global library table. This will almost // assuredly be wrong for a different project. @@ -942,8 +858,7 @@ void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) if( fileType == PCB_IO_MGR::FILE_TYPE_NONE ) { - wxLogWarning( wxT( "File type selection event received but could not find the file type " - "in the table" ) ); + wxLogWarning( wxT( "File type selection event received but could not find the file type in the table" ) ); return; } @@ -1213,10 +1128,6 @@ void PANEL_FP_LIB_TABLE::populateEnvironReadOnlyTable() m_path_subs_grid->SetCellEditor( row, 1, new GRID_CELL_READONLY_TEXT_EDITOR() ); } - // No combobox editors here, but it looks better if its consistent with the other - // grids in the dialog. - m_path_subs_grid->SetDefaultRowSize( m_path_subs_grid->GetDefaultRowSize() + 2 ); - adjustPathSubsGridColumns( m_path_subs_grid->GetRect().GetWidth() ); } diff --git a/pcbnew/dialogs/panel_fp_properties_3d_model.cpp b/pcbnew/dialogs/panel_fp_properties_3d_model.cpp index a71a82c72d..ff82d301f3 100644 --- a/pcbnew/dialogs/panel_fp_properties_3d_model.cpp +++ b/pcbnew/dialogs/panel_fp_properties_3d_model.cpp @@ -79,8 +79,6 @@ PANEL_FP_PROPERTIES_3D_MODEL::PANEL_FP_PROPERTIES_3D_MODEL( PCB_BASE_EDIT_FRAME* m_splitter1->SetSashPosition( FromDIP( m_splitter1->GetSashPosition() ) ); m_splitter1->SetMinimumPaneSize( FromDIP( m_splitter1->GetMinimumPaneSize() ) ); - m_modelsGrid->SetDefaultRowSize( m_modelsGrid->GetDefaultRowSize() + 4 ); - GRID_TRICKS* trick = new GRID_TRICKS( m_modelsGrid, [this]( wxCommandEvent& aEvent ) { OnAdd3DRow( aEvent ); @@ -125,8 +123,7 @@ PANEL_FP_PROPERTIES_3D_MODEL::PANEL_FP_PROPERTIES_3D_MODEL( PCB_BASE_EDIT_FRAME* PROJECT_PCB::Get3DCacheManager( &m_frame->Prj() )->GetResolver()->SetProgramBase( &Pgm() ); - m_previewPane = new PANEL_PREVIEW_3D_MODEL( m_lowerPanel, m_frame, m_footprint, - &m_shapes3D_list ); + m_previewPane = new PANEL_PREVIEW_3D_MODEL( m_lowerPanel, m_frame, m_footprint, &m_shapes3D_list ); m_LowerSizer3D->Add( m_previewPane, 1, wxEXPAND, 5 ); @@ -503,8 +500,7 @@ void PANEL_FP_PROPERTIES_3D_MODEL::updateValidateStatus( int aRow ) } m_modelsGrid->SetCellValue( aRow, COL_PROBLEM, errStr ); - m_modelsGrid->SetCellRenderer( aRow, COL_PROBLEM, - new GRID_CELL_STATUS_ICON_RENDERER( icon ) ); + m_modelsGrid->SetCellRenderer( aRow, COL_PROBLEM, new GRID_CELL_STATUS_ICON_RENDERER( icon ) ); } @@ -524,6 +520,7 @@ MODEL_VALIDATE_ERRORS PANEL_FP_PROPERTIES_3D_MODEL::validateModelExists( const w wxString libraryName = m_footprint->GetFPID().GetLibNickname(); const FP_LIB_TABLE_ROW* fpRow = nullptr; + try { fpRow = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() )->FindRow( libraryName, false ); @@ -568,8 +565,7 @@ void PANEL_FP_PROPERTIES_3D_MODEL::AdjustGridColumnWidths() // Account for scroll bars int modelsWidth = KIPLATFORM::UI::GetUnobscuredSize( m_modelsGrid ).x; - int width = modelsWidth - m_modelsGrid->GetColSize( COL_SHOWN ) - - m_modelsGrid->GetColSize( COL_PROBLEM ); + int width = modelsWidth - m_modelsGrid->GetColSize( COL_SHOWN ) - m_modelsGrid->GetColSize( COL_PROBLEM ); if( width > 0 ) m_modelsGrid->SetColSize( COL_FILENAME, width ); @@ -606,8 +602,7 @@ void PANEL_FP_PROPERTIES_3D_MODEL::onShowEvent( wxShowEvent& aEvent ) void PANEL_FP_PROPERTIES_3D_MODEL::onDialogActivateEvent( wxActivateEvent& aEvent ) { - postCustomPanelShownEventWithPredicate( aEvent.GetActive() - && m_previewPane->IsShownOnScreen() ); + postCustomPanelShownEventWithPredicate( aEvent.GetActive() && m_previewPane->IsShownOnScreen() ); aEvent.Skip(); } diff --git a/pcbnew/dialogs/panel_setup_text_and_graphics.cpp b/pcbnew/dialogs/panel_setup_text_and_graphics.cpp index cd34112dc1..347fbd58d2 100644 --- a/pcbnew/dialogs/panel_setup_text_and_graphics.cpp +++ b/pcbnew/dialogs/panel_setup_text_and_graphics.cpp @@ -61,15 +61,13 @@ PANEL_SETUP_TEXT_AND_GRAPHICS::PANEL_SETUP_TEXT_AND_GRAPHICS( wxWindow* aP PANEL_SETUP_TEXT_AND_GRAPHICS_BASE( aParentWindow ), m_Frame( aFrame ), m_BrdSettings( &m_Frame->GetBoard()->GetDesignSettings() ), - m_dimensionsPanel( - std::make_unique( this, *aFrame, *m_BrdSettings ) ) + m_dimensionsPanel( std::make_unique( this, *aFrame, *m_BrdSettings ) ) { m_grid->SetUnitsProvider( m_Frame ); m_grid->SetAutoEvalCols( { COL_LINE_THICKNESS, COL_TEXT_WIDTH, COL_TEXT_HEIGHT, COL_TEXT_THICKNESS } ); - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + FromDIP( 4 ) ); m_grid->SetUseNativeColLabels(); // Work around a bug in wxWidgets where it fails to recalculate the grid height @@ -157,10 +155,10 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow() SET_MILS_CELL( i, COL_TEXT_WIDTH, m_BrdSettings->m_TextSize[ i ].x ); SET_MILS_CELL( i, COL_TEXT_HEIGHT, m_BrdSettings->m_TextSize[ i ].y ); SET_MILS_CELL( i, COL_TEXT_THICKNESS, m_BrdSettings->m_TextThickness[ i ] ); - m_grid->SetCellValue( i, COL_TEXT_ITALIC, - m_BrdSettings->m_TextItalic[ i ] ? wxT( "1" ) : wxT( "" ) ); - m_grid->SetCellValue( i, COL_TEXT_UPRIGHT, - m_BrdSettings->m_TextUpright[ i ] ? wxT( "1" ) : wxT( "" ) ); + m_grid->SetCellValue( i, COL_TEXT_ITALIC, m_BrdSettings->m_TextItalic[ i ] ? wxT( "1" ) + : wxT( "" ) ); + m_grid->SetCellValue( i, COL_TEXT_UPRIGHT, m_BrdSettings->m_TextUpright[ i ] ? wxT( "1" ) + : wxT( "" ) ); auto attr = new wxGridCellAttr; attr->SetRenderer( new wxGridCellBoolRenderer() ); @@ -233,8 +231,7 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow() int textHeight = m_grid->GetUnitValue( i, COL_TEXT_HEIGHT ); int textThickness = m_grid->GetUnitValue( i, COL_TEXT_THICKNESS ); - if( textWidth < minSize || textHeight < minSize - || textWidth > maxSize || textHeight > maxSize ) + if( textWidth < minSize || textHeight < minSize || textWidth > maxSize || textHeight > maxSize ) { if( !errorsMsg.IsEmpty() ) errorsMsg += wxT( "\n\n" ); @@ -255,18 +252,20 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow() if( !errorsMsg.IsEmpty() ) errorsMsg += wxT( "\n\n" ); - if( textThickness > textMaxThickness ) + { errorsMsg += wxString::Format( _( "%s: Text thickness is too large.\n" "It will be truncated to %s" ), m_grid->GetRowLabelValue( i ), unitProvider->StringFromValue( textMaxThickness , true) ); - + } else if( textThickness < minWidth ) + { errorsMsg += wxString::Format( _( "%s: Text thickness is too small.\n" "It will be truncated to %s" ), m_grid->GetRowLabelValue( i ), unitProvider->StringFromValue( minWidth , true ) ); + } textThickness = std::min( textThickness, textMaxThickness ); textThickness = std::max( textThickness, minWidth ); @@ -290,8 +289,7 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow() if( errorsMsg.IsEmpty() ) return true; - KIDIALOG dlg( wxGetTopLevelParent( this ), errorsMsg, KIDIALOG::KD_ERROR, - _( "Parameter error" ) ); + KIDIALOG dlg( wxGetTopLevelParent( this ), errorsMsg, KIDIALOG::KD_ERROR, _( "Parameter error" ) ); dlg.ShowModal(); return false; diff --git a/pcbnew/dialogs/panel_setup_time_domain_parameters.cpp b/pcbnew/dialogs/panel_setup_time_domain_parameters.cpp index 9da83d553e..e1e064cd79 100644 --- a/pcbnew/dialogs/panel_setup_time_domain_parameters.cpp +++ b/pcbnew/dialogs/panel_setup_time_domain_parameters.cpp @@ -34,10 +34,12 @@ #include PANEL_SETUP_TIME_DOMAIN_PARAMETERS::PANEL_SETUP_TIME_DOMAIN_PARAMETERS( - wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame, BOARD* aBoard, - std::shared_ptr aTimeDomainParameters ) : + wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame, BOARD* aBoard, + std::shared_ptr aTimeDomainParameters ) : PANEL_SETUP_TIME_DOMAIN_PARAMETERS_BASE( aParentWindow ), - m_timeDomainParameters( std::move( aTimeDomainParameters ) ), m_frame( aFrame ), m_board( aFrame->GetBoard() ) + m_timeDomainParameters( std::move( aTimeDomainParameters ) ), + m_frame( aFrame ), + m_board( aFrame->GetBoard() ) { m_timeDomainParametersPane->SetBorders( true, false, false, false ); @@ -55,7 +57,6 @@ PANEL_SETUP_TIME_DOMAIN_PARAMETERS::PANEL_SETUP_TIME_DOMAIN_PARAMETERS( m_tracePropagationGrid->SetUseNativeColLabels(); m_tracePropagationGrid->EnsureColLabelsVisible(); - m_tracePropagationGrid->SetDefaultRowSize( m_tracePropagationGrid->GetDefaultRowSize() + 4 ); m_tracePropagationGrid->PushEventHandler( new GRID_TRICKS( m_tracePropagationGrid ) ); m_tracePropagationGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); @@ -73,7 +74,6 @@ PANEL_SETUP_TIME_DOMAIN_PARAMETERS::PANEL_SETUP_TIME_DOMAIN_PARAMETERS( m_viaPropagationGrid->SetUseNativeColLabels(); m_viaPropagationGrid->EnsureColLabelsVisible(); - m_viaPropagationGrid->SetDefaultRowSize( m_viaPropagationGrid->GetDefaultRowSize() + 4 ); m_viaPropagationGrid->PushEventHandler( new GRID_TRICKS( m_viaPropagationGrid ) ); m_viaPropagationGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); @@ -169,9 +169,7 @@ void PANEL_SETUP_TIME_DOMAIN_PARAMETERS::addProfileRow( const DELAY_PROFILE& aDe int col = m_copperLayerIdsToColumns[layerId]; if( col < m_tracePropagationGrid->GetNumberCols() ) - { m_tracePropagationGrid->SetUnitValue( rowId, col, velocity ); - } } } diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp index d74b1a5092..86958ced7a 100644 --- a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp +++ b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp @@ -53,7 +53,7 @@ enum DIFF_VAR_GRID_COLUMNS PANEL_SETUP_TRACKS_AND_VIAS::PANEL_SETUP_TRACKS_AND_VIAS( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame ) : - PANEL_SETUP_TRACKS_AND_VIAS_BASE( aParentWindow ) + PANEL_SETUP_TRACKS_AND_VIAS_BASE( aParentWindow ) { m_Frame = aFrame; m_Pcb = m_Frame->GetBoard(); @@ -69,12 +69,6 @@ PANEL_SETUP_TRACKS_AND_VIAS::PANEL_SETUP_TRACKS_AND_VIAS( wxWindow* aParentWindo m_diffPairsSortButton->SetBitmap( KiBitmapBundle( BITMAPS::small_sort_desc ) ); m_diffPairsRemoveButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) ); - // Membership combobox editors require a bit more room, so increase the row size of - // all our grids for consistency - m_trackWidthsGrid->SetDefaultRowSize( m_trackWidthsGrid->GetDefaultRowSize() + FromDIP( 4 ) ); - m_viaSizesGrid->SetDefaultRowSize( m_viaSizesGrid->GetDefaultRowSize() + FromDIP( 4 ) ); - m_diffPairsGrid->SetDefaultRowSize( m_diffPairsGrid->GetDefaultRowSize() + FromDIP( 4 ) ); - m_trackWidthsGrid->PushEventHandler( new GRID_TRICKS( m_trackWidthsGrid, [this]( wxCommandEvent& aEvent ) { @@ -322,7 +316,7 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow() diffPair_dim.m_Width = m_diffPairsGrid->GetUnitValue( row, DP_WIDTH_COL ); if( !m_diffPairsGrid->GetCellValue( row, DP_GAP_COL ).IsEmpty() ) - diffPair_dim.m_Gap = m_diffPairsGrid->GetUnitValue( row, DP_GAP_COL ); + diffPair_dim.m_Gap = m_diffPairsGrid->GetUnitValue( row, DP_GAP_COL ); if( !m_diffPairsGrid->GetCellValue( row, DP_VIA_GAP_COL ).IsEmpty() ) diffPair_dim.m_ViaGap = m_diffPairsGrid->GetUnitValue( row, DP_VIA_GAP_COL ); @@ -441,7 +435,7 @@ void removeSelectedRows( WX_GRID* aGrid ) if( selectedRows.empty() && curRow >= 0 && curRow < aGrid->GetNumberRows() ) selectedRows.Add( curRow ); - for( int ii = selectedRows.Count() - 1; ii >= 0; --ii ) + for( int ii = (int) selectedRows.Count() - 1; ii >= 0; --ii ) { int row = selectedRows.Item( ii ); aGrid->DeleteRows( row, 1 );