
/*
   MiscFileDragView.m

   Copyright (C) 1996 Todd Thomas
   Use is governed by the MiscKit license

   This object is included in the MiscKit by permission from the author
   and its use is governed by the MiscKit license, found in the file
   "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
   for a list of all applicable permissions and restrictions.
*/

// RCS identification information
static char *rcsID = "$Id: MiscFileDragView.m,v 1.3 1996/10/07 02:49:25 todd Exp $";
static void __AvoidCompilerWarning(void) {if(!rcsID)__AvoidCompilerWarning();}

#import <AppKit/AppKit.h>

#import "MiscFileDragCell.h"
#import "MiscFileDragView.h"

// Our current class version (for archiving purposes).
#define MISC_FILE_DRAG_VIEW_VERSION 0

// Class ivars
static Class _dragCellClass = nil;


@implementation MiscFileDragView

/*"
   MiscFileDragView is a subclass of MiscDragView that only adds the
   few extra methods that MiscFileDragCell adds to MiscDragCell's API.
   Our default cell class is the MiscFileDragCell class. Most of our
   methods just pass the message on to our cell.
"*/


+ (void) initialize
/*"
   Our class initializer. Sets our class version (for archiving) and
   our cell class (MiscFileDragCell).
"*/
{
    if (self == [MiscFileDragView class]) {
        [self setVersion:MISC_FILE_DRAG_VIEW_VERSION];
        [self setCellClass:[MiscFileDragCell class]];
    }
}


+ (Class) cellClass
/*"
   Returns the cell class we use to create our cell upon initialization.
   By default it is MiscFileDragCell.
"*/
{
    return _dragCellClass;
}


+ (void) setCellClass:(Class)newDragCellClass
/*"
   Sets our cell class that new instances will use. It should be
   a subclass of MiscFileDragCell for everything to work
   properly.
"*/
{
    _dragCellClass = newDragCellClass;
}


- (NSString *) filename
/*"
   Returns our filename or the empty string if we don't currently
   have a filename. If we represent more than one filename we
   return the first one. If you want access to all the filenames
   use our #filenames method.
"*/
{
    return [[self cell] filename];
}


- (void) setFilename:(NSString*)aFilename
/*"
   Sets the filename we currently represent. This will also set
   the appropriate matching image. If aFilename is nil or empty
   we clear our current filename and image.
"*/
{
    [[self cell] setFilename:aFilename];
}


- (NSArray*) filenames
/*"
   Returns our filenames or nil if we don't currently
   have a filename. If we represent one filename it will
   be the only filename in the array. If you know for sure
   we only represent a single filename you can use #filename.
"*/
{
    return [[self cell] filenames];
}


- (void) setFilenames:(NSArray*)filenames
/*"
   Sets the filenames we currently represent. If filenames
   is nil that will remove any files we used to represent.
"*/
{
    [[self cell] setFilenames:filenames];
}


- (BOOL) allowsDoubleClickLaunch
/*"
   Returns YES if double clicking the view when there is an
   image will get NSWorkspace to launch the filenames in
   whatever applications they've been registered to handled
   by.
"*/
{
    return [[self cell] allowsDoubleClickLaunch];
}


- (void) setAllowsDoubleClickLaunch:(BOOL)aBool
/*"
   Sets whether double clicking will launch the filenames
   we represent.
"*/
{
    [[self cell] setAllowsDoubleClickLaunch:aBool];
}


- (void) launch:(id)sender
/*"
   Passes the launch: message onto our cell.
"*/
{
    [[self cell] launch:sender];
}


- (id) initWithCoder:(NSCoder*)aDecoder
/*"
   Decodes an instance of MiscFileDragView.
"*/
{
    int version;
    
    [super initWithCoder:aDecoder];

    version = [aDecoder versionForClassName:@"MiscFileDragView"];
        
    switch (version) {
      case MISC_FILE_DRAG_VIEW_VERSION:
          break;

      default:
          NSLog(@"[%@ %@] - unknown version found.",
                NSStringFromClass([self class]), NSStringFromSelector(_cmd));
          break;
    }

    return self;
}

- (void) encodeWithCoder:(NSCoder *)aCoder
/*"
   Standard instance encoder. Currently does nothing because we have
   no instance variables.
"*/
{
    [super encodeWithCoder:aCoder];
}

@end

