2001-12-17 16:51:51 +00:00
|
|
|
|
/** <title>NSWindow</title>
|
|
|
|
|
|
|
|
|
|
<abstract>The window class</abstract>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
1999-06-11 04:46:12 +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
|
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
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
|
1999-06-11 04:46:12 +00:00
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1996-05-30 20:03:15 +00:00
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
|
If not, write to the Free Software Foundation,
|
2005-05-26 02:52:46 +00:00
|
|
|
|
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
|
|
|
|
|
2003-07-31 23:52:10 +00:00
|
|
|
|
#include "config.h"
|
2005-05-20 14:33:43 +00:00
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <float.h>
|
1998-11-12 10:49:00 +00:00
|
|
|
|
|
2002-04-11 23:17:42 +00:00
|
|
|
|
#include <Foundation/NSDebug.h>
|
|
|
|
|
#include <Foundation/NSRunLoop.h>
|
|
|
|
|
#include <Foundation/NSScanner.h>
|
|
|
|
|
#include <Foundation/NSAutoreleasePool.h>
|
1997-08-18 17:10:23 +00:00
|
|
|
|
#include <Foundation/NSString.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
|
#include <Foundation/NSCoder.h>
|
|
|
|
|
#include <Foundation/NSArray.h>
|
1999-05-07 11:06:37 +00:00
|
|
|
|
#include <Foundation/NSGeometry.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
|
#include <Foundation/NSNotification.h>
|
1997-10-09 22:55:31 +00:00
|
|
|
|
#include <Foundation/NSValue.h>
|
1997-12-04 01:58:57 +00:00
|
|
|
|
#include <Foundation/NSException.h>
|
1999-07-06 05:37:15 +00:00
|
|
|
|
#include <Foundation/NSSet.h>
|
|
|
|
|
#include <Foundation/NSLock.h>
|
|
|
|
|
#include <Foundation/NSUserDefaults.h>
|
1997-07-07 16:56:52 +00:00
|
|
|
|
|
2003-06-13 15:01:12 +00:00
|
|
|
|
#include "AppKit/NSApplication.h"
|
|
|
|
|
#include "AppKit/NSButtonCell.h"
|
2004-07-06 20:20:31 +00:00
|
|
|
|
#include "AppKit/NSCachedImageRep.h"
|
2003-06-13 15:01:12 +00:00
|
|
|
|
#include "AppKit/NSColor.h"
|
2004-07-06 20:20:31 +00:00
|
|
|
|
#include "AppKit/NSColorList.h"
|
2003-06-13 15:01:12 +00:00
|
|
|
|
#include "AppKit/NSCursor.h"
|
2004-10-18 01:48:15 +00:00
|
|
|
|
#include "AppKit/NSDocumentController.h"
|
2004-07-06 20:20:31 +00:00
|
|
|
|
#include "AppKit/NSDocument.h"
|
2003-06-13 15:01:12 +00:00
|
|
|
|
#include "AppKit/NSDragging.h"
|
2004-07-06 20:20:31 +00:00
|
|
|
|
#include "AppKit/NSFont.h"
|
2003-06-13 15:01:12 +00:00
|
|
|
|
#include "AppKit/NSGraphics.h"
|
2004-07-06 20:20:31 +00:00
|
|
|
|
#include "AppKit/NSHelpManager.h"
|
|
|
|
|
#include "AppKit/NSImage.h"
|
|
|
|
|
#include "AppKit/NSMenu.h"
|
|
|
|
|
#include "AppKit/NSPasteboard.h"
|
|
|
|
|
#include "AppKit/NSScreen.h"
|
|
|
|
|
#include "AppKit/NSTextField.h"
|
|
|
|
|
#include "AppKit/NSTextFieldCell.h"
|
2003-06-13 15:01:12 +00:00
|
|
|
|
#include "AppKit/NSToolbar.h"
|
2004-07-06 20:20:31 +00:00
|
|
|
|
#include "AppKit/NSView.h"
|
|
|
|
|
#include "AppKit/NSWindow.h"
|
|
|
|
|
#include "AppKit/NSWindowController.h"
|
|
|
|
|
#include "AppKit/PSOperators.h"
|
2003-07-31 23:52:10 +00:00
|
|
|
|
#include "GNUstepGUI/GSTrackingRect.h"
|
|
|
|
|
#include "GNUstepGUI/GSDisplayServer.h"
|
2003-11-11 19:40:18 +00:00
|
|
|
|
#include "GNUstepGUI/GSToolbarView.h"
|
2006-10-02 19:22:22 +00:00
|
|
|
|
#include "GSToolTips.h"
|
|
|
|
|
|
|
|
|
|
static GSToolTips *toolTipVisible = nil;
|
1998-11-25 17:16:48 +00:00
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
#include "GSWindowDecorationView.h"
|
|
|
|
|
|
|
|
|
|
static id<GSWindowDecorator> windowDecorator;
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
at: (NSPoint)screenLocation
|
|
|
|
|
offset: (NSSize)initialOffset
|
|
|
|
|
event: (NSEvent*)event
|
|
|
|
|
pasteboard: (NSPasteboard*)pboard
|
|
|
|
|
source: (id)sourceObject
|
|
|
|
|
slideBack: (BOOL)slideFlag;
|
|
|
|
|
- (void) postDragEvent: (NSEvent*)event;
|
|
|
|
|
@end
|
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
@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;
|
|
|
|
|
// Method used to support validation in the toolbar implementation
|
2000-03-06 11:39:22 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
{
|
|
|
|
|
if (_f.is_autodisplay && _rFlags.needs_display)
|
|
|
|
|
{
|
|
|
|
|
[self disableFlushWindow];
|
|
|
|
|
[self displayIfNeeded];
|
|
|
|
|
[self enableFlushWindow];
|
|
|
|
|
[self flushWindowIfNeeded];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NSArray *modes = nil;
|
|
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
|
|
|
|
|
/* 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]
|
2004-07-12 23:19:14 +00:00
|
|
|
|
performSelector: @selector(_handleAutodisplay:)
|
|
|
|
|
target: self
|
|
|
|
|
argument: nil
|
|
|
|
|
order: 600000
|
|
|
|
|
modes: modes];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+(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,
|
|
|
|
|
NSModalPanelRunLoopMode,
|
|
|
|
|
NSEventTrackingRunLoopMode, nil];
|
|
|
|
|
[[NSRunLoop currentRunLoop]
|
|
|
|
|
performSelector: @selector(_handleAutodisplay:)
|
2003-04-06 18:03:33 +00:00
|
|
|
|
target: self
|
|
|
|
|
argument: nil
|
|
|
|
|
order: 600000
|
2003-11-29 01:36:50 +00:00
|
|
|
|
modes: modes];
|
2004-07-12 23:19:14 +00:00
|
|
|
|
GSIArrayInitWithZoneAndCapacity(&autodisplayedWindows,
|
|
|
|
|
NSDefaultMallocZone(), 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
|
{
|
|
|
|
|
GSIArrayRemoveItemAtIndex(&autodisplayedWindows, i);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/* 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.)
|
|
|
|
|
|
|
|
|
|
FIXME: It would really be better if we maintained a stack of the
|
|
|
|
|
most recent key/main windows and went through in order of most
|
|
|
|
|
recent to least recent. That's probably a lot of work, however.
|
|
|
|
|
*/
|
2000-03-08 21:26:11 +00:00
|
|
|
|
- (void) _lossOfKeyOrMainWindow
|
|
|
|
|
{
|
|
|
|
|
NSArray *windowList = GSAllWindows();
|
|
|
|
|
unsigned pos = [windowList indexOfObjectIdenticalTo: self];
|
|
|
|
|
unsigned c = [windowList count];
|
|
|
|
|
unsigned i;
|
|
|
|
|
NSWindow *w;
|
|
|
|
|
|
|
|
|
|
if ([self isKeyWindow])
|
|
|
|
|
{
|
2002-10-20 01:48:55 +00:00
|
|
|
|
NSWindow *menu_window= [[NSApp mainMenu] window];
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[self resignKeyWindow];
|
|
|
|
|
i = pos + 1;
|
|
|
|
|
if (i == c)
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
while (i != pos)
|
|
|
|
|
{
|
|
|
|
|
w = [windowList objectAtIndex: i];
|
2002-10-20 01:48:55 +00:00
|
|
|
|
if ([w isVisible] && [w canBecomeKeyWindow] && w != menu_window)
|
2000-03-08 21:26:11 +00:00
|
|
|
|
{
|
|
|
|
|
[w makeKeyWindow];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
if (i == c)
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
2002-10-20 01:48:55 +00:00
|
|
|
|
* if we didn't find a possible key window - use the main menu window
|
2000-03-08 21:26:11 +00:00
|
|
|
|
*/
|
|
|
|
|
if (i == pos)
|
|
|
|
|
{
|
2002-10-20 01:48:55 +00:00
|
|
|
|
if (menu_window != nil)
|
2000-03-08 21:26:11 +00:00
|
|
|
|
{
|
2002-10-20 01:48:55 +00:00
|
|
|
|
[GSServerForWindow(menu_window) setinputfocus:
|
|
|
|
|
[menu_window windowNumber]];
|
2000-03-08 21:26:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ([self isMainWindow])
|
|
|
|
|
{
|
|
|
|
|
NSWindow *w = [NSApp keyWindow];
|
|
|
|
|
|
|
|
|
|
[self resignMainWindow];
|
|
|
|
|
if (w != nil && [w canBecomeMainWindow])
|
|
|
|
|
{
|
|
|
|
|
[w makeMainWindow];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
i = pos + 1;
|
|
|
|
|
if (i == c)
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
while (i != pos)
|
|
|
|
|
{
|
|
|
|
|
w = [windowList objectAtIndex: i];
|
|
|
|
|
if ([w isVisible] && [w canBecomeMainWindow])
|
|
|
|
|
{
|
|
|
|
|
[w makeMainWindow];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
if (i == c)
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-23 18:39:07 +00:00
|
|
|
|
|
|
|
|
|
- (NSView *) _windowView
|
|
|
|
|
{
|
|
|
|
|
return _wv;
|
|
|
|
|
}
|
2000-03-06 11:39:22 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-03-01 17:21:08 +00:00
|
|
|
|
@interface NSMiniWindow : NSWindow
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation NSMiniWindow
|
|
|
|
|
|
|
|
|
|
- (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];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_windowLevel = NSDockWindowLevel;
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@interface NSMiniWindowView : NSView
|
|
|
|
|
{
|
2001-02-07 11:17:38 +00:00
|
|
|
|
NSCell *imageCell;
|
|
|
|
|
NSTextFieldCell *titleCell;
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
- (void) setImage: (NSImage*)anImage;
|
|
|
|
|
- (void) setTitle: (NSString*)aString;
|
|
|
|
|
@end
|
|
|
|
|
|
2001-02-07 11:17:38 +00:00
|
|
|
|
static NSCell *tileCell = nil;
|
2004-11-10 17:12:57 +00:00
|
|
|
|
|
|
|
|
|
static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|
|
|
|
{
|
|
|
|
|
NSSize iconSize, retSize;
|
|
|
|
|
|
|
|
|
|
iconSize = [GSCurrentServer() iconSize];
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
iconSize = [GSCurrentServer() iconSize];
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2004-11-10 17:12:57 +00:00
|
|
|
|
NSSize iconSize = [GSCurrentServer() iconSize];
|
|
|
|
|
|
|
|
|
|
[tileCell drawWithFrame: NSMakeRect(0, 0, iconSize.width, iconSize.height)
|
|
|
|
|
inView: self];
|
|
|
|
|
[imageCell
|
|
|
|
|
drawWithFrame: NSMakeRect(iconSize.width / 8,
|
|
|
|
|
(iconSize.height / 16),
|
|
|
|
|
iconSize.width - ((iconSize.width / 8) * 2),
|
|
|
|
|
iconSize.height - ((iconSize.height / 8) * 2))
|
|
|
|
|
inView: self];
|
|
|
|
|
[titleCell drawWithFrame: NSMakeRect(1, iconSize.height - 12,
|
|
|
|
|
iconSize.width - 2, 11)
|
|
|
|
|
inView: self];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) mouseDown: (NSEvent*)theEvent
|
|
|
|
|
{
|
|
|
|
|
if ([theEvent clickCount] >= 2)
|
|
|
|
|
{
|
|
|
|
|
NSWindow *w = [_window counterpart];
|
2000-08-03 08:48:22 +00:00
|
|
|
|
[w deminiaturize: self];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSPoint lastLocation;
|
|
|
|
|
NSPoint location;
|
|
|
|
|
unsigned eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
2002-03-02 07:23:18 +00:00
|
|
|
|
| NSPeriodicMask | NSOtherMouseUpMask | NSRightMouseUpMask;
|
2000-03-01 17:21:08 +00:00
|
|
|
|
NSDate *theDistantFuture = [NSDate distantFuture];
|
|
|
|
|
BOOL done = NO;
|
|
|
|
|
|
|
|
|
|
lastLocation = [theEvent locationInWindow];
|
|
|
|
|
[NSEvent startPeriodicEventsAfterDelay: 0.02 withPeriod: 0.02];
|
|
|
|
|
|
|
|
|
|
while (!done)
|
|
|
|
|
{
|
|
|
|
|
theEvent = [NSApp nextEventMatchingMask: eventMask
|
|
|
|
|
untilDate: theDistantFuture
|
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
|
dequeue: YES];
|
|
|
|
|
|
|
|
|
|
switch ([theEvent type])
|
|
|
|
|
{
|
|
|
|
|
case NSRightMouseUp:
|
2002-03-02 07:23:18 +00:00
|
|
|
|
case NSOtherMouseUp:
|
2000-03-01 17:21:08 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
NSPoint origin = [_window frame].origin;
|
|
|
|
|
|
|
|
|
|
origin.x += (location.x - lastLocation.x);
|
|
|
|
|
origin.y += (location.y - lastLocation.y);
|
|
|
|
|
[_window setFrameOrigin: origin];
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[NSEvent stopPeriodicEvents];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setImage: (NSImage*)anImage
|
|
|
|
|
{
|
2004-11-10 17:12:57 +00:00
|
|
|
|
NSImage *imgCopy = [anImage copy];
|
|
|
|
|
|
|
|
|
|
[imgCopy setScalesWhenResized: YES];
|
|
|
|
|
[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
|
|
|
|
/*****************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* NSWindow
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
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 20:08:51 +00:00
|
|
|
|
typedef struct NSView_struct
|
|
|
|
|
{
|
|
|
|
|
@defs(NSView)
|
|
|
|
|
} *NSViewPtr;
|
|
|
|
|
|
|
|
|
|
|
1999-05-07 11:06:37 +00:00
|
|
|
|
/*
|
|
|
|
|
* Class variables
|
|
|
|
|
*/
|
2000-10-31 12:47:09 +00:00
|
|
|
|
static SEL ccSel;
|
|
|
|
|
static SEL ctSel;
|
1999-05-07 11:06:37 +00:00
|
|
|
|
static IMP ccImp;
|
|
|
|
|
static IMP ctImp;
|
1999-05-14 14:50:05 +00:00
|
|
|
|
static Class responderClass;
|
1999-10-04 06:18:17 +00:00
|
|
|
|
static Class viewClass;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
static NSMutableSet *autosaveNames;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
static NSMapTable* windowmaps = 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])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: 2];
|
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];
|
2001-08-21 23:24:00 +00:00
|
|
|
|
nc = [NSNotificationCenter defaultCenter];
|
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)
|
|
|
|
|
{
|
|
|
|
|
NSString *key;
|
|
|
|
|
|
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
|
1999-06-11 04:46:12 +00:00
|
|
|
|
styleMask: (unsigned int)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
|
|
|
|
|
styleMask: aStyle];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
+ (NSRect) frameRectForContentRect: (NSRect)aRect
|
1999-06-11 04:46:12 +00:00
|
|
|
|
styleMask: (unsigned int)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
|
|
|
|
|
styleMask: aStyle];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
+ (float) minFrameWidthWithTitle: (NSString *)aTitle
|
|
|
|
|
styleMask: (unsigned int)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
|
|
|
|
|
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
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
int style;
|
|
|
|
|
|
|
|
|
|
style = NSTitledWindowMask | NSClosableWindowMask
|
|
|
|
|
| NSMiniaturizableWindowMask | NSResizableWindowMask;
|
1998-11-03 21:04:55 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return [self initWithContentRect: NSZeroRect
|
|
|
|
|
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
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
|
|
|
|
|
/* Check for context also as it might have disappeared before us */
|
|
|
|
|
if (context && _gstate)
|
|
|
|
|
{
|
|
|
|
|
GSUndefineGState(context, _gstate);
|
|
|
|
|
_gstate = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_windowNum)
|
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setWindowNumber: 0];
|
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
|
|
|
|
|
{
|
2001-08-21 23:24:00 +00:00
|
|
|
|
[nc removeObserver: self];
|
2004-07-12 23:19:14 +00:00
|
|
|
|
[isa _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
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
NSWindow *mini = [NSApp windowWithWindowNumber: _counterpart];
|
|
|
|
|
|
|
|
|
|
_counterpart = 0;
|
|
|
|
|
RELEASE(mini);
|
|
|
|
|
}
|
2001-10-22 17:50:07 +00:00
|
|
|
|
/* Clean references to this window - important if some of the views
|
|
|
|
|
are not deallocated now */
|
|
|
|
|
[_wv viewWillMoveToWindow: nil];
|
|
|
|
|
/* 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);
|
1999-06-01 17:05:57 +00:00
|
|
|
|
TEST_RELEASE(_fieldEditor);
|
2000-09-05 17:22:46 +00:00
|
|
|
|
TEST_RELEASE(_backgroundColor);
|
|
|
|
|
TEST_RELEASE(_representedFilename);
|
|
|
|
|
TEST_RELEASE(_miniaturizedTitle);
|
|
|
|
|
TEST_RELEASE(_miniaturizedImage);
|
|
|
|
|
TEST_RELEASE(_windowTitle);
|
|
|
|
|
TEST_RELEASE(_rectsBeingDrawn);
|
|
|
|
|
TEST_RELEASE(_initialFirstResponder);
|
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
|
|
|
|
TEST_RELEASE(_defaultButtonCell);
|
2002-07-12 11:12:32 +00:00
|
|
|
|
TEST_RELEASE(_cachedImage);
|
2003-02-02 00:58:32 +00:00
|
|
|
|
TEST_RELEASE(_toolbar);
|
2003-07-22 05:18:05 +00:00
|
|
|
|
DESTROY(_lastView);
|
|
|
|
|
DESTROY(_lastDragView);
|
2002-04-22 15:45:10 +00:00
|
|
|
|
RELEASE(_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
|
|
|
|
|
2003-02-02 00:58:32 +00:00
|
|
|
|
[self _terminateBackendWindow];
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
- (void) _initBackendWindow
|
2000-09-27 22:18:34 +00:00
|
|
|
|
{
|
2002-04-22 15:45:10 +00:00
|
|
|
|
int screenNumber;
|
2002-12-28 00:49:40 +00:00
|
|
|
|
NSCountedSet *dragTypes;
|
2002-03-28 03:53:18 +00:00
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
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. */
|
|
|
|
|
[srv removeDragTypes: nil fromWindow: self];
|
2000-09-29 03:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-23 20:50:24 +00:00
|
|
|
|
screenNumber = [_screen screenNumber];
|
2004-07-06 20:20:31 +00:00
|
|
|
|
|
|
|
|
|
_windowNum =
|
|
|
|
|
[srv window: _frame
|
|
|
|
|
: _backingType
|
|
|
|
|
: _styleMask
|
|
|
|
|
: screenNumber];
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[srv setwindowlevel: [self level] : _windowNum];
|
2006-01-14 11:39:37 +00:00
|
|
|
|
NSMapInsert (windowmaps, (void*)(intptr_t)_windowNum, self);
|
2000-09-27 22:18:34 +00:00
|
|
|
|
|
|
|
|
|
// Set window in new _gstate
|
|
|
|
|
DPSgsave(context);
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[srv windowdevice: _windowNum];
|
|
|
|
|
_gstate = GSDefineGState(context);
|
2000-09-27 22:18:34 +00:00
|
|
|
|
DPSgrestore(context);
|
|
|
|
|
|
2004-08-09 12:59:53 +00:00
|
|
|
|
{
|
|
|
|
|
NSRect frame = _frame;
|
|
|
|
|
frame.origin = NSZeroPoint;
|
|
|
|
|
[_wv setFrame: frame];
|
|
|
|
|
[_wv setNeedsDisplay: YES];
|
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
|
|
|
|
int i, count = [dragTypes countForObject: type];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
[dragTypesArray addObject: type];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
[_wv setWindowNumber: _windowNum];
|
|
|
|
|
|
|
|
|
|
NSDebugLLog(@"NSWindow", @"Created NSWindow window frame %@",
|
2000-09-27 22:18:34 +00:00
|
|
|
|
NSStringFromRect(_frame));
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2002-01-26 04:14:38 +00:00
|
|
|
|
backing store type of <var>backingType</var>.
|
|
|
|
|
</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
|
|
|
|
|
styleMask: (unsigned int)aStyle
|
|
|
|
|
backing: (NSBackingStoreType)bufferingType
|
|
|
|
|
defer: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return [self initWithContentRect: contentRect
|
|
|
|
|
styleMask: aStyle
|
|
|
|
|
backing: bufferingType
|
|
|
|
|
defer: flag
|
|
|
|
|
screen: nil];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
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>, 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
|
2002-01-26 04:14:38 +00:00
|
|
|
|
(<code>YES</code>).
|
|
|
|
|
</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
|
|
|
|
|
styleMask: (unsigned int)aStyle
|
|
|
|
|
backing: (NSBackingStoreType)bufferingType
|
|
|
|
|
defer: (BOOL)flag
|
1999-06-11 04:46:12 +00:00
|
|
|
|
screen: (NSScreen*)aScreen
|
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");
|
1999-10-21 18:08:50 +00:00
|
|
|
|
if (!windowmaps)
|
|
|
|
|
windowmaps = NSCreateMapTable(NSIntMapKeyCallBacks,
|
|
|
|
|
NSNonRetainedObjectMapValueCallBacks, 20);
|
1999-06-11 04:46:12 +00:00
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
if (!windowDecorator)
|
|
|
|
|
windowDecorator = [GSWindowDecorationView windowDecorator];
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/* Initialize attributes and flags */
|
2000-03-06 21:10:08 +00:00
|
|
|
|
[super init];
|
|
|
|
|
[self _initDefaults];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_backingType = bufferingType;
|
|
|
|
|
_styleMask = aStyle;
|
2002-04-22 15:45:10 +00:00
|
|
|
|
if (aScreen == nil)
|
|
|
|
|
aScreen = [NSScreen mainScreen];
|
|
|
|
|
ASSIGN(_screen, aScreen);
|
|
|
|
|
_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,
|
2004-07-06 20:20:31 +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;
|
|
|
|
|
_wv = [windowDecorator newWindowDecorationViewWithFrame: cframe
|
|
|
|
|
window: self];
|
1999-12-08 15:01:52 +00:00
|
|
|
|
[_wv viewWillMoveToWindow: self];
|
|
|
|
|
|
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
|
|
|
|
|
selector: @selector(colorListChanged:)
|
|
|
|
|
name: NSColorListChangedNotification
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2006-05-03 21:09:08 +00:00
|
|
|
|
- (id) initWithWindowRef: (void *)windowRef
|
|
|
|
|
{
|
|
|
|
|
NSRect contentRect;
|
|
|
|
|
unsigned int aStyle;
|
|
|
|
|
NSBackingStoreType bufferingType;
|
|
|
|
|
NSScreen* aScreen;
|
|
|
|
|
int screen;
|
|
|
|
|
int winNum;
|
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
GSDisplayServer *srv = GSCurrentServer();
|
|
|
|
|
|
|
|
|
|
// Get the properties for the underlying window
|
|
|
|
|
winNum = [srv nativeWindow: windowRef : &contentRect : &bufferingType
|
|
|
|
|
: &aStyle : &screen];
|
|
|
|
|
// FIXME: Get the screen for the right screen number.
|
|
|
|
|
aScreen = nil;
|
|
|
|
|
|
|
|
|
|
// Set up a NSWindow with the same properties
|
|
|
|
|
self = [self initWithContentRect: contentRect
|
|
|
|
|
styleMask: aStyle
|
|
|
|
|
backing: bufferingType
|
|
|
|
|
defer: YES
|
|
|
|
|
screen: aScreen];
|
|
|
|
|
|
|
|
|
|
// Fake the initialisation of the backend
|
|
|
|
|
_windowNum = winNum;
|
|
|
|
|
NSMapInsert (windowmaps, (void*)(intptr_t)_windowNum, self);
|
|
|
|
|
|
|
|
|
|
// Set window in new _gstate
|
|
|
|
|
DPSgsave(context);
|
|
|
|
|
[srv windowdevice: _windowNum];
|
|
|
|
|
_gstate = GSDefineGState(context);
|
|
|
|
|
DPSgrestore(context);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
NSRect frame = _frame;
|
|
|
|
|
frame.origin = NSZeroPoint;
|
|
|
|
|
[_wv setFrame: frame];
|
|
|
|
|
[_wv setNeedsDisplay: YES];
|
|
|
|
|
[_wv setWindowNumber: _windowNum];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
-(void) colorListChanged:(NSNotification*)notif
|
|
|
|
|
{
|
|
|
|
|
if ([[notif object] isEqual: [NSColorList colorListNamed:@"System"]])
|
|
|
|
|
{
|
|
|
|
|
[_wv setNeedsDisplay:YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (aView == nil)
|
1999-01-09 21:43:09 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
aView = AUTORELEASE([[NSView alloc]
|
|
|
|
|
initWithFrame:
|
|
|
|
|
[NSWindow contentRectForFrameRect: _frame
|
|
|
|
|
styleMask: _styleMask]]);
|
1999-01-09 21:43:09 +00:00
|
|
|
|
}
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (_contentView != nil)
|
1999-12-08 15:01:52 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +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
|
|
|
|
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setContentView: _contentView];
|
1999-06-11 04:46:12 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[_contentView setNextResponder: self];
|
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)
|
1999-12-03 11:32:39 +00:00
|
|
|
|
{
|
|
|
|
|
[NSApp changeWindowsItem: self
|
2004-07-06 20:20:31 +00:00
|
|
|
|
title: _windowTitle
|
1999-12-03 11:32:39 +00:00
|
|
|
|
filename: NO];
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
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];
|
1999-12-03 11:32:39 +00:00
|
|
|
|
aString = [NSString stringWithFormat:
|
|
|
|
|
@"%@ -- %@", [aString lastPathComponent],
|
|
|
|
|
[aString stringByDeletingLastPathComponent]];
|
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)
|
1999-12-03 11:32:39 +00:00
|
|
|
|
{
|
|
|
|
|
[NSApp changeWindowsItem: self
|
2004-07-06 20:20:31 +00:00
|
|
|
|
title: _windowTitle
|
1999-12-03 11:32:39 +00:00
|
|
|
|
filename: YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (unsigned int) styleMask
|
|
|
|
|
{
|
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
|
|
|
|
{
|
2003-02-02 00:58:32 +00:00
|
|
|
|
// FIXME: Should be send to backend
|
2001-11-26 20:25:50 +00:00
|
|
|
|
_f.has_shadow = hasShadow;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
- (void) setAlphaValue: (float)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
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
- (float) 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
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (int) gState
|
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int) windowNumber
|
|
|
|
|
{
|
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
|
|
|
|
{
|
2006-07-04 21:31:49 +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:)])
|
|
|
|
|
{
|
|
|
|
|
[v setImage: [self miniwindowImage]];
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
{
|
2006-07-04 21:31:49 +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:)])
|
|
|
|
|
{
|
|
|
|
|
[v setTitle: [self miniwindowTitle]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (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
|
1999-11-14 03:16:39 +00:00
|
|
|
|
forObject: anObject];
|
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (t && (_firstResponder == t))
|
1999-11-14 03:16:39 +00:00
|
|
|
|
{
|
2001-08-21 23:24:00 +00:00
|
|
|
|
[nc postNotificationName: NSTextDidEndEditingNotification
|
|
|
|
|
object: t];
|
1999-11-14 03:16:39 +00:00
|
|
|
|
[t setText: @""];
|
|
|
|
|
[t setDelegate: nil];
|
|
|
|
|
[t removeFromSuperview];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_firstResponder = self;
|
|
|
|
|
[_firstResponder becomeFirstResponder];
|
1999-11-14 03:16:39 +00:00
|
|
|
|
}
|
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
|
2002-09-23 05:52:36 +00:00
|
|
|
|
toObject: anObject];
|
2000-12-16 02:03:03 +00:00
|
|
|
|
|
|
|
|
|
if (editor != nil)
|
|
|
|
|
{
|
|
|
|
|
return editor;
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
{
|
1999-11-22 15:03:41 +00:00
|
|
|
|
if (_f.is_key == NO)
|
|
|
|
|
{
|
2002-07-17 13:29:20 +00:00
|
|
|
|
_f.is_key = YES;
|
|
|
|
|
|
2003-04-01 05:13:16 +00:00
|
|
|
|
if ((!_firstResponder) || (_firstResponder == self))
|
|
|
|
|
{
|
|
|
|
|
if (_initialFirstResponder)
|
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: _initialFirstResponder];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[_firstResponder becomeFirstResponder];
|
|
|
|
|
if ((_firstResponder != self)
|
2002-07-17 13:29:20 +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
|
|
|
|
|
{
|
1999-11-22 15:03:41 +00:00
|
|
|
|
if (_f.is_main == NO)
|
|
|
|
|
{
|
|
|
|
|
_f.is_main = YES;
|
2000-03-06 21:10:08 +00:00
|
|
|
|
if (_f.is_key == NO)
|
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setInputState: GSTitleBarMain];
|
2000-03-06 21:10:08 +00:00
|
|
|
|
}
|
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
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _f.is_key;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isMainWindow
|
|
|
|
|
{
|
2006-02-03 10:07:01 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int) level
|
|
|
|
|
{
|
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
|
|
|
|
{
|
1999-12-14 16:53:23 +00:00
|
|
|
|
[self orderFront: sender];
|
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
|
|
|
|
{
|
2002-06-22 03:44:57 +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
|
|
|
|
{
|
2002-06-22 03:44:57 +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
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)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;
|
|
|
|
|
|
1999-11-29 06:12:34 +00:00
|
|
|
|
if (place == NSWindowOut)
|
|
|
|
|
{
|
2006-10-02 05:09:48 +00:00
|
|
|
|
if (_windowNum == 0)
|
|
|
|
|
{
|
|
|
|
|
return; /* This deferred window was never ordered in. */
|
|
|
|
|
}
|
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
|
|
|
|
|
*/
|
2004-07-12 23:19:14 +00:00
|
|
|
|
[isa _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
|
|
|
|
|
titled windows are constrained. Also, and this is the tricky part,
|
|
|
|
|
don't constrain if we are merely unhidding 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)
|
2006-03-05 13:21:33 +00:00
|
|
|
|
&& [NSApp isHidden] == NO
|
|
|
|
|
&& _f.visible == NO)
|
2002-01-09 20:41:07 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
NSRect nframe = [self constrainFrameRect: _frame
|
2002-01-09 20:41:07 +00:00
|
|
|
|
toScreen: [self screen]];
|
2004-07-28 17:56:57 +00:00
|
|
|
|
[self setFrame: nframe display: NO];
|
2002-01-09 20:41:07 +00:00
|
|
|
|
}
|
2000-09-27 22:18:34 +00:00
|
|
|
|
// create deferred window
|
2001-07-30 14:17:37 +00:00
|
|
|
|
if (_windowNum == 0)
|
2000-09-27 22:18:34 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[self _initBackendWindow];
|
2000-09-27 22:18:34 +00:00
|
|
|
|
display = YES;
|
|
|
|
|
}
|
|
|
|
|
}
|
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.
|
|
|
|
|
*/
|
2004-07-12 23:19:14 +00:00
|
|
|
|
[isa _addAutodisplayedWindow: self];
|
2003-11-25 16:27:15 +00:00
|
|
|
|
|
2000-02-25 17:43:32 +00:00
|
|
|
|
if (_f.has_closed == YES)
|
|
|
|
|
{
|
|
|
|
|
_f.has_closed = NO; /* A closed window has re-opened */
|
|
|
|
|
}
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.has_opened == NO)
|
|
|
|
|
{
|
|
|
|
|
_f.has_opened = YES;
|
|
|
|
|
if (_f.menu_exclude == NO)
|
|
|
|
|
{
|
|
|
|
|
BOOL isFileName;
|
2005-02-08 19:57:03 +00:00
|
|
|
|
NSString *aString;
|
|
|
|
|
|
|
|
|
|
aString = [NSString stringWithFormat: @"%@ -- %@",
|
|
|
|
|
[_representedFilename lastPathComponent],
|
|
|
|
|
[_representedFilename stringByDeletingLastPathComponent]];
|
|
|
|
|
isFileName = [_windowTitle isEqual: aString];
|
1999-12-08 15:01:52 +00:00
|
|
|
|
|
|
|
|
|
[NSApp addWindowsItem: self
|
2000-09-05 17:22:46 +00:00
|
|
|
|
title: _windowTitle
|
1999-12-08 15:01:52 +00:00
|
|
|
|
filename: isFileName];
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-12-14 16:53:23 +00:00
|
|
|
|
if ([self isKeyWindow] == YES)
|
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setInputState: GSTitleBarKey];
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[srv setinputfocus: _windowNum];
|
1999-12-14 16:53:23 +00:00
|
|
|
|
}
|
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
|
|
|
|
{
|
1999-11-22 15:03:41 +00:00
|
|
|
|
if (_f.is_key == YES)
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if ((_firstResponder != self)
|
|
|
|
|
&& [_firstResponder respondsToSelector: @selector(resignKeyWindow)])
|
|
|
|
|
[_firstResponder resignKeyWindow];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
1999-11-22 15:03:41 +00:00
|
|
|
|
_f.is_key = NO;
|
2000-03-06 21:10:08 +00:00
|
|
|
|
|
|
|
|
|
if (_f.is_main == YES)
|
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setInputState: GSTitleBarMain];
|
2000-03-06 21:10:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setInputState: GSTitleBarNormal];
|
2000-03-06 21:10:08 +00:00
|
|
|
|
}
|
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
|
|
|
|
{
|
1999-11-22 15:03:41 +00:00
|
|
|
|
if (_f.is_main == YES)
|
|
|
|
|
{
|
|
|
|
|
_f.is_main = NO;
|
2000-03-06 21:10:08 +00:00
|
|
|
|
if (_f.is_key == YES)
|
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setInputState: GSTitleBarKey];
|
2000-03-06 21:10:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[_wv setInputState: GSTitleBarNormal];
|
2000-03-06 21:10:08 +00:00
|
|
|
|
}
|
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;
|
|
|
|
|
}
|
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) setLevel: (int)newLevel
|
|
|
|
|
{
|
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)
|
2002-03-28 03:53:18 +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
|
|
|
|
{
|
2006-09-06 11:29:20 +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)
|
|
|
|
|
{
|
|
|
|
|
topLeftPoint.x = _frame.origin.x;
|
|
|
|
|
topLeftPoint.y = _frame.origin.y + _frame.size.height;
|
|
|
|
|
}
|
2003-02-02 00:58:32 +00:00
|
|
|
|
[self setFrameTopLeftPoint: topLeftPoint];
|
2006-09-06 11:29:20 +00:00
|
|
|
|
cRect = [isa contentRectForFrameRect: _frame styleMask: _styleMask];
|
|
|
|
|
topLeftPoint.x = cRect.origin.x;
|
|
|
|
|
topLeftPoint.y = cRect.origin.y + cRect.size.height;
|
|
|
|
|
|
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",
|
|
|
|
|
"showsResizeIndicator", "NSWindow");
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setShowsResizeIndicator: (BOOL)show
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
NSLog(@"Method %s is not implemented for class %s",
|
|
|
|
|
"setShowsResizeIndicator:", "NSWindow");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setFrame: (NSRect)frameRect
|
|
|
|
|
display: (BOOL)displayFlag
|
|
|
|
|
animate: (BOOL)animationFlag
|
|
|
|
|
{
|
2005-05-20 14:33:43 +00:00
|
|
|
|
if (animationFlag)
|
|
|
|
|
{
|
|
|
|
|
// time that the resize is expected to take in seconds
|
|
|
|
|
NSTimeInterval resizeTime;
|
|
|
|
|
// velocity
|
|
|
|
|
NSRect v;
|
|
|
|
|
// time parameter
|
|
|
|
|
float t;
|
|
|
|
|
float tdiff;
|
|
|
|
|
|
|
|
|
|
v.origin.x = _frame.origin.x - frameRect.origin.x;
|
|
|
|
|
v.origin.y = _frame.origin.y - frameRect.origin.y;
|
|
|
|
|
v.size.width = _frame.size.width - frameRect.size.width;
|
|
|
|
|
v.size.height = _frame.size.height - frameRect.size.height;
|
|
|
|
|
|
|
|
|
|
resizeTime = [self animationResizeTime: frameRect];
|
|
|
|
|
tdiff = 0.1 / resizeTime;
|
|
|
|
|
|
|
|
|
|
[NSEvent startPeriodicEventsAfterDelay: 0 withPeriod: 0.02];
|
|
|
|
|
t = 1.0;
|
|
|
|
|
while (t > 0.0)
|
|
|
|
|
{
|
|
|
|
|
NSEvent *theEvent = [NSApp nextEventMatchingMask: NSPeriodicMask
|
|
|
|
|
untilDate: [NSDate distantFuture]
|
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
|
dequeue: YES];
|
|
|
|
|
|
|
|
|
|
if ([theEvent type] == NSPeriodic)
|
|
|
|
|
{
|
|
|
|
|
NSRect newFrame;
|
|
|
|
|
|
|
|
|
|
t -= tdiff;
|
|
|
|
|
if (t <= 0.0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// move
|
|
|
|
|
newFrame.origin.x = frameRect.origin.x + v.origin.x * t;
|
|
|
|
|
newFrame.origin.y = frameRect.origin.y + v.origin.y * t;
|
|
|
|
|
// strech
|
|
|
|
|
newFrame.size.width = frameRect.size.width + v.size.width * t;
|
|
|
|
|
newFrame.size.height = frameRect.size.height + v.size.height * t;
|
|
|
|
|
|
|
|
|
|
[self setFrame: newFrame display: displayFlag];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[NSEvent stopPeriodicEvents];
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 20:25:50 +00:00
|
|
|
|
[self setFrame: frameRect display: displayFlag];
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
resizeTime = [num floatValue];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
resizeTime = 0.20;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find the biggest difference
|
|
|
|
|
maxDiff = abs(newFrame.origin.x - _frame.origin.x);
|
|
|
|
|
maxDiff = MAX(maxDiff, newFrame.origin.y - _frame.origin.y);
|
|
|
|
|
maxDiff = MAX(maxDiff, newFrame.size.width - _frame.size.width);
|
|
|
|
|
maxDiff = MAX(maxDiff, newFrame.size.height - _frame.size.height);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2005-05-20 14:33:43 +00:00
|
|
|
|
NSSize screenSize = [[self screen] visibleFrame].size;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
NSPoint origin = _frame.origin;
|
2000-03-12 04:35:43 +00:00
|
|
|
|
|
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
|
|
|
|
{
|
2005-05-20 14:33:43 +00:00
|
|
|
|
NSRect screenRect = [screen visibleFrame];
|
2000-09-08 17:07:04 +00:00
|
|
|
|
float difference;
|
|
|
|
|
|
|
|
|
|
/* Move top edge of the window inside the screen */
|
|
|
|
|
difference = NSMaxY (frameRect) - NSMaxY (screenRect);
|
|
|
|
|
if (difference > 0)
|
|
|
|
|
{
|
|
|
|
|
frameRect.origin.y -= difference;
|
|
|
|
|
}
|
2004-11-07 18:03:50 +00:00
|
|
|
|
|
2000-09-08 17:07:04 +00:00
|
|
|
|
/* If the window is resizable, resize it (if needed) so that the
|
2004-11-07 18:03:50 +00:00
|
|
|
|
bottom edge is on the screen or can be on the screen when the user moves
|
|
|
|
|
the window */
|
|
|
|
|
difference = NSMaxY (screenRect) - NSMaxY (frameRect);
|
2000-09-08 17:07:04 +00:00
|
|
|
|
if (_styleMask & NSResizableWindowMask)
|
|
|
|
|
{
|
2004-11-07 18:03:50 +00:00
|
|
|
|
float difference2;
|
|
|
|
|
|
|
|
|
|
difference2 = screenRect.origin.y - frameRect.origin.y;
|
|
|
|
|
difference2 -= difference;
|
|
|
|
|
// Take in account the space between the top of window and the top of the
|
|
|
|
|
// screen which can be used to move the bottom of the window on the screen
|
|
|
|
|
if (difference2 > 0)
|
|
|
|
|
{
|
|
|
|
|
frameRect.size.height -= difference2;
|
|
|
|
|
frameRect.origin.y += difference2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ensure that resizing doesn't makewindow smaller than minimum */
|
|
|
|
|
difference2 = _minimumSize.height - frameRect.size.height;
|
|
|
|
|
if (difference2 > 0)
|
|
|
|
|
{
|
|
|
|
|
frameRect.size.height += difference2;
|
|
|
|
|
frameRect.origin.y -= difference2;
|
|
|
|
|
}
|
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
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
NSRect r = _frame;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
|
|
|
|
r.size = aSize;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
r = [NSWindow frameRectForContentRect: r styleMask: _styleMask];
|
|
|
|
|
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
|
|
|
|
{
|
2000-09-05 17:22:46 +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]];
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
if (NSEqualSizes(frameRect.size, _frame.size) == NO)
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowWillResize:toSize:)])
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
1999-12-07 05:53:26 +00:00
|
|
|
|
frameRect.size = [_delegate windowWillResize: self
|
2002-09-23 05:52:36 +00:00
|
|
|
|
toSize: frameRect.size];
|
1999-07-06 05:37:15 +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
|
|
|
|
|
{
|
2000-09-05 17:22:46 +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
|
|
|
|
|
{
|
2000-09-05 17:22:46 +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
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
|
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-11-15 21:45:56 +00:00
|
|
|
|
_rFlags.needs_display = NO;
|
2001-02-08 00:00:32 +00:00
|
|
|
|
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv display];
|
2002-07-12 11:12:32 +00:00
|
|
|
|
[self discardCachedImage];
|
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
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_rFlags.needs_display)
|
1999-02-12 17:00:59 +00:00
|
|
|
|
{
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv displayIfNeeded];
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_rFlags.needs_display = NO;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-12-22 12:34:03 +00:00
|
|
|
|
- (void) update
|
1998-11-20 02:14:22 +00:00
|
|
|
|
{
|
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
|
|
|
|
|
{
|
2002-06-28 08:05:49 +00:00
|
|
|
|
int 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)
|
|
|
|
|
{
|
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
|
|
|
|
|
[context flushGraphics];
|
|
|
|
|
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)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.needs_flush = NO;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
|
|
: _windowNum];
|
|
|
|
|
}
|
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
|
|
|
|
|
{
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_rFlags.needs_display != flag)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
1999-12-08 15:01:52 +00:00
|
|
|
|
_rFlags.needs_display = flag;
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
2003-04-06 18:03:33 +00:00
|
|
|
|
/* TODO: this call most likely shouldn't be here */
|
1999-12-08 15:01:52 +00:00
|
|
|
|
[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
|
|
|
|
|
{
|
2006-02-03 10:07:01 +00:00
|
|
|
|
return _rFlags.needs_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
|
|
|
|
|
rect: cacheRect];
|
|
|
|
|
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],
|
|
|
|
|
[_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
|
|
|
|
{
|
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
|
|
|
|
{
|
|
|
|
|
limit = [isa defaultDepthLimit];
|
|
|
|
|
}
|
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
|
|
|
|
|
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
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_currects)
|
|
|
|
|
{
|
|
|
|
|
[theView discardCursorRects];
|
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *s = ((NSViewPtr)theView)->_sub_views;
|
1999-11-15 16:00:47 +00:00
|
|
|
|
unsigned count = [s count];
|
|
|
|
|
|
|
|
|
|
if (count)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
|
|
|
|
unsigned i;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
|
1999-11-15 16:00:47 +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
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (((NSViewPtr)aView)->_rFlags.valid_rects)
|
|
|
|
|
{
|
2006-06-09 17:33:11 +00:00
|
|
|
|
[aView discardCursorRects];
|
2006-05-27 21:54:29 +00:00
|
|
|
|
|
|
|
|
|
if (_f.cursor_rects_valid)
|
|
|
|
|
{
|
|
|
|
|
if (_f.is_key && _f.cursor_rects_enabled)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *s = ((NSViewPtr)theView)->_sub_views;
|
1999-11-15 16:00:47 +00:00
|
|
|
|
unsigned count = [s count];
|
|
|
|
|
|
|
|
|
|
if (count)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
|
|
|
|
unsigned i;
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-11-15 16:00:47 +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
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
if (_f.is_key && _f.cursor_rects_enabled)
|
|
|
|
|
{
|
|
|
|
|
NSPoint loc = [self mouseLocationOutsideOfEventStream];
|
|
|
|
|
if (NSMouseInRect(loc, [_wv bounds], NO))
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
(*ccImp)(self, ccSel, _wv, e);
|
|
|
|
|
_lastPoint = loc;
|
|
|
|
|
}
|
|
|
|
|
}
|
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);
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
RETAIN(self);
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-19 02:33:52 +00:00
|
|
|
|
[nc postNotificationName: NSWindowWillCloseNotification object: self];
|
|
|
|
|
_f.has_opened = NO;
|
|
|
|
|
[NSApp removeWindowsItem: self];
|
|
|
|
|
[self orderOut: self];
|
|
|
|
|
|
|
|
|
|
RELEASE(pool);
|
|
|
|
|
|
2000-02-25 17:43:32 +00:00
|
|
|
|
_f.has_closed = YES;
|
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
|
|
|
|
{
|
2000-10-16 19:20:32 +00:00
|
|
|
|
_f.is_miniaturized = NO;
|
|
|
|
|
[nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self];
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
#if 0
|
|
|
|
|
/* 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)
|
|
|
|
|
{
|
|
|
|
|
NSWindow *mini = GSWindowWithNumber(_counterpart);
|
|
|
|
|
|
|
|
|
|
[mini orderOut: self];
|
|
|
|
|
}
|
2003-10-21 03:10:24 +00:00
|
|
|
|
#endif
|
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
|
|
|
|
|
|
|
|
|
if (_f.is_miniaturized
|
|
|
|
|
|| (!(_styleMask & NSMiniaturizableWindowMask))
|
|
|
|
|
|| (_styleMask & (NSIconWindowMask | NSMiniWindowMask))
|
|
|
|
|
|| (![self isVisible]))
|
|
|
|
|
return;
|
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
[nc postNotificationName: NSWindowWillMiniaturizeNotification
|
2000-03-08 21:26:11 +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
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
NSWindow *mini;
|
|
|
|
|
NSMiniWindowView *v;
|
2004-11-10 17:12:57 +00:00
|
|
|
|
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
|
2000-03-08 21:26:11 +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)
|
|
|
|
|
{
|
|
|
|
|
NSWindow *mini = GSWindowWithNumber(_counterpart);
|
|
|
|
|
|
|
|
|
|
[mini orderFront: self];
|
|
|
|
|
}
|
2000-03-04 07:55:42 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidMiniaturizeNotification
|
2000-03-08 21:26:11 +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])
|
|
|
|
|
return;
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* if delegate responds to windowShouldClose query it to see if
|
|
|
|
|
* it's ok to close the window
|
|
|
|
|
*/
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if (![_delegate windowShouldClose: self])
|
1999-05-04 13:17:26 +00:00
|
|
|
|
{
|
|
|
|
|
NSBeep();
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-05-04 13:17:26 +00:00
|
|
|
|
/*
|
|
|
|
|
* else if self responds to windowShouldClose query
|
|
|
|
|
* self to see if it's ok to close self
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if ([self respondsToSelector: @selector(windowShouldClose:)])
|
1999-05-04 13:17:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (![self windowShouldClose: self])
|
|
|
|
|
{
|
|
|
|
|
NSBeep();
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int) resizeFlags
|
|
|
|
|
{
|
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)
|
1999-06-11 04:46:12 +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
|
|
|
|
/**
|
|
|
|
|
Get a undo manager from the delegate or create one.
|
|
|
|
|
*/
|
|
|
|
|
- (NSUndoManager*) undoManager
|
|
|
|
|
{
|
|
|
|
|
NSUndoManager *undo;
|
|
|
|
|
|
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowWillReturnUndoManager:)])
|
|
|
|
|
{
|
|
|
|
|
return [_delegate windowWillReturnUndoManager: self];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// FIXME: This is more a hack to get an undo manager.
|
|
|
|
|
if (_windowController)
|
|
|
|
|
{
|
|
|
|
|
NSDocument *document = [_windowController document];
|
|
|
|
|
|
|
|
|
|
if (document && (undo = [document undoManager]) != nil)
|
|
|
|
|
{
|
|
|
|
|
return undo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FIXME: We should reuse the same undo manager all the time!!!
|
|
|
|
|
//return AUTORELEASE([[NSUndoManager alloc] init]);
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) discardEventsMatchingMask: (unsigned int)mask
|
2000-03-07 12:00:00 +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])
|
|
|
|
|
return NO;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2006-05-05 13:41:33 +00:00
|
|
|
|
if (![aResponder acceptsFirstResponder])
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
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]))
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_firstResponder = aResponder;
|
|
|
|
|
if (![_firstResponder becomeFirstResponder])
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_firstResponder = self;
|
|
|
|
|
[_firstResponder becomeFirstResponder];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
2002-09-23 05:52:36 +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;
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
[self selectPreviousKeyView: self];
|
|
|
|
|
else
|
|
|
|
|
[self selectNextKeyView: self];
|
|
|
|
|
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)
|
1999-10-12 15:05:37 +00:00
|
|
|
|
{
|
|
|
|
|
// NB: The following *never* returns.
|
2000-09-04 02:00:14 +00:00
|
|
|
|
[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)
|
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
|
|
|
|
[_defaultButtonCell performClick: self];
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
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]
|
|
|
|
|
location: NSZeroPoint
|
1999-10-14 00:39:46 +00:00
|
|
|
|
modifierFlags: ([theEvent modifierFlags] | NSCommandKeyMask)
|
1999-12-16 04:53:50 +00:00
|
|
|
|
timestamp: [theEvent timestamp]
|
1999-10-13 00:51:46 +00:00
|
|
|
|
windowNumber: [theEvent windowNumber]
|
1999-12-16 04:53:50 +00:00
|
|
|
|
context: [theEvent context]
|
2000-09-04 02:00:14 +00:00
|
|
|
|
characters: characters
|
1999-12-16 04:53:50 +00:00
|
|
|
|
charactersIgnoringModifiers: [theEvent
|
1999-10-13 00:51:46 +00:00
|
|
|
|
charactersIgnoringModifiers]
|
|
|
|
|
isARepeat: [theEvent isARepeat]
|
2000-09-04 02:00:14 +00:00
|
|
|
|
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])
|
|
|
|
|
{
|
|
|
|
|
NSString *characters = [theEvent characters];
|
|
|
|
|
unichar character = 0;
|
|
|
|
|
|
|
|
|
|
if ([characters length] > 0)
|
|
|
|
|
{
|
|
|
|
|
character = [characters characterAtIndex: 0];
|
|
|
|
|
}
|
|
|
|
|
if (character == NSHelpFunctionKey)
|
|
|
|
|
{
|
|
|
|
|
[NSHelpManager setContextHelpModeActive: NO];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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;
|
2000-03-07 12:00:00 +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
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSEvent*) nextEventMatchingMask: (unsigned int)mask
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
return [NSApp nextEventMatchingMask: mask
|
|
|
|
|
untilDate: nil
|
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
|
dequeue: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSEvent*) nextEventMatchingMask: (unsigned int)mask
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setAcceptsMouseMovedEvents: (BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.accepts_mouse_moved = flag;
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) _checkTrackingRectangles: (NSView*)theView
|
|
|
|
|
forEvent: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_trkrects)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *tr = ((NSViewPtr)theView)->_tracking_rects;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
unsigned 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)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
|
GSTrackingRect *rects[count];
|
|
|
|
|
NSPoint loc = [theEvent locationInWindow];
|
|
|
|
|
unsigned i;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
[tr getObjects: rects];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
for (i = 0; i < count; ++i)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
|
BOOL last;
|
|
|
|
|
BOOL now;
|
|
|
|
|
GSTrackingRect *r = rects[i];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
/* Check mouse at last point */
|
2000-09-05 17:22:46 +00:00
|
|
|
|
last = NSMouseInRect(_lastPoint, r->rectangle, NO);
|
1999-05-07 20:08:51 +00:00
|
|
|
|
/* Check mouse at current point */
|
1999-07-15 17:04:25 +00:00
|
|
|
|
now = NSMouseInRect(loc, r->rectangle, NO);
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if ((!last) && (now)) // Mouse entered event
|
1999-05-07 11:06:37 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
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)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
|
|
|
|
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];
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-23 18:39:07 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if ((last) && (!now)) // Mouse exited event
|
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (r->flags.checked == NO)
|
2004-05-23 18:39:07 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
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)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
|
|
|
|
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-05-07 11:06:37 +00:00
|
|
|
|
}
|
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
|
|
|
|
|
*/
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
1999-05-07 11:06:37 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *sb = ((NSViewPtr)theView)->_sub_views;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
unsigned count = [sb count];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[sb getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
|
(*ctImp)(self, ctSel, subs[i], theEvent);
|
|
|
|
|
}
|
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
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.valid_rects)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *tr = ((NSViewPtr)theView)->_cursor_rects;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
unsigned count = [tr count];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
// Loop through cursor rectangles
|
|
|
|
|
if (count > 0)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
|
GSTrackingRect *rects[count];
|
|
|
|
|
NSPoint loc = [theEvent locationInWindow];
|
|
|
|
|
unsigned i;
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
[tr getObjects: rects];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
1999-05-07 11:06:37 +00:00
|
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
|
GSTrackingRect *r = rects[i];
|
1999-07-15 17:04:25 +00:00
|
|
|
|
BOOL last;
|
|
|
|
|
BOOL now;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
|
|
|
|
|
if ([r isValid] == NO)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check for presence of point in rectangle.
|
|
|
|
|
*/
|
2000-09-05 17:22:46 +00:00
|
|
|
|
last = NSMouseInRect(_lastPoint, r->rectangle, NO);
|
1999-11-15 16:00:47 +00:00
|
|
|
|
now = NSMouseInRect(loc, r->rectangle, NO);
|
1999-05-07 20:08:51 +00:00
|
|
|
|
|
|
|
|
|
// 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
|
2000-03-07 12:00:00 +00:00
|
|
|
|
userData: (void*)r];
|
1999-05-07 20:08:51 +00:00
|
|
|
|
[self postEvent: e atStart: YES];
|
|
|
|
|
}
|
|
|
|
|
// 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
|
2000-03-07 12:00:00 +00:00
|
|
|
|
userData: (void*)r];
|
1999-05-07 20:08:51 +00:00
|
|
|
|
[self postEvent: e atStart: YES];
|
|
|
|
|
}
|
1999-05-07 11:06:37 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-07 11:06:37 +00:00
|
|
|
|
/*
|
|
|
|
|
* Check cursor rectangles for the subviews
|
|
|
|
|
*/
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
1999-05-07 11:06:37 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *sb = ((NSViewPtr)theView)->_sub_views;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
unsigned count = [sb count];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[sb getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
|
(*ccImp)(self, ccSel, subs[i], theEvent);
|
|
|
|
|
}
|
1999-05-07 11:06:37 +00:00
|
|
|
|
}
|
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
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
1999-10-21 18:08:50 +00:00
|
|
|
|
DPSgsave(context);
|
2000-09-05 17:22:46 +00:00
|
|
|
|
DPSsetgstate(context, _gstate);
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[GSServerForWindow(self) windowdevice: _windowNum];
|
|
|
|
|
GSReplaceGState(context, _gstate);
|
1999-12-13 22:14:54 +00:00
|
|
|
|
DPSgrestore(context);
|
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
|
|
|
|
{
|
1999-03-24 11:31:06 +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)
|
|
|
|
|
return;
|
|
|
|
|
|
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];
|
|
|
|
|
switch (type)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSLeftMouseDown:
|
2000-01-02 20:24:56 +00:00
|
|
|
|
{
|
|
|
|
|
BOOL wasKey = _f.is_key;
|
|
|
|
|
|
2001-03-22 00:27:37 +00:00
|
|
|
|
if (_f.has_closed == NO)
|
2000-01-02 20:24:56 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
2004-05-04 12:46:48 +00:00
|
|
|
|
if (_f.is_key == NO && _windowLevel != NSDesktopWindowLevel)
|
2000-01-02 20:24:56 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
/* NSPanel modification: check becomesKeyOnlyIfNeeded. */
|
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
|
|
|
|
if (![self becomesKeyOnlyIfNeeded]
|
|
|
|
|
|| [v needsPanelToBecomeKey])
|
2004-07-06 20:20:31 +00:00
|
|
|
|
[self makeKeyAndOrderFront: self];
|
2000-01-02 20:24:56 +00:00
|
|
|
|
}
|
2003-11-19 16:01:53 +00:00
|
|
|
|
/* Activate the app *after* making the receiver key, as app
|
|
|
|
|
activation tries to make the previous key window key. */
|
|
|
|
|
if ([NSApp isActive] == NO && self != [NSApp iconWindow])
|
|
|
|
|
{
|
|
|
|
|
[NSApp activateIgnoringOtherApps: YES];
|
|
|
|
|
}
|
2001-03-22 00:27:37 +00:00
|
|
|
|
if (_firstResponder != v)
|
2000-01-02 20:24:56 +00:00
|
|
|
|
{
|
2001-03-22 00:27:37 +00:00
|
|
|
|
[self makeFirstResponder: v];
|
|
|
|
|
}
|
2002-10-04 02:44:13 +00:00
|
|
|
|
if (_lastView)
|
2003-07-26 18:56:06 +00:00
|
|
|
|
{
|
|
|
|
|
DESTROY(_lastView);
|
|
|
|
|
}
|
2001-03-22 00:27:37 +00:00
|
|
|
|
if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
|
|
|
|
|
{
|
|
|
|
|
if ([NSHelpManager isContextHelpModeActive])
|
|
|
|
|
{
|
|
|
|
|
[v helpRequested: theEvent];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-10-04 02:44:13 +00:00
|
|
|
|
ASSIGN(_lastView, v);
|
2006-10-02 19:22:22 +00:00
|
|
|
|
if (toolTipVisible != nil)
|
|
|
|
|
{
|
|
|
|
|
/* Inform the tooltips system that we have had
|
|
|
|
|
* a mouse down so it should stop displaying.
|
|
|
|
|
*/
|
|
|
|
|
[toolTipVisible mouseDown: theEvent];
|
|
|
|
|
}
|
2001-03-22 00:27:37 +00:00
|
|
|
|
[v mouseDown: theEvent];
|
|
|
|
|
}
|
2000-01-02 20:24:56 +00:00
|
|
|
|
}
|
2002-02-06 10:29:26 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[self mouseDown: theEvent];
|
|
|
|
|
}
|
2000-01-02 20:24:56 +00:00
|
|
|
|
}
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
2000-01-02 20:24:56 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSLeftMouseUp:
|
2002-11-01 22:42:52 +00:00
|
|
|
|
v = AUTORELEASE(RETAIN(_lastView));
|
2002-10-04 02:44:13 +00:00
|
|
|
|
DESTROY(_lastView);
|
2002-08-25 02:47:00 +00:00
|
|
|
|
if (v == nil)
|
|
|
|
|
break;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[v mouseUp: theEvent];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-03-02 07:23:18 +00:00
|
|
|
|
case NSOtherMouseDown:
|
2004-07-06 20:20:31 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
2002-03-02 07:23:18 +00:00
|
|
|
|
[v otherMouseDown: theEvent];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
2000-08-03 08:48:22 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-03-02 07:23:18 +00:00
|
|
|
|
case NSOtherMouseUp:
|
2004-07-06 20:20:31 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
2002-03-02 07:23:18 +00:00
|
|
|
|
[v otherMouseUp: theEvent];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
2000-08-03 08:48:22 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSRightMouseDown:
|
2003-02-08 21:39:31 +00:00
|
|
|
|
{
|
2004-07-06 20:20:31 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
2003-04-10 14:00:53 +00:00
|
|
|
|
[v rightMouseDown: theEvent];
|
2003-02-08 21:39:31 +00:00
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSRightMouseUp:
|
2004-07-06 20:20:31 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[v rightMouseUp: theEvent];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
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:
|
1999-03-24 11:31:06 +00:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case NSLeftMouseDragged:
|
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
|
|
|
|
[_lastView mouseDragged: theEvent];
|
1999-03-24 11:31:06 +00:00
|
|
|
|
break;
|
2002-03-02 07:23:18 +00:00
|
|
|
|
case NSOtherMouseDragged:
|
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
|
|
|
|
[_lastView otherMouseDragged: theEvent];
|
2000-08-03 08:48:22 +00:00
|
|
|
|
break;
|
1999-03-24 11:31:06 +00:00
|
|
|
|
case NSRightMouseDragged:
|
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
|
|
|
|
[_lastView rightMouseDragged: theEvent];
|
1999-03-24 11:31:06 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_f.accepts_mouse_moved)
|
1999-03-24 11:31:06 +00:00
|
|
|
|
{
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* If the window is set to accept mouse movements, we need to
|
|
|
|
|
* forward the mouse movement to the correct view.
|
|
|
|
|
*/
|
2004-07-06 20:20:31 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
2006-10-02 19:22:22 +00:00
|
|
|
|
|
|
|
|
|
/* 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];
|
|
|
|
|
}
|
1999-03-24 11:31:06 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +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 NSMouseEntered or NSMouseExited event.
|
|
|
|
|
*/
|
2004-05-23 18:39:07 +00:00
|
|
|
|
(*ctImp)(self, ctSel, _wv, theEvent);
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_f.is_key)
|
1999-03-24 11:31:06 +00:00
|
|
|
|
{
|
1999-06-11 04:46:12 +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.
|
|
|
|
|
*/
|
2002-01-15 16:43:13 +00:00
|
|
|
|
if (_f.cursor_rects_enabled)
|
2004-07-06 20:20:31 +00:00
|
|
|
|
(*ccImp)(self, ccSel, _wv, theEvent);
|
1999-03-24 11:31:06 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_lastPoint = [theEvent locationInWindow];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSMouseEntered:
|
|
|
|
|
case NSMouseExited:
|
1999-03-23 22:35:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
1999-12-16 04:53:50 +00:00
|
|
|
|
case NSKeyDown:
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[_firstResponder keyDown: theEvent];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSKeyUp:
|
|
|
|
|
[_firstResponder keyUp: theEvent];
|
|
|
|
|
break;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSFlagsChanged:
|
2002-02-25 14:31:36 +00:00
|
|
|
|
[_firstResponder flagsChanged: theEvent];
|
2002-02-21 23:40:39 +00:00
|
|
|
|
break;
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
2002-02-21 23:40:39 +00:00
|
|
|
|
case NSCursorUpdate:
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
GSTrackingRect *r =(GSTrackingRect*)[theEvent userData];
|
|
|
|
|
NSCursor *c = (NSCursor*)[r owner];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
if ([theEvent trackingNumber]) // It's a mouse entered
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
[c mouseEntered: theEvent];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1999-06-11 04:46:12 +00:00
|
|
|
|
else // it is a mouse exited
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
[c mouseExited: theEvent];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2001-08-21 23:24:00 +00:00
|
|
|
|
case NSScrollWheel:
|
2005-01-18 16:04:40 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
2001-08-21 23:24:00 +00:00
|
|
|
|
[v scrollWheel: theEvent];
|
|
|
|
|
break;
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSAppKitDefined:
|
1999-07-06 11:56:22 +00:00
|
|
|
|
{
|
1999-07-29 20:58:04 +00:00
|
|
|
|
id dragInfo;
|
|
|
|
|
int action;
|
|
|
|
|
NSEvent *e;
|
1999-07-06 11:56:22 +00:00
|
|
|
|
GSAppKitSubtype sub = [theEvent subtype];
|
|
|
|
|
|
|
|
|
|
switch (sub)
|
|
|
|
|
{
|
2000-10-16 19:20:32 +00:00
|
|
|
|
case GSAppKitWindowMoved:
|
|
|
|
|
_frame.origin.x = (float)[theEvent data1];
|
|
|
|
|
_frame.origin.y = (float)[theEvent data2];
|
|
|
|
|
NSDebugLLog(@"Moving", @"Move event: %d %@",
|
|
|
|
|
_windowNum, NSStringFromPoint(_frame.origin));
|
|
|
|
|
if (_autosaveName != nil)
|
1999-12-08 15:01:52 +00:00
|
|
|
|
{
|
2000-10-16 19:20:32 +00:00
|
|
|
|
[self saveFrameUsingName: _autosaveName];
|
|
|
|
|
}
|
|
|
|
|
[nc postNotificationName: NSWindowDidMoveNotification
|
|
|
|
|
object: self];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowResized:
|
|
|
|
|
{
|
2004-07-28 17:56:57 +00:00
|
|
|
|
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];
|
|
|
|
|
|
|
|
|
|
_frame = newFrame;
|
|
|
|
|
newFrame.origin = NSZeroPoint;
|
|
|
|
|
[_wv setFrame: newFrame];
|
2000-10-16 19:20:32 +00:00
|
|
|
|
[_wv setNeedsDisplay: YES];
|
2004-07-28 17:56:57 +00:00
|
|
|
|
|
|
|
|
|
if (_autosaveName != nil)
|
|
|
|
|
{
|
|
|
|
|
[self saveFrameUsingName: _autosaveName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self _processResizeEvent];
|
|
|
|
|
[nc postNotificationName: NSWindowDidResizeNotification
|
|
|
|
|
object: self];
|
|
|
|
|
break;
|
2000-10-16 19:20:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-23 19:08:18 +00:00
|
|
|
|
case GSAppKitRegionExposed:
|
|
|
|
|
{
|
|
|
|
|
NSRect region;
|
|
|
|
|
|
|
|
|
|
region.size.width = [theEvent data1];
|
|
|
|
|
region.size.height = [theEvent data2];
|
|
|
|
|
region.origin = [theEvent locationInWindow];
|
|
|
|
|
switch (_backingType)
|
|
|
|
|
{
|
|
|
|
|
case NSBackingStoreBuffered:
|
|
|
|
|
case NSBackingStoreRetained:
|
2006-09-24 12:45:21 +00:00
|
|
|
|
/*
|
|
|
|
|
* 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.
|
2006-09-23 19:08:18 +00:00
|
|
|
|
*/
|
2006-09-24 12:45:21 +00:00
|
|
|
|
_rectNeedingFlush
|
|
|
|
|
= NSUnionRect(_rectNeedingFlush, region);
|
|
|
|
|
_f.needs_flush = YES;
|
|
|
|
|
if (_rFlags.needs_display)
|
|
|
|
|
{
|
|
|
|
|
/* 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.
|
|
|
|
|
*/
|
|
|
|
|
[_wv displayIfNeeded];
|
|
|
|
|
}
|
2006-09-24 18:59:08 +00:00
|
|
|
|
[self flushWindowIfNeeded];
|
2006-09-23 19:08:18 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* non-retained ... so we need to redraw the exposed
|
|
|
|
|
* region here.
|
|
|
|
|
*/
|
|
|
|
|
[_wv setNeedsDisplayInRect: region];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2000-10-16 19:20:32 +00:00
|
|
|
|
case GSAppKitWindowClose:
|
|
|
|
|
[self performClose: NSApp];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowMiniaturize:
|
|
|
|
|
[self performMiniaturize: NSApp];
|
|
|
|
|
break;
|
1999-07-06 11:56:22 +00:00
|
|
|
|
|
2000-10-16 19:20:32 +00:00
|
|
|
|
case GSAppKitWindowFocusIn:
|
|
|
|
|
if (_f.is_miniaturized)
|
|
|
|
|
{
|
|
|
|
|
/* Window Manager just deminiaturized us */
|
2003-04-25 07:04:57 +00:00
|
|
|
|
[self deminiaturize: self];
|
1999-12-08 15:01:52 +00:00
|
|
|
|
}
|
2003-11-19 16:01:53 +00:00
|
|
|
|
if ([NSApp modalWindow]
|
|
|
|
|
&& self != [NSApp modalWindow])
|
2002-10-09 17:35:03 +00:00
|
|
|
|
{
|
2003-11-19 16:01:53 +00:00
|
|
|
|
/* Ignore this request. We're in a modal loop and the
|
|
|
|
|
user pressed on the title bar of another window. */
|
2002-10-09 17:35:03 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2000-10-16 19:20:32 +00:00
|
|
|
|
if ([self canBecomeKeyWindow] == YES)
|
|
|
|
|
{
|
2003-11-19 16:01:53 +00:00
|
|
|
|
NSDebugLLog(@"Focus", @"Making %d key", _windowNum);
|
2000-10-16 19:20:32 +00:00
|
|
|
|
[self makeKeyWindow];
|
|
|
|
|
[self makeMainWindow];
|
|
|
|
|
[NSApp activateIgnoringOtherApps: YES];
|
|
|
|
|
}
|
2002-11-08 16:39:41 +00:00
|
|
|
|
if (self == [[NSApp mainMenu] window])
|
|
|
|
|
{
|
|
|
|
|
/* We should really find another window that can become
|
|
|
|
|
key (if possible)
|
|
|
|
|
*/
|
|
|
|
|
[self _lossOfKeyOrMainWindow];
|
|
|
|
|
}
|
2000-10-16 19:20:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowFocusOut:
|
|
|
|
|
break;
|
2000-03-08 14:15:17 +00:00
|
|
|
|
|
2002-01-26 04:14:38 +00:00
|
|
|
|
case GSAppKitWindowLeave:
|
|
|
|
|
/*
|
|
|
|
|
* 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. */
|
2004-05-23 18:39:07 +00:00
|
|
|
|
(*ctImp)(self, ctSel, _wv, theEvent);
|
2002-01-26 04:14:38 +00:00
|
|
|
|
|
|
|
|
|
if (_f.is_key)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* 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)
|
2004-07-06 20:20:31 +00:00
|
|
|
|
(*ccImp)(self, ccSel, _wv, theEvent);
|
2002-01-26 04:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_lastPoint = NSMakePoint(-1, -1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowEnter:
|
|
|
|
|
break;
|
|
|
|
|
|
1999-07-06 11:56:22 +00:00
|
|
|
|
|
2001-12-11 04:31:08 +00:00
|
|
|
|
#define GSPerformDragSelector(view, sel, info, action) \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
if ([view window] == self) \
|
|
|
|
|
{ \
|
2003-10-28 20:27:54 +00:00
|
|
|
|
id target = view; \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
\
|
2003-10-28 20:27:54 +00:00
|
|
|
|
if (target == _wv) \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
{ \
|
2003-10-28 20:27:54 +00:00
|
|
|
|
if (_delegate != nil \
|
|
|
|
|
&& [_delegate respondsToSelector: sel] == YES) \
|
|
|
|
|
{ \
|
|
|
|
|
target = _delegate; \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
target = self; \
|
|
|
|
|
} \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
if ([target respondsToSelector: sel]) \
|
|
|
|
|
{ \
|
2006-01-14 11:39:37 +00:00
|
|
|
|
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) \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
if ([view window] == self) \
|
|
|
|
|
{ \
|
2003-10-28 20:27:54 +00:00
|
|
|
|
id target = view; \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
\
|
2003-10-28 20:27:54 +00:00
|
|
|
|
if (target == _wv) \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
{ \
|
2003-10-28 20:27:54 +00:00
|
|
|
|
if (_delegate != nil \
|
|
|
|
|
&& [_delegate respondsToSelector: sel] == YES) \
|
|
|
|
|
{ \
|
|
|
|
|
target = _delegate; \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
target = self; \
|
|
|
|
|
} \
|
2002-01-21 04:22:55 +00:00
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
if ([target respondsToSelector: sel]) \
|
|
|
|
|
{ \
|
|
|
|
|
[target performSelector: sel withObject: info]; \
|
|
|
|
|
} \
|
|
|
|
|
}
|
1999-07-29 20:58:04 +00:00
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingEnter:
|
|
|
|
|
case GSAppKitDraggingUpdate:
|
2002-01-20 21:08:58 +00:00
|
|
|
|
{
|
|
|
|
|
BOOL isEntry;
|
|
|
|
|
|
2006-11-21 13:46:18 +00:00
|
|
|
|
dragInfo = [GSServerForWindow(self) dragInfo];
|
2004-07-06 20:20:31 +00:00
|
|
|
|
v = [_wv hitTest: [theEvent locationInWindow]];
|
2006-11-21 13:46:18 +00:00
|
|
|
|
|
|
|
|
|
while (v != nil)
|
2003-10-28 20:27:54 +00:00
|
|
|
|
{
|
2006-11-21 13:46:18 +00:00
|
|
|
|
if (((NSViewPtr)v)->_rFlags.has_draginfo != 0
|
|
|
|
|
&& GSViewAcceptsDrag(v, dragInfo))
|
|
|
|
|
break;
|
2003-10-28 20:27:54 +00:00
|
|
|
|
v = [v superview];
|
|
|
|
|
}
|
2002-01-20 21:08:58 +00:00
|
|
|
|
if (v == nil)
|
2002-01-20 17:54:13 +00:00
|
|
|
|
{
|
2003-10-28 20:27:54 +00:00
|
|
|
|
v = _wv;
|
2002-01-20 17:54:13 +00:00
|
|
|
|
}
|
2002-01-20 21:08:58 +00:00
|
|
|
|
if (_lastDragView == v)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
2002-01-20 21:08:58 +00:00
|
|
|
|
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);
|
2003-10-28 20:27:54 +00:00
|
|
|
|
action = NSDragOperationNone;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
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;
|
2002-01-20 21:08:58 +00:00
|
|
|
|
NSDebugLLog(@"NSDragging", @"Dragging entered");
|
2001-12-11 04:31:08 +00:00
|
|
|
|
GSPerformDragSelector(v, @selector(draggingEntered:),
|
2002-01-20 17:54:13 +00:00
|
|
|
|
dragInfo, action);
|
2001-12-11 04:31:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
action = _lastDragOperationMask;
|
2002-01-20 21:08:58 +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];
|
1999-07-29 20:58:04 +00:00
|
|
|
|
break;
|
2002-01-20 21:08:58 +00:00
|
|
|
|
}
|
1999-07-29 20:58:04 +00:00
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingStatus:
|
2000-01-16 09:52:49 +00:00
|
|
|
|
NSDebugLLog(@"NSDragging",
|
|
|
|
|
@"Internal: dropped GSAppKitDraggingStatus event");
|
1999-07-29 20:58:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingExit:
|
2002-01-20 21:08:58 +00:00
|
|
|
|
NSDebugLLog(@"NSDragging", @"GSAppKitDraggingExit");
|
2002-03-28 03:53:18 +00:00
|
|
|
|
dragInfo = [GSServerForWindow(self) dragInfo];
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_lastDragView && _f.accepts_drag)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
2002-01-20 21:08:58 +00:00
|
|
|
|
NSDebugLLog(@"NSDragging", @"Dragging exit");
|
2001-12-11 04:31:08 +00:00
|
|
|
|
GSPerformVoidDragSelector(_lastDragView,
|
2002-01-20 17:54:13 +00:00
|
|
|
|
@selector(draggingExited:), dragInfo);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
2001-12-11 04:31:08 +00:00
|
|
|
|
_lastDragOperationMask = NSDragOperationNone;
|
2002-01-20 17:54:13 +00:00
|
|
|
|
DESTROY(_lastDragView);
|
1999-07-29 20:58:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingDrop:
|
2002-01-20 21:08:58 +00:00
|
|
|
|
NSDebugLLog(@"NSDragging", @"GSAppKitDraggingDrop");
|
2002-03-28 03:53:18 +00:00
|
|
|
|
dragInfo = [GSServerForWindow(self) dragInfo];
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_lastDragView && _f.accepts_drag)
|
1999-07-29 20:58:04 +00:00
|
|
|
|
{
|
2001-12-11 04:31:08 +00:00
|
|
|
|
action = NO;
|
|
|
|
|
GSPerformDragSelector(_lastDragView,
|
2002-01-20 17:54:13 +00:00
|
|
|
|
@selector(prepareForDragOperation:), dragInfo, action);
|
1999-07-29 20:58:04 +00:00
|
|
|
|
if (action)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
2001-12-11 04:31:08 +00:00
|
|
|
|
action = NO;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
GSPerformDragSelector(_lastDragView,
|
2002-01-20 17:54:13 +00:00
|
|
|
|
@selector(performDragOperation:), dragInfo, action);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-07-29 20:58:04 +00:00
|
|
|
|
if (action)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
GSPerformVoidDragSelector(_lastDragView,
|
2002-01-20 17:54:13 +00:00
|
|
|
|
@selector(concludeDragOperation:), dragInfo);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-07-29 20:58:04 +00:00
|
|
|
|
}
|
2001-12-11 04:31:08 +00:00
|
|
|
|
_lastDragOperationMask = NSDragOperationNone;
|
2002-01-20 17:54:13 +00:00
|
|
|
|
DESTROY(_lastDragView);
|
1999-07-29 20:58:04 +00:00
|
|
|
|
e = [NSEvent otherEventWithType: NSAppKitDefined
|
|
|
|
|
location: [theEvent locationInWindow]
|
|
|
|
|
modifierFlags: 0
|
|
|
|
|
timestamp: 0
|
2000-09-05 17:22:46 +00:00
|
|
|
|
windowNumber: _windowNum
|
1999-07-29 20:58:04 +00:00
|
|
|
|
context: GSCurrentContext()
|
|
|
|
|
subtype: GSAppKitDraggingFinished
|
|
|
|
|
data1: [theEvent data1]
|
|
|
|
|
data2: 0];
|
2001-12-21 00:45:48 +00:00
|
|
|
|
[dragInfo postDragEvent: e];
|
1999-07-29 20:58:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingFinished:
|
2001-12-11 04:31:08 +00:00
|
|
|
|
_lastDragOperationMask = NSDragOperationNone;
|
2002-01-20 17:54:13 +00:00
|
|
|
|
DESTROY(_lastDragView);
|
2000-01-16 09:52:49 +00:00
|
|
|
|
NSDebugLLog(@"NSDragging",
|
|
|
|
|
@"Internal: dropped GSAppKitDraggingFinished event");
|
1999-07-29 20:58:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
1999-07-06 11:56:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
1999-12-16 04:53:50 +00:00
|
|
|
|
case NSPeriodic:
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSSystemDefined:
|
|
|
|
|
case NSApplicationDefined:
|
1999-03-23 22:35:21 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: theView];
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_selectionDirection = NSSelectingNext;
|
1999-11-18 01:00:58 +00:00
|
|
|
|
[(id)theView selectText: self];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_selectionDirection = NSDirectSelection;
|
1999-11-18 01:00:58 +00:00
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: theView];
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_selectionDirection = NSSelectingPrevious;
|
1999-11-18 01:00:58 +00:00
|
|
|
|
[(id)theView selectText: self];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_selectionDirection = NSDirectSelection;
|
1999-11-18 01:00:58 +00:00
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
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])
|
|
|
|
|
theView = _initialFirstResponder;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
else
|
2000-09-05 17:22:46 +00:00
|
|
|
|
theView = [_initialFirstResponder nextValidKeyView];
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (theView)
|
1999-11-14 21:16:04 +00:00
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: theView];
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_selectionDirection = NSSelectingNext;
|
1999-11-18 01:00:58 +00:00
|
|
|
|
[(id)theView selectText: self];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_selectionDirection = NSDirectSelection;
|
1999-11-18 01:00:58 +00:00
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
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])
|
|
|
|
|
theView = _initialFirstResponder;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
else
|
2000-09-05 17:22:46 +00:00
|
|
|
|
theView = [_initialFirstResponder previousValidKeyView];
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (theView)
|
1999-11-14 21:16:04 +00:00
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: theView];
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_selectionDirection = NSSelectingPrevious;
|
1999-11-18 01:00:58 +00:00
|
|
|
|
[(id)theView selectText: self];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_selectionDirection = NSDirectSelection;
|
1999-11-18 01:00:58 +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).
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSSelectionDirection) keyViewSelectionDirection
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
2000-09-05 17:22:46 +00:00
|
|
|
|
return _selectionDirection;
|
1999-11-18 01:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Dragging
|
|
|
|
|
*/
|
1999-07-04 18:13:15 +00:00
|
|
|
|
- (void) dragImage: (NSImage*)anImage
|
|
|
|
|
at: (NSPoint)baseLocation
|
|
|
|
|
offset: (NSSize)initialOffset
|
|
|
|
|
event: (NSEvent*)event
|
|
|
|
|
pasteboard: (NSPasteboard*)pboard
|
|
|
|
|
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
|
|
|
|
|
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)
|
1999-11-30 20:26:33 +00:00
|
|
|
|
{
|
2005-10-23 10:53:39 +00:00
|
|
|
|
[NSApp removeWindowsItem: self];
|
|
|
|
|
}
|
|
|
|
|
else if (_f.has_opened == YES && flag == NO)
|
|
|
|
|
{
|
|
|
|
|
BOOL isFileName;
|
|
|
|
|
NSString *aString;
|
|
|
|
|
|
|
|
|
|
aString = [NSString stringWithFormat: @"%@ -- %@",
|
|
|
|
|
[_representedFilename lastPathComponent],
|
|
|
|
|
[_representedFilename stringByDeletingLastPathComponent]];
|
|
|
|
|
isFileName = [_windowTitle isEqual: aString];
|
|
|
|
|
|
|
|
|
|
[NSApp addWindowsItem: self
|
|
|
|
|
title: _windowTitle
|
|
|
|
|
filename: isFileName];
|
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
|
|
|
|
|
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
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: We should not forward this method if the delegate is a NSResponder
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if (_delegate && [_delegate respondsToSelector: _cmd])
|
|
|
|
|
result = [_delegate validRequestorForSendType: sendType
|
1999-03-23 22:35:21 +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
|
|
|
|
|
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
|
|
|
|
{
|
1999-11-16 09:40:14 +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
|
|
|
|
{
|
|
|
|
|
return YES; /* That's our name already. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ([autosaveNames member: name] != nil)
|
|
|
|
|
{
|
|
|
|
|
return NO; /* Name in use elsewhere. */
|
|
|
|
|
}
|
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
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSScanner *scanner = [NSScanner scannerWithString: string];
|
|
|
|
|
NSRect nRect;
|
|
|
|
|
NSRect sRect;
|
|
|
|
|
NSRect fRect;
|
|
|
|
|
int value;
|
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;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
|
*/
|
2003-02-02 00:58:32 +00:00
|
|
|
|
nRect = [[self 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)
|
|
|
|
|
* (nRect.size.width / sRect.size.width);
|
|
|
|
|
}
|
|
|
|
|
if (nRect.size.height != sRect.size.height)
|
|
|
|
|
{
|
|
|
|
|
fRect.origin.y = nRect.origin.y + (fRect.origin.y - nRect.origin.y)
|
|
|
|
|
* (nRect.size.height / sRect.size.height);
|
1999-11-16 07:00:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-23 15:34:34 +00:00
|
|
|
|
/* If we aren't resizable (ie. if we don't have a resize bar), make sure
|
|
|
|
|
we don't change the size. */
|
|
|
|
|
if (!(_styleMask & NSResizableWindowMask))
|
|
|
|
|
fRect.size = _frame.size;
|
|
|
|
|
|
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
|
|
|
|
{
|
1999-11-16 09:40:14 +00:00
|
|
|
|
NSUserDefaults *defs;
|
|
|
|
|
id obj;
|
2000-01-07 16:46:35 +00:00
|
|
|
|
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;
|
|
|
|
|
[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
|
2006-03-05 13:21:33 +00:00
|
|
|
|
force: (BOOL)force
|
2001-11-26 20:25:50 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME
|
|
|
|
|
return [self setFrameUsingName: name];
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-08 00:00:32 +00:00
|
|
|
|
- (NSString *) stringWithSavedFrame
|
1998-12-17 13:06:17 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSRect fRect;
|
|
|
|
|
NSRect sRect;
|
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
fRect = _frame;
|
2002-08-09 10:14:45 +00:00
|
|
|
|
|
1999-11-16 07:00:43 +00:00
|
|
|
|
/*
|
2003-02-02 00:58:32 +00:00
|
|
|
|
* The screen rectangle should 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
|
|
|
|
*/
|
2003-02-02 00:58:32 +00:00
|
|
|
|
sRect = [[self screen] visibleFrame];
|
1999-11-16 07:00:43 +00:00
|
|
|
|
|
1999-11-16 09:40:14 +00:00
|
|
|
|
return [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d ",
|
1999-11-16 07:00:43 +00:00
|
|
|
|
(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];
|
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:
|
|
|
|
|
[_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:
|
|
|
|
|
[_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
|
|
|
|
|
*/
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
// FIXME: Method is missing
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2003-02-02 00:58:32 +00:00
|
|
|
|
#define DIST 3
|
|
|
|
|
|
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
|
2006-03-05 13:21:33 +00:00
|
|
|
|
if ((abs(NSMaxX(maxRect) - NSMaxX(_frame)) < DIST)
|
|
|
|
|
&& (abs(NSMaxY(maxRect) - NSMaxY(_frame)) < DIST)
|
|
|
|
|
&& (abs(NSMinX(maxRect) - NSMinX(_frame)) < DIST)
|
|
|
|
|
&& (abs(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)
|
|
|
|
|
{
|
|
|
|
|
[self setFrameUsingName: _autosaveName];
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowShouldZoom:toFrame:)])
|
|
|
|
|
{
|
|
|
|
|
if (![_delegate windowShouldZoom: self toFrame: maxRect])
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if ([self respondsToSelector: @selector(windowShouldZoom:toFrame:)])
|
|
|
|
|
{
|
|
|
|
|
if (![self windowShouldZoom: self toFrame: maxRect])
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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];
|
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
|
|
|
|
|
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
|
|
|
|
|
{
|
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
|
|
|
|
{
|
1999-12-03 14:51:56 +00:00
|
|
|
|
BOOL flag;
|
1999-11-15 21:45:56 +00:00
|
|
|
|
|
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
|
2006-06-08 04:04:17 +00:00
|
|
|
|
format: @"Keyed coding not implemented for %@.",
|
2006-06-04 05:16:37 +00:00
|
|
|
|
NSStringFromClass([self class])];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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]];
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &_styleMask];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSBackingStoreType) 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
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[aCoder encodeSize: _minimumSize];
|
|
|
|
|
[aCoder encodeSize: _maximumSize];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
2000-09-05 17:22:46 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(int) 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
|
|
|
|
{
|
1999-11-30 19:44:53 +00:00
|
|
|
|
id oldself = self;
|
1999-11-15 21:45:56 +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 ([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
|
2006-06-08 04:04:17 +00:00
|
|
|
|
format: @"Keyed coding not implemented for %@.",
|
2006-06-04 05:16:37 +00:00
|
|
|
|
NSStringFromClass([self class])];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-30 19:44:53 +00:00
|
|
|
|
if ((self = [super initWithCoder: aDecoder]) == oldself)
|
|
|
|
|
{
|
|
|
|
|
NSSize aSize;
|
|
|
|
|
NSRect aRect;
|
1999-12-03 14:51:56 +00:00
|
|
|
|
NSPoint p;
|
1999-11-30 19:44:53 +00:00
|
|
|
|
unsigned aStyle;
|
|
|
|
|
NSBackingStoreType aBacking;
|
|
|
|
|
int anInt;
|
|
|
|
|
id obj;
|
|
|
|
|
|
|
|
|
|
aRect = [aDecoder decodeRect];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(unsigned)
|
|
|
|
|
at: &aStyle];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(NSBackingStoreType)
|
|
|
|
|
at: &aBacking];
|
|
|
|
|
|
|
|
|
|
self = [self initWithContentRect: aRect
|
|
|
|
|
styleMask: aStyle
|
|
|
|
|
backing: aBacking
|
|
|
|
|
defer: NO
|
|
|
|
|
screen: nil];
|
|
|
|
|
|
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];
|
|
|
|
|
|
|
|
|
|
aSize = [aDecoder decodeSize];
|
|
|
|
|
[self setMinSize: aSize];
|
|
|
|
|
aSize = [aDecoder decodeSize];
|
|
|
|
|
[self setMaxSize: aSize];
|
|
|
|
|
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(int)
|
|
|
|
|
at: &anInt];
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[self setLevel: anInt];
|
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)
|
|
|
|
|
[self enableCursorRects];
|
|
|
|
|
else
|
|
|
|
|
[self disableCursorRects];
|
|
|
|
|
[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)
|
2004-12-28 17:06:14 +00:00
|
|
|
|
{
|
|
|
|
|
ASSIGN(_miniaturizedImage, obj);
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-30 19:44:53 +00:00
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id)
|
2000-09-05 17:22:46 +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;
|
|
|
|
|
}
|
|
|
|
|
|
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",
|
|
|
|
|
"drawers", "NSWindow");
|
|
|
|
|
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
|
|
|
|
}
|
1996-10-03 18:45:41 +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
|
|
|
|
|
{
|
2002-03-28 03:53:18 +00:00
|
|
|
|
[GSCurrentServer() capturemouse: _windowNum];
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) _releaseMouse: sender
|
|
|
|
|
{
|
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;
|
|
|
|
|
_initialFirstResponder = nil;
|
|
|
|
|
_selectionDirection = NSDirectSelection;
|
1999-12-07 05:53:26 +00:00
|
|
|
|
_delegate = nil;
|
2000-09-05 17:22:46 +00:00
|
|
|
|
_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
|
|
|
|
|
|
|
|
|
_f.is_one_shot = NO;
|
|
|
|
|
_f.is_autodisplay = YES;
|
2003-02-02 00:58:32 +00:00
|
|
|
|
_f.optimize_drawing = NO;
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.dynamic_depth_limit = YES;
|
|
|
|
|
_f.cursor_rects_enabled = NO;
|
|
|
|
|
_f.visible = NO;
|
|
|
|
|
_f.is_key = NO;
|
|
|
|
|
_f.is_main = NO;
|
|
|
|
|
_f.is_edited = NO;
|
|
|
|
|
_f.is_released_when_closed = YES;
|
|
|
|
|
_f.is_miniaturized = NO;
|
|
|
|
|
_f.menu_exclude = NO;
|
|
|
|
|
_f.hides_on_deactivate = NO;
|
|
|
|
|
_f.accepts_mouse_moved = NO;
|
1999-12-08 15:01:52 +00:00
|
|
|
|
_f.has_opened = NO;
|
2000-02-25 17:43:32 +00:00
|
|
|
|
_f.has_closed = NO;
|
2001-11-26 20:25:50 +00:00
|
|
|
|
_f.can_hide = YES;
|
|
|
|
|
_f.has_shadow = NO;
|
|
|
|
|
_f.is_opaque = YES;
|
|
|
|
|
|
2000-04-13 19:23:16 +00:00
|
|
|
|
_rFlags.needs_display = YES;
|
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
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-06 11:39:22 +00:00
|
|
|
|
void NSCountWindows(int *count)
|
|
|
|
|
{
|
2006-10-21 19:13:42 +00:00
|
|
|
|
*count = (int)[[GSCurrentServer() windowlist] count];
|
2000-03-06 11:39:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NSWindowList(int size, int list[])
|
|
|
|
|
{
|
2006-10-21 19:13:42 +00:00
|
|
|
|
NSArray *windowList = [GSCurrentServer() windowlist];
|
|
|
|
|
unsigned i, c;
|
|
|
|
|
for (i = 0, c = [windowList count]; i < size && i < c; i++)
|
|
|
|
|
{
|
|
|
|
|
list[i] = [[windowList objectAtIndex:i] intValue];
|
|
|
|
|
}
|
|
|
|
|
}
|
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];
|
|
|
|
|
int i, c;
|
|
|
|
|
|
|
|
|
|
for (i = 0, c = [window_list count]; i < c; i++)
|
2000-03-06 11:39:22 +00:00
|
|
|
|
{
|
2006-10-21 19:13:42 +00:00
|
|
|
|
int windowNumber = [[window_list objectAtIndex:i] intValue];
|
|
|
|
|
NSWindow *win = GSWindowWithNumber(windowNumber);
|
|
|
|
|
|
|
|
|
|
[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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NSWindow* GSWindowWithNumber(int num)
|
|
|
|
|
{
|
2006-01-14 11:39:37 +00:00
|
|
|
|
return (NSWindow*)NSMapGet(windowmaps, (void*)(intptr_t)num);
|
2000-03-06 11:39:22 +00:00
|
|
|
|
}
|