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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef KISTATUSBAR_H
22#define KISTATUSBAR_H
23
24#include <kicommon.h>
25#include <ki_error.h>
26#include <map>
27#include <optional>
28#include <mutex>
29#include <vector>
30#include <unordered_map>
31#include <wx/statusbr.h>
32
33class wxGauge;
34class wxButton;
35class wxStaticText;
36class BITMAP_BUTTON;
38
47
48
49class KICOMMON_API KISTATUSBAR : public wxStatusBar
50{
51public:
52 enum STYLE_FLAGS : int
53 {
54 NONE_STYLE = 0x00,
58 };
59
60 static constexpr auto DEFAULT_STYLE =
62
63 KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id,
64 STYLE_FLAGS aFlags = DEFAULT_STYLE );
65
67
71 void ShowBackgroundProgressBar( bool aCancellable = false );
72
77
81 void SetBackgroundProgress( int aAmount );
82
86 void SetBackgroundProgressMax( int aAmount );
87
91 void SetBackgroundStatusText( const wxString& aTxt );
92
98 void SetNotificationCount( int aCount );
99
103 void ClearWarningMessages( const wxString& aSource = wxEmptyString );
104
109 void AddWarningMessages( const wxString& aSource, const wxString& aMessages );
110
115 void AddWarningMessages( const wxString& aSource, const std::vector<KI_ERROR>& aMessages );
116
120 size_t GetLoadWarningCount() const;
121
126 std::map<wxString, std::vector<KI_ERROR>> GetWarningMessages() const;
127
131 void CloseWarningList();
132
137 virtual void SetStatusWidths( int aSize, const int* aWidths ) override;
138
139private:
140 void onSize( wxSizeEvent& aEvent );
141 void onBackgroundProgressClick( wxMouseEvent& aEvent );
142 void onNotificationsIconClick( wxCommandEvent& aEvent );
143 void onLoadWarningsIconClick( wxCommandEvent& aEvent );
144 void openWarningList();
145 void updateWarningUI();
148 void layoutControls();
149
158
159 std::optional<int> fieldIndex( FIELD aField ) const;
160
161private:
164 wxStaticText* m_backgroundTxt;
168 mutable std::mutex m_warningMutex;
169 std::unordered_map<wxString, std::vector<KI_ERROR>> 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<KI_ERROR> variant from other threads...
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.
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()
std::unordered_map< wxString, std::vector< KI_ERROR > > m_warningMessages
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 CloseWarningList()
Close the warning message overlay panel, if it is shown.
void updateWarningUI()
Update warning button visibility and badge (main thread only)
virtual void SetStatusWidths(int aSize, const int *aWidths) override
std::map< wxString, std::vector< KI_ERROR > > GetWarningMessages() const
Get a copy of all stored warning/error messages, grouped by source and sorted by source name for stab...
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.
void PositionWarningPanel()
Position the warning message overlay panel above the warning icon.
wxStaticText * m_backgroundTxt
void ShowBackgroundProgressBar(bool aCancellable=false)
Show the background progress bar.
void openWarningList()
static constexpr auto DEFAULT_STYLE
Definition kistatusbar.h:60
STATUSBAR_WARNING_LIST * m_warningList
Overlay panel listing the warning messages.
void SetNotificationCount(int aCount)
Set the notification count on the notifications button.
#define KICOMMON_API
Definition kicommon.h:27
PCB_VIA::VIA_PARAMETER_ERROR::FIELD FIELD