KiCad PCB EDA Suite
WX_GRID Class Reference

#include <wx_grid.h>

Inheritance diagram for WX_GRID:

Public Member Functions

 WX_GRID (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS, const wxString &name=wxGridNameStr)
 
 ~WX_GRID () override
 
void SetColLabelSize (int aHeight)
 Hide wxGrid's SetColLabelSize() method with one which makes sure the size is tall enough for the system GUI font. More...
 
wxString GetShownColumns ()
 Get a tokenized string containing the shown column indexes. More...
 
void ShowHideColumns (const wxString &shownColumns)
 Show/hide the grid columns based on a tokenized string of shown column indexes. More...
 
void SetTable (wxGridTableBase *table, bool aTakeOwnership=false)
 Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting the table. More...
 
void DestroyTable (wxGridTableBase *aTable)
 Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was not closed. More...
 
bool CommitPendingChanges (bool aQuietMode=false)
 Close any open cell edit controls. More...
 
int GetVisibleWidth (int aCol, bool aHeader=true, bool aContents=false, bool aKeep=true)
 Calculates the specified column based on the actual size of the text on screen. More...
 
void EnsureColLabelsVisible ()
 Ensure the height of the row displaying the column labels is enough, even if labels are multiline texts. More...
 
void ShowEditorOnMouseUp ()
 WxWidgets has a bunch of bugs in its handling of wxGrid mouse events which close cell editors right after opening them. More...
 
void ClearRows ()
 wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number of rows (even if the delete count is 0). More...
 

Protected Member Functions

void DrawColLabel (wxDC &dc, int col) override
 A re-implementation of wxGrid::DrawColLabel which left-aligns the first column when there are no row labels. More...
 
void onGridColMove (wxGridEvent &aEvent)
 
void onGridCellSelect (wxGridEvent &aEvent)
 

Protected Attributes

bool m_weOwnTable
 

Detailed Description

Definition at line 32 of file wx_grid.h.

Constructor & Destructor Documentation

◆ WX_GRID()

WX_GRID::WX_GRID ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxWANTS_CHARS,
const wxString &  name = wxGridNameStr 
)

Definition at line 34 of file wx_grid.cpp.

35  :
36  wxGrid( parent, id, pos, size, style, name ),
37  m_weOwnTable( false )
38 {
39  SetDefaultCellOverflow( false );
40 
41  // Make sure the GUI font scales properly on GTK
42  SetDefaultCellFont( KIUI::GetControlFont( this ) );
43 
44 #if wxCHECK_VERSION( 3, 1, 0 )
45  Connect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this );
46 #endif
47 
48 }
bool m_weOwnTable
Definition: wx_grid.h:129
wxFont GetControlFont(wxWindow *aWindow)
Definition: ui_common.cpp:150
const char * name
Definition: DXF_plotter.cpp:56

References KIUI::GetControlFont().

◆ ~WX_GRID()

WX_GRID::~WX_GRID ( )
override

Definition at line 51 of file wx_grid.cpp.

52 {
53  if( m_weOwnTable )
54  DestroyTable( GetTable() );
55 
56 #if wxCHECK_VERSION( 3, 1, 0 )
57  Disconnect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this );
58 #endif
59 
60 }
bool m_weOwnTable
Definition: wx_grid.h:129
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
Definition: wx_grid.cpp:139

References DestroyTable(), and m_weOwnTable.

Member Function Documentation

◆ ClearRows()

void WX_GRID::ClearRows ( )
inline

wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number of rows (even if the delete count is 0).

Needless to say, this makes using DeleteRows for clearing a lot more cumbersome so we add a helper here.

Definition at line 109 of file wx_grid.h.

110  {
111  if( GetNumberRows() )
112  DeleteRows( 0, GetNumberRows() );
113  }

Referenced by DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS(), DIALOG_EDIT_SYMBOLS_LIBID::initDlg(), PANEL_TEXT_VARIABLES::PANEL_TEXT_VARIABLES(), PANEL_FP_LIB_TABLE::populateEnvironReadOnlyTable(), PANEL_SYM_LIB_TABLE::populateEnvironReadOnlyTable(), FOOTPRINT_WIZARD_FRAME::ReCreateParameterList(), PANEL_FP_PROPERTIES_3D_MODEL::ReloadModelsFromFootprint(), PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataToGrid(), PANEL_PCBNEW_ACTION_PLUGINS::TransferDataToWindow(), PANEL_SETUP_NETCLASSES::TransferDataToWindow(), and PANEL_SETUP_TRACKS_AND_VIAS::TransferDataToWindow().

◆ CommitPendingChanges()

bool WX_GRID::CommitPendingChanges ( bool  aQuietMode = false)

Close any open cell edit controls.

Parameters
aQuietModeif true don't send events (ie: for row/col delete operations)
Returns
false if validation failed

Definition at line 226 of file wx_grid.cpp.

227 {
228  if( !IsCellEditControlEnabled() )
229  return true;
230 
231  if( !aQuietMode && SendEvent( wxEVT_GRID_EDITOR_HIDDEN ) == -1 )
232  return false;
233 
234  HideCellEditControl();
235 
236  // do it after HideCellEditControl()
237  m_cellEditCtrlEnabled = false;
238 
239  int row = m_currentCellCoords.GetRow();
240  int col = m_currentCellCoords.GetCol();
241 
242  wxString oldval = GetCellValue( row, col );
243  wxString newval;
244 
245  wxGridCellAttr* attr = GetCellAttr( row, col );
246  wxGridCellEditor* editor = attr->GetEditor( this, row, col );
247 
248  bool changed = editor->EndEdit( row, col, this, oldval, &newval );
249 
250  editor->DecRef();
251  attr->DecRef();
252 
253  if( changed )
254  {
255  if( !aQuietMode && SendEvent( wxEVT_GRID_CELL_CHANGING, newval ) == -1 )
256  return false;
257 
258  editor->ApplyEdit( row, col, this );
259 
260  // for compatibility reasons dating back to wx 2.8 when this event
261  // was called wxEVT_GRID_CELL_CHANGE and wxEVT_GRID_CELL_CHANGING
262  // didn't exist we allow vetoing this one too
263  if( !aQuietMode && SendEvent( wxEVT_GRID_CELL_CHANGED, oldval ) == -1 )
264  {
265  // Event has been vetoed, set the data back.
266  SetCellValue( row, col, oldval );
267  return false;
268  }
269  }
270 
271  return true;
272 }

References editor.

Referenced by PANEL_FP_LIB_TABLE::appendRowHandler(), PANEL_SYM_LIB_TABLE::appendRowHandler(), PANEL_FP_LIB_TABLE::browseLibrariesHandler(), PANEL_SYM_LIB_TABLE::deleteRowHandler(), PANEL_FP_LIB_TABLE::deleteRowHandler(), DestroyTable(), PANEL_SETUP_NETCLASSES::doApplyFilters(), PANEL_SETUP_NETCLASSES::doAssignments(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::doValidate(), PANEL_SETUP_TEXT_AND_GRAPHICS::ImportSettingsFrom(), PANEL_SETUP_TRACKS_AND_VIAS::ImportSettingsFrom(), PANEL_SYM_LIB_TABLE::moveDownHandler(), PANEL_FP_LIB_TABLE::moveDownHandler(), PANEL_SYM_LIB_TABLE::moveUpHandler(), PANEL_FP_LIB_TABLE::moveUpHandler(), PANEL_FP_PROPERTIES_3D_MODEL::OnAdd3DModel(), PANEL_FP_PROPERTIES_3D_MODEL::OnAdd3DRow(), DIALOG_PIN_PROPERTIES::OnAddAlternate(), PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnAddButtonClick(), DIALOG_CONFIGURE_PATHS::OnAddEnvVar(), DIALOG_LIB_SYMBOL_PROPERTIES::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField(), DIALOG_SHEET_PROPERTIES::OnAddField(), DIALOG_SYMBOL_PROPERTIES::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), PANEL_SETUP_NETCLASSES::OnAddNetclassClick(), DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow(), DIALOG_CONFIGURE_PATHS::OnAddSearchPath(), PANEL_FP_EDITOR_DEFAULTS::OnAddTextItem(), PANEL_TEXT_VARIABLES::OnAddTextVar(), DIALOG_FP_PLUGIN_OPTIONS::onAppendOption(), DIALOG_FP_PLUGIN_OPTIONS::onAppendRow(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonAdd(), TEXT_BUTTON_FILE_BROWSER::OnButtonClick(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonDelete(), GRID_TRICKS::onCharHook(), DIALOG_LIB_EDIT_PIN_TABLE::OnClose(), DIALOG_SYMBOL_FIELDS_TABLE::OnClose(), PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries(), DIALOG_PIN_PROPERTIES::OnDeleteAlternate(), PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnDeleteButtonClick(), DIALOG_LIB_SYMBOL_PROPERTIES::OnDeleteField(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnDeleteField(), DIALOG_SHEET_PROPERTIES::OnDeleteField(), DIALOG_SYMBOL_PROPERTIES::OnDeleteField(), DIALOG_FOOTPRINT_PROPERTIES::OnDeleteField(), DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow(), DIALOG_FP_PLUGIN_OPTIONS::onDeleteRow(), DIALOG_CONFIGURE_PATHS::OnDeleteSearchPath(), PANEL_FP_EDITOR_DEFAULTS::OnDeleteTextItem(), onGridColMove(), GRID_TRICKS::onGridLabelLeftClick(), DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveDown(), DIALOG_SHEET_PROPERTIES::OnMoveDown(), DIALOG_SYMBOL_PROPERTIES::OnMoveDown(), DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveUp(), DIALOG_SHEET_PROPERTIES::OnMoveUp(), DIALOG_SYMBOL_PROPERTIES::OnMoveUp(), DIALOG_LIB_EDIT_PIN_TABLE::OnRebuildRows(), PANEL_FP_PROPERTIES_3D_MODEL::OnRemove3DModel(), DIALOG_CONFIGURE_PATHS::OnRemoveEnvVar(), PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick(), PANEL_TEXT_VARIABLES::OnRemoveTextVar(), DIALOG_CONFIGURE_PATHS::OnSearchPathMoveDown(), DIALOG_CONFIGURE_PATHS::OnSearchPathMoveUp(), PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns(), PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromGrid(), PANEL_TEXT_VARIABLES::TransferDataFromWindow(), DIALOG_SWAP_LAYERS::TransferDataFromWindow(), DIALOG_SYMBOL_FIELDS_TABLE::TransferDataFromWindow(), PANEL_FP_LIB_TABLE::TransferDataFromWindow(), PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow(), DIALOG_CONFIGURE_PATHS::TransferDataFromWindow(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow(), PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), DIALOG_LIB_EDIT_PIN_TABLE::TransferDataFromWindow(), DIALOG_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), PANEL_FP_PROPERTIES_3D_MODEL::TransferDataFromWindow(), PANEL_SYM_LIB_TABLE::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_FP_PLUGIN_OPTIONS::TransferDataFromWindow(), PANEL_SETUP_NETCLASSES::Validate(), DIALOG_LIB_SYMBOL_PROPERTIES::Validate(), PANEL_SETUP_TRACKS_AND_VIAS::Validate(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::Validate(), DIALOG_FOOTPRINT_PROPERTIES::Validate(), DIALOG_SHEET_PROPERTIES::Validate(), DIALOG_SYMBOL_PROPERTIES::Validate(), PANEL_FP_EDITOR_DEFAULTS::validateData(), and DIALOG_EDIT_SYMBOLS_LIBID::validateLibIds().

◆ DestroyTable()

void WX_GRID::DestroyTable ( wxGridTableBase *  aTable)

Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was not closed.

Definition at line 139 of file wx_grid.cpp.

140 {
141  // wxGrid's destructor will crash trying to look up the cell attr if the edit control
142  // is left open. Normally it's closed in Validate(), but not if the user hit Cancel.
143  CommitPendingChanges( true /* quiet mode */ );
144 
145  Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
146  Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this );
147 
148  wxGrid::SetTable( nullptr );
149  delete aTable;
150 }
void onGridColMove(wxGridEvent &aEvent)
Definition: wx_grid.cpp:275
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226
void onGridCellSelect(wxGridEvent &aEvent)
Definition: wx_grid.cpp:126

References CommitPendingChanges(), onGridCellSelect(), and onGridColMove().

Referenced by DIALOG_FOOTPRINT_PROPERTIES::~DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::~DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(), DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE(), DIALOG_LIB_SYMBOL_PROPERTIES::~DIALOG_LIB_SYMBOL_PROPERTIES(), DIALOG_PIN_PROPERTIES::~DIALOG_PIN_PROPERTIES(), DIALOG_SHEET_PROPERTIES::~DIALOG_SHEET_PROPERTIES(), DIALOG_SWAP_LAYERS::~DIALOG_SWAP_LAYERS(), DIALOG_SYMBOL_PROPERTIES::~DIALOG_SYMBOL_PROPERTIES(), and ~WX_GRID().

◆ DrawColLabel()

void WX_GRID::DrawColLabel ( wxDC &  dc,
int  col 
)
overrideprotected

A re-implementation of wxGrid::DrawColLabel which left-aligns the first column when there are no row labels.

Definition at line 190 of file wx_grid.cpp.

191 {
192  if( GetColWidth( col ) <= 0 || m_colLabelHeight <= 0 )
193  return;
194 
195  int colLeft = GetColLeft( col );
196 
197  wxRect rect( colLeft, 0, GetColWidth( col ), m_colLabelHeight );
198  static wxGridColumnHeaderRendererDefault rend;
199 
200  // It is reported that we need to erase the background to avoid display
201  // artifacts, see #12055.
202  // wxWidgets renamed this variable between 3.1.2 and 3.1.3 ...
203 #if wxCHECK_VERSION( 3, 1, 3 )
204  wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
205 #else
206  wxDCBrushChanger setBrush( dc, m_colWindow->GetBackgroundColour() );
207 #endif
208  dc.DrawRectangle(rect);
209 
210  rend.DrawBorder( *this, dc, rect );
211 
212  // Make sure fonts get scaled correctly on GTK HiDPI monitors
213  dc.SetFont( GetLabelFont() );
214 
215  int hAlign, vAlign;
216  GetColLabelAlignment( &hAlign, &vAlign );
217  const int orient = GetColLabelTextOrientation();
218 
219  if( col == 0 && GetRowLabelSize() == 0 )
220  hAlign = wxALIGN_LEFT;
221 
222  rend.DrawLabel( *this, dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient );
223 }

◆ EnsureColLabelsVisible()

void WX_GRID::EnsureColLabelsVisible ( )

Ensure the height of the row displaying the column labels is enough, even if labels are multiline texts.

Definition at line 327 of file wx_grid.cpp.

328 {
329  // The 1.1 scale factor is due to the fact row labels use a bold font, bigger than
330  // the normal font
331  // TODO: use a better way to evaluate the text size, for bold font
332  int line_height = int( GetTextExtent( "Mj" ).y * 1.1 ) + 3;
333  int row_height = GetColLabelSize();
334  int initial_row_height = row_height;
335 
336  // Headers can be multiline. Fix the Column Label Height to show the full header
337  // However GetTextExtent does not work on multiline strings,
338  // and do not return the full text height (only the height of one line)
339  for( int col = 0; col < GetNumberCols(); col++ )
340  {
341  int nl_count = GetColLabelValue( col ).Freq( '\n' );
342 
343  if( nl_count )
344  {
345  // Col Label height must be able to show nl_count+1 lines
346  if( row_height < line_height * ( nl_count+1 ) )
347  row_height += line_height * nl_count;
348  }
349  }
350 
351  // Update the column label size, but only if needed, to avoid generating useless
352  // and perhaps annoying UI events when the size does not change
353  if( initial_row_height != row_height )
354  SetColLabelSize( row_height );
355 }
void SetColLabelSize(int aHeight)
Hide wxGrid's SetColLabelSize() method with one which makes sure the size is tall enough for the syst...
Definition: wx_grid.cpp:74

References SetColLabelSize().

Referenced by DIALOG_BOARD_STATISTICS::adjustDrillGridColumns(), GetVisibleWidth(), and PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES().

◆ GetShownColumns()

wxString WX_GRID::GetShownColumns ( )

Get a tokenized string containing the shown column indexes.

Tokens are separated by spaces.

Definition at line 153 of file wx_grid.cpp.

154 {
155  wxString shownColumns;
156 
157  for( int i = 0; i < GetNumberCols(); ++i )
158  {
159  if( IsColShown( i ) )
160  {
161  if( shownColumns.Length() )
162  shownColumns << wxT( " " );
163 
164  shownColumns << i;
165  }
166  }
167 
168  return shownColumns;
169 }

Referenced by DIALOG_LIB_EDIT_PIN_TABLE::OnUpdateUI(), DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI(), DIALOG_SHEET_PROPERTIES::OnUpdateUI(), DIALOG_SYMBOL_PROPERTIES::OnUpdateUI(), DIALOG_FOOTPRINT_PROPERTIES::~DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::~DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(), DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE(), DIALOG_LIB_SYMBOL_PROPERTIES::~DIALOG_LIB_SYMBOL_PROPERTIES(), DIALOG_SHEET_PROPERTIES::~DIALOG_SHEET_PROPERTIES(), and DIALOG_SYMBOL_PROPERTIES::~DIALOG_SYMBOL_PROPERTIES().

◆ GetVisibleWidth()

int WX_GRID::GetVisibleWidth ( int  aCol,
bool  aHeader = true,
bool  aContents = false,
bool  aKeep = true 
)

Calculates the specified column based on the actual size of the text on screen.

Will return the maximum value of all calculated widths.

Parameters
aCol- Integer value of the column to resize. Specify -1 for the row labels.
aHeader- Include the header in the width calculation
aContents- Include the full contents of the column
aKeep- Use the current size as a minimum value
Returns
The new size of the column

Definition at line 282 of file wx_grid.cpp.

283 {
284  int size = 0;
285 
286  if( aCol < 0 )
287  {
288  if( aKeep )
289  size = GetRowLabelSize();
290 
291  // The 1.1 scale factor is due to the fact row labels use a bold font, bigger than
292  // the normal font.
293  // TODO: use a better way to evaluate the text size, for bold font
294  for( int row = 0; aContents && row < GetNumberRows(); row++ )
295  size = std::max( size, int( GetTextExtent( GetRowLabelValue( row ) + wxT( "M" ) ).x * 1.1 ) );
296  }
297  else
298  {
299  if( aKeep )
300  size = GetColSize( aCol );
301 
302  // 'M' is generally the widest character, so we buffer the column width by default to
303  // ensure we don't write a continuous line of text at the column header
304  if( aHeader )
305  {
307 
308  // The 1.1 scale factor is due to the fact headers use a bold font, bigger than
309  // the normal font.
310  size = std::max( size, int( GetTextExtent( GetColLabelValue( aCol ) + wxT( "M" ) ).x * 1.1 ) );
311  }
312 
313  for( int row = 0; aContents && row < GetNumberRows(); row++ )
314  {
315  // If we have text, get the size. Otherwise, use a placeholder for the checkbox
316  if( GetTable()->CanGetValueAs( row, aCol, wxGRID_VALUE_STRING ) )
317  size = std::max( size, GetTextExtent( GetCellValue( row, aCol ) + wxT( "M" ) ).x );
318  else
319  size = std::max( size, GetTextExtent( "MM" ).x );
320  }
321  }
322 
323  return size;
324 }
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
Definition: wx_grid.cpp:327

References EnsureColLabelsVisible().

Referenced by DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::adjustGridColumns(), DIALOG_FOOTPRINT_PROPERTIES::adjustGridColumns(), PANEL_PACKAGES_VIEW::PANEL_PACKAGES_VIEW(), PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES(), PANEL_SETUP_TEXT_AND_GRAPHICS::PANEL_SETUP_TEXT_AND_GRAPHICS(), PANEL_SETUP_TRACKS_AND_VIAS::PANEL_SETUP_TRACKS_AND_VIAS(), PANEL_FP_PROPERTIES_3D_MODEL::ReloadModelsFromFootprint(), DIALOG_MANAGE_REPOSITORIES::setColumnWidths(), PANEL_PACKAGES_VIEW::setPackageDetails(), PANEL_PCBNEW_ACTION_PLUGINS::TransferDataToWindow(), PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow(), PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), and DIALOG_PCM::updatePendingActionsTab().

◆ onGridCellSelect()

void WX_GRID::onGridCellSelect ( wxGridEvent &  aEvent)
protected

Definition at line 126 of file wx_grid.cpp.

127 {
128  // Highlight the selected cell.
129  // Calling SelectBlock() allows a visual effect when cells are selected
130  // by tab or arrow keys.
131  // Otherwise, one cannot really know what actual cell is selected
132  int row = aEvent.GetRow();
133  int col = aEvent.GetCol();
134 
135  if( row >= 0 && col >= 0 )
136  SelectBlock(row,col,row,col,false);
137 }

Referenced by DestroyTable(), and SetTable().

◆ onGridColMove()

void WX_GRID::onGridColMove ( wxGridEvent &  aEvent)
protected

Definition at line 275 of file wx_grid.cpp.

276 {
277  // wxWidgets won't move an open editor, so better just to close it
278  CommitPendingChanges( true );
279 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226

References CommitPendingChanges().

Referenced by DestroyTable(), and SetTable().

◆ SetColLabelSize()

void WX_GRID::SetColLabelSize ( int  aHeight)

Hide wxGrid's SetColLabelSize() method with one which makes sure the size is tall enough for the system GUI font.

Parameters
height

Definition at line 74 of file wx_grid.cpp.

75 {
76  if( aHeight == 0 )
77  {
78  wxGrid::SetColLabelSize( 0 );
79  return;
80  }
81 
82  wxFont headingFont = KIUI::GetControlFont( this ).Bold();
83 
84  // Make sure the GUI font scales properly on GTK
85  SetLabelFont( headingFont );
86 
87  // Correct wxFormBuilder height for large fonts
88  int minHeight = headingFont.GetPixelSize().y + 2 * MIN_GRIDCELL_MARGIN;
89  wxGrid::SetColLabelSize( std::max( aHeight, minHeight ) );
90 }
wxFont GetControlFont(wxWindow *aWindow)
Definition: ui_common.cpp:150
#define MIN_GRIDCELL_MARGIN
Definition: wx_grid.cpp:31

References KIUI::GetControlFont(), and MIN_GRIDCELL_MARGIN.

Referenced by APPEARANCE_CONTROLS::APPEARANCE_CONTROLS(), APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE(), DIALOG_BOARD_STATISTICS_BASE::DIALOG_BOARD_STATISTICS_BASE(), DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_BASE(), DIALOG_EDIT_SYMBOLS_LIBID_BASE::DIALOG_EDIT_SYMBOLS_LIBID_BASE(), DIALOG_FOOTPRINT_PROPERTIES_BASE::DIALOG_FOOTPRINT_PROPERTIES_BASE(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR_BASE::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR_BASE(), DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE(), DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE(), DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE(), DIALOG_MANAGE_REPOSITORIES_BASE::DIALOG_MANAGE_REPOSITORIES_BASE(), DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE::DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE(), DIALOG_PCM_BASE::DIALOG_PCM_BASE(), DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE(), DIALOG_SHEET_PROPERTIES_BASE::DIALOG_SHEET_PROPERTIES_BASE(), DIALOG_SWAP_LAYERS_BASE::DIALOG_SWAP_LAYERS_BASE(), DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE(), DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE(), EnsureColLabelsVisible(), FOOTPRINT_WIZARD_FRAME::initParameterGrid(), PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE(), PANEL_FP_EDITOR_DEFAULTS_BASE::PANEL_FP_EDITOR_DEFAULTS_BASE(), PANEL_FP_LIB_TABLE_BASE::PANEL_FP_LIB_TABLE_BASE(), PANEL_FP_PROPERTIES_3D_MODEL_BASE::PANEL_FP_PROPERTIES_3D_MODEL_BASE(), PANEL_PACKAGES_VIEW_BASE::PANEL_PACKAGES_VIEW_BASE(), PANEL_PCBNEW_ACTION_PLUGINS_BASE::PANEL_PCBNEW_ACTION_PLUGINS_BASE(), PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE(), PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::PANEL_SETUP_TEXT_AND_GRAPHICS_BASE(), PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE(), PANEL_SYM_LIB_TABLE_BASE::PANEL_SYM_LIB_TABLE_BASE(), and PANEL_TEXT_VARIABLES_BASE::PANEL_TEXT_VARIABLES_BASE().

◆ SetTable()

void WX_GRID::SetTable ( wxGridTableBase *  table,
bool  aTakeOwnership = false 
)

Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting the table.

Definition at line 93 of file wx_grid.cpp.

94 {
95  // wxGrid::SetTable() messes up the column widths from wxFormBuilder so we have to save
96  // and restore them.
97  int numberCols = GetNumberCols();
98  int* formBuilderColWidths = new int[numberCols];
99 
100  for( int i = 0; i < numberCols; ++i )
101  formBuilderColWidths[ i ] = GetColSize( i );
102 
103  wxGrid::SetTable( aTable );
104 
105  // wxGrid::SetTable() may change the number of columns, so prevent out-of-bounds access
106  // to formBuilderColWidths
107  numberCols = std::min( numberCols, GetNumberCols() );
108 
109  for( int i = 0; i < numberCols; ++i )
110  {
111  // correct wxFormBuilder width for large fonts and/or long translations
112  int headingWidth = GetTextExtent( GetColLabelValue( i ) ).x + 2 * MIN_GRIDCELL_MARGIN;
113 
114  SetColSize( i, std::max( formBuilderColWidths[ i ], headingWidth ) );
115  }
116 
117  delete[] formBuilderColWidths;
118 
119  Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
120  Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this );
121 
122  m_weOwnTable = aTakeOwnership;
123 }
bool m_weOwnTable
Definition: wx_grid.h:129
#define MIN_GRIDCELL_MARGIN
Definition: wx_grid.cpp:31
void onGridColMove(wxGridEvent &aEvent)
Definition: wx_grid.cpp:275
void onGridCellSelect(wxGridEvent &aEvent)
Definition: wx_grid.cpp:126

References m_weOwnTable, MIN_GRIDCELL_MARGIN, onGridCellSelect(), and onGridColMove().

Referenced by APPEARANCE_CONTROLS::APPEARANCE_CONTROLS(), DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(), DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE(), DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES(), DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES(), DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES(), DIALOG_SWAP_LAYERS::DIALOG_SWAP_LAYERS(), DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE(), DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES(), PANEL_FP_EDITOR_DEFAULTS::PANEL_FP_EDITOR_DEFAULTS(), PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE(), and PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE().

◆ ShowEditorOnMouseUp()

void WX_GRID::ShowEditorOnMouseUp ( )
inline

WxWidgets has a bunch of bugs in its handling of wxGrid mouse events which close cell editors right after opening them.

Helpfully, it already has a bunch of work-arounds in place (such as the SetInSetFocus() hack), including one to make slow clicks work. We re-purpose this hack to work-around the bugs when we want to open an editor.

Definition at line 102 of file wx_grid.h.

102 { m_waitForSlowClick = true; }

Referenced by GRID_TRICKS::showEditor().

◆ ShowHideColumns()

void WX_GRID::ShowHideColumns ( const wxString &  shownColumns)

Show/hide the grid columns based on a tokenized string of shown column indexes.

Definition at line 172 of file wx_grid.cpp.

173 {
174  for( int i = 0; i < GetNumberCols(); ++i )
175  HideCol( i );
176 
177  wxStringTokenizer shownTokens( shownColumns );
178 
179  while( shownTokens.HasMoreTokens() )
180  {
181  long colNumber;
182  shownTokens.GetNextToken().ToLong( &colNumber );
183 
184  if( colNumber >= 0 && colNumber < GetNumberCols() )
185  ShowCol( colNumber );
186  }
187 }

Referenced by DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(), DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE(), DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES(), DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES(), and DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES().

Member Data Documentation

◆ m_weOwnTable

bool WX_GRID::m_weOwnTable
protected

Definition at line 129 of file wx_grid.h.

Referenced by SetTable(), and ~WX_GRID().


The documentation for this class was generated from the following files: