mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Add support for custom views
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@11078 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1e8fa702d9
commit
bfc6f87df4
9 changed files with 174 additions and 14 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2001-10-03 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Add support for custom views
|
||||
* GormClassManager.m (-allActionsForObject:): Add support for
|
||||
GormCustomView
|
||||
(-allOutletsForObject:): Likewise.
|
||||
(-classInfoForObject:): Likewise.
|
||||
* GormDocument.m (-loadDocument:): Decode GSCustomView
|
||||
as GormCustomView.
|
||||
(-saveDocument:): likewise for encoding.
|
||||
* GormCustomView.m: New class.
|
||||
* Palettes/2Controls/main.m: Add customview item.
|
||||
|
||||
2001-10-02 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Palettes/2Controls/inspectors.m: Fix NSButton and popup button
|
||||
|
|
|
@ -76,13 +76,15 @@ Gorm_RESOURCE_FILES = \
|
|||
|
||||
Gorm_HEADERS = \
|
||||
Gorm.h \
|
||||
GormPrivate.h
|
||||
GormPrivate.h \
|
||||
GormCustomView.h
|
||||
|
||||
Gorm_OBJC_FILES = \
|
||||
Gorm.m \
|
||||
GormDocument.m \
|
||||
IBInspector.m \
|
||||
IBPalette.m \
|
||||
GormCustomView.m \
|
||||
GormViewKnobs.m \
|
||||
GormFilesOwner.m \
|
||||
GormClassEditor.m \
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "GormPrivate.h"
|
||||
#include "GormCustomView.h"
|
||||
|
||||
NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
|
||||
|
||||
|
@ -137,6 +138,11 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
|
|||
// this adds support for class proxies
|
||||
className = [(id)obj className];
|
||||
}
|
||||
else if ([obj isKindOfClass: [GormCustomView class]] == YES)
|
||||
{
|
||||
// this adds support for custom views
|
||||
className = [(id)obj className];
|
||||
}
|
||||
else
|
||||
{
|
||||
className = NSStringFromClass(theClass);
|
||||
|
@ -249,6 +255,11 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
|
|||
// this adds support for class proxies
|
||||
className = [(id)obj className];
|
||||
}
|
||||
else if ([obj isKindOfClass: [GormCustomView class]] == YES)
|
||||
{
|
||||
// this adds support for custom views
|
||||
className = [(id)obj className];
|
||||
}
|
||||
else
|
||||
{
|
||||
className = NSStringFromClass(theClass);
|
||||
|
@ -387,6 +398,11 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
|
|||
// this adds support for class proxies
|
||||
className = [(id)obj className];
|
||||
}
|
||||
else if ([obj isKindOfClass: [GormCustomView class]] == YES)
|
||||
{
|
||||
// this adds support for custom views
|
||||
className = [(id)obj className];
|
||||
}
|
||||
else
|
||||
{
|
||||
className = NSStringFromClass(theClass);
|
||||
|
|
38
GormCustomView.h
Normal file
38
GormCustomView.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* GormCustomView.h - Visual representation of a custom view placeholder
|
||||
*
|
||||
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Adam Fedor <fedor@gnu.org>
|
||||
* Date: 2001
|
||||
*
|
||||
* 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 GormCustomView_H
|
||||
#define GormCustomView_H
|
||||
|
||||
#include <AppKit/NSTextField.h>
|
||||
|
||||
@interface GormCustomView : NSTextField
|
||||
{
|
||||
}
|
||||
|
||||
- (void) setClassName: (NSString *)aName;
|
||||
- (NSString *) className;
|
||||
@end
|
||||
|
||||
#endif
|
85
GormCustomView.m
Normal file
85
GormCustomView.m
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* GormCustomView - Visual representation of a custom view placeholder
|
||||
*
|
||||
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Adam Fedor <fedor@gnu.org>
|
||||
* Date: 2001
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "GormCustomView.h"
|
||||
#include <AppKit/NSColor.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include <AppKit/NSFont.h>
|
||||
|
||||
@implementation GormCustomView
|
||||
|
||||
- (id)initWithFrame:(NSRect)frameRect
|
||||
{
|
||||
self = [super initWithFrame: frameRect];
|
||||
|
||||
[self setBackgroundColor: [NSColor darkGrayColor]];
|
||||
[self setTextColor: [NSColor whiteColor]];
|
||||
[self setDrawsBackground: YES];
|
||||
[self setAlignment: NSCenterTextAlignment];
|
||||
[self setFont: [NSFont boldSystemFontOfSize: 12]];
|
||||
[self setEditable: NO];
|
||||
[self setClassName: @"CustomView"];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormFilesOwnerInspector";
|
||||
}
|
||||
|
||||
- (void) setClassName: (NSString *)aName
|
||||
{
|
||||
[self setStringValue: aName];
|
||||
}
|
||||
|
||||
- (NSString *) className
|
||||
{
|
||||
return [self stringValue];
|
||||
}
|
||||
|
||||
/*
|
||||
* This needs to be coded like a GSNibItem. How do we make sure this
|
||||
* tracks changes in GSNibItem coding?
|
||||
*/
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeObject: [self stringValue]];
|
||||
[aCoder encodeRect: _frame];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
NSString *string;
|
||||
// do not decode super. We need to maintain mapping to NibItems
|
||||
string = [aCoder decodeObject];
|
||||
_frame = [aCoder decodeRect];
|
||||
|
||||
[self initWithFrame: _frame];
|
||||
[self setClassName: string];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
@ -1151,6 +1151,7 @@ static NSImage *classesImage = nil;
|
|||
u = AUTORELEASE([[NSUnarchiver alloc] initForReadingWithData: data]);
|
||||
[u decodeClassName: @"GSNibContainer" asClassName: @"GormDocument"];
|
||||
[u decodeClassName: @"GSNibItem" asClassName: @"GormObjectProxy"];
|
||||
[u decodeClassName: @"GSCustomView" asClassName: @"GormCustomView"];
|
||||
|
||||
c = [u decodeObject];
|
||||
if (c == nil || [c isKindOfClass: [GSNibContainer class]] == NO)
|
||||
|
@ -1235,7 +1236,8 @@ static NSImage *classesImage = nil;
|
|||
[objectsView addObject: obj];
|
||||
[[self openEditorForObject: obj] activate];
|
||||
}
|
||||
else if ([obj isKindOfClass: [GSNibItem class]] == YES)
|
||||
else if ([obj isKindOfClass: [GSNibItem class]] == YES
|
||||
&& [obj isKindOfClass: [GSCustomView class]] == NO)
|
||||
{
|
||||
[objectsView addObject: obj];
|
||||
//[[self openEditorForObject: obj] activate];
|
||||
|
@ -1684,6 +1686,8 @@ static NSImage *classesImage = nil;
|
|||
archiverData = [NSMutableData dataWithCapacity: 0];
|
||||
archiver = [[NSArchiver alloc] initForWritingWithMutableData: archiverData];
|
||||
[archiver encodeClassName: @"GormObjectProxy" intoClassName: @"GSNibItem"];
|
||||
[archiver encodeClassName: @"GormCustomView"
|
||||
intoClassName: @"GSCustomView"];
|
||||
[archiver encodeRootObject: self];
|
||||
archiveResult = [archiverData writeToFile: documentPath atomically: YES];
|
||||
//archiveResult = [NSArchiver archiveRootObject: self toFile: documentPath];
|
||||
|
|
|
@ -68,17 +68,6 @@
|
|||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface GormFilesOwnerInspector : IBInspector
|
||||
{
|
||||
NSBrowser *browser;
|
||||
NSArray *classes;
|
||||
BOOL hasConnections;
|
||||
}
|
||||
- (void) takeClassFrom: (id)sender;
|
||||
@end
|
||||
|
||||
@implementation GormFilesOwnerInspector
|
||||
|
||||
- (int) browser: (NSBrowser*)sender numberOfRowsInColumn: (int)column
|
||||
|
|
|
@ -165,6 +165,15 @@ extern NSString *GormLinkPboardType;
|
|||
- (void) changeObject: anObject;
|
||||
@end
|
||||
|
||||
@interface GormFilesOwnerInspector : IBInspector
|
||||
{
|
||||
NSBrowser *browser;
|
||||
NSArray *classes;
|
||||
BOOL hasConnections;
|
||||
}
|
||||
- (void) takeClassFrom: (id)sender;
|
||||
@end
|
||||
|
||||
/*
|
||||
* Functions for drawing knobs etc.
|
||||
*/
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <Foundation/Foundation.h>
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "../../Gorm.h"
|
||||
#include "../../GormCustomView.h"
|
||||
|
||||
@interface ControlsPalette: IBPalette
|
||||
{
|
||||
|
@ -158,6 +159,9 @@
|
|||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
// TODO: Add CustomView as soon as I figure out how it works.
|
||||
// CustomView
|
||||
v = [[GormCustomView alloc] initWithFrame: NSMakeRect(172, 9, 89, 40)];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue