Class

NSRuler​View

An NSRulerView displays a ruler and markers above or to the side of an NSScrollView’s document view. Views within the NSScrollView can become clients of the ruler view, having it display markers for their elements, and receiving messages from the ruler view when the user manipulates the markers.

Overview

Principal Attributes

  • Displays markers that represent elements of the client view.

  • Displays in arbitrary units.

  • Provides for an accessory view containing extra controls.

Creation

Commonly Used Methods

client​View

Changes the ruler’s client view.

markers

Sets the markers displayed by the ruler view.

accessory​View

Sets the accessory view.

track​Marker(_:​with​Mouse​Event:​)

Allows the user to add a new marker.

Overview

See NSRulerMarkerClientViewDelegation for delegate methods that may be of interest.

Symbols

Creating instances

init(scroll​View:​ NSScroll​View?, orientation:​ NSRuler​Orientation)

Initializes a newly allocated NSRulerView to have orientation (NSHorizontal​Ruler or NSVertical​Ruler) within a​Scroll​View.

Altering measurement units

var measurement​Units:​ String

The measurement units used by the ruler to unit​Name.

Setting the client view

var client​View:​ NSView?

The receiver’s client view, if it has one.

Setting an accessory view

var accessory​View:​ NSView?

The receiver’s accessory view to a​View.

Setting the zero mark position

var origin​Offset:​ CGFloat

The distance to the zero hash mark from the bounds origin of the NSScrollView’s document view (not of the receiver’s client view), in the document view’s coordinate system.

Adding and removing markers

var markers:​ [NSRuler​Marker]?

The receiver’s ruler markers to markers, removing any existing ruler markers and not consulting with the client view about the new markers.

func add​Marker(NSRuler​Marker)

Adds a​Marker to the receiver, without consulting the client view for approval.

func remove​Marker(NSRuler​Marker)

Removes a​Marker from the receiver, without consulting the client view for approval.

func track​Marker(NSRuler​Marker, with​Mouse​Event:​ NSEvent)

Tracks the mouse to add a​Marker based on the initial mouse-down or mouse-dragged event the​Event.

Drawing temporary ruler lines

Drawing

func draw​Hash​Marks​And​Labels(in:​ NSRect)

Draws the receiver’s hash marks and labels in a​Rect, which is expressed in the receiver’s coordinate system.

func draw​Markers(in:​ NSRect)

Draws the receiver’s markers in a​Rect, which is expressed in the receiver’s coordinate system.

func invalidate​Hash​Marks()

Forces recalculation of the hash mark spacing for the next time the receiver is displayed.

Ruler layout

var scroll​View:​ NSScroll​View?

The NSScrollView that owns the receiver to scroll​View, without retaining it.

var orientation:​ NSRuler​Orientation

The orientation of the receiver to orientation.

var reserved​Thickness​For​Accessory​View:​ CGFloat

The room available for the receiver’s accessory view to thickness.

var reserved​Thickness​For​Markers:​ CGFloat

The room available for ruler markers to thickness.

var rule​Thickness:​ CGFloat

The thickness of the area where ruler hash marks and labels are drawn.

var required​Thickness:​ CGFloat

The thickness needed for proper tiling of the receiver within an NSScrollView.

var baseline​Location:​ CGFloat

The location of the receiver’s baseline, in its own coordinate system.

var is​Flipped:​ Bool

A boolean that indicates if the NSRulerView’s coordinate system is flipped.

Constants

NSRuler​Orientation

These constants are defined to specify a ruler’s orientation and are used by orientation.