Added capability to the column inspector to update the data cell.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19997 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-09-05 13:42:45 +00:00
parent 214c6e9a03
commit 8e55cad2a1
5 changed files with 99 additions and 1 deletions

View file

@ -1,3 +1,14 @@
2004-09-05 16:43 Gregory John Casamento <greg_casamento@yahoo.com>
* Palettes/3Containers/GormNSTableColumnInspector.gorm:
Made changes to allow user to edit the tableColumn dataCell.
* Palettes/3Containers/inspectors.m: Added code
for the delegate and datasource of the table added to the
inspector. Also modified methods _getValuesFromObject and
_setValuesFromControl: in GormTableColumnInspector to
accommodate changing the dataCell and redisplaying the
tableView which the column belongs to.
2004-08-28 16:43 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCustomView.m: Modified _bestPossibleSuperClass to

View file

@ -143,7 +143,10 @@
editableSwitch,
identifierTextField,
resizableSwitch,
titleAlignmentMatrix
titleAlignmentMatrix,
cellTable,
defaultButton,
setButton
);
Super = IBInspector;
};

View file

@ -26,6 +26,7 @@
#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>
#include "GormNSTableView.h"
#include "GormPrivate.h"
#include <InterfaceBuilder/IBInspector.h>
#include <InterfaceBuilder/IBObjectAdditions.h>
@ -185,6 +186,9 @@
id identifierTextField;
id resizableSwitch;
id editableSwitch;
id setButton;
id defaultButton;
id cellTable;
}
- (void) _getValuesFromObject: (id)anObject;
- (void) _setValuesFromControl: (id)anObject;
@ -207,6 +211,11 @@
return self;
}
- (void) awakeFromNib
{
[cellTable setDoubleAction: @selector(ok:)];
}
- (void) ok: (id)sender
{
[self _setValuesFromControl: sender];
@ -219,6 +228,16 @@
}
- (void) _getValuesFromObject: anObject
{
NSString *cellClassName = NSStringFromClass([[anObject dataCell] class]);
NSArray *list = [[(Gorm *)NSApp classManager] allSubclassesOf: @"NSCell"];
int index = [list indexOfObject: cellClassName];
if(index != NSNotFound && index != -1)
{
[cellTable selectRow: index byExtendingSelection: NO];
[cellTable scrollRowToVisible: index];
}
switch ([[anObject headerCell] alignment])
{
case NSLeftTextAlignment:
@ -262,6 +281,7 @@
[editableSwitch setState: NSOnState];
else
[editableSwitch setState: NSOffState];
}
- (void) _setValuesFromControl: (id) control
@ -317,6 +337,70 @@
[object setResizable:
([resizableSwitch state] == NSOnState)];
}
else if (control == setButton || control == cellTable)
{
int i = [cellTable selectedRow];
id cell = nil;
NSArray *list = [[(Gorm *)NSApp classManager] allSubclassesOf: @"NSCell"];
NSString *className = [list objectAtIndex: i];
BOOL isCustom = [[(Gorm *)NSApp classManager] isCustomClass: className];
Class cls = nil;
if(isCustom)
{
NSLog(@"Setting custom cell.. not working yet...");
}
else
{
cls = NSClassFromString(className);
}
// initialize
cell = [cls new];
[object setDataCell: cell];
[[object tableView] setNeedsDisplay: YES];
RELEASE(cell);
}
else if (control == defaultButton)
{
[object setDataCell: [[NSTextFieldCell alloc] init]];
[[object tableView] setNeedsDisplay: YES];
[self setObject: [self object]]; // reset...
}
}
// data source
- (int) numberOfRowsInTableView: (NSTableView *)tv
{
NSArray *list = [[(Gorm *)NSApp classManager] allSubclassesOf: @"NSCell"];
return [list count];
}
- (id) tableView: (NSTableView *)tv
objectValueForTableColumn: (NSTableColumn *)tc
row: (int)rowIndex
{
NSArray *list = [[(Gorm *)NSApp classManager] allSubclassesOf: @"NSCell"];
id value = nil;
if([list count] > 0)
{
value = [list objectAtIndex: rowIndex];
}
return value;
}
// delegate
- (BOOL) tableView: (NSTableView *)tableView
shouldEditTableColumn: (NSTableColumn *)aTableColumn
row: (int)rowIndex
{
return NO;
}
- (BOOL) tableView: (NSTableView *)tv
shouldSelectRow: (int)rowIndex
{
return YES;
}
@end