DrawKit
Vector and illustration framework for Mac OS X
|
This is a very general-purpose view class that provides some handy high-level methods for doing zooming. More...
Instance Methods | |
(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 |
(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: |
Class Methods | |
(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: |
This is a very general-purpose view class that provides some handy high-level methods for doing zooming.
This is a very general-purpose view class that provides some handy high-level methods for doing zooming. Simply hook up the action methods to suitable menu commands and away you go. The stuff you draw within drawRect: doesn't need to know or care abut the zoom of the view - you can just draw as usual and it works.
- (NSPoint) centredPointInDocView |
Calculates the coordinates of the point that is visually centred in the view at the current scroll position and zoom.
- (BOOL) isChangingScale |
Returns whether the scale is being changed.
This property can be used to detect whether the user is rapidly changing the scale, for example using the scrollwheel. When a scrollwheel change starts, this is set to YES and a timer is run which is retriggered by further events. If it times out, this resets to NO. It can be used as one part of a drawing strategy where rapid changes temporarily use a lower quality drawing mechanism for performance, but reverts to a higher quality when things settle.
- (CGFloat) maximumScale |
Returns the maximum permitted view scale (zoom)
- (CGFloat) minimumScale |
Returns the minimum permitted view scale (zoom)
- (CGFloat) scale |
Returns the current view scale (zoom)
- (void) scrollPointToCentre: | (NSPoint) | aPoint |
Scrolls the view so that the point ends up visually centred.
aPoint | the desired centre point |
+ (BOOL) scrollwheelInverted |
Return whether view zooms in or out for a given scrollwheel rotation direction.
Default sense is to zoom in when scrollwheel is rotated towards the user. Some apps (e.g. Google Earth) use the opposite convention, which feels less natural but may become a defacto "standard".
+ (NSUInteger) scrollwheelModifierKeyMask |
Return the default zoom key mask used by new instances of this class.
Reads the value from the prefs. If not set or set to zero, defaults to option key.
+ (BOOL) scrollwheelZoomEnabled |
Return whether scroll-wheel zooming is enabled.
Default is YES
- (void) setMaximumScale: | (CGFloat) | scmax |
Sets the maximum permitted view scale (zoom)
scmax | the maximum scale |
- (void) setMinimumScale: | (CGFloat) | scmin |
Sets the minimum permitted view scale (zoom)
scmin | the minimum scale |
- (void) setScale: | (CGFloat) | sc |
Zooms the view to the given scale.
All zooms bottleneck through here. Scale passed is pinned within the min and max limits.
sc | - the desired scale |
+ (void) setScrollwheelInverted: | (BOOL) | inverted |
Set whether view zooms in or out for a given scrollwheel rotation direction.
Default sense is to zoom in when scrollwheel is rotated towards the user. Some apps (e.g. Google Earth) use the opposite convention, which feels less natural but may become a defacto "standard".
+ (void) setScrollwheelModiferKeyMask: | (NSUInteger) | aMask |
Set the modifier key(s) that will activate zooming using the scrollwheel.
Operating the given modifier keys along with the scroll wheel will zoom the view
aMask | a modifier key mask value |
+ (void) setScrollwheelZoomEnabled: | (BOOL) | enable |
Set whether scroll-wheel zooming is enabled.
Default is YES
enable | YES to enable, NO to disable |
- (IBAction) zoomFitInWindow: | (id) | sender |
Zoom so that the entire extent of the enclosing frame is visible.
sender | - the sender of the action |
- (IBAction) zoomIn: | (id) | sender |
Zoom in (scale up) by a factor of 2.
sender | - the sender of the action |
- (IBAction) zoomMax: | (id) | sender |
- (IBAction) zoomMin: | (id) | sender |
- (IBAction) zoomOut: | (id) | sender |
Zoom out (scale down) by a factor of 2.
sender | - the sender of the action |
- (IBAction) zoomToActualSize: | (id) | sender |
Restore the zoom to 100%.
sender | - the sender of the action |
- (IBAction) zoomToPercentageWithTag: | (id) | sender |
Takes the senders tag value as the desired percentage.
sender | - the sender of the action |
- (void) zoomViewByFactor: | (CGFloat) | factor |
Zoom by the desired scaling factor.
A factor of 2.0 will double the zoom scale, from 100% to 200% say, a factor of 0.5 will zoom out. This also maintains the current visible centre point of the view so the zoom remains stable.
factor | - how much to change the current scale by |
- (void) zoomViewByFactor: | (CGFloat) | factor | |
andCentrePoint: | (NSPoint) | p | |
Zooms the view by the given factor and centres the passed point.
factor | - relative zoom factor |
p | a point within the view that should be scrolled to the centre of the zoomed view. |
- (void) zoomViewToAbsoluteScale: | (CGFloat) | scale |
- (void) zoomViewToFitRect: | (NSRect) | aRect |
Zooms so that the passed rect will fit in the view.
In general this should be used for a zoom OUT, such as a "fit to window" command, though it will zoom in if the view is smaller than the current frame.
aRect | - a rect |
- (void) zoomViewToRect: | (NSRect) | aRect |
Zooms so that the passed rect fills the view.
The centre of the rect is centred in the view. In general this should be used for a zoom IN to a specific smaller rectange. <aRect> is in current view coordinates. This is good for a dragged rect zoom tool.
aRect | - a rect |
- (void) zoomWithScrollWheelDelta: | (CGFloat) | delta | |
toCentrePoint: | (NSPoint) | cp | |