This commit is contained in:
Jeff Young 2022-08-18 17:56:36 +01:00
parent a60053c800
commit 508df402f6
13 changed files with 67 additions and 47 deletions

View File

@ -138,7 +138,7 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, EDA_DRAW_
{
// We calculate the column min size only from texts sizes, not using the initial col width
// as this initial width is sometimes strange depending on the language (wxGrid bug?)
int min_width = m_netclassGrid->GetVisibleWidth( i, true, true, false );
int min_width = m_netclassGrid->GetVisibleWidth( i, true, true );
if( i == GRID_LINESTYLE )
min_best_width *= 1.5;

View File

@ -85,7 +85,7 @@ public:
* @param aKeep - Use the current size as a minimum value
* @return The new size of the column
*/
int GetVisibleWidth( int aCol, bool aHeader = true, bool aContents = false, bool aKeep = true );
int GetVisibleWidth( int aCol, bool aHeader = true, bool aContents = true, bool aKeep = false );
/**
* Ensure the height of the row displaying the column labels is enough, even

View File

@ -82,7 +82,7 @@ void DIALOG_MANAGE_REPOSITORIES::setColumnWidths()
for( int col = 0; col < m_grid->GetNumberCols(); col++ )
{
// Set the width to see the full contents
m_grid->SetColSize( col, m_grid->GetVisibleWidth( col, true, true, false ) );
m_grid->SetColSize( col, m_grid->GetVisibleWidth( col, true, true ) );
}
}

View File

@ -369,8 +369,7 @@ void DIALOG_PCM::updatePendingActionsTab()
for( int col = 0; col < m_gridPendingActions->GetNumberCols(); col++ )
{
// Set the width to see the full contents
m_gridPendingActions->SetColSize(
col, m_gridPendingActions->GetVisibleWidth( col, true, true, false ) );
m_gridPendingActions->SetColSize( col, m_gridPendingActions->GetVisibleWidth( col ) );
}
}

View File

@ -82,8 +82,7 @@ PANEL_PACKAGES_VIEW::PANEL_PACKAGES_VIEW( wxWindow*
// Set the minimal width to the column label size.
m_gridVersions->SetColMinimalWidth( col, headingWidth );
m_gridVersions->SetColSize( col,
m_gridVersions->GetVisibleWidth( col, true, true, false ) );
m_gridVersions->SetColSize( col, m_gridVersions->GetVisibleWidth( col ) );
}
// Most likely should be changed to wxGridSelectNone once WxWidgets>=3.1.5 is mandatory.
@ -322,8 +321,7 @@ void PANEL_PACKAGES_VIEW::setPackageDetails( const PACKAGE_VIEW_DATA& aPackageDa
for( int col = 0; col < m_gridVersions->GetNumberCols(); col++ )
{
// Set the width to see the full contents
m_gridVersions->SetColSize( col,
m_gridVersions->GetVisibleWidth( col, true, true, false ) );
m_gridVersions->SetColSize( col, m_gridVersions->GetVisibleWidth( col ) );
}
// Autoselect preferred or installed version

View File

@ -62,7 +62,7 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
m_formatting = new PANEL_SETUP_FORMATTING( this, aFrame );
m_constraints = new PANEL_SETUP_CONSTRAINTS( this, aFrame );
m_rules = new PANEL_SETUP_RULES( this, aFrame );
m_tracksAndVias = new PANEL_SETUP_TRACKS_AND_VIAS( this, aFrame, m_constraints );
m_tracksAndVias = new PANEL_SETUP_TRACKS_AND_VIAS( this, aFrame );
m_maskAndPaste = new PANEL_SETUP_MASK_AND_PASTE( this, aFrame );
m_physicalStackup = new PANEL_SETUP_BOARD_STACKUP( this, aFrame, m_layers );
m_boardFinish = new PANEL_SETUP_BOARD_FINISH( this, board );

View File

@ -310,10 +310,10 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow()
for( int col = 0; col < m_itemsGrid->GetNumberCols(); col++ )
{
m_itemsGrid->SetColMinimalWidth( col, m_itemsGrid->GetVisibleWidth( col, true, false,
false ) );
m_itemsGrid->SetColMinimalWidth( col, m_itemsGrid->GetVisibleWidth( col, true, false ) );
// Adjust the column size.
int col_size = m_itemsGrid->GetVisibleWidth( col, true, true, false );
int col_size = m_itemsGrid->GetVisibleWidth( col );
if( col == FPT_LAYER ) // This one's a drop-down. Check all possible values.
{
@ -584,11 +584,8 @@ void DIALOG_FOOTPRINT_PROPERTIES::adjustGridColumns()
for( int i = 1; i < m_itemsGrid->GetNumberCols(); i++ )
itemsWidth -= m_itemsGrid->GetColSize( i );
if( itemsWidth > 0 )
{
m_itemsGrid->SetColSize( 0, std::max( itemsWidth,
m_itemsGrid->GetVisibleWidth( 0, true, false, false ) ) );
}
m_itemsGrid->GetVisibleWidth( 0, true, false ) ) );
// Update the width of the 3D panel
m_3dPanel->AdjustGridColumnWidths();

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -268,7 +268,7 @@ void PANEL_FP_EDITOR_DEFAULTS::loadFPSettings( FOOTPRINT_EDITOR_SETTINGS* aCfg )
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, false ) );
m_graphicsGrid->SetColMinimalWidth( col, m_graphicsGrid->GetVisibleWidth( col, true, false ) );
// Set the width to see the full contents
if( m_graphicsGrid->IsColShown( col ) )

View File

@ -4,7 +4,7 @@
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -26,9 +26,7 @@
#include <panel_fp_properties_3d_model.h>
#include <confirm.h>
#include <3d_viewer/eda_3d_viewer_frame.h>
#include <board_design_settings.h>
#include <bitmaps.h>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/grid_text_button_helpers.h>
@ -43,7 +41,6 @@
#include "dialogs/panel_preview_3d_model.h"
#include "dialogs/3d_cache_dialogs.h"
#include <settings/settings_manager.h>
#include <kiway_holder.h>
#include <wx/defs.h>
enum MODELS_TABLE_COLUMNS
@ -174,7 +171,7 @@ void PANEL_FP_PROPERTIES_3D_MODEL::ReloadModelsFromFootprint()
select3DModel( 0 );
m_previewPane->UpdateDummyFootprint();
m_modelsGrid->SetColSize( COL_SHOWN, m_modelsGrid->GetVisibleWidth( COL_SHOWN, true, false, false ) );
m_modelsGrid->SetColSize( COL_SHOWN, m_modelsGrid->GetVisibleWidth( COL_SHOWN, true, false ) );
Layout();
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Andrew Lutsenko, anlutsenko at gmail dot com
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@ -204,7 +204,7 @@ bool PANEL_PCBNEW_ACTION_PLUGINS::TransferDataToWindow()
// Set the minimal width to the column label size.
m_grid->SetColMinimalWidth( col, headingWidth );
// Set the width to see the full contents
m_grid->SetColSize( col, m_grid->GetVisibleWidth( col, true, true, false ) );
m_grid->SetColSize( col, m_grid->GetVisibleWidth( col ) );
}
m_grid->AutoSizeRows();

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018-2021 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2018-2022 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -82,7 +82,7 @@ PANEL_SETUP_TEXT_AND_GRAPHICS::PANEL_SETUP_TEXT_AND_GRAPHICS( PAGED_DIALOG* aPar
{
// We calculate the column min size only from texts sizes, not using the initial col width
// as this initial width is sometimes strange depending on the language (wxGrid bug?)
int min_width = m_grid->GetVisibleWidth( i, true, true, false );
int min_width = m_grid->GetVisibleWidth( i );
m_grid->SetColMinimalWidth( i, min_width );
@ -167,7 +167,7 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow()
// Work around an issue where wxWidgets doesn't calculate the row width on its own
for( int col = 0; col < m_grid->GetNumberCols(); col++ )
m_grid->SetColMinimalWidth( col, m_grid->GetVisibleWidth( col, true, true, false ) );
m_grid->SetColMinimalWidth( col, m_grid->GetVisibleWidth( col ) );
m_grid->SetRowLabelSize( m_grid->GetVisibleWidth( -1, true, true, true ) );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018-2021 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2018-2022 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -53,15 +53,13 @@ enum DIFF_VAR_GRID_COLUMNS
PANEL_SETUP_TRACKS_AND_VIAS::PANEL_SETUP_TRACKS_AND_VIAS( PAGED_DIALOG* aParent,
PCB_EDIT_FRAME* aFrame,
PANEL_SETUP_CONSTRAINTS* aConstraintsPanel ) :
PCB_EDIT_FRAME* aFrame ) :
PANEL_SETUP_TRACKS_AND_VIAS_BASE( aParent->GetTreebook() )
{
m_Parent = aParent;
m_Frame = aFrame;
m_Pcb = m_Frame->GetBoard();
m_BrdSettings = &m_Pcb->GetDesignSettings();
m_ConstraintsPanel = aConstraintsPanel;
m_trackWidthsAddButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
m_trackWidthsSortButton->SetBitmap( KiBitmap( BITMAPS::small_sort_desc ) );
@ -272,13 +270,6 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow()
std::vector<VIA_DIMENSION> vias;
std::vector<DIFF_PAIR_DIMENSION> diffPairs;
if( !m_trackWidthsGrid->CommitPendingChanges()
|| !m_viaSizesGrid->CommitPendingChanges()
|| !m_diffPairsGrid->CommitPendingChanges() )
{
return false;
}
// Test ONLY for malformed data. Design rules and constraints are the business of DRC.
for( int row = 0; row < m_trackWidthsGrid->GetNumberRows(); ++row )
@ -443,6 +434,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs( const int aWidth, const int a
}
}
void removeSelectedRows( WX_GRID* aGrid )
{
wxArrayInt selectedRows = aGrid->GetSelectedRows();
@ -466,6 +458,13 @@ void removeSelectedRows( WX_GRID* aGrid )
void PANEL_SETUP_TRACKS_AND_VIAS::OnAddTrackWidthsClick( wxCommandEvent& aEvent )
{
if( !m_trackWidthsGrid->CommitPendingChanges()
|| !m_viaSizesGrid->CommitPendingChanges()
|| !m_diffPairsGrid->CommitPendingChanges() )
{
return;
}
AppendTrackWidth( 0 );
m_trackWidthsGrid->MakeCellVisible( m_trackWidthsGrid->GetNumberRows() - 1, TR_WIDTH_COL );
@ -478,12 +477,26 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnAddTrackWidthsClick( wxCommandEvent& aEvent
void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveTrackWidthsClick( wxCommandEvent& event )
{
if( !m_trackWidthsGrid->CommitPendingChanges()
|| !m_viaSizesGrid->CommitPendingChanges()
|| !m_diffPairsGrid->CommitPendingChanges() )
{
return;
}
removeSelectedRows( m_trackWidthsGrid );
}
void PANEL_SETUP_TRACKS_AND_VIAS::OnAddViaSizesClick( wxCommandEvent& event )
{
if( !m_trackWidthsGrid->CommitPendingChanges()
|| !m_viaSizesGrid->CommitPendingChanges()
|| !m_diffPairsGrid->CommitPendingChanges() )
{
return;
}
AppendViaSize( 0, 0 );
m_viaSizesGrid->MakeCellVisible( m_viaSizesGrid->GetNumberRows() - 1, VIA_SIZE_COL );
@ -496,12 +509,26 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnAddViaSizesClick( wxCommandEvent& event )
void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveViaSizesClick( wxCommandEvent& event )
{
if( !m_trackWidthsGrid->CommitPendingChanges()
|| !m_viaSizesGrid->CommitPendingChanges()
|| !m_diffPairsGrid->CommitPendingChanges() )
{
return;
}
removeSelectedRows( m_viaSizesGrid );
}
void PANEL_SETUP_TRACKS_AND_VIAS::OnAddDiffPairsClick( wxCommandEvent& event )
{
if( !m_trackWidthsGrid->CommitPendingChanges()
|| !m_viaSizesGrid->CommitPendingChanges()
|| !m_diffPairsGrid->CommitPendingChanges() )
{
return;
}
AppendDiffPairs( 0, 0, 0 );
m_diffPairsGrid->MakeCellVisible( m_diffPairsGrid->GetNumberRows() - 1, DP_WIDTH_COL );
@ -514,6 +541,13 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnAddDiffPairsClick( wxCommandEvent& event )
void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveDiffPairsClick( wxCommandEvent& event )
{
if( !m_trackWidthsGrid->CommitPendingChanges()
|| !m_viaSizesGrid->CommitPendingChanges()
|| !m_diffPairsGrid->CommitPendingChanges() )
{
return;
}
removeSelectedRows( m_diffPairsGrid );
}

View File

@ -39,8 +39,7 @@ class BOARD_DESIGN_SETTINGS;
class PANEL_SETUP_TRACKS_AND_VIAS : public PANEL_SETUP_TRACKS_AND_VIAS_BASE
{
public:
PANEL_SETUP_TRACKS_AND_VIAS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame,
PANEL_SETUP_CONSTRAINTS* aConstraintsPanel );
PANEL_SETUP_TRACKS_AND_VIAS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame );
~PANEL_SETUP_TRACKS_AND_VIAS() override;
bool TransferDataToWindow() override;
@ -72,10 +71,6 @@ private:
PCB_EDIT_FRAME* m_Frame;
BOARD* m_Pcb;
BOARD_DESIGN_SETTINGS* m_BrdSettings;
// We must validate against the current m_BrdSettings as they may have been
// changed but not yet committed. Fetch them from the constraints panel.
PANEL_SETUP_CONSTRAINTS* m_ConstraintsPanel;
};
#endif //PANEL_SETUP_TRACKS_AND_VIAS_H