DrawKit
Vector and illustration framework for Mac OS X
|
drawing layers are lightweight objects which represent a layer. More...
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 *) | |
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: |
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.
- (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.
- (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
- (NSSet*) allStyles |
Return all of styles used by the layer.
Override if your layer uses styles
- (CGFloat) alpha |
Returns the alpha level for the layer as a whole.
Default is 1.0 (fully opaque objects)
- (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.
dpi | image resolution in dots per inch |
- (BOOL) clipsDrawingToInterior |
Whether the drawing will be clipped to the interior or not.
Default is NO.
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.
- (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.
- (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
- (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.
sizeVal | the 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
um | the 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.
rect | the overall area being updated |
aView | the 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
event | the event |
Provided by category DKLayer(Metadata).
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.
sender | the 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.
p | the point to test |
- (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.
p | the point to test |
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.
Provided by category DKLayer(Metadata).
- (BOOL) isActive |
Is the layer the active layer?
- (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.
aGroup | a layer group |
- (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.
- (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
- (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
- (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.
- (NSString*) layerName |
Returns the layer's 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
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
- (BOOL) lockedOrHidden |
Returns whether the layer is locked or hidden.
Locked or hidden layers cannot usually be edited.
- (IBAction) lockLayer: | (id) | sender |
User interface level method can be linked to a menu or other appropriate UI widget.
sender | the sender of the action |
- (IBAction) logDescription: | (id) | sender |
Debugging method.
sender | the sender of the action |
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.
theEvent | the original event (a right-click mouse event) |
view | the view that received the original event |
- (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).
Provided by category DKLayer(Metadata).
- (void) metadataWillChangeKey: | (NSString *) | key |
Provided by category DKLayer(Metadata).
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.
event | the original mouseDown event |
view | the view which responded to the event and passed it on to us |
Subclasses must override to be notified of mouse dragged events.
event | the original mouseDragged event |
view | the view which responded to the event and passed it on to us |
Provided by category DKLayer(OptionalMethods).
Override to respond to the event.
event | the original mouseUpevent |
view | the 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.
pb | the pasteboard |
op | the kind of operation we need pasteboard types for |
- (NSArray*) pasteboardTypesForOperation: | (DKPasteboardOperationType) | op |
Return the pasteboard types this layer is able to receive in a given operation (drop or paste)
op | the kind of operation we need pasteboard types for |
- (NSData*) pdf |
- (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.
aSet | a set of style objects |
- (BOOL) rulerMarkerUpdatesEnabled |
- (DKLayerMetadataSchema) schema |
Provided by category DKLayer(Metadata).
- (NSColor*) selectionColour |
Returns the currently preferred selection colour for this layer.
+ (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.
- (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).
alpha | the 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.
clip | YES to limit drawing to the interior, NO to allow drawing to be visible in the margins. |
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.
colour | a 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
group | the 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.
name | the 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.
locked | YES 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).
Provided by category DKLayer(Metadata).
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.
update | flag 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.
rect | the 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.
setOfRects | a 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.
setOfRects | a set containing NSValues with rect values |
padding | the 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.
colour | the 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
listOfColours | an array containing NSColor objects |
- (void) setShouldDrawToPrinter: | (BOOL) | printIt |
Set whether this layer should be included in printed output.
Default is YES
printIt | YES to includethe layer, NO to skip it |
- (void) setSize: | (NSSize) | size | |
forKey: | (NSString *) | key | |
Provided by category DKLayer(Metadata).
Provided by category DKLayer(Metadata).
- (void) setupMetadata |
Provided by category DKLayer(Metadata).
- (void) setUserInfo: | (NSMutableDictionary *) | info |
- (void) setVisible: | (BOOL) | visible |
Sets whether the layer is visible or not.
Invisible layers are neither drawn nor can be edited.
visible | YES to show the layer, NO to hide it |
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.
event | the event (usually a mouse down) of the view that is asking |
- (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.
- (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
str | a pre-formatted string containg some information to display |
p | a point in local drawing coordinates |
- (IBAction) showLayer: | (id) | sender |
User interface level method can be linked to a menu or other appropriate UI widget.
sender | the sender of the action |
- (NSSize) sizeForKey: | (NSString *) | key |
Provided by category DKLayer(Metadata).
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.
- (IBAction) toggleLayerLock: | (id) | sender |
User interface level method can be linked to a menu or other appropriate UI widget.
sender | the sender of the action |
- (IBAction) toggleLayerVisible: | (id) | sender |
User interface level method can be linked to a menu or other appropriate UI widget.
sender | the sender of the action |
- (NSUndoManager*) undoManager |
Obtains the undo manager that is handling undo for the drawing and hence, this layer.
Implemented in DKDrawing.
- (NSString*) uniqueKey |
Returns the layer's unique key.
- (IBAction) unlockLayer: | (id) | sender |
User interface level method can be linked to a menu or other appropriate UI widget.
sender | the 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.
Return an item of user info.
key | the key to use to refer to the item |
- (BOOL) visible |
Is the layer visible?
Also returns NO if the layer's group is not visible
- (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.
aDrawing | the 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
pb | the pasteboard |