From 17712ba321548525caf50674330d19c1c113c1ca Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 17 Mar 2025 13:55:44 +0000 Subject: [PATCH] Improve text alignment in grids and one-line Scintilla controls. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16685 --- common/widgets/grid_text_helpers.cpp | 19 +++++++++++++++---- eeschema/dialogs/dialog_field_properties.cpp | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/common/widgets/grid_text_helpers.cpp b/common/widgets/grid_text_helpers.cpp index 9d8adfe6df..737b3587ed 100644 --- a/common/widgets/grid_text_helpers.cpp +++ b/common/widgets/grid_text_helpers.cpp @@ -47,8 +47,8 @@ void GRID_CELL_TEXT_EDITOR::StartingKey( wxKeyEvent& event ) { if( m_validator ) { - m_validator.get()->SetWindow( Text() ); - m_validator.get()->ProcessEvent( event ); + m_validator->SetWindow( Text() ); + m_validator->ProcessEvent( event ); } if( event.GetSkipped() ) @@ -66,9 +66,12 @@ void GRID_CELL_TEXT_EDITOR::SetSize( const wxRect& aRect ) #if defined( __WXMSW__ ) rect.Offset( 0, 1 ); +#elif defined( __WXMAC__ ) + rect.Offset( 0, 2 ); + rect.SetHeight( rect.GetHeight() - 4 ); #endif - wxGridCellEditor::SetSize( rect ); + wxGridCellEditor::SetSize( rect ); // NOLINT(*-parent-virtual-call) } @@ -125,7 +128,10 @@ void GRID_CELL_STC_EDITOR::SetSize( const wxRect& aRect ) #if defined( __WXMSW__ ) rect.Offset( -1, 1 ); #elif defined( __WXGTK__ ) - rect.Offset( -1, 3 ); + rect.Offset( -1, 1 ); +#else + rect.Offset( 1, 3 ); + rect.SetHeight( rect.GetHeight() - 6 ); #endif wxGridCellEditor::SetSize( rect ); @@ -137,6 +143,11 @@ void GRID_CELL_STC_EDITOR::Create( wxWindow* aParent, wxWindowID aId, wxEvtHandl m_control = new wxStyledTextCtrl( aParent, wxID_ANY, wxDefaultPosition, wxSize( 0, 0 ), wxBORDER_NONE ); +#ifdef __WXGTK__ + stc_ctrl()->SetExtraAscent( 6 ); + stc_ctrl()->SetExtraDescent( 2 ); +#endif + stc_ctrl()->SetTabIndents( false ); stc_ctrl()->SetBackSpaceUnIndents( false ); stc_ctrl()->SetViewEOL( false ); diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp index cf5d6830c2..701f11b780 100644 --- a/eeschema/dialogs/dialog_field_properties.cpp +++ b/eeschema/dialogs/dialog_field_properties.cpp @@ -76,6 +76,14 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const m_StyledTextCtrl->SetEOLMode( wxSTC_EOL_LF ); // Normalize EOL across platforms +#ifdef __WXGTK__ + m_StyledTextCtrl->SetExtraAscent( 6 ); + m_StyledTextCtrl->SetExtraDescent( 2 ); +#else + m_StyledTextCtrl->SetExtraAscent( 1 ); + m_StyledTextCtrl->SetExtraDescent( 2 ); +#endif + #ifdef _WIN32 // Without this setting, on Windows, some esoteric unicode chars create display issue // in a wxStyledTextCtrl.