From 7fe9b4072605410ca9f84699230312c0c02364a5 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sun, 5 Sep 2004 16:21:47 +0000 Subject: [PATCH] More enhancements for cells in table columns. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20000 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 11 ++++++- Palettes/3Containers/inspectors.m | 51 ++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37ec2371..99777af6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,13 @@ -2004-09-05 16:43 Gregory John Casamento +2004-09-05 12:17 Gregory John Casamento + + * Palettes/inspectors.m: Added _getCellClassName to + GormTableColumnAttribitesInspector to get the cell class + for the inspector. Also modified _getValuesFromObject: to + call the method and display the cell class name in the table. + Modified setValuesFromControl to add the object to the + document and assign the correct custom class. + +2004-09-05 10:15 Gregory John Casamento * Palettes/3Containers/GormNSTableColumnInspector.gorm: Made changes to allow user to edit the tableColumn dataCell. diff --git a/Palettes/3Containers/inspectors.m b/Palettes/3Containers/inspectors.m index 658a4e37..198e08fa 100644 --- a/Palettes/3Containers/inspectors.m +++ b/Palettes/3Containers/inspectors.m @@ -25,10 +25,9 @@ #include #include +#include #include "GormNSTableView.h" #include "GormPrivate.h" -#include -#include /* This macro makes sure that the string contains a value, even if @"" */ #define VSTR(str) ({id _str = str; (_str) ? _str : @"";}) @@ -226,10 +225,29 @@ [super setObject: anObject]; [self _getValuesFromObject: anObject]; } + +- (NSString *)_getCellClassName +{ + id cell = [[self object] dataCell]; + NSString *customClassName = [[(Gorm *)NSApp classManager] customClassForObject: cell]; + NSString *result = nil; + + if(customClassName == nil) + { + result = NSStringFromClass(cell); + } + else + { + result = customClassName; + } + + return result; +} + - (void) _getValuesFromObject: anObject { - NSString *cellClassName = NSStringFromClass([[anObject dataCell] class]); NSArray *list = [[(Gorm *)NSApp classManager] allSubclassesOf: @"NSCell"]; + NSString *cellClassName = [self _getCellClassName]; int index = [list indexOfObject: cellClassName]; if(index != NSNotFound && index != -1) @@ -339,16 +357,20 @@ } else if (control == setButton || control == cellTable) { - int i = [cellTable selectedRow]; + id classManager = [(Gorm *)NSApp classManager]; + id doc = [(id)NSApp activeDocument]; id cell = nil; - NSArray *list = [[(Gorm *)NSApp classManager] allSubclassesOf: @"NSCell"]; + int i = [cellTable selectedRow]; + NSArray *list = [classManager allSubclassesOf: @"NSCell"]; NSString *className = [list objectAtIndex: i]; - BOOL isCustom = [[(Gorm *)NSApp classManager] isCustomClass: className]; + BOOL isCustom = [classManager isCustomClass: className]; Class cls = nil; if(isCustom) { - NSLog(@"Setting custom cell.. not working yet..."); + NSString *superClass = [classManager nonCustomSuperClassOf: className]; + cls = NSClassFromString(superClass); + NSLog(@"Setting custom cell.."); } else { @@ -359,6 +381,21 @@ cell = [cls new]; [object setDataCell: cell]; [[object tableView] setNeedsDisplay: YES]; + + // add it to the document, since it needs a custom class... + if(isCustom) + { + NSString *name = nil; + + // An object needs to be a "named object" to have a custom class + // assigned to it. Add it to the document and get the name. + [doc attachObject: cell toParent: object]; + if((name = [doc nameForObject: cell]) != nil) + { + [classManager setCustomClass: className forObject: name]; + } + } + RELEASE(cell); } else if (control == defaultButton)