Only use NSCriticalAlertStyle for serious questions

Don't use NSCriticalAlertStyle for wxICON_WARNING unconditionally, this
was a violation of the OS X guidelines. According to the hig HIG,
NSCriticalAlertStyle (aka caution icon) is only appropriate in rare
cases and only if the user is performing a task that might result in the
inadvertent and unexpected destruction of data.

It therefore doesn't make sense to use it for information warnings, but
only for _questions_, and so NSCriticalAlertStyle is only used if a
combination of wxICON_WARNING with either wxYES_NO or wxCANCEL is used.
This commit is contained in:
Václav Slavík
2015-03-07 16:15:21 +01:00
parent 94fc40b7ea
commit 6b8b3ee379
2 changed files with 19 additions and 11 deletions

View File

@@ -53,7 +53,10 @@ const char wxMessageBoxCaptionStr[] = "Message";
@style{wxICON_ERROR}
Displays an error icon in the dialog.
@style{wxICON_WARNING}
Displays a warning icon in the dialog.
Displays a warning icon in the dialog. This style should be used for
informative warnings or, in combination with @c wxYES_NO or @c wxCANCEL,
for questions that have potentially serious consequences (caution
icon is used on OS X in this case).
@style{wxICON_QUESTION}
Displays a question mark symbol. This icon is automatically used
with @c wxYES_NO so it's usually unnecessary to specify it explicitly.

View File

@@ -31,16 +31,21 @@ namespace
{
NSAlertStyle GetAlertStyleFromWXStyle( long style )
{
NSAlertStyle alertType = NSWarningAlertStyle;
if (style & wxICON_EXCLAMATION)
alertType = NSCriticalAlertStyle;
else if (style & wxICON_HAND)
alertType = NSWarningAlertStyle;
else if (style & wxICON_INFORMATION)
alertType = NSInformationalAlertStyle;
else if (style & wxICON_QUESTION)
alertType = NSInformationalAlertStyle;
return alertType;
if (style & wxICON_WARNING)
{
// NSCriticalAlertStyle should only be used for questions where
// caution is needed per the OS X HIG. wxICON_WARNING alone doesn't
// warrant it, but a question with a warning (rather than question)
// icon is something serious.
if (style & (wxYES_NO | wxCANCEL))
return NSCriticalAlertStyle;
else
return NSWarningAlertStyle;
}
else if (style & wxICON_ERROR)
return NSWarningAlertStyle;
else
return NSInformationalAlertStyle;
}
}