From 37839119b2be6c87a46f1be2d0777ef74f4fff72 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Wed, 17 Nov 2004 05:59:04 +0000 Subject: [PATCH] Various improvements and a correction for but #10849. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20356 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 10 ++++++++++ GormColorsPref.h | 29 +++++++++++++++++++++++++++-- GormColorsPref.m | 8 +++++--- GormViewEditor.m | 21 +++++++++++---------- GormViewWindow.m | 7 ++++--- 5 files changed, 57 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9569d2a5..a4d36b97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-11-17 12:59 Gregory John Casamento + + * GormViewEditor.m: initWithObject:withDocument: added code + to instantiated GormViewWindow if the view being added has no + window attached to it. This is to handle standalone views. + Correction for Report #10849. + * GormViewWindow.m: [GormViewWindow initWithView:] call to + setReleasedWhenClosed so that the window isn't released when + the view window is closed. This was causing a crash. + 2004-11-16 19:19 Gregory John Casamento * GormClassPanelController.[hm]: Added method browserAction:. Changed diff --git a/GormColorsPref.h b/GormColorsPref.h index 14d46d5f..5a50de39 100644 --- a/GormColorsPref.h +++ b/GormColorsPref.h @@ -1,15 +1,40 @@ +#/* GormColorsPref.h + * + * Copyright (C) 2003 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 1999, 2003 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + #ifndef INCLUDED_GormColorsPref_h #define INCLUDED_GormColorsPref_h #include #include - #include +@class NSWindow; + @interface GormColorsPref : NSObject { id color; - id window; + NSWindow *window; id _view; } - (NSView *) view; diff --git a/GormColorsPref.m b/GormColorsPref.m index 07fa1e83..83d7d104 100644 --- a/GormColorsPref.m +++ b/GormColorsPref.m @@ -31,8 +31,7 @@ } [color setColor: aColor]; - - _view = [[window contentView] retain]; + _view = [[window contentView] retain]; } return self; } @@ -52,6 +51,9 @@ - (void) ok: (id)sender { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - [defaults setObject: colorToDict([color color]) forKey: @"GuideColor"]; + if(sender == color) + { + [defaults setObject: colorToDict([color color]) forKey: @"GuideColor"]; + } } @end diff --git a/GormViewEditor.m b/GormViewEditor.m index c9ea8637..cfad916f 100644 --- a/GormViewEditor.m +++ b/GormViewEditor.m @@ -158,17 +158,10 @@ static BOOL currently_displaying = NO; { NSView *superview; - // put the view into a "view window" if it's a standalone view... - if([_editedObject window] == nil) + // if the view window is not nil, it's a standalone view... + if(viewWindow != nil) { - if(viewWindow == nil) - { - viewWindow = [[GormViewWindow alloc] initWithView: _editedObject]; - } - else - { - [viewWindow setView: _editedObject]; - } + [viewWindow setView: _editedObject]; } superview = [_editedObject superview]; @@ -317,6 +310,14 @@ static BOOL currently_displaying = NO; activated = NO; closed = NO; + + // if this window is nil when the editor is created, we know it's a + // standalone view. + if([anObject window] == nil) + { + NSLog(@"#### Stand alone view: %@",_editedObject); + viewWindow = [[GormViewWindow alloc] initWithView: _editedObject]; + } } return self; diff --git a/GormViewWindow.m b/GormViewWindow.m index b48cfd04..383ba833 100644 --- a/GormViewWindow.m +++ b/GormViewWindow.m @@ -32,16 +32,16 @@ @interface GormViewWindowDelegate : NSObject { - id _view; + NSView *_view; } -- (id) initWithView: (id)view; +- (id) initWithView: (NSView *)view; - (void) resize; @end @implementation GormViewWindowDelegate -- (id) initWithView: (id)view; +- (id) initWithView: (NSView *)view; { if((self = [super init]) != nil) { @@ -87,6 +87,7 @@ [self setTitle: title]; [self setFrame: NSMakeRect(0,0,400,300) display: YES]; // [self setBackgroundColor: [NSColor redColor]]; + [self setReleasedWhenClosed: NO]; [self setView: view]; } return self;