Class

NSRulerView

A ruler and the markers above or to the side of a scroll view’s document view.

Declaration

@interface NSRulerView : NSView

Overview

Views within the scroll view 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.

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

clientView

Changes the ruler’s client view.

markers

Sets the markers displayed by the ruler view.

accessoryView

Sets the accessory view.

trackMarker:withMouseEvent:

Allows the user to add a new marker.

Overview

See NSRulerMarkerClientViewDelegation for delegate methods that may be of interest.

Topics

Creating a Ruler View

- initWithScrollView:orientation:

Initializes a newly allocated NSRulerView to have orientation (NSHorizontalRuler or NSVerticalRuler) within aScrollView.

Altering measurement units

+ registerUnitWithName:abbreviation:unitToPointsConversionFactor:stepUpCycle:stepDownCycle:

Registers a new unit of measurement with the NSRulerView class, making it available to all instances of NSRulerView.

measurementUnits

The measurement units used by the ruler to unitName.

Setting the client view

clientView

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

Setting an accessory view

accessoryView

The receiver’s accessory view to aView.

Setting the zero mark position

originOffset

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

markers

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

- addMarker:

Adds aMarker to the receiver, without consulting the client view for approval.

- removeMarker:

Removes aMarker from the receiver, without consulting the client view for approval.

- trackMarker:withMouseEvent:

Tracks the mouse to add aMarker based on the initial mouse-down or mouse-dragged event theEvent.

Drawing temporary ruler lines

- moveRulerlineFromLocation:toLocation:

Draws temporary lines in the ruler area.

Drawing

- drawHashMarksAndLabelsInRect:

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

- drawMarkersInRect:

Draws the receiver’s markers in aRect, which is expressed in the receiver’s coordinate system.

- invalidateHashMarks

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

Ruler layout

scrollView

The NSScrollView that owns the receiver to scrollView, without retaining it.

orientation

The orientation of the receiver to orientation.

NSRulerOrientation

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

reservedThicknessForAccessoryView

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

reservedThicknessForMarkers

The room available for ruler markers to thickness.

ruleThickness

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

requiredThickness

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

baselineLocation

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

flipped

A Boolean that indicates if the ruler view's coordinate system is flipped.

Relationships

Inherits From

See Also

Rulers

NSRulerMarker

A symbol on a ruler view, indicating a location for the graphics element it represents in the client of the ruler view.