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> 2004-04-13 20:57 Gregory John Casamento <greg_casamento@yahoo.com>
* Version 0.7.5 * Version 0.7.5

View file

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

View file

@ -451,7 +451,46 @@
else if (control == rowsHeightForm) 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] ]; [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) else if (control == optionMatrix)
@ -516,7 +555,8 @@
} }
[[rowsHeightForm cellAtIndex: 0] setIntValue: [anObject rowHeight] ]; [[rowsHeightForm cellAtIndex: 0] setIntValue: [anObject rowHeight] ];
[[rowsHeightForm cellAtIndex: 1] setIntValue: [anObject numberOfColumns]];
[optionMatrix deselectAllCells]; [optionMatrix deselectAllCells];
if ([anObject drawsGrid]) if ([anObject drawsGrid])
[optionMatrix selectCellAtRow: 0 column: 0]; [optionMatrix selectCellAtRow: 0 column: 0];

View file

@ -18,7 +18,7 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <Foundation/Foundation.h> #include <Foundation/Foundation.h>
@ -112,8 +112,6 @@
tv = [[GormNSTableView alloc] initWithFrame: tv = [[GormNSTableView alloc] initWithFrame:
NSZeroRect]; NSZeroRect];
//[v setDocumentView: tv];
//RELEASE(tv);
tc = [[NSTableColumn alloc] initWithIdentifier: @"column1"]; tc = [[NSTableColumn alloc] initWithIdentifier: @"column1"];
[[tc headerCell] setStringValue: @" "]; [[tc headerCell] setStringValue: @" "];
@ -148,8 +146,6 @@
ov = [[GormNSOutlineView alloc] initWithFrame: ov = [[GormNSOutlineView alloc] initWithFrame:
NSZeroRect]; NSZeroRect];
//[v setDocumentView: ov];
//RELEASE(ov);
tc = [[NSTableColumn alloc] initWithIdentifier: @"classes"]; tc = [[NSTableColumn alloc] initWithIdentifier: @"classes"];
[[tc headerCell] setStringValue: @" "]; [[tc headerCell] setStringValue: @" "];
@ -169,9 +165,20 @@
[tc setEditable: YES]; [tc setEditable: YES];
[ov addTableColumn: tc]; [ov addTableColumn: tc];
RELEASE(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 setDrawsGrid: NO];
[ov setIndentationPerLevel: 10.]; [ov setIndentationPerLevel: 10.];
[ov setIndentationMarkerFollowsCell: YES]; [ov setIndentationMarkerFollowsCell: YES];
[ov expandItem: @"NSObject" expandChildren: YES];
[v setDocumentView: ov]; [v setDocumentView: ov];
RELEASE(ov); RELEASE(ov);