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...
 

Protected Member Functions

void DrawColLabel (wxDC &dc, int col) override
 
void onGridColMove (wxGridEvent &aEvent)
 

Protected Attributes

bool m_weOwnTable
 

Detailed Description

Definition at line 29 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 33 of file wx_grid.cpp.

34  :
35  wxGrid( parent, id, pos, size, style, name ),
36  m_weOwnTable( false )
37 {}
bool m_weOwnTable
Definition: wx_grid.h:106
const char * name
Definition: DXF_plotter.cpp:61

◆ ~WX_GRID()

WX_GRID::~WX_GRID ( )
override

Definition at line 40 of file wx_grid.cpp.

41 {
42  if( m_weOwnTable )
43  DestroyTable( GetTable() );
44 }
bool m_weOwnTable
Definition: wx_grid.h:106
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:88

References DestroyTable(), and m_weOwnTable.

Member Function Documentation

◆ 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 167 of file wx_grid.cpp.

168 {
169  if( !IsCellEditControlEnabled() )
170  return true;
171 
172  if( !aQuietMode && SendEvent( wxEVT_GRID_EDITOR_HIDDEN ) == -1 )
173  return false;
174 
175  HideCellEditControl();
176 
177  // do it after HideCellEditControl()
178  m_cellEditCtrlEnabled = false;
179 
180  int row = m_currentCellCoords.GetRow();
181  int col = m_currentCellCoords.GetCol();
182 
183  wxString oldval = GetCellValue( row, col );
184  wxString newval;
185 
186  wxGridCellAttr* attr = GetCellAttr( row, col );
187  wxGridCellEditor* editor = attr->GetEditor( this, row, col );
188 
189  bool changed = editor->EndEdit( row, col, this, oldval, &newval );
190 
191  editor->DecRef();
192  attr->DecRef();
193 
194  if( changed )
195  {
196  if( !aQuietMode && SendEvent(wxEVT_GRID_CELL_CHANGING, newval) == -1 )
197  return false;
198 
199  editor->ApplyEdit(row, col, this);
200 
201  // for compatibility reasons dating back to wx 2.8 when this event
202  // was called wxEVT_GRID_CELL_CHANGE and wxEVT_GRID_CELL_CHANGING
203  // didn't exist we allow vetoing this one too
204  if( !aQuietMode && SendEvent( wxEVT_GRID_CELL_CHANGED, oldval ) == -1 )
205  {
206  // Event has been vetoed, set the data back.
207  SetCellValue( row, col, oldval );
208  return false;
209  }
210  }
211 
212  return true;
213 }

Referenced by PANEL_SYM_LIB_TABLE::appendRowHandler(), PANEL_FP_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(), DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DRow(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DRow(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnAddAlias(), PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnAddButtonClick(), DIALOG_CONFIGURE_PATHS::OnAddEnvVar(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnAddField(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnAddField(), DIALOG_FOOTPRINT_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAddField(), PANEL_SETUP_NETCLASSES::OnAddNetclassClick(), DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow(), DIALOG_CONFIGURE_PATHS::OnAddSearchPath(), DIALOG_FP_PLUGIN_OPTIONS::onAppendOption(), DIALOG_FP_PLUGIN_OPTIONS::onAppendRow(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonAdd(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::OnButtonDelete(), DIALOG_LIB_EDIT_PIN_TABLE::OnClose(), DIALOG_FIELDS_EDITOR_GLOBAL::OnClose(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnDeleteAlias(), PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnDeleteButtonClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnDeleteField(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnDeleteField(), DIALOG_FOOTPRINT_FP_EDITOR::OnDeleteField(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnDeleteField(), DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow(), DIALOG_FP_PLUGIN_OPTIONS::onDeleteRow(), DIALOG_CONFIGURE_PATHS::OnDeleteSearchPath(), onGridColMove(), GRID_TRICKS::onGridLabelLeftClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnMoveDown(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnMoveDown(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnMoveUp(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnMoveUp(), DIALOG_LIB_EDIT_PIN_TABLE::OnRebuildRows(), DIALOG_FOOTPRINT_FP_EDITOR::OnRemove3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnRemove3DModel(), DIALOG_CONFIGURE_PATHS::OnRemoveEnvVar(), PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick(), DIALOG_CONFIGURE_PATHS::OnSearchPathMoveDown(), DIALOG_CONFIGURE_PATHS::OnSearchPathMoveUp(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnSelectAlias(), PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns(), PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromGrid(), DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataFromWindow(), DIALOG_CONFIGURE_PATHS::TransferDataFromWindow(), PANEL_FP_LIB_TABLE::TransferDataFromWindow(), DIALOG_LIB_EDIT_PIN_TABLE::TransferDataFromWindow(), PANEL_SYM_LIB_TABLE::TransferDataFromWindow(), PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow(), DIALOG_SWAP_LAYERS::TransferDataFromWindow(), DIALOG_FP_PLUGIN_OPTIONS::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::Validate(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::Validate(), DIALOG_FOOTPRINT_FP_EDITOR::Validate(), DIALOG_FOOTPRINT_BOARD_EDITOR::Validate(), PANEL_MODEDIT_DEFAULTS::validateData(), PANEL_SETUP_TEXT_AND_GRAPHICS::validateData(), PANEL_SETUP_TRACKS_AND_VIAS::validateData(), PANEL_SETUP_NETCLASSES::validateData(), and DIALOG_EDIT_COMPONENTS_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 88 of file wx_grid.cpp.

89 {
90  // wxGrid's destructor will crash trying to look up the cell attr if the edit control
91  // is left open. Normally it's closed in Validate(), but not if the user hit Cancel.
92  CommitPendingChanges( true /* quiet mode */ );
93 
94  Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), NULL, this );
95 
96  wxGrid::SetTable( nullptr );
97  delete aTable;
98 }
void onGridColMove(wxGridEvent &aEvent)
Definition: wx_grid.cpp:216
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:167

References CommitPendingChanges(), and onGridColMove().

Referenced by DIALOG_EDIT_COMPONENT_IN_LIBRARY::~DIALOG_EDIT_COMPONENT_IN_LIBRARY(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC(), DIALOG_FOOTPRINT_BOARD_EDITOR::~DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::~DIALOG_FOOTPRINT_FP_EDITOR(), DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE(), DIALOG_SWAP_LAYERS::~DIALOG_SWAP_LAYERS(), and ~WX_GRID().

◆ DrawColLabel()

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

Definition at line 139 of file wx_grid.cpp.

140 {
141  if( GetColWidth( col ) <= 0 || m_colLabelHeight <= 0 )
142  return;
143 
144  int colLeft = GetColLeft( col );
145 
146  wxRect rect( colLeft, 0, GetColWidth( col ), m_colLabelHeight );
147  static wxGridColumnHeaderRendererDefault rend;
148 
149  // It is reported that we need to erase the background to avoid display
150  // artefacts, see #12055.
151  wxDCBrushChanger setBrush( dc, m_colWindow->GetBackgroundColour() );
152  dc.DrawRectangle(rect);
153 
154  rend.DrawBorder( *this, dc, rect );
155 
156  int hAlign, vAlign;
157  GetColLabelAlignment( &hAlign, &vAlign );
158  const int orient = GetColLabelTextOrientation();
159 
160  if( col == 0 && GetRowLabelSize() == 0 )
161  hAlign = wxALIGN_LEFT;
162 
163  rend.DrawLabel( *this, dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient );
164 }

◆ 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 265 of file wx_grid.cpp.

266 {
267  int row_height = GetColLabelSize();
268  // The 1.1 scale factor is due to the fact row labels use a bold font, bigger than the normal font
269  // TODO: use a better way to evaluate the text size, for bold font
270  // Headers can be multiline. Fix the Column Label Height to show the full header
271  // However GetTextExtent does not work on multiline strings,
272  // and do not return the full text height (only the height of one line)
273  for( int col = 0; col < GetNumberCols(); col++ )
274  {
275  int nl_count = 0;
276 
277  for( unsigned ii = 0; ii < GetColLabelValue( col ).size(); ii++ )
278  if( GetColLabelValue( col )[ii] == '\n' )
279  nl_count++;
280 
281  if( nl_count )
282  {
283  // calculate a reasonable text height and its margin
284  int heigth = int( GetTextExtent( "Mj" ).y * 1.1 ) + 3;
285 
286  // Col Label height must be able to show nl_count+1 lines
287  if( row_height < heigth * (nl_count+1) )
288  row_height += heigth*nl_count;
289  }
290  }
291 
292  SetColLabelSize( row_height );
293 }
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:47

References SetColLabelSize().

Referenced by 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 101 of file wx_grid.cpp.

102 {
103  wxString shownColumns;
104 
105  for( int i = 0; i < GetNumberCols(); ++i )
106  {
107  if( IsColShown( i ) )
108  {
109  if( shownColumns.Length() )
110  shownColumns << wxT( " " );
111  shownColumns << i;
112  }
113  }
114 
115  return shownColumns;
116 }
size_t i
Definition: json11.cpp:597

References i.

Referenced by DIALOG_LIB_EDIT_PIN_TABLE::OnUpdateUI(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnUpdateUI(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnUpdateUI(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::~DIALOG_EDIT_COMPONENT_IN_LIBRARY(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC(), DIALOG_FOOTPRINT_BOARD_EDITOR::~DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::~DIALOG_FOOTPRINT_FP_EDITOR(), and DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE().

◆ 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 223 of file wx_grid.cpp.

224 {
225  int size = 0;
226 
227  if( aCol < 0 )
228  {
229  if( aKeep )
230  size = GetRowLabelSize();
231 
232  // The 1.1 scale factor is due to the fact row labels use a bold font, bigger than the normal font
233  // TODO: use a better way to evaluate the text size, for bold font
234  for( int row = 0; aContents && row < GetNumberRows(); row++ )
235  size = std::max( size, int( GetTextExtent( GetRowLabelValue( row ) + "M" ).x * 1.1 ) );
236  }
237  else
238  {
239  if( aKeep )
240  size = GetColSize( aCol );
241 
242  // 'M' is generally the widest character, so we buffer the column width by default to ensure
243  // we don't write a continuous line of text at the column header
244  if( aHeader )
245  {
247  // The 1.1 scale factor is due to the fact headers use a bold font, bigger than the normal font
248  size = std::max( size, int( GetTextExtent( GetColLabelValue( aCol ) + "M" ).x * 1.1 ) );
249  }
250 
251  for( int row = 0; aContents && row < GetNumberRows(); row++ )
252  {
253  // If we have text, get the size. Otherwise, use a placeholder for the checkbox
254  if( GetTable()->CanGetValueAs( row, aCol, wxGRID_VALUE_STRING ) )
255  size = std::max( size, GetTextExtent( GetCellValue( row, aCol ) + "M" ).x );
256  else
257  size = std::max( size, GetTextExtent( "MM" ).x );
258  }
259  }
260 
261  return size;
262 }
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
Definition: wx_grid.cpp:265
#define max(a, b)
Definition: auxiliary.h:86

References EnsureColLabelsVisible(), and max.

Referenced by DIALOG_FOOTPRINT_FP_EDITOR::adjustGridColumns(), DIALOG_FOOTPRINT_BOARD_EDITOR::adjustGridColumns(), PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES(), PANEL_PCBNEW_ACTION_PLUGINS::TransferDataToWindow(), PANEL_MODEDIT_DEFAULTS::TransferDataToWindow(), PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow(), DIALOG_FOOTPRINT_FP_EDITOR::TransferDataToWindow(), and DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow().

◆ onGridColMove()

void WX_GRID::onGridColMove ( wxGridEvent &  aEvent)
protected

Definition at line 216 of file wx_grid.cpp.

217 {
218  // wxWidgets won't move an open editor, so better just to close it
219  CommitPendingChanges( true );
220 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:167

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 47 of file wx_grid.cpp.

48 {
49  // correct wxFormBuilder height for large fonts
50  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
51  int minHeight = guiFont.GetPixelSize().y + 2 * MIN_GRIDCELL_MARGIN;
52 
53  wxGrid::SetColLabelSize( std::max( aHeight, minHeight ) );
54 }
#define MIN_GRIDCELL_MARGIN
Definition: wx_grid.cpp:30
#define max(a, b)
Definition: auxiliary.h:86

References max, and MIN_GRIDCELL_MARGIN.

Referenced by DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_BASE(), DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE(), DIALOG_EDIT_COMPONENTS_LIBID_BASE::DIALOG_EDIT_COMPONENTS_LIBID_BASE(), DIALOG_FIELDS_EDITOR_GLOBAL_BASE::DIALOG_FIELDS_EDITOR_GLOBAL_BASE(), DIALOG_FOOTPRINT_BOARD_EDITOR_BASE::DIALOG_FOOTPRINT_BOARD_EDITOR_BASE(), DIALOG_FOOTPRINT_FP_EDITOR_BASE::DIALOG_FOOTPRINT_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_PAD_PRIMITIVE_POLY_PROPS_BASE::DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE(), DIALOG_SWAP_LAYERS_BASE::DIALOG_SWAP_LAYERS_BASE(), EnsureColLabelsVisible(), FOOTPRINT_WIZARD_FRAME::initParameterGrid(), PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE(), PANEL_FP_LIB_TABLE_BASE::PANEL_FP_LIB_TABLE_BASE(), PANEL_MODEDIT_DEFAULTS_BASE::PANEL_MODEDIT_DEFAULTS_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(), and PANEL_SYM_LIB_TABLE_BASE::PANEL_SYM_LIB_TABLE_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 57 of file wx_grid.cpp.

58 {
59  // wxGrid::SetTable() messes up the column widths from wxFormBuilder so we have to save
60  // and restore them.
61  int numberCols = GetNumberCols();
62  int* formBuilderColWidths = new int[numberCols];
63 
64  for( int i = 0; i < numberCols; ++i )
65  formBuilderColWidths[ i ] = GetColSize( i );
66 
67  wxGrid::SetTable( aTable );
68  // wxGrid::SetTable() may change the number of columns, so prevent out-of-bounds access
69  // to formBuilderColWidths
70  numberCols = std::min( numberCols, GetNumberCols() );
71 
72  for( int i = 0; i < numberCols; ++i )
73  {
74  // correct wxFormBuilder width for large fonts and/or long translations
75  int headingWidth = GetTextExtent( GetColLabelValue( i ) ).x + 2 * MIN_GRIDCELL_MARGIN;
76 
77  SetColSize( i, std::max( formBuilderColWidths[ i ], headingWidth ) );
78  }
79 
80  delete[] formBuilderColWidths;
81 
82  Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), NULL, this );
83 
84  m_weOwnTable = aTakeOwnership;
85 }
bool m_weOwnTable
Definition: wx_grid.h:106
#define MIN_GRIDCELL_MARGIN
Definition: wx_grid.cpp:30
void onGridColMove(wxGridEvent &aEvent)
Definition: wx_grid.cpp:216
#define max(a, b)
Definition: auxiliary.h:86
size_t i
Definition: json11.cpp:597
#define min(a, b)
Definition: auxiliary.h:85

References i, m_weOwnTable, max, min, MIN_GRIDCELL_MARGIN, and onGridColMove().

Referenced by DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC(), DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL(), DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR(), DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE(), DIALOG_SWAP_LAYERS::DIALOG_SWAP_LAYERS(), 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 99 of file wx_grid.h.

99 { 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 119 of file wx_grid.cpp.

120 {
121  for( int i = 0; i < GetNumberCols(); ++i )
122  HideCol( i );
123 
124  wxStringTokenizer shownTokens( shownColumns );
125 
126  while( shownTokens.HasMoreTokens() )
127  {
128  long colNumber;
129  shownTokens.GetNextToken().ToLong( &colNumber );
130 
131  if( colNumber >= 0 && colNumber < GetNumberCols() )
132  ShowCol( colNumber );
133  }
134 }
size_t i
Definition: json11.cpp:597

References i.

Referenced by DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC(), DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR(), and DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE().

Member Data Documentation

◆ m_weOwnTable

bool WX_GRID::m_weOwnTable
protected

Definition at line 106 of file wx_grid.h.

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


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