Inherits from: NSObject
Package: com.apple.yellow.application
An NSRulerMarker displays a symbol on an NSRulerView, indicating a location for whatever graphic element it represents in the client of the NSRulerView (for example, a margin or tab setting, or the edges of a graphic on the page). A ruler marker comprises three primary attributes: the image it displays on the NSRulerView, the location of that image, and the object it represents. The setImage, setMarkerLocation and setRepresentedObject methods set each of these attributes, respectively. In addition, a ruler marker records an offset for the image, allowing it to be placed relative to the marker location much in the way a cursor's hot spot relates a cursor image to the mouse location; the setImageOrigin method establishes this offset.
Most of these attributes are set upon initialization by the constructor. New ruler markers don't have represented objects; the client typically establishes the represented object in its rulerView:didAddMarker: method. A new NSRulerMarker can be moved around in its NSRulerView, but not removed from it. The setMovable and setRemovable methods alter these default settings.
Represented objects allow the NSRulerView's client to distinguish among different attributes of the selection. In the NSRulerView client methods, the client can retrieve the marker's represented object to determine what attribute to alter. Generic attributes can be represented by string or other value objects, such as the edge names "Left", "Right", "Top", and "Bottom". Attributes already implemented as objects can be represented by those objects. For example, the text system records tab stops as NSTextTab objects, which include the tab location and its alignment. When an NSTextView is the client view of a ruler, it simply makes the NSTextTabs the represented objects of the ruler markers.
- NSCopying
- - copyWithZone:
- Creating instances
- initWithRulerView:markerLocation:image:imageOrigin:
- Getting the ruler view
- ruler
- Setting the image
- setImage
- image
- setImageOrigin
- imageOrigin
- imageRectInRuler
- thicknessRequiredInRuler
- Setting movability
- setMovable
- isMovable
- setRemovable
- isRemovable
- Setting the location
- setMarkerLocation
- markerLocation
- Setting the represented object
- setRepresentedObject
- representedObject
- Drawing and event handling
- drawRect
- isDragging
- trackMouseToAddMarker
public NSRulerMarker(NSRulerView aRulerView, float location, NSImage anImage, NSPoint imageOrigin)
null
.The image used to draw the marker must be appropriate for the orientation of the ruler. Markers may need to look different on a horizontal ruler than on a vertical ruler, and the NSRulerView neither scales nor rotates the images.
To add the new ruler marker to aRulerView, use either of NSRulerView's addMarker: or trackMarker:withMouseEvent: methods. addMarker: immediately puts the marker on the ruler, while trackMarker:withMousEvent: allows the client view to intercede in the addition and placement of the marker.
A new ruler marker can be moved on its NSRulerView, but not removed. Use setMovable and setRemovable to change these attributes. The new ruler marker also has no represented object; use setRepresentedObject to provide or change it.
See Also: - setMarkerLocation:, - setImage:, - setImageOrigin:
public void drawRect(NSRect aRect)
See Also: imageRectInRuler
public NSImage image()
See Also: setImage
public NSPoint imageOrigin()
For a horizontal ruler, the x coordinate of the image origin is aligned with the location of the marker, and the y coordinate lies on the baseline of the ruler. For vertical rulers, the y coordinate of the image origin is the location, and the x coordinate lies on the baseline.
See Also: setImageOrigin, imageRectInRuler
public NSRect imageRectInRuler()
See Also: drawRect, thicknessRequiredInRuler
public boolean isDragging()
true
if
the receiver is being dragged, false otherwise.See Also: trackMouseToAddMarker
public boolean isMovable()
true
if
the user can move the receiver on its NSRulerView, false
otherwise. NSRulerMarkers
are by default movable.See Also: setMovable, isRemovable
public boolean isRemovable()
true
if
the user can remove the receiver from its NSRulerView, false
otherwise. NSRulerMarkers
cannot by default be removed from their NSRulerViews.See Also: setRemovable, isMovable
public float markerLocation()
See Also: setMarkerLocation
public Object representedObject()
See Also: setRepresentedObject
public NSRulerView ruler()
See Also: - addMarker: (NSRulerView)
public void setImage(NSImage anImage)
See Also: image, setImageOrigin
public void setImageOrigin(NSPoint aPoint)
For a horizontal ruler, the x coordinate of the image origin is aligned with the location of the marker, and the y coordinate lies on the baseline of the ruler. For vertical rulers, the y coordinate of the image origin is the location, and the x coordinate lies on the baseline.
See Also: imageOrigin, setImage, setMarkerLocation
public void setMarkerLocation(float location)
See Also: markerLocation, setImageOrigin
public void setMovable(boolean flag)
true
,
the user can drag the marker image in the ruler. If flag is false
,
the receiver is immovable. NSRulerMarkers are by default movable.See Also: isMovable, setRemovable
public void setRemovable(boolean flag)
true
,
the user can drag the marker image off of the ruler. If flag is false
,
the receiver can't be removed. NSRulerMarkers are by default not removable.See Also: isRemovable, setMovable
public void setRepresentedObject(Object anObject)
See Also: representedObject
public float thicknessRequiredInRuler()
See Also: imageOrigin
public boolean trackMouseToAddMarker(NSEvent theEvent, boolean flag)
If flag is true
,
the receiver is a new marker being added to its NSRulerView. Before
the receiver actually adds itself to the NSRulerView, it queries
the NSRulerView's client view using rulerView:shouldAddMarker:.
If the client view responds to this method and returns false
,
this method immediately returns false
and
the new marker isn't added.
If flag is false
,
this method attempts to move or remove an existing marker, once
again based on responses from the NSRulerView's client view. If
the receiver is neither movable nor removable, this method immediately
returns false. Further, if the NSRulerView's client responds to rulerView:shouldMoveMarker: and
returns false
, this method returns false
, indicating
the receiver can't be moved.
If the receiver is being added or moved, this method queries the client view using rulerView:willAddMarker:atLocation: or rulerView:willMoveMarker:toLocation:, respectively. If the client responds to the method, the return value is used as the receiver's location. These methods are invoked repeatedly as the receiver is dragged within the NSRulerView.
If
the receiver is an existing marker being removed (dragged off the
ruler), this method queries the client view using rulerView:shouldRemoveMarker:.
If the client responds to this method and returns false
,
the marker is pinned to the NSRulerView's baseline (following
the mouse on the baseline if it's movable).
When the
user releases the mouse, this method informs the client view of
the marker's new status using rulerView:didAddMarker:, rulerView:didMoveMarker:,
or rulerView:didRemoveMarker: as appropriate. The
client view can use this notification to set the marker's represented
object, modify its state and redisplay (for example, adjusting text
layout around a new tab stop), or take whatever other action it
might need. If flag is true
and
the user dragged the new marker away from the ruler, the marker
isn't added, no message is sent, and this method returns false
.
See the NSRulerView class description for more information on these client methods.
See Also: isMovable, isRemovable