# NSWindow

scottc@net-community.com
far@ix.netcom.com
richard@brainstorm.co.uk

The window class

1996 Free Software Foundation, Inc.
NSWindow

Instances of the NSWindow class handle on-screen windows, their associated NSViews, and events generate by the user. An NSWindow's size is defined by its frame rectangle, which encompasses its entire structure, and its content rectangle, which includes only the content.

Every NSWindow has a content view, the NSView which forms the root of the window's view hierarchy. This view can be set using the `setContentView:` method, and accessed through the `contentView` method. `setContentView:` replaces the default content view created by NSWindow.

Other views may be added to the window by using the content view's `addSubview:` method. These subviews can also have subviews added, forming a tree structure, the view hierarchy. When an NSWindow must display itself, it causes this hierarchy to draw itself. Leaf nodes in the view hierarchy are drawn last, causing them to potentially obscure views further up in the hierarchy.

A delegate can be specified for an NSWindow, which will receive notifications of events pertaining to the window. The delegate is set using `setDelegate:`, and can be retrieved using `delegate`. The delegate can restrain resizing by implementing the `windowWillResize: toSize:` method, or control the closing of the window by implementing `windowShouldClose:`.

AppKit/NSWindow.h
NSCoding
Description forthcoming.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
contentRectForFrameRect:
aRect
styleMask:
aStyle
Description forthcoming.
defaultDepthLimit
Description forthcoming.
frameRectForContentRect:
aRect
styleMask:
aStyle
Description forthcoming.
frameRectForScreenRect:
aRect
styleMask:
aStyle
Description forthcoming.
menuChanged:
aMenu
Description forthcoming.
minFrameWidthWithTitle:
aTitle
styleMask:
aStyle
Description forthcoming.
removeFrameUsingName:
name
Description forthcoming.
screenRectForFrameRect:
aRect
styleMask:
aStyle
Description forthcoming.
acceptsMouseMovedEvents
Description forthcoming.
alphaValue
Description forthcoming.
animationResizeTime:
newFrame
Description forthcoming.
areCursorRectsEnabled
Description forthcoming.
aspectRatio
Description forthcoming.
backgroundColor
Description forthcoming.
backingType
Description forthcoming.
becomeKeyWindow
Description forthcoming.
becomeMainWindow
Description forthcoming.
cacheImageInRect:
aRect
Description forthcoming.
canBecomeKeyWindow
Returns `YES` if the receiver can be made key. If this method returns `NO`, the window will not be made key. This implementation returns `YES` if the window is resizable or has a title bar. You can override this method to change it's behavior
canBecomeMainWindow
Returns `YES` if the receiver can be the main window. If this method returns `NO`, the window will not become the main window. This implementation returns `YES` if the window is resizable or has a title bar and is visible and is not an NSPanel. You can override this method to change it's behavior
canHide
Description forthcoming.
canStoreColor
Description forthcoming.
cascadeTopLeftFromPoint:
topLeftPoint
Description forthcoming.
center
Description forthcoming.
close
Description forthcoming.
constrainFrameRect:
frameRect
toScreen:
screen
Given a proposed frame rectangle, return a modified version which will fit inside the screen .
contentView
Description forthcoming.
convertBaseToScreen:
aPoint
Convert from a point in the base coordinate system for the window to a point in the screen coordinate system.
convertScreenToBase:
aPoint
Convert from a point in the screen coordinate system to a point in the screen coordinate system of the receiver.
counterpart
Description forthcoming.
currentEvent
Description forthcoming.
dataWithEPSInsideRect:
rect
Description forthcoming.
dataWithPDFInsideRect:
aRect
Description forthcoming.
deepestScreen
Returns the screen the window is on. Unlike (apparently) OpenStep and MacOSX, GNUstep does not support windows being split across multiple screens
defaultButtonCell
Description forthcoming.
delegate
Description forthcoming.
deminiaturize:
sender
Causes the window to deminiaturize. Normally you would not call this method directly. A window is automatically deminiaturized by the user via a mouse click event. Does nothing it the window isn't miniaturized.
depthLimit
Description forthcoming.
deviceDescription
Description forthcoming.
disableCursorRects
Description forthcoming.
disableFlushWindow
Description forthcoming.
disableKeyEquivalentForDefaultButtonCell
Description forthcoming.
discardCachedImage
Description forthcoming.
discardCursorRects
Description forthcoming.
discardEventsMatchingMask:
mask
beforeEvent:
lastEvent
Description forthcoming.
display
Description forthcoming.
displayIfNeeded
Description forthcoming.
dragImage:
anImage
at:
baseLocation
offset:
initialOffset
event:
event
pasteboard:
pboard
source:
sourceObject
slideBack:
slideFlag
Description forthcoming.
drawers
Description forthcoming.
enableCursorRects
Description forthcoming.
enableFlushWindow
Description forthcoming.
enableKeyEquivalentForDefaultButtonCell
Description forthcoming.
endEditingFor:
anObject
Description forthcoming.
fax:
sender
Description forthcoming.
fieldEditor:
createFlag
forObject:
anObject
Description forthcoming.
firstResponder
Description forthcoming.
flushWindow
Flush all drawing in the windows buffer to the screen unless the window is not buffered or flushing is not enabled.
flushWindowIfNeeded
Description forthcoming.
frame
Description forthcoming.
frameAutosaveName
Description forthcoming.
gState
Description forthcoming.
hasDynamicDepthLimit
Description forthcoming.
hasShadow
Description forthcoming.
hidesOnDeactivate
Description forthcoming.
initWithContentRect:
contentRect
styleMask:
aStyle
backing:
bufferingType
defer:
flag

Initializes the receiver with a content rect of contentRect, a style mask of styleMask, and a backing store type of backingType.

The style mask values are `NSTitledWindowMask`, for a window with a title, `NSClosableWindowMask`, for a window with a close widget, `NSMiniaturizableWindowMask`, for a window with a miniaturize widget, and `NSResizableWindowMask`, for a window with a resizing widget. These mask values can be OR'd in any combination.

Backing store values are `NSBackingStoreBuffered`, `NSBackingStoreRetained` and `NSBackingStoreNonretained`.

initWithContentRect:
contentRect
styleMask:
aStyle
backing:
bufferingType
defer:
flag
screen:
aScreen

Initializes the receiver with a content rect of contentRect, a style mask of styleMask, a backing store type of backingType and a boolean flag. flag specifies whether the window should be created now (`NO`), or when it is displayed (`YES`).

The style mask values are `NSTitledWindowMask`, for a window with a title, `NSClosableWindowMask`, for a window with a close widget, `NSMiniaturizableWindowMask`, for a window with a miniaturize widget, and `NSResizableWindowMask`, for a window with a resizing widget. These mask values can be OR'd in any combination.

Backing store values are `NSBackingStoreBuffered`, `NSBackingStoreRetained` and `NSBackingStoreNonretained`.

initWithWindowRef:
windowRef
Description forthcoming.
initialFirstResponder
Description forthcoming.
invalidateCursorRectsForView:
aView
Description forthcoming.
isAutodisplay
Description forthcoming.
isDocumentEdited
Description forthcoming.
isExcludedFromWindowsMenu
Description forthcoming.
isFlushWindowDisabled
Description forthcoming.
isKeyWindow
Description forthcoming.
isMainWindow
Description forthcoming.
isMiniaturized
Description forthcoming.
isOneShot
Description forthcoming.
isOpaque
Description forthcoming.
isReleasedWhenClosed
Description forthcoming.
isVisible
Description forthcoming.
keyDown:
theEvent
Description forthcoming.
keyViewSelectionDirection
Description forthcoming.
level
Description forthcoming.
makeFirstResponder:
aResponder
This method attempts to make aResponder the first responder.
If aResponder is already the first responder, this method has no effect and simply returns `YES`. Otherwise, the method sends a -resignFirstResponder message to the current first responder (if there is one) and immediately returns `NO` if the current first responder refuses to resign.
Then the method asks aResponder to become first responder by sending it a -becomeFirstResponder message, and if that returns `YES` then this method immediately returns `YES`.
However, if that returns `NO`, the receiver is made the first responder by sending it a -becomeFirstResponder message, and this method returns `NO`.
If aResponder is neither `nil` nor an instance of NSResponder (or of a subclass of NSResponder) then behavior is undefined (though the current GNUstep implementation just returns `NO`).
makeKeyAndOrderFront:
sender
Description forthcoming.
makeKeyWindow
Description forthcoming.
makeMainWindow
Description forthcoming.
maxSize
Description forthcoming.
minSize
Description forthcoming.
miniaturize:
sender
Causes the window to miniaturize, that is the window is removed from the screen and it's counterpart (mini)window is displayed. Does nothing if the window can't be miniaturized (eg. because it's already miniaturized).
miniwindowImage
Description forthcoming.
miniwindowTitle
Description forthcoming.
mouseLocationOutsideOfEventStream
Description forthcoming.
nextEventMatchingMask:
mask
Description forthcoming.
nextEventMatchingMask:
mask
untilDate:
expiration
inMode:
mode
dequeue:
deqFlag
Description forthcoming.
orderBack:
sender
Orders the window to the back of its level. Equivalent to -orderWindow: NSWindowBelow relativeTo: 0.
orderFront:
sender
If the application is active, orders the window to the front in its level. If the application is not active, the window is ordered in as far forward as possible in its level without being ordered in front of the key or main window of the currently active app. The current key and main window status is not changed. Equivalent to -orderWindow: NSWindowAbove relativeTo: 0.
orderFrontRegardless
Orders the window to the front in its level (even in front of the key and main windows of the current app) regardless of whether the app is current or not. This method should only be used in rare cases where the app is cooperating with another app that is displaying data for it. The current key and main window status is not changed.
orderOut:
sender
Orders the window out from the screen. Equivalent to -orderWindow: NSWindowOut relativeTo: 0.
orderWindow:
place
relativeTo:
otherWin

If place is NSWindowOut, removes the window from the screen. If place is NSWindowAbove, places the window directly above otherWin, or directly above all windows in its level if otherWin is 0. If place is NSWindowBelow, places the window directly below otherWin, or directly below all windows in its level if otherWin is 0.

If place is NSWindowAbove or NSWindowBelow and the application is hidden, the application is unhidden.

performClose:
sender
Description forthcoming.
performMiniaturize:
sender
Miniaturize the receiver... as long as its style mask includes NSMiniaturizableWindowMask (and as long as the receiver is not an icon or mini window itsself). Calls -miniaturize: to do this.
Beeps if the window can't be miniaturised.
Should ideally provide visual feedback (highlighting the miniaturize button as if it had been clicked) first... but that's not yet implemented.
performZoom:
sender
Description forthcoming.
postEvent:
event
atStart:
flag
Description forthcoming.
print:
sender
Description forthcoming.
registerForDraggedTypes:
newTypes
Description forthcoming.
representedFilename
Description forthcoming.
resetCursorRects
Description forthcoming.
resignKeyWindow
Description forthcoming.
resignMainWindow
Description forthcoming.
resizeFlags
Description forthcoming.
resizeIncrements
Description forthcoming.
restoreCachedImage
Description forthcoming.
saveFrameUsingName:
name
Description forthcoming.
screen
Returns the screen the window is on.
selectKeyViewFollowingView:
aView
Description forthcoming.
selectKeyViewPrecedingView:
aView
Description forthcoming.
selectNextKeyView:
sender
Description forthcoming.
selectPreviousKeyView:
sender
Description forthcoming.
sendEvent:
theEvent
Handles mouse and other events sent to the receiver by NSApplication. Do not invoke this method directly.
setAcceptsMouseMovedEvents:
flag
Description forthcoming.
setAlphaValue:
windowAlpha
Description forthcoming.
setAspectRatio:
ratio
Description forthcoming.
setAutodisplay:
flag
Description forthcoming.
setBackgroundColor:
color
Description forthcoming.
setBackingType:
type
Description forthcoming.
setCanHide:
flag
Description forthcoming.
setContentSize:
aSize
Description forthcoming.
setContentView:
aView
Sets the window's content view to aView, replacing any previous content view.
setDefaultButtonCell:
aCell
Description forthcoming.
setDelegate:
anObject
Description forthcoming.
setDepthLimit:
limit
Description forthcoming.
setDocumentEdited:
flag
Description forthcoming.
setDynamicDepthLimit:
flag
Description forthcoming.
setExcludedFromWindowsMenu:
flag
Description forthcoming.
setFrame:
frameRect
display:
flag
Description forthcoming.
setFrame:
frameRect
display:
displayFlag
animate:
animationFlag
Description forthcoming.
setFrameAutosaveName:
name
Description forthcoming.
setFrameFromString:
string
Description forthcoming.
setFrameOrigin:
aPoint
Description forthcoming.
setFrameTopLeftPoint:
aPoint
Description forthcoming.
setFrameUsingName:
name
Description forthcoming.
setFrameUsingName:
name
force:
force
Description forthcoming.
setHasShadow:
hasShadow
Description forthcoming.
setHidesOnDeactivate:
flag
Description forthcoming.
setInitialFirstResponder:
aView
Description forthcoming.
setLevel:
newLevel
Description forthcoming.
setMaxSize:
aSize
Description forthcoming.
setMinSize:
aSize
Description forthcoming.
setMiniwindowImage:
image
Description forthcoming.
setMiniwindowTitle:
title
Description forthcoming.
setOneShot:
flag
Description forthcoming.
setOpaque:
isOpaque
Description forthcoming.
setReleasedWhenClosed:
flag
Description forthcoming.
setRepresentedFilename:
aString
Description forthcoming.
setResizeIncrements:
aSize
Description forthcoming.
setShowsResizeIndicator:
show
Description forthcoming.
setTitle:
aString
Sets the window's title to the string aString.
setTitleWithRepresentedFilename:
aString
Description forthcoming.
setViewsNeedDisplay:
flag
Description forthcoming.
setWindowController:
windowController
Description forthcoming.
showsResizeIndicator
Description forthcoming.
stringWithSavedFrame
Description forthcoming.
styleMask
Description forthcoming.
title
Returns an NSString containing the text of the window's title.
tryToPerform:
anAction
with:
anObject
Description forthcoming.
unregisterDraggedTypes
Description forthcoming.
update
Description forthcoming.
useOptimizedDrawing:
flag
Description forthcoming.
validRequestorForSendType:
sendType
returnType:
returnType
Description forthcoming.
viewsNeedDisplay
Description forthcoming.
windowController
Description forthcoming.
windowHandle
Description forthcoming.
windowNumber
Description forthcoming.
windowRef
Description forthcoming.
worksWhenModal
Description forthcoming.
zoom:
sender
Description forthcoming.
Software documentation for the NSObject(NSWindowDelegate) informal protocol
AppKit/NSWindow.h
Description forthcoming.
windowDidBecomeKey:
aNotification
Description forthcoming.
windowDidBecomeMain:
aNotification
Description forthcoming.
windowDidChangeScreen:
aNotification
Description forthcoming.
windowDidDeminiaturize:
aNotification
Description forthcoming.
windowDidExpose:
aNotification
Description forthcoming.
windowDidMiniaturize:
aNotification
Description forthcoming.
windowDidMove:
aNotification
Description forthcoming.
windowDidResignKey:
aNotification
Description forthcoming.
windowDidResignMain:
aNotification
Description forthcoming.
windowDidResize:
aNotification
Description forthcoming.
windowDidUpdate:
aNotification
Description forthcoming.
windowShouldClose:
sender
Description forthcoming.
windowShouldZoom:
sender
toFrame:
aFrame
Description forthcoming.
windowWillClose:
aNotification
Description forthcoming.
windowWillMiniaturize:
aNotification
Description forthcoming.
windowWillMove:
aNotification
Description forthcoming.
windowWillResize:
sender
toSize:
frameSize
Description forthcoming.
windowWillReturnFieldEditor:
sender
toObject:
client
Description forthcoming.
windowWillUseStandardFrame:
sender
defaultFrame:
aFrame
Description forthcoming.
Software documentation for the NSWindow(GNUstepBackend) category
AppKit/NSWindow.h
Description forthcoming.
_captureMouse:
sender
Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.
_initDefaults
Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.
_releaseMouse:
sender
Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.
_setVisible:
flag
Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.
Software documentation for the NSWindow(GNUstepTextView) category
AppKit/NSWindow.h
Description forthcoming.
_futureFirstResponder
Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.