Inherits from: NSResponder : NSObject
Conforms to: NSCoding
(from NSResponder)
NSObject (from NSObject)
Declared in: AppKit/NSWindow.h
Interface Builder | |
- initWithContentRect:styleMask:backing:defer: | Designated initializer. |
- makeKeyAndOrderFront: | Moves the NSWindow to the front and makes it the key window. |
- makeFirstResponder: | Sets the first responder in the NSWindow. |
- fieldEditor:forObject: | Returns the shared text object for the NSWindow. |
- setContentView: | Sets the root-level NSView in the NSWindow. |
- representedFilename | Returns the filename whose contents the NSWindow presents. |
- setDocumentEdited: | Sets whether the NSWindow's represented file needs to be saved. |
- setTitle: | Sets the title of the NSWindow. |
- setTitleWithRepresentedFilename: | Sets the title of the NSWindow in a readable format for filenames. |
The NSWindow class defines objects that manage and coordinate the windows an application displays on the screen. A single NSWindow object corresponds to at most one on-screen window. The two principal functions of NSWindow are to provide an area in which NSViews can be placed and to accept and distribute, to the appropriate NSViews, events the user instigates through actions with the mouse and keyboard. Note that the term window sometimes refers to the Application Kit object and sometimes to the Window Server's PostScript window device; which meaning is intended is made clear in context. The Application Kit also defines an abstract subclass of NSWindow-NSPanel-that adds behavior more appropriate for auxiliary windows.
You typically set up windows using Interface Builder, which allows you to position them, set up many of their visual and behavioral attributes, and lay out views in them. The programmatic work you do with windows more often involves bringing them on and off the screen; changing dynamic attributes such as the window's title; running modal windows to restrict user input; and assigning a delegate that can monitor certain of the window's actions, such as closing, zooming, and resizing.
An NSWindow is defined by a frame rectangle that encloses the entire window, including its title bar, border, and other peripheral elements (such as the resize bar on OPENSTEP for Mach), and by a content rectangle that encloses just its content area. Both rectangles are specified in the screen coordinate system and restricted to integer values. The frame rectangle establishes the NSWindow's base coordinate system. This coordinate system is always aligned with and measured in the same increments as the screen coordinate system (in other words, the base coordinate system can't be rotated or scaled). The origin of the base coordinate system is the bottom-left corner of the NSWindow's frame rectangle.
You create an NSWindow programmatically through one of the initWithContentRect:... methods by specifying, among other attributes, the size and location of its content rectangle. The frame rectangle is derived from the dimensions of the content rectangle. Various sections below describe other attributes you can specify at initialization and afterward.
When it's created, an NSWindow automatically creates two NSViews: An opaque frame view that fills the frame rectangle and draws the border, title bar, other peripheral elements, and background, and a transparent content view that fills the content rectangle. The frame view and its peripheral elements are private objects that your application can't access directly. The content view is the "highest" accessible NSView in the NSWindow; you can replace the default content view with an NSView of your own creation using the setContentView: method. The NSWindow determines the placement of the content view; you can't position it using NSView's setFrame... methods, but must use NSWindow's placement methods, described in "Windows on the Screen" below.
You add other NSViews to the NSWindow as subviews of the content view or as subviews of any of the content view's subviews, and so on, through NSView's addSubview: method. This tree of NSViews is called the NSWindow's view hierarchy. When an NSWindow is told to display itself, it does so by sending display... messages to the top-level NSView in its view hierarchy. Because displaying is carried out in a determined order, the content view (which is drawn first) may be wholly or partially obscured by its subviews, and these subviews may be obscured by their subviews (and so on).
The peripheral elements that an NSWindow displays define its style. Though you can't access and manipulate them directly, you can determine at initialization whether an NSWindow has them by providing a style mask to the - initWithContentRect:styleMask:backing:defer: method. There are four possible style elements, specifiable by combining their mask values using the C bitwise OR operator:
Element | Mask Value |
A title bar | NSTitledWindowMask |
A close button | NSClosableWindowMask |
A miniaturize button | NSMiniaturizableWindowMask |
A resize bar, border, or box | NSResizableWindowMask |
You can also specify NSBorderlessWindowMask
,
in which case none of these style elements is used.
NSWindows can be placed on the screen in three dimensions. Besides horizontal and vertical placement, NSWindows are ordered back-to-front in several distinct levels, which group windows of similar type and purpose so that the more "important" ones appear in front of those less so. (For more information, see the description for setLevel:.) Placing an NSWindow on the screen is accomplished with the setFrame:display: method and its variants setFrameOrigin: and setFrameTopLeftPoint:. Ordering takes place in two ways. The setLevel: method puts an NSWindow into a group, such as that for standard windows, floating windows (for example, palettes and some inspector panels), menus, and so on. The orderWindow:relativeTo: method orders an NSWindow within its level in front of or in back of another. Convenience methods for ordering include makeKeyAndOrderFront:, orderFront: and orderBack:, as well as orderOut:, which removes an NSWindow from the screen. The isVisible method tells whether an NSWindow is on or off the screen. You can also set a window to be removed from the screen automatically when its application isn't active using setHidesOnDeactivate:.
NSWindow offers several means of constraining and adjusting window placement:
setMinSize: and setMaxSize: limit the user's ability to resize the NSWindow (you can still set it to any size programmatically). Similarly, setAspectRatio: keeps a window's width and height at the same proportions as the user resizes it, and setResizeIncrements: makes the window resize in discrete amounts larger than a single pixel. (Aspect ratio and resize increments are mutually exclusive attributes. See the setAspectRatio: and setResizeIncrements: method descriptions for more information.)
The constrainFrameRect:toScreen: method adjusts a proposed frame rectangle so that it lies on the screen in such a way that the user can move and resize a window. Note that any NSWindow with a title bar automatically constrains itself to the screen. The cascadeTopLeftFromPoint: method shifts the top left point by an amount that allows one NSWindow to be placed relative to another so that both their title bars are visible.
The zoom: method toggles the size and location of a window between its standard state, as determined by the application, and its user state-a new size and location the user may have set by moving or resizing the window.
Finally, the center method places an NSWindow in the most prominent location on the screen, one suitable for important messages and attention panels.
Closely related to window ordering is the idea of opening or closing an NSWindow. Normally, opening is accomplished simply by ordering the NSWindow in front of or in back of another that's on screen. Closing a window involves explicit use of either the close method, which simply removes the NSWindow from the screen, or performClose:, which highlights the close button as though the user clicked it. Closing an NSWindow involves at least removing it from the screen but adds the possibility of disposing of it altogether. The setReleasedWhenClosed: method sets whether an NSWindow releases itself when it receives a close message. An NSWindow's delegate is also notified when it's about to close, as described in the "Notifications and the NSWindow's Delegate" section.
Miniaturizable windows can be removed from the screen and replaced by a smaller counterpart, whether a freestanding miniwindow or, on Microsoft Windows, a button in the task bar. The miniaturize: and deminiaturize: methods reduce and reconstitute an NSWindow, and performMiniaturize: simulates the user clicking the NSWindow's miniaturize button. You can also set the image and title displayed in a freestanding miniwindow by sending setMiniwindowImage: and setMiniwindowTitle: messages to the NSWindow object.
An NSWindow can store its placement in the user defaults system, so that it appears in the same location the next time the user starts the application. The saveFrameUsingName: method stores the frame rectangle, and setFrameUsingName: sets it from the value in user defaults. You can also use the setFrameAutosaveName: method to have an NSWindow save the frame rectangle any time it changes. To expunge a frame rectangle from the defaults system, use the class method removeFrameUsingName:.
A titled NSWindow can display an arbitrary title or one derived from a filename. The setTitle: method puts an arbitrary string on the title bar. The setTitleWithRepresentedFilename: method formats a filename in the title bar in a readable format (which varies with the platform) and associates the NSWindow with that file. You can set the associated file without changing the title using setRepresentedFilename:. You can use the association between the NSWindow and the file in any way you see fit. One convenience offered by NSWindow is marking the file as being edited, so that you can prompt the user to save it on closing the window. The method for marking this is setDocumentEdited:. When the window closes, its delegate can check it with isDocumentEdited to see whether the document needs to be saved.
Most OPENSTEP applications include a submenu that displays the titles of windows, called the Windows menu. This submenu automatically lists windows that have a title bar and are resizable and that can become the main window (as described under "Event Handling"). When you change an NSWindow's title, this change is also automatically reflected in the Windows menu. You can exclude a window that would otherwise be listed by sending it a setExcludedFromWindowsMenu: message.
Nearly every NSWindow has a corresponding PostScript window device in the Window Server. The window device holds the NSWindow's drawn image, and has two attributes determined by the Window Server and five attributes that the NSWindow controls. The Window Server assigns the window device a unique identifier (within an application). This is the window number, and it's returned by the windowNumber method. Each window also has a PostScript graphics state that most NSViews share for drawing (NSViews can create their own as well). The gState method returns its identifier. The five attributes under direct NSWindow control are:
A window device's backing store type is set when the NSWindow is initialized and can be one of three types. A buffered window device renders all drawing into a display buffer and then flushes it to the screen. Always drawing to the buffer produces very smooth display, but can require significant amounts of memory. Buffered windows are best for displaying material that must be redrawn often, such as text. A retained window device also uses a buffer, but draws directly to the screen where possible and to the buffer for any portions that are obscured. A nonretained window device has no buffer at all, and must redraw portions as they're exposed. Further, this redrawing is suspended when the NSWindow's display mechanism is preempted. For example, if the user drags a window across a nonretained window, the nonretained window is "erased" and isn't redrawn until the user releases the mouse. Both retained and nonretained windows are also subject to a flashing effect as individual drawing operations are performed, but their results do get to the screen more quickly than those of buffered windows. You can change the backing store type between buffered and retained after initialization using the setBackingType: method.
The defer argument to initWithContentRect:styleMask:backing:defer: specifies whether the NSWindow creates its window device immediately or only when it's moved on screen. Deferring creation of the window device can offer some performance gain for windows that aren't displayed immediately because it reduces the amount of work that needs to be performed up front. Deferring creation of the window device is particularly useful when creation of the NSWindow itself can't be deferred or when an NSWindow is needed for purposes other than displaying content. Submenus with key equivalents, for example, must exist for the key equivalents to work, but may never actually be displayed.
Memory can also be saved by destroying the window device when the window is removed from the screen. The setOneShot: method controls this behavior. One-shot window devices exist only when their NSWindows are on screen.
Like the display hardware, a window device's buffer has a depth, or a limit to the memory allotted each pixel. Buffered and retained windows start out with a default window depth of 2 bits per pixel, and this depth grows to the window device's limit as the NSWindow draws richer images (more shades of gray, more colors). A window device's depth is set using the setDepthLimit: method, which takes as an argument a window depth limit created using the NSBestDepth function.
If an NSWindow draws color into its buffer and there's a color screen available, the Window Server automatically promotes the window's depth (up to its limit). This happens whether or not the window is actually on a color screen; similarly, if the user drags a window that displays color from a color screen to a monochrome screen, it remains at its richer depth. In both cases, the window's depth is greater than the screen can properly display. Keeping a window's depth at its richest preserves the displayed image, but it may produce undesired results such as dithering on a more limited screen and does causes slight performance reduction when the window buffer is deeper than the screen requires. You can set an NSWindow to keep its depth at the limit of the screen it's on with the setDynamicDepthLimit: method. When it's moved to a new screen, a window with a dynamic depth limit is redrawn into the newly adjusted buffer. Making a window's depth limit dynamic overrides the limit set using setDepthLimit:, and removing the dynamic limit reverts the static limit to the default.
Display of an NSWindow begins with the drawing performed by its view objects, which accumulates in the window's display buffer or appears immediately on the screen. NSWindows, like NSViews, can be displayed unconditionally or merely marked as needing display, using the display and setViewsNeedDisplay: methods, respectively. A displayIfNeeded message causes the NSWindow's views to display only if they've been marked as needing display. Normally, any time an NSView is marked as needing display, the NSWindow makes note of this fact and automatically displays itself shortly after. This automatic display is typically performed on each pass through the event loop, but can be turned off using the setAutodisplay: method. If you turn off autodisplay for an NSWindow, you're then responsible for displaying it whenever necessary.
A related mechanism is that of updating. On each pass through the event loop, the application object invokes its updateWindows method, which sends an update message to each NSWindow. Subclasses of NSWindow can override this method to examine the state of the application and change their own state or appearance accordingly-enabling or disabling menus, buttons, and other controls based on the object that's selected, for example.
In addition to displaying itself on the screen, an NSWindow can print itself in its entirety, just as an NSView can. The print: method runs the application's Print panel and causes the NSWindow's frame view to print itself. The fax: and dataWithEPSInsideRect: methods behave similarly. See the NSView class specification for more information on printing.
As described in the NSResponder class specification, most events coming into an application make their way to an NSWindow in a sendEvent: message. A key event is directed at the key window, while a mouse event is directed at whatever window lies under the cursor. If an event affects the window directly-resizing or moving it, for example-it performs the appropriate operation itself and sends messages to its delegate informing it of its intentions, thus allowing your application to intercede. The window sends other events up its responder chain from the appropriate starting point: the first responder for a key event, the view under the cursor for a mouse event. These events are then typically handled by some view object in the window. See the NSView and NSEvent class specifications for more information on how to intercept and handle events.
The following sections describe aspects of events not directly related to handling individual events. These include changing the key and main windows, changing the first responder by keyboard rather than mouse actions, sharing a single text object for lightweight editing tasks, and running a modal event loop around an entire window rather than a single view object.
Windows already on screen automatically change their status as the key or main window based on the user's actions with the mouse and on how the clicked view handles the mouse event. You can also set the key and main windows programmatically by sending the relevant window object a makeKeyWindow or makeMainWindow message. Setting the key and main windows programmatically is particularly useful when creating a new window. Because making a window key is often combined with ordering the window to the front of the screen, NSWindow defines a convenience method, makeKeyAndOrderFront:, that performs both operations.
Not all windows are suitable for acting as the key or main
window. For example, a window that merely displays information,
and contains no objects that need to respond to events or action
messages, can completely forgo ever becoming the key window. Similarly,
a window that acts as a floating palette of items that are only dragged
out by mouse actions never needs to be the key window. Such a window can
be defined as a subclass of NSWindow that overrides the methods canBecomeKeyWindow and canBecomeMainWindow to
return NO
instead of the default
of YES
. Defining a window in this
way prevents it from ever becoming the key or main window. Though
NSWindow defines these methods, typically only subclasses of NSPanel
refuse to accept key or main window status.
A window's first responder is often a view object selected by the user clicking it. For text fields and other view objects (mainly subclasses of NSControl), the user can select the first responder with the keyboard using the Tab and Shift keys. NSView defines the methods for setting up and examining the loop of objects that the user can select in this manner. A view that's the first responder is called the key view, and the views that can become the key view in a window are linked together in the window's key view loop. You normally set up the key view loop using Interface Builder, establishing connections between the nextKeyView outlets of views in the window and setting the window's initialFirstResponder outlet to the view that you want selected when the window is first placed on screen. If you do not set this outlet, the window sets a key loop (not necessarily the same as the one you would have specified!) and picks a default initial first responder for you.
In addition to the key view loop, a window can have a default button cell, which uses the Return (or Enter) key as its key equivalent. The setDefaultButtonCell: method establishes this button cell; you can also set it in Interface Builder by setting a button cell's key equivalent to íŸÚ\r'. The default button cell draws itself as a focal element for keyboard interface control unless another button cell is focused on. In this case, it temporarily draws itself as normal and disables its key equivalent. Another default key established by NSWindow is the Escape key, which immediately aborts a modal loop (described below under "Modal Windows").
See the NSResponder class specification for more information on keyboard interface control.
Each NSWindow has a text object that is shared for light editing tasks. This object, the window's field editor, is inserted in the view hierarchy when an object needs to edit some text and removed when the object is finished. The field editor is used by NSTextFields and other controls, for example, to edit the text that they display. The fieldEditor:forObject: method returns a window's field editor, after asking the delegate for a substitute using windowWillReturnFieldEditor:toObject:. You can override the NSWindow method in subclasses or provide a delegate to substitute a class of text object different from the default of NSTextView, thereby customizing text editing in your application.
You can make a whole window or panel run in modal fashion, using the application's normal event loop machinery but restricting input to the modal window or panel. Modal operation is useful for windows and panels that require the user's attention before an action can proceed. Examples include error messages and warnings, as well as operations that require input, such as printing or saving a document.
There are two mechanisms for operating a modal window or panel. The first, and simpler, is to invoke NSApplication's runModalForWindow: method, which monopolizes events for the specified window until one of the NSApplication methods stopModal, abortModal, or stopModalWithCode: is invoked, typically by a button's action method. The stopModal method ends the modal status of the window or panel from within the event loop. It doesn't work if invoked from a method invoked by a timer or by a distributed object because those mechanisms operate outside of the event loop. To terminate the modal loop in these situations, you can use abortModal. The stopModal method is typically invoked when the user clicks the OK button (or equivalent), abortModal when the user clicks the Cancel button (or presses the Escape key). These two methods are equivalent to stopModalWithCode: with the appropriate argument. See the method descriptions in the NSApplication class specification for more information.
The second mechanism for operating a modal window or panel, called a modal session, allows the application to perform a long operation while it still sends events to the window or panel. Modal sessions are particularly useful for panels that allow the user to cancel or modify an operation. To begin a modal session, invoke NSApplication's beginModalSessionForWindow: method, which sets the window up for the session and returns an identifier used for other session-controlling methods. At this point, the application can run in a loop that performs the operation, on each pass sending runModalSession: to the application object so that pending events can be dispatched to the modal window. This method returns a code indicating whether the operation should continue, stop, or abort, which is typically established by the methods described above for runModalForWindow:. After the loop concludes, you can remove the window from the screen and invoke NSApplication's endModalSession: method to restore the normal event loop. The method description for runModalForWindow in the NSApplication class specification includes sample code illustrating a modal session.
You can write a modal event loop for a view object so that the object has access to all events pertaining to a particular task, such as tracking the mouse in the view. For an example, see "Mouse Events" in the class specification for NSView. |
Constant | Description |
NSBorderlessWindowMask |
The NSWindow displays none of the usual peripheral elements. Useful only for display or caching purposes. |
NSTitledWindowMask |
The NSWindow displays a title bar. |
NSClosableWindowMask |
The NSWindow displays a close button. |
NSMiniaturizableWindowMask |
The NSWindow displays a miniaturize button. |
NSResizableWindowMask |
The NSWindow displays a resize bar or border. |
These constants specify how the drawing done in a window is buffered by the window device
Constant | Description |
NSBackingStoreBuffered |
<<Description Forthcoming>> |
NSBackingStoreRetained |
<<Description Forthcoming>> |
NSBackingStoreNonretained |
<<Description Forthcoming>> |
These constants specify the window's level
Constant | Description |
NSNormalWindowLevel |
The default level for NSWindow objects. |
NSFloatingWindowLevel |
Useful for floating palettes. |
NSDockWindowLevel |
Reserved for the application dock (Mach-based systems only). <<Deprecated>> |
NSSubmenuWindowLevel |
Reserved for submenus (not used on Microsoft Windows).
Synonymous with NSTornOffMenuWindowLevel . |
NSTornOffMenuWindowLevel |
The level for a torn-off menu. Synonymous with NSSubmenuWindowLevel . |
NSMainMenuWindowLevel |
Reserved for the application's main menu (not used on Microsoft Windows). |
NSModalPanelWindowLevel |
The level for a modal panel. |
NSPopUpMenuWindowLevel |
The level for a popup menu. |
NSScreenSaverWindowLevel |
<<Description Forthcoming>> |
These constants let you specify how a window is ordered relative to another window. For more information, see orderWindow:relativeTo:.
Constant | Description |
NSWindowAbove |
<<Description Forthcoming>> |
NSWindowBelow |
<<Description Forthcoming>> |
NSWindowOut |
<<Description Forthcoming>> |
These constants specify the direction a window is currently using to change the key view. It's used by keyViewSelectionDirection
Constant | Description |
NSDirectSelection |
The receiver isn't traversing the key view loop. |
NSSelectingNext |
The receiver is proceeding to the next valid key view. |
NSSelectingPrevious |
The receiver is proceeding to the previous valid key view. |
- Creating instances
- - initWithContentRect:styleMask:backing:defer:
- - initWithContentRect:styleMask:backing:defer:screen:
- Calculating layout
- + contentRectForFrameRect:styleMask:
- + frameRectForContentRect:styleMask:
- + minFrameWidthWithTitle:styleMask:
- Converting coordinates
- - convertBaseToScreen:
- - convertScreenToBase:
- Moving and resizing
- - setFrame:display:
- - frame
- - setFrameOrigin:
- - setFrameTopLeftPoint:
- - setContentSize:
- - cascadeTopLeftFromPoint:
- - center
- - resizeFlags
- - performZoom:
- - zoom:
- Constraining window size
- - maxSize
- - minSize
- - setMaxSize:
- - setMinSize:
- - setAspectRatio:
- - aspectRatio
- - setResizeIncrements:
- - resizeIncrements
- - constrainFrameRect:toScreen:
- Saving the frame to user defaults
- + removeFrameUsingName:
- - saveFrameUsingName:
- - setFrameUsingName:
- - setFrameAutosaveName:
- - frameAutosaveName
- - setFrameFromString:
- - stringWithSavedFrame
- Ordering windows
- - orderBack:
- - orderFront:
- - orderFrontRegardless
- - orderOut:
- - orderWindow:relativeTo:
- - setLevel:
- - level
- - isVisible
- Making key and main windows
- - becomeKeyWindow
- - canBecomeKeyWindow
- - isKeyWindow
- - makeKeyAndOrderFront:
- - makeKeyWindow
- - resignKeyWindow
- - becomeMainWindow
- - canBecomeMainWindow
- - isMainWindow
- - makeMainWindow
- - resignMainWindow
- Working with the default button
- - defaultButtonCell
- - setDefaultButtonCell:
- - disableKeyEquivalentForDefaultButtonCell
- - enableKeyEquivalentForDefaultButtonCell
- Display and drawing
- - display
- - displayIfNeeded
- - setViewsNeedDisplay:
- - viewsNeedDisplay
- - useOptimizedDrawing:
- - setAutodisplay:
- - isAutodisplay
- - update
- Setting the interface style
- - setInterfaceStyle:
- - interfaceStyle
- Flushing graphics
- - flushWindow
- - flushWindowIfNeeded
- - enableFlushWindow
- - disableFlushWindow
- - isFlushWindowDisabled
- Bracketing temporary drawing
- - cacheImageInRect:
- - restoreCachedImage
- - discardCachedImage
- Window Server information
- - windowNumber
- - gState
- - deviceDescription
- - setBackingType:
- - backingType
- - setOneShot:
- - isOneShot
- + defaultDepthLimit
- - setDepthLimit:
- - depthLimit
- - setDynamicDepthLimit:
- - hasDynamicDepthLimit
- - canStoreColor
- Screen information
- - deepestScreen
- - screen
- Working with the responder chain
- - makeFirstResponder:
- - firstResponder
- Event handling
- - currentEvent
- - nextEventMatchingMask:
- - nextEventMatchingMask:untilDate:inMode:dequeue:
- - discardEventsMatchingMask:beforeEvent:
- - postEvent:atStart:
- - sendEvent:
- - tryToPerform:with:
- - keyDown:
- - mouseLocationOutsideOfEventStream
- - setAcceptsMouseMovedEvents:
- - acceptsMouseMovedEvents
- Working with the field editor
- - fieldEditor:forObject:
- - endEditingFor:
- Keyboard interface control
- - setInitialFirstResponder:
- - initialFirstResponder
- - selectKeyViewFollowingView:
- - selectKeyViewPrecedingView:
- - selectNextKeyView:
- - selectPreviousKeyView:
- - keyViewSelectionDirection
- Setting the title and filename
- - setTitle:
- - setTitleWithRepresentedFilename:
- - title
- - setRepresentedFilename:
- - representedFilename
- Marking a window edited
- - setDocumentEdited:
- - isDocumentEdited
- Closing the window
- - close
- - performClose:
- - setReleasedWhenClosed:
- - isReleasedWhenClosed
- Miniaturizing and miniwindows
- - miniaturize:
- - performMiniaturize:
- - deminiaturize:
- - isMiniaturized
- - setMiniwindowImage:
- - miniwindowImage
- - setMiniwindowTitle:
- - miniwindowTitle
- Working with menus
- + menuChanged:
- Working with the Windows menu
- - setExcludedFromWindowsMenu:
- - isExcludedFromWindowsMenu
- Working with cursor rectangles
- - areCursorRectsEnabled
- - enableCursorRects
- - disableCursorRects
- - discardCursorRects
- - invalidateCursorRectsForView:
- - resetCursorRects
- Dragging
- - dragImage:at:offset:event:pasteboard:source:slideBack:
- - registerForDraggedTypes:
- - unregisterDraggedTypes
- Controlling behavior
- - setHidesOnDeactivate:
- - hidesOnDeactivate
- - worksWhenModal
- Setting the content view
- - setContentView:
- - contentView
- Setting the background color
- - setBackgroundColor:
- - backgroundColor
- Getting the style mask
- - styleMask
- Working with Services
- - validRequestorForSendType:returnType:
- Printing and faxing
- - print:
- - dataWithEPSInsideRect:
- - fax:
- Getting the Microsoft Windows handle
- - windowHandle
- Setting the delegate
- - setDelegate:
- - delegate
NS
+ (NSRect)contentRectForFrameRect:(NSRect)frameRect styleMask:(unsigned
int)aStyle
See Also: + frameRectForContentRect:styleMask:
+ (NSWindowDepth)defaultDepthLimit
The
value returned can be examined with the Application Kit functions NSPlanarFromDepth
, NSColorSpaceFromDepth
, NSBitsPerSampleFromDepth
, NSBitsPerPixelFromDepth
.
.
See Also: - setDepthLimit:, - setDynamicDepthLimit:, - canStoreColor
+ (NSRect)frameRectForContentRect:(NSRect)contentRect styleMask:(unsigned
int)aStyle
See Also: + contentRectForFrameRect:styleMask:
+ (void)menuChanged:(NSMenu
*)aMenu
See Also: - menu (NSResponder)
+ (float)minFrameWidthWithTitle:(NSString
*)aTitle styleMask:(unsigned
int)aStyle
+ (void)removeFrameUsingName:(NSString
*)name
See Also: - setFrameUsingName:, - setFrameAutosaveName:
- (BOOL)acceptsMouseMovedEvents
YES
if
the receiver accepts and distributes mouse-moved events, NO
if it
doesn't. NSWindows by default don't accept
mouse-moved events.See Also: - setAcceptsMouseMovedEvents:
- (BOOL)areCursorRectsEnabled
YES
if
the receiver's cursor rectangles are enabled, NO
if
they're not.See Also: - enableCursorRects, - addCursorRect:cursor: (NSView)
- (NSSize)aspectRatio
See Also: - resizeIncrements, - setAspectRatio:, - setFrame:display:
- (NSColor *)backgroundColor
See Also: - setBackgroundColor:
- (NSBackingStoreType)backingType
NSBackingStoreBuffered
NSBackingStoreRetained
NSBackingStoreNonretained
See Also: - setBackingType:
- (void)becomeKeyWindow
See Also: - makeKeyWindow, - makeKeyAndOrderFront:, - becomeMainWindow
- (void)becomeMainWindow
See Also: - makeMainWindow, - becomeKeyWindow
- (void)cacheImageInRect:(NSRect)aRect
See Also: - display
- (BOOL)canBecomeKeyWindow
YES
if
the receiver can become the key window, NO
if
it can't. Attempts to make the receiver the
key window are abandoned if this method returns NO
.
NSWindow's implementation returns YES
if
the receiver has a title bar or a resize bar (size border in Windows), NO
otherwise.See Also: - isKeyWindow, - makeKeyWindow
- (BOOL)canBecomeMainWindow
YES
if
the receiver can become the main window, NO
if
it can't. Attempts to make the receiver the
main window are abandoned if this method returns NO
.
NSWindow's implementation returns YES
if
the receiver is visible, is not an NSPanel, and has a title bar
or a resize mechanism. Otherwise it returns NO
.See Also: - isMainWindow, - makeMainWindow
- (BOOL)canStoreColor
YES
if
the receiver has a depth limit that allows it to store color values, NO
if
it doesn't.See Also: - depthLimit, - shouldDrawColor (NSView)
- (NSPoint)cascadeTopLeftFromPoint:(NSPoint)topLeftPoint
See Also: - setFrameTopLeftPoint:
- (void)center
You typically use this method to place an NSWindow-most likely an attention panel-where the user can't miss it. This method is invoked automatically when an NSPanel is placed on the screen by NSApplication's runModalForWindow: method.
- (void)close
A window doesn't have to be visible to receive the close message. For example, when the application terminates, it sends the close message to all windows in its window list, even those that are not currently visible.
The close method posts an NSWindowWillCloseNotification to the default notification center.
The close method differs in two important ways from the performClose: method:
Use performClose: if you need these features.
See Also: - orderOut:
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen
*)aScreen
Subclasses can override this method to prevent their instances from being constrained or to constrain them differently.
- (id)contentView
See Also: - setContentView:
- (NSPoint)convertBaseToScreen:(NSPoint)aPoint
See Also: - convertScreenToBase:, - convertPoint:toView: (NSView)
- (NSPoint)convertScreenToBase:(NSPoint)aPoint
See Also: - convertBaseToScreen:, - convertPoint:fromView: (NSView)
- (NSEvent *)currentEvent
- (NSData *)dataWithEPSInsideRect:(NSRect)aRect
See Also: - dataWithEPSInsideRect: (NSView) - writeEPSInsideRect:toPasteboard: (NSView)
- (NSScreen *)deepestScreen
nil
if
the receiver is off screen.See Also: - screen
- (NSButtonCell *)defaultButtonCell
The window receives a Return key event if no responder in its responder chain claims it, or if the user presses the Control key along with the Return key.
See Also: - setDefaultButtonCell:, - disableKeyEquivalentForDefaultButtonCell, - enableKeyEquivalentForDefaultButtonCell
- (id)delegate
nil
if it doesn't have a delegate.See Also: - setDelegate:
- (void)deminiaturize:(id)sender
See Also: - miniaturize:, - styleMask
- (NSWindowDepth)depthLimit
NSPlanarFromDepth
, NSColorSpaceFromDepth
, NSBitsPerSampleFromDepth
, NSBitsPerPixelFromDepth
. See Also: + defaultDepthLimit, - setDepthLimit:, - setDynamicDepthLimit:
- (NSDictionary *)deviceDescription
Dictionary Key | Value |
NSDeviceResolution | An NSValue containing a value of type NSSize that describe the receiver's raster resolution in dots per inch (dpi). |
NSDeviceColorSpaceName | An NSString giving the name of the receiver's color space. See the Application Kit Types and Constantsfor a list of possible values. |
NSDeviceBitsPerSample | An NSNumber containing an integer that gives the bit depth of the receiver's raster image (2-bit, 8-bit, and so forth). |
NSDeviceIsScreen | YES , indicating that the
receiver displays on the screen. |
NSDeviceSize | An NSValue containing a value of type NSSize that gives the size of the receiver's frame rectangle. |
See Also: - deviceDescription (NSScreen), - bestRepresentationForDevice: (NSImage) - colorUsingColorSpaceName: (NSColor)
- (void)disableCursorRects
See Also: - enableCursorRects
- (void)disableFlushWindow
Flushing should be disabled only temporarily, while the NSWindow's display is being updated. Each disableFlushWindow message must be paired with a subsequent enableFlushWindow message. Invocations of these methods can be nested; flushing isn't reenabled until the last (unnested) enableFlushWindow message is sent.
- (void)disableKeyEquivalentForDefaultButtonCell
See Also: - enableKeyEquivalentForDefaultButtonCell
- (void)discardCachedImage
See Also: - cacheImageInRect:, - restoreCachedImage, - display
- (void)discardCursorRects
- (void)discardEventsMatchingMask:(unsigned
int)mask beforeEvent:(NSEvent
*)lastEvent
- (void)display
You rarely need to invoke this method. NSWindows normally record which of their NSViews need display and display them automatically on each pass through the event loop.
See Also: - display (NSView), - displayIfNeeded, - isAutodisplay
- (void)displayIfNeeded
You rarely need to invoke this method. NSWindows normally record which of their NSViews need display and display them automatically on each pass through the event loop.
See Also: - display, - displayIfNeeded (NSView) - setNeedsDisplay: (NSView), - isAutodisplay
- (void)dragImage:(NSImage
*)anImage at:(NSPoint)aPoint offset:(NSSize)initialOffset event:(NSEvent
*)theEvent pasteboard:(NSPasteboard
*)pboard source:(id)sourceObject slideBack:(BOOL)slideBack
- (void)enableCursorRects
- (void)enableFlushWindow
- (void)enableKeyEquivalentForDefaultButtonCell
See Also: - disableKeyEquivalentForDefaultButtonCell
- (void)endEditingFor:(id)anObject
NO
. This forces the field
editor to send a textDidEndEditing: message
to its delegate. The field editor is then removed from the view
hierarchy, its delegate is set to nil
,
and it's emptied of any text it may contain.This method is typically invoked by the object using the field editor when it's finished. Other objects normally change the first responder by simply using makeFirstResponder:, which allows a field editor or other object to retain its first responder status if, for example, the user has entered an invalid value. The endEditingFor: method should be used only as a last resort if the field editor refuses to resign first responder status. Even in this case, you should always allow the field editor a chance to validate its text and take whatever other action it needs first. You can do this by first trying to make the NSWindow the first responder:
if ([myWindow makeFirstResponder:myWindow]) { /* All fields are now valid; it's safe to use fieldEditor:forObject: to claim the field editor. */ } else { /* Force first responder to resign. */ [myWindow endEditingFor:nil]; }
See Also: - fieldEditor:forObject:, - windowWillReturnFieldEditor:toObject:
- (void)fax:(id)sender
See Also: - print:
- (NSText *)fieldEditor:(BOOL)createFlag forObject:(id)anObject
YES
. Returns nil
if createFlag is NO
and
the field editor doesn't exist. anObject is used
to allow the receiver's delegate to substitute another object
in place of the field editor, as described below. The field editor
may be in use by some view object, so be sure to properly dissociate
it from that object before actually using it yourself (the appropriate
way to do this is illustrated in the description of endEditingFor:).
Once you retrieve the field editor, you can insert it in the view hierarchy,
set a delegate to interpret text events, and have it perform whatever editing
is needed. Then, when it sends a textDidEndEditing: message
to the delegate, you can get its text to display or store, and remove
the field editor using endEditingFor:.The field editor is provided as a convenience and can be used however your application sees fit. Typically, the field editor is used by simple text-bearing objects-for example, an NSTextField object uses its window's field editor to display and manipulate text. The field editor can be shared by any number of objects and so its state may be constantly changing. Therefore, it shouldn't be used to display text that demands sophisticated layout (for this you should create a dedicated NSText object).
A freshly created
NSWindow doesn't have a field editor. After a field editor has been
created for an NSWindow, the createFlag argument
is ignored. By passing NO
for createFlag and
testing the return value, however, you can predicate an action on
the existence of the field editor.
The receiver's
delegate can substitute a custom editor in place of the NSWindow's field
editor by implementing windowWillReturnFieldEditor:toObject:. The receiver
sends this message to its delegate with itself and anObject as
the arguments, and if the return value is not nil
the
NSWindow returns that object instead of its field editor. However,
note the following:
- (NSResponder *)firstResponder
See Also: - makeFirstResponder:, - acceptsFirstResponder (NSResponder)
- (void)flushWindow
See Also: - flushWindowIfNeeded, - disableFlushWindow, - enableFlushWindow
- (void)flushWindowIfNeeded
See Also: - flushWindow, - disableFlushWindow, - enableFlushWindow
- (NSRect)frame
See Also: - screen, - deepestScreen
- (NSString *)frameAutosaveName
See Also: - setFrameUsingName:
- (int)gState
- (BOOL)hasDynamicDepthLimit
YES
if
the receiver's depth limit can change to match the depth of the screen
it's on, NO
if it can't.See Also: - setDynamicDepthLimit:
- (BOOL)hidesOnDeactivate
YES
if
the receiver is removed from the screen when its application is deactivated, NO
if
it remains on screen.See Also: - setHidesOnDeactivate:
- (NSView *)initialFirstResponder
See Also: - setInitialFirstResponder:, - setNextKeyView: (NSView)
- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned
int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag
contentRect specifies the location and size of the NSWindow's content area in screen coordinates. Note that the Window Server limits window position coordinates to ¨±16,000 and sizes to 10,000.
styleMask specifies the receiver's style. It can either be NSBorderlessWindowMask, or it can contain any of the following options, combined using the C bitwise OR operator:
NSTitledWindowMask
NSClosableWindowMask
NSMiniaturizableWindowMask
NSResizableWindowMask
Borderless
windows display none of the usual peripheral elements and are generally
useful only for display or caching purposes; you should normally
not need to create them. Also, note that an NSWindow's style mask
should include NSTitledWindowMask
if
it includes any of the others.
backingType specifies how the drawing done in the receiver is buffered by the object's window device:
NSBackingStoreBuffered
NSBackingStoreRetained
NSBackingStoreNonretained
flag determines
whether the Window Server creates a window device for the new object
immediately. If flag is YES
,
it defers creating the window until the receiver is moved on screen.
All display messages sent to the NSWindow or its NSViews are postponed
until the window is created, just before it's moved on screen.
Deferring the creation of the window improves launch time and minimizes the
virtual memory load on the Window Server.
The new NSWindow creates an instance of NSView to be its default content view. You can replace it with your own object by using the setContentView: method.
See Also: - orderFront:, - setTitle:, - setOneShot:, - initWithContentRect:styleMask:backing:defer:screen:
- (id)initWithContentRect:(NSRect)contentRect
styleMask:(unsigned int)styleMask
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag
screen:(NSScreen *)aScreen
If aScreen is nil
,
the content rectangle is interpreted relative to the lower-left corner
of the main screen. The main screen is the one that contains the
current key window, or, if there is no key window, the one that
contains the main menu. If there's neither a key window nor a
main menu (if there's no active application), the main screen
is the one where the origin of the screen coordinate system is located.
See Also: - orderFront:, - setTitle:, - setOneShot:
- (NSInterfaceStyle)interfaceStyle
See Also: - setInterfaceStyle:
- (void)invalidateCursorRectsForView:(NSView
*)aView
See Also: - resetCursorRects, - resetCursorRects (NSView)
- (BOOL)isAutodisplay
YES
if
the receiver automatically displays its views that are marked as needing
it, NO
if it doesn't. Automatic
display typically occurs on each pass through the event loop.See Also: - setAutodisplay:, - displayIfNeeded, - setNeedsDisplay: (NSView)
- (BOOL)isDocumentEdited
YES
or NO
according
to the argument supplied with the last setDocumentEdited: message.- (BOOL)isExcludedFromWindowsMenu
YES
if
the receiver's title is omitted from the application's Windows menu, NO
if
it is listed.See Also: - setExcludedFromWindowsMenu:
- (BOOL)isFlushWindowDisabled
YES
if
the receiver's flushing ability has been disabled; otherwise returns NO
.See Also: - disableFlushWindow, - enableFlushWindow
- (BOOL)isKeyWindow
YES
if
the receiver is the key window for the application, NO
if
it isn't.See Also: - isMainWindow, - makeKeyWindow
- (BOOL)isMainWindow
YES
if
the receiver is the main window for the application, NO
if
it isn't.See Also: - isKeyWindow, - makeMainWindow
- (BOOL)isMiniaturized
YES
if
the receiver has been miniaturized, NO
if
it hasn't. A miniaturized window is removed
from the screen and replaced by a miniwindow, icon, or button that
represents it, called the counterpart (the particular form depends
on the platform).See Also: - miniaturize:
- (BOOL)isOneShot
YES
if
the PostScript window device the receiver manages is freed when it's
removed from the screen list, NO
if
not. The default is NO
.See Also: - setOneShot:
- (BOOL)isReleasedWhenClosed
YES
if
the receiver is automatically released after being closed, NO
if
it's simply removed from the screen. The default
for NSWindow is YES
; the default for
NSPanel is NO
.See Also: - setReleasedWhenClosed:
- (BOOL)isVisible
YES
if
the receiver is on screen (even if it's obscured by other windows).See Also: - visibleRect (NSView)
- (BOOL)isZoomed;
- (void)keyDown:(NSEvent
*)theEvent
See Also: - selectNextKeyView:, - nextKeyView (NSView) - performMnemonic: (NSView)
- (NSSelectionDirection)keyViewSelectionDirection
Value | Meaning |
NSDirectSelection |
The receiver isn't traversing the key view loop. |
NSSelectingNext |
The receiver is proceeding to the next valid key view. |
NSSelectingPrevious |
The receiver is proceeding to the previous valid key view. |
See Also: - selectNextKeyView:, - selectPreviousKeyView:
- (int)level
- (BOOL)makeFirstResponder:(NSResponder
*)aResponder
NO
.
If it returns YES
, this methods sends
a becomeFirstResponder message to aResponder.
If aResponder accepts first responder
status, this method returns YES
.
If it refuses, this method returns NO
,
and the NSWindow becomes first responder.The Application Kit uses this method to alter the first responder in response to mouse-down events; you can also use it to explicitly set the first responder from within your program. aResponder is typically an NSView in the receiver's view hierarchy.
See Also: - becomeFirstResponder (NSResponder) - resignFirstResponder (NSResponder)
- (void)makeKeyAndOrderFront:(id)sender
See Also: - orderFront:, - orderBack:, - orderOut:, - orderWindow:relativeTo:, - setLevel:
- (void)makeKeyWindow
See Also: - makeMainWindow, - becomeKeyWindow, - isKeyWindow
- (void)makeMainWindow
See Also: - makeKeyWindow, - becomeMainWindow, - isMainWindow
- (NSSize)maxSize
See Also: - setMaxSize:, - minSize, - aspectRatio, - resizeIncrements
- (void)miniaturize:(id)sender
See Also: - deminiaturize:
- (NSImage *)miniwindowImage
See Also: - setMiniwindowImage:, - miniwindowTitle
- (NSString *)miniwindowTitle
See Also: - setMiniwindowTitle:, - miniwindowImage
- (NSSize)minSize
See Also: - setMinSize:, - maxSize, - aspectRatio, - resizeIncrements
- (NSPoint)mouseLocationOutsideOfEventStream
See Also: - currentEvent (NSApplication)
- (NSEvent *)nextEventMatchingMask:(unsigned
int)mask
NSEventTrackingRunLoopMode
,
and a dequeue flag of YES
. See
the method description in the NSApplication class specification
for more information.- (NSEvent *)nextEventMatchingMask:(unsigned
int)mask untilDate:(NSDate
*)expirationDate inMode:(NSString
*)mode dequeue:(BOOL)dequeue
NSApp
. See
the method description in the NSApplication class specification
for more information.- (void)orderBack:(id)sender
See Also: - orderFront:, - orderOut:, - orderWindow:relativeTo:, - makeKeyAndOrderFront:, - level
- (void)orderFront:(id)sender
See Also: - orderBack:, - orderOut:, - orderWindow:relativeTo:, - makeKeyAndOrderFront:, - level
- (void)orderFrontRegardless
See Also: - orderFront:, - level
- (void)orderOut:(id)sender
See Also: - orderFront:, - orderBack:, - orderWindow:relativeTo:, - setReleasedWhenClosed:
- (void)orderWindow:(NSWindowOrderingMode)place relativeTo:(int)otherWindowNumber
NSWindowOut
,
the receiver is removed from the screen list and otherWindowNumber is
ignored. If it's NSWindowAbove
the
receiver is ordered immediately in front of the window whose window
number is otherWindowNumber. Similarly,
if place is NSWindowBelow
, the receiver
is placed immediately behind the window represented by otherWindowNumber.
If otherWindowNumber is 0, the receiver
is placed in front of or behind all other windows in its level.See Also: - orderFront:, - orderBack:, - orderOut:, - makeKeyAndOrderFront:, - level, - windowNumber
- (void)performClose:(id)sender
NO
, the window isn't closed.
If it returns YES
, or if it isn't
implemented, performClose: invokes
the close method to
close the window.If the receiver doesn't have a close button
or can't be closed (for example, if the delegate replies NO
to
a windowShouldClose: message), this method calls the NSBeep
function.
See Also: - styleMask, - performClick: (NSButton), - performMiniaturize:
- (void)performMiniaturize:(id)sender
NSBeep
function. See Also: - close, - styleMask, - performClick: (NSButton), - performClose:
- (void)performZoom:(id)sender
NSBeep
function. See Also: - styleMask, - performClick: (NSButton), - zoom:
- (void)postEvent:(NSEvent
*)anEvent atStart:(BOOL)flag
NSApp
.public boolean prepareForDragOperation(NSDraggingInfo aNSDraggingInfo)
- (void)print:(id)sender
See Also: - fax:
- (void)registerForDraggedTypes:(NSArray
*)pboardTypes
Registering an NSWindow for dragged types automatically makes it a candidate destination object for a dragging session. As such, it must properly implement some or all of the NSDraggingDestination protocol methods. As a convenience, NSWindow provides default implementations of these methods. See the NSDraggingDestination protocol specification for details.
See Also: - unregisterDraggedTypes
- (NSString *)representedFilename
See Also: - setRepresentedFilename:
- (void)resetCursorRects
This method is typically invoked by the NSApplication object when it detects that the key window's cursor rectangles are invalid. In program code, it's more efficient to invoke invalidateCursorRectsForView:.
- (void)resignKeyWindow
See Also: - becomeKeyWindow, - resignMainWindow
- (void)resignMainWindow
See Also: - becomeMainWindow, - resignKeyWindow
- (int)resizeFlags
- (NSSize)resizeIncrements
increments.width
and increments.height
when
the user resizes it. These amounts are whole number
values, 1.0 or greater. You can set an NSWindow's size to any
value programmatically.See Also: - setResizeIncrements:, - setAspectRatio:, - setFrame:display:
- (void)restoreCachedImage
See Also: - discardCachedImage, - display
- (void)saveFrameUsingName:(NSString
*)name
See Also: - stringWithSavedFrame
- (NSScreen *)screen
See Also: - deepestScreen
- (void)selectKeyViewFollowingView:(NSView
*)aView
See Also: - selectKeyViewPrecedingView:
- (void)selectKeyViewPrecedingView:(NSView
*)aView
See Also: - selectKeyViewFollowingView:
- (void)selectNextKeyView:(id)sender
YES
to an acceptsFirstResponder message.nil
.See Also: - selectPreviousKeyView:, - selectKeyViewFollowingView:
- (void)selectPreviousKeyView:(id)sender
YES
to an acceptsFirstResponder message.nil
.See Also: - selectNextKeyView:, - selectKeyViewPrecedingView:
- (void)sendEvent:(NSEvent
*)theEvent
- (void)setAcceptsMouseMovedEvents:(BOOL)flag
YES
it
does accept them; if flag is NO
it
doesn't. NSWindows don't accept mouse-moved events by default.See Also: - acceptsMouseMovedEvents
- (void)setAspectRatio:(NSSize)ratio
An NSWindow's aspect ratio and its resize increments are mutually exclusive attributes. In fact, setting one attribute cancels the setting of the other. For example, to cancel an established aspect ratio setting for an NSWindow, you send the NSWindow object a setResizeIncrements: message with the width and height set to 1.0:
[myWindow setResizeIncrements:NSMakeSize(1.0,1.0)];
See Also: - aspectRatio, - setFrame:display:
- (void)setAutodisplay:(BOOL)flag
YES
,
views are automatically displayed as needed, typically on each pass
through the event loop. If flag is NO
,
the receiver or its views must be explicitly displayed.See Also: - isAutodisplay, - displayIfNeeded, - displayIfNeeded (NSView)
- (void)setBackgroundColor:(NSColor
*)aColor
See Also: - backgroundColor
- (void)setBackingType:(NSBackingStoreType)backingType
NSBackingStoreBuffered
NSBackingStoreRetained
This method can only be used to switch a buffered NSWindow to retained or vice versa; you can't change the backing type to or from nonretained after initializing an NSWindow (a PostScript error is generated if you attempt to do so).
See Also: - backingType, - initWithContentRect:styleMask:backing:defer:, - initWithContentRect:styleMask:backing:defer:screen:
- (void)setContentSize:(NSSize)aSize
See Also: - setFrame:display:, + contentRectForFrameRect:styleMask:, + frameRectForContentRect:styleMask:
- (void)setContentView:(NSView
*)aView
This method causes the old content view to be released; if you plan to reuse it, be sure to retain it before sending this message and to release it as appropriate when adding it to another NSWindow or NSView.
See Also: - contentView, - setContentSize:
- (void)setDefaultButtonCell:(NSButtonCell
*)aButtonCell
See Also: - disableKeyEquivalentForDefaultButtonCell, - enableKeyEquivalentForDefaultButtonCell
- (void)setDelegate:(id)anObject
See Also: - delegate, - tryToPerform:with:, - sendAction:to:from: (NSApplication)
- (void)setDepthLimit:(NSWindowDepth)limit
NSBestDepth
function. Passing
a value of 0 for limit sets the depth
limit to the receiver's default depth limit; using a value of
0 can be useful for reverting an NSWindow to its initial depth.See Also: - depthLimit, + defaultDepthLimit, - setDynamicDepthLimit:
- (void)setDocumentEdited:(BOOL)flag
You should invoke
this method with an argument of YES
every
time the NSWindow's document changes in such a way that it needs
to be saved and with an argument of NO
every
time it gets saved. Then, before closing the NSWindow you can use isDocumentEdited to
determine whether to allow the user a chance to save the document.
- (void)setDynamicDepthLimit:(BOOL)flag
YES
,
the depth limit depends on which screen the receiver is on. If flag is NO
, the
receiver uses either its preset depth limit or the default depth
limit. A different, and nondynamic, depth limit can be set with
the setDepthLimit: method.See Also: - hasDynamicDepthLimit, + defaultDepthLimit
- (void)setExcludedFromWindowsMenu:(BOOL)flag
YES
it's
omitted; if flag is NO
,
it's listed when it or its miniwindow is on screen. The default
is NO
.See Also: - isExcludedFromWindowsMenu
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag
YES
. Note
that the Window Server limits window position coordinates to ¨±16,000
and sizes to 10,000.See Also: - frame, - setFrameFromString:, - setFrameOrigin:, - setFrameTopLeftPoint:, - setFrameUsingName:
- (BOOL)setFrameAutosaveName:(NSString
*)name
YES
if the
name is set successfully, NO
if it's being
used as an autosave name by another NSWindow in the application
(in which case the receiver's old name remains in effect).See Also: + removeFrameUsingName:, - stringWithSavedFrame, - setFrameFromString:
- (void)setFrameFromString:(NSString
*)aString
- (void)setFrameOrigin:(NSPoint)aPoint
See Also: - setFrame:display:, - setFrameTopLeftPoint:
- (void)setFrameTopLeftPoint:(NSPoint)aPoint
See Also: - cascadeTopLeftFromPoint:, - setFrame:display:, - setFrameOrigin:
- (BOOL)setFrameUsingName:(NSString
*)name
YES
if name is
read and the frame is set successfully; otherwise returns NO
.See Also: - setFrameAutosaveName:, + removeFrameUsingName:, - stringWithSavedFrame, - setFrameFromString:
- (void)setHidesOnDeactivate:(BOOL)flag
YES
,
the receiver is hidden (taken out of the screen list) when the application
stops being the active application. If flag is NO
,
the receiver stays on screen. The default for NSWindow is NO
;
the default for NSPanel is YES
.See Also: - hidesOnDeactivate
- (void)setInitialFirstResponder:(NSView
*)aView
See Also: - initialFirstResponder
- (void)setInterfaceStyle:(NSInterfaceStyle)interfaceStyle
super
's
implementation.See Also: - interfaceStyle
- (void)setLevel:(int)newLevel
Level | Comment |
NSNormalWindowLevel |
The default level for NSWindow objects. |
NSFloatingWindowLevel |
Useful for floating palettes. |
NSDockWindowLevel |
Reserved for the application dock (Mach-based systems only). <<Deprecated>> |
NSSubmenuWindowLevel |
Reserved for submenus (not used on Microsoft Windows).
Synonymous with NSTornOffMenuWindowLevel . |
NSTornOffMenuWindowLevel |
The level for a torn-off menu. Synonymous with NSSubmenuWindowLevel . |
NSMainMenuWindowLevel |
Reserved for the application's main menu (not used on Microsoft Windows). |
NSModalPanelWindowLevel |
The level for a modal panel. |
NSPopUpMenuWindowLevel |
The level for a popup menu. |
NSScreenSaverWindowLevel |
<<Description Forthcoming>> |
Each level in the list groups windows within it in front of those in all preceding groups. Floating windows, for example, appear in front of all normal-level windows. When a window enters a new level, it's ordered in front of all its peers in that level.
The
constant NSTornOffMenuWindowLevel
is
preferable to its synonym, NSSubmenuWindowLevel
See Also: - level, - orderWindow:relativeTo:, - orderFront:, - orderBack:
- (void)setMaxSize:(NSSize)aSize
See Also: - maxSize, - setMinSize:, - setAspectRatio:, - setResizeIncrements:
- (void)setMiniwindowImage:(NSImage
*)anImage
See Also: - miniwindowImage, - isMiniaturized
- (void)setMiniwindowTitle:(NSString
*)aString
See Also: - miniwindowTitle
- (void)setMinSize:(NSSize)aSize
See Also: - minSize, - setMaxSize:, - setAspectRatio:, - setResizeIncrements:
- (void)setOneShot:(BOOL)flag
NO
.See Also: - isOneShot
- (void)setReleasedWhenClosed:(BOOL)flag
NO
) or hidden and
then released (YES
) when it receives
a close message. The
default for NSWindow is YES
; the default
for NSPanel is NO
.Another strategy for releasing an NSWindow is to have its delegate autorelease it on receiving a windowShouldClose: message.
See Also: - close, - isReleasedWhenClosed
- (void)setRepresentedFilename:(NSString
*)path
See Also: - representedFilename, - setTitleWithRepresentedFilename:
- (void)setResizeIncrements:(NSSize)increments
.width
and increments.height
as
the user resizes the window. The width and height
increments should be whole numbers, 1.0 or greater. Whatever the
current resize increments, you can set an NSWindow's size to any
height and width programmatically.Resize increments and aspect ratio are mutually exclusive attributes. For more information, see setAspectRatio:.
See Also: - resizeIncrements, - setFrame:display:
- (void)setTitle:(NSString
*)aString
See Also: - title, - setTitleWithRepresentedFilename:, - setMiniwindowTitle:
- (void)setTitleWithRepresentedFilename:(NSString
*)path
This method also sets the title of the receiver's miniwindow.
See Also: - title, - setTitle:, - setMiniwindowTitle:
- (void)setViewsNeedDisplay:(BOOL)flag
YES
) or do not
need display (NO
). You
should rarely need to invoke this method; NSView's setNeedsDisplay: and
similar methods invoke it automatically.See Also: - viewsNeedDisplay
- (void)setWindowController:(NSWindowController
*)windowController
- (NSString *)stringWithSavedFrame
- (unsigned int)styleMask
- (NSString *)title
See Also: - setTitle:, - setTitleWithRepresentedFilename:
- (BOOL)tryToPerform:(SEL)anAction with:(id)anObject
YES
; otherwise
it returns NO
.- (void)unregisterDraggedTypes
See Also: - registerForDraggedTypes:
- (void)update
super
just
before returning. For example, the NSMenu class implements this
method to disable and enable menu commands.An NSWindow is automatically sent an update message on every pass through the event loop and before it's displayed on screen. You can manually cause an update message to be sent to all visible NSWindows through NSApplication's updateWindows method.
See Also: - setWindowsNeedUpdate: (NSApplication) - updateWindows (NSApplication)
- (void)useOptimizedDrawing:(BOOL)flag
YES
if
there are no overlapping subviews within the NSWindow. The default
is NO
.- (id)validRequestorForSendType:(NSString
*)sendType returnType:(NSString
*)returnType
nil
if none is found.Messages to perform this method are initiated by the Services menu. It's part of the mechanism that passes validRequestorForSendType:returnType: messages up the responder chain. See the Services documentation in Programming Topics for more information.
This method works by forwarding
the message to the receiver's delegate if it responds (and provided
it isn't an NSResponder with its own next responder). If the delegate
doesn't respond to the message or returns nil
when
sent it, this method forwards the message to the NSApplication object.
If the NSApplication object returns nil
,
this method also returns nil
. Otherwise
this method returns the object returned by the delegate or the NSApplication
object.
See Also: - validRequestorForSendType:returnType: (NSResponder and NSApplication)
- (BOOL)viewsNeedDisplay
YES
if
any of the receiver's NSView's need to be displayed, NO
otherwise.See Also: - setViewsNeedDisplay:
- (id)windowController
- (void *)windowHandle
- (int)windowNumber
NSWindowList
and NSConvertWindowNumberToGlobal
.If the receiver doesn't have a window device, the value returned will be equal to or less than 0.
See Also: - initWithContentRect:styleMask:backing:defer:, - setOneShot:
- (BOOL)worksWhenModal
YES
if
the receiver is able to receive keyboard and mouse events even when
some other window is being run modally, NO
otherwise. NSWindow's implementation
of this method returns NO
. Only subclasses
of NSPanel should override this default.See Also: - setWorksWhenModal: (NSPanel)
- (void)zoom:(id)sender
The zoom: method is typically invoked after a user clicks the window's zoom box but may also be invoked programmatically from the performZoom: method. It performs the following steps:
NO
if
zooming is not currently allowed.Posted whenever the NSWindow becomes the key window.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has become key.
Posted whenever the NSWindow becomes the main window.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has become main.
Posted whenever a portion of the NSWindow's frame moves onto or off of a screen.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has changed screens.
Posted whenever the NSWindow is deminiaturized.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has been deminiaturized.
Posted whenever a portion of a nonretained NSWindow is exposed, whether by being ordered in front of other windows or by other widows being removed from in front of it.
This notification contains a notification object and a userInfo dictionary. The notification object is the NSWindow that has been exposed. The userInfo dictionary contains the key NSExposedRect and an associated value for the rectangle that has been exposed.
Posted whenever the NSWindow is miniaturized.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has been miniaturized.
Posted whenever the NSWindow is moved.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has moved.
Posted whenever the NSWindow resigns its status as key window.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has resigned its key window status.
Posted whenever the NSWindow resigns its status as main window.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has resigned its main window status.
Posted whenever the NSWindow's size changes.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow whose size has changed.
Posted whenever the NSWindow receives an update message.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that received the update message.
Posted whenever the NSWindow is about to close.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that is about to close.
Posted whenever the NSWindow is about to be miniaturized.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that is about to be miniaturized.
Posted whenever the NSWindow is about to move.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that is about to move.