1996-05-30 20:03:15 +00:00
|
|
|
/*
|
|
|
|
NSWindow.m
|
|
|
|
|
|
|
|
The window class
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
|
|
|
Venkat Ajjanagadde <venkat@ocbi.com>
|
|
|
|
Date: 1996
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
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,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
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>
|
|
|
|
#include <Foundation/NSNotification.h>
|
1997-07-07 16:56:52 +00:00
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSWindow.h>
|
|
|
|
#include <AppKit/NSApplication.h>
|
1997-07-07 16:56:52 +00:00
|
|
|
#include <AppKit/NSImage.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSTextFieldCell.h>
|
|
|
|
#include <AppKit/NSTextField.h>
|
|
|
|
#include <AppKit/NSColor.h>
|
|
|
|
#include <AppKit/TrackingRectangle.h>
|
|
|
|
#include <AppKit/NSSliderCell.h>
|
|
|
|
#include <AppKit/NSScreen.h>
|
1997-03-05 01:11:17 +00:00
|
|
|
#include <AppKit/NSCursor.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
#define ASSIGN(variable, value) \
|
|
|
|
[value retain]; \
|
|
|
|
[variable release]; \
|
|
|
|
variable = value;
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// NSWindow implementation
|
|
|
|
//
|
|
|
|
@implementation NSWindow
|
|
|
|
|
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
|
|
|
+ (void)initialize
|
|
|
|
{
|
|
|
|
if (self == [NSWindow class])
|
|
|
|
{
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"Initialize NSWindow class\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Initial version
|
1996-12-05 13:07:59 +00:00
|
|
|
[self setVersion:2];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Saving and restoring the frame
|
|
|
|
+ (void)removeFrameUsingName:(NSString *)name
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Computing frame and content rectangles
|
|
|
|
+ (NSRect)contentRectForFrameRect:(NSRect)aRect
|
|
|
|
styleMask:(unsigned int)aStyle
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return aRect;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSRect)frameRectForContentRect:(NSRect)aRect
|
|
|
|
styleMask:(unsigned int)aStyle
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return aRect;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSRect)minFrameWidthWithTitle:(NSString *)aTitle
|
|
|
|
styleMask:(unsigned int)aStyle
|
|
|
|
{
|
|
|
|
NSRect t;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Screens and window depths
|
1996-08-22 18:51:08 +00:00
|
|
|
+ (NSWindowDepth)defaultDepthLimit
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return 8;
|
1996-08-22 18:51:08 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Initialization
|
|
|
|
//
|
|
|
|
- init
|
|
|
|
{
|
|
|
|
int style;
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSWindow -init\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
style = NSTitledWindowMask | NSClosableWindowMask
|
|
|
|
| NSMiniaturizableWindowMask | NSResizableWindowMask;
|
|
|
|
return [self initWithContentRect:NSZeroRect styleMask:style
|
|
|
|
backing:NSBackingStoreBuffered defer:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
|
|
|
// Release the content view
|
|
|
|
if (content_view) [content_view release];
|
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
[background_color release];
|
|
|
|
[represented_filename release];
|
|
|
|
[miniaturized_title release];
|
|
|
|
[miniaturized_image release];
|
|
|
|
[window_title release];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initializing and getting a new NSWindow object
|
|
|
|
//
|
|
|
|
- initWithContentRect:(NSRect)contentRect
|
|
|
|
styleMask:(unsigned int)aStyle
|
|
|
|
backing:(NSBackingStoreType)bufferingType
|
|
|
|
defer:(BOOL)flag
|
|
|
|
{
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSWindow -initWithContentRect:\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
return [self initWithContentRect:contentRect styleMask:aStyle
|
|
|
|
backing:bufferingType defer:flag screen:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- initWithContentRect:(NSRect)contentRect
|
|
|
|
styleMask:(unsigned int)aStyle
|
|
|
|
backing:(NSBackingStoreType)bufferingType
|
|
|
|
defer:(BOOL)flag
|
|
|
|
screen:aScreen
|
|
|
|
{
|
|
|
|
NSApplication *theApp = [NSApplication sharedApplication];
|
1996-10-03 18:45:41 +00:00
|
|
|
NSRect r = [[NSScreen mainScreen] frame];
|
1997-07-07 16:56:52 +00:00
|
|
|
NSRect cframe;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSWindow default initializer\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
if (!theApp)
|
|
|
|
NSLog(@"No application!\n");
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSWindow start of init\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
// Initialize attributes and flags
|
|
|
|
[self cleanInit];
|
|
|
|
|
|
|
|
backing_type = bufferingType;
|
1996-05-30 20:03:15 +00:00
|
|
|
style_mask = aStyle;
|
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
// Size attributes
|
|
|
|
frame = [NSWindow frameRectForContentRect: contentRect styleMask: aStyle];
|
|
|
|
minimum_size = NSZeroSize;
|
|
|
|
maximum_size = r.size;
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Next responder is the application
|
|
|
|
[self setNextResponder:theApp];
|
|
|
|
|
1997-03-05 01:11:17 +00:00
|
|
|
// Cursor management
|
|
|
|
cursor_rects_enabled = YES;
|
|
|
|
cursor_rects_valid = NO;
|
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
// Create our content view
|
1997-07-07 16:56:52 +00:00
|
|
|
cframe.origin = NSZeroPoint;
|
|
|
|
cframe.size = frame.size;
|
|
|
|
[self setContentView:[[[NSView alloc] initWithFrame:cframe] autorelease]];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Register ourselves with the Application object
|
|
|
|
[theApp addWindowsItem:self title:window_title filename:NO];
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSWindow end of init\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Accessing the content view
|
|
|
|
//
|
|
|
|
- contentView
|
|
|
|
{
|
|
|
|
return content_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setContentView:(NSView *)aView
|
|
|
|
{
|
|
|
|
if (content_view)
|
1997-07-07 16:56:52 +00:00
|
|
|
[content_view viewWillMoveToWindow:nil];
|
|
|
|
|
|
|
|
ASSIGN(content_view, aView);
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Tell the view its changing windows
|
|
|
|
[content_view viewWillMoveToWindow:self];
|
1997-07-07 16:56:52 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Make us the view's next responder
|
|
|
|
[content_view setNextResponder:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Window graphics
|
|
|
|
//
|
|
|
|
- (NSColor *)backgroundColor
|
|
|
|
{
|
|
|
|
return background_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)representedFilename
|
|
|
|
{
|
|
|
|
return represented_filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBackgroundColor:(NSColor *)color
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
ASSIGN(background_color, color);
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setRepresentedFilename:(NSString *)aString
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
ASSIGN(represented_filename, aString);
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setTitle:(NSString *)aString
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
ASSIGN(window_title, aString);
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setTitleWithRepresentedFilename:(NSString *)aString
|
|
|
|
{
|
|
|
|
[self setRepresentedFilename:aString];
|
|
|
|
[self setTitle:aString];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned int)styleMask
|
|
|
|
{
|
|
|
|
return style_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)title
|
|
|
|
{
|
|
|
|
return window_title;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Window device attributes
|
|
|
|
//
|
|
|
|
- (NSBackingStoreType)backingType
|
|
|
|
{
|
|
|
|
return backing_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *)deviceDescription
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int)gState
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isOneShot
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return is_one_shot;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBackingType:(NSBackingStoreType)type
|
|
|
|
{
|
|
|
|
backing_type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setOneShot:(BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
is_one_shot = flag;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (int)windowNumber
|
|
|
|
{
|
|
|
|
return window_num;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setWindowNumber:(int)windowNum
|
|
|
|
{
|
|
|
|
window_num = windowNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// The miniwindow
|
|
|
|
//
|
|
|
|
- (NSImage *)miniwindowImage
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return miniaturized_image;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)miniwindowTitle
|
|
|
|
{
|
|
|
|
return miniaturized_title;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setMiniwindowImage:(NSImage *)image
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
ASSIGN(miniaturized_image, image);
|
1996-10-03 18:45:41 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setMiniwindowTitle:(NSString *)title;
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
ASSIGN(miniaturized_title, title);
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// The field editor
|
|
|
|
//
|
|
|
|
- (void)endEditingFor:anObject
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (NSText *)fieldEditor:(BOOL)createFlag
|
|
|
|
forObject:anObject
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Window status and ordering
|
|
|
|
//
|
|
|
|
- (void)becomeKeyWindow
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
1996-07-10 20:43:47 +00:00
|
|
|
// We are the key window
|
|
|
|
is_key = YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-03-05 01:11:17 +00:00
|
|
|
// Reset the cursor rects
|
|
|
|
[self resetCursorRects];
|
|
|
|
|
1996-07-10 20:43:47 +00:00
|
|
|
// Post notification
|
1996-10-03 18:45:41 +00:00
|
|
|
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)becomeMainWindow
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
1996-07-10 20:43:47 +00:00
|
|
|
// We are the main window
|
|
|
|
is_main = YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1996-07-10 20:43:47 +00:00
|
|
|
// Post notification
|
1996-10-03 18:45:41 +00:00
|
|
|
[nc postNotificationName: NSWindowDidBecomeMainNotification object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)canBecomeKeyWindow
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)canBecomeMainWindow
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)hidesOnDeactivate
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return hides_on_deactivate;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isKeyWindow
|
|
|
|
{
|
|
|
|
return is_key;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isMainWindow
|
|
|
|
{
|
|
|
|
return is_main;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isMiniaturized
|
|
|
|
{
|
|
|
|
return is_miniaturized;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isVisible
|
|
|
|
{
|
|
|
|
return visible;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int)level
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return window_level;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)makeKeyAndOrderFront:sender
|
|
|
|
{
|
1996-07-10 20:43:47 +00:00
|
|
|
// Make ourself the key window
|
|
|
|
[self makeKeyWindow];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Now order to the front
|
|
|
|
[self orderFront:sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)makeKeyWindow
|
|
|
|
{
|
1996-07-10 20:43:47 +00:00
|
|
|
NSApplication *theApp = [NSApplication sharedApplication];
|
|
|
|
|
|
|
|
// Can we become the key window
|
|
|
|
if (![self canBecomeKeyWindow]) return;
|
|
|
|
|
|
|
|
// Make the current key window resign
|
|
|
|
[[theApp keyWindow] resignKeyWindow];
|
|
|
|
|
|
|
|
// Make ourself become the key window
|
|
|
|
[self becomeKeyWindow];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)makeMainWindow
|
|
|
|
{
|
1996-07-10 20:43:47 +00:00
|
|
|
NSApplication *theApp = [NSApplication sharedApplication];
|
|
|
|
|
|
|
|
// Can we become the main window
|
|
|
|
if (![self canBecomeMainWindow]) return;
|
|
|
|
|
|
|
|
// Make the current main window resign
|
|
|
|
[[theApp mainWindow] resignMainWindow];
|
|
|
|
|
|
|
|
// Make ourself become the main window
|
|
|
|
[self becomeMainWindow];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)orderBack:sender
|
|
|
|
{
|
|
|
|
visible = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)orderFront:sender
|
|
|
|
{
|
|
|
|
visible = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)orderFrontRegardless
|
|
|
|
{
|
|
|
|
visible = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)orderOut:sender
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
visible = NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)orderWindow:(NSWindowOrderingMode)place
|
|
|
|
relativeTo:(int)otherWin
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)resignKeyWindow
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
is_key = NO;
|
1996-07-10 20:43:47 +00:00
|
|
|
|
1997-03-05 01:11:17 +00:00
|
|
|
// Discard the cursor rects
|
|
|
|
[self discardCursorRects];
|
|
|
|
|
1996-07-10 20:43:47 +00:00
|
|
|
// Post notification
|
1996-10-03 18:45:41 +00:00
|
|
|
[nc postNotificationName: NSWindowDidResignKeyNotification object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)resignMainWindow
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
is_main = NO;
|
1996-07-10 20:43:47 +00:00
|
|
|
|
|
|
|
// Post notification
|
1996-10-03 18:45:41 +00:00
|
|
|
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setHidesOnDeactivate:(BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
hides_on_deactivate = flag;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setLevel:(int)newLevel
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
window_level = newLevel;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Moving and resizing the window
|
|
|
|
//
|
|
|
|
- (NSPoint)cascadeTopLeftFromPoint:(NSPoint)topLeftPoint
|
|
|
|
{
|
|
|
|
return NSZeroPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)center
|
|
|
|
{
|
|
|
|
float w, h;
|
|
|
|
NSRect n;
|
|
|
|
|
|
|
|
// Should use MBScreen
|
|
|
|
//w = MB_SCREEN_MAXWIDTH();
|
|
|
|
//h = MB_SCREEN_MAXHEIGHT();
|
|
|
|
n = frame;
|
|
|
|
n.origin.x = (w - frame.size.width) / 2;
|
|
|
|
n.origin.y = (h - frame.size.height) / 2;
|
|
|
|
[self setFrame:n display:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect)constrainFrameRect:(NSRect)frameRect
|
|
|
|
toScreen:screen
|
|
|
|
{
|
|
|
|
return NSZeroRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect)frame
|
|
|
|
{
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSSize)minSize
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return minimum_size;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSSize)maxSize
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return maximum_size;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setContentSize:(NSSize)aSize
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setFrame:(NSRect)frameRect
|
|
|
|
display:(BOOL)flag
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
frame = frameRect;
|
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
// post notification
|
|
|
|
[nc postNotificationName: NSWindowDidResizeNotification object: self];
|
|
|
|
|
|
|
|
// display if requested
|
1996-05-30 20:03:15 +00:00
|
|
|
if (!flag) return;
|
|
|
|
[self display];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setFrameOrigin:(NSPoint)aPoint
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
frame.origin = aPoint;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setFrameTopLeftPoint:(NSPoint)aPoint
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)setMinSize:(NSSize)aSize
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
minimum_size = aSize;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setMaxSize:(NSSize)aSize
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
maximum_size = aSize;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Converting coordinates
|
|
|
|
//
|
|
|
|
- (NSPoint)convertBaseToScreen:(NSPoint)aPoint
|
|
|
|
{
|
|
|
|
return NSZeroPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSPoint)convertScreenToBase:(NSPoint)aPoint
|
|
|
|
{
|
|
|
|
return NSZeroPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing the display
|
|
|
|
//
|
|
|
|
- (void)display
|
|
|
|
{
|
|
|
|
visible = YES;
|
|
|
|
|
|
|
|
// Tell the first responder that it is the first responder
|
|
|
|
// So it can set the focus to itself
|
|
|
|
[first_responder becomeFirstResponder];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)disableFlushWindow
|
|
|
|
{
|
|
|
|
disable_flush_window = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)displayIfNeeded
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
if (needs_display)
|
|
|
|
[self display];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)enableFlushWindow
|
|
|
|
{
|
|
|
|
disable_flush_window = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)flushWindow
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)flushWindowIfNeeded
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
if (!disable_flush_window && needs_flush)
|
1996-10-03 18:45:41 +00:00
|
|
|
[self flushWindow];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (BOOL)isAutodisplay
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return is_autodisplay;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isFlushWindowDisabled
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return disable_flush_window;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setAutoDisplay:(BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
is_autodisplay = flag;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setViewsNeedDisplay:(BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
views_need_display = flag;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)update
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
|
|
[nc postNotificationName: NSWindowDidUpdateNotification object: self];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)useOptimizedDrawing:(BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
optimize_drawing = flag;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (BOOL)viewsNeedDisplay
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return views_need_display;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Screens and window depths
|
1996-08-22 18:51:08 +00:00
|
|
|
- (BOOL)canStoreColor
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
// If the depth is greater than a single bit
|
|
|
|
if (depth_limit > 1)
|
|
|
|
return YES;
|
|
|
|
else
|
|
|
|
return NO;
|
1996-08-22 18:51:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSScreen *)deepestScreen
|
|
|
|
{
|
|
|
|
return [NSScreen deepestScreen];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSWindowDepth)depthLimit
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return depth_limit;
|
1996-08-22 18:51:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)hasDynamicDepthLimit
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return dynamic_depth_limit;
|
1996-08-22 18:51:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSScreen *)screen
|
|
|
|
{
|
|
|
|
return [NSScreen mainScreen];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setDepthLimit:(NSWindowDepth)limit
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
depth_limit = limit;
|
|
|
|
}
|
1996-08-22 18:51:08 +00:00
|
|
|
|
|
|
|
- (void)setDynamicDepthLimit:(BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
dynamic_depth_limit = flag;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Cursor management
|
|
|
|
//
|
|
|
|
- (BOOL)areCursorRectsEnabled
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return cursor_rects_enabled;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)disableCursorRects
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
cursor_rects_enabled = NO;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-03-05 01:11:17 +00:00
|
|
|
- (void)discardCursorRectsForView:(NSView *)theView
|
|
|
|
{
|
|
|
|
NSArray *s;
|
|
|
|
id e;
|
|
|
|
NSView *v;
|
|
|
|
|
|
|
|
// Discard for the view
|
|
|
|
[theView discardCursorRects];
|
|
|
|
|
|
|
|
// Discard for the view's subviews
|
|
|
|
s = [theView subviews];
|
|
|
|
e = [s objectEnumerator];
|
|
|
|
while ((v = [e nextObject]))
|
|
|
|
[self discardCursorRectsForView: v];
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)discardCursorRects
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
|
|
|
[self discardCursorRectsForView: content_view];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)enableCursorRects
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
cursor_rects_enabled = YES;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)invalidateCursorRectsForView:(NSView *)aView
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
|
|
|
cursor_rects_valid = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)resetCursorRectsForView:(NSView *)theView
|
|
|
|
{
|
|
|
|
NSArray *s;
|
|
|
|
id e;
|
|
|
|
NSView *v;
|
|
|
|
|
|
|
|
// Reset the view
|
|
|
|
[theView resetCursorRects];
|
|
|
|
|
|
|
|
// Reset the view's subviews
|
|
|
|
s = [theView subviews];
|
|
|
|
e = [s objectEnumerator];
|
|
|
|
while ((v = [e nextObject]))
|
|
|
|
[self resetCursorRectsForView: v];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)resetCursorRects
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
|
|
|
// Tell all the views to reset their cursor rects
|
|
|
|
[self resetCursorRectsForView: content_view];
|
|
|
|
|
|
|
|
// Cursor rects are now valid
|
|
|
|
cursor_rects_valid = YES;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Handling user actions and events
|
|
|
|
//
|
|
|
|
- (void)close
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Notify our delegate
|
1996-10-03 18:45:41 +00:00
|
|
|
[nc postNotificationName: NSWindowWillCloseNotification object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
[self performClose:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)deminiaturize:sender
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Set our flag to say we are not miniaturized
|
|
|
|
is_miniaturized = NO;
|
|
|
|
visible = YES;
|
|
|
|
|
1997-08-16 23:47:24 +00:00
|
|
|
[self performDeminiaturize:self];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Notify our delegate
|
1996-10-03 18:45:41 +00:00
|
|
|
[nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isDocumentEdited
|
|
|
|
{
|
|
|
|
return is_edited;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isReleasedWhenClosed
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return is_released_when_closed;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)miniaturize:sender
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Notify our delegate
|
1996-10-03 18:45:41 +00:00
|
|
|
[nc postNotificationName: NSWindowWillMiniaturizeNotification object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
[self performMiniaturize:self];
|
|
|
|
|
|
|
|
// Notify our delegate
|
1996-10-03 18:45:41 +00:00
|
|
|
[nc postNotificationName: NSWindowDidMiniaturizeNotification object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)performClose:sender
|
|
|
|
{
|
|
|
|
visible = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)performMiniaturize:sender
|
|
|
|
{
|
|
|
|
// Set our flag to say we are miniaturized
|
|
|
|
is_miniaturized = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int)resizeFlags
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setDocumentEdited:(BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
is_edited = flag;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setReleasedWhenClosed:(BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
is_released_when_closed = flag;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Aiding event handling
|
|
|
|
//
|
|
|
|
- (BOOL)acceptsMouseMovedEvents
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return accepts_mouse_moved;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSEvent *)currentEvent
|
|
|
|
{
|
|
|
|
NSApplication *theApp = [NSApplication sharedApplication];
|
|
|
|
|
|
|
|
return [theApp currentEvent];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)discardEventsMatchingMask:(unsigned int)mask
|
|
|
|
beforeEvent:(NSEvent *)lastEvent
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
NSApplication *theApp = [NSApplication sharedApplication];
|
|
|
|
|
|
|
|
[theApp discardEventsMatchingMask: mask beforeEvent: lastEvent];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (NSResponder *)firstResponder
|
|
|
|
{
|
|
|
|
return first_responder;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)keyDown:(NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
// save the first responder so that the key up
|
|
|
|
// goes to it and not a possible new first responder
|
|
|
|
original_responder = first_responder;
|
|
|
|
|
|
|
|
// Send the first responder the key down
|
|
|
|
[first_responder keyDown:theEvent];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)makeFirstResponder:(NSResponder *)aResponder
|
|
|
|
{
|
|
|
|
// If already the first responder then return
|
|
|
|
if (first_responder == aResponder)
|
|
|
|
return YES;
|
|
|
|
|
1996-07-10 20:43:47 +00:00
|
|
|
// If not a NSResponder then forget it
|
1996-05-30 20:03:15 +00:00
|
|
|
if (![aResponder isKindOfClass:[NSResponder class]])
|
|
|
|
return NO;
|
|
|
|
|
1996-07-10 20:43:47 +00:00
|
|
|
// Does it accept the first responder?
|
1996-05-30 20:03:15 +00:00
|
|
|
if (![aResponder acceptsFirstResponder])
|
|
|
|
return NO;
|
|
|
|
|
1996-07-10 20:43:47 +00:00
|
|
|
// Notify current first responder that it should resign
|
|
|
|
// If it says NO then no change
|
|
|
|
// But make sure that there even is a first responder
|
1997-08-16 23:47:24 +00:00
|
|
|
if ((first_responder) && (![first_responder resignFirstResponder]))
|
1996-05-30 20:03:15 +00:00
|
|
|
return NO;
|
|
|
|
|
1996-07-10 20:43:47 +00:00
|
|
|
// Make it the first responder
|
1996-05-30 20:03:15 +00:00
|
|
|
first_responder = aResponder;
|
|
|
|
|
|
|
|
// Notify it that it just became the first responder
|
|
|
|
[first_responder becomeFirstResponder];
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSPoint)mouseLocationOutsideOfEventStream
|
|
|
|
{
|
|
|
|
return NSZeroPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSApplication *theApp = [NSApplication sharedApplication];
|
|
|
|
return [theApp nextEventMatchingMask: mask untilDate: nil
|
1997-04-22 18:23:58 +00:00
|
|
|
inMode:NSEventTrackingRunLoopMode dequeue: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
|
|
|
|
untilDate:(NSDate *)expiration
|
1996-07-10 20:43:47 +00:00
|
|
|
inMode:(NSString *)mode
|
1996-05-30 20:03:15 +00:00
|
|
|
dequeue:(BOOL)deqFlag
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSApplication *theApp = [NSApplication sharedApplication];
|
|
|
|
return [theApp nextEventMatchingMask: mask untilDate: expiration
|
|
|
|
inMode: mode dequeue: deqFlag];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)postEvent:(NSEvent *)event
|
|
|
|
atStart:(BOOL)flag
|
|
|
|
{
|
|
|
|
NSApplication *theApp = [NSApplication sharedApplication];
|
|
|
|
|
|
|
|
[theApp postEvent:event atStart:flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setAcceptsMouseMovedEvents:(BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
{
|
|
|
|
accepts_mouse_moved = flag;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)checkTrackingRectangles:(NSView *)theView forEvent:(NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
NSArray *tr = [theView trackingRectangles];
|
|
|
|
NSArray *sb = [theView subviews];
|
|
|
|
TrackingRectangle *r;
|
|
|
|
int i, j;
|
|
|
|
BOOL last, now;
|
|
|
|
NSEvent *e;
|
|
|
|
|
|
|
|
// Loop through tracking rectangles
|
|
|
|
j = [tr count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
r = (TrackingRectangle *)[tr objectAtIndex:i];
|
|
|
|
// Check mouse at last point
|
|
|
|
last = [theView mouse:last_point inRect:[r rectangle]];
|
|
|
|
// Check mouse at current point
|
|
|
|
now = [theView mouse:[theEvent locationInWindow] inRect:[r rectangle]];
|
|
|
|
|
|
|
|
// Mouse entered event
|
|
|
|
if ((!last) && (now))
|
|
|
|
{
|
1997-03-05 01:11:17 +00:00
|
|
|
id owner = [r owner];
|
1996-05-30 20:03:15 +00:00
|
|
|
e = [NSEvent enterExitEventWithType:NSMouseEntered
|
|
|
|
location:[theEvent locationInWindow]
|
|
|
|
modifierFlags:[theEvent modifierFlags]
|
|
|
|
timestamp:0 windowNumber:[theEvent windowNumber]
|
|
|
|
context:NULL eventNumber:0
|
|
|
|
trackingNumber:[r tag] userData:[r userData]];
|
1997-03-05 01:11:17 +00:00
|
|
|
// Send the event to the owner
|
|
|
|
if ([owner respondsToSelector:@selector(mouseEntered:)])
|
|
|
|
[owner mouseEntered:e];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mouse exited event
|
|
|
|
if ((last) && (!now))
|
|
|
|
{
|
1997-03-05 01:11:17 +00:00
|
|
|
id owner = [r owner];
|
1996-05-30 20:03:15 +00:00
|
|
|
e = [NSEvent enterExitEventWithType:NSMouseExited
|
|
|
|
location:[theEvent locationInWindow]
|
|
|
|
modifierFlags:[theEvent modifierFlags]
|
|
|
|
timestamp:0 windowNumber:[theEvent windowNumber]
|
|
|
|
context:NULL eventNumber:0
|
|
|
|
trackingNumber:[r tag] userData:[r userData]];
|
1997-03-05 01:11:17 +00:00
|
|
|
// Send the event to the owner
|
|
|
|
if ([owner respondsToSelector:@selector(mouseExited:)])
|
|
|
|
[owner mouseExited:e];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the tracking rectangles for the subviews
|
|
|
|
j = [sb count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
[self checkTrackingRectangles:[sb objectAtIndex:i] forEvent:theEvent];
|
|
|
|
}
|
|
|
|
|
1997-03-05 01:11:17 +00:00
|
|
|
- (void)checkCursorRectangles:(NSView *)theView forEvent:(NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
NSArray *tr = [theView cursorRectangles];
|
|
|
|
NSArray *sb = [theView subviews];
|
|
|
|
TrackingRectangle *r;
|
|
|
|
int i, j;
|
|
|
|
BOOL last, now;
|
|
|
|
NSEvent *e;
|
|
|
|
NSPoint loc = [theEvent locationInWindow];
|
1997-08-18 17:10:23 +00:00
|
|
|
NSPoint lastPointConverted;
|
|
|
|
NSPoint locationConverted;
|
|
|
|
NSRect rect;
|
1997-03-05 01:11:17 +00:00
|
|
|
|
|
|
|
// Loop through cursor rectangles
|
|
|
|
j = [tr count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
// Convert cursor rectangle to window coordinates
|
|
|
|
r = (TrackingRectangle *)[tr objectAtIndex:i];
|
1997-08-18 17:10:23 +00:00
|
|
|
|
|
|
|
lastPointConverted = [theView convertPoint:last_point fromView:nil];
|
|
|
|
locationConverted = [theView convertPoint:loc fromView:nil];
|
|
|
|
|
1997-03-05 01:11:17 +00:00
|
|
|
// Check mouse at last point
|
1997-08-18 17:10:23 +00:00
|
|
|
rect = [r rectangle];
|
|
|
|
last = [theView mouse:lastPointConverted inRect:rect];
|
|
|
|
now = [theView mouse:locationConverted inRect:rect];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
|
|
|
// Mouse entered
|
|
|
|
if ((!last) && (now))
|
|
|
|
{
|
|
|
|
// Post cursor update event
|
|
|
|
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
|
|
|
location: loc
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
timestamp: 0
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
context: [theEvent context]
|
|
|
|
eventNumber: 0
|
|
|
|
trackingNumber: (int)YES
|
|
|
|
userData: (void *)r];
|
|
|
|
[self postEvent: e atStart: YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mouse exited event
|
|
|
|
if ((last) && (!now))
|
|
|
|
{
|
|
|
|
// Post cursor update event
|
|
|
|
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
|
|
|
location: loc
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
timestamp: 0
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
context: [theEvent context]
|
|
|
|
eventNumber: 0
|
|
|
|
trackingNumber: (int)NO
|
|
|
|
userData: (void *)r];
|
|
|
|
[self postEvent: e atStart: YES];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the cursor rectangles for the subviews
|
|
|
|
j = [sb count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
[self checkCursorRectangles:[sb objectAtIndex:i] forEvent:theEvent];
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)sendEvent:(NSEvent *)theEvent
|
|
|
|
{
|
1997-03-05 01:11:17 +00:00
|
|
|
// If the cursor rects are invalid
|
|
|
|
// Then discard and reset
|
|
|
|
if (!cursor_rects_valid)
|
|
|
|
{
|
|
|
|
[self discardCursorRects];
|
|
|
|
[self resetCursorRects];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
switch ([theEvent type])
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Mouse events
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Left mouse down
|
|
|
|
//
|
|
|
|
case NSLeftMouseDown:
|
|
|
|
{
|
|
|
|
NSView *v = [content_view hitTest:[theEvent locationInWindow]];
|
1997-03-05 01:11:17 +00:00
|
|
|
NSDebugLog([v description]);
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
[v mouseDown:theEvent];
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Left mouse up
|
|
|
|
//
|
|
|
|
case NSLeftMouseUp:
|
|
|
|
{
|
|
|
|
NSView *v = [content_view hitTest:[theEvent locationInWindow]];
|
|
|
|
[v mouseUp:theEvent];
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Right mouse down
|
|
|
|
//
|
|
|
|
case NSRightMouseDown:
|
|
|
|
{
|
|
|
|
NSView *v = [content_view hitTest:[theEvent locationInWindow]];
|
|
|
|
[v rightMouseDown:theEvent];
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Right mouse up
|
|
|
|
//
|
|
|
|
case NSRightMouseUp:
|
|
|
|
{
|
|
|
|
NSView *v = [content_view hitTest:[theEvent locationInWindow]];
|
|
|
|
[v rightMouseUp:theEvent];
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Mouse moved
|
|
|
|
//
|
|
|
|
case NSMouseMoved:
|
|
|
|
{
|
|
|
|
NSView *v = [content_view hitTest:[theEvent locationInWindow]];
|
|
|
|
|
|
|
|
// First send the NSMouseMoved event
|
|
|
|
[v mouseMoved:theEvent];
|
|
|
|
|
|
|
|
// We need to go through all of the views, and any with
|
|
|
|
// a tracking rectangle then we need to determine if we
|
|
|
|
// should send a NSMouseEntered or NSMouseExited event
|
|
|
|
[self checkTrackingRectangles:content_view forEvent:theEvent];
|
|
|
|
|
1997-03-05 01:11:17 +00:00
|
|
|
// We need to go through all of the views, and any with
|
|
|
|
// a cursor rectangle then we need to determine if we
|
|
|
|
// should send a cursor update event
|
|
|
|
// We only do this if we are the key window
|
|
|
|
if ([self isKeyWindow])
|
|
|
|
[self checkCursorRectangles: content_view forEvent: theEvent];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Left mouse dragged
|
|
|
|
//
|
|
|
|
case NSLeftMouseDragged:
|
|
|
|
{
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Right mouse dragged
|
|
|
|
//
|
|
|
|
case NSRightMouseDragged:
|
|
|
|
{
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Mouse entered
|
|
|
|
//
|
|
|
|
case NSMouseEntered:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Mouse exited
|
|
|
|
//
|
|
|
|
case NSMouseExited:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Keyboard events
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Key down
|
|
|
|
//
|
|
|
|
case NSKeyDown:
|
|
|
|
{
|
|
|
|
[self keyDown:theEvent];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Key up
|
|
|
|
//
|
|
|
|
case NSKeyUp:
|
|
|
|
{
|
|
|
|
// send message to object that got the key down
|
|
|
|
if (original_responder)
|
|
|
|
[original_responder keyUp:theEvent];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Miscellaneous events
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Flags changed
|
|
|
|
//
|
|
|
|
case NSFlagsChanged:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Cursor update
|
|
|
|
//
|
|
|
|
case NSCursorUpdate:
|
|
|
|
{
|
1997-03-05 01:11:17 +00:00
|
|
|
// Is it a mouse entered
|
|
|
|
if ([theEvent trackingNumber])
|
|
|
|
{
|
|
|
|
// push the cursor
|
|
|
|
TrackingRectangle *r = (TrackingRectangle *)[theEvent userData];
|
|
|
|
NSCursor *c = (NSCursor *)[r owner];
|
|
|
|
[c push];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// it is a mouse exited
|
|
|
|
// so pop the cursor
|
|
|
|
[NSCursor pop];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
break;
|
|
|
|
}
|
1997-02-18 00:29:25 +00:00
|
|
|
case NSPeriodic:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)tryToPerform:(SEL)anAction with:anObject
|
|
|
|
{
|
|
|
|
return ([super tryToPerform:anAction with:anObject]);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)worksWhenModal
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Dragging
|
|
|
|
//
|
|
|
|
- (void)dragImage:(NSImage *)anImage
|
|
|
|
at:(NSPoint)baseLocation
|
1996-07-10 20:43:47 +00:00
|
|
|
offset:(NSSize)initialOffset
|
|
|
|
event:(NSEvent *)event
|
|
|
|
pasteboard:(NSPasteboard *)pboard
|
|
|
|
source:sourceObject
|
|
|
|
slideBack:(BOOL)slideFlag
|
1996-05-30 20:03:15 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)registerForDraggedTypes:(NSArray *)newTypes
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)unregisterDraggedTypes
|
|
|
|
{}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Services and windows menu support
|
|
|
|
//
|
|
|
|
- (BOOL)isExcludedFromWindowsMenu
|
|
|
|
{
|
|
|
|
return menu_exclude;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setExcludedFromWindowsMenu:(BOOL)flag
|
|
|
|
{
|
|
|
|
menu_exclude = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
- validRequestorForSendType:(NSString *)sendType
|
|
|
|
returnType:(NSString *)returnType
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Saving and restoring the frame
|
|
|
|
//
|
|
|
|
- (NSString *)frameAutosaveName
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)saveFrameUsingName:(NSString *)name
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (BOOL)setFrameAutosaveName:(NSString *)name
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setFrameFromString:(NSString *)string
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (BOOL)setFrameUsingName:(NSString *)name
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)stringWithSavedFrame
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Printing and postscript
|
|
|
|
//
|
1996-10-03 18:45:41 +00:00
|
|
|
- (NSData *)dataWithEPSInsideRect:(NSRect)rect
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)fax:sender
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)print:sender
|
|
|
|
{}
|
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
- (void)_setNeedsFlush:(BOOL)flag { needs_flush = flag; }
|
|
|
|
- (BOOL)_needsFlush { return needs_flush; }
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Assigning a delegate
|
|
|
|
//
|
|
|
|
- delegate
|
|
|
|
{
|
|
|
|
return delegate;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setDelegate:anObject
|
|
|
|
{
|
|
|
|
delegate = anObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Implemented by the delegate
|
|
|
|
//
|
|
|
|
- (BOOL)windowShouldClose:sender
|
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowShouldClose:)])
|
1996-05-30 20:03:15 +00:00
|
|
|
return [delegate windowShouldClose:sender];
|
|
|
|
else
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSSize)windowWillResize:(NSWindow *)sender
|
|
|
|
toSize:(NSSize)frameSize
|
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowWillResize:toSize:)])
|
1996-05-30 20:03:15 +00:00
|
|
|
return [delegate windowWillResize:sender toSize:frameSize];
|
|
|
|
else
|
|
|
|
return frameSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
- windowWillReturnFieldEditor:(NSWindow *)sender
|
|
|
|
toObject:client
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidBecomeKey:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidBecomeKey:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidBecomeKey:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidBecomeMain:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidBecomeMain:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidBecomeMain:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidChangeScreen:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidChangeScreen:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidChangeScreen:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidDeminiaturize:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidDeminiaturize:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidDeminiaturize:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidExpose:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidExpose:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidExpose:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidMiniaturize:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidMiniaturize:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidMiniaturize:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidMove:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidMove:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidMove:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidResignKey:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidResignKey:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidResignKey:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidResignMain:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidResignMain:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidResignMain:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidResize:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidResize:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidResize:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowDidUpdate:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowDidUpdate:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowDidUpdate:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowWillClose:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowWillClose:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowWillClose:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowWillMiniaturize:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowWillMiniaturize:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowWillMiniaturize:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)windowWillMove:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(windowWillMove:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
return [delegate windowWillMove:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// NSCoding protocol
|
|
|
|
//
|
|
|
|
- (void)encodeWithCoder:aCoder
|
|
|
|
{
|
|
|
|
[self setNextResponder: nil];
|
|
|
|
|
|
|
|
[super encodeWithCoder:aCoder];
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSWindow: start encoding\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeRect:frame];
|
|
|
|
[aCoder encodeObject:content_view];
|
|
|
|
// [aCoder encodeObjectReference: first_responder withName:NULL];
|
|
|
|
// [aCoder encodeObjectReference: original_responder withName:NULL];
|
|
|
|
// [aCoder encodeObjectReference: delegate withName:NULL];
|
|
|
|
[aCoder encodeValueOfObjCType:"i" at:&window_num];
|
|
|
|
[aCoder encodeObject:background_color];
|
|
|
|
[aCoder encodeObject:represented_filename];
|
|
|
|
[aCoder encodeObject:miniaturized_title];
|
|
|
|
[aCoder encodeObject:window_title];
|
|
|
|
[aCoder encodePoint:last_point];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &visible];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_key];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_main];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_edited];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_miniaturized];
|
|
|
|
[aCoder encodeValueOfObjCType:"I" at: &style_mask];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &menu_exclude];
|
1996-12-05 13:07:59 +00:00
|
|
|
|
|
|
|
// Version 2
|
|
|
|
[aCoder encodeSize:minimum_size];
|
|
|
|
[aCoder encodeSize:maximum_size];
|
|
|
|
[aCoder encodeObject:miniaturized_image];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(NSBackingStoreType) at: &backing_type];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(int) at: &window_level];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_one_shot];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_autodisplay];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &optimize_drawing];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(NSWindowDepth) at: &depth_limit];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &dynamic_depth_limit];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &cursor_rects_enabled];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_released_when_closed];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &disable_flush_window];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &hides_on_deactivate];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &accepts_mouse_moved];
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSWindow: finish encoding\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- initWithCoder:aDecoder
|
|
|
|
{
|
|
|
|
NSApplication *theApp;
|
|
|
|
|
|
|
|
[super initWithCoder:aDecoder];
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSWindow: start decoding\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
frame = [aDecoder decodeRect];
|
|
|
|
content_view = [aDecoder decodeObject];
|
|
|
|
// [aDecoder decodeObjectAt: &first_responder withName:NULL];
|
|
|
|
// [aDecoder decodeObjectAt: &original_responder withName:NULL];
|
|
|
|
// [aDecoder decodeObjectAt: &delegate withName:NULL];
|
|
|
|
[aDecoder decodeValueOfObjCType:"i" at:&window_num];
|
|
|
|
background_color = [aDecoder decodeObject];
|
|
|
|
represented_filename = [aDecoder decodeObject];
|
|
|
|
miniaturized_title = [aDecoder decodeObject];
|
|
|
|
window_title = [aDecoder decodeObject];
|
|
|
|
last_point = [aDecoder decodePoint];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &visible];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_key];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_main];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_edited];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_miniaturized];
|
|
|
|
[aDecoder decodeValueOfObjCType:"I" at: &style_mask];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &menu_exclude];
|
|
|
|
|
1996-12-05 13:07:59 +00:00
|
|
|
// Version 2
|
|
|
|
minimum_size = [aDecoder decodeSize];
|
|
|
|
maximum_size = [aDecoder decodeSize];
|
|
|
|
miniaturized_image = [aDecoder decodeObject];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(NSBackingStoreType)
|
|
|
|
at: &backing_type];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(int) at: &window_level];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_one_shot];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_autodisplay];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &optimize_drawing];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(NSWindowDepth) at: &depth_limit];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &dynamic_depth_limit];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &cursor_rects_enabled];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_released_when_closed];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &disable_flush_window];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &hides_on_deactivate];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &accepts_mouse_moved];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Register ourselves with the Application object
|
1996-06-21 15:08:08 +00:00
|
|
|
// +++ we shouldn't do this because coding may not be done?
|
|
|
|
// better to do it in the awakeFromCoder method
|
1996-05-30 20:03:15 +00:00
|
|
|
theApp = [NSApplication sharedApplication];
|
|
|
|
[theApp addWindowsItem:self title:nil filename:NO];
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSWindow: finish decoding\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
@end
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1996-10-03 18:45:41 +00:00
|
|
|
// GNUstep backend methods
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1996-10-03 18:45:41 +00:00
|
|
|
@implementation NSWindow (GNUstepBackend)
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
+ (NSWindow*)windowWithNumber:(int)windowNumber
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Mouse capture/release
|
|
|
|
//
|
|
|
|
- (void)captureMouse: sender
|
|
|
|
{
|
|
|
|
// Do nothing, should be overridden by back-end
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)releaseMouse: sender
|
|
|
|
{
|
|
|
|
// Do nothing, should be overridden by back-end
|
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
// Allow subclasses to init without the backend class
|
|
|
|
// attempting to create an actual window
|
1996-10-03 18:45:41 +00:00
|
|
|
- (void)initDefaults
|
|
|
|
{
|
|
|
|
first_responder = nil;
|
|
|
|
original_responder = nil;
|
|
|
|
delegate = nil;
|
|
|
|
window_num = 0;
|
1997-07-07 16:56:52 +00:00
|
|
|
background_color = [[NSColor lightGrayColor] retain];
|
1996-10-03 18:45:41 +00:00
|
|
|
represented_filename = @"Window";
|
|
|
|
miniaturized_title = @"Window";
|
|
|
|
miniaturized_image = nil;
|
|
|
|
window_title = @"Window";
|
|
|
|
last_point = NSZeroPoint;
|
|
|
|
window_level = NSNormalWindowLevel;
|
|
|
|
|
|
|
|
is_one_shot = NO;
|
|
|
|
needs_display = NO;
|
|
|
|
is_autodisplay = YES;
|
|
|
|
optimize_drawing = YES;
|
|
|
|
views_need_display = NO;
|
|
|
|
depth_limit = 8;
|
|
|
|
dynamic_depth_limit = YES;
|
|
|
|
cursor_rects_enabled = NO;
|
|
|
|
visible = NO;
|
|
|
|
is_key = NO;
|
|
|
|
is_main = NO;
|
|
|
|
is_edited = NO;
|
|
|
|
is_released_when_closed = NO;
|
|
|
|
is_miniaturized = NO;
|
|
|
|
disable_flush_window = NO;
|
|
|
|
menu_exclude = NO;
|
|
|
|
hides_on_deactivate = NO;
|
|
|
|
accepts_mouse_moved = YES;
|
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- cleanInit
|
|
|
|
{
|
|
|
|
[super init];
|
1996-10-03 18:45:41 +00:00
|
|
|
|
|
|
|
[self initDefaults];
|
1996-09-12 19:24:32 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
1997-08-16 23:47:24 +00:00
|
|
|
- (void)performDeminiaturize:sender
|
|
|
|
{
|
|
|
|
// Do nothing, should be overridden by back-end
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)performHide:sender
|
|
|
|
{
|
|
|
|
// Do nothing, should be overridden by back-end
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)performUnhide:sender
|
|
|
|
{
|
|
|
|
// Do nothing, should be overridden by back-end
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
@end
|