|
KiCad PCB EDA Suite
|
A modified version of the wxInfoBar class that allows us to: More...
#include <wx_infobar.h>
Public Types | |
| using | MESSAGE_TYPE = INFOBAR_MESSAGE_TYPE |
Public Member Functions | |
| WX_INFOBAR (wxWindow *aParent, wxWindowID aWinid=wxID_ANY, bool aOverlay=false) | |
| Construct an infobar. | |
| ~WX_INFOBAR () | |
| MESSAGE_TYPE | GetMessageType () const |
| void | SetShowTime (int aTime) |
| Set the time period to show the infobar. | |
| void | AddCloseButton (const wxString &aTooltip=_("Hide this message.")) |
| Add the default close button to the infobar on the right side. | |
| void | AddButton (wxButton *aButton) |
| Add an already created button to the infobar. | |
| void | AddLink (const wxString &aLinkText, const std::function< void(wxHyperlinkEvent &)> &aFn) |
| Add a hypertext link to the infobar. | |
| void | AddButton (wxWindowID aId, const wxString &aLabel=wxEmptyString) override |
| Add a button with the provided ID and text. | |
| void | RemoveAllButtons () |
| Remove all the buttons that have been added by the user. | |
| bool | HasCloseButton () const |
| wxBitmapButton * | GetCloseButton () 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). | |
| void | ShowMessageFor (const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC) |
| Show the infobar with the provided message and icon for a specific period of time. | |
| void | ShowMessage (const wxString &aMessage, int aFlags=wxICON_INFORMATION) override |
| Show the info bar with the provided message and icon. | |
| void | ShowMessage (const wxString &aMessage, int aFlags, MESSAGE_TYPE aType) |
| Show the info bar with the provided message and icon, setting the type. | |
| void | Dismiss () override |
| Dismisses the infobar and updates the containing layout and AUI manager (if one is provided). | |
| void | QueueShowMessage (const wxString &aMessage, int aFlags=wxICON_INFORMATION) |
| Send the infobar an event telling it to show a message. | |
| void | QueueDismiss () |
| Send the infobar an event telling it to hide itself. | |
| void | FixSize () |
| Address some long-standing bugs regarding infobars comming up only partial-width. | |
Protected Member Functions | |
| void | onShowInfoBar (wxCommandEvent &aEvent) |
| Event handler for showing the infobar using a wxCommandEvent of the type KIEVT_SHOW_INFOBAR. | |
| void | onDismissInfoBar (wxCommandEvent &aEvent) |
| Event handler for dismissing the infobar using a wxCommandEvent of the type KIEVT_DISMISS_INFOBAR. | |
| void | onCloseButton (wxCommandEvent &aEvent) |
| Event handler for the close button. | |
| void | onThemeChange (wxSysColourChangedEvent &aEvent) |
| Event handler for the color theme change event. | |
| void | onTimer (wxTimerEvent &aEvent) |
| Event handler for the automatic closing timer. | |
| void | onSize (wxSizeEvent &aEvent) |
| void | doSize () |
| void | stackOverlays () |
| Lay out every overlay infobar sharing this one's parent as a top-anchored stack, so that two infobars on the same canvas do not cover each other. | |
| void | refreshParent () |
| Repaint the parent so that the area the infobar covered is not left stale. | |
Protected Attributes | |
| int | m_showTime |
| The time to show the infobar. 0 = don't auto hide. | |
| bool | m_updateLock |
| True if this infobar requested the UI update. | |
| bool | m_overlay |
| True if this infobar is drawn on top of its parent. | |
| wxTimer * | m_showTimer |
| The timer counting the autoclose period. | |
| MESSAGE_TYPE | m_type |
| The type of message being displayed. | |
| wxString | m_message |
| The original message without wrapping. | |
| std::optional< std::function< void(void)> > | m_callback |
| Optional callback made when closing infobar. | |
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.
Definition at line 75 of file wx_infobar.h.
Definition at line 94 of file wx_infobar.h.
| WX_INFOBAR::WX_INFOBAR | ( | wxWindow * | aParent, |
| wxWindowID | aWinid = wxID_ANY, | ||
| bool | aOverlay = false ) |
Construct an infobar.
In overlay mode the infobar is drawn on top of its parent and does not take space from it, so a drawing canvas parent keeps its size and does not have to repaint. Otherwise the infobar is laid out by the parent's sizer.
| aParent | is the parent |
| aWinId | is the ID for this infobar object |
| aOverlay | is true to overlay the parent instead of being laid out by its sizer |
Definition at line 53 of file wx_infobar.cpp.
References GENERIC, DPI_SCALING_COMMON::GetContentScaleFactor(), KIPLATFORM::UI::GetInfoBarColours(), ID_CLOSE_INFOBAR, m_overlay, m_showTime, m_showTimer, m_type, m_updateLock, onSize(), RemoveAllButtons(), and WX_INFOBAR().
Referenced by stackOverlays(), and WX_INFOBAR().
| WX_INFOBAR::~WX_INFOBAR | ( | ) |
Definition at line 109 of file wx_infobar.cpp.
References m_showTimer, and onSize().
| 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 397 of file wx_infobar.cpp.
Referenced by AddButton(), and AddCloseButton().
|
override |
Add a button with the provided ID and text.
The new button is created on the right-most position.
| aId | is the ID to assign to the button |
| aLabel | is the text for the button |
Definition at line 389 of file wx_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 438 of file wx_infobar.cpp.
References AddButton(), and ID_CLOSE_INFOBAR.
Referenced by APPEARANCE_CONTROLS::onReadOnlySwatch(), onShowInfoBar(), onThemeChange(), EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), APPEARANCE_CONTROLS_3D::rebuildLayers(), FOOTPRINT_EDIT_FRAME::updateInfoBar(), and SYMBOL_EDIT_FRAME::updateInfoBar().
| void WX_INFOBAR::AddLink | ( | const wxString & | aLinkText, |
| const std::function< void(wxHyperlinkEvent &)> & | aFn ) |
Add a hypertext link to the infobar.
Link is added in the right-most position.
| aLinkText | is the text to show |
| aFn | is the function to execute if the link is clicked |
Definition at line 421 of file wx_infobar.cpp.
Referenced by ZONE_FILLER_TOOL::FillAllZones(), APPEARANCE_CONTROLS::onReadOnlySwatch(), EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), PCB_CONTROL::unfilledZoneCheck(), FOOTPRINT_EDIT_FRAME::updateInfoBar(), SYMBOL_EDIT_FRAME::updateInfoBar(), and ZONE_FILLER_TOOL::ZoneFillDirty().
|
override |
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition at line 193 of file wx_infobar.cpp.
References m_callback, m_updateLock, refreshParent(), and stackOverlays().
Referenced by DRAWING_TOOL::DrawVia(), SYMBOL_EDIT_FRAME::LoadOneLibrarySymbol(), onCloseButton(), onDismissInfoBar(), onTimer(), PCB_EDIT_FRAME::OpenProjectFiles(), FOOTPRINT_EDITOR_CONTROL::SaveAs(), FOOTPRINT_EDIT_FRAME::updateInfoBar(), and SYMBOL_EDIT_FRAME::updateInfoBar().
|
protected |
Definition at line 274 of file wx_infobar.cpp.
References m_message.
| void WX_INFOBAR::FixSize | ( | ) |
Address some long-standing bugs regarding infobars comming up only partial-width.
Definition at line 241 of file wx_infobar.cpp.
References doSize().
Referenced by ShowMessage().
| wxBitmapButton * WX_INFOBAR::GetCloseButton | ( | ) | const |
Definition at line 482 of file wx_infobar.cpp.
References ID_CLOSE_INFOBAR.
Referenced by HasCloseButton(), and onThemeChange().
|
inline |
Definition at line 96 of file wx_infobar.h.
References m_type.
Referenced by DRAWING_TOOL::DrawVia().
| bool WX_INFOBAR::HasCloseButton | ( | ) | const |
Definition at line 476 of file wx_infobar.cpp.
References GetCloseButton().
Referenced by FOOTPRINT_EDITOR_CONTROL::SaveAs(), FOOTPRINT_EDIT_FRAME::updateInfoBar(), and SYMBOL_EDIT_FRAME::updateInfoBar().
|
protected |
Event handler for the close button.
This is bound to ID_CLOSE_INFOBAR on the infobar.
Definition at line 518 of file wx_infobar.cpp.
References Dismiss().
Referenced by wxDEFINE_EVENT().
|
protected |
Event handler for dismissing the infobar using a wxCommandEvent of the type KIEVT_DISMISS_INFOBAR.
Definition at line 512 of file wx_infobar.cpp.
References Dismiss().
Referenced by wxDEFINE_EVENT().
|
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 504 of file wx_infobar.cpp.
References AddCloseButton(), RemoveAllButtons(), and ShowMessage().
Referenced by wxDEFINE_EVENT().
|
protected |
Definition at line 265 of file wx_infobar.cpp.
References doSize(), and stackOverlays().
Referenced by WX_INFOBAR(), and ~WX_INFOBAR().
|
protected |
Event handler for the color theme change event.
Definition at line 216 of file wx_infobar.cpp.
References AddCloseButton(), GetCloseButton(), KIPLATFORM::UI::GetInfoBarColours(), and RemoveAllButtons().
Referenced by wxDEFINE_EVENT().
|
protected |
Event handler for the automatic closing timer.
Definition at line 524 of file wx_infobar.cpp.
References Dismiss(), m_showTime, and m_showTimer.
Referenced by wxDEFINE_EVENT().
| void WX_INFOBAR::QueueDismiss | ( | ) |
Send the infobar an event telling it to hide itself.
Definition at line 134 of file wx_infobar.cpp.
| 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 123 of file wx_infobar.cpp.
|
protected |
Repaint the parent so that the area the infobar covered is not left stale.
Definition at line 369 of file wx_infobar.cpp.
References m_overlay.
Referenced by Dismiss().
| void WX_INFOBAR::RemoveAllButtons | ( | ) |
Remove all the buttons that have been added by the user.
Definition at line 448 of file wx_infobar.cpp.
Referenced by PAD_TOOL::enterPadEditMode(), ZONE_FILLER_TOOL::FillAllZones(), APPEARANCE_CONTROLS::onReadOnlySwatch(), onShowInfoBar(), onThemeChange(), EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), APPEARANCE_CONTROLS_3D::rebuildLayers(), PCB_CONTROL::unfilledZoneCheck(), FOOTPRINT_EDIT_FRAME::updateInfoBar(), SYMBOL_EDIT_FRAME::updateInfoBar(), WX_INFOBAR(), and ZONE_FILLER_TOOL::ZoneFillDirty().
|
inline |
Provide a callback to be called when the infobar is dismissed (either by user action or timer).
| aCallback |
Definition at line 155 of file wx_infobar.h.
References m_callback.
| 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 117 of file wx_infobar.cpp.
References m_showTime.
| 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 181 of file wx_infobar.cpp.
References m_type, m_updateLock, and ShowMessage().
|
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 156 of file wx_infobar.cpp.
References FixSize(), m_message, m_showTime, m_showTimer, m_type, m_updateLock, and stackOverlays().
Referenced by PAD_TOOL::enterPadEditMode(), onShowInfoBar(), ShowMessage(), ShowMessageFor(), FOOTPRINT_EDIT_FRAME::updateInfoBar(), and SYMBOL_EDIT_FRAME::updateInfoBar().
| void WX_INFOBAR::ShowMessageFor | ( | const wxString & | aMessage, |
| int | aTime, | ||
| int | aFlags = wxICON_INFORMATION, | ||
| MESSAGE_TYPE | aType = WX_INFOBAR::MESSAGE_TYPE::GENERIC ) |
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 142 of file wx_infobar.cpp.
References m_showTime, m_type, m_updateLock, and ShowMessage().
Referenced by PCB_CONTROL::AppendBoard(), SCH_EDIT_FRAME::CopyVariant(), SCH_EDIT_FRAME::EditVariantDescription(), ZONE_FILLER_TOOL::FillAllZones(), ROUTER_TOOL::handleLayerSwitch(), SIMULATOR_FRAME_UI::InitWorkbook(), APPEARANCE_CONTROLS::onReadOnlySwatch(), EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), APPEARANCE_CONTROLS_3D::rebuildLayers(), SCH_EDIT_FRAME::RenameVariant(), SCH_EDIT_FRAME::ShowAddVariantDialog(), EDA_BASE_FRAME::ShowInfoBarError(), EDA_BASE_FRAME::ShowInfoBarError(), EDA_BASE_FRAME::ShowInfoBarMsg(), EDA_BASE_FRAME::ShowInfoBarWarning(), PCB_CONTROL::unfilledZoneCheck(), SCH_EDIT_FRAME::validateNewVariantName(), and ZONE_FILLER_TOOL::ZoneFillDirty().
|
protected |
Lay out every overlay infobar sharing this one's parent as a top-anchored stack, so that two infobars on the same canvas do not cover each other.
Definition at line 339 of file wx_infobar.cpp.
References m_overlay, and WX_INFOBAR().
Referenced by Dismiss(), onSize(), and ShowMessage().
|
protected |
Optional callback made when closing infobar.
Definition at line 264 of file wx_infobar.h.
Referenced by Dismiss(), and SetCallback().
|
protected |
The original message without wrapping.
Definition at line 262 of file wx_infobar.h.
Referenced by doSize(), and ShowMessage().
|
protected |
True if this infobar is drawn on top of its parent.
Definition at line 259 of file wx_infobar.h.
Referenced by refreshParent(), stackOverlays(), and WX_INFOBAR().
|
protected |
The time to show the infobar. 0 = don't auto hide.
Definition at line 257 of file wx_infobar.h.
Referenced by onTimer(), SetShowTime(), ShowMessage(), ShowMessageFor(), and WX_INFOBAR().
|
protected |
The timer counting the autoclose period.
Definition at line 260 of file wx_infobar.h.
Referenced by onTimer(), ShowMessage(), WX_INFOBAR(), and ~WX_INFOBAR().
|
protected |
The type of message being displayed.
Definition at line 261 of file wx_infobar.h.
Referenced by GetMessageType(), ShowMessage(), ShowMessage(), ShowMessageFor(), and WX_INFOBAR().
|
protected |
True if this infobar requested the UI update.
Definition at line 258 of file wx_infobar.h.
Referenced by Dismiss(), ShowMessage(), ShowMessage(), ShowMessageFor(), and WX_INFOBAR().