Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/AppKit.framework |
Availability | Available in Mac OS X v10.0 and later. |
Companion guide | |
Declared in | NSSplitView.h |
Related sample code |
An NSSplitView
object stacks several subviews within one view so that the user can change their relative sizes. By default, the split bars between the views are horizontal, so the views are one on top of the other.
Divider indices are zero-based, with the topmost (in horizontal split views) or leftmost (vertical) divider having an index of 0.
– adjustSubviews
– isSubviewCollapsed:
– splitView:resizeSubviewsWithOldSize:
delegate method
– splitViewWillResizeSubviews:
delegate method
– splitViewDidResizeSubviews:
delegate method
– splitView:canCollapseSubview:
delegate method
– splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:
delegate method
– setDividerStyle:
– dividerStyle
– dividerThickness
– dividerColor
– drawDividerInRect:
– splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:
delegate method
– splitView:shouldHideDividerAtIndex:
delegate method
– splitView:additionalEffectiveRectOfDividerAtIndex:
delegate method
– minPossiblePositionOfDividerAtIndex:
– maxPossiblePositionOfDividerAtIndex:
– setPosition:ofDividerAtIndex:
– splitView:constrainMaxCoordinate:ofSubviewAt:
delegate method
– splitView:constrainMinCoordinate:ofSubviewAt:
delegate method
– splitView:constrainSplitPosition:ofSubviewAt:
delegate method
Adjusts the sizes of the receiver’s subviews so they (plus the dividers) fill the receiver.
- (void)adjustSubviews
The subviews are resized proportionally; the size of a subview relative to the other subviews doesn’t change.
– setDelegate:
– setFrame:
(NSView)NSSplitView.h
Returns the name under which receiver’s divider position is automatically saved.
- (NSString *)autosaveName
The name used to save the receiver’s state.
NSSplitView.h
Returns the receiver’s delegate.
- (id)delegate
NSSplitView.h
Return the color of the dividers that the split view is drawing between subviews.
- (NSColor *)dividerColor
The color drawn between the subviews.
The default implementation of this method returns clearColor
when dividerStyle
returns NSSplitViewDividerStyleThick
. It will also return clearColor
when dividerStyle
returns NSSplitViewDividerStyleThin
if the split view is in a textured window. All other thin dividers are drawn with a color that looks good between two white panes.
You can override this method to change the color of dividers.
NSSplitView.h
Returns the style of the divider drawn between subviews.
- (NSSplitViewDividerStyle)dividerStyle
The current divider style. The possible values are described in “Split View Divider Styles.”
NSSplitView.h
Returns the thickness of the divider.
- (CGFloat)dividerThickness
You can subclass NSSplitView and override this method to change the divider’s size, if necessary.
NSSplitView.h
Draws the divider between two of the receiver’s subviews.
- (void)drawDividerInRect:(NSRect)aRect
aRect describes the entire divider rectangle in the receiver’s coordinates, which are flipped. If you override this method and use a custom icon to identify the divider, you may need to change the size of the divider.
NSSplitView.h
Returns YES
if the receiver’s splitter is a bar that goes across the split view. Returns NO
if the splitter is a thumb on the regular background pattern.
- (BOOL)isPaneSplitter
NSSplitView.h
Returns YES
if subview is in a collapsed state, NO
otherwise.
- (BOOL)isSubviewCollapsed:(NSView *)subview
NSSplitView.h
Returns YES
if the split bars are vertical (subviews are side by side), NO
if they are horizontal (views are one on top of the other).
- (BOOL)isVertical
By default, split bars are vertical.
NSSplitView.h
Returns the maximum possible position of the divider at the specified index.
- (CGFloat)maxPossiblePositionOfDividerAtIndex:(NSInteger)dividerIndex
The index of the divider.
A CGFloat specifying the maximum possible position of the divider.
The position is "possible" in that it is dictated by the bounds of the receiver and the current position of other dividers. "Allowable" positions are those that result from letting the delegate apply constraints to the possible positions.
You can invoke this method to determine the range of values that can be usefully passed to setPosition:ofDividerAtIndex:
.
You can also invoke it from delegate methods like splitView:constrainSplitPosition:ofSubviewAt:
to implement relatively complex behaviors that depend on the current state of the split view.
The results of invoking this method when adjustSubviews
has not been invoked, and the subview frames are invalid, is undefined.
NSSplitView.h
Returns the minimum possible position of the divider at the specified index.
- (CGFloat)minPossiblePositionOfDividerAtIndex:(NSInteger)dividerIndex
The index of the divider.
A CGFloat specifying the minimum possible position of the divider.
The position is "possible" in that it is dictated by the bounds of the receiver and the current position of other dividers. "Allowable" positions are those that result from letting the delegate apply constraints to the possible positions.
You can invoke this method to determine the range of values that can be usefully passed to setPosition:ofDividerAtIndex:
.
You can also invoke it from delegate methods like splitView:constrainSplitPosition:ofSubviewAt:
to implement relatively complex behaviors that depend on the current state of the split view.
The results of invoking this method when adjustSubviews
has not been invoked, and the subview frames are invalid, is undefined.
NSSplitView.h
Sets the name under which receiver’s divider position is automatically saved.
- (void)setAutosaveName:(NSString *)autosaveName
The name used to save the receiver’s state.
If this value is nil
or the string is empty no autosaving is done.
NSSplitView.h
Makes anObject the receiver’s delegate.
- (void)setDelegate:(id)anObject
The notification messages the delegate can expect to receive are listed in “Notifications.” The delegate doesn’t need to implement all of the delegate methods.
NSSplitView.h
Sets the style of divider drawn between subviews.
- (void)setDividerStyle:(NSSplitViewDividerStyle)dividerStyle
The divider style. Possible values are described in “Split View Divider Styles.”
NSSplitView.h
Sets the type of splitter.
- (void)setIsPaneSplitter:(BOOL)flag
If flag is YES
, the receiver’s splitter is a bar that goes across the split view. If flag is NO
, the splitter is a thumb on the regular background pattern.
NSSplitView.h
Sets the position of the divider at the specified index.
- (void)setPosition:(CGFloat)position ofDividerAtIndex:(NSInteger)dividerIndex
The position of the divider
The index of the divider.
The default implementation of this method behaves as if the user were attempting to drag the divider to the proposed position, so the constraints imposed by the delegate are applied and one of the views adjacent to the divider may be collapsed.
This method is not invoked by NSSplitView
itself.
NSSplitView.h
Sets whether the split bars are vertical.
- (void)setVertical:(BOOL)flag
If flag is YES
, they’re vertical (views are side by side); if it’s NO
, they’re horizontal (views are one on top of the other). Split bars are horizontal by default.
NSSplitView.h
Allows the delegate to return an additional rectangle in which mouse clicks will initiate divider dragging.
- (NSRect)splitView:(NSSplitView *)splitView additionalEffectiveRectOfDividerAtIndex:(NSInteger)dividerIndex
The split view that sent the message.
The index of the divider.
An additional rectangle in which mouse clicks should initiate divider dragging. The rectangle should be expressed in the coordinate system defined by splitView. Returning NSZeroRect
indicates no additional dragging rectangle is desired.
If a split view has no delegate, or if its delegate does not respond to this message, only mouse clicks within the effective frame of a divider initiate divider dragging.
NSSplitView.h
Allows the delegate to determine whether the user can collapse and uncollapse subview.
- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview
If this method returns NO
or is not implemented, subview can’t be collapsed. If this method returns YES
, subview collapses when the user drags a divider beyond the halfway mark between its minimum size and its edge. subview uncollapses when the user drags the divider back beyond that point. To specify the minimum size, define the methods splitView:constrainMaxCoordinate:ofSubviewAt:
and splitView:constrainMinCoordinate:ofSubviewAt:
. Note that a subview can collapse only if you also define splitView:constrainMinCoordinate:ofSubviewAt:
.
A collapsed subview is hidden but retained by the NSSplitView object, with the same size it had before it was collapsed.
NSSplitView.h
Allows the delegate for sender to constrain the maximum coordinate limit of a divider when the user drags it.
- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)offset
This method is invoked before the NSSplitView begins tracking the mouse to position a divider. You may further constrain the limits that have been already set, but you cannot extend the divider limits. proposedMax is specified in the NSSplitView’s flipped coordinate system. If the split bars are horizontal (views are one on top of the other), proposedMax is the bottom limit. If the split bars are vertical (views are side by side), proposedMax is the right limit. The initial value of proposedMax is the bottom (or right side) of the subview after the divider. offset specifies the divider the user is moving, with the first divider being 0 and going up from top to bottom (or left to right).
NSSplitView.h
Allows the delegate for sender to constrain the minimum coordinate limit of a divider when the user drags it.
- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)offset
This method is invoked before the NSSplitView begins tracking the cursor to position a divider. You may further constrain the limits that have been already set, but you cannot extend the divider limits. proposedMin is specified in the NSSplitView’s flipped coordinate system. If the split bars are horizontal (views are one on top of the other), proposedMin is the top limit. If the split bars are vertical (views are side by side), proposedMin is the left limit. The initial value of proposedMin is the top (or left side) of the subview before the divider. offset specifies the divider the user is moving, with the first divider being 0 and going up from top to bottom (or left to right).
NSSplitView.h
Allows the delegate for sender to constrain the divider to certain positions.
- (CGFloat)splitView:(NSSplitView *)sender constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)offset
If the delegate implements this method, the NSSplitView calls it repeatedly as the user moves the divider. This method returns where you want the divider to be, given proposedPosition, the cursor’s current position. offset is the divider the user is moving, with the first divider being 0 and going up from top to bottom (or from left to right).
For example, if a subview’s height must be a multiple of a certain number, use this method to return the multiple nearest to proposedPosition.
NSSplitView.h
Allows the delegate to modify the rectangle in which mouse clicks initiate divider dragging.
- (NSRect)splitView:(NSSplitView *)splitView effectiveRect:(NSRect)proposedEffectiveRect forDrawnRect:(NSRect)drawnRect ofDividerAtIndex:(NSInteger)dividerIndex
The split view that sent the message.
The proposed rectangle in which mouse clicks should initiate divider dragging. The rectangle is expressed in the coordinate system defined by splitView.
The frame of the divider, expressed in the coordinate system defined by splitView.
The index of the divider.
The rectangle in which mouse clicks should initiate divider dragging. The rectangle should be expressed in the coordinate system defined by splitView.
A split view with thick dividers proposes the drawn frame as the effective frame. A split view with thin dividers proposes an effective frame that's a little larger than the drawn frame, to make it easier for the user to actually grab the divider.
If a split view has no delegate, or if its delegate does not respond to this message, the split view behaves as if it has a delegate that returns proposedEffectiveRect when sent this message.
NSSplitView.h
Allows the delegate to specify custom sizing behavior for the subviews of the NSSplitView sender.
- (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSize
If the delegate implements this method, splitView:resizeSubviewsWithOldSize:
is invoked after the NSSplitView is resized. The size of the NSSplitView before the user resized it is indicated by oldSize; the subviews should be resized such that the sum of the sizes of the subviews plus the sum of the thickness of the dividers equals the size of the NSSplitView’s new frame. You can get the thickness of a divider through the dividerThickness method.
Note that if you implement this delegate method to resize subviews on your own, the NSSplitView does not perform any error checking for you. However, you can invoke adjustSubviews
to perform the default sizing behavior.
– adjustSubviews
– setFrame:
(NSView)NSSplitView.h
Invoked to allow a delegate to determine if a subview should collapse in response to a double click.
- (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex
The splitview that sent the message.
The subview to collapse.
The index of the divider.
YES
if the subview should collapse, NO
otherwise.
If implemented, the delegate will receive this message once for the subview before a divider when the user double-clicks on that divider, and again for the subview after the divider, but only if the delegate returned YES
when sent splitView:canCollapseSubview:
for the subview in question. When the delegate indicates that both subviews should be collapsed NSSplitView's behavior is undefined.
NSSplitView.h
Allows the delegate to determine whether a divider can be dragged or adjusted off the edge of the split view.
- (BOOL)splitView:(NSSplitView *)splitView shouldHideDividerAtIndex:(NSInteger)dividerIndex
The split view that sent the message.
The zero-based index of the divider.
YES
if the divider should allow dragging off the edge of the split view, resulting in it not being visible.
If a split view has no delegate, or if its delegate does not respond to this message, the split view behaves as if it has a delegate that returns NO
when sent this message.
NSSplitView.h
Invoked by the default notification center to notify the delegate that the splitview did resize its subviews.
- (void)splitViewDidResizeSubviews:(NSNotification *)aNotification
An NSSplitViewDidResizeSubviewsNotification
notification.
If the delegate implements this method, the delegate is automatically registered to receive this notification.
This method is invoked after the NSSplitView resizes two of its subviews in response to the repositioning of a divider.
NSSplitView.h
Invoked by the default notification center to notify the delegate that the splitview will resize its subviews.
- (void)splitViewWillResizeSubviews:(NSNotification *)aNotification
An NSSplitViewWillResizeSubviewsNotification
notification.
If the delegate implements this method, the delegate is automatically registered to receive this notification.
This method is invoked before the NSSplitView resizes two of its subviews in response to the repositioning of a divider.
NSSplitView.h
These constants specify the possible divider styles used by dividerStyle
and setDividerStyle:
.
enum { NSSplitViewDividerStyleThick = 1, NSSplitViewDividerStyleThin = 2, }; typedef NSInteger NSSplitViewDividerStyle;
NSSplitViewDividerStyleThick
A thick style divider is displayed between subviews. This is the default.
Available in Mac OS X v10.5 and later.
Declared in NSSplitView.h
.
NSSplitViewDividerStyleThin
A thin style divider is displayed between subviews.
Available in Mac OS X v10.5 and later.
Declared in NSSplitView.h
.
NSSplitView declares and posts the following notifications. In addition, it posts notifications declared by its superclass, NSView. See the NSView
class specification for more information.
Posted after an NSSplitView changes the sizes of some or all of its subviews. The notification object is the NSSplitView that resized its subviews.
Note: In Mac OS X v10.5 and later if the notification is sent because the user is dragging a divider, the userInfo
dictionary contains a key @"NSSplitViewDividerIndex"
containing an NSInteger
-wrapped NSNumber
that is the index of the divider being dragged. Earlier versions of Mac OS X do not return a user info dictionary in any situation.
NSSplitView.h
Posted before an NSSplitView changes the sizes of some or all of its subviews. The notification object is the NSSplitView object that is about to resize its subviews.
Note: In Mac OS X v10.5 and later if the notification is sent because the user is dragging a divider, the userInfo
dictionary contains a key @"NSSplitViewDividerIndex"
containing an NSInteger
-wrapped NSNumber
that is the index of the divider being dragged. Earlier versions of Mac OS X do not return a user info dictionary in any situation.
NSSplitView.h
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-04-08)