2001-12-17 16:51:51 +00:00
|
|
|
|
/** <title>NSWindow</title>
|
|
|
|
|
|
|
|
|
|
<abstract>The window class</abstract>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2015-08-28 22:39:48 +00:00
|
|
|
|
Copyright (C) 1996-2015 Free Software Foundation, Inc.
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
2007-09-09 12:19:01 +00:00
|
|
|
|
Venkat Ajjanagadde <venkat@ocbi.com>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
Date: 1996
|
2001-12-17 16:51:51 +00:00
|
|
|
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
1998-07-10 18:44:18 +00:00
|
|
|
|
Date: June 1998
|
2001-12-17 16:51:51 +00:00
|
|
|
|
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
1999-02-19 20:31:07 +00:00
|
|
|
|
Date: December 1998
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1996-05-30 20:03:15 +00:00
|
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 21:16:17 +00:00
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Lesser General Public License for more details.
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA.
|
1998-12-17 13:06:17 +00:00
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2010-05-24 10:48:14 +00:00
|
|
|
|
#import "config.h"
|
2005-05-20 14:33:43 +00:00
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <float.h>
|
1998-11-12 10:49:00 +00:00
|
|
|
|
|
2011-07-24 18:53:07 +00:00
|
|
|
|
#import <Foundation/NSArray.h>
|
2010-05-24 10:48:14 +00:00
|
|
|
|
#import <Foundation/NSDebug.h>
|
|
|
|
|
#import <Foundation/NSRunLoop.h>
|
|
|
|
|
#import <Foundation/NSScanner.h>
|
|
|
|
|
#import <Foundation/NSAutoreleasePool.h>
|
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
|
#import <Foundation/NSCoder.h>
|
|
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
|
#import <Foundation/NSEnumerator.h>
|
|
|
|
|
#import <Foundation/NSGeometry.h>
|
|
|
|
|
#import <Foundation/NSNotification.h>
|
|
|
|
|
#import <Foundation/NSValue.h>
|
|
|
|
|
#import <Foundation/NSException.h>
|
|
|
|
|
#import <Foundation/NSSet.h>
|
|
|
|
|
#import <Foundation/NSLock.h>
|
|
|
|
|
#import <Foundation/NSUserDefaults.h>
|
|
|
|
|
#import <Foundation/NSUndoManager.h>
|
|
|
|
|
|
2011-07-24 18:53:07 +00:00
|
|
|
|
#import "AppKit/NSAnimation.h"
|
2010-05-24 10:48:14 +00:00
|
|
|
|
#import "AppKit/NSApplication.h"
|
|
|
|
|
#import "AppKit/NSButton.h"
|
|
|
|
|
#import "AppKit/NSButtonCell.h"
|
|
|
|
|
#import "AppKit/NSCachedImageRep.h"
|
|
|
|
|
#import "AppKit/NSColor.h"
|
|
|
|
|
#import "AppKit/NSColorList.h"
|
|
|
|
|
#import "AppKit/NSCursor.h"
|
|
|
|
|
#import "AppKit/NSDocumentController.h"
|
|
|
|
|
#import "AppKit/NSDocument.h"
|
|
|
|
|
#import "AppKit/NSDragging.h"
|
|
|
|
|
#import "AppKit/NSEvent.h"
|
|
|
|
|
#import "AppKit/NSFont.h"
|
|
|
|
|
#import "AppKit/NSGraphics.h"
|
|
|
|
|
#import "AppKit/NSHelpManager.h"
|
|
|
|
|
#import "AppKit/NSKeyValueBinding.h"
|
|
|
|
|
#import "AppKit/NSImage.h"
|
|
|
|
|
#import "AppKit/NSMenu.h"
|
|
|
|
|
#import "AppKit/NSPasteboard.h"
|
|
|
|
|
#import "AppKit/NSScreen.h"
|
|
|
|
|
#import "AppKit/NSTextField.h"
|
|
|
|
|
#import "AppKit/NSTextFieldCell.h"
|
|
|
|
|
#import "AppKit/NSView.h"
|
|
|
|
|
#import "AppKit/NSWindow.h"
|
|
|
|
|
#import "AppKit/NSWindowController.h"
|
|
|
|
|
#import "AppKit/PSOperators.h"
|
2011-07-11 08:40:31 +00:00
|
|
|
|
|
2010-05-24 10:48:14 +00:00
|
|
|
|
#import "GNUstepGUI/GSTheme.h"
|
|
|
|
|
#import "GNUstepGUI/GSTrackingRect.h"
|
|
|
|
|
#import "GNUstepGUI/GSDisplayServer.h"
|
2011-07-11 08:40:31 +00:00
|
|
|
|
#import "GNUstepGUI/GSWindowDecorationView.h"
|
|
|
|
|
#import "GSBindingHelpers.h"
|
2010-05-24 10:48:14 +00:00
|
|
|
|
#import "GSGuiPrivate.h"
|
|
|
|
|
#import "GSToolTips.h"
|
|
|
|
|
#import "GSIconManager.h"
|
|
|
|
|
#import "NSToolbarFrameworkPrivate.h"
|
2012-10-04 09:20:08 +00:00
|
|
|
|
#import "NSViewPrivate.h"
|
2010-05-24 10:48:14 +00:00
|
|
|
|
|
2009-02-04 22:43:26 +00:00
|
|
|
|
#define GSI_ARRAY_TYPES 0
|
|
|
|
|
#define GSI_ARRAY_TYPE NSWindow *
|
|
|
|
|
#define GSI_ARRAY_NO_RELEASE 1
|
|
|
|
|
#define GSI_ARRAY_NO_RETAIN 1
|
|
|
|
|
|
|
|
|
|
#ifdef GSIArray
|
|
|
|
|
#undef GSIArray
|
|
|
|
|
#endif
|
|
|
|
|
#include <GNUstepBase/GSIArray.h>
|
|
|
|
|
|
2008-12-28 15:16:05 +00:00
|
|
|
|
static GSToolTips *toolTipVisible = nil;
|
|
|
|
|
static id<GSWindowDecorator> windowDecorator = nil;
|
2004-07-06 20:20:31 +00:00
|
|
|
|
|
|
|
|
|
|
1999-07-29 20:58:04 +00:00
|
|
|
|
BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
1998-11-25 17:16:48 +00:00
|
|
|
|
|
2001-12-21 00:45:48 +00:00
|
|
|
|
@interface NSObject (DragInfoBackend)
|
|
|
|
|
- (void) dragImage: (NSImage*)anImage
|
2007-09-09 12:19:01 +00:00
|
|
|
|
at: (NSPoint)screenLocation
|
|
|
|
|
offset: (NSSize)initialOffset
|
|
|
|
|
event: (NSEvent*)event
|
|
|
|
|
pasteboard: (NSPasteboard*)pboard
|
|
|
|
|
source: (id)sourceObject
|
|
|
|
|
slideBack: (BOOL)slideFlag;
|
2001-12-21 00:45:48 +00:00
|
|
|
|
- (void) postDragEvent: (NSEvent*)event;
|
|
|
|
|
@end
|
|
|
|
|
|
2008-02-11 11:37:29 +00:00
|
|
|
|
@interface NSView (MoveToWindow)
|
|
|
|
|
// Normally this method is only used internally.
|
|
|
|
|
- (void) _viewWillMoveToWindow: (NSWindow*)newWindow;
|
|
|
|
|
@end
|
|
|
|
|
|
2008-04-27 22:44:12 +00:00
|
|
|
|
@interface NSScreen (PrivateMethods)
|
|
|
|
|
- (id) _initWithScreenNumber: (int)screen;
|
|
|
|
|
@end
|
|
|
|
|
|
2011-05-31 09:59:48 +00:00
|
|
|
|
@interface NSApplication(Inactive)
|
|
|
|
|
- (BOOL) _isWindowInactive: (NSWindow *)window;
|
|
|
|
|
- (void) _setWindow: (NSWindow *)window inactive: (BOOL)inactive;
|
|
|
|
|
@end
|
|
|
|
|
|
2011-07-24 18:53:07 +00:00
|
|
|
|
@interface GSWindowAnimationDelegate : NSObject
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation GSWindowAnimationDelegate
|
|
|
|
|
- (void) animationDidEnd: (NSAnimation *)animation
|
|
|
|
|
{
|
|
|
|
|
AUTORELEASE(animation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) animationDidStop: (NSAnimation *)animation
|
|
|
|
|
{
|
|
|
|
|
AUTORELEASE(animation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
static GSWindowAnimationDelegate *animationDelegate;
|
2008-04-27 22:44:12 +00:00
|
|
|
|
|
2000-03-06 11:39:22 +00:00
|
|
|
|
/*
|
2004-05-23 18:39:07 +00:00
|
|
|
|
* Category for internal methods (for use only within the NSWindow class itself
|
2006-10-02 19:22:22 +00:00
|
|
|
|
* or with other AppKit classes.
|
2000-03-06 11:39:22 +00:00
|
|
|
|
*/
|
2007-09-09 12:19:01 +00:00
|
|
|
|
@interface NSWindow (GNUstepPrivate)
|
2006-10-02 19:22:22 +00:00
|
|
|
|
|
|
|
|
|
+ (void) _addAutodisplayedWindow: (NSWindow *)w;
|
|
|
|
|
+ (void) _removeAutodisplayedWindow: (NSWindow *)w;
|
|
|
|
|
+ (void) _setToolTipVisible: (GSToolTips*)t;
|
|
|
|
|
+ (GSToolTips*) _toolTipVisible;
|
2004-07-12 23:19:14 +00:00
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
- (void) _lossOfKeyOrMainWindow;
|
2004-05-23 18:39:07 +00:00
|
|
|
|
- (NSView *) _windowView;
|
2012-08-17 13:16:12 +00:00
|
|
|
|
- (NSScreen *) _screenForFrame: (NSRect)frame;
|
2000-03-06 11:39:22 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
@implementation NSWindow (GNUstepPrivate)
|
2003-04-06 18:03:33 +00:00
|
|
|
|
|
2006-10-02 19:22:22 +00:00
|
|
|
|
+ (void) _setToolTipVisible: (GSToolTips*)t
|
|
|
|
|
{
|
|
|
|
|
toolTipVisible = t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (GSToolTips*) _toolTipVisible
|
|
|
|
|
{
|
|
|
|
|
return toolTipVisible;
|
|
|
|
|
}
|
2004-07-12 23:19:14 +00:00
|
|
|
|
|
|
|
|
|
/* Window autodisplay machinery. */
|
|
|
|
|
- (void) _handleAutodisplay
|
|
|
|
|
{
|
2007-03-08 12:52:01 +00:00
|
|
|
|
if (_f.is_autodisplay && _f.views_need_display)
|
2004-07-12 23:19:14 +00:00
|
|
|
|
{
|
|
|
|
|
[self disableFlushWindow];
|
|
|
|
|
[self displayIfNeeded];
|
|
|
|
|
[self enableFlushWindow];
|
|
|
|
|
[self flushWindowIfNeeded];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NSArray *modes = nil;
|
|
|
|
|
|
|
|
|
|
/* Array of windows we might need to handle autodisplay for (in practice
|
|
|
|
|
a list of windows that are, wrt. -gui, on-screen). */
|
|
|
|
|
static GSIArray_t autodisplayedWindows;
|
|
|
|
|
|
2003-04-06 18:03:33 +00:00
|
|
|
|
/*
|
|
|
|
|
This method handles all normal displaying. It is set to be run on each
|
2004-07-12 23:19:14 +00:00
|
|
|
|
runloop iteration when the first window is created
|
2003-04-06 18:03:33 +00:00
|
|
|
|
|
|
|
|
|
The reason why this performer is always added, as opposed to adding it
|
|
|
|
|
when display is needed and not re-adding it here, is that
|
|
|
|
|
-setNeedsDisplay* might be called from a method invoked by
|
|
|
|
|
-performSelector:target:argument:order:modes:, and if it is, the display
|
|
|
|
|
needs to happen in the same runloop iteration, before blocking for
|
|
|
|
|
events. If the performer were added in a call to another performer, it
|
|
|
|
|
wouldn't be called until the next runloop iteration, ie. after the runloop
|
|
|
|
|
has blocked and waited for events.
|
|
|
|
|
*/
|
2004-07-12 23:19:14 +00:00
|
|
|
|
+(void) _handleAutodisplay: (id)bogus
|
2000-03-06 11:39:22 +00:00
|
|
|
|
{
|
2004-07-12 23:19:14 +00:00
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < GSIArrayCount(&autodisplayedWindows); i++)
|
|
|
|
|
[GSIArrayItemAtIndex(&autodisplayedWindows, i).ext _handleAutodisplay];
|
|
|
|
|
|
2003-04-06 18:03:33 +00:00
|
|
|
|
[[NSRunLoop currentRunLoop]
|
2007-09-09 12:19:01 +00:00
|
|
|
|
performSelector: @selector(_handleAutodisplay:)
|
|
|
|
|
target: self
|
|
|
|
|
argument: nil
|
|
|
|
|
order: 600000
|
|
|
|
|
modes: modes];
|
2004-07-12 23:19:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+(void) _addAutodisplayedWindow: (NSWindow *)w
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
/* If it's the first time we're called, set up the performer and modes
|
|
|
|
|
array. */
|
|
|
|
|
if (!modes)
|
|
|
|
|
{
|
|
|
|
|
modes = [[NSArray alloc] initWithObjects: NSDefaultRunLoopMode,
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSModalPanelRunLoopMode,
|
|
|
|
|
NSEventTrackingRunLoopMode, nil];
|
2004-07-12 23:19:14 +00:00
|
|
|
|
[[NSRunLoop currentRunLoop]
|
2007-09-09 12:19:01 +00:00
|
|
|
|
performSelector: @selector(_handleAutodisplay:)
|
|
|
|
|
target: self
|
|
|
|
|
argument: nil
|
|
|
|
|
order: 600000
|
|
|
|
|
modes: modes];
|
2004-07-12 23:19:14 +00:00
|
|
|
|
GSIArrayInitWithZoneAndCapacity(&autodisplayedWindows,
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSDefaultMallocZone(), 1);
|
2004-07-12 23:19:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* O(n), but it's much more important that _handleAutodisplay: can iterate
|
|
|
|
|
quickly over the array. (_handleAutodisplay: is called once for every
|
|
|
|
|
event, this method is only called when windows are ordered in or out.) */
|
|
|
|
|
for (i = 0; i < GSIArrayCount(&autodisplayedWindows); i++)
|
|
|
|
|
if (GSIArrayItemAtIndex(&autodisplayedWindows, i).ext == w)
|
|
|
|
|
return;
|
|
|
|
|
GSIArrayAddItem(&autodisplayedWindows, (GSIArrayItem)w);
|
2000-03-06 11:39:22 +00:00
|
|
|
|
}
|
2002-10-20 01:48:55 +00:00
|
|
|
|
|
2004-07-12 23:19:14 +00:00
|
|
|
|
+(void) _removeAutodisplayedWindow: (NSWindow *)w
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < GSIArrayCount(&autodisplayedWindows); i++)
|
|
|
|
|
if (GSIArrayItemAtIndex(&autodisplayedWindows, i).ext == w)
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
GSIArrayRemoveItemAtIndex(&autodisplayedWindows, i);
|
|
|
|
|
return;
|
2004-07-12 23:19:14 +00:00
|
|
|
|
}
|
|
|
|
|
/* This happens eg. if a window is ordered out twice. In such cases,
|
|
|
|
|
the window has already been removed from the list, so we don't need
|
|
|
|
|
to do anything here. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-10-20 01:48:55 +00:00
|
|
|
|
/* We get here if we were ordered out or miniaturized. In this case if
|
|
|
|
|
we were the key or main window, go through the list of all windows
|
|
|
|
|
and try to find another window that can take our place as key
|
|
|
|
|
and/or main. Automatically ignore windows that cannot become
|
|
|
|
|
key/main and skip the main menu window (which is the only
|
|
|
|
|
non-obvious window that can become key) unless we have no choice
|
|
|
|
|
(i.e. all the candidate windows were ordered out.)
|
|
|
|
|
*/
|
2000-03-08 21:26:11 +00:00
|
|
|
|
- (void) _lossOfKeyOrMainWindow
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSArray *windowList = GSOrderedWindows();
|
2011-12-17 17:16:09 +00:00
|
|
|
|
NSUInteger pos = [windowList indexOfObjectIdenticalTo: self];
|
|
|
|
|
NSUInteger c = [windowList count];
|
|
|
|
|
NSUInteger i;
|
2007-08-28 22:01:29 +00:00
|
|
|
|
|
|
|
|
|
// Don't bother when application is closing.
|
|
|
|
|
if ([NSApp isRunning] == NO)
|
|
|
|
|
return;
|
2000-03-08 21:26:11 +00:00
|
|
|
|
|
2007-02-21 23:18:01 +00:00
|
|
|
|
if (!c)
|
|
|
|
|
return;
|
|
|
|
|
|
2007-08-28 22:01:29 +00:00
|
|
|
|
if (pos == NSNotFound)
|
2007-02-21 23:18:01 +00:00
|
|
|
|
{
|
2007-08-28 22:01:29 +00:00
|
|
|
|
pos = c;
|
2007-02-21 23:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
if ([self isKeyWindow])
|
|
|
|
|
{
|
2007-08-28 22:01:29 +00:00
|
|
|
|
NSWindow *w = [NSApp mainWindow];
|
2007-02-21 23:18:01 +00:00
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[self resignKeyWindow];
|
2007-08-28 22:01:29 +00:00
|
|
|
|
if (w != nil && w != self
|
|
|
|
|
&& [w canBecomeKeyWindow])
|
|
|
|
|
{
|
|
|
|
|
[w makeKeyWindow];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSWindow *menu_window = [[NSApp mainMenu] window];
|
2007-02-21 23:18:01 +00:00
|
|
|
|
|
2007-08-28 22:01:29 +00:00
|
|
|
|
// try all windows front to back except self and menu
|
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i != pos)
|
|
|
|
|
{
|
|
|
|
|
w = [windowList objectAtIndex: i];
|
|
|
|
|
if ([w isVisible] && [w canBecomeKeyWindow]
|
|
|
|
|
&& w != menu_window)
|
|
|
|
|
{
|
|
|
|
|
[w makeKeyWindow];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* if we didn't find a possible key window - use the main menu window
|
|
|
|
|
*/
|
|
|
|
|
if (i == c)
|
|
|
|
|
{
|
|
|
|
|
if (menu_window != nil)
|
|
|
|
|
{
|
|
|
|
|
// FIXME: Why this call and not makeKeyWindow?
|
|
|
|
|
[GSServerForWindow(menu_window) setinputfocus:
|
|
|
|
|
[menu_window windowNumber]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-03-08 21:26:11 +00:00
|
|
|
|
}
|
2007-08-28 22:01:29 +00:00
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
if ([self isMainWindow])
|
|
|
|
|
{
|
2007-08-28 22:01:29 +00:00
|
|
|
|
NSWindow *w = [NSApp keyWindow];
|
2000-03-08 21:26:11 +00:00
|
|
|
|
|
|
|
|
|
[self resignMainWindow];
|
|
|
|
|
if (w != nil && [w canBecomeMainWindow])
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
[w makeMainWindow];
|
|
|
|
|
}
|
2000-03-08 21:26:11 +00:00
|
|
|
|
else
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
// try all windows front to back except self
|
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i != pos)
|
|
|
|
|
{
|
|
|
|
|
w = [windowList objectAtIndex: i];
|
|
|
|
|
if ([w isVisible] && [w canBecomeMainWindow])
|
|
|
|
|
{
|
|
|
|
|
[w makeMainWindow];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-03-08 21:26:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-23 18:39:07 +00:00
|
|
|
|
|
|
|
|
|
- (NSView *) _windowView
|
|
|
|
|
{
|
|
|
|
|
return _wv;
|
|
|
|
|
}
|
2010-03-13 15:17:21 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This is just the Apple name for our _windowView method.
|
|
|
|
|
*/
|
|
|
|
|
- (NSView *) _borderView
|
|
|
|
|
{
|
|
|
|
|
return _wv;
|
|
|
|
|
}
|
2000-03-06 11:39:22 +00:00
|
|
|
|
|
2012-08-17 13:16:12 +00:00
|
|
|
|
/* Support method to properly implement the 'screen' method for NSWindow.
|
|
|
|
|
According to documentation the 'screen' method should return the screen
|
|
|
|
|
that the window "show up the most or nil". This method supports the 'screen'
|
|
|
|
|
method and internal requests for the correct 'screen' based on the
|
|
|
|
|
supplied frame request.
|
|
|
|
|
*/
|
|
|
|
|
- (NSScreen *) _screenForFrame: (NSRect)frame
|
|
|
|
|
{
|
2017-10-05 21:05:28 +00:00
|
|
|
|
// FIXME: We always return the first screen, if there is no overlap.
|
|
|
|
|
// Other code relies on [window screen] not returning nil.
|
|
|
|
|
CGFloat largest = -1.0;
|
2012-08-17 13:16:12 +00:00
|
|
|
|
NSArray *screens = [NSScreen screens];
|
|
|
|
|
NSInteger index = 0;
|
|
|
|
|
NSScreen *theScreen = nil;
|
|
|
|
|
|
|
|
|
|
for (index = 0; index < [screens count]; ++index)
|
|
|
|
|
{
|
|
|
|
|
NSScreen *screen = [screens objectAtIndex: index];
|
|
|
|
|
NSRect sframe = [screen frame];
|
|
|
|
|
NSRect iframe = NSIntersectionRect(frame, sframe);
|
2014-05-03 21:45:47 +00:00
|
|
|
|
CGFloat isize = NSWidth(iframe) * NSHeight(iframe);
|
|
|
|
|
|
2012-08-17 13:16:12 +00:00
|
|
|
|
if (isize > largest)
|
|
|
|
|
{
|
|
|
|
|
largest = isize;
|
|
|
|
|
theScreen = screen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
NSDebugLLog(@"NSWindow", @"%s: frame: %@ screen: %@ size: %ld\n", __PRETTY_FUNCTION__,
|
|
|
|
|
NSStringFromRect(frame), theScreen, (long)largest);
|
|
|
|
|
|
|
|
|
|
return theScreen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
2000-03-06 11:39:22 +00:00
|
|
|
|
|
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
@interface NSMiniWindow : NSWindow
|
2000-03-01 17:21:08 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
@implementation NSMiniWindow
|
2000-03-01 17:21:08 +00:00
|
|
|
|
|
|
|
|
|
- (BOOL) canBecomeMainWindow
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) canBecomeKeyWindow
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-06 11:39:22 +00:00
|
|
|
|
- (void) _initDefaults
|
2000-03-01 17:21:08 +00:00
|
|
|
|
{
|
2000-03-06 11:39:22 +00:00
|
|
|
|
[super _initDefaults];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
[self setExcludedFromWindowsMenu: YES];
|
|
|
|
|
[self setReleasedWhenClosed: NO];
|
2011-02-14 22:25:57 +00:00
|
|
|
|
/* App icons and mini windows are displayed at dock level by default. Yet,
|
|
|
|
|
with the current window level mapping in -back, some window managers
|
|
|
|
|
will order pop up and context menus behind app icons and mini windows.
|
|
|
|
|
Therefore, it is possible to have app icons and mini windows displayed
|
|
|
|
|
at normal window level under control of a user preference. */
|
|
|
|
|
// See also NSIconWindow _initDefaults in NSApplication.m
|
|
|
|
|
if ([[NSUserDefaults standardUserDefaults]
|
|
|
|
|
boolForKey: @"GSAllowWindowsOverIcons"] == YES)
|
|
|
|
|
_windowLevel = NSDockWindowLevel;
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@interface NSMiniWindowView : NSView
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSCell *imageCell;
|
|
|
|
|
NSTextFieldCell *titleCell;
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
- (void) setImage: (NSImage*)anImage;
|
|
|
|
|
- (void) setTitle: (NSString*)aString;
|
|
|
|
|
@end
|
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
static NSCell *tileCell = nil;
|
2004-11-10 17:12:57 +00:00
|
|
|
|
|
|
|
|
|
static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|
|
|
|
{
|
|
|
|
|
NSSize iconSize, retSize;
|
|
|
|
|
|
2009-12-21 17:27:56 +00:00
|
|
|
|
iconSize = GSGetIconSize();
|
2004-11-10 17:12:57 +00:00
|
|
|
|
retSize.width = imageSize.width * iconSize.width / 64;
|
|
|
|
|
retSize.height = imageSize.height * iconSize.height / 64;
|
|
|
|
|
return retSize;
|
|
|
|
|
}
|
2000-03-01 17:21:08 +00:00
|
|
|
|
|
|
|
|
|
@implementation NSMiniWindowView
|
|
|
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
2004-07-22 23:57:46 +00:00
|
|
|
|
NSImage *tileImage;
|
2004-11-10 17:12:57 +00:00
|
|
|
|
NSSize iconSize;
|
|
|
|
|
|
2009-12-21 17:27:56 +00:00
|
|
|
|
iconSize = GSGetIconSize();
|
2004-11-10 17:12:57 +00:00
|
|
|
|
|
|
|
|
|
tileImage = [[GSCurrentServer() iconTileImage] copy];
|
|
|
|
|
[tileImage setScalesWhenResized: YES];
|
|
|
|
|
[tileImage setSize: iconSize];
|
|
|
|
|
|
|
|
|
|
tileCell = [[NSCell alloc] initImageCell: tileImage];
|
|
|
|
|
RELEASE(tileImage);
|
|
|
|
|
[tileCell setBordered: NO];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
TEST_RELEASE(imageCell);
|
|
|
|
|
TEST_RELEASE(titleCell);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) drawRect: (NSRect)rect
|
2004-07-22 23:57:46 +00:00
|
|
|
|
{
|
2009-12-21 17:27:56 +00:00
|
|
|
|
NSSize iconSize = GSGetIconSize();
|
2004-11-10 17:12:57 +00:00
|
|
|
|
|
|
|
|
|
[tileCell drawWithFrame: NSMakeRect(0, 0, iconSize.width, iconSize.height)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
inView: self];
|
2004-11-10 17:12:57 +00:00
|
|
|
|
[imageCell
|
|
|
|
|
drawWithFrame: NSMakeRect(iconSize.width / 8,
|
|
|
|
|
(iconSize.height / 16),
|
|
|
|
|
iconSize.width - ((iconSize.width / 8) * 2),
|
|
|
|
|
iconSize.height - ((iconSize.height / 8) * 2))
|
2007-09-09 12:19:01 +00:00
|
|
|
|
inView: self];
|
2004-11-10 17:12:57 +00:00
|
|
|
|
[titleCell drawWithFrame: NSMakeRect(1, iconSize.height - 12,
|
2007-09-09 12:19:01 +00:00
|
|
|
|
iconSize.width - 2, 11)
|
|
|
|
|
inView: self];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) mouseDown: (NSEvent*)theEvent
|
|
|
|
|
{
|
|
|
|
|
if ([theEvent clickCount] >= 2)
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSWindow *w = [_window counterpart];
|
2000-08-03 08:48:22 +00:00
|
|
|
|
[w deminiaturize: self];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSPoint lastLocation;
|
|
|
|
|
NSPoint location;
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
2007-09-09 12:19:01 +00:00
|
|
|
|
| NSPeriodicMask | NSOtherMouseUpMask | NSRightMouseUpMask;
|
|
|
|
|
NSDate *theDistantFuture = [NSDate distantFuture];
|
|
|
|
|
BOOL done = NO;
|
2000-03-01 17:21:08 +00:00
|
|
|
|
|
|
|
|
|
lastLocation = [theEvent locationInWindow];
|
|
|
|
|
[NSEvent startPeriodicEventsAfterDelay: 0.02 withPeriod: 0.02];
|
|
|
|
|
|
|
|
|
|
while (!done)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
theEvent = [NSApp nextEventMatchingMask: eventMask
|
|
|
|
|
untilDate: theDistantFuture
|
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
|
dequeue: YES];
|
|
|
|
|
|
|
|
|
|
switch ([theEvent type])
|
|
|
|
|
{
|
|
|
|
|
case NSRightMouseUp:
|
|
|
|
|
case NSOtherMouseUp:
|
|
|
|
|
case NSLeftMouseUp:
|
|
|
|
|
/* right mouse up or left mouse up means we're done */
|
|
|
|
|
done = YES;
|
|
|
|
|
break;
|
|
|
|
|
case NSPeriodic:
|
|
|
|
|
location = [_window mouseLocationOutsideOfEventStream];
|
|
|
|
|
if (NSEqualPoints(location, lastLocation) == NO)
|
|
|
|
|
{
|
2013-02-16 00:08:33 +00:00
|
|
|
|
NSPoint origin = [_window frame].origin;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
|
|
|
|
|
origin.x += (location.x - lastLocation.x);
|
|
|
|
|
origin.y += (location.y - lastLocation.y);
|
|
|
|
|
[_window setFrameOrigin: origin];
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-03-01 17:21:08 +00:00
|
|
|
|
[NSEvent stopPeriodicEvents];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setImage: (NSImage*)anImage
|
|
|
|
|
{
|
2004-11-10 17:12:57 +00:00
|
|
|
|
NSImage *imgCopy = [anImage copy];
|
|
|
|
|
|
|
|
|
|
[imgCopy setScalesWhenResized: YES];
|
2016-10-23 20:36:14 +00:00
|
|
|
|
if (imgCopy != nil)
|
|
|
|
|
{
|
|
|
|
|
[imgCopy setSize: scaledIconSizeForSize([imgCopy size])];
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-01 17:21:08 +00:00
|
|
|
|
if (imageCell == nil)
|
|
|
|
|
{
|
2004-11-10 17:12:57 +00:00
|
|
|
|
imageCell = [[NSCell alloc] initImageCell: imgCopy];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
[imageCell setBordered: NO];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-11-10 17:12:57 +00:00
|
|
|
|
[imageCell setImage: imgCopy];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
2004-11-10 17:12:57 +00:00
|
|
|
|
RELEASE(imgCopy);
|
|
|
|
|
[self setNeedsDisplay: YES];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setTitle: (NSString*)aString
|
|
|
|
|
{
|
|
|
|
|
if (titleCell == nil)
|
|
|
|
|
{
|
2001-02-07 11:17:38 +00:00
|
|
|
|
titleCell = [[NSTextFieldCell alloc] initTextCell: aString];
|
|
|
|
|
[titleCell setSelectable: NO];
|
|
|
|
|
[titleCell setEditable: NO];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
[titleCell setBordered: NO];
|
2001-02-08 07:02:39 +00:00
|
|
|
|
[titleCell setAlignment: NSCenterTextAlignment];
|
2004-07-22 23:57:46 +00:00
|
|
|
|
[titleCell setDrawsBackground: YES];
|
|
|
|
|
[titleCell setBackgroundColor: [NSColor blackColor]];
|
2001-02-07 11:17:38 +00:00
|
|
|
|
[titleCell setTextColor: [NSColor whiteColor]];
|
|
|
|
|
[titleCell setFont: [NSFont systemFontOfSize: 8]];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[titleCell setStringValue: aString];
|
|
|
|
|
}
|
2004-11-10 17:12:57 +00:00
|
|
|
|
[self setNeedsDisplay: YES];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*****************************************************************************
|
|
|
|
|
*
|
2007-09-09 12:19:01 +00:00
|
|
|
|
* NSWindow
|
1999-06-11 04:46:12 +00:00
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
/**
|
|
|
|
|
<unit>
|
|
|
|
|
<heading>NSWindow</heading>
|
|
|
|
|
|
|
|
|
|
<p> Instances of the NSWindow class handle on-screen windows, their
|
|
|
|
|
associated NSViews, and events generate by the user. An NSWindow's
|
|
|
|
|
size is defined by its frame rectangle, which encompasses its entire
|
|
|
|
|
structure, and its content rectangle, which includes only the
|
2002-01-26 04:14:38 +00:00
|
|
|
|
content.
|
|
|
|
|
</p>
|
2001-12-17 16:51:51 +00:00
|
|
|
|
|
|
|
|
|
<p> Every NSWindow has a content view, the NSView which forms the
|
|
|
|
|
root of the window's view hierarchy. This view can be set using the
|
|
|
|
|
<code>setContentView:</code> method, and accessed through the
|
|
|
|
|
<code>contentView</code> method. <code>setContentView:</code>
|
2002-01-26 04:14:38 +00:00
|
|
|
|
replaces the default content view created by NSWindow.
|
|
|
|
|
</p>
|
2001-12-17 16:51:51 +00:00
|
|
|
|
|
|
|
|
|
<p> Other views may be added to the window by using the content
|
|
|
|
|
view's <code>addSubview:</code> method. These subviews can also
|
|
|
|
|
have subviews added, forming a tree structure, the view hierarchy.
|
|
|
|
|
When an NSWindow must display itself, it causes this hierarchy to
|
|
|
|
|
draw itself. Leaf nodes in the view hierarchy are drawn last,
|
|
|
|
|
causing them to potentially obscure views further up in the
|
2002-01-26 04:14:38 +00:00
|
|
|
|
hierarchy.
|
|
|
|
|
</p>
|
2001-12-17 16:51:51 +00:00
|
|
|
|
|
|
|
|
|
<p> A delegate can be specified for an NSWindow, which will receive
|
|
|
|
|
notifications of events pertaining to the window. The delegate is
|
|
|
|
|
set using <code>setDelegate:</code>, and can be retrieved using
|
|
|
|
|
<code>delegate</code>. The delegate can restrain resizing by
|
|
|
|
|
implementing the <code>windowWillResize: toSize:</code> method, or
|
|
|
|
|
control the closing of the window by implementing
|
2002-01-26 04:14:38 +00:00
|
|
|
|
<code>windowShouldClose:</code>.
|
|
|
|
|
</p>
|
2001-12-17 16:51:51 +00:00
|
|
|
|
|
|
|
|
|
</unit>
|
|
|
|
|
*/
|
1998-11-12 10:49:00 +00:00
|
|
|
|
@implementation NSWindow
|
1997-10-09 22:55:31 +00:00
|
|
|
|
|
1999-05-07 11:06:37 +00:00
|
|
|
|
/*
|
|
|
|
|
* Class variables
|
|
|
|
|
*/
|
2007-09-09 12:19:01 +00:00
|
|
|
|
static SEL ccSel;
|
|
|
|
|
static SEL ctSel;
|
|
|
|
|
static IMP ccImp;
|
|
|
|
|
static IMP ctImp;
|
|
|
|
|
static Class responderClass;
|
|
|
|
|
static Class viewClass;
|
|
|
|
|
static NSMutableSet *autosaveNames;
|
2009-01-17 16:32:37 +00:00
|
|
|
|
static NSMapTable *windowmaps = NULL;
|
|
|
|
|
static NSMapTable *windowUndoManagers = NULL;
|
2001-08-21 23:24:00 +00:00
|
|
|
|
static NSNotificationCenter *nc = nil;
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Class methods
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
+ (void) initialize
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (self == [NSWindow class])
|
|
|
|
|
{
|
2014-05-03 18:32:20 +00:00
|
|
|
|
[self setVersion: 3];
|
2000-10-31 12:47:09 +00:00
|
|
|
|
ccSel = @selector(_checkCursorRectangles:forEvent:);
|
|
|
|
|
ctSel = @selector(_checkTrackingRectangles:forEvent:);
|
1999-05-07 11:06:37 +00:00
|
|
|
|
ccImp = [self instanceMethodForSelector: ccSel];
|
|
|
|
|
ctImp = [self instanceMethodForSelector: ctSel];
|
1999-05-14 14:50:05 +00:00
|
|
|
|
responderClass = [NSResponder class];
|
1999-10-04 06:18:17 +00:00
|
|
|
|
viewClass = [NSView class];
|
1999-07-06 05:37:15 +00:00
|
|
|
|
autosaveNames = [NSMutableSet new];
|
2008-10-17 15:41:00 +00:00
|
|
|
|
windowmaps = NSCreateMapTable(NSIntMapKeyCallBacks,
|
|
|
|
|
NSNonRetainedObjectMapValueCallBacks, 20);
|
2001-08-21 23:24:00 +00:00
|
|
|
|
nc = [NSNotificationCenter defaultCenter];
|
2009-12-10 12:43:35 +00:00
|
|
|
|
|
|
|
|
|
[self exposeBinding: NSTitleBinding];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-06 05:37:15 +00:00
|
|
|
|
+ (void) removeFrameUsingName: (NSString*)name
|
1999-06-11 04:46:12 +00:00
|
|
|
|
{
|
1999-07-06 05:37:15 +00:00
|
|
|
|
if (name != nil)
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSString *key;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
1999-11-16 09:48:54 +00:00
|
|
|
|
key = [NSString stringWithFormat: @"NSWindow Frame %@", name];
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[[NSUserDefaults standardUserDefaults] removeObjectForKey: key];
|
|
|
|
|
}
|
1999-06-11 04:46:12 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
+ (NSRect) contentRectForFrameRect: (NSRect)aRect
|
2013-01-27 20:28:35 +00:00
|
|
|
|
styleMask: (NSUInteger)aStyle
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
if (!windowDecorator)
|
|
|
|
|
windowDecorator = [GSWindowDecorationView windowDecorator];
|
2000-03-07 12:00:00 +00:00
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
return [windowDecorator contentRectForFrameRect: aRect
|
2007-09-09 12:19:01 +00:00
|
|
|
|
styleMask: aStyle];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
+ (NSRect) frameRectForContentRect: (NSRect)aRect
|
2013-01-27 20:28:35 +00:00
|
|
|
|
styleMask: (NSUInteger)aStyle
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
if (!windowDecorator)
|
|
|
|
|
windowDecorator = [GSWindowDecorationView windowDecorator];
|
2000-03-07 12:00:00 +00:00
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
return [windowDecorator frameRectForContentRect: aRect
|
2007-09-09 12:19:01 +00:00
|
|
|
|
styleMask: aStyle];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-16 00:08:33 +00:00
|
|
|
|
+ (CGFloat) minFrameWidthWithTitle: (NSString *)aTitle
|
2013-01-27 20:28:35 +00:00
|
|
|
|
styleMask: (NSUInteger)aStyle
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
if (!windowDecorator)
|
|
|
|
|
windowDecorator = [GSWindowDecorationView windowDecorator];
|
2000-03-07 12:00:00 +00:00
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
return [windowDecorator minFrameWidthWithTitle: aTitle
|
2007-09-09 12:19:01 +00:00
|
|
|
|
styleMask: aStyle];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/* default Screen and window depth */
|
|
|
|
|
+ (NSWindowDepth) defaultDepthLimit
|
|
|
|
|
{
|
2002-04-22 15:45:10 +00:00
|
|
|
|
return [[NSScreen deepestScreen] depth];
|
1997-10-09 22:55:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
+ (void)menuChanged: (NSMenu*)aMenu
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: This method is for MS Windows only, does nothing
|
|
|
|
|
// on other window systems
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Instance methods
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (id) init
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger style;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
|
|
|
|
style = NSTitledWindowMask | NSClosableWindowMask
|
2007-09-09 12:19:01 +00:00
|
|
|
|
| NSMiniaturizableWindowMask | NSResizableWindowMask;
|
1998-11-03 21:04:55 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return [self initWithContentRect: NSZeroRect
|
2007-09-09 12:19:01 +00:00
|
|
|
|
styleMask: style
|
|
|
|
|
backing: NSBackingStoreBuffered
|
|
|
|
|
defer: NO];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-13 18:26:20 +00:00
|
|
|
|
/*
|
|
|
|
|
It is important to make sure that the window is in a meaningful state after
|
|
|
|
|
this has been called, and that the backend window can be recreated later,
|
|
|
|
|
since one-shot windows may have their backend windows created and terminated
|
|
|
|
|
many times.
|
|
|
|
|
*/
|
2003-02-02 00:58:32 +00:00
|
|
|
|
- (void) _terminateBackendWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2003-02-02 00:58:32 +00:00
|
|
|
|
if (_windowNum)
|
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setWindowNumber: 0];
|
2008-05-18 23:12:24 +00:00
|
|
|
|
|
|
|
|
|
/* Check for context also as it might have disappeared before us */
|
|
|
|
|
if (_context && _gstate)
|
|
|
|
|
{
|
|
|
|
|
GSUndefineGState(_context, _gstate);
|
|
|
|
|
_gstate = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_context)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
If there was a context, clear it and let it remove the
|
|
|
|
|
window in that process. This indirection is needed so solve the
|
|
|
|
|
circular references between the window and the context.
|
|
|
|
|
But first undo the release call in _startBackendWindow.
|
|
|
|
|
*/
|
|
|
|
|
RETAIN(self);
|
|
|
|
|
DESTROY(_context);
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-02 00:58:32 +00:00
|
|
|
|
[GSServerForWindow(self) termwindow: _windowNum];
|
2006-01-14 11:39:37 +00:00
|
|
|
|
NSMapRemove(windowmaps, (void*)(intptr_t)_windowNum);
|
2003-05-13 18:26:20 +00:00
|
|
|
|
_windowNum = 0;
|
2003-02-02 00:58:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-11-22 07:31:01 +00:00
|
|
|
|
|
2003-02-02 00:58:32 +00:00
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
2011-07-11 08:40:31 +00:00
|
|
|
|
// Remove all key value bindings for this object.
|
|
|
|
|
[GSKeyValueBinding unbindAllForObject: self];
|
|
|
|
|
|
2010-05-08 20:18:14 +00:00
|
|
|
|
DESTROY(_toolbar);
|
2001-08-21 23:24:00 +00:00
|
|
|
|
[nc removeObserver: self];
|
2011-02-20 18:24:44 +00:00
|
|
|
|
[[self class] _removeAutodisplayedWindow: self];
|
2000-02-25 17:43:32 +00:00
|
|
|
|
[NSApp removeWindowsItem: self];
|
2003-11-26 13:58:32 +00:00
|
|
|
|
[NSApp _windowWillDealloc: self];
|
|
|
|
|
|
|
|
|
|
NSAssert([NSApp keyWindow] != self, @"window being deallocated is key");
|
|
|
|
|
NSAssert([NSApp mainWindow] != self, @"window being deallocated is main");
|
1999-11-22 07:31:01 +00:00
|
|
|
|
|
2009-01-17 16:32:37 +00:00
|
|
|
|
if (windowUndoManagers != NULL)
|
|
|
|
|
NSMapRemove(windowUndoManagers, self);
|
|
|
|
|
|
2002-02-22 23:05:06 +00:00
|
|
|
|
if (_autosaveName != nil)
|
|
|
|
|
{
|
|
|
|
|
[autosaveNames removeObject: _autosaveName];
|
|
|
|
|
_autosaveName = nil;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (_counterpart != 0 && (_styleMask & NSMiniWindowMask) == 0)
|
2000-03-01 17:21:08 +00:00
|
|
|
|
{
|
2008-05-18 23:12:24 +00:00
|
|
|
|
NSWindow *mini = [NSApp windowWithWindowNumber: _counterpart];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
|
|
|
|
|
_counterpart = 0;
|
2010-05-08 20:18:14 +00:00
|
|
|
|
DESTROY(mini);
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
2008-05-18 23:12:24 +00:00
|
|
|
|
|
2010-05-31 21:55:33 +00:00
|
|
|
|
/* Terminate backend window early so that the receiver is no longer returned
|
|
|
|
|
from GSOrderedWindows() or GSAllWindows(). This helps to prevent crashes
|
|
|
|
|
due to a race with some lame window managers under X that do not update
|
|
|
|
|
the _NET_CLIENT_LIST_STACKING property quickly enough. GSOrderedWindows()
|
|
|
|
|
may be called (indirectly) when a tooltip is visible while a window is
|
|
|
|
|
deallocated. */
|
|
|
|
|
if (_windowNum)
|
|
|
|
|
{
|
|
|
|
|
[self _terminateBackendWindow];
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-22 17:50:07 +00:00
|
|
|
|
/* Clean references to this window - important if some of the views
|
|
|
|
|
are not deallocated now */
|
2008-02-11 11:37:29 +00:00
|
|
|
|
[_wv _viewWillMoveToWindow: nil];
|
2001-10-22 17:50:07 +00:00
|
|
|
|
/* NB: releasing the window view does not necessarily result in the
|
|
|
|
|
deallocation of the window's views ! - some of them might be
|
|
|
|
|
retained for some other reason by the programmer or by other
|
|
|
|
|
parts of the code */
|
2004-07-06 20:20:31 +00:00
|
|
|
|
DESTROY(_wv);
|
2008-05-18 23:12:24 +00:00
|
|
|
|
DESTROY(_fieldEditor);
|
|
|
|
|
DESTROY(_backgroundColor);
|
|
|
|
|
DESTROY(_representedFilename);
|
|
|
|
|
DESTROY(_miniaturizedTitle);
|
|
|
|
|
DESTROY(_miniaturizedImage);
|
|
|
|
|
DESTROY(_windowTitle);
|
|
|
|
|
DESTROY(_rectsBeingDrawn);
|
|
|
|
|
DESTROY(_initialFirstResponder);
|
|
|
|
|
DESTROY(_defaultButtonCell);
|
|
|
|
|
DESTROY(_cachedImage);
|
|
|
|
|
DESTROY(_children);
|
2010-04-11 00:31:59 +00:00
|
|
|
|
DESTROY(_lastLeftMouseDownView);
|
|
|
|
|
DESTROY(_lastRightMouseDownView);
|
|
|
|
|
DESTROY(_lastOtherMouseDownView);
|
2003-07-22 05:18:05 +00:00
|
|
|
|
DESTROY(_lastDragView);
|
2008-05-18 23:12:24 +00:00
|
|
|
|
DESTROY(_screen);
|
1999-10-04 06:18:17 +00:00
|
|
|
|
|
1999-06-15 09:23:39 +00:00
|
|
|
|
/*
|
|
|
|
|
* FIXME This should not be necessary - the views should have removed
|
|
|
|
|
* their drag types, so we should already have been removed.
|
|
|
|
|
*/
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[GSServerForWindow(self) removeDragTypes: nil fromWindow: self];
|
1997-07-07 16:56:52 +00:00
|
|
|
|
|
2002-09-24 01:33:09 +00:00
|
|
|
|
if (_delegate != nil)
|
|
|
|
|
{
|
|
|
|
|
[nc removeObserver: _delegate name: nil object: self];
|
|
|
|
|
_delegate = nil;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[super dealloc];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-11-20 13:36:46 +00:00
|
|
|
|
- (NSString*) description
|
|
|
|
|
{
|
2015-05-26 17:57:19 +00:00
|
|
|
|
return [[super description] stringByAppendingFormat: @"Number: %ld Title: %@",
|
|
|
|
|
(long) [self windowNumber], [self title]];
|
2009-11-20 13:36:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-18 23:12:24 +00:00
|
|
|
|
- (void) _startBackendWindow
|
|
|
|
|
{
|
|
|
|
|
NSDictionary *info;
|
|
|
|
|
|
|
|
|
|
NSMapInsert(windowmaps, (void*)(intptr_t)_windowNum, self);
|
|
|
|
|
|
|
|
|
|
// Make sure not to create an autoreleased object,
|
|
|
|
|
// as this will lead to problems when the window is deallocated.
|
|
|
|
|
info = [[NSDictionary alloc]
|
|
|
|
|
initWithObjects: &self
|
|
|
|
|
forKeys: &NSGraphicsContextDestinationAttributeName
|
|
|
|
|
count: 1];
|
|
|
|
|
_context = [[NSGraphicsContext alloc] initWithContextInfo: info];
|
|
|
|
|
RELEASE(info);
|
|
|
|
|
if (_context)
|
|
|
|
|
{
|
|
|
|
|
// Now the context retains the window, release it once to make up
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set window in new _gstate
|
|
|
|
|
_gstate = GSDefineGState(_context);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
NSRect frame = _frame;
|
|
|
|
|
frame.origin = NSZeroPoint;
|
|
|
|
|
[_wv setFrame: frame];
|
|
|
|
|
[_wv setWindowNumber: _windowNum];
|
2008-12-14 19:15:18 +00:00
|
|
|
|
[_wv setDocumentEdited: _f.is_edited];
|
2008-05-18 23:12:24 +00:00
|
|
|
|
[_wv setNeedsDisplay: YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
- (void) _initBackendWindow
|
2000-09-27 22:18:34 +00:00
|
|
|
|
{
|
2002-12-28 00:49:40 +00:00
|
|
|
|
NSCountedSet *dragTypes;
|
2002-03-28 03:53:18 +00:00
|
|
|
|
GSDisplayServer *srv = GSCurrentServer();
|
2000-09-27 22:18:34 +00:00
|
|
|
|
|
2002-04-23 20:50:24 +00:00
|
|
|
|
/* If we were deferred or one shot, our drag types may not have
|
2000-09-29 03:55:30 +00:00
|
|
|
|
been registered properly in the backend. Remove them then re-add
|
|
|
|
|
them when we create the window */
|
2002-03-28 03:53:18 +00:00
|
|
|
|
dragTypes = [srv dragTypesForWindow: self];
|
2000-09-29 03:55:30 +00:00
|
|
|
|
if (dragTypes)
|
|
|
|
|
{
|
2001-02-19 00:39:28 +00:00
|
|
|
|
// As this is the original entry, it will change soon.
|
|
|
|
|
// We use a copy to reregister the same types later on.
|
|
|
|
|
dragTypes = [dragTypes copy];
|
2002-12-28 00:49:40 +00:00
|
|
|
|
|
|
|
|
|
/* Now we need to remove all the drag types for this window. */
|
2008-01-19 13:11:16 +00:00
|
|
|
|
[srv removeDragTypes: nil fromWindow: self];
|
2000-09-29 03:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-01-19 13:11:16 +00:00
|
|
|
|
_windowNum = [srv window: _frame
|
|
|
|
|
: _backingType
|
|
|
|
|
: _styleMask
|
|
|
|
|
: [_screen screenNumber]];
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (_windowNum == 0)
|
|
|
|
|
[NSException raise:@"No Window" format:@"Failed to obtain window from the back end"];
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[srv setwindowlevel: [self level] : _windowNum];
|
2009-01-29 09:37:30 +00:00
|
|
|
|
if (_parent != nil)
|
2009-01-31 09:59:32 +00:00
|
|
|
|
[srv setParentWindow: [_parent windowNumber]
|
|
|
|
|
forChildWindow: _windowNum];
|
2007-04-04 14:33:39 +00:00
|
|
|
|
|
2008-05-18 23:12:24 +00:00
|
|
|
|
// Set up context
|
|
|
|
|
[self _startBackendWindow];
|
2000-09-29 03:55:30 +00:00
|
|
|
|
|
|
|
|
|
/* Ok, now add the drag types back */
|
|
|
|
|
if (dragTypes)
|
|
|
|
|
{
|
2002-12-28 00:49:40 +00:00
|
|
|
|
id type;
|
|
|
|
|
NSMutableArray *dragTypesArray = [NSMutableArray array];
|
|
|
|
|
NSEnumerator *enumerator = [dragTypes objectEnumerator];
|
|
|
|
|
|
2000-09-29 03:55:30 +00:00
|
|
|
|
NSDebugLLog(@"NSWindow", @"Resetting drag types for window");
|
2002-12-28 00:49:40 +00:00
|
|
|
|
/* Now we need to restore the drag types. */
|
|
|
|
|
|
|
|
|
|
/* Put all the drag types to the dragTypesArray - counted
|
|
|
|
|
* with their multiplicity.
|
|
|
|
|
*/
|
|
|
|
|
while ((type = [enumerator nextObject]) != nil)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger i, count = [dragTypes countForObject: type];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
[dragTypesArray addObject: type];
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-12-28 00:49:40 +00:00
|
|
|
|
|
|
|
|
|
/* Now store the array. */
|
|
|
|
|
[srv addDragTypes: dragTypesArray toWindow: self];
|
2001-02-19 00:39:28 +00:00
|
|
|
|
// Free our local copy.
|
|
|
|
|
RELEASE(dragTypes);
|
2000-09-29 03:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Other stuff we need to do for deferred windows */
|
|
|
|
|
if (!NSEqualSizes(_minimumSize, NSZeroSize))
|
|
|
|
|
[self setMinSize: _minimumSize];
|
|
|
|
|
if (!NSEqualSizes(_maximumSize, NSZeroSize))
|
|
|
|
|
[self setMaxSize: _maximumSize];
|
|
|
|
|
if (!NSEqualSizes(_increments, NSZeroSize))
|
|
|
|
|
[self setResizeIncrements: _increments];
|
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
NSDebugLLog(@"NSWindow", @"Created NSWindow window frame %@",
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSStringFromRect(_frame));
|
2000-09-27 22:18:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Initializing and getting a new NSWindow object
|
|
|
|
|
*/
|
2001-12-17 16:51:51 +00:00
|
|
|
|
/**
|
|
|
|
|
<p> Initializes the receiver with a content rect of
|
|
|
|
|
<var>contentRect</var>, a style mask of <var>styleMask</var>, and a
|
2010-05-12 14:47:10 +00:00
|
|
|
|
backing store type of <var>backingType</var>. This is the designated
|
|
|
|
|
initializer.
|
2002-01-26 04:14:38 +00:00
|
|
|
|
</p>
|
2001-12-17 16:51:51 +00:00
|
|
|
|
|
|
|
|
|
<p> The style mask values are <code>NSTitledWindowMask</code>, for a
|
|
|
|
|
window with a title, <code>NSClosableWindowMask</code>, for a window
|
|
|
|
|
with a close widget, <code>NSMiniaturizableWindowMask</code>, for a
|
|
|
|
|
window with a miniaturize widget, and
|
|
|
|
|
<code>NSResizableWindowMask</code>, for a window with a resizing
|
2002-01-26 04:14:38 +00:00
|
|
|
|
widget. These mask values can be OR'd in any combination.
|
|
|
|
|
</p>
|
2001-12-17 16:51:51 +00:00
|
|
|
|
|
|
|
|
|
<p> Backing store values are <code>NSBackingStoreBuffered</code>,
|
|
|
|
|
<code>NSBackingStoreRetained</code> and
|
2002-01-26 04:14:38 +00:00
|
|
|
|
<code>NSBackingStoreNonretained</code>.
|
|
|
|
|
</p>
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (id) initWithContentRect: (NSRect)contentRect
|
2013-01-27 20:28:35 +00:00
|
|
|
|
styleMask: (NSUInteger)aStyle
|
2007-09-09 12:19:01 +00:00
|
|
|
|
backing: (NSBackingStoreType)bufferingType
|
|
|
|
|
defer: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2002-04-22 15:45:10 +00:00
|
|
|
|
NSRect cframe;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2005-01-18 16:04:40 +00:00
|
|
|
|
NSAssert(NSApp,
|
|
|
|
|
@"The shared NSApplication instance must be created before windows "
|
|
|
|
|
@"can be created.");
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
2002-03-19 20:10:26 +00:00
|
|
|
|
NSDebugLLog(@"NSWindow", @"NSWindow start of init\n");
|
2004-07-06 20:20:31 +00:00
|
|
|
|
|
2008-05-18 23:12:24 +00:00
|
|
|
|
// FIXME: This hack is here to work around a gorm decoding problem.
|
|
|
|
|
if (_windowNum)
|
|
|
|
|
{
|
2013-01-30 09:48:54 +00:00
|
|
|
|
NSLog(@"Window already initialized %d", (int)_windowNum);
|
2008-05-18 23:12:24 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/* Initialize attributes and flags */
|
2000-03-06 21:10:08 +00:00
|
|
|
|
[super init];
|
|
|
|
|
[self _initDefaults];
|
2009-08-02 14:16:13 +00:00
|
|
|
|
|
|
|
|
|
_attachedSheet = nil;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_backingType = bufferingType;
|
|
|
|
|
_styleMask = aStyle;
|
2010-05-12 14:47:10 +00:00
|
|
|
|
ASSIGN(_screen, [NSScreen mainScreen]);
|
2002-04-22 15:45:10 +00:00
|
|
|
|
_depthLimit = [_screen depth];
|
2000-03-12 04:35:43 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_frame = [NSWindow frameRectForContentRect: contentRect styleMask: aStyle];
|
|
|
|
|
_minimumSize = NSMakeSize(_frame.size.width - contentRect.size.width + 1,
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_frame.size.height - contentRect.size.height + 1);
|
2000-09-08 17:07:04 +00:00
|
|
|
|
_maximumSize = NSMakeSize (10e4, 10e4);
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
[self setNextResponder: NSApp];
|
|
|
|
|
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.cursor_rects_enabled = YES;
|
|
|
|
|
_f.cursor_rects_valid = NO;
|
1996-10-03 18:45:41 +00:00
|
|
|
|
|
1999-12-08 15:01:52 +00:00
|
|
|
|
/* Create the window view */
|
|
|
|
|
cframe.origin = NSZeroPoint;
|
2004-07-06 20:20:31 +00:00
|
|
|
|
cframe.size = _frame.size;
|
2008-10-20 13:28:28 +00:00
|
|
|
|
if (!windowDecorator)
|
|
|
|
|
windowDecorator = [GSWindowDecorationView windowDecorator];
|
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
_wv = [windowDecorator newWindowDecorationViewWithFrame: cframe
|
2007-09-09 12:19:01 +00:00
|
|
|
|
window: self];
|
2008-02-11 11:37:29 +00:00
|
|
|
|
[_wv _viewWillMoveToWindow: self];
|
2009-01-18 15:52:06 +00:00
|
|
|
|
[_wv setNextResponder: self];
|
1999-12-08 15:01:52 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/* Create the content view */
|
|
|
|
|
cframe.origin = NSZeroPoint;
|
2000-03-07 12:00:00 +00:00
|
|
|
|
cframe.size = contentRect.size;
|
1999-06-01 17:05:57 +00:00
|
|
|
|
[self setContentView: AUTORELEASE([[NSView alloc] initWithFrame: cframe])];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-05-02 01:34:06 +00:00
|
|
|
|
/* rectBeingDrawn is variable used to optimize flushing the backing store.
|
1999-10-21 18:08:50 +00:00
|
|
|
|
It is set by NSGraphicsContext during a lockFocus to tell NSWindow what
|
1999-05-02 01:34:06 +00:00
|
|
|
|
part a view is drawing in, so NSWindow only has to flush that portion */
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_rectsBeingDrawn = RETAIN([NSMutableArray arrayWithCapacity: 10]);
|
1998-12-16 15:21:55 +00:00
|
|
|
|
|
2000-09-27 22:18:34 +00:00
|
|
|
|
/* Create window (if not deferred) */
|
|
|
|
|
_windowNum = 0;
|
|
|
|
|
_gstate = 0;
|
|
|
|
|
if (flag == NO)
|
|
|
|
|
{
|
|
|
|
|
NSDebugLLog(@"NSWindow", @"Creating NSWindow\n");
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[self _initBackendWindow];
|
2000-09-27 22:18:34 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2004-07-06 20:20:31 +00:00
|
|
|
|
NSDebugLLog(@"NSWindow", @"Deferring NSWindow creation\n");
|
|
|
|
|
|
|
|
|
|
[nc addObserver: self
|
2007-09-09 12:19:01 +00:00
|
|
|
|
selector: @selector(colorListChanged:)
|
2011-01-15 19:28:24 +00:00
|
|
|
|
name: NSColorListDidChangeNotification
|
2007-09-09 12:19:01 +00:00
|
|
|
|
object: nil];
|
1999-10-23 02:48:20 +00:00
|
|
|
|
|
2002-03-19 20:10:26 +00:00
|
|
|
|
NSDebugLLog(@"NSWindow", @"NSWindow end of init\n");
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return self;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-12 14:47:10 +00:00
|
|
|
|
/**
|
|
|
|
|
<p> Initializes the receiver with a content rect of
|
|
|
|
|
<var>contentRect</var>, a style mask of <var>styleMask</var>, a
|
|
|
|
|
backing store type of <var>backingType</var> and a boolean
|
|
|
|
|
<var>flag</var>. <var>flag</var> specifies whether the window
|
|
|
|
|
should be created now (<code>NO</code>), or when it is displayed
|
|
|
|
|
(<code>YES</code>).
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p> The style mask values are <code>NSTitledWindowMask</code>, for a
|
|
|
|
|
window with a title, <code>NSClosableWindowMask</code>, for a window
|
|
|
|
|
with a close widget, <code>NSMiniaturizableWindowMask</code>, for a
|
|
|
|
|
window with a miniaturize widget, and
|
|
|
|
|
<code>NSResizableWindowMask</code>, for a window with a resizing
|
|
|
|
|
widget. These mask values can be OR'd in any combination.
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p> Backing store values are <code>NSBackingStoreBuffered</code>,
|
|
|
|
|
<code>NSBackingStoreRetained</code> and
|
|
|
|
|
<code>NSBackingStoreNonretained</code>.
|
|
|
|
|
</p>
|
|
|
|
|
*/
|
|
|
|
|
- (id) initWithContentRect: (NSRect)contentRect
|
2013-01-27 20:28:35 +00:00
|
|
|
|
styleMask: (NSUInteger)aStyle
|
2010-05-12 14:47:10 +00:00
|
|
|
|
backing: (NSBackingStoreType)bufferingType
|
|
|
|
|
defer: (BOOL)flag
|
|
|
|
|
screen: (NSScreen*)aScreen
|
|
|
|
|
{
|
|
|
|
|
self = [self initWithContentRect: contentRect
|
|
|
|
|
styleMask: aStyle
|
|
|
|
|
backing: bufferingType
|
|
|
|
|
defer: flag];
|
|
|
|
|
if (self && aScreen != nil)
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_screen, aScreen);
|
|
|
|
|
_depthLimit = [_screen depth];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-03 21:09:08 +00:00
|
|
|
|
- (id) initWithWindowRef: (void *)windowRef
|
|
|
|
|
{
|
|
|
|
|
NSRect contentRect;
|
2013-02-16 00:08:33 +00:00
|
|
|
|
unsigned int aStyle;
|
2006-05-03 21:09:08 +00:00
|
|
|
|
NSBackingStoreType bufferingType;
|
|
|
|
|
NSScreen* aScreen;
|
|
|
|
|
int screen;
|
2013-02-16 00:08:33 +00:00
|
|
|
|
NSInteger winNum;
|
2006-05-03 21:09:08 +00:00
|
|
|
|
GSDisplayServer *srv = GSCurrentServer();
|
|
|
|
|
|
|
|
|
|
// Get the properties for the underlying window
|
|
|
|
|
winNum = [srv nativeWindow: windowRef : &contentRect : &bufferingType
|
2007-09-09 12:19:01 +00:00
|
|
|
|
: &aStyle : &screen];
|
2008-04-27 22:44:12 +00:00
|
|
|
|
|
|
|
|
|
// Get the screen for the right screen number.
|
|
|
|
|
aScreen = [[NSScreen alloc] _initWithScreenNumber: screen];
|
2006-05-03 21:09:08 +00:00
|
|
|
|
|
|
|
|
|
// Set up a NSWindow with the same properties
|
|
|
|
|
self = [self initWithContentRect: contentRect
|
2007-09-09 12:19:01 +00:00
|
|
|
|
styleMask: aStyle
|
|
|
|
|
backing: bufferingType
|
|
|
|
|
defer: YES
|
|
|
|
|
screen: aScreen];
|
2011-02-20 22:36:49 +00:00
|
|
|
|
RELEASE(aScreen);
|
2006-05-03 21:09:08 +00:00
|
|
|
|
|
|
|
|
|
// Fake the initialisation of the backend
|
|
|
|
|
_windowNum = winNum;
|
|
|
|
|
|
2008-05-18 23:12:24 +00:00
|
|
|
|
// Set up context
|
|
|
|
|
[self _startBackendWindow];
|
2006-05-03 21:09:08 +00:00
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
-(void) colorListChanged:(NSNotification*)notif
|
|
|
|
|
{
|
|
|
|
|
if ([[notif object] isEqual: [NSColorList colorListNamed:@"System"]])
|
|
|
|
|
{
|
|
|
|
|
[_wv setNeedsDisplay:YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
- (NSRect) contentRectForFrameRect: (NSRect)frameRect
|
|
|
|
|
{
|
2008-10-20 13:28:28 +00:00
|
|
|
|
return [_wv contentRectForFrameRect: frameRect styleMask: _styleMask];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSRect) frameRectForContentRect: (NSRect)contentRect
|
|
|
|
|
{
|
2008-10-20 13:28:28 +00:00
|
|
|
|
return [_wv frameRectForContentRect: contentRect styleMask: _styleMask];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Accessing the content view
|
|
|
|
|
*/
|
1999-05-04 13:17:26 +00:00
|
|
|
|
- (id) contentView
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _contentView;
|
1999-05-04 13:17:26 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
/**
|
|
|
|
|
Sets the window's content view to <var>aView</var>, replacing any
|
|
|
|
|
previous content view. */
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setContentView: (NSView*)aView
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2008-12-16 19:28:25 +00:00
|
|
|
|
if (aView == _contentView)
|
|
|
|
|
return;
|
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (_contentView != nil)
|
1999-12-08 15:01:52 +00:00
|
|
|
|
{
|
2011-02-15 19:50:54 +00:00
|
|
|
|
[_contentView removeFromSuperview];
|
1999-12-08 15:01:52 +00:00
|
|
|
|
}
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_contentView = aView;
|
2000-02-19 00:40:47 +00:00
|
|
|
|
|
2011-02-15 21:48:00 +00:00
|
|
|
|
if (_contentView != nil)
|
|
|
|
|
{
|
|
|
|
|
[_wv setContentView: _contentView];
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Window graphics
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSColor*) backgroundColor
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _backgroundColor;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSString*) representedFilename
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _representedFilename;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setBackgroundColor: (NSColor*)color
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
ASSIGN(_backgroundColor, color);
|
2004-07-28 17:56:57 +00:00
|
|
|
|
[_wv setBackgroundColor: color];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (void) setRepresentedFilename: (NSString*)aString
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
ASSIGN(_representedFilename, aString);
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
/** Sets the window's title to the string <var>aString</var>. */
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (void) setTitle: (NSString*)aString
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ([_windowTitle isEqual: aString] == NO)
|
1999-12-03 11:32:39 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
ASSIGNCOPY(_windowTitle, aString);
|
|
|
|
|
[self setMiniwindowTitle: _windowTitle];
|
|
|
|
|
[_wv setTitle: _windowTitle];
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.menu_exclude == NO && _f.has_opened == YES)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
[NSApp changeWindowsItem: self
|
|
|
|
|
title: _windowTitle
|
|
|
|
|
filename: NO];
|
|
|
|
|
}
|
1999-12-03 11:32:39 +00:00
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2012-10-03 12:58:26 +00:00
|
|
|
|
static NSString *
|
|
|
|
|
titleWithRepresentedFilename(NSString *representedFilename)
|
|
|
|
|
{
|
|
|
|
|
return [NSString stringWithFormat: @"%@ -- %@",
|
|
|
|
|
[representedFilename lastPathComponent],
|
|
|
|
|
[[representedFilename stringByDeletingLastPathComponent]
|
|
|
|
|
stringByAbbreviatingWithTildeInPath]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) _hasTitleWithRepresentedFilename
|
|
|
|
|
{
|
|
|
|
|
NSString *aString = titleWithRepresentedFilename (_representedFilename);
|
|
|
|
|
return [_windowTitle isEqualToString: aString];
|
|
|
|
|
}
|
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (void) setTitleWithRepresentedFilename: (NSString*)aString
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1998-12-17 13:06:17 +00:00
|
|
|
|
[self setRepresentedFilename: aString];
|
2012-10-03 12:58:26 +00:00
|
|
|
|
aString = titleWithRepresentedFilename(aString);
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ([_windowTitle isEqual: aString] == NO)
|
1999-12-03 11:32:39 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
ASSIGNCOPY(_windowTitle, aString);
|
|
|
|
|
[self setMiniwindowTitle: _windowTitle];
|
|
|
|
|
[_wv setTitle: _windowTitle];
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.menu_exclude == NO && _f.has_opened == YES)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
[NSApp changeWindowsItem: self
|
|
|
|
|
title: _windowTitle
|
|
|
|
|
filename: YES];
|
|
|
|
|
}
|
1999-12-03 11:32:39 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
- (NSUInteger) styleMask
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _styleMask;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
/** Returns an NSString containing the text of the window's title. */
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSString*) title
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _windowTitle;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
- (void) setHasShadow: (BOOL)hasShadow
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
|
|
|
|
_f.has_shadow = hasShadow;
|
2007-08-16 14:47:03 +00:00
|
|
|
|
if (_windowNum)
|
|
|
|
|
{
|
|
|
|
|
[GSServerForWindow(self) setShadow: hasShadow : _windowNum];
|
|
|
|
|
}
|
2001-11-26 20:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
- (BOOL) hasShadow
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.has_shadow;
|
2001-11-26 20:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
- (void) invalidateShadow
|
|
|
|
|
{
|
|
|
|
|
// FIXME
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-16 00:08:33 +00:00
|
|
|
|
- (void) setAlphaValue: (CGFloat)windowAlpha
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
|
|
|
|
_alphaValue = windowAlpha;
|
2005-02-12 18:15:25 +00:00
|
|
|
|
if (_windowNum)
|
|
|
|
|
{
|
|
|
|
|
[GSServerForWindow(self) setalpha: _alphaValue : _windowNum];
|
|
|
|
|
}
|
2001-11-26 20:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-16 00:08:33 +00:00
|
|
|
|
- (CGFloat) alphaValue
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
|
|
|
|
return _alphaValue;
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
- (void) setOpaque: (BOOL)isOpaque
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
2003-02-02 00:58:32 +00:00
|
|
|
|
// FIXME
|
2001-11-26 20:25:50 +00:00
|
|
|
|
_f.is_opaque = isOpaque;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isOpaque
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.is_opaque;
|
2001-11-26 20:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Window device attributes
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (NSBackingStoreType) backingType
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _backingType;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSDictionary*) deviceDescription
|
1998-12-17 13:06:17 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
return [[self screen] deviceDescription];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-06 16:11:45 +00:00
|
|
|
|
- (NSGraphicsContext*) graphicsContext
|
|
|
|
|
{
|
2007-04-04 14:33:39 +00:00
|
|
|
|
return _context;
|
2007-03-06 16:11:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-16 00:08:33 +00:00
|
|
|
|
- (CGFloat) userSpaceScaleFactor
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
if (_styleMask & NSUnscaledWindowMask)
|
|
|
|
|
{
|
|
|
|
|
return 1.0;
|
|
|
|
|
}
|
2014-05-03 21:45:47 +00:00
|
|
|
|
else if (_screen != nil)
|
|
|
|
|
{
|
|
|
|
|
return [_screen userSpaceScaleFactor];
|
|
|
|
|
}
|
2007-09-09 12:19:01 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2014-05-03 21:45:47 +00:00
|
|
|
|
return 1.0;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
- (NSInteger) gState
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-29 03:55:30 +00:00
|
|
|
|
if (_gstate <= 0)
|
|
|
|
|
NSDebugLLog(@"NSWindow", @"gState called on deferred window");
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _gstate;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isOneShot
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.is_one_shot;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setBackingType: (NSBackingStoreType)type
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_backingType = type;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setOneShot: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_one_shot = flag;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
- (NSInteger) windowNumber
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-29 03:55:30 +00:00
|
|
|
|
if (_windowNum <= 0)
|
|
|
|
|
NSDebugLLog(@"NSWindow", @"windowNumber called on deferred window");
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _windowNum;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* The miniwindow
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSImage*) miniwindowImage
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _miniaturizedImage;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSString*) miniwindowTitle
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _miniaturizedTitle;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setMiniwindowImage: (NSImage*)image
|
1996-10-03 18:45:41 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
ASSIGN(_miniaturizedImage, image);
|
|
|
|
|
if (_counterpart != 0 && (_styleMask & NSMiniWindowMask) == 0)
|
2000-03-01 17:21:08 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSMiniWindow *mini;
|
|
|
|
|
id v;
|
2000-03-01 17:21:08 +00:00
|
|
|
|
|
2006-07-04 21:31:49 +00:00
|
|
|
|
mini = (NSMiniWindow*)[NSApp windowWithWindowNumber: _counterpart];
|
|
|
|
|
v = [mini contentView];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
if ([v respondsToSelector: @selector(setImage:)])
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
[v setImage: [self miniwindowImage]];
|
|
|
|
|
}
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (void) setMiniwindowTitle: (NSString*)title
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
ASSIGN(_miniaturizedTitle, title);
|
|
|
|
|
if (_counterpart != 0 && (_styleMask & NSMiniWindowMask) == 0)
|
2000-03-01 17:21:08 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSMiniWindow *mini;
|
|
|
|
|
id v;
|
2000-03-01 17:21:08 +00:00
|
|
|
|
|
2006-07-04 21:31:49 +00:00
|
|
|
|
mini = (NSMiniWindow*)[NSApp windowWithWindowNumber: _counterpart];
|
|
|
|
|
v = [mini contentView];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
if ([v respondsToSelector: @selector(setTitle:)])
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
[v setTitle: [self miniwindowTitle]];
|
|
|
|
|
}
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSWindow*) counterpart
|
|
|
|
|
{
|
|
|
|
|
if (_counterpart == 0)
|
|
|
|
|
return nil;
|
|
|
|
|
return [NSApp windowWithWindowNumber: _counterpart];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* The field editor
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) endEditingFor: (id)anObject
|
1998-11-12 10:49:00 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
NSText *t = [self fieldEditor: NO
|
2007-09-09 12:19:01 +00:00
|
|
|
|
forObject: anObject];
|
1999-11-14 03:16:39 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (t && (_firstResponder == t))
|
1999-11-14 03:16:39 +00:00
|
|
|
|
{
|
2008-08-10 22:04:14 +00:00
|
|
|
|
// Change first responder first to avoid recusion.
|
|
|
|
|
_firstResponder = self;
|
|
|
|
|
[_firstResponder becomeFirstResponder];
|
2001-08-21 23:24:00 +00:00
|
|
|
|
[nc postNotificationName: NSTextDidEndEditingNotification
|
2007-09-09 12:19:01 +00:00
|
|
|
|
object: t];
|
1999-11-14 03:16:39 +00:00
|
|
|
|
[t setText: @""];
|
|
|
|
|
[t setDelegate: nil];
|
|
|
|
|
[t removeFromSuperview];
|
|
|
|
|
}
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSText*) fieldEditor: (BOOL)createFlag forObject: (id)anObject
|
1999-06-01 17:05:57 +00:00
|
|
|
|
{
|
|
|
|
|
/* ask delegate if it can provide a field editor */
|
2000-12-16 02:03:03 +00:00
|
|
|
|
if ((_delegate != anObject)
|
2002-09-23 05:52:36 +00:00
|
|
|
|
&& [_delegate respondsToSelector:
|
|
|
|
|
@selector(windowWillReturnFieldEditor:toObject:)])
|
2000-12-16 02:03:03 +00:00
|
|
|
|
{
|
|
|
|
|
NSText *editor;
|
|
|
|
|
|
|
|
|
|
editor = [_delegate windowWillReturnFieldEditor: self
|
2007-09-09 12:19:01 +00:00
|
|
|
|
toObject: anObject];
|
2000-12-16 02:03:03 +00:00
|
|
|
|
|
|
|
|
|
if (editor != nil)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
return editor;
|
|
|
|
|
}
|
2000-12-16 02:03:03 +00:00
|
|
|
|
}
|
1999-06-01 17:05:57 +00:00
|
|
|
|
/*
|
|
|
|
|
* Each window has a global text field editor, if it doesn't exist create it
|
|
|
|
|
* if create flag is set
|
|
|
|
|
*/
|
|
|
|
|
if (!_fieldEditor && createFlag)
|
|
|
|
|
{
|
|
|
|
|
_fieldEditor = [NSText new];
|
|
|
|
|
[_fieldEditor setFieldEditor: YES];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
* NSWindow.m renmae captureMouse: to _captureMouse: (designate as non OS),
various methods add fieldEditor support.
* GSContext.m/GSContext.h revert to previous code as solution discussed
with Adam Fedor regarding backends had problems I had not forseen.
* NSBrowserCell.h/.m specify text subcell as an NSCell, eliminate image
cell, copyWithZone: optimize and eliminate use of ASSIGN (fixes serious
dealloc bug), highlight: eliminate method (fixes dup display bug).
* NSButtonCell.m copyWithZone: optimize and eliminate use of ASSIGN
* NSStringDrawing.h/.m remove unimplemented draw methods from Category
(these are backend specific, can't be defined twice and are already
implemented in xraw).
* NSApplication.h redefine initialize_gnustep_backend () per Adam's
redefinition in the backend.
* Functions.m/.h remove initialize_gnustep_backend()
* NSCell.m preliminary implementation of fieldEditor mechanism,
copyWithZone: optimize and eliminate use of ASSIGN
* NSControl.m rename cell class global to _NSCONTROL_CELL_CLASS
* NSMatrix.m implement NSControl's updateCell: to prevent unecessary
matrix drawing if possible.
* NSView.m -resizeWithOldSuperviewSize reverted code to my own once more
(fewer lines and no if/else logic), changed code to use view frame instead
of bounds per 3.3/4.2 docs, optimize to avoid floating point math and scale
adjustment unless view has been scaled.
* NSScrollView.m define as externs various PS* functions for use in
drawing, polish drawing, move all backend code to front.
* Tools/dummy.m define dummy PS* functions employed in gui.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3454 72102866-910b-0410-8b05-ffd578937521
1998-12-14 09:54:38 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return _fieldEditor;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-11 00:52:04 +00:00
|
|
|
|
/*
|
|
|
|
|
* Window controller
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setWindowController: (NSWindowController*)windowController
|
1999-09-11 00:52:04 +00:00
|
|
|
|
{
|
2001-07-20 09:16:35 +00:00
|
|
|
|
/* The window controller owns us, we only keep a weak reference to
|
|
|
|
|
it */
|
|
|
|
|
_windowController = windowController;
|
1999-09-11 00:52:04 +00:00
|
|
|
|
}
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
1999-11-22 12:58:14 +00:00
|
|
|
|
- (id) windowController
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
1999-09-11 00:52:04 +00:00
|
|
|
|
return _windowController;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Window status and ordering
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) becomeKeyWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (_f.is_key == NO)
|
1999-11-22 15:03:41 +00:00
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
_f.is_key = YES;
|
|
|
|
|
|
2003-04-01 05:13:16 +00:00
|
|
|
|
if ((!_firstResponder) || (_firstResponder == self))
|
2007-08-31 10:52:52 +00:00
|
|
|
|
{
|
2012-10-04 09:20:08 +00:00
|
|
|
|
if (!_initialFirstResponder)
|
|
|
|
|
{
|
|
|
|
|
[self recalculateKeyViewLoop];
|
|
|
|
|
}
|
2007-08-31 10:52:52 +00:00
|
|
|
|
if (_initialFirstResponder)
|
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: _initialFirstResponder];
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-01 05:13:16 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[_firstResponder becomeFirstResponder];
|
|
|
|
|
if ((_firstResponder != self)
|
2007-08-31 10:52:52 +00:00
|
|
|
|
&& [_firstResponder respondsToSelector: @selector(becomeKeyWindow)])
|
|
|
|
|
{
|
|
|
|
|
[_firstResponder becomeKeyWindow];
|
|
|
|
|
}
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setInputState: GSTitleBarKey];
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[GSServerForWindow(self) setinputfocus: _windowNum];
|
1999-11-22 15:03:41 +00:00
|
|
|
|
[self resetCursorRects];
|
|
|
|
|
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
2001-10-07 04:22:41 +00:00
|
|
|
|
NSDebugLLog(@"NSWindow", @"%@ is now key window", [self title]);
|
1999-11-22 15:03:41 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) becomeMainWindow
|
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (_f.is_main == NO)
|
1999-11-22 15:03:41 +00:00
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
_f.is_main = YES;
|
|
|
|
|
if (_f.is_key == NO)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
[_wv setInputState: GSTitleBarMain];
|
|
|
|
|
}
|
1999-11-22 15:03:41 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidBecomeMainNotification object: self];
|
2001-10-07 04:22:41 +00:00
|
|
|
|
NSDebugLLog(@"NSWindow", @"%@ is now main window", [self title]);
|
1999-11-22 15:03:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-22 03:44:57 +00:00
|
|
|
|
/** Returns YES if the receiver can be made key. If this method returns
|
|
|
|
|
NO, the window will not be made key. This implementation returns YES
|
|
|
|
|
if the window is resizable or has a title bar. You can override this
|
|
|
|
|
method to change it's behavior */
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) canBecomeKeyWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ((NSResizableWindowMask | NSTitledWindowMask) & _styleMask)
|
2000-03-04 07:55:42 +00:00
|
|
|
|
return YES;
|
|
|
|
|
else
|
|
|
|
|
return NO;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
2002-06-22 03:44:57 +00:00
|
|
|
|
/** Returns YES if the receiver can be the main window. If this method
|
|
|
|
|
returns NO, the window will not become the main window. This
|
|
|
|
|
implementation returns YES if the window is resizable or has a
|
|
|
|
|
title bar and is visible and is not an NSPanel. You can override
|
|
|
|
|
this method to change it's behavior */
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) canBecomeMainWindow
|
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
if (!_f.visible)
|
|
|
|
|
return NO;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ((NSResizableWindowMask | NSTitledWindowMask) & _styleMask)
|
2000-03-04 07:55:42 +00:00
|
|
|
|
return YES;
|
|
|
|
|
else
|
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) hidesOnDeactivate
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.hides_on_deactivate;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
- (void) setCanHide: (BOOL)flag
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
|
|
|
|
_f.can_hide = flag;
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
- (BOOL) canHide
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.can_hide;
|
2001-11-26 20:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) isKeyWindow
|
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
return _f.is_key;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isMainWindow
|
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
return _f.is_main;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isMiniaturized
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.is_miniaturized;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isVisible
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.visible;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
- (NSInteger) level
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _windowLevel;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) makeKeyAndOrderFront: (id)sender
|
1998-12-17 13:06:17 +00:00
|
|
|
|
{
|
2008-03-06 06:58:20 +00:00
|
|
|
|
[self deminiaturize: self];
|
2008-08-15 06:45:17 +00:00
|
|
|
|
/*
|
|
|
|
|
* If a window is ordered in, make sure that the application isn't hidden,
|
|
|
|
|
* and is active.
|
|
|
|
|
*/
|
|
|
|
|
if ([self canBecomeKeyWindow])
|
|
|
|
|
[NSApp unhide: self];
|
2007-09-09 20:38:10 +00:00
|
|
|
|
[self orderFrontRegardless];
|
1999-06-11 04:46:12 +00:00
|
|
|
|
[self makeKeyWindow];
|
1998-12-22 12:34:03 +00:00
|
|
|
|
/*
|
|
|
|
|
* OPENSTEP makes a window the main window when it makes it the key window.
|
|
|
|
|
* So we do the same (though the documentation doesn't mention it).
|
|
|
|
|
*/
|
|
|
|
|
[self makeMainWindow];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-12-22 12:34:03 +00:00
|
|
|
|
- (void) makeKeyWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (!_f.visible || _f.is_miniaturized || _f.is_key == YES)
|
2002-03-31 20:17:20 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (![self canBecomeKeyWindow])
|
1998-12-22 12:34:03 +00:00
|
|
|
|
return;
|
1999-06-09 08:54:08 +00:00
|
|
|
|
[[NSApp keyWindow] resignKeyWindow];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[self becomeKeyWindow];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) makeMainWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (!_f.visible || _f.is_miniaturized || _f.is_main == YES)
|
2002-03-31 20:17:20 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (![self canBecomeMainWindow])
|
|
|
|
|
return;
|
1999-06-09 08:54:08 +00:00
|
|
|
|
[[NSApp mainWindow] resignMainWindow];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[self becomeMainWindow];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-10 19:40:43 +00:00
|
|
|
|
/**
|
2006-11-06 13:58:37 +00:00
|
|
|
|
* Orders the window to the back of its level. Equivalent to
|
|
|
|
|
* -orderWindow:relativeTo: with arguments NSWindowBelow and 0.
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) orderBack: (id)sender
|
1999-07-06 18:22:58 +00:00
|
|
|
|
{
|
|
|
|
|
[self orderWindow: NSWindowBelow relativeTo: 0];
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2004-01-10 19:40:43 +00:00
|
|
|
|
/**
|
2006-11-06 13:58:37 +00:00
|
|
|
|
* If the application is active, orders the window to the front in its
|
|
|
|
|
* level. If the application is not active, the window is ordered in as
|
|
|
|
|
* far forward as possible in its level without being ordered in front
|
|
|
|
|
* of the key or main window of the currently active app. The current key
|
|
|
|
|
* and main window status is not changed. Equivalent to
|
|
|
|
|
* -orderWindow:relativeTo: with arguments NSWindowAbove and 0.
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) orderFront: (id)sender
|
1999-07-06 18:22:58 +00:00
|
|
|
|
{
|
2004-01-10 19:40:43 +00:00
|
|
|
|
[self orderWindow: NSWindowAbove relativeTo: 0];
|
1999-07-06 18:22:58 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2004-01-10 19:40:43 +00:00
|
|
|
|
/**
|
|
|
|
|
Orders the window to the front in its level (even in front of the
|
|
|
|
|
key and main windows of the current app) regardless of whether the
|
|
|
|
|
app is current or not. This method should only be used in rare cases
|
|
|
|
|
where the app is cooperating with another app that is displaying
|
|
|
|
|
data for it. The current key and main window status is not changed.
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) orderFrontRegardless
|
1999-07-06 18:22:58 +00:00
|
|
|
|
{
|
2004-01-10 19:40:43 +00:00
|
|
|
|
[self orderWindow: NSWindowAbove relativeTo: -1];
|
1999-07-06 18:22:58 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2004-01-10 19:40:43 +00:00
|
|
|
|
/**
|
2006-11-06 13:58:37 +00:00
|
|
|
|
* Orders the window out from the screen. Equivalent to
|
|
|
|
|
* -orderWindow:relativeTo: with arguments NSWindowOut and 0.
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) orderOut: (id)sender
|
1999-07-06 18:22:58 +00:00
|
|
|
|
{
|
|
|
|
|
[self orderWindow: NSWindowOut relativeTo: 0];
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2004-01-10 19:40:43 +00:00
|
|
|
|
/**
|
|
|
|
|
<p>
|
|
|
|
|
If place is NSWindowOut, removes the window from the screen. If
|
|
|
|
|
place is NSWindowAbove, places the window directly above otherWin,
|
|
|
|
|
or directly above all windows in its level if otherWin is 0. If
|
|
|
|
|
place is NSWindowBelow, places the window directly below otherWin,
|
|
|
|
|
or directly below all windows in its level if otherWin is 0.
|
|
|
|
|
</p>
|
2006-11-06 13:58:37 +00:00
|
|
|
|
<p>If otherWin is zero and the key window is at the same window level
|
|
|
|
|
as the receiver, the receiver cannot be positioned above the key window.
|
|
|
|
|
</p>
|
2004-01-10 19:40:43 +00:00
|
|
|
|
<p>
|
|
|
|
|
If place is NSWindowAbove or NSWindowBelow and the application is
|
|
|
|
|
hidden, the application is unhidden.
|
2004-07-29 15:13:36 +00:00
|
|
|
|
</p>
|
2004-01-10 19:40:43 +00:00
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
As a special undocumented case (for -orderFrontRegardless), if otherWin
|
2006-11-06 13:58:37 +00:00
|
|
|
|
is minus one, then the backend should not try to keep the window below the
|
2004-01-10 19:40:43 +00:00
|
|
|
|
current key/main window
|
|
|
|
|
*/
|
2013-01-27 20:28:35 +00:00
|
|
|
|
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (NSInteger)otherWin
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2002-03-28 03:53:18 +00:00
|
|
|
|
GSDisplayServer *srv = GSServerForWindow(self);
|
2000-09-27 22:18:34 +00:00
|
|
|
|
BOOL display = NO;
|
|
|
|
|
|
2009-10-17 05:35:56 +00:00
|
|
|
|
if (YES == [[NSUserDefaults standardUserDefaults]
|
|
|
|
|
boolForKey: @"GSBackgroundApp"])
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-29 06:12:34 +00:00
|
|
|
|
if (place == NSWindowOut)
|
|
|
|
|
{
|
2006-10-02 05:09:48 +00:00
|
|
|
|
if (_windowNum == 0)
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
return; /* This deferred window was never ordered in. */
|
2007-08-28 22:01:29 +00:00
|
|
|
|
}
|
2000-01-02 20:24:56 +00:00
|
|
|
|
_f.visible = NO;
|
2004-01-25 14:16:09 +00:00
|
|
|
|
/*
|
|
|
|
|
* Don't keep trying to update the window while it is ordered out
|
|
|
|
|
*/
|
2011-02-20 18:24:44 +00:00
|
|
|
|
[[self class] _removeAutodisplayedWindow: self];
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[self _lossOfKeyOrMainWindow];
|
1999-11-29 06:12:34 +00:00
|
|
|
|
}
|
2000-09-27 22:18:34 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2002-01-09 20:41:07 +00:00
|
|
|
|
/* Windows need to be constrained when displayed or resized - but only
|
2007-08-28 22:01:29 +00:00
|
|
|
|
titled windows are constrained. Also, and this is the tricky part,
|
2011-05-31 09:59:48 +00:00
|
|
|
|
don't constrain if we are merely unhiding the window or if it's
|
2003-05-13 18:26:20 +00:00
|
|
|
|
already visible and is just being reordered. */
|
2002-01-09 20:41:07 +00:00
|
|
|
|
if ((_styleMask & NSTitledWindowMask)
|
2007-08-28 22:01:29 +00:00
|
|
|
|
&& [NSApp isHidden] == NO
|
|
|
|
|
&& _f.visible == NO)
|
|
|
|
|
{
|
|
|
|
|
NSRect nframe = [self constrainFrameRect: _frame
|
|
|
|
|
toScreen: [self screen]];
|
|
|
|
|
[self setFrame: nframe display: NO];
|
|
|
|
|
}
|
2000-09-27 22:18:34 +00:00
|
|
|
|
// create deferred window
|
2001-07-30 14:17:37 +00:00
|
|
|
|
if (_windowNum == 0)
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
[self _initBackendWindow];
|
|
|
|
|
display = YES;
|
|
|
|
|
}
|
2000-09-27 22:18:34 +00:00
|
|
|
|
}
|
2003-04-09 07:18:44 +00:00
|
|
|
|
|
2011-05-31 09:59:48 +00:00
|
|
|
|
/* If a hide on deactivate window is explicitly ordered in or out while
|
|
|
|
|
the application is not active, remove it from the list of inactive
|
|
|
|
|
windows. */
|
|
|
|
|
if ([self hidesOnDeactivate] && ![NSApp isActive])
|
|
|
|
|
{
|
|
|
|
|
[NSApp _setWindow: self inactive: NO];
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-09 07:18:44 +00:00
|
|
|
|
// Draw content before backend window ordering
|
|
|
|
|
if (display)
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv display];
|
2003-09-23 17:16:59 +00:00
|
|
|
|
else if (place != NSWindowOut)
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv displayIfNeeded];
|
2003-05-13 18:26:20 +00:00
|
|
|
|
|
2004-01-10 19:40:43 +00:00
|
|
|
|
/* The backend will keep us below the current key window unless we
|
|
|
|
|
force it not too */
|
|
|
|
|
if ((otherWin == 0
|
|
|
|
|
|| otherWin == [[NSApp keyWindow] windowNumber]
|
|
|
|
|
|| otherWin == [[NSApp mainWindow] windowNumber])
|
|
|
|
|
&& [NSApp isActive])
|
|
|
|
|
otherWin = -1;
|
|
|
|
|
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[srv orderwindow: place : otherWin : _windowNum];
|
2000-09-27 22:18:34 +00:00
|
|
|
|
if (display)
|
|
|
|
|
[self display];
|
|
|
|
|
|
1999-12-14 16:53:23 +00:00
|
|
|
|
if (place != NSWindowOut)
|
1999-12-01 12:02:09 +00:00
|
|
|
|
{
|
2003-11-25 16:27:15 +00:00
|
|
|
|
/*
|
|
|
|
|
* Once we are ordered back in, we will want to update the window
|
|
|
|
|
* whenever there is anything to do.
|
|
|
|
|
*/
|
2011-02-20 18:24:44 +00:00
|
|
|
|
[[self class] _addAutodisplayedWindow: self];
|
2003-11-25 16:27:15 +00:00
|
|
|
|
|
2000-02-25 17:43:32 +00:00
|
|
|
|
if (_f.has_closed == YES)
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_f.has_closed = NO; /* A closed window has re-opened */
|
2007-08-28 22:01:29 +00:00
|
|
|
|
}
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.has_opened == NO)
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
_f.has_opened = YES;
|
|
|
|
|
if (_f.menu_exclude == NO)
|
|
|
|
|
{
|
|
|
|
|
[NSApp addWindowsItem: self
|
|
|
|
|
title: _windowTitle
|
2012-10-03 12:58:26 +00:00
|
|
|
|
filename: [self _hasTitleWithRepresentedFilename]];
|
2007-08-28 22:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-12-14 16:53:23 +00:00
|
|
|
|
if ([self isKeyWindow] == YES)
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
[_wv setInputState: GSTitleBarKey];
|
|
|
|
|
[srv setinputfocus: _windowNum];
|
|
|
|
|
}
|
2000-10-16 19:20:32 +00:00
|
|
|
|
_f.visible = YES;
|
1999-12-01 12:02:09 +00:00
|
|
|
|
}
|
2003-02-02 00:58:32 +00:00
|
|
|
|
else if ([self isOneShot])
|
|
|
|
|
{
|
|
|
|
|
[self _terminateBackendWindow];
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) resignKeyWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (_f.is_key == YES)
|
1999-11-22 15:03:41 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ((_firstResponder != self)
|
2007-08-28 22:01:29 +00:00
|
|
|
|
&& [_firstResponder respondsToSelector: @selector(resignKeyWindow)])
|
|
|
|
|
[_firstResponder resignKeyWindow];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
2010-01-17 06:01:58 +00:00
|
|
|
|
_f.is_key = NO;
|
|
|
|
|
|
|
|
|
|
if (_f.is_main == YES)
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
[_wv setInputState: GSTitleBarMain];
|
|
|
|
|
}
|
2000-03-06 21:10:08 +00:00
|
|
|
|
else
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
[_wv setInputState: GSTitleBarNormal];
|
|
|
|
|
}
|
1999-11-22 15:03:41 +00:00
|
|
|
|
[self discardCursorRects];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
1999-11-22 15:03:41 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidResignKeyNotification object: self];
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) resignMainWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (_f.is_main == YES)
|
1999-11-22 15:03:41 +00:00
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
_f.is_main = NO;
|
|
|
|
|
if (_f.is_key == YES)
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
[_wv setInputState: GSTitleBarKey];
|
|
|
|
|
}
|
2000-03-06 21:10:08 +00:00
|
|
|
|
else
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
[_wv setInputState: GSTitleBarNormal];
|
|
|
|
|
}
|
1999-11-22 15:03:41 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setHidesOnDeactivate: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (flag != _f.hides_on_deactivate)
|
|
|
|
|
{
|
|
|
|
|
_f.hides_on_deactivate = flag;
|
2011-05-31 09:59:48 +00:00
|
|
|
|
if (![NSApp isActive])
|
|
|
|
|
{
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
if (_f.visible)
|
|
|
|
|
{
|
|
|
|
|
/* Order is important here. We must first order out the window
|
|
|
|
|
and then add it to the inactive list, since -orderOut:
|
|
|
|
|
removes the receiver from the inactive list. */
|
|
|
|
|
[self orderOut: nil];
|
|
|
|
|
[NSApp _setWindow: self inactive: YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ([NSApp _isWindowInactive: self])
|
|
|
|
|
{
|
|
|
|
|
[NSApp _setWindow: self inactive: NO];
|
|
|
|
|
[self orderFront: nil];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-11-15 21:45:56 +00:00
|
|
|
|
}
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
- (void) setLevel: (NSInteger)newLevel
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (_windowLevel != newLevel)
|
2000-03-08 21:26:11 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_windowLevel = newLevel;
|
2000-09-29 03:55:30 +00:00
|
|
|
|
if (_windowNum > 0)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
GSDisplayServer *srv = GSServerForWindow(self);
|
|
|
|
|
[srv setwindowlevel: _windowLevel : _windowNum];
|
|
|
|
|
}
|
2000-03-08 21:26:11 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (NSPoint) cascadeTopLeftFromPoint: (NSPoint)topLeftPoint
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSRect cRect;
|
2003-02-02 00:58:32 +00:00
|
|
|
|
|
2006-09-06 11:29:20 +00:00
|
|
|
|
if (NSEqualPoints(topLeftPoint, NSZeroPoint) == YES)
|
|
|
|
|
{
|
2007-09-30 22:02:14 +00:00
|
|
|
|
topLeftPoint.x = NSMinX(_frame);
|
|
|
|
|
topLeftPoint.y = NSMaxY(_frame);
|
2006-09-06 11:29:20 +00:00
|
|
|
|
}
|
2007-09-30 22:02:14 +00:00
|
|
|
|
|
2003-02-02 00:58:32 +00:00
|
|
|
|
[self setFrameTopLeftPoint: topLeftPoint];
|
2008-10-20 13:28:28 +00:00
|
|
|
|
cRect = [self contentRectForFrameRect: _frame];
|
2007-09-30 22:02:14 +00:00
|
|
|
|
topLeftPoint.x = NSMinX(cRect);
|
|
|
|
|
topLeftPoint.y = NSMaxY(cRect);
|
|
|
|
|
|
|
|
|
|
/* make sure the new point is inside the screen */
|
|
|
|
|
if ([self screen])
|
|
|
|
|
{
|
|
|
|
|
NSRect screenRect;
|
|
|
|
|
|
|
|
|
|
screenRect = [[self screen] visibleFrame];
|
|
|
|
|
if (topLeftPoint.x >= NSMaxX(screenRect))
|
|
|
|
|
{
|
|
|
|
|
topLeftPoint.x = NSMinX(screenRect);
|
|
|
|
|
}
|
|
|
|
|
if (topLeftPoint.y <= NSMinY(screenRect))
|
|
|
|
|
{
|
|
|
|
|
topLeftPoint.y = NSMaxY(screenRect);
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-09-06 11:29:20 +00:00
|
|
|
|
|
2003-02-02 00:58:32 +00:00
|
|
|
|
return topLeftPoint;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 20:25:50 +00:00
|
|
|
|
- (BOOL) showsResizeIndicator
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
NSLog(@"Method %s is not implemented for class %s",
|
2007-09-09 12:19:01 +00:00
|
|
|
|
"showsResizeIndicator", "NSWindow");
|
2001-11-26 20:25:50 +00:00
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setShowsResizeIndicator: (BOOL)show
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
NSLog(@"Method %s is not implemented for class %s",
|
2007-09-09 12:19:01 +00:00
|
|
|
|
"setShowsResizeIndicator:", "NSWindow");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) preservesContentDuringLiveResize
|
|
|
|
|
{
|
|
|
|
|
return _f.preserves_content_during_live_resize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setPreservesContentDuringLiveResize: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
_f.preserves_content_during_live_resize = flag;
|
2001-11-26 20:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setFrame: (NSRect)frameRect
|
2007-09-09 12:19:01 +00:00
|
|
|
|
display: (BOOL)displayFlag
|
|
|
|
|
animate: (BOOL)animationFlag
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
2011-07-24 18:53:07 +00:00
|
|
|
|
if (animationFlag && !NSEqualRects(_frame, frameRect))
|
2005-05-20 14:33:43 +00:00
|
|
|
|
{
|
|
|
|
|
// time that the resize is expected to take in seconds
|
|
|
|
|
NSTimeInterval resizeTime;
|
2011-07-24 18:53:07 +00:00
|
|
|
|
NSArray *animations;
|
|
|
|
|
NSViewAnimation *viewAnimation;
|
2005-05-20 14:33:43 +00:00
|
|
|
|
|
|
|
|
|
resizeTime = [self animationResizeTime: frameRect];
|
2011-07-24 18:53:07 +00:00
|
|
|
|
animations = [NSArray arrayWithObject:
|
|
|
|
|
[NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
|
self, NSViewAnimationTargetKey,
|
|
|
|
|
[NSValue valueWithRect: frameRect], NSViewAnimationEndFrameKey,
|
|
|
|
|
nil]];
|
|
|
|
|
viewAnimation = [[NSViewAnimation alloc] initWithViewAnimations: animations];
|
|
|
|
|
[viewAnimation setAnimationBlockingMode: NSAnimationNonblocking];
|
|
|
|
|
[viewAnimation setDuration: resizeTime];
|
|
|
|
|
if (animationDelegate == nil)
|
2005-05-20 14:33:43 +00:00
|
|
|
|
{
|
2011-07-24 18:53:07 +00:00
|
|
|
|
animationDelegate = [[GSWindowAnimationDelegate alloc] init];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
}
|
2011-07-24 18:53:07 +00:00
|
|
|
|
// The delegate handles the release of the viewAnimation
|
|
|
|
|
[viewAnimation setDelegate: animationDelegate];
|
|
|
|
|
[viewAnimation startAnimation];
|
|
|
|
|
//AUTORELEASE(viewAnimation);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[self setFrame: frameRect display: displayFlag];
|
2005-05-20 14:33:43 +00:00
|
|
|
|
}
|
2001-11-26 20:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
- (NSTimeInterval) animationResizeTime: (NSRect)newFrame
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
2005-05-20 14:33:43 +00:00
|
|
|
|
static float resizeTime = 0;
|
|
|
|
|
float maxDiff;
|
|
|
|
|
|
|
|
|
|
if (resizeTime == 0)
|
|
|
|
|
{
|
|
|
|
|
NSNumber *num;
|
2006-03-05 13:21:33 +00:00
|
|
|
|
num = [[NSUserDefaults standardUserDefaults]
|
|
|
|
|
objectForKey: @"NSWindowResizeTime"];
|
2005-05-20 14:33:43 +00:00
|
|
|
|
if (num != nil)
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
resizeTime = [num floatValue];
|
|
|
|
|
}
|
2005-05-20 14:33:43 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
resizeTime = 0.20;
|
|
|
|
|
}
|
2005-05-20 14:33:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find the biggest difference
|
2015-05-26 17:57:19 +00:00
|
|
|
|
maxDiff = fabs(newFrame.origin.x - _frame.origin.x);
|
|
|
|
|
maxDiff = MAX(maxDiff, fabs(newFrame.origin.y - _frame.origin.y));
|
|
|
|
|
maxDiff = MAX(maxDiff, fabs(newFrame.size.width - _frame.size.width));
|
|
|
|
|
maxDiff = MAX(maxDiff, fabs(newFrame.size.height - _frame.size.height));
|
2005-05-20 14:33:43 +00:00
|
|
|
|
|
|
|
|
|
return (maxDiff * resizeTime) / 150;
|
2001-11-26 20:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) center
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2012-10-13 18:43:38 +00:00
|
|
|
|
NSScreen *screen = [self screen];
|
|
|
|
|
NSSize screenSize;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
NSPoint origin = _frame.origin;
|
2000-03-12 04:35:43 +00:00
|
|
|
|
|
2012-10-13 18:43:38 +00:00
|
|
|
|
if (screen == nil) {
|
|
|
|
|
screen = [NSScreen mainScreen];
|
|
|
|
|
}
|
|
|
|
|
screenSize = [screen visibleFrame].size;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
origin.x = (screenSize.width - _frame.size.width) / 2;
|
|
|
|
|
origin.y = (screenSize.height - _frame.size.height) / 2;
|
2000-09-08 17:07:04 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[self setFrameOrigin: origin];
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-13 07:00:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* Given a proposed frame rectangle, return a modified version
|
|
|
|
|
* which will fit inside the screen.
|
|
|
|
|
*/
|
|
|
|
|
- (NSRect) constrainFrameRect: (NSRect)frameRect toScreen: (NSScreen*)screen
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2015-11-02 21:14:11 +00:00
|
|
|
|
NSRect screenRect;
|
2013-02-16 00:08:33 +00:00
|
|
|
|
CGFloat difference;
|
2000-09-08 17:07:04 +00:00
|
|
|
|
|
2015-11-02 21:14:11 +00:00
|
|
|
|
if (nil == screen)
|
2000-09-08 17:07:04 +00:00
|
|
|
|
{
|
2015-11-02 21:14:11 +00:00
|
|
|
|
return frameRect;
|
2000-09-08 17:07:04 +00:00
|
|
|
|
}
|
2014-08-18 16:16:52 +00:00
|
|
|
|
|
2015-11-02 21:14:11 +00:00
|
|
|
|
screenRect = [screen visibleFrame];
|
|
|
|
|
|
|
|
|
|
if (NSHeight(frameRect) < NSHeight(screenRect))
|
2014-08-18 16:16:52 +00:00
|
|
|
|
{
|
2015-11-02 21:14:11 +00:00
|
|
|
|
/* Move top edge of the window inside the screen */
|
|
|
|
|
difference = NSMaxY (frameRect) - NSMaxY (screenRect);
|
|
|
|
|
if (difference > 0)
|
|
|
|
|
{
|
|
|
|
|
frameRect.origin.y -= difference;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Move bottom edge of the window inside the screen */
|
|
|
|
|
difference = screenRect.origin.y - frameRect.origin.y;
|
|
|
|
|
if (difference > 0)
|
|
|
|
|
{
|
|
|
|
|
frameRect.origin.y += difference;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-08-18 16:16:52 +00:00
|
|
|
|
}
|
2015-11-02 21:14:11 +00:00
|
|
|
|
else
|
2000-09-08 17:07:04 +00:00
|
|
|
|
{
|
2015-11-02 21:14:11 +00:00
|
|
|
|
/* If the window is resizable, resize it so that
|
|
|
|
|
it fits on the screen. */
|
|
|
|
|
if (_styleMask & NSResizableWindowMask)
|
2004-11-07 18:03:50 +00:00
|
|
|
|
{
|
2015-11-02 21:14:11 +00:00
|
|
|
|
/* Ensure that resizing doesn't make window smaller than minimum */
|
|
|
|
|
if (_minimumSize.height < NSHeight(screenRect))
|
|
|
|
|
{
|
|
|
|
|
frameRect.origin.y = NSMinY(screenRect);
|
|
|
|
|
frameRect.size.height = NSHeight(screenRect);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
frameRect.origin.y = NSMaxY(screenRect) - _minimumSize.height;
|
|
|
|
|
frameRect.size.height = _minimumSize.height;
|
|
|
|
|
}
|
2004-11-07 18:03:50 +00:00
|
|
|
|
}
|
2015-11-03 08:15:02 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Move top edge of the window to the screen limit */
|
|
|
|
|
frameRect.origin.y -= NSMaxY(frameRect) - NSMaxY(screenRect);
|
|
|
|
|
}
|
2015-11-02 21:14:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NSWidth(frameRect) < NSWidth(screenRect))
|
|
|
|
|
{
|
|
|
|
|
/* Move right edge of the window inside the screen */
|
|
|
|
|
difference = NSMaxX (frameRect) - NSMaxX (screenRect);
|
|
|
|
|
if (difference > 0)
|
|
|
|
|
{
|
|
|
|
|
frameRect.origin.x -= difference;
|
|
|
|
|
}
|
|
|
|
|
else
|
2004-11-07 18:03:50 +00:00
|
|
|
|
{
|
2015-11-02 21:14:11 +00:00
|
|
|
|
/* Move left edge of the window inside the screen */
|
|
|
|
|
difference = screenRect.origin.x - frameRect.origin.x;
|
|
|
|
|
if (difference > 0)
|
|
|
|
|
{
|
|
|
|
|
frameRect.origin.x += difference;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* If the window is resizable, resize it so that
|
|
|
|
|
it fits on the screen. */
|
|
|
|
|
if (_styleMask & NSResizableWindowMask)
|
|
|
|
|
{
|
|
|
|
|
/* Ensure that resizing doesn't make window smaller than minimum */
|
|
|
|
|
if (_minimumSize.width < NSWidth(screenRect))
|
|
|
|
|
{
|
|
|
|
|
frameRect.origin.x = NSMinX(screenRect);
|
|
|
|
|
frameRect.size.width = NSWidth(screenRect);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
frameRect.origin.x = NSMaxX(screenRect) - _minimumSize.width;
|
|
|
|
|
frameRect.size.width = _minimumSize.width;
|
|
|
|
|
}
|
2004-11-07 18:03:50 +00:00
|
|
|
|
}
|
2015-11-03 08:15:02 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Move right edge of the window to the screen limit */
|
|
|
|
|
frameRect.origin.x -= NSMaxX(frameRect) - NSMaxX(screenRect);
|
|
|
|
|
}
|
2000-09-08 17:07:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return frameRect;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSRect) frame
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _frame;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSSize) minSize
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _minimumSize;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (NSSize) maxSize
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _maximumSize;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setContentSize: (NSSize)aSize
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSRect r = _frame;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
|
|
|
|
r.size = aSize;
|
2008-10-20 13:28:28 +00:00
|
|
|
|
r = [self frameRectForContentRect: r];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
r.origin = _frame.origin;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[self setFrame: r display: YES];
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setFrame: (NSRect)frameRect display: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (_maximumSize.width > 0 && frameRect.size.width > _maximumSize.width)
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
frameRect.size.width = _maximumSize.width;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
}
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (_maximumSize.height > 0 && frameRect.size.height > _maximumSize.height)
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
2014-05-03 18:32:20 +00:00
|
|
|
|
frameRect.size.height = _maximumSize.height;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
}
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (frameRect.size.width < _minimumSize.width)
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
frameRect.size.width = _minimumSize.width;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
}
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (frameRect.size.height < _minimumSize.height)
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
frameRect.size.height = _minimumSize.height;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
}
|
2004-11-07 18:03:50 +00:00
|
|
|
|
|
|
|
|
|
/* Windows need to be constrained when displayed or resized - but only
|
|
|
|
|
titled windows are constrained */
|
|
|
|
|
if (_styleMask & NSTitledWindowMask)
|
|
|
|
|
{
|
|
|
|
|
frameRect = [self constrainFrameRect: frameRect toScreen: [self screen]];
|
|
|
|
|
}
|
2007-09-09 12:19:01 +00:00
|
|
|
|
|
2002-03-31 20:17:20 +00:00
|
|
|
|
// If nothing changes, don't send it to the backend and don't redisplay
|
|
|
|
|
if (NSEqualRects(_frame, frameRect))
|
|
|
|
|
return;
|
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (NSEqualPoints(_frame.origin, frameRect.origin) == NO)
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[nc postNotificationName: NSWindowWillMoveNotification object: self];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Now we can tell the graphics context to do the actual resizing.
|
1999-11-16 07:00:43 +00:00
|
|
|
|
* We will recieve an event to tell us when the resize is done.
|
1999-07-06 05:37:15 +00:00
|
|
|
|
*/
|
2002-09-23 05:52:36 +00:00
|
|
|
|
if (_windowNum)
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[GSServerForWindow(self) placewindow: frameRect : _windowNum];
|
2000-09-27 22:18:34 +00:00
|
|
|
|
else
|
2000-10-02 17:48:46 +00:00
|
|
|
|
{
|
|
|
|
|
_frame = frameRect;
|
|
|
|
|
frameRect.origin = NSZeroPoint;
|
|
|
|
|
[_wv setFrame: frameRect];
|
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (flag)
|
|
|
|
|
[self display];
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setFrameOrigin: (NSPoint)aPoint
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSRect r = _frame;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
|
|
|
|
r.origin = aPoint;
|
2000-04-13 19:23:16 +00:00
|
|
|
|
[self setFrame: r display: NO];
|
1999-07-06 05:37:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setFrameTopLeftPoint: (NSPoint)aPoint
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSRect r = _frame;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
1999-08-26 13:51:56 +00:00
|
|
|
|
r.origin = aPoint;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
r.origin.y -= _frame.size.height;
|
2000-04-13 19:23:16 +00:00
|
|
|
|
[self setFrame: r display: NO];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setMinSize: (NSSize)aSize
|
|
|
|
|
{
|
1999-07-25 11:54:26 +00:00
|
|
|
|
if (aSize.width < 1)
|
|
|
|
|
aSize.width = 1;
|
|
|
|
|
if (aSize.height < 1)
|
|
|
|
|
aSize.height = 1;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_minimumSize = aSize;
|
2000-09-29 03:55:30 +00:00
|
|
|
|
if (_windowNum > 0)
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[GSServerForWindow(self) setminsize: aSize : _windowNum];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setMaxSize: (NSSize)aSize
|
|
|
|
|
{
|
1999-09-09 02:56:20 +00:00
|
|
|
|
/*
|
|
|
|
|
* Documented maximum size for macOS-X - do we need this restriction?
|
|
|
|
|
*/
|
|
|
|
|
if (aSize.width > 10000)
|
|
|
|
|
aSize.width = 10000;
|
|
|
|
|
if (aSize.height > 10000)
|
|
|
|
|
aSize.height = 10000;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_maximumSize = aSize;
|
2000-09-29 03:55:30 +00:00
|
|
|
|
if (_windowNum > 0)
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[GSServerForWindow(self) setmaxsize: aSize : _windowNum];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
|
- (NSSize) resizeIncrements
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _increments;
|
1999-05-04 13:17:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setResizeIncrements: (NSSize)aSize
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_increments = aSize;
|
2000-09-29 03:55:30 +00:00
|
|
|
|
if (_windowNum > 0)
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[GSServerForWindow(self) setresizeincrements: aSize : _windowNum];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
- (NSSize) aspectRatio
|
|
|
|
|
{
|
|
|
|
|
// FIXME: This method is missing
|
|
|
|
|
return NSMakeSize(1, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setAspectRatio: (NSSize)ratio
|
|
|
|
|
{
|
|
|
|
|
// FIXME: This method is missing
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
- (NSSize) contentMaxSize
|
|
|
|
|
{
|
|
|
|
|
// FIXME
|
|
|
|
|
NSRect rect;
|
|
|
|
|
|
|
|
|
|
rect.origin = NSMakePoint(0, 0);
|
|
|
|
|
rect.size = [self maxSize];
|
|
|
|
|
rect = [self contentRectForFrameRect: rect];
|
|
|
|
|
return rect.size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setContentMaxSize: (NSSize)size
|
|
|
|
|
{
|
|
|
|
|
// FIXME
|
|
|
|
|
NSRect rect;
|
|
|
|
|
|
|
|
|
|
rect.origin = NSMakePoint(0, 0);
|
|
|
|
|
rect.size = size;
|
|
|
|
|
rect = [self frameRectForContentRect: rect];
|
|
|
|
|
[self setMaxSize: rect.size];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSSize) contentMinSize
|
|
|
|
|
{
|
|
|
|
|
// FIXME
|
|
|
|
|
NSRect rect;
|
|
|
|
|
|
|
|
|
|
rect.origin = NSMakePoint(0, 0);
|
|
|
|
|
rect.size = [self minSize];
|
|
|
|
|
rect = [self contentRectForFrameRect: rect];
|
|
|
|
|
return rect.size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setContentMinSize: (NSSize)size
|
|
|
|
|
{
|
|
|
|
|
// FIXME
|
|
|
|
|
NSRect rect;
|
|
|
|
|
|
|
|
|
|
rect.origin = NSMakePoint(0, 0);
|
|
|
|
|
rect.size = size;
|
|
|
|
|
rect = [self frameRectForContentRect: rect];
|
|
|
|
|
[self setMinSize: rect.size];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSSize) contentAspectRatio
|
|
|
|
|
{
|
|
|
|
|
// FIXME
|
|
|
|
|
return NSMakeSize(1, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setContentAspectRatio: (NSSize)ratio
|
|
|
|
|
{
|
|
|
|
|
// FIXME
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSSize) contentResizeIncrements
|
|
|
|
|
{
|
|
|
|
|
// FIXME
|
|
|
|
|
return [self resizeIncrements];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setContentResizeIncrements: (NSSize)increments
|
|
|
|
|
{
|
|
|
|
|
// FIXME
|
|
|
|
|
[self setResizeIncrements: increments];
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-13 07:00:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* Convert from a point in the base coordinate system for the window
|
|
|
|
|
* to a point in the screen coordinate system.
|
1999-06-11 04:46:12 +00:00
|
|
|
|
*/
|
2002-10-13 07:00:38 +00:00
|
|
|
|
- (NSPoint) convertBaseToScreen: (NSPoint)aPoint
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
NSPoint screenPoint;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
screenPoint.x = _frame.origin.x + aPoint.x;
|
|
|
|
|
screenPoint.y = _frame.origin.y + aPoint.y;
|
1999-06-10 03:05:11 +00:00
|
|
|
|
return screenPoint;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-13 07:00:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* Convert from a point in the screen coordinate system to a point in the
|
|
|
|
|
* screen coordinate system of the receiver.
|
|
|
|
|
*/
|
|
|
|
|
- (NSPoint) convertScreenToBase: (NSPoint)aPoint
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
NSPoint basePoint;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
basePoint.x = aPoint.x - _frame.origin.x;
|
|
|
|
|
basePoint.y = aPoint.y - _frame.origin.y;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return basePoint;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2013-04-24 09:25:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* Converts aRect from the coordinate system of the screen
|
|
|
|
|
* to the coordinate system of the window.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
- (NSRect) convertRectFromScreen: (NSRect)aRect
|
|
|
|
|
{
|
|
|
|
|
NSRect result = aRect;
|
|
|
|
|
NSPoint origin = result.origin;
|
|
|
|
|
NSPoint newOrigin = [self convertScreenToBase: origin];
|
|
|
|
|
result.origin = newOrigin;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Converts aRect from the window coordinate system to a rect in
|
|
|
|
|
* the screen coordinate system.
|
|
|
|
|
*/
|
|
|
|
|
- (NSRect) convertRectToScreen: (NSRect)aRect
|
|
|
|
|
{
|
|
|
|
|
NSRect result = aRect;
|
|
|
|
|
NSPoint origin = result.origin;
|
|
|
|
|
NSPoint newOrigin = [self convertBaseToScreen: origin];
|
|
|
|
|
result.origin = newOrigin;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Managing the display
|
|
|
|
|
*/
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) disableFlushWindow
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_disableFlushWindow++;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1997-10-09 22:55:31 +00:00
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) display
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-09-27 22:18:34 +00:00
|
|
|
|
if (_gstate == 0 || _f.visible == NO)
|
|
|
|
|
return;
|
|
|
|
|
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv display];
|
2002-07-12 11:12:32 +00:00
|
|
|
|
[self discardCachedImage];
|
2007-03-08 12:52:01 +00:00
|
|
|
|
_f.views_need_display = NO;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) displayIfNeeded
|
1996-10-03 18:45:41 +00:00
|
|
|
|
{
|
2007-03-08 12:52:01 +00:00
|
|
|
|
if (_gstate == 0 || _f.visible == NO)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (_f.views_need_display)
|
1999-02-12 17:00:59 +00:00
|
|
|
|
{
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv displayIfNeeded];
|
2007-03-08 12:52:01 +00:00
|
|
|
|
[self discardCachedImage];
|
|
|
|
|
_f.views_need_display = NO;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-23 23:41:07 +00:00
|
|
|
|
- (void) update
|
|
|
|
|
{
|
1998-12-22 12:34:03 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidUpdateNotification object: self];
|
1998-11-20 02:14:22 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) flushWindowIfNeeded
|
1996-10-03 18:45:41 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (_disableFlushWindow == 0 && _f.needs_flush == YES)
|
1999-02-12 17:00:59 +00:00
|
|
|
|
{
|
|
|
|
|
[self flushWindow];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-28 08:05:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Flush all drawing in the windows buffer to the screen unless the window
|
|
|
|
|
* is not buffered or flushing is not enabled.
|
|
|
|
|
*/
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) flushWindow
|
|
|
|
|
{
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger i;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
|
2002-06-28 08:05:49 +00:00
|
|
|
|
/*
|
|
|
|
|
* If flushWindow is called while flush is disabled
|
|
|
|
|
* mark self as needing a flush, then return
|
|
|
|
|
*/
|
|
|
|
|
if (_disableFlushWindow)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
2002-06-28 08:05:49 +00:00
|
|
|
|
_f.needs_flush = YES;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-28 08:05:49 +00:00
|
|
|
|
/*
|
|
|
|
|
* Just flush graphics if backing is not buffered.
|
|
|
|
|
* The documentation actually says that this is wrong ... the method
|
|
|
|
|
* should do nothing when the backingType is NSBackingStoreNonretained
|
|
|
|
|
*/
|
|
|
|
|
if (_backingType == NSBackingStoreNonretained)
|
|
|
|
|
{
|
2007-04-04 14:33:39 +00:00
|
|
|
|
[_context flushGraphics];
|
2002-06-28 08:05:49 +00:00
|
|
|
|
return;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check for special case of flushing while we are lock focused.
|
|
|
|
|
For instance, when we are highlighting a button. */
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (NSIsEmptyRect(_rectNeedingFlush))
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ([_rectsBeingDrawn count] == 0)
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
|
|
|
|
_f.needs_flush = NO;
|
|
|
|
|
return;
|
|
|
|
|
}
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Accumulate the rectangles from all nested focus locks.
|
|
|
|
|
*/
|
2000-09-05 17:22:46 +00:00
|
|
|
|
i = [_rectsBeingDrawn count];
|
1999-10-21 18:08:50 +00:00
|
|
|
|
while (i-- > 0)
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_rectNeedingFlush = NSUnionRect(_rectNeedingFlush,
|
2002-06-28 08:05:49 +00:00
|
|
|
|
[[_rectsBeingDrawn objectAtIndex: i] rectValue]);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
2002-06-28 08:05:49 +00:00
|
|
|
|
if (_windowNum > 0)
|
|
|
|
|
{
|
|
|
|
|
[GSServerForWindow(self) flushwindowrect: _rectNeedingFlush
|
2007-09-09 12:19:01 +00:00
|
|
|
|
: _windowNum];
|
2002-06-28 08:05:49 +00:00
|
|
|
|
}
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.needs_flush = NO;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_rectNeedingFlush = NSZeroRect;
|
1997-10-09 22:55:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) enableFlushWindow
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (_disableFlushWindow > 0)
|
1999-09-06 05:18:16 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_disableFlushWindow--;
|
1999-09-06 05:18:16 +00:00
|
|
|
|
}
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isAutodisplay
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.is_autodisplay;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isFlushWindowDisabled
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _disableFlushWindow == 0 ? NO : YES;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setAutodisplay: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_autodisplay = flag;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1999-02-03 21:53:29 +00:00
|
|
|
|
|
|
|
|
|
- (void) setViewsNeedDisplay: (BOOL)flag
|
|
|
|
|
{
|
2007-03-08 12:52:01 +00:00
|
|
|
|
if (_f.views_need_display != flag)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
2007-03-08 12:52:01 +00:00
|
|
|
|
_f.views_need_display = flag;
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (flag)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
/* TODO: this call most likely shouldn't be here */
|
|
|
|
|
[NSApp setWindowsNeedUpdate: YES];
|
|
|
|
|
}
|
1999-09-09 02:56:20 +00:00
|
|
|
|
}
|
1999-02-03 21:53:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (BOOL) viewsNeedDisplay
|
|
|
|
|
{
|
2007-03-08 12:52:01 +00:00
|
|
|
|
return _f.views_need_display;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) cacheImageInRect: (NSRect)aRect
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2002-07-12 11:12:32 +00:00
|
|
|
|
NSView *cacheView;
|
|
|
|
|
NSRect cacheRect;
|
|
|
|
|
|
2002-07-16 17:42:48 +00:00
|
|
|
|
aRect = NSIntegralRect (NSIntersectionRect (aRect, [_wv frame]));
|
2002-07-12 11:12:32 +00:00
|
|
|
|
_cachedImageOrigin = aRect.origin;
|
|
|
|
|
DESTROY(_cachedImage);
|
|
|
|
|
|
|
|
|
|
if (NSIsEmptyRect (aRect))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cacheRect.origin = NSZeroPoint;
|
|
|
|
|
cacheRect.size = aRect.size;
|
|
|
|
|
_cachedImage = [[NSCachedImageRep alloc] initWithWindow: nil
|
2007-09-09 12:19:01 +00:00
|
|
|
|
rect: cacheRect];
|
2002-07-12 11:12:32 +00:00
|
|
|
|
cacheView = [[_cachedImage window] contentView];
|
|
|
|
|
[cacheView lockFocus];
|
|
|
|
|
NSCopyBits (_gstate, aRect, NSZeroPoint);
|
|
|
|
|
[cacheView unlockFocus];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) discardCachedImage
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2002-07-12 11:12:32 +00:00
|
|
|
|
DESTROY(_cachedImage);
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) restoreCachedImage
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2002-07-12 11:12:32 +00:00
|
|
|
|
if (_cachedImage == nil)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-07-16 17:42:48 +00:00
|
|
|
|
[_wv lockFocus];
|
2002-07-12 11:12:32 +00:00
|
|
|
|
NSCopyBits ([[_cachedImage window] gState],
|
2007-09-09 12:19:01 +00:00
|
|
|
|
[_cachedImage rect],
|
|
|
|
|
_cachedImageOrigin);
|
2002-07-16 17:42:48 +00:00
|
|
|
|
[_wv unlockFocus];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) useOptimizedDrawing: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.optimize_drawing = flag;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (BOOL) canStoreColor
|
1996-08-22 18:51:08 +00:00
|
|
|
|
{
|
2002-04-22 15:45:10 +00:00
|
|
|
|
if (NSNumberOfColorComponents(NSColorSpaceFromDepth(_depthLimit)) > 1)
|
2001-02-08 00:00:32 +00:00
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
1999-02-12 17:00:59 +00:00
|
|
|
|
else
|
2001-02-08 00:00:32 +00:00
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
1996-08-22 18:51:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-22 15:45:10 +00:00
|
|
|
|
/** Returns the screen the window is on. Unlike (apparently) OpenStep
|
|
|
|
|
and MacOSX, GNUstep does not support windows being split across
|
|
|
|
|
multiple screens */
|
2001-02-08 00:00:32 +00:00
|
|
|
|
- (NSScreen *) deepestScreen
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2002-04-22 15:45:10 +00:00
|
|
|
|
return [self screen];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSWindowDepth) depthLimit
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _depthLimit;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) hasDynamicDepthLimit
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.dynamic_depth_limit;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-22 15:45:10 +00:00
|
|
|
|
/** Returns the screen the window is on. */
|
2001-02-08 00:00:32 +00:00
|
|
|
|
- (NSScreen *) screen
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2012-08-17 13:16:12 +00:00
|
|
|
|
// Only recompute the screen if the current screen
|
|
|
|
|
// doesn't contain the whole window.
|
|
|
|
|
// FIXME: Containing half the window would be enough
|
|
|
|
|
if (_screen != nil)
|
|
|
|
|
{
|
|
|
|
|
NSRect sframe = [_screen frame];
|
|
|
|
|
if (NSContainsRect(sframe, _frame))
|
|
|
|
|
{
|
|
|
|
|
return _screen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ASSIGN(_screen, [self _screenForFrame: _frame]);
|
2002-04-22 15:45:10 +00:00
|
|
|
|
return _screen;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setDepthLimit: (NSWindowDepth)limit
|
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
if (limit == 0)
|
2001-02-08 00:00:32 +00:00
|
|
|
|
{
|
2011-02-20 18:24:44 +00:00
|
|
|
|
limit = [[self class] defaultDepthLimit];
|
2001-02-08 00:00:32 +00:00
|
|
|
|
}
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_depthLimit = limit;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setDynamicDepthLimit: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.dynamic_depth_limit = flag;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2015-10-28 01:49:12 +00:00
|
|
|
|
- (NSWindowCollectionBehavior)collectionBehavior
|
2015-08-28 22:39:48 +00:00
|
|
|
|
{
|
|
|
|
|
//TODO: we don't handle collections yet and perhaps never will fully
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-28 01:49:12 +00:00
|
|
|
|
- (void)setCollectionBehavior:(NSWindowCollectionBehavior)props
|
2015-08-28 22:39:48 +00:00
|
|
|
|
{
|
|
|
|
|
//TODO we don't handle collections yet. Perhaps certain features can be mapped on existing ones
|
|
|
|
|
//other features are Expose specific or anyway probably not implementable
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Cursor management
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) areCursorRectsEnabled
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.cursor_rects_enabled;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) disableCursorRects
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.cursor_rects_enabled = NO;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-11-15 16:00:47 +00:00
|
|
|
|
static void
|
|
|
|
|
discardCursorRectsForView(NSView *theView)
|
1997-03-05 01:11:17 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (theView != nil)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
2010-03-27 00:01:03 +00:00
|
|
|
|
if (theView->_rFlags.has_currects)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
[theView discardCursorRects];
|
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
|
2010-03-27 00:01:03 +00:00
|
|
|
|
if (theView->_rFlags.has_subviews)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
2010-03-27 00:01:03 +00:00
|
|
|
|
NSArray *s = theView->_sub_views;
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger count = [s count];
|
1999-11-15 16:00:47 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
if (count)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger i;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
[s getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
discardCursorRectsForView(subs[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-07 20:08:51 +00:00
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) discardCursorRects
|
1997-03-05 01:11:17 +00:00
|
|
|
|
{
|
1999-12-17 12:06:35 +00:00
|
|
|
|
discardCursorRectsForView(_wv);
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) enableCursorRects
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.cursor_rects_enabled = YES;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) invalidateCursorRectsForView: (NSView*)aView
|
1997-03-05 01:11:17 +00:00
|
|
|
|
{
|
2010-03-27 00:01:03 +00:00
|
|
|
|
if (aView->_rFlags.valid_rects)
|
1999-11-15 16:00:47 +00:00
|
|
|
|
{
|
2006-06-09 17:33:11 +00:00
|
|
|
|
[aView discardCursorRects];
|
2006-05-27 21:54:29 +00:00
|
|
|
|
|
|
|
|
|
if (_f.cursor_rects_valid)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (_f.is_key && _f.cursor_rects_enabled)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
NSEvent *e = [NSEvent otherEventWithType: NSAppKitDefined
|
|
|
|
|
location: NSMakePoint(-1, -1)
|
|
|
|
|
modifierFlags: 0
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: _windowNum
|
|
|
|
|
context: GSCurrentContext()
|
|
|
|
|
subtype: -1
|
|
|
|
|
data1: 0
|
|
|
|
|
data2: 0];
|
|
|
|
|
[self postEvent: e atStart: YES];
|
|
|
|
|
}
|
|
|
|
|
_f.cursor_rects_valid = NO;
|
|
|
|
|
}
|
1999-11-15 16:00:47 +00:00
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-15 16:00:47 +00:00
|
|
|
|
static void
|
|
|
|
|
resetCursorRectsForView(NSView *theView)
|
1997-03-05 01:11:17 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (theView != nil)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
[theView resetCursorRects];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
|
2010-03-27 00:01:03 +00:00
|
|
|
|
if (theView->_rFlags.has_subviews)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
2010-03-27 00:01:03 +00:00
|
|
|
|
NSArray *s = theView->_sub_views;
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger count = [s count];
|
1999-11-15 16:00:47 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
if (count)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger i;
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
[s getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
resetCursorRectsForView(subs[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-07 20:08:51 +00:00
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2013-08-30 11:27:10 +00:00
|
|
|
|
static void
|
|
|
|
|
checkCursorRectanglesEntered(NSView *theView, NSEvent *theEvent, NSPoint lastPoint)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check cursor rectangles for the subviews
|
|
|
|
|
*/
|
|
|
|
|
if (theView->_rFlags.has_subviews)
|
|
|
|
|
{
|
|
|
|
|
NSArray *sb = theView->_sub_views;
|
|
|
|
|
NSUInteger count = [sb count];
|
|
|
|
|
|
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
|
|
|
|
NSUInteger i;
|
|
|
|
|
|
|
|
|
|
[sb getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (![subs[i] isHidden])
|
|
|
|
|
{
|
|
|
|
|
checkCursorRectanglesEntered(subs[i], theEvent, lastPoint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (theView->_rFlags.valid_rects)
|
|
|
|
|
{
|
|
|
|
|
NSArray *tr = theView->_cursor_rects;
|
|
|
|
|
NSUInteger count = [tr count];
|
|
|
|
|
|
|
|
|
|
// Loop through cursor rectangles
|
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
GSTrackingRect *rects[count];
|
|
|
|
|
NSPoint loc = [theEvent locationInWindow];
|
|
|
|
|
NSUInteger i;
|
|
|
|
|
|
|
|
|
|
[tr getObjects: rects];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
|
{
|
|
|
|
|
GSTrackingRect *r = rects[i];
|
|
|
|
|
BOOL last;
|
|
|
|
|
BOOL now;
|
|
|
|
|
|
|
|
|
|
if ([r isValid] == NO)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check for presence of point in rectangle.
|
|
|
|
|
*/
|
|
|
|
|
last = NSMouseInRect(lastPoint, r->rectangle, NO);
|
|
|
|
|
now = NSMouseInRect(loc, r->rectangle, NO);
|
|
|
|
|
|
|
|
|
|
// Mouse entered
|
|
|
|
|
if ((!last) && (now))
|
|
|
|
|
{
|
|
|
|
|
NSEvent *e;
|
|
|
|
|
|
|
|
|
|
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
|
|
|
|
location: loc
|
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
|
context: [theEvent context]
|
|
|
|
|
eventNumber: 0
|
|
|
|
|
trackingNumber: (int)YES
|
|
|
|
|
userData: (void*)r];
|
|
|
|
|
[NSApp postEvent: e atStart: YES];
|
|
|
|
|
//NSLog(@"Add enter event %@ for view %@ rect %@", e, theView, NSStringFromRect(r->rectangle));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
checkCursorRectanglesExited(NSView *theView, NSEvent *theEvent, NSPoint lastPoint)
|
|
|
|
|
{
|
|
|
|
|
if (theView->_rFlags.valid_rects)
|
|
|
|
|
{
|
|
|
|
|
NSArray *tr = theView->_cursor_rects;
|
|
|
|
|
NSUInteger count = [tr count];
|
|
|
|
|
|
|
|
|
|
// Loop through cursor rectangles
|
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
GSTrackingRect *rects[count];
|
|
|
|
|
NSPoint loc = [theEvent locationInWindow];
|
|
|
|
|
NSUInteger i;
|
|
|
|
|
|
|
|
|
|
[tr getObjects: rects];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
|
{
|
|
|
|
|
GSTrackingRect *r = rects[i];
|
|
|
|
|
BOOL last;
|
|
|
|
|
BOOL now;
|
|
|
|
|
|
|
|
|
|
if ([r isValid] == NO)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check for presence of point in rectangle.
|
|
|
|
|
*/
|
|
|
|
|
last = NSMouseInRect(lastPoint, r->rectangle, NO);
|
|
|
|
|
now = NSMouseInRect(loc, r->rectangle, NO);
|
|
|
|
|
|
|
|
|
|
// Mouse exited
|
|
|
|
|
if ((last) && (!now))
|
|
|
|
|
{
|
|
|
|
|
NSEvent *e;
|
|
|
|
|
|
|
|
|
|
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
|
|
|
|
location: loc
|
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
|
context: [theEvent context]
|
|
|
|
|
eventNumber: 0
|
|
|
|
|
trackingNumber: (int)NO
|
|
|
|
|
userData: (void*)r];
|
|
|
|
|
[NSApp postEvent: e atStart: YES];
|
|
|
|
|
//[NSApp postEvent: e atStart: NO];
|
|
|
|
|
//NSLog(@"Add exit event %@ for view %@ rect %@", e, theView, NSStringFromRect(r->rectangle));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check cursor rectangles for the subviews
|
|
|
|
|
*/
|
|
|
|
|
if (theView->_rFlags.has_subviews)
|
|
|
|
|
{
|
|
|
|
|
NSArray *sb = theView->_sub_views;
|
|
|
|
|
NSUInteger count = [sb count];
|
|
|
|
|
|
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
|
|
|
|
NSUInteger i;
|
|
|
|
|
|
|
|
|
|
[sb getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (![subs[i] isHidden])
|
|
|
|
|
{
|
|
|
|
|
checkCursorRectanglesExited(subs[i], theEvent, lastPoint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) resetCursorRects
|
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
[self discardCursorRects];
|
1999-12-17 12:06:35 +00:00
|
|
|
|
resetCursorRectsForView(_wv);
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.cursor_rects_valid = YES;
|
2006-05-27 21:54:29 +00:00
|
|
|
|
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (_f.is_key && _f.cursor_rects_enabled)
|
2006-05-27 21:54:29 +00:00
|
|
|
|
{
|
|
|
|
|
NSPoint loc = [self mouseLocationOutsideOfEventStream];
|
|
|
|
|
if (NSMouseInRect(loc, [_wv bounds], NO))
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
NSEvent *e = [NSEvent mouseEventWithType: NSMouseMoved
|
|
|
|
|
location: loc
|
|
|
|
|
modifierFlags: 0
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: _windowNum
|
|
|
|
|
context: GSCurrentContext()
|
|
|
|
|
eventNumber: 0
|
|
|
|
|
clickCount: 0
|
|
|
|
|
pressure: 0];
|
|
|
|
|
_lastPoint = NSMakePoint(-1,-1);
|
2013-08-30 11:27:10 +00:00
|
|
|
|
checkCursorRectanglesEntered(_wv, e, _lastPoint);
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_lastPoint = loc;
|
|
|
|
|
}
|
2006-05-27 21:54:29 +00:00
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Handling user actions and events
|
|
|
|
|
*/
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (void) close
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-02-25 17:43:32 +00:00
|
|
|
|
if (_f.has_closed == NO)
|
|
|
|
|
{
|
2002-09-16 17:11:12 +00:00
|
|
|
|
CREATE_AUTORELEASE_POOL(pool);
|
2010-04-13 22:54:33 +00:00
|
|
|
|
_f.has_closed = YES;
|
2002-09-16 17:11:12 +00:00
|
|
|
|
|
2002-09-16 17:08:18 +00:00
|
|
|
|
/* The NSWindowCloseNotification might result in us being
|
|
|
|
|
deallocated. To make sure self stays valid as long as is
|
|
|
|
|
necessary, we retain ourselves here and balance it with a
|
|
|
|
|
release later (unless we're supposed to release ourselves when
|
|
|
|
|
we close).
|
|
|
|
|
*/
|
|
|
|
|
if (!_f.is_released_when_closed)
|
2007-08-28 22:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
RETAIN(self);
|
|
|
|
|
}
|
2002-09-16 17:08:18 +00:00
|
|
|
|
|
2002-02-19 02:33:52 +00:00
|
|
|
|
[nc postNotificationName: NSWindowWillCloseNotification object: self];
|
|
|
|
|
_f.has_opened = NO;
|
|
|
|
|
[NSApp removeWindowsItem: self];
|
|
|
|
|
[self orderOut: self];
|
2009-12-21 17:27:56 +00:00
|
|
|
|
|
|
|
|
|
if (_f.is_miniaturized == YES)
|
|
|
|
|
{
|
|
|
|
|
NSWindow *mini = GSWindowWithNumber(_counterpart);
|
|
|
|
|
GSRemoveIcon(mini);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-27 12:42:37 +00:00
|
|
|
|
[pool drain];
|
2002-09-16 17:08:18 +00:00
|
|
|
|
RELEASE(self);
|
2000-02-25 17:43:32 +00:00
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-10-16 19:20:32 +00:00
|
|
|
|
/* Private Method. Many X Window managers will just deminiaturize us without
|
|
|
|
|
telling us to do it ourselves. Deal with it.
|
|
|
|
|
*/
|
|
|
|
|
- (void) _didDeminiaturize: sender
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2009-10-17 15:18:26 +00:00
|
|
|
|
if (_f.is_miniaturized == YES)
|
|
|
|
|
{
|
|
|
|
|
_f.is_miniaturized = NO;
|
|
|
|
|
_f.visible = YES;
|
|
|
|
|
if (self == [NSApp iconWindow])
|
|
|
|
|
{
|
|
|
|
|
[self orderOut: self];
|
2009-10-18 08:02:40 +00:00
|
|
|
|
if ([NSApp isActive] == NO)
|
|
|
|
|
{
|
|
|
|
|
[NSApp activateIgnoringOtherApps: YES];
|
|
|
|
|
}
|
|
|
|
|
if ([NSApp isHidden] == YES)
|
|
|
|
|
{
|
|
|
|
|
[NSApp unhide: self];
|
|
|
|
|
}
|
2009-10-17 15:18:26 +00:00
|
|
|
|
}
|
|
|
|
|
[nc postNotificationName: NSWindowDidDeminiaturizeNotification
|
|
|
|
|
object: self];
|
|
|
|
|
}
|
2000-10-16 19:20:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
/**
|
|
|
|
|
Causes the window to deminiaturize. Normally you would not call this
|
|
|
|
|
method directly. A window is automatically deminiaturized by the
|
2003-10-07 12:34:10 +00:00
|
|
|
|
user via a mouse click event. Does nothing it the window isn't
|
|
|
|
|
miniaturized. */
|
2000-10-16 19:20:32 +00:00
|
|
|
|
- (void) deminiaturize: sender
|
|
|
|
|
{
|
2003-10-07 12:34:10 +00:00
|
|
|
|
if (!_f.is_miniaturized)
|
|
|
|
|
return;
|
|
|
|
|
|
2003-10-21 03:10:24 +00:00
|
|
|
|
/* At least with X-Windows, the counterpart is tied to us, so it will
|
|
|
|
|
automatically be ordered out when we are deminiaturized */
|
2000-03-08 21:26:11 +00:00
|
|
|
|
if (_counterpart != 0)
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSWindow *mini = GSWindowWithNumber(_counterpart);
|
2000-03-08 21:26:11 +00:00
|
|
|
|
|
2009-12-21 17:27:56 +00:00
|
|
|
|
GSRemoveIcon(mini);
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[mini orderOut: self];
|
|
|
|
|
}
|
2007-10-02 21:58:47 +00:00
|
|
|
|
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_miniaturized = NO;
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[self makeKeyAndOrderFront: self];
|
2000-10-16 19:20:32 +00:00
|
|
|
|
[self _didDeminiaturize: sender];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Returns YES, if the document has been changed.
|
|
|
|
|
*/
|
1999-05-04 13:17:26 +00:00
|
|
|
|
- (BOOL) isDocumentEdited
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.is_edited;
|
1999-05-04 13:17:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Returns YES, if the window is released when it is closed.
|
|
|
|
|
*/
|
1999-05-04 13:17:26 +00:00
|
|
|
|
- (BOOL) isReleasedWhenClosed
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.is_released_when_closed;
|
1999-05-04 13:17:26 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
/**
|
|
|
|
|
Causes the window to miniaturize, that is the window is removed from
|
2003-10-07 12:34:10 +00:00
|
|
|
|
the screen and it's counterpart (mini)window is displayed. Does
|
|
|
|
|
nothing if the window can't be miniaturized (eg. because it's already
|
|
|
|
|
miniaturized). */
|
2000-03-08 21:26:11 +00:00
|
|
|
|
- (void) miniaturize: (id)sender
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2002-04-02 03:13:14 +00:00
|
|
|
|
GSDisplayServer *srv = GSServerForWindow(self);
|
2004-11-10 17:12:57 +00:00
|
|
|
|
NSSize iconSize = [GSCurrentServer() iconSize];
|
2003-10-07 12:34:10 +00:00
|
|
|
|
|
2009-10-17 15:18:26 +00:00
|
|
|
|
if (_f.is_miniaturized || (_styleMask & NSMiniWindowMask))
|
|
|
|
|
{
|
|
|
|
|
/* Can't miniaturize a miniwindow or a miniaturized window.
|
|
|
|
|
*/
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self == [NSApp iconWindow])
|
|
|
|
|
{
|
|
|
|
|
if (NO == [[NSUserDefaults standardUserDefaults]
|
|
|
|
|
boolForKey: @"GSSuppressAppIcon"])
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((!(_styleMask & (NSIconWindowMask | NSMiniaturizableWindowMask)))
|
|
|
|
|
|| (_styleMask & NSMiniWindowMask)
|
|
|
|
|
|| (![self isVisible]))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-10-07 12:34:10 +00:00
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
[nc postNotificationName: NSWindowWillMiniaturizeNotification
|
2007-09-09 12:19:01 +00:00
|
|
|
|
object: self];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
_f.is_miniaturized = YES;
|
2001-07-09 02:49:03 +00:00
|
|
|
|
/* Make sure we're not defered */
|
2002-02-09 08:58:37 +00:00
|
|
|
|
if (_windowNum == 0)
|
2001-07-09 02:49:03 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[self _initBackendWindow];
|
2001-07-09 02:49:03 +00:00
|
|
|
|
}
|
2000-03-04 07:55:42 +00:00
|
|
|
|
/*
|
|
|
|
|
* Ensure that we have a miniwindow counterpart.
|
|
|
|
|
*/
|
2002-04-02 03:13:14 +00:00
|
|
|
|
if (_counterpart == 0 && [srv appOwnsMiniwindow])
|
2000-03-01 17:21:08 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSWindow *mini;
|
|
|
|
|
NSMiniWindowView *v;
|
|
|
|
|
NSRect rect = NSMakeRect(0, 0, iconSize.height, iconSize.width);
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
2004-11-10 17:12:57 +00:00
|
|
|
|
mini = [[NSMiniWindow alloc] initWithContentRect: rect
|
2007-09-09 12:19:01 +00:00
|
|
|
|
styleMask: NSMiniWindowMask
|
|
|
|
|
backing: NSBackingStoreBuffered
|
|
|
|
|
defer: NO];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
mini->_counterpart = [self windowNumber];
|
|
|
|
|
_counterpart = [mini windowNumber];
|
2004-11-10 17:12:57 +00:00
|
|
|
|
v = [[NSMiniWindowView alloc] initWithFrame: rect];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
[v setImage: [self miniwindowImage]];
|
|
|
|
|
[v setTitle: [self miniwindowTitle]];
|
|
|
|
|
[mini setContentView: v];
|
|
|
|
|
RELEASE(v);
|
|
|
|
|
}
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[self _lossOfKeyOrMainWindow];
|
2002-04-02 03:13:14 +00:00
|
|
|
|
[srv miniwindow: _windowNum];
|
2001-04-17 03:17:23 +00:00
|
|
|
|
_f.visible = NO;
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
2003-03-07 09:04:54 +00:00
|
|
|
|
/*
|
|
|
|
|
* We must order the miniwindow in so that we will start sending
|
2004-07-12 23:19:14 +00:00
|
|
|
|
* it messages to tell it to display itsself when neccessary.
|
2003-03-07 09:04:54 +00:00
|
|
|
|
*/
|
|
|
|
|
if (_counterpart != 0)
|
|
|
|
|
{
|
2009-12-21 17:27:56 +00:00
|
|
|
|
NSRect iconRect;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSWindow *mini = GSWindowWithNumber(_counterpart);
|
2009-12-21 17:27:56 +00:00
|
|
|
|
iconRect = GSGetIconFrame(mini);
|
|
|
|
|
[mini setFrame: iconRect display: YES];
|
2003-03-07 09:04:54 +00:00
|
|
|
|
[mini orderFront: self];
|
|
|
|
|
}
|
2000-03-04 07:55:42 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidMiniaturizeNotification
|
2007-09-09 12:19:01 +00:00
|
|
|
|
object: self];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Causes the window to close. Calls the windowShouldClose: method
|
|
|
|
|
on the delegate to determine if it should close and calls
|
|
|
|
|
shouldCloseWindowController on the controller for the receiver.
|
|
|
|
|
*/
|
2000-03-08 21:26:11 +00:00
|
|
|
|
- (void) performClose: (id)sender
|
1998-12-17 13:06:17 +00:00
|
|
|
|
{
|
2002-09-08 04:21:10 +00:00
|
|
|
|
/* Don't close if a modal session is running and we are not the
|
|
|
|
|
modal window */
|
|
|
|
|
if ([NSApp modalWindow] && self != [NSApp modalWindow])
|
2010-11-26 16:07:19 +00:00
|
|
|
|
{
|
|
|
|
|
/* Panel that work in modal session can be closed nevertheless */
|
|
|
|
|
if (![self worksWhenModal])
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-09-08 04:21:10 +00:00
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
|
/* self must have a close button in order to be closed */
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (!(_styleMask & NSClosableWindowMask))
|
1999-05-04 13:17:26 +00:00
|
|
|
|
{
|
|
|
|
|
NSBeep();
|
|
|
|
|
return;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
2000-04-07 23:49:10 +00:00
|
|
|
|
if (_windowController)
|
|
|
|
|
{
|
2003-09-21 02:27:50 +00:00
|
|
|
|
NSDocument *document = [_windowController document];
|
|
|
|
|
|
2003-08-20 14:12:43 +00:00
|
|
|
|
if (document && ![document shouldCloseWindowController: _windowController])
|
2000-04-07 23:49:10 +00:00
|
|
|
|
{
|
|
|
|
|
NSBeep();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowShouldClose:)])
|
1999-05-04 13:17:26 +00:00
|
|
|
|
{
|
|
|
|
|
/*
|
2007-09-09 12:19:01 +00:00
|
|
|
|
* if delegate responds to windowShouldClose query it to see if
|
|
|
|
|
* it's ok to close the window
|
1999-05-04 13:17:26 +00:00
|
|
|
|
*/
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if (![_delegate windowShouldClose: self])
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
NSBeep();
|
|
|
|
|
return;
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-05-04 13:17:26 +00:00
|
|
|
|
/*
|
2007-09-09 12:19:01 +00:00
|
|
|
|
* else if self responds to windowShouldClose query
|
|
|
|
|
* self to see if it's ok to close self
|
1999-05-04 13:17:26 +00:00
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if ([self respondsToSelector: @selector(windowShouldClose:)])
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
if (![self windowShouldClose: self])
|
|
|
|
|
{
|
|
|
|
|
NSBeep();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: The button should be highlighted
|
2003-09-21 02:27:50 +00:00
|
|
|
|
[self close];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Performs the key equivalent represented by theEvent.
|
|
|
|
|
*/
|
1999-06-02 19:43:09 +00:00
|
|
|
|
- (BOOL) performKeyEquivalent: (NSEvent*)theEvent
|
|
|
|
|
{
|
2006-04-29 04:51:26 +00:00
|
|
|
|
if (_contentView)
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return [_contentView performKeyEquivalent: theEvent];
|
1999-06-02 19:43:09 +00:00
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-09 08:58:37 +00:00
|
|
|
|
/**
|
|
|
|
|
* Miniaturize the receiver ... as long as its style mask includes
|
|
|
|
|
* NSMiniaturizableWindowMask (and as long as the receiver is not an
|
2003-07-22 16:32:30 +00:00
|
|
|
|
* icon or mini window itsself). Calls -miniaturize: to do this.<br />
|
2002-02-09 08:58:37 +00:00
|
|
|
|
* Beeps if the window can't be miniaturised.<br />
|
|
|
|
|
* Should ideally provide visual feedback (highlighting the miniaturize
|
|
|
|
|
* button as if it had been clicked) first ... but that's not yet implemented.
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) performMiniaturize: (id)sender
|
|
|
|
|
{
|
2002-02-09 08:58:37 +00:00
|
|
|
|
if ((!(_styleMask & NSMiniaturizableWindowMask))
|
|
|
|
|
|| (_styleMask & (NSIconWindowMask | NSMiniWindowMask)))
|
2000-03-01 17:21:08 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
NSBeep();
|
2002-02-09 08:58:37 +00:00
|
|
|
|
return;
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
2002-02-09 08:58:37 +00:00
|
|
|
|
|
|
|
|
|
// FIXME: The button should be highlighted
|
|
|
|
|
[self miniaturize: sender];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
+ (NSButton *) standardWindowButton: (NSWindowButton)button
|
2013-01-27 20:28:35 +00:00
|
|
|
|
forStyleMask: (NSUInteger) mask
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
2015-06-26 00:13:05 +00:00
|
|
|
|
return [[GSTheme theme] standardWindowButton: button
|
|
|
|
|
forStyleMask: mask];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSButton *) standardWindowButton: (NSWindowButton)button
|
|
|
|
|
{
|
|
|
|
|
return [_wv viewWithTag: button];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) showsToolbarButton
|
|
|
|
|
{
|
|
|
|
|
return _f.shows_toolbar_button;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setShowsToolbarButton: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
_f.shows_toolbar_button = flag;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
- (NSInteger) resizeFlags
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: The implementation is missing
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
1999-01-06 18:01:05 +00:00
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Set document edit status. If YES, then, if the receiver has a close
|
|
|
|
|
button, the close button will show a broken X. If NO, then, if the reciever
|
|
|
|
|
has a close button, the close button will show a solid X.
|
|
|
|
|
*/
|
1999-01-06 18:01:05 +00:00
|
|
|
|
- (void) setDocumentEdited: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_f.is_edited != flag)
|
1999-01-06 18:01:05 +00:00
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_edited = flag;
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.menu_exclude == NO && _f.has_opened == YES)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
[NSApp updateWindowsItem: self];
|
|
|
|
|
}
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setDocumentEdited: flag];
|
1999-01-06 18:01:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-24 09:37:16 +00:00
|
|
|
|
/**
|
2009-01-17 16:32:37 +00:00
|
|
|
|
Get an undo manager from the delegate or create one.
|
2006-12-24 09:37:16 +00:00
|
|
|
|
*/
|
|
|
|
|
- (NSUndoManager*) undoManager
|
|
|
|
|
{
|
2009-01-17 16:32:37 +00:00
|
|
|
|
NSUndoManager *undo = nil;
|
2006-12-24 09:37:16 +00:00
|
|
|
|
|
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowWillReturnUndoManager:)])
|
|
|
|
|
{
|
2009-01-17 16:32:37 +00:00
|
|
|
|
undo = [_delegate windowWillReturnUndoManager: self];
|
2006-12-24 09:37:16 +00:00
|
|
|
|
}
|
2009-01-17 16:32:37 +00:00
|
|
|
|
else if (_windowController)
|
2006-12-24 09:37:16 +00:00
|
|
|
|
{
|
2009-01-17 16:32:37 +00:00
|
|
|
|
NSDocument *document = [_windowController document];
|
2006-12-24 09:37:16 +00:00
|
|
|
|
|
2009-01-17 16:32:37 +00:00
|
|
|
|
if (document)
|
|
|
|
|
undo = [document undoManager];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (undo == nil)
|
|
|
|
|
{
|
|
|
|
|
if (windowUndoManagers == NULL)
|
|
|
|
|
windowUndoManagers =
|
|
|
|
|
NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
|
|
|
|
|
NSObjectMapValueCallBacks, 0);
|
|
|
|
|
else
|
|
|
|
|
undo = NSMapGet(windowUndoManagers, self);
|
2006-12-24 09:37:16 +00:00
|
|
|
|
|
2009-01-17 16:32:37 +00:00
|
|
|
|
if (undo == nil)
|
|
|
|
|
{
|
|
|
|
|
undo = [[NSUndoManager alloc] init];
|
|
|
|
|
NSMapInsertKnownAbsent(windowUndoManagers, self, undo);
|
|
|
|
|
[undo release];
|
|
|
|
|
}
|
2006-12-24 09:37:16 +00:00
|
|
|
|
}
|
2009-01-17 16:32:37 +00:00
|
|
|
|
return undo;
|
2006-12-24 09:37:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-06 10:58:38 +00:00
|
|
|
|
- (void) undo: (id)sender
|
|
|
|
|
{
|
2009-12-22 00:14:16 +00:00
|
|
|
|
[[_firstResponder undoManager] undo];
|
2008-12-06 10:58:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) redo: (id)sender
|
|
|
|
|
{
|
2009-12-22 00:14:16 +00:00
|
|
|
|
[[_firstResponder undoManager] redo];
|
2008-12-06 10:58:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
If YES, then the window is released when the close method is called.
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setReleasedWhenClosed: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_released_when_closed = flag;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Aiding event handling
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) acceptsMouseMovedEvents
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.accepts_mouse_moved;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
- (void) setAcceptsMouseMovedEvents: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
_f.accepts_mouse_moved = flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) ignoresMouseEvents
|
|
|
|
|
{
|
|
|
|
|
return _f.ignores_mouse_events;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setIgnoresMouseEvents: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
_f.ignores_mouse_events = flag;
|
2013-07-08 20:42:49 +00:00
|
|
|
|
[GSServerForWindow(self) setIgnoreMouse: flag : _windowNum];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSEvent*) currentEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
return [NSApp currentEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
- (void) discardEventsMatchingMask: (NSUInteger)mask
|
2007-09-09 12:19:01 +00:00
|
|
|
|
beforeEvent: (NSEvent*)lastEvent
|
1996-10-03 18:45:41 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
[NSApp discardEventsMatchingMask: mask beforeEvent: lastEvent];
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Returns the first responder of the window.
|
|
|
|
|
*/
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (NSResponder*) firstResponder
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _firstResponder;
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
1998-12-16 22:33:40 +00:00
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Returns YES, if the window can accept first responder. The default
|
|
|
|
|
implementation of this method returns YES.
|
|
|
|
|
*/
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (BOOL) acceptsFirstResponder
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Makes aResponder the first responder within the receiver.
|
|
|
|
|
*/
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (BOOL) makeFirstResponder: (NSResponder*)aResponder
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (_firstResponder == aResponder)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2006-05-05 13:41:33 +00:00
|
|
|
|
if (aResponder != nil)
|
|
|
|
|
{
|
|
|
|
|
if (![aResponder isKindOfClass: responderClass])
|
2007-08-20 13:46:03 +00:00
|
|
|
|
return NO;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2006-05-05 13:41:33 +00:00
|
|
|
|
if (![aResponder acceptsFirstResponder])
|
2007-09-05 13:04:49 +00:00
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
2006-05-05 13:41:33 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-12-21 17:20:33 +00:00
|
|
|
|
/* So that the implementation of -resignFirstResponder in
|
|
|
|
|
_firstResponder might ask for what will be the new first
|
|
|
|
|
responder by calling our method _futureFirstResponder */
|
|
|
|
|
_futureFirstResponder = aResponder;
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* If there is a first responder tell it to resign.
|
2002-05-21 15:54:10 +00:00
|
|
|
|
* Change only if it replies YES.
|
|
|
|
|
*/
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ((_firstResponder) && (![_firstResponder resignFirstResponder]))
|
2007-09-05 13:04:49 +00:00
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_firstResponder = aResponder;
|
2007-08-31 10:52:52 +00:00
|
|
|
|
if ((aResponder == nil) || ![_firstResponder becomeFirstResponder])
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2007-09-05 13:04:49 +00:00
|
|
|
|
_firstResponder = self;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[_firstResponder becomeFirstResponder];
|
2007-08-31 10:52:52 +00:00
|
|
|
|
return (aResponder == nil);
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Sets the initial first responder of the receiver.
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setInitialFirstResponder: (NSView*)aView
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
1999-10-04 06:18:17 +00:00
|
|
|
|
if ([aView isKindOfClass: viewClass])
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
ASSIGN(_initialFirstResponder, aView);
|
1999-10-04 06:18:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
returns the initial first responder of the receiver.
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSView*) initialFirstResponder
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _initialFirstResponder;
|
1999-10-04 06:18:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Processes theEvent when a key is pressed while within
|
|
|
|
|
the window.
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) keyDown: (NSEvent*)theEvent
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSString *characters = [theEvent characters];
|
|
|
|
|
unichar character = 0;
|
2000-09-04 02:00:14 +00:00
|
|
|
|
|
|
|
|
|
if ([characters length] > 0)
|
|
|
|
|
{
|
|
|
|
|
character = [characters characterAtIndex: 0];
|
|
|
|
|
}
|
1999-10-12 15:05:37 +00:00
|
|
|
|
|
2006-10-04 05:26:47 +00:00
|
|
|
|
if (character == NSHelpFunctionKey)
|
|
|
|
|
{
|
|
|
|
|
[NSHelpManager setContextHelpModeActive: YES];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-25 20:51:40 +00:00
|
|
|
|
// If this is a BACKTAB event, move to the previous key view
|
2010-07-26 11:05:07 +00:00
|
|
|
|
if (character == NSBackTabCharacter)
|
2010-07-25 20:51:40 +00:00
|
|
|
|
{
|
|
|
|
|
[self selectPreviousKeyView: self];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-12 15:05:37 +00:00
|
|
|
|
// If this is a TAB or TAB+SHIFT event, move to the next key view
|
2000-09-04 02:00:14 +00:00
|
|
|
|
if (character == NSTabCharacter)
|
1999-10-12 15:05:37 +00:00
|
|
|
|
{
|
|
|
|
|
if ([theEvent modifierFlags] & NSShiftKeyMask)
|
2007-08-20 13:46:03 +00:00
|
|
|
|
[self selectPreviousKeyView: self];
|
1999-10-12 15:05:37 +00:00
|
|
|
|
else
|
2007-08-20 13:46:03 +00:00
|
|
|
|
[self selectNextKeyView: self];
|
1999-10-12 15:05:37 +00:00
|
|
|
|
return;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If this is an ESC event, abort modal loop
|
2000-09-04 02:00:14 +00:00
|
|
|
|
if (character == 0x001b)
|
1999-10-12 15:05:37 +00:00
|
|
|
|
{
|
2000-09-04 02:00:14 +00:00
|
|
|
|
if ([NSApp modalWindow] == self)
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
|
|
|
|
// NB: The following *never* returns.
|
|
|
|
|
[NSApp abortModal];
|
|
|
|
|
}
|
1999-10-12 15:05:37 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid
core dump due to NSConnection bug.
* Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform
key equivalent for null character events. Triggered return key for
default button cell.
([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]),
([NSWindow -disableKeyEquivalentForDefaultButtonCell]),
([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented.
([NSWindow -dealloc]): release _defaultButtonCell
* Headers/AppKit/NSWindow.h: added ivar and flag.
* Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]),
([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]):
implemented keyboard navigation.
([NSOpenPanel -runModalForDirectory:file:types:]): do not allow
branch selection if can't choose directories.
([NSOpenPanel -_selectTextInColumn:]),
([NSOpenPanel -_selectCellName:]): new private methods.
([NSOpenPanel -filenames]): change for choose dirs.
* Source/NSText.m ([NSText -keyDown:]): forwards text field illegal
events to the next responder.
* Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]),
([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]),
([NSBrowser -keyDown:]): implemented keyboard navigation
([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]),
([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]):
changed return value from NSNotFound to -1 to conforms to NSMatrix
([NSBrowser -doClick:]): fix for new return values, added support for
multiple and branch selection.
([NSBrowser -setLastColumn:]): mark column titles need display
([NSBrowser -_getTitleOfColumn:]): fix for multiple selection.
* Source/NSCell.m ([NSCell -setState:]): bug fix: set value to
NSOnState if someone try to set NSMixedState in a two state cell.
([NSCell -performClick:]): do not perform click if the cell is
disabled.
* Source/NSMatrix.m ([NSMatrix
-_privateFrame:mode:numberOfRows:numberOfColumns:]),
([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]),
([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn
to -1 when no cells are selected
([NSMatrix -performKeyEquivalent:]): saves _selectedRow and
_selectedColumn.
([NSMatrix -getRow:column:ofCell:]): check for null values for row and
column.
([NSMatrix -selectCellAtRow:column:]): deselect the current selection
only in NSRadioModeMatrix mode.
([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix
and fix for this mode.
* Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select
text of the cell and enable okButton.
([NSSavePanel -controlTextDidChange:]): implemented.
([NSSavePanel -controlTextDidEndEditing:]): removed.
([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows
symbolic links.
([NSSavePanel -_initWithoutGModel]): set browser doubleAction to
performClick: of the _okButton. Set _okButton as default window button.
Disable _okButton.
([NSSavePanel -browser:selectCellWithString:inColumn:]),
([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented
keyboard navigation.
([NSSavePanel -runModalForDirectory:file:]): enable _okButton if
filename is valid.
([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]),
([NSSavePanel -_selectCellName:]): new private methods.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7468 72102866-910b-0410-8b05-ffd578937521
2000-09-10 21:55:17 +00:00
|
|
|
|
|
2002-09-23 05:52:36 +00:00
|
|
|
|
if (character == NSEnterCharacter
|
|
|
|
|
|| character == NSFormFeedCharacter
|
|
|
|
|
|| character == NSCarriageReturnCharacter)
|
2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid
core dump due to NSConnection bug.
* Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform
key equivalent for null character events. Triggered return key for
default button cell.
([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]),
([NSWindow -disableKeyEquivalentForDefaultButtonCell]),
([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented.
([NSWindow -dealloc]): release _defaultButtonCell
* Headers/AppKit/NSWindow.h: added ivar and flag.
* Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]),
([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]):
implemented keyboard navigation.
([NSOpenPanel -runModalForDirectory:file:types:]): do not allow
branch selection if can't choose directories.
([NSOpenPanel -_selectTextInColumn:]),
([NSOpenPanel -_selectCellName:]): new private methods.
([NSOpenPanel -filenames]): change for choose dirs.
* Source/NSText.m ([NSText -keyDown:]): forwards text field illegal
events to the next responder.
* Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]),
([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]),
([NSBrowser -keyDown:]): implemented keyboard navigation
([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]),
([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]):
changed return value from NSNotFound to -1 to conforms to NSMatrix
([NSBrowser -doClick:]): fix for new return values, added support for
multiple and branch selection.
([NSBrowser -setLastColumn:]): mark column titles need display
([NSBrowser -_getTitleOfColumn:]): fix for multiple selection.
* Source/NSCell.m ([NSCell -setState:]): bug fix: set value to
NSOnState if someone try to set NSMixedState in a two state cell.
([NSCell -performClick:]): do not perform click if the cell is
disabled.
* Source/NSMatrix.m ([NSMatrix
-_privateFrame:mode:numberOfRows:numberOfColumns:]),
([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]),
([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn
to -1 when no cells are selected
([NSMatrix -performKeyEquivalent:]): saves _selectedRow and
_selectedColumn.
([NSMatrix -getRow:column:ofCell:]): check for null values for row and
column.
([NSMatrix -selectCellAtRow:column:]): deselect the current selection
only in NSRadioModeMatrix mode.
([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix
and fix for this mode.
* Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select
text of the cell and enable okButton.
([NSSavePanel -controlTextDidChange:]): implemented.
([NSSavePanel -controlTextDidEndEditing:]): removed.
([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows
symbolic links.
([NSSavePanel -_initWithoutGModel]): set browser doubleAction to
performClick: of the _okButton. Set _okButton as default window button.
Disable _okButton.
([NSSavePanel -browser:selectCellWithString:inColumn:]),
([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented
keyboard navigation.
([NSSavePanel -runModalForDirectory:file:]): enable _okButton if
filename is valid.
([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]),
([NSSavePanel -_selectCellName:]): new private methods.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7468 72102866-910b-0410-8b05-ffd578937521
2000-09-10 21:55:17 +00:00
|
|
|
|
{
|
2002-09-23 05:52:36 +00:00
|
|
|
|
if (_defaultButtonCell && _f.default_button_cell_key_disabled == NO)
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
|
|
|
|
[_defaultButtonCell performClick: self];
|
|
|
|
|
return;
|
|
|
|
|
}
|
2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid
core dump due to NSConnection bug.
* Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform
key equivalent for null character events. Triggered return key for
default button cell.
([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]),
([NSWindow -disableKeyEquivalentForDefaultButtonCell]),
([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented.
([NSWindow -dealloc]): release _defaultButtonCell
* Headers/AppKit/NSWindow.h: added ivar and flag.
* Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]),
([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]):
implemented keyboard navigation.
([NSOpenPanel -runModalForDirectory:file:types:]): do not allow
branch selection if can't choose directories.
([NSOpenPanel -_selectTextInColumn:]),
([NSOpenPanel -_selectCellName:]): new private methods.
([NSOpenPanel -filenames]): change for choose dirs.
* Source/NSText.m ([NSText -keyDown:]): forwards text field illegal
events to the next responder.
* Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]),
([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]),
([NSBrowser -keyDown:]): implemented keyboard navigation
([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]),
([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]):
changed return value from NSNotFound to -1 to conforms to NSMatrix
([NSBrowser -doClick:]): fix for new return values, added support for
multiple and branch selection.
([NSBrowser -setLastColumn:]): mark column titles need display
([NSBrowser -_getTitleOfColumn:]): fix for multiple selection.
* Source/NSCell.m ([NSCell -setState:]): bug fix: set value to
NSOnState if someone try to set NSMixedState in a two state cell.
([NSCell -performClick:]): do not perform click if the cell is
disabled.
* Source/NSMatrix.m ([NSMatrix
-_privateFrame:mode:numberOfRows:numberOfColumns:]),
([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]),
([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn
to -1 when no cells are selected
([NSMatrix -performKeyEquivalent:]): saves _selectedRow and
_selectedColumn.
([NSMatrix -getRow:column:ofCell:]): check for null values for row and
column.
([NSMatrix -selectCellAtRow:column:]): deselect the current selection
only in NSRadioModeMatrix mode.
([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix
and fix for this mode.
* Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select
text of the cell and enable okButton.
([NSSavePanel -controlTextDidChange:]): implemented.
([NSSavePanel -controlTextDidEndEditing:]): removed.
([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows
symbolic links.
([NSSavePanel -_initWithoutGModel]): set browser doubleAction to
performClick: of the _okButton. Set _okButton as default window button.
Disable _okButton.
([NSSavePanel -browser:selectCellWithString:inColumn:]),
([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented
keyboard navigation.
([NSSavePanel -runModalForDirectory:file:]): enable _okButton if
filename is valid.
([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]),
([NSSavePanel -_selectCellName:]): new private methods.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7468 72102866-910b-0410-8b05-ffd578937521
2000-09-10 21:55:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Discard null character events such as a Shift event after a tab key
|
2002-09-23 05:52:36 +00:00
|
|
|
|
if ([characters length] == 0)
|
2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid
core dump due to NSConnection bug.
* Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform
key equivalent for null character events. Triggered return key for
default button cell.
([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]),
([NSWindow -disableKeyEquivalentForDefaultButtonCell]),
([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented.
([NSWindow -dealloc]): release _defaultButtonCell
* Headers/AppKit/NSWindow.h: added ivar and flag.
* Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]),
([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]):
implemented keyboard navigation.
([NSOpenPanel -runModalForDirectory:file:types:]): do not allow
branch selection if can't choose directories.
([NSOpenPanel -_selectTextInColumn:]),
([NSOpenPanel -_selectCellName:]): new private methods.
([NSOpenPanel -filenames]): change for choose dirs.
* Source/NSText.m ([NSText -keyDown:]): forwards text field illegal
events to the next responder.
* Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]),
([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]),
([NSBrowser -keyDown:]): implemented keyboard navigation
([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]),
([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]):
changed return value from NSNotFound to -1 to conforms to NSMatrix
([NSBrowser -doClick:]): fix for new return values, added support for
multiple and branch selection.
([NSBrowser -setLastColumn:]): mark column titles need display
([NSBrowser -_getTitleOfColumn:]): fix for multiple selection.
* Source/NSCell.m ([NSCell -setState:]): bug fix: set value to
NSOnState if someone try to set NSMixedState in a two state cell.
([NSCell -performClick:]): do not perform click if the cell is
disabled.
* Source/NSMatrix.m ([NSMatrix
-_privateFrame:mode:numberOfRows:numberOfColumns:]),
([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]),
([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn
to -1 when no cells are selected
([NSMatrix -performKeyEquivalent:]): saves _selectedRow and
_selectedColumn.
([NSMatrix -getRow:column:ofCell:]): check for null values for row and
column.
([NSMatrix -selectCellAtRow:column:]): deselect the current selection
only in NSRadioModeMatrix mode.
([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix
and fix for this mode.
* Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select
text of the cell and enable okButton.
([NSSavePanel -controlTextDidChange:]): implemented.
([NSSavePanel -controlTextDidEndEditing:]): removed.
([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows
symbolic links.
([NSSavePanel -_initWithoutGModel]): set browser doubleAction to
performClick: of the _okButton. Set _okButton as default window button.
Disable _okButton.
([NSSavePanel -browser:selectCellWithString:inColumn:]),
([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented
keyboard navigation.
([NSSavePanel -runModalForDirectory:file:]): enable _okButton if
filename is valid.
([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]),
([NSSavePanel -_selectCellName:]): new private methods.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7468 72102866-910b-0410-8b05-ffd578937521
2000-09-10 21:55:17 +00:00
|
|
|
|
return;
|
1999-10-13 00:51:46 +00:00
|
|
|
|
|
2007-08-20 13:46:03 +00:00
|
|
|
|
// FIXME: Why is this here, is the code still needed or a left over hack?
|
1999-12-16 04:53:50 +00:00
|
|
|
|
// Try to process the event as a key equivalent
|
1999-10-14 00:39:46 +00:00
|
|
|
|
// without Command having being pressed
|
1999-10-13 00:51:46 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
NSEvent *new_event
|
|
|
|
|
= [NSEvent keyEventWithType: [theEvent type]
|
2007-09-09 12:19:01 +00:00
|
|
|
|
location: NSZeroPoint
|
|
|
|
|
modifierFlags: ([theEvent modifierFlags] | NSCommandKeyMask)
|
|
|
|
|
timestamp: [theEvent timestamp]
|
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
|
context: [theEvent context]
|
|
|
|
|
characters: characters
|
|
|
|
|
charactersIgnoringModifiers: [theEvent
|
|
|
|
|
charactersIgnoringModifiers]
|
|
|
|
|
isARepeat: [theEvent isARepeat]
|
|
|
|
|
keyCode: [theEvent keyCode]];
|
1999-10-13 00:51:46 +00:00
|
|
|
|
if ([self performKeyEquivalent: new_event])
|
|
|
|
|
return;
|
|
|
|
|
}
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
1999-10-12 15:05:37 +00:00
|
|
|
|
// Otherwise, pass the event up
|
|
|
|
|
[super keyDown: theEvent];
|
|
|
|
|
}
|
1999-10-04 06:18:17 +00:00
|
|
|
|
|
2006-10-04 05:26:47 +00:00
|
|
|
|
- (void) keyUp: (NSEvent*)theEvent
|
|
|
|
|
{
|
|
|
|
|
if ([NSHelpManager isContextHelpModeActive])
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSString *characters = [theEvent characters];
|
|
|
|
|
unichar character = 0;
|
2006-10-04 05:26:47 +00:00
|
|
|
|
|
|
|
|
|
if ([characters length] > 0)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
character = [characters characterAtIndex: 0];
|
|
|
|
|
}
|
2006-10-04 05:26:47 +00:00
|
|
|
|
if (character == NSHelpFunctionKey)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
[NSHelpManager setContextHelpModeActive: NO];
|
|
|
|
|
return;
|
|
|
|
|
}
|
2006-10-04 05:26:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[super keyUp: theEvent];
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
/* Return mouse location in reciever's base coord system, ignores event
|
1999-06-09 08:54:08 +00:00
|
|
|
|
* loop status */
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (NSPoint) mouseLocationOutsideOfEventStream
|
|
|
|
|
{
|
2002-04-23 20:50:24 +00:00
|
|
|
|
int screen;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSPoint p;
|
1999-06-09 08:54:08 +00:00
|
|
|
|
|
2002-04-23 20:50:24 +00:00
|
|
|
|
screen = [_screen screenNumber];
|
|
|
|
|
p = [GSServerForWindow(self) mouseLocationOnScreen: screen window: NULL];
|
|
|
|
|
if (p.x != -1)
|
|
|
|
|
p = [self convertScreenToBase: p];
|
2000-03-07 12:00:00 +00:00
|
|
|
|
return p;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
- (NSEvent*) nextEventMatchingMask: (NSUInteger)mask
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
return [NSApp nextEventMatchingMask: mask
|
2009-03-02 16:26:23 +00:00
|
|
|
|
untilDate: [NSDate distantFuture]
|
2007-09-09 12:19:01 +00:00
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
|
dequeue: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
- (NSEvent*) nextEventMatchingMask: (NSUInteger)mask
|
2007-09-09 12:19:01 +00:00
|
|
|
|
untilDate: (NSDate*)expiration
|
|
|
|
|
inMode: (NSString*)mode
|
|
|
|
|
dequeue: (BOOL)deqFlag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
return [NSApp nextEventMatchingMask: mask
|
2007-09-09 12:19:01 +00:00
|
|
|
|
untilDate: expiration
|
|
|
|
|
inMode: mode
|
|
|
|
|
dequeue: deqFlag];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) postEvent: (NSEvent*)event atStart: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
[NSApp postEvent: event atStart: flag];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) _checkTrackingRectangles: (NSView*)theView
|
2007-09-09 12:19:01 +00:00
|
|
|
|
forEvent: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2010-04-24 17:21:22 +00:00
|
|
|
|
if (theView == nil)
|
|
|
|
|
return;
|
2010-03-27 00:01:03 +00:00
|
|
|
|
if (theView->_rFlags.has_trkrects)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2012-10-06 19:42:56 +00:00
|
|
|
|
BOOL isFlipped = [theView isFlipped];
|
2010-03-27 00:01:03 +00:00
|
|
|
|
NSArray *tr = theView->_tracking_rects;
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger count = [tr count];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
/*
|
|
|
|
|
* Loop through the tracking rectangles
|
|
|
|
|
*/
|
|
|
|
|
if (count > 0)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
GSTrackingRect *rects[count];
|
|
|
|
|
NSPoint loc = [theEvent locationInWindow];
|
2012-10-06 19:42:56 +00:00
|
|
|
|
NSPoint lastPoint = _lastPoint;
|
2014-12-26 07:59:29 +00:00
|
|
|
|
NSRect vr = [theView visibleRect];
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger i;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
|
2012-10-06 19:42:56 +00:00
|
|
|
|
lastPoint = [theView convertPoint: lastPoint fromView: nil];
|
|
|
|
|
loc = [theView convertPoint: loc fromView: nil];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
[tr getObjects: rects];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
|
{
|
|
|
|
|
BOOL last;
|
|
|
|
|
BOOL now;
|
|
|
|
|
GSTrackingRect *r = rects[i];
|
2014-12-26 07:59:29 +00:00
|
|
|
|
NSRect tr = NSIntersectionRect(vr, r->rectangle);
|
2007-09-09 12:19:01 +00:00
|
|
|
|
|
2009-01-24 08:38:21 +00:00
|
|
|
|
if ([r isValid] == NO)
|
|
|
|
|
continue;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
/* Check mouse at last point */
|
2014-12-26 07:59:29 +00:00
|
|
|
|
last = NSMouseInRect(lastPoint, tr, isFlipped);
|
2007-09-09 12:19:01 +00:00
|
|
|
|
/* Check mouse at current point */
|
2014-12-26 07:59:29 +00:00
|
|
|
|
now = NSMouseInRect(loc, tr, isFlipped);
|
2007-09-09 12:19:01 +00:00
|
|
|
|
|
|
|
|
|
if ((!last) && (now)) // Mouse entered event
|
|
|
|
|
{
|
|
|
|
|
if (r->flags.checked == NO)
|
|
|
|
|
{
|
|
|
|
|
if ([r->owner respondsToSelector:
|
|
|
|
|
@selector(mouseEntered:)])
|
|
|
|
|
r->flags.ownerRespondsToMouseEntered = YES;
|
|
|
|
|
if ([r->owner respondsToSelector:
|
|
|
|
|
@selector(mouseExited:)])
|
|
|
|
|
r->flags.ownerRespondsToMouseExited = YES;
|
|
|
|
|
r->flags.checked = YES;
|
|
|
|
|
}
|
|
|
|
|
if (r->flags.ownerRespondsToMouseEntered)
|
|
|
|
|
{
|
|
|
|
|
NSEvent *e;
|
|
|
|
|
|
|
|
|
|
e = [NSEvent enterExitEventWithType: NSMouseEntered
|
|
|
|
|
location: loc
|
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
|
context: NULL
|
|
|
|
|
eventNumber: 0
|
|
|
|
|
trackingNumber: r->tag
|
|
|
|
|
userData: r->user_data];
|
|
|
|
|
[r->owner mouseEntered: e];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((last) && (!now)) // Mouse exited event
|
|
|
|
|
{
|
|
|
|
|
if (r->flags.checked == NO)
|
|
|
|
|
{
|
|
|
|
|
if ([r->owner respondsToSelector:
|
|
|
|
|
@selector(mouseEntered:)])
|
|
|
|
|
r->flags.ownerRespondsToMouseEntered = YES;
|
|
|
|
|
if ([r->owner respondsToSelector:
|
|
|
|
|
@selector(mouseExited:)])
|
|
|
|
|
r->flags.ownerRespondsToMouseExited = YES;
|
|
|
|
|
r->flags.checked = YES;
|
|
|
|
|
}
|
|
|
|
|
if (r->flags.ownerRespondsToMouseExited)
|
|
|
|
|
{
|
|
|
|
|
NSEvent *e;
|
|
|
|
|
|
|
|
|
|
e = [NSEvent enterExitEventWithType: NSMouseExited
|
|
|
|
|
location: loc
|
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
|
context: NULL
|
|
|
|
|
eventNumber: 0
|
|
|
|
|
trackingNumber: r->tag
|
|
|
|
|
userData: r->user_data];
|
|
|
|
|
[r->owner mouseExited: e];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-05-07 11:06:37 +00:00
|
|
|
|
/*
|
|
|
|
|
* Check tracking rectangles for the subviews
|
|
|
|
|
*/
|
2010-03-27 00:01:03 +00:00
|
|
|
|
if (theView->_rFlags.has_subviews)
|
1999-05-07 11:06:37 +00:00
|
|
|
|
{
|
2010-03-27 00:01:03 +00:00
|
|
|
|
NSArray *sb = theView->_sub_views;
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger count = [sb count];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (count > 0)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger i;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
[sb getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; ++i)
|
2007-12-22 16:11:24 +00:00
|
|
|
|
{
|
|
|
|
|
if (![subs[i] isHidden])
|
|
|
|
|
(*ctImp)(self, ctSel, subs[i], theEvent);
|
|
|
|
|
}
|
2007-09-09 12:19:01 +00:00
|
|
|
|
}
|
1999-05-07 11:06:37 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) _checkCursorRectangles: (NSView*)theView forEvent: (NSEvent*)theEvent
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2013-08-30 11:27:10 +00:00
|
|
|
|
// As we add the events to the front of the queue, we need to add the last
|
|
|
|
|
// events first. That is, first the enter evnts from inner to outer and
|
|
|
|
|
// then the exit events
|
|
|
|
|
checkCursorRectanglesEntered(theView, theEvent, _lastPoint);
|
|
|
|
|
checkCursorRectanglesExited(theView, theEvent, _lastPoint);
|
|
|
|
|
//[GSServerForWindow(self) _printEventQueue];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-21 18:08:50 +00:00
|
|
|
|
- (void) _processResizeEvent
|
|
|
|
|
{
|
2000-09-29 03:55:30 +00:00
|
|
|
|
if (_windowNum && _gstate)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
2008-01-19 13:11:16 +00:00
|
|
|
|
[GSServerForWindow(self) setWindowdevice: _windowNum
|
|
|
|
|
forContext: _context];
|
2007-04-04 14:33:39 +00:00
|
|
|
|
GSReplaceGState(_context, _gstate);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self update];
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-06 10:29:26 +00:00
|
|
|
|
- (void) mouseDown: (NSEvent*)theEvent
|
|
|
|
|
{
|
|
|
|
|
// Quietly discard an unused mouse down.
|
|
|
|
|
}
|
1999-10-21 18:08:50 +00:00
|
|
|
|
|
2005-01-21 21:43 Alexander Malmberg <alexander@malmberg.org>
Various whitespace cleanups, comment type fixes, and changes
to avoid warnings from recent versions of gcc.
* Headers/Additions/GNUstepGUI/GSToolbar.h (-_toolbars): Declare.
* Source/NSWindow+Toolbar.m: Remove conflicting declaration of
[NSToolbar -_toolbars].
* Headers/Additions/GNUstepGUI/GSServicesManager.h,
Source/GSServicesMananger.m (-item2title:, -validateMenuItem:):
Adjust argument types.
* Headers/AppKit/NSMenu.h (-validateMenuItem:): Adjust argument
type.
* Source/NSTextView.m (-sizeToFit): Don't use size uninitialized
if neither resizable flags is set.
(-insertText:): Adjust argument type.
* Headers/AppKit/NSResponder.h, Source/NSResponder.m (-insertText:):
Adjust argument type. Document.
* Headers/AppKit/NSView.h: Change type of ivar _window to NSWindow *.
* Source/GSTitleView.m (-mouseDown:): Always initialize
startWindowOrigin.
* Source/NSApplication.m (-setApplicationIconImage:): Add casts
to avoid warnings.
* Source/NSCell.m (-cellSize): Add default: case.
* Source/NSPasteboard.m
([GSFiltered -pasteboard:provideDataForType:]): Detect and warn if we
can't find a filter that will get us the desired type.
* Source/NSProgressIndicator.m: Comment out unused variable 'images'.
* Source/NSBezierPath.m: Declare GSBezierPath fully before using it.
(-bezierPathByFlatteningPath, -bezierPathByReversingPath): Make sure
variables are always initialized.
* Source/NSMenuView.m,
* Source/NSPrintOperation.m,
* Source/NSSplitView.m,
* Source/NSTableHeaderView.m: Make sure variables are always
initialized.
* Source/NSBox.m,
* Source/NSImageview.m,
* Source/NSText.m,
* Source/NSTextStorage.m: Add missing includes.
* Source/GSKeyBindingTable.m,
* Source/GSLayoutManager.m,
* Source/NSBitmapImageRep+PNM.m,
* Source/NSBundleAdditions.m,
* Source/NSLayoutManager.m,
* Source/nsimage-tiff.h,
* Source/tiff.m,
* Headers/Additions/GNUstepGUI/GSDisplayServer.h,
* Source/GSDisplayServer.m: Change signedness of various variables.
* Source/NSPanel.m (-sendEvent:): Remove.
* Source/NSWindow.m (-becomesKeyOnlyIfNeeded): New method.
(-_sendEvent:becomesKeyOnlyIfNeeded:): Remove. Move code ...
(-sendEvent:): ... here. Use -becomesKeyOnlyIfNeeded instead
of the argument.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20590 72102866-910b-0410-8b05-ffd578937521
2005-01-21 20:39:18 +00:00
|
|
|
|
- (BOOL) becomesKeyOnlyIfNeeded
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-04 02:44:13 +00:00
|
|
|
|
/** Handles mouse and other events sent to the receiver by NSApplication.
|
2002-03-19 20:10:26 +00:00
|
|
|
|
Do not invoke this method directly.
|
|
|
|
|
*/
|
2005-01-21 21:43 Alexander Malmberg <alexander@malmberg.org>
Various whitespace cleanups, comment type fixes, and changes
to avoid warnings from recent versions of gcc.
* Headers/Additions/GNUstepGUI/GSToolbar.h (-_toolbars): Declare.
* Source/NSWindow+Toolbar.m: Remove conflicting declaration of
[NSToolbar -_toolbars].
* Headers/Additions/GNUstepGUI/GSServicesManager.h,
Source/GSServicesMananger.m (-item2title:, -validateMenuItem:):
Adjust argument types.
* Headers/AppKit/NSMenu.h (-validateMenuItem:): Adjust argument
type.
* Source/NSTextView.m (-sizeToFit): Don't use size uninitialized
if neither resizable flags is set.
(-insertText:): Adjust argument type.
* Headers/AppKit/NSResponder.h, Source/NSResponder.m (-insertText:):
Adjust argument type. Document.
* Headers/AppKit/NSView.h: Change type of ivar _window to NSWindow *.
* Source/GSTitleView.m (-mouseDown:): Always initialize
startWindowOrigin.
* Source/NSApplication.m (-setApplicationIconImage:): Add casts
to avoid warnings.
* Source/NSCell.m (-cellSize): Add default: case.
* Source/NSPasteboard.m
([GSFiltered -pasteboard:provideDataForType:]): Detect and warn if we
can't find a filter that will get us the desired type.
* Source/NSProgressIndicator.m: Comment out unused variable 'images'.
* Source/NSBezierPath.m: Declare GSBezierPath fully before using it.
(-bezierPathByFlatteningPath, -bezierPathByReversingPath): Make sure
variables are always initialized.
* Source/NSMenuView.m,
* Source/NSPrintOperation.m,
* Source/NSSplitView.m,
* Source/NSTableHeaderView.m: Make sure variables are always
initialized.
* Source/NSBox.m,
* Source/NSImageview.m,
* Source/NSText.m,
* Source/NSTextStorage.m: Add missing includes.
* Source/GSKeyBindingTable.m,
* Source/GSLayoutManager.m,
* Source/NSBitmapImageRep+PNM.m,
* Source/NSBundleAdditions.m,
* Source/NSLayoutManager.m,
* Source/nsimage-tiff.h,
* Source/tiff.m,
* Headers/Additions/GNUstepGUI/GSDisplayServer.h,
* Source/GSDisplayServer.m: Change signedness of various variables.
* Source/NSPanel.m (-sendEvent:): Remove.
* Source/NSWindow.m (-becomesKeyOnlyIfNeeded): New method.
(-_sendEvent:becomesKeyOnlyIfNeeded:): Remove. Move code ...
(-sendEvent:): ... here. Use -becomesKeyOnlyIfNeeded instead
of the argument.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20590 72102866-910b-0410-8b05-ffd578937521
2005-01-21 20:39:18 +00:00
|
|
|
|
- (void) sendEvent: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSView *v;
|
|
|
|
|
NSEventType type;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
|
2003-11-26 23:02:20 +00:00
|
|
|
|
/*
|
|
|
|
|
If the backend reacts slowly, events (eg. mouse down) might arrive for a
|
|
|
|
|
window that has been ordered out (and thus is logically invisible). We
|
|
|
|
|
need to ignore those events. Otherwise, eg. clicking twice on a button
|
|
|
|
|
that ends a modal session and closes the window with the button might
|
|
|
|
|
cause the button to be pressed twice, which causes Bad Things to happen
|
|
|
|
|
when it tries to stop a modal session twice.
|
|
|
|
|
|
|
|
|
|
We let NSAppKitDefined events through since they deal with window ordering.
|
|
|
|
|
*/
|
|
|
|
|
if (!_f.visible && [theEvent type] != NSAppKitDefined)
|
2009-11-20 13:36:46 +00:00
|
|
|
|
{
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Discard (window not visible) %@", theEvent);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-11-26 23:02:20 +00:00
|
|
|
|
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (!_f.cursor_rects_valid)
|
1999-06-11 04:46:12 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[self resetCursorRects];
|
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-24 11:31:06 +00:00
|
|
|
|
type = [theEvent type];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
if ([self ignoresMouseEvents]
|
2009-11-20 13:36:46 +00:00
|
|
|
|
&& GSMouseEventMask == NSEventMaskFromType(type))
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
2009-11-20 13:36:46 +00:00
|
|
|
|
NSDebugLLog(@"NSEvent", @"Discard (window ignoring mouse) %@", theEvent);
|
2007-09-09 12:19:01 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-24 11:31:06 +00:00
|
|
|
|
switch (type)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSLeftMouseDown:
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
2010-01-17 06:01:58 +00:00
|
|
|
|
BOOL wasKey = _f.is_key;
|
2000-01-02 20:24:56 +00:00
|
|
|
|
|
2007-08-20 13:46:03 +00:00
|
|
|
|
if (_f.has_closed == NO)
|
|
|
|
|
{
|
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (_f.is_key == NO && _windowLevel != NSDesktopWindowLevel)
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
|
|
|
|
/* NSPanel modification: check becomesKeyOnlyIfNeeded. */
|
|
|
|
|
if (![self becomesKeyOnlyIfNeeded]
|
|
|
|
|
|| [v needsPanelToBecomeKey])
|
|
|
|
|
{
|
|
|
|
|
v = nil;
|
|
|
|
|
[self makeKeyAndOrderFront: self];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* Activate the app *after* making the receiver key, as app
|
2009-01-17 16:45:14 +00:00
|
|
|
|
activation tries to make the previous key window key.
|
|
|
|
|
However, don't activate the app after a single click into
|
|
|
|
|
the app icon or a miniwindow. This allows dragging app
|
|
|
|
|
icons and miniwindows without unnecessarily switching
|
|
|
|
|
applications (cf. Sect. 4 of the OpenStep UI Guidelines).
|
|
|
|
|
*/
|
|
|
|
|
if ((_styleMask & (NSIconWindowMask | NSMiniWindowMask)) == 0
|
|
|
|
|
&& [NSApp isActive] == NO)
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
|
|
|
|
v = nil;
|
|
|
|
|
[NSApp activateIgnoringOtherApps: YES];
|
|
|
|
|
}
|
|
|
|
|
// Activating the app may change the window layout.
|
|
|
|
|
if (v == nil)
|
|
|
|
|
{
|
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
|
|
|
|
}
|
2010-04-11 00:31:59 +00:00
|
|
|
|
if (_lastLeftMouseDownView)
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
2010-04-11 00:31:59 +00:00
|
|
|
|
DESTROY(_lastLeftMouseDownView);
|
2007-08-20 13:46:03 +00:00
|
|
|
|
}
|
2010-02-03 19:12:02 +00:00
|
|
|
|
// Don't make buttons first responder otherwise they cannot
|
|
|
|
|
// send actions to the current first responder.
|
|
|
|
|
// TODO: First responder status update would more cleanly
|
|
|
|
|
// handled by -mouseDown in each control subclass (Mac OS X
|
|
|
|
|
// seems to do that).
|
|
|
|
|
if (_firstResponder != v && ![v isKindOfClass: [NSButton class]])
|
2007-09-05 13:04:49 +00:00
|
|
|
|
{
|
|
|
|
|
// Only try to set first responder, when the view wants it.
|
|
|
|
|
if ([v acceptsFirstResponder] && ![self makeFirstResponder: v])
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-08-20 13:46:03 +00:00
|
|
|
|
if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
|
|
|
|
|
{
|
|
|
|
|
if ([NSHelpManager isContextHelpModeActive])
|
|
|
|
|
{
|
|
|
|
|
[v helpRequested: theEvent];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-04-11 00:31:59 +00:00
|
|
|
|
ASSIGN(_lastLeftMouseDownView, v);
|
2007-08-20 13:46:03 +00:00
|
|
|
|
if (toolTipVisible != nil)
|
|
|
|
|
{
|
|
|
|
|
/* Inform the tooltips system that we have had
|
|
|
|
|
* a mouse down so it should stop displaying.
|
|
|
|
|
*/
|
|
|
|
|
[toolTipVisible mouseDown: theEvent];
|
|
|
|
|
}
|
|
|
|
|
[v mouseDown: theEvent];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[self mouseDown: theEvent];
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-11-20 13:36:46 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Discard (window closed) %@", theEvent);
|
|
|
|
|
}
|
2007-08-20 13:46:03 +00:00
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSLeftMouseUp:
|
2010-04-11 00:31:59 +00:00
|
|
|
|
v = AUTORELEASE(RETAIN(_lastLeftMouseDownView));
|
|
|
|
|
DESTROY(_lastLeftMouseDownView);
|
2007-08-20 13:46:03 +00:00
|
|
|
|
if (v == nil)
|
|
|
|
|
break;
|
|
|
|
|
[v mouseUp: theEvent];
|
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
|
|
|
|
break;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2002-03-02 07:23:18 +00:00
|
|
|
|
case NSOtherMouseDown:
|
2007-08-20 13:46:03 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
2010-04-11 00:31:59 +00:00
|
|
|
|
ASSIGN(_lastOtherMouseDownView, v);
|
2007-08-20 13:46:03 +00:00
|
|
|
|
[v otherMouseDown: theEvent];
|
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
|
|
|
|
break;
|
2000-08-03 08:48:22 +00:00
|
|
|
|
|
2002-03-02 07:23:18 +00:00
|
|
|
|
case NSOtherMouseUp:
|
2010-04-11 00:31:59 +00:00
|
|
|
|
v = AUTORELEASE(RETAIN(_lastOtherMouseDownView));
|
|
|
|
|
DESTROY(_lastOtherMouseDownView);
|
|
|
|
|
if (v == nil)
|
|
|
|
|
break;
|
2007-08-20 13:46:03 +00:00
|
|
|
|
[v otherMouseUp: theEvent];
|
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
|
|
|
|
break;
|
2000-08-03 08:48:22 +00:00
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSRightMouseDown:
|
2007-08-20 13:46:03 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
2010-04-11 00:31:59 +00:00
|
|
|
|
ASSIGN(_lastRightMouseDownView, v);
|
2007-08-20 13:46:03 +00:00
|
|
|
|
[v rightMouseDown: theEvent];
|
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
|
|
|
|
break;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSRightMouseUp:
|
2010-04-11 00:31:59 +00:00
|
|
|
|
v = AUTORELEASE(RETAIN(_lastRightMouseDownView));
|
|
|
|
|
DESTROY(_lastRightMouseDownView);
|
|
|
|
|
if (v == nil)
|
|
|
|
|
break;
|
2007-08-20 13:46:03 +00:00
|
|
|
|
[v rightMouseUp: theEvent];
|
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
|
|
|
|
break;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSLeftMouseDragged:
|
2002-03-02 07:23:18 +00:00
|
|
|
|
case NSOtherMouseDragged:
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSRightMouseDragged:
|
|
|
|
|
case NSMouseMoved:
|
2007-08-20 13:46:03 +00:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case NSLeftMouseDragged:
|
2010-04-11 00:31:59 +00:00
|
|
|
|
[_lastLeftMouseDownView mouseDragged: theEvent];
|
2007-08-20 13:46:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case NSOtherMouseDragged:
|
2010-04-11 00:31:59 +00:00
|
|
|
|
[_lastOtherMouseDownView otherMouseDragged: theEvent];
|
2007-08-20 13:46:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case NSRightMouseDragged:
|
2010-04-11 00:31:59 +00:00
|
|
|
|
[_lastRightMouseDownView rightMouseDragged: theEvent];
|
2007-08-20 13:46:03 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (_f.accepts_mouse_moved)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* If the window is set to accept mouse movements, we need to
|
|
|
|
|
* forward the mouse movement to the correct view.
|
|
|
|
|
*/
|
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
|
|
|
|
|
|
|
|
|
/* If the view is displaying a tooltip, we should
|
|
|
|
|
* send mouse movements to the tooltip system so
|
|
|
|
|
* that the window can track the mouse.
|
|
|
|
|
*/
|
|
|
|
|
if (toolTipVisible != nil)
|
|
|
|
|
{
|
|
|
|
|
[toolTipVisible mouseMoved: theEvent];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[v mouseMoved: theEvent];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* We need to go through all of the views, and if there is any with
|
|
|
|
|
* a tracking rectangle then we need to determine if we should send
|
|
|
|
|
* a NSMouseEntered or NSMouseExited event.
|
|
|
|
|
*/
|
|
|
|
|
(*ctImp)(self, ctSel, _wv, theEvent);
|
|
|
|
|
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (_f.is_key)
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* We need to go through all of the views, and if there is any with
|
|
|
|
|
* a cursor rectangle then we need to determine if we should send a
|
|
|
|
|
* cursor update event.
|
|
|
|
|
*/
|
|
|
|
|
if (_f.cursor_rects_enabled)
|
2013-08-30 11:27:10 +00:00
|
|
|
|
{
|
2007-08-20 13:46:03 +00:00
|
|
|
|
(*ccImp)(self, ccSel, _wv, theEvent);
|
2013-08-30 11:27:10 +00:00
|
|
|
|
}
|
2007-08-20 13:46:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
|
|
|
|
break;
|
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSMouseEntered:
|
|
|
|
|
case NSMouseExited:
|
2007-08-20 13:46:03 +00:00
|
|
|
|
break;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-12-16 04:53:50 +00:00
|
|
|
|
case NSKeyDown:
|
2009-11-14 22:45:23 +00:00
|
|
|
|
/* Always shift keyboard focus to the next and previous key view,
|
|
|
|
|
* respectively, upon receiving Ctrl-Tab and Ctrl-Shift-Tab keyboard
|
|
|
|
|
* events. This means that the key view loop won't get stuck in views
|
|
|
|
|
* that interpret the Tab key differently, e.g., NSTextView. (cf. the
|
|
|
|
|
* Keyboard Interface Control section in Apple's Cocoa Event-Handling
|
|
|
|
|
* Guide).
|
|
|
|
|
*/
|
|
|
|
|
if (([theEvent modifierFlags] & NSControlKeyMask)
|
|
|
|
|
&& [[theEvent charactersIgnoringModifiers] isEqualToString: @"\t"])
|
|
|
|
|
{
|
|
|
|
|
if ([theEvent modifierFlags] & NSShiftKeyMask)
|
|
|
|
|
[self selectPreviousKeyView: self];
|
|
|
|
|
else
|
|
|
|
|
[self selectNextKeyView: self];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
[_firstResponder keyDown: theEvent];
|
2007-08-20 13:46:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSKeyUp:
|
2007-08-20 13:46:03 +00:00
|
|
|
|
[_firstResponder keyUp: theEvent];
|
|
|
|
|
break;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSFlagsChanged:
|
2007-08-20 13:46:03 +00:00
|
|
|
|
[_firstResponder flagsChanged: theEvent];
|
|
|
|
|
break;
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSCursorUpdate:
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
GSTrackingRect *r =(GSTrackingRect*)[theEvent userData];
|
|
|
|
|
NSCursor *c = (NSCursor*)[r owner];
|
2013-07-02 16:57:54 +00:00
|
|
|
|
|
|
|
|
|
// Don't update the cursor if the window isn't the key window.
|
|
|
|
|
if (!_f.is_key)
|
2013-08-30 11:27:10 +00:00
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2007-08-20 13:46:03 +00:00
|
|
|
|
|
2013-10-09 19:45:55 +00:00
|
|
|
|
if ([theEvent trackingNumber]) // It's a mouse entered
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
2013-10-09 19:45:55 +00:00
|
|
|
|
/* Only send the event mouse entered if the
|
|
|
|
|
* cursor rectangle is valid. */
|
|
|
|
|
if ([r isValid])
|
|
|
|
|
{
|
|
|
|
|
[c mouseEntered: theEvent];
|
2013-11-22 19:21:02 +00:00
|
|
|
|
|
|
|
|
|
/* This could seems redundant, but ensure the correct
|
|
|
|
|
* value to use in events mouse moved. And avoids strange
|
|
|
|
|
* issues with cursor. */
|
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
2013-10-09 19:45:55 +00:00
|
|
|
|
}
|
2007-08-20 13:46:03 +00:00
|
|
|
|
}
|
2007-09-09 12:19:01 +00:00
|
|
|
|
else // it is a mouse exited
|
2007-08-20 13:46:03 +00:00
|
|
|
|
{
|
|
|
|
|
[c mouseExited: theEvent];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2001-08-21 23:24:00 +00:00
|
|
|
|
case NSScrollWheel:
|
2007-08-20 13:46:03 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
|
|
|
|
[v scrollWheel: theEvent];
|
|
|
|
|
break;
|
2001-08-21 23:24:00 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSAppKitDefined:
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
id dragInfo;
|
|
|
|
|
int action;
|
|
|
|
|
NSEvent *e;
|
|
|
|
|
GSAppKitSubtype sub = [theEvent subtype];
|
2010-02-11 11:22:52 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
switch (sub)
|
|
|
|
|
{
|
|
|
|
|
case GSAppKitWindowMoved:
|
2013-02-16 00:08:33 +00:00
|
|
|
|
_frame.origin.x = (CGFloat)[theEvent data1];
|
|
|
|
|
_frame.origin.y = (CGFloat)[theEvent data2];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSDebugLLog(@"Moving", @"Move event: %d %@",
|
2013-01-30 09:48:54 +00:00
|
|
|
|
(int)_windowNum, NSStringFromPoint(_frame.origin));
|
2007-09-09 12:19:01 +00:00
|
|
|
|
if (_autosaveName != nil)
|
|
|
|
|
{
|
|
|
|
|
[self saveFrameUsingName: _autosaveName];
|
|
|
|
|
}
|
|
|
|
|
[nc postNotificationName: NSWindowDidMoveNotification
|
|
|
|
|
object: self];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowResized:
|
|
|
|
|
{
|
|
|
|
|
NSRect newFrame;
|
|
|
|
|
|
|
|
|
|
newFrame.size.width = [theEvent data1];
|
|
|
|
|
newFrame.size.height = [theEvent data2];
|
|
|
|
|
/* Resize events always move the frame origin. The new origin
|
|
|
|
|
is stored in the event location field. */
|
|
|
|
|
newFrame.origin = [theEvent locationInWindow];
|
|
|
|
|
|
2009-11-12 09:05:22 +00:00
|
|
|
|
/* FIXME: For a user resize we should call windowWillResize:toSize:
|
|
|
|
|
on the delegate.
|
|
|
|
|
*/
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_frame = newFrame;
|
|
|
|
|
newFrame.origin = NSZeroPoint;
|
|
|
|
|
[_wv setFrame: newFrame];
|
|
|
|
|
[_wv setNeedsDisplay: YES];
|
|
|
|
|
|
|
|
|
|
if (_autosaveName != nil)
|
|
|
|
|
{
|
|
|
|
|
[self saveFrameUsingName: _autosaveName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self _processResizeEvent];
|
|
|
|
|
[nc postNotificationName: NSWindowDidResizeNotification
|
|
|
|
|
object: self];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case GSAppKitRegionExposed:
|
|
|
|
|
{
|
|
|
|
|
NSRect region;
|
|
|
|
|
|
|
|
|
|
region.size.width = [theEvent data1];
|
|
|
|
|
region.size.height = [theEvent data2];
|
|
|
|
|
region.origin = [theEvent locationInWindow];
|
|
|
|
|
switch (_backingType)
|
|
|
|
|
{
|
|
|
|
|
case NSBackingStoreBuffered:
|
|
|
|
|
case NSBackingStoreRetained:
|
|
|
|
|
/*
|
|
|
|
|
* The backend may have the region buffered ...
|
|
|
|
|
* so we add it to the rectangle to be flushed
|
|
|
|
|
* and set the flag to say that a flush is required.
|
|
|
|
|
*/
|
|
|
|
|
_rectNeedingFlush
|
|
|
|
|
= NSUnionRect(_rectNeedingFlush, region);
|
|
|
|
|
_f.needs_flush = YES;
|
|
|
|
|
/* Some or all of the window has not been drawn,
|
|
|
|
|
* so we must at least make sure that the exposed
|
|
|
|
|
* region gets drawn before its backing store is
|
|
|
|
|
* flushed ... otherwise we might actually flush
|
|
|
|
|
* bogus data from an out of date buffer.
|
|
|
|
|
* Maybe we should call
|
|
|
|
|
* [_wv displayIfNeededInRect: region]
|
|
|
|
|
* but why not do all drawing at this point so
|
|
|
|
|
* that if we get another expose event immediately
|
|
|
|
|
* (eg. something is dragged over the window and
|
|
|
|
|
* we get a series of expose events) we can just
|
|
|
|
|
* flush without having to draw again.
|
|
|
|
|
*/
|
|
|
|
|
[self displayIfNeeded];
|
|
|
|
|
[self flushWindowIfNeeded];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* non-retained ... so we need to redraw the exposed
|
|
|
|
|
* region here.
|
|
|
|
|
*/
|
|
|
|
|
[_wv setNeedsDisplayInRect: region];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowClose:
|
|
|
|
|
[self performClose: NSApp];
|
|
|
|
|
break;
|
|
|
|
|
|
2009-10-17 15:18:26 +00:00
|
|
|
|
case GSAppKitWindowDeminiaturize:
|
|
|
|
|
[self _didDeminiaturize: NSApp];
|
|
|
|
|
break;
|
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
case GSAppKitWindowMiniaturize:
|
|
|
|
|
[self performMiniaturize: NSApp];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowFocusIn:
|
|
|
|
|
if (_f.is_miniaturized)
|
2009-10-17 15:18:26 +00:00
|
|
|
|
{
|
|
|
|
|
/* Window Manager just deminiaturized us */
|
|
|
|
|
[self deminiaturize: self];
|
|
|
|
|
}
|
2007-09-09 12:19:01 +00:00
|
|
|
|
if ([NSApp modalWindow]
|
2010-12-07 07:55:48 +00:00
|
|
|
|
&& self != [NSApp modalWindow]
|
|
|
|
|
&& ![self worksWhenModal])
|
2009-10-17 15:18:26 +00:00
|
|
|
|
{
|
|
|
|
|
/* Ignore this request. We're in a modal loop and the
|
|
|
|
|
user pressed on the title bar of another window. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
2007-09-09 12:19:01 +00:00
|
|
|
|
if ([self canBecomeKeyWindow] == YES)
|
2009-10-17 15:18:26 +00:00
|
|
|
|
{
|
2013-01-30 09:48:54 +00:00
|
|
|
|
NSDebugLLog(@"Focus", @"Making %d key", (int)_windowNum);
|
2009-10-17 15:18:26 +00:00
|
|
|
|
[self makeKeyWindow];
|
|
|
|
|
[self makeMainWindow];
|
|
|
|
|
[NSApp activateIgnoringOtherApps: YES];
|
|
|
|
|
}
|
2007-09-09 12:19:01 +00:00
|
|
|
|
if (self == [[NSApp mainMenu] window])
|
2009-10-17 15:18:26 +00:00
|
|
|
|
{
|
|
|
|
|
/* We should really find another window that can become
|
|
|
|
|
key (if possible)
|
|
|
|
|
*/
|
|
|
|
|
[self _lossOfKeyOrMainWindow];
|
|
|
|
|
}
|
2007-09-09 12:19:01 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowFocusOut:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowLeave:
|
2010-02-11 11:22:52 +00:00
|
|
|
|
/* we ignore this event for a window that is already closed */
|
2010-03-30 07:28:05 +00:00
|
|
|
|
if (_f.has_closed == YES)
|
2010-01-20 14:58:59 +00:00
|
|
|
|
break;
|
2010-02-11 11:22:52 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
/*
|
|
|
|
|
* We need to go through all of the views, and if there
|
|
|
|
|
* is any with a tracking rectangle then we need to
|
|
|
|
|
* determine if we should send a NSMouseExited event. */
|
|
|
|
|
(*ctImp)(self, ctSel, _wv, theEvent);
|
|
|
|
|
|
2010-01-17 06:01:58 +00:00
|
|
|
|
if (_f.is_key)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* We need to go through all of the views, and if
|
|
|
|
|
* there is any with a cursor rectangle then we need
|
|
|
|
|
* to determine if we should send a cursor update
|
|
|
|
|
* event. */
|
|
|
|
|
if (_f.cursor_rects_enabled)
|
2013-08-30 11:27:10 +00:00
|
|
|
|
{
|
|
|
|
|
checkCursorRectanglesExited(_wv, theEvent, _lastPoint);
|
|
|
|
|
}
|
2007-09-09 12:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_lastPoint = NSMakePoint(-1, -1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowEnter:
|
|
|
|
|
break;
|
2002-01-26 04:14:38 +00:00
|
|
|
|
|
1999-07-06 11:56:22 +00:00
|
|
|
|
|
2001-12-11 04:31:08 +00:00
|
|
|
|
#define GSPerformDragSelector(view, sel, info, action) \
|
2007-09-09 12:19:01 +00:00
|
|
|
|
if ([view window] == self) \
|
|
|
|
|
{ \
|
|
|
|
|
id target = view; \
|
|
|
|
|
\
|
|
|
|
|
if (target == _wv) \
|
|
|
|
|
{ \
|
|
|
|
|
if (_delegate != nil \
|
|
|
|
|
&& [_delegate respondsToSelector: sel] == YES) \
|
|
|
|
|
{ \
|
|
|
|
|
target = _delegate; \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
target = self; \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
if ([target respondsToSelector: sel]) \
|
|
|
|
|
{ \
|
|
|
|
|
action = (intptr_t)[target performSelector: sel \
|
|
|
|
|
withObject: info]; \
|
|
|
|
|
} \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
}
|
2001-12-11 04:31:08 +00:00
|
|
|
|
|
|
|
|
|
#define GSPerformVoidDragSelector(view, sel, info) \
|
2007-09-09 12:19:01 +00:00
|
|
|
|
if ([view window] == self) \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
{ \
|
2007-09-09 12:19:01 +00:00
|
|
|
|
id target = view; \
|
|
|
|
|
\
|
|
|
|
|
if (target == _wv) \
|
|
|
|
|
{ \
|
|
|
|
|
if (_delegate != nil \
|
|
|
|
|
&& [_delegate respondsToSelector: sel] == YES) \
|
|
|
|
|
{ \
|
|
|
|
|
target = _delegate; \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
target = self; \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
if ([target respondsToSelector: sel]) \
|
|
|
|
|
{ \
|
|
|
|
|
[target performSelector: sel withObject: info]; \
|
|
|
|
|
} \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
}
|
1999-07-29 20:58:04 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
case GSAppKitDraggingEnter:
|
|
|
|
|
case GSAppKitDraggingUpdate:
|
|
|
|
|
{
|
|
|
|
|
BOOL isEntry;
|
|
|
|
|
|
|
|
|
|
dragInfo = [GSServerForWindow(self) dragInfo];
|
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
|
|
|
|
|
|
|
|
|
while (v != nil)
|
|
|
|
|
{
|
2010-03-27 00:01:03 +00:00
|
|
|
|
if (v->_rFlags.has_draginfo != 0
|
2007-09-09 12:19:01 +00:00
|
|
|
|
&& GSViewAcceptsDrag(v, dragInfo))
|
|
|
|
|
break;
|
|
|
|
|
v = [v superview];
|
|
|
|
|
}
|
|
|
|
|
if (v == nil)
|
|
|
|
|
{
|
|
|
|
|
v = _wv;
|
|
|
|
|
}
|
|
|
|
|
if (_lastDragView == v)
|
|
|
|
|
{
|
|
|
|
|
isEntry = NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isEntry = YES;
|
|
|
|
|
if (_lastDragView != nil && _f.accepts_drag)
|
|
|
|
|
{
|
|
|
|
|
NSDebugLLog(@"NSDragging", @"Dragging exit");
|
|
|
|
|
GSPerformVoidDragSelector(_lastDragView,
|
|
|
|
|
@selector(draggingExited:), dragInfo);
|
|
|
|
|
}
|
|
|
|
|
ASSIGN(_lastDragView, v);
|
|
|
|
|
_f.accepts_drag = GSViewAcceptsDrag(v, dragInfo);
|
|
|
|
|
}
|
2001-12-11 04:31:08 +00:00
|
|
|
|
if (_f.accepts_drag)
|
|
|
|
|
{
|
2002-01-20 21:08:58 +00:00
|
|
|
|
if (isEntry == YES)
|
2001-12-11 04:31:08 +00:00
|
|
|
|
{
|
|
|
|
|
action = NSDragOperationNone;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSDebugLLog(@"NSDragging", @"Dragging entered");
|
2001-12-11 04:31:08 +00:00
|
|
|
|
GSPerformDragSelector(v, @selector(draggingEntered:),
|
2007-09-09 12:19:01 +00:00
|
|
|
|
dragInfo, action);
|
2001-12-11 04:31:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
action = _lastDragOperationMask;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSDebugLLog(@"NSDragging", @"Dragging updated");
|
2001-12-11 04:31:08 +00:00
|
|
|
|
GSPerformDragSelector(v, @selector(draggingUpdated:),
|
|
|
|
|
dragInfo, action);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
action = NSDragOperationNone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e = [NSEvent otherEventWithType: NSAppKitDefined
|
|
|
|
|
location: [theEvent locationInWindow]
|
|
|
|
|
modifierFlags: 0
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: _windowNum
|
|
|
|
|
context: GSCurrentContext()
|
|
|
|
|
subtype: GSAppKitDraggingStatus
|
|
|
|
|
data1: [theEvent data1]
|
|
|
|
|
data2: action];
|
|
|
|
|
|
|
|
|
|
_lastDragOperationMask = action;
|
2001-12-21 00:45:48 +00:00
|
|
|
|
[dragInfo postDragEvent: e];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingStatus:
|
|
|
|
|
NSDebugLLog(@"NSDragging",
|
|
|
|
|
@"Internal: dropped GSAppKitDraggingStatus event");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingExit:
|
|
|
|
|
NSDebugLLog(@"NSDragging", @"GSAppKitDraggingExit");
|
|
|
|
|
dragInfo = [GSServerForWindow(self) dragInfo];
|
|
|
|
|
if (_lastDragView && _f.accepts_drag)
|
|
|
|
|
{
|
|
|
|
|
NSDebugLLog(@"NSDragging", @"Dragging exit");
|
|
|
|
|
GSPerformVoidDragSelector(_lastDragView,
|
|
|
|
|
@selector(draggingExited:), dragInfo);
|
|
|
|
|
}
|
2001-12-11 04:31:08 +00:00
|
|
|
|
_lastDragOperationMask = NSDragOperationNone;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
DESTROY(_lastDragView);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingDrop:
|
|
|
|
|
NSDebugLLog(@"NSDragging", @"GSAppKitDraggingDrop");
|
|
|
|
|
dragInfo = [GSServerForWindow(self) dragInfo];
|
2012-03-09 08:03:45 +00:00
|
|
|
|
if (_lastDragView && _f.accepts_drag
|
|
|
|
|
&& _lastDragOperationMask != NSDragOperationNone)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
2008-06-09 18:09:09 +00:00
|
|
|
|
action = YES;
|
2001-12-11 04:31:08 +00:00
|
|
|
|
GSPerformDragSelector(_lastDragView,
|
2007-09-09 12:19:01 +00:00
|
|
|
|
@selector(prepareForDragOperation:), dragInfo, action);
|
|
|
|
|
if (action)
|
|
|
|
|
{
|
2001-12-11 04:31:08 +00:00
|
|
|
|
action = NO;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
GSPerformDragSelector(_lastDragView,
|
|
|
|
|
@selector(performDragOperation:), dragInfo, action);
|
|
|
|
|
}
|
|
|
|
|
if (action)
|
|
|
|
|
{
|
|
|
|
|
GSPerformVoidDragSelector(_lastDragView,
|
|
|
|
|
@selector(concludeDragOperation:), dragInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-12-11 04:31:08 +00:00
|
|
|
|
_lastDragOperationMask = NSDragOperationNone;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
DESTROY(_lastDragView);
|
|
|
|
|
e = [NSEvent otherEventWithType: NSAppKitDefined
|
|
|
|
|
location: [theEvent locationInWindow]
|
|
|
|
|
modifierFlags: 0
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: _windowNum
|
|
|
|
|
context: GSCurrentContext()
|
|
|
|
|
subtype: GSAppKitDraggingFinished
|
|
|
|
|
data1: [theEvent data1]
|
|
|
|
|
data2: 0];
|
|
|
|
|
[dragInfo postDragEvent: e];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingFinished:
|
2001-12-11 04:31:08 +00:00
|
|
|
|
_lastDragOperationMask = NSDragOperationNone;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
DESTROY(_lastDragView);
|
|
|
|
|
NSDebugLLog(@"NSDragging",
|
|
|
|
|
@"Internal: dropped GSAppKitDraggingFinished event");
|
|
|
|
|
break;
|
1999-07-29 20:58:04 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
1999-07-06 11:56:22 +00:00
|
|
|
|
|
1999-12-16 04:53:50 +00:00
|
|
|
|
case NSPeriodic:
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSSystemDefined:
|
|
|
|
|
case NSApplicationDefined:
|
2007-09-09 12:19:01 +00:00
|
|
|
|
break;
|
2007-08-03 11:27:41 +00:00
|
|
|
|
|
|
|
|
|
case NSTabletPoint:
|
|
|
|
|
case NSTabletProximity:
|
|
|
|
|
// FIXME: Tablet events
|
|
|
|
|
break;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-05-20 12:31:42 +00:00
|
|
|
|
- (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent
|
|
|
|
|
{
|
|
|
|
|
NSView *v;
|
|
|
|
|
|
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
|
|
|
|
if (![self isMainWindow])
|
|
|
|
|
{
|
|
|
|
|
return (v != _wv);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return [v shouldBeTreatedAsInkEvent: theEvent];
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-06 20:20:31 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (BOOL) tryToPerform: (SEL)anAction with: (id)anObject
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2001-11-26 20:25:50 +00:00
|
|
|
|
if ([super tryToPerform: anAction with: anObject])
|
|
|
|
|
return YES;
|
|
|
|
|
else if (_delegate && [_delegate respondsToSelector: anAction])
|
|
|
|
|
{
|
|
|
|
|
[_delegate performSelector: anAction withObject: anObject];
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) worksWhenModal
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-15 10:18:24 +00:00
|
|
|
|
/** If aView responds to -nextValidKeyView with a new NSView, call
|
|
|
|
|
-makeFirstResponder: for the returned view.
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) selectKeyViewFollowingView: (NSView*)aView
|
1999-10-08 07:17:19 +00:00
|
|
|
|
{
|
|
|
|
|
NSView *theView = nil;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
1999-10-08 07:17:19 +00:00
|
|
|
|
if ([aView isKindOfClass: viewClass])
|
|
|
|
|
theView = [aView nextValidKeyView];
|
|
|
|
|
if (theView)
|
1999-11-14 21:16:04 +00:00
|
|
|
|
{
|
2007-09-05 13:04:49 +00:00
|
|
|
|
if (![self makeFirstResponder: theView])
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
2007-09-05 13:04:49 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_f.selectionDirection = NSSelectingNext;
|
2007-09-05 13:04:49 +00:00
|
|
|
|
[(id)theView selectText: self];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_f.selectionDirection = NSDirectSelection;
|
2012-10-04 09:20:08 +00:00
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-15 10:18:24 +00:00
|
|
|
|
/** If aView responds to -previousValidKeyView with a new NSView, call
|
|
|
|
|
-makeFirstResponder: for this view.
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) selectKeyViewPrecedingView: (NSView*)aView
|
1999-10-08 07:17:19 +00:00
|
|
|
|
{
|
|
|
|
|
NSView *theView = nil;
|
|
|
|
|
|
|
|
|
|
if ([aView isKindOfClass: viewClass])
|
|
|
|
|
theView = [aView previousValidKeyView];
|
|
|
|
|
if (theView)
|
1999-11-14 21:16:04 +00:00
|
|
|
|
{
|
2007-09-05 13:04:49 +00:00
|
|
|
|
if (![self makeFirstResponder: theView])
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
2007-09-05 13:04:49 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_f.selectionDirection = NSSelectingPrevious;
|
2007-09-05 13:04:49 +00:00
|
|
|
|
[(id)theView selectText: self];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_f.selectionDirection = NSDirectSelection;
|
2007-09-05 13:04:49 +00:00
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-15 10:18:24 +00:00
|
|
|
|
/** This method checks if:
|
|
|
|
|
<list>
|
|
|
|
|
<item>_firstResponder answers to -nextValidKeyView</item>
|
|
|
|
|
<item>_initialFirstResponder answers to -acceptsFirstResponder</item>
|
|
|
|
|
<item>_initialFirstResponder answers to -previousValidKeyView</item>
|
|
|
|
|
</list>
|
|
|
|
|
If any of these checks return a NSView, call -makeFirstResponder: on
|
|
|
|
|
this NSView.
|
|
|
|
|
*/
|
1999-10-08 07:17:19 +00:00
|
|
|
|
- (void) selectNextKeyView: (id)sender
|
|
|
|
|
{
|
|
|
|
|
NSView *theView = nil;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ([_firstResponder isKindOfClass: viewClass])
|
|
|
|
|
theView = [_firstResponder nextValidKeyView];
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ((theView == nil) && (_initialFirstResponder))
|
1999-10-08 07:17:19 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ([_initialFirstResponder acceptsFirstResponder])
|
2007-08-31 10:52:52 +00:00
|
|
|
|
theView = _initialFirstResponder;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
else
|
2007-08-31 10:52:52 +00:00
|
|
|
|
theView = [_initialFirstResponder nextValidKeyView];
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (theView)
|
1999-11-14 21:16:04 +00:00
|
|
|
|
{
|
2007-09-05 13:04:49 +00:00
|
|
|
|
if (![self makeFirstResponder: theView])
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
2007-08-31 10:52:52 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_f.selectionDirection = NSSelectingNext;
|
2007-08-31 10:52:52 +00:00
|
|
|
|
[(id)theView selectText: self];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_f.selectionDirection = NSDirectSelection;
|
2007-08-31 10:52:52 +00:00
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-15 10:18:24 +00:00
|
|
|
|
/** This method checks if:
|
|
|
|
|
<list>
|
|
|
|
|
<item>_firstResponder answers to -previousValidKeyView</item>
|
|
|
|
|
<item>_initialFirstResponder answers to -acceptsFirstResponder</item>
|
|
|
|
|
<item>_initialFirstResponder answers to -previousValidKeyView</item>
|
|
|
|
|
</list>
|
|
|
|
|
If any of these checks return a NSView, call -makeFirstResponder: on
|
|
|
|
|
this NSView.
|
|
|
|
|
*/
|
1999-10-08 07:17:19 +00:00
|
|
|
|
- (void) selectPreviousKeyView: (id)sender
|
|
|
|
|
{
|
|
|
|
|
NSView *theView = nil;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ([_firstResponder isKindOfClass: viewClass])
|
|
|
|
|
theView = [_firstResponder previousValidKeyView];
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ((theView == nil) && (_initialFirstResponder))
|
1999-10-08 07:17:19 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ([_initialFirstResponder acceptsFirstResponder])
|
2007-08-31 10:52:52 +00:00
|
|
|
|
theView = _initialFirstResponder;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
else
|
2007-08-31 10:52:52 +00:00
|
|
|
|
theView = [_initialFirstResponder previousValidKeyView];
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (theView)
|
1999-11-14 21:16:04 +00:00
|
|
|
|
{
|
2007-09-05 13:04:49 +00:00
|
|
|
|
if (![self makeFirstResponder: theView])
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-10-04 09:20:08 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
2007-08-31 10:52:52 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_f.selectionDirection = NSSelectingPrevious;
|
2007-08-31 10:52:52 +00:00
|
|
|
|
[(id)theView selectText: self];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_f.selectionDirection = NSDirectSelection;
|
2007-08-31 10:52:52 +00:00
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-18 01:00:58 +00:00
|
|
|
|
// This is invoked by selectText: of some views (eg matrixes),
|
|
|
|
|
// to know whether they have received it from the window, and
|
1999-12-16 04:53:50 +00:00
|
|
|
|
// if so, in which direction is the selection moving (so that they know
|
1999-11-18 01:00:58 +00:00
|
|
|
|
// if they should select the last or the first editable cell).
|
2007-01-15 10:18:24 +00:00
|
|
|
|
/** Returns the value of _selectionDirection, the direction of the
|
|
|
|
|
current key view.<br />
|
|
|
|
|
See Also:
|
|
|
|
|
<list>
|
|
|
|
|
<item>-selectKeyViewFollowingView:</item>
|
|
|
|
|
<item>-selectKeyViewPrecedingView:</item>
|
|
|
|
|
<item>-selectNextKeyView:</item>
|
|
|
|
|
<item>-selectPreviousKeyView:</item>
|
|
|
|
|
</list>
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSSelectionDirection) keyViewSelectionDirection
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
return _f.selectionDirection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) autorecalculatesKeyViewLoop
|
|
|
|
|
{
|
|
|
|
|
return _f.autorecalculates_keyview_loop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setAutorecalculatesKeyViewLoop: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
_f.autorecalculates_keyview_loop = flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) recalculateKeyViewLoop
|
|
|
|
|
{
|
2012-10-04 09:20:08 +00:00
|
|
|
|
// Should be called from NSView viewWillMoveToWindow (but only if
|
|
|
|
|
// -autorecalculatesKeyViewLoop returns YES)
|
|
|
|
|
[_contentView _setUpKeyViewLoopWithNextKeyView: _contentView];
|
|
|
|
|
[self setInitialFirstResponder: [_contentView nextValidKeyView]];
|
1999-11-18 01:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Dragging
|
|
|
|
|
*/
|
1999-07-04 18:13:15 +00:00
|
|
|
|
- (void) dragImage: (NSImage*)anImage
|
2007-09-09 12:19:01 +00:00
|
|
|
|
at: (NSPoint)baseLocation
|
|
|
|
|
offset: (NSSize)initialOffset
|
|
|
|
|
event: (NSEvent*)event
|
1999-07-04 18:13:15 +00:00
|
|
|
|
pasteboard: (NSPasteboard*)pboard
|
2007-09-09 12:19:01 +00:00
|
|
|
|
source: (id)sourceObject
|
|
|
|
|
slideBack: (BOOL)slideFlag
|
1998-11-12 10:49:00 +00:00
|
|
|
|
{
|
2002-03-28 03:53:18 +00:00
|
|
|
|
id dragView = [GSServerForWindow(self) dragInfo];
|
2001-12-21 00:45:48 +00:00
|
|
|
|
|
|
|
|
|
[NSApp preventWindowOrdering];
|
|
|
|
|
[dragView dragImage: anImage
|
2007-09-09 12:19:01 +00:00
|
|
|
|
at: [self convertBaseToScreen: baseLocation]
|
|
|
|
|
offset: initialOffset
|
|
|
|
|
event: event
|
|
|
|
|
pasteboard: pboard
|
|
|
|
|
source: sourceObject
|
|
|
|
|
slideBack: slideFlag];
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-01 17:05:57 +00:00
|
|
|
|
- (void) registerForDraggedTypes: (NSArray*)newTypes
|
1998-11-12 10:49:00 +00:00
|
|
|
|
{
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv registerForDraggedTypes: newTypes];
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) unregisterDraggedTypes
|
1998-11-12 10:49:00 +00:00
|
|
|
|
{
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv unregisterDraggedTypes];
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Services and windows menu support
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) isExcludedFromWindowsMenu
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.menu_exclude;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setExcludedFromWindowsMenu: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-30 20:26:33 +00:00
|
|
|
|
if (_f.menu_exclude != flag)
|
|
|
|
|
{
|
|
|
|
|
_f.menu_exclude = flag;
|
2005-10-23 10:53:39 +00:00
|
|
|
|
if (flag == YES)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
[NSApp removeWindowsItem: self];
|
|
|
|
|
}
|
2005-10-23 10:53:39 +00:00
|
|
|
|
else if (_f.has_opened == YES && flag == NO)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
[NSApp addWindowsItem: self
|
|
|
|
|
title: _windowTitle
|
2012-10-03 12:58:26 +00:00
|
|
|
|
filename: [self _hasTitleWithRepresentedFilename]];
|
2007-09-09 12:19:01 +00:00
|
|
|
|
}
|
1999-11-30 20:26:33 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (id) validRequestorForSendType: (NSString*)sendType
|
2007-09-09 12:19:01 +00:00
|
|
|
|
returnType: (NSString*)returnType
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
id result = nil;
|
1998-11-24 15:25:22 +00:00
|
|
|
|
|
2010-11-03 20:06:00 +00:00
|
|
|
|
if (_delegate && [_delegate respondsToSelector: _cmd]
|
|
|
|
|
&& ![_delegate isKindOfClass: [NSResponder class]])
|
1999-12-07 05:53:26 +00:00
|
|
|
|
result = [_delegate validRequestorForSendType: sendType
|
2007-09-09 12:19:01 +00:00
|
|
|
|
returnType: returnType];
|
1998-11-24 15:25:22 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (result == nil)
|
1999-06-09 08:54:08 +00:00
|
|
|
|
result = [NSApp validRequestorForSendType: sendType
|
2007-09-09 12:19:01 +00:00
|
|
|
|
returnType: returnType];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return result;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Saving and restoring the frame
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSString*) frameAutosaveName
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _autosaveName;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) saveFrameUsingName: (NSString*)name
|
1998-11-12 10:49:00 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSUserDefaults *defs;
|
|
|
|
|
NSString *key;
|
|
|
|
|
id obj;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
1999-11-16 09:40:14 +00:00
|
|
|
|
defs = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
obj = [self stringWithSavedFrame];
|
2000-01-07 16:46:35 +00:00
|
|
|
|
key = [NSString stringWithFormat: @"NSWindow Frame %@", name];
|
1999-11-16 09:40:14 +00:00
|
|
|
|
[defs setObject: obj forKey: key];
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (BOOL) setFrameAutosaveName: (NSString*)name
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ([name isEqual: _autosaveName])
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
return YES; /* That's our name already. */
|
1999-07-06 05:37:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ([autosaveNames member: name] != nil)
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
return NO; /* Name in use elsewhere. */
|
1999-07-06 05:37:15 +00:00
|
|
|
|
}
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (_autosaveName != nil)
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
2003-10-03 14:09:58 +00:00
|
|
|
|
[[self class] removeFrameUsingName: _autosaveName];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[autosaveNames removeObject: _autosaveName];
|
|
|
|
|
_autosaveName = nil;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
}
|
|
|
|
|
if (name != nil && [name isEqual: @""] == NO)
|
|
|
|
|
{
|
|
|
|
|
name = [name copy];
|
|
|
|
|
[autosaveNames addObject: name];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_autosaveName = name;
|
2000-02-21 15:33:30 +00:00
|
|
|
|
RELEASE(name);
|
2003-10-03 14:09:58 +00:00
|
|
|
|
if (![self setFrameUsingName: _autosaveName])
|
|
|
|
|
{
|
|
|
|
|
[self saveFrameUsingName: _autosaveName];
|
|
|
|
|
}
|
1999-12-01 08:26:33 +00:00
|
|
|
|
}
|
1999-07-06 05:37:15 +00:00
|
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setFrameFromString: (NSString*)string
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSScanner *scanner = [NSScanner scannerWithString: string];
|
|
|
|
|
NSRect nRect;
|
|
|
|
|
NSRect sRect;
|
|
|
|
|
NSRect fRect;
|
|
|
|
|
int value;
|
2012-08-17 13:16:12 +00:00
|
|
|
|
NSScreen *screen;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
1999-11-16 07:00:43 +00:00
|
|
|
|
/*
|
|
|
|
|
* Scan in the window frame (flipped coordinate system).
|
|
|
|
|
*/
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSLog(@"Bad window frame format - x-coord missing");
|
|
|
|
|
return;
|
1999-09-09 02:56:20 +00:00
|
|
|
|
}
|
1999-11-16 07:00:43 +00:00
|
|
|
|
fRect.origin.x = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSLog(@"Bad window frame format - y-coord missing");
|
|
|
|
|
return;
|
1999-09-09 02:56:20 +00:00
|
|
|
|
}
|
1999-11-16 07:00:43 +00:00
|
|
|
|
fRect.origin.y = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSLog(@"Bad window frame format - width missing");
|
|
|
|
|
return;
|
1999-09-09 02:56:20 +00:00
|
|
|
|
}
|
1999-11-16 07:00:43 +00:00
|
|
|
|
fRect.size.width = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSLog(@"Bad window frame format - height missing");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
fRect.size.height = value;
|
2010-02-25 18:30:10 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check that the window will come up on screen
|
|
|
|
|
*/
|
2012-08-17 13:16:12 +00:00
|
|
|
|
#if 0 // Not valid since screen frame x/y values can be negative...
|
2010-02-25 18:30:10 +00:00
|
|
|
|
if (fRect.origin.x + fRect.size.width < 0)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Bad screen frame - window is off screen");
|
2012-08-17 13:16:12 +00:00
|
|
|
|
return;
|
2010-02-25 18:30:10 +00:00
|
|
|
|
}
|
2012-08-17 13:16:12 +00:00
|
|
|
|
#endif
|
1999-11-16 07:00:43 +00:00
|
|
|
|
|
2011-01-24 08:59:10 +00:00
|
|
|
|
// if toolbar is showing, adjust saved frame to add the toolbar back in
|
|
|
|
|
if ([_toolbar isVisible])
|
|
|
|
|
{
|
2013-02-16 00:08:33 +00:00
|
|
|
|
CGFloat toolbarHeight = [[_toolbar _toolbarView] frame].size.height;
|
2011-01-24 08:59:10 +00:00
|
|
|
|
fRect.size.height += toolbarHeight;
|
|
|
|
|
fRect.origin.y -= toolbarHeight;
|
|
|
|
|
}
|
2011-01-24 13:19:30 +00:00
|
|
|
|
// if window has a menu, adjust saved frame to add the menu back in
|
|
|
|
|
if ([_wv hasMenu])
|
|
|
|
|
{
|
2013-02-16 00:08:33 +00:00
|
|
|
|
CGFloat menuBarHeight = [[GSTheme theme] menuHeightForWindow: self];
|
2012-02-20 17:46:28 +00:00
|
|
|
|
fRect.size.height += menuBarHeight;
|
2011-01-24 13:19:30 +00:00
|
|
|
|
fRect.origin.y -= menuBarHeight;
|
|
|
|
|
}
|
2011-01-24 08:59:10 +00:00
|
|
|
|
|
1999-11-16 07:00:43 +00:00
|
|
|
|
/*
|
|
|
|
|
* Scan in the frame for the area the window was placed in in screen.
|
|
|
|
|
*/
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Bad screen frame format - x-coord missing");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sRect.origin.x = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Bad screen frame format - y-coord missing");
|
|
|
|
|
return;
|
1999-09-09 02:56:20 +00:00
|
|
|
|
}
|
1999-11-16 07:00:43 +00:00
|
|
|
|
sRect.origin.y = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Bad screen frame format - width missing");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sRect.size.width = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Bad screen frame format - height missing");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sRect.size.height = value;
|
|
|
|
|
|
|
|
|
|
/*
|
2003-02-02 00:58:32 +00:00
|
|
|
|
* The screen rectangle gives the area of the screen in which
|
|
|
|
|
* the window could be placed (ie a rectangle excluding the dock).
|
1999-11-16 07:00:43 +00:00
|
|
|
|
*/
|
2012-08-17 13:16:12 +00:00
|
|
|
|
screen = [self _screenForFrame: fRect];
|
|
|
|
|
|
|
|
|
|
// Check whether a portion is showing somewhere...
|
|
|
|
|
if (screen == nil)
|
|
|
|
|
{
|
|
|
|
|
// If the window doesn't show up on any screen then we need
|
|
|
|
|
// to move it so it can be seen and assign it to the main
|
|
|
|
|
// screen...
|
|
|
|
|
screen = [NSScreen mainScreen];
|
|
|
|
|
NSDebugLLog(@"NSWindow", @"%s: re-assigning to main screen\n", __PRETTY_FUNCTION__);
|
|
|
|
|
}
|
|
|
|
|
nRect = [screen visibleFrame];
|
|
|
|
|
|
1999-11-16 07:00:43 +00:00
|
|
|
|
/*
|
2003-04-26 06:39:49 +00:00
|
|
|
|
* If the new screen drawable area has moved relative to the one in
|
|
|
|
|
* which the window was saved, adjust the window position accordingly.
|
1999-11-16 07:00:43 +00:00
|
|
|
|
*/
|
2003-04-26 06:39:49 +00:00
|
|
|
|
if (NSEqualPoints(nRect.origin, sRect.origin) == NO)
|
1999-11-16 07:00:43 +00:00
|
|
|
|
{
|
2003-04-26 06:39:49 +00:00
|
|
|
|
fRect.origin.x += nRect.origin.x - sRect.origin.x;
|
|
|
|
|
fRect.origin.y += nRect.origin.y - sRect.origin.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If the stored screen area is not the same as that currently
|
|
|
|
|
* available, we adjust the window frame (position) to try to
|
|
|
|
|
* make layout sensible.
|
|
|
|
|
*/
|
|
|
|
|
if (nRect.size.width != sRect.size.width)
|
|
|
|
|
{
|
|
|
|
|
fRect.origin.x = nRect.origin.x + (fRect.origin.x - nRect.origin.x)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
* (nRect.size.width / sRect.size.width);
|
2003-04-26 06:39:49 +00:00
|
|
|
|
}
|
|
|
|
|
if (nRect.size.height != sRect.size.height)
|
|
|
|
|
{
|
|
|
|
|
fRect.origin.y = nRect.origin.y + (fRect.origin.y - nRect.origin.y)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
* (nRect.size.height / sRect.size.height);
|
2008-07-08 20:17:44 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If height of the window goes above the screen height, then adjust the window down.
|
|
|
|
|
*/
|
|
|
|
|
if ((fRect.size.height + fRect.origin.y) > nRect.size.height)
|
2012-08-17 13:16:12 +00:00
|
|
|
|
{
|
|
|
|
|
fRect.origin.y = nRect.size.height - fRect.size.height;
|
|
|
|
|
}
|
1999-11-16 07:00:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-11-12 09:05:22 +00:00
|
|
|
|
// FIXME: Is this check needed?
|
2004-08-23 15:34:34 +00:00
|
|
|
|
/* If we aren't resizable (ie. if we don't have a resize bar), make sure
|
2009-11-12 09:05:22 +00:00
|
|
|
|
we don't change the size. */
|
2004-08-23 15:34:34 +00:00
|
|
|
|
if (!(_styleMask & NSResizableWindowMask))
|
|
|
|
|
fRect.size = _frame.size;
|
|
|
|
|
|
2009-11-12 09:05:22 +00:00
|
|
|
|
if (NSEqualSizes(fRect.size, _frame.size) == NO)
|
|
|
|
|
{
|
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowWillResize:toSize:)])
|
|
|
|
|
{
|
|
|
|
|
fRect.size = [_delegate windowWillResize: self
|
|
|
|
|
toSize: fRect.size];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-17 13:16:12 +00:00
|
|
|
|
// Make sure we are using the new screen we are applying to...
|
|
|
|
|
ASSIGN(_screen, screen);
|
|
|
|
|
|
1999-11-16 07:00:43 +00:00
|
|
|
|
/*
|
2003-02-02 00:58:32 +00:00
|
|
|
|
* Set frame.
|
1999-11-16 07:00:43 +00:00
|
|
|
|
*/
|
2000-08-07 22:06:04 +00:00
|
|
|
|
[self setFrame: fRect display: (_f.visible) ? YES : NO];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (BOOL) setFrameUsingName: (NSString*)name
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSUserDefaults *defs;
|
|
|
|
|
id obj;
|
|
|
|
|
NSString *key;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
1999-11-16 09:40:14 +00:00
|
|
|
|
defs = [NSUserDefaults standardUserDefaults];
|
2000-01-07 16:46:35 +00:00
|
|
|
|
key = [NSString stringWithFormat: @"NSWindow Frame %@", name];
|
|
|
|
|
obj = [defs objectForKey: key];
|
1999-07-06 05:37:15 +00:00
|
|
|
|
if (obj == nil)
|
|
|
|
|
return NO;
|
2009-11-12 09:05:22 +00:00
|
|
|
|
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[self setFrameFromString: obj];
|
|
|
|
|
return YES;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 20:25:50 +00:00
|
|
|
|
- (BOOL) setFrameUsingName: (NSString *)name
|
2007-09-09 12:19:01 +00:00
|
|
|
|
force: (BOOL)force
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME
|
2009-11-12 09:05:22 +00:00
|
|
|
|
if ((_styleMask & NSResizableWindowMask) || force)
|
|
|
|
|
return [self setFrameUsingName: name];
|
|
|
|
|
else
|
|
|
|
|
return NO;
|
2001-11-26 20:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-02-08 00:00:32 +00:00
|
|
|
|
- (NSString *) stringWithSavedFrame
|
1998-12-17 13:06:17 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSRect fRect;
|
|
|
|
|
NSRect sRect;
|
2012-08-17 13:16:12 +00:00
|
|
|
|
NSString *autosaveString;
|
1999-11-16 07:00:43 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
fRect = _frame;
|
2002-08-09 10:14:45 +00:00
|
|
|
|
|
2011-01-24 08:59:10 +00:00
|
|
|
|
// if toolbar is showing, adjust saved frame to not include the toolbar
|
|
|
|
|
if ([_toolbar isVisible])
|
|
|
|
|
{
|
2013-02-16 00:08:33 +00:00
|
|
|
|
CGFloat toolbarHeight = [[_toolbar _toolbarView] frame].size.height;
|
2011-01-24 08:59:10 +00:00
|
|
|
|
fRect.size.height -= toolbarHeight;
|
|
|
|
|
fRect.origin.y += toolbarHeight;
|
|
|
|
|
}
|
2011-01-24 13:19:30 +00:00
|
|
|
|
// if window has a menu, adjust saved frame to not include the menu
|
|
|
|
|
if ([_wv hasMenu])
|
|
|
|
|
{
|
2013-02-16 00:08:33 +00:00
|
|
|
|
CGFloat menuBarHeight = [[GSTheme theme] menuHeightForWindow: self];
|
2011-01-24 13:19:30 +00:00
|
|
|
|
fRect.size.height -= menuBarHeight;
|
|
|
|
|
fRect.origin.y += menuBarHeight;
|
|
|
|
|
}
|
2011-01-24 08:59:10 +00:00
|
|
|
|
|
1999-11-16 07:00:43 +00:00
|
|
|
|
/*
|
2009-11-12 09:05:22 +00:00
|
|
|
|
* The screen rectangle should give the area of the screen in which
|
2003-02-02 00:58:32 +00:00
|
|
|
|
* the window could be placed (ie a rectangle excluding the dock).
|
1999-11-16 07:00:43 +00:00
|
|
|
|
*/
|
2003-02-02 00:58:32 +00:00
|
|
|
|
sRect = [[self screen] visibleFrame];
|
2012-08-17 13:16:12 +00:00
|
|
|
|
autosaveString = [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d ",
|
|
|
|
|
(int)fRect.origin.x, (int)fRect.origin.y,
|
|
|
|
|
(int)fRect.size.width, (int)fRect.size.height,
|
|
|
|
|
(int)sRect.origin.x, (int)sRect.origin.y,
|
|
|
|
|
(int)sRect.size.width, (int)sRect.size.height];
|
|
|
|
|
NSDebugLLog(@"NSWindow", @"%s:autosaveName: %@ frame string: %@", __PRETTY_FUNCTION__,
|
|
|
|
|
_autosaveName, autosaveString);
|
|
|
|
|
|
|
|
|
|
return autosaveString;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
/*
|
|
|
|
|
* Printing and postscript
|
|
|
|
|
*/
|
2001-02-08 00:00:32 +00:00
|
|
|
|
- (NSData *) dataWithEPSInsideRect: (NSRect)rect
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
return [_wv dataWithEPSInsideRect:
|
2007-09-09 12:19:01 +00:00
|
|
|
|
[_wv convertRect: rect fromView: nil]];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-06 11:29:20 +00:00
|
|
|
|
- (NSData *) dataWithPDFInsideRect:(NSRect)aRect
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
return [_wv dataWithPDFInsideRect:
|
2007-09-09 12:19:01 +00:00
|
|
|
|
[_wv convertRect: aRect fromView: nil]];
|
2001-11-26 20:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Opens the fax panel to allow the user to fax the contents of
|
|
|
|
|
the window view.
|
|
|
|
|
*/
|
2000-03-04 07:55:42 +00:00
|
|
|
|
- (void) fax: (id)sender
|
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv fax: sender];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Opens the print panel to allow the user to print the contents of
|
|
|
|
|
the window view.
|
|
|
|
|
*/
|
2000-03-04 07:55:42 +00:00
|
|
|
|
- (void) print: (id)sender
|
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv print: sender];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Zooming
|
|
|
|
|
*/
|
|
|
|
|
|
2009-11-12 09:05:22 +00:00
|
|
|
|
#define DIST 3
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Returns yes, if the receiver is zoomed.
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (BOOL) isZoomed
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2009-11-12 09:05:22 +00:00
|
|
|
|
NSRect maxRect = [[self screen] visibleFrame];
|
|
|
|
|
|
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)])
|
|
|
|
|
{
|
|
|
|
|
maxRect = [_delegate windowWillUseStandardFrame: self defaultFrame: maxRect];
|
|
|
|
|
}
|
|
|
|
|
else if ([self respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)])
|
|
|
|
|
{
|
|
|
|
|
maxRect = [self windowWillUseStandardFrame: self defaultFrame: maxRect];
|
|
|
|
|
}
|
|
|
|
|
else if ([_delegate respondsToSelector: @selector(windowWillResize:toSize:)])
|
|
|
|
|
{
|
|
|
|
|
maxRect.size = [_delegate windowWillResize: self toSize: maxRect.size];
|
|
|
|
|
}
|
|
|
|
|
else if ([self respondsToSelector: @selector(windowWillResize:toSize:)])
|
|
|
|
|
{
|
|
|
|
|
maxRect.size = [self windowWillResize: self toSize: maxRect.size];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Compare the new frame with the current one
|
|
|
|
|
return NSEqualRects(maxRect, _frame);
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Performs the zoom method on the receiver.
|
|
|
|
|
*/
|
2000-03-03 02:22:11 +00:00
|
|
|
|
- (void) performZoom: (id)sender
|
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: We should check for the style and highlight the button
|
|
|
|
|
[self zoom: sender];
|
2000-03-03 02:22:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Zooms the receiver. This method calls the delegate method
|
|
|
|
|
windowShouldZoom:toFrame: to determine if the window should
|
|
|
|
|
be allowed to zoom to full screen.
|
|
|
|
|
*/
|
2000-03-03 02:22:11 +00:00
|
|
|
|
- (void) zoom: (id)sender
|
|
|
|
|
{
|
2003-02-02 00:58:32 +00:00
|
|
|
|
NSRect maxRect = [[self screen] visibleFrame];
|
|
|
|
|
|
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)])
|
|
|
|
|
{
|
|
|
|
|
maxRect = [_delegate windowWillUseStandardFrame: self defaultFrame: maxRect];
|
|
|
|
|
}
|
|
|
|
|
else if ([self respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)])
|
|
|
|
|
{
|
|
|
|
|
maxRect = [self windowWillUseStandardFrame: self defaultFrame: maxRect];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
maxRect = [self constrainFrameRect: maxRect toScreen: [self screen]];
|
|
|
|
|
|
|
|
|
|
// Compare the new frame with the current one
|
2015-05-26 17:57:19 +00:00
|
|
|
|
if ((fabs(NSMaxX(maxRect) - NSMaxX(_frame)) < DIST)
|
|
|
|
|
&& (fabs(NSMaxY(maxRect) - NSMaxY(_frame)) < DIST)
|
|
|
|
|
&& (fabs(NSMinX(maxRect) - NSMinX(_frame)) < DIST)
|
|
|
|
|
&& (fabs(NSMinY(maxRect) - NSMinY(_frame)) < DIST))
|
2003-02-02 00:58:32 +00:00
|
|
|
|
{
|
|
|
|
|
// Already in zoomed mode, reset user frame, if stored
|
|
|
|
|
if (_autosaveName != nil)
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
[self setFrameUsingName: _autosaveName];
|
|
|
|
|
}
|
2003-02-02 00:58:32 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowShouldZoom:toFrame:)])
|
|
|
|
|
{
|
|
|
|
|
if (![_delegate windowShouldZoom: self toFrame: maxRect])
|
2007-09-09 12:19:01 +00:00
|
|
|
|
return;
|
2003-02-02 00:58:32 +00:00
|
|
|
|
}
|
|
|
|
|
else if ([self respondsToSelector: @selector(windowShouldZoom:toFrame:)])
|
|
|
|
|
{
|
|
|
|
|
if (![self windowShouldZoom: self toFrame: maxRect])
|
2007-09-09 12:19:01 +00:00
|
|
|
|
return;
|
2003-02-02 00:58:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_autosaveName != nil)
|
|
|
|
|
{
|
|
|
|
|
[self saveFrameUsingName: _autosaveName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self setFrame: maxRect display: YES];
|
2000-03-03 02:22:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
2000-03-04 07:55:42 +00:00
|
|
|
|
* Default botton
|
1999-06-11 04:46:12 +00:00
|
|
|
|
*/
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
2001-02-08 00:00:32 +00:00
|
|
|
|
- (NSButtonCell *) defaultButtonCell
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid
core dump due to NSConnection bug.
* Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform
key equivalent for null character events. Triggered return key for
default button cell.
([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]),
([NSWindow -disableKeyEquivalentForDefaultButtonCell]),
([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented.
([NSWindow -dealloc]): release _defaultButtonCell
* Headers/AppKit/NSWindow.h: added ivar and flag.
* Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]),
([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]):
implemented keyboard navigation.
([NSOpenPanel -runModalForDirectory:file:types:]): do not allow
branch selection if can't choose directories.
([NSOpenPanel -_selectTextInColumn:]),
([NSOpenPanel -_selectCellName:]): new private methods.
([NSOpenPanel -filenames]): change for choose dirs.
* Source/NSText.m ([NSText -keyDown:]): forwards text field illegal
events to the next responder.
* Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]),
([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]),
([NSBrowser -keyDown:]): implemented keyboard navigation
([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]),
([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]):
changed return value from NSNotFound to -1 to conforms to NSMatrix
([NSBrowser -doClick:]): fix for new return values, added support for
multiple and branch selection.
([NSBrowser -setLastColumn:]): mark column titles need display
([NSBrowser -_getTitleOfColumn:]): fix for multiple selection.
* Source/NSCell.m ([NSCell -setState:]): bug fix: set value to
NSOnState if someone try to set NSMixedState in a two state cell.
([NSCell -performClick:]): do not perform click if the cell is
disabled.
* Source/NSMatrix.m ([NSMatrix
-_privateFrame:mode:numberOfRows:numberOfColumns:]),
([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]),
([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn
to -1 when no cells are selected
([NSMatrix -performKeyEquivalent:]): saves _selectedRow and
_selectedColumn.
([NSMatrix -getRow:column:ofCell:]): check for null values for row and
column.
([NSMatrix -selectCellAtRow:column:]): deselect the current selection
only in NSRadioModeMatrix mode.
([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix
and fix for this mode.
* Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select
text of the cell and enable okButton.
([NSSavePanel -controlTextDidChange:]): implemented.
([NSSavePanel -controlTextDidEndEditing:]): removed.
([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows
symbolic links.
([NSSavePanel -_initWithoutGModel]): set browser doubleAction to
performClick: of the _okButton. Set _okButton as default window button.
Disable _okButton.
([NSSavePanel -browser:selectCellWithString:inColumn:]),
([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented
keyboard navigation.
([NSSavePanel -runModalForDirectory:file:]): enable _okButton if
filename is valid.
([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]),
([NSSavePanel -_selectCellName:]): new private methods.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7468 72102866-910b-0410-8b05-ffd578937521
2000-09-10 21:55:17 +00:00
|
|
|
|
return _defaultButtonCell;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-13 07:00:38 +00:00
|
|
|
|
- (void) setDefaultButtonCell: (NSButtonCell *)aCell
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2002-10-13 07:00:38 +00:00
|
|
|
|
ASSIGN(_defaultButtonCell, aCell);
|
2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid
core dump due to NSConnection bug.
* Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform
key equivalent for null character events. Triggered return key for
default button cell.
([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]),
([NSWindow -disableKeyEquivalentForDefaultButtonCell]),
([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented.
([NSWindow -dealloc]): release _defaultButtonCell
* Headers/AppKit/NSWindow.h: added ivar and flag.
* Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]),
([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]):
implemented keyboard navigation.
([NSOpenPanel -runModalForDirectory:file:types:]): do not allow
branch selection if can't choose directories.
([NSOpenPanel -_selectTextInColumn:]),
([NSOpenPanel -_selectCellName:]): new private methods.
([NSOpenPanel -filenames]): change for choose dirs.
* Source/NSText.m ([NSText -keyDown:]): forwards text field illegal
events to the next responder.
* Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]),
([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]),
([NSBrowser -keyDown:]): implemented keyboard navigation
([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]),
([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]):
changed return value from NSNotFound to -1 to conforms to NSMatrix
([NSBrowser -doClick:]): fix for new return values, added support for
multiple and branch selection.
([NSBrowser -setLastColumn:]): mark column titles need display
([NSBrowser -_getTitleOfColumn:]): fix for multiple selection.
* Source/NSCell.m ([NSCell -setState:]): bug fix: set value to
NSOnState if someone try to set NSMixedState in a two state cell.
([NSCell -performClick:]): do not perform click if the cell is
disabled.
* Source/NSMatrix.m ([NSMatrix
-_privateFrame:mode:numberOfRows:numberOfColumns:]),
([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]),
([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn
to -1 when no cells are selected
([NSMatrix -performKeyEquivalent:]): saves _selectedRow and
_selectedColumn.
([NSMatrix -getRow:column:ofCell:]): check for null values for row and
column.
([NSMatrix -selectCellAtRow:column:]): deselect the current selection
only in NSRadioModeMatrix mode.
([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix
and fix for this mode.
* Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select
text of the cell and enable okButton.
([NSSavePanel -controlTextDidChange:]): implemented.
([NSSavePanel -controlTextDidEndEditing:]): removed.
([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows
symbolic links.
([NSSavePanel -_initWithoutGModel]): set browser doubleAction to
performClick: of the _okButton. Set _okButton as default window button.
Disable _okButton.
([NSSavePanel -browser:selectCellWithString:inColumn:]),
([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented
keyboard navigation.
([NSSavePanel -runModalForDirectory:file:]): enable _okButton if
filename is valid.
([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]),
([NSSavePanel -_selectCellName:]): new private methods.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7468 72102866-910b-0410-8b05-ffd578937521
2000-09-10 21:55:17 +00:00
|
|
|
|
_f.default_button_cell_key_disabled = NO;
|
2001-07-09 02:49:03 +00:00
|
|
|
|
|
2002-10-13 07:00:38 +00:00
|
|
|
|
[aCell setKeyEquivalent: @"\r"];
|
|
|
|
|
[aCell setKeyEquivalentModifierMask: 0];
|
2015-06-26 00:13:05 +00:00
|
|
|
|
[[GSTheme theme] didSetDefaultButtonCell: aCell];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) disableKeyEquivalentForDefaultButtonCell
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid
core dump due to NSConnection bug.
* Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform
key equivalent for null character events. Triggered return key for
default button cell.
([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]),
([NSWindow -disableKeyEquivalentForDefaultButtonCell]),
([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented.
([NSWindow -dealloc]): release _defaultButtonCell
* Headers/AppKit/NSWindow.h: added ivar and flag.
* Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]),
([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]):
implemented keyboard navigation.
([NSOpenPanel -runModalForDirectory:file:types:]): do not allow
branch selection if can't choose directories.
([NSOpenPanel -_selectTextInColumn:]),
([NSOpenPanel -_selectCellName:]): new private methods.
([NSOpenPanel -filenames]): change for choose dirs.
* Source/NSText.m ([NSText -keyDown:]): forwards text field illegal
events to the next responder.
* Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]),
([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]),
([NSBrowser -keyDown:]): implemented keyboard navigation
([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]),
([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]):
changed return value from NSNotFound to -1 to conforms to NSMatrix
([NSBrowser -doClick:]): fix for new return values, added support for
multiple and branch selection.
([NSBrowser -setLastColumn:]): mark column titles need display
([NSBrowser -_getTitleOfColumn:]): fix for multiple selection.
* Source/NSCell.m ([NSCell -setState:]): bug fix: set value to
NSOnState if someone try to set NSMixedState in a two state cell.
([NSCell -performClick:]): do not perform click if the cell is
disabled.
* Source/NSMatrix.m ([NSMatrix
-_privateFrame:mode:numberOfRows:numberOfColumns:]),
([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]),
([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn
to -1 when no cells are selected
([NSMatrix -performKeyEquivalent:]): saves _selectedRow and
_selectedColumn.
([NSMatrix -getRow:column:ofCell:]): check for null values for row and
column.
([NSMatrix -selectCellAtRow:column:]): deselect the current selection
only in NSRadioModeMatrix mode.
([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix
and fix for this mode.
* Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select
text of the cell and enable okButton.
([NSSavePanel -controlTextDidChange:]): implemented.
([NSSavePanel -controlTextDidEndEditing:]): removed.
([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows
symbolic links.
([NSSavePanel -_initWithoutGModel]): set browser doubleAction to
performClick: of the _okButton. Set _okButton as default window button.
Disable _okButton.
([NSSavePanel -browser:selectCellWithString:inColumn:]),
([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented
keyboard navigation.
([NSSavePanel -runModalForDirectory:file:]): enable _okButton if
filename is valid.
([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]),
([NSSavePanel -_selectCellName:]): new private methods.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7468 72102866-910b-0410-8b05-ffd578937521
2000-09-10 21:55:17 +00:00
|
|
|
|
_f.default_button_cell_key_disabled = YES;
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) enableKeyEquivalentForDefaultButtonCell
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid
core dump due to NSConnection bug.
* Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform
key equivalent for null character events. Triggered return key for
default button cell.
([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]),
([NSWindow -disableKeyEquivalentForDefaultButtonCell]),
([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented.
([NSWindow -dealloc]): release _defaultButtonCell
* Headers/AppKit/NSWindow.h: added ivar and flag.
* Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]),
([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]):
implemented keyboard navigation.
([NSOpenPanel -runModalForDirectory:file:types:]): do not allow
branch selection if can't choose directories.
([NSOpenPanel -_selectTextInColumn:]),
([NSOpenPanel -_selectCellName:]): new private methods.
([NSOpenPanel -filenames]): change for choose dirs.
* Source/NSText.m ([NSText -keyDown:]): forwards text field illegal
events to the next responder.
* Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]),
([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]),
([NSBrowser -keyDown:]): implemented keyboard navigation
([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]),
([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]):
changed return value from NSNotFound to -1 to conforms to NSMatrix
([NSBrowser -doClick:]): fix for new return values, added support for
multiple and branch selection.
([NSBrowser -setLastColumn:]): mark column titles need display
([NSBrowser -_getTitleOfColumn:]): fix for multiple selection.
* Source/NSCell.m ([NSCell -setState:]): bug fix: set value to
NSOnState if someone try to set NSMixedState in a two state cell.
([NSCell -performClick:]): do not perform click if the cell is
disabled.
* Source/NSMatrix.m ([NSMatrix
-_privateFrame:mode:numberOfRows:numberOfColumns:]),
([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]),
([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn
to -1 when no cells are selected
([NSMatrix -performKeyEquivalent:]): saves _selectedRow and
_selectedColumn.
([NSMatrix -getRow:column:ofCell:]): check for null values for row and
column.
([NSMatrix -selectCellAtRow:column:]): deselect the current selection
only in NSRadioModeMatrix mode.
([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix
and fix for this mode.
* Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select
text of the cell and enable okButton.
([NSSavePanel -controlTextDidChange:]): implemented.
([NSSavePanel -controlTextDidEndEditing:]): removed.
([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows
symbolic links.
([NSSavePanel -_initWithoutGModel]): set browser doubleAction to
performClick: of the _okButton. Set _okButton as default window button.
Disable _okButton.
([NSSavePanel -browser:selectCellWithString:inColumn:]),
([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented
keyboard navigation.
([NSSavePanel -runModalForDirectory:file:]): enable _okButton if
filename is valid.
([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]),
([NSSavePanel -_selectCellName:]): new private methods.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7468 72102866-910b-0410-8b05-ffd578937521
2000-09-10 21:55:17 +00:00
|
|
|
|
_f.default_button_cell_key_disabled = NO;
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
- (NSArray *) childWindows
|
|
|
|
|
{
|
|
|
|
|
return _children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) addChildWindow: (NSWindow *)child
|
|
|
|
|
ordered: (NSWindowOrderingMode)place
|
|
|
|
|
{
|
|
|
|
|
if (_children == nil)
|
|
|
|
|
{
|
|
|
|
|
_children = [[NSMutableArray alloc] init];
|
|
|
|
|
}
|
|
|
|
|
[_children addObject: child];
|
|
|
|
|
[child setParentWindow: self];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) removeChildWindow: (NSWindow *)child
|
|
|
|
|
{
|
|
|
|
|
[_children removeObject: child];
|
|
|
|
|
[child setParentWindow: nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSWindow *) parentWindow
|
|
|
|
|
{
|
|
|
|
|
return _parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setParentWindow: (NSWindow *)window
|
|
|
|
|
{
|
|
|
|
|
_parent = window;
|
2009-01-29 09:37:30 +00:00
|
|
|
|
|
|
|
|
|
if (_windowNum)
|
|
|
|
|
{
|
2009-01-31 09:59:32 +00:00
|
|
|
|
[GSServerForWindow(self) setParentWindow: [_parent windowNumber]
|
|
|
|
|
forChildWindow: _windowNum];
|
2009-01-29 09:37:30 +00:00
|
|
|
|
}
|
2007-09-09 12:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) allowsToolTipsWhenApplicationIsInactive
|
|
|
|
|
{
|
|
|
|
|
return _f.allows_tooltips_when_inactive;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setAllowsToolTipsWhenApplicationIsInactive: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
_f.allows_tooltips_when_inactive = flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isMovableByWindowBackground
|
|
|
|
|
{
|
|
|
|
|
return _f.is_movable_by_window_background;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setMovableByWindowBackground: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
_f.is_movable_by_window_background = flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) displaysWhenScreenProfileChanges
|
|
|
|
|
{
|
|
|
|
|
return _f.displays_when_screen_profile_changes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setDisplaysWhenScreenProfileChanges: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
_f.displays_when_screen_profile_changes = flag;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-06 10:58:38 +00:00
|
|
|
|
/*
|
|
|
|
|
* Menu item validation
|
|
|
|
|
*/
|
|
|
|
|
|
2009-12-22 00:14:16 +00:00
|
|
|
|
- (BOOL) validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>)anItem
|
2008-12-06 10:58:38 +00:00
|
|
|
|
{
|
|
|
|
|
BOOL result = YES;
|
|
|
|
|
SEL action = [anItem action];
|
|
|
|
|
|
2010-09-09 23:50:38 +00:00
|
|
|
|
if (sel_isEqual(action, @selector(performClose:)))
|
2008-12-06 10:58:38 +00:00
|
|
|
|
{
|
|
|
|
|
result = ([self styleMask] & NSClosableWindowMask) ? YES : NO;
|
|
|
|
|
}
|
2010-09-09 23:50:38 +00:00
|
|
|
|
else if (sel_isEqual(action, @selector(performMiniaturize:)))
|
2008-12-06 10:58:38 +00:00
|
|
|
|
{
|
|
|
|
|
result = ([self styleMask] & NSMiniaturizableWindowMask) ? YES : NO;
|
|
|
|
|
}
|
2010-09-09 23:50:38 +00:00
|
|
|
|
else if (sel_isEqual(action, @selector(performZoom:)))
|
2008-12-06 10:58:38 +00:00
|
|
|
|
{
|
|
|
|
|
result = ([self styleMask] & NSResizableWindowMask) ? YES : NO;
|
|
|
|
|
}
|
2010-09-09 23:50:38 +00:00
|
|
|
|
else if (sel_isEqual(action, @selector(undo:)))
|
2008-12-06 10:58:38 +00:00
|
|
|
|
{
|
2009-12-22 00:14:16 +00:00
|
|
|
|
NSUndoManager *undo = [_firstResponder undoManager];
|
2008-12-06 10:58:38 +00:00
|
|
|
|
if (undo == nil)
|
|
|
|
|
{
|
|
|
|
|
result = NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-22 00:14:16 +00:00
|
|
|
|
result = [undo canUndo];
|
|
|
|
|
if ([(id)anItem respondsToSelector: @selector(setTitle:)])
|
2008-12-06 10:58:38 +00:00
|
|
|
|
{
|
2009-12-22 00:14:16 +00:00
|
|
|
|
if (result)
|
|
|
|
|
[(id)anItem setTitle: [undo undoMenuItemTitle]];
|
|
|
|
|
else
|
|
|
|
|
[(id)anItem setTitle:
|
|
|
|
|
[undo undoMenuTitleForUndoActionName: @""]];
|
2008-12-06 10:58:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-09-09 23:50:38 +00:00
|
|
|
|
else if (sel_isEqual(action, @selector(redo:)))
|
2008-12-06 10:58:38 +00:00
|
|
|
|
{
|
2009-12-22 00:14:16 +00:00
|
|
|
|
NSUndoManager *undo = [_firstResponder undoManager];
|
2008-12-06 10:58:38 +00:00
|
|
|
|
if (undo == nil)
|
|
|
|
|
{
|
|
|
|
|
result = NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-22 00:14:16 +00:00
|
|
|
|
result = [undo canRedo];
|
|
|
|
|
if ([(id)anItem respondsToSelector: @selector(setTitle:)])
|
2008-12-06 10:58:38 +00:00
|
|
|
|
{
|
2009-12-22 00:14:16 +00:00
|
|
|
|
if (result)
|
|
|
|
|
[(id)anItem setTitle: [undo redoMenuItemTitle]];
|
|
|
|
|
else
|
|
|
|
|
[(id)anItem setTitle:
|
|
|
|
|
[undo redoMenuTitleForUndoActionName: @""]];
|
2008-12-06 10:58:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-09-09 23:50:38 +00:00
|
|
|
|
else if (sel_isEqual(action, @selector(toggleToolbarShown:)))
|
2008-12-30 23:56:35 +00:00
|
|
|
|
{
|
|
|
|
|
NSToolbar *toolbar = [self toolbar];
|
|
|
|
|
|
|
|
|
|
if (toolbar == nil)
|
|
|
|
|
{
|
|
|
|
|
result = NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-22 00:14:16 +00:00
|
|
|
|
result = YES;
|
|
|
|
|
if ([(id)anItem respondsToSelector: @selector(setTitle:)])
|
2008-12-30 23:56:35 +00:00
|
|
|
|
{
|
2009-12-22 00:14:16 +00:00
|
|
|
|
if ([toolbar isVisible])
|
|
|
|
|
[(id)anItem setTitle: _(@"Hide Toolbar")];
|
|
|
|
|
else
|
|
|
|
|
[(id)anItem setTitle: _(@"Show Toolbar")];
|
2008-12-30 23:56:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-30 18:58:12 +00:00
|
|
|
|
else if (sel_isEqual(action, @selector(runToolbarCustomizationPalette:)))
|
|
|
|
|
{
|
|
|
|
|
NSToolbar *toolbar = [self toolbar];
|
|
|
|
|
|
|
|
|
|
if (toolbar == nil)
|
|
|
|
|
{
|
|
|
|
|
result = NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = [toolbar allowsUserCustomization];
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-06 10:58:38 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-22 00:14:16 +00:00
|
|
|
|
- (BOOL) validateMenuItem: (NSMenuItem *)anItem
|
|
|
|
|
{
|
|
|
|
|
return [self validateUserInterfaceItem: anItem];
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Assigning a delegate
|
|
|
|
|
*/
|
2006-09-03 16:18:42 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Returns the delegate.
|
|
|
|
|
*/
|
1999-02-17 04:52:58 +00:00
|
|
|
|
- (id) delegate
|
|
|
|
|
{
|
1999-12-07 05:53:26 +00:00
|
|
|
|
return _delegate;
|
1999-02-17 04:52:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Sets the delegate to anObject.
|
|
|
|
|
*/
|
1999-02-17 04:52:58 +00:00
|
|
|
|
- (void) setDelegate: (id)anObject
|
|
|
|
|
{
|
2013-02-23 15:36:46 +00:00
|
|
|
|
if (anObject == _delegate)
|
|
|
|
|
{
|
|
|
|
|
// don't remove previously registered notifications if delegate is unchanged!
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if (_delegate)
|
2000-06-13 17:34:47 +00:00
|
|
|
|
{
|
|
|
|
|
[nc removeObserver: _delegate name: nil object: self];
|
|
|
|
|
}
|
1999-12-07 05:53:26 +00:00
|
|
|
|
_delegate = anObject;
|
1999-02-17 04:52:58 +00:00
|
|
|
|
|
|
|
|
|
#define SET_DELEGATE_NOTIFICATION(notif_name) \
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if ([_delegate respondsToSelector: @selector(window##notif_name:)]) \
|
|
|
|
|
[nc addObserver: _delegate \
|
1999-03-23 22:35:21 +00:00
|
|
|
|
selector: @selector(window##notif_name:) \
|
|
|
|
|
name: NSWindow##notif_name##Notification object: self]
|
1999-02-17 04:52:58 +00:00
|
|
|
|
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidBecomeKey);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidBecomeMain);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidChangeScreen);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidDeminiaturize);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidExpose);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidMiniaturize);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidMove);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidResignKey);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidResignMain);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidResize);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidUpdate);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillClose);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillMiniaturize);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillMove);
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* NSCoding protocol
|
|
|
|
|
*/
|
1999-03-02 08:58:30 +00:00
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
BOOL flag;
|
2006-06-04 05:16:37 +00:00
|
|
|
|
|
|
|
|
|
// If were're being initialized from a keyed coder...
|
2006-10-15 08:34:47 +00:00
|
|
|
|
if ([aCoder allowsKeyedCoding])
|
2006-06-04 05:16:37 +00:00
|
|
|
|
{
|
|
|
|
|
// The docs indicate that there should be an error when directly encoding with
|
|
|
|
|
// a keyed coding archiver. We should only encode NSWindow and subclasses
|
|
|
|
|
// using NSWindowTemplate.
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-09-09 12:19:01 +00:00
|
|
|
|
format: @"Keyed coding not implemented for %@.",
|
|
|
|
|
NSStringFromClass([self class])];
|
2006-06-04 05:16:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
|
[super encodeWithCoder: aCoder];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-11-30 19:44:53 +00:00
|
|
|
|
[aCoder encodeRect: [[self contentView] frame]];
|
2013-02-17 16:53:48 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSUInteger) at: &_styleMask];
|
|
|
|
|
// This used to be int, we need to stay compatible
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSInteger) at: &_backingType];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
1999-12-03 14:51:56 +00:00
|
|
|
|
[aCoder encodePoint: NSMakePoint(NSMinX([self frame]), NSMaxY([self frame]))];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[aCoder encodeObject: _contentView];
|
|
|
|
|
[aCoder encodeObject: _backgroundColor];
|
|
|
|
|
[aCoder encodeObject: _representedFilename];
|
|
|
|
|
[aCoder encodeObject: _miniaturizedTitle];
|
|
|
|
|
[aCoder encodeObject: _windowTitle];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
2014-05-03 18:32:20 +00:00
|
|
|
|
// [aCoder encodeSize: _minimumSize];
|
|
|
|
|
// [aCoder encodeSize: _maximumSize];
|
|
|
|
|
[aCoder encodeSize: [self contentMinSize]];
|
|
|
|
|
[aCoder encodeSize: [self contentMaxSize]];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
2013-02-17 16:53:48 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSInteger) at: &_windowLevel];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
|
|
|
|
flag = _f.menu_exclude;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
1999-11-15 21:45:56 +00:00
|
|
|
|
flag = _f.is_one_shot;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.is_autodisplay;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.optimize_drawing;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.dynamic_depth_limit;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.cursor_rects_enabled;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.is_released_when_closed;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.hides_on_deactivate;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.accepts_mouse_moved;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
1996-12-05 13:07:59 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[aCoder encodeObject: _miniaturizedImage];
|
|
|
|
|
[aCoder encodeConditionalObject: _initialFirstResponder];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
id oldself = self;
|
|
|
|
|
BOOL flag;
|
2006-06-04 05:16:37 +00:00
|
|
|
|
|
|
|
|
|
// If were're being initialized from a keyed coder...
|
2006-10-15 08:34:47 +00:00
|
|
|
|
if ([aDecoder allowsKeyedCoding])
|
2006-06-04 05:16:37 +00:00
|
|
|
|
{
|
|
|
|
|
// The docs indicate that there should be an error when directly encoding with
|
|
|
|
|
// a keyed coding archiver. We should only encode NSWindow and subclasses
|
|
|
|
|
// using NSWindowTemplate.
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-09-09 12:19:01 +00:00
|
|
|
|
format: @"Keyed coding not implemented for %@.",
|
|
|
|
|
NSStringFromClass([self class])];
|
2006-06-04 05:16:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-30 19:44:53 +00:00
|
|
|
|
if ((self = [super initWithCoder: aDecoder]) == oldself)
|
|
|
|
|
{
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSSize aSize;
|
|
|
|
|
NSRect aRect;
|
|
|
|
|
NSPoint p;
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger aStyle;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
NSBackingStoreType aBacking;
|
2013-02-17 16:53:48 +00:00
|
|
|
|
NSInteger level;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
id obj;
|
2014-05-03 18:32:20 +00:00
|
|
|
|
int version = [aDecoder versionForClassName: @"NSWindow"];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
|
|
|
|
aRect = [aDecoder decodeRect];
|
2013-02-17 16:53:48 +00:00
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(NSUInteger)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
at: &aStyle];
|
2013-02-17 16:53:48 +00:00
|
|
|
|
// This used to be int, we need to stay compatible
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(NSInteger)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
at: &aBacking];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
2008-05-24 15:00:12 +00:00
|
|
|
|
// call the designated initializer....
|
1999-11-30 19:44:53 +00:00
|
|
|
|
self = [self initWithContentRect: aRect
|
2007-09-09 12:19:01 +00:00
|
|
|
|
styleMask: aStyle
|
|
|
|
|
backing: aBacking
|
2008-05-24 15:00:12 +00:00
|
|
|
|
defer: NO];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
1999-12-03 14:51:56 +00:00
|
|
|
|
p = [aDecoder decodePoint];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
|
[self setContentView: obj];
|
|
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
|
[self setBackgroundColor: obj];
|
|
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
|
[self setRepresentedFilename: obj];
|
|
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
|
[self setMiniwindowTitle: obj];
|
|
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
|
[self setTitle: obj];
|
|
|
|
|
|
2014-05-03 18:32:20 +00:00
|
|
|
|
if (version < 3)
|
|
|
|
|
{
|
|
|
|
|
aSize = [aDecoder decodeSize];
|
|
|
|
|
[self setMinSize: aSize];
|
|
|
|
|
aSize = [aDecoder decodeSize];
|
|
|
|
|
[self setMaxSize: aSize];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aSize = [aDecoder decodeSize];
|
|
|
|
|
[self setContentMinSize: aSize];
|
|
|
|
|
aSize = [aDecoder decodeSize];
|
|
|
|
|
[self setContentMaxSize: aSize];
|
|
|
|
|
}
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
2013-02-22 15:39:29 +00:00
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(NSInteger)
|
2013-02-17 16:53:48 +00:00
|
|
|
|
at: &level];
|
|
|
|
|
[self setLevel: level];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setExcludedFromWindowsMenu: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setOneShot: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setAutodisplay: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self useOptimizedDrawing: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setDynamicDepthLimit: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
if (flag)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
[self enableCursorRects];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
else
|
2007-09-09 12:19:01 +00:00
|
|
|
|
[self disableCursorRects];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setReleasedWhenClosed: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setHidesOnDeactivate: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setAcceptsMouseMovedEvents: flag];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2004-12-28 17:06:14 +00:00
|
|
|
|
/* If the image has been specified, use it, if not use the default. */
|
|
|
|
|
obj = [aDecoder decodeObject];
|
2005-11-16 11:34:25 +00:00
|
|
|
|
if (obj != nil)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
{
|
|
|
|
|
ASSIGN(_miniaturizedImage, obj);
|
|
|
|
|
}
|
2004-12-28 17:06:14 +00:00
|
|
|
|
|
1999-11-30 19:44:53 +00:00
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id)
|
2007-09-09 12:19:01 +00:00
|
|
|
|
at: &_initialFirstResponder];
|
1996-12-05 13:07:59 +00:00
|
|
|
|
|
1999-12-03 14:51:56 +00:00
|
|
|
|
[self setFrameTopLeftPoint: p];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-10 12:43:35 +00:00
|
|
|
|
- (void) bind: (NSString *)binding
|
|
|
|
|
toObject: (id)anObject
|
|
|
|
|
withKeyPath: (NSString *)keyPath
|
|
|
|
|
options: (NSDictionary *)options
|
|
|
|
|
{
|
|
|
|
|
if ([binding isEqual: NSTitleBinding])
|
|
|
|
|
{
|
2011-03-07 13:35:37 +00:00
|
|
|
|
GSKeyValueBinding *kvb;
|
|
|
|
|
|
2009-12-10 12:43:35 +00:00
|
|
|
|
[self unbind: binding];
|
2011-03-07 13:35:37 +00:00
|
|
|
|
kvb = [[GSKeyValueBinding alloc] initWithBinding: @"title"
|
|
|
|
|
withName: NSTitleBinding
|
|
|
|
|
toObject: anObject
|
|
|
|
|
withKeyPath: keyPath
|
|
|
|
|
options: options
|
|
|
|
|
fromObject: self];
|
|
|
|
|
// The binding will be retained in the binding table
|
|
|
|
|
RELEASE(kvb);
|
2009-12-10 12:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[super bind: binding toObject: anObject withKeyPath: keyPath
|
|
|
|
|
options: options];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 16:18:42 +00:00
|
|
|
|
/**
|
|
|
|
|
Returns all drawers associated with this window.
|
|
|
|
|
*/
|
2001-11-26 20:25:50 +00:00
|
|
|
|
- (NSArray *) drawers
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
NSLog(@"Method %s is not implemented for class %s",
|
2007-09-09 12:19:01 +00:00
|
|
|
|
"drawers", "NSWindow");
|
2001-11-26 20:25:50 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
- (void *)windowRef
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
2006-05-03 21:09:08 +00:00
|
|
|
|
GSDisplayServer *srv = GSServerForWindow(self);
|
|
|
|
|
|
|
|
|
|
return [srv windowDevice: _windowNum];
|
1999-05-04 13:17:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-02-08 00:00:32 +00:00
|
|
|
|
- (void *) windowHandle
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2003-02-02 00:58:32 +00:00
|
|
|
|
// Should only be defined on MS Windows
|
2006-01-14 11:39:37 +00:00
|
|
|
|
return (void *)(intptr_t)_windowNum;
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
2008-11-26 21:29:32 +00:00
|
|
|
|
|
|
|
|
|
- (NSWindow *) attachedSheet
|
|
|
|
|
{
|
2009-08-02 14:16:13 +00:00
|
|
|
|
return _attachedSheet;
|
2008-11-26 21:29:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 01:38:54 +00:00
|
|
|
|
- (NSWindow *) sheetParent
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 01:43:52 +00:00
|
|
|
|
- (CGFloat) backingScaleFactor
|
|
|
|
|
{
|
2017-12-03 21:02:06 +00:00
|
|
|
|
return 1.0;
|
2017-08-15 01:43:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-16 21:55:00 +00:00
|
|
|
|
+ (NSInteger)windowNumberAtPoint:(NSPoint)point
|
|
|
|
|
belowWindowWithWindowNumber:(NSInteger)windowNumber
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2009-01-09 09:14:13 +00:00
|
|
|
|
@implementation NSWindow (Toolbar)
|
|
|
|
|
|
|
|
|
|
- (void) runToolbarCustomizationPalette: (id)sender
|
|
|
|
|
{
|
|
|
|
|
[[self toolbar] runCustomizationPalette: sender];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) toggleToolbarShown: (id)sender
|
|
|
|
|
{
|
|
|
|
|
NSToolbar *toolbar = [self toolbar];
|
|
|
|
|
BOOL isVisible = [toolbar isVisible];
|
|
|
|
|
|
|
|
|
|
if (!toolbar)
|
|
|
|
|
return;
|
2009-01-22 09:19:22 +00:00
|
|
|
|
|
2009-09-21 16:04:36 +00:00
|
|
|
|
// We do this again on a lower level, but doing it here is faster.
|
2009-01-09 09:14:13 +00:00
|
|
|
|
if (isVisible)
|
|
|
|
|
{
|
|
|
|
|
[_wv removeToolbarView: [toolbar _toolbarView]];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[_wv addToolbarView: [toolbar _toolbarView]];
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-21 16:04:36 +00:00
|
|
|
|
[toolbar setVisible: !isVisible];
|
|
|
|
|
|
2009-01-09 09:14:13 +00:00
|
|
|
|
[self display];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
|
|
|
|
|
|
- (NSToolbar *) toolbar
|
|
|
|
|
{
|
|
|
|
|
return _toolbar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setToolbar: (NSToolbar*)toolbar
|
|
|
|
|
{
|
|
|
|
|
if (toolbar == _toolbar)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (_toolbar != nil)
|
|
|
|
|
{
|
|
|
|
|
if ([_toolbar isVisible])
|
|
|
|
|
{
|
|
|
|
|
// Throw the last toolbar view out
|
|
|
|
|
[_wv removeToolbarView: [_toolbar _toolbarView]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ASSIGN(_toolbar, toolbar);
|
|
|
|
|
|
|
|
|
|
if (_toolbar != nil)
|
|
|
|
|
{
|
|
|
|
|
if ([_toolbar isVisible])
|
|
|
|
|
{
|
|
|
|
|
// Make the new toolbar view visible
|
|
|
|
|
[_wv addToolbarView: [_toolbar _toolbarView]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// To show the changed toolbar
|
|
|
|
|
[self displayIfNeeded];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
2009-01-22 09:19:22 +00:00
|
|
|
|
@implementation NSWindow (Menu)
|
|
|
|
|
|
|
|
|
|
- (void) setMenu: (NSMenu *)menu
|
|
|
|
|
{
|
2010-01-13 20:51:30 +00:00
|
|
|
|
// Do theme specific logic...
|
|
|
|
|
[[GSTheme theme] setMenu: menu forWindow: self];
|
2009-01-25 13:47:30 +00:00
|
|
|
|
|
2010-01-13 20:51:30 +00:00
|
|
|
|
if([self menu] != menu)
|
|
|
|
|
[super setMenu: menu];
|
2009-01-22 09:19:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* GNUstep backend methods
|
|
|
|
|
*/
|
2000-03-06 11:39:22 +00:00
|
|
|
|
@implementation NSWindow (GNUstepBackend)
|
1999-10-29 18:43:48 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Mouse capture/release
|
|
|
|
|
*/
|
1999-10-21 18:08:50 +00:00
|
|
|
|
- (void) _captureMouse: sender
|
|
|
|
|
{
|
2011-03-05 16:10:43 +00:00
|
|
|
|
NSDebugLLog(@"CaptureMouse", @"Capturing the mouse");
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[GSCurrentServer() capturemouse: _windowNum];
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) _releaseMouse: sender
|
|
|
|
|
{
|
2011-03-05 16:10:43 +00:00
|
|
|
|
NSDebugLLog(@"CaptureMouse", @"Releasing the mouse");
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[GSCurrentServer() releasemouse];
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) _setVisible: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.visible = flag;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
- (void) performDeminiaturize: sender
|
|
|
|
|
{
|
|
|
|
|
[self deminiaturize: sender];
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
|
/*
|
|
|
|
|
* Allow subclasses to init without the backend
|
|
|
|
|
* class attempting to create an actual window
|
|
|
|
|
*/
|
2000-03-06 11:39:22 +00:00
|
|
|
|
- (void) _initDefaults
|
1999-05-04 13:17:26 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_firstResponder = self;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
// _initialFirstResponder = nil;
|
|
|
|
|
// _delegate = nil;
|
|
|
|
|
// _windowNum = 0;
|
|
|
|
|
// _gstate = 0;
|
2002-08-03 03:32:19 +00:00
|
|
|
|
_backgroundColor = RETAIN([NSColor windowBackgroundColor]);
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_representedFilename = @"Window";
|
|
|
|
|
_miniaturizedTitle = @"Window";
|
2002-06-08 20:38:11 +00:00
|
|
|
|
_miniaturizedImage = RETAIN([NSApp applicationIconImage]);
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_windowTitle = @"Window";
|
|
|
|
|
_lastPoint = NSZeroPoint;
|
|
|
|
|
_windowLevel = NSNormalWindowLevel;
|
|
|
|
|
|
2002-04-22 15:45:10 +00:00
|
|
|
|
_depthLimit = NSDefaultDepth;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_disableFlushWindow = 0;
|
2005-02-12 18:15:25 +00:00
|
|
|
|
_alphaValue = 1.0;
|
1999-11-15 21:45:56 +00:00
|
|
|
|
|
2007-09-09 12:19:01 +00:00
|
|
|
|
// _f.accepts_drag = NO;
|
|
|
|
|
// _f.is_one_shot = NO;
|
|
|
|
|
// _f.needs_flush = NO;
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_autodisplay = YES;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
// _f.optimize_drawing = NO;
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.dynamic_depth_limit = YES;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
// _f.cursor_rects_enabled = NO;
|
|
|
|
|
// _f.cursor_rects_valid = NO;
|
|
|
|
|
// _f.visible = NO;
|
|
|
|
|
// _f.is_key = NO;
|
|
|
|
|
// _f.is_main = NO;
|
|
|
|
|
// _f.is_edited = NO;
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_released_when_closed = YES;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
// _f.is_miniaturized = NO;
|
|
|
|
|
// _f.menu_exclude = NO;
|
|
|
|
|
// _f.hides_on_deactivate = NO;
|
|
|
|
|
// _f.accepts_mouse_moved = NO;
|
|
|
|
|
// _f.has_opened = NO;
|
|
|
|
|
// _f.has_closed = NO;
|
|
|
|
|
// _f.default_button_cell_key_disabled = NO;
|
2001-11-26 20:25:50 +00:00
|
|
|
|
_f.can_hide = YES;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
// _f.has_shadow = NO;
|
2001-11-26 20:25:50 +00:00
|
|
|
|
_f.is_opaque = YES;
|
2007-03-08 12:52:01 +00:00
|
|
|
|
_f.views_need_display = YES;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
_f.selectionDirection = NSDirectSelection;
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
|
@end
|
1999-07-29 20:58:04 +00:00
|
|
|
|
|
2000-12-21 17:20:33 +00:00
|
|
|
|
@implementation NSWindow (GNUstepTextView)
|
|
|
|
|
- (id) _futureFirstResponder
|
|
|
|
|
{
|
|
|
|
|
return _futureFirstResponder;
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
2011-05-31 09:59:48 +00:00
|
|
|
|
@implementation NSApplication(Inactive)
|
|
|
|
|
- (BOOL) _isWindowInactive: (NSWindow *)window
|
|
|
|
|
{
|
|
|
|
|
return [_inactive containsObject: window];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) _setWindow: (NSWindow *)window inactive: (BOOL)inactive
|
|
|
|
|
{
|
|
|
|
|
if (inactive)
|
|
|
|
|
{
|
|
|
|
|
[_inactive addObject: window];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[_inactive removeObject: window];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
1999-07-29 20:58:04 +00:00
|
|
|
|
BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo)
|
|
|
|
|
{
|
1999-09-09 02:56:20 +00:00
|
|
|
|
NSPasteboard *pb = [dragInfo draggingPasteboard];
|
1999-07-29 20:58:04 +00:00
|
|
|
|
if ([pb availableTypeFromArray: GSGetDragTypes(v)])
|
|
|
|
|
return YES;
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
void NSCountWindows(NSInteger *count)
|
2000-03-06 11:39:22 +00:00
|
|
|
|
{
|
2013-01-27 20:28:35 +00:00
|
|
|
|
*count = [[GSCurrentServer() windowlist] count];
|
2000-03-06 11:39:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
void NSWindowList(NSInteger size, NSInteger list[])
|
2000-03-06 11:39:22 +00:00
|
|
|
|
{
|
2006-10-21 19:13:42 +00:00
|
|
|
|
NSArray *windowList = [GSCurrentServer() windowlist];
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger i, c;
|
2007-09-09 12:19:01 +00:00
|
|
|
|
|
2006-10-21 19:13:42 +00:00
|
|
|
|
for (i = 0, c = [windowList count]; i < size && i < c; i++)
|
|
|
|
|
{
|
2013-01-27 20:28:35 +00:00
|
|
|
|
list[i] = [[windowList objectAtIndex: i] integerValue];
|
2006-10-21 19:13:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-03-06 11:39:22 +00:00
|
|
|
|
|
2006-10-21 19:13:42 +00:00
|
|
|
|
NSArray *GSOrderedWindows(void)
|
|
|
|
|
{
|
|
|
|
|
NSArray *window_list = [GSCurrentServer() windowlist];
|
|
|
|
|
NSMutableArray *ret = [NSMutableArray array];
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSUInteger i, c;
|
2006-10-21 19:13:42 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0, c = [window_list count]; i < c; i++)
|
2000-03-06 11:39:22 +00:00
|
|
|
|
{
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSInteger windowNumber = [[window_list objectAtIndex: i] integerValue];
|
2006-10-21 19:13:42 +00:00
|
|
|
|
NSWindow *win = GSWindowWithNumber(windowNumber);
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
[ret addObject: win];
|
2000-03-06 11:39:22 +00:00
|
|
|
|
}
|
2006-10-21 19:13:42 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
2000-03-06 11:39:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-10-21 19:13:42 +00:00
|
|
|
|
|
2003-01-26 17:49:35 +00:00
|
|
|
|
NSArray* GSAllWindows(void)
|
2000-03-06 11:39:22 +00:00
|
|
|
|
{
|
2003-02-10 14:29:31 +00:00
|
|
|
|
if (windowmaps)
|
|
|
|
|
return NSAllMapTableValues(windowmaps);
|
|
|
|
|
return nil;
|
2000-03-06 11:39:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-27 20:28:35 +00:00
|
|
|
|
NSWindow* GSWindowWithNumber(NSInteger num)
|
2000-03-06 11:39:22 +00:00
|
|
|
|
{
|
2009-01-28 18:05:26 +00:00
|
|
|
|
if (windowmaps)
|
|
|
|
|
return (NSWindow*)NSMapGet(windowmaps, (void*)(intptr_t)num);
|
|
|
|
|
return nil;
|
2000-03-06 11:39:22 +00:00
|
|
|
|
}
|