More uniform handling of status fonts.

Fixes https://gitlab.com/kicad/code/kicad/issues/8608
This commit is contained in:
Jeff Young 2021-09-08 21:34:02 +01:00
parent e7debc495b
commit f013dbc7c4
8 changed files with 29 additions and 44 deletions

View File

@ -145,7 +145,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
};
SetStatusWidths( arrayDim( dims ), dims );
stsbar->SetFont( KIUI::GetInfoFont() );
stsbar->SetFont( KIUI::GetStatusFont() );
// Create child subwindows.
GetClientSize( &m_frameSize.x, &m_frameSize.y );

View File

@ -48,7 +48,7 @@ EDA_MSG_PANEL::EDA_MSG_PANEL( wxWindow* aParent, int aId,
long style, const wxString &name ) :
wxPanel( aParent, aId, aPosition, aSize, style, name )
{
SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) );
SetFont( KIUI::GetStatusFont() );
SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
// informs wx not to paint the background itself as we will paint it later in erase()
@ -56,7 +56,6 @@ EDA_MSG_PANEL::EDA_MSG_PANEL( wxWindow* aParent, int aId,
m_last_x = 0;
SetFont( KIUI::GetInfoFont() );
m_fontSize = GetTextExtent( wxT( "W" ) );
}
@ -71,7 +70,7 @@ int EDA_MSG_PANEL::GetRequiredHeight()
wxSize fontSizeInPixels;
wxScreenDC dc;
dc.SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) );
dc.SetFont( KIUI::GetStatusFont() );
dc.GetTextExtent( wxT( "W" ), &fontSizeInPixels.x, &fontSizeInPixels.y );
// make space for two rows of text plus a number of pixels between them.
@ -79,20 +78,6 @@ int EDA_MSG_PANEL::GetRequiredHeight()
}
wxSize EDA_MSG_PANEL::computeTextSize( const wxString& aText ) const
{
// Get size of the wxSYS_DEFAULT_GUI_FONT
wxSize textSizeInPixels;
wxScreenDC dc;
dc.SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) );
dc.GetTextExtent( aText, &textSizeInPixels.x, &textSizeInPixels.y );
return textSizeInPixels;
}
void EDA_MSG_PANEL::OnPaint( wxPaintEvent& aEvent )
{
wxPaintDC dc( this );
@ -102,7 +87,7 @@ void EDA_MSG_PANEL::OnPaint( wxPaintEvent& aEvent )
dc.SetBackground( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
dc.SetBackgroundMode( wxSOLID );
dc.SetTextBackground( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
dc.SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) );
dc.SetFont( KIUI::GetStatusFont() );
for( const MSG_PANEL_ITEM& item : m_Items )
showItem( dc, item );
@ -135,7 +120,7 @@ void EDA_MSG_PANEL::AppendMessage( const wxString& aUpperText, const wxString& a
item.m_UpperText = aUpperText;
item.m_LowerText = aLowerText;
m_Items.push_back( item );
m_last_x += computeTextSize( text ).x;
m_last_x += GetTextExtent( text ).x;
// Add an extra space between texts for a better look:
m_last_x += m_fontSize.x;

View File

@ -109,6 +109,19 @@ wxFont KIUI::GetInfoFont()
}
wxFont KIUI::GetStatusFont()
{
// wxFONTSIZE_X_SMALL is too small, so we take the wxFONTSIZE_SMALL infofont and adjust
// it by wxFONTSIZE_SMALL again.
wxFont font = GetInfoFont();
font.SetPointSize( wxFont::AdjustToSymbolicSize( wxFONTSIZE_SMALL, font.GetPointSize() ) );
return font;
}
bool KIUI::EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )
{
wxWindow* window = aCtrl->GetParent();
@ -176,14 +189,10 @@ void KIUI::SelectReferenceNumber( wxTextEntry* aTextEntry )
bool KIUI::IsInputControlFocused( wxWindow* aFocus )
{
if( aFocus == nullptr )
{
aFocus = wxWindow::FindFocus();
}
if( !aFocus )
{
return false;
}
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( aFocus );
wxStyledTextCtrl* styledText = dynamic_cast<wxStyledTextCtrl*>( aFocus );
@ -196,20 +205,17 @@ bool KIUI::IsInputControlFocused( wxWindow* aFocus )
wxSpinCtrlDouble* spinDblCtrl = dynamic_cast<wxSpinCtrlDouble*>( aFocus );
wxSlider* sliderCtl = dynamic_cast<wxSlider*>( aFocus );
// Data view control is annoying, the focus is on a "wxDataViewCtrlMainWindow"
// class that is not formerly exported via the header.
// However, we can test the parent is wxDataViewCtrl instead
// Data view control is annoying, the focus is on a "wxDataViewCtrlMainWindow" class that
// is not formerly exported via the header.
wxDataViewCtrl* dataViewCtrl = nullptr;
wxWindow* parent = aFocus->GetParent();
if( parent )
{
dataViewCtrl = dynamic_cast<wxDataViewCtrl*>( parent );
}
return ( textEntry || styledText || listBox || dataViewCtrl || searchCtrl || dataViewCtrl
|| checkboxCtrl || choiceCtrl || radioBtn || spinCtrl || spinDblCtrl || sliderCtl );
return ( textEntry || styledText || listBox || searchCtrl || checkboxCtrl || choiceCtrl
|| radioBtn || spinCtrl || spinDblCtrl || sliderCtl || dataViewCtrl );
}

View File

@ -116,10 +116,8 @@ DIALOG_TEXT_AND_LABEL_PROPERTIES::DIALOG_TEXT_AND_LABEL_PROPERTIES( SCH_EDIT_FRA
if( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T )
{
wxFont infoFont = KIUI::GetInfoFont();
infoFont.SetSymbolicSize( wxFONTSIZE_X_SMALL );
m_note1->SetFont( infoFont );
m_note2->SetFont( infoFont );
m_note1->SetFont( KIUI::GetStatusFont() );
m_note2->SetFont( KIUI::GetStatusFont() );
}
else
{

View File

@ -54,6 +54,8 @@ wxFont GetMonospacedUIFont();
wxFont GetInfoFont();
wxFont GetStatusFont();
/**
* Set the minimum pixel width on a text control in order to make a text
* string be fully visible within it.

View File

@ -78,9 +78,7 @@ PROPERTIES_FRAME::PROPERTIES_FRAME( PL_EDITOR_FRAME* aParent ) :
m_stcText->SetUseHorizontalScrollBar( false );
m_scintillaTricks = new SCINTILLA_TRICKS( m_stcText, wxT( "{}" ), false );
wxFont infoFont = KIUI::GetInfoFont();
infoFont.SetSymbolicSize( wxFONTSIZE_X_SMALL );
m_staticTextSizeInfo->SetFont( infoFont );
m_staticTextSizeInfo->SetFont( KIUI::GetStatusFont() );
m_buttonOK->SetDefault();

View File

@ -46,9 +46,7 @@ public:
m_sdbSizerOK->SetDefault();
m_choiceFpList->Append( aFpList );
wxFont infoFont = KIUI::GetInfoFont();
infoFont.SetSymbolicSize( wxFONTSIZE_X_SMALL );
m_multipleHint->SetFont( infoFont );
m_multipleHint->SetFont( KIUI::GetStatusFont() );
// Hide help string until someone implements successive placement (#2227)
m_multipleHint->Show( false );

View File

@ -131,9 +131,7 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO
m_OrientCtrl->SetString( ii, wxString::Format( "%.1f", rot_list[ii] ) );
// Set font sizes
wxFont infoFont = KIUI::GetInfoFont();
infoFont.SetSymbolicSize( wxFONTSIZE_X_SMALL );
m_statusLine->SetFont( infoFont );
m_statusLine->SetFont( KIUI::GetStatusFont() );
m_sdbSizerOK->SetDefault();