20#include <wx/dcclient.h>
21#include <wx/checkbox.h>
23#include <wx/listbox.h>
24#include <wx/dataview.h>
25#include <wx/radiobut.h>
27#include <wx/spinctrl.h>
28#include <wx/srchctrl.h>
29#include <wx/stc/stc.h>
30#include <wx/scrolbar.h>
37#include <wx/settings.h>
54 if( aSeverity == wxT(
"warning" ) )
56 else if( aSeverity == wxT(
"ignore" ) )
66 return wxT(
"ignore" );
68 return wxT(
"warning" );
70 return wxT(
"error" );
80 wxClientDC dc( aWindow );
81 dc.SetFont( aWindow->GetFont() );
82 dc.GetTextExtent( aSingleLine, &width, &height );
85 return wxSize( width, height );
91 static int guiFontSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
93 wxFont font( guiFontSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );
97 if( font.GetFaceName().IsEmpty() )
98 font.SetFaceName( wxS(
"Menlo" ) );
107 wxFont font = aWindow->GetFont();
109 font.SetPointSize( font.GetPointSize() + aRelativeSize );
111 if(
Pgm().GetCommonSettings()->m_Appearance.apply_icon_scale_to_fonts )
113 double icon_scale_fourths;
115 if(
Pgm().GetCommonSettings()->m_Appearance.icon_scale <= 0 )
118 icon_scale_fourths =
Pgm().GetCommonSettings()->m_Appearance.icon_scale;
120 font.SetPointSize(
KiROUND( icon_scale_fourths * font.GetPointSize() / 4.0 ) );
125 if( font.GetFaceName().IsEmpty() )
126 font.SetFaceName( wxS(
"San Francisco" ) );
174 wxWindow* window = aCtrl->GetParent();
183 ctrlText = aCtrl->GetValue();
188 wxSize ctrlz = aCtrl->GetSize();
190 if( ctrlz.GetWidth() < textz.GetWidth() + 10 )
192 ctrlz.SetWidth( textz.GetWidth() + 10 );
193 aCtrl->SetSizeHints( ctrlz );
205 msg.Replace( wxT(
"\n" ), wxT(
" " ) );
206 msg.Replace( wxT(
"\r" ), wxT(
" " ) );
207 msg.Replace( wxT(
"\t" ), wxT(
" " ) );
209 wxClientDC dc( aWindow );
210 int statusWidth = aWindow->GetSize().GetWidth();
213 int textWidth = std::min( statusWidth, 800 ) * 0.3 + std::max( statusWidth - 800, 0 ) * 0.6;
215 return wxControl::Ellipsize( msg, dc, wxELLIPSIZE_END, textWidth );
223 msg.Replace( wxT(
"\n" ), wxT(
" " ) );
224 msg.Replace( wxT(
"\r" ), wxT(
" " ) );
225 msg.Replace( wxT(
"\t" ), wxT(
" " ) );
227 if( msg.Length() > 36 )
228 msg = msg.Left( 34 ) + wxT(
"..." );
236 wxString ref = aTextEntry->GetValue();
238 if( ref.find_first_of(
'?' ) != ref.npos )
240 aTextEntry->SetSelection( ref.find_first_of(
'?' ), ref.find_last_of(
'?' ) + 1 );
242 else if( ref.find_first_of(
'*' ) != ref.npos )
244 aTextEntry->SetSelection( ref.find_first_of(
'*' ), ref.find_last_of(
'*' ) + 1 );
250 while( !num.IsEmpty() && ( !isdigit( num.Last() ) || !isdigit( num.GetChar( 0 ) ) ) )
253 if( !isdigit( num.Last() ) )
257 if( !num.IsEmpty() && !isdigit( num.GetChar( 0 ) ) )
258 num = num.Right( num.Length() - 1 );
261 aTextEntry->SetSelection( ref.Find( num ), ref.Find( num ) + num.Length() );
264 aTextEntry->SetSelection( -1, -1 );
271 if( aFocus ==
nullptr )
272 aFocus = wxWindow::FindFocus();
281 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( aFocus );
282 wxStyledTextCtrl* styledText =
dynamic_cast<wxStyledTextCtrl*
>( aFocus );
283 wxListBox* listBox =
dynamic_cast<wxListBox*
>( aFocus );
284 wxSearchCtrl* searchCtrl =
dynamic_cast<wxSearchCtrl*
>( aFocus );
285 wxCheckBox* checkboxCtrl =
dynamic_cast<wxCheckBox*
>( aFocus );
286 wxChoice* choiceCtrl =
dynamic_cast<wxChoice*
>( aFocus );
287 wxRadioButton* radioBtn =
dynamic_cast<wxRadioButton*
>( aFocus );
288 wxSpinCtrl* spinCtrl =
dynamic_cast<wxSpinCtrl*
>( aFocus );
289 wxSpinCtrlDouble* spinDblCtrl =
dynamic_cast<wxSpinCtrlDouble*
>( aFocus );
290 wxSlider* sliderCtl =
dynamic_cast<wxSlider*
>( aFocus );
294 wxDataViewCtrl* dataViewCtrl =
nullptr;
296 wxWindow* parent = aFocus->GetParent();
299 dataViewCtrl =
dynamic_cast<wxDataViewCtrl*
>( parent );
301 return ( textEntry || styledText || listBox || searchCtrl || checkboxCtrl || choiceCtrl
302 || radioBtn || spinCtrl || spinDblCtrl || sliderCtl || dataViewCtrl );
308 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( aFocus );
309 wxStyledTextCtrl* styledText =
dynamic_cast<wxStyledTextCtrl*
>( aFocus );
310 wxSearchCtrl* searchCtrl =
dynamic_cast<wxSearchCtrl*
>( aFocus );
313 return textEntry->IsEditable();
314 else if( styledText )
315 return styledText->IsEditable();
316 else if( searchCtrl )
317 return searchCtrl->IsEditable();
325 return !
Pgm().m_ModalDialogs.empty();
331 wxScrollBar* scrollBar =
dynamic_cast<wxScrollBar*
>( aWindow );
332 wxGrid*
grid =
dynamic_cast<wxGrid*
>( aWindow );
333 wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aWindow );
334 wxControl* control =
dynamic_cast<wxControl*
>( aWindow );
342 for(
int row = 0; row <
grid->GetNumberRows(); ++row )
344 for(
int col = 0; col <
grid->GetNumberCols(); ++col )
345 grid->SetReadOnly( row, col );
350 scintilla->SetReadOnly(
true );
358 for( wxWindow* child : aWindow->GetChildren() )
int KiIconScale(wxWindow *aWindow)
Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScale...
wxFont GetMonospacedUIFont()
int GetStdMargin()
Get the standard margin around a widget in the KiCad UI.
wxFont GetDockedPaneFont(wxWindow *aWindow)
wxFont GetStatusFont(wxWindow *aWindow)
bool IsInputControlFocused(wxWindow *aFocus=nullptr)
Check if a input control has focus.
bool IsInputControlEditable(wxWindow *aControl)
Check if a input control has focus.
wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
wxFont GetInfoFont(wxWindow *aWindow)
bool IsModalDialogFocused()
wxFont GetControlFont(wxWindow *aWindow)
wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
const wxString s_FocusStealableInputName
void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString=nullptr)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
void Disable(wxWindow *aWindow)
Makes a window read-only.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxString UnescapeString(const wxString &aSource)
SEVERITY SeverityFromString(const wxString &aSeverity)
wxString SeverityToString(const SEVERITY &aSeverity)
wxFont getGUIFont(wxWindow *aWindow, int aRelativeSize)
Functions to provide common constants and other functions to assist in making a consistent UI.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".