KiCad PCB EDA Suite
infobar.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) 2020 Ian McInerney <ian.s.mcinerney@ieee.org>
5  * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef INFOBAR_H_
22 #define INFOBAR_H_
23 
24 #include <wx/event.h>
25 #include <wx/infobar.h>
26 #include <wx/wx.h>
27 
28 class wxAuiManager;
29 
30 
31 enum
32 {
35 };
36 
37 
38 wxDECLARE_EVENT( KIEVT_SHOW_INFOBAR, wxCommandEvent );
39 wxDECLARE_EVENT( KIEVT_DISMISS_INFOBAR, wxCommandEvent );
40 
68 class WX_INFOBAR : public wxInfoBarGeneric
69 {
70 public:
78  WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr = nullptr, wxWindowID aWinid = wxID_ANY );
79 
80  ~WX_INFOBAR();
81 
91  void SetShowTime( int aTime );
92 
98  void AddCloseButton( const wxString& aTooltip = _( "Hide this message." ) );
99 
106  void AddButton( wxButton* aButton );
107 
115  void AddButton( wxWindowID aId, const wxString& aLabel = wxEmptyString ) override;
116 
120  void RemoveAllButtons();
121 
130  void ShowMessageFor( const wxString& aMessage, int aTime, int aFlags = wxICON_INFORMATION );
131 
138  void ShowMessage( const wxString& aMessage, int aFlags = wxICON_INFORMATION ) override;
139 
144  void Dismiss() override;
145 
152  void QueueShowMessage( const wxString& aMessage, int aFlags = wxICON_INFORMATION );
153 
157  void QueueDismiss();
158 
159 protected:
165  void OnShowInfoBar( wxCommandEvent& aEvent );
166 
171  void OnDismissInfoBar( wxCommandEvent& aEvent );
172 
177  void OnCloseButton( wxCommandEvent& aEvent );
178 
182  void OnTimer( wxTimerEvent& aEvent );
183 
189  void UpdateAuiLayout( bool aShow );
190 
193  wxTimer* m_showTimer;
194  wxAuiManager* m_auiManager;
195 
196  DECLARE_EVENT_TABLE()
197 };
198 
199 
214 class EDA_INFOBAR_PANEL : public wxPanel
215 {
216 public:
217  EDA_INFOBAR_PANEL( wxWindow* aParent, wxWindowID aId = wxID_ANY,
218  const wxPoint& aPos = wxDefaultPosition,
219  const wxSize& aSize = wxSize( -1,-1 ),
220  long aStyle = wxTAB_TRAVERSAL,
221  const wxString& aName = wxEmptyString );
222 
228  void AddInfoBar( WX_INFOBAR* aInfoBar );
229 
236  void AddOtherItem( wxWindow* aOtherItem );
237 
238 protected:
239  // The sizer containing the infobar and the other object
240  wxFlexGridSizer* m_mainSizer;
241 };
242 
243 #endif // INFOBAR_H_
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:108
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:119
A wxPanel derived class that hold an infobar and another control.
Definition: infobar.h:214
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:184
wxTimer * m_showTimer
The timer counting the autoclose period.
Definition: infobar.h:193
void OnDismissInfoBar(wxCommandEvent &aEvent)
Event handler for dismissing the infobar using a wxCommandEvent of the type KIEVT_DISMISS_INFOBAR.
Definition: infobar.cpp:244
~WX_INFOBAR()
Definition: infobar.cpp:77
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:139
void AddOtherItem(wxWindow *aOtherItem)
Add the other item to the panel.
Definition: infobar.cpp:289
void OnShowInfoBar(wxCommandEvent &aEvent)
Event handler for showing the infobar using a wxCommandEvent of the type KIEVT_SHOW_INFOBAR.
Definition: infobar.cpp:236
WX_INFOBAR(wxWindow *aParent, wxAuiManager *aMgr=nullptr, wxWindowID aWinid=wxID_ANY)
Construct an infobar that can exist inside an AUI managed frame.
Definition: infobar.cpp:43
void OnTimer(wxTimerEvent &aEvent)
Event handler for the automatic closing timer.
Definition: infobar.cpp:256
ID for the close button on the frame's infobar.
Definition: infobar.h:34
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:212
void QueueShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION)
Send the infobar an event telling it to show a message.
Definition: infobar.cpp:89
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
void SetShowTime(int aTime)
Set the time period to show the infobar.
Definition: infobar.cpp:83
void QueueDismiss()
Send the infobar an event telling it to hide itself.
Definition: infobar.cpp:100
void OnCloseButton(wxCommandEvent &aEvent)
Event handler for the close button.
Definition: infobar.cpp:250
#define _(s)
Definition: 3d_actions.cpp:33
wxFlexGridSizer * m_mainSizer
Definition: infobar.h:240
EDA_INFOBAR_PANEL(wxWindow *aParent, wxWindowID aId=wxID_ANY, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxSize(-1,-1), long aStyle=wxTAB_TRAVERSAL, const wxString &aName=wxEmptyString)
Definition: infobar.cpp:266
wxAuiManager * m_auiManager
The AUI manager that contains this infobar.
Definition: infobar.h:194
bool m_updateLock
True if this infobar requested the UI update.
Definition: infobar.h:192
wxDECLARE_EVENT(KIEVT_SHOW_INFOBAR, wxCommandEvent)
void AddInfoBar(WX_INFOBAR *aInfoBar)
Add the given infobar object to the panel.
Definition: infobar.cpp:279
void UpdateAuiLayout(bool aShow)
Update the AUI pane to show or hide this infobar.
Definition: infobar.cpp:156
int m_showTime
The time to show the infobar. 0 = don't auto hide.
Definition: infobar.h:191
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:202