+void wxInfoBarGeneric::Dismiss()
+{
+ DoHide();
+}
+
+void wxInfoBarGeneric::AddButton(wxWindowID btnid, const wxString& label)
+{
+ wxSizer * const sizer = GetSizer();
+ wxCHECK_RET( sizer, "must be created first" );
+
+ // user-added buttons replace the standard close button so remove it if we
+ // hadn't done it yet
+ if ( sizer->Detach(m_button) )
+ {
+ m_button->Hide();
+ }
+
+ wxButton * const button = new wxButton(this, btnid, label);
+
+#ifdef __WXMAC__
+ // smaller buttons look better in the (narrow) info bar under OS X
+ button->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
+#endif // __WXMAC__
+
+ sizer->Add(button, wxSizerFlags().Centre().DoubleBorder());
+}
+
+void wxInfoBarGeneric::RemoveButton(wxWindowID btnid)
+{
+ wxSizer * const sizer = GetSizer();
+ wxCHECK_RET( sizer, "must be created first" );
+
+ // iterate over the sizer items in reverse order to find the last added
+ // button with this id (ids of all buttons should be unique anyhow but if
+ // they are repeated removing the last added one probably makes more sense)
+ const wxSizerItemList& items = sizer->GetChildren();
+ for ( wxSizerItemList::compatibility_iterator node = items.GetLast();
+ node != items.GetFirst();
+ node = node->GetPrevious() )
+ {
+ const wxSizerItem * const item = node->GetData();
+
+ // if we reached the spacer separating the buttons from the text
+ // preceding them without finding our button, it must mean it's not
+ // there at all
+ if ( item->IsSpacer() )
+ {
+ wxFAIL_MSG( wxString::Format("button with id %d not found", btnid) );
+ return;
+ }
+
+ // check if we found our button
+ if ( item->GetWindow()->GetId() == btnid )
+ {
+ delete item->GetWindow();
+ break;
+ }
+ }
+
+ // check if there are any custom buttons left
+ if ( sizer->GetChildren().GetLast()->GetData()->IsSpacer() )
+ {
+ // if the last item is the spacer, none are left so restore the
+ // standard close button
+ sizer->Add(m_button, wxSizerFlags().Centre().DoubleBorder());
+ m_button->Show();
+ }
+}
+
+void wxInfoBarGeneric::OnButton(wxCommandEvent& WXUNUSED(event))