20#include <wx/dcclient.h>
21#include <wx/checkbox.h>
24#include <wx/menuitem.h>
25#include <wx/listbox.h>
26#include <wx/dataview.h>
27#include <wx/radiobut.h>
29#include <wx/spinctrl.h>
30#include <wx/srchctrl.h>
31#include <wx/stc/stc.h>
32#include <wx/scrolbar.h>
39#include <wx/settings.h>
43#include <wx/hyperlink.h>
58 if( aSeverity == wxT(
"warning" ) )
60 else if( aSeverity == wxT(
"ignore" ) )
70 return wxT(
"ignore" );
72 return wxT(
"warning" );
74 return wxT(
"error" );
84 wxClientDC dc( aWindow );
85 dc.SetFont( aWindow->GetFont() );
86 dc.GetTextExtent( aSingleLine, &width, &height );
89 return wxSize( width, height );
95 static int guiFontSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
97 wxFont font( guiFontSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );
101 if( font.GetFaceName().IsEmpty() )
102 font.SetFaceName( wxS(
"Menlo" ) );
111 wxFont font = aWindow->GetFont();
113 font.SetPointSize( font.GetPointSize() + aRelativeSize );
115 if(
Pgm().GetCommonSettings()->m_Appearance.apply_icon_scale_to_fonts )
120 if( font.GetFaceName().IsEmpty() )
121 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();
277 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( aFocus );
278 wxStyledTextCtrl* styledText =
dynamic_cast<wxStyledTextCtrl*
>( aFocus );
279 wxListBox* listBox =
dynamic_cast<wxListBox*
>( aFocus );
280 wxSearchCtrl* searchCtrl =
dynamic_cast<wxSearchCtrl*
>( aFocus );
281 wxCheckBox* checkboxCtrl =
dynamic_cast<wxCheckBox*
>( aFocus );
282 wxChoice* choiceCtrl =
dynamic_cast<wxChoice*
>( aFocus );
283 wxRadioButton* radioBtn =
dynamic_cast<wxRadioButton*
>( aFocus );
284 wxSpinCtrl* spinCtrl =
dynamic_cast<wxSpinCtrl*
>( aFocus );
285 wxSpinCtrlDouble* spinDblCtrl =
dynamic_cast<wxSpinCtrlDouble*
>( aFocus );
286 wxSlider* sliderCtl =
dynamic_cast<wxSlider*
>( aFocus );
290 wxDataViewCtrl* dataViewCtrl =
nullptr;
292 wxWindow* parent = aFocus->GetParent();
295 dataViewCtrl =
dynamic_cast<wxDataViewCtrl*
>( parent );
297 return ( textEntry || styledText || listBox || searchCtrl || checkboxCtrl || choiceCtrl
298 || radioBtn || spinCtrl || spinDblCtrl || sliderCtl || dataViewCtrl );
304 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( aFocus );
305 wxStyledTextCtrl* styledText =
dynamic_cast<wxStyledTextCtrl*
>( aFocus );
306 wxSearchCtrl* searchCtrl =
dynamic_cast<wxSearchCtrl*
>( aFocus );
309 return textEntry->IsEditable();
310 else if( styledText )
311 return styledText->IsEditable();
312 else if( searchCtrl )
313 return searchCtrl->IsEditable();
328 wxScrollBar* scrollBar =
dynamic_cast<wxScrollBar*
>( aWindow );
329 wxHyperlinkCtrl* hyperlink =
dynamic_cast<wxHyperlinkCtrl*
>( aWindow );
330 wxGrid*
grid =
dynamic_cast<wxGrid*
>( aWindow );
331 wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aWindow );
332 wxControl* control =
dynamic_cast<wxControl*
>( aWindow );
334 if( scrollBar || hyperlink )
340 for(
int row = 0; row <
grid->GetNumberRows(); ++row )
342 for(
int col = 0; col <
grid->GetNumberCols(); ++col )
343 grid->SetReadOnly( row, col );
348 scintilla->SetReadOnly(
true );
356 for( wxWindow* child : aWindow->GetChildren() )
367 wxItemKind menu_type = aMenu->GetKind();
369 if( useImagesInMenus && menu_type != wxITEM_CHECK && menu_type != wxITEM_RADIO )
371 aMenu->SetBitmap( aImage );
377 const wxBitmapBundle& aImage, wxItemKind aType )
379 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText, wxEmptyString, aType );
382 aMenu->Append( item );
389 const wxString& aHelpText,
const wxBitmapBundle& aImage,
392 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText, aHelpText, aType );
395 aMenu->Append( item );
402 const wxBitmapBundle& aImage )
404 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText );
405 item->SetSubMenu( aSubMenu );
408 aMenu->Append( item );
415 const wxString& aHelpText,
const wxBitmapBundle& aImage )
417 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText, aHelpText );
418 item->SetSubMenu( aSubMenu );
421 aMenu->Append( item );
int KiIconScale(wxWindow *aWindow)
Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScale...
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
virtual COMMON_SETTINGS * GetCommonSettings() const
std::vector< void * > m_ModalDialogs
KICOMMON_API wxFont GetMonospacedUIFont()
KICOMMON_API int GetStdMargin()
Get the standard margin around a widget in the KiCad UI.
KICOMMON_API wxFont GetDockedPaneFont(wxWindow *aWindow)
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
KICOMMON_API bool IsInputControlFocused(wxWindow *aFocus=nullptr)
Check if a input control has focus.
KICOMMON_API bool IsInputControlEditable(wxWindow *aControl)
Check if a input control has focus.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
KICOMMON_API bool IsModalDialogFocused()
KICOMMON_API wxFont GetControlFont(wxWindow *aWindow)
KICOMMON_API wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmapBundle &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
KICOMMON_API const wxString s_FocusStealableInputName
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
KICOMMON_API 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...
KICOMMON_API void AddBitmapToMenuItem(wxMenuItem *aMenu, const wxBitmapBundle &aImage)
Add a bitmap to a menuitem.
KICOMMON_API 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 ...
KICOMMON_API void Disable(wxWindow *aWindow)
Makes a window read-only.
PGM_BASE & Pgm()
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.