DrawKit
Vector and illustration framework for Mac OS X
|
DKDrawingView is the visible "front end" for the DKDrawing architecture. More...
Instance Methods | |
(DKLayer *) | - activeLayer |
Returns the current active layer, by asking the controller for it. More... | |
(DKViewController *) | - controller |
Return the view's controller. More... | |
(void) | - createAutomaticDrawing |
Create an entire "back end" for the view. More... | |
(void) | - createRulerMarkers |
Set up the markers for the rulers. More... | |
(void) | - drawCropMarks |
Draws the crop marks if set to do so and the view is being printed. More... | |
(DKDrawing *) | - drawing |
Return the drawing that the view will draw. More... | |
(void) | - drawPageBreaks |
Draw page breaks based on the page break print info. More... | |
(NSTextStorage *) | - editedText |
Return the text from the temporary editing view. More... | |
(void) | - editorFrameChangedNotification: |
Respond to frame size changes in the text editor view. More... | |
(NSTextView *) | - editText:inRect:delegate: |
Start editing text in a box within the view. More... | |
(NSTextView *) | - editText:inRect:delegate:drawsBackground: |
Start editing text in a box within the view. More... | |
(void) | - endTextEditing |
Stop the temporary text editing and get rid of the editing view. More... | |
(BOOL) | - isTextBeingEdited |
Is the text editor visible and active? More... | |
(DKViewController *) | - makeViewController |
Creates a controller for this view that can be added to a drawing. More... | |
(void) | - moveRulerMarkerNamed:toLocation: |
Set a ruler marker to a given position. More... | |
(NSBezierPath *) | - pageBreakPathWithExtension:options: |
Returns a path which represents all of the printed page rectangles. More... | |
(BOOL) | - pageBreaksVisible |
Are page breaks vissble? More... | |
(DKCropMarkKind) | - printCropMarkKind |
What sort of crop mark sare applied to printed output. More... | |
(NSPrintInfo *) | - printInfo |
Return the print info to use for drawing the page breaks, paginating and general printing operations. More... | |
(void) | - removeRulerMarkers |
Remove the markers from the rulers. More... | |
(void) | - replaceControllerWithController: |
Sea new controller for this view. More... | |
(void) | - resetRulerClientView |
Set up the client view for the rulers. More... | |
(void) | - set |
(void) | - setController: |
Set the view's controller. More... | |
(void) | - setPageBreaksVisible: |
Sets whether the page breaks are shown or not. More... | |
(void) | - setPrintCropMarkKind: |
Set what kind of crop marks printed output includes. More... | |
(void) | - setPrintInfo: |
(NSTextView *) | - textEditingView |
Return the current temporary text editing view. More... | |
(IBAction) | - toggleRuler: |
Show or hide the ruler. More... | |
(IBAction) | - toggleShowPageBreaks: |
(void) | - updateRulerMouseTracking: |
Set the ruler lines to the current mouse point. More... | |
(void) | - windowActiveStateChanged: |
Invalidate the view when window active state changes. More... | |
Instance Methods inherited from GCZoomView | |
(NSPoint) | - centredPointInDocView |
Calculates the coordinates of the point that is visually centred in the view at the current scroll position and zoom. More... | |
(BOOL) | - isChangingScale |
Returns whether the scale is being changed. More... | |
(CGFloat) | - maximumScale |
Returns the maximum permitted view scale (zoom) More... | |
(CGFloat) | - minimumScale |
Returns the minimum permitted view scale (zoom) More... | |
(CGFloat) | - scale |
Returns the current view scale (zoom) More... | |
(void) | - scrollPointToCentre: |
Scrolls the view so that the point ends up visually centred. More... | |
(void) | - setMaximumScale: |
Sets the maximum permitted view scale (zoom) More... | |
(void) | - setMinimumScale: |
Sets the minimum permitted view scale (zoom) More... | |
(void) | - setScale: |
Zooms the view to the given scale. More... | |
(IBAction) | - zoomFitInWindow: |
Zoom so that the entire extent of the enclosing frame is visible. More... | |
(IBAction) | - zoomIn: |
Zoom in (scale up) by a factor of 2. More... | |
(IBAction) | - zoomMax: |
(IBAction) | - zoomMin: |
(IBAction) | - zoomOut: |
Zoom out (scale down) by a factor of 2. More... | |
(IBAction) | - zoomToActualSize: |
Restore the zoom to 100%. More... | |
(IBAction) | - zoomToPercentageWithTag: |
Takes the senders tag value as the desired percentage. More... | |
(void) | - zoomViewByFactor: |
Zoom by the desired scaling factor. More... | |
(void) | - zoomViewByFactor:andCentrePoint: |
Zooms the view by the given factor and centres the passed point. More... | |
(void) | - zoomViewToAbsoluteScale: |
(void) | - zoomViewToFitRect: |
Zooms so that the passed rect will fit in the view. More... | |
(void) | - zoomViewToRect: |
Zooms so that the passed rect fills the view. More... | |
(void) | - zoomWithScrollWheelDelta:toCentrePoint: |
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 |
(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: |
Class Methods | |
(NSColor *) | + backgroundColour |
Return the colour used to draw the background area of the scrollview outside the drawing area. More... | |
(DKDrawingView *) | + currentlyDrawingView |
Return the view currently drawing. More... | |
(NSImage *) | + imageResourceNamed: |
Return an image resource from the framework bundle. More... | |
(NSColor *) | + pageBreakColour |
Get the colour used to draw the page breaks. More... | |
(NSPoint) | + pointForLastContextualMenuEvent |
Get the point for the initial mouse down that last opened a contextual menu. More... | |
(void) | + pop |
(void) | + setPageBreakColour: |
Set the colour used to draw the page breaks. More... | |
Temporary Text Editor | |
Setting the class to use for the temporary text editor | |
(Class) | + classForTextEditor |
(void) | + setClassForTextEditor: |
(void) | + setTextEditorAllowsTypingUndo: |
(BOOL) | + textEditorAllowsTypingUndo |
Class Methods inherited from GCZoomView | |
(BOOL) | + scrollwheelInverted |
Return whether view zooms in or out for a given scrollwheel rotation direction. More... | |
(NSUInteger) | + scrollwheelModifierKeyMask |
Return the default zoom key mask used by new instances of this class. More... | |
(BOOL) | + scrollwheelZoomEnabled |
Return whether scroll-wheel zooming is enabled. More... | |
(void) | + setScrollwheelInverted: |
Set whether view zooms in or out for a given scrollwheel rotation direction. More... | |
(void) | + setScrollwheelModiferKeyMask: |
Set the modifier key(s) that will activate zooming using the scrollwheel. More... | |
(void) | + setScrollwheelZoomEnabled: |
Set whether scroll-wheel zooming is enabled. More... | |
Class Methods inherited from NSObject | |
(id) | + alloc |
(Class) | + class |
(void) | + initialize |
(void) | + load |
(id) | + new |
Class Methods inherited from <NSKeyValueBindingCreation> | |
(void) | + exposeBinding: |
DKDrawingView is the visible "front end" for the DKDrawing architecture.
A drawing can have multiple views into the same drawing data model, each with independent scales, scroll positions and so forth, but all showing the same drawing. Manipulating the drawing through any view updates all of the views. In many cases there will only be one view. The views are not required to be in the same window.
The actual contents of the drawing are all supplied by DKDrawing - all this does is call it to render its contents.
If the drawing system is built by hand, the drawing owns the view controller(s), and some other object (a document for example) will own the drawing. However, like NSTextView, if you don't build a system by hand, this creates a default one for you which it takes ownership of. By default this consists of 3 layers - a grid layer, a guide layer and a standard object layer. You can change this however you like, it's there just as a construction convenience.
Note that because the controllers are owned by the drawing, there is no retain cycle even when the view owns the drawing. Views are owned by their parent view or window, not by their controller.
- (DKLayer*) activeLayer |
Returns the current active layer, by asking the controller for it.
DKDrawing maintains the active layer - look there for a method to set it
Provided by category DKDrawingView(DropHandling).
+ (NSColor*) backgroundColour |
Return the colour used to draw the background area of the scrollview outside the drawing area.
+ (Class) classForTextEditor |
- (DKViewController*) controller |
Return the view's controller.
- (void) createAutomaticDrawing |
Create an entire "back end" for the view.
Normally you create a drawing, and add layers to it. However, you can also let the view create the drawing back-end for you. This will occur when the view is asked to draw and there is no back end. This method does the building. This feature means you can simply drop a drawingView into a NIB and get a functional drawing program. For more sophisticated needs however, you really need to build it yourself.
- (void) createRulerMarkers |
Set up the markers for the rulers.
Done as part of the view's initialization - markers are initially created offscreen.
+ (DKDrawingView*) currentlyDrawingView |
Return the view currently drawing.
This is only valid during a drawRect: call - some internal parts of DK use this to obtain the view doing the drawing when they do not have a direct parameter to it.
- (void) drawCropMarks |
Draws the crop marks if set to do so and the view is being printed.
- (DKDrawing*) drawing |
Return the drawing that the view will draw.
The drawing is obtained via the controller, and may be nil if the controller hasn't been added to a drawing yet. Even when the view owns the drawing (for auto back-end) you should use this method to get a view's drawing.
- (void) drawPageBreaks |
Draw page breaks based on the page break print info.
- (NSTextStorage*) editedText |
Return the text from the temporary editing view.
This must be called prior to calling -endTextEditing, because the storage is made empty at that time
- (void) editorFrameChangedNotification: | (NSNotification *) | note |
Respond to frame size changes in the text editor view.
This tidies up the display when the editor frame changes size. The frame can change during editing depending on how the client has configured it, but to prevent bits from being left behind when the frame is made smaller, this simply invalidates the previous frame rect.
note | the notification |
- (NSTextView*) editText: | (NSAttributedString *) | text | |
inRect: | (NSRect) | rect | |
delegate: | (id) | del | |
Start editing text in a box within the view.
When an object in the drawing wishes to allow the user to edit some text, it can use this utility to set up the editor. This creates a subview for text editing with the nominated text and the bounds rect given within the drawing. The text is installed, selected and activated. User actions then edit that text. When done, call endTextEditing. To get the text edited, call editedText before ending the mode. You can only set one item at a time to be editable.
text | the text to edit |
rect | the position and size of the text box to edit within |
del | a delegate object |
- (NSTextView*) editText: | (NSAttributedString *) | text | |
inRect: | (NSRect) | rect | |
delegate: | (id) | del | |
drawsBackground: | (BOOL) | drawBkGnd | |
Start editing text in a box within the view.
When an object in the drawing wishes to allow the user to edit some text, it can use this utility to set up the editor. This creates a subview for text editing with the nominated text and the bounds rect given within the drawing. The text is installed, selected and activated. User actions then edit that text. When done, call endTextEditing. To get the text edited, call editedText before ending the mode. You can only set one item at a time to be editable.
text | the text to edit |
rect | the position and size of the text box to edit within |
del | a delegate object |
drawBkGnd | YES to draw a background, NO to have transparent text |
- (void) endTextEditing |
Stop the temporary text editing and get rid of the editing view.
Return an image resource from the framework bundle.
name | the image name |
Reimplemented from NSObject.
- (BOOL) isTextBeingEdited |
Is the text editor visible and active?
Clients should not generally start a text editing operation if there is already one in progress, though if they do the old one is immediately ended anyway.
- (DKViewController*) makeViewController |
Creates a controller for this view that can be added to a drawing.
Normally you wouldn't call this yourself unless you are building the entire DK system by hand rather than using DKDrawDocument or automatic drawing creation. You can override it to create different kinds of controller however. Th edefault controller is DKToolController so that DK provides you with a set of working drawing tools by default.
Set a ruler marker to a given position.
Generally called from the view's controller
markerName | the name of the marker to move |
loc | a position value to move the ruler marker to |
+ (NSColor*) pageBreakColour |
Get the colour used to draw the page breaks.
- (NSBezierPath*) pageBreakPathWithExtension: | (CGFloat) | amount | |
options: | (DKCropMarkKind) | options | |
Returns a path which represents all of the printed page rectangles.
Any extension may not end up visible when printed depending on the printer's margin settings, etc. The only supported option currently is kDKCornerOnly, which generates corner crop marks rather than the full rectangles.
amount | the extension amount by which each line is extended beyond the end of the corner. May be 0. |
options | crop marks kind |
- (BOOL) pageBreaksVisible |
Are page breaks vissble?
+ (NSPoint) pointForLastContextualMenuEvent |
Get the point for the initial mouse down that last opened a contextual menu.
+ (void) pop |
- (DKCropMarkKind) printCropMarkKind |
What sort of crop mark sare applied to printed output.
Default is no crop marks
- (NSPrintInfo*) printInfo |
Return the print info to use for drawing the page breaks, paginating and general printing operations.
Implemented in DKPrintDrawingView.
- (void) removeRulerMarkers |
Remove the markers from the rulers.
- (void) replaceControllerWithController: | (DKViewController *) | newController |
Sea new controller for this view.
This is a convenience that allows a controller to be simply instantiated and passed in, replacing the existing controller. Note that -setController: does NOT achieve that. The drawing must already exist for this to work.
newController | the new controller |
- (void) resetRulerClientView |
Set up the client view for the rulers.
Done as part of the view's initialization
- (void) set |
+ (void) setClassForTextEditor: | (Class) | aClass |
- (void) setController: | (DKViewController *) | aController |
Set the view's controller.
Do not call this directly - the controller will call it to set up the relationship at the right time.
aController | the controller for this view |
+ (void) setPageBreakColour: | (NSColor *) | colour |
Set the colour used to draw the page breaks.
colour | the colour to draw page breaks with |
- (void) setPageBreaksVisible: | (BOOL) | pbVisible |
Sets whether the page breaks are shown or not.
Page breaks also need a valid printInfo object set
pbVisible | YES to show the page breaks, NO otherwise |
- (void) setPrintCropMarkKind: | (DKCropMarkKind) | kind |
Set what kind of crop marks printed output includes.
Default is no crop marks
kind | the kind of crop mark (including none) |
- (void) setPrintInfo: | (NSPrintInfo *) | printInfo |
Implemented in DKPrintDrawingView.
+ (void) setTextEditorAllowsTypingUndo: | (BOOL) | allowUndo |
- (NSTextView*) textEditingView |
Return the current temporary text editing view.
+ (BOOL) textEditorAllowsTypingUndo |
- (IBAction) toggleRuler: | (id) | sender |
Show or hide the ruler.
sender | the action's sender |
- (IBAction) toggleShowPageBreaks: | (id) | sender |
- (void) updateRulerMouseTracking: | (NSPoint) | mouse |
Set the ruler lines to the current mouse point.
N.b. on 10.4 and earlier, there is a bug in NSRulerView that prevents both h and v ruler lines showing up correctly at the same time. No workaround is known. Fixed in 10.5+
mouse | the current mouse poin tin local coordinates |
- (void) windowActiveStateChanged: | (NSNotification *) | note |
Invalidate the view when window active state changes.
Drawings can change appearance when the active state changes, for example selections are drawn in inactive colour, etc. This makes sure that the drawing is refreshed when the state does change.
note | the notification |