Mac Developer Library

Developer

IKImageBrowserView Class Reference

Options
Deployment Target:

On This Page
Language:

IKImageBrowserView

The IKImageBrowserView class is a view for displaying and browsing a large amount of images and movies efficiently.

You must set a datasource for the view and implement, at a minimum, the numberOfItemsInImageBrowser: and imageBrowser:itemAtIndex: described in IKImageBrowserDataSource Protocol Reference. The items must conform to the IKImageBrowserItem Protocol protocol.

The class’s delegate object must conform to IKImageBrowserDelegate Protocol protocol. It receives notification of changes in selection, as well as mouse events in the cells.

  • Initializes a newly allocated image browser view with the provided frame rectangle.

    Declaration

    - (id)initWithFrame:(NSRect)frame

    Parameters

    frame

    The rectangle for the image browser.

    Return Value

    The initialized object.

  • Marks the receiver as needing its data reloaded.

    Declaration

    - (void)reloadData

  • Sets the delegate of the receiver.

    Declaration

    - (void)setDelegate:(id)aDelegate

    Parameters

    aDelegate

    The delegate must implement the IKImageBrowserDelegate informal protocol.

    See Also

    – delegate

  • Returns the delegate of the receiver.

    Declaration

    - (id)delegate

    Return Value

    The delegate.

  • Sets the data source of the receiver.

    Declaration

    - (void)setDataSource:(id)source

    Parameters

    source

    A data source (IKImageBrowserDataSource).

    See Also

    – dataSource

  • Returns the data source of the receiver.

    Declaration

    - (id)dataSource

    Return Value

    The data source (IKImageBrowserDataSource). The data source is not retained by the receiver.

  • Defines the appearance style of the cells.

    Declaration

    - (void)setCellsStyleMask:(NSUInteger)mask

    Parameters

    mask

    An integer bit mask. A mask can be specified by combining any of the options described in “Cell Appearance Style Masks” using the C bitwise OR operator.

  • Returns the appearance style mask for the cell.

    Declaration

    - (NSUInteger)cellsStyleMask

    Return Value

    The appearance style mask for the cell.

  • Sets whether the receiver constrains the cell’s image to its original size.

    Declaration

    - (void)setConstrainsToOriginalSize:(BOOL)flag

    Parameters

    flag

    A flag that specifies whether to constrain the image. The default value is NOfalse.

  • Returns whether the receiver constrains the cell's image to its original size.

    Declaration

    - (BOOL)constrainsToOriginalSize

    Return Value

    NOfalse if the image is not constrained; otherwise YEStrue.

  • Sets the spacing between cells in the view.

    Declaration

    - (void)setIntercellSpacing:(NSSize)aSize

    Parameters

    aSize

    The vertical and horizontal spacing between cells.

    Discussion

    By default, both values are 10.0 in the receiver’s coordinate system.

  • Returns the spacing between cells in the view.

    Declaration

    - (NSSize)intercellSpacing

    Return Value

    The vertical and horizontal spacing between cells.

  • Returns the cell to use for the specified item.

    Declaration

    - (IKImageBrowserCell *)newCellForRepresentedItem:(id)anItem

    Parameters

    anItem

    The item that the returned cell will represent.

    Return Value

    A new cell.

    Discussion

    Subclasses can override this method to customize the appearance of the cell that will represent anItem.

  • Sets the zoom value.

    Declaration

    - (void)setZoomValue:(float)aValue

    Parameters

    aValue

    The zoom value. This value should be greater or equal to zero and less or equal than one. A zoom value of zero corresponds to the minimum size (40x40 pixels). A zoom value of one means images fits the browser bounds. Other values are interpolated.

    Discussion

    You must use setZoomValue or setCellSize:, but not both. Setting the zoom value changes the cell size, and vice versa.

  • Returns the current zoom value.

    Declaration

    - (float)zoomValue

    Return Value

    The zoom value.

  • Determines how the receiver resizes its content when zooming.

    Declaration

    - (void)setContentResizingMask:(NSUInteger)mask

    Parameters

    mask

    A resizing mask. You specify a mask by combining any of the following options using the C bitwise OR operator: NSViewWidthSizable, NSViewHeightSizable. Other values are ignored.

  • Returns the receiver’s content resizing mask, which determines how its content is resized while zooming.

    Declaration

    - (NSUInteger)contentResizingMask

    Return Value

    The content resizing mask.

  • Scrolls the receiver to the item at the specified index.

    Declaration

    - (void)scrollIndexToVisible:(NSInteger)index

    Parameters

    index

    The index of the item to scroll to.

  • Returns the index of the item at the specified location.

    Declaration

    - (NSInteger)indexOfItemAtPoint:(NSPoint)point

    Parameters

    point

    The location of the item.

    Return Value

    The index of the item or NSNotFound if no item at this location.

  • Returns the frame rectangle for the item located at the specified index.

    Declaration

    - (NSRect)itemFrameAtIndex:(NSInteger)index

    Parameters

    index

    The index of the item whose frame rectangle you want to obtain.

    Return Value

    The frame rectangle of the item.

  • Returns the indexes of the view’s currently visible items.

    Declaration

    - (NSIndexSet *)visibleItemIndexes

    Return Value

    A set containing the indexes.

  • Returns the browser cell for the item at the specified index.

    Declaration

    - (IKImageBrowserCell *)cellForItemAtIndex:(NSUInteger)index

    Parameters

    index

    The index.

    Return Value

    The browser cell at the specified index.

    Discussion

    Subclasses must not override this method.

  • Returns the indexes of the selected cells.

    Declaration

    - (NSIndexSet *)selectionIndexes

    Return Value

    The indexes of the selected cells.

  • Selects cells at the specified indexes.

    Declaration

    - (void)setSelectionIndexes:(NSIndexSet *)indexes byExtendingSelection:(BOOL)extendSelection

    Parameters

    indexes

    The indexes of the cells you want to select.

    extendSelection

    A BOOL value that specifies whether to extend the current selection. Pass YEStrue to extends the selection; NOfalse replaces the current selection.

  • Controls whether the user can select more than one cell at a time.

    Declaration

    - (void)setAllowsMultipleSelection:(BOOL)flag

    Parameters

    flag

    A BOOL value that specifies whether to allow multiple selections.

  • Returns whether multiple selections are allowed.

    Declaration

    - (BOOL)allowsMultipleSelection

    Return Value

    YEStrue if the receiver allows the user to select more than one cell at a time; NOfalse otherwise.

  • Controls whether an empty selection is allowed.

    Declaration

    - (void)setAllowsEmptySelection:(BOOL)flag

    Parameters

    flag

    A BOOL value that specifies whether to allow an empty selection.

  • Returns whether an empty selection is allowed.

    Declaration

    - (BOOL)allowsEmptySelection

    Return Value

    YEStrue if the receiver allows an empty selection; NOfalse otherwise.

  • Controls whether the user can reorder items.

    Declaration

    - (void)setAllowsReordering:(BOOL)flag

    Parameters

    flag

    A BOOL value that specifies whether the user can reorder items.

  • Returns whether the user can reorder items.

    Declaration

    - (BOOL)allowsReordering

    Return Value

    YEStrue if the user can reorder items; NOfalse otherwise.

  • Controls whether the receiver animates reordering and changes of the data source.

    Declaration

    - (void)setAnimates:(BOOL)flag

    Parameters

    flag

    A BOOL value that specifies whether the receiver animates reordering and changes of the data source.

    See Also

    – animates

  • Returns whether the receiver animates reordering and changes of the data source.

    Declaration

    - (BOOL)animates

    Return Value

    YEStrue if the receiver animates reordering and changes of the data source; NOfalse otherwise.

  • Expands a group at the specified index.

    Declaration

    - (void)expandGroupAtIndex:(NSUInteger)index

    Parameters

    index

    The index of the group you want to expand.

    Special Considerations

    This method is declared in OS X v10.5, but an implementation was not provided until OS X v10.6. Avoid using this method on OS X v10.5.

    Availability

    Available in OS X v10.6 and later.

  • Collapses a group at the specified index.

    Declaration

    - (void)collapseGroupAtIndex:(NSUInteger)index

    Parameters

    index

    The index of the group you want to collapse.

    Special Considerations

    This method is declared in OS X v10.5, but an implementation was not provided until OS X v10.6. Avoid using this method on OS X v10.5.

    Availability

    Available in OS X v10.6 and later.

  • Returns whether the group at the provided index is expanded.

    Declaration

    - (BOOL)isGroupExpandedAtIndex:(NSUInteger)index

    Parameters

    index

    The index you want to check.

    Return Value

    YEStrue if the group is expanded; NOfalse otherwise.

    Special Considerations

    This method is declared in OS X v10.5, but an implementation was not provided until OS X v10.6. Avoid using this method on OS X v10.5.

    Availability

    Available in OS X v10.6 and later.

  • Sets the dragging destination delegate of the receiver.

    Declaration

    - (void)setDraggingDestinationDelegate:(id)delegate

    Parameters

    delegate

    The delegate (NSDraggingDestination) to set.

  • Returns the dragging destination delegate of the receiver.

    Declaration

    - (id)draggingDestinationDelegate

    Return Value

    The receiver's dragging destination delegate.

  • Allows the class to retarget the drop action.

    Declaration

    - (void)setDropIndex:(NSInteger)index dropOperation:(IKImageBrowserDropOperation)operation

    Parameters

    index

    The requested drop index.

    operation

    The requested drop operation. The possible values are described in IKImageBrowserDropOperation.

    Discussion

    For example, To specify a drop on the second item, one would specify index as 1, and operation as IKImageBrowserDropOn. To specify a drop after the last item, one would specify index as the number of items and operation as IKImageBrowserDropBefore.

    Passing a value of –1 for index, and IKImageBrowserDropOn as the operation causes the entire browser view to be highlighted rather than a specific item. This is useful if the data displayed by the receiver does not allow the user to drop items at a specific item location

    .

  • Returns the index of the cell where the drop operation occurred.

    Declaration

    - (NSUInteger)indexAtLocationOfDroppedItem

    Return Value

    The index of the cell where the drop operation occurred.

    Discussion

    The returned index is valid until the next drop occurs.

  • Specifies whether the user can drop on items.

    Declaration

    - (void)setAllowsDroppingOnItems:(BOOL)flag

    Parameters

    flag

    YEStrue if the user is able to drop on items, otherwise NOfalse.

    Discussion

    The default is NOfalse.

  • Returns whether the user can drop on items.

    Declaration

    - (BOOL)allowsDroppingOnItems

    Return Value

    YEStrue if the user is able to drop on items, otherwise NOfalse.

    Discussion

    The default is NOfalse.

  • Returns the current drop operation.

    Declaration

    - (IKImageBrowserDropOperation)dropOperation

    Return Value

    IKImageBrowserDropOn if the drop occurs on an item, otherwise IKImageBrowserDropBefore.

    Discussion

    The returned value is valid when a drop occurred and until next drop.

    For example, given a browser with N cells , a cell of N-1 and operation of IKImageBrowserDropOn would specify a drop on the last cell. To specify a drop after the last cell, one would use an index of N and IKImageBrowserDropBefore for the operation.

  • The Core Animation layer used as the foreground overlay.

    Declaration

    - (void)setForegroundLayer:(CALayer *)aLayer

    Parameters

    aLayer

    A CALayer instance.

    Discussion

    The foreground overlay layer can have sublayers. Additionally, the layers can also contain animations.

    The foreground layer is an overlay that is applied to the view. It can be used to provide information such as loading progress or for pure cosmetic purposes, such as dark gradients on top and bottom of the browser view.

    This layer is optional.

  • Returns the foreground Core Animation layer

    Declaration

    - (CALayer *)foregroundLayer

    Return Value

    A CALayer instance.

  • The Core Animation layer used as the view’s background.

    Declaration

    - (void)setBackgroundLayer:(CALayer *)aLayer

    Parameters

    aLayer

    A CALayer instance.

    Discussion

    The background layer can have sublayers. Additionally, the layers can also contain animations.

    The layer is optional.

  • Returns the foreground Core Animation layer

    Declaration

    - (CALayer *)backgroundLayer

    Return Value

    A CALayer instance.

  • Specifies whether the view can automatically take control of the QuickLook panel.

    Declaration

    - (void)setCanControlQuickLookPanel:(BOOL)flag

    Parameters

    flag

    YEStrue, if the view can display the QuickLook panel, otherwise NOfalse.

    Discussion

    When the browser view displays the QuickLook panel it sets itself as the QuickLook datasource. If the browser cells returned by the datasource return items that are URLs or paths, then the QuickLook panel will display the image at that location. Otherwise, the browser cell must implement the QLPreviewItem protocol and return the requested URL for the custom cell.

  • Returns whether the view can automatically take control of the QuickLook panel.

    Declaration

    - (BOOL)canControlQuickLookPanel

    Return Value

    YEStrue, if the view can display the Quick Look panel, otherwise NOfalse.

  • Returns the current number of columns.

    Declaration

    - (NSUInteger)numberOfColumns

    Return Value

    The number of columns.

  • Returns the current number of rows.

    Declaration

    - (NSUInteger)numberOfRows

    Return Value

    The number of rows.

  • Returns the rectangle containing the specified column.

    Declaration

    - (NSRect)rectOfColumn:(NSUInteger)columnIndex

    Parameters

    columnIndex

    The column index.

    Return Value

    A rectangle containing the column. Specified in the view’s coordinate system.

  • Returns the column indexes in the specified rectangle.

    Declaration

    - (NSIndexSet *)columnIndexesInRect:(NSRect)rect

    Parameters

    rect

    The rectangle in the view’s coordinate system.

    Return Value

    An index set containing the cell indexes.

  • Returns the rectangle containing the specified row.

    Declaration

    - (NSRect)rectOfRow:(NSUInteger)rowIndex

    Parameters

    rowIndex

    The row index.

    Return Value

    A rectangle containing the column. Specified in the view’s coordinate system.

  • Returns the row indexes in the specified rectangle.

    Declaration

    - (NSIndexSet *)rowIndexesInRect:(NSRect)rect

    Parameters

    rect

    A rectangle in the view’s coordinate system.

    Return Value

    An index set containing the item indexes.

Data Types

  • These constants specify the locations for dropping items onto the browser view. Used by the method setDropIndex:dropOperation:.

    Declaration

    typedef enum { IKImageBrowserDropOn=0, IKImageBrowserDropBefore=1, }IKImageBrowserDropOperation;

    Constants

    • IKImageBrowserDropOn

      Drop the item on the cell.

    • IKImageBrowserDropBefore

      Drop the item before the cell.

    Import Statement

  • Masks for the appearance style bit field.

    Declaration

    enum{ IKCellsStyleNone =0, IKCellsStyleShadowed =1, IKCellsStyleOutlined =2, IKCellsStyleTitled =4, IKCellsStyleSubtitled =8 };

    Constants

    • IKCellsStyleNone

      No style.

    • IKCellsStyleShadowed

      Cells use shadows.

    • IKCellsStyleOutlined

      Cells are outlined.

    • IKCellsStyleTitled

      Cells display a title.

    • IKCellsStyleSubtitled

      Cells display a subtitle.

  • Attributes for the group style. Used by the

    Declaration

    enum{ IKGroupBezelStyle, IKGroupDisclosureStyle, };

    Constants

    • IKGroupBezelStyle

      A bezel style.

    • IKGroupDisclosureStyle

      A disclosure triangle.

    Discussion

    These constants affect the appearance of a group.

  • Keys for image browser view options. You set and retrieve values for these keys by sending the view setValue:forKey and valueForKey: messages.

    Declaration

    NSString * const IKImageBrowserBackgroundColorKey; NSString * const IKImageBrowserSelectionColorKey; NSString * const IKImageBrowserCellsOutlineColorKey; NSString * const IKImageBrowserCellsTitleAttributesKey; NSString * const IKImageBrowserCellsHighlightedTitleAttributesKey; NSString * const IKImageBrowserCellsSubtitleAttributesKey;

    Constants

    • IKImageBrowserBackgroundColorKey

      A key for the background color of the image browser view. The associated value is an NSColor object.

    • IKImageBrowserSelectionColorKey

      A key for the color that indicates a selection. The associated value is an NSColor object.

    • IKImageBrowserCellsOutlineColorKey

      A key for the outline color for an item in the image browser view. The associated value is an NSColor object.

    • IKImageBrowserCellsTitleAttributesKey

      A key for title attribute of an item in the image browser view. The associated value is an NSDictionary object.

    • IKImageBrowserCellsHighlightedTitleAttributesKey

      A key for the highlighted title attribute for an item in the image browser view. The associated value is an NSDictionary object.

    • IKImageBrowserCellsSubtitleAttributesKey

      A key for a subtitle attribute for an item in the image browser view. The associated value is an NSDictionary object.

    Discussion

  • Keys for group attributes.

    Declaration

    NSString * const IKImageBrowserGroupRangeKey; NSString * const IKImageBrowserGroupBackgroundColorKey; NSString * const IKImageBrowserGroupTitleKey; NSString * const IKImageBrowserGroupStyleKey; NSString * const IKImageBrowserGroupHeaderLayer; NSString * const IKImageBrowserGroupFooterLayer;

    Constants

    • IKImageBrowserGroupRangeKey

      A key for the range of a group. The associated value is an NSValue object. This is required if the view uses grouping

    • IKImageBrowserGroupBackgroundColorKey

      A key for the background color of a group. The associated value is an NSColor object. This color is used only for the bezel style.

    • IKImageBrowserGroupTitleKey

      A key for the title of a group. The associated value is an NSString object. This string is used for the disclosure style only.

    • IKImageBrowserGroupStyleKey

      A key for the style of a group. The associated value is one of the constants defined in “Group Style Attributes”.

    • IKImageBrowserGroupHeaderLayer

      A key for the header layer of the group. The associated value is a CALayer.

    • IKImageBrowserGroupFooterLayer

      A key for the header layer of the group. The associated value is a CALayer.