void AttentionBar::ShowMessage(const AttentionMessage& msg) { if ( msg.IsBlacklisted() ) return; wxString iconName; switch ( msg.m_kind ) { case AttentionMessage::Info: iconName = wxART_INFORMATION; break; case AttentionMessage::Warning: iconName = wxART_WARNING; break; case AttentionMessage::Error: iconName = wxART_ERROR; break; } m_icon->SetBitmap(wxArtProvider::GetBitmap(iconName, wxART_MENU)); #if wxCHECK_VERSION(2,9,0) m_label->SetLabelText(msg.m_text); #else m_label->SetLabel(msg.m_text); #endif m_buttons->Clear(true/*delete_windows*/); m_actions.clear(); for ( AttentionMessage::Actions::const_iterator i = msg.m_actions.begin(); i != msg.m_actions.end(); ++i ) { wxButton *b = new wxButton(this, wxID_ANY, i->first); #ifdef __WXMAC__ MakeButtonRounded(b->GetHandle()); #endif m_buttons->Add(b, wxSizerFlags().Center().Border(wxRIGHT, BUTTONS_SPACE)); m_actions[b] = i->second; } // we need to size the control correctly _and_ lay out the controls if this // is the first time it's being shown, otherwise we can get garbled look: SetSize(GetParent()->GetClientSize().x, GetBestSize().y); Layout(); #ifdef USE_SLIDE_EFFECT ShowWithEffect(wxSHOW_EFFECT_SLIDE_TO_BOTTOM); #else Show(); #endif GetParent()->Layout(); }
void wxInfoBarGeneric::DoShow() { // re-layout the parent first so that the window expands into an already // unoccupied by the other controls area: for this we need to change our // internal visibility flag to force Layout() to take us into account (an // alternative solution to this hack would be to temporarily set // wxRESERVE_SPACE_EVEN_IF_HIDDEN flag but it's not really batter) // just change the internal flag indicating that the window is visible, // without really showing it wxWindowBase::Show(); // adjust the parent layout to account for us UpdateParent(); // reset the flag back before really showing the window or it wouldn't be // shown at all because it would believe itself already visible wxWindowBase::Show(false); // finally do really show the window. ShowWithEffect(GetShowEffect(), GetEffectDuration()); }