Window/Menu location saving updated to be exactly as per MacOS-X

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5196 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-11-16 09:40:14 +00:00
parent fae5235486
commit 87e7715a40
2 changed files with 63 additions and 10 deletions

View file

@ -4,6 +4,8 @@ Tue Nov 16 7:05:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
up to date on exit.
* Source/NSWindow.m: various changes to sving window frame info.
Use top-left as window origin, and save in OPENSTEP format.
Include code to save NSMenuWindow locations exactly as in
MacOS-X also.
Mon Nov 15 21:29:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>

View file

@ -62,6 +62,8 @@
#include <AppKit/NSGraphicsContext.h>
#include <AppKit/GSWraps.h>
@class NSMenuWindow;
BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
@interface GSWindowView : NSView
@ -2174,13 +2176,40 @@ resetCursorRectsForView(NSView *theView)
- (void) saveFrameUsingName: (NSString *)name
{
NSString *key;
NSString *obj;
NSUserDefaults *defs;
NSString *key;
id obj;
key = [NSString stringWithFormat: @"NSWindow frame %@", name];
obj = [self stringWithSavedFrame];
[windowsLock lock];
[[NSUserDefaults standardUserDefaults] setObject: obj forKey: key];
defs = [NSUserDefaults standardUserDefaults];
obj = [self stringWithSavedFrame];
if ([self isKindOfClass: [NSMenuWindow class]])
{
id dict;
key = @"NSMenuLocations";
dict = [defs objectForKey: key];
if (dict == nil)
{
dict = [NSMutableDictionary dictionaryWithCapacity: 1];
}
else if ([dict isKindOfClass: [NSDictionary class]] == NO)
{
NSLog(@"NSMenuLocations default is not a dictionary - overwriting");
dict = [NSMutableDictionary dictionaryWithCapacity: 1];
}
else
{
dict = AUTORELEASE([dict mutableCopy]);
}
[dict setObject: obj forKey: name];
obj = dict;
}
else
{
key = [NSString stringWithFormat: @"NSWindow frame %@", name];
}
[defs setObject: obj forKey: key];
[windowsLock unlock];
}
@ -2328,12 +2357,34 @@ resetCursorRectsForView(NSView *theView)
- (BOOL) setFrameUsingName: (NSString *)name
{
NSString *key;
NSString *obj;
NSUserDefaults *defs;
id obj;
key = [NSString stringWithFormat: @"NSWindow frame %@", name];
[windowsLock lock];
obj = [[NSUserDefaults standardUserDefaults] objectForKey: key];
defs = [NSUserDefaults standardUserDefaults];
if ([self isKindOfClass: [NSMenuWindow class]] == YES)
{
obj = [defs objectForKey: @"NSMenuLocations"];
if (obj != nil)
{
if ([obj isKindOfClass: [NSDictionary class]] == YES)
{
obj = [obj objectForKey: name];
}
else
{
NSLog(@"NSMenuLocations default is not a dictionary");
obj = nil;
}
}
}
else
{
NSString *key;
key = [NSString stringWithFormat: @"NSWindow frame %@", name];
obj = [defs objectForKey: key];
}
[windowsLock unlock];
if (obj == nil)
return NO;
@ -2355,7 +2406,7 @@ resetCursorRectsForView(NSView *theView)
*/
sRect = [[NSScreen mainScreen] frame];
return [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d",
return [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d ",
(int)fRect.origin.x, (int)fRect.origin.y,
(int)fRect.size.width, (int)fRect.size.height,
(int)sRect.origin.x, (int)sRect.origin.y,