File: programming/cocoa/Filie.zip/Filie/UKDistributedView/UKDistributedView.m


/* =============================================================================
	FILE:		UKDistributedView.m
	PROJECT:	UKDistributedView
 
	PURPOSE:	An NSTableView-like class that allows arbitrary positioning
				of evenly-sized items. This is intended for things like the
				Finder's "icon view", and even lets you snap items to a grid
				in various ways, reorder them etc.
				
				Your data source must be able to provide a position for its
				list items, which are simply enumerated. An NSCell subclass
				can be used for actually displaying the data, e.g. as an
				NSImage or similar.
    
    COPYRIGHT:  (c) 2003-2007 M. Uli Kusterer, all rights reserved.
    
	AUTHORS:	M. Uli Kusterer - UK
    
    LICENSES:   GPL or Commercial (see Readme)
 
	REVISIONS:
		2007-04-07	UK	Fixed a few more bugs when both no-multi-selection and
						no-empty-selection were on.
		2006-07-06	UK	Did some fixes to no-multi-selection-mode submitted by
						Todd Ransom, fixed more bugs found along the way.
        2004-12-01  UK  Ported over David Rozga's code. He caught some DnD bugs,
                        provided default type-ahead code and more...
        2004-11-20  UK  Added tool tips, item-caching callbacks, fixed title
                        rect stuff, documented new type-ahead stuff etc.
		2004-04-17  UK  Adapted David Sinclair's external code for allowing
						inline editing. I should hand over maintenance to him...
		2004-01-23  UK  Incorporated bug fixes from David Sinclair.
		2003-06-24	UK	Created.
   ========================================================================== */
 
/* -----------------------------------------------------------------------------
	Headers:
   -------------------------------------------------------------------------- */
 
#import "UKDistributedView.h"
#import <limits.h>
 
 
/* -----------------------------------------------------------------------------
	Notifications:
   -------------------------------------------------------------------------- */"UKDistributedViewSelectionDidChange";
 
 
/* -----------------------------------------------------------------------------
	UKDistributedView:
   -------------------------------------------------------------------------- */// always route through designated initializer
/* -----------------------------------------------------------------------------
	initWithCoder:
		Persistence constructor needed for IB palette.
	
	REVISIONS:
        2004-12-02  UK  Changed to use flags structure instead of lots of BOOLs.
		2004-12-01	UK	Documented.
   -------------------------------------------------------------------------- */"UKDVcellSize""UKDVgridSize""UKDVcontentInset""UKDVflags""UKDVprototype""UKDVgridColor"// Apply defaults, if needed:
/* -----------------------------------------------------------------------------
	encodeWithCoder:
		Save this view to a file. Used by IB.
	
	REVISIONS:
        2004-12-02  UK  Changed to use flags structure instead of lots of BOOLs.
		2004-12-01	UK	Documented.
   -------------------------------------------------------------------------- */"UKDVcellSize""UKDVgridSize""UKDVcontentInset""UKDVflags""UKDVprototype""UKDVgridColor"// -----------------------------------------------------------------------------
//  Selection Management:
// -----------------------------------------------------------------------------
#pragma mark Selection Management
// Make sure items are redrawn unselected.
// Make sure newly selected items are drawn that way.
// -----------------------------------------------------------------------------
//  Menu actions:
// -----------------------------------------------------------------------------
#pragma mark Menu Actions
/* -----------------------------------------------------------------------------
	validateMenuItem:
		Make sure menu items are enabled properly.
	
	REVISIONS:
		2003-06-29	UK	Created.
   -------------------------------------------------------------------------- */// Edit menu commands:
// Grid, repositioning and other Finder-like behaviour:
// Don't see why you'd want a menu item for this (besides debugging). You should really call this from your window zooming code.
// -----------------------------------------------------------------------------
//  Accessors:
// -----------------------------------------------------------------------------
#pragma mark Accessors
 
/* Set this to NO if you never want more than one item to be selected: */// Make sure all unselected items are redrawn.
/* Set this to NO if you always want at least one item to be selected: *//* If you want the user to be able to click in the view's background to drag
    a "rubber-band" selection rectangle for selecting multiple items, set this
    to YES: */// Selection rect implicitly turns on allowsMultipleSelection:
/* If drawsGrid == YES, this color will be used to draw grid lines: *//* The prototype is the "data cell" used for displaying items:
	Use this to change the cell type used for display. */// NSImageCell throws on setTarget/setAction :-T
/* All items's positions will be nudged to lie on a grid coordinate:
	This will only modify the coordinates during display. This will
	*not* change any actual item positions, and this doesn't make sure
	that no items overlap. *//* Dragging an item moves the items or starts drag and drop. If you're just
    after NSTableView-ish behavior, you'll want this to be NO. *//* When dragMovesItems == YES and the data source doesn't implement DnD, drags
    happen locally and 'live' within the view, and simply reposition the items.
    If you set dragLocally to YES, local drags will also be used when the data
    source implements DnD, and "real" DnD will not happen until the mouse leaves
    the view's visible rectangle. *//* Whenever an object moves, make this view resize to fit. *//* If you need to positionItem: or suggestedPosition a number of items in a row,
	call this around these calls. That way, the view will keep track of the
	previous item's position and start looking for a position for the next
	one after that, instead of starting at the top again. *//* Always force newly positioned and moved items to lie on the grid. */// The number of pixels of border to keep around the items:
// The cell size to use for our items:
// The size to use for our positioning grid:
// -----------------------------------------------------------------------------
//  Item Positioning:
// -----------------------------------------------------------------------------
#pragma mark Item Positioning
 
/* Position all items in order on the grid:
	This changes all items' positions *permanently*. Note that this simply tries to
	fit the items as orderly rows in the given rect, wrapping at the right edge. */// Calculate display rect:
// Calculate # of items that fit in display area in an orderly fashion:
// Now loop over all slots in the window where we would put something:
/* Position all items on the closest grid location to their current location:
	This changes all items' positions *permanently*. */// Now loop over all slots in the window where we would put something:
/* -----------------------------------------------------------------------------
	suggestedPosition:
		Reposition the item at the specified index. This moves the item
        somewhere where there is no other item.
        
        Note that this will *always* move the current item.
	
	REVISIONS:
		2004-12-02	UK	Added NSParameterAssert call.
   -------------------------------------------------------------------------- */// Calculate display rect:
// Calculate # of grid locations where we can put items:
//numRows = myFrame.size.height / gridSize.height;
// Now loop over all slots in the window where we would put something:
// No item in this rect?
// Only first time round do we want to start in that row.
	}
}
 
 
/* -----------------------------------------------------------------------------
	suggestedPosition:
		Returns a position that is suggested for a new item. This doesn't
        propose any positions at which there already are items.
	
	REVISIONS:
		2004-12-02	UK	Documented.
   -------------------------------------------------------------------------- */// Calculate display rect:
// Calculate # of grid slots where we could put this item:
// Now loop over all slots in the window where we would put something:
// * 10 so we don't try infinitely. Add to startRow since otherwise long lists would start stacking too early.
// No item in this rect?
/* -----------------------------------------------------------------------------
	itemPositionBasedOnItemIndex:
		Calculate a position for an item based on the item's index. Call this
        from your data source if you want items to "wrap" to the width of the
        view, like the Finder's "keep arranged by XX" option.
	
	REVISIONS:
		2004-12-02	UK	Added NSParameterAssert call.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	rectAroundItems:
		Return a rectangle enclosing all the items whose indexes are specified
		in the NSNumbers in the array dragIndexes.
	
	REVISIONS:
		2003-12-20	UK	Created.
   -------------------------------------------------------------------------- */// Find the lowest/highest X and Y coordinates and stuff them in l, t, r, and b:
// Return the whole shebang as a rect:
// Offset objects relative to content inset:
	box.origin.x -= contentInset;
	box.origin.y -= contentInset;
	
	// Move rect to positive coordinates, otherwise they crowd at 0,0:
// Actually move it onto the grid:
// Undo origin shift:
// Undo content inset shift:
	box.origin.x += contentInset;
	box.origin.y += contentInset;
	
	// Return adjusted box:
// Point must be in regular (non-flipped) coordinates:
// Opposite from drawing order, so we hit last drawn object (on top) first.
// if we're in the vicinity...		
// Lock focus on ourselves to perform some spot drawing:
// First empty the pixels inside our box:
// Next, draw our cell and grab the color at our mouse:
// Update or our temporary drawing screws up the looks.
			
			/* Now if we've found a color, and if it's sufficiently
				opaque, then call the hit a success: */// Rect must be in flipped coordinates:
//box = [self flipRectsYAxis: box];
// Rect must be in flipped coordinates:
// Rect must be in flipped coordinates:
// yPos must be in flipped coordinates:
/* Return the best rect for this object that encloses all items at their current positions plus the
	content inset: *//* -----------------------------------------------------------------------------
	windowFrameSizeForBestSize:
		This assumes this view is set up so it always keeps the same distance
		to window edges and resizes along with the window, i.e. the "Size" view
		in IB looks something like the following:
		
	    |
	 +--+--+
	 |  s  |       "s" and "un" are supposed to be "springs".
	-+un+un+-
	 |  s  |
	 +--+--+
	    |
	
	REVISIONS:
		2003-12-18	UK	Created.
   -------------------------------------------------------------------------- */// Calculate rect for our window's content area:
// Calculate how many pixels are around this view in the window:
// Calc best size and enlarge it by that many pixels:
// Adjust for scrollbars:
// Return that as best size for our window:
/* -----------------------------------------------------------------------------
	windowFrameForBestSize:
		Calls windowFrameSizeForBestSize, then returns a rectangle of that size
        which has its upper left corner in the same position as the view's
        window. Handy one-shot call for decent in-place zooming.
	
	REVISIONS:
		2004-11-18	UK	Created.
   -------------------------------------------------------------------------- */// Rect is in flipped coordinates:
// -----------------------------------------------------------------------------
//  Drawing and Display:
// -----------------------------------------------------------------------------
#pragma mark Drawing and Display
// Draw outline around margin:
	box.origin.x += contentInset +0.5;		// 0.5 so it draws on a full pixel
	box.origin.y += contentInset -0.5;		// 0.5 so it draws on a full pixel, - because it has to match the Y-flipped rects below
// TODO Do we want this to clip drawing of cells? Or should we restore graf state?
	
	// Now draw grid itself:
/* This rect isn't in our cache?
		Redo the cache, including 5 item heights above/below and 5 item widths
		left/right beyond what is currently visible: */// Now use the cache to draw all visible items:
//NSLog(@"count visible: %d",[visibleItems count]);
// Does nothing if "force to grid" is off.
/* A simple blue frame with slight white fill. You can also get a transparent
	version of the cell instead, if that's what you like. */#if UKDISTVIEW_DRAW_FANCY_SNAP_GUIDES
#else
// Move them onto full pixels.
#endif
// Move them onto full pixels
// Draw this view's contents:
"UKDistributedView"// If item image can move freely, invalidate that rect.
// If we force to grid, only invalidate grid position. If we show "snap" rects, invalidate grid position in addition to free one so we see item and "snap" indicator fully.
// Position is in flipped coordinates:
// Rect is in item coordinates, i.e. flipped Y-axis compared to Quartz:
//	Call invalidateVisibleItemsCache before this if you are recacheing to get rid of the old items.
// Visible!
// -----------------------------------------------------------------------------
//  Moving and Drag and Drop:
// -----------------------------------------------------------------------------
#pragma mark Moving and Drag and Drop
 
/* -----------------------------------------------------------------------------
	initiateMove:
		There has been a mouse down, and now we want the mouseItem/selection
		set to be moved on subsequent mouseDragged events. This is old-style
		"live" dragging, not inter-application drag and drop.
	
	REVISIONS:
		2003-12-20	UK	Extracted from mouseDown so initiateDrag can call it.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	initiateDrag:
		There has been a mouse down, and now we want the mouseItem/selection
		set to be dragged using the Drag & drop protocol. Takes care of setting
		up the drag image etc. by querying the data source.
		
		If the drag fails due to unsupported data source calls or similar, this
		will cause a local old-style "live" move using initiateMove.
	
	REVISIONS:
		2003-12-20	UK	Created.
   -------------------------------------------------------------------------- */// Actually commence the drag:
/* -----------------------------------------------------------------------------
	addPositionsOfItems:toPasteboard:
		Determine the positions of items (relative to the drag image's origin)
        and add them to the drag as an additional drag item. That way we can
		position the items exactly where their drag image was dropped, when
		someone drags between two UKDistributedViews.
	
	REVISIONS:
		2003-12-20	UK	Created.
   -------------------------------------------------------------------------- */
 
// I'll leave this in to remind myself how annoying it was to store a point in a plist:
//#define PLIST_POINT(p)    [NSValue valueWithPoint: p]
//#define PLIST_POINT(p)    NSStringFromPoint(p)
#define PLIST_POINT(p)      [NSData dataWithBytes: &p length: sizeof(NSPoint)]
//#define PLIST_POINT_X(p)  [p pointValue]
//#define PLIST_POINT_X(p)  NSPointFromString(p)
#define PLIST_POINT_X(p)    (*(NSPoint*) [p bytes])
// Build an array of our icon positions:
// Make position relative to drag image's loc:
// Put it on the drag pasteboard:
/* -----------------------------------------------------------------------------
	positionsOfItemsOnPasteboard:forImagePosition:
		This is the opposite of addPositionsOfItems:toPasteboard: and gives you
        back the actual positions at which the individual items in the drag have
        been dropped.
	
	REVISIONS:
		2004-12-07	UK	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	dragImageForItems:event:dragImageOffset:
		Paint a nice drag image of all our items being dragged.
	
	REVISIONS:
		2003-12-20	UK	Created.
   -------------------------------------------------------------------------- */// Draw each one: 
/* -----------------------------------------------------------------------------
	draggingEntered:
		Someone moved a dragged item over our view, and it's of a flavor
		we've been declared to understand. Return what operation we want to
		do.
	
	REVISIONS:
		2003-12-21	UK	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	draggingUpdated:
		Someone moved a dragged item over our view, and it's of a flavor
		we've been declared to understand. Return what operation we want to
		do.
	
	REVISIONS:
		2003-12-21	UK	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	draggingExited:
		The mouse has left this object during a drag to drop an item elsewhere.
        Reset all drag-related vars so we can start freshly on the next drag.
	
	REVISIONS:
        2004-12-02  UK  Fixed comment, made this clear drop highlight.
		2003-12-21	UK	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	performDragOperation:
		The user dropped something in this window. Let the data source handle
        the drop and clean up in preparation for future drags.
	
	REVISIONS:
		2003-12-21	UK	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	draggedImage:endedAt:operation:
		React to special drags, like on trash.
	
	REVISIONS:
		2004-12-07	UK	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	draggingSourceOperationMaskForLocal:
		Forward this DnD message to our delegate.
	
	REVISIONS:
		2003-12-20	UK	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	mouseDown:
		Find whatever was clicked and start tracking drags/the selection rect
        as needed.
	
	REVISIONS:
		2007-04-06	UK	Changed to ignore shift key if allowMultipleSelection
						is off.
		2006-07-06	UK	Fixed to unselect all items on mouseDown when we only
						allow a single selection.
		2004-12-02	UK	Documented.
   -------------------------------------------------------------------------- */// No item hit? Remove selection and start mouse tracking for selection rect.
// Empty selection not allowed? Can't unselect, and since rubber band needs to reset the selection, can't do selection rect either.
// Possible threading deadlock here ... ?
// An item was clicked?
// Double click!
// Editable item double-clicked?
// Title of editable item double-clicked? User wants to edit!
// Single click but shift key held down?
		{
			// If shift key is down, toggle this item's selection status
// Don't drag unselected item.
// Bail. Delegate told us not to select this item.
// If shift isn't down, make sure we're selected and drag:
// Bail. Delegate told us not to select this item.
// Don't start tracking if we're dealing with a selection rect and we're not allowed to do a selection rect.
/* -----------------------------------------------------------------------------
	mouseDragged:
		This is where we handle "live" old-style "moves" as well as the
		selection rectangles.
	
	REVISIONS:
		2007-04-06	UK	Made this do nothing in the case where selection rect
						is off and no item was clicked, so clicks in the empty
						area don't cause item drags.
		2006-07-06	UK	Fixed to again allow having old-style "moves" that don't
						turn into DnD drags when we leave the window.
		2003-12-20	UK	Documented.
   -------------------------------------------------------------------------- */// No item hit? Selection rect!
// Invalidate old position.
		
		// Build rect:
// Flip it if we have negative width or height:
// Invalidate new position.
 
		// Select items in the rect:
// Item hit? Drag the item, if we're set up that way:
// If mouse is inside our rect, drag locally:
// snapToGrid is toggled using command key.
// Invalidate old position.
// Invalidate new position.
// Left our rect? Use system drag & drop service instead:
/* -----------------------------------------------------------------------------
	mouseUp:
		A local drag or selection rectangle drag finished. This also ends
        editing in the previous cell and sends cellClicked: messages.
	
	REVISIONS:
		2006-07-06	UK	Fixed to trigger not just on move, but also when we're
						snapping to grid.
		2004-12-02	UK	Documented.
   -------------------------------------------------------------------------- */// No item hit? Must be selection rect. Reset that.
// Make sure old selection rect is removed.
// An item hit? Must be end of drag or so:
// Wasn't a drag.
// Item hit? Drag the item, if we're set up that way:
// Apply grid to item, if necessary:
// snapToGrid is toggled using command key.
// TODO: We should check whether the cell actually *is* being edited here!
/* -----------------------------------------------------------------------------
	moveItems:
		Move the items with the indexes specified in the array by the specified
        distance.
        
        *** PRIVATE *** DO NOT USE. Here because I could need it for finishing
        drag & drop support. But may be changed substantially or removed at any
        time!
	
	REVISIONS:
		2004-12-01	UK	Copied from David Rozga's modifications.
   -------------------------------------------------------------------------- */// old position
// new position
// brute force
}
 
 
/* -----------------------------------------------------------------------------
	acceptsFirstMouse:
		This view will use clicks that bring it to the front.
	
	REVISIONS:
		2004-12-01	UK	Documented.
   -------------------------------------------------------------------------- */// -----------------------------------------------------------------------------
//  Callbacks:
// -----------------------------------------------------------------------------
#pragma mark Callbacks
""// -----------------------------------------------------------------------------
//  Data Source Management:
// -----------------------------------------------------------------------------
#pragma mark Data Source Management
// try to preserve the selection set here, this is most likely called when the current set
	// of items has changed (but not to a different set)
// Adjust for change in size so window doesn't "scroll away":
// if the new frame is bigger than the content size (i.e. it grew), adjust scroll
			// position so that it maintains the same relative position.  Note that this only
			// has to adjust the y position (because of the bottom->top coordinate orientation).
// new frame is entirely inside the scroll view
// Resize and maintain scroll position:
//NSLog(@"newscroll: %f, %f newFrame: %@\n", newScroll.x, newScroll.y,NSStringFromRect( newFrame ));
// -----------------------------------------------------------------------------
//  Scrolling
// -----------------------------------------------------------------------------
#pragma mark Scrolling
 
/* -----------------------------------------------------------------------------
	rescrollItems:
		Move the items, maintaining their relative positions, so the topmost
        and leftmost items are positioned at exactly contentInset pixels from
        the top left.
	
	REVISIONS:
		2004-12-02	UK	Fixed comment, moved to be with other scroll methods.
   -------------------------------------------------------------------------- *///  Find topmost and leftmost positions of our items:
// Now reposition all our items:
/* -----------------------------------------------------------------------------
	scrollByX:y:
		Scroll our containing scroll view by a certain distance.
        
        Calls scrollToPoint: to do the actual work.
	
	REVISIONS:
		2004-12-01	UK	Copied from David Rozga's modifications.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	scrollToPoint:
		Scroll our containing scroll view to a certain location.
	
	REVISIONS:
		2004-12-01	UK	Copied from David Rozga's modifications.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	scrollItemToVisible:
		Scroll our containing scroll view so the specified item is visible.
        
        Calls scrollToPoint: to do the actual scrolling.
	
	REVISIONS:
		2004-12-02	UK	Copied from David Rozga's modifications, changed to use
                        NSParameterAssert instead of quietly returning.
   -------------------------------------------------------------------------- */// Item already visible?
// Nothing to do.
	
    // Calc minimum distance we need to scroll to see the item:
// Scroll!
//[sv setNeedsDisplay: YES];
// when this happens, we need to establish a base frame position/size
// Make sure tool tips etc. are current.
// at least consume all of the scroll area
/* -----------------------------------------------------------------------------
	resizeWithOldSuperviewSize:
		This view was resized. Make sure view is displayed properly.
	
	REVISIONS:
		2003-12-20	UK	Commented.
   -------------------------------------------------------------------------- */// Set line and page values of owning scroll view:
    //  Note: page values are percentages expressed as fractions between 0.0 and
    //  1.0, while line values are in pixels.
// -----------------------------------------------------------------------------
//  Keyboard Navigation
// -----------------------------------------------------------------------------
#pragma mark Keyboard Navigation
/* -----------------------------------------------------------------------------
	keyDown:
		Make sure insertText:, moveUp: etc. are called in response to key
        presses while this view has focus.
	
	REVISIONS:
		2004-12-01	UK	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	moveRight:
		Right arrow key has been pressed. Select the item next to the current
        selection.
	
	REVISIONS:
		2004-12-01	UK	Documented.
   -------------------------------------------------------------------------- */// Try using cache.
// But otherwise fall back on full list.
/* -----------------------------------------------------------------------------
	moveLeft:
		Left arrow key has been pressed. Select the item next to the current
        selection.
	
	REVISIONS:
		2004-12-01	UK	Documented.
   -------------------------------------------------------------------------- */// Try using cache.
// But otherwise fall back on full list.
/* -----------------------------------------------------------------------------
	moveUp:
		Up arrow key has been pressed. Select the item next to the current
        selection.
	
	REVISIONS:
		2004-12-01	UK	Documented.
   -------------------------------------------------------------------------- */// Try using cache.
// But otherwise fall back on full list.
/* -----------------------------------------------------------------------------
	moveDown:
		Down arrow key has been pressed. Select the item next to the current
        selection.
	
	REVISIONS:
		2004-12-01	UK	Documented.
   -------------------------------------------------------------------------- */// Try using cache.
// But otherwise fall back on full list.
/* -----------------------------------------------------------------------------
	insertTab:
		Tab key was hit. Select the next item in the list.
	
	REVISIONS:
		2004-12-01	UK	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	insertBacktab:
		Back-tab (shift-tab) key was hit. Select the previous item in the list.
	
	REVISIONS:
		2004-12-01	UK	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	insertText:
		User typed some text. Perform type-ahead selection.
	
	REVISIONS:
		2004-12-01	UK	Created.
   -------------------------------------------------------------------------- */"typeaheadstring: %@"// -----------------------------------------------------------------------------
//  Inline Editing:
// -----------------------------------------------------------------------------
#pragma mark Inline Editing
 
/* -----------------------------------------------------------------------------
	editItemIndex:withEvent:select:
		Open the field editor for a particular item's cell.
	
	REVISIONS:
		2004-12-01	UK	Documented.
   -------------------------------------------------------------------------- *//*may be NIL*/// Take over editor:
// Does it give up willingly?
// Otherwise, force field editor to give up and reset it.
	
	// Remember who we're messing with:
	editedItem = item;
 
	// Set up our cell for display:
// Fetch us one of them new-fangled field editors:
// Get the object value as a string so we can measure it:
// Select the string and open a field editor for it:
// Actually start editing:
//[self itemNeedsDisplay: editedItem];
}
 
 
/* -----------------------------------------------------------------------------
	textDidEndEditing:
		Clean up after the editor has been closed.
	
	REVISIONS:
		2004-12-01	UK	Documented.
   -------------------------------------------------------------------------- */// Finish the edit:
//cellBox = [prototype titleRectForBounds: cellBox];
    //[prototype resetCursorRect: cellBox inView: self];
    
    // I'm outta ideas what I can do to remove the cell's cursor rect:
	//[fieldEditor setHidden: YES];
	//[prototype setEditable: NO];
    
	/*[[self window] makeFirstResponder: self];
 	[[self window] invalidateCursorRectsForView: self];	
 	[[self window] invalidateCursorRectsForView: fieldEditor];	
  	[[self window] discardCursorRects];
  	[[self window] resetCursorRects];
  	[fieldEditor discardCursorRects];*/// Anything else I can try to get my NSCell to remove its cursor rectangle?
/*[prototype resetCursorRect: [self frame] inView: self];*/ // tried NSZeroRect here, too...
}
 
#pragma mark Live Resize
/* -----------------------------------------------------------------------------
	Make sure delegate gets all messages we don't have a use for:
   -------------------------------------------------------------------------- */// This isn't UKDistributedViewDelegate!!! That way we avoid warnings about unimplemented methods in category.
 
/* -----------------------------------------------------------------------------
	distributedView:itemIndexForString:options:
		Default implementation of type-ahead-selection so people using simple
        cells (like NSButtonCell or NSCell) get type-ahead-selection for free.
		
		Note that, for this to work, the items must be in alphabetic order.
	
	REVISIONS:
        2004-12-11  UK  Added options, renamed from itemIndexForTypeAheadString:
		2004-12-01	UK	Documented.
   -------------------------------------------------------------------------- */// An ok default matching algorithm.  You can probably get better performance if you
	//  implement this yourself, that way the NSCell doesn't have to get setup everytime,
	//  may matter, may not.
// Find the closest match:
 

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.