From: Vadim Zeitlin Date: Mon, 29 Apr 2013 12:54:08 +0000 (+0000) Subject: Add support for wxICON_AUTH_NEEDED to wxMessageDialog. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/67315c8bf9584d2dde61d13169c5a445f68f44c6 Add support for wxICON_AUTH_NEEDED to wxMessageDialog. Allow showing the standard "Authentication needed" dialog in the message boxes under MSW. Closes #15121. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73877 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index f53582277b..061af1a26f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -666,6 +666,7 @@ wxMSW: - Generate menu highlight events for popup menus in wxDialog (Sam Partington). - Return more native shell icons from wxArtProvider (Markus Juergens). - Fix filter checks in wxDir::FindFirst/Next() (Catalin Raceanu). +- Add support for wxICON_AUTH_NEEDED to wxMessageDialog (Chris Spencer). wxOSX/Cocoa: diff --git a/include/wx/defs.h b/include/wx/defs.h index f95bb7cc34..d7d08a7469 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1924,9 +1924,10 @@ enum wxBorder #define wxMORE 0x00010000 #define wxSETUP 0x00020000 #define wxICON_NONE 0x00040000 +#define wxICON_AUTH_NEEDED 0x00080000 #define wxICON_MASK \ - (wxICON_EXCLAMATION|wxICON_HAND|wxICON_QUESTION|wxICON_INFORMATION|wxICON_NONE) + (wxICON_EXCLAMATION|wxICON_HAND|wxICON_QUESTION|wxICON_INFORMATION|wxICON_NONE|wxICON_AUTH_NEEDED) /* * Background styles. See wxWindow::SetBackgroundStyle diff --git a/include/wx/msgdlg.h b/include/wx/msgdlg.h index 4dbd2d5ac2..14df02f961 100644 --- a/include/wx/msgdlg.h +++ b/include/wx/msgdlg.h @@ -209,8 +209,9 @@ public: { return m_help.empty() ? GetDefaultHelpLabel() : m_help; } // based on message dialog style, returns exactly one of: wxICON_NONE, - // wxICON_ERROR, wxICON_WARNING, wxICON_QUESTION, wxICON_INFORMATION - long GetEffectiveIcon() const + // wxICON_ERROR, wxICON_WARNING, wxICON_QUESTION, wxICON_INFORMATION, + // wxICON_AUTH_NEEDED + virtual long GetEffectiveIcon() const { if ( m_dialogStyle & wxICON_NONE ) return wxICON_NONE; diff --git a/include/wx/msw/msgdlg.h b/include/wx/msw/msgdlg.h index 30573d8eac..6b2f11004b 100644 --- a/include/wx/msw/msgdlg.h +++ b/include/wx/msw/msgdlg.h @@ -27,6 +27,8 @@ public: virtual int ShowModal(); + virtual long GetEffectiveIcon() const; + // implementation-specific // return the font used for the text in the message box diff --git a/interface/wx/msgdlg.h b/interface/wx/msgdlg.h index 1dde94ee77..378fa4624e 100644 --- a/interface/wx/msgdlg.h +++ b/interface/wx/msgdlg.h @@ -68,6 +68,15 @@ const char wxMessageBoxCaptionStr[] = "Message"; Displays an information symbol. This icon is used by default if @c wxYES_NO is not given so it is usually unnecessary to specify it explicitly. + @style{wxICON_AUTH_NEEDED} + Displays an authentication needed symbol. This style is only supported + for message dialogs under wxMSW when a task dialog is used to implement + them (i.e. when running under Windows Vista or later). In other cases + the default icon selection logic will be used. Note this can be + combined with other styles to provide a fallback. For instance, using + wxICON_AUTH_NEEDED | wxICON_QUESTION will show a shield symbol on + Windows Vista or above and a question symbol on other platforms. + @since 2.9.5 @style{wxSTAY_ON_TOP} Makes the message box stay on top of all other windows and not only just its parent (currently implemented only under MSW and GTK). diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 7cc3287cef..679838a4dd 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -3005,7 +3005,8 @@ bool TestMessageBoxDialog::Create() "&Information icon", "&Question icon", "&Warning icon", - "&Error icon" + "&Error icon", + "A&uth needed icon" }; wxCOMPILE_TIME_ASSERT( WXSIZEOF(icons) == MsgDlgIcon_Max, IconMismatch ); @@ -3106,6 +3107,10 @@ long TestMessageBoxDialog::GetStyle() case MsgDlgIcon_Error: style |= wxICON_ERROR; break; + + case MsgDlgIcon_AuthNeeded: + style |= wxICON_AUTH_NEEDED; + break; } if ( m_chkCentre->IsChecked() ) diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index 54a2fe3138..f92379f33f 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -249,6 +249,7 @@ private: MsgDlgIcon_Question, MsgDlgIcon_Warning, MsgDlgIcon_Error, + MsgDlgIcon_AuthNeeded, MsgDlgIcon_Max }; diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index edff0a0f5a..e9b25735a9 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -629,6 +629,18 @@ int wxMessageDialog::ShowModal() return ShowMessageBox(); } +long wxMessageDialog::GetEffectiveIcon() const +{ + // only use the auth needed icon if available, otherwise fallback to the default logic + if ( (m_dialogStyle & wxICON_AUTH_NEEDED) && + wxMSWMessageDialog::HasNativeTaskDialog() ) + { + return wxICON_AUTH_NEEDED; + } + + return wxMessageDialogBase::GetEffectiveIcon(); +} + void wxMessageDialog::DoCentre(int dir) { #ifdef wxHAS_MSW_TASKDIALOG @@ -738,6 +750,10 @@ void wxMSWTaskDialogConfig::MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc) case wxICON_INFORMATION: tdc.pszMainIcon = TD_INFORMATION_ICON; break; + + case wxICON_AUTH_NEEDED: + tdc.pszMainIcon = TD_SHIELD_ICON; + break; } // custom label button array that can hold all buttons in use