PATH  Documentation > Mac OS X > Application Kit Reference: Java

Table of Contents

NSCellForTextAttachment


Package:
com.apple.yellow.application

Interface Description


The NSCellForTextAttachment protocol declares the interface for objects that draw text attachment icons and handle mouse events on their icons. With the exceptions of cellBaselineOffset, setAttachment and attachment, all of these methods are implemented by the NSCell class and described in that class specification.

See the NSAttributedString and NSTextView class specifications for general information on text attachments.



Method Types


Drawing
drawWithFrameInView
highlightWithFrameInView
Cell size and position
cellSize
cellBaselineOffset
cellFrame
Event handling
wantsToTrackMouse
trackMouse
Setting the attachment
setAttachment
attachment


Instance Methods



attachment

public abstract NSTextAttachment attachment()

Returns the text attachment object that owns the receiver.

See Also: setAttachment



cellBaselineOffset

public abstract NSPoint cellBaselineOffset()

Returns the position where the attachment cell's image should be drawn in text, relative to the current point established in the glyph layout. The image should be drawn so its lower left corner lies on this point.

See Also: - icon (NSFileWrapper)



cellFrame

public abstract NSRect cellFrame( NSTextContainer textContainer, NSRect lineFrag, NSPoint position, int charIndex)

Description forthcoming.

cellSize

public abstract NSSize cellSize()

Returns the size of the attachment's icon.

See Also: - icon (NSFileWrapper), - fileWrapper (NSTextAttachment)



drawWithFrameInView

public abstract void drawWithFrameInView( NSRect cellFrame, NSView aView)

Draws the receiver's image within cellFrame in aView, which should be the focus view.

See Also: - drawWithFrameInViewdrawWithFrame:inView: (NSCell), - lockFocus (NSView)

public abstract void drawWithFrameInView( NSRect cellFrame, NSView aView, int charIndex)

Description forthcoming.

highlightWithFrameInView

public abstract void highlightWithFrameInView( boolean flag, NSRect cellFrame, NSView aView)

Draws the receiver's image-with highlighting if flag is true-within cellFrame in aView, which should be the focus view.

See Also: - highlightWithFrameInViewhighlight:withFrame:inView: (NSCell), - lockFocus (NSView)



setAttachment

public abstract void setAttachment(NSTextAttachment anAttachment)

Sets the text attachment object that owns the receiver to anAttachment.

See Also: attachment, - setAttachmentCell: (NSTextAttachment)



trackMouse

public abstract boolean trackMouse( NSEvent theEvent, NSRect cellFrame, NSView aTextView, int charIndex, boolean flag)

Description forthcoming.

public abstract boolean trackMouse( NSEvent theEvent, NSRect cellFrame, NSView aTextView, boolean flag)

Handles a mouse-down event on the receiver's image. theEvent is the mouse-down event. cellFrame is the region of aTextView in which further mouse events should be tracked. aTextView is the view that received the event. It's assumed to be an NSTextView, and should be the focus view. If flag is true, the receiver tracks the mouse until a mouse-up event occurs; if flag is false, it stops tracking when a mouse-dragged event occurs outside of cellFrame. Returns true if the receiver successfully finished tracking the mouse (typically through a mouse-up event), false otherwise (such as when the mouse is dragged outside cellFrame).

NSTextAttachmentCell's implementation of this method calls upon aTextView's delegate to handle the event. If theEvent is a mouse-up event for a double click, the text attachment cell sends the delegate a textViewDoubleClickedCelltextView:doubleClickedOnCell:inRect: message and returns true. Otherwise, depending on whether the user clicks or drags the cell, it sends the delegate a textViewClickedCelltextView:clickedOnCell:inRect: or a textViewDraggedCelltextView:draggedCell:inRect:event: message and returns true. NSTextAttachmentCell's implementation returns false only if flag is false and the mouse is dragged outside of cellFrame. The delegate methods are invoked only if the delegate responds.

See Also: wantsToTrackMouse, - trackMouse:inRect:ofView:untilMouseUp: (NSCell), - lockFocus (NSView)



wantsToTrackMouse

public abstract boolean wantsToTrackMouse()

Returns true if the receiver will handle a mouse event occurring over its image (to support dragging, for example), false otherwise. NSTextAttachmentCell's implementation of this method returns true. The NSView containing the cell should invoke this method before sending a trackMouse:inRect:ofView:untilMouseUp: message.

For an attachment in an attributed string, if the attachment cell returns false its attachment character should be selected rather than the cell being asked to track the mouse. This results in the attachment icon behaving as any regular glyph in text.




Table of Contents