Changes to make the inspectors for formatters as well as drag and drop of formatter objects into controls work properly.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20230 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-10-17 14:43:28 +00:00
parent a7d656b579
commit 3d23397134
8 changed files with 113 additions and 91 deletions

View file

@ -1,3 +1,19 @@
2004-10-17 12:51 Gregory John Casamento <greg_casamento@yahoo.com>
* GormControlEditor.m: Added necessary methods for dragging
of the formatter to the view.
* GormInternalViewEditor.m: Changed initWithObject:inDocument:
so that the view doesn't attempt to accept an IBFormatterPboardType
object from the drag when it shouldn't.
* GormViewEditor.m: Made similar changes here.
* Palettes/4Data/inspectors.m: Removed hard coded implementations
of tables. Added code to blank inspector when the formatter is
detached.
* Palette/4Data/GormNSDateFormatterInspector.gorm: Updated with
new table.
* Palette/4Data/GormNSNumberFormatterInspector.gorm: Updated with
new table.
2004-10-03 12:51 Gregory John Casamento <greg_casamento@yahoo.com>
* GormMatrixEditor.m: Added performDragOperation implementation

View file

@ -23,6 +23,7 @@
*/
#include <AppKit/AppKit.h>
#include <Foundation/NSArchiver.h>
#include "GormPrivate.h"
@ -635,5 +636,84 @@
[super mouseDown: theEvent];
}
}
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
{
NSPasteboard *dragPb;
NSArray *types;
unsigned result = NSDragOperationNone;
dragPb = [sender draggingPasteboard];
types = [dragPb types];
if ([types containsObject: IBFormatterPboardType] == YES)
{
result = NSDragOperationCopy;
}
return result;
}
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
{
NSPasteboard *dragPb;
NSArray *types;
BOOL result = NO;
dragPb = [sender draggingPasteboard];
types = [dragPb types];
if ([types containsObject: IBFormatterPboardType] == YES)
{
NSData *data = [dragPb dataForType: IBFormatterPboardType];
id array = RETAIN([NSUnarchiver unarchiveObjectWithData: data]);
if(array != nil)
{
if([array count] > 0)
{
id object = [array objectAtIndex: 0];
if([_editedObject respondsToSelector: @selector(setFormatter:)])
{
id fieldValue = nil;
[_editedObject setFormatter: object];
if ([object isMemberOfClass: [NSNumberFormatter class]])
{
fieldValue = [NSNumber numberWithFloat: 1.123456789];
[_editedObject setStringValue: [fieldValue stringValue]];
[_editedObject setObjectValue: fieldValue];
}
else if ([object isMemberOfClass: [NSDateFormatter class]])
{
fieldValue = [NSDate date];
[_editedObject setStringValue: [fieldValue description]];
[_editedObject setObjectValue: fieldValue];
}
result = YES;
}
}
}
}
return result;
}
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
{
NSPasteboard *dragPb;
NSArray *types;
BOOL result = NO;
dragPb = [sender draggingPasteboard];
types = [dragPb types];
if ([types containsObject: IBFormatterPboardType] == YES)
{
result = YES;
}
return result;
}
@end

View file

@ -220,6 +220,16 @@ static NSImage *horizontalImage;
- (id) initWithObject: (id)anObject
inDocument: (id<IBDocuments>)aDocument
{
NSMutableArray *types =
[NSMutableArray arrayWithObjects: IBViewPboardType,
GormLinkPboardType, nil];
// if the object can take a formatter, add it to the list.
if([anObject respondsToSelector: @selector(setFormatter:)])
{
[types addObject: IBFormatterPboardType];
}
opened = NO;
openedSubeditor = nil;
@ -230,8 +240,7 @@ static NSImage *horizontalImage;
selection = [[NSMutableArray alloc] initWithCapacity: 5];
[self registerForDraggedTypes: [NSArray arrayWithObjects:
IBViewPboardType, GormLinkPboardType, IBFormatterPboardType, nil]];
IBViewPboardType, GormLinkPboardType, IBFormatterPboardType, nil]];
if (horizontalImage == nil)
{

View file

@ -308,6 +308,10 @@ static BOOL currently_displaying = NO;
{
[draggedTypes addObject: GormSoundPboardType];
}
if ([_editedObject respondsToSelector: @selector(setFormatter:)])
{
[draggedTypes addObject: IBFormatterPboardType];
}
[self registerForDraggedTypes: draggedTypes];

View file

@ -619,9 +619,7 @@ extern NSArray *predefinedDateFormats, *predefinedNumberFormats;
if (control == detachButton)
{
[[object cell] setFormatter: nil];
// FIXME: Should empty the inspector window or show
// the default inspector. How do we do that?
//[ (GormInspectorManager *)[window view] setCurrentInspector: 0] ??
[[(Gorm *)NSApp activeDocument] setSelectionFromEditor: nil];
}
else
{
@ -711,48 +709,6 @@ extern NSArray *predefinedDateFormats, *predefinedNumberFormats;
return nil;
}
// Add format/date table view by hand for now...
{
NSScrollView *v;
NSTableColumn *tc;
NSSize contentSize;
v = [[NSScrollView alloc] initWithFrame: NSMakeRect(5,170,IVW-10,200)];
[v setHasVerticalScroller: YES];
[v setHasHorizontalScroller: NO];
contentSize = [v contentSize];
formatTable = [[NSTableView alloc] initWithFrame:
NSMakeRect(0,0,contentSize.width, contentSize.height)];
[formatTable setDataSource: self];
[formatTable setDelegate: self];
[formatTable setAutoresizesAllColumnsToFit: YES];
[formatTable setAllowsEmptySelection: YES];
[formatTable setAllowsMultipleSelection: NO];
[v setDocumentView: formatTable];
tc = [[NSTableColumn alloc] initWithIdentifier: @"format"];
[[tc headerCell] setStringValue: @"Format"];
[tc setWidth: contentSize.width*4/9];
[tc setResizable: NO];
[tc setEditable: NO];
[formatTable addTableColumn: tc];
RELEASE(tc);
tc = [[NSTableColumn alloc] initWithIdentifier: @"date"];
[[tc headerCell] setStringValue: @"Date"];
[tc setMinWidth: contentSize.width*5/9];
[tc setResizable: NO];
[tc setEditable: NO];
[formatTable addTableColumn: tc];
RELEASE(tc);
[v setDocumentView: formatTable];
[[window contentView] addSubview: v];
RELEASE(v);
}
return self;
}
@ -863,9 +819,7 @@ extern NSArray *predefinedDateFormats, *predefinedNumberFormats;
if (control == detachButton)
{
[cell setFormatter: nil];
// FIXME: Should empty the inspector window or show
// the default inspector. How do we do that?
//[ (GormInspectorManager *)[window view] setCurrentInspector: 0] ??
[[(Gorm *)NSApp activeDocument] setSelectionFromEditor: nil];
}
else
{
@ -1020,47 +974,6 @@ extern NSArray *predefinedDateFormats, *predefinedNumberFormats;
return nil;
}
// Add positive/negative format table view by hand for now...
{
NSScrollView *v;
NSTableColumn *tc;
NSSize contentSize;
v = [[NSScrollView alloc] initWithFrame: NSMakeRect(12,268,245,118)];
[v setHasVerticalScroller: YES];
[v setHasHorizontalScroller: NO];
contentSize = [v contentSize];
formatTable = [[NSTableView alloc] initWithFrame:
NSMakeRect(0,0,contentSize.width, contentSize.height)];
[formatTable setDataSource: self];
[formatTable setDelegate: self];
[formatTable setAutoresizesAllColumnsToFit: YES];
[formatTable setAllowsEmptySelection: YES];
[formatTable setAllowsMultipleSelection: NO];
tc = [[NSTableColumn alloc] initWithIdentifier: @"positive"];
[[tc headerCell] setStringValue: @"Positive"];
[tc setWidth: contentSize.width/2];
[tc setResizable: NO];
[tc setEditable: NO];
[formatTable addTableColumn: tc];
RELEASE(tc);
tc = [[NSTableColumn alloc] initWithIdentifier: @"negative"];
[[tc headerCell] setStringValue: @"Negative"];
[tc setMinWidth: contentSize.width/2];
[tc setResizable: NO];
[tc setEditable: NO];
[formatTable addTableColumn: tc];
RELEASE(tc);
[v setDocumentView: formatTable];
[[window contentView] addSubview: v];
RELEASE(v);
}
// Initialize Positive/Negative appearance fields formatter
{
NSNumberFormatter *fmtr = [[NSNumberFormatter alloc] init];