mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 12:01:16 +00:00
Made a more generic cell replacement algorith for custom classes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21423 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7aac9ffaa4
commit
03dfa955f4
8 changed files with 114 additions and 106 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2005-07-07 22:02 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* GormCore/GormCustomClassInspector.m: In the method
|
||||||
|
- (void) _replaceCellClassForObject:className: added logic to
|
||||||
|
automatically replace the cell in a more generic fashion.
|
||||||
|
* GormCore/GormPrivate.m: Added logic to canSubstituteForClass: to
|
||||||
|
determine if it's possible for the class passed in to substitute for
|
||||||
|
the reciever.
|
||||||
|
* Palettes/2Controls/inspectors.m: Removed canSubstituteForClass:
|
||||||
|
implementation for NSSecureTextView.
|
||||||
|
* Palettes/3Containers/GormNSOutlineView.[hm]: Cleaned up
|
||||||
|
initWithCoder: and encodeWithCoder:.
|
||||||
|
* Palettes/3Containers/GormNSTableView.[hm]: Ditto
|
||||||
|
|
||||||
2005-07-07 13:22 Gregory John Casamento <greg_casamento@yahoo.com>
|
2005-07-07 13:22 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* GormCore/GormControlEditor.m: Removed commented out code
|
* GormCore/GormControlEditor.m: Removed commented out code
|
||||||
|
|
|
@ -89,9 +89,20 @@
|
||||||
while((className = [en nextObject]) != nil)
|
while((className = [en nextObject]) != nil)
|
||||||
{
|
{
|
||||||
if([_classManager isCustomClass: className] == YES)
|
if([_classManager isCustomClass: className] == YES)
|
||||||
|
{
|
||||||
|
NSString *superClass = [_classManager nonCustomSuperClassOf: className];
|
||||||
|
Class cls = NSClassFromString(superClass);
|
||||||
|
if(cls != nil)
|
||||||
|
{
|
||||||
|
if([cls respondsToSelector: @selector(canSubstituteForClass:)])
|
||||||
|
{
|
||||||
|
if([cls canSubstituteForClass: parentClass])
|
||||||
{
|
{
|
||||||
[classes addObject: className];
|
[classes addObject: className];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(parentClass != nil)
|
else if(parentClass != nil)
|
||||||
{
|
{
|
||||||
Class cls = NSClassFromString(className);
|
Class cls = NSClassFromString(className);
|
||||||
|
@ -154,42 +165,58 @@
|
||||||
- (void) _replaceCellClassForObject: (id)obj
|
- (void) _replaceCellClassForObject: (id)obj
|
||||||
className: (NSString *)name
|
className: (NSString *)name
|
||||||
{
|
{
|
||||||
if([name isEqualToString: @"NSSecureTextField"] ||
|
NSString *className = name;
|
||||||
[name isEqualToString: @"NSTextField"])
|
|
||||||
|
if([[obj class] respondsToSelector: @selector(cellClass)])
|
||||||
|
{
|
||||||
|
if([_classManager isCustomClass: className])
|
||||||
|
{
|
||||||
|
className = [_classManager nonCustomSuperClassOf: name];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(className != nil)
|
||||||
|
{
|
||||||
|
Class cls = NSClassFromString(className);
|
||||||
|
if(cls != nil)
|
||||||
{
|
{
|
||||||
NSCell *cell = [obj cell];
|
NSCell *cell = [obj cell];
|
||||||
NSCell *newCell = nil;
|
Class cellClass = [cls cellClass];
|
||||||
|
NSCell *newCell = [[cellClass alloc] init];
|
||||||
BOOL drawsBackground = [object drawsBackground];
|
BOOL drawsBackground = [object drawsBackground];
|
||||||
|
|
||||||
// instantiate the cell...
|
|
||||||
if([name isEqualToString: @"NSSecureTextField"])
|
|
||||||
{
|
|
||||||
newCell = [[NSSecureTextFieldCell alloc] init];
|
|
||||||
}
|
|
||||||
else if([name isEqualToString: @"NSTextField"])
|
|
||||||
{
|
|
||||||
newCell = [[NSTextFieldCell alloc] init];
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy everything from the old cell...
|
// copy everything from the old cell...
|
||||||
|
if([newCell respondsToSelector: @selector(setFont:)])
|
||||||
[newCell setFont: [cell font]];
|
[newCell setFont: [cell font]];
|
||||||
|
if([newCell respondsToSelector: @selector(setEnabled:)])
|
||||||
[newCell setEnabled: [cell isEnabled]];
|
[newCell setEnabled: [cell isEnabled]];
|
||||||
|
if([newCell respondsToSelector: @selector(setEditable:)])
|
||||||
[newCell setEditable: [cell isEditable]];
|
[newCell setEditable: [cell isEditable]];
|
||||||
|
if([newCell respondsToSelector: @selector(setImportsGraphics:)])
|
||||||
[newCell setImportsGraphics: [cell importsGraphics]];
|
[newCell setImportsGraphics: [cell importsGraphics]];
|
||||||
|
if([newCell respondsToSelector: @selector(setShowsFirstResponder:)])
|
||||||
[newCell setShowsFirstResponder: [cell showsFirstResponder]];
|
[newCell setShowsFirstResponder: [cell showsFirstResponder]];
|
||||||
|
if([newCell respondsToSelector: @selector(setRefusesFirstResponder:)])
|
||||||
[newCell setRefusesFirstResponder: [cell refusesFirstResponder]];
|
[newCell setRefusesFirstResponder: [cell refusesFirstResponder]];
|
||||||
|
if([newCell respondsToSelector: @selector(setBordered:)])
|
||||||
[newCell setBordered: [cell isBordered]];
|
[newCell setBordered: [cell isBordered]];
|
||||||
|
if([newCell respondsToSelector: @selector(setBezeled:)])
|
||||||
[newCell setBezeled: [cell isBezeled]];
|
[newCell setBezeled: [cell isBezeled]];
|
||||||
|
if([newCell respondsToSelector: @selector(setScrollable:)])
|
||||||
[newCell setScrollable: [cell isScrollable]];
|
[newCell setScrollable: [cell isScrollable]];
|
||||||
|
if([newCell respondsToSelector: @selector(setSelectable:)])
|
||||||
[newCell setSelectable: [cell isSelectable]];
|
[newCell setSelectable: [cell isSelectable]];
|
||||||
|
if([newCell respondsToSelector: @selector(setState:)])
|
||||||
[newCell setState: [cell state]];
|
[newCell setState: [cell state]];
|
||||||
|
|
||||||
// set attributes of textfield.
|
// set attributes of textfield.
|
||||||
[object setCell: newCell];
|
[object setCell: newCell];
|
||||||
|
if([newCell respondsToSelector: @selector(setDrawsBackground:)])
|
||||||
[object setDrawsBackground: drawsBackground];
|
[object setDrawsBackground: drawsBackground];
|
||||||
|
[object setNeedsDisplay: YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) select: (id)sender
|
- (void) select: (id)sender
|
||||||
{
|
{
|
||||||
NSCell *cell = [browser selectedCellInColumn: 0];
|
NSCell *cell = [browser selectedCellInColumn: 0];
|
||||||
|
|
|
@ -86,6 +86,25 @@ static BOOL _illegalClassSubstitution = NO;
|
||||||
|
|
||||||
+ (BOOL) canSubstituteForClass: (Class)origClass
|
+ (BOOL) canSubstituteForClass: (Class)origClass
|
||||||
{
|
{
|
||||||
|
if(self == origClass)
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
else if([self isSubclassOfClass: origClass])
|
||||||
|
{
|
||||||
|
Class cls = self;
|
||||||
|
while(cls != nil && cls != origClass)
|
||||||
|
{
|
||||||
|
if(GSGetMethod(cls, @selector(initWithCoder:), YES, NO) != NULL &&
|
||||||
|
GSGetMethod(cls, @selector(encodeWithCoder:), YES, NO) != NULL)
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
cls = GSObjCSuper(cls); // get super class
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#define VSTR(str) ({id _str = str; (_str) ? _str : @"";})
|
#define VSTR(str) ({id _str = str; (_str) ? _str : @"";})
|
||||||
|
|
||||||
/* This is so that the NSSecureTextField will show in the custom class inspector */
|
/* This is so that the NSSecureTextField will show in the custom class inspector */
|
||||||
|
/*
|
||||||
@implementation NSSecureTextField (IBObjectAdditions)
|
@implementation NSSecureTextField (IBObjectAdditions)
|
||||||
+ (BOOL) canSubstituteForClass: (Class)origClass
|
+ (BOOL) canSubstituteForClass: (Class)origClass
|
||||||
{
|
{
|
||||||
|
@ -42,6 +43,7 @@
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
*/
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
* NSBox
|
* NSBox
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
BOOL _gormAllowsColumnSelection;
|
BOOL _gormAllowsColumnSelection;
|
||||||
BOOL _gormAllowsMultipleSelection;
|
BOOL _gormAllowsMultipleSelection;
|
||||||
BOOL _gormAllowsEmptySelection;
|
BOOL _gormAllowsEmptySelection;
|
||||||
// NSColor *_savedColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setGormDelegate: (id)anObject;
|
- (void) setGormDelegate: (id)anObject;
|
||||||
|
@ -51,10 +50,6 @@
|
||||||
- (BOOL) gormAllowsEmptySelection;
|
- (BOOL) gormAllowsEmptySelection;
|
||||||
- (void) setGormAllowsColumnSelection: (BOOL)flag;
|
- (void) setGormAllowsColumnSelection: (BOOL)flag;
|
||||||
- (BOOL) gormAllowsColumnSelection;
|
- (BOOL) gormAllowsColumnSelection;
|
||||||
|
|
||||||
// preserve the color during selection...
|
|
||||||
//- (void) select;
|
|
||||||
//- (void) unselect;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -192,7 +192,6 @@ static id _sharedDataSource = nil;
|
||||||
self = [super initWithFrame: aRect];
|
self = [super initWithFrame: aRect];
|
||||||
[super setDataSource: [GormNSOutlineView sharedDataSource]];
|
[super setDataSource: [GormNSOutlineView sharedDataSource]];
|
||||||
_gormDataSource = nil;
|
_gormDataSource = nil;
|
||||||
// ASSIGN(_savedColor,[NSColor controlBackgroundColor]);
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,18 +224,22 @@ static id _sharedDataSource = nil;
|
||||||
{
|
{
|
||||||
id oldDelegate;
|
id oldDelegate;
|
||||||
int oldNumberOfRows;
|
int oldNumberOfRows;
|
||||||
|
|
||||||
|
// set real values...
|
||||||
_allowsColumnReordering = _gormAllowsColumnReordering;
|
_allowsColumnReordering = _gormAllowsColumnReordering;
|
||||||
_allowsColumnResizing = _gormAllowsColumnResizing;
|
_allowsColumnResizing = _gormAllowsColumnResizing;
|
||||||
_allowsColumnSelection = _gormAllowsColumnSelection;
|
_allowsColumnSelection = _gormAllowsColumnSelection;
|
||||||
_allowsMultipleSelection = _gormAllowsMultipleSelection;
|
_allowsMultipleSelection = _gormAllowsMultipleSelection;
|
||||||
_allowsEmptySelection = _gormAllowsEmptySelection;
|
_allowsEmptySelection = _gormAllowsEmptySelection;
|
||||||
|
|
||||||
_dataSource = _gormDataSource;
|
_dataSource = _gormDataSource;
|
||||||
oldDelegate = _delegate;
|
oldDelegate = _delegate;
|
||||||
_delegate = _gormDelegate;
|
_delegate = _gormDelegate;
|
||||||
oldNumberOfRows = _numberOfRows;
|
oldNumberOfRows = _numberOfRows;
|
||||||
_numberOfRows = 0;
|
_numberOfRows = 0;
|
||||||
|
|
||||||
[super encodeWithCoder: aCoder];
|
[super encodeWithCoder: aCoder];
|
||||||
|
|
||||||
|
// set fake values back...
|
||||||
_numberOfRows = oldNumberOfRows;
|
_numberOfRows = oldNumberOfRows;
|
||||||
_allowsColumnReordering = YES;
|
_allowsColumnReordering = YES;
|
||||||
_allowsColumnResizing = YES;
|
_allowsColumnResizing = YES;
|
||||||
|
@ -251,8 +254,8 @@ static id _sharedDataSource = nil;
|
||||||
- (id) initWithCoder: (NSCoder*) aCoder
|
- (id) initWithCoder: (NSCoder*) aCoder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: aCoder];
|
self = [super initWithCoder: aCoder];
|
||||||
[super setDataSource: [GormNSOutlineView sharedDataSource]];
|
|
||||||
|
|
||||||
|
[super setDataSource: [GormNSOutlineView sharedDataSource]];
|
||||||
_gormAllowsColumnReordering = _allowsColumnReordering;
|
_gormAllowsColumnReordering = _allowsColumnReordering;
|
||||||
_gormAllowsColumnResizing = _allowsColumnResizing;
|
_gormAllowsColumnResizing = _allowsColumnResizing;
|
||||||
_gormAllowsColumnSelection = _allowsColumnSelection;
|
_gormAllowsColumnSelection = _allowsColumnSelection;
|
||||||
|
@ -260,15 +263,13 @@ static id _sharedDataSource = nil;
|
||||||
_gormAllowsEmptySelection = _allowsEmptySelection;
|
_gormAllowsEmptySelection = _allowsEmptySelection;
|
||||||
_gormDelegate = _delegate;
|
_gormDelegate = _delegate;
|
||||||
_delegate = nil;
|
_delegate = nil;
|
||||||
// ASSIGN(_savedColor, [self backgroundColor]);
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) awakeFromNib
|
||||||
{
|
{
|
||||||
// RELEASE(_savedColor);
|
[super setDataSource: [GormNSOutlineView sharedDataSource]];
|
||||||
[super dealloc];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setGormAllowsColumnReordering: (BOOL)flag
|
- (void) setGormAllowsColumnReordering: (BOOL)flag
|
||||||
|
@ -325,23 +326,4 @@ static id _sharedDataSource = nil;
|
||||||
{
|
{
|
||||||
return @"NSOutlineView";
|
return @"NSOutlineView";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
- (void) setBackgroundColor: (NSColor *)color
|
|
||||||
{
|
|
||||||
[super setBackgroundColor: color];
|
|
||||||
ASSIGN(_savedColor, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) select
|
|
||||||
{
|
|
||||||
[super setBackgroundColor: [NSColor whiteColor]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) unselect
|
|
||||||
{
|
|
||||||
[super setBackgroundColor: _savedColor];
|
|
||||||
[self deselectAll: self];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
BOOL _gormAllowsColumnSelection;
|
BOOL _gormAllowsColumnSelection;
|
||||||
BOOL _gormAllowsMultipleSelection;
|
BOOL _gormAllowsMultipleSelection;
|
||||||
BOOL _gormAllowsEmptySelection;
|
BOOL _gormAllowsEmptySelection;
|
||||||
// NSColor *_savedColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setGormDelegate: (id)anObject;
|
- (void) setGormDelegate: (id)anObject;
|
||||||
|
@ -51,12 +50,6 @@
|
||||||
- (BOOL) gormAllowsEmptySelection;
|
- (BOOL) gormAllowsEmptySelection;
|
||||||
- (void) setGormAllowsColumnSelection: (BOOL)flag;
|
- (void) setGormAllowsColumnSelection: (BOOL)flag;
|
||||||
- (BOOL) gormAllowsColumnSelection;
|
- (BOOL) gormAllowsColumnSelection;
|
||||||
|
|
||||||
// preserve the color during selection...
|
|
||||||
/*
|
|
||||||
- (void) select;
|
|
||||||
- (void) unselect;
|
|
||||||
*/
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -144,21 +144,21 @@ static id _sharedDataSource = nil;
|
||||||
- (void)encodeWithCoder: (NSCoder*) aCoder
|
- (void)encodeWithCoder: (NSCoder*) aCoder
|
||||||
{
|
{
|
||||||
id oldDelegate;
|
id oldDelegate;
|
||||||
|
|
||||||
|
// set actual values...
|
||||||
_allowsColumnReordering = _gormAllowsColumnReordering;
|
_allowsColumnReordering = _gormAllowsColumnReordering;
|
||||||
_allowsColumnResizing = _gormAllowsColumnResizing;
|
_allowsColumnResizing = _gormAllowsColumnResizing;
|
||||||
_allowsColumnSelection = _gormAllowsColumnSelection;
|
_allowsColumnSelection = _gormAllowsColumnSelection;
|
||||||
_allowsMultipleSelection = _gormAllowsMultipleSelection;
|
_allowsMultipleSelection = _gormAllowsMultipleSelection;
|
||||||
_allowsEmptySelection = _gormAllowsEmptySelection;
|
_allowsEmptySelection = _gormAllowsEmptySelection;
|
||||||
|
|
||||||
if([(id<IB>)NSApp isTestingInterface] == NO)
|
|
||||||
{
|
|
||||||
_dataSource = _gormDataSource;
|
_dataSource = _gormDataSource;
|
||||||
oldDelegate = _delegate;
|
oldDelegate = _delegate;
|
||||||
_delegate = _gormDelegate;
|
_delegate = _gormDelegate;
|
||||||
}
|
|
||||||
|
|
||||||
_numberOfRows = 0;
|
_numberOfRows = 0;
|
||||||
|
|
||||||
[super encodeWithCoder: aCoder];
|
[super encodeWithCoder: aCoder];
|
||||||
|
|
||||||
|
// reset fake values...
|
||||||
_numberOfRows = 10;
|
_numberOfRows = 10;
|
||||||
_allowsColumnReordering = YES;
|
_allowsColumnReordering = YES;
|
||||||
_allowsColumnResizing = YES;
|
_allowsColumnResizing = YES;
|
||||||
|
@ -166,18 +166,15 @@ static id _sharedDataSource = nil;
|
||||||
_allowsMultipleSelection = NO;
|
_allowsMultipleSelection = NO;
|
||||||
_allowsEmptySelection = YES;
|
_allowsEmptySelection = YES;
|
||||||
|
|
||||||
if([(id<IB>)NSApp isTestingInterface] == NO)
|
|
||||||
{
|
|
||||||
_delegate = oldDelegate;
|
_delegate = oldDelegate;
|
||||||
_dataSource = _sharedDataSource;
|
_dataSource = _sharedDataSource;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*) aCoder
|
- (id) initWithCoder: (NSCoder*) aCoder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: aCoder];
|
self = [super initWithCoder: aCoder];
|
||||||
[super setDataSource: [GormNSTableView sharedDataSource]];
|
|
||||||
|
|
||||||
|
[super setDataSource: [GormNSTableView sharedDataSource]];
|
||||||
_gormAllowsColumnReordering = _allowsColumnReordering;
|
_gormAllowsColumnReordering = _allowsColumnReordering;
|
||||||
_gormAllowsColumnResizing = _allowsColumnResizing;
|
_gormAllowsColumnResizing = _allowsColumnResizing;
|
||||||
_gormAllowsColumnSelection = _allowsColumnSelection;
|
_gormAllowsColumnSelection = _allowsColumnSelection;
|
||||||
|
@ -185,15 +182,13 @@ static id _sharedDataSource = nil;
|
||||||
_gormAllowsEmptySelection = _allowsEmptySelection;
|
_gormAllowsEmptySelection = _allowsEmptySelection;
|
||||||
_gormDelegate = _delegate;
|
_gormDelegate = _delegate;
|
||||||
_delegate = nil;
|
_delegate = nil;
|
||||||
// ASSIGN(_savedColor, [self backgroundColor]);
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) awakeFromNib
|
||||||
{
|
{
|
||||||
// RELEASE(_savedColor);
|
[super setDataSource: [GormNSTableView sharedDataSource]];
|
||||||
[super dealloc];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setGormAllowsColumnReordering: (BOOL)flag
|
- (void) setGormAllowsColumnReordering: (BOOL)flag
|
||||||
|
@ -250,23 +245,4 @@ static id _sharedDataSource = nil;
|
||||||
{
|
{
|
||||||
return @"NSTableView";
|
return @"NSTableView";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
- (void) setBackgroundColor: (NSColor *)color
|
|
||||||
{
|
|
||||||
[super setBackgroundColor: color];
|
|
||||||
ASSIGN(_savedColor, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) select
|
|
||||||
{
|
|
||||||
[super setBackgroundColor: [NSColor whiteColor]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) unselect
|
|
||||||
{
|
|
||||||
[super setBackgroundColor: _savedColor];
|
|
||||||
[self deselectAll: self];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue