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>
33#include <wx/statusbr.h>
34
35class wxGauge;
36class wxButton;
37class wxStaticText;
38class BITMAP_BUTTON;
39
48
53{
54 wxString message;
56};
57
58
59class KICOMMON_API KISTATUSBAR : public wxStatusBar
60{
61public:
62 enum STYLE_FLAGS : int
63 {
64 NONE_STYLE = 0x00,
68 };
69
70 static constexpr auto DEFAULT_STYLE =
72
73 KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id,
74 STYLE_FLAGS aFlags = DEFAULT_STYLE );
75
77
84 void SetEllipsedTextField( const wxString& aText, int aFieldId );
85
89 void ShowBackgroundProgressBar( bool aCancellable = false );
90
95
99 void SetBackgroundProgress( int aAmount );
100
104 void SetBackgroundProgressMax( int aAmount );
105
109 void SetBackgroundStatusText( const wxString& aTxt );
110
116 void SetNotificationCount( int aCount );
117
118 void SetLoadWarningMessages( const wxString& aMessages );
120
125 void AddLoadWarningMessages( const std::vector<LOAD_MESSAGE>& aMessages );
126
130 size_t GetLoadWarningCount() const;
131
132private:
133 void onSize( wxSizeEvent& aEvent );
134 void onBackgroundProgressClick( wxMouseEvent& aEvent );
135 void onNotificationsIconClick( wxCommandEvent& aEvent );
136 void onLoadWarningsIconClick( wxCommandEvent& aEvent );
137 void updateWarningUI();
138
147
148 std::optional<int> fieldIndex( FIELD aField ) const;
149
150private:
153 wxStaticText* m_backgroundTxt;
156 mutable std::mutex m_loadWarningMutex;
157 std::vector<LOAD_MESSAGE> m_loadWarningMessages;
160};
161
162#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 onLoadWarningsIconClick(wxCommandEvent &aEvent)
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)
int m_normalFieldsCount
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.
static constexpr auto DEFAULT_STYLE
Definition kistatusbar.h:70
void SetLoadWarningMessages(const wxString &aMessages)
void SetNotificationCount(int aCount)
Set the notification count on the notifications button.
void ClearLoadWarningMessages()
#define KICOMMON_API
Definition kicommon.h:28
SEVERITY
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
Definition kistatusbar.h:53
wxString message
Definition kistatusbar.h:54
SEVERITY severity
Definition kistatusbar.h:55