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>
42BEGIN_EVENT_TABLE(
WX_INFOBAR, wxInfoBarGeneric )
52 : wxInfoBarGeneric( aParent, aWinid ),
54 m_updateLock( false ),
55 m_showTimer(
nullptr ),
64 SetBackgroundColour( wxColour( 28, 27, 20 ) );
66 SetBackgroundColour( wxColour( 255, 249, 189 ) );
69 SetShowHideEffects( wxSHOW_EFFECT_ROLL_TO_BOTTOM, wxSHOW_EFFECT_ROLL_TO_TOP );
70 SetEffectDuration( 200 );
73 SetShowHideEffects( wxSHOW_EFFECT_NONE, wxSHOW_EFFECT_NONE );
84 wxSizer* sizer = GetSizer();
85 wxSize iconSize = wxArtProvider::GetSizeHint( wxART_BUTTON );
96 sizer->SetItemMinSize( (
size_t) 0, iconSize.x, sy );
123 wxCommandEvent* evt =
new wxCommandEvent( KIEVT_SHOW_INFOBAR );
125 evt->SetString( aMessage.c_str() );
126 evt->SetInt( aFlags );
128 GetEventHandler()->QueueEvent( evt );
134 wxCommandEvent* evt =
new wxCommandEvent( KIEVT_DISMISS_INFOBAR );
136 GetEventHandler()->QueueEvent( evt );
162 wxString msg = aMessage;
165 wxInfoBarGeneric::ShowMessage( msg, aFlags );
192 if( !IsShownOnScreen() )
201 wxInfoBarGeneric::Dismiss();
215 int barWidth = GetSize().GetWidth();
221 int parentWidth = m_parent->GetClientSize().GetWidth();
228 if( barWidth != parentWidth )
229 SetSize( parentWidth, GetSize().GetHeight() );
257 wxButton* button =
new wxButton(
this, aId, aLabel );
265 wxSizer* sizer = GetSizer();
272 aButton->SetWindowVariant( wxWINDOW_VARIANT_SMALL );
274 sizer->Add( aButton, wxSizerFlags().Centre().Border( wxRIGHT ) );
276 if( IsShownOnScreen() )
283 wxSizer* sizer = GetSizer();
285 wxASSERT( aHypertextButton );
287 sizer->Add( aHypertextButton, wxSizerFlags().Centre().Border( wxRIGHT ) );
289 if( IsShownOnScreen() )
296 wxBitmapButton* button = wxBitmapButton::NewCloseButton(
this,
ID_CLOSE_INFOBAR );
298 button->SetToolTip( aTooltip );
306 wxSizer* sizer = GetSizer();
308 if( sizer->GetItemCount() == 0 )
312 if( sizer->GetItem( sizer->GetItemCount() - 1 )->IsSpacer() )
315 for(
int i = sizer->GetItemCount() - 1; i >= 0; i-- )
317 wxSizerItem* sItem = sizer->GetItem( i );
320 if( sItem->IsSpacer() )
323 delete sItem->GetWindow();
330 wxSizer* sizer = GetSizer();
332 if( sizer->GetItemCount() == 0 )
335 if( sizer->GetItem( sizer->GetItemCount() - 1 )->IsSpacer() )
338 wxSizerItem* item = sizer->GetItem( sizer->GetItemCount() - 1 );
348 ShowMessage( aEvent.GetString(), aEvent.GetInt() );
375 const wxSize& aSize,
long aStyle,
const wxString& aName )
376 : wxPanel( aParent, aId, aPos, aSize, aStyle, aName )
389 wxASSERT( aInfoBar );
391 aInfoBar->Reparent(
this );
399 wxASSERT( aOtherItem );
401 aOtherItem->Reparent(
this );
411 m_message.reset(
new wxString( aText ) );
435 int icon = wxICON_NONE;
Class to handle configuration and automatic determination of the DPI scale to use for canvases.
double GetContentScaleFactor() const override
Get the content scale factor, which may be different from the scale factor on some platforms.
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)
wxFlexGridSizer * m_mainSizer
void AddInfoBar(WX_INFOBAR *aInfoBar)
Add the given infobar object to the panel.
void AddOtherItem(wxWindow *aOtherItem)
Add the other item to the panel.
void Finalize()
Update the infobar with the reported text.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
std::unique_ptr< wxString > m_message
bool HasMessage() const override
Returns true if the reporter client is non-empty.
A pure virtual class used to derive REPORTER objects from.
A modified version of the wxInfoBar class that allows us to:
void SetShowTime(int aTime)
Set the time period to show the infobar.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
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.
bool HasCloseButton() const
MESSAGE_TYPE m_type
The type of message being displayed.
void updateAuiLayout(bool aShow)
Update the AUI pane to show or hide this infobar.
std::optional< std::function< void(void)> > m_callback
Optional callback made when closing infobar.
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.
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 AddButton(wxButton *aButton)
Add an already created button to the infobar.
MESSAGE_TYPE
Sets the type of message for special handling if needed.
@ GENERIC
GENERIC Are messages that do not have special handling.
void QueueShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION)
Send the infobar an event telling it to show a message.
void onCloseButton(wxCommandEvent &aEvent)
Event handler for the close button.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
wxTimer * m_showTimer
The timer counting the autoclose period.
void onTimer(wxTimerEvent &aEvent)
Event handler for the automatic closing timer.
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
wxAuiManager * m_auiManager
The AUI manager that contains this infobar.
void onSize(wxSizeEvent &aEvent)
void QueueDismiss()
Send the infobar an event telling it to hide itself.
Base window classes and related definitions.
wxDEFINE_EVENT(KIEVT_SHOW_INFOBAR, wxCommandEvent)
@ ID_CLOSE_INFOBAR
ID for the close button on the frame's infobar.