mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 19:51:00 +00:00
Implemented view resource delegate functionality.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21402 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2d1582f27c
commit
b742588aea
11 changed files with 353 additions and 65 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2005-07-03 12:26 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GormBoxEditor.m: Minor cleanup.
|
||||
* GormCore/GormControlEditor.m: Removed unecessary code to
|
||||
handle formatter, since it is now handled generically via the
|
||||
dragging delegate code.
|
||||
* GormCore/GormViewEditor.m: Added code in performDragOperation:
|
||||
and other dragging methods to correctly use the dragging delegate
|
||||
code.
|
||||
* GormCore/NSView+GormExtensions.m: Added implementation
|
||||
of delegate registration methods to NSView here.
|
||||
* GormLib/IBApplicationAdditions.h: Added declaration
|
||||
for documentForObject: to the IBDocuments protocol.
|
||||
* GormLib/IBPalette.h: Changed "document" ivar to paletteDocument.
|
||||
* GormLib/IBPalette.m: Changed "document" ivar to paletteDocument.
|
||||
* Gorm.m: Added implementation of documentForObject:
|
||||
* Palettes/2Controls/main.m: Added methods for
|
||||
IBViewResourceDraggingDelegates to handle images and sounds
|
||||
dragged to controls.
|
||||
* Palettes/4Data/main.m: Added methods for
|
||||
IBViewResourceDraggingDelegates to handle formatters being
|
||||
dragged to controls.
|
||||
|
||||
2005-07-02 16:12 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GormControlEditor.m: Added call to setSelectionFromEditor:
|
||||
|
|
17
Gorm.m
17
Gorm.m
|
@ -1129,6 +1129,23 @@
|
|||
return [[selectionOwner selection] lastObject];
|
||||
}
|
||||
|
||||
- (id<IBDocuments>) documentForObject: (id)object
|
||||
{
|
||||
NSEnumerator *en = [documents objectEnumerator];
|
||||
id doc = nil;
|
||||
id result = nil;
|
||||
|
||||
while((doc = [en nextObject]) != nil)
|
||||
{
|
||||
if([doc containsObject: object])
|
||||
{
|
||||
result = doc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) startConnecting
|
||||
{
|
||||
|
|
|
@ -109,12 +109,9 @@
|
|||
return nil;
|
||||
|
||||
selection = [[NSMutableArray alloc] initWithCapacity: 5];
|
||||
|
||||
|
||||
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects:
|
||||
IBViewPboardType, GormLinkPboardType, IBFormatterPboardType, nil]];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -637,6 +637,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *dragPb;
|
||||
|
@ -728,5 +729,6 @@
|
|||
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
@end
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <InterfaceBuilder/InterfaceBuilder.h>
|
||||
|
||||
#include "GormGenericEditor.h"
|
||||
#include "GormViewEditor.h"
|
||||
|
@ -294,19 +295,9 @@ static BOOL currently_displaying = NO;
|
|||
document = aDocument;
|
||||
|
||||
draggedTypes = [NSMutableArray arrayWithObject: GormLinkPboardType];
|
||||
if ([_editedObject respondsToSelector: @selector(setImage:)])
|
||||
{
|
||||
[draggedTypes addObject: GormImagePboardType];
|
||||
}
|
||||
if ([_editedObject respondsToSelector: @selector(setSound:)])
|
||||
{
|
||||
[draggedTypes addObject: GormSoundPboardType];
|
||||
}
|
||||
if ([_editedObject respondsToSelector: @selector(setFormatter:)])
|
||||
{
|
||||
[draggedTypes addObject: IBFormatterPboardType];
|
||||
}
|
||||
|
||||
|
||||
// in addition to the link, any other types accepted by dragging delegates.
|
||||
[draggedTypes addObjectsFromArray: [NSView acceptedViewResourcePasteboardTypes]];
|
||||
[self registerForDraggedTypes: draggedTypes];
|
||||
|
||||
activated = NO;
|
||||
|
@ -343,7 +334,6 @@ static BOOL currently_displaying = NO;
|
|||
{
|
||||
GormPlacementInfo *gip;
|
||||
gip = [[GormPlacementInfo alloc] init];
|
||||
|
||||
|
||||
gip->resizingIn = view;
|
||||
gip->firstPass = YES;
|
||||
|
@ -384,7 +374,6 @@ static BOOL currently_displaying = NO;
|
|||
int guideSpacing = [userDefaults integerForKey: @"GuideSpacing"];
|
||||
int halfSpacing = guideSpacing / 2;
|
||||
|
||||
// NSLog(@"initializing hints");
|
||||
gpi->lastLeftRect = NSZeroRect;
|
||||
gpi->lastRightRect = NSZeroRect;
|
||||
gpi->lastTopRect = NSZeroRect;
|
||||
|
@ -827,15 +816,12 @@ static BOOL currently_displaying = NO;
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
GormShowFrameWithKnob(gpi->hintFrame, gpi->knob);
|
||||
gpi->oldRect = GormExtBoundsForRect(gpi->hintFrame);
|
||||
gpi->oldRect.origin.x--;
|
||||
gpi->oldRect.origin.y--;
|
||||
gpi->oldRect.size.width += 2;
|
||||
gpi->oldRect.size.height += 2;
|
||||
|
||||
}
|
||||
|
||||
- (void) updateResizingWithFrame: (NSRect) frame
|
||||
|
@ -1226,11 +1212,7 @@ static BOOL currently_displaying = NO;
|
|||
and: _editedObject];
|
||||
return NSDragOperationLink;
|
||||
}
|
||||
else if ([types containsObject: GormImagePboardType] == YES)
|
||||
{
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
else if ([types containsObject: GormSoundPboardType] == YES)
|
||||
else if ([types firstObjectCommonWithArray: [NSView acceptedViewResourcePasteboardTypes]] != nil)
|
||||
{
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
@ -1301,6 +1283,31 @@ static BOOL currently_displaying = NO;
|
|||
}
|
||||
}
|
||||
|
||||
- (id) _selectDelegate: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSEnumerator *en = [[NSView registeredViewResourceDraggingDelegates] objectEnumerator];
|
||||
id delegate = nil;
|
||||
id selectedDelegate = nil;
|
||||
NSPasteboard *pb = [sender draggingPasteboard];
|
||||
NSPoint point = [sender draggingLocation];
|
||||
|
||||
while((delegate = [en nextObject]) != nil)
|
||||
{
|
||||
if([delegate respondsToSelector: @selector(acceptsViewResourceFromPasteboard:forObject:atPoint:)])
|
||||
{
|
||||
if([delegate acceptsViewResourceFromPasteboard: pb
|
||||
forObject: _editedObject
|
||||
atPoint: point])
|
||||
{
|
||||
selectedDelegate = delegate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return selectedDelegate;
|
||||
}
|
||||
|
||||
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *dragPb;
|
||||
|
@ -1312,11 +1319,7 @@ static BOOL currently_displaying = NO;
|
|||
{
|
||||
return YES;
|
||||
}
|
||||
else if ([types containsObject: GormImagePboardType] == YES)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
else if ([types containsObject: GormSoundPboardType] == YES)
|
||||
else if ([types firstObjectCommonWithArray: [NSView acceptedViewResourcePasteboardTypes]] != nil)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
@ -1330,7 +1333,9 @@ static BOOL currently_displaying = NO;
|
|||
{
|
||||
NSPasteboard *dragPb;
|
||||
NSArray *types;
|
||||
|
||||
id delegate = nil;
|
||||
NSPoint point = [sender draggingLocation];
|
||||
|
||||
dragPb = [sender draggingPasteboard];
|
||||
types = [dragPb types];
|
||||
|
||||
|
@ -1340,30 +1345,31 @@ static BOOL currently_displaying = NO;
|
|||
and: _editedObject];
|
||||
[NSApp startConnecting];
|
||||
}
|
||||
else if ([types containsObject: GormImagePboardType] == YES)
|
||||
else if ((delegate = [self _selectDelegate: sender]) != nil)
|
||||
{
|
||||
NSString *name = [dragPb stringForType: GormImagePboardType];
|
||||
if([(id)_editedObject respondsToSelector: @selector(setImage:)])
|
||||
if([delegate respondsToSelector: @selector(shouldDrawConnectionFrame)])
|
||||
{
|
||||
NSImage *image = [NSImage imageNamed: name];
|
||||
// [image setArchiveByName: NO];
|
||||
[(id)_editedObject setImage: AUTORELEASE([image copy])];
|
||||
[document setSelectionFromEditor: self];
|
||||
if([delegate shouldDrawConnectionFrame])
|
||||
{
|
||||
[NSApp displayConnectionBetween: [NSApp connectSource]
|
||||
and: _editedObject];
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
else if ([types containsObject: GormSoundPboardType] == YES)
|
||||
{
|
||||
NSString *name;
|
||||
name = [dragPb stringForType: GormSoundPboardType];
|
||||
if([(id)_editedObject respondsToSelector: @selector(setSound:)])
|
||||
|
||||
if([delegate respondsToSelector: @selector(depositViewResourceFromPasteboard:onObject:atPoint:)])
|
||||
{
|
||||
NSSound *sound = [NSSound soundNamed: name];
|
||||
[(id)_editedObject setSound: AUTORELEASE([sound copy])];
|
||||
[delegate depositViewResourceFromPasteboard: dragPb
|
||||
onObject: _editedObject
|
||||
atPoint: point];
|
||||
|
||||
// refresh the selection...
|
||||
[document setSelectionFromEditor: self];
|
||||
|
||||
// return success.
|
||||
return YES;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,14 @@
|
|||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSEnumerator.h>
|
||||
#include "NSView+GormExtensions.h"
|
||||
#include <InterfaceBuilder/IBViewResourceDragging.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSEnumerator.h>
|
||||
|
||||
@implementation NSView (GormExtensions)
|
||||
/**
|
||||
* All superviews of this view
|
||||
*/
|
||||
- (NSArray *) superviews
|
||||
{
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
|
@ -41,6 +47,9 @@
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a superview of a give class.
|
||||
*/
|
||||
- (BOOL) hasSuperviewKindOfClass: (Class)cls
|
||||
{
|
||||
NSEnumerator *en = [[self superviews] objectEnumerator];
|
||||
|
@ -56,3 +65,64 @@
|
|||
return result;
|
||||
}
|
||||
@end
|
||||
|
||||
static NSMutableArray *_registeredViewResourceDraggingDelegates = nil;
|
||||
|
||||
@implementation NSView (IBViewResourceDraggingDelegates)
|
||||
|
||||
/**
|
||||
* Types accepted by the view.
|
||||
*/
|
||||
+ (NSArray *) acceptedViewResourcePasteboardTypes
|
||||
{
|
||||
NSMutableArray *result = nil;
|
||||
if([_registeredViewResourceDraggingDelegates count] > 0)
|
||||
{
|
||||
NSEnumerator *en = [_registeredViewResourceDraggingDelegates objectEnumerator];
|
||||
id delegate = nil;
|
||||
result = [NSMutableArray array];
|
||||
|
||||
while((delegate = [en nextObject]) != nil)
|
||||
{
|
||||
if([delegate respondsToSelector: @selector(viewResourcePasteboardTypes)])
|
||||
{
|
||||
[result addObjectsFromArray: [delegate viewResourcePasteboardTypes]];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of registered delegates.
|
||||
*/
|
||||
+ (NSArray *) registeredViewResourceDraggingDelegates
|
||||
{
|
||||
return _registeredViewResourceDraggingDelegates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a delegate.
|
||||
*/
|
||||
+ (void) registerViewResourceDraggingDelegate: (id<IBViewResourceDraggingDelegates>)delegate
|
||||
{
|
||||
if(_registeredViewResourceDraggingDelegates == nil)
|
||||
{
|
||||
_registeredViewResourceDraggingDelegates = [[NSMutableArray alloc] init];
|
||||
}
|
||||
|
||||
[_registeredViewResourceDraggingDelegates addObject: delegate];
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a previously registered delegate.
|
||||
*/
|
||||
+ (void) unregisterViewResourceDraggingDelegate: (id<IBViewResourceDraggingDelegates>)delegate
|
||||
{
|
||||
if(_registeredViewResourceDraggingDelegates != nil)
|
||||
{
|
||||
[_registeredViewResourceDraggingDelegates removeObject: delegate];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -55,6 +55,11 @@ IB_EXTERN NSString *IBDidEndTestingInterfaceNotification;
|
|||
* owner.
|
||||
*/
|
||||
- (id) selectedObject;
|
||||
|
||||
/**
|
||||
* Returns the document which contains this object.
|
||||
*/
|
||||
- (id<IBDocuments>) documentForObject: (id)object;
|
||||
@end
|
||||
|
||||
@interface NSApplication (GormSpecific)
|
||||
|
|
|
@ -62,7 +62,7 @@ IB_EXTERN NSString *GormLinkPboardType;
|
|||
{
|
||||
NSWindow *originalWindow;
|
||||
NSImage *icon;
|
||||
id<IBDocuments> document;
|
||||
id<IBDocuments> paletteDocument;
|
||||
}
|
||||
/*
|
||||
* For internal use only - these class methods return the information
|
||||
|
|
|
@ -98,7 +98,7 @@ static NSMapTable *viewToType = 0;
|
|||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
RELEASE(icon);
|
||||
RELEASE(document);
|
||||
RELEASE(paletteDocument);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ static NSMapTable *viewToType = 0;
|
|||
}
|
||||
}
|
||||
|
||||
document = [[IBPaletteDocument alloc] init];
|
||||
paletteDocument = [[IBPaletteDocument alloc] init];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ static NSMapTable *viewToType = 0;
|
|||
|
||||
- (id<IBDocuments>) paletteDocument
|
||||
{
|
||||
return document;
|
||||
return paletteDocument;
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -24,16 +24,38 @@
|
|||
*/
|
||||
|
||||
#include <InterfaceBuilder/IBPalette.h>
|
||||
#include <InterfaceBuilder/IBViewResourceDragging.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSPopUpButton.h>
|
||||
#include <AppKit/NSPasteboard.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSSound.h>
|
||||
|
||||
@class GormNSPopUpButton;
|
||||
|
||||
@interface ControlsPalette: IBPalette
|
||||
@interface ControlsPalette: IBPalette <IBViewResourceDraggingDelegates>
|
||||
@end
|
||||
|
||||
|
||||
@implementation ControlsPalette
|
||||
@implementation ControlsPalette
|
||||
- (id) init
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
// Make ourselves a delegate, so that when the sound/image is dragged in,
|
||||
// this code is called...
|
||||
[NSView registerViewResourceDraggingDelegate: self];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[NSView unregisterViewResourceDraggingDelegate: self];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) finishInstantiate
|
||||
{
|
||||
NSView *contents;
|
||||
|
@ -47,4 +69,64 @@
|
|||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask if the view accepts the object.
|
||||
*/
|
||||
- (BOOL) acceptsViewResourceFromPasteboard: (NSPasteboard *)pb
|
||||
forObject: (id)obj
|
||||
atPoint: (NSPoint)p
|
||||
{
|
||||
NSArray *types = [pb types];
|
||||
return (([obj respondsToSelector: @selector(setSound:)] ||
|
||||
[obj respondsToSelector: @selector(setImage:)]) &&
|
||||
([types containsObject: GormImagePboardType] ||
|
||||
[types containsObject: GormSoundPboardType]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the action of depositing the object.
|
||||
*/
|
||||
- (void) depositViewResourceFromPasteboard: (NSPasteboard *)pb
|
||||
onObject: (id)obj
|
||||
atPoint: (NSPoint)p
|
||||
{
|
||||
NSArray *types = [pb types];
|
||||
if ([types containsObject: GormImagePboardType] == YES)
|
||||
{
|
||||
NSString *name = [pb stringForType: GormImagePboardType];
|
||||
if([(id)obj respondsToSelector: @selector(setImage:)])
|
||||
{
|
||||
NSImage *image = [NSImage imageNamed: name];
|
||||
[(id)obj setImage: AUTORELEASE([image copy])];
|
||||
}
|
||||
}
|
||||
else if ([types containsObject: GormSoundPboardType] == YES)
|
||||
{
|
||||
NSString *name;
|
||||
name = [pb stringForType: GormSoundPboardType];
|
||||
if([(id)obj respondsToSelector: @selector(setSound:)])
|
||||
{
|
||||
NSSound *sound = [NSSound soundNamed: name];
|
||||
[(id)obj setSound: AUTORELEASE([sound copy])];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we draw the connection frame when the resource is
|
||||
* dragged in?
|
||||
*/
|
||||
- (BOOL) shouldDrawConnectionFrame
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Types of resources accepted by this view.
|
||||
*/
|
||||
- (NSArray *)viewResourcePasteboardTypes
|
||||
{
|
||||
return [NSArray arrayWithObjects: GormImagePboardType, GormSoundPboardType, nil];
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSClipView.h>
|
||||
#include <InterfaceBuilder/IBPalette.h>
|
||||
#include <InterfaceBuilder/IBViewResourceDragging.h>
|
||||
#include <GormCore/GormPrivate.h>
|
||||
|
||||
/* -----------------------------------------------------------
|
||||
|
@ -191,13 +192,38 @@ int defaultDateFormatIndex = 3;
|
|||
* The Data Palette (Scroll Text View, formatters, Combo box,...)
|
||||
*
|
||||
* -----------------------------------------------------------*/
|
||||
@interface DataPalette: IBPalette
|
||||
{
|
||||
}
|
||||
@interface DataPalette: IBPalette <IBViewResourceDraggingDelegates>
|
||||
@end
|
||||
|
||||
@implementation DataPalette
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
// Make ourselves a delegate, so that when the formatter is dragged in,
|
||||
// this code is called...
|
||||
[NSView registerViewResourceDraggingDelegate: self];
|
||||
|
||||
// subscribe to the notification...
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(willInspectObject:)
|
||||
name: IBWillInspectObjectNotification
|
||||
object: nil];
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[NSView unregisterViewResourceDraggingDelegate: self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) finishInstantiate
|
||||
{
|
||||
|
||||
|
@ -301,13 +327,6 @@ int defaultDateFormatIndex = 3;
|
|||
v = [[NSComboBox alloc] initWithFrame: NSMakeRect(143, 22, 96, 21)];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
// subscribe to the notification...
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(willInspectObject:)
|
||||
name: IBWillInspectObjectNotification
|
||||
object: nil];
|
||||
}
|
||||
|
||||
- (void) willInspectObject: (NSNotification *)notification
|
||||
|
@ -332,4 +351,71 @@ int defaultDateFormatIndex = 3;
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// view resource dragging delegate...
|
||||
|
||||
/**
|
||||
* Ask if the view accepts the object.
|
||||
*/
|
||||
- (BOOL) acceptsViewResourceFromPasteboard: (NSPasteboard *)pb
|
||||
forObject: (id)obj
|
||||
atPoint: (NSPoint)p
|
||||
{
|
||||
return ([obj respondsToSelector: @selector(setFormatter:)] &&
|
||||
[[pb types] containsObject: IBFormatterPboardType]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the action of depositing the object.
|
||||
*/
|
||||
- (void) depositViewResourceFromPasteboard: (NSPasteboard *)pb
|
||||
onObject: (id)obj
|
||||
atPoint: (NSPoint)p
|
||||
{
|
||||
NSData *data = [pb dataForType: IBFormatterPboardType];
|
||||
id array = [NSUnarchiver unarchiveObjectWithData: data];
|
||||
|
||||
if(array != nil)
|
||||
{
|
||||
if([array count] > 0)
|
||||
{
|
||||
id <IBDocuments> document = [(id<IB>)NSApp documentForObject: obj];
|
||||
id formatter = [array objectAtIndex: 0];
|
||||
if([obj respondsToSelector: @selector(setFormatter:)])
|
||||
{
|
||||
[obj setFormatter: formatter];
|
||||
if ([formatter isMemberOfClass: [NSNumberFormatter class]])
|
||||
{
|
||||
id fieldValue = [NSNumber numberWithFloat: 1.123456789];
|
||||
[obj setStringValue: [fieldValue stringValue]];
|
||||
[obj setObjectValue: fieldValue];
|
||||
}
|
||||
else if ([formatter isMemberOfClass: [NSDateFormatter class]])
|
||||
{
|
||||
id fieldValue = [NSDate date];
|
||||
[obj setStringValue: [fieldValue description]];
|
||||
[obj setObjectValue: fieldValue];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we draw the connection frame when the resource is
|
||||
* dragged in?
|
||||
*/
|
||||
- (BOOL) shouldDrawConnectionFrame
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Types of resources accepted by this view.
|
||||
*/
|
||||
- (NSArray *)viewResourcePasteboardTypes
|
||||
{
|
||||
return [NSArray arrayWithObject: IBFormatterPboardType];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue