KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kistatusbar.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 Mark Roszko <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef KISTATUSBAR_H
26#define KISTATUSBAR_H
27
28#include <kicommon.h>
29#include <optional>
30#include <mutex>
31#include <vector>
32#include <unordered_map>
34#include <wx/statusbr.h>
35
36class wxGauge;
37class wxButton;
38class wxStaticText;
39class BITMAP_BUTTON;
40
49
54{
55 wxString message;
57};
58
59
60class KICOMMON_API KISTATUSBAR : public wxStatusBar
61{
62public:
63 enum STYLE_FLAGS : int
64 {
65 NONE_STYLE = 0x00,
69 };
70
71 static constexpr auto DEFAULT_STYLE =
73
74 KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id,
75 STYLE_FLAGS aFlags = DEFAULT_STYLE );
76
78
85 void SetEllipsedTextField( const wxString& aText, int aFieldId );
86
90 void ShowBackgroundProgressBar( bool aCancellable = false );
91
96
100 void SetBackgroundProgress( int aAmount );
101
105 void SetBackgroundProgressMax( int aAmount );
106
110 void SetBackgroundStatusText( const wxString& aTxt );
111
117 void SetNotificationCount( int aCount );
118
122 void ClearWarningMessages( const wxString& aSource = wxEmptyString );
123
128 void AddWarningMessages( const wxString& aSource, const wxString& aMessages );
129
134 void AddWarningMessages( const wxString& aSource, const std::vector<LOAD_MESSAGE>& aMessages );
135
139 size_t GetLoadWarningCount() const;
140
141private:
142 void onSize( wxSizeEvent& aEvent );
143 void onBackgroundProgressClick( wxMouseEvent& aEvent );
144 void onNotificationsIconClick( wxCommandEvent& aEvent );
145 void onLoadWarningsIconClick( wxCommandEvent& aEvent );
146 void updateWarningUI();
149 void layoutControls();
150
159
160 std::optional<int> fieldIndex( FIELD aField ) const;
161
162private:
165 wxStaticText* m_backgroundTxt;
168 mutable std::mutex m_warningMutex;
169 std::unordered_map<wxString, std::vector<LOAD_MESSAGE>> m_warningMessages;
174 std::vector<int> m_fieldWidths;
175};
176
177#endif
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
STYLE_FLAGS m_styleFlags
BITMAP_BUTTON * m_notificationsButton
void AddWarningMessages(const wxString &aSource, const wxString &aMessages)
Add warning/error messages (not thread-safe, use the std::vector<LOAD_MESSAGE> variant from other thr...
void onLoadWarningsIconClick(wxCommandEvent &aEvent)
void SetBackgroundStatusText(const wxString &aTxt)
Set the status text that displays next to the progress bar.
BITMAP_BUTTON * m_warningButton
wxString m_backgroundRawText
Unellipsized background status text.
std::unordered_map< wxString, std::vector< LOAD_MESSAGE > > m_warningMessages
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 updateAuxFieldWidths()
void layoutControls()
void onSize(wxSizeEvent &aEvent)
int m_normalFieldsCount
void ClearWarningMessages(const wxString &aSource=wxEmptyString)
Clears all warning messages from the given source (or all sources if aSource is empty)
wxString m_savedStatusText
Saved text from adjacent field during background jobs.
std::mutex m_warningMutex
Protects m_warningMessages.
void updateBackgroundText()
void SetBackgroundProgress(int aAmount)
Set the current progress of the progress bar.
wxGauge * m_backgroundProgressBar
wxButton * m_backgroundStopButton
void updateWarningUI()
Update warning button visibility and badge (main thread only)
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.
std::vector< int > m_fieldWidths
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.
static constexpr auto DEFAULT_STYLE
Definition kistatusbar.h:71
void SetNotificationCount(int aCount)
Set the notification count on the notifications button.
#define KICOMMON_API
Definition kicommon.h:27
SEVERITY
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
Definition kistatusbar.h:54
wxString message
Definition kistatusbar.h:55
SEVERITY severity
Definition kistatusbar.h:56