diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 986ab281c8..550ec51b34 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -186,11 +186,12 @@ set( COMMON_WIDGET_SRCS widgets/mathplot.cpp widgets/paged_dialog.cpp widgets/progress_reporter.cpp + widgets/stepped_slider.cpp widgets/text_ctrl_eval.cpp widgets/two_column_tree_list.cpp widgets/unit_binder.cpp widgets/widget_hotkey_list.cpp - widgets/stepped_slider.cpp + widgets/wx_grid.cpp ) set( COMMON_PAGE_LAYOUT_SRCS diff --git a/common/grid_tricks.cpp b/common/grid_tricks.cpp index f14c933154..52fcd9a1f9 100644 --- a/common/grid_tricks.cpp +++ b/common/grid_tricks.cpp @@ -387,69 +387,3 @@ void GRID_TRICKS::cutcopy( bool doCut ) m_grid->ForceRefresh(); } } - - -// --------------- Static Helper Methods ---------------------------------------------- - - -void GRID_TRICKS::ShowHideGridColumns( wxGrid* aGrid, const wxString& shownColumns ) -{ - for( int i = 0; i < aGrid->GetNumberCols(); ++i ) - aGrid->HideCol( i ); - - wxStringTokenizer shownTokens( shownColumns ); - - while( shownTokens.HasMoreTokens() ) - { - long colNumber; - shownTokens.GetNextToken().ToLong( &colNumber ); - - if( colNumber >= 0 && colNumber < aGrid->GetNumberCols() ) - aGrid->ShowCol( colNumber ); - } -} - - -wxString GRID_TRICKS::GetShownColumns( wxGrid* aGrid ) -{ - wxString shownColumns; - - for( int i = 0; i < aGrid->GetNumberCols(); ++i ) - { - if( aGrid->IsColShown( i ) ) - { - if( shownColumns.Length() ) - shownColumns << wxT( " " ); - shownColumns << i; - } - } - - return shownColumns; -} - - -void GRID_TRICKS::SetGridTable( wxGrid* aGrid, wxGridTableBase* aTable ) -{ - // SetTable() messes up the column widths from wxFormBuilder so we have to save and - // restore them. - int formBuilderColWidths[ aGrid->GetNumberCols() ]; - - for( int i = 0; i < aGrid->GetNumberCols(); ++i ) - formBuilderColWidths[ i ] = aGrid->GetColSize( i ); - - aGrid->SetTable( aTable ); - - for( int i = 0; i < aGrid->GetNumberCols(); ++i ) - aGrid->SetColSize( i, formBuilderColWidths[ i ] ); -} - - -void GRID_TRICKS::DestroyGridTable( wxGrid* aGrid, 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. - aGrid->DisableCellEditControl(); - - aGrid->SetTable( nullptr ); - delete aTable; -} diff --git a/common/widgets/wx_grid.cpp b/common/widgets/wx_grid.cpp new file mode 100644 index 0000000000..bb02555295 --- /dev/null +++ b/common/widgets/wx_grid.cpp @@ -0,0 +1,118 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include "wx_grid.h" + + +void WX_GRID::SetTable( wxGridTableBase* aTable ) +{ + // wxGrid::SetTable() messes up the column widths from wxFormBuilder so we have to save + // and restore them. + int formBuilderColWidths[ GetNumberCols() ]; + + for( int i = 0; i < GetNumberCols(); ++i ) + formBuilderColWidths[ i ] = GetColSize( i ); + + wxGrid::SetTable( aTable ); + + for( int i = 0; i < GetNumberCols(); ++i ) + SetColSize( i, formBuilderColWidths[ i ] ); +} + + +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(); + + wxGrid::SetTable( nullptr ); + delete aTable; +} + + +wxString WX_GRID::GetShownColumns() +{ + wxString shownColumns; + + for( int i = 0; i < GetNumberCols(); ++i ) + { + if( IsColShown( i ) ) + { + if( shownColumns.Length() ) + shownColumns << wxT( " " ); + shownColumns << i; + } + } + + return shownColumns; +} + + +void WX_GRID::ShowHideColumns( const wxString& shownColumns ) +{ + for( int i = 0; i < GetNumberCols(); ++i ) + HideCol( i ); + + wxStringTokenizer shownTokens( shownColumns ); + + while( shownTokens.HasMoreTokens() ) + { + long colNumber; + shownTokens.GetNextToken().ToLong( &colNumber ); + + if( colNumber >= 0 && colNumber < GetNumberCols() ) + ShowCol( colNumber ); + } +} + + +// An re-implementation of wxGrid::DrawColLabel which left-aligns the first column. +void WX_GRID::DrawColLabel( wxDC& dc, int col ) +{ + if( GetColWidth( col ) <= 0 || m_colLabelHeight <= 0 ) + return; + + int colLeft = GetColLeft( col ); + + wxRect rect( colLeft, 0, GetColWidth( col ), m_colLabelHeight ); + static wxGridColumnHeaderRendererDefault rend; + + // It is reported that we need to erase the background to avoid display + // artefacts, see #12055. + wxDCBrushChanger setBrush( dc, m_colWindow->GetBackgroundColour() ); + dc.DrawRectangle(rect); + + rend.DrawBorder( *this, dc, rect ); + + int hAlign, vAlign; + GetColLabelAlignment( &hAlign, &vAlign ); + const int orient = GetColLabelTextOrientation(); + + if( col == 0 ) + hAlign = wxALIGN_LEFT; + + rend.DrawLabel( *this, dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient ); +} diff --git a/common/widgets/wx_grid.h b/common/widgets/wx_grid.h new file mode 100644 index 0000000000..7aecb46f9a --- /dev/null +++ b/common/widgets/wx_grid.h @@ -0,0 +1,67 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef KICAD_WX_GRID_H +#define KICAD_WX_GRID_H + +#include +#include + +class WX_GRID : public wxGrid +{ +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 ) + {} + + /** + * Get a tokenized string containing the shown column indexes. + * Tokens are separated by spaces. + */ + wxString GetShownColumns(); + + /** + * Show/hide the grid columns based on a tokenized string of shown column indexes. + */ + void ShowHideColumns( const wxString& shownColumns ); + + /** + * Hide wxGrid's SetTable() method with one which doesn't mess up the grid column + * widths when setting the table. + */ + void SetTable( wxGridTableBase* table ); + + /** + * Work-around for a bug in wxGrid which crashes when deleting the table if the + * cell edit control was not closed. + */ + void DestroyTable( wxGridTableBase* aTable ); + +protected: + void DrawColLabel( wxDC& dc, int col ) override; +}; + +#endif //KICAD_WX_GRID_H diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 7c11487e10..ef71bb0a59 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -23,8 +23,6 @@ #include -#include - #include #include #include @@ -32,7 +30,7 @@ #include #include #include - +#include #include #include #include @@ -162,14 +160,12 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT // Give a bit more room for combobox editors m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); - // wxGrid::SetTable() messes up the column widths; use GRID_TRICKS version instead - GRID_TRICKS::SetGridTable( m_grid, m_fields ); - + m_grid->SetTable( m_fields ); m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) ); // Show/hide columns according to user's preference m_config->Read( SymbolFieldsShownColumnsKey, &m_shownColumns, wxT( "0 1 2 3 4 5 6 7" ) ); - GRID_TRICKS::ShowHideGridColumns( m_grid, m_shownColumns ); + m_grid->ShowHideColumns( m_shownColumns ); wxToolTip::Enable( true ); m_stdDialogButtonSizerOK->SetDefault(); @@ -190,10 +186,10 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC() { - m_config->Write( SymbolFieldsShownColumnsKey, GRID_TRICKS::GetShownColumns( m_grid ) ); + m_config->Write( SymbolFieldsShownColumnsKey, m_grid->GetShownColumns() ); // Prevents crash bug in wxGrid's d'tor - GRID_TRICKS::DestroyGridTable( m_grid, m_fields ); + m_grid->DestroyTable( m_fields ); m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging ), NULL, this ); @@ -709,7 +705,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::AdjustGridColumns( int aWidth ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnUpdateUI( wxUpdateUIEvent& event ) { - wxString shownColumns = GRID_TRICKS::GetShownColumns( m_grid ); + wxString shownColumns = m_grid->GetShownColumns(); if( shownColumns != m_shownColumns ) { diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp index 14af3a557f..494c21d991 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp @@ -5,6 +5,8 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "widgets/wx_grid.h" + #include "dialog_edit_component_in_schematic_base.h" /////////////////////////////////////////////////////////////////////////// @@ -19,7 +21,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE wxStaticBoxSizer* sbFields; sbFields = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxVERTICAL ); - m_grid = new wxGrid( sbFields->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_grid = new WX_GRID( sbFields->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid m_grid->CreateGrid( 4, 11 ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp index ee21f405db..72d9605f1f 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp @@ -186,7 +186,7 @@ 4 1 - ; forward_declare + WX_GRID; widgets/wx_grid.h; forward_declare 0 diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.h b/eeschema/dialogs/dialog_edit_component_in_schematic_base.h index cb49dd98e8..e84c44e32b 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.h +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.h @@ -11,6 +11,8 @@ #include #include #include +class WX_GRID; + #include "dialog_shim.h" #include #include @@ -44,7 +46,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE : public DIALOG_SHIM private: protected: - wxGrid* m_grid; + WX_GRID* m_grid; wxBitmapButton* m_bpAdd; wxBitmapButton* m_bpDelete; wxBitmapButton* m_bpMoveUp; diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index a307b69d41..386463303e 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -134,9 +135,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( LIB_EDIT // Give a bit more room for combobox editors m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 2 ); - // wxGrid::SetTable() messes up the column widths; use GRID_TRICKS version instead - GRID_TRICKS::SetGridTable( m_grid, m_fields ); - + m_grid->SetTable( m_fields ); m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) ); stdDialogButtonSizerOK->SetDefault(); @@ -156,10 +155,10 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( LIB_EDIT DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB() { - m_config->Write( LibEditFieldsShownColumnsKey, GRID_TRICKS::GetShownColumns( m_grid ) ); + m_config->Write( LibEditFieldsShownColumnsKey, m_grid->GetShownColumns() ); // Prevents crash bug in wxGrid's d'tor - GRID_TRICKS::DestroyGridTable( m_grid, m_fields ); + m_grid->DestroyTable( m_fields ); m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnGridCellChanging ), NULL, this ); @@ -191,7 +190,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::TransferDataToWindow() // Show/hide columns according to the user's preference m_config->Read( LibEditFieldsShownColumnsKey, &m_shownColumns, wxT( "0 1 2 3 4 5 6 7" ) ); - GRID_TRICKS::ShowHideGridColumns( m_grid, m_shownColumns ); + m_grid->ShowHideColumns( m_shownColumns ); Layout(); @@ -453,7 +452,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::AdjustGridColumns( int aWidth ) void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnUpdateUI( wxUpdateUIEvent& event ) { - wxString shownColumns = GRID_TRICKS::GetShownColumns( m_grid ); + wxString shownColumns = m_grid->GetShownColumns(); if( shownColumns != m_shownColumns ) { diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp index 695c8f40fa..36b22a476c 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp @@ -5,6 +5,8 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "widgets/wx_grid.h" + #include "dialog_edit_libentry_fields_in_lib_base.h" /////////////////////////////////////////////////////////////////////////// @@ -19,7 +21,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE wxBoxSizer* bSizerFieldsSetup; bSizerFieldsSetup = new wxBoxSizer( wxVERTICAL ); - m_grid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid m_grid->CreateGrid( 4, 11 ); diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp index 678be80073..79a3a089f0 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp @@ -182,7 +182,7 @@ 4 1 - ; forward_declare + WX_GRID; widgets/wx_grid.h; forward_declare 0 diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h index d0c9680183..e1ddf8953c 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h @@ -11,6 +11,8 @@ #include #include #include +class WX_GRID; + #include "dialog_shim.h" #include #include @@ -38,7 +40,7 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public DIALOG_SHIM private: protected: - wxGrid* m_grid; + WX_GRID* m_grid; wxBitmapButton* m_bpAdd; wxBitmapButton* m_bpDelete; wxBitmapButton* m_bpMoveUp; diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index 6e44a2eb49..3cd4112def 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -26,7 +26,7 @@ #include "pin_number.h" #include "grid_tricks.h" #include - +#include #include #include #include @@ -360,14 +360,12 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent, LIB_PART // Give a bit more room for combobox editors m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); - // wxGrid::SetTable() messes up the column widths; use GRID_TRICKS version instead - GRID_TRICKS::SetGridTable( m_grid, m_dataModel ); - + m_grid->SetTable( m_dataModel ); m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) ); // Show/hide columns according to the user's preference m_config->Read( PinTableShownColumnsKey, &m_columnsShown, wxT( "0 1 2 3 4 8 9" ) ); - GRID_TRICKS::ShowHideGridColumns( m_grid, m_columnsShown ); + m_grid->ShowHideColumns( m_columnsShown ); // Set special attributes wxGridCellAttr* attr; @@ -416,13 +414,13 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent, LIB_PART DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE() { - m_config->Write( PinTableShownColumnsKey, GRID_TRICKS::GetShownColumns( m_grid ) ); + m_config->Write( PinTableShownColumnsKey, m_grid->GetShownColumns() ); // Disconnect Events m_grid->Disconnect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_LIB_EDIT_PIN_TABLE::OnColSort ), nullptr, this ); // Prevents crash bug in wxGrid's d'tor - GRID_TRICKS::DestroyGridTable( m_grid, m_dataModel ); + m_grid->DestroyTable( m_dataModel ); // Delete the GRID_TRICKS. m_grid->PopEventHandler( true ); @@ -583,7 +581,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnSize( wxSizeEvent& event ) void DIALOG_LIB_EDIT_PIN_TABLE::OnUpdateUI( wxUpdateUIEvent& event ) { - wxString columnsShown = GRID_TRICKS::GetShownColumns( m_grid ); + wxString columnsShown = m_grid->GetShownColumns(); if( columnsShown != m_columnsShown ) { diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp index 767c233469..1a8e49f414 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp @@ -5,6 +5,8 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "widgets/wx_grid.h" + #include "dialog_lib_edit_pin_table_base.h" /////////////////////////////////////////////////////////////////////////// @@ -16,7 +18,7 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent wxBoxSizer* top_sizer; top_sizer = new wxBoxSizer( wxVERTICAL ); - m_grid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid m_grid->CreateGrid( 5, 10 ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp b/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp index a0d62aadc1..ef33c0295b 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp @@ -173,7 +173,7 @@ 5 1 - ; forward_declare + WX_GRID; widgets/wx_grid.h; forward_declare 0 diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.h b/eeschema/dialogs/dialog_lib_edit_pin_table_base.h index d56cbe7d59..3e46926779 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.h @@ -11,6 +11,8 @@ #include #include #include +class WX_GRID; + #include "dialog_shim.h" #include #include @@ -40,7 +42,7 @@ class DIALOG_LIB_EDIT_PIN_TABLE_BASE : public DIALOG_SHIM private: protected: - wxGrid* m_grid; + WX_GRID* m_grid; wxBitmapButton* m_addButton; wxBitmapButton* m_deleteButton; wxStaticLine* m_staticline1; diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames.cpp b/eeschema/dialogs/panel_eeschema_template_fieldnames.cpp index 53c2b4f57c..43b6317617 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames.cpp +++ b/eeschema/dialogs/panel_eeschema_template_fieldnames.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -39,7 +40,7 @@ PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( SCH_EDIT m_addFieldButton->SetBitmap( KiBitmap( small_plus_xpm ) ); m_deleteFieldButton->SetBitmap( KiBitmap( trash_xpm ) ); - m_checkboxWidth = m_grid->GetColSize( 1 ); + m_checkboxColWidth = m_grid->GetColSize( 1 ); m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) ); } @@ -157,8 +158,8 @@ void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::AdjustGridColumns( int aWidth ) // Account for scroll bars aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x ); - m_grid->SetColSize( 0, aWidth - m_checkboxWidth ); - m_grid->SetColSize( 1, m_checkboxWidth ); + m_grid->SetColSize( 0, aWidth - m_checkboxColWidth ); + m_grid->SetColSize( 1, m_checkboxColWidth ); } diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames.h b/eeschema/dialogs/panel_eeschema_template_fieldnames.h index 46e24d2e54..9479fb00c7 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames.h +++ b/eeschema/dialogs/panel_eeschema_template_fieldnames.h @@ -32,7 +32,7 @@ protected: SCH_EDIT_FRAME* m_frame; TEMPLATE_FIELDNAMES m_fields; - int m_checkboxWidth; + int m_checkboxColWidth; /** * Function OnAddButtonClick diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.cpp b/eeschema/dialogs/panel_eeschema_template_fieldnames_base.cpp index 21487c07a9..e01d72ce06 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.cpp +++ b/eeschema/dialogs/panel_eeschema_template_fieldnames_base.cpp @@ -5,6 +5,8 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "widgets/wx_grid.h" + #include "panel_eeschema_template_fieldnames_base.h" /////////////////////////////////////////////////////////////////////////// @@ -17,7 +19,7 @@ PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE wxBoxSizer* bMargins; bMargins = new wxBoxSizer( wxVERTICAL ); - m_grid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid m_grid->CreateGrid( 0, 2 ); diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.fbp b/eeschema/dialogs/panel_eeschema_template_fieldnames_base.fbp index d1dd4f3b68..65f25d652e 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.fbp +++ b/eeschema/dialogs/panel_eeschema_template_fieldnames_base.fbp @@ -172,7 +172,7 @@ 0 1 - + WX_GRID; widgets/wx_grid.h; forward_declare 0 diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.h b/eeschema/dialogs/panel_eeschema_template_fieldnames_base.h index fc449f181f..e2583852df 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.h +++ b/eeschema/dialogs/panel_eeschema_template_fieldnames_base.h @@ -11,6 +11,8 @@ #include #include #include +class WX_GRID; + #include #include #include @@ -35,7 +37,7 @@ class PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE : public wxPanel private: protected: - wxGrid* m_grid; + WX_GRID* m_grid; wxBitmapButton* m_addFieldButton; wxBitmapButton* m_deleteFieldButton; diff --git a/include/grid_tricks.h b/include/grid_tricks.h index 120595f1be..682ef4e97f 100644 --- a/include/grid_tricks.h +++ b/include/grid_tricks.h @@ -54,18 +54,6 @@ public: explicit GRID_TRICKS( wxGrid* aGrid ); - /// Helper routines for column visibility preferences - static void ShowHideGridColumns( wxGrid* aGrid, const wxString& shownColumns ); - static wxString GetShownColumns( wxGrid* aGrid ); - - /// Workaround for wxGrid::SetTable(), which messes up the column widths that were set - /// in wxFormBuilder.) - static void SetGridTable( wxGrid* aGrid, wxGridTableBase* aTable ); - - /// Workaround for crash bug in wxGrid where it tries to call the table in the d'tor - /// in order to hide the cell editor - static void DestroyGridTable( wxGrid* aGrid, wxGridTableBase* aTable ); - protected: wxGrid* m_grid; ///< I don't own the grid, but he owns me diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp index c82253bc1b..bc5114f68c 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp @@ -37,20 +37,20 @@ #include #include #include - #include #include +#include #include #include - -#include #include "3d_cache/dialogs/panel_prev_model.h" #include "3d_cache/dialogs/3d_cache_dialogs.h" - #include #include #include <3d_viewer.h> +#include + + #define FootprintTextShownColumnsKey wxT( "FootprintTextShownColumns" ) int DIALOG_FOOTPRINT_BOARD_EDITOR::m_page = 0; // remember the last open page during session @@ -88,16 +88,14 @@ DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR( PCB_EDIT_FRAME* aP m_itemsGrid->SetDefaultRowSize( m_itemsGrid->GetDefaultRowSize() + 4 ); m_modelsGrid->SetDefaultRowSize( m_modelsGrid->GetDefaultRowSize() + 4 ); - // wxGrid::SetTable() messes up the column widths; use GRID_TRICKS version instead - GRID_TRICKS::SetGridTable( m_itemsGrid, m_texts ); - + m_itemsGrid->SetTable( m_texts ); m_itemsGrid->PushEventHandler( new GRID_TRICKS( m_itemsGrid ) ); m_modelsGrid->PushEventHandler( new GRID_TRICKS( m_modelsGrid ) ); // Show/hide text item columns according to the user's preference wxString shownColumns; m_config->Read( FootprintTextShownColumnsKey, &shownColumns, wxT( "0 1 2 3 4 5 6" ) ); - GRID_TRICKS::ShowHideGridColumns( m_itemsGrid, shownColumns ); + m_itemsGrid->ShowHideColumns( shownColumns ); // Set up the 3D models grid wxGridCellAttr* attr = new wxGridCellAttr; @@ -156,10 +154,10 @@ DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR( PCB_EDIT_FRAME* aP DIALOG_FOOTPRINT_BOARD_EDITOR::~DIALOG_FOOTPRINT_BOARD_EDITOR() { - m_config->Write( FootprintTextShownColumnsKey, GRID_TRICKS::GetShownColumns( m_itemsGrid ) ); + m_config->Write( FootprintTextShownColumnsKey, m_itemsGrid->GetShownColumns() ); // Prevents crash bug in wxGrid's d'tor - GRID_TRICKS::DestroyGridTable( m_itemsGrid, m_texts ); + m_itemsGrid->DestroyTable( m_texts ); // Delete the GRID_TRICKS. m_itemsGrid->PopEventHandler( true ); diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.cpp index 69a07dce58..fec30d8e3f 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.cpp @@ -5,8 +5,8 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "text_mod_grid_table.h" #include "widgets/text_ctrl_eval.h" +#include "widgets/wx_grid.h" #include "dialog_edit_footprint_for_BoardEditor_base.h" @@ -26,7 +26,7 @@ DIALOG_FOOTPRINT_BOARD_EDITOR_BASE::DIALOG_FOOTPRINT_BOARD_EDITOR_BASE( wxWindow wxStaticBoxSizer* sbSizerTexts; sbSizerTexts = new wxStaticBoxSizer( new wxStaticBox( m_PanelGeneral, wxID_ANY, wxEmptyString ), wxVERTICAL ); - m_itemsGrid = new TEXT_MOD_GRID( sbSizerTexts->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0 ); + m_itemsGrid = new WX_GRID( sbSizerTexts->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0 ); // Grid m_itemsGrid->CreateGrid( 2, 11 ); @@ -117,7 +117,7 @@ DIALOG_FOOTPRINT_BOARD_EDITOR_BASE::DIALOG_FOOTPRINT_BOARD_EDITOR_BASE( wxWindow m_XPosLabel->Wrap( -1 ); fgSizerPos->Add( m_XPosLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_ModPositionX = new TEXT_CTRL_EVAL( m_PanelGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_ModPositionX = new wxTextCtrl( m_PanelGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerPos->Add( m_ModPositionX, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP, 5 ); m_XPosUnit = new wxStaticText( m_PanelGeneral, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -128,7 +128,7 @@ DIALOG_FOOTPRINT_BOARD_EDITOR_BASE::DIALOG_FOOTPRINT_BOARD_EDITOR_BASE( wxWindow m_YPosLabel->Wrap( -1 ); fgSizerPos->Add( m_YPosLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_ModPositionY = new TEXT_CTRL_EVAL( m_PanelGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_ModPositionY = new wxTextCtrl( m_PanelGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerPos->Add( m_ModPositionY, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM, 5 ); m_YPosUnit = new wxStaticText( m_PanelGeneral, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -307,7 +307,7 @@ DIALOG_FOOTPRINT_BOARD_EDITOR_BASE::DIALOG_FOOTPRINT_BOARD_EDITOR_BASE( wxWindow fgSizerClearances->Add( m_NetClearanceLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); - m_NetClearanceCtrl = new TEXT_CTRL_EVAL( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_NetClearanceCtrl = new wxTextCtrl( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerClearances->Add( m_NetClearanceCtrl, 1, wxEXPAND|wxALL, 5 ); m_NetClearanceUnits = new wxStaticText( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -320,7 +320,7 @@ DIALOG_FOOTPRINT_BOARD_EDITOR_BASE::DIALOG_FOOTPRINT_BOARD_EDITOR_BASE( wxWindow fgSizerClearances->Add( m_SolderMaskMarginLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); - m_SolderMaskMarginCtrl = new TEXT_CTRL_EVAL( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_SolderMaskMarginCtrl = new wxTextCtrl( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerClearances->Add( m_SolderMaskMarginCtrl, 1, wxALL|wxEXPAND, 5 ); m_SolderMaskMarginUnits = new wxStaticText( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -333,7 +333,7 @@ DIALOG_FOOTPRINT_BOARD_EDITOR_BASE::DIALOG_FOOTPRINT_BOARD_EDITOR_BASE( wxWindow fgSizerClearances->Add( m_SolderPasteMarginLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - m_SolderPasteMarginCtrl = new TEXT_CTRL_EVAL( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_SolderPasteMarginCtrl = new wxTextCtrl( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerClearances->Add( m_SolderPasteMarginCtrl, 1, wxEXPAND|wxLEFT|wxRIGHT, 5 ); m_SolderPasteMarginUnits = new wxStaticText( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.fbp b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.fbp index 533e542002..320456b762 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.fbp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.fbp @@ -351,7 +351,7 @@ 2 1 -1,-1 - TEXT_MOD_GRID; text_mod_grid_table.h; forward_declare + WX_GRID; widgets/wx_grid.h; forward_declare 0 @@ -641,11 +641,11 @@ bSizerLeft wxVERTICAL private - + 5 wxEXPAND|wxRIGHT|wxLEFT 0 - + 3 wxHORIZONTAL 1 @@ -791,7 +791,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -1048,7 +1048,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -2376,20 +2376,20 @@ - + 5 wxEXPAND 8 - + bSizerRight wxVERTICAL none - + 5 wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 - + bButtonsSizer wxVERTICAL @@ -2850,11 +2850,11 @@ bSizerPanelClearances wxVERTICAL none - + 10 wxEXPAND|wxALL 0 - + wxID_ANY Clearances @@ -3112,11 +3112,11 @@ - + 5 wxEXPAND 1 - + 3 wxBOTH 1 @@ -3262,7 +3262,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -3519,7 +3519,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -3776,7 +3776,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -4243,11 +4243,11 @@ - + 10 wxALL|wxEXPAND 0 - + wxID_ANY Connection to Copper Zones diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.h b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.h index edc0c8e01a..d1f3b89300 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.h +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor_base.h @@ -12,7 +12,7 @@ #include #include class TEXT_CTRL_EVAL; -class TEXT_MOD_GRID; +class WX_GRID; #include "dialog_shim.h" #include @@ -60,14 +60,14 @@ class DIALOG_FOOTPRINT_BOARD_EDITOR_BASE : public DIALOG_SHIM protected: wxNotebook* m_NoteBook; wxPanel* m_PanelGeneral; - TEXT_MOD_GRID* m_itemsGrid; + WX_GRID* m_itemsGrid; wxBitmapButton* m_bpAdd; wxBitmapButton* m_bpDelete; wxStaticText* m_XPosLabel; - TEXT_CTRL_EVAL* m_ModPositionX; + wxTextCtrl* m_ModPositionX; wxStaticText* m_XPosUnit; wxStaticText* m_YPosLabel; - TEXT_CTRL_EVAL* m_ModPositionY; + wxTextCtrl* m_ModPositionY; wxStaticText* m_YPosUnit; wxRadioButton* m_Orient0; wxRadioButton* m_Orient90; @@ -90,13 +90,13 @@ class DIALOG_FOOTPRINT_BOARD_EDITOR_BASE : public DIALOG_SHIM wxStaticText* m_staticTextInfoValPos; wxStaticText* m_staticTextInfoValNeg; wxStaticText* m_NetClearanceLabel; - TEXT_CTRL_EVAL* m_NetClearanceCtrl; + wxTextCtrl* m_NetClearanceCtrl; wxStaticText* m_NetClearanceUnits; wxStaticText* m_SolderMaskMarginLabel; - TEXT_CTRL_EVAL* m_SolderMaskMarginCtrl; + wxTextCtrl* m_SolderMaskMarginCtrl; wxStaticText* m_SolderMaskMarginUnits; wxStaticText* m_SolderPasteMarginLabel; - TEXT_CTRL_EVAL* m_SolderPasteMarginCtrl; + wxTextCtrl* m_SolderPasteMarginCtrl; wxStaticText* m_SolderPasteMarginUnits; wxStaticText* m_staticTextRatio; TEXT_CTRL_EVAL* m_SolderPasteMarginRatioCtrl; diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index c8b03d6f20..0ba4a49b49 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -39,8 +39,8 @@ #include #include #include +#include #include - #include #include #include @@ -60,8 +60,7 @@ int DIALOG_FOOTPRINT_FP_EDITOR::m_page = 0; // remember the last open page d DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aParent, MODULE* aModule ) : DIALOG_FOOTPRINT_FP_EDITOR_BASE( aParent ), - m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits, - false, 0 ), + m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits, false, 0 ), m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl, m_SolderMaskMarginUnits ), m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl, m_SolderPasteMarginUnits ) { @@ -86,16 +85,14 @@ DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aP m_itemsGrid->SetDefaultRowSize( m_itemsGrid->GetDefaultRowSize() + 4 ); m_modelsGrid->SetDefaultRowSize( m_modelsGrid->GetDefaultRowSize() + 4 ); - // wxGrid::SetTable() messes up the column widths; use GRID_TRICKS version instead - GRID_TRICKS::SetGridTable( m_itemsGrid, m_texts ); - + m_itemsGrid->SetTable( m_texts ); m_itemsGrid->PushEventHandler( new GRID_TRICKS( m_itemsGrid ) ); m_modelsGrid->PushEventHandler( new GRID_TRICKS( m_modelsGrid ) ); // Show/hide columns according to the user's preference wxString shownColumns; m_config->Read( LibFootprintTextShownColumnsKey, &shownColumns, wxT( "0 1 2 3 4 5 6" ) ); - GRID_TRICKS::ShowHideGridColumns( m_itemsGrid, shownColumns ); + m_itemsGrid->ShowHideColumns( shownColumns ); wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); infoFont.SetSymbolicSize( wxFONTSIZE_SMALL ); @@ -150,10 +147,10 @@ DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aP DIALOG_FOOTPRINT_FP_EDITOR::~DIALOG_FOOTPRINT_FP_EDITOR() { - m_config->Write( LibFootprintTextShownColumnsKey, GRID_TRICKS::GetShownColumns( m_itemsGrid ) ); + m_config->Write( LibFootprintTextShownColumnsKey, m_itemsGrid->GetShownColumns() ); // Prevents crash bug in wxGrid's d'tor - GRID_TRICKS::DestroyGridTable( m_itemsGrid, m_texts ); + m_itemsGrid->DestroyTable( m_texts ); // Delete the GRID_TRICKS. m_itemsGrid->PopEventHandler( true ); diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.cpp index fb697e65bb..e4439646ce 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.cpp @@ -5,8 +5,8 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "text_mod_grid_table.h" #include "widgets/text_ctrl_eval.h" +#include "widgets/wx_grid.h" #include "dialog_edit_footprint_for_fp_editor_base.h" @@ -26,7 +26,7 @@ DIALOG_FOOTPRINT_FP_EDITOR_BASE::DIALOG_FOOTPRINT_FP_EDITOR_BASE( wxWindow* pare wxStaticBoxSizer* sbSizerTexts; sbSizerTexts = new wxStaticBoxSizer( new wxStaticBox( m_PanelGeneral, wxID_ANY, wxEmptyString ), wxVERTICAL ); - m_itemsGrid = new TEXT_MOD_GRID( sbSizerTexts->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0 ); + m_itemsGrid = new WX_GRID( sbSizerTexts->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0 ); // Grid m_itemsGrid->CreateGrid( 2, 11 ); @@ -237,7 +237,7 @@ DIALOG_FOOTPRINT_FP_EDITOR_BASE::DIALOG_FOOTPRINT_FP_EDITOR_BASE( wxWindow* pare fgSizerClearances->Add( m_NetClearanceLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); - m_NetClearanceCtrl = new TEXT_CTRL_EVAL( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_NetClearanceCtrl = new wxTextCtrl( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerClearances->Add( m_NetClearanceCtrl, 1, wxEXPAND|wxALL, 5 ); m_NetClearanceUnits = new wxStaticText( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -250,7 +250,7 @@ DIALOG_FOOTPRINT_FP_EDITOR_BASE::DIALOG_FOOTPRINT_FP_EDITOR_BASE( wxWindow* pare fgSizerClearances->Add( m_SolderMaskMarginLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); - m_SolderMaskMarginCtrl = new TEXT_CTRL_EVAL( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_SolderMaskMarginCtrl = new wxTextCtrl( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerClearances->Add( m_SolderMaskMarginCtrl, 1, wxALL|wxEXPAND, 5 ); m_SolderMaskMarginUnits = new wxStaticText( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -263,7 +263,7 @@ DIALOG_FOOTPRINT_FP_EDITOR_BASE::DIALOG_FOOTPRINT_FP_EDITOR_BASE( wxWindow* pare fgSizerClearances->Add( m_SolderPasteMarginLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - m_SolderPasteMarginCtrl = new TEXT_CTRL_EVAL( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_SolderPasteMarginCtrl = new wxTextCtrl( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerClearances->Add( m_SolderPasteMarginCtrl, 1, wxEXPAND|wxLEFT|wxRIGHT, 5 ); m_SolderPasteMarginUnits = new wxStaticText( sbSizerLocalProperties->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.fbp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.fbp index b764598a72..8326e7b55c 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.fbp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.fbp @@ -351,7 +351,7 @@ 2 1 -1,-1 - TEXT_MOD_GRID; text_mod_grid_table.h; forward_declare + WX_GRID; widgets/wx_grid.h; forward_declare 0 @@ -2437,7 +2437,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -2694,7 +2694,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -2951,7 +2951,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.h b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.h index 7b4598aeaa..1aaaf2ebf0 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.h +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor_base.h @@ -12,7 +12,7 @@ #include #include class TEXT_CTRL_EVAL; -class TEXT_MOD_GRID; +class WX_GRID; #include "dialog_shim.h" #include @@ -52,7 +52,7 @@ class DIALOG_FOOTPRINT_FP_EDITOR_BASE : public DIALOG_SHIM protected: wxNotebook* m_NoteBook; wxPanel* m_PanelGeneral; - TEXT_MOD_GRID* m_itemsGrid; + WX_GRID* m_itemsGrid; wxBitmapButton* m_bpAdd; wxBitmapButton* m_bpDelete; wxStaticText* m_libraryName; @@ -71,13 +71,13 @@ class DIALOG_FOOTPRINT_FP_EDITOR_BASE : public DIALOG_SHIM wxStaticText* m_staticTextInfoValPos; wxStaticText* m_staticTextInfoValNeg; wxStaticText* m_NetClearanceLabel; - TEXT_CTRL_EVAL* m_NetClearanceCtrl; + wxTextCtrl* m_NetClearanceCtrl; wxStaticText* m_NetClearanceUnits; wxStaticText* m_SolderMaskMarginLabel; - TEXT_CTRL_EVAL* m_SolderMaskMarginCtrl; + wxTextCtrl* m_SolderMaskMarginCtrl; wxStaticText* m_SolderMaskMarginUnits; wxStaticText* m_SolderPasteMarginLabel; - TEXT_CTRL_EVAL* m_SolderPasteMarginCtrl; + wxTextCtrl* m_SolderPasteMarginCtrl; wxStaticText* m_SolderPasteMarginUnits; wxStaticText* m_staticTextRatio; TEXT_CTRL_EVAL* m_SolderPasteMarginRatioCtrl; diff --git a/pcbnew/text_mod_grid_table.cpp b/pcbnew/text_mod_grid_table.cpp index f803113a1d..612ea382dc 100644 --- a/pcbnew/text_mod_grid_table.cpp +++ b/pcbnew/text_mod_grid_table.cpp @@ -336,31 +336,3 @@ void TEXT_MOD_GRID_TABLE::SetValueAsLong( int aRow, int aCol, long aValue ) } } - -// An override of wxGrid::DrawColLabel which left-aligns the first column. -void TEXT_MOD_GRID::DrawColLabel( wxDC& dc, int col ) -{ - if( GetColWidth( col ) <= 0 || m_colLabelHeight <= 0 ) - return; - - int colLeft = GetColLeft( col ); - - wxRect rect( colLeft, 0, GetColWidth( col ), m_colLabelHeight ); - static wxGridColumnHeaderRendererDefault rend; - - // It is reported that we need to erase the background to avoid display - // artefacts, see #12055. - wxDCBrushChanger setBrush( dc, m_colWindow->GetBackgroundColour() ); - dc.DrawRectangle(rect); - - rend.DrawBorder( *this, dc, rect ); - - int hAlign, vAlign; - GetColLabelAlignment( &hAlign, &vAlign ); - const int orient = GetColLabelTextOrientation(); - - if( col == 0 ) - hAlign = wxALIGN_LEFT; - - rend.DrawLabel( *this, dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient ); -} diff --git a/pcbnew/text_mod_grid_table.h b/pcbnew/text_mod_grid_table.h index f297b629ff..6ccd63a562 100644 --- a/pcbnew/text_mod_grid_table.h +++ b/pcbnew/text_mod_grid_table.h @@ -91,20 +91,4 @@ private: }; -// A sub-class of wxGrid which draws the first column label left-aligned. - -class TEXT_MOD_GRID : public wxGrid -{ -public: - TEXT_MOD_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 ) - { - } - - void DrawColLabel( wxDC& dc, int col ) override; -}; - - #endif // TEXT_MOD_GRID_TABLE_H