KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wx_grid.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <wx/tokenzr.h>
25#include <wx/dc.h>
26#include <wx/settings.h>
27
28#include <widgets/wx_grid.h>
29#include <widgets/ui_common.h>
30#include <algorithm>
31#include <core/kicad_algo.h>
32#include <gal/color4d.h>
33
34#define MIN_GRIDCELL_MARGIN FromDIP( 3 )
35
36
38{
39 KIGFX::COLOR4D bg = wxSystemSettings::GetColour( wxSYS_COLOUR_FRAMEBK );
40 KIGFX::COLOR4D fg = wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER );
41 KIGFX::COLOR4D border = fg.Mix( bg, 0.50 );
42 return border.ToColour();
43}
44
45
46class WX_GRID_CORNER_HEADER_RENDERER : public wxGridCornerHeaderRendererDefault
47{
48public:
49 void DrawBorder( const wxGrid& grid, wxDC& dc, wxRect& rect ) const override
50 {
51 wxDCBrushChanger SetBrush( dc, *wxTRANSPARENT_BRUSH );
52 wxDCPenChanger SetPen( dc, wxPen( getBorderColour(), 1 ) );
53
54 rect.SetTop( rect.GetTop() + 1 );
55 rect.SetLeft( rect.GetLeft() + 1 );
56 rect.SetBottom( rect.GetBottom() - 1 );
57 rect.SetRight( rect.GetRight() - 1 );
58 dc.DrawRectangle( rect );
59 }
60};
61
62
63class WX_GRID_COLUMN_HEADER_RENDERER : public wxGridColumnHeaderRendererDefault
64{
65public:
66 void DrawBorder( const wxGrid& grid, wxDC& dc, wxRect& rect ) const override
67 {
68 wxDCBrushChanger SetBrush( dc, *wxTRANSPARENT_BRUSH );
69 wxDCPenChanger SetPen( dc, wxPen( getBorderColour(), 1 ) );
70
71 rect.SetTop( rect.GetTop() + 1 );
72 rect.SetLeft( rect.GetLeft() );
73 rect.SetBottom( rect.GetBottom() - 1 );
74 rect.SetRight( rect.GetRight() - 1 );
75 dc.DrawRectangle( rect );
76 }
77};
78
79
80class WX_GRID_ROW_HEADER_RENDERER : public wxGridRowHeaderRendererDefault
81{
82public:
83 void DrawBorder( const wxGrid& grid, wxDC& dc, wxRect& rect ) const override
84 {
85 wxDCBrushChanger SetBrush( dc, *wxTRANSPARENT_BRUSH );
86 wxDCPenChanger SetPen( dc, wxPen( getBorderColour(), 1 ) );
87
88 rect.SetTop( rect.GetTop() + 1 );
89 rect.SetLeft( rect.GetLeft() + 1 );
90 rect.SetBottom( rect.GetBottom() - 1 );
91 rect.SetRight( rect.GetRight() );
92 dc.DrawRectangle( rect );
93 }
94};
95
96
97WX_GRID::WX_GRID( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
98 long style, const wxString& name ) :
99 wxGrid( parent, id, pos, size, style, name ),
100 m_weOwnTable( false )
101{
102 SetDefaultCellOverflow( false );
103
104 // Make sure the GUI font scales properly
105 SetDefaultCellFont( KIUI::GetControlFont( this ) );
107
108 if( GetColLabelSize() > 0 )
109 SetColLabelSize( GetColLabelSize() + FromDIP( 4 ) );
110
111 Connect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this );
112 Connect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, this );
113 Connect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, this );
114}
115
116
118{
119 if( m_weOwnTable )
120 DestroyTable( GetTable() );
121
122 Disconnect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this );
123}
124
125
126void WX_GRID::onDPIChanged(wxDPIChangedEvent& aEvt)
127{
130#ifndef __WXMAC__
131 aEvt.Skip();
132#endif
133}
134
135
136void WX_GRID::SetColLabelSize( int aHeight )
137{
138 if( aHeight == 0 )
139 {
140 wxGrid::SetColLabelSize( 0 );
141 return;
142 }
143
144 // Correct wxFormBuilder height for large fonts
145 int minHeight = GetLabelFont().GetPixelSize().y + 2 * MIN_GRIDCELL_MARGIN;
146 wxGrid::SetColLabelSize( std::max( aHeight, minHeight ) );
147}
148
149
150void WX_GRID::SetLabelFont( const wxFont& aFont )
151{
152 wxGrid::SetLabelFont( KIUI::GetControlFont( this ) );
153}
154
155
156void WX_GRID::SetTable( wxGridTableBase* aTable, bool aTakeOwnership )
157{
158 // wxGrid::SetTable() messes up the column widths from wxFormBuilder so we have to save
159 // and restore them.
160 int numberCols = GetNumberCols();
161 int* formBuilderColWidths = new int[numberCols];
162
163 for( int i = 0; i < numberCols; ++i )
164 formBuilderColWidths[ i ] = GetColSize( i );
165
166 wxGrid::SetTable( aTable );
167
168 // wxGrid::SetTable() may change the number of columns, so prevent out-of-bounds access
169 // to formBuilderColWidths
170 numberCols = std::min( numberCols, GetNumberCols() );
171
172 for( int i = 0; i < numberCols; ++i )
173 {
174 // correct wxFormBuilder width for large fonts and/or long translations
175 int headingWidth = GetTextExtent( GetColLabelValue( i ) ).x + 2 * MIN_GRIDCELL_MARGIN;
176
177 SetColSize( i, std::max( formBuilderColWidths[ i ], headingWidth ) );
178 }
179
180 delete[] formBuilderColWidths;
181
182 Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
183 Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this );
184
185 m_weOwnTable = aTakeOwnership;
186}
187
188
189void WX_GRID::onGridCellSelect( wxGridEvent& aEvent )
190{
191 // Highlight the selected cell.
192 // Calling SelectBlock() allows a visual effect when cells are selected by tab or arrow keys.
193 // Otherwise, one cannot really know what actual cell is selected.
194 int row = aEvent.GetRow();
195 int col = aEvent.GetCol();
196
197 if( row >= 0 && row < GetNumberRows() && col >= 0 && col < GetNumberCols() )
198 {
199 if( GetSelectionMode() == wxGrid::wxGridSelectCells )
200 {
201 SelectBlock( row, col, row, col, false );
202 }
203 else if( GetSelectionMode() == wxGrid::wxGridSelectRows
204 || GetSelectionMode() == wxGrid::wxGridSelectRowsOrColumns )
205 {
206 SelectBlock( row, 0, row, GetNumberCols() - 1, false );
207 }
208 else if( GetSelectionMode() == wxGrid::wxGridSelectColumns )
209 {
210 SelectBlock( 0, col, GetNumberRows() - 1, col, false );
211 }
212 }
213}
214
215
216void WX_GRID::onCellEditorShown( wxGridEvent& aEvent )
217{
218 if( alg::contains( m_autoEvalCols, aEvent.GetCol() ) )
219 {
220 int row = aEvent.GetRow();
221 int col = aEvent.GetCol();
222
223 const std::pair<wxString, wxString>& beforeAfter = m_evalBeforeAfter[ { row, col } ];
224
225 if( GetCellValue( row, col ) == beforeAfter.second )
226 SetCellValue( row, col, beforeAfter.first );
227 }
228}
229
230
231void WX_GRID::onCellEditorHidden( wxGridEvent& aEvent )
232{
233 if( alg::contains( m_autoEvalCols, aEvent.GetCol() ) )
234 {
235 UNITS_PROVIDER* unitsProvider = m_unitsProviders[ aEvent.GetCol() ];
236
237 if( !unitsProvider )
238 unitsProvider = m_unitsProviders.begin()->second;
239
240 m_eval->SetDefaultUnits( unitsProvider->GetUserUnits() );
241
242 int row = aEvent.GetRow();
243 int col = aEvent.GetCol();
244
245 CallAfter(
246 [this, row, col, unitsProvider]()
247 {
248 wxString stringValue = GetCellValue( row, col );
249
250 if( m_eval->Process( stringValue ) )
251 {
252 int val = unitsProvider->ValueFromString( m_eval->Result() );
253 wxString evalValue = unitsProvider->StringFromValue( val, true );
254
255 if( stringValue != evalValue )
256 {
257 SetCellValue( row, col, evalValue );
258 m_evalBeforeAfter[ { row, col } ] = { stringValue, evalValue };
259 }
260 }
261 } );
262 }
263
264 aEvent.Skip();
265}
266
267
268void WX_GRID::DestroyTable( wxGridTableBase* aTable )
269{
270 // wxGrid's destructor will crash trying to look up the cell attr if the edit control
271 // is left open. Normally it's closed in Validate(), but not if the user hit Cancel.
272 CommitPendingChanges( true /* quiet mode */ );
273
274 Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
275 Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this );
276
277 wxGrid::SetTable( nullptr );
278 delete aTable;
279}
280
281
283{
284 wxString shownColumns;
285
286 for( int i = 0; i < GetNumberCols(); ++i )
287 {
288 if( IsColShown( i ) )
289 {
290 if( shownColumns.Length() )
291 shownColumns << wxT( " " );
292
293 shownColumns << i;
294 }
295 }
296
297 return shownColumns;
298}
299
300
302{
303 std::bitset<64> shownColumns;
304
305 for( int ii = 0; ii < GetNumberCols(); ++ii )
306 shownColumns[ii] = IsColShown( ii );
307
308 return shownColumns;
309}
310
311
312void WX_GRID::ShowHideColumns( const wxString& shownColumns )
313{
314 for( int i = 0; i < GetNumberCols(); ++i )
315 HideCol( i );
316
317 wxStringTokenizer shownTokens( shownColumns );
318
319 while( shownTokens.HasMoreTokens() )
320 {
321 long colNumber;
322 shownTokens.GetNextToken().ToLong( &colNumber );
323
324 if( colNumber >= 0 && colNumber < GetNumberCols() )
325 ShowCol( (int) colNumber );
326 }
327}
328
329
330void WX_GRID::ShowHideColumns( const std::bitset<64>& aShownColumns )
331{
332 for( int ii = 0; ii < GetNumberCols(); ++ ii )
333 {
334 if( aShownColumns[ii] )
335 ShowCol( ii );
336 else
337 HideCol( ii );
338 }
339}
340
341
343{
344 if( m_nativeColumnLabels )
345 wxGrid::DrawCornerLabel( dc );
346
347 wxRect rect( wxSize( m_rowLabelWidth, m_colLabelHeight ) );
348
350
351 // It is reported that we need to erase the background to avoid display
352 // artifacts, see #12055.
353 {
354 wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
355 wxDCPenChanger setPen( dc, m_colLabelWin->GetBackgroundColour() );
356 dc.DrawRectangle( rect.Inflate( 1 ) );
357 }
358
359 rend.DrawBorder( *this, dc, rect );
360}
361
362
363void WX_GRID::DrawColLabel( wxDC& dc, int col )
364{
365 if( m_nativeColumnLabels )
366 wxGrid::DrawColLabel( dc, col );
367
368 if( GetColWidth( col ) <= 0 || m_colLabelHeight <= 0 )
369 return;
370
371 wxRect rect( GetColLeft( col ), 0, GetColWidth( col ), m_colLabelHeight );
372
374
375 // It is reported that we need to erase the background to avoid display
376 // artifacts, see #12055.
377 {
378 wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
379 wxDCPenChanger setPen( dc, m_colLabelWin->GetBackgroundColour() );
380 dc.DrawRectangle( rect.Inflate( 1 ) );
381 }
382
383 rend.DrawBorder( *this, dc, rect );
384
385 // Make sure fonts get scaled correctly on GTK HiDPI monitors
386 dc.SetFont( GetLabelFont() );
387
388 int hAlign, vAlign;
389 GetColLabelAlignment( &hAlign, &vAlign );
390 const int orient = GetColLabelTextOrientation();
391
392 if( col == 0 )
393 hAlign = wxALIGN_LEFT;
394
395 if( hAlign == wxALIGN_LEFT )
396 rect.SetLeft( rect.GetLeft() + MIN_GRIDCELL_MARGIN );
397
398 rend.DrawLabel( *this, dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient );
399}
400
401
402void WX_GRID::DrawRowLabel( wxDC& dc, int row )
403{
404 if ( GetRowHeight( row ) <= 0 || m_rowLabelWidth <= 0 )
405 return;
406
407 wxRect rect( 0, GetRowTop( row ), m_rowLabelWidth, GetRowHeight( row ) );
408
409 static WX_GRID_ROW_HEADER_RENDERER rend;
410
411 // It is reported that we need to erase the background to avoid display
412 // artifacts, see #12055.
413 {
414 wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
415 wxDCPenChanger setPen( dc, m_colLabelWin->GetBackgroundColour() );
416 dc.DrawRectangle( rect.Inflate( 1 ) );
417 }
418
419 rend.DrawBorder( *this, dc, rect );
420
421 // Make sure fonts get scaled correctly on GTK HiDPI monitors
422 dc.SetFont( GetLabelFont() );
423
424 int hAlign, vAlign;
425 GetRowLabelAlignment(&hAlign, &vAlign);
426
427 if( hAlign == wxALIGN_LEFT )
428 rect.SetLeft( rect.GetLeft() + MIN_GRIDCELL_MARGIN );
429
430 rend.DrawLabel( *this, dc, GetRowLabelValue( row ), rect, hAlign, vAlign, wxHORIZONTAL );
431}
432
433
435{
436 if( !IsCellEditControlEnabled() )
437 return true;
438
439 HideCellEditControl();
440
441 // do it after HideCellEditControl()
442 m_cellEditCtrlEnabled = false;
443
444 int row = m_currentCellCoords.GetRow();
445 int col = m_currentCellCoords.GetCol();
446
447 wxString oldval = GetCellValue( row, col );
448 wxString newval;
449
450 wxGridCellAttr* attr = GetCellAttr( row, col );
451 wxGridCellEditor* editor = attr->GetEditor( this, row, col );
452
453 editor->EndEdit( row, col, this, oldval, &newval );
454
455 editor->DecRef();
456 attr->DecRef();
457
458 return true;
459}
460
461
462bool WX_GRID::CommitPendingChanges( bool aQuietMode )
463{
464 if( !IsCellEditControlEnabled() )
465 return true;
466
467 if( !aQuietMode && SendEvent( wxEVT_GRID_EDITOR_HIDDEN ) == -1 )
468 return false;
469
470 HideCellEditControl();
471
472 // do it after HideCellEditControl()
473 m_cellEditCtrlEnabled = false;
474
475 int row = m_currentCellCoords.GetRow();
476 int col = m_currentCellCoords.GetCol();
477
478 wxString oldval = GetCellValue( row, col );
479 wxString newval;
480
481 wxGridCellAttr* attr = GetCellAttr( row, col );
482 wxGridCellEditor* editor = attr->GetEditor( this, row, col );
483
484 bool changed = editor->EndEdit( row, col, this, oldval, &newval );
485
486 editor->DecRef();
487 attr->DecRef();
488
489 if( changed )
490 {
491 if( !aQuietMode && SendEvent( wxEVT_GRID_CELL_CHANGING, newval ) == -1 )
492 return false;
493
494 editor->ApplyEdit( row, col, this );
495
496 // for compatibility reasons dating back to wx 2.8 when this event
497 // was called wxEVT_GRID_CELL_CHANGE and wxEVT_GRID_CELL_CHANGING
498 // didn't exist we allow vetoing this one too
499 if( !aQuietMode && SendEvent( wxEVT_GRID_CELL_CHANGED, oldval ) == -1 )
500 {
501 // Event has been vetoed, set the data back.
502 SetCellValue( row, col, oldval );
503 return false;
504 }
505 }
506
507 return true;
508}
509
510
511void WX_GRID::SetUnitsProvider( UNITS_PROVIDER* aProvider, int aCol )
512{
513 m_unitsProviders[ aCol ] = aProvider;
514
515 if( !m_eval )
516 m_eval = std::make_unique<NUMERIC_EVALUATOR>( aProvider->GetUserUnits() );
517}
518
519
520int WX_GRID::GetUnitValue( int aRow, int aCol )
521{
522 UNITS_PROVIDER* unitsProvider = m_unitsProviders[ aCol ];
523
524 if( !unitsProvider )
525 unitsProvider = m_unitsProviders.begin()->second;
526
527 wxString stringValue = GetCellValue( aRow, aCol );
528
529 if( alg::contains( m_autoEvalCols, aCol ) )
530 {
531 m_eval->SetDefaultUnits( unitsProvider->GetUserUnits() );
532
533 if( m_eval->Process( stringValue ) )
534 stringValue = m_eval->Result();
535 }
536
537 return unitsProvider->ValueFromString( stringValue );
538}
539
540
541void WX_GRID::SetUnitValue( int aRow, int aCol, int aValue )
542{
543 UNITS_PROVIDER* unitsProvider = m_unitsProviders[ aCol ];
544
545 if( !unitsProvider )
546 unitsProvider = m_unitsProviders.begin()->second;
547
548 SetCellValue( aRow, aCol, unitsProvider->StringFromValue( aValue, true ) );
549}
550
551
552void WX_GRID::onGridColMove( wxGridEvent& aEvent )
553{
554 // wxWidgets won't move an open editor, so better just to close it
555 CommitPendingChanges( true );
556}
557
558
559int WX_GRID::GetVisibleWidth( int aCol, bool aHeader, bool aContents, bool aKeep )
560{
561 int size = 0;
562
563 if( aCol < 0 )
564 {
565 if( aKeep )
566 size = GetRowLabelSize();
567
568 for( int row = 0; aContents && row < GetNumberRows(); row++ )
569 size = std::max( size, int( GetTextExtent( GetRowLabelValue( row ) + wxS( "M" ) ).x ) );
570 }
571 else
572 {
573 if( aKeep )
574 size = GetColSize( aCol );
575
576 // 'M' is generally the widest character, so we buffer the column width by default to
577 // ensure we don't write a continuous line of text at the column header
578 if( aHeader )
579 {
581
582 size = std::max( size, int( GetTextExtent( GetColLabelValue( aCol ) + wxS( "M" ) ).x ) );
583 }
584
585 for( int row = 0; aContents && row < GetNumberRows(); row++ )
586 {
587 // If we have text, get the size. Otherwise, use a placeholder for the checkbox
588 if( GetTable()->CanGetValueAs( row, aCol, wxGRID_VALUE_STRING ) )
589 size = std::max( size, GetTextExtent( GetCellValue( row, aCol ) + wxS( "M" ) ).x );
590 else
591 size = std::max( size, GetTextExtent( "MM" ).x );
592 }
593 }
594
595 return size;
596}
597
598
600{
601 int line_height = int( GetTextExtent( "Mj" ).y ) + 3;
602 int row_height = GetColLabelSize();
603 int initial_row_height = row_height;
604
605 // Headers can be multiline. Fix the Column Label Height to show the full header
606 // However GetTextExtent does not work on multiline strings,
607 // and do not return the full text height (only the height of one line)
608 for( int col = 0; col < GetNumberCols(); col++ )
609 {
610 int nl_count = GetColLabelValue( col ).Freq( '\n' );
611
612 if( nl_count )
613 {
614 // Col Label height must be able to show nl_count+1 lines
615 if( row_height < line_height * ( nl_count+1 ) )
616 row_height += line_height * nl_count;
617 }
618 }
619
620 // Update the column label size, but only if needed, to avoid generating useless
621 // and perhaps annoying UI events when the size does not change
622 if( initial_row_height != row_height )
623 SetColLabelSize( row_height );
624}
const char * name
Definition: DXF_plotter.cpp:57
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
wxColour ToColour() const
Definition: color4d.cpp:220
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition: color4d.h:295
EDA_UNITS GetUserUnits() const
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aValue in internal units into a united string.
int ValueFromString(const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aTextValue in aUnits to internal units used by the frame.
void DrawBorder(const wxGrid &grid, wxDC &dc, wxRect &rect) const override
Definition: wx_grid.cpp:66
void DrawBorder(const wxGrid &grid, wxDC &dc, wxRect &rect) const override
Definition: wx_grid.cpp:49
void DrawBorder(const wxGrid &grid, wxDC &dc, wxRect &rect) const override
Definition: wx_grid.cpp:83
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculates the specified column based on the actual size of the text on screen.
Definition: wx_grid.cpp:559
void onGridCellSelect(wxGridEvent &aEvent)
Definition: wx_grid.cpp:189
~WX_GRID() override
Definition: wx_grid.cpp:117
void SetLabelFont(const wxFont &aFont)
Hide wxGrid's SetLabelFont() because for some reason on MSW it's a one-shot and subsequent calls to i...
Definition: wx_grid.cpp:150
bool m_weOwnTable
Definition: wx_grid.h:178
void onDPIChanged(wxDPIChangedEvent &event)
Definition: wx_grid.cpp:126
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:312
std::map< int, UNITS_PROVIDER * > m_unitsProviders
Definition: wx_grid.h:180
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 th...
Definition: wx_grid.cpp:156
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:268
bool CancelPendingChanges()
Definition: wx_grid.cpp:434
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:136
void SetUnitValue(int aRow, int aCol, int aValue)
Set a unitized cell's value.
Definition: wx_grid.cpp:541
WX_GRID(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS, const wxString &name=wxGridNameStr)
Definition: wx_grid.cpp:97
int GetUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
Definition: wx_grid.cpp:520
std::vector< int > m_autoEvalCols
Definition: wx_grid.h:182
std::map< std::pair< int, int >, std::pair< wxString, wxString > > m_evalBeforeAfter
Definition: wx_grid.h:184
void DrawCornerLabel(wxDC &dc) override
A re-implementation of wxGrid::DrawCornerLabel which draws flat borders.
Definition: wx_grid.cpp:342
void onCellEditorHidden(wxGridEvent &aEvent)
Definition: wx_grid.cpp:231
void onGridColMove(wxGridEvent &aEvent)
Definition: wx_grid.cpp:552
void onCellEditorShown(wxGridEvent &aEvent)
Definition: wx_grid.cpp:216
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
Definition: wx_grid.cpp:599
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:282
void DrawRowLabel(wxDC &dc, int row) override
A re-implementation of wxGrid::DrawRowLabel which draws flat borders.
Definition: wx_grid.cpp:402
std::bitset< 64 > GetShownColumns()
Definition: wx_grid.cpp:301
void SetUnitsProvider(UNITS_PROVIDER *aProvider, int aCol=0)
Set a UNITS_PROVIDER to enable use of unit- and eval-based Getters.
Definition: wx_grid.cpp:511
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:462
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
Definition: wx_grid.h:181
void DrawColLabel(wxDC &dc, int col) override
A re-implementation of wxGrid::DrawColLabel which left-aligns the first column and draws flat borders...
Definition: wx_grid.cpp:363
wxFont GetControlFont(wxWindow *aWindow)
Definition: ui_common.cpp:157
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:100
Functions to provide common constants and other functions to assist in making a consistent UI.
wxColour getBorderColour()
Definition: wx_grid.cpp:37
#define MIN_GRIDCELL_MARGIN
Definition: wx_grid.cpp:34