Mac: Address deprecation warnings with the latest Xcode and macOS.

git-svn-id: https://svn.eduke32.com/eduke32@6109 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-03-27 17:13:07 +00:00
parent cf3a4550b0
commit cb2d1f4bce
3 changed files with 59 additions and 23 deletions

View file

@ -3,6 +3,22 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#ifndef MAC_OS_X_VERSION_10_5
# define NSImageScaleNone NSScaleNone
#endif
#ifndef MAC_OS_X_VERSION_10_12
# define NSEventModifierFlagOption NSAlternateKeyMask
# define NSEventModifierFlagCommand NSCommandKeyMask
# define NSEventMaskAny NSAnyEventMask
# define NSWindowStyleMaskTitled NSTitledWindowMask
# define NSWindowStyleMaskClosable NSClosableWindowMask
# define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
# define NSWindowStyleMaskResizable NSResizableWindowMask
# define NSAlertStyleInformational NSInformationalAlertStyle
# define NSControlSizeSmall NSSmallControlSize
#endif
#ifndef MAC_OS_VERSION_10_3
# define MAC_OS_VERSION_10_3 1030
#endif
@ -15,7 +31,7 @@ int osx_msgbox(const char *name, const char *msg)
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle: @"OK"];
[alert setInformativeText: mmsg];
[alert setAlertStyle: NSInformationalAlertStyle];
[alert setAlertStyle: NSAlertStyleInformational];
[alert runModal];
@ -43,7 +59,7 @@ int osx_ynbox(const char *name, const char *msg)
[alert addButtonWithTitle:@"Yes"];
[alert addButtonWithTitle:@"No"];
[alert setInformativeText: mmsg];
[alert setAlertStyle: NSInformationalAlertStyle];
[alert setAlertStyle: NSAlertStyleInformational];
r = ([alert runModal] == NSAlertFirstButtonReturn);

View file

@ -6,6 +6,22 @@
#include "build.h"
#include "editor.h"
#ifndef MAC_OS_X_VERSION_10_5
# define NSImageScaleNone NSScaleNone
#endif
#ifndef MAC_OS_X_VERSION_10_12
# define NSEventModifierFlagOption NSAlternateKeyMask
# define NSEventModifierFlagCommand NSCommandKeyMask
# define NSEventMaskAny NSAnyEventMask
# define NSWindowStyleMaskTitled NSTitledWindowMask
# define NSWindowStyleMaskClosable NSClosableWindowMask
# define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
# define NSWindowStyleMaskResizable NSResizableWindowMask
# define NSAlertStyleInformational NSInformationalAlertStyle
# define NSControlSizeSmall NSSmallControlSize
#endif
static NSRect NSRectChangeXY(NSRect const rect, CGFloat const x, CGFloat const y)
{
return NSMakeRect(x, y, rect.size.width, rect.size.height);
@ -32,11 +48,7 @@ static void setFontToSmall(id control)
static void setControlToSmall(id control)
{
#ifdef MAC_OS_X_VERSION_10_12
[control setControlSize:NSControlSizeSmall];
#else
[control setControlSize:NSSmallControlSize];
#endif
}
static NSTextField * makeLabel(NSString * labelText)
@ -134,7 +146,7 @@ static void CreateApplicationMenus(void)
[rootMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
menuItem = (NSMenuItem *)[rootMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
[menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEventModifierFlagCommand)];
[rootMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
@ -200,7 +212,7 @@ static struct {
- (StartupWindow *)init
{
NSUInteger const style = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask;
NSUInteger const style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
NSRect const windowFrame = NSMakeRect(0, 0, 480, 280);
self = [super initWithContentRect:windowFrame styleMask:style backing:NSBackingStoreBuffered defer:NO];
@ -219,11 +231,7 @@ static struct {
// image on the left
NSRect const imageFrame = NSMakeRect(0, 0, 100, 280);
NSImageView * imageView = [[NSImageView alloc] initWithFrame:imageFrame];
#ifdef MAC_OS_X_VERSION_10_5
[imageView setImageScaling:NSImageScaleNone];
#else
[imageView setImageScaling:NSScaleNone];
#endif
[imageView setImage:[NSImage imageNamed:@"build"]];
[[self contentView] addSubview:imageView];
[imageView setAutoresizingMask:NSViewMaxXMargin | NSViewHeightSizable];
@ -640,7 +648,7 @@ int startwin_idle(void *v)
NSEvent *event;
do
{
event = [nsapp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate date] inMode:NSDefaultRunLoopMode dequeue:YES];
event = [nsapp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate date] inMode:NSDefaultRunLoopMode dequeue:YES];
[nsapp sendEvent:event];
}
while (event != nil);
@ -669,7 +677,7 @@ int startwin_run(void)
do
{
NSEvent *event = [nsapp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
NSEvent *event = [nsapp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
[nsapp sendEvent:event];
[nsapp updateWindows];
}

View file

@ -13,6 +13,22 @@
#import "GrpFile.game.h"
#import "GameListSource.game.h"
#ifndef MAC_OS_X_VERSION_10_5
# define NSImageScaleNone NSScaleNone
#endif
#ifndef MAC_OS_X_VERSION_10_12
# define NSEventModifierFlagOption NSAlternateKeyMask
# define NSEventModifierFlagCommand NSCommandKeyMask
# define NSEventMaskAny NSAnyEventMask
# define NSWindowStyleMaskTitled NSTitledWindowMask
# define NSWindowStyleMaskClosable NSClosableWindowMask
# define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
# define NSWindowStyleMaskResizable NSResizableWindowMask
# define NSAlertStyleInformational NSInformationalAlertStyle
# define NSControlSizeSmall NSSmallControlSize
#endif
static NSRect NSRectChangeXY(NSRect const rect, CGFloat const x, CGFloat const y)
{
return NSMakeRect(x, y, rect.size.width, rect.size.height);
@ -42,7 +58,7 @@ static void setControlToSmall(id control)
#ifdef MAC_OS_X_VERSION_10_12
[control setControlSize:NSControlSizeSmall];
#else
[control setControlSize:NSSmallControlSize];
[control setControlSize:NSControlSizeSmall];
#endif
}
@ -141,7 +157,7 @@ static void CreateApplicationMenus(void)
[rootMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
menuItem = (NSMenuItem *)[rootMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
[menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEventModifierFlagCommand)];
[rootMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
@ -207,7 +223,7 @@ static struct {
- (StartupWindow *)init
{
NSUInteger const style = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask;
NSUInteger const style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
NSRect const windowFrame = NSMakeRect(0, 0, 480, 280);
self = [super initWithContentRect:windowFrame styleMask:style backing:NSBackingStoreBuffered defer:NO];
@ -226,11 +242,7 @@ static struct {
// image on the left
NSRect const imageFrame = NSMakeRect(0, 0, 100, 280);
NSImageView * imageView = [[NSImageView alloc] initWithFrame:imageFrame];
#ifdef MAC_OS_X_VERSION_10_5
[imageView setImageScaling:NSImageScaleNone];
#else
[imageView setImageScaling:NSScaleNone];
#endif
[imageView setImage:[NSImage imageNamed:@"game"]];
[[self contentView] addSubview:imageView];
[imageView setAutoresizingMask:NSViewMaxXMargin | NSViewHeightSizable];
@ -647,7 +659,7 @@ int startwin_idle(void *v)
NSEvent *event;
do
{
event = [nsapp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate date] inMode:NSDefaultRunLoopMode dequeue:YES];
event = [nsapp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate date] inMode:NSDefaultRunLoopMode dequeue:YES];
[nsapp sendEvent:event];
}
while (event != nil);
@ -675,7 +687,7 @@ int startwin_run(void)
do
{
NSEvent *event = [nsapp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
NSEvent *event = [nsapp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
[nsapp sendEvent:event];
[nsapp updateWindows];
}