Up
Authors
- Scott Christley (
scottc@net-community.com)
-
Date: Generated at 2025-12-03
Simple box view that can display a border and title
Copyright: (C) 1996-2024 Free Software Foundation, Inc.
- Declared in:
- AppKit/NSBox.h
- Conforms to:
- NSCoding
Availability: OpenStep
Class: NSBox Description: NSBox is a container view
capable of drawing a border and title around its
content. It is often used to group related interface
elements visually and semantically. Instance
Variables: _cell - The underlying cell used for
drawing. _content_view - The view contained inside
the box. _offsets - Margins between the border and the
content. _border_rect - Rectangle defining the area
of the border. _title_rect - Rectangle defining the area
of the title. _border_type - Type of border drawn (line,
bezel, etc). _title_position - Position of the title
relative to the border. _box_type - General
appearance of the box. _fill_color - Fill color
(only if NSBoxCustom). _border_color - Border color
(only if NSBoxCustom). _border_width - Width of the
border (only if NSBoxCustom). _corner_radius - Corner
radius for rounded borders (only if NSBoxCustom).
_transparent - Determines whether the box is
drawn transparently.
TODO : Description
NSBox declares 13 Instance Variables
- (
NSColor*)
borderColor;
Availability: MacOS-X 10.5.0
Returns the border color when using NSBoxCustom.
- (
NSRect)
borderRect;
Availability: OpenStep
Returns the rectangle used to draw the box's
border.
Returns the border rectangle of the box.
- (CGFloat)
borderWidth;
Availability: MacOS-X 10.5.0
Returns the width of the border when using
NSBoxCustom.
- (
NSBoxType)
boxType;
Availability: MacOS-X 10.0.0
Returns the type of box used.
- (id)
contentView;
Availability: OpenStep
Returns the view contained within the box.
Returns the NSBox's content view. The content
view is created as NSView when the box is
initialized. The contentView is resizes when
needed.
See Also:
-setContentView:
- (
NSSize)
contentViewMargins;
Availability: OpenStep
Returns the margins applied to the content view.
Returns an NSSize containing the interior margins
of the receiver. An NSBox's content view margins are
empty space that is subtracted from the top,
bottom, and sides as padding between the inside
of the box and the frame of its content view.
See Also:
-setContentViewMargins:
- (CGFloat)
cornerRadius;
Availability: MacOS-X 10.5.0
Returns the corner radius when using NSBoxCustom.
- (
NSColor*)
fillColor;
Availability: MacOS-X 10.5.0
Returns the fill color when using NSBoxCustom.
- (BOOL)
isTransparent;
Availability: MacOS-X 10.5.0
Returns whether the box is transparent.
- (
NSSize)
minimumSize;
Availability: Not in OpenStep/MacOS-X
Returns the minimum size of the box.
- (void)
setBorderColor: (
NSColor*)newBorderColor;
Availability: MacOS-X 10.5.0
Sets the border color when using NSBoxCustom.
- (void)
setBorderType: (
NSBorderType)aType;
Availability: OpenStep
Sets the border type of the box.
Sets the border type to aType, resizes
the content view frame if needed, and marks self for
display. See
NSBorderType
for more informations The default boder type is
NSGrooveBorder
.
See Also:
-borderType
- (void)
setBorderWidth: (CGFloat)borderWidth;
Availability: MacOS-X 10.5.0
Sets the width of the border when using NSBoxCustom.
- (void)
setBoxType: (
NSBoxType)aType;
Availability: MacOS-X 10.0.0
Sets the box's display type.
- (void)
setContentView: (
NSView*)aView;
Availability: OpenStep
Sets the content view of the box.
Sets the content view to aView. The
current content view is replaced by
-replaceSubview:with:
. So you should
-retain
the current view if you want to use it later. The
contentView frame is resized if needed.
See Also:
-contentView
- (void)
setContentViewMargins: (
NSSize)offsetSize;
Availability: OpenStep
Sets the margins around the content view.
Sets the NSSize containing the interior margins to
offsetSize. An NSBox's content view
margins are empty space that is subtracted from
the top, bottom, and sides as padding between the
inside of the box and the frame of its content
view
See Also:
-contentViewMargins
- (void)
setCornerRadius: (CGFloat)cornerRadius;
Availability: MacOS-X 10.5.0
Sets the corner radius when using NSBoxCustom.
- (void)
setFillColor: (
NSColor*)newFillColor;
Availability: MacOS-X 10.5.0
Sets the fill color when using NSBoxCustom.
- (void)
setFrameFromContentFrame: (
NSRect)contentFrame;
Availability: OpenStep
Adjusts the box frame to fit a given content frame.
Resizes the NSBox to fit the content view frame
contentFrame.
- (void)
setTitle: (
NSString*)aString;
Availability: OpenStep
Sets the title string displayed by the box.
Sets the title cell to aString, resizes
the content view frame if needed and marks self for
display.
Warning: This method does not implement the
Cocoa behaviour
See Also: -title
[NSCell -setStringValue:]
- (void)
setTitleFont: (
NSFont*)fontObj;
Availability: OpenStep
Sets the font used to display the title.
Sets the title cell font to fontObj,
resizes the content view frame if needed and
marks self for display.
See Also:
-titleFont
[NSCell -setFont:]
- (void)
setTitlePosition: (
NSTitlePosition)aPosition;
Availability: OpenStep
Sets the title position relative to the box.
Sets the title cell position to aPosition
, resizes the content view frame if needed and marks
self for display. See
NSTitlePosition
for more information. The default position is
NSAtTop
.
See Also:
-titlePosition
- (void)
setTitleWithMnemonic: (
NSString*)aString;
Availability: MacOS-X 10.0.0
Sets the title string and enables keyboard shortcut
via mnemonic.
- (void)
setTransparent: (BOOL)transparent;
Availability: MacOS-X 10.5.0
Sets whether the box should be transparent.
- (void)
sizeToFit;
Availability: OpenStep
Resizes the box to tightly fit its content.
Resizes the NSBox and its content view to fit its
subviews.
- (
NSString*)
title;
Availability: OpenStep
- (id)
titleCell;
Availability: OpenStep
Returns the cell used to draw the title.
Returns the title cell
- (
NSFont*)
titleFont;
Availability: OpenStep
- (
NSRect)
titleRect;
Availability: OpenStep
Returns the rectangle used to draw the title.
Returns the title rectangle
Instance Variables for NSBox Class
@protected NSColor*
_border_color;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected NSRect
_border_rect;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected NSBorderType
_border_type;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected CGFloat
_border_width;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected NSBoxType
_box_type;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected id
_cell;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected id
_content_view;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected CGFloat
_corner_radius;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected NSColor*
_fill_color;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected NSSize
_offsets;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected NSTitlePosition
_title_position;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected NSRect
_title_rect;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected BOOL
_transparent;
Availability: OpenStep
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Up