31#include <wx/combobox.h>
32#include <wx/settings.h>
42 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
65 std::vector<std::pair<wxString, size_t>> lines;
67 for(
const wxString&
message : aMessages )
69 auto it = std::find_if( lines.begin(), lines.end(),
70 [&](
const std::pair<wxString, size_t>& aLine )
72 return aLine.first == message;
75 if( it != lines.end() )
78 lines.emplace_back(
message, 1 );
83 for(
size_t ii = 0; ii < lines.size() && ii <
MAX_LINES; ++ii )
88 text += lines[ii].first;
90 if( lines[ii].second > 1 )
91 text += wxString::Format(
_(
" (%zu times)" ), lines[ii].second );
95 text += wxString::Format(
_(
"\n... and %zu more" ), lines.size() -
MAX_LINES );
98 Show( !
text.IsEmpty() );
106 wxArrayString messages;
108 if( !aMessage.IsEmpty() )
109 messages.Add( aMessage );
120 const wxSize fieldSize =
m_field->GetSize();
125 if(
dynamic_cast<wxComboBox*
>(
m_field ) ||
dynamic_cast<wxChoice*
>(
m_field )
126 ||
dynamic_cast<wxComboCtrl*
>(
m_field ) )
129 buttonWidth = wxSystemSettings::GetMetric( wxSYS_VSCROLL_X,
m_field );
131 buttonWidth = fieldSize.y;
135 const wxSize iconSize = GetSize();
136 const int gap =
m_field->FromDIP( 3 );
138 SetPosition(
m_field->GetPosition()
139 + wxPoint( fieldSize.x - buttonWidth - iconSize.x - gap, ( fieldSize.y - iconSize.y ) / 2 ) );
160 if( aEvent.GetEventObject() ==
m_field )
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
BITMAPS
A list of all bitmap identifiers.
static constexpr size_t MAX_LINES
The most warnings listed in the tooltip, with a count of the rest.
wxWindow * m_field
Null once the field has been destroyed.
~FIELD_WARNING_ICON() override
void onFieldChanged(wxEvent &aEvent)
FIELD_WARNING_ICON(wxWindow *aField)
void Reposition()
Moves the icon back over the field after the field has moved or changed size.
void SetWarnings(const wxArrayString &aMessages)
Lists aMessages in the tooltip, once each with a count when repeated, and shows the icon,...
void SetWarning(const wxString &aMessage)
Shows aMessage as the tooltip, or hides the icon when it is empty.
void onFieldDestroyed(wxWindowDestroyEvent &aEvent)
Some functions to handle hotkeys in KiCad.