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
This commit is contained in:
Vadim Zeitlin
2013-04-29 12:54:08 +00:00
parent add6e9193d
commit 67315c8bf9
8 changed files with 40 additions and 4 deletions

View File

@@ -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:

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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).

View File

@@ -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() )

View File

@@ -249,6 +249,7 @@ private:
MsgDlgIcon_Question,
MsgDlgIcon_Warning,
MsgDlgIcon_Error,
MsgDlgIcon_AuthNeeded,
MsgDlgIcon_Max
};

View File

@@ -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