Пример #1
0
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 AttentionMessage::MergeFrom(const AttentionMessage& from) {
  GOOGLE_CHECK_NE(&from, this);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from.has_message()) {
      set_message(from.message());
    }
    if (from.has_time_to_show()) {
      set_time_to_show(from.time_to_show());
    }
    if (from.has_team_color()) {
      set_team_color(from.team_color());
    }
  }
  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
Пример #3
0
void AttentionBar::ShowMessage(const AttentionMessage& msg)
{
    if ( msg.IsBlacklisted() )
        return;

#ifdef __WXGTK__
    switch ( msg.m_kind )
    {
        case AttentionMessage::Info:
            SetBackgroundColour(wxColour(252,252,189));
            break;
        case AttentionMessage::Warning:
            SetBackgroundColour(wxColour(250,173,61));
            break;
        case AttentionMessage::Question:
            SetBackgroundColour(wxColour(138,173,212));
            break;
        case AttentionMessage::Error:
            SetBackgroundColour(wxColour(237,54,54));
            break;
    }
#else

    switch ( msg.m_kind )
    {
        case AttentionMessage::Question:
            SetBackgroundColour("#ABE887");
            break;
        default:
    #ifdef __WXMSW__
            SetBackgroundColour("#FFF499"); // match Visual Studio 2012+'s aesthetics
    #else
            SetBackgroundColour("#FCDE59");
    #endif
            break;
    }

#ifdef __WXMSW__
    auto bg = GetBackgroundColour();
    for (auto w : GetChildren())
        w->SetBackgroundColour(bg);
#endif

    wxString iconName;
    switch ( msg.m_kind )
    {
        case AttentionMessage::Info:
            iconName = wxART_INFORMATION;
            break;
        case AttentionMessage::Warning:
            iconName = wxART_WARNING;
            break;
        case AttentionMessage::Question:
            iconName = wxART_QUESTION;
            break;
        case AttentionMessage::Error:
            iconName = wxART_ERROR;
            break;
    }
    m_icon->SetBitmap(wxArtProvider::GetBitmap(iconName, wxART_MENU, wxSize(PX(16), PX(16))));
#endif

    m_label->SetAndWrapLabel(msg.m_text);
    m_explanation->SetAndWrapLabel(msg.m_explanation);
    m_explanation->GetContainingSizer()->Show(m_explanation, !msg.m_explanation.empty());
    m_checkbox->SetLabel(msg.m_checkbox);
    m_checkbox->GetContainingSizer()->Show(m_checkbox, !msg.m_checkbox.empty());

    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 __WXOSX__
        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();

    Refresh();
    Show();
    GetParent()->Layout();
}