From 6b8b3ee37906b5f49382741b4e1b44f48a9794c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= Date: Sat, 7 Mar 2015 16:15:21 +0100 Subject: [PATCH] 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. --- interface/wx/msgdlg.h | 5 ++++- src/osx/cocoa/msgdlg.mm | 25 +++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/interface/wx/msgdlg.h b/interface/wx/msgdlg.h index 3eee8e4ad5..66cf4c1701 100644 --- a/interface/wx/msgdlg.h +++ b/interface/wx/msgdlg.h @@ -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. diff --git a/src/osx/cocoa/msgdlg.mm b/src/osx/cocoa/msgdlg.mm index fb52f0a7a0..1e5f8fe84a 100644 --- a/src/osx/cocoa/msgdlg.mm +++ b/src/osx/cocoa/msgdlg.mm @@ -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; } }