From: Vadim Zeitlin Date: Sun, 28 Jun 2009 16:25:37 +0000 (+0000) Subject: added wxICON_NONE and implement support for it in wxGTK (closes #2897) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/7e3204b45cf8e1bb882b314d456e75f2a22850d7 added wxICON_NONE and implement support for it in wxGTK (closes #2897) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61234 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/defs.h b/include/wx/defs.h index 75d36d81b3..633ddf1147 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1824,7 +1824,7 @@ enum wxBorder #define wxICON_INFORMATION 0x00000800 #define wxICON_STOP wxICON_HAND #define wxICON_ASTERISK wxICON_INFORMATION -#define wxICON_MASK (0x00000100|0x00000200|0x00000400|0x00000800) +#define wxICON_MASK (wxICON_EXCLAMATION|wxICON_HAND|wxICON_QUESTION|wxICON_INFORMATION) #define wxFORWARD 0x00001000 #define wxBACKWARD 0x00002000 @@ -1832,6 +1832,7 @@ enum wxBorder #define wxHELP 0x00008000 #define wxMORE 0x00010000 #define wxSETUP 0x00020000 +#define wxICON_NONE 0x00040000 /* * Background styles. See wxWindow::SetBackgroundStyle diff --git a/interface/wx/msgdlg.h b/interface/wx/msgdlg.h index 4477d22675..6a88ff8558 100644 --- a/interface/wx/msgdlg.h +++ b/interface/wx/msgdlg.h @@ -31,10 +31,16 @@ @style{wxOK_DEFAULT} Makes the "OK" button default, this is the default behaviour and this flag exists solely for symmetry with @c wxCANCEL_DEFAULT. + @style{wxICON_NONE} + Displays no icon in the dialog if possible (an icon might still be + displayed if the current platform mandates its use). This style may be + used to prevent the dialog from using the default icon based on @c + wxYES_NO presence as explained in @c wxICON_QUESTION and @c + wxICON_INFORMATION documentation below. @style{wxICON_EXCLAMATION} - Displays an exclamation mark symbol. + Displays an exclamation, or warning, icon in the dialog. @style{wxICON_ERROR} - Displays an error symbol. + Displays an error icon in the dialog. @style{wxICON_HAND} Displays an error symbol, this is a MSW-inspired synonym for @c wxICON_ERROR. @style{wxICON_QUESTION} diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index d9cd57f079..b334211622 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -2458,12 +2458,14 @@ TestMessageBoxDialog::TestMessageBoxDialog(wxWindow *parent) // icon choice const wxString icons[] = { - "&Information", "&Question", "&Warning", "&Error" + "&None", "&Information", "&Question", "&Warning", "&Error" }; - m_icons = new wxRadioBox(this, wxID_ANY, "&Icon:", + m_icons = new wxRadioBox(this, wxID_ANY, "&Icons", wxDefaultPosition, wxDefaultSize, WXSIZEOF(icons), icons); + // Make the 'Information' icon the default one: + m_icons->SetSelection(1); sizerTop->Add(m_icons, wxSizerFlags().Expand().Border()); @@ -2524,10 +2526,11 @@ void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event)) switch ( m_icons->GetSelection() ) { - case 0: style |= wxICON_INFORMATION; break; - case 1: style |= wxICON_QUESTION; break; - case 2: style |= wxICON_WARNING; break; - case 3: style |= wxICON_ERROR; break; + 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; } if ( m_chkCentre->IsChecked() ) diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index afcfa394dd..2a8dbf931b 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -1283,14 +1283,14 @@ wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt) int wxMessageBox(const wxString& message, const wxString& caption, long style, wxWindow *parent, int WXUNUSED(x), int WXUNUSED(y) ) { - long decorated_style = style; - - if ( ( style & ( wxICON_EXCLAMATION | wxICON_HAND | wxICON_INFORMATION | wxICON_QUESTION ) ) == 0 ) + // add the appropriate icon unless this was explicitly disabled by use of + // wxICON_NONE + if ( !(style & wxICON_NONE) && !(style & wxICON_MASK) ) { - decorated_style |= ( style & wxYES ) ? wxICON_QUESTION : wxICON_INFORMATION ; + style |= style & wxYES ? wxICON_QUESTION : wxICON_INFORMATION; } - wxMessageDialog dialog(parent, message, caption, decorated_style); + wxMessageDialog dialog(parent, message, caption, style); int ans = dialog.ShowModal(); switch ( ans ) diff --git a/src/gtk/msgdlg.cpp b/src/gtk/msgdlg.cpp index d7b27a4777..cca4971b6e 100644 --- a/src/gtk/msgdlg.cpp +++ b/src/gtk/msgdlg.cpp @@ -86,7 +86,9 @@ void wxMessageDialog::GTKCreateMsgDialog() #if wxUSE_LIBHILDON const char *stockIcon; - if ( m_dialogStyle & wxICON_ERROR ) + if ( m_dialogStyle & wxICON_NONE ) + stockIcon = ""; + else if ( m_dialogStyle & wxICON_ERROR ) stockIcon = "qgn_note_gene_syserror"; else if ( m_dialogStyle & wxICON_EXCLAMATION ) stockIcon = "qgn_note_gene_syswarning"; @@ -127,6 +129,11 @@ void wxMessageDialog::GTKCreateMsgDialog() } } +#ifdef __WXGTK210__ + if ( gtk_check_version(2, 10, 0) == NULL && (m_dialogStyle & wxICON_NONE)) + type = GTK_MESSAGE_OTHER; + else +#endif // __WXGTK210__ if (m_dialogStyle & wxICON_EXCLAMATION) type = GTK_MESSAGE_WARNING; else if (m_dialogStyle & wxICON_ERROR) @@ -137,7 +144,8 @@ void wxMessageDialog::GTKCreateMsgDialog() type = GTK_MESSAGE_QUESTION; else { - // GTK+ doesn't have a "typeless" msg box, so try to auto detect... + // if no style is explicitly specified, detect the suitable icon + // ourselves (this can be disabled by using wxICON_NONE) type = m_dialogStyle & wxYES ? GTK_MESSAGE_QUESTION : GTK_MESSAGE_INFO; }