From e75e26da92424528e190a2111acfcc49c657e894 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Mon, 29 Mar 2021 19:14:07 -0700 Subject: Replace Dialog.hpp with portable-file-dialogs, more work on projects --- core/src/Utils/Dialog/Dialog_macos.mm | 113 ---------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 core/src/Utils/Dialog/Dialog_macos.mm (limited to 'core/src/Utils/Dialog/Dialog_macos.mm') diff --git a/core/src/Utils/Dialog/Dialog_macos.mm b/core/src/Utils/Dialog/Dialog_macos.mm deleted file mode 100644 index c0164a0..0000000 --- a/core/src/Utils/Dialog/Dialog_macos.mm +++ /dev/null @@ -1,113 +0,0 @@ -// Adapted from https://github.com/aaronmjacobs/Boxer/blob/master/src/boxer_osx.mm -#include "Dialog.hpp" - -#import - -namespace Dialog { -namespace { - - NSString* const kOkStr = @"OK"; - NSString* const kCancelStr = @"Cancel"; - NSString* const kYesStr = @"Yes"; - NSString* const kNoStr = @"No"; - NSString* const kQuitStr = @"Quit"; - - NSAlertStyle GetAlertStyle(Style style) { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 - switch (style) { - case Style::Info: - return NSAlertStyleInformational; - case Style::Warning: - return NSAlertStyleWarning; - case Style::Error: - return NSAlertStyleCritical; - case Style::Question: - return NSAlertStyleWarning; - default: - return NSAlertStyleInformational; - } -#else - switch (style) { - case Style::Info: - return NSInformationalAlertStyle; - case Style::Warning: - return NSWarningAlertStyle; - case Style::Error: - return NSCriticalAlertStyle; - case Style::Question: - return NSWarningAlertStyle; - default: - return NSInformationalAlertStyle; - } -#endif - } - - void SetButtons(NSAlert* alert, Buttons buttons) { - switch (buttons) { - case Buttons::OK: - [alert addButtonWithTitle:kOkStr]; - break; - case Buttons::OKCancel: - [alert addButtonWithTitle:kOkStr]; - [alert addButtonWithTitle:kCancelStr]; - break; - case Buttons::YesNo: - [alert addButtonWithTitle:kYesStr]; - [alert addButtonWithTitle:kNoStr]; - break; - case Buttons::Quit: - [alert addButtonWithTitle:kQuitStr]; - break; - default: - [alert addButtonWithTitle:kOkStr]; - } - } - - Selection GetSelection(int index, Buttons buttons) { - switch (buttons) { - case Buttons::OK: - return index == NSAlertFirstButtonReturn ? Selection::OK : Selection::None; - case Buttons::OKCancel: - if (index == NSAlertFirstButtonReturn) { - return Selection::OK; - } else if (index == NSAlertSecondButtonReturn) { - return Selection::Cancel; - } else { - return Selection::None; - } - case Buttons::YesNo: - if (index == NSAlertFirstButtonReturn) { - return Selection::Yes; - } else if (index == NSAlertSecondButtonReturn) { - return Selection::No; - } else { - return Selection::None; - } - case Buttons::Quit: - return index == NSAlertFirstButtonReturn ? Selection::Quit : Selection::None; - default: - return Selection::None; - } - } - -} // namespace - -Selection show(const char* message, const char* title, Style style, Buttons buttons) { - NSAlert* alert = [[NSAlert alloc] init]; - - [alert setMessageText:[NSString stringWithCString:title encoding:[NSString defaultCStringEncoding]]]; - [alert setInformativeText:[NSString stringWithCString:message encoding:[NSString defaultCStringEncoding]]]; - - [alert setAlertStyle:GetAlertStyle(style)]; - SetButtons(alert, buttons); - - // Force the alert to appear on top of any other windows - [[alert window] setLevel:NSModalPanelWindowLevel]; - - Selection selection = GetSelection([alert runModal], buttons); - [alert release]; - - return selection; -} - -} // namespace Dialog -- cgit v1.2.3-70-g09d2