NSWindow

NSWindow Mac OS X 10.0

This class declares an interface to application windows and is one of the key components of the Application Kit architecture. NSWindow objects are responsible for managing and displaying a hierarchy of views within the window, as well as handling mouse and keyboard events that occur in the window.

figs/cocn_15115.gif

@interface NSWindow : NSResponder
 // Initializers
   - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle
        backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag;
   - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle
        backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag screen:(NSScreen *)screen;
   - (NSWindow *)initWithWindowRef:(void * /* WindowRef */)windowRef;
   - (NSView *)initialFirstResponder;
 // Accessor Methods
   - (void)setAspectRatio:(NSSize)ratio;
   - (NSSize)aspectRatio;
   - (void)setOrderedIndex:(int)index;
   - (int)orderedIndex;
   - (void)setIsVisible:(BOOL)flag;
   - (BOOL)isVisible;
   - (void)setTitle:(NSString *)aString;
   - (NSString *)title;
   - (void)setIsMiniaturized:(BOOL)flag;
   - (BOOL)isMiniaturized;
   - (void)setRepresentedFilename:(NSString *)aString;
   - (NSString *)representedFilename;
   - (void)setTitleWithRepresentedFilename:(NSString *)filename;
   - (void)setExcludedFromWindowsMenu:(BOOL)flag;
   - (void)setIsZoomed:(BOOL)flag;
   - (BOOL)isZoomed;
   - (void)setMiniwindowTitle:(NSString *)title;
   - (NSString *)miniwindowTitle;
   - (void)setDelegate:(id)anObject;
   - (id)delegate;
   - (void)setToolbar:(NSToolbar*)toolbar;
   - (NSToolbar *)toolbar;
   - (void)setDefaultButtonCell:(NSButtonCell *)defButt;
   - (NSButtonCell *)defaultButtonCell;
   - (void)setParentWindow:(NSWindow *)window;
   - (NSWindow *)parentWindow;
   - (void)setFrame:(NSRect)frameRect display:(BOOL)flag;
   - (NSRect)frame;
   - (void)setFrameOrigin:(NSPoint)aPoint;
   - (void)setFrameTopLeftPoint:(NSPoint)aPoint;
   - (void)setFrame:(NSRect)frameRect display:(BOOL)displayFlag animate:(BOOL)animateFlag;
   - (void)setResizeIncrements:(NSSize)increments;
   - (NSSize)resizeIncrements;
   - (void)setWindowController:(NSWindowController *)windowController;
   - (id)windowController;
   - (void)setMovableByWindowBackground:(BOOL)flag;
   - (void)setIgnoresMouseEvents:(BOOL)flag;
   - (BOOL)ignoresMouseEvents;
   - (void)setAcceptsMouseMovedEvents:(BOOL)flag;
   - (BOOL)acceptsMouseMovedEvents;
   - (void)setMaxSize:(NSSize)size;
   - (NSSize)maxSize;
   - (void)setMiniwindowImage:(NSImage *)image;
   - (NSImage *)miniwindowImage;
   - (void)setCanHide:(BOOL)flag;
   - (BOOL)canHide;
   - (BOOL)setFrameAutosaveName:(NSString *)name;
   - (NSString *)frameAutosaveName;
   - (BOOL)setFrameUsingName:(NSString *)name;
   - (void)setAutodisplay:(BOOL)flag;
   - (BOOL)setFrameUsingName:(NSString *)name force:(BOOL)force;
   - (void)setFrameFromString:(NSString *)string;
   - (void)setOpaque:(BOOL)isOpaque;
   - (void)setAlphaValue:(float)windowAlpha;
   - (float)alphaValue;
   - (void)setHasShadow:(BOOL)hasShadow;
   - (BOOL)hasShadow;
   - (void)setReleasedWhenClosed:(BOOL)flag;
   - (void)setDynamicDepthLimit:(BOOL)flag;
   - (void)setHidesOnDeactivate:(BOOL)flag;
   - (BOOL)hidesOnDeactivate;
   - (void)setLevel:(int)newLevel;
   - (int)level;
   - (void)setBackingType:(NSBackingStoreType)bufferingType;
   - (NSBackingStoreType)backingType;
   - (void)setOneShot:(BOOL)flag;
   - (void)setBackgroundColor:(NSColor *)color;
   - (NSColor *)backgroundColor;
   - (void)setMinSize:(NSSize)size;
   - (NSSize)minSize;
   - (void)setContentView:(NSView *)aView;
   - (id)contentView;
   - (void)setDocumentEdited:(BOOL)flag;
   - (void)setInitialFirstResponder:(NSView *)view;
   - (void)setShowsResizeIndicator:(BOOL)show;
   - (BOOL)showsResizeIndicator;
   - (void)setViewsNeedDisplay:(BOOL)flag;
   - (BOOL)viewsNeedDisplay;
   - (void)setDepthLimit:(NSWindowDepth)limit;
   - (NSWindowDepth)depthLimit;
   - (void)setContentSize:(NSSize)aSize;
 // Class Methods
   + (NSRect)contentRectForFrameRect:(NSRect)fRect styleMask:(unsigned int)aStyle;
   + (NSWindowDepth)defaultDepthLimit;
   + (NSRect)frameRectForContentRect:(NSRect)cRect styleMask:(unsigned int)aStyle;
   + (void)menuChanged:(NSMenu *)menu;
   + (float)minFrameWidthWithTitle:(NSString *)aTitle styleMask:(unsigned int)aStyle;
   + (void)removeFrameUsingName:(NSString *)name;
   + (NSButton *)standardWindowButton:(NSWindowButton)b forStyleMask:(unsigned int)styleMask;
 // Instance Methods
   - (BOOL)canBecomeKeyWindow;
   - (BOOL)canBecomeMainWindow;
   - (void)becomeKeyWindow;
   - (NSArray *)childWindows;
   - (void)becomeMainWindow;
   - (void)addChildWindow:(NSWindow *)childWin ordered:(NSWindowOrderingMode)place;
   - (NSTimeInterval)animationResizeTime:(NSRect)newFrame;
   - (NSPoint)cascadeTopLeftFromPoint:(NSPoint)topLeftPoint;
   - (NSWindow *)attachedSheet;
   - (NSEvent *)currentEvent;
   - (void)cacheImageInRect:(NSRect)aRect;
   - (void)close;
   - (BOOL)canStoreColor;
   - (BOOL)areCursorRectsEnabled;
   - (void)center;
   - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen;
   - (NSPoint)convertBaseToScreen:(NSPoint)aPoint;
   - (NSPoint)convertScreenToBase:(NSPoint)aPoint;
   - (NSData *)dataWithEPSInsideRect:(NSRect)rect;
   - (NSData *)dataWithPDFInsideRect:(NSRect)rect;
   - (NSScreen *)deepestScreen;
   - (void)deminiaturize:(id)sender;
   - (NSDictionary *)deviceDescription;
   - (void)disableCursorRects;
   - (void)disableFlushWindow;
   - (void)disableKeyEquivalentForDefaultButtonCell;
   - (void)discardCachedImage;
   - (void)discardCursorRects;
   - (void)discardEventsMatchingMask:(unsigned int)mask beforeEvent:(NSEvent *)lastEvent;
   - (void)display;
   - (void)displayIfNeeded;
   - (void)dragImage:(NSImage *)anImage at:(NSPoint)baseLocation offset:(NSSize)initialOffset
        event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag;
   - (NSArray *)drawers;
   - (void)enableCursorRects;
   - (void)enableFlushWindow;
   - (void)enableKeyEquivalentForDefaultButtonCell;
   - (void)endEditingFor:(id)anObject;
   - (NSText *)fieldEditor:(BOOL)createFlag forObject:(id)anObject;
   - (NSResponder *)firstResponder;
   - (void)flushWindow;
   - (void)flushWindowIfNeeded;
   - (int)gState;
   - (id)handleCloseScriptCommand:(NSCloseCommand *)command;
   - (id)handlePrintScriptCommand:(NSScriptCommand *)command;
   - (id)handleSaveScriptCommand:(NSScriptCommand *)command;
   - (BOOL)hasCloseBox;
   - (BOOL)hasDynamicDepthLimit;
   - (BOOL)hasTitleBar;
   - (void)invalidateCursorRectsForView:(NSView *)aView;
   - (void)invalidateShadow;
   - (BOOL)isAutodisplay;
   - (BOOL)isDocumentEdited;
   - (BOOL)isExcludedFromWindowsMenu;
   - (BOOL)isFloatingPanel;
   - (BOOL)isFlushWindowDisabled;
   - (BOOL)isKeyWindow;
   - (BOOL)isMainWindow;
   - (BOOL)isMiniaturizable;
   - (BOOL)isModalPanel;
   - (BOOL)isMovableByWindowBackground;
   - (BOOL)isOneShot;
   - (BOOL)isOpaque;
   - (BOOL)isReleasedWhenClosed;
   - (BOOL)isResizable;
   - (BOOL)isSheet;
   - (BOOL)isZoomable;
   - (void)keyDown:(NSEvent *)theEvent;
   - (NSSelectionDirection)keyViewSelectionDirection;
   - (BOOL)makeFirstResponder:(NSResponder *)aResponder;
   - (void)makeKeyAndOrderFront:(id)sender;
   - (void)makeKeyWindow;
   - (void)makeMainWindow;
   - (void)miniaturize:(id)sender;
   - (NSPoint)mouseLocationOutsideOfEventStream;
   - (NSEvent *)nextEventMatchingMask:(unsigned int)mask;
   - (NSEvent *)nextEventMatchingMask:(unsigned int)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode
        dequeue:(BOOL)deqFlag;
   - (void)orderBack:(id)sender;
   - (void)orderFront:(id)sender;
   - (void)orderFrontRegardless;
   - (void)orderOut:(id)sender;
   - (void)orderWindow:(NSWindowOrderingMode)place relativeTo:(int)otherWin;
   - (void)performClose:(id)sender;
   - (void)performMiniaturize:(id)sender;
   - (void)performZoom:(id)sender;
   - (void)postEvent:(NSEvent *)event atStart:(BOOL)flag;
   - (void)print:(id)sender;
   - (void)registerForDraggedTypes:(NSArray *)newTypes;
   - (void)removeChildWindow:(NSWindow *)childWin;
   - (void)resetCursorRects;
   - (void)resignKeyWindow;
   - (void)resignMainWindow;
   - (int)resizeFlags;
   - (void)restoreCachedImage;
   - (void)runToolbarCustomizationPalette:(id)sender;
   - (void)saveFrameUsingName:(NSString *)name;
   - (NSScreen *)screen;
   - (void)selectKeyViewFollowingView:(NSView *)aView;
   - (void)selectKeyViewPrecedingView:(NSView *)aView;
   - (void)selectNextKeyView:(id)sender;
   - (void)selectPreviousKeyView:(id)sender;
   - (void)sendEvent:(NSEvent *)theEvent;
   - (NSButton *)standardWindowButton:(NSWindowButton)b;
   - (NSString *)stringWithSavedFrame;
   - (unsigned int)styleMask;
   - (void)toggleToolbarShown:(id)sender;
   - (BOOL)tryToPerform:(SEL)anAction with:(id)anObject;
   - (void)unregisterDraggedTypes;
   - (void)update;
   - (void)useOptimizedDrawing:(BOOL)flag;
   - (id)validRequestorForSendType:(NSString *)sendType  returnType:(NSString *)returnType;
   - (void * /*HWND*/)windowHandle;
   - (int)windowNumber;
   - (void * /* WindowRef */)windowRef;
   - (BOOL)worksWhenModal;
   - (void)zoom:(id)sender;
// Methods Implemented by the Delegate
   - (void)windowDidBecomeKey:(NSNotification *)notification;
   - (void)windowDidBecomeMain:(NSNotification *)notification;
   - (void)windowDidChangeScreen:(NSNotification *)notification;
   - (void)windowDidDeminiaturize:(NSNotification *)notification;
   - (void)windowDidEndSheet:(NSNotification *)notification;
   - (void)windowDidExpose:(NSNotification *)notification;
   - (void)windowDidMiniaturize:(NSNotification *)notification;
   - (void)windowDidMove:(NSNotification *)notification;
   - (void)windowDidResignKey:(NSNotification *)notification;
   - (void)windowDidResignMain:(NSNotification *)notification;
   - (void)windowDidResize:(NSNotification *)notification;
   - (void)windowDidUpdate:(NSNotification *)notification;
   - (BOOL)windowShouldClose:(id)sender;
   - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
   - (void)windowWillBeginSheet:(NSNotification *)notification;
   - (void)windowWillClose:(NSNotification *)notification;
   - (void)windowWillMiniaturize:(NSNotification *)notification;
   - (void)windowWillMove:(NSNotification *)notification;
   - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize;
   - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client;
   - (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window;
   - (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)newFrame;
// Notifications
   NSWindowDidBecomeKeyNotification;
   NSWindowDidBecomeMainNotification;
   NSWindowDidChangeScreenNotification;
   NSWindowDidDeminiaturizeNotification;
   NSWindowDidEndSheetNotification;
   NSWindowDidMiniaturizeNotification;
   NSWindowDidMoveNotification;
   NSWindowDidResignKeyNotification;
   NSWindowDidResignMainNotification;
   NSWindowDidResizeNotification;
   NSWindowDidUpdateNotification;
   NSWindowWillBeginSheetNotification;
   NSWindowWillCloseNotification;
   NSWindowWillMiniaturizeNotification;
   NSWindowWillMoveNotification;

Subclasses

NSPanel



    Part II: API Quick Reference
    Chapter 13. Foundation Classes