NSRulerMarker Class Objective-C Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSRulerMarker.h |
Overview
An NSRulerMarker object displays a symbol on an NSRulerView object, indicating a location for whatever graphics element it represents in the client of the ruler view (for example, a margin or tab setting, or the edges of a graphic on the page).
Adopted Protocols
Tasks
Creating Instances
Getting the Ruler View
Setting the Image
Setting Movability
Setting the Location
Setting the Represented Object
Drawing and Event Handling
Instance Methods
drawRect:
Draws the receiver’s image that appears in the supplied rectangle.
Parameters
- aRect
The rectangle to be drawn, in the ruler view's coordinate system.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.himage
Returns the image displayed by the receiver.
Return Value
The image displayed by the receiver.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.himageOrigin
Returns the point in the receiver’s image positioned at the receiver’s location on the ruler view.
Return Value
The point in the receiver’s image positioned at the receiver’s location on the ruler view, expressed in the image’s coordinate system.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.himageRectInRuler
Returns the rectangle occupied by the receiver’s image.
Return Value
The rectangle occupied by the receiver’s image, in the ruler view's coordinate system, accounting for whether the ruler view's coordinate system is flipped.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hinitWithRulerView:markerLocation:image:imageOrigin:
Initializes a newly allocated ruler marker, associating it with (but not adding it to) a specified ruler view and assigning the attributes provided.
Parameters
- aRulerView
The ruler view with which to associate the ruler marker. This method raises an
NSInvalidArgumentExceptionif aRulerView isnil.- location
The x or y position of the marker in the client view’s coordinate system, depending on whether the ruler view is horizontal or vertical.
- anImage
The image displayed at the marker location. This method raises an
NSInvalidArgumentExceptionif anImage isnil.- imageOrigin
The point within the image positioned at the marker location, expressed in pixels relative to the lower-left corner of the image.
Return Value
An initialized ruler marker object.
Discussion
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 ruler view 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:withMouseEvent: allows the client view to intercede in the addition and placement of the marker.
A new ruler marker can be moved on its ruler view, but not removed. Use setMovable: and setRemovable: to change these attributes. The new ruler marker also has no represented object; use setRepresentedObject: to set one.
This method is the designated initializer for the NSRulerMarker class.
Availability
- Available in OS X v10.0 and later.
Declared In
NSRulerMarker.hisDragging
Returns whether the receiver is being dragged.
Return Value
YES if the receiver is being dragged, NO otherwise.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hisMovable
Returns whether the user can move the receiver on its ruler view.
Return Value
YES if the user can move the receiver on its ruler view, NO otherwise.
Discussion
By default ruler markers are movable.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hisRemovable
Returns whether the user can remove the receiver from its ruler view.
Return Value
YES if the user can remove the receiver from its ruler view, NO otherwise.
Discussion
By default ruler markers are not removable.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hmarkerLocation
Returns the location of the receiver in the coordinate system of the ruler view's client view.
Return Value
The location of the receiver in the coordinate system of the ruler view's client view. This is an x position for a horizontal ruler, a y position for a vertical ruler.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hrepresentedObject
Returns the object the receiver represents.
Return Value
The object the receiver represents.
Discussion
See About Ruler Markers for more information on the represented object.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hruler
Returns the receiver's ruler view.
Return Value
The receiver's ruler view.
Availability
- Available in OS X v10.0 and later.
See Also
-
– addMarker:(NSRulerView)
Declared In
NSRulerMarker.hsetImage:
Sets the receiver’s image.
Parameters
- anImage
The new image.
Discussion
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 ruler view neither scales nor rotates the images.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hsetImageOrigin:
Sets the point in the receiver’s image that is positioned at the receiver’s location on the ruler view.
Parameters
- aPoint
The point within the image positioned at the marker location, expressed in pixels relative to the lower-left corner of the image.
Discussion
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.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hsetMarkerLocation:
Sets the location of the receiver in the coordinate system of the ruler view's client view.
Parameters
- location
The location of the receiver in the coordinate system of the ruler view's client view. This is an x position for a horizontal ruler, a y position for a vertical ruler.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hsetMovable:
Sets whether the user can move the receiver in its ruler view.
Parameters
- flag
YESto allow the user to drag the marker image in the ruler,NOto make it immobile.
Discussion
By default ruler markers are movable.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hsetRemovable:
Sets whether the user can remove the receiver from its ruler view.
Parameters
- flag
YESto allow the user to drag the marker image off of the ruler and remove the marker,NOto prevent the user from removing the marker.
Discussion
By default ruler markers are not removable.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hsetRepresentedObject:
Sets the object the receiver represents.
Parameters
- anObject
The new represented object.
Discussion
See About Ruler Markers for more information on the represented object.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.hthicknessRequiredInRuler
Returns the amount of the receiver’s image that’s displayed above or to the left of the ruler view's baseline.
Return Value
The amount of the receiver’s image that’s displayed above or to the left of the ruler view's baseline, the height for a horizontal ruler or width for a vertical ruler.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.htrackMouse:adding:
Handles user manipulation of the receiver in its ruler view.
Parameters
- theEvent
The event that represents the user manipulation being attempted on the ruler marker.
- flag
YESto indicate that the receiver is a new marker being added to its ruler view,NOotherwise.
Return Value
YES if the user manipulation was allowed, NO if it was not allowed.
Discussion
NSRulerView objects invoke this method automatically to add a new marker or to move or remove an existing marker. You should never need to invoke it directly.
If the receiver is a new marker being added to its ruler view (flag is YES), the receiver queries the ruler view's client before adding itself to the ruler view. If the client responds to rulerView:shouldAddMarker: and that method returns NO, this method immediately returns NO, and the new marker isn’t added.
If the receiver is not a new marker being added to its ruler view (flag is NO), this method attempts to move or remove an existing marker, once again based on responses from the ruler view's client view. If the receiver is neither movable nor removable, this method immediately returns NO. Further, if the ruler view's client responds to rulerView:shouldMoveMarker: and returns NO, this method returns NO, 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 ruler view.
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 NO, the marker is pinned to the ruler view's baseline (following the cursor on the baseline if it’s movable).
When the user releases the mouse button, 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 YES and the user dragged the new marker away from the ruler, the marker isn’t added, no message is sent, and this method returns NO.
See Ruler and Paragraph Style Programming Topics for more information on these client methods.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSRulerMarker.h© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)