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>
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( wxS(
"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( wxS(
"San Francisco" ) );
170 wxWindow* window = aCtrl->GetParent();
179 ctrlText = aCtrl->GetValue();
184 wxSize ctrlz = aCtrl->GetSize();
186 if( ctrlz.GetWidth() < textz.GetWidth() + 10 )
188 ctrlz.SetWidth( textz.GetWidth() + 10 );
189 aCtrl->SetSizeHints( ctrlz );
201 msg.Replace( wxT(
"\n" ), wxT(
" " ) );
202 msg.Replace( wxT(
"\r" ), wxT(
" " ) );
203 msg.Replace( wxT(
"\t" ), wxT(
" " ) );
205 wxClientDC dc( aWindow );
206 int statusWidth = aWindow->GetSize().GetWidth();
209 int textWidth = std::min( statusWidth, 800 ) * 0.3 + std::max( statusWidth - 800, 0 ) * 0.6;
211 return wxControl::Ellipsize( msg, dc, wxELLIPSIZE_END, textWidth );
219 msg.Replace( wxT(
"\n" ), wxT(
" " ) );
220 msg.Replace( wxT(
"\r" ), wxT(
" " ) );
221 msg.Replace( wxT(
"\t" ), wxT(
" " ) );
223 if( msg.Length() > 36 )
224 msg = msg.Left( 34 ) + wxT(
"..." );
232 wxString ref = aTextEntry->GetValue();
234 if( ref.find_first_of(
'?' ) != ref.npos )
236 aTextEntry->SetSelection( ref.find_first_of(
'?' ), ref.find_last_of(
'?' ) + 1 );
238 else if( ref.find_first_of(
'*' ) != ref.npos )
240 aTextEntry->SetSelection( ref.find_first_of(
'*' ), ref.find_last_of(
'*' ) + 1 );
246 while( !num.IsEmpty() && ( !isdigit( num.Last() ) || !isdigit( num.GetChar( 0 ) ) ) )
249 if( !isdigit( num.Last() ) )
253 if( !num.IsEmpty() && !isdigit( num.GetChar( 0 ) ) )
254 num = num.Right( num.Length() - 1 );
257 aTextEntry->SetSelection( ref.Find( num ), ref.Find( num ) + num.Length() );
260 aTextEntry->SetSelection( -1, -1 );
267 if( aFocus ==
nullptr )
268 aFocus = wxWindow::FindFocus();
273 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( aFocus );
274 wxStyledTextCtrl* styledText =
dynamic_cast<wxStyledTextCtrl*
>( aFocus );
275 wxListBox* listBox =
dynamic_cast<wxListBox*
>( aFocus );
276 wxSearchCtrl* searchCtrl =
dynamic_cast<wxSearchCtrl*
>( aFocus );
277 wxCheckBox* checkboxCtrl =
dynamic_cast<wxCheckBox*
>( aFocus );
278 wxChoice* choiceCtrl =
dynamic_cast<wxChoice*
>( aFocus );
279 wxRadioButton* radioBtn =
dynamic_cast<wxRadioButton*
>( aFocus );
280 wxSpinCtrl* spinCtrl =
dynamic_cast<wxSpinCtrl*
>( aFocus );
281 wxSpinCtrlDouble* spinDblCtrl =
dynamic_cast<wxSpinCtrlDouble*
>( aFocus );
282 wxSlider* sliderCtl =
dynamic_cast<wxSlider*
>( aFocus );
286 wxDataViewCtrl* dataViewCtrl =
nullptr;
288 wxWindow* parent = aFocus->GetParent();
291 dataViewCtrl =
dynamic_cast<wxDataViewCtrl*
>( parent );
293 return ( textEntry || styledText || listBox || searchCtrl || checkboxCtrl || choiceCtrl
294 || radioBtn || spinCtrl || spinDblCtrl || sliderCtl || dataViewCtrl );
300 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( aFocus );
301 wxStyledTextCtrl* styledText =
dynamic_cast<wxStyledTextCtrl*
>( aFocus );
302 wxSearchCtrl* searchCtrl =
dynamic_cast<wxSearchCtrl*
>( aFocus );
305 return textEntry->IsEditable();
306 else if( styledText )
307 return styledText->IsEditable();
308 else if( searchCtrl )
309 return searchCtrl->IsEditable();
317 return !
Pgm().m_ModalDialogs.empty();
323 wxScrollBar* scrollBar =
dynamic_cast<wxScrollBar*
>( aWindow );
324 wxGrid*
grid =
dynamic_cast<wxGrid*
>( aWindow );
325 wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aWindow );
326 wxControl*
control =
dynamic_cast<wxControl*
>( aWindow );
334 for(
int row = 0; row <
grid->GetNumberRows(); ++row )
336 for(
int col = 0; col <
grid->GetNumberCols(); ++col )
337 grid->SetReadOnly( row, col );
342 scintilla->SetReadOnly(
true );
350 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.
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.
must_if< error >::control< Rule > control
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".