Adding code to allow expansion or deletion of columns from the table in the inspector.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19138 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-04-17 15:04:26 +00:00
parent 6e42574be2
commit 0c7061e1a9
5 changed files with 81 additions and 96 deletions

View file

@ -1,3 +1,19 @@
2004-04-17 10:58 Gregory John Casamento <greg_casamento@yahoo.com>
* Palettes/3Containers/GormNSOutlineView.m: Changed some of
the default data source's elements to be closer to the actual
class hierarchy.
* Palettes/3Containers/inspectors.m: Added code to the
GormTableViewInspector to add or delete columns based on the
new field which specifies the number of columns in the
table/outline.
* Palettes/3Containers/main.m: removed some old code and
added code to expand the outline view so it looks better
in the palette.
* Palettes/3Containers/GormNSTableViewInspector.gorm: added
"#Columns" field to allow the user to modify the columns in the
table without cutting/pasting.
2004-04-13 20:57 Gregory John Casamento <greg_casamento@yahoo.com>
* Version 0.7.5

View file

@ -60,33 +60,27 @@
return @"NSApplication";
break;
case 1:
return @"NSPanel";
return @"NSTableColumn";
break;
case 2:
return @"NSWindow";
return @"NSStatusBar";
break;
case 3:
return @"NSOutlineView";
return @"NSResponder";
break;
default:
break;
}
}
if([item isEqual: @"NSPanel"])
if([item isEqual: @"NSResponder"])
{
switch(index)
{
case 0:
return @"class1";
return @"NSWindow";
break;
case 1:
return @"class2";
break;
case 2:
return @"class3";
break;
case 3:
return @"class4";
return @"NSView";
break;
default:
break;
@ -107,7 +101,7 @@
{
if([item isEqual: @"NSObject"])
return YES;
if([item isEqual: @"NSPanel"])
if([item isEqual: @"NSResponder"])
return YES;
return NO;
@ -122,8 +116,8 @@
if([item isEqual: @"NSObject"])
return 4;
else
if([item isEqual: @"NSPanel"])
return 4;
if([item isEqual: @"NSResponder"])
return 2;
return 0;
}
@ -142,15 +136,15 @@
else
if([[tableColumn identifier] isEqual: @"outlets"])
{
value = @"1";
value = @"0";
}
else
if([[tableColumn identifier] isEqual: @"actions"])
{
value = @"2";
value = @"0";
}
}
if([item isEqual: @"NSApplication"])
else
{
if([[tableColumn identifier] isEqual: @"classes"])
{
@ -167,78 +161,6 @@
value = @"3";
}
}
if([item isEqual: @"NSPanel"])
{
if([[tableColumn identifier] isEqual: @"classes"])
{
value = @"NSPanel";
}
else
if([[tableColumn identifier] isEqual: @"outlets"])
{
value = @"2";
}
else
if([[tableColumn identifier] isEqual: @"actions"])
{
value = @"3";
}
}
if([item isEqual: @"NSWindow"])
{
if([[tableColumn identifier] isEqual: @"classes"])
{
value = @"NSWindow";
}
else
if([[tableColumn identifier] isEqual: @"outlets"])
{
value = @"3";
}
else
if([[tableColumn identifier] isEqual: @"actions"])
{
value = @"5";
}
}
if([item isEqual: @"NSOutlineView"])
{
if([[tableColumn identifier] isEqual: @"classes"])
{
value = @"NSOutlineView";
}
else
if([[tableColumn identifier] isEqual: @"outlets"])
{
value = @"4";
}
else
if([[tableColumn identifier] isEqual: @"actions"])
{
value = @"6";
}
}
if([item isEqual: @"class1"] ||
[item isEqual: @"class2"] ||
[item isEqual: @"class3"] ||
[item isEqual: @"class4"])
{
if([[tableColumn identifier] isEqual: @"classes"])
{
value = item;
}
else
if([[tableColumn identifier] isEqual: @"outlets"])
{
value = @"2";
}
else
if([[tableColumn identifier] isEqual: @"actions"])
{
value = @"3";
}
}
return value;
}

View file

@ -451,7 +451,46 @@
else if (control == rowsHeightForm)
{
int numCols = [object numberOfColumns];
int newNumCols = [[control cellAtIndex: 1] intValue];
// add/delete columns based on number in #columns field...
[object setRowHeight: [[control cellAtIndex: 0] intValue] ];
if(newNumCols > 0)
{
if(numCols < newNumCols)
{
int colsToAdd = newNumCols - numCols;
int i = 0;
// Add columns from the last to the target number...
for(i = 0; i < colsToAdd; i++)
{
NSString *identifier = [NSString stringWithFormat: @"TableColumn%d",(numCols + i + 1)];
NSTableColumn *tc = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: identifier]);
[tc setWidth: 50];
[tc setMinWidth: 20];
[tc setResizable: YES];
[tc setEditable: YES];
[object addTableColumn: tc];
}
}
else if(numCols > newNumCols)
{
int colsToDelete = numCols - newNumCols;
int i = 0;
NSArray *columns = [object tableColumns];
// remove columns...
for(i = 0; i < colsToDelete; i++)
{
NSTableColumn *tc = [columns objectAtIndex: (i + newNumCols)];
[object removeTableColumn: tc];
}
}
}
// recompute column sizes..
[object sizeToFit];
[object tile];
}
else if (control == optionMatrix)
@ -516,6 +555,7 @@
}
[[rowsHeightForm cellAtIndex: 0] setIntValue: [anObject rowHeight] ];
[[rowsHeightForm cellAtIndex: 1] setIntValue: [anObject numberOfColumns]];
[optionMatrix deselectAllCells];
if ([anObject drawsGrid])

View file

@ -112,8 +112,6 @@
tv = [[GormNSTableView alloc] initWithFrame:
NSZeroRect];
//[v setDocumentView: tv];
//RELEASE(tv);
tc = [[NSTableColumn alloc] initWithIdentifier: @"column1"];
[[tc headerCell] setStringValue: @" "];
@ -148,8 +146,6 @@
ov = [[GormNSOutlineView alloc] initWithFrame:
NSZeroRect];
//[v setDocumentView: ov];
//RELEASE(ov);
tc = [[NSTableColumn alloc] initWithIdentifier: @"classes"];
[[tc headerCell] setStringValue: @" "];
@ -169,9 +165,20 @@
[tc setEditable: YES];
[ov addTableColumn: tc];
RELEASE(tc);
tc = [[NSTableColumn alloc] initWithIdentifier: @"actions"];
[[tc headerCell] setStringValue: @" "];
[tc setWidth: ceil(contentSize.width/2)];
[tc setMinWidth: 20];
[tc setResizable: YES];
[tc setEditable: YES];
[ov addTableColumn: tc];
RELEASE(tc);
[ov setDrawsGrid: NO];
[ov setIndentationPerLevel: 10.];
[ov setIndentationMarkerFollowsCell: YES];
[ov expandItem: @"NSObject" expandChildren: YES];
[v setDocumentView: ov];
RELEASE(ov);