2002-11-07 00:28:16 +00:00
|
|
|
|
/* GormSoundEditor.m
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 Free Software Foundation, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
|
|
|
|
* Date: 2002
|
|
|
|
|
*
|
|
|
|
|
* This file is part of GNUstep.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "GormPrivate.h"
|
2004-05-03 22:43:50 +00:00
|
|
|
|
#include "GormFunctions.h"
|
2004-07-14 03:10:44 +00:00
|
|
|
|
#include "GormPalettesManager.h"
|
2003-05-10 21:19:25 +00:00
|
|
|
|
#include <AppKit/NSSound.h>
|
2004-12-05 20:52:36 +00:00
|
|
|
|
#include "GormSound.h"
|
2002-11-07 00:28:16 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Method to return the image that should be used to display objects within
|
|
|
|
|
* the matrix containing the objects in a document.
|
|
|
|
|
*/
|
|
|
|
|
@implementation NSObject (GormSoundAdditions)
|
|
|
|
|
- (NSString*) soundInspectorClassName
|
|
|
|
|
{
|
|
|
|
|
return @"GormSoundInspector";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSImage*) soundImageForViewer
|
|
|
|
|
{
|
|
|
|
|
static NSImage *image = nil;
|
|
|
|
|
|
|
|
|
|
if (image == nil)
|
|
|
|
|
{
|
|
|
|
|
NSBundle *bundle = [NSBundle mainBundle];
|
|
|
|
|
NSString *path = [bundle pathForImageResource: @"GormSound"];
|
|
|
|
|
|
|
|
|
|
image = [[NSImage alloc] initWithContentsOfFile: path];
|
|
|
|
|
}
|
|
|
|
|
return image;
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@implementation GormSoundEditor
|
|
|
|
|
|
|
|
|
|
static NSMapTable *docMap = 0;
|
|
|
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [GormSoundEditor class])
|
|
|
|
|
{
|
|
|
|
|
docMap = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
|
|
|
|
|
NSObjectMapValueCallBacks, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (GormSoundEditor*) editorForDocument: (id<IBDocuments>)aDocument
|
|
|
|
|
{
|
|
|
|
|
id editor = NSMapGet(docMap, (void*)aDocument);
|
|
|
|
|
|
|
|
|
|
if (editor == nil)
|
|
|
|
|
{
|
|
|
|
|
editor = [[self alloc] initWithObject: nil inDocument: aDocument];
|
|
|
|
|
AUTORELEASE(editor);
|
|
|
|
|
}
|
|
|
|
|
return editor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) acceptsTypeFromArray: (NSArray*)types
|
|
|
|
|
{
|
|
|
|
|
if ([types containsObject: IBObjectPboardType] == YES)
|
|
|
|
|
return YES;
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) copySelection
|
|
|
|
|
{
|
|
|
|
|
if (selected != nil)
|
|
|
|
|
{
|
|
|
|
|
[document copyObjects: [self selection]
|
|
|
|
|
type: IBViewPboardType
|
|
|
|
|
toPasteboard: [NSPasteboard generalPasteboard]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Dragging source protocol implementation
|
|
|
|
|
*/
|
|
|
|
|
- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
|
|
|
|
{
|
|
|
|
|
NSArray *types;
|
|
|
|
|
|
|
|
|
|
dragPb = [sender draggingPasteboard];
|
|
|
|
|
types = [dragPb types];
|
|
|
|
|
if ([types containsObject: IBObjectPboardType] == YES)
|
|
|
|
|
{
|
|
|
|
|
dragType = IBObjectPboardType;
|
|
|
|
|
}
|
|
|
|
|
else if ([types containsObject: GormLinkPboardType] == YES)
|
|
|
|
|
{
|
|
|
|
|
dragType = GormLinkPboardType;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dragType = nil;
|
|
|
|
|
}
|
|
|
|
|
return [self draggingUpdated: sender];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
|
|
|
|
|
{
|
|
|
|
|
if (dragType == IBObjectPboardType)
|
|
|
|
|
{
|
|
|
|
|
return NSDragOperationCopy;
|
|
|
|
|
}
|
|
|
|
|
else if (dragType == GormLinkPboardType)
|
|
|
|
|
{
|
|
|
|
|
NSPoint loc = [sender draggingLocation];
|
|
|
|
|
int r, c;
|
|
|
|
|
int pos;
|
|
|
|
|
id obj = nil;
|
|
|
|
|
|
|
|
|
|
loc = [self convertPoint: loc fromView: nil];
|
|
|
|
|
[self getRow: &r column: &c forPoint: loc];
|
|
|
|
|
pos = r * [self numberOfColumns] + c;
|
|
|
|
|
if (pos >= 0 && pos < [objects count])
|
|
|
|
|
{
|
|
|
|
|
obj = [objects objectAtIndex: pos];
|
|
|
|
|
}
|
|
|
|
|
if (obj == [NSApp connectSource])
|
|
|
|
|
{
|
|
|
|
|
return NSDragOperationNone; /* Can't drag an object onto itsself */
|
|
|
|
|
}
|
|
|
|
|
[NSApp displayConnectionBetween: [NSApp connectSource] and: obj];
|
|
|
|
|
if (obj != nil)
|
|
|
|
|
{
|
|
|
|
|
return NSDragOperationLink;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return NSDragOperationNone;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return NSDragOperationNone;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) drawSelection
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) handleNotification: (NSNotification*)aNotification
|
|
|
|
|
{
|
2004-05-03 22:43:50 +00:00
|
|
|
|
NSString *name = [aNotification name];
|
2004-05-13 05:13:36 +00:00
|
|
|
|
|
2004-05-03 22:43:50 +00:00
|
|
|
|
if([name isEqual: GormResizeCellNotification])
|
|
|
|
|
{
|
|
|
|
|
NSDebugLog(@"Recieved notification");
|
|
|
|
|
[self setCellSize: defaultCellSize()];
|
|
|
|
|
}
|
2002-11-07 00:28:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Initialisation - register to receive DnD with our own types.
|
|
|
|
|
*/
|
|
|
|
|
- (id) initWithObject: (id)anObject inDocument: (id<IBDocuments>)aDocument
|
|
|
|
|
{
|
|
|
|
|
id old = NSMapGet(docMap, (void*)aDocument);
|
|
|
|
|
|
|
|
|
|
if (old != nil)
|
|
|
|
|
{
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
self = RETAIN(old);
|
|
|
|
|
[self addObject: anObject];
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-13 05:13:36 +00:00
|
|
|
|
self = [super initWithObject: anObject inDocument: aDocument];
|
2002-11-07 00:28:16 +00:00
|
|
|
|
if (self != nil)
|
|
|
|
|
{
|
|
|
|
|
NSButtonCell *proto;
|
2004-07-14 03:10:44 +00:00
|
|
|
|
NSMutableArray *list = [NSMutableArray array];
|
2004-05-15 17:03:33 +00:00
|
|
|
|
NSEnumerator *en;
|
|
|
|
|
id obj;
|
2004-07-14 03:10:44 +00:00
|
|
|
|
GormPalettesManager *palettesManager = [(Gorm *)NSApp palettesManager];
|
2002-11-07 00:28:16 +00:00
|
|
|
|
|
|
|
|
|
[self registerForDraggedTypes: [NSArray arrayWithObjects:
|
|
|
|
|
IBObjectPboardType, GormLinkPboardType, nil]];
|
|
|
|
|
|
|
|
|
|
[self setAutosizesCells: NO];
|
|
|
|
|
[self setCellSize: NSMakeSize(72,72)];
|
|
|
|
|
[self setIntercellSpacing: NSMakeSize(8,8)];
|
|
|
|
|
[self setAutoresizingMask: NSViewMinYMargin|NSViewWidthSizable];
|
|
|
|
|
[self setMode: NSRadioModeMatrix];
|
|
|
|
|
/*
|
|
|
|
|
* Send mouse click actions to self, so we can handle selection.
|
|
|
|
|
*/
|
|
|
|
|
[self setAction: @selector(changeSelection:)];
|
|
|
|
|
[self setDoubleAction: @selector(raiseSelection:)];
|
|
|
|
|
[self setTarget: self];
|
|
|
|
|
|
|
|
|
|
objects = [NSMutableArray new];
|
|
|
|
|
proto = [NSButtonCell new];
|
|
|
|
|
[proto setBordered: NO];
|
|
|
|
|
[proto setAlignment: NSCenterTextAlignment];
|
|
|
|
|
[proto setImagePosition: NSImageAbove];
|
|
|
|
|
[proto setSelectable: NO];
|
|
|
|
|
[proto setEditable: NO];
|
|
|
|
|
[self setPrototype: proto];
|
|
|
|
|
RELEASE(proto);
|
|
|
|
|
NSMapInsert(docMap, (void*)aDocument, (void*)self);
|
2004-05-15 17:03:33 +00:00
|
|
|
|
|
|
|
|
|
// do not insert it if it's nil.
|
|
|
|
|
if(anObject != nil)
|
|
|
|
|
{
|
|
|
|
|
[self addObject: anObject];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// add all of the system objects...
|
2004-07-14 03:10:44 +00:00
|
|
|
|
[list addObjectsFromArray: systemSoundsList()];
|
|
|
|
|
[list addObjectsFromArray: [palettesManager importedSounds]];
|
2004-05-15 17:03:33 +00:00
|
|
|
|
en = [list objectEnumerator];
|
|
|
|
|
while((obj = [en nextObject]) != nil)
|
|
|
|
|
{
|
2004-12-05 20:52:36 +00:00
|
|
|
|
GormSound *sound = [GormSound soundForPath: obj];
|
2004-05-15 17:03:33 +00:00
|
|
|
|
[sound setSystemSound: YES];
|
|
|
|
|
[self addObject: sound];
|
|
|
|
|
}
|
2004-05-03 22:43:50 +00:00
|
|
|
|
|
|
|
|
|
// set up the notification...
|
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
|
addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: GormResizeCellNotification
|
|
|
|
|
object: nil];
|
2002-11-07 00:28:16 +00:00
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-13 05:13:36 +00:00
|
|
|
|
- (void) close
|
|
|
|
|
{
|
|
|
|
|
[super close];
|
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
|
|
|
|
NSMapRemove(docMap,document);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 00:28:16 +00:00
|
|
|
|
- (void) makeSelectionVisible: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
if (flag == YES && selected != nil)
|
|
|
|
|
{
|
|
|
|
|
unsigned pos = [objects indexOfObjectIdenticalTo: selected];
|
|
|
|
|
int r = pos / [self numberOfColumns];
|
|
|
|
|
int c = pos % [self numberOfColumns];
|
|
|
|
|
|
|
|
|
|
[self selectCellAtRow: r column: c];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[self deselectAllCells];
|
|
|
|
|
}
|
|
|
|
|
[self displayIfNeeded];
|
|
|
|
|
[[self window] flushWindow];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) mouseDown: (NSEvent*)theEvent
|
|
|
|
|
{
|
2002-11-18 20:54:26 +00:00
|
|
|
|
int row, column;
|
|
|
|
|
int newRow, newColumn;
|
|
|
|
|
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDownMask
|
|
|
|
|
| NSMouseMovedMask | NSLeftMouseDraggedMask
|
|
|
|
|
| NSPeriodicMask;
|
|
|
|
|
NSPoint lastLocation = [theEvent locationInWindow];
|
|
|
|
|
NSEvent* lastEvent = theEvent;
|
|
|
|
|
NSPoint initialLocation;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Pathological case -- ignore mouse down
|
|
|
|
|
*/
|
|
|
|
|
if ((_numRows == 0) || (_numCols == 0))
|
2002-11-07 00:28:16 +00:00
|
|
|
|
{
|
2002-11-18 20:54:26 +00:00
|
|
|
|
[super mouseDown: theEvent];
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-11-07 00:28:16 +00:00
|
|
|
|
|
2002-11-18 20:54:26 +00:00
|
|
|
|
lastLocation = [self convertPoint: lastLocation
|
|
|
|
|
fromView: nil];
|
|
|
|
|
initialLocation = lastLocation;
|
|
|
|
|
// If mouse down was on a selectable cell, start editing/selecting.
|
|
|
|
|
if ([self getRow: &row
|
|
|
|
|
column: &column
|
|
|
|
|
forPoint: lastLocation])
|
|
|
|
|
{
|
|
|
|
|
if ([_cells[row][column] isEnabled])
|
2002-11-07 00:28:16 +00:00
|
|
|
|
{
|
2002-11-18 20:54:26 +00:00
|
|
|
|
if ((_mode == NSRadioModeMatrix) && _selectedCell != nil)
|
|
|
|
|
{
|
|
|
|
|
[_selectedCell setState: NSOffState];
|
|
|
|
|
[self drawCellAtRow: _selectedRow column: _selectedColumn];
|
|
|
|
|
_selectedCells[_selectedRow][_selectedColumn] = NO;
|
|
|
|
|
_selectedCell = nil;
|
|
|
|
|
_selectedRow = _selectedColumn = -1;
|
|
|
|
|
}
|
|
|
|
|
[_cells[row][column] setState: NSOnState];
|
|
|
|
|
[self drawCellAtRow: row column: column];
|
|
|
|
|
[_window flushWindow];
|
|
|
|
|
_selectedCells[row][column] = YES;
|
|
|
|
|
_selectedCell = _cells[row][column];
|
|
|
|
|
_selectedRow = row;
|
|
|
|
|
_selectedColumn = column;
|
2002-11-07 00:28:16 +00:00
|
|
|
|
}
|
2002-11-18 20:54:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lastEvent = [NSApp nextEventMatchingMask: eventMask
|
|
|
|
|
untilDate: [NSDate distantFuture]
|
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
|
dequeue: YES];
|
|
|
|
|
|
|
|
|
|
lastLocation = [self convertPoint: [lastEvent locationInWindow]
|
|
|
|
|
fromView: nil];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ([lastEvent type] != NSLeftMouseUp)
|
|
|
|
|
{
|
|
|
|
|
if((![self getRow: &newRow
|
|
|
|
|
column: &newColumn
|
|
|
|
|
forPoint: lastLocation])
|
|
|
|
|
||
|
|
|
|
|
(row != newRow)
|
|
|
|
|
||
|
|
|
|
|
(column != newColumn)
|
|
|
|
|
||
|
|
|
|
|
((lastLocation.x - initialLocation.x) *
|
|
|
|
|
(lastLocation.x - initialLocation.x) +
|
|
|
|
|
(lastLocation.y - initialLocation.y) *
|
|
|
|
|
(lastLocation.y - initialLocation.y)
|
|
|
|
|
>= 25))
|
2002-11-07 00:28:16 +00:00
|
|
|
|
{
|
2002-11-18 20:54:26 +00:00
|
|
|
|
NSPasteboard *pb;
|
|
|
|
|
int pos;
|
|
|
|
|
pos = row * [self numberOfColumns] + column;
|
|
|
|
|
|
|
|
|
|
pb = [NSPasteboard pasteboardWithName: NSDragPboard];
|
|
|
|
|
[pb declareTypes: [NSArray arrayWithObject: GormSoundPboardType]
|
|
|
|
|
owner: self];
|
|
|
|
|
[pb setString: [[objects objectAtIndex: pos] soundName]
|
|
|
|
|
forType: GormSoundPboardType];
|
|
|
|
|
[self dragImage: [[objects objectAtIndex: pos] soundImageForViewer]
|
|
|
|
|
at: lastLocation
|
|
|
|
|
offset: NSZeroSize
|
|
|
|
|
event: theEvent
|
|
|
|
|
pasteboard: pb
|
|
|
|
|
source: self
|
|
|
|
|
slideBack: YES];
|
|
|
|
|
|
2002-11-07 00:28:16 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-18 20:54:26 +00:00
|
|
|
|
lastEvent = [NSApp nextEventMatchingMask: eventMask
|
|
|
|
|
untilDate: [NSDate distantFuture]
|
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
|
dequeue: YES];
|
|
|
|
|
|
|
|
|
|
lastLocation = [self convertPoint: [lastEvent locationInWindow]
|
|
|
|
|
fromView: nil];
|
2002-11-07 00:28:16 +00:00
|
|
|
|
|
2002-11-18 20:54:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self changeSelection: self];
|
2002-11-07 00:28:16 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) pasteInSelection
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
|
|
|
|
{
|
|
|
|
|
if (dragType == IBObjectPboardType)
|
|
|
|
|
{
|
|
|
|
|
NSArray *array;
|
|
|
|
|
NSEnumerator *enumerator;
|
|
|
|
|
id obj;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Ask the document to get the dragged objects from the pasteboard and
|
|
|
|
|
* add them to it's collection of known objects.
|
|
|
|
|
*/
|
|
|
|
|
array = [document pasteType: IBViewPboardType
|
|
|
|
|
fromPasteboard: dragPb
|
|
|
|
|
parent: [objects objectAtIndex: 0]];
|
|
|
|
|
enumerator = [array objectEnumerator];
|
|
|
|
|
while ((obj = [enumerator nextObject]) != nil)
|
|
|
|
|
{
|
|
|
|
|
[self addObject: obj];
|
|
|
|
|
}
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
else if (dragType == GormLinkPboardType)
|
|
|
|
|
{
|
|
|
|
|
NSPoint loc = [sender draggingLocation];
|
|
|
|
|
int r, c;
|
|
|
|
|
int pos;
|
|
|
|
|
id obj = nil;
|
|
|
|
|
|
|
|
|
|
loc = [self convertPoint: loc fromView: nil];
|
|
|
|
|
[self getRow: &r column: &c forPoint: loc];
|
|
|
|
|
pos = r * [self numberOfColumns] + c;
|
|
|
|
|
if (pos >= 0 && pos < [objects count])
|
|
|
|
|
{
|
|
|
|
|
obj = [objects objectAtIndex: pos];
|
|
|
|
|
}
|
|
|
|
|
if (obj == nil)
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[NSApp displayConnectionBetween: [NSApp connectSource] and: obj];
|
|
|
|
|
[NSApp startConnecting];
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-10-28 05:25:14 +00:00
|
|
|
|
NSDebugLog(@"Drop with unrecognized type!");
|
2002-11-07 00:28:16 +00:00
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* Tell the source that we will accept the drop if we can.
|
|
|
|
|
*/
|
|
|
|
|
if (dragType == IBObjectPboardType)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* We can accept objects dropped anywhere.
|
|
|
|
|
*/
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
else if (dragType == GormLinkPboardType)
|
|
|
|
|
{
|
|
|
|
|
NSPoint loc = [sender draggingLocation];
|
|
|
|
|
int r, c;
|
|
|
|
|
int pos;
|
|
|
|
|
id obj = nil;
|
|
|
|
|
|
|
|
|
|
loc = [self convertPoint: loc fromView: nil];
|
|
|
|
|
[self getRow: &r column: &c forPoint: loc];
|
|
|
|
|
pos = r * [self numberOfColumns] + c;
|
|
|
|
|
if (pos >= 0 && pos < [objects count])
|
|
|
|
|
{
|
|
|
|
|
obj = [objects objectAtIndex: pos];
|
|
|
|
|
}
|
|
|
|
|
if (obj != nil)
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-18 20:54:26 +00:00
|
|
|
|
- (unsigned int) draggingSourceOperationMaskForLocal: (BOOL) flag
|
|
|
|
|
{
|
|
|
|
|
return NSDragOperationCopy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-11-07 00:28:16 +00:00
|
|
|
|
- (id) raiseSelection: (id)sender
|
|
|
|
|
{
|
|
|
|
|
id obj = [self changeSelection: sender];
|
|
|
|
|
id e;
|
|
|
|
|
|
|
|
|
|
e = [document editorForObject: obj create: YES];
|
|
|
|
|
[e orderFront];
|
|
|
|
|
[e resetObject: obj];
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) refreshCells
|
|
|
|
|
{
|
|
|
|
|
unsigned count = [objects count];
|
|
|
|
|
unsigned index;
|
|
|
|
|
int cols = 0;
|
|
|
|
|
int rows;
|
|
|
|
|
int width;
|
|
|
|
|
|
2004-06-05 03:51:37 +00:00
|
|
|
|
// return if the superview is not available.
|
|
|
|
|
if(![self superview])
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 00:28:16 +00:00
|
|
|
|
width = [[self superview] bounds].size.width;
|
|
|
|
|
while (width >= 72)
|
|
|
|
|
{
|
|
|
|
|
width -= (72 + 8);
|
|
|
|
|
cols++;
|
|
|
|
|
}
|
|
|
|
|
if (cols == 0)
|
|
|
|
|
{
|
|
|
|
|
cols = 1;
|
|
|
|
|
}
|
|
|
|
|
rows = count / cols;
|
|
|
|
|
if (rows == 0 || rows * cols != count)
|
|
|
|
|
{
|
|
|
|
|
rows++;
|
|
|
|
|
}
|
|
|
|
|
[self renewRows: rows columns: cols];
|
|
|
|
|
|
|
|
|
|
for (index = 0; index < count; index++)
|
|
|
|
|
{
|
|
|
|
|
id obj = [objects objectAtIndex: index];
|
|
|
|
|
NSButtonCell *but = [self cellAtRow: index/cols column: index%cols];
|
|
|
|
|
NSString *name = [obj soundName];
|
|
|
|
|
|
2003-10-28 05:25:14 +00:00
|
|
|
|
NSDebugLog(@"sound name = %@",name);
|
2002-11-07 00:28:16 +00:00
|
|
|
|
[but setImage: [obj soundImageForViewer]];
|
|
|
|
|
[but setTitle: name];
|
|
|
|
|
[but setShowsStateBy: NSChangeGrayCellMask];
|
|
|
|
|
[but setHighlightsBy: NSChangeGrayCellMask];
|
|
|
|
|
}
|
|
|
|
|
while (index < rows * cols)
|
|
|
|
|
{
|
|
|
|
|
NSButtonCell *but = [self cellAtRow: index/cols column: index%cols];
|
|
|
|
|
|
|
|
|
|
[but setImage: nil];
|
|
|
|
|
[but setTitle: @""];
|
|
|
|
|
[but setShowsStateBy: NSNoCellMask];
|
|
|
|
|
[but setHighlightsBy: NSNoCellMask];
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
[self setIntercellSpacing: NSMakeSize(8,8)];
|
|
|
|
|
[self sizeToCells];
|
|
|
|
|
[self setNeedsDisplay: YES];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) resetObject: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|