1/* Implementation of class NSAppearance 2 Copyright (C) 2020 Free Software Foundation, Inc. 3 4 By: Gregory John Casamento 5 Date: Wed Jan 15 07:03:39 EST 2020 6 7 This file is part of the GNUstep Library. 8 9 This library is free software; you can redistribute it and/or 10 modify it under the terms of the GNU Lesser General Public 11 License as published by the Free Software Foundation; either 12 version 2 of the License, or (at your option) any later version. 13 14 This library is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public 20 License along with this library; if not, write to the Free 21 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 Boston, MA 02110 USA. 23*/ 24 25#import <AppKit/NSAppearance.h> 26#import <Foundation/NSArchiver.h> 27 28NSAppearance *__currentAppearance = nil; 29 30@implementation NSAppearance 31 32// Creating an appearance... 33+ (instancetype) appearanceNamed: (NSString *)name 34{ 35 return [[NSAppearance alloc] initWithAppearanceNamed: name bundle: nil]; 36} 37 38- (instancetype) initWithAppearanceNamed: (NSString *)name bundle: (NSBundle *)bundle 39{ 40 self = [super init]; 41 if (self) 42 { 43 ASSIGNCOPY(_name, name); 44 _allowsVibrancy = NO; 45 } 46 return self; 47} 48 49- (instancetype) initWithCoder: (NSCoder *)coder 50{ 51 if ([coder allowsKeyedCoding]) 52 { 53 } 54 else 55 { 56 ASSIGN(_name, [coder decodeObject]); 57 [coder decodeValueOfObjCType: @encode(BOOL) at: &_allowsVibrancy]; 58 } 59 return self; 60} 61 62- (void) encodeWithCoder: (NSCoder *)coder 63{ 64 if ([coder allowsKeyedCoding]) 65 { 66 } 67 else 68 { 69 [coder encodeObject: _name]; 70 [coder encodeValueOfObjCType: @encode(BOOL) at: &_allowsVibrancy]; 71 } 72} 73 74- (void) dealloc 75{ 76 RELEASE(_name); 77 [super dealloc]; 78} 79 80// Getting the appearance name 81- (NSString *) name 82{ 83 return _name; 84} 85 86// Determining the most appropriate appearance 87- (NSAppearanceName) bestMatchFromAppearancesWithNames: (NSArray *)appearances 88{ 89 return nil; 90} 91 92// Getting and setting the appearance 93+ (void) setCurrentAppearance: (NSAppearance *)appearance 94{ 95 ASSIGN(__currentAppearance, appearance); 96} 97 98+ (NSAppearance *) currentAppearance 99{ 100 return __currentAppearance; 101} 102 103// Managing vibrancy 104- (BOOL) allowsVibrancy 105{ 106 return _allowsVibrancy; 107} 108 109@end 110 111