File: programming/cocoa/UKDistributedView.zip/UKDistributedView/Example/MyDataSource.m


//
//  MyDataSource.m
//  UKDistributedView
//
//  Created by Uli Kusterer on Wed Jun 25 2003.
//  Copyright (c) 2003 M. Uli Kusterer. All rights reserved.
//
 
#import "UKDistributedView.h"
#import "UKFinderIconCell.h"
#import "MyDataSource.h"
#import "MyDistViewItem.h"
// This example keeps its items in an array.
// When we've finished building, set up our custom cell type and a few sample items to play with:
/* Set up a finder icon cell to use: */// Add a few items:
	//	These must be in alphabetic order for type-ahead-selection to work:
// Make items draggable and initially position them neatly:
// Instead of this you'd probably load the positions from wherever you get your items from.
	[distView setDragMovesItems:YES];	// Allow dragging around items in the view.
	[distView setDragLocally: YES];
	//[distView setAllowsMultipleSelection: NO];
// Menu item action for adding new items at runtime to play with:
"LadyJayeIcon.icns""MediDoc.icns""MimiRogersIcon.icns""FourthDoctor.icns""ThirdDoctor.icns""EighthDoctor.icns""FirstDoctor.icns""SecondDoctor.icns""K9.icns""Jabe.icns""NSApplicationIcon""Susan Foreman",
											@"Barbara Wright",
											@"Ian Chesterton",
											@"Vicki",
											@"Steven Taylor",
											@"Katarina",
											@"Sara Kingdom",
											@"Dorothea Chaplet",
											@"Ben Jackson",
											@"Polly",
											@"James Robert McCrimmon",
											@"Dr. Elizabeth Shaw",
											@"Josephine Grant",
											@"Sarah Jane Smith",
											@"Harry Sullivan",
											@"Leela",
											@"K9 Mark I",
											@"K9 Mark II",
											@"Romanadvoratrelundar",
											@"Adric",
											@"Nyssa of Traken",
											@"Tegan Jovanka",
											@"Vislor Turlough",
											@"Kamelion",
											@"Perpugilliam Brown",
											@"Melanie Bush",
											@"Dorothy",
											@"Dr. Grace Holloway",
											@"Rose Tyler",
											@"Adam Mitchell",
											@"Captain Jack Harkness",
											@"Mickey Smith",
											@"Martha Jones"// -----------------------------------------------------------------------------
// DistributedView delegate methods:
// Tell our list view how many items to expect:
// Display item data in cell:
	[cell setImage: [item image]];
	[cell setTitle: [item title]];
	
	/* Tell list view where to display this item:
		You *must* keep track of your items' positions, and if you
		want to be able to move them, you must also implement setPosition:forItemIndex: */// User has repositioned this item. Pick up the change:
// User double-clicked an item. You don't have to implement this method, but we do, just for fun:
"Item double-clicked", @"You double-clicked on the item \"%@\".%@", @"OK", @"", @""" There are additional items selected." : @"");
}
 
// -----------------------------------------------------------------------------
// Zooming:
// Yes, it's that easy!
}
 
 
// -----------------------------------------------------------------------------
// Inter-application drag and drop:
#if DEMO_DRAG_AND_DROP
// Loop over dragged items and collect data for each:
"/Users/"// Build pseudo file path as data so people can see the Finder actually accept our drags.
	}
	
	// Add data to pasteboard:
// Are we copying when dragging out of this view?
// Specify where the dropped data should end up. On ("inside") an item, or just among them?
// Just accept it in the general area of our view.
// Say whether you accept a drop of an item:
// Use this to handle drops on the trash etc:
// Drag to trash!
	{
		// You could loop over the items here and delete all selected items from your array.
	}
}
 
#endif
 
// -----------------------------------------------------------------------------
 
// Additional menu actions for testing dist view:
 

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.