Added method which switches to the appropriate editor to accept a drag.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21143 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-04-22 20:02:45 +00:00
parent e2bd7a4fc5
commit 2d0b6fc07e
5 changed files with 53 additions and 11 deletions

View file

@ -1,3 +1,15 @@
2005-04-22 15:57 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormDocument.h: Added new method.
* GormCore/GormDocument.m: Added implementation for
changeToTopLevelEditorAcceptingTypes and changeToViewWithTag:.
* GormCore/GormObjectEditor.m: Added code to call
changeToTopLevelEditorAcceptingTypes: when a given type isn't
accepted by this editor.
* GormCore/GormResourceEditor.m: Added code to call
changeToTopLevelEditorAcceptingTypes: when a given type isn't
accepted by this editor.
2005-04-22 12:38 Gregory John Casamento <greg_casamento@yahoo.com>
* Palettes/0Menus/GormMenuEditor.m: [GormMenuEditor pasteInSelection]

View file

@ -105,6 +105,7 @@
- (void) createResourceManagers;
- (NSArray *) resourceManagers;
- (IBResourceManager *) resourceManagerForPasteboard: (NSPasteboard *)pboard;
- (void) changeToTopLevelEditorAcceptingTypes: (NSArray *)types;
/* Managing classes */
- (GormClassManager*) classManager;

View file

@ -771,13 +771,8 @@ static NSImage *fileImage = nil;
[filePrefsManager setClassVersions];
}
/**
* Change the view in the document window.
*/
- (void) changeView: (id)sender
- (void) changeToViewWithTag: (int)tag
{
int tag = [sender tag];
switch (tag)
{
case 0: // objects
@ -817,6 +812,34 @@ static NSImage *fileImage = nil;
}
}
- (void) changeToTopLevelEditorAcceptingTypes: (NSArray *)types
{
if([objectsView acceptsTypeFromArray: types])
{
[self changeToViewWithTag: 0];
}
else if([imagesView acceptsTypeFromArray: types])
{
[self changeToViewWithTag: 1];
}
else if([soundsView acceptsTypeFromArray: types])
{
[self changeToViewWithTag: 2];
}
else if([classesView acceptsTypeFromArray: types])
{
[self changeToViewWithTag: 3];
}
}
/**
* Change the view in the document window.
*/
- (void) changeView: (id)sender
{
[self changeToViewWithTag: [sender tag]];
}
/**
* The class manager.
*/

View file

@ -117,7 +117,8 @@ static NSMapTable *docMap = 0;
- (BOOL) acceptsTypeFromArray: (NSArray*)types
{
NSArray *resourceTypes = [resourceManager resourcePasteboardTypes];
return ([resourceTypes firstObjectCommonWithArray: types] != nil);
return ([resourceTypes firstObjectCommonWithArray: types] != nil ||
[types containsObject: GormLinkPboardType] == YES);
}
- (void) pasteInSelection
@ -233,6 +234,7 @@ static NSMapTable *docMap = 0;
}
else
{
[(GormDocument *)document changeToTopLevelEditorAcceptingTypes: pbTypes];
dragType = nil;
}

View file

@ -35,7 +35,7 @@ static int handled_mask= NSDragOperationCopy | NSDragOperationGeneric | NSDragOp
- (BOOL) acceptsTypeFromArray: (NSArray*)types
{
return NO;
return [types containsObject: NSFilenamesPboardType];
}
- (NSArray *) fileTypes
@ -58,10 +58,10 @@ static int handled_mask= NSDragOperationCopy | NSDragOperationGeneric | NSDragOp
- (unsigned int) draggingEntered: (id<NSDraggingInfo>)sender
{
NSPasteboard *pb = [sender draggingPasteboard];
NSArray *pbtypes = [pb types];
NSArray *pbTypes = [pb types];
unsigned int mask = [sender draggingSourceOperationMask];
if ((mask & handled_mask) && [pbtypes containsObject: NSFilenamesPboardType])
if ((mask & handled_mask) && [pbTypes containsObject: NSFilenamesPboardType])
{
NSArray *data;
NSEnumerator *en;
@ -90,6 +90,10 @@ static int handled_mask= NSDragOperationCopy | NSDragOperationGeneric | NSDragOp
return NSDragOperationCopy;
}
else
{
[(GormDocument *)document changeToTopLevelEditorAcceptingTypes: pbTypes];
}
return NSDragOperationNone;
}
@ -187,7 +191,7 @@ static int handled_mask= NSDragOperationCopy | NSDragOperationGeneric | NSDragOp
NSButtonCell *proto;
[self registerForDraggedTypes: [NSArray arrayWithObjects:
NSFilenamesPboardType, nil]];
NSFilenamesPboardType, GormLinkPboardType, nil]];
[self setAutosizesCells: NO];
[self setCellSize: NSMakeSize(72,72)];