Only show the default close button in wxInfoBar if there are no others.

Assume that user-added buttons can be already used to close the message so
don't show the default close button if any were added.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62280 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-10-05 22:55:40 +00:00
parent c0945eb234
commit 6a3f8b4f1f
5 changed files with 74 additions and 18 deletions

View File

@@ -245,9 +245,15 @@ void wxInfoBarGeneric::AddButton(wxWindowID btnid, const wxString& label)
wxSizer * const sizer = GetSizer();
wxCHECK_RET( sizer, "must be created first" );
sizer->Insert(sizer->GetItemCount() - 1,
new wxButton(this, btnid, label),
wxSizerFlags().Centre().DoubleBorder());
// 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();
}
sizer->Add(new wxButton(this, btnid, label),
wxSizerFlags().Centre().DoubleBorder());
}
void wxInfoBarGeneric::RemoveButton(wxWindowID btnid)
@@ -263,7 +269,6 @@ void wxInfoBarGeneric::RemoveButton(wxWindowID btnid)
node != items.GetFirst();
node = node->GetPrevious() )
{
node = node->GetPrevious();
const wxSizerItem * const item = node->GetData();
// if we reached the spacer separating the buttons from the text
@@ -282,6 +287,15 @@ void wxInfoBarGeneric::RemoveButton(wxWindowID btnid)
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))