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

drawing layers are lightweight objects which represent a layer. More...

Inheritance diagram for DKLayer:
Inheritance graph
[legend]

Instance Methods

(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...
 
(DKDrawableObject *) - hitTest:
 Detect what object 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
 

Class Methods

(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:
 

Detailed Description

drawing layers are lightweight objects which represent a layer.

drawing layers are lightweight objects which represent a layer. They are owned by a DKDrawing which manages the stacking order and invokes the drawRect: method as needed. The other state variables control whether the layer is visible, locked, etc.

DKDrawing will not ever call a drawRect: on a layer that returns NO for visible.

if isOpaque returns YES, layers that are stacked below this one will not be drawn, even if they are visible. isOpaque returns NO by default.

locked layers should not be editable, but this must be enforced by subclasses, as this class contains no editing features. However, locked layers will never receive mouse event calls so generally this will be enough.

As layers are retained by the drawing, this does not retain the drawing.

By definition the bounds of the layer is the same as the bounds of the drawing.

DKLayer does not implement a dragging destination but some subclasses do. NSDraggingDestination is declared to indicate likely handling of drag and drop operations by a layer instance.

Method Documentation

- (NSRect) activeCursorRect

Return a rect where the layer's cursor is shown when the mouse is within it.

By default the cursor rect is the entire interior area.

Returns
the cursor rect
- (void) addMetadata: (NSDictionary *)  dict

Provided by category DKLayer(Metadata).

- (void) addUserInfo: (NSDictionary *)  info
- (NSSet*) allRegisteredStyles

Return all of registered styles used by the layer.

Override if your layer uses styles

Returns
nil
- (NSSet*) allStyles

Return all of styles used by the layer.

Override if your layer uses styles

Returns
nil
- (CGFloat) alpha

Returns the alpha level for the layer as a whole.

Default is 1.0 (fully opaque objects)

Returns
the current alpha level
- (void) beginDrawing

Called before the layer starts drawing its content.

Can be used to hook into the start of drawing - by default does nothing

- (NSBitmapImageRep*) bitmapRepresentationWithDPI: (NSUInteger dpi

Returns the layer's content as a transparent bitmap having the given DPI.

A dpi of 0 uses the default, which is 72 dpi. The image pixel size is calculated from the drawing size and the dpi. The layer is imaged onto a transparent background with alpha.

Parameters
dpiimage resolution in dots per inch
Returns
the bitmap
- (BOOL) clipsDrawingToInterior

Whether the drawing will be clipped to the interior or not.

Default is NO.

Returns
YES if clipping, NO if not.
- (NSColor*) colourForKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (IBAction) copy: (id sender

Implemented in DKObjectDrawingLayer.

- (NSView*) currentView

Returns the view which is either currently drawing the layer, or the one that mouse events are coming from.

This generally does the expected thing. If you're drawing, it returns the view that's doing the drawing original event in question. At any other time it will return nil. Wherever possible you should use the view parameter that is passed to you rather than use this.

Returns
the currently "important" view
- (NSCursor*) cursor

Returns the cursor to display while the mouse is over this layer while it's active.

Subclasses will usually want to override this and provide a cursor appropriate to the layer or where the mouse is within it, or which tool has been attached.

Returns
the desired cursor
- (DKDrawing*) drawing

Returns the drawing that the layer belongs to.

The drawing is the root object in a layer hierarchy, it overrides -drawing to return self, which is how this works

Returns
the layer's owner drawing
- (void) drawingDidChangeMargins: (NSValue *)  newInterior
- (void) drawingDidChangeToSize: (NSValue *)  sizeVal

Called when the drawing's size is changed - this gives layers that need to know about this a direct notification.

If you need to know before and after sizes, you'll need to subscribe to the relevant notifications.

Parameters
sizeValthe new size of the drawing - extract -sizeValue.
- (void) drawingHasNewUndoManager: (NSUndoManager *)  um

Called when the drawing's undo manager is changed - this gives objects that cache the UM a chance to update their references.

The default implementation does nothing - override to make something of it

Parameters
umthe new undo manager
- (void) drawRect: (NSRect rect
inView: (DKDrawingView *)  aView 

Main entry point for drawing the layer and its contents to the drawing's views.

Can be treated as the similar NSView call - to optimise drawing you can query the view that's doing the drawing and use calls such as needsToDrawRect: etc. Will not be called in cases where the layer is not visible, so you don't need to test for that. Must be overridden.

Parameters
rectthe overall area being updated
aViewthe view doing the rendering
- (void) endDrawing

Called after the layer has finished drawing its content.

Can be used to hook into the end of drawing - by default does nothing

- (void) flagsChanged: (NSEvent *)  event

Respond to a change in the modifier key state.

Is passed from the key view to the active layer

Parameters
eventthe event
- (CGFloat) floatValueForKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (BOOL) hasMetadataForKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (void) hideInfoWindow

Hides the info window if it's visible.

- (IBAction) hideLayer: (id sender

User interface level method can be linked to a menu or other appropriate UI widget.

Parameters
senderthe sender of the action
- (void) hideRulerMarkers
- (BOOL) hitLayer: (NSPoint)  p

Detect whether the layer was "hit" by a point.

This is used to implement automatic layer activation when the user clicks in a view. This isn't always the most useful behaviour, so by default this returns NO. Subclasses can override to refine the hit test appropriately.

Parameters
pthe point to test
Returns
YES if the layer was hit, NO otherwise
- (DKDrawableObject*) hitTest: (NSPoint)  p

Detect what object was hit by a point.

Layers that support objects implement this meaningfully. A non-object layer returns nil which simplifies the design of certain tools that look for targets to operate on, without the need to ascertain the layer class first.

Parameters
pthe point to test
Returns
the object hit, or nil

Implemented in DKObjectOwnerLayer.

- (NSUInteger) indexInGroup

Gets the layer's index within the group that the layer is contained in.

If the layer isn't in a group yet, result is 0. This is intended for debugging mostly.

Returns
an integer, the layer's index
- (NSInteger) intValueForKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (BOOL) isActive

Is the layer the active layer?

Returns
YES if the active layer, NO otherwise
- (BOOL) isChildOfGroup: (DKLayerGroup *)  aGroup

Determine whether a given group is the parent of this layer, or anywhere above it in the hierarchy.

Intended to check for absurd operations, such as moving a parent group into one of its own children.

Parameters
aGroupa layer group
Returns
YES if the group sits above this in the hierarchy, NO otherwise
- (BOOL) isOpaque

Is the layer opaque or transparent?

Can be overridden to optimise drawing in some cases. Layers below an opaque layer are skipped when drawing, so if you know your layer is opaque, return YES to implement the optimisation. The default is NO, layers are considered to be transparent.

Returns
whether to treat the layer as opaque or not
- (DKKnob*) knobs
- (BOOL) knobsShouldAdjustToViewScale
- (void) layerDidBecomeActiveLayer

The layer was made the active layer by the owning drawing.

Layers may want to know when their active state changes. Override to make use of this.

- (void) layerDidResignActiveLayer

The layer is no longer the active layer.

Layers may want to know when their active state changes. Override to make use of this.

- (DKLayerGroup*) layerGroup

Gets the group that the layer is contained in.

The layer's group might be the drawing itself, which is a group

Returns
the layer's group
- (BOOL) layerMayBecomeActive

Returns whether the layer can become the active layer.

The default is YES. Layers may override this and return NO if they do not want to ever become active

Returns
YES if the layer can become active, NO to not become active
- (BOOL) layerMayBeDeleted

Return whether the layer can be deleted.

This setting is intended to be checked by UI-level code to prevent deletion of layers within the UI. It does not prevent code from directly removing the layer.

Returns
YES if layer can be deleted, override to return NO to prevent this
- (NSString*) layerName

Returns the layer's name.

Returns
the name
- (NSUInteger) level

Returns the hierarchical level of this layer, i.e.

how deeply nested it is

Layers in the root group return 1. A layer's level is its group's level + 1

Returns
the layer's level

Implemented in DKLayerGroup.

- (BOOL) locked

Returns whether the layer is locked or not.

Locked layers cannot be edited. Also returns YES if the layer belongs to a locked group

Returns
YES if locked, NO if unlocked
- (BOOL) lockedOrHidden

Returns whether the layer is locked or hidden.

Locked or hidden layers cannot usually be edited.

Returns
YES if locked or hidden, NO if unlocked and visible
- (IBAction) lockLayer: (id sender

User interface level method can be linked to a menu or other appropriate UI widget.

Parameters
senderthe sender of the action
- (IBAction) logDescription: (id sender

Debugging method.

Parameters
senderthe sender of the action
- (NSMenu*) menuForEvent: (NSEvent *)  theEvent
inView: (NSView *)  view 

Allows a contextual menu to be built for the layer or its contents.

By default this returns nil, resulting in nothing being displayed. Subclasses can override to build a suitable menu for the point where the layer was clicked.

Parameters
theEventthe original event (a right-click mouse event)
viewthe view that received the original event
Returns
a menu that will be displayed as a contextual menu
- (NSMutableDictionary*) metadata

Provided by category DKLayer(Metadata).

+ (BOOL) metadataChangesAreUndoable

Provided by category DKLayer(Metadata).

- (NSUInteger) metadataChecksum

Provided by category DKLayer(Metadata).

- (void) metadataDidChangeKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (DKMetadataItem*) metadataItemForKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (NSArray*) metadataKeys

Provided by category DKLayer(Metadata).

- (id) metadataObjectForKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (void) metadataWillChangeKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (void) mouseDown: (NSEvent *)  event
inView: (NSView *)  view 

The mouse went down in this layer.

Override to respond to the event. Note that where tool controllers and tools are used, these methods may never be called, as the tool will operate on target objects within the layer directly.

Parameters
eventthe original mouseDown event
viewthe view which responded to the event and passed it on to us
- (void) mouseDragged: (NSEvent *)  event
inView: (NSView *)  view 

Subclasses must override to be notified of mouse dragged events.

Parameters
eventthe original mouseDragged event
viewthe view which responded to the event and passed it on to us
- (void) mouseMoved: (NSEvent *)  event
inView: (NSView *)  view 

Provided by category DKLayer(OptionalMethods).

- (void) mouseUp: (NSEvent *)  event
inView: (NSView *)  view 

Override to respond to the event.

Parameters
eventthe original mouseUpevent
viewthe view which responded to the event and passed it on to us
- (BOOL) pasteboard: (NSPasteboard *)  pb
hasAvailableTypeForOperation: (DKPasteboardOperationType)  op 

Tests whether the pasteboard has any of the types the layer is interested in receiving for the given operation.

Parameters
pbthe pasteboard
opthe kind of operation we need pasteboard types for
Returns
YES if the pasteboard has any of the types of interest, otherwise NO
- (NSArray*) pasteboardTypesForOperation: (DKPasteboardOperationType)  op

Return the pasteboard types this layer is able to receive in a given operation (drop or paste)

Parameters
opthe kind of operation we need pasteboard types for
Returns
an array of pasteboard types they can handle and also implement the necessary parts of the NSDraggingDestination protocol just as if they were a view.
- (NSData*) pdf

Returns the content of the layer as a pdf.

By default the pdf contains the entire layer's visible content exactly as drawn to a printer.

Returns
NSData containing the pdf representation of the layer and its contents

Implemented in DKDrawing.

- (void) removeMetadataForKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (void) replaceMatchingStylesFromSet: (NSSet *)  aSet

Substitute styles with those in the given set.

Subclasses may implement this to replace styles they use with styles from the set that have matching keys. This is an important step in reconciling the styles loaded from a file with the existing registry. Implemented by DKObjectOwnerLayer, etc. Layer groups also implement this to propagate the change to all sublayers.

Parameters
aSeta set of style objects
- (BOOL) rulerMarkerUpdatesEnabled
- (DKLayerMetadataSchema) schema

Provided by category DKLayer(Metadata).

- (NSColor*) selectionColour

Returns the currently preferred selection colour for this layer.

Returns
the colour
+ (NSColor*) selectionColourForIndex: (NSUInteger index
+ (NSArray*) selectionColours

Returns the list of colours used for supplying the selection colours.

If never specifically set, this returns a very simple list of basic colours which is what DK has traditionally used.

Returns
an array containing NSColor objects
- (void) setAlpha: (CGFloat alpha

Sets the alpha level for the layer.

Default is 1.0 (fully opaque objects). Note that alpha must be implemented by a layer's -drawRect:inView: method to have an actual effect, and unless compositing to a CGLayer or other graphics surface, may not have the expected effect (just setting the context's alpha before drawing renders each individual object with the given alpha, for example).

Parameters
alphathe alpha level, 0..1
- (void) setClipsDrawingToInterior: (BOOL clip

Sets whether drawing is limited to the interior area or not.

Default is NO, so drawings show in the margins.

Parameters
clipYES to limit drawing to the interior, NO to allow drawing to be visible in the margins.
- (void) setColour: (NSColor *)  colour
forKey: (NSString *)  key 

Provided by category DKLayer(Metadata).

- (void) setFloatValue: (float)  val
forKey: (NSString *)  key 

Provided by category DKLayer(Metadata).

- (void) setInfoWindowBackgroundColour: (NSColor *)  colour

Sets the background colour of the small floating info window.

Parameters
coloura colour for the window
- (void) setIntValue: (int)  val
forKey: (NSString *)  key 

Provided by category DKLayer(Metadata).

- (void) setKnobs: (DKKnob *)  knobs
- (void) setKnobsShouldAdustToViewScale: (BOOL ka
- (void) setLayerGroup: (DKLayerGroup *)  group

Sets the group that the layer is contained in - called automatically when the layer is added to a group.

The group retains this, so the group isn't retained here

Parameters
groupthe group we belong to
- (void) setLayerName: (NSString *)  name

Sets the user-readable name of the layer.

Layer names are a convenience for the user, and can be displayed by a user interface. The name is not significant internally. This copies the name passed for safety.

Parameters
namethe layer's name
- (void) setLocked: (BOOL locked

Sets whether the layer is locked or not.

A locked layer will be drawn but cannot be edited. In case the layer's appearance changes according to this state change, a refresh is performed.

Parameters
lockedYES to lock, NO to unlock
- (void) setMetadata: (NSDictionary *)  dict

Provided by category DKLayer(Metadata).

+ (void) setMetadataChangesAreUndoable: (BOOL undo

Provided by category DKLayer(Metadata).

- (void) setMetadataItem: (DKMetadataItem *)  item
forKey: (NSString *)  key 

Provided by category DKLayer(Metadata).

- (void) setMetadataItemType: (DKMetadataType)  type
forKey: (NSString *)  key 

Provided by category DKLayer(Metadata).

- (void) setMetadataItemValue: (id value
forKey: (NSString *)  key 

Provided by category DKLayer(Metadata).

- (void) setMetadataObject: (id obj
forKey: (id key 

Provided by category DKLayer(MetadataDeprecated).

- (void) setNeedsDisplay: (BOOL update

Flags the whole layer as needing redrawing.

Always use this method instead of trying to access the view directly. This ensures that all attached views get refreshed correctly.

Parameters
updateflag whether to update or not
- (void) setNeedsDisplayInRect: (NSRect rect

Flags part of a layer as needing redrawing.

Always use this method instead of trying to access the view directly. This ensures that all attached views get refreshed correctly.

Parameters
rectthe area that needs to be redrawn
- (void) setNeedsDisplayInRects: (NSSet *)  setOfRects

Marks several areas for update at once.

Several update optimising methods return sets of rect values, this allows them to be processed directly.

Parameters
setOfRectsa set containing NSValues with rect values
- (void) setNeedsDisplayInRects: (NSSet *)  setOfRects
withExtraPadding: (NSSize)  padding 

Marks several areas for update at once.

Several update optimising methods return sets of rect values, this allows them to be processed directly.

Parameters
setOfRectsa set containing NSValues with rect values
paddingthe width and height will be added to EACH rect before invalidating
- (void) setRulerMarkerUpdatesEnabled: (BOOL enable
- (void) setSelectionColour: (NSColor *)  colour

Sets the colour preference to use for selected objects within this layer.

Different layers may wish to have a different colour for selections to help the user tell which layer they are working in. The layer doesn't enforce this - it's up to objects to make use of this provided colour where necessary.

Parameters
colourthe selection colour preference
+ (void) setSelectionColours: (NSArray *)  listOfColours

Allows a list of colours to be set for supplying the selection colours.

The list is used to supply colours in rotation when new layers are instantiated

Parameters
listOfColoursan array containing NSColor objects
- (void) setShouldDrawToPrinter: (BOOL printIt

Set whether this layer should be included in printed output.

Default is YES

Parameters
printItYES to includethe layer, NO to skip it
- (void) setSize: (NSSize)  size
forKey: (NSString *)  key 

Provided by category DKLayer(Metadata).

- (void) setString: (NSString *)  string
forKey: (NSString *)  key 

Provided by category DKLayer(Metadata).

- (void) setupMetadata

Provided by category DKLayer(Metadata).

- (void) setUserInfo: (NSMutableDictionary *)  info
- (void) setUserInfoObject: (id obj
forKey: (NSString *)  key 
- (void) setVisible: (BOOL visible

Sets whether the layer is visible or not.

Invisible layers are neither drawn nor can be edited.

Parameters
visibleYES to show the layer, NO to hide it
- (BOOL) shouldAutoActivateWithEvent: (NSEvent *)  event

Should the layer automatically activate on a click if the view has this behaviour set?

Override to return NO if your layer type should not auto activate. Note that auto-activation also needs to be set for the view. The event is passed so that a sensible decision can be reached.

Parameters
eventthe event (usually a mouse down) of the view that is asking
Returns
YES if the layer is unlocked, NO otherwise
- (BOOL) shouldDrawToPrinter

Return whether the layer should be part of the printed output or not.

Some layers won't want to be printed - guides for example. Override this to return NO if you don't want the layer to be printed. By default layers are printed.

Returns
YES to draw to printer, NO to suppress drawing on the printer
- (void) showInfoWindowWithString: (NSString *)  str
atPoint: (NSPoint)  p 

Displays a small floating info window near the point p containg the string.

The window is shown near the point rather than at it. Generally the info window should be used for small, dynamically changing and temporary information, like a coordinate value. The background colour is initially set to the layer's selection colour

Parameters
stra pre-formatted string containg some information to display
pa point in local drawing coordinates
- (IBAction) showLayer: (id sender

User interface level method can be linked to a menu or other appropriate UI widget.

Parameters
senderthe sender of the action
- (NSSize) sizeForKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (NSString*) stringForKey: (NSString *)  key

Provided by category DKLayer(Metadata).

- (BOOL) supportsMetadata

Provided by category DKLayer(Metadata).

- (NSImage*) thumbnail
- (NSImage*) thumbnailImageWithSize: (NSSize)  size

Returns an image of the layer a the given size.

While the image has the size passed, the rendered content will have the same aspect ratio as the drawing, scaled to fit. Areas left outside of the drawn portion are transparent.

Returns
an image of this layer onlyReturns an image of the layer at the default size
an image of this layer only
- (IBAction) toggleLayerLock: (id sender

User interface level method can be linked to a menu or other appropriate UI widget.

Parameters
senderthe sender of the action
- (IBAction) toggleLayerVisible: (id sender

User interface level method can be linked to a menu or other appropriate UI widget.

Parameters
senderthe sender of the action
- (NSUndoManager*) undoManager

Obtains the undo manager that is handling undo for the drawing and hence, this layer.

Returns
the undo manager in use

Implemented in DKDrawing.

- (NSString*) uniqueKey

Returns the layer's unique key.

Returns
the unique key
- (IBAction) unlockLayer: (id sender

User interface level method can be linked to a menu or other appropriate UI widget.

Parameters
senderthe sender of the action
- (void) updateMetadataKeys

Provided by category DKLayer(Metadata).

- (void) updateRulerMarkersForRect: (NSRect rect
- (NSMutableDictionary*) userInfo

Return the attached user info.

The user info is returned as a mutable dictionary (which it is), and can thus have its contents mutated directly for certain uses. Doing this cannot cause any notification of the status of the object however.

Returns
the user info
- (id) userInfoObjectForKey: (NSString *)  key

Return an item of user info.

Parameters
keythe key to use to refer to the item
Returns
the user info item
- (BOOL) visible

Is the layer visible?

Also returns NO if the layer's group is not visible

Returns
YES if visible, NO if not
- (void) wasAddedToDrawing: (DKDrawing *)  aDrawing

Notifies the layer that it or a group containing it was added to a drawing.

This can be used to perform additional setup that requires knowledge of the drawing such as its size. The default method does nothing - override to use.

Parameters
aDrawingthe drawing that added the layer
- (BOOL) writePDFDataToPasteboard: (NSPasteboard *)  pb

Writes the content of the layer as a pdf to a nominated pasteboard.

Becomes the new pasteboard owner and removes any existing declared types

Parameters
pbthe pasteboard
Returns
YES if written OK, NO otherwise