Implemented logic to use canSubstituteForClass: to determine what classes should appear in the custom class inspector.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21157 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-04-24 15:21:12 +00:00
parent c7f0afb590
commit d9356d6300
5 changed files with 80 additions and 16 deletions

View file

@ -1,3 +1,15 @@
2005-04-24 11:16 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormClassManager.m: Remove special case for
NSSecureTextField.
* GormCore/GormCustomClassInspector.m: Added new private
method to call canSubstituteForClass: when appropriate to
determine if the class should appear in the class list.
* GormCore/GormPrivate.m: Added default implementation of
canSubstituteForClass: on NSObject to return NO.
* Palettes/2Controls/inspectors.m: Added implementation of
canSubstituteForClass: to NSSecureTextField.
2005-04-23 22:57 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormClassEditor.m: Change in performDragOperation: to

View file

@ -997,15 +997,18 @@
{
NSMutableArray *array = [NSMutableArray array];
[self allSubclassesOf: superClass
referenceClassList: customClasses
intoArray: array];
if(superClass != nil)
{
[self allSubclassesOf: superClass
referenceClassList: customClasses
intoArray: array];
}
// add known allowable subclasses to the list.
if ([superClass isEqualToString: @"NSTextField"])
{
[array addObject: @"NSSecureTextField"];
}
// if ([superClass isEqualToString: @"NSTextField"])
// {
// [array addObject: @"NSSecureTextField"];
// }
return array;
}

View file

@ -78,6 +78,39 @@
ASSIGN(_parentClassName, [anobject className]);
}
- (NSMutableArray *) _generateClassList
{
NSMutableArray *classes = [NSMutableArray arrayWithObject: _parentClassName];
NSArray *subclasses = [_classManager allSubclassesOf: _parentClassName];
NSEnumerator *en = [subclasses objectEnumerator];
NSString *className = nil;
Class parentClass = NSClassFromString(_parentClassName);
while((className = [en nextObject]) != nil)
{
if([_classManager isCustomClass: className] == YES)
{
[classes addObject: className];
}
else if(parentClass != nil)
{
Class cls = NSClassFromString(className);
if(cls != nil)
{
if([cls respondsToSelector: @selector(canSubstituteForClass:)])
{
if([cls canSubstituteForClass: parentClass])
{
[classes addObject: className];
}
}
}
}
}
return classes;
}
- (void) setObject: (id)anObject
{
if(anObject != nil)
@ -97,8 +130,9 @@
// get a list of all of the classes allowed and the class to be shown
// and select the appropriate row in the inspector...
classes = [NSMutableArray arrayWithObject: _parentClassName];
[classes addObjectsFromArray: [_classManager allCustomSubclassesOf: _parentClassName]];
classes = [self _generateClassList];
// [NSMutableArray arrayWithObject: _parentClassName];
// [classes addObjectsFromArray: [_classManager allCustomSubclassesOf: _parentClassName]];
_rowToSelect = [classes indexOfObject: _currentSelectionClassName];
_rowToSelect = (_rowToSelect != NSNotFound)?_rowToSelect:0;
@ -200,10 +234,11 @@ createRowsForColumn: (int)column
NSBrowserCell *cell = nil;
int i = 0;
classes = [NSMutableArray arrayWithObject: _parentClassName];
classes = [self _generateClassList];
// [NSMutableArray arrayWithObject: _parentClassName];
// get a list of all of the classes allowed and the class to be shown.
[classes addObjectsFromArray:
[_classManager allCustomSubclassesOf: _parentClassName]];
//[classes addObjectsFromArray:
// [_classManager allCustomSubclassesOf: _parentClassName]];
// enumerate through the classes...
e = [classes objectEnumerator];

View file

@ -51,8 +51,6 @@ static BOOL _illegalClassSubstitution = NO;
// we had this include for grouping/ungrouping selectors
#include "GormViewWithContentViewEditor.h"
@implementation GSNibItem (GormAdditions)
- initWithClassName: (NSString*)className frame: (NSRect)frame
{
@ -85,6 +83,11 @@ static BOOL _illegalClassSubstitution = NO;
_illegalClassSubstitution = YES;
}
}
+ (BOOL) canSubstituteForClass: (Class)origClass
{
return NO;
}
@end
@implementation GormObjectProxy

View file

@ -30,16 +30,27 @@
/* This macro makes sure that the string contains a value, even if @"" */
#define VSTR(str) ({id _str = str; (_str) ? _str : @"";})
/* This is so that the NSSecureTextField will show in the custom class inspector */
@implementation NSSecureTextField (IBObjectAdditions)
+ (BOOL) canSubstituteForClass: (Class)origClass
{
if(origClass == [NSTextField class])
{
return YES;
}
return NO;
}
@end
/*----------------------------------------------------------------------------
* NSBox
*/
@implementation NSBox (IBObjectAdditions)
- (NSString*) inspectorClassName
{
return @"GormBoxAttributesInspector";
}
@end
@interface GormBoxAttributesInspector : IBInspector