20 #include <wx/dcclient.h> 21 #include <wx/checkbox.h> 22 #include <wx/choice.h> 23 #include <wx/listbox.h> 24 #include <wx/dataview.h> 25 #include <wx/radiobut.h> 26 #include <wx/slider.h> 27 #include <wx/spinctrl.h> 28 #include <wx/srchctrl.h> 29 #include <wx/stc/stc.h> 30 #include <wx/scrolbar.h> 31 #include <wx/scrolwin.h> 38 #include <wx/settings.h> 50 if( aSeverity == wxT(
"warning" ) )
52 else if( aSeverity == wxT(
"ignore" ) )
62 return wxT(
"ignore" );
64 return wxT(
"warning" );
66 return wxT(
"error" );
76 wxClientDC dc( aWindow );
77 dc.SetFont( aWindow->GetFont() );
78 dc.GetTextExtent( aSingleLine, &width, &height );
81 return wxSize( width, height );
87 static int guiFontSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
89 wxFont font( guiFontSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );
93 if( font.GetFaceName().IsEmpty() )
94 font.SetFaceName( wxT(
"Menlo" ) );
103 wxFont font = aWindow->GetFont();
105 font.SetPointSize( font.GetPointSize() + aRelativeSize );
107 if(
Pgm().GetCommonSettings()->m_Appearance.apply_icon_scale_to_fonts )
109 double icon_scale_fourths;
111 if(
Pgm().GetCommonSettings()->m_Appearance.icon_scale <= 0 )
114 icon_scale_fourths =
Pgm().GetCommonSettings()->m_Appearance.icon_scale;
116 font.SetPointSize(
KiROUND( icon_scale_fourths * font.GetPointSize() / 4.0 ) );
121 if( font.GetFaceName().IsEmpty() )
122 font.SetFaceName( wxT(
"San Francisco" ) );
158 wxWindow* window = aCtrl->GetParent();
167 ctrlText = aCtrl->GetValue();
172 wxSize ctrlz = aCtrl->GetSize();
174 if( ctrlz.GetWidth() < textz.GetWidth() + 10 )
176 ctrlz.SetWidth( textz.GetWidth() + 10 );
177 aCtrl->SetSizeHints( ctrlz );
187 wxString ref = aTextEntry->GetValue();
189 if( ref.find_first_of(
'?' ) != ref.npos )
191 aTextEntry->SetSelection( ref.find_first_of(
'?' ), ref.find_last_of(
'?' ) + 1 );
193 else if( ref.find_first_of(
'*' ) != ref.npos )
195 aTextEntry->SetSelection( ref.find_first_of(
'*' ), ref.find_last_of(
'*' ) + 1 );
201 while( !num.IsEmpty() && ( !isdigit( num.Last() ) || !isdigit( num.GetChar( 0 ) ) ) )
204 if( !isdigit( num.Last() ) )
208 if( !num.IsEmpty() && !isdigit( num.GetChar( 0 ) ) )
209 num = num.Right( num.Length() - 1 );
212 aTextEntry->SetSelection( ref.Find( num ), ref.Find( num ) + num.Length() );
215 aTextEntry->SetSelection( -1, -1 );
222 if( aFocus ==
nullptr )
223 aFocus = wxWindow::FindFocus();
228 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( aFocus );
229 wxStyledTextCtrl* styledText = dynamic_cast<wxStyledTextCtrl*>( aFocus );
230 wxListBox* listBox = dynamic_cast<wxListBox*>( aFocus );
231 wxSearchCtrl* searchCtrl = dynamic_cast<wxSearchCtrl*>( aFocus );
232 wxCheckBox* checkboxCtrl = dynamic_cast<wxCheckBox*>( aFocus );
233 wxChoice* choiceCtrl = dynamic_cast<wxChoice*>( aFocus );
234 wxRadioButton* radioBtn = dynamic_cast<wxRadioButton*>( aFocus );
235 wxSpinCtrl* spinCtrl = dynamic_cast<wxSpinCtrl*>( aFocus );
236 wxSpinCtrlDouble* spinDblCtrl = dynamic_cast<wxSpinCtrlDouble*>( aFocus );
237 wxSlider* sliderCtl = dynamic_cast<wxSlider*>( aFocus );
241 wxDataViewCtrl* dataViewCtrl =
nullptr;
243 wxWindow* parent = aFocus->GetParent();
246 dataViewCtrl = dynamic_cast<wxDataViewCtrl*>( parent );
248 return ( textEntry || styledText || listBox || searchCtrl || checkboxCtrl || choiceCtrl
249 || radioBtn || spinCtrl || spinDblCtrl || sliderCtl || dataViewCtrl );
255 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( aFocus );
256 wxStyledTextCtrl* styledText = dynamic_cast<wxStyledTextCtrl*>( aFocus );
257 wxSearchCtrl* searchCtrl = dynamic_cast<wxSearchCtrl*>( aFocus );
260 return textEntry->IsEditable();
261 else if( styledText )
262 return styledText->IsEditable();
263 else if( searchCtrl )
264 return searchCtrl->IsEditable();
272 return Pgm().m_ModalDialogCount > 0;
278 wxScrollBar* scrollBar = dynamic_cast<wxScrollBar*>( aWindow );
279 wxGrid*
grid = dynamic_cast<wxGrid*>( aWindow );
280 wxStyledTextCtrl* scintilla = dynamic_cast<wxStyledTextCtrl*>( aWindow );
281 wxControl* control = dynamic_cast<wxControl*>( aWindow );
289 for(
int row = 0; row <
grid->GetNumberRows(); ++row )
291 for(
int col = 0; col <
grid->GetNumberCols(); ++col )
292 grid->SetReadOnly( row, col );
297 scintilla->SetReadOnly(
true );
305 for( wxWindow* child : aWindow->GetChildren() )
void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
bool IsModalDialogFocused()
bool IsInputControlEditable(wxWindow *aControl)
Check if a input control has focus.
void Disable(wxWindow *aWindow)
Makes a window read-only.
wxFont GetMonospacedUIFont()
int KiIconScale(wxWindow *aWindow)
Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScale...
wxFont GetInfoFont(wxWindow *aWindow)
int GetStdMargin()
Get the standard margin around a widget in the KiCad UI.
wxFont GetControlFont(wxWindow *aWindow)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
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 ...
bool IsInputControlFocused(wxWindow *aFocus=nullptr)
Check if a input control has focus.
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...
Functions to provide common constants and other functions to assist in making a consistent UI.
wxFont GetStatusFont(wxWindow *aWindow)
wxString SeverityToString(const SEVERITY &aSeverity)
wxFont getGUIFont(wxWindow *aWindow, int aRelativeSize)
SEVERITY SeverityFromString(const wxString &aSeverity)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".