Adding NSTabView inspector submitted by Fabien Vallon

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@15185 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2002-11-30 00:49:55 +00:00
parent 941ef0858c
commit 1649aa007e
7 changed files with 422 additions and 12 deletions

View file

@ -1,3 +1,11 @@
2002-11-29 Gregory John Casamento <greg_casamento@yahoo.com>
* NOTE: Added a patch submitted by Fabien Vallon to
add tab view inspector. Thanks.
* Palettes/3Containers/GormTabViewInspector.gorm: added.
* Palettes/3Containers/inspectors.m: Patched.
* Palettes/3Containers/GNUmakefile: Patched.
2002-11-24 Gregory John Casamento <greg_casamento@yahoo.com>
* NOTE: Added a patch submitted by Fabien Vallon to
@ -5,7 +13,6 @@
* Palettes/4Data/GormNSComboBoxInspector.gorm: added.
* Palettes/4Data/inspectors.m: Patched.
2002-11-24 Gregory John Casamento <greg_casamento@yahoo.com>
* Gorm.m: -[GormObjectProxy classInspectorClassName]

View file

@ -117,6 +117,7 @@
- (BOOL) removeConnectionsWithLabel: (NSString *)name
forClassNamed: (NSString *)className
isAction: (BOOL)action;
- (BOOL) removeConnectionsForClassNamed: (NSString *)name;
@end
#endif

View file

@ -1633,6 +1633,7 @@ static NSImage *classesImage = nil;
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSMutableDictionary *nt;
NSMutableDictionary *cc;
NSData *data;
NSUnarchiver *u;
GSNibContainer *c;
@ -1709,8 +1710,14 @@ static NSImage *classesImage = nil;
}
// retrieve the custom class data...
[classManager setCustomClassMap: [[c nameTable] objectForKey: @"GSCustomClassMap"]];
cc = [[c nameTable] objectForKey: @"GSCustomClassMap"];
if(cc == nil)
{
cc = [NSMutableDictionary dictionary]; // create an empty one.
}
[classManager setCustomClassMap: cc];
// convert from old file format...
if(isDir == NO)
{
if (![classManager loadCustomClasses: [[aFile stringByDeletingPathExtension]
@ -2788,6 +2795,44 @@ static NSImage *classesImage = nil;
return removed;
}
- (BOOL) removeConnectionsForClassNamed: (NSString *)className
{
NSEnumerator *en = [connections objectEnumerator];
id<IBConnectors> c = nil;
BOOL removed = YES;
int retval = -1;
NSString *title = [NSString stringWithFormat: @"Modifying Class"];
NSString *msg = [NSString stringWithFormat:
@"This will break all connections to actions/outlets to instances of class '%@'. Continue?",
className];
// ask the user if he/she wants to continue...
retval = NSRunAlertPanel(title,msg,@"OK",@"Cancel",nil,nil);
if(retval == NSAlertDefaultReturn)
{
removed = YES;
}
else
{
removed = NO;
}
// remove all.
while((c = [en nextObject]) != nil)
{
// check both...
if([[[c source] className] isEqualToString: className] ||
[[[c destination] className] isEqualToString: className])
{
[self removeConnector: c];
}
}
// done...
NSDebugLog(@"Removed references to actions/outlets for objects of %@", className);
return removed;
}
// --- NSOutlineView dataSource ---
- (id) outlineView: (NSOutlineView *)anOutlineView
objectValueForTableColumn: (NSTableColumn *)aTableColumn
@ -2886,8 +2931,13 @@ objectValueForTableColumn: (NSTableColumn *)aTableColumn
{
if(![anObject isEqualToString: @""])
{
[classManager renameClassNamed: item newName: anObject];
[gov reloadData];
BOOL removed = [self removeConnectionsForClassNamed: item];
if(removed)
{
[classManager renameClassNamed: item newName: anObject];
[self detachObject: [self objectForName: item]];
[gov reloadData];
}
}
}
[gov setNeedsDisplay: YES];

View file

@ -45,7 +45,8 @@ PALETTE_NAME = 3Containers
GormBrowserInspector.gorm \
GormTableViewInspector.gorm \
GormTableColumnInspector.gorm \
GormTableColumnSizeInspector.gorm
GormTableColumnSizeInspector.gorm \
GormTabViewInspector.gorm
-include GNUmakefile.preamble

View file

@ -0,0 +1,154 @@
{
FirstResponder = {
Actions = (
"activateContextHelpMode:",
"alignCenter:",
"alignJustified:",
"alignLeft:",
"alignRight:",
"arrangeInFront:",
"cancel:",
"capitalizeWord:",
"changeColor:",
"changeFont:",
"checkSpelling:",
"close:",
"complete:",
"copy:",
"copyFont:",
"copyRuler:",
"cut:",
"delete:",
"deleteBackward:",
"deleteForward:",
"deleteToBeginningOfLine:",
"deleteToBeginningOfParagraph:",
"deleteToEndOfLine:",
"deleteToEndOfParagraph:",
"deleteToMark:",
"deleteWordBackward:",
"deleteWordForward:",
"deminiaturize:",
"deselectAll:",
"fax:",
"hide:",
"hideOtherApplications:",
"indent:",
"loosenKerning:",
"lowerBaseline:",
"lowercaseWord:",
"makeKeyAndOrderFront:",
"miniaturize:",
"miniaturizeAll:",
"moveBackward:",
"moveBackwardAndModifySelection:",
"moveDown:",
"moveDownAndModifySelection:",
"moveForward:",
"moveForwardAndModifySelection:",
"moveLeft:",
"moveRight:",
"moveToBeginningOfDocument:",
"moveToBeginningOfLine:",
"moveToBeginningOfParagraph:",
"moveToEndOfDocument:",
"moveToEndOfLine:",
"moveToEndOfParagraph:",
"moveUp:",
"moveUpAndModifySelection:",
"moveWordBackward:",
"moveWordBackwardAndModifySelection:",
"moveWordForward:",
"moveWordForwardAndModifySelection:",
"newDocument:",
"ok:",
"openDocument:",
"orderBack:",
"orderFront:",
"orderFrontColorPanel:",
"orderFrontDataLinkPanel:",
"orderFrontHelpPanel:",
"orderFrontStandardAboutPanel:",
"orderFrontStandardInfoPanel:",
"orderOut:",
"pageDown:",
"pageUp:",
"paste:",
"pasteAsPlainText:",
"pasteAsRichText:",
"pasteFont:",
"pasteRuler:",
"performClose:",
"performMiniaturize:",
"performZoom:",
"print:",
"raiseBaseline:",
"revertDocumentToSaved:",
"runPageLayout:",
"runToolbarCustomizationPalette:",
"saveAllDocuments:",
"saveDocument:",
"saveDocumentAs:",
"saveDocumentTo:",
"scrollLineDown:",
"scrollLineUp:",
"scrollPageDown:",
"scrollPageUp:",
"scrollViaScroller:",
"selectAll:",
"selectLine:",
"selectNextKeyView:",
"selectParagraph:",
"selectPreviousKeyView:",
"selectText:",
"selectText:",
"selectToMark:",
"selectWord:",
"showContextHelp:",
"showGuessPanel:",
"showHelp:",
"showWindow:",
"stop:",
"subscript:",
"superscript:",
"swapWithMark:",
"takeDoubleValueFrom:",
"takeFloatValueFrom:",
"takeIntValueFrom:",
"takeObjectValueFrom:",
"takeStringValueFrom:",
"terminate:",
"tightenKerning:",
"toggle:",
"toggleContinuousSpellChecking:",
"toggleRuler:",
"toggleToolbarShown:",
"toggleTraditionalCharacterShape:",
"transpose:",
"transposeWords:",
"turnOffKerning:",
"turnOffLigatures:",
"underline:",
"unhide:",
"unhideAllApplications:",
"unscript:",
"uppercaseWord:",
"useAllLigatures:",
"useStandardKerning:",
"useStandardLigatures:",
"yank:",
"zoom:"
);
Super = NSObject;
};
GormTabViewInspector = {
Actions = (
);
Outlets = (
typeMatrix,
numberOfItemsField,
allowtruncate
);
Super = IBInspector;
};
}

View file

@ -27,7 +27,7 @@
#include "../../GormPrivate.h"
#import "GormNSTableView.h"
#import "../../GormInternalViewEditor.h"
/* This macro makes sure that the string contains a value, even if @"" */
#define VSTR(str) ({id _str = str; (_str) ? _str : @"";})
@ -496,11 +496,11 @@
{
[verticalScrollerSwitch setEnabled: YES];
[verticalScrollerSwitch setState:
([scrollView hasVerticalScroller]) ? NSOnState : NSOffState];
([scrollView hasVerticalScroller]) ? NSOnState : NSOffState];
[horizontalScrollerSwitch setEnabled: YES];
[horizontalScrollerSwitch setState:
([scrollView hasHorizontalScroller]) ? NSOnState : NSOffState];
([scrollView hasHorizontalScroller]) ? NSOnState : NSOffState];
[borderMatrix setEnabled: YES];
[borderMatrix selectCellWithTag: [scrollView borderType]];
@ -582,3 +582,200 @@
@implementation GormScrollViewAttributesInspector
@end
/*----------------------------------------------------------------------------
* NSTabView (possibly embedded in a Scroll view)
*/
static NSString *ITEM=@"item";
@implementation NSTabView (IBInspectorClassNames)
- (NSString*) inspectorClassName
{
return @"GormTabViewInspector";
}
- (NSString*) sizeInspectorClassName
{
// return @"GormTableViewSizeInspector";
}
@end
@interface GormTabViewInspector : IBInspector
{
id typeMatrix;
int numberOfDisplayItem;
id allowtruncate;
id numberOfItemsField;
}
- (void) _getValuesFromObject: (id)anObject;
- (void) _setValuesFromControl: (id)anObject;
@end
@implementation GormTabViewInspector
- (void) _setValuesFromControl: (id)control
{
if (control == typeMatrix)
{
[object setTabViewType:[[control selectedCell] tag]];
}
if (control == allowtruncate)
{
BOOL flag;
flag = ([allowtruncate state] == NSOnState) ? YES : NO;
[object setAllowsTruncatedLabels:flag];
}
if (control == numberOfItemsField)
{
int newNumber = [[numberOfItemsField stringValue] intValue];
//Can we allow stupid numbers like 66666666 ????????
if (newNumber < 0)
{
[numberOfItemsField setStringValue:[NSString stringWithFormat:@"%i",[object numberOfTabViewItems]]];
return;
}
if ( newNumber > [object numberOfTabViewItems] )
{
int i;
NSTabViewItem *newTabItem;
for (i=([object numberOfTabViewItems]+1);i<=newNumber;i++)
{
NSString *identif = [NSString stringWithFormat:@"%i",i];
newTabItem = [[NSTabViewItem alloc] initWithIdentifier:identif];
[newTabItem setLabel:[ITEM stringByAppendingString:identif]];
[newTabItem setView:[[NSView alloc] init]];
[object addTabViewItem:newTabItem];
}
}
else
{
int i;
for (i=([object numberOfTabViewItems]-1);i>=newNumber;i--)
{
[object removeTabViewItem:[object tabViewItemAtIndex:i]];
}
}
}
// int newNumber = [itemStepper intValue];
// NSTabViewItem *newTabItem;
// if ( newNumber > numberOfDisplayItem )
// {
// NSString *identif = [NSString stringWithFormat:@"%i",newNumber];
// newTabItem = [[NSTabViewItem alloc] initWithIdentifier:identif];
// [newTabItem setLabel:[ITEM stringByAppendingString:identif]];
// [newTabItem setView:[[NSView alloc] init]];
// [object addTabViewItem:newTabItem];
// [displayItemsField setStringValue:identif];
// [labelField setStringValue: [ITEM stringByAppendingString:identif]];
// [identifierField setStringValue:[ITEM stringByAppendingString:identif]];
// numberOfDisplayItem = newNumber;
// }
// if ( newNumber < numberOfDisplayItem )
// {
// NSLog(@"remove");
// }
[object display];
}
- (void) _getValuesFromObject: anObject
{
// BOOL isScrollView;
// id scrollView;
// scrollView = //[[object superview] superview];
// [object enclosingScrollView];
// isScrollView = [ scrollView isKindOfClass: [NSScrollView class]];
// if (anObject != object)
// {
// return;
// }
// [selectionMatrix deselectAllCells];
// if ([anObject gormAllowsMultipleSelection])
// [selectionMatrix selectCellAtRow: 0 column: 0];
// if ([anObject gormAllowsEmptySelection])
// [selectionMatrix selectCellAtRow: 1 column: 0];
// if ([anObject gormAllowsColumnSelection])
// [selectionMatrix selectCellAtRow: 2 column: 0];
// if (isScrollView)
// {
// [verticalScrollerSwitch setEnabled: YES];
// [verticalScrollerSwitch setState:
// ([scrollView hasVerticalScroller]) ? NSOnState : NSOffState];
// [horizontalScrollerSwitch setEnabled: YES];
// [horizontalScrollerSwitch setState:
// ([scrollView hasHorizontalScroller]) ? NSOnState : NSOffState];
// [borderMatrix setEnabled: YES];
// [borderMatrix selectCellWithTag: [scrollView borderType]];
// }
// else
// {
// [verticalScrollerSwitch setEnabled: NO];
// [horizontalScrollerSwitch setEnabled: NO];
// [borderMatrix setEnabled: NO];
// }
// [[rowsHeightForm cellAtIndex: 0] setIntValue: [anObject rowHeight] ];
// [optionMatrix deselectAllCells];
// if ([anObject drawsGrid])
// [optionMatrix selectCellAtRow: 0 column: 0];
// if ([anObject gormAllowsColumnResizing])
// [optionMatrix selectCellAtRow: 1 column: 0];
// if ([anObject gormAllowsColumnReordering])
// [optionMatrix selectCellAtRow: 2 column: 0];
// [[tagField cellAtIndex:0] setIntValue:[anObject tag]];
}
- (id) init
{
if ([super init] == nil)
{
return nil;
}
if ([NSBundle loadNibNamed: @"GormTabViewInspector" owner: self] == NO)
{
NSLog(@"Could not gorm GormTableViewInspector");
return nil;
}
// itemsViewArray=[[NSMutableArray alloc] initWithCapacity:2];
// [itemsViewArray setArray: [NSArray arrayWithObjects:@"plop",@"plip",nil]];
// numberOfDisplayItem = [itemsViewArray count];
// [itemsViewArray retain];
return self;
}
- (void) ok: (id)sender
{
[self _setValuesFromControl: sender];
}
- (void) setObject: (id)anObject
{
[super setObject: anObject];
[self _getValuesFromObject: anObject];
}
@end