DrawKit
Vector and illustration framework for Mac OS X
Instance Methods | Class Methods | Protected Attributes | List of all members
DKObjectOwnerLayer Class Reference

This layer class can be the owner of any number of DKDrawableObjects. More...

Inheritance diagram for DKObjectOwnerLayer:
Inheritance graph
[legend]

Instance Methods

(void) - addObject:
 Adds an object to the layer. More...
 
(void) - addObject:atIndex:
 
(void) - addObjectPendingCreation:
 Adds a new object to the layer pending successful interactive creation. More...
 
(void) - addObjects:fromPasteboard:atDropLocation:
 Add objects to the layer from the pasteboard. More...
 
(void) - addObjectsFromArray:
 Adds a set of objects to the layer. More...
 
(BOOL- addObjectsFromArray:bounds:relativeToPoint:pinToInterior:
 Adds a set of objects to the layer offsetting their location by the given delta values relative to a given point. More...
 
(BOOL- addObjectsFromArray:relativeToPoint:pinToInterior:
 Adds a set of objects to the layer offsetting their location by the given delta values relative to a given point. More...
 
(BOOL- allowsEditing
 Does the layer permit editing of its objects? More...
 
(BOOL- allowsSnapToObjects
 Does the layer permit snapping to its objects? More...
 
(void) - applyTransformToObjects:
 Modifies the objects by applying the given transform to each of them. More...
 
(NSArray *) - availableObjects
 Returns objects that are available to the user, that is, not locked or invisible. More...
 
(NSArray *) - availableObjectsInRect:
 Returns objects that are available to the user, that is, not locked or invisible and that intersect the rect. More...
 
(NSArray *) - availableObjectsOfClass:
 Returns objects that are available to the user of the given class. More...
 
(DKDrawableObject *) - bottomObject
 Returns the bottom object. More...
 
(void) - commitPendingObjectWithUndoActionName:
 Commits the pending object to the layer and sets up the undo task action name. More...
 
(NSUInteger- countOfObjects
 
(void) - drawable:needsDisplayInRect:
 
(void) - drawable:wasDoubleClickedAtPoint:
 An object owned by the layer was double-clicked. More...
 
(void) - drawHighlightingForDrag
 Draws the highlighting to indicate the layer is a drag target. More...
 
(void) - drawPendingObjectInView:
 Draws the pending object, if any, in the layer - called by drawRect:inView: More...
 
(void) - drawVisibleObjects
 
(DKDrawableObject *) - hitTest:
 Find which object was hit by the given point, if any. More...
 
(DKDrawableObject *) - hitTest:partCode:
 Performs a hit test but also returns the hit part code. More...
 
(NSImage *) - imageOfObjects
 
(NSIndexSet *) - indexesOfObjectsInArray:
 Given a list of objects that are part of this layer, return an index set for them. More...
 
(NSUInteger- indexOfObject:
 Returns the stacking position of the given object. More...
 
(void) - insertObject:inObjectsAtIndex:
 Adds an object to the layer. More...
 
(void) - insertObjects:atIndexes:
 Inserts a set of objects at the indexes given. More...
 
(BOOL- isHighlightedForDrag
 Query whether the layer is currently highlighted for a drag (receive) operation. More...
 
(BOOL- isRecordingPasteOffset
 Return whether the paste offset will be recorded for the current drag operation. More...
 
(DKObjectOwnerLayer *) - layer
 Returns the layer of a drawable's container - since this is that layer, returns self. More...
 
(DKLayerCacheOption) - layerCacheOption
 Query whether the layer caches its content in an offscreen layer when not active. More...
 
(void) - moveDownObject:
 Moves the object down in the stacking order. More...
 
(void) - moveObject:toIndex:
 Movesthe object to the given stacking position index. More...
 
(void) - moveObjectsAtIndexes:toIndex:
 Moves the objects indexed by the set to the given stacking position index. More...
 
(void) - moveObjectsInArray:toIndex:
 Moves the objects in the array to the given stacking position index. More...
 
(void) - moveObjectToBottom:
 Moves the object to the bottom of the stacking order. More...
 
(void) - moveObjectToTop:
 Moves the object to the top of the stacking order. More...
 
(void) - moveUpObject:
 Moves the object up in the stacking order. More...
 
(NSEnumerator *) - objectEnumeratorForUpdateRect:inView:
 Return an iterator that will enumerate the objects needing update. More...
 
(NSEnumerator *) - objectEnumeratorForUpdateRect:inView:options:
 Return an iterator that will enumerate the objects needing update. More...
 
(DKDrawableObject *) - objectInObjectsAtIndex:
 Returns the object at a given stacking position index. More...
 
(NSArray *) - objects
 Returns all owned objects. More...
 
(void) - objects:wereDraggedFromPoint:toPoint:
 Sets the paste offset (distance between successively pasted objects) More...
 
(NSArray *) - objectsAtIndexes:
 Returns a list of objects given by the index set. More...
 
(NSArray *) - objectsForUpdateRect:inView:
 Return the objects needing update. More...
 
(NSArray *) - objectsForUpdateRect:inView:options:
 Return the objects needing update. More...
 
(NSArray *) - objectsInRect:
 Finds all objects touched by the given rect. More...
 
(NSArray *) - objectsReturning:toSelector:
 Returns objects that respond to the selector with the value <answer> <selector> a selector taking no parameters. More...
 
(NSArray *) - objectsWithStyle:
 Returns objects that share the given style. More...
 
(NSInteger- pasteCount
 
(NSSize) - pasteOffset
 Returns the paste offset (distance between successively pasted objects) More...
 
(NSPoint) - pasteOrigin
 Return the current point where pasted object will be positioned relative to. More...
 
(NSData *) - pdfDataOfObjects
 
(DKDrawableObject *) - pendingObject
 Returns the pending object, if any, in the layer. More...
 
(void) - refreshAllObjects
 Causes all visible objects to redraw themselves. More...
 
(void) - refreshObjectsInContainer:
 Causes all objects in the passed array, set or other container to redraw themselves. More...
 
(void) - removeAllObjects
 Removes all objects from the layer. More...
 
(void) - removeObject:
 Removes the object from the layer. More...
 
(void) - removeObjectAtIndex:
 Removes the object at the given stacking position index. More...
 
(void) - removeObjectFromObjectsAtIndex:
 Removes an object from the layer. More...
 
(void) - removeObjectsAtIndexes:
 Removes objects from the indexes listed by the set. More...
 
(void) - removeObjectsInArray:
 Removes a set of objects from the layer. More...
 
(void) - removePendingObject
 Removes a pending object in the situation that the creation was unsuccessful. More...
 
(NSAffineTransform *) - renderingTransform
 Returns the layer's transform used when rendering objects within. More...
 
(void) - replaceObjectInObjectsAtIndex:withObject:
 Replaces an object in the layer with another. More...
 
(void) - setAllowsEditing:
 Sets whether the layer permits editing of its objects. More...
 
(void) - setAllowsSnapToObjects:
 Sets whether the layer permits snapping to its objects. More...
 
(void) - setHighlightedForDrag:
 Set whether the layer is currently highlighted for a drag (receive) operation. More...
 
(void) - setLayerCacheOption:
 Set whether the layer caches its content in an offscreen layer when not active, and how. More...
 
(void) - setObjects:
 Sets the objects that this layer owns. More...
 
(void) - setPasteOffset:
 Sets the paste offset (distance between successively pasted objects) More...
 
(void) - setPasteOffsetX:y:
 Establish the paste offset - a value used to position items when pasting and duplicating. More...
 
(void) - setPasteOrigin:
 Sets the current point where pasted object will be positioned relative to. More...
 
(void) - setRecordingPasteOffset:
 Set whether the paste offset will be recorded for the current drag operation. More...
 
(void) - setStorage:
 
(NSPoint) - snappedMousePoint:forObject:withControlFlag:
 Snap a (mouse) point to grid, guide or other object according to settings. More...
 
(NSPoint) - snapPoint:toAnyObjectExcept:snapTolerance:
 Snap a point to any existing object control point within tolerance. More...
 
(id< DKObjectStorage >) - storage
 Returns the storage object for the layer. More...
 
(IBAction) - toggleShowStorageDebuggingPath:
 Toggles whether the debugging path is overlaid afterdrawing the content. More...
 
(IBAction) - toggleSnapToObjects:
 Sets the snapping state for the layer. More...
 
(DKDrawableObject *) - topObject
 Returns the topmost object. More...
 
(NSRect- unionOfAllObjectBounds
 Return the union of all the visible objects in the layer. More...
 
(BOOL- updatePasteCountWithPasteboard:
 Detect whether the paste from the pasteboard is a new paste, or a repeat paste. More...
 
(NSArray *) - visibleObjects
 Returns objects that are visible to the user, but may be locked. More...
 
(NSArray *) - visibleObjectsInRect:
 Returns objects that are visible to the user, intersect the rect, but may be locked. More...
 
- Instance Methods inherited from DKLayer
(NSRect- activeCursorRect
 Return a rect where the layer's cursor is shown when the mouse is within it. More...
 
(void) - addMetadata:
 
(void) - addUserInfo:
 
(NSSet *) - allRegisteredStyles
 Return all of registered styles used by the layer. More...
 
(NSSet *) - allStyles
 Return all of styles used by the layer. More...
 
(CGFloat- alpha
 Returns the alpha level for the layer as a whole. More...
 
(void) - beginDrawing
 Called before the layer starts drawing its content. More...
 
(NSBitmapImageRep *) - bitmapRepresentationWithDPI:
 Returns the layer's content as a transparent bitmap having the given DPI. More...
 
(BOOL- clipsDrawingToInterior
 Whether the drawing will be clipped to the interior or not. More...
 
(NSColor *) - colourForKey:
 
(IBAction) - copy:
 
(NSView *) - currentView
 Returns the view which is either currently drawing the layer, or the one that mouse events are coming from. More...
 
(NSCursor *) - cursor
 Returns the cursor to display while the mouse is over this layer while it's active. More...
 
(DKDrawing *) - drawing
 Returns the drawing that the layer belongs to. More...
 
(void) - drawingDidChangeMargins:
 
(void) - drawingDidChangeToSize:
 Called when the drawing's size is changed - this gives layers that need to know about this a direct notification. More...
 
(void) - drawingHasNewUndoManager:
 Called when the drawing's undo manager is changed - this gives objects that cache the UM a chance to update their references. More...
 
(void) - drawRect:inView:
 Main entry point for drawing the layer and its contents to the drawing's views. More...
 
(void) - endDrawing
 Called after the layer has finished drawing its content. More...
 
(void) - flagsChanged:
 Respond to a change in the modifier key state. More...
 
(CGFloat- floatValueForKey:
 
(BOOL- hasMetadataForKey:
 
(void) - hideInfoWindow
 Hides the info window if it's visible. More...
 
(IBAction) - hideLayer:
 User interface level method can be linked to a menu or other appropriate UI widget. More...
 
(void) - hideRulerMarkers
 
(BOOL- hitLayer:
 Detect whether the layer was "hit" by a point. More...
 
(NSUInteger- indexInGroup
 Gets the layer's index within the group that the layer is contained in. More...
 
(NSInteger- intValueForKey:
 
(BOOL- isActive
 Is the layer the active layer? More...
 
(BOOL- isChildOfGroup:
 Determine whether a given group is the parent of this layer, or anywhere above it in the hierarchy. More...
 
(BOOL- isOpaque
 Is the layer opaque or transparent? More...
 
(DKKnob *) - knobs
 
(BOOL- knobsShouldAdjustToViewScale
 
(void) - layerDidBecomeActiveLayer
 The layer was made the active layer by the owning drawing. More...
 
(void) - layerDidResignActiveLayer
 The layer is no longer the active layer. More...
 
(DKLayerGroup *) - layerGroup
 Gets the group that the layer is contained in. More...
 
(BOOL- layerMayBecomeActive
 Returns whether the layer can become the active layer. More...
 
(BOOL- layerMayBeDeleted
 Return whether the layer can be deleted. More...
 
(NSString *) - layerName
 Returns the layer's name. More...
 
(NSUInteger- level
 Returns the hierarchical level of this layer, i.e. More...
 
(BOOL- locked
 Returns whether the layer is locked or not. More...
 
(BOOL- lockedOrHidden
 Returns whether the layer is locked or hidden. More...
 
(IBAction) - lockLayer:
 User interface level method can be linked to a menu or other appropriate UI widget. More...
 
(IBAction) - logDescription:
 Debugging method. More...
 
(NSMenu *) - menuForEvent:inView:
 Allows a contextual menu to be built for the layer or its contents. More...
 
(NSMutableDictionary *) - metadata
 
(NSUInteger- metadataChecksum
 
(void) - metadataDidChangeKey:
 
(DKMetadataItem *) - metadataItemForKey:
 
(NSArray *) - metadataKeys
 
(id- metadataObjectForKey:
 
(void) - metadataWillChangeKey:
 
(void) - mouseDown:inView:
 The mouse went down in this layer. More...
 
(void) - mouseDragged:inView:
 Subclasses must override to be notified of mouse dragged events. More...
 
(void) - mouseMoved:inView:
 
(void) - mouseUp:inView:
 Override to respond to the event. More...
 
(BOOL- pasteboard:hasAvailableTypeForOperation:
 Tests whether the pasteboard has any of the types the layer is interested in receiving for the given operation. More...
 
(NSArray *) - pasteboardTypesForOperation:
 Return the pasteboard types this layer is able to receive in a given operation (drop or paste) More...
 
(NSData *) - pdf
 Returns the content of the layer as a pdf. More...
 
(void) - removeMetadataForKey:
 
(void) - replaceMatchingStylesFromSet:
 Substitute styles with those in the given set. More...
 
(BOOL- rulerMarkerUpdatesEnabled
 
(DKLayerMetadataSchema) - schema
 
(NSColor *) - selectionColour
 Returns the currently preferred selection colour for this layer. More...
 
(void) - setAlpha:
 Sets the alpha level for the layer. More...
 
(void) - setClipsDrawingToInterior:
 Sets whether drawing is limited to the interior area or not. More...
 
(void) - setColour:forKey:
 
(void) - setFloatValue:forKey:
 
(void) - setInfoWindowBackgroundColour:
 Sets the background colour of the small floating info window. More...
 
(void) - setIntValue:forKey:
 
(void) - setKnobs:
 
(void) - setKnobsShouldAdustToViewScale:
 
(void) - setLayerGroup:
 Sets the group that the layer is contained in - called automatically when the layer is added to a group. More...
 
(void) - setLayerName:
 Sets the user-readable name of the layer. More...
 
(void) - setLocked:
 Sets whether the layer is locked or not. More...
 
(void) - setMetadata:
 
(void) - setMetadataItem:forKey:
 
(void) - setMetadataItemType:forKey:
 
(void) - setMetadataItemValue:forKey:
 
(void) - setMetadataObject:forKey:
 
(void) - setNeedsDisplay:
 Flags the whole layer as needing redrawing. More...
 
(void) - setNeedsDisplayInRect:
 Flags part of a layer as needing redrawing. More...
 
(void) - setNeedsDisplayInRects:
 Marks several areas for update at once. More...
 
(void) - setNeedsDisplayInRects:withExtraPadding:
 Marks several areas for update at once. More...
 
(void) - setRulerMarkerUpdatesEnabled:
 
(void) - setSelectionColour:
 Sets the colour preference to use for selected objects within this layer. More...
 
(void) - setShouldDrawToPrinter:
 Set whether this layer should be included in printed output. More...
 
(void) - setSize:forKey:
 
(void) - setString:forKey:
 
(void) - setupMetadata
 
(void) - setUserInfo:
 
(void) - setUserInfoObject:forKey:
 
(void) - setVisible:
 Sets whether the layer is visible or not. More...
 
(BOOL- shouldAutoActivateWithEvent:
 Should the layer automatically activate on a click if the view has this behaviour set? More...
 
(BOOL- shouldDrawToPrinter
 Return whether the layer should be part of the printed output or not. More...
 
(void) - showInfoWindowWithString:atPoint:
 Displays a small floating info window near the point p containg the string. More...
 
(IBAction) - showLayer:
 User interface level method can be linked to a menu or other appropriate UI widget. More...
 
(NSSize) - sizeForKey:
 
(NSString *) - stringForKey:
 
(BOOL- supportsMetadata
 
(NSImage *) - thumbnail
 
(NSImage *) - thumbnailImageWithSize:
 Returns an image of the layer a the given size. More...
 
(IBAction) - toggleLayerLock:
 User interface level method can be linked to a menu or other appropriate UI widget. More...
 
(IBAction) - toggleLayerVisible:
 User interface level method can be linked to a menu or other appropriate UI widget. More...
 
(NSUndoManager *) - undoManager
 Obtains the undo manager that is handling undo for the drawing and hence, this layer. More...
 
(NSString *) - uniqueKey
 Returns the layer's unique key. More...
 
(IBAction) - unlockLayer:
 User interface level method can be linked to a menu or other appropriate UI widget. More...
 
(void) - updateMetadataKeys
 
(void) - updateRulerMarkersForRect:
 
(NSMutableDictionary *) - userInfo
 Return the attached user info. More...
 
(id- userInfoObjectForKey:
 Return an item of user info. More...
 
(BOOL- visible
 Is the layer visible? More...
 
(void) - wasAddedToDrawing:
 Notifies the layer that it or a group containing it was added to a drawing. More...
 
(BOOL- writePDFDataToPasteboard:
 Writes the content of the layer as a pdf to a nominated pasteboard. More...
 
- Instance Methods inherited from NSObject
(NSString *) - address
 
(DKStyleRegistry *) - applicationWillReturnStyleRegistry
 
(BOOL- canBeUsedWithSelectionTool
 
(id- categoryManager:shouldReplaceObject:withObject:
 
(Class- classForCoder
 
(NSColor *) - colorValue
 
(NSColor *) - colourValue
 
(id- copy
 
(void) - dealloc
 
(id- deepCopy
 
(NSDictionary *) - dimensionValuesForArrowStroke:
 
(CGFloat- drawing:convertDistanceToExternalCoordinates:
 
(NSPoint) - drawing:convertLocationToExternalCoordinates:
 
(void) - drawing:didDrawRect:inView:
 
(void) - drawing:willDrawRect:inView:
 
(NSString *) - drawing:willReturnAbbreviationForUnit:
 
(NSString *) - drawing:willReturnFormattedCoordinateForDistance:
 
(CGFloat- drawingWillReturnUnitToPointsConversonFactor:
 
(void) - finalize
 
(NSString *) - hexString
 
(void) - hotspot:didEndTrackingWithEvent:inView:
 
(void) - hotspot:isTrackingWithEvent:inView:
 
(void) - hotspot:willBeginTrackingWithEvent:inView:
 
(NSData *) - imageData
 
(NSImage *) - imageResourceNamed:
 
(id- init
 
(id- initWithExpression:
 
(id- instantiateObjectWithShortName:parameters:
 
(BOOL- isLiteralValue
 
(void) - layoutManager:willPlaceGlyphAtIndex:atLocation:pathAngle:yOffset:
 
(void) - menuItem:wasAddedForObject:inCategory:
 
(BOOL- moveObjectTo:position:slope:userInfo:
 
(id- mutableCopy
 
(void) - oneShotComplete
 
(void) - oneShotHasReached:
 
(void) - oneShotWillBegin
 
(void) - path:elementIndex:type:points:subPathIndex:subPathClosed:contextInfo:
 
(id- placeLinkFromPoint:toPoint:onPath:linkNumber:userInfo:
 
(id- placeObjectAtPoint:onPath:position:slope:userInfo:
 
(NSPoint) - point
 
(NSPoint) - pointForTextLayout
 
(DKStyle *) - registry:shouldReplaceStyle:withStyle:
 
(NSBezierPath *) - renderer:willRenderPath:
 
(void) - routeFinder:progressHasReached:
 
(void) - setValue:forNumericParameter:
 
(NSString *) - stringValue
 
(CGFloat- taperFactorAtDistance:onPath:ofLength:
 
(void) - toolDidPerformUndoableAction:
 
(void) - toolWillPerformUndoableAction:
 
(NSURL *) - url
 
- Instance Methods inherited from <NSObject>
(NSString *) - description
 
(NSUInteger- hash
 
(BOOL- isEqual:
 
- Instance Methods inherited from <NSKeyValueBindingCreation>
(void) - bind:toObject:withKeyPath:options:
 
(NSArray *) - exposedBindings
 
(NSDictionary *) - infoForBinding:
 
(NSArray *) - optionDescriptionsForBinding:
 
(void) - unbind:
 
(Class- valueClassForBinding:
 
- Instance Methods inherited from <NSCoding>
(void) - encodeWithCoder:
 
(id- initWithCoder:
 
- Instance Methods inherited from <DKKnobOwner>
(BOOL- knobsWantDrawingActiveState
 
(CGFloat- knobsWantDrawingScale
 
- Instance Methods inherited from <DKDrawableContainer>
(DKDrawing *) - drawing
 
(DKImageDataManager *) - imageManager
 
(DKMetadataItem *) - metadataItemForKey:
 
(id- metadataObjectForKey:
 

Class Methods

(DKLayerCacheOption) + defaultLayerCacheOption
 
(void) + setDefaultLayerCacheOption:
 
(void) + setStorageClass:
 
(Class+ storageClass
 
- Class Methods inherited from DKLayer
(BOOL+ metadataChangesAreUndoable
 
(NSColor *) + selectionColourForIndex:
 
(NSArray *) + selectionColours
 Returns the list of colours used for supplying the selection colours. More...
 
(void) + setMetadataChangesAreUndoable:
 
(void) + setSelectionColours:
 Allows a list of colours to be set for supplying the selection colours. More...
 
- Class Methods inherited from NSObject
(id+ alloc
 
(Class+ class
 
(void) + initialize
 
(void) + load
 
(id+ new
 
- Class Methods inherited from <NSKeyValueBindingCreation>
(void) + exposeBinding:
 

Protected Attributes

BOOL mShowStorageDebugging
 

Detailed Description

This layer class can be the owner of any number of DKDrawableObjects.

This layer class can be the owner of any number of DKDrawableObjects. It implements the ability to contain and render these objects.

It does NOT support the concept of a selection, or of a list of selected objects (DKObjectDrawingLayer subclasses this to provide that functionality).

This split between the owner/renderer layer and selection allows a more fine-grained opportunity to subclass for different application needs.

Layer caching:

When a layer is NOT active, it may boost drawing performance to cache the layer's contents offscreen. This is especially beneficial if you are using many layers. By setting the cache option, you can control how caching is done. If set to "none", objects are never drawn using a cache, but simply drawn in the usual way. If "pdf", the cache is an NSPDFImageRep, which stores the image as a PDF and so draws it at full vector quality at all zoom scales. If "CGLayer", an offscreen CGLayer is used which gives the fastest rendering but will show pixellation at higher zooms. If both pdf and CGLayer are set, both caches will be created and the CGLayer one used when DKDrawing has its "low quality" hint set, and the PDF rep otherwise.

The cache is only used for screen drawing.

NOTE: PDF caching has been shown to be actually slower when there are many objects, espcially with advanced storage in use. This is because it's an all-or-nothing rendering proposition which direct drawing of a layer's objects is not.

Method Documentation

- (void) addObject: (DKDrawableObject *)  obj

Adds an object to the layer.

If layer locked, does nothing

Parameters
objthe object to add
- (void) addObject: (DKDrawableObject *)  obj
atIndex: (NSUInteger index 
- (void) addObjectPendingCreation: (DKDrawableObject *)  pend

Adds a new object to the layer pending successful interactive creation.

When interactively creating objects, it is preferable to create the object successfully before committing it to the layer - this gives the caller a chance to abort the creation without needing to be concerned about any undos, etc. The pending object is drawn on top of all others as normal but until it is committed, it creates no undo task for the layer.

Parameters
penda new potential object to be added to the layer
- (void) addObjects: (NSArray *)  objects
fromPasteboard: (NSPasteboard *)  pb
atDropLocation: (NSPoint)  p 

Add objects to the layer from the pasteboard.

Parameters
objectsa list of objects already dearchived from the pasteboard
pbthe pasteboard (for information only)
pthe drop location of the objects, defined as the lower left corner of the drag image - thus
Returns
none a multiple selection is positioned at the point p, with others maintaining their positions relative to this object as in the original set. This is the preferred method to use when pasting or dropping anything, because the subclass that implements selection overrides this to handle the selection also. Thus when pasting non-native objects, convert them to native objects and pass to this method in an array.
- (void) addObjectsFromArray: (NSArray *)  objs

Adds a set of objects to the layer.

Take care that no objects are already owned by any layer - this doesn't check.

Parameters
objsan array of DKDrawableObjects, or subclasses.
- (BOOL) addObjectsFromArray: (NSArray *)  objs
bounds: (NSRect bounds
relativeToPoint: (NSPoint)  origin
pinToInterior: (BOOL pin 

Adds a set of objects to the layer offsetting their location by the given delta values relative to a given point.

Used for paste and other similar ops. The objects are placed such that their bounding rect's origin ends up at <origin>, regardless of the object's current location. Note that if pin is YES, the method will not return NO, as no object was placed outside the interior. Note that the <bounds> parameter can differ when calculated compared with the original recorded bounds during the copy. This is because bounds often takes into account other relationships such as the layer's knobs and so on, which might no be available when pasting. For accurate positioning, the original bounds should be passed.

Parameters
objsa list of DKDrawableObjects to add
boundsthe original bounding rect of the objects. If NSZeroRect, it is calculated.
originthe required relative origin of the group of objects
pinif YES, object locations are pinned to the drawing interior
Returns
YES if all objects were placed within the interior bounds of the drawing, NO if any object was placed outside the interior.
- (BOOL) addObjectsFromArray: (NSArray *)  objs
relativeToPoint: (NSPoint)  origin
pinToInterior: (BOOL pin 

Adds a set of objects to the layer offsetting their location by the given delta values relative to a given point.

Used for paste and other similar ops. The objects are placed such that their bounding rect's origin ends up at <origin>, regardless of the object's current location. Note that if pin is YES, the method will not return NO, as no object was placed outside the interior.

Parameters
objsa list of DKDrawableObjects to add
originthe required relative origin of the group of objects
pinif YES, object locations are pinned to the drawing interior
Returns
YES if all objects were placed within the interior bounds of the drawing, NO if any object was placed outside the interior.
- (BOOL) allowsEditing

Does the layer permit editing of its objects?

Locking and hiding the layer also disables editing

Returns
YES if editing will take place, NO if it is prevented
- (BOOL) allowsSnapToObjects

Does the layer permit snapping to its objects?

Returns
YES if snapping allowed
- (void) applyTransformToObjects: (NSAffineTransform *)  transform

Modifies the objects by applying the given transform to each of them.

This modifies the geometry of each object by applying the transform to each one. The purpose of this is to permit gross changes to a drawing's layout if the client application requires it - for example scaling all objects to some new size.

Parameters
transforma transform
- (NSArray*) availableObjects

Returns objects that are available to the user, that is, not locked or invisible.

If the layer itself is locked, returns the empty list

Returns
an array of available objects
- (NSArray*) availableObjectsInRect: (NSRect aRect

Returns objects that are available to the user, that is, not locked or invisible and that intersect the rect.

If the layer itself is locked, returns the empty list

Parameters
aRect- objects must also intersect this rect
Returns
an array of available objects
- (NSArray*) availableObjectsOfClass: (Class aClass

Returns objects that are available to the user of the given class.

If the layer itself is locked, returns the empty list

Parameters
aClass- class of the desired objects
Returns
an array of available objects
- (DKDrawableObject*) bottomObject

Returns the bottom object.

Returns
the bottom object
- (void) commitPendingObjectWithUndoActionName: (NSString *)  actionName

Commits the pending object to the layer and sets up the undo task action name.

When interactively creating objects, if the creation succeeded, the pending object should be committed to the layer permanently. This does that by adding it using addObject. The undo task thus created is given the action name (note that other operations can also change this later).

Parameters
actionNamethe action name to give the undo manager after committing the object
- (NSUInteger) countOfObjects
+ (DKLayerCacheOption) defaultLayerCacheOption
- (void) drawable: (DKDrawableObject *)  obj
needsDisplayInRect: (NSRect rect 
- (void) drawable: (DKDrawableObject *)  obj
wasDoubleClickedAtPoint: (NSPoint)  mp 

An object owned by the layer was double-clicked.

Override to use

Parameters
objthe object hit
mpthe mouse point of the click
- (void) drawHighlightingForDrag

Draws the highlighting to indicate the layer is a drag target.

Is only called when the drag highlight is YES. Override for different highlight effect.

- (void) drawPendingObjectInView: (NSView *)  aView

Draws the pending object, if any, in the layer - called by drawRect:inView:

Pending objects are drawn normally is if part of the current list, and on top of all others. Subclasses may need to override this if the selected state needs passing differently. Typically pending objects will be drawn selected, so the default is YES.

Parameters
aViewthe view being drawn into
- (void) drawVisibleObjects
- (DKDrawableObject*) hitTest: (NSPoint)  point

Find which object was hit by the given point, if any.

Parameters
pointa point to test against
Returns
the object hit, or nil if none

Implements DKLayer.

- (DKDrawableObject*) hitTest: (NSPoint)  point
partCode: (NSInteger *)  part 

Performs a hit test but also returns the hit part code.

Parameters
pointthe point to test
partpointer to int, receives the partcode hit as a result of the test. Can be NULL to ignore
Returns
the object hit, or nil if none
- (NSImage*) imageOfObjects
- (NSIndexSet*) indexesOfObjectsInArray: (NSArray *)  objs

Given a list of objects that are part of this layer, return an index set for them.

Parameters
objsa list of objects
Returns
an index set listing the array index positions for the objects passed
- (NSUInteger) indexOfObject: (DKDrawableObject *)  obj

Returns the stacking position of the given object.

Will return NSNotFound if the object is not presently owned by the layer

Parameters
objthe object
Returns
the object's stacking order index

Reimplemented from <DKDrawableContainer>.

- (void) insertObject: (DKDrawableObject *)  obj
inObjectsAtIndex: (NSUInteger indx 

Adds an object to the layer.

Parameters
objthe object to add
indexthe index at which the object should be inserted
Returns
none these. Adding multiple objects calls this multiple times.
- (void) insertObjects: (NSArray *)  objs
atIndexes: (NSIndexSet *)  set 

Inserts a set of objects at the indexes given.

The array and set order should match, and have equal counts.

Parameters
objsthe objects to insert
setthe indexes where they should be inserted
- (BOOL) isHighlightedForDrag

Query whether the layer is currently highlighted for a drag (receive) operation.

Returns
YES if highlighted, NO otherwise
- (BOOL) isRecordingPasteOffset

Return whether the paste offset will be recorded for the current drag operation.

Returns
YES if paste offset will be recorded, NO otherwise
- (DKObjectOwnerLayer*) layer

Returns the layer of a drawable's container - since this is that layer, returns self.

See DKDrawableObject which also implements this protocol

Returns
self

Reimplemented from <DKDrawableContainer>.

- (DKLayerCacheOption) layerCacheOption

Query whether the layer caches its content in an offscreen layer when not active.

Layers can cache their entire contents offscreen when they are inactive. This can boost drawing performance when there are many layers, or the layers have complex contents. When the layer is deactivated the cache is updated, on activation the "real" content is drawn.

Returns
the current cache option
- (void) moveDownObject: (DKDrawableObject *)  obj

Moves the object down in the stacking order.

Parameters
objthe object to move
- (void) moveObject: (DKDrawableObject *)  obj
toIndex: (NSUInteger indx 

Movesthe object to the given stacking position index.

Used to implement all the other moveTo.. ops

Parameters
objthe object to move
ithe index it should be moved to
- (void) moveObjectsAtIndexes: (NSIndexSet *)  set
toIndex: (NSUInteger indx 

Moves the objects indexed by the set to the given stacking position index.

Useful for restacking several objects

Parameters
seta set of indexes
indxthe index it should be moved to
- (void) moveObjectsInArray: (NSArray *)  objs
toIndex: (NSUInteger indx 

Moves the objects in the array to the given stacking position index.

Useful for restacking several objects. Array passed can be the selection. The order of objects in the array is preserved relative to one another, after the operation the lowest indexed object will be at <indx> and the rest at consecutive indexes above it.

Parameters
objsan array of objects already owned by the layer
indxthe index it should be moved to
- (void) moveObjectToBottom: (DKDrawableObject *)  obj

Moves the object to the bottom of the stacking order.

Parameters
objobject to move
- (void) moveObjectToTop: (DKDrawableObject *)  obj

Moves the object to the top of the stacking order.

Parameters
objthe object to move
- (void) moveUpObject: (DKDrawableObject *)  obj

Moves the object up in the stacking order.

Parameters
objobject to move
- (NSEnumerator*) objectEnumeratorForUpdateRect: (NSRect rect
inView: (NSView *)  aView 

Return an iterator that will enumerate the objects needing update.

The iterator returned iterates in bottom-to-top order and includes only those objects that are visible and whose bounds intersect the update region of the view. If the view is nil <rect> is still used to determine inclusion.

Parameters
rectthe update rect as passed to a drawRect: method of a view
aViewthe view being updated, if any (may be nil)
Returns
an iterator
- (NSEnumerator*) objectEnumeratorForUpdateRect: (NSRect rect
inView: (NSView *)  aView
options: (DKObjectStorageOptions)  options 

Return an iterator that will enumerate the objects needing update.

The iterator returned iterates in bottom-to-top order and includes only those objects that are visible and whose bounds intersect the update region of the view. If the view is nil <rect> is still used to determine inclusion.

Parameters
rectthe update rect as passed to a drawRect: method of a view
aViewthe view being updated, if any (may be nil)
optionsvarious flags that you can pass to modify behaviour:
Returns
an iterator
- (DKDrawableObject*) objectInObjectsAtIndex: (NSUInteger indx

Returns the object at a given stacking position index.

Parameters
indexthe stacking position
- (NSArray*) objects

Returns all owned objects.

Returns
an array of the objects
- (void) objects: (NSArray *)  objects
wereDraggedFromPoint: (NSPoint)  startPt
toPoint: (NSPoint)  endPt 

Sets the paste offset (distance between successively pasted objects)

Parameters
objectsthe list of objects that were moved
startPtthe starting point for the drag
endPtthe ending point for the drag
Returns
none if offset recording is currently set to YES, then resets the record flag.
- (NSArray*) objectsAtIndexes: (NSIndexSet *)  set

Returns a list of objects given by the index set.

Parameters
setan index set
Returns
a list of objects
- (NSArray*) objectsForUpdateRect: (NSRect rect
inView: (NSView *)  aView 

Return the objects needing update.

If the view is nil <rect> is used to determine inclusion.

Parameters
rectthe update rect as passed to a drawRect: method of a view
aViewthe view being updated, if any (may be nil)
Returns
an array, the objects needing update, in drawing order
- (NSArray*) objectsForUpdateRect: (NSRect rect
inView: (NSView *)  aView
options: (DKObjectStorageOptions)  options 

Return the objects needing update.

If the view is nil <rect> is used to determine inclusion.

Parameters
rectthe update rect as passed to a drawRect: method of a view
aViewthe view being updated, if any (may be nil)
optionsvarious flags that you can pass to modify behaviour:
Returns
an array, the objects needig update, in drawing order
- (NSArray*) objectsInRect: (NSRect rect

Finds all objects touched by the given rect.

Test for inclusion by calling the object's intersectsRect method. Can be used to select objects in a given rect or for any other purpose. For selections, the results can be passed directly to exchangeSelection:

Parameters
recta rectangle
Returns
a list of objects touched by the rect
- (NSArray*) objectsReturning: (NSInteger answer
toSelector: (SEL selector 

Returns objects that respond to the selector with the value <answer> <selector> a selector taking no parameters.

This is a very simple type of predicate test. Note - the method <selector> must not return anything larger than an int or it will be ignored and the result may be wrong.

Returns
an array, objects that match the value of <answer>
- (NSArray*) objectsWithStyle: (DKStyle *)  style

Returns objects that share the given style.

The style is compared by unique key, so style clones are not considered a match. Unavailable objects are also included.

Parameters
stylethe style to compare
Returns
an array of those objects that have the style
- (NSInteger) pasteCount
- (NSSize) pasteOffset

Returns the paste offset (distance between successively pasted objects)

Returns
the paste offset as a NSSize
- (NSPoint) pasteOrigin

Return the current point where pasted object will be positioned relative to.

See paste: for how this is used

Returns
the paste origin
- (NSData*) pdfDataOfObjects
- (DKDrawableObject*) pendingObject

Returns the pending object, if any, in the layer.

Returns
the pending object, or nil
- (void) refreshAllObjects

Causes all visible objects to redraw themselves.

- (void) refreshObjectsInContainer: (id container

Causes all objects in the passed array, set or other container to redraw themselves.

Parameters
containera container of drawable objects. Any NSArray or NSSet is acceptable
- (void) removeAllObjects

Removes all objects from the layer.

- (void) removeObject: (DKDrawableObject *)  obj

Removes the object from the layer.

Parameters
objthe object to remove
- (void) removeObjectAtIndex: (NSUInteger indx

Removes the object at the given stacking position index.

Parameters
indexthe stacking index value
- (void) removeObjectFromObjectsAtIndex: (NSUInteger indx

Removes an object from the layer.

Parameters
indexthe index at which the object should be removed
Returns
none these. Removing multiple objects calls this multiple times.
- (void) removeObjectsAtIndexes: (NSIndexSet *)  set

Removes objects from the indexes listed by the set.

Parameters
setan index set
- (void) removeObjectsInArray: (NSArray *)  objs

Removes a set of objects from the layer.

- (void) removePendingObject

Removes a pending object in the situation that the creation was unsuccessful.

When interactively creating objects, if for any reason the creation failed, this should be called to remove the object from the layer without triggering any undo tasks, and to remove any the object itself made

- (NSAffineTransform*) renderingTransform

Returns the layer's transform used when rendering objects within.

Returns the identity transform

Returns
a transform

Reimplemented from <DKDrawableContainer>.

- (void) replaceObjectInObjectsAtIndex: (NSUInteger indx
withObject: (DKDrawableObject *)  obj 

Replaces an object in the layer with another.

Parameters
indexthe index at which the object should be exchanged
objthe object that will replace the item at index
Returns
none can be observed if desired to get notified of these events.
- (void) setAllowsEditing: (BOOL editable

Sets whether the layer permits editing of its objects.

Parameters
editableYES to enable editing, NO to prevent it
- (void) setAllowsSnapToObjects: (BOOL snap

Sets whether the layer permits snapping to its objects.

Parameters
snapYES to allow snapping
+ (void) setDefaultLayerCacheOption: (DKLayerCacheOption)  option
- (void) setHighlightedForDrag: (BOOL highlight

Set whether the layer is currently highlighted for a drag (receive) operation.

Parameters
highlightYES to highlight, NO otherwise
- (void) setLayerCacheOption: (DKLayerCacheOption)  option

Set whether the layer caches its content in an offscreen layer when not active, and how.

Layers can cache their entire contents offscreen when they are inactive. This can boost drawing performance when there are many layers, or the layers have complex contents. When the layer is deactivated the cache is updated, on activation the "real" content is drawn.

Parameters
optionthe desired cache option
- (void) setObjects: (NSArray *)  objs

Sets the objects that this layer owns.

Parameters
objsan array of DKDrawableObjects, or subclasses thereof
- (void) setPasteOffset: (NSSize)  offset

Sets the paste offset (distance between successively pasted objects)

Parameters
offsetthe paste offset as a NSSize
- (void) setPasteOffsetX: (CGFloat x
y: (CGFloat y 

Establish the paste offset - a value used to position items when pasting and duplicating.

The values passed will be adjusted to the nearest grid interval if snap to grid is on.

Parameters
x>,<ythe x and y values of the offset
- (void) setPasteOrigin: (NSPoint)  po

Sets the current point where pasted object will be positioned relative to.

See paste: for how this is used

Parameters
pothe desired paste origin.
- (void) setRecordingPasteOffset: (BOOL record

Set whether the paste offset will be recorded for the current drag operation.

Parameters
recordYES to record the offset
- (void) setStorage: (id< DKObjectStorage >)  storage
+ (void) setStorageClass: (Class aClass
- (NSPoint) snappedMousePoint: (NSPoint)  mp
forObject: (DKDrawableObject *)  obj
withControlFlag: (BOOL snapControl 

Snap a (mouse) point to grid, guide or other object according to settings.

Usually called from snappedMousePoint: method in DKDrawableObject

Parameters
pa point
Returns
the modified point, or the original point
- (NSPoint) snapPoint: (NSPoint)  p
toAnyObjectExcept: (DKDrawableObject *)  except
snapTolerance: (CGFloat tol 

Snap a point to any existing object control point within tolerance.

If snap to object is not set for this layer, this simply returns the original point unmodified. currently uses hitPart to test for a hit, so tolerance is ignored and objects apply their internal hit testing tolerance.

Parameters
pa point
exceptdon't snap to this object (intended to be the one being snapped)
tolhas to be within this distance to snap
Returns
the modified point, or the original point
- (id<DKObjectStorage>) storage

Returns the storage object for the layer.

Returns
a storage object
+ (Class) storageClass
- (IBAction) toggleShowStorageDebuggingPath: (id sender

Toggles whether the debugging path is overlaid afterdrawing the content.

This is purely to assist with storage debugging and should not be invoked in production code.

- (IBAction) toggleSnapToObjects: (id sender

Sets the snapping state for the layer.

- (DKDrawableObject*) topObject

Returns the topmost object.

Returns
the topmost object
- (NSRect) unionOfAllObjectBounds

Return the union of all the visible objects in the layer.

If there are no visible objects, returns NSZeroRect.

Avoid using for refreshing objects. It is more efficient to use refreshAllObjects

Returns
a rect, the union of all visible object's bounds in the layer
- (BOOL) updatePasteCountWithPasteboard: (NSPasteboard *)  pb

Detect whether the paste from the pasteboard is a new paste, or a repeat paste.

Since this is a one-shot method that changes the internal state of the layer, it should not be called except internally to manage the auto paste repeat. It may either increment or reset the paste count. It also sets the paste origin to the origin of the pasted objects' bounds.

Parameters
pbthe pasteboard in question
Returns
YES if this is a new paste, NO if a repeat
- (NSArray*) visibleObjects

Returns objects that are visible to the user, but may be locked.

If the layer itself is not visible, returns nil

Returns
an array of visible objects
- (NSArray*) visibleObjectsInRect: (NSRect aRect

Returns objects that are visible to the user, intersect the rect, but may be locked.

If the layer itself is not visible, returns nil

Parameters
aRectthe objects returned intersect this rect
Returns
an array of visible objects

Member Data Documentation

- (BOOL) mShowStorageDebugging
protected