More refactoring.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20458 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-12-15 06:51:55 +00:00
parent 84ef527ee2
commit 4bf6880f87
4 changed files with 83 additions and 26 deletions

View file

@ -1,3 +1,13 @@
2004-12-15 01:43 Gregory John Casamento <greg_casamento@yahoo.com>
* GormClassEditor.m: Code from -changeView added to select
contents of a scrollview instead of the scrollview itself
(when appropriate).
* GormDocument.m: Moved code from -changeView: to
GormClassEditor.
* GormPrivate.h: Added methods for changing the selection
in the outline view without setting the inspector.
2004-12-14 21:26 Gregory John Casamento <greg_casamento@yahoo.com>
* GormClassManager.m: -addClassNamed:withSuperClassNamed:

View file

@ -122,15 +122,25 @@ NSString *GormClassPboardType = @"GormClassPboardType";
return className;
}
// class selection...
- (void) selectClass: (NSString *)className
{
[self selectClass: className editClass: YES];
}
// class selection...
- (void) selectClass: (NSString *)className editClass: (BOOL)flag
{
NSString *currentClass = nil;
NSArray *classes;
NSEnumerator *en;
int row = 0;
// abort, if we're editing a class.
if([self isEditing])
{
return;
}
ASSIGN(selectedClass, className);
if(className != nil)
{
if([className isEqual: @"CustomView"] ||
@ -162,21 +172,44 @@ NSString *GormClassPboardType = @"GormClassPboardType";
[self scrollRowToVisible: row];
}
// set the editor...
[document setSelectionFromEditor: (id)self];
if(flag)
{
// set the editor...
ASSIGN(selectedClass, className);
[document setSelectionFromEditor: (id)self];
}
}
- (void) selectClassWithObject: (id)obj
{
NSString *customClass = [classManager customClassForObject: obj];
[self selectClassWithObject: obj editClass: YES];
}
- (void) selectClassWithObject: (id)object editClass: (BOOL)flag
{
id obj = object;
NSString *customClass = nil;
// if it's a scrollview focus on it's contents.
if([obj isKindOfClass: [NSScrollView class]])
{
id newobj = nil;
newobj = [obj documentView];
if(newobj != nil)
{
obj = newobj;
}
}
// check for a custom class.
customClass = [classManager customClassForObject: obj];
if(customClass != nil)
{
[self selectClass: customClass];
[self selectClass: customClass editClass: flag];
}
else if ([obj respondsToSelector: @selector(className)])
{
[self selectClass: [obj className]];
[self selectClass: [obj className] editClass: flag];
}
}
@ -199,6 +232,7 @@ NSString *GormClassPboardType = @"GormClassPboardType";
- (void) editClass
{
int row = [self selectedRow];
if (row >= 0)
{
ASSIGN(selectedClass, [self selectedClassName]);
@ -379,16 +413,19 @@ NSString *GormClassPboardType = @"GormClassPboardType";
{
if(selectedClass != nil)
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSMutableDictionary *dict =
[NSMutableDictionary dictionaryWithObjectsAndKeys: [classManager dictionaryForClassNamed: selectedClass],
selectedClass, nil];
id classPlist = [[dict description] propertyList];
if(classPlist != nil)
if([selectedClass isEqual: @"FirstResponder"] == NO)
{
[pb declareTypes: [NSArray arrayWithObject: GormClassPboardType] owner: self];
[pb setPropertyList: classPlist forType: GormClassPboardType];
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSMutableDictionary *dict =
[NSMutableDictionary dictionaryWithObjectsAndKeys: [classManager dictionaryForClassNamed: selectedClass],
selectedClass, nil];
id classPlist = [[dict description] propertyList];
if(classPlist != nil)
{
[pb declareTypes: [NSArray arrayWithObject: GormClassPboardType] owner: self];
[pb setPropertyList: classPlist forType: GormClassPboardType];
}
}
}
}
@ -434,6 +471,22 @@ NSString *GormClassPboardType = @"GormClassPboardType";
}
}
}
/*
- (void) handleNotification: (NSNotification *)notification
{
NSArray *selection = [[(id<IB>)NSApp selectionOwner] selection];
[selectionBox setContentView: classesScrollView];
// if something is selected, in the object view.
// show the equivalent class in the classes view.
if ([selection count] > 0)
{
id obj = [selection objectAtIndex: 0];
[classesView selectClassWithObject: obj];
}
}
*/
@end
@implementation GormClassEditor (NSOutlineViewDataSource)

View file

@ -719,16 +719,6 @@ static NSImage *fileImage = nil;
if ([selection count] > 0)
{
id obj = [selection objectAtIndex: 0];
// if it's a scrollview focus on it's contents.
if([obj isKindOfClass: [NSScrollView class]])
{
id newobj = nil;
newobj = [obj documentView];
if(newobj != nil)
{
obj = newobj;
}
}
[classesView selectClassWithObject: obj];
}
}
@ -2920,6 +2910,8 @@ static NSImage *fileImage = nil;
- (void) setSelectionFromEditor: (id<IBEditors>)anEditor
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// NSArray *selection = [[(id<IB>)NSApp selectionOwner] selection];
NSDebugLog(@"setSelectionFromEditor %@", anEditor);
lastEditor = anEditor;
if ([(NSObject *)anEditor respondsToSelector: @selector(window)])

View file

@ -176,7 +176,9 @@ extern NSString *GormResizeCellNotification;
+ (GormClassEditor*) classEditorForDocument: (GormDocument*)doc;
- (void) setSelectedClassName: (NSString*)cn;
- (NSString *) selectedClassName;
- (void) selectClassWithObject: (id)obj editClass: (BOOL)flag;
- (void) selectClassWithObject: (id)obj;
- (void) selectClass: (NSString *)className editClass: (BOOL)flag;
- (void) selectClass: (NSString *)className;
- (BOOL) currentSelectionIsClass;
- (void) editClass;