![]() |
KiCad PCB EDA Suite
|
A modified version of the wxInfoBar class that allows us to: More...
#include <infobar.h>
Public Types | |
enum | MESSAGE_TYPE { MESSAGE_TYPE::GENERIC, MESSAGE_TYPE::OUTDATED_SAVE } |
Sets the type of message for special handling if needed. More... | |
Public Member Functions | |
WX_INFOBAR (wxWindow *aParent, wxAuiManager *aMgr=nullptr, wxWindowID aWinid=wxID_ANY) | |
Construct an infobar that can exist inside an AUI managed frame. More... | |
~WX_INFOBAR () | |
void | SetShowTime (int aTime) |
Set the time period to show the infobar. More... | |
void | AddCloseButton (const wxString &aTooltip=_("Hide this message.")) |
Add the default close button to the infobar on the right side. More... | |
void | AddButton (wxButton *aButton) |
Add an already created button to the infobar. More... | |
void | AddButton (wxHyperlinkCtrl *aHypertextButton) |
Add an already created hypertext link to the infobar. More... | |
void | AddButton (wxWindowID aId, const wxString &aLabel=wxEmptyString) override |
Add a button with the provided ID and text. More... | |
void | RemoveAllButtons () |
Remove all the buttons that have been added by the user. More... | |
bool | HasCloseButton () const |
void | SetCallback (std::function< void(void)> aCallback) |
Provide a callback to be called when the infobar is dismissed (either by user action or timer). More... | |
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. More... | |
void | ShowMessage (const wxString &aMessage, int aFlags=wxICON_INFORMATION) override |
Show the info bar with the provided message and icon. More... | |
void | ShowMessage (const wxString &aMessage, int aFlags, MESSAGE_TYPE aType) |
Show the info bar with the provided message and icon, setting the type. More... | |
void | Dismiss () override |
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided). More... | |
void | DismissOutdatedSave () |
Dismisses the infobar for outdated save warnings and updates the containing layout and AUI manager (if one is provided). More... | |
void | QueueShowMessage (const wxString &aMessage, int aFlags=wxICON_INFORMATION) |
Send the infobar an event telling it to show a message. More... | |
void | QueueDismiss () |
Send the infobar an event telling it to hide itself. More... | |
bool | IsLocked () |
Returns true if the infobar is being updated. More... | |
Protected Member Functions | |
void | onShowInfoBar (wxCommandEvent &aEvent) |
Event handler for showing the infobar using a wxCommandEvent of the type KIEVT_SHOW_INFOBAR. More... | |
void | onDismissInfoBar (wxCommandEvent &aEvent) |
Event handler for dismissing the infobar using a wxCommandEvent of the type KIEVT_DISMISS_INFOBAR. More... | |
void | onCloseButton (wxCommandEvent &aEvent) |
Event handler for the close button. More... | |
void | onTimer (wxTimerEvent &aEvent) |
Event handler for the automatic closing timer. More... | |
void | onSize (wxSizeEvent &aEvent) |
void | updateAuiLayout (bool aShow) |
Update the AUI pane to show or hide this infobar. More... | |
Protected Attributes | |
int | m_showTime |
The time to show the infobar. 0 = don't auto hide. More... | |
bool | m_updateLock |
True if this infobar requested the UI update. More... | |
wxTimer * | m_showTimer |
The timer counting the autoclose period. More... | |
wxAuiManager * | m_auiManager |
The AUI manager that contains this infobar. More... | |
MESSAGE_TYPE | m_type |
The type of message being displayed. More... | |
OPT< std::function< void(void)> > | m_callback |
Optional callback made when closing infobar. More... | |
A modified version of the wxInfoBar class that allows us to:
This inherits from the generic infobar because the native infobar on GTK doesn't include the icon on the left and it looks worse.
There are 2 events associated with the infobar:
KIEVT_SHOW_INFOBAR: An event that tells the infobar to show a message.
The message text is contained inside the string component, and the message flag is contained inside the int component.
Sample event creation code: wxCommandEvent* evt = new wxCommandEvent( KIEVT_SHOW_INFOBAR ); evt->SetString( "A message to show" ); evt->SetInt( wxICON_WARNING );
KIEVT_DISMISS_INFOBAR: An event that tells the infobar to hide itself.
|
strong |
WX_INFOBAR::WX_INFOBAR | ( | wxWindow * | aParent, |
wxAuiManager * | aMgr = nullptr , |
||
wxWindowID | aWinid = wxID_ANY |
||
) |
Construct an infobar that can exist inside an AUI managed frame.
aParent | is the parent |
aMgr | is the AUI manager that this infobar is added to |
aWinId | is the ID for this infobar object |
Definition at line 45 of file infobar.cpp.
References ID_CLOSE_INFOBAR, and onSize().
WX_INFOBAR::~WX_INFOBAR | ( | ) |
Definition at line 87 of file infobar.cpp.
References m_showTimer.
void WX_INFOBAR::AddButton | ( | wxButton * | aButton | ) |
Add an already created button to the infobar.
New buttons are added in the right-most position.
aButton | is the button to add |
Definition at line 241 of file infobar.cpp.
Referenced by AddButton(), AddCloseButton(), DIALOG_ERC::DIALOG_ERC(), ZONE_FILLER_TOOL::FillAllZones(), ROUTER_TOOL::handleLayerSwitch(), APPEARANCE_CONTROLS::onReadOnlySwatch(), and SYMBOL_EDIT_FRAME::SetCurPart().
void WX_INFOBAR::AddButton | ( | wxHyperlinkCtrl * | aHypertextButton | ) |
Add an already created hypertext link to the infobar.
New buttons are added in the right-most position.
aHypertextButton | is the button to add |
Definition at line 259 of file infobar.cpp.
|
override |
Add a button with the provided ID and text.
The new button is created on the right-most positon.
aId | is the ID to assign to the button |
aLabel | is the text for the button |
Definition at line 233 of file infobar.cpp.
References AddButton().
void WX_INFOBAR::AddCloseButton | ( | const wxString & | aTooltip = _( "Hide this message." ) | ) |
Add the default close button to the infobar on the right side.
aTooltip | is the tooltip to give the close button |
Definition at line 272 of file infobar.cpp.
References AddButton(), and ID_CLOSE_INFOBAR.
Referenced by FOOTPRINT_EDIT_FRAME::AddFootprintToBoard(), PL_EDITOR_FRAME::LoadPageLayoutDescrFile(), APPEARANCE_CONTROLS::onReadOnlySwatch(), onShowInfoBar(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::ShowFindReplaceStatus(), EDA_BASE_FRAME::ShowInfoBarError(), EDA_BASE_FRAME::ShowInfoBarMsg(), and EDA_BASE_FRAME::ShowInfoBarWarning().
|
override |
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition at line 171 of file infobar.cpp.
References m_auiManager, m_callback, m_updateLock, and updateAuiLayout().
Referenced by SCH_EDIT_FRAME::ClearFindReplaceStatus(), DismissOutdatedSave(), DRAWING_TOOL::DrawVia(), PAD_TOOL::EditPad(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), SYMBOL_EDIT_FRAME::LoadOneLibraryPartAux(), PL_EDITOR_FRAME::LoadPageLayoutDescrFile(), onCloseButton(), onDismissInfoBar(), DIALOG_BOARD_SETUP::OnPageChange(), onTimer(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), SYMBOL_EDIT_FRAME::saveAllLibraries(), FOOTPRINT_EDITOR_CONTROL::SaveAs(), PCB_EDIT_FRAME::SavePcbFile(), SYMBOL_EDIT_FRAME::SetCurPart(), and SCH_DRAWING_TOOLS::SingleClickPlace().
void WX_INFOBAR::DismissOutdatedSave | ( | ) |
Dismisses the infobar for outdated save warnings and updates the containing layout and AUI manager (if one is provided).
Definition at line 162 of file infobar.cpp.
References Dismiss(), m_type, m_updateLock, and OUTDATED_SAVE.
Referenced by PCB_EDIT_FRAME::SavePcbFile(), and SCH_EDIT_FRAME::SaveProject().
bool WX_INFOBAR::HasCloseButton | ( | ) | const |
Definition at line 306 of file infobar.cpp.
References ID_CLOSE_INFOBAR.
Referenced by FOOTPRINT_EDITOR_CONTROL::SaveAs(), and PCB_EDIT_FRAME::SavePcbFile().
|
inline |
Returns true if the infobar is being updated.
Definition at line 210 of file infobar.h.
References m_updateLock.
Referenced by EDA_DRAW_PANEL_GAL::onSize().
|
protected |
Event handler for the close button.
This is bound to ID_CLOSE_INFOBAR on the infobar.
Definition at line 336 of file infobar.cpp.
References Dismiss().
|
protected |
Event handler for dismissing the infobar using a wxCommandEvent of the type KIEVT_DISMISS_INFOBAR.
Definition at line 330 of file infobar.cpp.
References Dismiss().
|
protected |
Event handler for showing the infobar using a wxCommandEvent of the type KIEVT_SHOW_INFOBAR.
The message is stored inside the string field, and the icon flag is stored inside the int field.
Definition at line 322 of file infobar.cpp.
References AddCloseButton(), RemoveAllButtons(), and ShowMessage().
|
protected |
Definition at line 191 of file infobar.cpp.
References TOOLS_HOLDER::GetToolCanvas().
Referenced by WX_INFOBAR().
|
protected |
Event handler for the automatic closing timer.
Definition at line 342 of file infobar.cpp.
References Dismiss(), m_showTime, and m_showTimer.
void WX_INFOBAR::QueueDismiss | ( | ) |
Send the infobar an event telling it to hide itself.
Definition at line 110 of file infobar.cpp.
Referenced by INFOBAR_REPORTER::Finalize().
void WX_INFOBAR::QueueShowMessage | ( | const wxString & | aMessage, |
int | aFlags = wxICON_INFORMATION |
||
) |
Send the infobar an event telling it to show a message.
aMessage | is the message to display |
aFlags | is the flag containing the icon to display on the left side of the infobar |
Definition at line 99 of file infobar.cpp.
Referenced by INFOBAR_REPORTER::Finalize().
void WX_INFOBAR::RemoveAllButtons | ( | ) |
Remove all the buttons that have been added by the user.
Definition at line 282 of file infobar.cpp.
Referenced by FOOTPRINT_EDIT_FRAME::AddFootprintToBoard(), AUTOPLACE_TOOL::autoplace(), DIALOG_ANNOTATE::DIALOG_ANNOTATE(), DIALOG_ERC::DIALOG_ERC(), PAD_TOOL::EditPad(), ZONE_FILLER_TOOL::FillAllZones(), ROUTER_TOOL::handleLayerSwitch(), PL_EDITOR_FRAME::LoadPageLayoutDescrFile(), APPEARANCE_CONTROLS::onReadOnlySwatch(), onShowInfoBar(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), SYMBOL_EDIT_FRAME::SetCurPart(), SCH_EDIT_FRAME::ShowFindReplaceStatus(), EDA_BASE_FRAME::ShowInfoBarError(), EDA_BASE_FRAME::ShowInfoBarMsg(), and EDA_BASE_FRAME::ShowInfoBarWarning().
|
inline |
Provide a callback to be called when the infobar is dismissed (either by user action or timer).
aCallback |
Definition at line 150 of file infobar.h.
References m_callback.
Referenced by EDA_BASE_FRAME::ShowInfoBarError().
void WX_INFOBAR::SetShowTime | ( | int | aTime | ) |
Set the time period to show the infobar.
This only applies for the next showing of the infobar, so it must be reset every time. A value of 0 disables the automatic hiding (this is the default).
aTime | is the time in milliseconds to show the infobar |
Definition at line 93 of file infobar.cpp.
References m_showTime.
|
override |
Show the info bar with the provided message and icon.
aMessage | is the message to display |
aFlags | is the flag containing the icon to display on the left side of the infobar |
Definition at line 129 of file infobar.cpp.
References GENERIC, m_auiManager, m_showTime, m_showTimer, m_type, m_updateLock, and updateAuiLayout().
Referenced by FOOTPRINT_EDIT_FRAME::AddFootprintToBoard(), DIALOG_ANNOTATE::DIALOG_ANNOTATE(), DIALOG_ERC::DIALOG_ERC(), DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP(), PAD_TOOL::EditPad(), PL_EDITOR_FRAME::LoadPageLayoutDescrFile(), DIALOG_BOARD_SETUP::OnPageChange(), onShowInfoBar(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), SYMBOL_EDIT_FRAME::SetCurPart(), ShowMessage(), ShowMessageFor(), and PAGED_DIALOG::TransferDataFromWindow().
void WX_INFOBAR::ShowMessage | ( | const wxString & | aMessage, |
int | aFlags, | ||
MESSAGE_TYPE | aType | ||
) |
Show the info bar with the provided message and icon, setting the type.
aMessage | is the message to display |
aFlags | is the flag containing the icon to display on the left side of the infobar |
aType | is the type of message being displayed |
Definition at line 150 of file infobar.cpp.
References m_type, m_updateLock, and ShowMessage().
void WX_INFOBAR::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.
aMessage | is the message to display |
aTime | is the amount of time in milliseconds to show the infobar |
aFlags | is the flag containing the icon to display on the left side of the infobar |
Definition at line 118 of file infobar.cpp.
References m_showTime, m_updateLock, and ShowMessage().
Referenced by AUTOPLACE_TOOL::autoplace(), ZONE_FILLER_TOOL::FillAllZones(), ROUTER_TOOL::handleLayerSwitch(), APPEARANCE_CONTROLS::onReadOnlySwatch(), PAGED_DIALOG::OnUpdateUI(), SYMBOL_EDIT_FRAME::saveAllLibraries(), SCH_EDIT_FRAME::ShowFindReplaceStatus(), EDA_BASE_FRAME::ShowInfoBarError(), EDA_BASE_FRAME::ShowInfoBarMsg(), and EDA_BASE_FRAME::ShowInfoBarWarning().
|
protected |
Update the AUI pane to show or hide this infobar.
aShow | is true to show the pane |
Definition at line 213 of file infobar.cpp.
References m_auiManager.
Referenced by Dismiss(), and ShowMessage().
|
protected |
The AUI manager that contains this infobar.
Definition at line 253 of file infobar.h.
Referenced by Dismiss(), ShowMessage(), and updateAuiLayout().
|
protected |
Optional callback made when closing infobar.
Definition at line 256 of file infobar.h.
Referenced by Dismiss(), and SetCallback().
|
protected |
The time to show the infobar. 0 = don't auto hide.
Definition at line 250 of file infobar.h.
Referenced by onTimer(), SetShowTime(), ShowMessage(), and ShowMessageFor().
|
protected |
The timer counting the autoclose period.
Definition at line 252 of file infobar.h.
Referenced by onTimer(), ShowMessage(), and ~WX_INFOBAR().
|
protected |
The type of message being displayed.
Definition at line 254 of file infobar.h.
Referenced by DismissOutdatedSave(), and ShowMessage().
|
protected |
True if this infobar requested the UI update.
Definition at line 251 of file infobar.h.
Referenced by Dismiss(), DismissOutdatedSave(), IsLocked(), ShowMessage(), and ShowMessageFor().