26#include <wx/statusbr.h>
28#include <wx/stattext.h>
29#include <wx/tokenzr.h>
30#include <fmt/format.h>
43#include <wx/dcclient.h>
47 wxStatusBar( parent, id ),
73 if( showNotification )
76 SetFieldsCount( aNumberFields + extraFields );
78 int* widths =
new int[aNumberFields + extraFields];
80 for(
int i = 0; i < aNumberFields; i++ )
84 widths[aNumberFields + *idx] = -1;
87 widths[aNumberFields + *idx] = 75;
90 widths[aNumberFields + *idx] = 20;
93 widths[aNumberFields + *idx] = 20;
96 widths[aNumberFields + *idx] = 20;
100 widths[aNumberFields + extraFields - 1] = 10;
103 SetStatusWidths( aNumberFields + extraFields, widths );
106 int* styles =
new int[aNumberFields + extraFields];
108 for(
int i = 0; i < aNumberFields + extraFields; i++ )
109 styles[i] = wxSB_FLAT;
111 SetStatusStyles( aNumberFields + extraFields, styles );
117 wxGA_HORIZONTAL | wxGA_SMOOTH );
122 wxDefaultSize, wxBU_EXACTFIT );
125 if( showNotification )
128 wxDefaultSize, wxBU_EXACTFIT );
141 wxDefaultSize, wxBU_EXACTFIT );
183 pos.x += r.GetWidth();
198 pos.x += r.GetWidth();
207 constexpr int padding = 5;
215 if( r.GetHeight() > textHeight )
216 y += ( r.GetHeight() - textHeight ) / 2;
223 int w = r.GetWidth();
224 int h = r.GetHeight();
225 wxSize buttonSize( 0, 0 );
232 buttonSize.x += padding;
284 if( value <= aAmount )
309 cnt = fmt::format(
"{}", aCount );
324 wxStringTokenizer tokenizer( aMessages, wxS(
"\n" ), wxTOKEN_STRTOK );
326 while( tokenizer.HasMoreTokens() )
329 msg.
message = tokenizer.GetNextToken();
341 wxLogTrace(
traceLibraries,
"KISTATUSBAR::AddLoadWarningMessages: this=%p, count=%zu",
342 this, aMessages.size() );
344 if( aMessages.empty() )
354 wxLogTrace(
traceLibraries,
" -> calling CallAfter for updateWarningUI" );
368 wxLogTrace(
traceLibraries,
"KISTATUSBAR::updateWarningUI: this=%p, m_warningButton=%p",
373 wxLogTrace(
traceLibraries,
" -> no warning button, returning early" );
383 wxLogTrace(
traceLibraries,
" -> message count=%zu, showing button=%s",
384 messageCount, messageCount > 0 ?
"true" :
"false" );
388 if( messageCount > 0 )
390 m_warningButton->SetToolTip( wxString::Format(
_(
"View %zu load message(s)" ), messageCount ) );
394 wxString badgeText = messageCount > 99
396 : wxString::Format( wxS(
"%zu" ), messageCount );
429 std::vector<LOAD_MESSAGE> messages;
435 if( messages.empty() )
451 wxString etext = aText;
455 if( GetFieldRect( aFieldId, fieldRect ) )
456 width = fieldRect.GetWidth();
460 wxClientDC dc(
this );
464 etext = wxControl::Ellipsize( etext, dc, wxELLIPSIZE_MIDDLE, width - margin );
467 SetStatusText( etext, aFieldId );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
void ShowList(wxWindow *aParent, wxPoint aPos)
Shows the background job list.
Class DIALOG_HTML_REPORTER.
WX_HTML_REPORT_BOX * m_Reporter
BITMAP_BUTTON * m_notificationsButton
void onLoadWarningsIconClick(wxCommandEvent &aEvent)
std::optional< int > fieldIndex(FIELD aField) const
void SetBackgroundStatusText(const wxString &aTxt)
Set the status text that displays next to the progress bar.
BITMAP_BUTTON * m_warningButton
size_t GetLoadWarningCount() const
Get current message count (thread-safe).
void onBackgroundProgressClick(wxMouseEvent &aEvent)
KISTATUSBAR(int aNumberFields, wxWindow *parent, wxWindowID id, STYLE_FLAGS aFlags=DEFAULT_STYLE)
void onSize(wxSizeEvent &aEvent)
void SetBackgroundProgress(int aAmount)
Set the current progress of the progress bar.
wxGauge * m_backgroundProgressBar
void AddLoadWarningMessages(const std::vector< LOAD_MESSAGE > &aMessages)
Add warning/error messages thread-safely.
wxButton * m_backgroundStopButton
std::mutex m_loadWarningMutex
Protects m_loadWarningMessages.
void updateWarningUI()
Update warning button visibility and badge (main thread only)
std::vector< LOAD_MESSAGE > m_loadWarningMessages
void SetEllipsedTextField(const wxString &aText, int aFieldId)
Set the text in a field using wxELLIPSIZE_MIDDLE option to adjust the text size to the field size.
void HideBackgroundProgressBar()
Hide the background progress bar.
void onNotificationsIconClick(wxCommandEvent &aEvent)
void SetBackgroundProgressMax(int aAmount)
Set the max progress of the progress bar.
wxStaticText * m_backgroundTxt
void ShowBackgroundProgressBar(bool aCancellable=false)
Show the background progress bar.
void SetLoadWarningMessages(const wxString &aMessages)
void SetNotificationCount(int aCount)
Set the notification count on the notifications button.
void ClearLoadWarningMessages()
void ShowList(wxWindow *aParent, wxPoint aPos)
Show the notification list.
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
virtual NOTIFICATIONS_MANAGER & GetNotificationsManager() const
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
void Flush()
Build the HTML messages page.
const wxChar *const traceLibraries
Flag to enable library table and library manager tracing.
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...
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
PGM_BASE & Pgm()
The global program "get" accessor.
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
wxLogTrace helper definitions.
Functions to provide common constants and other functions to assist in making a consistent UI.