More safety fixes for uncommitted grid changes.

This commit is contained in:
Jeff Young 2018-08-19 17:10:14 +01:00
parent 2398edda38
commit b90a261d5c
39 changed files with 2298 additions and 3719 deletions

View File

@ -29,6 +29,7 @@
#include <validators.h>
#include <html_messagebox.h>
#include <filename_resolver.h>
#include <widgets/wx_grid.h>
enum ENV_VAR_GRID_COLUMNS
@ -184,12 +185,11 @@ void DIALOG_CONFIGURE_PATHS::AppendSearchPath( const wxString& aName, const wxSt
bool DIALOG_CONFIGURE_PATHS::TransferDataFromWindow()
{
if( !wxDialog::TransferDataFromWindow() )
if( !m_EnvVars->CommitPendingChanges() || !m_SearchPaths->CommitPendingChanges() )
return false;
// Commit any pending in-place edits and close the editor
m_EnvVars->DisableCellEditControl();
m_SearchPaths->DisableCellEditControl();
if( !wxDialog::TransferDataFromWindow() )
return false;
// Environment variables
@ -320,6 +320,9 @@ void DIALOG_CONFIGURE_PATHS::OnGridCellChanging( wxGridEvent& event )
void DIALOG_CONFIGURE_PATHS::OnAddEnvVar( wxCommandEvent& event )
{
if( !m_EnvVars->CommitPendingChanges() )
return;
AppendEnvVar( wxEmptyString, wxEmptyString, false );
m_EnvVars->MakeCellVisible( m_EnvVars->GetNumberRows() - 1, EV_NAME_COL );
@ -332,6 +335,9 @@ void DIALOG_CONFIGURE_PATHS::OnAddEnvVar( wxCommandEvent& event )
void DIALOG_CONFIGURE_PATHS::OnAddSearchPath( wxCommandEvent& event )
{
if( !m_SearchPaths->CommitPendingChanges() )
return;
AppendSearchPath( wxEmptyString, wxEmptyString, wxEmptyString);
m_SearchPaths->MakeCellVisible( m_SearchPaths->GetNumberRows() - 1, SP_ALIAS_COL );
@ -344,6 +350,9 @@ void DIALOG_CONFIGURE_PATHS::OnAddSearchPath( wxCommandEvent& event )
void DIALOG_CONFIGURE_PATHS::OnRemoveEnvVar( wxCommandEvent& event )
{
if( !m_EnvVars->CommitPendingChanges() )
return;
int curRow = m_EnvVars->GetGridCursorRow();
if( !m_EnvVars->HasFocus() || curRow < 0 )
@ -360,14 +369,16 @@ void DIALOG_CONFIGURE_PATHS::OnRemoveEnvVar( wxCommandEvent& event )
m_EnvVars->DeleteRows( curRow, 1 );
curRow = std::max( 0, curRow - 1 );
m_EnvVars->MakeCellVisible( curRow, m_EnvVars->GetGridCursorCol() );
m_EnvVars->SetGridCursor( curRow, m_EnvVars->GetGridCursorCol() );
m_EnvVars->MakeCellVisible( std::max( 0, curRow-1 ), m_EnvVars->GetGridCursorCol() );
m_EnvVars->SetGridCursor( std::max( 0, curRow-1 ), m_EnvVars->GetGridCursorCol() );
}
void DIALOG_CONFIGURE_PATHS::OnDeleteSearchPath( wxCommandEvent& event )
{
if( !m_SearchPaths->CommitPendingChanges() )
return;
int curRow = m_SearchPaths->GetGridCursorRow();
if( !m_SearchPaths->HasFocus() || curRow < 0 )
@ -378,19 +389,19 @@ void DIALOG_CONFIGURE_PATHS::OnDeleteSearchPath( wxCommandEvent& event )
m_SearchPaths->DeleteRows( curRow, 1 );
curRow = std::max( 0, curRow - 1 );
m_SearchPaths->MakeCellVisible( curRow, m_SearchPaths->GetGridCursorCol() );
m_SearchPaths->SetGridCursor( curRow, m_SearchPaths->GetGridCursorCol() );
m_SearchPaths->MakeCellVisible( std::max( 0, curRow-1 ), m_SearchPaths->GetGridCursorCol() );
m_SearchPaths->SetGridCursor( std::max( 0, curRow-1 ), m_SearchPaths->GetGridCursorCol() );
}
void DIALOG_CONFIGURE_PATHS::OnSearchPathMoveUp( wxCommandEvent& event )
{
if( !m_SearchPaths->CommitPendingChanges() )
return;
int curRow = m_SearchPaths->GetGridCursorRow();
int prevRow = curRow - 1;
m_SearchPaths->DisableCellEditControl();
if( curRow > 0 )
{
for( int i = 0; i < m_SearchPaths->GetNumberCols(); ++i )
@ -407,11 +418,12 @@ void DIALOG_CONFIGURE_PATHS::OnSearchPathMoveUp( wxCommandEvent& event )
void DIALOG_CONFIGURE_PATHS::OnSearchPathMoveDown( wxCommandEvent& event )
{
if( !m_SearchPaths->CommitPendingChanges() )
return;
int curRow = m_SearchPaths->GetGridCursorRow();
int nextRow = curRow + 1;
m_SearchPaths->DisableCellEditControl();
if( curRow < m_SearchPaths->GetNumberRows() - 1 )
{
for( int i = 0; i < m_SearchPaths->GetNumberCols(); ++i )

View File

@ -1,10 +1,12 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 2 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/wx_grid.h"
#include "dialog_configure_paths_base.h"
///////////////////////////////////////////////////////////////////////////
@ -19,7 +21,7 @@ DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_BASE( wxWindow* parent, wxWi
wxStaticBoxSizer* sbEnvVars;
sbEnvVars = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Environment Variables") ), wxVERTICAL );
m_EnvVars = new wxGrid( sbEnvVars->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_EnvVars = new WX_GRID( sbEnvVars->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_EnvVars->CreateGrid( 1, 2 );
@ -54,7 +56,7 @@ DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_BASE( wxWindow* parent, wxWi
wxBoxSizer* bSizerEnvVarBtns;
bSizerEnvVarBtns = new wxBoxSizer( wxHORIZONTAL );
m_btnAddEnvVar = new wxBitmapButton( sbEnvVars->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnAddEnvVar = new wxBitmapButton( sbEnvVars->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
m_btnAddEnvVar->SetMinSize( wxSize( 30,29 ) );
bSizerEnvVarBtns->Add( m_btnAddEnvVar, 0, wxRIGHT, 5 );
@ -62,7 +64,7 @@ DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_BASE( wxWindow* parent, wxWi
bSizerEnvVarBtns->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_btnDeleteEnvVar = new wxBitmapButton( sbEnvVars->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnDeleteEnvVar = new wxBitmapButton( sbEnvVars->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
m_btnDeleteEnvVar->SetMinSize( wxSize( 30,29 ) );
bSizerEnvVarBtns->Add( m_btnDeleteEnvVar, 0, wxRIGHT|wxLEFT, 5 );
@ -75,7 +77,7 @@ DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_BASE( wxWindow* parent, wxWi
m_sb3DSearchPaths = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("3D Search Paths") ), wxVERTICAL );
m_SearchPaths = new wxGrid( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_SearchPaths = new WX_GRID( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_SearchPaths->CreateGrid( 1, 3 );
@ -113,17 +115,17 @@ DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_BASE( wxWindow* parent, wxWi
wxBoxSizer* bSizerSearchPathBtns;
bSizerSearchPathBtns = new wxBoxSizer( wxHORIZONTAL );
m_btnAddSearchPath = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnAddSearchPath = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
m_btnAddSearchPath->SetMinSize( wxSize( 30,29 ) );
bSizerSearchPathBtns->Add( m_btnAddSearchPath, 0, wxRIGHT, 5 );
m_btnMoveUp = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnMoveUp = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
m_btnMoveUp->SetMinSize( wxSize( 30,29 ) );
bSizerSearchPathBtns->Add( m_btnMoveUp, 0, wxRIGHT, 5 );
m_btnMoveDown = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnMoveDown = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
m_btnMoveDown->SetMinSize( wxSize( 30,29 ) );
bSizerSearchPathBtns->Add( m_btnMoveDown, 0, wxRIGHT, 5 );
@ -131,7 +133,7 @@ DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_BASE( wxWindow* parent, wxWi
bSizerSearchPathBtns->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_btnDeleteSearchPath = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnDeleteSearchPath = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
m_btnDeleteSearchPath->SetMinSize( wxSize( 30,29 ) );
bSizerSearchPathBtns->Add( m_btnDeleteSearchPath, 0, wxRIGHT|wxLEFT, 5 );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 2 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -11,6 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class WX_GRID;
#include "dialog_shim.h"
#include <wx/colour.h>
#include <wx/settings.h>
@ -18,10 +20,10 @@
#include <wx/font.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/bmpbuttn.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
@ -38,11 +40,11 @@ class DIALOG_CONFIGURE_PATHS_BASE : public DIALOG_SHIM
private:
protected:
wxGrid* m_EnvVars;
WX_GRID* m_EnvVars;
wxBitmapButton* m_btnAddEnvVar;
wxBitmapButton* m_btnDeleteEnvVar;
wxStaticBoxSizer* m_sb3DSearchPaths;
wxGrid* m_SearchPaths;
WX_GRID* m_SearchPaths;
wxBitmapButton* m_btnAddSearchPath;
wxBitmapButton* m_btnMoveUp;
wxBitmapButton* m_btnMoveDown;

View File

@ -29,7 +29,21 @@
#define MIN_GRIDCELL_MARGIN 3
void WX_GRID::SetTable( wxGridTableBase* aTable )
WX_GRID::WX_GRID( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) :
wxGrid( parent, id, pos, size, style, name ),
m_weOwnTable( false )
{}
WX_GRID::~WX_GRID()
{
if( m_weOwnTable )
DestroyTable( GetTable() );
}
void WX_GRID::SetTable( wxGridTableBase* aTable, bool aTakeOwnership )
{
// wxGrid::SetTable() messes up the column widths from wxFormBuilder so we have to save
// and restore them.
@ -49,6 +63,8 @@ void WX_GRID::SetTable( wxGridTableBase* aTable )
}
delete[] formBuilderColWidths;
m_weOwnTable = aTakeOwnership;
}
@ -56,7 +72,7 @@ void WX_GRID::DestroyTable( wxGridTableBase* aTable )
{
// wxGrid's destructor will crash trying to look up the cell attr if the edit control
// is left open. Normally it's closed in Validate(), but not if the user hit Cancel.
DisableCellEditControl();
CommitPendingChanges( true /* quiet mode */ );
wxGrid::SetTable( nullptr );
delete aTable;

View File

@ -33,9 +33,9 @@ public:
// Constructor has to be wxFormBuilder-compatible
WX_GRID( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxWANTS_CHARS, const wxString& name = wxGridNameStr ) :
wxGrid( parent, id, pos, size, style, name )
{}
long style = wxWANTS_CHARS, const wxString& name = wxGridNameStr );
~WX_GRID() override;
/**
* Get a tokenized string containing the shown column indexes.
@ -52,7 +52,7 @@ public:
* Hide wxGrid's SetTable() method with one which doesn't mess up the grid column
* widths when setting the table.
*/
void SetTable( wxGridTableBase* table );
void SetTable( wxGridTableBase* table, bool aTakeOwnership = false );
/**
* Work-around for a bug in wxGrid which crashes when deleting the table if the
@ -69,6 +69,8 @@ public:
protected:
void DrawColLabel( wxDC& dc, int col ) override;
bool m_weOwnTable;
};
#endif //KICAD_WX_GRID_H

View File

@ -25,6 +25,7 @@
#include <wx/msgdlg.h>
#include <wx/grid.h>
#include <widgets/wx_grid.h>
#include <base_units.h>
#include <confirm.h>
#include <bitmaps.h>
@ -423,7 +424,7 @@ public:
{
// Commit any pending in-place edits before the row gets moved out from under
// the editor.
GetView()->DisableCellEditControl();
dynamic_cast<WX_GRID*>( GetView() )->CommitPendingChanges( true );
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, m_rows.size() );
GetView()->ProcessTableMessage( msg );
@ -722,8 +723,8 @@ DIALOG_FIELDS_EDITOR_GLOBAL::~DIALOG_FIELDS_EDITOR_GLOBAL()
bool DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataFromWindow()
{
// Commit any pending in-place edits and close the editor
m_grid->DisableCellEditControl();
if( !m_grid->CommitPendingChanges() )
return false;
if( !wxDialog::TransferDataFromWindow() )
return false;
@ -974,8 +975,8 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnCancel( wxCommandEvent& event )
void DIALOG_FIELDS_EDITOR_GLOBAL::OnClose( wxCloseEvent& event )
{
// Commit any pending in-place edits and close the editor
m_grid->DisableCellEditControl();
// This is a cancel, so commit quietly as we're going to throw the results away anyway.
m_grid->CommitPendingChanges( true );
if( m_dataModel->IsEdited() )
{

View File

@ -1,10 +1,12 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 2 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/wx_grid.h"
#include "dialog_fields_editor_global_base.h"
///////////////////////////////////////////////////////////////////////////
@ -59,7 +61,7 @@ DIALOG_FIELDS_EDITOR_GLOBAL_BASE::DIALOG_FIELDS_EDITOR_GLOBAL_BASE( wxWindow* pa
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );
m_grid = new wxGrid( m_panel4, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_grid = new WX_GRID( m_panel4, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_grid->CreateGrid( 5, 5 );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 2 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -11,6 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class WX_GRID;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/checkbox.h>
@ -18,10 +20,10 @@
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/bmpbuttn.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/dataview.h>
@ -49,7 +51,7 @@ class DIALOG_FIELDS_EDITOR_GLOBAL_BASE : public DIALOG_SHIM
wxDataViewListCtrl* m_fieldsCtrl;
wxButton* m_addFieldButton;
wxPanel* m_panel4;
wxGrid* m_grid;
WX_GRID* m_grid;
wxButton* m_button1;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;

View File

@ -246,7 +246,7 @@ public:
{
// Commit any pending in-place edits before the row gets moved out from under
// the editor.
GetView()->DisableCellEditControl();
dynamic_cast<WX_GRID*>( GetView() )->CommitPendingChanges( true );
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, m_rows.size() );
GetView()->ProcessTableMessage( msg );
@ -448,8 +448,8 @@ bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataToWindow()
bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataFromWindow()
{
// Commit any pending in-place edits and close the editor
m_grid->DisableCellEditControl();
if( !m_grid->CommitPendingChanges() )
return false;
// Delete the part's pins
while( LIB_PIN* pin = m_part->GetNextPin( nullptr ) )
@ -488,6 +488,9 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnColSort( wxGridEvent& aEvent )
void DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow( wxCommandEvent& event )
{
if( !m_grid->CommitPendingChanges() )
return;
m_pins.push_back( new LIB_PIN( nullptr ) );
m_dataModel->AppendRow( m_pins[ m_pins.size() - 1 ] );
@ -504,6 +507,9 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow( wxCommandEvent& event )
void DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow( wxCommandEvent& event )
{
if( !m_grid->CommitPendingChanges() )
return;
int curRow = m_grid->GetGridCursorRow();
if( curRow < 0 )
@ -530,6 +536,9 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnCellEdited( wxGridEvent& event )
void DIALOG_LIB_EDIT_PIN_TABLE::OnRebuildRows( wxCommandEvent& )
{
if( !m_grid->CommitPendingChanges() )
return;
m_dataModel->RebuildRows( m_pins, m_cbGroup->GetValue() );
adjustGridColumns( m_grid->GetRect().GetWidth() );

View File

@ -62,6 +62,9 @@ bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataToWindow()
void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnAddButtonClick( wxCommandEvent& event )
{
if( !m_grid->CommitPendingChanges() )
return;
int row = m_grid->GetNumberRows();
TransferDataFromGrid();
@ -78,6 +81,9 @@ void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnAddButtonClick( wxCommandEvent& event
void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnDeleteButtonClick( wxCommandEvent& event )
{
if( !m_grid->CommitPendingChanges() )
return;
int curRow = m_grid->GetGridCursorRow();
if( curRow >= 0 )
@ -86,9 +92,8 @@ void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnDeleteButtonClick( wxCommandEvent& ev
m_grid->DeleteRows( curRow );
}
curRow = std::max( 0, curRow - 1 );
m_grid->MakeCellVisible( curRow, m_grid->GetGridCursorCol() );
m_grid->SetGridCursor( curRow, m_grid->GetGridCursorCol() );
m_grid->MakeCellVisible( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() );
m_grid->SetGridCursor( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() );
}
@ -128,8 +133,8 @@ bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataToGrid()
bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromGrid()
{
// Commit any pending edits
m_grid->DisableCellEditControl();
if( !m_grid->CommitPendingChanges() )
return false;
for( int row = 0; row < m_grid->GetNumberRows(); ++row )
{

View File

@ -28,6 +28,7 @@
#include <symbol_lib_table.h>
#include <lib_table_lexer.h>
#include <grid_tricks.h>
#include <widgets/wx_grid.h>
#include <confirm.h>
#include <bitmaps.h>
#include <lib_table_grid.h>
@ -417,6 +418,9 @@ void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
void PANEL_SYM_LIB_TABLE::appendRowHandler( wxCommandEvent& event )
{
if( !m_cur_grid->CommitPendingChanges() )
return;
if( m_cur_grid->AppendRows( 1 ) )
{
int row = m_cur_grid->GetNumberRows() - 1;
@ -435,6 +439,9 @@ void PANEL_SYM_LIB_TABLE::appendRowHandler( wxCommandEvent& event )
void PANEL_SYM_LIB_TABLE::deleteRowHandler( wxCommandEvent& event )
{
if( !m_cur_grid->CommitPendingChanges() )
return;
int curRow = m_cur_grid->GetGridCursorRow();
int curCol = m_cur_grid->GetGridCursorCol();
@ -485,6 +492,9 @@ void PANEL_SYM_LIB_TABLE::deleteRowHandler( wxCommandEvent& event )
void PANEL_SYM_LIB_TABLE::moveUpHandler( wxCommandEvent& event )
{
if( !m_cur_grid->CommitPendingChanges() )
return;
SYMBOL_LIB_TABLE_GRID* tbl = cur_model();
int curRow = m_cur_grid->GetGridCursorRow();
@ -512,6 +522,9 @@ void PANEL_SYM_LIB_TABLE::moveUpHandler( wxCommandEvent& event )
void PANEL_SYM_LIB_TABLE::moveDownHandler( wxCommandEvent& event )
{
if( !m_cur_grid->CommitPendingChanges() )
return;
SYMBOL_LIB_TABLE_GRID* tbl = cur_model();
int curRow = m_cur_grid->GetGridCursorRow();
@ -539,8 +552,8 @@ void PANEL_SYM_LIB_TABLE::moveDownHandler( wxCommandEvent& event )
bool PANEL_SYM_LIB_TABLE::TransferDataFromWindow()
{
// Commit any pending in-place edits and close the editor
m_cur_grid->DisableCellEditControl();
if( !m_cur_grid->CommitPendingChanges() )
return false;
if( !verifyTables() )
return false;

View File

@ -77,7 +77,7 @@ private:
DIALOG_EDIT_LIBRARY_TABLES* m_parent;
wxGrid* m_cur_grid; ///< changed based on tab choice
WX_GRID* m_cur_grid; ///< changed based on tab choice
static size_t m_pageNdx; ///< Remember the last notebook page selected during a session
wxString m_lastBrowseDir; ///< last browsed directory
};

View File

@ -5,6 +5,8 @@
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/wx_grid.h"
#include "panel_sym_lib_table_base.h"
///////////////////////////////////////////////////////////////////////////
@ -40,7 +42,7 @@ PANEL_SYM_LIB_TABLE_BASE::PANEL_SYM_LIB_TABLE_BASE( wxWindow* parent, wxWindowID
m_global_sizer->Add( fgSizer1, 0, wxEXPAND, 2 );
m_global_grid = new wxGrid( m_global_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_global_grid = new WX_GRID( m_global_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_global_grid->CreateGrid( 1, 5 );
@ -93,7 +95,7 @@ PANEL_SYM_LIB_TABLE_BASE::PANEL_SYM_LIB_TABLE_BASE( wxWindow* parent, wxWindowID
m_project_sizer->Add( fgSizer2, 0, wxEXPAND, 5 );
m_project_grid = new wxGrid( m_project_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_project_grid = new WX_GRID( m_project_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_project_grid->CreateGrid( 1, 5 );
@ -158,7 +160,7 @@ PANEL_SYM_LIB_TABLE_BASE::PANEL_SYM_LIB_TABLE_BASE( wxWindow* parent, wxWindowID
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Path Substitutions:") ), wxVERTICAL );
m_path_subs_grid = new wxGrid( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_path_subs_grid = new WX_GRID( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_path_subs_grid->CreateGrid( 1, 2 );

View File

@ -533,7 +533,7 @@
<property name="rows">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
@ -946,7 +946,7 @@
<property name="rows">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
@ -1595,7 +1595,7 @@
<property name="rows">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">This is a read-only table which shows pertinent environment variables.</property>
<property name="window_extra_style"></property>

View File

@ -11,6 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class WX_GRID;
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
@ -43,17 +45,17 @@ class PANEL_SYM_LIB_TABLE_BASE : public wxPanel
wxPanel* m_global_panel;
wxStaticText* m_staticText3;
wxStaticText* m_GblTableFilename;
wxGrid* m_global_grid;
WX_GRID* m_global_grid;
wxPanel* m_project_panel;
wxStaticText* m_staticText4;
wxStaticText* m_PrjTableFilename;
wxGrid* m_project_grid;
WX_GRID* m_project_grid;
wxBitmapButton* m_append_button;
wxBitmapButton* m_browse_button;
wxBitmapButton* m_move_up_button;
wxBitmapButton* m_move_down_button;
wxBitmapButton* m_delete_button;
wxGrid* m_path_subs_grid;
WX_GRID* m_path_subs_grid;
// Virtual event handlers, overide them in your derived class
virtual void pageChangedHandler( wxAuiNotebookEvent& event ) { event.Skip(); }

View File

@ -357,6 +357,9 @@ void DIALOG_FOOTPRINT_FP_EDITOR::On3DModelCellChanged( wxGridEvent& aEvent )
void DIALOG_FOOTPRINT_FP_EDITOR::OnRemove3DModel( wxCommandEvent& )
{
if( !m_modelsGrid->CommitPendingChanges() )
return;
int idx = m_modelsGrid->GetGridCursorRow();
if( idx >= 0 )
@ -364,7 +367,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnRemove3DModel( wxCommandEvent& )
m_shapes3D_list.erase( m_shapes3D_list.begin() + idx );
m_modelsGrid->DeleteRows( idx );
select3DModel( idx ); // will clamp idx within bounds
select3DModel( idx-1 ); // will clamp idx within bounds
m_PreviewPane->UpdateDummyModule();
}
}
@ -372,6 +375,9 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnRemove3DModel( wxCommandEvent& )
void DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel( wxCommandEvent& )
{
if( !m_modelsGrid->CommitPendingChanges() )
return;
PROJECT& prj = Prj();
MODULE_3D_SETTINGS model;
@ -432,6 +438,9 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel( wxCommandEvent& )
void DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DRow( wxCommandEvent& )
{
if( !m_modelsGrid->CommitPendingChanges() )
return;
MODULE_3D_SETTINGS model;
model.m_Preview = true;
@ -452,8 +461,8 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DRow( wxCommandEvent& )
bool DIALOG_FOOTPRINT_FP_EDITOR::Validate()
{
// Commit any pending in-place edits and close the editor
m_itemsGrid->DisableCellEditControl();
if( !m_itemsGrid->CommitPendingChanges() )
return false;
if( !DIALOG_SHIM::Validate() )
return false;
@ -600,6 +609,9 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::TransferDataFromWindow()
void DIALOG_FOOTPRINT_FP_EDITOR::OnAddField( wxCommandEvent& event )
{
if( !m_itemsGrid->CommitPendingChanges() )
return;
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
TEXTE_MODULE textMod( m_footprint );
@ -630,29 +642,29 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnAddField( wxCommandEvent& event )
void DIALOG_FOOTPRINT_FP_EDITOR::OnDeleteField( wxCommandEvent& event )
{
int rowCount = m_itemsGrid->GetNumberRows();
int curRow = m_itemsGrid->GetGridCursorRow();
if( curRow < 0 || curRow >= (int) m_texts->size() )
if( !m_itemsGrid->CommitPendingChanges() )
return;
if( curRow < 2 )
int curRow = m_itemsGrid->GetGridCursorRow();
if( curRow < 0 )
return;
else if( curRow < 2 )
{
DisplayError( nullptr, _( "Reference and value are mandatory." ) );
return;
}
auto start = m_texts->begin() + curRow;
m_texts->erase( start, start + 1 );
m_texts->erase( m_texts->begin() + curRow );
// notify the grid
wxGridTableMessage msg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 );
m_itemsGrid->ProcessTableMessage( msg );
if( curRow == rowCount - 1 )
if( m_itemsGrid->GetNumberRows() > 0 )
{
m_itemsGrid->MakeCellVisible( curRow-1, m_itemsGrid->GetGridCursorCol() );
m_itemsGrid->SetGridCursor( curRow-1, m_itemsGrid->GetGridCursorCol() );
m_itemsGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_itemsGrid->GetGridCursorCol() );
m_itemsGrid->SetGridCursor( std::max( 0, curRow-1 ), m_itemsGrid->GetGridCursorCol() );
}
}

View File

@ -313,7 +313,7 @@ DIALOG_FOOTPRINT_FP_EDITOR_BASE::DIALOG_FOOTPRINT_FP_EDITOR_BASE( wxWindow* pare
wxStaticBoxSizer* sbSizer3;
sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( m_Panel3D, wxID_ANY, wxEmptyString ), wxVERTICAL );
m_modelsGrid = new wxGrid( sbSizer3->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER );
m_modelsGrid = new WX_GRID( sbSizer3->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER );
// Grid
m_modelsGrid->CreateGrid( 3, 2 );

View File

@ -3627,7 +3627,7 @@
<property name="rows">3</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass">; forward_declare</property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>

View File

@ -89,7 +89,7 @@ class DIALOG_FOOTPRINT_FP_EDITOR_BASE : public DIALOG_SHIM
wxChoice* m_ZoneConnectionChoice;
wxPanel* m_Panel3D;
wxBoxSizer* bSizerMain3D;
wxGrid* m_modelsGrid;
WX_GRID* m_modelsGrid;
wxBitmapButton* m_button3DShapeAdd;
wxBitmapButton* m_button3DShapeBrowse;
wxBitmapButton* m_button3DShapeRemove;

View File

@ -29,6 +29,7 @@
#include <dialog_fp_plugin_options_base.h>
#include <fp_lib_table.h>
#include <grid_tricks.h>
#include <widgets/wx_grid.h>
#include <bitmaps.h>
@ -129,8 +130,8 @@ public:
bool TransferDataFromWindow() override
{
// Write any active editors into the grid
m_grid->DisableCellEditControl();
if( !m_grid->CommitPendingChanges() )
return false;
if( !DIALOG_SHIM::TransferDataFromWindow() )
return false;
@ -223,16 +224,25 @@ private:
void onAppendOption( wxCommandEvent& ) override
{
if( !m_grid->CommitPendingChanges() )
return;
appendOption();
}
void onAppendRow( wxCommandEvent& ) override
{
if( !m_grid->CommitPendingChanges() )
return;
appendRow();
}
void onDeleteRow( wxCommandEvent& ) override
{
if( !m_grid->CommitPendingChanges() )
return;
if( !m_grid->HasFocus() )
{
m_grid->SetFocus();

View File

@ -5,6 +5,8 @@
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/wx_grid.h"
#include "dialog_fp_plugin_options_base.h"
///////////////////////////////////////////////////////////////////////////
@ -23,7 +25,7 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent,
m_grid_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Plugin Options") ), wxVERTICAL );
m_grid_sizer->SetMinSize( wxSize( 400,300 ) );
m_grid = new wxGrid( m_grid_sizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxVSCROLL );
m_grid = new WX_GRID( m_grid_sizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxVSCROLL );
// Grid
m_grid->CreateGrid( 1, 2 );

View File

@ -195,7 +195,7 @@
<property name="rows">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>

View File

@ -11,6 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class WX_GRID;
#include "dialog_shim.h"
#include <wx/colour.h>
#include <wx/settings.h>
@ -40,7 +42,7 @@ class DIALOG_FP_PLUGIN_OPTIONS_BASE : public DIALOG_SHIM
private:
protected:
wxGrid* m_grid;
WX_GRID* m_grid;
wxBitmapButton* m_append_button;
wxBitmapButton* m_delete_button;
wxListBox* m_listbox;

View File

@ -37,7 +37,7 @@
#include <macros.h>
#include <pcb_base_frame.h>
#include <base_units.h>
#include <widgets/wx_grid.h>
#include <class_board.h>
#include <class_module.h>
@ -264,8 +264,8 @@ bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::Validate()
// test for a valid polygon (a not self intersectiong polygon)
bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate( bool aRemoveRedundantCorners )
{
// Commit any pending edits
m_gridCornersList->DisableCellEditControl();
if( !m_gridCornersList->CommitPendingChanges() )
return false;
if( m_currshape.m_Poly.size() < 3 )
{
@ -324,8 +324,8 @@ bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate( bool aRemoveRedundantCorners )
void DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonAdd( wxCommandEvent& event )
{
// Commit any pending edits
m_gridCornersList->DisableCellEditControl();
if( !m_gridCornersList->CommitPendingChanges() )
return;
// Insert a new corner after the currently selected:
wxArrayInt selections = m_gridCornersList->GetSelectedRows();
@ -361,8 +361,8 @@ void DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonAdd( wxCommandEvent& event )
void DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonDelete( wxCommandEvent& event )
{
// Commit any pending edits
m_gridCornersList->DisableCellEditControl();
if( !m_gridCornersList->CommitPendingChanges() )
return;
wxArrayInt selections = m_gridCornersList->GetSelectedRows();

View File

@ -1,11 +1,12 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 11 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/text_ctrl_eval.h"
#include "widgets/wx_grid.h"
#include "dialog_pad_properties_base.h"
@ -1079,7 +1080,7 @@ DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE::DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE( wxWi
wxBoxSizer* bLeftSizer;
bLeftSizer = new wxBoxSizer( wxVERTICAL );
m_gridCornersList = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE );
m_gridCornersList = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE );
// Grid
m_gridCornersList->CreateGrid( 1, 2 );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 11 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -12,6 +12,7 @@
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class TEXT_CTRL_EVAL;
class WX_GRID;
#include "dialog_shim.h"
#include <wx/string.h>
@ -298,7 +299,7 @@ class DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE : public DIALOG_SHIM
private:
protected:
wxGrid* m_gridCornersList;
WX_GRID* m_gridCornersList;
wxBitmapButton* m_addButton;
wxBitmapButton* m_deleteButton;
wxStaticText* m_thicknessLabel;

View File

@ -144,8 +144,8 @@ bool DIALOG_SWAP_LAYERS::TransferDataToWindow()
bool DIALOG_SWAP_LAYERS::TransferDataFromWindow()
{
// Commit any pending changes
m_grid->DisableCellEditControl();
if( !m_grid->CommitPendingChanges() )
return false;
LSET enabledCopperLayers = LSET::AllCuMask( m_parent->GetBoard()->GetCopperLayerCount() );
wxGridTableBase* table = m_grid->GetTable();

View File

@ -45,6 +45,7 @@
#include <invoke_pcb_dialog.h>
#include <bitmaps.h>
#include <grid_tricks.h>
#include <widgets/wx_grid.h>
#include <confirm.h>
#include <lib_table_grid.h>
#include <wildcards_and_files_ext.h>
@ -461,6 +462,9 @@ void PANEL_FP_LIB_TABLE::pageChangedHandler( wxAuiNotebookEvent& event )
void PANEL_FP_LIB_TABLE::appendRowHandler( wxCommandEvent& event )
{
if( !m_cur_grid->CommitPendingChanges() )
return;
if( m_cur_grid->AppendRows( 1 ) )
{
int last_row = m_cur_grid->GetNumberRows() - 1;
@ -476,6 +480,9 @@ void PANEL_FP_LIB_TABLE::appendRowHandler( wxCommandEvent& event )
void PANEL_FP_LIB_TABLE::deleteRowHandler( wxCommandEvent& event )
{
if( !m_cur_grid->CommitPendingChanges() )
return;
int curRow = m_cur_grid->GetGridCursorRow();
int curCol = m_cur_grid->GetGridCursorCol();
@ -525,6 +532,9 @@ void PANEL_FP_LIB_TABLE::deleteRowHandler( wxCommandEvent& event )
void PANEL_FP_LIB_TABLE::moveUpHandler( wxCommandEvent& event )
{
if( !m_cur_grid->CommitPendingChanges() )
return;
FP_LIB_TABLE_GRID* tbl = cur_model();
int curRow = m_cur_grid->GetGridCursorRow();
@ -552,6 +562,9 @@ void PANEL_FP_LIB_TABLE::moveUpHandler( wxCommandEvent& event )
void PANEL_FP_LIB_TABLE::moveDownHandler( wxCommandEvent& event )
{
if( !m_cur_grid->CommitPendingChanges() )
return;
FP_LIB_TABLE_GRID* tbl = cur_model();
int curRow = m_cur_grid->GetGridCursorRow();
@ -579,6 +592,9 @@ void PANEL_FP_LIB_TABLE::moveDownHandler( wxCommandEvent& event )
void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
{
if( !m_cur_grid->CommitPendingChanges() )
return;
if( m_lastBrowseDir.IsEmpty() )
m_lastBrowseDir = m_projectBasePath;
@ -669,8 +685,8 @@ void PANEL_FP_LIB_TABLE::onSizeGrid( wxSizeEvent& event )
bool PANEL_FP_LIB_TABLE::TransferDataFromWindow()
{
// stuff any pending cell editor text into the table.
m_cur_grid->DisableCellEditControl();
if( !m_cur_grid->CommitPendingChanges() )
return false;
if( verifyTables() )
{

View File

@ -22,6 +22,7 @@
#include <dialog_edit_library_tables.h>
#include <panel_fp_lib_table_base.h>
#include <widgets/wx_grid.h>
class FP_LIB_TABLE;
class FP_LIB_TABLE_GRID;
@ -86,7 +87,7 @@ private:
DIALOG_EDIT_LIBRARY_TABLES* m_parent;
wxGrid* m_cur_grid; // changed based on tab choice
WX_GRID* m_cur_grid; // changed based on tab choice
static size_t m_pageNdx; // Remember last notebook page selected during a session
static wxString m_lastBrowseDir; // Remember last directory browsed during a session
};

View File

@ -5,6 +5,8 @@
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/wx_grid.h"
#include "panel_fp_lib_table_base.h"
///////////////////////////////////////////////////////////////////////////
@ -40,7 +42,7 @@ PANEL_FP_LIB_TABLE_BASE::PANEL_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID i
m_global_sizer->Add( fgSizer1, 0, wxEXPAND, 5 );
m_global_grid = new wxGrid( m_global_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_global_grid = new WX_GRID( m_global_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_global_grid->CreateGrid( 1, 5 );
@ -92,7 +94,7 @@ PANEL_FP_LIB_TABLE_BASE::PANEL_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID i
m_project_sizer->Add( fgSizer2, 0, wxEXPAND, 5 );
m_project_grid = new wxGrid( m_project_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_project_grid = new WX_GRID( m_project_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_project_grid->CreateGrid( 1, 5 );
@ -157,7 +159,7 @@ PANEL_FP_LIB_TABLE_BASE::PANEL_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID i
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Path Substitutions:") ), wxVERTICAL );
m_path_subs_grid = new wxGrid( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_path_subs_grid = new WX_GRID( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_path_subs_grid->CreateGrid( 1, 2 );

View File

@ -533,7 +533,7 @@
<property name="rows">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
@ -946,7 +946,7 @@
<property name="rows">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
@ -1595,7 +1595,7 @@
<property name="rows">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">This is a read-only table which shows pertinent environment variables.</property>
<property name="window_extra_style"></property>

View File

@ -11,6 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class WX_GRID;
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
@ -43,17 +45,17 @@ class PANEL_FP_LIB_TABLE_BASE : public wxPanel
wxPanel* m_global_panel;
wxStaticText* m_staticText3;
wxStaticText* m_GblTableFilename;
wxGrid* m_global_grid;
WX_GRID* m_global_grid;
wxPanel* m_project_panel;
wxStaticText* m_staticText4;
wxStaticText* m_PrjTableFilename;
wxGrid* m_project_grid;
WX_GRID* m_project_grid;
wxBitmapButton* m_append_button;
wxBitmapButton* m_browse_button;
wxBitmapButton* m_move_up_button;
wxBitmapButton* m_move_down_button;
wxBitmapButton* m_delete_button;
wxGrid* m_path_subs_grid;
WX_GRID* m_path_subs_grid;
// Virtual event handlers, overide them in your derived class
virtual void pageChangedHandler( wxAuiNotebookEvent& event ) { event.Skip(); }

View File

@ -137,8 +137,8 @@ int PANEL_MODEDIT_DEFAULTS::getGridValue( int aRow, int aCol )
bool PANEL_MODEDIT_DEFAULTS::validateData()
{
// Commit any pending in-place edits and close editors from grid
m_grid->DisableCellEditControl();
if( !m_grid->CommitPendingChanges() )
return false;
// Test text parameters.
for( int row : { ROW_SILK, ROW_COPPER, ROW_OTHERS } )

View File

@ -300,6 +300,9 @@ void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging( wxGridEvent& event )
void PANEL_SETUP_NETCLASSES::OnAddNetclassClick( wxCommandEvent& event )
{
if( !m_netclassGrid->CommitPendingChanges() )
return;
int row = m_netclassGrid->GetNumberRows();
m_netclassGrid->AppendRows();
@ -319,7 +322,8 @@ void PANEL_SETUP_NETCLASSES::OnAddNetclassClick( wxCommandEvent& event )
void PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick( wxCommandEvent& event )
{
m_netclassGrid->DisableCellEditControl();
if( !m_netclassGrid->CommitPendingChanges() )
return;
int curRow = m_netclassGrid->GetGridCursorRow();
@ -345,9 +349,8 @@ void PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick( wxCommandEvent& event )
m_netclassGrid->DeleteRows( curRow, 1 );
curRow = std::max( 0, curRow - 1 );
m_netclassGrid->MakeCellVisible( curRow, m_netclassGrid->GetGridCursorCol() );
m_netclassGrid->SetGridCursor( curRow, m_netclassGrid->GetGridCursorCol() );
m_netclassGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
m_netclassGrid->SetGridCursor( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
m_netclassesDirty = true;
}
@ -398,8 +401,8 @@ void PANEL_SETUP_NETCLASSES::OnSizeMembershipGrid( wxSizeEvent& event )
void PANEL_SETUP_NETCLASSES::doApplyFilters( bool aShowAll )
{
// Commit any pending in-place edits in the membership grid
m_membershipGrid->DisableCellEditControl();
if( !m_membershipGrid->CommitPendingChanges() )
return;
wxString netClassFilter = m_netClassFilter->GetStringSelection();
wxString netFilter = m_netNameFilter->GetValue().MakeLower();
@ -432,8 +435,8 @@ void PANEL_SETUP_NETCLASSES::doApplyFilters( bool aShowAll )
void PANEL_SETUP_NETCLASSES::doAssignments( bool aAssignAll )
{
// Commit any pending in-place edits in the membership grid
m_membershipGrid->DisableCellEditControl();
if( !m_membershipGrid->CommitPendingChanges() )
return;
wxArrayInt selectedRows = m_membershipGrid->GetSelectedRows();
@ -468,9 +471,8 @@ int PANEL_SETUP_NETCLASSES::getNetclassValue( int aRow, int aCol )
bool PANEL_SETUP_NETCLASSES::validateData()
{
// Commit any pending in-place edits and close editors from grid controls
m_netclassGrid->DisableCellEditControl();
m_membershipGrid->DisableCellEditControl();
if( !m_netclassGrid->CommitPendingChanges() || !m_membershipGrid->CommitPendingChanges() )
return false;
wxString msg;
int minViaDia = m_ConstraintsPanel->m_viaMinSize.GetValue();

View File

@ -136,8 +136,8 @@ int PANEL_SETUP_TEXT_AND_GRAPHICS::getGridValue( int aRow, int aCol )
bool PANEL_SETUP_TEXT_AND_GRAPHICS::validateData()
{
// Commit any pending in-place edits and close editors from grid
m_grid->DisableCellEditControl();
if( !m_grid->CommitPendingChanges() )
return false;
// Test text parameters.
for( int row : { ROW_SILK, ROW_COPPER, ROW_OTHERS } )
@ -185,6 +185,9 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow()
void PANEL_SETUP_TEXT_AND_GRAPHICS::ImportSettingsFrom( BOARD* aBoard )
{
if( !m_grid->CommitPendingChanges() )
return;
BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
m_BrdSettings = &aBoard->GetDesignSettings();

View File

@ -168,10 +168,10 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow()
bool PANEL_SETUP_TRACKS_AND_VIAS::validateData()
{
// Commit any pending in-place edits and close editors from grid controls
m_trackWidthsGrid->DisableCellEditControl();
m_viaSizesGrid->DisableCellEditControl();
m_diffPairsGrid->DisableCellEditControl();
if( !m_trackWidthsGrid->CommitPendingChanges()
|| !m_viaSizesGrid->CommitPendingChanges()
|| !m_diffPairsGrid->CommitPendingChanges() )
return false;
wxString msg;
int minViaDia = m_ConstraintsPanel->m_viaMinSize.GetValue();
@ -243,6 +243,10 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::validateData()
void PANEL_SETUP_TRACKS_AND_VIAS::ImportSettingsFrom( BOARD* aBoard )
{
m_trackWidthsGrid->CommitPendingChanges( true );
m_viaSizesGrid->CommitPendingChanges( true );
m_diffPairsGrid->CommitPendingChanges( true );
// Note: do not change the board, as we need to get the current nets from it for
// netclass memberships. All the netclass definitions and dimension lists are in
// the BOARD_DESIGN_SETTINGS.