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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <wx/colour.h>
21#include <wx/tokenzr.h>
22#include <wx/dc.h>
23#include <wx/settings.h>
24#include <wx/event.h> // Needed for textentry.h on MSW
25#include <wx/textentry.h>
26
29#include <widgets/wx_grid.h>
30#include <widgets/ui_common.h>
31#include <algorithm>
32#include <vector>
33#include <core/kicad_algo.h>
34#include <gal/color4d.h>
35#include <kiplatform/ui.h>
36#include <utility>
37
38#include <pgm_base.h>
40#include <dialog_shim.h>
41
42
43wxGridCellAttr* WX_GRID_TABLE_BASE::enhanceAttr( wxGridCellAttr* aInputAttr, int aRow, int aCol,
44 wxGridCellAttr::wxAttrKind aKind )
45{
46 wxGridCellAttr* attr = aInputAttr;
47
48 if( wxGridCellAttrProvider* provider = GetAttrProvider() )
49 {
50 wxGridCellAttr* providerAttr = provider->GetAttr( aRow, aCol, aKind );
51
52 if( providerAttr )
53 {
54 attr = new wxGridCellAttr;
55 attr->SetKind( wxGridCellAttr::Merged );
56
57 if( aInputAttr )
58 {
59 attr->MergeWith( aInputAttr );
60 aInputAttr->DecRef();
61 }
62
63 attr->MergeWith( providerAttr );
64 providerAttr->DecRef();
65 }
66 }
67
68 return attr;
69}
70
71
72#define MIN_GRIDCELL_MARGIN FromDIP( 2 )
73
74
75void WX_GRID::CellEditorSetMargins( wxTextEntryBase* aEntry )
76{
77 // This is consistent with wxGridCellTextEditor. But works differently across platforms of course.
78 aEntry->SetMargins( 0, 0 );
79}
80
81
83{
84#if defined( __WXMSW__ ) || defined( __WXGTK__ )
85 aRect.Deflate( 2 );
86#endif
87}
88
89
90int WX_GRID::CapHeightToVisibleRows( int aMinHeight, int aHeaderHeight,
91 const std::vector<int>& aRowHeights, int aMaxRows )
92{
93 if( aMaxRows < 0 )
94 return aMinHeight;
95
96 int rowsHeight = aHeaderHeight;
97 int count = std::min( aMaxRows, (int) aRowHeights.size() );
98
99 for( int row = 0; row < count; ++row )
100 rowsHeight += aRowHeights[row];
101
102 return std::min( aMinHeight, rowsHeight );
103}
104
105
106void WX_GRID::SetMinVisibleRows( wxWindow* aDialog, int aMinRows )
107{
108 aDialog->Layout();
109
110 std::vector<int> rowHeights;
111 rowHeights.reserve( GetNumberRows() );
112
113 int allRowsHeight = GetColLabelSize();
114
115 for( int row = 0; row < GetNumberRows(); ++row )
116 {
117 rowHeights.push_back( GetRowSize( row ) );
118 allRowsHeight += rowHeights.back();
119 }
120
121 // Floor the grid at a few rows, then re-derive the dialog's minimum so it can be shrunk down to
122 // that floor with the grid scrolling past it.
123 SetMinSize( wxSize( GetMinSize().x, CapHeightToVisibleRows( allRowsHeight, GetColLabelSize(),
124 rowHeights, aMinRows ) ) );
125
126 aDialog->SetMinSize( wxDefaultSize );
127 aDialog->InvalidateBestSize();
128 aDialog->SetMinSize( aDialog->GetBestSize() );
129
130 // Open tall enough to show every row; Show() clamps the result to the monitor work area.
131 int grow = allRowsHeight - GetSize().y;
132
133 if( grow > 0 )
134 aDialog->SetSize( aDialog->GetSize().x, aDialog->GetSize().y + grow );
135}
136
137
139{
140 KIGFX::COLOR4D bg = wxSystemSettings::GetColour( wxSYS_COLOUR_FRAMEBK );
141 KIGFX::COLOR4D fg = wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER );
142 KIGFX::COLOR4D border = fg.Mix( bg, 0.50 );
143 return border.ToColour();
144}
145
146
147class WX_GRID_CORNER_HEADER_RENDERER : public wxGridCornerHeaderRendererDefault
148{
149public:
150 void DrawBorder( const wxGrid& grid, wxDC& dc, wxRect& rect ) const override
151 {
152 wxDCBrushChanger SetBrush( dc, *wxTRANSPARENT_BRUSH );
153 wxDCPenChanger SetPen( dc, wxPen( getBorderColour(), 1 ) );
154
155 rect.SetTop( rect.GetTop() + 1 );
156 rect.SetLeft( rect.GetLeft() + 1 );
157 rect.SetBottom( rect.GetBottom() - 1 );
158 rect.SetRight( rect.GetRight() - 1 );
159 dc.DrawRectangle( rect );
160 }
161};
162
163
164class WX_GRID_COLUMN_HEADER_RENDERER : public wxGridColumnHeaderRendererDefault
165{
166public:
167 void DrawBorder( const wxGrid& grid, wxDC& dc, wxRect& rect ) const override
168 {
169 wxDCBrushChanger SetBrush( dc, *wxTRANSPARENT_BRUSH );
170 wxDCPenChanger SetPen( dc, wxPen( getBorderColour(), 1 ) );
171
172 rect.SetTop( rect.GetTop() + 1 );
173 rect.SetLeft( rect.GetLeft() );
174 rect.SetBottom( rect.GetBottom() - 1 );
175 rect.SetRight( rect.GetRight() - 1 );
176 dc.DrawRectangle( rect );
177 }
178};
179
180
181class WX_GRID_ROW_HEADER_RENDERER : public wxGridRowHeaderRendererDefault
182{
183public:
184 void DrawBorder( const wxGrid& grid, wxDC& dc, wxRect& rect ) const override
185 {
186 wxDCBrushChanger SetBrush( dc, *wxTRANSPARENT_BRUSH );
187 wxDCPenChanger SetPen( dc, wxPen( getBorderColour(), 1 ) );
188
189 rect.SetTop( rect.GetTop() + 1 );
190 rect.SetLeft( rect.GetLeft() + 1 );
191 rect.SetBottom( rect.GetBottom() - 1 );
192 rect.SetRight( rect.GetRight() );
193 dc.DrawRectangle( rect );
194 }
195};
196
197
202class WX_GRID_ALT_ROW_COLOR_PROVIDER : public wxGridCellAttrProvider
203{
204public:
205 WX_GRID_ALT_ROW_COLOR_PROVIDER( const wxColor& aBaseColor ) :
206 wxGridCellAttrProvider(),
207 m_attrEven( new wxGridCellAttr() )
208 {
209 UpdateColors( aBaseColor );
210 }
211
212 void UpdateColors( const wxColor& aBaseColor )
213 {
214 // Choose the default color, taking into account if the dark mode theme is enabled
215 wxColor rowColor = aBaseColor.ChangeLightness( KIPLATFORM::UI::IsDarkTheme() ? 105 : 95 );
216
217 m_attrEven->SetBackgroundColour( rowColor );
218 }
219
220 wxGridCellAttr* GetAttr( int row, int col, wxGridCellAttr::wxAttrKind kind ) const override
221 {
222 wxGridCellAttrPtr cellAttr( wxGridCellAttrProvider::GetAttr( row, col, kind ) );
223
224 // Just pass through the cell attribute on odd rows (start normal to allow for the
225 // header row)
226 if( !( row % 2 ) )
227 return cellAttr.release();
228
229 if( !cellAttr )
230 {
231 cellAttr = m_attrEven;
232 }
233 else
234 {
235 if( !cellAttr->HasBackgroundColour() )
236 {
237 cellAttr = cellAttr->Clone();
238 cellAttr->SetBackgroundColour( m_attrEven->GetBackgroundColour() );
239 }
240 }
241
242 return cellAttr.release();
243 }
244
245private:
246 wxGridCellAttrPtr m_attrEven;
247};
248
249
250WX_GRID::WX_GRID( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style,
251 const wxString& name ) :
252 wxGrid( parent, id, pos, size, style, name ),
253 m_weOwnTable( false )
254{
255 // Grids with comboboxes need a bit of extra height; other grids look better if they're consistent.
256 SetDefaultRowSize( GetDefaultRowSize() + FromDIP( 4 ) );
257
258 SetDefaultCellOverflow( false );
259
260 // Make sure the GUI font scales properly
261 SetDefaultCellFont( KIUI::GetControlFont( this ) );
263
265
266 Connect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this );
267 Connect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, this );
268 Connect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, this );
269}
270
271
273{
274 if( m_weOwnTable )
275 DestroyTable( GetTable() );
276
277 delete m_rowIconProvider;
278
279 Disconnect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, this );
280 Disconnect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, this );
281 Disconnect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this );
282}
283
284
285void WX_GRID::onDPIChanged(wxDPIChangedEvent& aEvt)
286{
287 // Workaround for wxWidgets bug where hidden column widths (stored as negative values)
288 // are not scaled during DPI changes, corrupting the internal m_colRights array.
289 // https://github.com/wxWidgets/wxWidgets/issues/26079
290 // Fix is to re-hide all hidden columns after the DPI change completes, which forces
291 // wxGrid to recalculate the column geometry correctly.
292
293 std::vector<int> hiddenCols;
294
295 for( int col = 0; col < GetNumberCols(); ++col )
296 {
297 if( !IsColShown( col ) )
298 hiddenCols.push_back( col );
299 }
300
301 aEvt.Skip();
302
303 if( !hiddenCols.empty() )
304 {
305 CallAfter(
306 [this, hiddenCols]()
307 {
308 for( int col : hiddenCols )
309 {
310 ShowCol( col );
311 HideCol( col );
312 }
313
314 ForceRefresh();
315 } );
316 }
317
318 CallAfter(
319 [this]()
320 {
321 wxGrid::SetColLabelSize( wxGRID_AUTOSIZE );
322 } );
323}
324
325
326void WX_GRID::SetColLabelSize( int aHeight )
327{
328 if( aHeight == 0 || aHeight == wxGRID_AUTOSIZE )
329 {
330 wxGrid::SetColLabelSize( aHeight );
331 return;
332 }
333
334 // Correct wxFormBuilder height for large fonts
335 int minHeight = GetCharHeight() + 2 * MIN_GRIDCELL_MARGIN;
336
337 wxGrid::SetColLabelSize( std::max( aHeight, minHeight ) );
338}
339
340
341void WX_GRID::SetLabelFont( const wxFont& aFont )
342{
343 wxGrid::SetLabelFont( KIUI::GetControlFont( this ) );
344}
345
346
347void WX_GRID::SetTable( wxGridTableBase* aTable, bool aTakeOwnership )
348{
349 // wxGrid::SetTable() messes up the column widths from wxFormBuilder so we have to save
350 // and restore them.
351 int numberCols = GetNumberCols();
352 int* formBuilderColWidths = new int[numberCols];
353
354 for( int i = 0; i < numberCols; ++i )
355 formBuilderColWidths[ i ] = GetColSize( i );
356
357 wxGrid::SetTable( aTable );
358
359 // wxGrid::SetTable() may change the number of columns, so prevent out-of-bounds access
360 // to formBuilderColWidths
361 numberCols = std::min( numberCols, GetNumberCols() );
362
363 for( int i = 0; i < numberCols; ++i )
364 {
365 // correct wxFormBuilder width for large fonts and/or long translations
366 int headingWidth = GetTextExtent( GetColLabelValue( i ) ).x + 2 * MIN_GRIDCELL_MARGIN;
367
368 SetColSize( i, std::max( formBuilderColWidths[ i ], headingWidth ) );
369 }
370
371 delete[] formBuilderColWidths;
372
373 EnableAlternateRowColors( Pgm().GetCommonSettings() && Pgm().GetCommonSettings()->m_Appearance.grid_striping );
374
375 Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
376 Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this );
377
378 m_weOwnTable = aTakeOwnership;
379}
380
381
383{
384 wxGridTableBase* table = wxGrid::GetTable();
385
386 wxCHECK_MSG( table, /* void */, "Tried to enable alternate row colors without a table assigned to the grid" );
387
388 if( aEnable )
389 {
390 wxColor color = wxGrid::GetDefaultCellBackgroundColour();
391 table->SetAttrProvider( new WX_GRID_ALT_ROW_COLOR_PROVIDER( color ) );
392 }
393 else
394 {
395 table->SetAttrProvider( nullptr );
396 }
397}
398
399
400void WX_GRID::onGridCellSelect( wxGridEvent& aEvent )
401{
402 // Highlight the selected cell.
403 // Calling SelectBlock() allows a visual effect when cells are selected by tab or arrow keys.
404 // Otherwise, one cannot really know what actual cell is selected.
405 int row = aEvent.GetRow();
406 int col = aEvent.GetCol();
407
408 if( row >= 0 && row < GetNumberRows() && col >= 0 && col < GetNumberCols() )
409 {
410 if( GetSelectionMode() == wxGrid::wxGridSelectCells )
411 {
412 SelectBlock( row, col, row, col, false );
413 }
414 else if( GetSelectionMode() == wxGrid::wxGridSelectRows
415 || GetSelectionMode() == wxGrid::wxGridSelectRowsOrColumns )
416 {
417 SelectBlock( row, 0, row, GetNumberCols() - 1, false );
418 }
419 else if( GetSelectionMode() == wxGrid::wxGridSelectColumns )
420 {
421 SelectBlock( 0, col, GetNumberRows() - 1, col, false );
422 }
423
424#ifdef __WXMSW__
425 // On Windows with wxWidgets 3.3+, the selection highlight can be drawn incorrectly
426 // on the first selection if the grid hasn't been fully laid out yet. Force a single
427 // deferred refresh after the first selection to ensure correct rendering.
428 if( !m_firstSelectionRefreshDone )
429 {
430 m_firstSelectionRefreshDone = true;
431 CallAfter( [this]() { ForceRefresh(); } );
432 }
433#endif
434 }
435}
436
437
438void WX_GRID::onCellEditorShown( wxGridEvent& aEvent )
439{
440 if( alg::contains( m_autoEvalCols, aEvent.GetCol() ) )
441 {
442 int row = aEvent.GetRow();
443 int col = aEvent.GetCol();
444
445 const std::pair<wxString, wxString>& beforeAfter = m_evalBeforeAfter[ { row, col } ];
446
447 if( GetCellValue( row, col ) == beforeAfter.second )
448 SetCellValue( row, col, beforeAfter.first );
449 }
450}
451
452
453void WX_GRID::onCellEditorHidden( wxGridEvent& aEvent )
454{
455 const int col = aEvent.GetCol();
456
457 if( alg::contains( m_autoEvalCols, col ) )
458 {
459 UNITS_PROVIDER* unitsProvider = getUnitsProvider( col );
460
461 auto cellUnitsData = getColumnUnits( col );
462 EDA_UNITS cellUnits = cellUnitsData.first;
463 EDA_DATA_TYPE cellDataType = cellUnitsData.second;
464
465 m_eval->SetDefaultUnits( cellUnits );
466
467 const int row = aEvent.GetRow();
468
469 // Determine if this cell is marked as holding nullable values
470 bool isNullable = false;
471 wxGridCellEditor* cellEditor = GetCellEditor( row, col );
472
473 if( cellEditor )
474 {
475 if( const GRID_CELL_NULLABLE_INTERFACE* nullable =
476 dynamic_cast<GRID_CELL_NULLABLE_INTERFACE*>( cellEditor ) )
477 isNullable = nullable->IsNullable();
478
479 cellEditor->DecRef();
480 }
481
482 CallAfter(
483 [this, row, col, isNullable, unitsProvider, cellDataType]()
484 {
485 // Careful; if called from CommitPendingChange() in a delete operation, the cell may
486 // no longer exist.
487 if( row >= GetNumberRows() || col >= GetNumberCols() )
488 return;
489
490 wxString stringValue = GetCellValue( row, col );
491 bool processedOk = true;
492
493 if( stringValue != UNITS_PROVIDER::NullUiString )
494 processedOk = m_eval->Process( stringValue );
495
496 if( processedOk )
497 {
498 wxString evalValue;
499
500 if( isNullable )
501 {
502 std::optional<int> val;
503
504 if( stringValue == UNITS_PROVIDER::NullUiString )
505 {
507 cellDataType );
508 }
509 else
510 {
511 val = unitsProvider->OptionalValueFromString( m_eval->Result(), cellDataType );
512 }
513
514 evalValue = unitsProvider->StringFromOptionalValue( val, true, cellDataType );
515 }
516 else
517 {
518 int val = unitsProvider->ValueFromString( m_eval->Result(), cellDataType );
519 evalValue = unitsProvider->StringFromValue( val, true, cellDataType );
520 }
521
522 if( stringValue != evalValue )
523 {
524 SetCellValue( row, col, evalValue );
525 m_evalBeforeAfter[{ row, col }] = { stringValue, evalValue };
526 }
527 }
528 } );
529 }
530
531 aEvent.Skip();
532}
533
534
535void WX_GRID::DestroyTable( wxGridTableBase* aTable )
536{
537 // wxGrid's destructor will crash trying to look up the cell attr if the edit control
538 // is left open. Normally it's closed in Validate(), but not if the user hit Cancel.
539 CommitPendingChanges( true /* quiet mode */ );
540
541 Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
542 Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this );
543
544 wxGrid::SetTable( nullptr );
545 delete aTable;
546}
547
548
550{
551 wxString shownColumns;
552
553 for( int i = 0; i < GetNumberCols(); ++i )
554 {
555 if( IsColShown( i ) )
556 {
557 if( shownColumns.Length() )
558 shownColumns << wxT( " " );
559
560 shownColumns << i;
561 }
562 }
563
564 return shownColumns;
565}
566
567
569{
570 std::bitset<64> shownColumns;
571
572 for( int ii = 0; ii < GetNumberCols(); ++ii )
573 shownColumns[ii] = IsColShown( ii );
574
575 return shownColumns;
576}
577
578
579void WX_GRID::ShowHideColumns( const wxString& shownColumns )
580{
581 for( int i = 0; i < GetNumberCols(); ++i )
582 HideCol( i );
583
584 wxStringTokenizer shownTokens( shownColumns, " \t\r\n", wxTOKEN_STRTOK );
585
586 while( shownTokens.HasMoreTokens() )
587 {
588 long colNumber;
589 shownTokens.GetNextToken().ToLong( &colNumber );
590
591 if( colNumber >= 0 && colNumber < GetNumberCols() )
592 ShowCol( (int) colNumber );
593 }
594}
595
596
598{
599 if( m_nativeColumnLabels )
600 wxGrid::DrawCornerLabel( dc );
601
602 wxRect rect( wxSize( m_rowLabelWidth, m_colLabelHeight ) );
603
605
606 // It is reported that we need to erase the background to avoid display artifacts; see #12055.
607 {
608 wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
609 wxDCPenChanger setPen( dc, m_colLabelWin->GetBackgroundColour() );
610 dc.DrawRectangle( rect.Inflate( 1 ) );
611 }
612
613 rend.DrawBorder( *this, dc, rect );
614}
615
616
617void WX_GRID::DrawColLabel( wxDC& dc, int col )
618{
619 if( m_nativeColumnLabels )
620 wxGrid::DrawColLabel( dc, col );
621
622 if( GetColWidth( col ) <= 0 || m_colLabelHeight <= 0 )
623 return;
624
625 wxRect rect( GetColLeft( col ), 0, GetColWidth( col ), m_colLabelHeight );
626
628
629 // It is reported that we need to erase the background to avoid display artifacts; see #12055.
630 {
631 wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
632 wxDCPenChanger setPen( dc, m_colLabelWin->GetBackgroundColour() );
633 dc.DrawRectangle( rect.Inflate( 1 ) );
634 }
635
636 rend.DrawBorder( *this, dc, rect );
637
638 // Make sure fonts get scaled correctly on GTK HiDPI monitors
639 dc.SetFont( GetLabelFont() );
640
641 int hAlign, vAlign;
642 GetColLabelAlignment( &hAlign, &vAlign );
643 const int orient = GetColLabelTextOrientation();
644
645 if( col == 0 )
646 hAlign = wxALIGN_LEFT;
647
648 if( hAlign == wxALIGN_LEFT )
649 rect.SetLeft( rect.GetLeft() + MIN_GRIDCELL_MARGIN );
650
651 rend.DrawLabel( *this, dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient );
652}
653
654
655void WX_GRID::DrawRowLabel( wxDC& dc, int row )
656{
657 if( GetRowHeight( row ) <= 0 || m_rowLabelWidth <= 0 )
658 return;
659
660 wxRect rect( 0, GetRowTop( row ), m_rowLabelWidth, GetRowHeight( row ) );
661
662 static WX_GRID_ROW_HEADER_RENDERER rend;
663
664 // It is reported that we need to erase the background to avoid display artifacts; see #12055.
665 {
666 wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
667 wxDCPenChanger setPen( dc, m_colLabelWin->GetBackgroundColour() );
668 dc.DrawRectangle( rect.Inflate( 1 ) );
669 }
670
671 rend.DrawBorder( *this, dc, rect );
672
673 // Make sure fonts get scaled correctly on GTK HiDPI monitors
674 dc.SetFont( GetLabelFont() );
675
676 int hAlign, vAlign;
677 GetRowLabelAlignment(&hAlign, &vAlign);
678
679 if( hAlign == wxALIGN_LEFT )
680 rect.SetLeft( rect.GetLeft() + MIN_GRIDCELL_MARGIN );
681
682 rend.DrawLabel( *this, dc, GetRowLabelValue( row ), rect, hAlign, vAlign, wxHORIZONTAL );
683}
684
685
687{
688 if( !IsCellEditControlEnabled() )
689 return true;
690
691 HideCellEditControl();
692
693 // do it after HideCellEditControl()
694 m_cellEditCtrlEnabled = false;
695
696 int row = m_currentCellCoords.GetRow();
697 int col = m_currentCellCoords.GetCol();
698
699 wxString oldval = GetCellValue( row, col );
700 wxString newval;
701
702 wxGridCellAttr* attr = GetCellAttr( row, col );
703 wxGridCellEditor* editor = attr->GetEditor( this, row, col );
704
705 editor->EndEdit( row, col, this, oldval, &newval );
706
707 editor->DecRef();
708 attr->DecRef();
709
710 return true;
711}
712
713
714bool WX_GRID::CommitPendingChanges( bool aQuietMode )
715{
716 if( !IsCellEditControlEnabled() )
717 return true;
718
719 if( !aQuietMode && SendEvent( wxEVT_GRID_EDITOR_HIDDEN ) == -1 )
720 return false;
721
722 HideCellEditControl();
723
724 // do it after HideCellEditControl()
725 m_cellEditCtrlEnabled = false;
726
727 int row = m_currentCellCoords.GetRow();
728 int col = m_currentCellCoords.GetCol();
729
730 wxString oldval = GetCellValue( row, col );
731 wxString newval;
732
733 wxGridCellAttr* attr = GetCellAttr( row, col );
734 wxGridCellEditor* editor = attr->GetEditor( this, row, col );
735
736 bool changed = editor->EndEdit( row, col, this, oldval, &newval );
737
738 editor->DecRef();
739 attr->DecRef();
740
741 if( changed )
742 {
743 if( !aQuietMode && SendEvent( wxEVT_GRID_CELL_CHANGING, newval ) == -1 )
744 return false;
745
746 editor->ApplyEdit( row, col, this );
747
748 // for compatibility reasons dating back to wx 2.8 when this event
749 // was called wxEVT_GRID_CELL_CHANGE and wxEVT_GRID_CELL_CHANGING
750 // didn't exist we allow vetoing this one too
751 if( !aQuietMode && SendEvent( wxEVT_GRID_CELL_CHANGED, oldval ) == -1 )
752 {
753 // Event has been vetoed, set the data back.
754 SetCellValue( row, col, oldval );
755 return false;
756 }
757
758 if( DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( wxGetTopLevelParent( this ) ) )
759 dlg->OnModify();
760 }
761
762 return true;
763}
764
765
766void WX_GRID::OnAddRow( const std::function<std::pair<int, int>()>& aAdder )
767{
768 if( !CommitPendingChanges() )
769 return;
770
771 auto [row, editCol] = aAdder();
772
773 // wx documentation is wrong, SetGridCursor does not make visible.
774 SetFocus();
775 MakeCellVisible( row, std::max( editCol, 0 ) );
776 SetGridCursor( row, std::max( editCol, 0 ) );
777
778 if( editCol >= 0 )
779 {
780 EnableCellEditControl( true );
781 ShowCellEditControl();
782 }
783}
784
785
786void WX_GRID::OnDeleteRows( const std::function<void( int row )>& aDeleter )
787{
789 []( int row )
790 {
791 return true;
792 },
793 aDeleter );
794}
795
796
797void WX_GRID::OnDeleteRows( const std::function<bool( int row )>& aFilter,
798 const std::function<void( int row )>& aDeleter )
799{
800 wxArrayInt selectedRows = GetSelectedRows();
801
802 auto addSelectedRow = [&]( int row )
803 {
804 for( size_t i = 0; i < selectedRows.size(); ++i )
805 {
806 if( selectedRows[i] == row )
807 return;
808 }
809
810 selectedRows.push_back( row );
811 };
812
813 wxGridCellCoordsArray topLeft = GetSelectionBlockTopLeft();
814 wxGridCellCoordsArray botRight = GetSelectionBlockBottomRight();
815
816 for( size_t i = 0; i < std::min( topLeft.Count(), botRight.Count() ); ++i )
817 {
818 for( int row = topLeft[i].GetRow(); row <= botRight[i].GetRow(); ++row )
819 addSelectedRow( row );
820 }
821
822 wxGridCellCoordsArray cells = GetSelectedCells();
823
824 for( size_t i = 0; i < cells.Count(); ++i )
825 addSelectedRow( cells[i].GetRow() );
826
827 if( selectedRows.empty() && GetGridCursorRow() >= 0 )
828 selectedRows.push_back( GetGridCursorRow() );
829
830 if( selectedRows.empty() )
831 return;
832
833 for( int row : selectedRows )
834 {
835 if( !aFilter( row ) )
836 return;
837 }
838
839 if( !CommitPendingChanges() )
840 return;
841
842 // Reverse sort so deleting a row doesn't change the indexes of the other rows.
843 selectedRows.Sort(
844 []( int* first, int* second )
845 {
846 return *second - *first;
847 } );
848
849 int nextSelRow = selectedRows.back() - 1;
850
851 if( nextSelRow >= 0 )
852 {
853 GoToCell( nextSelRow, GetGridCursorCol() );
854 SetGridCursor( nextSelRow, GetGridCursorCol() );
855 }
856
857 for( int row : selectedRows )
858 aDeleter( row );
859}
860
861
862void WX_GRID::SwapRows( int aRowA, int aRowB )
863{
864 for( int col = 0; col < GetNumberCols(); ++col )
865 {
866 wxString temp = GetCellValue( aRowA, col );
867 SetCellValue( aRowA, col, GetCellValue( aRowB, col ) );
868 SetCellValue( aRowB, col, temp );
869 }
870}
871
872
873void WX_GRID::OnMoveRowUp( const std::function<void( int row )>& aMover )
874{
876 []( int row )
877 {
878 return true;
879 },
880 aMover );
881}
882
883
884void WX_GRID::OnMoveRowUp( const std::function<bool( int row )>& aFilter,
885 const std::function<void( int row )>& aMover )
886{
887 if( !CommitPendingChanges() )
888 return;
889
890 int i = GetGridCursorRow();
891
892 if( i > 0 && aFilter( i ) )
893 {
894 aMover( i );
895
896 SetGridCursor( i - 1, GetGridCursorCol() );
897 MakeCellVisible( GetGridCursorRow(), GetGridCursorCol() );
898 }
899 else
900 {
901 wxBell();
902 }
903}
904
905
906void WX_GRID::OnMoveRowDown( const std::function<void( int row )>& aMover )
907{
909 []( int row )
910 {
911 return true;
912 },
913 aMover );
914}
915
916
917void WX_GRID::OnMoveRowDown( const std::function<bool( int row )>& aFilter,
918 const std::function<void( int row )>& aMover )
919{
920 if( !CommitPendingChanges() )
921 return;
922
923 int i = GetGridCursorRow();
924
925 if( i + 1 < GetNumberRows() && aFilter( i ) )
926 {
927 aMover( i );
928
929 SetGridCursor( i + 1, GetGridCursorCol() );
930 MakeCellVisible( GetGridCursorRow(), GetGridCursorCol() );
931 }
932 else
933 {
934 wxBell();
935 }
936}
937
938
939void WX_GRID::SetUnitsProvider( UNITS_PROVIDER* aProvider, int aCol )
940{
941 m_unitsProviders[ aCol ] = aProvider;
942
943 if( !m_eval )
944 m_eval = std::make_unique<NUMERIC_EVALUATOR>( aProvider->GetUserUnits() );
945}
946
947
948void WX_GRID::SetAutoEvalColUnits( const int col, EDA_UNITS aUnit, EDA_DATA_TYPE aUnitType )
949{
950 m_autoEvalColsUnits[col] = std::make_pair( aUnit, aUnitType );
951}
952
953
954void WX_GRID::SetAutoEvalColUnits( const int col, EDA_UNITS aUnit )
955{
957 SetAutoEvalColUnits( col, aUnit, type );
958}
959
960
961int WX_GRID::GetUnitValue( int aRow, int aCol )
962{
963 wxString stringValue = GetCellValue( aRow, aCol );
964
965 auto [cellUnits, cellDataType] = getColumnUnits( aCol );
966
967 if( alg::contains( m_autoEvalCols, aCol ) )
968 {
969 m_eval->SetDefaultUnits( cellUnits );
970
971 if( m_eval->Process( stringValue ) )
972 stringValue = m_eval->Result();
973 }
974
975 return getUnitsProvider( aCol )->ValueFromString( stringValue, cellDataType );
976}
977
978
979std::optional<int> WX_GRID::GetOptionalUnitValue( int aRow, int aCol )
980{
981 wxString stringValue = GetCellValue( aRow, aCol );
982
983 auto [cellUnits, cellDataType] = getColumnUnits( aCol );
984
985 if( alg::contains( m_autoEvalCols, aCol ) )
986 {
987 m_eval->SetDefaultUnits( cellUnits );
988
989 if( stringValue != UNITS_PROVIDER::NullUiString && m_eval->Process( stringValue ) )
990 stringValue = m_eval->Result();
991 }
992
993 return getUnitsProvider( aCol )->OptionalValueFromString( stringValue, cellDataType );
994}
995
996
997void WX_GRID::SetUnitValue( int aRow, int aCol, int aValue )
998{
999 EDA_DATA_TYPE cellDataType;
1000
1001 if( m_autoEvalColsUnits.contains( aCol ) )
1002 cellDataType = m_autoEvalColsUnits[aCol].second;
1003 else
1004 cellDataType = EDA_DATA_TYPE::DISTANCE;
1005
1006 SetCellValue( aRow, aCol, getUnitsProvider( aCol )->StringFromValue( aValue, true, cellDataType ) );
1007}
1008
1009
1010void WX_GRID::SetOptionalUnitValue( int aRow, int aCol, std::optional<int> aValue )
1011{
1012 EDA_DATA_TYPE cellDataType;
1013
1014 if( m_autoEvalColsUnits.contains( aCol ) )
1015 cellDataType = m_autoEvalColsUnits[aCol].second;
1016 else
1017 cellDataType = EDA_DATA_TYPE::DISTANCE;
1018
1019 SetCellValue( aRow, aCol, getUnitsProvider( aCol )->StringFromOptionalValue( aValue, true, cellDataType ) );
1020}
1021
1022
1023void WX_GRID::onGridColMove( wxGridEvent& aEvent )
1024{
1025 // wxWidgets won't move an open editor, so better just to close it
1026 CommitPendingChanges( true );
1027}
1028
1029
1030int WX_GRID::GetVisibleWidth( int aCol, bool aHeader, bool aContents, bool aKeep )
1031{
1032 int size = 0;
1033
1034 if( aCol < 0 )
1035 {
1036 if( aKeep )
1037 size = GetRowLabelSize();
1038
1039 for( int row = 0; aContents && row < GetNumberRows(); row++ )
1040 size = std::max( size, int( GetTextExtent( GetRowLabelValue( row ) + wxS( "M" ) ).x ) );
1041 }
1042 else
1043 {
1044 if( aKeep )
1045 size = GetColSize( aCol );
1046
1047 // 'M' is generally the widest character, so we buffer the column width by default to
1048 // ensure we don't write a continuous line of text at the column header
1049 if( aHeader )
1050 {
1052
1053 size = std::max( size, int( GetTextExtent( GetColLabelValue( aCol ) + wxS( "M" ) ).x ) );
1054 }
1055
1056 for( int row = 0; aContents && row < GetNumberRows(); row++ )
1057 {
1058 // If we have text, get the size. Otherwise, use a placeholder for the checkbox
1059 if( GetTable()->CanGetValueAs( row, aCol, wxGRID_VALUE_STRING ) )
1060 size = std::max( size, GetTextExtent( GetCellValue( row, aCol ) + wxS( "M" ) ).x );
1061 else
1062 size = std::max( size, GetTextExtent( "MM" ).x );
1063 }
1064 }
1065
1066 return size;
1067}
1068
1069
1071{
1072 int line_height = int( GetTextExtent( "Mj" ).y ) + 3;
1073 int row_height = GetColLabelSize();
1074 int initial_row_height = row_height;
1075
1076 // Headers can be multiline. Fix the Column Label Height to show the full header
1077 // However GetTextExtent does not work on multiline strings,
1078 // and do not return the full text height (only the height of one line)
1079 for( int col = 0; col < GetNumberCols(); col++ )
1080 {
1081 int nl_count = GetColLabelValue( col ).Freq( '\n' );
1082
1083 if( nl_count )
1084 {
1085 // Col Label height must be able to show nl_count+1 lines
1086 if( row_height < line_height * ( nl_count+1 ) )
1087 row_height += line_height * nl_count;
1088 }
1089 }
1090
1091 // Update the column label size, but only if needed, to avoid generating useless
1092 // and perhaps annoying UI events when the size does not change
1093 if( initial_row_height != row_height )
1094 SetColLabelSize( row_height );
1095}
1096
1097
1098std::pair<EDA_UNITS, EDA_DATA_TYPE> WX_GRID::getColumnUnits( const int aCol ) const
1099{
1100 if( m_autoEvalColsUnits.contains( aCol ) )
1101 return { m_autoEvalColsUnits.at( aCol ).first, m_autoEvalColsUnits.at( aCol ).second };
1102
1103 // Legacy - default always DISTANCE
1105}
1106
1107
1108void WX_GRID::SetupColumnAutosizer( int aFlexibleCol )
1109{
1110 const int colCount = GetNumberCols();
1111
1112 for( int ii = 0; ii < GetNumberCols(); ++ii )
1113 m_autosizedCols[ii] = GetColSize( ii );
1114
1115 m_flexibleCol = aFlexibleCol;
1116
1117 wxASSERT_MSG( m_flexibleCol < colCount, "Flexible column index does not exist in grid" );
1118
1119 Bind( wxEVT_UPDATE_UI,
1120 [this]( wxUpdateUIEvent& aEvent )
1121 {
1123 aEvent.Skip();
1124 } );
1125
1126 Bind( wxEVT_SIZE,
1127 [this]( wxSizeEvent& aEvent )
1128 {
1129 onSizeEvent( aEvent );
1130 aEvent.Skip();
1131 } );
1132
1133 // Handles the case when the user changes the cell content to be longer than the current column size
1134 Bind( wxEVT_GRID_CELL_CHANGED,
1135 [this]( wxGridEvent& aEvent )
1136 {
1137 m_gridWidthsDirty = true;
1138 aEvent.Skip();
1139 } );
1140}
1141
1142
1144{
1145 if( m_gridWidthsDirty )
1146 {
1147 const int width = GetSize().GetX() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X );
1148
1149 std::optional<int> flexibleMinWidth;
1150
1151 for( const auto& [colIndex, minWidth] : m_autosizedCols )
1152 {
1153 if( GetColSize( colIndex ) != 0 )
1154 {
1155 AutoSizeColumn( colIndex );
1156 const int colSize = GetColSize( colIndex );
1157
1158 int minWidthScaled = FromDIP( minWidth );
1159 SetColSize( colIndex, std::max( minWidthScaled, colSize ) );
1160
1161 if( colIndex == m_flexibleCol )
1162 flexibleMinWidth = minWidthScaled;
1163 }
1164 }
1165
1166 // Gather all the widths except the flexi one
1167 int nonFlexibleWidth = 0;
1168
1169 for( int i = 0; i < GetNumberCols(); ++i )
1170 {
1171 if( i != m_flexibleCol )
1172 nonFlexibleWidth += GetColSize( i );
1173 }
1174
1175 if( GetColSize( m_flexibleCol ) != 0 )
1176 SetColSize( m_flexibleCol, std::max( flexibleMinWidth.value_or( 0 ), width - nonFlexibleWidth ) );
1177
1178 // Store the state for next time
1179 m_gridWidth = GetSize().GetX();
1180 m_gridWidthsDirty = false;
1181 }
1182}
1183
1184
1185void WX_GRID::onSizeEvent( wxSizeEvent& aEvent )
1186{
1187 const int width = aEvent.GetSize().GetX();
1188
1189 if( width != m_gridWidth )
1190 m_gridWidthsDirty = true;
1191}
const char * name
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:65
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
wxColour ToColour() const
Definition color4d.cpp:221
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition color4d.h:292
Icon provider for the "standard" row indicators, for example in layer selection lists.
static const wxString NullUiString
The string that is used in the UI to represent a null value.
std::optional< int > OptionalValueFromString(const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aTextValue in aUnits to internal units used by the frame.
wxString StringFromOptionalValue(std::optional< int > aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts an optional aValue in internal units into a united string.
EDA_UNITS GetUserUnits() const
static EDA_DATA_TYPE GetTypeFromUnits(const EDA_UNITS aUnits)
Gets the inferred type from the given units.
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.
Attribute provider that provides attributes (or modifies the existing attribute) to alternate a row c...
Definition wx_grid.cpp:203
WX_GRID_ALT_ROW_COLOR_PROVIDER(const wxColor &aBaseColor)
Definition wx_grid.cpp:205
wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) const override
Definition wx_grid.cpp:220
wxGridCellAttrPtr m_attrEven
Definition wx_grid.cpp:246
void UpdateColors(const wxColor &aBaseColor)
Definition wx_grid.cpp:212
void DrawBorder(const wxGrid &grid, wxDC &dc, wxRect &rect) const override
Definition wx_grid.cpp:167
void DrawBorder(const wxGrid &grid, wxDC &dc, wxRect &rect) const override
Definition wx_grid.cpp:150
void DrawBorder(const wxGrid &grid, wxDC &dc, wxRect &rect) const override
Definition wx_grid.cpp:184
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
Definition wx_grid.cpp:43
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculate the specified column based on the actual size of the text on screen.
Definition wx_grid.cpp:1030
int m_flexibleCol
Definition wx_grid.h:395
void onGridCellSelect(wxGridEvent &aEvent)
Definition wx_grid.cpp:400
std::map< int, int > m_autosizedCols
Definition wx_grid.h:394
bool m_gridWidthsDirty
Definition wx_grid.h:397
~WX_GRID() override
Definition wx_grid.cpp:272
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:341
bool m_weOwnTable
Definition wx_grid.h:384
void onDPIChanged(wxDPIChangedEvent &event)
Definition wx_grid.cpp:285
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition wx_grid.cpp:579
void OnMoveRowUp(const std::function< void(int row)> &aMover)
Definition wx_grid.cpp:873
std::map< int, UNITS_PROVIDER * > m_unitsProviders
Definition wx_grid.h:386
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:347
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:535
std::unordered_map< int, std::pair< EDA_UNITS, EDA_DATA_TYPE > > m_autoEvalColsUnits
Definition wx_grid.h:389
void SetAutoEvalColUnits(int col, EDA_UNITS aUnit, EDA_DATA_TYPE aUnitType)
Set the unit and unit data type to use for a given column.
Definition wx_grid.cpp:948
bool CancelPendingChanges()
Definition wx_grid.cpp:686
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:326
static int CapHeightToVisibleRows(int aMinHeight, int aHeaderHeight, const std::vector< int > &aRowHeights, int aMaxRows)
Height of aMaxRows data rows plus the column-label header, never more than aMinHeight.
Definition wx_grid.cpp:90
void SwapRows(int aRowA, int aRowB)
These aren't that tricky, but might as well share code.
Definition wx_grid.cpp:862
std::pair< EDA_UNITS, EDA_DATA_TYPE > getColumnUnits(int aCol) const
Returns the units and data type associated with a given column.
Definition wx_grid.cpp:1098
void SetUnitValue(int aRow, int aCol, int aValue)
Set a unitized cell's value.
Definition wx_grid.cpp:997
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:250
int GetUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
Definition wx_grid.cpp:961
std::vector< int > m_autoEvalCols
Definition wx_grid.h:388
UNITS_PROVIDER * getUnitsProvider(int aCol) const
Definition wx_grid.h:367
std::map< std::pair< int, int >, std::pair< wxString, wxString > > m_evalBeforeAfter
Definition wx_grid.h:390
void SetMinVisibleRows(wxWindow *aDialog, int aMinRows)
Floor this grid at aMinRows visible rows and grow aDialog so it opens tall enough to show every curre...
Definition wx_grid.cpp:106
void DrawCornerLabel(wxDC &dc) override
A re-implementation of wxGrid::DrawCornerLabel which draws flat borders.
Definition wx_grid.cpp:597
ROW_ICON_PROVIDER * m_rowIconProvider
Definition wx_grid.h:404
void onCellEditorHidden(wxGridEvent &aEvent)
Definition wx_grid.cpp:453
void SetupColumnAutosizer(int aFlexibleCol)
Set autosize behaviour using wxFormBuilder column widths as minimums, with a single specified growabl...
Definition wx_grid.cpp:1108
void RecomputeGridWidths()
Definition wx_grid.cpp:1143
void OnMoveRowDown(const std::function< void(int row)> &aMover)
Definition wx_grid.cpp:906
void onGridColMove(wxGridEvent &aEvent)
Definition wx_grid.cpp:1023
void SetOptionalUnitValue(int aRow, int aCol, std::optional< int > aValue)
Set a unitized cell's optional value.
Definition wx_grid.cpp:1010
void onSizeEvent(wxSizeEvent &aEvent)
Definition wx_grid.cpp:1185
void onCellEditorShown(wxGridEvent &aEvent)
Definition wx_grid.cpp:438
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
Definition wx_grid.cpp:1070
void OnDeleteRows(const std::function< void(int row)> &aDeleter)
Handles a row deletion event.
Definition wx_grid.cpp:786
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
Definition wx_grid.cpp:549
void OnAddRow(const std::function< std::pair< int, int >()> &aAdder)
Definition wx_grid.cpp:766
int m_gridWidth
Definition wx_grid.h:398
void DrawRowLabel(wxDC &dc, int row) override
A re-implementation of wxGrid::DrawRowLabel which draws flat borders.
Definition wx_grid.cpp:655
std::bitset< 64 > GetShownColumns()
Definition wx_grid.cpp:568
static void CellEditorSetMargins(wxTextEntryBase *aEntry)
A helper function to set OS-specific margins for text-based cell editors.
Definition wx_grid.cpp:75
std::optional< int > GetOptionalUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
Definition wx_grid.cpp:979
void EnableAlternateRowColors(bool aEnable=true)
Enable alternate row highlighting, where every odd row has a different background color than the even...
Definition wx_grid.cpp:382
void SetUnitsProvider(UNITS_PROVIDER *aProvider, int aCol=0)
Set a EUNITS_PROVIDER to enable use of unit- and eval-based Getters.
Definition wx_grid.cpp:939
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition wx_grid.cpp:714
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
Definition wx_grid.h:387
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:617
static void CellEditorTransformSizeRect(wxRect &aRect)
A helper function to tweak sizes of text-based cell editors depending on OS.
Definition wx_grid.cpp:82
EDA_DATA_TYPE
The type of unit.
Definition eda_units.h:34
EDA_UNITS
Definition eda_units.h:44
bool IsDarkTheme()
Determine if the desktop interface is currently using a dark theme or a light theme.
Definition wxgtk/ui.cpp:50
KICOMMON_API wxFont GetControlFont(wxWindow *aWindow)
const int c_IndicatorSizeDIP
Definition ui_common.h:52
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:96
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
std::vector< std::vector< std::string > > table
Functions to provide common constants and other functions to assist in making a consistent UI.
wxColour getBorderColour()
Definition wx_grid.cpp:138
#define MIN_GRIDCELL_MARGIN
Definition wx_grid.cpp:72