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/colour.h>
25#include <wx/tokenzr.h>
26#include <wx/dc.h>
27#include <wx/settings.h>
28#include <wx/event.h> // Needed for textentry.h on MSW
29#include <wx/textentry.h>
30
31#include <widgets/wx_grid.h>
32#include <widgets/ui_common.h>
33#include <algorithm>
34#include <core/kicad_algo.h>
35#include <gal/color4d.h>
36#include <kiplatform/ui.h>
37
38#include <pgm_base.h>
40
41#define MIN_GRIDCELL_MARGIN FromDIP( 3 )
42
43
44void WX_GRID::CellEditorSetMargins( wxTextEntryBase* aEntry )
45{
46 // This is consistent with wxGridCellTextEditor. But works differently across platforms or course.
47 aEntry->SetMargins( 0, 0 );
48}
49
50
52{
53#if defined( __WXMSW__ ) || defined( __WXGTK__ )
54 aRect.Deflate( 2 );
55#endif
56}
57
58
60{
61 KIGFX::COLOR4D bg = wxSystemSettings::GetColour( wxSYS_COLOUR_FRAMEBK );
62 KIGFX::COLOR4D fg = wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER );
63 KIGFX::COLOR4D border = fg.Mix( bg, 0.50 );
64 return border.ToColour();
65}
66
67
68class WX_GRID_CORNER_HEADER_RENDERER : public wxGridCornerHeaderRendererDefault
69{
70public:
71 void DrawBorder( const wxGrid& grid, wxDC& dc, wxRect& rect ) const override
72 {
73 wxDCBrushChanger SetBrush( dc, *wxTRANSPARENT_BRUSH );
74 wxDCPenChanger SetPen( dc, wxPen( getBorderColour(), 1 ) );
75
76 rect.SetTop( rect.GetTop() + 1 );
77 rect.SetLeft( rect.GetLeft() + 1 );
78 rect.SetBottom( rect.GetBottom() - 1 );
79 rect.SetRight( rect.GetRight() - 1 );
80 dc.DrawRectangle( rect );
81 }
82};
83
84
85class WX_GRID_COLUMN_HEADER_RENDERER : public wxGridColumnHeaderRendererDefault
86{
87public:
88 void DrawBorder( const wxGrid& grid, wxDC& dc, wxRect& rect ) const override
89 {
90 wxDCBrushChanger SetBrush( dc, *wxTRANSPARENT_BRUSH );
91 wxDCPenChanger SetPen( dc, wxPen( getBorderColour(), 1 ) );
92
93 rect.SetTop( rect.GetTop() + 1 );
94 rect.SetLeft( rect.GetLeft() );
95 rect.SetBottom( rect.GetBottom() - 1 );
96 rect.SetRight( rect.GetRight() - 1 );
97 dc.DrawRectangle( rect );
98 }
99};
100
101
102class WX_GRID_ROW_HEADER_RENDERER : public wxGridRowHeaderRendererDefault
103{
104public:
105 void DrawBorder( const wxGrid& grid, wxDC& dc, wxRect& rect ) const override
106 {
107 wxDCBrushChanger SetBrush( dc, *wxTRANSPARENT_BRUSH );
108 wxDCPenChanger SetPen( dc, wxPen( getBorderColour(), 1 ) );
109
110 rect.SetTop( rect.GetTop() + 1 );
111 rect.SetLeft( rect.GetLeft() + 1 );
112 rect.SetBottom( rect.GetBottom() - 1 );
113 rect.SetRight( rect.GetRight() );
114 dc.DrawRectangle( rect );
115 }
116};
117
118
123class WX_GRID_ALT_ROW_COLOR_PROVIDER : public wxGridCellAttrProvider
124{
125public:
126 WX_GRID_ALT_ROW_COLOR_PROVIDER( const wxColor& aBaseColor ) : wxGridCellAttrProvider(),
127 m_attrOdd( new wxGridCellAttr() )
128 {
129 UpdateColors( aBaseColor );
130 }
131
132
133 void UpdateColors( const wxColor& aBaseColor )
134 {
135 // Choose the default color, taking into account if the dark mode theme is enabled
136 wxColor rowColor = aBaseColor.ChangeLightness( KIPLATFORM::UI::IsDarkTheme() ? 105 : 95 );
137
138 m_attrOdd->SetBackgroundColour( rowColor );
139 }
140
141
142 wxGridCellAttr* GetAttr( int row, int col,
143 wxGridCellAttr::wxAttrKind kind ) const override
144 {
145 wxGridCellAttrPtr cellAttr( wxGridCellAttrProvider::GetAttr( row, col, kind ) );
146
147 // Just pass through the cell attribute on even rows
148 if( row % 2 )
149 return cellAttr.release();
150
151 if( !cellAttr )
152 {
153 cellAttr = m_attrOdd;
154 }
155 else
156 {
157 if( !cellAttr->HasBackgroundColour() )
158 {
159 cellAttr = cellAttr->Clone();
160 cellAttr->SetBackgroundColour( m_attrOdd->GetBackgroundColour() );
161 }
162 }
163
164 return cellAttr.release();
165 }
166
167private:
168 wxGridCellAttrPtr m_attrOdd;
169};
170
171
172WX_GRID::WX_GRID( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
173 long style, const wxString& name ) :
174 wxGrid( parent, id, pos, size, style, name ),
175 m_weOwnTable( false )
176{
177 SetDefaultCellOverflow( false );
178
179 // Make sure the GUI font scales properly
180 SetDefaultCellFont( KIUI::GetControlFont( this ) );
182
183 if( GetColLabelSize() > 0 )
184 SetColLabelSize( GetColLabelSize() + FromDIP( 4 ) );
185
186 Connect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this );
187 Connect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, this );
188 Connect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, this );
189}
190
191
193{
194 if( m_weOwnTable )
195 DestroyTable( GetTable() );
196
197 Disconnect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this );
198}
199
200
201void WX_GRID::onDPIChanged(wxDPIChangedEvent& aEvt)
202{
205#ifndef __WXMAC__
206 aEvt.Skip();
207#endif
208}
209
210
211void WX_GRID::SetColLabelSize( int aHeight )
212{
213 if( aHeight == 0 )
214 {
215 wxGrid::SetColLabelSize( 0 );
216 return;
217 }
218
219 // Correct wxFormBuilder height for large fonts
220 int minHeight = GetLabelFont().GetPixelSize().y + 2 * MIN_GRIDCELL_MARGIN;
221 wxGrid::SetColLabelSize( std::max( aHeight, minHeight ) );
222}
223
224
225void WX_GRID::SetLabelFont( const wxFont& aFont )
226{
227 wxGrid::SetLabelFont( KIUI::GetControlFont( this ) );
228}
229
230
231void WX_GRID::SetTable( wxGridTableBase* aTable, bool aTakeOwnership )
232{
233 // wxGrid::SetTable() messes up the column widths from wxFormBuilder so we have to save
234 // and restore them.
235 int numberCols = GetNumberCols();
236 int* formBuilderColWidths = new int[numberCols];
237
238 for( int i = 0; i < numberCols; ++i )
239 formBuilderColWidths[ i ] = GetColSize( i );
240
241 wxGrid::SetTable( aTable );
242
243 // wxGrid::SetTable() may change the number of columns, so prevent out-of-bounds access
244 // to formBuilderColWidths
245 numberCols = std::min( numberCols, GetNumberCols() );
246
247 for( int i = 0; i < numberCols; ++i )
248 {
249 // correct wxFormBuilder width for large fonts and/or long translations
250 int headingWidth = GetTextExtent( GetColLabelValue( i ) ).x + 2 * MIN_GRIDCELL_MARGIN;
251
252 SetColSize( i, std::max( formBuilderColWidths[ i ], headingWidth ) );
253 }
254
255 delete[] formBuilderColWidths;
256
257 EnableAlternateRowColors( Pgm().GetCommonSettings()->m_Appearance.grid_striping );
258
259 Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
260 Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this );
261
262 m_weOwnTable = aTakeOwnership;
263}
264
265
267{
268 wxGridTableBase* table = wxGrid::GetTable();
269
270 wxCHECK_MSG( table, /* void */,
271 "Tried to enable alternate row colors without a table assigned to the grid" );
272
273 if( aEnable )
274 {
275 wxColor color = wxGrid::GetDefaultCellBackgroundColour();
276 table->SetAttrProvider( new WX_GRID_ALT_ROW_COLOR_PROVIDER( color ) );
277 }
278 else
279 {
280 table->SetAttrProvider( nullptr );
281 }
282}
283
284
285void WX_GRID::onGridCellSelect( wxGridEvent& aEvent )
286{
287 // Highlight the selected cell.
288 // Calling SelectBlock() allows a visual effect when cells are selected by tab or arrow keys.
289 // Otherwise, one cannot really know what actual cell is selected.
290 int row = aEvent.GetRow();
291 int col = aEvent.GetCol();
292
293 if( row >= 0 && row < GetNumberRows() && col >= 0 && col < GetNumberCols() )
294 {
295 if( GetSelectionMode() == wxGrid::wxGridSelectCells )
296 {
297 SelectBlock( row, col, row, col, false );
298 }
299 else if( GetSelectionMode() == wxGrid::wxGridSelectRows
300 || GetSelectionMode() == wxGrid::wxGridSelectRowsOrColumns )
301 {
302 SelectBlock( row, 0, row, GetNumberCols() - 1, false );
303 }
304 else if( GetSelectionMode() == wxGrid::wxGridSelectColumns )
305 {
306 SelectBlock( 0, col, GetNumberRows() - 1, col, false );
307 }
308 }
309}
310
311
312void WX_GRID::onCellEditorShown( wxGridEvent& aEvent )
313{
314 if( alg::contains( m_autoEvalCols, aEvent.GetCol() ) )
315 {
316 int row = aEvent.GetRow();
317 int col = aEvent.GetCol();
318
319 const std::pair<wxString, wxString>& beforeAfter = m_evalBeforeAfter[ { row, col } ];
320
321 if( GetCellValue( row, col ) == beforeAfter.second )
322 SetCellValue( row, col, beforeAfter.first );
323 }
324}
325
326
327void WX_GRID::onCellEditorHidden( wxGridEvent& aEvent )
328{
329 if( alg::contains( m_autoEvalCols, aEvent.GetCol() ) )
330 {
331 UNITS_PROVIDER* unitsProvider = m_unitsProviders[ aEvent.GetCol() ];
332
333 if( !unitsProvider )
334 unitsProvider = m_unitsProviders.begin()->second;
335
336 m_eval->SetDefaultUnits( unitsProvider->GetUserUnits() );
337
338 int row = aEvent.GetRow();
339 int col = aEvent.GetCol();
340
341 CallAfter(
342 [this, row, col, unitsProvider]()
343 {
344 wxString stringValue = GetCellValue( row, col );
345
346 if( m_eval->Process( stringValue ) )
347 {
348 int val = unitsProvider->ValueFromString( m_eval->Result() );
349 wxString evalValue = unitsProvider->StringFromValue( val, true );
350
351 if( stringValue != evalValue )
352 {
353 SetCellValue( row, col, evalValue );
354 m_evalBeforeAfter[ { row, col } ] = { stringValue, evalValue };
355 }
356 }
357 } );
358 }
359
360 aEvent.Skip();
361}
362
363
364void WX_GRID::DestroyTable( wxGridTableBase* aTable )
365{
366 // wxGrid's destructor will crash trying to look up the cell attr if the edit control
367 // is left open. Normally it's closed in Validate(), but not if the user hit Cancel.
368 CommitPendingChanges( true /* quiet mode */ );
369
370 Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
371 Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this );
372
373 wxGrid::SetTable( nullptr );
374 delete aTable;
375}
376
377
379{
380 wxString shownColumns;
381
382 for( int i = 0; i < GetNumberCols(); ++i )
383 {
384 if( IsColShown( i ) )
385 {
386 if( shownColumns.Length() )
387 shownColumns << wxT( " " );
388
389 shownColumns << i;
390 }
391 }
392
393 return shownColumns;
394}
395
396
398{
399 std::bitset<64> shownColumns;
400
401 for( int ii = 0; ii < GetNumberCols(); ++ii )
402 shownColumns[ii] = IsColShown( ii );
403
404 return shownColumns;
405}
406
407
408void WX_GRID::ShowHideColumns( const wxString& shownColumns )
409{
410 for( int i = 0; i < GetNumberCols(); ++i )
411 HideCol( i );
412
413 wxStringTokenizer shownTokens( shownColumns );
414
415 while( shownTokens.HasMoreTokens() )
416 {
417 long colNumber;
418 shownTokens.GetNextToken().ToLong( &colNumber );
419
420 if( colNumber >= 0 && colNumber < GetNumberCols() )
421 ShowCol( (int) colNumber );
422 }
423}
424
425
426void WX_GRID::ShowHideColumns( const std::bitset<64>& aShownColumns )
427{
428 for( int ii = 0; ii < GetNumberCols(); ++ ii )
429 {
430 if( aShownColumns[ii] )
431 ShowCol( ii );
432 else
433 HideCol( ii );
434 }
435}
436
437
439{
440 if( m_nativeColumnLabels )
441 wxGrid::DrawCornerLabel( dc );
442
443 wxRect rect( wxSize( m_rowLabelWidth, m_colLabelHeight ) );
444
446
447 // It is reported that we need to erase the background to avoid display
448 // artifacts, see #12055.
449 {
450 wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
451 wxDCPenChanger setPen( dc, m_colLabelWin->GetBackgroundColour() );
452 dc.DrawRectangle( rect.Inflate( 1 ) );
453 }
454
455 rend.DrawBorder( *this, dc, rect );
456}
457
458
459void WX_GRID::DrawColLabel( wxDC& dc, int col )
460{
461 if( m_nativeColumnLabels )
462 wxGrid::DrawColLabel( dc, col );
463
464 if( GetColWidth( col ) <= 0 || m_colLabelHeight <= 0 )
465 return;
466
467 wxRect rect( GetColLeft( col ), 0, GetColWidth( col ), m_colLabelHeight );
468
470
471 // It is reported that we need to erase the background to avoid display
472 // artifacts, see #12055.
473 {
474 wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
475 wxDCPenChanger setPen( dc, m_colLabelWin->GetBackgroundColour() );
476 dc.DrawRectangle( rect.Inflate( 1 ) );
477 }
478
479 rend.DrawBorder( *this, dc, rect );
480
481 // Make sure fonts get scaled correctly on GTK HiDPI monitors
482 dc.SetFont( GetLabelFont() );
483
484 int hAlign, vAlign;
485 GetColLabelAlignment( &hAlign, &vAlign );
486 const int orient = GetColLabelTextOrientation();
487
488 if( col == 0 )
489 hAlign = wxALIGN_LEFT;
490
491 if( hAlign == wxALIGN_LEFT )
492 rect.SetLeft( rect.GetLeft() + MIN_GRIDCELL_MARGIN );
493
494 rend.DrawLabel( *this, dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient );
495}
496
497
498void WX_GRID::DrawRowLabel( wxDC& dc, int row )
499{
500 if ( GetRowHeight( row ) <= 0 || m_rowLabelWidth <= 0 )
501 return;
502
503 wxRect rect( 0, GetRowTop( row ), m_rowLabelWidth, GetRowHeight( row ) );
504
505 static WX_GRID_ROW_HEADER_RENDERER rend;
506
507 // It is reported that we need to erase the background to avoid display
508 // artifacts, see #12055.
509 {
510 wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
511 wxDCPenChanger setPen( dc, m_colLabelWin->GetBackgroundColour() );
512 dc.DrawRectangle( rect.Inflate( 1 ) );
513 }
514
515 rend.DrawBorder( *this, dc, rect );
516
517 // Make sure fonts get scaled correctly on GTK HiDPI monitors
518 dc.SetFont( GetLabelFont() );
519
520 int hAlign, vAlign;
521 GetRowLabelAlignment(&hAlign, &vAlign);
522
523 if( hAlign == wxALIGN_LEFT )
524 rect.SetLeft( rect.GetLeft() + MIN_GRIDCELL_MARGIN );
525
526 rend.DrawLabel( *this, dc, GetRowLabelValue( row ), rect, hAlign, vAlign, wxHORIZONTAL );
527}
528
529
531{
532 if( !IsCellEditControlEnabled() )
533 return true;
534
535 HideCellEditControl();
536
537 // do it after HideCellEditControl()
538 m_cellEditCtrlEnabled = false;
539
540 int row = m_currentCellCoords.GetRow();
541 int col = m_currentCellCoords.GetCol();
542
543 wxString oldval = GetCellValue( row, col );
544 wxString newval;
545
546 wxGridCellAttr* attr = GetCellAttr( row, col );
547 wxGridCellEditor* editor = attr->GetEditor( this, row, col );
548
549 editor->EndEdit( row, col, this, oldval, &newval );
550
551 editor->DecRef();
552 attr->DecRef();
553
554 return true;
555}
556
557
558bool WX_GRID::CommitPendingChanges( bool aQuietMode )
559{
560 if( !IsCellEditControlEnabled() )
561 return true;
562
563 if( !aQuietMode && SendEvent( wxEVT_GRID_EDITOR_HIDDEN ) == -1 )
564 return false;
565
566 HideCellEditControl();
567
568 // do it after HideCellEditControl()
569 m_cellEditCtrlEnabled = false;
570
571 int row = m_currentCellCoords.GetRow();
572 int col = m_currentCellCoords.GetCol();
573
574 wxString oldval = GetCellValue( row, col );
575 wxString newval;
576
577 wxGridCellAttr* attr = GetCellAttr( row, col );
578 wxGridCellEditor* editor = attr->GetEditor( this, row, col );
579
580 bool changed = editor->EndEdit( row, col, this, oldval, &newval );
581
582 editor->DecRef();
583 attr->DecRef();
584
585 if( changed )
586 {
587 if( !aQuietMode && SendEvent( wxEVT_GRID_CELL_CHANGING, newval ) == -1 )
588 return false;
589
590 editor->ApplyEdit( row, col, this );
591
592 // for compatibility reasons dating back to wx 2.8 when this event
593 // was called wxEVT_GRID_CELL_CHANGE and wxEVT_GRID_CELL_CHANGING
594 // didn't exist we allow vetoing this one too
595 if( !aQuietMode && SendEvent( wxEVT_GRID_CELL_CHANGED, oldval ) == -1 )
596 {
597 // Event has been vetoed, set the data back.
598 SetCellValue( row, col, oldval );
599 return false;
600 }
601 }
602
603 return true;
604}
605
606
607void WX_GRID::SetUnitsProvider( UNITS_PROVIDER* aProvider, int aCol )
608{
609 m_unitsProviders[ aCol ] = aProvider;
610
611 if( !m_eval )
612 m_eval = std::make_unique<NUMERIC_EVALUATOR>( aProvider->GetUserUnits() );
613}
614
615
616int WX_GRID::GetUnitValue( int aRow, int aCol )
617{
618 UNITS_PROVIDER* unitsProvider = m_unitsProviders[ aCol ];
619
620 if( !unitsProvider )
621 unitsProvider = m_unitsProviders.begin()->second;
622
623 wxString stringValue = GetCellValue( aRow, aCol );
624
625 if( alg::contains( m_autoEvalCols, aCol ) )
626 {
627 m_eval->SetDefaultUnits( unitsProvider->GetUserUnits() );
628
629 if( m_eval->Process( stringValue ) )
630 stringValue = m_eval->Result();
631 }
632
633 return unitsProvider->ValueFromString( stringValue );
634}
635
636
637void WX_GRID::SetUnitValue( int aRow, int aCol, int aValue )
638{
639 UNITS_PROVIDER* unitsProvider = m_unitsProviders[ aCol ];
640
641 if( !unitsProvider )
642 unitsProvider = m_unitsProviders.begin()->second;
643
644 SetCellValue( aRow, aCol, unitsProvider->StringFromValue( aValue, true ) );
645}
646
647
648void WX_GRID::onGridColMove( wxGridEvent& aEvent )
649{
650 // wxWidgets won't move an open editor, so better just to close it
651 CommitPendingChanges( true );
652}
653
654
655int WX_GRID::GetVisibleWidth( int aCol, bool aHeader, bool aContents, bool aKeep )
656{
657 int size = 0;
658
659 if( aCol < 0 )
660 {
661 if( aKeep )
662 size = GetRowLabelSize();
663
664 for( int row = 0; aContents && row < GetNumberRows(); row++ )
665 size = std::max( size, int( GetTextExtent( GetRowLabelValue( row ) + wxS( "M" ) ).x ) );
666 }
667 else
668 {
669 if( aKeep )
670 size = GetColSize( aCol );
671
672 // 'M' is generally the widest character, so we buffer the column width by default to
673 // ensure we don't write a continuous line of text at the column header
674 if( aHeader )
675 {
677
678 size = std::max( size, int( GetTextExtent( GetColLabelValue( aCol ) + wxS( "M" ) ).x ) );
679 }
680
681 for( int row = 0; aContents && row < GetNumberRows(); row++ )
682 {
683 // If we have text, get the size. Otherwise, use a placeholder for the checkbox
684 if( GetTable()->CanGetValueAs( row, aCol, wxGRID_VALUE_STRING ) )
685 size = std::max( size, GetTextExtent( GetCellValue( row, aCol ) + wxS( "M" ) ).x );
686 else
687 size = std::max( size, GetTextExtent( "MM" ).x );
688 }
689 }
690
691 return size;
692}
693
694
696{
697 int line_height = int( GetTextExtent( "Mj" ).y ) + 3;
698 int row_height = GetColLabelSize();
699 int initial_row_height = row_height;
700
701 // Headers can be multiline. Fix the Column Label Height to show the full header
702 // However GetTextExtent does not work on multiline strings,
703 // and do not return the full text height (only the height of one line)
704 for( int col = 0; col < GetNumberCols(); col++ )
705 {
706 int nl_count = GetColLabelValue( col ).Freq( '\n' );
707
708 if( nl_count )
709 {
710 // Col Label height must be able to show nl_count+1 lines
711 if( row_height < line_height * ( nl_count+1 ) )
712 row_height += line_height * nl_count;
713 }
714 }
715
716 // Update the column label size, but only if needed, to avoid generating useless
717 // and perhaps annoying UI events when the size does not change
718 if( initial_row_height != row_height )
719 SetColLabelSize( row_height );
720}
int color
Definition: DXF_plotter.cpp:58
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.
Attribute provider that provides attributes (or modifies the existing attribute) to alternate a row c...
Definition: wx_grid.cpp:124
WX_GRID_ALT_ROW_COLOR_PROVIDER(const wxColor &aBaseColor)
Definition: wx_grid.cpp:126
wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) const override
Definition: wx_grid.cpp:142
void UpdateColors(const wxColor &aBaseColor)
Definition: wx_grid.cpp:133
wxGridCellAttrPtr m_attrOdd
Definition: wx_grid.cpp:168
void DrawBorder(const wxGrid &grid, wxDC &dc, wxRect &rect) const override
Definition: wx_grid.cpp:88
void DrawBorder(const wxGrid &grid, wxDC &dc, wxRect &rect) const override
Definition: wx_grid.cpp:71
void DrawBorder(const wxGrid &grid, wxDC &dc, wxRect &rect) const override
Definition: wx_grid.cpp:105
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:655
void onGridCellSelect(wxGridEvent &aEvent)
Definition: wx_grid.cpp:285
~WX_GRID() override
Definition: wx_grid.cpp:192
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:225
bool m_weOwnTable
Definition: wx_grid.h:198
void onDPIChanged(wxDPIChangedEvent &event)
Definition: wx_grid.cpp:201
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:408
std::map< int, UNITS_PROVIDER * > m_unitsProviders
Definition: wx_grid.h:200
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:231
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:364
bool CancelPendingChanges()
Definition: wx_grid.cpp:530
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:211
void SetUnitValue(int aRow, int aCol, int aValue)
Set a unitized cell's value.
Definition: wx_grid.cpp:637
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:172
int GetUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
Definition: wx_grid.cpp:616
std::vector< int > m_autoEvalCols
Definition: wx_grid.h:202
std::map< std::pair< int, int >, std::pair< wxString, wxString > > m_evalBeforeAfter
Definition: wx_grid.h:204
void DrawCornerLabel(wxDC &dc) override
A re-implementation of wxGrid::DrawCornerLabel which draws flat borders.
Definition: wx_grid.cpp:438
void onCellEditorHidden(wxGridEvent &aEvent)
Definition: wx_grid.cpp:327
void onGridColMove(wxGridEvent &aEvent)
Definition: wx_grid.cpp:648
void onCellEditorShown(wxGridEvent &aEvent)
Definition: wx_grid.cpp:312
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
Definition: wx_grid.cpp:695
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:378
void DrawRowLabel(wxDC &dc, int row) override
A re-implementation of wxGrid::DrawRowLabel which draws flat borders.
Definition: wx_grid.cpp:498
std::bitset< 64 > GetShownColumns()
Definition: wx_grid.cpp:397
static void CellEditorSetMargins(wxTextEntryBase *aEntry)
A helper function to set OS-specific margins for text-based cell editors.
Definition: wx_grid.cpp:44
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:266
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:607
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:558
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
Definition: wx_grid.h:201
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:459
static void CellEditorTransformSizeRect(wxRect &aRect)
A helper function to tweak sizes of text-based cell editors depending on OS.
Definition: wx_grid.cpp:51
bool IsDarkTheme()
Determine if the desktop interface is currently using a dark theme or a light theme.
Definition: gtk/ui.cpp:48
KICOMMON_API 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
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
Functions to provide common constants and other functions to assist in making a consistent UI.
wxColour getBorderColour()
Definition: wx_grid.cpp:59
#define MIN_GRIDCELL_MARGIN
Definition: wx_grid.cpp:41