24 #include "wx/artprov.h" 25 #include <wx/aui/framemanager.h> 27 #include <wx/infobar.h> 30 #include <wx/hyperlink.h> 31 #include <wx/bmpbuttn.h> 38 BEGIN_EVENT_TABLE(
WX_INFOBAR, wxInfoBarGeneric )
48 : wxInfoBarGeneric( aParent, aWinid ),
50 m_updateLock( false ),
51 m_showTimer(
nullptr ),
60 SetBackgroundColour( wxColour( 28, 27, 20 ) );
62 SetBackgroundColour( wxColour( 255, 249, 189 ) );
65 SetShowHideEffects( wxSHOW_EFFECT_ROLL_TO_BOTTOM, wxSHOW_EFFECT_ROLL_TO_TOP );
66 SetEffectDuration( 300 );
69 SetShowHideEffects( wxSHOW_EFFECT_NONE, wxSHOW_EFFECT_NONE );
81 wxSizer* sizer = GetSizer();
82 wxSize iconSize = wxArtProvider::GetSizeHint( wxART_BUTTON );
84 sizer->SetItemMinSize( (
size_t) 0, iconSize.x, sy );
111 wxCommandEvent* evt =
new wxCommandEvent( KIEVT_SHOW_INFOBAR );
113 evt->SetString( aMessage.c_str() );
114 evt->SetInt( aFlags );
116 GetEventHandler()->QueueEvent( evt );
122 wxCommandEvent* evt =
new wxCommandEvent( KIEVT_DISMISS_INFOBAR );
124 GetEventHandler()->QueueEvent( evt );
150 wxInfoBarGeneric::ShowMessage( aMessage, aFlags );
183 wxInfoBarGeneric::Dismiss();
197 int barWidth = GetSize().GetWidth();
203 int parentWidth = m_parent->GetClientSize().GetWidth();
204 EDA_BASE_FRAME* frame = dynamic_cast<EDA_BASE_FRAME*>( m_parent );
210 if( barWidth != parentWidth )
211 SetSize( parentWidth, GetSize().GetHeight() );
239 wxButton* button =
new wxButton(
this, aId, aLabel );
247 wxSizer* sizer = GetSizer();
254 aButton->SetWindowVariant( wxWINDOW_VARIANT_SMALL );
256 sizer->Add( aButton, wxSizerFlags().Centre().Border( wxRIGHT ) );
265 wxSizer* sizer = GetSizer();
267 wxASSERT( aHypertextButton );
269 sizer->Add( aHypertextButton, wxSizerFlags().Centre().Border( wxRIGHT ) );
278 wxBitmapButton* button = wxBitmapButton::NewCloseButton(
this,
ID_CLOSE_INFOBAR );
280 button->SetToolTip( aTooltip );
288 wxSizer* sizer = GetSizer();
290 if( sizer->GetItemCount() == 0 )
294 if( sizer->GetItem( sizer->GetItemCount() - 1 )->IsSpacer() )
297 for(
int i = sizer->GetItemCount() - 1; i >= 0; i-- )
299 wxSizerItem* sItem = sizer->GetItem( i );
302 if( sItem->IsSpacer() )
305 delete sItem->GetWindow();
312 wxSizer* sizer = GetSizer();
314 if( sizer->GetItemCount() == 0 )
317 if( sizer->GetItem( sizer->GetItemCount() - 1 )->IsSpacer() )
320 wxSizerItem* item = sizer->GetItem( sizer->GetItemCount() - 1 );
330 ShowMessage( aEvent.GetString(), aEvent.GetInt() );
357 const wxSize& aSize,
long aStyle,
const wxString& aName )
358 : wxPanel( aParent, aId, aPos, aSize, aStyle, aName )
371 wxASSERT( aInfoBar );
373 aInfoBar->Reparent(
this );
381 wxASSERT( aOtherItem );
383 aOtherItem->Reparent(
this );
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
MESSAGE_TYPE
Sets the type of message for special handling if needed.
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
void onTimer(wxTimerEvent &aEvent)
Event handler for the automatic closing timer.
void onSize(wxSizeEvent &aEvent)
void updateAuiLayout(bool aShow)
Update the AUI pane to show or hide this infobar.
void onCloseButton(wxCommandEvent &aEvent)
Event handler for the close button.
GENERIC Are messages that do not have special handling.
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.
wxTimer * m_showTimer
The timer counting the autoclose period.
void onShowInfoBar(wxCommandEvent &aEvent)
Event handler for showing the infobar using a wxCommandEvent of the type KIEVT_SHOW_INFOBAR.
OPT< std::function< void(void)> > m_callback
Optional callback made when closing infobar.
bool HasCloseButton() const
wxDEFINE_EVENT(KIEVT_SHOW_INFOBAR, wxCommandEvent)
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
ID for the close button on the frame's infobar.
void AddOtherItem(wxWindow *aOtherItem)
Add the other item to the panel.
Base window classes and related definitions.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
void QueueShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION)
Send the infobar an event telling it to show a message.
A modified version of the wxInfoBar class that allows us to:
void SetShowTime(int aTime)
Set the time period to show the infobar.
void QueueDismiss()
Send the infobar an event telling it to hide itself.
wxFlexGridSizer * m_mainSizer
The base frame for deriving all KiCad main window classes.
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)
wxAuiManager * m_auiManager
The AUI manager that contains this infobar.
void onDismissInfoBar(wxCommandEvent &aEvent)
Event handler for dismissing the infobar using a wxCommandEvent of the type KIEVT_DISMISS_INFOBAR.
bool m_updateLock
True if this infobar requested the UI update.
void AddInfoBar(WX_INFOBAR *aInfoBar)
Add the given infobar object to the panel.
MESSAGE_TYPE m_type
The type of message being displayed.
int m_showTime
The time to show the infobar. 0 = don't auto hide.
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.