Improved panel support and some cleanup.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@15504 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2003-01-05 06:03:14 +00:00
parent 99a4624a98
commit f86a25b225
9 changed files with 162 additions and 23 deletions

View file

@ -1,4 +1,20 @@
2003-01-03 Gregory John Casamento <greg_casamento@yahoo.com> 2003-01-05 Gregory John Casamento <greg_casamento@yahoo.com>
* Gorm.m: Cleaned up some NSLog statements.
-[Gorm testInterface]: Added call to encode GormNSPanel
as NSPanel when testing.
* GormDocument.m: -[GormDocument saveDocument]: Added
code to encode GormNSPanel as NSPanel.
-[GormDocument loadDocument]: Added code to decode NSPanel
as GormNSPanel so it can be edited.
* Palettes/1Windows/GNUmakefile: Added new files GormNSPanel.[hm].
* Palettes/1Windows/GormNSPanel.[hm]: Added.
* Palettes/1WIndows/main.m: Modified to use new GormNSPanel
class.
* Resources/GormPreferences.gorm: Modified to disallow resizing
of the panel.
2003-01-04 Gregory John Casamento <greg_casamento@yahoo.com>
* Palettes: Replaced all old .gorm/.classes files with * Palettes: Replaced all old .gorm/.classes files with
.gorm packages. .gorm packages.

6
Gorm.m
View file

@ -464,10 +464,10 @@ static NSButtonType _buttonTypeForObject( id button )
{ {
id obj = nil; id obj = nil;
NSString *name = [[(Gorm *)NSApp activeDocument] nameForObject: self]; NSString *name = [[(Gorm *)NSApp activeDocument] nameForObject: self];
NSLog(@"**** NAME: %@ %@",name, self); NSDebugLog(@"**** NAME: %@ %@",name, self);
[self setClassName: _parentClassName]; [self setClassName: _parentClassName];
obj = RETAIN([self instantiateObject: coder]); obj = RETAIN([self instantiateObject: coder]);
NSLog(@"******** OBJECT: %@",obj); NSDebugLog(@"******** OBJECT: %@",obj);
return obj; return obj;
} }
@end @end
@ -1390,6 +1390,8 @@ static NSButtonType _buttonTypeForObject( id button )
[a beginArchiving]; [a beginArchiving];
[archiver encodeClassName: @"GormNSWindow" [archiver encodeClassName: @"GormNSWindow"
intoClassName: @"NSWindow"]; intoClassName: @"NSWindow"];
[archiver encodeClassName: @"GormNSPanel"
intoClassName: @"NSPanel"];
[archiver encodeClassName: @"GormNSMenu" [archiver encodeClassName: @"GormNSMenu"
intoClassName: @"NSMenu"]; intoClassName: @"NSMenu"];
[archiver encodeClassName: @"GormNSPopUpButton" [archiver encodeClassName: @"GormNSPopUpButton"

View file

@ -1301,6 +1301,10 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
{ {
return @"NSWindow"; return @"NSWindow";
} }
if ([className isEqualToString: @"GormNSPanel"])
{
return @"NSPanel";
}
if ([className isEqualToString: @"GormNSBrowser"]) if ([className isEqualToString: @"GormNSBrowser"])
{ {
return @"NSBrowser"; return @"NSBrowser";

View file

@ -1803,6 +1803,7 @@ static NSImage *classesImage = nil;
[u decodeClassName: @"GSCustomView" asClassName: @"GormCustomView"]; [u decodeClassName: @"GSCustomView" asClassName: @"GormCustomView"];
[u decodeClassName: @"NSMenu" asClassName: @"GormNSMenu"]; [u decodeClassName: @"NSMenu" asClassName: @"GormNSMenu"];
[u decodeClassName: @"NSWindow" asClassName: @"GormNSWindow"]; [u decodeClassName: @"NSWindow" asClassName: @"GormNSWindow"];
[u decodeClassName: @"NSPanel" asClassName: @"GormNSPanel"];
[u decodeClassName: @"NSBrowser" asClassName: @"GormNSBrowser"]; [u decodeClassName: @"NSBrowser" asClassName: @"GormNSBrowser"];
[u decodeClassName: @"NSTableView" asClassName: @"GormNSTableView"]; [u decodeClassName: @"NSTableView" asClassName: @"GormNSTableView"];
[u decodeClassName: @"NSOutlineView" asClassName: @"GormNSOutlineView"]; [u decodeClassName: @"NSOutlineView" asClassName: @"GormNSOutlineView"];
@ -2488,6 +2489,8 @@ static NSImage *classesImage = nil;
intoClassName: @"NSMenu"]; intoClassName: @"NSMenu"];
[archiver encodeClassName: @"GormNSWindow" [archiver encodeClassName: @"GormNSWindow"
intoClassName: @"NSWindow"]; intoClassName: @"NSWindow"];
[archiver encodeClassName: @"GormNSPanel"
intoClassName: @"NSPanel"];
[archiver encodeClassName: @"GormNSBrowser" [archiver encodeClassName: @"GormNSBrowser"
intoClassName: @"NSBrowser"]; intoClassName: @"NSBrowser"];
[archiver encodeClassName: @"GormNSTableView" [archiver encodeClassName: @"GormNSTableView"

View file

@ -25,8 +25,8 @@ include $(GNUSTEP_MAKEFILES)/common.make
PALETTE_NAME = 1Windows PALETTE_NAME = 1Windows
1Windows_PALETTE_ICON = WindowsPalette 1Windows_PALETTE_ICON = WindowsPalette
1Windows_OBJC_FILES = main.m GormNSWindow.m 1Windows_OBJC_FILES = main.m GormNSWindow.m GormNSPanel.m
1Windows_HEADER_FILES = GormNSWindow.h 1Windows_HEADER_FILES = GormNSWindow.h GormNSPanel.h
1Windows_PRINCIPAL_CLASS = WindowsPalette 1Windows_PRINCIPAL_CLASS = WindowsPalette
1Windows_RESOURCE_FILES = WindowsPalette.tiff WindowDrag.tiff \ 1Windows_RESOURCE_FILES = WindowsPalette.tiff WindowDrag.tiff \
GormNSWindowSizeInspector.gorm \ GormNSWindowSizeInspector.gorm \

View file

@ -0,0 +1,34 @@
/* GormNSPanel.h
Copyright (C) 2003 Free Software Foundation, Inc.
Author: Gregory John Casamento <greg_casamento@yahoo.com>
Date: 2003
Adapted from GormNSWindow.h
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.
*/
#import <AppKit/AppKit.h>
@interface GormNSPanel : NSPanel
{
unsigned _gormStyleMask;
}
- (void)setStyleMask: (unsigned) newStyleMask;
- (unsigned)styleMask;
@end

View file

@ -0,0 +1,63 @@
/* GormNSPanel.m
Copyright (C) 2003 Free Software Foundation, Inc.
Author: Gregory John Casamento <greg_casamento@yahoo.com>
Date: 2003
Adapted from GormNSWindow.m
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.
*/
#import <AppKit/AppKit.h>
#import "GormNSPanel.h"
@implementation GormNSPanel
- (void)encodeWithCoder: (NSCoder*) aCoder
{
unsigned oldStyleMask;
oldStyleMask = _styleMask;
_styleMask = _gormStyleMask;
[super encodeWithCoder: aCoder];
_styleMask = oldStyleMask;
}
- (id) initWithContentRect: (NSRect)contentRect
styleMask: (unsigned int)aStyle
backing: (NSBackingStoreType)bufferingType
defer: (BOOL)flag
screen: (NSScreen*)aScreen
{
_gormStyleMask = aStyle;
return [super initWithContentRect: contentRect
styleMask: NSTitledWindowMask | NSClosableWindowMask
backing: bufferingType
defer: flag
screen: aScreen];
}
- (void)setStyleMask: (unsigned) newStyleMask
{
_gormStyleMask = newStyleMask;
}
- (unsigned)styleMask
{
return _gormStyleMask;
}
@end

View file

@ -25,6 +25,7 @@
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#include "../../GormPrivate.h" #include "../../GormPrivate.h"
#include "GormNSWindow.h" #include "GormNSWindow.h"
#include "GormNSPanel.h"
@interface GormWindowMaker : NSObject <NSCoding> @interface GormWindowMaker : NSObject <NSCoding>
{ {
@ -72,16 +73,14 @@
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
id w; id w;
unsigned style = NSTitledWindowMask | NSClosableWindowMask unsigned style = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
| NSResizableWindowMask | NSMiniaturizableWindowMask;
NSRect screenRect = [[NSScreen mainScreen] frame]; NSRect screenRect = [[NSScreen mainScreen] frame];
float float
x = (screenRect.size.width - 500)/2, x = (screenRect.size.width - 500)/2,
y = (screenRect.size.height - 300)/2; y = (screenRect.size.height - 300)/2;
NSRect windowRect = NSMakeRect(x,y,500,300); NSRect windowRect = NSMakeRect(x,y,500,300);
// NSLog(@"Making panel %@",NSStringFromRect(windowRect)); w = [[GormNSPanel alloc] initWithContentRect: windowRect
w = [[NSPanel alloc] initWithContentRect: windowRect
styleMask: style styleMask: style
backing: NSBackingStoreRetained backing: NSBackingStoreRetained
defer: NO]; defer: NO];
@ -166,7 +165,7 @@ NSwindow inspector
} }
@end @end
@implementation NSPanel (IBInspectorClassNames) @implementation GormNSPanel (IBInspectorClassNames)
- (NSString*) inspectorClassName - (NSString*) inspectorClassName
{ {
return @"GormWindowAttributesInspector"; return @"GormWindowAttributesInspector";
@ -242,7 +241,7 @@ NSwindow inspector
} }
// Deferred // Deferred
// FIXME: This flag is not a WIndow property. Like Visible at launch time // FIXME: This flag is not a Window property. Like Visible at launch time
// it should be stored in the Nib File and used at the Window creation time // it should be stored in the Nib File and used at the Window creation time
// but I do not know how to do that // but I do not know how to do that
flag = ([[control cellAtRow: 3 column: 0] state] == NSOnState) ? YES : NO; flag = ([[control cellAtRow: 3 column: 0] state] == NSOnState) ? YES : NO;
@ -260,7 +259,6 @@ NSwindow inspector
// FIXME: probably means window depth > 2 bits per pixel but don't know // FIXME: probably means window depth > 2 bits per pixel but don't know
// exactly what NSWindow method to use to enforce that. // exactly what NSWindow method to use to enforce that.
flag = ([[control cellAtRow: 6 column: 0] state] == NSOnState) ? YES : NO; flag = ([[control cellAtRow: 6 column: 0] state] == NSOnState) ? YES : NO;
} }
} }
@ -306,6 +304,22 @@ NSwindow inspector
} }
- (void) _validate: (id)anObject
{
id cell = [controlMatrix cellAtRow: 0 column: 0];
// Assumed to be the "miniaturize" cell.
// panels should not be allowed to miniaturize the app.
if([anObject isKindOfClass: [NSPanel class]])
{
[cell setEnabled: NO];
}
else
{
[cell setEnabled: YES];
}
}
- (id) init - (id) init
{ {
if ([super init] == nil) if ([super init] == nil)
@ -326,7 +340,10 @@ NSwindow inspector
- (void) setObject: (id)anObject - (void) setObject: (id)anObject
{ {
// Need to do something here to disable certain portions of
// the inspector if the object being edited is an NSPanel.
[super setObject: anObject]; [super setObject: anObject];
// [self _validate: anObject];
[self _getValuesFromObject: anObject]; [self _getValuesFromObject: anObject];
} }