1 /*
2    NSWindow.h
3 
4    The window class
5 
6    Copyright (C) 1996,1999,2004 Free Software Foundation, Inc.
7 
8    Author:  Scott Christley <scottc@net-community.com>
9    Date: 1996
10    Modified:  Felipe A. Rodriguez <far@ix.netcom.com>
11    Date: June 1998
12    Modified:  Richard Frith-Macdonald <richard@brainstorm.co.uk>
13    Date:  1998,1999
14    Author:  Quentin Mathe <qmathe@club-internet.fr>
15    Date: January 2004
16 
17    This file is part of the GNUstep GUI Library.
18 
19    This library is free software; you can redistribute it and/or
20    modify it under the terms of the GNU Lesser General Public
21    License as published by the Free Software Foundation; either
22    version 2 of the License, or (at your option) any later version.
23 
24    This library is distributed in the hope that it will be useful,
25    but WITHOUT ANY WARRANTY; without even the implied warranty of
26    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
27    Lesser General Public License for more details.
28 
29    You should have received a copy of the GNU Lesser General Public
30    License along with this library; see the file COPYING.LIB.
31    If not, see <http://www.gnu.org/licenses/> or write to the
32    Free Software Foundation, 51 Franklin Street, Fifth Floor,
33    Boston, MA 02110-1301, USA.
34 */
35 
36 #ifndef _GNUstep_H_NSWindow
37 #define _GNUstep_H_NSWindow
38 #import <GNUstepBase/GSVersionMacros.h>
39 
40 #import <AppKit/NSGraphicsContext.h>
41 #import <AppKit/NSResponder.h>
42 
43 @class NSArray;
44 @class NSData;
45 @class NSDate;
46 @class NSDictionary;
47 @class NSMutableArray;
48 @class NSNotification;
49 @class NSString;
50 @class NSUndoManager;
51 
52 @class NSButton;
53 @class NSButtonCell;
54 @class NSColor;
55 @class NSEvent;
56 @class NSImage;
57 @class NSMenu;
58 @class NSPasteboard;
59 @class NSScreen;
60 @class NSText;
61 @class NSToolbar;
62 @class NSView;
63 @class NSWindowController;
64 @class NSCachedImageRep;
65 
66 @class GSWindowDecorationView;
67 
68 /*
69  * Window levels are taken from MacOS-X
70  * NSDesktopWindowLevel is copied from Window maker and is intended to be
71  * the level at which things on the desktop sit ... so you should be able
72  * to put a desktop background just below it.
73  * FIXME: The hardcoded values here don't match the ones in Cocoa.
74  * But we cannot change them easily as the have to match the ones in Window maker.
75  */
76 enum {
77   NSDesktopWindowLevel = -1000,	/* GNUstep addition	*/ // 2
78   NSNormalWindowLevel = 0, // 3
79   NSFloatingWindowLevel = 2, // 4
80   NSSubmenuWindowLevel = 3, // 5
81   NSTornOffMenuWindowLevel = 3, // 5
82   NSMainMenuWindowLevel = 20, // 7
83   NSDockWindowLevel = 21,	/* Deprecated - use NSStatusWindowLevel */ // 6
84   NSStatusWindowLevel = 21, // 8
85   NSModalPanelWindowLevel = 100, // 9
86   NSPopUpMenuWindowLevel = 101,  // 10
87   NSScreenSaverWindowLevel = 1000  // 12
88 };
89 
90 #if OS_API_VERSION(MAC_OS_X_VERSION_10_9, GS_API_LATEST)
91 enum {
92   NSModalResponseOK = 1,
93   NSModalResponseCancel = 0
94 };
95 #endif
96 
97 enum {
98   NSBorderlessWindowMask = 0,
99   NSTitledWindowMask = 1,
100   NSClosableWindowMask = 1 << 1,
101   NSMiniaturizableWindowMask = 1 << 2,
102   NSResizableWindowMask = 1 << 3,
103 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
104   NSTexturedBackgroundWindowMask = 1 << 8,
105 #endif
106 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
107   NSUnscaledWindowMask = 1 << 11,
108   NSUnifiedTitleAndToolbarWindowMask = 1 << 12,
109 #endif
110 #if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
111   NSWindowStyleMaskHUDWindow = 1 << 13,
112 #endif
113 #if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
114   NSFullScreenWindowMask = 1 << 14,
115 #endif
116 #if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
117   NSFullSizeContentViewWindowMask = 1 << 15,
118 #endif
119 #if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
120   NSWindowStyleMaskBorderless = NSBorderlessWindowMask,
121   NSWindowStyleMaskTitled = NSTitledWindowMask,
122   NSWindowStyleMaskClosable = NSClosableWindowMask,
123   NSWindowStyleMaskMiniaturizable = NSMiniaturizableWindowMask,
124   NSWindowStyleMaskResizable = NSResizableWindowMask,
125   NSWindowStyleMaskUtilityWindow = 1 << 4,
126   NSWindowStyleMaskDocModalWindow = 1 << 6,
127   // Specifies that a panel that does not activate the owning application
128   NSWindowStyleMaskNonactivatingPanel = 1 << 7,
129   NSWindowStyleMaskTexturedBackground = NSTexturedBackgroundWindowMask,
130   NSWindowStyleMaskUnifiedTitleAndToolbar = NSUnifiedTitleAndToolbarWindowMask,
131   NSWindowStyleMaskFullScreen = NSFullScreenWindowMask,
132   NSWindowStyleMaskFullSizeContentView = NSFullSizeContentViewWindowMask,
133 #endif
134   NSIconWindowMask = 64,	/* GNUstep extension - app icon window	*/
135   NSMiniWindowMask = 128	/* GNUstep extension - miniwindows	*/
136 };
137 typedef NSUInteger NSWindowStyleMask;
138 
139 #if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
140 enum {
141   NSWindowCollectionBehaviorDefault = 0,
142   NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0,
143   NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1
144 };
145 #endif
146 #if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
147 enum {
148   NSWindowCollectionBehaviorManaged = 1 << 2,
149   NSWindowCollectionBehaviorTransient = 1 << 3,
150   NSWindowCollectionBehaviorStationary = 1 << 4,
151 };
152 enum {
153   NSWindowCollectionBehaviorParticipatesInCycle = 1 << 5,
154   NSWindowCollectionBehaviorIgnoresCycle = 1 << 6
155 };
156 #endif
157 #if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
158 enum {
159   NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
160   NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8
161 };
162 #endif
163 #if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
164 enum
165 {
166   NSWindowCollectionBehaviorFullScreenAllowsTiling = 1 << 11,
167   NSWindowCollectionBehaviorFullScreenDisallowsTiling = 1 << 12
168 };
169 #endif
170 typedef NSUInteger NSWindowCollectionBehavior;
171 
172 enum _NSSelectionDirection {
173   NSDirectSelection,
174   NSSelectingNext,
175   NSSelectingPrevious
176 };
177 typedef NSUInteger NSSelectionDirection;
178 
179 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
180 enum _NSWindowButton
181 {
182   NSWindowCloseButton = 0,
183   NSWindowMiniaturizeButton,
184   NSWindowZoomButton,
185   NSWindowToolbarButton,
186   NSWindowDocumentIconButton
187 };
188 typedef NSUInteger NSWindowButton;
189 #endif
190 
191 APPKIT_EXPORT NSSize NSIconSize;
192 APPKIT_EXPORT NSSize NSTokenSize;
193 
194 /**
195  * <p>An NSWindow instance represents a window, panel or menu on the
196  * screen.<br />
197  * Each window has a style, which determines how the window is decorated:
198  * ie whether it has a border, a title bar, a resize bar, minimise and
199  * close buttons.
200  * </p>
201  * <p>A window has a <em>frame</em>. This is the frame of the <em>entire</em>
202  * window on the screen, including all decorations and borders.  The origin
203  * of the frame represents its bottom left corner and the frame is expressed
204  * in screen coordinates (see [NSScreen]).
205  * </p>
206  * <p>When a window is created, it has a <em>private</em> [NSView] instance
207  * which fills the entire window frame and whose coordinate system is the
208  * same as the base coordinate system of the window (ie zero x and
209  * y coordinates are at the bottom left corner of the window, with increasing
210  * x and y corresponding to points to the right and above the origin).<br />
211  * This view may be used by the library internals (and theme engines) to
212  * draw window decorations if the backend library is not handling the
213  * window decorations.
214  * </p>
215  * <p>A window always contains a <em>content view</em> which is the highest
216  * level view available for public (application) use.  This view fills the
217  * area of the window inside any decoration/border.<br />
218  * This is the only part of the window that application programmers are
219  * allowed to draw in directly.
220  * </p>
221  * <p>You can convert between view coordinates and window base coordinates
222  * using the [NSView-convertPoint:fromView:], [NSView-convertPoint:toView:],
223  * [NSView-convertRect:fromView:], and [NSView-convertRect:toView:]
224  * methods with a nil view argument.<br />
225  * You can convert between window and screen coordinates using the
226  * -convertBaseToScreen: and -convertScreenToBase: methods.
227  * </p>
228  */
229 @interface NSWindow : NSResponder <NSCoding>
230 {
231   NSRect        _frame;
232   NSSize        _minimumSize;
233   NSSize        _maximumSize;
234   NSSize        _increments;
235   NSString	*_autosaveName;
236   GSWindowDecorationView *_wv;
237   id            _contentView;
238   id            _firstResponder;
239   id            _futureFirstResponder;
240   NSView        *_initialFirstResponder;
241 PACKAGE_SCOPE
242   id            _delegate;
243 @protected
244   id            _fieldEditor;
245   id            _lastLeftMouseDownView;
246   id            _lastRightMouseDownView;
247   id            _lastOtherMouseDownView;
248   id            _lastDragView;
249   NSInteger     _lastDragOperationMask;
250   NSInteger     _windowNum;
251   NSInteger     _gstate;
252   id            _defaultButtonCell;
253   NSGraphicsContext *_context;
254 
255   NSScreen      *_screen;
256   NSColor       *_backgroundColor;
257   NSString      *_representedFilename;
258   NSString      *_miniaturizedTitle;
259   NSImage       *_miniaturizedImage;
260   NSString      *_windowTitle;
261 PACKAGE_SCOPE
262   NSPoint       _lastPoint;
263 @protected
264   NSBackingStoreType _backingType;
265   NSUInteger    _styleMask;
266   NSInteger     _windowLevel;
267 PACKAGE_SCOPE
268   NSRect        _rectNeedingFlush;
269   NSMutableArray *_rectsBeingDrawn;
270 @protected
271   unsigned	_disableFlushWindow;
272 
273   NSWindowDepth _depthLimit;
274   NSWindowController *_windowController;
275   NSInteger     _counterpart;
276   CGFloat       _alphaValue;
277 
278   NSMutableArray *_children;
279   NSWindow       *_parent;
280   NSCachedImageRep *_cachedImage;
281   NSPoint        _cachedImageOrigin;
282   NSWindow       *_attachedSheet;
283 
284 PACKAGE_SCOPE
285   struct GSWindowFlagsType {
286     unsigned	accepts_drag:1;
287     unsigned	is_one_shot:1;
288     unsigned	needs_flush:1;
289     unsigned	is_autodisplay:1;
290     unsigned	optimize_drawing:1;
291     unsigned	dynamic_depth_limit:1;
292     unsigned	cursor_rects_enabled:1;
293     unsigned	cursor_rects_valid:1;
294     unsigned	visible:1;
295     unsigned	is_key:1;
296     unsigned	is_main:1;
297     unsigned	is_edited:1;
298     unsigned	is_released_when_closed:1;
299     unsigned	is_miniaturized:1;
300     unsigned	menu_exclude:1;
301     unsigned	hides_on_deactivate:1;
302     unsigned	accepts_mouse_moved:1;
303     unsigned	has_opened:1;
304     unsigned	has_closed:1;
305     unsigned	default_button_cell_key_disabled:1;
306     unsigned	can_hide:1;
307     unsigned	has_shadow:1;
308     unsigned	is_opaque:1;
309     unsigned	views_need_display:1;
310     // 3 bits reserved for subclass use
311     unsigned subclass_bool_one: 1;
312     unsigned subclass_bool_two: 1;
313     unsigned subclass_bool_three: 1;
314 
315     unsigned selectionDirection: 2;
316     unsigned displays_when_screen_profile_changes: 1;
317     unsigned is_movable_by_window_background: 1;
318     unsigned allows_tooltips_when_inactive: 1;
319 
320     // 4 used 28 available
321     unsigned shows_toolbar_button: 1;
322     unsigned autorecalculates_keyview_loop: 1;
323     unsigned ignores_mouse_events: 1;
324     unsigned preserves_content_during_live_resize: 1;
325   } _f;
326 @protected
327   NSToolbar     *_toolbar;
328   void          *_reserved_1;
329 }
330 
331 /*
332  * Class methods
333  */
334 
335 /*
336  * Computing frame and content rectangles
337  */
338 
339 /**
340  * Returns the rectangle which would be used for the content view of
341  * a window whose on-screen size and position is specified by aRect
342  * and which is decorated with the border and title etc given by aStyle.<br />
343  * Both rectangles are expressed in screen coordinates.
344  */
345 + (NSRect) contentRectForFrameRect: (NSRect)aRect
346 			 styleMask: (NSUInteger)aStyle;
347 
348 /**
349  * Returns the rectangle which would be used for the on-screen frame of
350  * a window if that window had a content view occupying the rectangle aRect
351  * and was decorated with the border and title etc given by aStyle.<br />
352  * Both rectangles are expressed in screen coordinates.
353  */
354 + (NSRect) frameRectForContentRect: (NSRect)aRect
355 			 styleMask: (NSUInteger)aStyle;
356 
357 /**
358  * Returns the smallest frame width that will fit the given title
359  * and style.  This is the on-screen width of the window including
360  * decorations.
361  */
362 + (CGFloat) minFrameWidthWithTitle: (NSString *)aTitle
363                          styleMask: (NSUInteger)aStyle;
364 
365 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
366 - (NSRect) contentRectForFrameRect: (NSRect)frameRect;
367 - (NSRect) frameRectForContentRect: (NSRect)contentRect;
368 #endif
369 /*
370  * Initializing and getting a new NSWindow object
371  */
372 - (id) initWithContentRect: (NSRect)contentRect
373 		 styleMask: (NSUInteger)aStyle
374 		   backing: (NSBackingStoreType)bufferingType
375 		     defer: (BOOL)flag;
376 
377 /**
378  * Creates a new window with the specified characteristics.<br />
379  * The contentRect is expressed in screen coordinates (for aScreen)
380  * and the window frame is calculated from the content rectangle and
381  * the window style mask.
382  */
383 - (id) initWithContentRect: (NSRect)contentRect
384 		 styleMask: (NSUInteger)aStyle
385 		   backing: (NSBackingStoreType)bufferingType
386 		     defer: (BOOL)flag
387 		    screen: (NSScreen*)aScreen;
388 
389 /**
390  * Converts aPoint from the base coordinate system of the receiver
391  * to a point in the screen coordinate system.
392  */
393 - (NSPoint) convertBaseToScreen: (NSPoint)aPoint;
394 
395 /**
396  * Converts aPoint from the screen coordinate system to a point in
397  * the base coordinate system of the receiver.
398  */
399 - (NSPoint) convertScreenToBase: (NSPoint)aPoint;
400 
401 /**
402  * Converts aRect from the coordinate system of the screen
403  * to the coordinate system of the window.
404  */
405 
406 - (NSRect) convertRectFromScreen: (NSRect)aRect;
407 
408 /**
409  * Converts aRect from the window coordinate system to a rect in
410  * the screen coordinate system.
411  */
412 - (NSRect) convertRectToScreen: (NSRect)aRect;
413 
414 /**
415  * Returns the frame of the receiver ... the rectangular area that the window
416  * (including any border, title, and other decorations) occupies on screen.
417  */
418 - (NSRect) frame;
419 
420 /**
421  * <p>Sets the frame for the receiver to frameRect and if flag is YES causes
422  * the window contents to be refreshed.  The value of frameRect is the
423  * desired on-screen size and position of the window including all
424  * border/decoration.
425  * </p>
426  * <p>The size of the frame is constrained to the minimum and maximum
427  * sizes set for the receiver (if any).<br />
428  * Its position is constrained to be on screen if it is a titled window.
429  * </p>
430  */
431 - (void) setFrame: (NSRect)frameRect
432 	  display: (BOOL)flag;
433 
434 /**
435  * Sets the origin (bottom left corner) of the receiver's frame to be the
436  * specified point (in screen coordinates).
437  */
438 - (void) setFrameOrigin: (NSPoint)aPoint;
439 
440 /**
441  * Sets the top left corner of the receiver's frame to be the
442  * specified point (in screen coordinates).
443  */
444 - (void) setFrameTopLeftPoint: (NSPoint)aPoint;
445 
446 /**
447  * Sets the size of the receiver's content view  to aSize, implicitly
448  * adjusting the size of the receiver's frame to match.
449  */
450 - (void) setContentSize: (NSSize)aSize;
451 
452 /**
453  * Positions the receiver at topLeftPoint (or if topLeftPoint is NSZeroPoint,
454  * leaves the receiver unmoved except for any necessary constraint to fit
455  * on screen).<br />
456  * Returns the position of the top left corner of the receivers content
457  * view (after repositioning), so that another window cascaded at the
458  * returned point will not obscure the title bar of the receiver.
459  */
460 - (NSPoint) cascadeTopLeftFromPoint: (NSPoint)topLeftPoint;
461 
462 - (void) center;
463 - (NSInteger) resizeFlags;
464 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
465 - (void) setFrame: (NSRect)frameRect
466 	  display: (BOOL)displayFlag
467 	  animate: (BOOL)animationFlag;
468 - (NSTimeInterval) animationResizeTime: (NSRect)newFrame;
469 - (void) performZoom: (id)sender;
470 - (void) zoom: (id)sender;
471 - (BOOL) isZoomed;
472 - (BOOL) showsResizeIndicator;
473 - (void) setShowsResizeIndicator: (BOOL)show;
474 #endif
475 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
476 - (BOOL) preservesContentDuringLiveResize;
477 - (void) setPreservesContentDuringLiveResize: (BOOL)flag;
478 #endif
479 
480 /*
481  * Constraining size
482  */
483 - (NSSize) minSize;
484 - (NSSize) maxSize;
485 - (void) setMinSize: (NSSize)aSize;
486 - (void) setMaxSize: (NSSize)aSize;
487 - (NSRect) constrainFrameRect: (NSRect)frameRect
488 		     toScreen: (NSScreen*)screen;
489 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
490 - (NSSize) aspectRatio;
491 - (void) setAspectRatio: (NSSize)ratio;
492 - (NSSize) resizeIncrements;
493 - (void) setResizeIncrements: (NSSize)aSize;
494 #endif
495 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
496 - (NSSize) contentMaxSize;
497 - (void) setContentMaxSize: (NSSize)size;
498 - (NSSize) contentMinSize;
499 - (void) setContentMinSize: (NSSize)size;
500 - (NSSize) contentAspectRatio;
501 - (void) setContentAspectRatio: (NSSize)ratio;
502 - (NSSize) contentResizeIncrements;
503 - (void) setContentResizeIncrements: (NSSize)increments;
504 #endif
505 
506 /*
507  * Saving and restoring the frame
508  */
509 + (void) removeFrameUsingName: (NSString*)name;
510 - (NSString*) frameAutosaveName;
511 - (void) saveFrameUsingName: (NSString*)name;
512 - (BOOL) setFrameAutosaveName: (NSString*)name;
513 - (void) setFrameFromString: (NSString*)string;
514 - (BOOL) setFrameUsingName: (NSString*)name;
515 - (NSString*) stringWithSavedFrame;
516 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
517 - (BOOL) setFrameUsingName: (NSString *)name
518 		     force: (BOOL)force;
519 #endif
520 
521 /*
522  * Window status and ordering
523  */
524 - (void) orderBack: sender;
525 - (void) orderFront: sender;
526 - (void) orderFrontRegardless;
527 - (void) orderOut: (id)sender;
528 - (void) orderWindow: (NSWindowOrderingMode)place
529 	  relativeTo: (NSInteger)otherWin;
530 - (BOOL) isVisible;
531 - (NSInteger) level;
532 - (void) setLevel: (NSInteger)newLevel;
533 
534 - (void) becomeKeyWindow;
535 - (void) becomeMainWindow;
536 - (BOOL) canBecomeKeyWindow;
537 - (BOOL) canBecomeMainWindow;
538 - (BOOL) isKeyWindow;
539 - (BOOL) isMainWindow;
540 - (void) makeKeyAndOrderFront: (id)sender;
541 - (void) makeKeyWindow;
542 - (void) makeMainWindow;
543 - (void) resignKeyWindow;
544 - (void) resignMainWindow;
545 
546 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
547 - (NSButtonCell*) defaultButtonCell;
548 - (void) setDefaultButtonCell: (NSButtonCell*)aCell;
549 - (void) disableKeyEquivalentForDefaultButtonCell;
550 - (void) enableKeyEquivalentForDefaultButtonCell;
551 #endif
552 
553 /*
554  * Managing the display
555  */
556 - (void) display;
557 - (void) displayIfNeeded;
558 - (BOOL) isAutodisplay;
559 - (void) setAutodisplay: (BOOL)flag;
560 - (void) setViewsNeedDisplay: (BOOL)flag;
561 - (void) update;
562 - (void) useOptimizedDrawing: (BOOL)flag;
563 - (BOOL) viewsNeedDisplay;
564 
565 - (BOOL) isFlushWindowDisabled;
566 - (void) disableFlushWindow;
567 - (void) enableFlushWindow;
568 - (void) flushWindow;
569 - (void) flushWindowIfNeeded;
570 
571 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
572 - (void) cacheImageInRect: (NSRect)aRect;
573 - (void) discardCachedImage;
574 - (void) restoreCachedImage;
575 #endif
576 
577 /*
578  * Window device attributes
579  */
580 - (NSInteger) windowNumber;
581 - (NSInteger) gState;
582 - (NSDictionary*) deviceDescription;
583 - (NSBackingStoreType) backingType;
584 - (void) setBackingType: (NSBackingStoreType)type;
585 - (BOOL) isOneShot;
586 - (void) setOneShot: (BOOL)flag;
587 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
588 - (NSGraphicsContext*) graphicsContext;
589 - (CGFloat) userSpaceScaleFactor;
590 #endif
591 
592 
593 /*
594  * Screens and window depths
595  */
596 + (NSWindowDepth) defaultDepthLimit;
597 - (BOOL) canStoreColor;
598 - (NSWindowDepth) depthLimit;
599 - (BOOL) hasDynamicDepthLimit;
600 - (void) setDepthLimit: (NSWindowDepth)limit;
601 - (void) setDynamicDepthLimit: (BOOL)flag;
602 
603 - (NSScreen*) deepestScreen;
604 - (NSScreen*) screen;
605 
606 - (NSResponder*) firstResponder;
607 
608 #if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
609 - (NSWindowCollectionBehavior)collectionBehavior;
610 - (void)setCollectionBehavior:(NSWindowCollectionBehavior)props;
611 #endif
612 
613 /**
614  * This method attempts to make aResponder the first responder.<br />
615  * If aResponder is already the first responder, this method has no
616  * effect and simply returns YES.
617  * Otherwise, the method sends a -resignFirstResponder message to the
618  * current first responder (if there is one) and immediately returns NO if
619  * the current first responder refuses to resign.<br />
620  * Then the method asks aResponder to become first responder by sending
621  * it a -becomeFirstResponder message, and if that returns YES then this
622  * method immediately returns YES.<br />
623  * However, if that returns NO, the receiver is made the first responder by
624  * sending it a -becomeFirstResponder message, and this method returns NO.<br />
625  * If aResponder is neither nil nor an instance of NSResponder (or of a
626  * subclass of NSResponder) then behavior is undefined (though the current
627  * GNUstep implementation just returns NO).
628  */
629 - (BOOL) makeFirstResponder: (NSResponder*)aResponder;
630 
631 /*
632  * Aiding event handling
633  */
634 - (NSEvent*) currentEvent;
635 - (NSEvent*) nextEventMatchingMask: (NSUInteger)mask;
636 - (NSEvent*) nextEventMatchingMask: (NSUInteger)mask
637 			 untilDate: (NSDate*)expiration
638 			    inMode: (NSString*)mode
639 			   dequeue: (BOOL)deqFlag;
640 - (void) discardEventsMatchingMask: (NSUInteger)mask
641 		       beforeEvent: (NSEvent*)lastEvent;
642 - (void) postEvent: (NSEvent*)event
643 	   atStart: (BOOL)flag;
644 - (void) sendEvent: (NSEvent*)theEvent;
645 - (BOOL) tryToPerform: (SEL)anAction with: (id)anObject;
646 - (void) keyDown: (NSEvent*)theEvent;
647 - (NSPoint) mouseLocationOutsideOfEventStream;
648 - (BOOL) acceptsMouseMovedEvents;
649 - (void) setAcceptsMouseMovedEvents: (BOOL)flag;
650 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
651 - (BOOL) ignoresMouseEvents;
652 - (void) setIgnoresMouseEvents: (BOOL)flag;
653 #endif
654 
655 /*
656  * The field editor
657  */
658 - (void) endEditingFor: anObject;
659 - (NSText*) fieldEditor: (BOOL)createFlag
660 	      forObject: (id)anObject;
661 
662 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
663 - (NSView*) initialFirstResponder;
664 - (NSSelectionDirection) keyViewSelectionDirection;
665 - (void) selectKeyViewFollowingView: (NSView*)aView;
666 - (void) selectKeyViewPrecedingView: (NSView*)aView;
667 - (void) selectNextKeyView: (id)sender;
668 - (void) selectPreviousKeyView: (id)sender;
669 - (void) setInitialFirstResponder: (NSView*)aView;
670 #endif
671 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
672 - (BOOL) autorecalculatesKeyViewLoop;
673 - (void) setAutorecalculatesKeyViewLoop: (BOOL)flag;
674 - (void) recalculateKeyViewLoop;
675 #endif
676 
677 /*
678  * Window graphics
679  */
680 - (NSString*) representedFilename;
681 - (void) setRepresentedFilename: (NSString*)aString;
682 - (void) setTitle: (NSString*)aString;
683 - (void) setTitleWithRepresentedFilename: (NSString*)aString;
684 - (NSString*) title;
685 
686 - (BOOL) isDocumentEdited;
687 - (void) setDocumentEdited: (BOOL)flag;
688 
689 /*
690  * Handling user actions and events
691  */
692 - (void) close;
693 - (void) performClose: (id)sender;
694 - (void) setReleasedWhenClosed: (BOOL)flag;
695 - (BOOL) isReleasedWhenClosed;
696 
697 - (void) deminiaturize: (id)sender;
698 - (void) miniaturize: (id)sender;
699 - (void) performMiniaturize: (id)sender;
700 - (BOOL) isMiniaturized;
701 
702 /*
703  * The miniwindow
704  */
705 - (NSImage*) miniwindowImage;
706 - (NSString*) miniwindowTitle;
707 - (void) setMiniwindowImage: (NSImage*)image;
708 - (void) setMiniwindowTitle: (NSString*)title;
709 #if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
710 - (NSWindow*) counterpart;
711 #endif
712 
713 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
714 + (void) menuChanged: (NSMenu*)aMenu;
715 #endif
716 
717 /*
718  * Windows menu support
719  */
720 - (BOOL) isExcludedFromWindowsMenu;
721 - (void) setExcludedFromWindowsMenu: (BOOL)flag;
722 
723 /*
724  * Cursor management
725  */
726 - (BOOL) areCursorRectsEnabled;
727 - (void) disableCursorRects;
728 - (void) discardCursorRects;
729 - (void) enableCursorRects;
730 - (void) invalidateCursorRectsForView: (NSView*)aView;
731 - (void) resetCursorRects;
732 
733 /*
734  * Dragging
735  */
736 - (void) dragImage: (NSImage*)anImage
737 		at: (NSPoint)baseLocation
738 	    offset: (NSSize)initialOffset
739 	     event: (NSEvent*)event
740 	pasteboard: (NSPasteboard*)pboard
741 	    source: sourceObject
742 	 slideBack: (BOOL)slideFlag;
743 - (void) registerForDraggedTypes: (NSArray*)newTypes;
744 - (void) unregisterDraggedTypes;
745 
746 - (BOOL) hidesOnDeactivate;
747 - (void) setHidesOnDeactivate: (BOOL)flag;
748 - (BOOL) worksWhenModal;
749 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
750 - (void) setCanHide: (BOOL)flag;
751 - (BOOL) canHide;
752 #endif
753 
754 /*
755  * Accessing the content view
756  */
757 - (id) contentView;
758 - (void) setContentView: (NSView*)aView;
759 - (void) setBackgroundColor: (NSColor*)color;
760 - (NSColor*) backgroundColor;
761 - (NSUInteger) styleMask;
762 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
763 - (void) setHasShadow: (BOOL)hasShadow;
764 - (BOOL) hasShadow;
765 - (void) setAlphaValue: (CGFloat)windowAlpha;
766 - (CGFloat) alphaValue;
767 - (void) setOpaque: (BOOL)isOpaque;
768 - (BOOL) isOpaque;
769 #endif
770 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
771 - (void) invalidateShadow;
772 #endif
773 
774 /*
775  * Services menu support
776  */
777 - (id) validRequestorForSendType: (NSString*)sendType
778 		      returnType: (NSString*)returnType;
779 
780 /*
781  * Printing and postscript
782  */
783 - (void) fax: (id)sender;
784 - (void) print: (id)sender;
785 - (NSData*) dataWithEPSInsideRect: (NSRect)rect;
786 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
787 - (NSData*) dataWithPDFInsideRect:(NSRect)aRect;
788 #endif
789 
790 /*
791  * Assigning a delegate
792  */
793 - (id) delegate;
794 - (void) setDelegate: (id)anObject;
795 
796 /*
797  * The window controller
798  */
799 - (void) setWindowController: (NSWindowController*)windowController;
800 - (id) windowController;
801 
802 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
803 - (NSArray *) drawers;
804 - (id) initWithWindowRef: (void *)windowRef;
805 - (void *)windowRef;
806 - (void*) windowHandle;
807 #endif
808 
809 /*
810  * Window buttons
811  */
812 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
813 + (NSButton *) standardWindowButton: (NSWindowButton)button
814                        forStyleMask: (NSUInteger) mask;
815 - (NSButton *) standardWindowButton: (NSWindowButton)button;
816 #endif
817 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
818 - (BOOL) showsToolbarButton;
819 - (void) setShowsToolbarButton: (BOOL)flag;
820 #endif
821 
822 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
823 - (NSArray *) childWindows;
824 - (void) addChildWindow: (NSWindow *)child
825                 ordered: (NSWindowOrderingMode)place;
826 - (void) removeChildWindow: (NSWindow *)child;
827 - (NSWindow *) parentWindow;
828 - (void) setParentWindow: (NSWindow *)window;
829 #endif
830 
831 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
832 - (BOOL) allowsToolTipsWhenApplicationIsInactive;
833 - (void) setAllowsToolTipsWhenApplicationIsInactive: (BOOL)flag;
834 #endif
835 
836 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
837 - (BOOL) isMovableByWindowBackground;
838 - (void) setMovableByWindowBackground: (BOOL)flag;
839 #endif
840 
841 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
842 - (BOOL) displaysWhenScreenProfileChanges;
843 - (void) setDisplaysWhenScreenProfileChanges: (BOOL)flag;
844 #endif
845 
846 #if OS_API_VERSION(MAC_OS_X_VERSION_10_9, GS_API_LATEST)
847 #if GS_HAS_DECLARED_PROPERTIES
848 @property (readonly) NSWindow *sheetParent;
849 #else
850 - (NSWindow *) sheetParent;
851 #endif
852 #endif
853 
854 #if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
855 #if GS_HAS_DECLARED_PROPERTIES
856 @property (readonly) CGFloat backingScaleFactor;
857 #else
858 - (CGFloat) backingScaleFactor;
859 #endif
860 #endif
861 
862 #if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
863 + (NSInteger)windowNumberAtPoint:(NSPoint)point
864      belowWindowWithWindowNumber:(NSInteger)windowNumber;
865 #endif
866 
867 @end
868 
869 @class NSToolbar;
870 
871 @interface NSWindow (Toolbar)
872 - (void) runToolbarCustomizationPalette: (id)sender;
873 - (void) toggleToolbarShown: (id)sender;
874 - (NSToolbar *) toolbar;
875 - (void) setToolbar: (NSToolbar*)toolbar;
876 @end
877 
878 #if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
879 /*
880  * GNUstep backend methods
881  */
882 @interface NSWindow (GNUstepBackend)
883 
884 /*
885  * Mouse capture/release
886  */
887 - (void) _captureMouse: (id)sender;
888 - (void) _releaseMouse: (id)sender;
889 
890 /*
891  * Allow subclasses to init without the backend class
892  * attempting to create an actual window
893  */
894 - (void) _initDefaults;
895 
896 /*
897  * Let backend set window visibility.
898  */
899 - (void) _setVisible: (BOOL)flag;
900 
901 @end
902 #endif
903 
904 #if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
905 @interface NSWindow (GNUstepTextView)
906 /*
907  * Called from NSTextView's resignFirstResponder to know which is
908  * the next first responder.
909  */
910 - (id) _futureFirstResponder;
911 @end
912 #endif
913 
914 /*
915  * Implemented by the delegate
916  */
917 
918 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
919 @protocol NSWindowDelegate <NSObject>
920 #if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL
921 @optional
922 #else
923 @end
924 @interface NSObject (NSWindowDelegate)
925 #endif
926 
927 - (BOOL) windowShouldClose: (id)sender;
928 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
929 - (void) windowWillBeginSheet: (NSNotification*)aNotification;
930 - (void) windowDidEndSheet: (NSNotification*)aNotification;
931 - (BOOL) windowShouldZoom: (NSWindow*)sender
932                   toFrame: (NSRect)aFrame;
933 - (NSUndoManager*) windowWillReturnUndoManager: (NSWindow*)sender;
934 - (NSRect) windowWillUseStandardFrame: (NSWindow*)sender
935                          defaultFrame: (NSRect)aFrame;
936 #endif
937 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
938 - (NSRect) window: (NSWindow *)window
939 willPositionSheet: (NSWindow *)sheet
940         usingRect: (NSRect)rect;
941 #endif
942 - (NSSize) windowWillResize: (NSWindow*)sender
943 		     toSize: (NSSize)frameSize;
944 - (id) windowWillReturnFieldEditor: (NSWindow*)sender
945 			  toObject: (id)client;
946 - (void) windowDidBecomeKey: (NSNotification*)aNotification;
947 - (void) windowDidBecomeMain: (NSNotification*)aNotification;
948 - (void) windowDidChangeScreen: (NSNotification*)aNotification;
949 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
950 - (void) windowDidChangeScreenProfile: (NSNotification *)aNotification;
951 #endif
952 - (void) windowDidDeminiaturize: (NSNotification*)aNotification;
953 - (void) windowDidExpose: (NSNotification*)aNotification;
954 - (void) windowDidMiniaturize: (NSNotification*)aNotification;
955 - (void) windowDidMove: (NSNotification*)aNotification;
956 - (void) windowDidResignKey: (NSNotification*)aNotification;
957 - (void) windowDidResignMain: (NSNotification*)aNotification;
958 - (void) windowDidResize: (NSNotification*)aNotification;
959 - (void) windowDidUpdate: (NSNotification*)aNotification;
960 - (void) windowWillClose: (NSNotification*)aNotification;
961 - (void) windowWillMiniaturize: (NSNotification*)aNotification;
962 - (void) windowWillMove: (NSNotification*)aNotification;
963 @end
964 #endif
965 
966 @interface NSObject (NSWindowDelegateAdditions) <NSWindowDelegate>
967 #if OS_API_VERSION(MAC_OS_X_VERSION_10_1, GS_API_LATEST)
968 - (NSWindow *) attachedSheet;
969 #endif
970 @end
971 
972 /* Notifications */
973 APPKIT_EXPORT NSString *NSWindowDidBecomeKeyNotification;
974 APPKIT_EXPORT NSString *NSWindowDidBecomeMainNotification;
975 APPKIT_EXPORT NSString *NSWindowDidChangeScreenNotification;
976 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
977 APPKIT_EXPORT NSString *NSWindowDidChangeScreenProfileNotification;
978 #endif
979 APPKIT_EXPORT NSString *NSWindowDidDeminiaturizeNotification;
980 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
981 APPKIT_EXPORT NSString *NSWindowDidEndSheetNotification;
982 #endif
983 APPKIT_EXPORT NSString *NSWindowDidExposeNotification;
984 APPKIT_EXPORT NSString *NSWindowDidMiniaturizeNotification;
985 APPKIT_EXPORT NSString *NSWindowDidMoveNotification;
986 APPKIT_EXPORT NSString *NSWindowDidResignKeyNotification;
987 APPKIT_EXPORT NSString *NSWindowDidResignMainNotification;
988 APPKIT_EXPORT NSString *NSWindowDidResizeNotification;
989 APPKIT_EXPORT NSString *NSWindowDidUpdateNotification;
990 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
991 APPKIT_EXPORT NSString *NSWindowWillBeginSheetNotification;
992 #endif
993 APPKIT_EXPORT NSString *NSWindowWillCloseNotification;
994 APPKIT_EXPORT NSString *NSWindowWillMiniaturizeNotification;
995 APPKIT_EXPORT NSString *NSWindowWillMoveNotification;
996 
997 #endif /* _GNUstep_H_NSWindow */
998