- Inherits from:
- NSView : NSResponder : NSObject
- Package:
- com.apple.yellow.application
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. To have vertical split bars (so the views are side by side), use the method setVertical. The rest of this section assumes you have horizontal split bars and gives information on vertical split bars in parentheses.
The NSSplitView resizes its subviews so that each subview is the same width (or height) as the NSSplitView, and the total of the subviews' heights (or widths), plus the total of the dividers' thicknesses, is equal to the height (or width) of the NSSplitView. The NSSplitView positions its subviews so that the first subview is at the top (or left) of the NSSplitView, and each successive subview is positioned below (or to the right of) the previous one. The user can set the height (or width) of two subviews by moving a horizontal (or vertical) bar called the divider, which makes one subview smaller and the other larger. Programmatically, you adjust the relative height of subviews simply by modifying the frame of each of the subviews.
Generally, you'll create an NSSplitView in Interface Builder by selecting the subviews and choosing the Group in Split View command. To add and remove subview to an NSSplitView programmatically, use the NSView methods addSubview: and removeFromSuperview.
When a mouse-down occurs in an NSSplitView's divider, the NSSplitView determines the limits of the divider's travel and tracks the mouse to allow the user to drag the divider within these limits. With the following mouse-up, the NSSplitView resizes the two affected subviews, informs the delegate that the subviews were resized, and displays the affected views and divider. The NSSplitView's delegate can constrain the travel of specific dividers by implementing the method splitViewConstrainMaxSplitPosition, splitViewConstrainMinSplitPosition, or splitViewConstrainSplitPosition
When the NSSplitView is displayed-whether it's being displayed for the first time or redisplayed because the user resized the NSSplitView's window-it checks to see if its subviews are properly tiled. If not, it invokes the delegate method splitViewResizeSubviews, allowing the delegate to specify the heights (or widths) of specific subviews. If the delegate doesn't implement this method, the NSSplitView sends adjustSubviews to itself to resize the subviews proportionately. Note that the NSSplitView doesn't call the delegate methods splitViewConstrainMaxSplitPosition, splitViewConstrainMinSplitPosition, or splitViewConstrainSplitPosition and may resize its subviews in a way that isn't allowed by these delegate methods.
- Constructors
- NSSplitView
- Managing component views
- adjustSubviews
- dividerThickness
- drawDividerInRect
- Managing orientation
- isVertical
- setVertical
- Assigning a delegate
- delegate
- setDelegate
public NSSplitView()
public NSSplitView(NSRect frameRect)
public void adjustSubviews()
See Also: setDelegate, setFrame (NSView)
public Object delegate()
public float dividerThickness()
See Also: drawDividerInRect
public void drawDividerInRect(NSRect aRect)
See Also: dividerThickness, compositeToPoint (NSImage)
public boolean isVertical()
true
if
the split bars are vertical (subviews are side by side), false
if
it they are horizontal (views are one on top of the other). By
default, split bars are vertical.See Also: setVertical
public void setDelegate(Object anObject)
public void setVertical(boolean flag)
true
,
they're vertical (views are side by side); if it's false
,
they're horizontal (views are one on top of the other). Split
bars are horizontal by default.See Also: isVertical
public abstract boolean splitViewCanCollapseSubview(
NSSplitView sender,
NSView subview)
false
or is undefined, subview can't
be collapsed. If this method returns true
, subview collapses
when the user drags a divider beyond the halfway mark between its
minimum size and its edge. subview un-collapses
when the user drags the divider back beyond that point. To specify the
minimum size, define the methods splitViewConstrainMaxSplitPosition and splitViewConstrainMinSplitPosition.
Note that a subview can collapse only if you also define splitViewConstrainMinSplitPosition.A collapsed subview is hidden by the NSSplitView object, with the same size it had before it was collapsed
public abstract float splitViewConstrainMaxSplitPosition(
NSSplitView sender,
float proposedMax,
int offset)
See Also: isVertical
public abstract float splitViewConstrainMinSplitPosition(
NSSplitView sender,
float proposedMin,
int offset)
See Also: isVertical
public abstract float splitViewConstrainSplitPosition(
NSSplitView splitView,
float proposedPosition,
int offset)
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.
public abstract void splitViewResizeSubviews(
NSSplitView sender,
NSSize oldSize)
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.
See Also: adjustSubviews, setFrame (NSView)
public abstract void splitViewDidResizeSubviews(NSNotification aNotification)
public abstract void splitViewWillResizeSubviews(NSNotification aNotification)
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 the NSSplitView changes the sizes of some or all of its subviews.
See Also: splitViewDidResizeSubviews
Posted before the NSSplitView changes the sizes of some or all of its subviews.
See Also: splitViewWillResizeSubviews