Copyright ã1994 by NeXT Computer, Inc.  All Rights Reserved.

NSBox

Inherits From:	NSView : NSResponder : NSObject

Conforms To:	NSCoding (NSResponder)
NSObject (NSObject)

Declared In:	AppKit/NSBox.h 

Class Description

An NSBox object is a simple NSView that can do two things: It can draw a border around itself and it can title itself. You can use an NSBox to group, visually, some number of other NSViews. These other NSViews are added to the NSBox through the typical subview-adding methods, such as addSubview: and replaceSubview:with:. 

An NSBox contains a content area, a rectangle set within the NSBox's frame in which the NSBox's subviews are displayed. The size and location of the content area depends on the NSBox's border type, title location, the size of the font used to draw the title, and an additional measure that you can set through the setContentViewMargins: method. When you create an NSBox, an instance of NSView is created and added (as a subview of the NSBox object) to fill the NSBox's content area. If you replace this content view with an NSView of your own, your NSView will be resized to fit the content area. Similarly, as you resize an NSBox its content view is automatically resized to fill the content area. 

The NSViews that you add as subviews to an NSBox are actually added to the NSBox's content viewÐNSView's subview-adding methods are redefined by NSBox to ensure that a subview is correctly placed in the view hierarchy. However, you should note that the subviews method isn't redefined: It returns an NSArray containing a single object, the NSBox's content view.

Getting and Modifying the Border and Title 

- (NSRect)borderRect	Returns the rectangle in which the border is drawn.

- (NSBorderType)borderType	Returns the box's border type.

- (void)setBorderType:(NSBorderType)aType	Sets the box's border to aType.

- (void)setTitle:(NSString *)aString	Sets the box's title to aString.

- (void)setTitleFont:(NSFont *)fontObj	Sets the NSFont of the title to fontObj.

- (void)setTitlePosition:(NSTitlePosition)aPosition	Sets the position of the title to aPosition.

- (NSString *)title	Returns the title of the box.

- (id)titleCell	Returns the Cell used to draw the title.

- (NSFont *)titleFont	Returns the NSFont used to draw the title.

- (NSTitlePosition)titlePosition	Returns the position of the title.

- (NSRect)titleRect	Returns the rectangle in which the title is drawn.

Setting and Placing the Content View 

- (id)contentView	Returns the content view.

- (NSSize)contentViewMargins	Gets the distances between the border and the content view.

- (void)setContentView:(NSView *)aView	Replaces the NSBox's content view with aView.

- (void)setContentViewMargins:(NSSize)offsetSize	Sets the distances between the border and the content view to the horizontal and vertical amounts in offsetSize.

Resizing the Box 

- (void)setFrameFromContentFrame:(NSRect)contentFrame	
	Resizes the box to accommodate contentFrame.

- (void)sizeToFit	Resizes the box to exactly enclose its subviews.