2001-12-17 16:51:51 +00:00
|
|
|
/** <title>NSScreen</title>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2000-04-25 20:26:51 +00:00
|
|
|
Copyright (C) 1996, 2000 Free Software Foundation, Inc.
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
1996-05-30 20:03:15 +00:00
|
|
|
Date: 1996
|
2000-04-25 20:26:51 +00:00
|
|
|
Major modifications and updates
|
|
|
|
Author: Gregory John Casamento <borgheron@yahoo.com>
|
|
|
|
Date: 2000
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1996-05-30 20:03:15 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 21:16:17 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
2010-05-24 10:48:14 +00:00
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
#import <Foundation/NSDebug.h>
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSEnumerator.h>
|
|
|
|
#import <Foundation/NSException.h>
|
|
|
|
#import <Foundation/NSGeometry.h>
|
|
|
|
#import <Foundation/NSNotification.h>
|
|
|
|
#import <Foundation/NSValue.h>
|
2011-04-19 08:42:59 +00:00
|
|
|
#import <Foundation/NSUserDefaults.h>
|
2010-05-24 10:48:14 +00:00
|
|
|
#import "AppKit/AppKitExceptions.h"
|
|
|
|
#import "AppKit/NSApplication.h"
|
|
|
|
#import "AppKit/NSInterfaceStyle.h"
|
|
|
|
#import "AppKit/NSMenu.h"
|
|
|
|
#import "AppKit/NSMenuView.h"
|
|
|
|
#import "AppKit/NSScreen.h"
|
|
|
|
#import "AppKit/NSWindow.h"
|
|
|
|
#import "GNUstepGUI/GSDisplayServer.h"
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-10-07 22:47:00 +00:00
|
|
|
@interface NSScreen (Private)
|
|
|
|
- (id) _initWithScreenNumber: (int)screen;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSScreen
|
2000-05-04 18:28:00 +00:00
|
|
|
|
|
|
|
/*
|
2001-10-07 22:47:00 +00:00
|
|
|
* Class methods
|
2000-05-04 18:28:00 +00:00
|
|
|
*/
|
2001-10-07 22:47:00 +00:00
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (self == [NSScreen class])
|
|
|
|
{
|
|
|
|
[self setVersion: 1];
|
2007-08-08 08:04:11 +00:00
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
addObserver: self
|
|
|
|
selector: @selector(_resetScreens:)
|
|
|
|
name: NSApplicationDidChangeScreenParametersNotification
|
|
|
|
object: nil];
|
|
|
|
}
|
2001-10-07 22:47:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static NSMutableArray *screenArray = nil;
|
|
|
|
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* Resets the cached list of screens.
|
|
|
|
*/
|
2007-08-08 08:04:11 +00:00
|
|
|
+ (void) _resetScreens: (NSNotification*)notification
|
|
|
|
{
|
|
|
|
[self resetScreens];
|
|
|
|
}
|
|
|
|
|
2001-10-07 22:47:00 +00:00
|
|
|
+ (void) resetScreens
|
|
|
|
{
|
2009-01-30 16:27:36 +00:00
|
|
|
DESTROY(screenArray);
|
2001-10-07 22:47:00 +00:00
|
|
|
}
|
|
|
|
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* Returns an NSArray containing NSScreen instances representing all of the
|
|
|
|
* screen devices attached to the computer.
|
|
|
|
*/
|
2001-10-07 22:47:00 +00:00
|
|
|
+ (NSArray*) screens
|
1999-10-29 18:43:48 +00:00
|
|
|
{
|
2001-10-07 22:47:00 +00:00
|
|
|
int count = 0, index = 0;
|
2002-03-28 03:53:18 +00:00
|
|
|
NSArray *screens;
|
|
|
|
GSDisplayServer *srv;
|
2001-10-07 22:47:00 +00:00
|
|
|
|
|
|
|
if (screenArray != nil)
|
|
|
|
return screenArray;
|
2000-04-25 20:26:51 +00:00
|
|
|
|
2002-03-28 03:53:18 +00:00
|
|
|
srv = GSCurrentServer();
|
|
|
|
screens = [srv screenList];
|
|
|
|
count = [screens count];
|
2001-10-07 22:47:00 +00:00
|
|
|
if (count == 0)
|
2000-04-25 20:26:51 +00:00
|
|
|
{
|
2001-10-07 22:47:00 +00:00
|
|
|
// something is wrong. This shouldn't happen.
|
|
|
|
[NSException raise: NSWindowServerCommunicationException
|
2007-08-08 08:04:11 +00:00
|
|
|
format: @"Unable to retrieve list of screens from window server."];
|
2001-10-07 22:47:00 +00:00
|
|
|
return nil;
|
2000-04-25 20:26:51 +00:00
|
|
|
}
|
1999-10-29 18:43:48 +00:00
|
|
|
|
2001-10-07 22:47:00 +00:00
|
|
|
screenArray = [NSMutableArray new];
|
|
|
|
|
|
|
|
// Iterate over the list
|
|
|
|
for (index = 0; index < count; index++)
|
|
|
|
{
|
|
|
|
NSScreen *screen = nil;
|
|
|
|
|
2002-03-28 03:53:18 +00:00
|
|
|
screen = [[NSScreen alloc] _initWithScreenNumber:
|
2007-08-08 08:04:11 +00:00
|
|
|
[[screens objectAtIndex: index] intValue]];
|
|
|
|
[screenArray addObject: screen];
|
|
|
|
RELEASE(screen);
|
2001-10-07 22:47:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return [NSArray arrayWithArray: screenArray];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Creating NSScreen Instances
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* Gets information about the main screen.
|
|
|
|
*/
|
2001-10-07 22:47:00 +00:00
|
|
|
+ (NSScreen*) mainScreen
|
|
|
|
{
|
2007-08-08 08:04:11 +00:00
|
|
|
NSWindow *keyWindow;
|
|
|
|
|
|
|
|
keyWindow = [NSApp keyWindow];
|
|
|
|
if (keyWindow != nil)
|
|
|
|
{
|
|
|
|
return [keyWindow screen];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSArray *screenArray = [self screens];
|
|
|
|
|
|
|
|
if (screenArray != nil)
|
|
|
|
{
|
|
|
|
return [screenArray objectAtIndex: 0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
}
|
2001-10-07 22:47:00 +00:00
|
|
|
}
|
|
|
|
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* Gets information about the screen with the highest depth (i.e. bits per pixel).
|
|
|
|
*/
|
2001-10-07 22:47:00 +00:00
|
|
|
+ (NSScreen*) deepestScreen
|
|
|
|
{
|
|
|
|
NSArray *screenArray = [self screens];
|
|
|
|
NSEnumerator *screenEnumerator = nil;
|
|
|
|
NSScreen *deepestScreen = nil, *screen = nil;
|
|
|
|
int maxBits = 0;
|
|
|
|
|
|
|
|
// Iterate over the list of screens and find the
|
|
|
|
// one with the most depth.
|
|
|
|
screenEnumerator = [screenArray objectEnumerator];
|
|
|
|
while ((screen = [screenEnumerator nextObject]) != nil)
|
|
|
|
{
|
|
|
|
int bits = 0;
|
|
|
|
|
|
|
|
bits = [screen depth];
|
|
|
|
|
|
|
|
if (bits > maxBits)
|
2007-08-08 08:04:11 +00:00
|
|
|
{
|
|
|
|
maxBits = bits;
|
|
|
|
deepestScreen = screen;
|
|
|
|
}
|
2001-10-07 22:47:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return deepestScreen;
|
1999-10-29 18:43:48 +00:00
|
|
|
}
|
1998-11-25 17:16:48 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2000-01-07 16:46:35 +00:00
|
|
|
/*
|
2000-04-25 20:26:51 +00:00
|
|
|
* Instance methods
|
2000-01-07 16:46:35 +00:00
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* NSScreen does not respond to the init method.
|
|
|
|
*/
|
2000-04-25 20:26:51 +00:00
|
|
|
- (id) init
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-04-25 20:26:51 +00:00
|
|
|
[self doesNotRecognizeSelector: _cmd];
|
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* Get all of the infomation for a given screen.
|
|
|
|
*/
|
2000-04-25 20:26:51 +00:00
|
|
|
- (id) _initWithScreenNumber: (int)screen
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2002-03-28 03:53:18 +00:00
|
|
|
GSDisplayServer *srv;
|
|
|
|
|
2007-08-08 08:04:11 +00:00
|
|
|
if (!(self = [super init]))
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
1999-10-29 18:43:48 +00:00
|
|
|
|
2000-04-25 20:26:51 +00:00
|
|
|
// Check for problems
|
|
|
|
if (screen < 0)
|
|
|
|
{
|
2001-10-07 22:47:00 +00:00
|
|
|
NSLog(@"Internal error: Invalid screen number %d\n", screen);
|
2000-04-25 20:26:51 +00:00
|
|
|
RELEASE(self);
|
|
|
|
return nil;
|
|
|
|
}
|
1999-10-29 18:43:48 +00:00
|
|
|
|
2007-08-08 08:04:11 +00:00
|
|
|
srv = GSCurrentServer();
|
2002-03-28 03:53:18 +00:00
|
|
|
if (srv == nil)
|
1999-12-28 19:20:45 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Internal error: No current context\n");
|
2000-04-25 20:26:51 +00:00
|
|
|
RELEASE(self);
|
1999-12-28 19:20:45 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2000-04-25 20:26:51 +00:00
|
|
|
// Fill in all of the i-vars with appropriate values.
|
|
|
|
_screenNumber = screen;
|
2002-03-28 03:53:18 +00:00
|
|
|
_frame = [srv boundsForScreen: _screenNumber];
|
|
|
|
_depth = [srv windowDepthForScreen: _screenNumber];
|
2000-05-04 18:28:00 +00:00
|
|
|
_supportedWindowDepths = NULL;
|
1999-04-15 04:47:54 +00:00
|
|
|
|
2000-04-25 20:26:51 +00:00
|
|
|
return self;
|
1996-06-21 15:27:13 +00:00
|
|
|
}
|
|
|
|
|
2000-04-25 21:20:52 +00:00
|
|
|
- (BOOL) isEqual: (id)anObject
|
|
|
|
{
|
|
|
|
if (anObject == self)
|
|
|
|
return YES;
|
2011-02-20 18:24:44 +00:00
|
|
|
if ([anObject isKindOfClass: [self class]] == NO)
|
2000-04-25 21:20:52 +00:00
|
|
|
return NO;
|
|
|
|
if (_screenNumber == ((NSScreen *)anObject)->_screenNumber)
|
|
|
|
return YES;
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* Returns the depth of the screen in bits.
|
2000-01-07 16:46:35 +00:00
|
|
|
*/
|
|
|
|
- (NSWindowDepth) depth
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-04-25 20:26:51 +00:00
|
|
|
return _depth;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* The full frame of the screen.
|
|
|
|
*/
|
2000-01-07 16:46:35 +00:00
|
|
|
- (NSRect) frame
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-04-25 20:26:51 +00:00
|
|
|
return _frame;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2012-08-17 13:16:12 +00:00
|
|
|
- (NSString*) description
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%@ number: %ld frame: %@",
|
|
|
|
[super description], (long)_screenNumber,
|
|
|
|
NSStringFromRect(_frame)];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* <p>
|
|
|
|
* This method generates a dictionary containing information
|
|
|
|
* about the screen device. The resulting dictionary will have the following
|
|
|
|
* entires: NSScreenNumber, NSDeviceSize, NSDeviceResolution, NSDeviceBitsPerSample,
|
|
|
|
* NSDeviceColorSpaceName.
|
|
|
|
* </p>
|
|
|
|
*/
|
2000-01-07 16:46:35 +00:00
|
|
|
- (NSDictionary*) deviceDescription
|
|
|
|
{
|
2009-01-30 16:27:36 +00:00
|
|
|
if (_reserved == 0)
|
2007-08-08 08:04:11 +00:00
|
|
|
{
|
2009-01-30 16:27:36 +00:00
|
|
|
NSMutableDictionary *devDesc;
|
|
|
|
int bps = 0;
|
|
|
|
NSSize screenResolution;
|
|
|
|
NSString *colorSpaceName = nil;
|
2011-05-04 01:33:21 +00:00
|
|
|
CGFloat scaleFactor;
|
2009-01-30 16:27:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This method generates a dictionary from the
|
|
|
|
* information we have gathered from the screen.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Set the screen number in the current object.
|
|
|
|
devDesc = [[NSMutableDictionary alloc] initWithCapacity: 8];
|
|
|
|
[devDesc setObject: [NSNumber numberWithInt: _screenNumber]
|
|
|
|
forKey: @"NSScreenNumber"];
|
|
|
|
|
|
|
|
// This is assumed since we are in NSScreen.
|
|
|
|
[devDesc setObject: @"YES" forKey: NSDeviceIsScreen];
|
|
|
|
|
|
|
|
// Add the NSDeviceSize dictionary item
|
|
|
|
[devDesc setObject: [NSValue valueWithSize: _frame.size]
|
|
|
|
forKey: NSDeviceSize];
|
|
|
|
|
|
|
|
// Add the NSDeviceResolution dictionary item
|
2011-05-04 01:33:21 +00:00
|
|
|
scaleFactor = [self userSpaceScaleFactor];
|
|
|
|
screenResolution = NSMakeSize(72.0 * scaleFactor, 72.0 * scaleFactor);
|
|
|
|
[devDesc setObject: [NSValue valueWithSize: screenResolution]
|
|
|
|
forKey: NSDeviceResolution];
|
2009-01-30 16:27:36 +00:00
|
|
|
|
|
|
|
// Add the bits per sample entry
|
|
|
|
bps = NSBitsPerSampleFromDepth(_depth);
|
|
|
|
[devDesc setObject: [NSNumber numberWithInt: bps]
|
|
|
|
forKey: NSDeviceBitsPerSample];
|
|
|
|
|
|
|
|
// Add the color space entry.
|
|
|
|
colorSpaceName = NSColorSpaceFromDepth(_depth);
|
|
|
|
[devDesc setObject: colorSpaceName
|
|
|
|
forKey: NSDeviceColorSpaceName];
|
|
|
|
|
|
|
|
_reserved = (void*)[devDesc copy];
|
|
|
|
RELEASE(devDesc);
|
2007-08-08 08:04:11 +00:00
|
|
|
}
|
2009-01-30 16:27:36 +00:00
|
|
|
return (NSDictionary*)_reserved;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-09-14 21:40:29 +00:00
|
|
|
// Mac OS X methods
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* Returns the window depths this screen will support.
|
|
|
|
*/
|
1999-09-14 21:40:29 +00:00
|
|
|
- (const NSWindowDepth*) supportedWindowDepths
|
|
|
|
{
|
2000-05-04 18:28:00 +00:00
|
|
|
// If the variable isn't initialized, get the info and
|
|
|
|
// store it for the future.
|
|
|
|
if (_supportedWindowDepths == NULL)
|
|
|
|
{
|
2002-03-28 03:53:18 +00:00
|
|
|
_supportedWindowDepths =
|
|
|
|
(NSWindowDepth*)[GSCurrentServer()
|
|
|
|
availableDepthsForScreen: _screenNumber];
|
2000-05-04 18:28:00 +00:00
|
|
|
|
|
|
|
// Check the results
|
|
|
|
if (_supportedWindowDepths == NULL)
|
2007-08-08 08:04:11 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Internal error: no depth list returned from window server.");
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-05-04 18:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return _supportedWindowDepths;
|
1999-09-14 21:40:29 +00:00
|
|
|
}
|
|
|
|
|
2004-01-02 04:19:32 +00:00
|
|
|
/**
|
|
|
|
* Returns the NSRect representing the visible area of the screen.
|
|
|
|
*/
|
2000-01-07 16:46:35 +00:00
|
|
|
- (NSRect) visibleFrame
|
1999-09-14 21:40:29 +00:00
|
|
|
{
|
2000-04-25 20:26:51 +00:00
|
|
|
NSRect visFrame = _frame;
|
2007-08-08 08:04:11 +00:00
|
|
|
float menuHeight;
|
2000-01-07 16:46:35 +00:00
|
|
|
|
2006-03-05 13:21:33 +00:00
|
|
|
switch (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil))
|
1999-09-14 21:40:29 +00:00
|
|
|
{
|
2000-01-07 16:46:35 +00:00
|
|
|
case NSMacintoshInterfaceStyle:
|
2007-08-08 08:04:11 +00:00
|
|
|
if ([NSApp mainMenu] == nil)
|
|
|
|
{
|
|
|
|
// No menu yet ... assume a standard height
|
|
|
|
menuHeight = [NSMenuView menuBarHeight];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menuHeight = [[[NSApp mainMenu] window] frame].size.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
visFrame.size.height -= menuHeight;
|
|
|
|
break;
|
2006-03-05 13:21:33 +00:00
|
|
|
|
2002-10-29 02:48:16 +00:00
|
|
|
case GSWindowMakerInterfaceStyle:
|
2000-01-07 16:46:35 +00:00
|
|
|
case NSNextStepInterfaceStyle:
|
2007-08-08 08:04:11 +00:00
|
|
|
/* FIXME: Menu width will vary from app to app and there is no
|
|
|
|
* fixed position for the menu ... should we be making room for
|
|
|
|
* a menu top left, or something else?
|
|
|
|
*/
|
2006-03-05 13:21:33 +00:00
|
|
|
#if 0
|
2007-08-08 08:04:11 +00:00
|
|
|
if ([NSApp mainMenu] != nil)
|
|
|
|
{
|
|
|
|
float menuWidth = [[[NSApp mainMenu] window] frame].size.width;
|
|
|
|
|
|
|
|
visFrame.size.width -= menuWidth;
|
|
|
|
visFrame.origin.x += menuWidth;
|
|
|
|
}
|
2006-03-05 13:21:33 +00:00
|
|
|
#endif
|
2007-08-08 08:04:11 +00:00
|
|
|
break;
|
2002-10-29 02:48:16 +00:00
|
|
|
|
2000-01-07 16:46:35 +00:00
|
|
|
default:
|
2007-08-08 08:04:11 +00:00
|
|
|
break;
|
2000-04-25 20:26:51 +00:00
|
|
|
}
|
2006-03-05 13:21:33 +00:00
|
|
|
return visFrame;
|
2000-04-25 20:26:51 +00:00
|
|
|
}
|
|
|
|
|
2002-04-23 20:50:24 +00:00
|
|
|
/** Returns the screen number */
|
|
|
|
- (int) screenNumber
|
|
|
|
{
|
|
|
|
return _screenNumber;
|
|
|
|
}
|
|
|
|
|
2000-05-04 18:28:00 +00:00
|
|
|
// Release the memory for the depths array.
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
// _supportedWindowDepths can be NULL since it may or may not
|
|
|
|
// be necessary to get this info. The most common use of NSScreen
|
|
|
|
// is to get the depth and frame attributes.
|
|
|
|
if (_supportedWindowDepths != NULL)
|
|
|
|
{
|
|
|
|
NSZoneFree(NSDefaultMallocZone(), _supportedWindowDepths);
|
|
|
|
}
|
2009-01-30 16:27:36 +00:00
|
|
|
if (_reserved != 0)
|
|
|
|
{
|
|
|
|
[(id)_reserved release];
|
|
|
|
}
|
2000-05-04 18:28:00 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2017-12-03 21:02:06 +00:00
|
|
|
- (CGFloat) userSpaceScaleFactor
|
2007-08-08 08:04:11 +00:00
|
|
|
{
|
2011-04-19 08:42:59 +00:00
|
|
|
NSNumber *factor = [[NSUserDefaults standardUserDefaults]
|
|
|
|
objectForKey: @"GSScaleFactor"];
|
2007-08-08 08:04:11 +00:00
|
|
|
|
2011-04-19 08:42:59 +00:00
|
|
|
if (factor != nil)
|
2007-08-08 08:04:11 +00:00
|
|
|
{
|
2011-04-19 08:42:59 +00:00
|
|
|
return [factor floatValue];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-07-30 20:44:06 +00:00
|
|
|
GSDisplayServer *srv = GSCurrentServer();
|
|
|
|
if (srv != nil)
|
|
|
|
{
|
|
|
|
NSSize dpi = [GSCurrentServer() resolutionForScreen: _screenNumber];
|
|
|
|
// average the width and height
|
|
|
|
return (dpi.width + dpi.height) / 144.0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 1.0;
|
|
|
|
}
|
2007-08-08 08:04:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-03 21:02:06 +00:00
|
|
|
- (CGFloat) backingScaleFactor
|
|
|
|
{
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
@end
|
2000-04-25 20:26:51 +00:00
|
|
|
|
|
|
|
|