From: Vadim Zeitlin Date: Sun, 14 Mar 2010 14:15:42 +0000 (+0000) Subject: Add a "not specified" icon style to the message box test dialog. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8783d72f041f3568641ae64f2b3934658db77156?ds=inline Add a "not specified" icon style to the message box test dialog. The sample allowed to test the behaviour with all wxICON_XXX including wxICON_NONE but not without any icon styles at all. Do allow it now. Also use symbolic names for the radiobox indices for clarity. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63681 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index eb0b735d89..209b051245 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -2589,15 +2589,24 @@ TestMessageBoxDialog::TestMessageBoxDialog(wxWindow *parent) // icon choice - const wxString icons[] = { - "&None", "&Information", "&Question", "&Warning", "&Error" + const wxString icons[] = + { + "&Not specified", + "E&xplicitly none", + "&Information icon", + "&Question icon", + "&Warning icon", + "&Error icon" }; - m_icons = new wxRadioBox(this, wxID_ANY, "&Icons", + wxCOMPILE_TIME_ASSERT( WXSIZEOF(icons) == MsgDlgIcon_Max, IconMismatch ); + + m_icons = new wxRadioBox(this, wxID_ANY, "&Icon style", wxDefaultPosition, wxDefaultSize, - WXSIZEOF(icons), icons); + WXSIZEOF(icons), icons, + 2, wxRA_SPECIFY_ROWS); // Make the 'Information' icon the default one: - m_icons->SetSelection(1); + m_icons->SetSelection(MsgDlgIcon_Info); sizerTop->Add(m_icons, wxSizerFlags().Expand().Border()); @@ -2658,11 +2667,31 @@ void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event)) switch ( m_icons->GetSelection() ) { - case 0: style |= wxICON_NONE; break; - case 1: style |= wxICON_INFORMATION; break; - case 2: style |= wxICON_QUESTION; break; - case 3: style |= wxICON_WARNING; break; - case 4: style |= wxICON_ERROR; break; + case MsgDlgIcon_Max: + wxFAIL_MSG( "unexpected selection" ); + + case MsgDlgIcon_No: + break; + + case MsgDlgIcon_None: + style |= wxICON_NONE; + break; + + case MsgDlgIcon_Info: + style |= wxICON_INFORMATION; + break; + + case MsgDlgIcon_Question: + style |= wxICON_QUESTION; + break; + + case MsgDlgIcon_Warning: + style |= wxICON_WARNING; + break; + + case MsgDlgIcon_Error: + style |= wxICON_ERROR; + break; } if ( m_chkCentre->IsChecked() ) diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index 66944fc65f..dde63a4e31 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -214,6 +214,17 @@ private: static const BtnInfo ms_btnInfo[Btn_Max]; + enum + { + MsgDlgIcon_No, + MsgDlgIcon_None, + MsgDlgIcon_Info, + MsgDlgIcon_Question, + MsgDlgIcon_Warning, + MsgDlgIcon_Error, + MsgDlgIcon_Max + }; + wxTextCtrl *m_textMsg, *m_textExtMsg;