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" ) );
176 wxWindow* window = aCtrl->GetParent();
185 ctrlText = aCtrl->GetValue();
190 wxSize ctrlz = aCtrl->GetSize();
192 if( ctrlz.GetWidth() < textz.GetWidth() + 10 )
194 ctrlz.SetWidth( textz.GetWidth() + 10 );
195 aCtrl->SetSizeHints( ctrlz );
207 msg.Replace( wxT(
"\n" ), wxT(
" " ) );
208 msg.Replace( wxT(
"\r" ), wxT(
" " ) );
209 msg.Replace( wxT(
"\t" ), wxT(
" " ) );
211 wxClientDC dc( aWindow );
212 int statusWidth = aWindow->GetSize().GetWidth();
215 int textWidth = std::min( statusWidth, 800 ) * 0.3 + std::max( statusWidth - 800, 0 ) * 0.6;
217 return wxControl::Ellipsize( msg, dc, wxELLIPSIZE_END, textWidth );
225 msg.Replace( wxT(
"\n" ), wxT(
" " ) );
226 msg.Replace( wxT(
"\r" ), wxT(
" " ) );
227 msg.Replace( wxT(
"\t" ), wxT(
" " ) );
229 if( msg.Length() > 36 )
230 msg = msg.Left( 34 ) + wxT(
"..." );
238 wxString ref = aTextEntry->GetValue();
240 if( ref.find_first_of(
'?' ) != ref.npos )
242 aTextEntry->SetSelection( ref.find_first_of(
'?' ), ref.find_last_of(
'?' ) + 1 );
244 else if( ref.find_first_of(
'*' ) != ref.npos )
246 aTextEntry->SetSelection( ref.find_first_of(
'*' ), ref.find_last_of(
'*' ) + 1 );
252 while( !num.IsEmpty() && ( !isdigit( num.Last() ) || !isdigit( num.GetChar( 0 ) ) ) )
255 if( !isdigit( num.Last() ) )
259 if( !num.IsEmpty() && !isdigit( num.GetChar( 0 ) ) )
260 num = num.Right( num.Length() - 1 );
263 aTextEntry->SetSelection( ref.Find( num ), ref.Find( num ) + num.Length() );
266 aTextEntry->SetSelection( -1, -1 );
273 if( aFocus ==
nullptr )
274 aFocus = wxWindow::FindFocus();
283 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( aFocus );
284 wxStyledTextCtrl* styledText =
dynamic_cast<wxStyledTextCtrl*
>( aFocus );
285 wxListBox* listBox =
dynamic_cast<wxListBox*
>( aFocus );
286 wxSearchCtrl* searchCtrl =
dynamic_cast<wxSearchCtrl*
>( aFocus );
287 wxCheckBox* checkboxCtrl =
dynamic_cast<wxCheckBox*
>( aFocus );
288 wxChoice* choiceCtrl =
dynamic_cast<wxChoice*
>( aFocus );
289 wxRadioButton* radioBtn =
dynamic_cast<wxRadioButton*
>( aFocus );
290 wxSpinCtrl* spinCtrl =
dynamic_cast<wxSpinCtrl*
>( aFocus );
291 wxSpinCtrlDouble* spinDblCtrl =
dynamic_cast<wxSpinCtrlDouble*
>( aFocus );
292 wxSlider* sliderCtl =
dynamic_cast<wxSlider*
>( aFocus );
296 wxDataViewCtrl* dataViewCtrl =
nullptr;
298 wxWindow* parent = aFocus->GetParent();
301 dataViewCtrl =
dynamic_cast<wxDataViewCtrl*
>( parent );
303 return ( textEntry || styledText || listBox || searchCtrl || checkboxCtrl || choiceCtrl
304 || radioBtn || spinCtrl || spinDblCtrl || sliderCtl || dataViewCtrl );
310 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( aFocus );
311 wxStyledTextCtrl* styledText =
dynamic_cast<wxStyledTextCtrl*
>( aFocus );
312 wxSearchCtrl* searchCtrl =
dynamic_cast<wxSearchCtrl*
>( aFocus );
315 return textEntry->IsEditable();
316 else if( styledText )
317 return styledText->IsEditable();
318 else if( searchCtrl )
319 return searchCtrl->IsEditable();
334 wxScrollBar* scrollBar =
dynamic_cast<wxScrollBar*
>( aWindow );
335 wxHyperlinkCtrl* hyperlink =
dynamic_cast<wxHyperlinkCtrl*
>( aWindow );
336 wxGrid*
grid =
dynamic_cast<wxGrid*
>( aWindow );
337 wxStyledTextCtrl* scintilla =
dynamic_cast<wxStyledTextCtrl*
>( aWindow );
338 wxControl* control =
dynamic_cast<wxControl*
>( aWindow );
340 if( scrollBar || hyperlink )
346 for(
int row = 0; row <
grid->GetNumberRows(); ++row )
348 for(
int col = 0; col <
grid->GetNumberCols(); ++col )
349 grid->SetReadOnly( row, col );
354 scintilla->SetReadOnly(
true );
362 for( wxWindow* child : aWindow->GetChildren() )
373 wxItemKind menu_type = aMenu->GetKind();
375 if( useImagesInMenus && menu_type != wxITEM_CHECK && menu_type != wxITEM_RADIO )
377 aMenu->SetBitmap( aImage );
383 const wxBitmapBundle& aImage, wxItemKind aType )
385 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText, wxEmptyString, aType );
388 aMenu->Append( item );
395 const wxString& aHelpText,
const wxBitmapBundle& aImage,
398 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText, aHelpText, aType );
401 aMenu->Append( item );
408 const wxBitmapBundle& aImage )
410 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText );
411 item->SetSubMenu( aSubMenu );
414 aMenu->Append( item );
421 const wxString& aHelpText,
const wxBitmapBundle& aImage )
423 wxMenuItem* item =
new wxMenuItem( aMenu, aId, aText, aHelpText );
424 item->SetSubMenu( aSubMenu );
427 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 wxFont GetSmallInfoFont(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.