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>
57 if( aSeverity == wxT(
"warning" ) )
59 else if( aSeverity == wxT(
"ignore" ) )
69 return wxT(
"ignore" );
71 return wxT(
"warning" );
73 return wxT(
"error" );
83 wxClientDC dc( aWindow );
84 dc.SetFont( aWindow->GetFont() );
85 dc.GetTextExtent( aSingleLine, &width, &height );
88 return wxSize( width, height );
94 static int guiFontSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
96 wxFont font( guiFontSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );
100 if( font.GetFaceName().IsEmpty() )
101 font.SetFaceName( wxS(
"Menlo" ) );
110 wxFont font = aWindow->GetFont();
112 font.SetPointSize( font.GetPointSize() + aRelativeSize );
114 if(
Pgm().GetCommonSettings()->m_Appearance.apply_icon_scale_to_fonts )
119 if( font.GetFaceName().IsEmpty() )
120 font.SetFaceName( wxS(
"San Francisco" ) );
168 wxWindow* window = aCtrl->GetParent();
177 ctrlText = aCtrl->GetValue();
182 wxSize ctrlz = aCtrl->GetSize();
184 if( ctrlz.GetWidth() < textz.GetWidth() + 10 )
186 ctrlz.SetWidth( textz.GetWidth() + 10 );
187 aCtrl->SetSizeHints( ctrlz );
199 msg.Replace( wxT(
"\n" ), wxT(
" " ) );
200 msg.Replace( wxT(
"\r" ), wxT(
" " ) );
201 msg.Replace( wxT(
"\t" ), wxT(
" " ) );
203 wxClientDC dc( aWindow );
204 int statusWidth = aWindow->GetSize().GetWidth();
207 int textWidth = std::min( statusWidth, 800 ) * 0.3 + std::max( statusWidth - 800, 0 ) * 0.6;
209 return wxControl::Ellipsize( msg, dc, wxELLIPSIZE_END, textWidth );
217 msg.Replace( wxT(
"\n" ), wxT(
" " ) );
218 msg.Replace( wxT(
"\r" ), wxT(
" " ) );
219 msg.Replace( wxT(
"\t" ), wxT(
" " ) );
221 if( msg.Length() > 36 )
222 msg = msg.Left( 34 ) + wxT(
"..." );
230 wxString ref = aTextEntry->GetValue();
232 if( ref.find_first_of(
'?' ) != ref.npos )
234 aTextEntry->SetSelection( ref.find_first_of(
'?' ), ref.find_last_of(
'?' ) + 1 );
236 else if( ref.find_first_of(
'*' ) != ref.npos )
238 aTextEntry->SetSelection( ref.find_first_of(
'*' ), ref.find_last_of(
'*' ) + 1 );
244 while( !num.IsEmpty() && ( !isdigit( num.Last() ) || !isdigit( num.GetChar( 0 ) ) ) )
247 if( !isdigit( num.Last() ) )
251 if( !num.IsEmpty() && !isdigit( num.GetChar( 0 ) ) )
252 num = num.Right( num.Length() - 1 );
255 aTextEntry->SetSelection( ref.Find( num ), ref.Find( num ) + num.Length() );
258 aTextEntry->SetSelection( -1, -1 );
265 if( aFocus ==
nullptr )
266 aFocus = wxWindow::FindFocus();
275 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( aFocus );
276 wxStyledTextCtrl* styledText =
dynamic_cast<wxStyledTextCtrl*
>( aFocus );
277 wxListBox* listBox =
dynamic_cast<wxListBox*
>( aFocus );
278 wxSearchCtrl* searchCtrl =
dynamic_cast<wxSearchCtrl*
>( aFocus );
279 wxCheckBox* checkboxCtrl =
dynamic_cast<wxCheckBox*
>( aFocus );
280 wxChoice* choiceCtrl =
dynamic_cast<wxChoice*
>( aFocus );
281 wxRadioButton* radioBtn =
dynamic_cast<wxRadioButton*
>( aFocus );
282 wxSpinCtrl* spinCtrl =
dynamic_cast<wxSpinCtrl*
>( aFocus );
283 wxSpinCtrlDouble* spinDblCtrl =
dynamic_cast<wxSpinCtrlDouble*
>( aFocus );
284 wxSlider* sliderCtl =
dynamic_cast<wxSlider*
>( aFocus );
288 wxDataViewCtrl* dataViewCtrl =
nullptr;
290 wxWindow* parent = aFocus->GetParent();
293 dataViewCtrl =
dynamic_cast<wxDataViewCtrl*
>( parent );
295 return ( textEntry || styledText || listBox || searchCtrl || checkboxCtrl || choiceCtrl
296 || radioBtn || spinCtrl || spinDblCtrl || sliderCtl || dataViewCtrl );
302 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( aFocus );
303 wxStyledTextCtrl* styledText =
dynamic_cast<wxStyledTextCtrl*
>( aFocus );
304 wxSearchCtrl* searchCtrl =
dynamic_cast<wxSearchCtrl*
>( aFocus );
307 return textEntry->IsEditable();
308 else if( styledText )
309 return styledText->IsEditable();
310 else if( searchCtrl )
311 return searchCtrl->IsEditable();
325 wxScrollBar* scrollBar =
dynamic_cast<wxScrollBar*
>( aWindow );
326 wxGrid*
grid =
dynamic_cast<wxGrid*
>( aWindow );
327 wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aWindow );
328 wxControl* control =
dynamic_cast<wxControl*
>( aWindow );
336 for(
int row = 0; row <
grid->GetNumberRows(); ++row )
338 for(
int col = 0; col <
grid->GetNumberCols(); ++col )
339 grid->SetReadOnly( row, col );
344 scintilla->SetReadOnly(
true );
352 for( wxWindow* child : aWindow->GetChildren() )
363 wxItemKind menu_type = aMenu->GetKind();
365 if( useImagesInMenus && menu_type != wxITEM_CHECK && menu_type != wxITEM_RADIO )
367 aMenu->SetBitmap( aImage );
373 const wxBitmapBundle& aImage, wxItemKind aType )
375 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText, wxEmptyString, aType );
378 aMenu->Append( item );
385 const wxString& aHelpText,
const wxBitmapBundle& aImage,
388 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText, aHelpText, aType );
391 aMenu->Append( item );
398 const wxBitmapBundle& aImage )
400 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText );
401 item->SetSubMenu( aSubMenu );
404 aMenu->Append( item );
411 const wxString& aHelpText,
const wxBitmapBundle& aImage )
413 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText, aHelpText );
414 item->SetSubMenu( aSubMenu );
417 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.