KiCad PCB EDA Suite
Loading...
Searching...
No Matches
WX_INFOBAR Class Reference

A modified version of the wxInfoBar class that allows us to: More...

#include <wx_infobar.h>

Inheritance diagram for WX_INFOBAR:

Public Types

enum class  MESSAGE_TYPE { GENERIC , OUTDATED_SAVE , DRC_RULES_ERROR , DRC_VIOLATION }
 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 ()
 
MESSAGE_TYPE GetMessageType () const
 
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, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
 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 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...
 
std::optional< std::function< void(void)> > m_callback
 Optional callback made when closing infobar. More...
 

Detailed Description

A modified version of the wxInfoBar class that allows us to:

  • Show the close button along with the other buttons
  • Remove all user-provided buttons at once
  • Allow automatically hiding the infobar after a time period
  • Show/hide using events
  • Place it inside an AUI manager

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 74 of file wx_infobar.h.

Member Enumeration Documentation

◆ MESSAGE_TYPE

enum class WX_INFOBAR::MESSAGE_TYPE
strong

Sets the type of message for special handling if needed.

Enumerator
GENERIC 

GENERIC Are messages that do not have special handling.

OUTDATED_SAVE 

OUTDATED_SAVE Messages that should be cleared on save.

DRC_RULES_ERROR 
DRC_VIOLATION 

Definition at line 92 of file wx_infobar.h.

Constructor & Destructor Documentation

◆ WX_INFOBAR()

WX_INFOBAR::WX_INFOBAR ( wxWindow *  aParent,
wxAuiManager *  aMgr = nullptr,
wxWindowID  aWinid = wxID_ANY 
)

Construct an infobar that can exist inside an AUI managed frame.

Parameters
aParentis the parent
aMgris the AUI manager that this infobar is added to
aWinIdis the ID for this infobar object

Definition at line 51 of file wx_infobar.cpp.

References DPI_SCALING_COMMON::GetContentScaleFactor(), ID_CLOSE_INFOBAR, KIPLATFORM::UI::IsDarkTheme(), and onSize().

◆ ~WX_INFOBAR()

WX_INFOBAR::~WX_INFOBAR ( )

Definition at line 109 of file wx_infobar.cpp.

References m_showTimer.

Member Function Documentation

◆ AddButton() [1/3]

void WX_INFOBAR::AddButton ( wxButton *  aButton)

Add an already created button to the infobar.

New buttons are added in the right-most position.

Parameters
aButtonis the button to add

Definition at line 260 of file wx_infobar.cpp.

Referenced by AddButton(), AddCloseButton(), ZONE_FILLER_TOOL::FillAllZones(), APPEARANCE_CONTROLS::onReadOnlySwatch(), SYMBOL_EDIT_FRAME::SetCurSymbol(), DIALOG_PIN_PROPERTIES::TransferDataToWindow(), PCB_CONTROL::unfilledZoneCheck(), DIALOG_ERC::UpdateAnnotationWarning(), and ZONE_FILLER_TOOL::ZoneFillDirty().

◆ AddButton() [2/3]

void WX_INFOBAR::AddButton ( wxHyperlinkCtrl *  aHypertextButton)

Add an already created hypertext link to the infobar.

New buttons are added in the right-most position.

Parameters
aHypertextButtonis the button to add

Definition at line 278 of file wx_infobar.cpp.

◆ AddButton() [3/3]

void WX_INFOBAR::AddButton ( wxWindowID  aId,
const wxString &  aLabel = wxEmptyString 
)
override

Add a button with the provided ID and text.

The new button is created on the right-most position.

Parameters
aIdis the ID to assign to the button
aLabelis the text for the button

Definition at line 252 of file wx_infobar.cpp.

References AddButton().

◆ AddCloseButton()

void WX_INFOBAR::AddCloseButton ( const wxString &  aTooltip = _( "Hide this message." ))

◆ Dismiss()

◆ GetMessageType()

◆ HasCloseButton()

bool WX_INFOBAR::HasCloseButton ( ) const

Definition at line 325 of file wx_infobar.cpp.

References ID_CLOSE_INFOBAR.

Referenced by FOOTPRINT_EDITOR_CONTROL::SaveAs(), and PCB_EDIT_FRAME::SavePcbFile().

◆ IsLocked()

bool WX_INFOBAR::IsLocked ( )
inline

Returns true if the infobar is being updated.

Definition at line 212 of file wx_infobar.h.

References m_updateLock.

Referenced by EDA_DRAW_PANEL_GAL::onSize().

◆ onCloseButton()

void WX_INFOBAR::onCloseButton ( wxCommandEvent &  aEvent)
protected

Event handler for the close button.

This is bound to ID_CLOSE_INFOBAR on the infobar.

Definition at line 355 of file wx_infobar.cpp.

References Dismiss().

◆ onDismissInfoBar()

void WX_INFOBAR::onDismissInfoBar ( wxCommandEvent &  aEvent)
protected

Event handler for dismissing the infobar using a wxCommandEvent of the type KIEVT_DISMISS_INFOBAR.

Definition at line 349 of file wx_infobar.cpp.

References Dismiss().

◆ onShowInfoBar()

void WX_INFOBAR::onShowInfoBar ( wxCommandEvent &  aEvent)
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 341 of file wx_infobar.cpp.

References AddCloseButton(), RemoveAllButtons(), and ShowMessage().

◆ onSize()

void WX_INFOBAR::onSize ( wxSizeEvent &  aEvent)
protected

Definition at line 210 of file wx_infobar.cpp.

References TOOLS_HOLDER::GetToolCanvas().

Referenced by WX_INFOBAR().

◆ onTimer()

void WX_INFOBAR::onTimer ( wxTimerEvent &  aEvent)
protected

Event handler for the automatic closing timer.

Definition at line 361 of file wx_infobar.cpp.

References Dismiss(), m_showTime, and m_showTimer.

◆ QueueDismiss()

void WX_INFOBAR::QueueDismiss ( )

Send the infobar an event telling it to hide itself.

Definition at line 132 of file wx_infobar.cpp.

Referenced by INFOBAR_REPORTER::Finalize().

◆ QueueShowMessage()

void WX_INFOBAR::QueueShowMessage ( const wxString &  aMessage,
int  aFlags = wxICON_INFORMATION 
)

Send the infobar an event telling it to show a message.

Parameters
aMessageis the message to display
aFlagsis the flag containing the icon to display on the left side of the infobar

Definition at line 121 of file wx_infobar.cpp.

Referenced by INFOBAR_REPORTER::Finalize().

◆ RemoveAllButtons()

◆ SetCallback()

void WX_INFOBAR::SetCallback ( std::function< void(void)>  aCallback)
inline

Provide a callback to be called when the infobar is dismissed (either by user action or timer).

Parameters
aCallback

Definition at line 157 of file wx_infobar.h.

References m_callback.

Referenced by EDA_BASE_FRAME::ShowInfoBarError().

◆ SetShowTime()

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).

Parameters
aTimeis the time in milliseconds to show the infobar

Definition at line 115 of file wx_infobar.cpp.

References m_showTime.

◆ ShowMessage() [1/2]

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.

Parameters
aMessageis the message to display
aFlagsis the flag containing the icon to display on the left side of the infobar
aTypeis the type of message being displayed

Definition at line 175 of file wx_infobar.cpp.

References m_type, m_updateLock, and ShowMessage().

◆ ShowMessage() [2/2]

◆ ShowMessageFor()

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.

Parameters
aMessageis the message to display
aTimeis the amount of time in milliseconds to show the infobar
aFlagsis the flag containing the icon to display on the left side of the infobar

Definition at line 140 of file wx_infobar.cpp.

References m_showTime, m_type, m_updateLock, and ShowMessage().

Referenced by AUTOPLACE_TOOL::autoplace(), FOOTPRINT_EDIT_FRAME::CanCloseFPFromBoard(), ZONE_FILLER_TOOL::FillAllZones(), ROUTER_TOOL::handleLayerSwitch(), APPEARANCE_CONTROLS::onReadOnlySwatch(), APPEARANCE_CONTROLS_3D::rebuildLayers(), SYMBOL_EDIT_FRAME::saveAllLibraries(), PAGED_DIALOG::SetError(), SCH_EDIT_FRAME::ShowFindReplaceStatus(), EDA_BASE_FRAME::ShowInfoBarError(), EDA_BASE_FRAME::ShowInfoBarMsg(), EDA_BASE_FRAME::ShowInfoBarWarning(), PCB_CONTROL::unfilledZoneCheck(), and ZONE_FILLER_TOOL::ZoneFillDirty().

◆ updateAuiLayout()

void WX_INFOBAR::updateAuiLayout ( bool  aShow)
protected

Update the AUI pane to show or hide this infobar.

Parameters
aShowis true to show the pane

Definition at line 232 of file wx_infobar.cpp.

References m_auiManager.

Referenced by Dismiss(), and ShowMessage().

Member Data Documentation

◆ m_auiManager

wxAuiManager* WX_INFOBAR::m_auiManager
protected

The AUI manager that contains this infobar.

Definition at line 255 of file wx_infobar.h.

Referenced by Dismiss(), ShowMessage(), and updateAuiLayout().

◆ m_callback

std::optional<std::function<void(void)> > WX_INFOBAR::m_callback
protected

Optional callback made when closing infobar.

Definition at line 258 of file wx_infobar.h.

Referenced by Dismiss(), and SetCallback().

◆ m_showTime

int WX_INFOBAR::m_showTime
protected

The time to show the infobar. 0 = don't auto hide.

Definition at line 252 of file wx_infobar.h.

Referenced by onTimer(), SetShowTime(), ShowMessage(), and ShowMessageFor().

◆ m_showTimer

wxTimer* WX_INFOBAR::m_showTimer
protected

The timer counting the autoclose period.

Definition at line 254 of file wx_infobar.h.

Referenced by onTimer(), ShowMessage(), and ~WX_INFOBAR().

◆ m_type

MESSAGE_TYPE WX_INFOBAR::m_type
protected

The type of message being displayed.

Definition at line 256 of file wx_infobar.h.

Referenced by GetMessageType(), ShowMessage(), and ShowMessageFor().

◆ m_updateLock

bool WX_INFOBAR::m_updateLock
protected

True if this infobar requested the UI update.

Definition at line 253 of file wx_infobar.h.

Referenced by Dismiss(), IsLocked(), ShowMessage(), and ShowMessageFor().


The documentation for this class was generated from the following files: