merged to trunk current status

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/themes@23385 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicolas Roard 2006-09-03 16:41:10 +00:00
parent 64dac156e8
commit 296a0bd206
87 changed files with 4164 additions and 2031 deletions

View file

@ -303,6 +303,8 @@ NSSavePanel.h \
NSScreen.h \ NSScreen.h \
NSScrollView.h \ NSScrollView.h \
NSScroller.h \ NSScroller.h \
NSSearchField.h \
NSSearchFieldCell.h \
NSSecureTextField.h \ NSSecureTextField.h \
NSSelection.h \ NSSelection.h \
NSSlider.h \ NSSlider.h \

View file

@ -80,7 +80,7 @@ GSServerForWindow(NSWindow *window)
/* Backend window hasn't been initialized yet, assume current server. */ /* Backend window hasn't been initialized yet, assume current server. */
return GSCurrentServer(); return GSCurrentServer();
} }
return NSMapGet(windowmaps, (void *)num); return NSMapGet(windowmaps, (void *)(intptr_t)num);
} }
/** Returns the current GSDisplayServer */ /** Returns the current GSDisplayServer */
@ -511,7 +511,7 @@ GSCurrentServer(void)
for a window that has already been created */ for a window that has already been created */
- (void) _setWindowOwnedByServer: (int)win - (void) _setWindowOwnedByServer: (int)win
{ {
NSMapInsert (windowmaps, (void*)win, self); NSMapInsert (windowmaps, (void*)(intptr_t)win, self);
} }
/** Creates a window whose location and size is described by frame and /** Creates a window whose location and size is described by frame and

View file

@ -543,7 +543,7 @@ static GSDragView *sharedDragView = nil;
NSEvent *e; NSEvent *e;
NSGraphicsContext *context = GSCurrentContext(); NSGraphicsContext *context = GSCurrentContext();
// FIXME: Should store this once // FIXME: Should store this once
int dragWindowRef = (int)[GSServerForWindow(_window) windowDevice: [_window windowNumber]]; int dragWindowRef = (int)(intptr_t)[GSServerForWindow(_window) windowDevice: [_window windowNumber]];
eventLocation = [dWindow convertScreenToBase: eventLocation]; eventLocation = [dWindow convertScreenToBase: eventLocation];
e = [NSEvent otherEventWithType: NSAppKitDefined e = [NSEvent otherEventWithType: NSAppKitDefined

View file

@ -160,15 +160,31 @@ enablingXResizing: (BOOL)aFlag
-(void) encodeWithCoder: (NSCoder*)aCoder -(void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews]; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin]; {
[aCoder encodeBool: _haveViews forKey: @"GSHaveViews"];
[aCoder encodeFloat: _defaultMinXMargin forKey: @"GSDefaultMinXMargin"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
[aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin];
}
} }
-(id) initWithCoder: (NSCoder*)aDecoder -(id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews]; if([aDecoder allowsKeyedCoding])
[aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin]; {
_haveViews = [aDecoder decodeBoolForKey: @"GSHaveViews"];
_defaultMinXMargin = [aDecoder decodeFloatForKey: @"GSDefaultMinXMargin"];
}
else
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin];
}
return self; return self;
} }
@end @end

View file

@ -28,11 +28,14 @@
#include "AppKit/NSApplication.h" #include "AppKit/NSApplication.h"
#include "AppKit/NSAttributedString.h" #include "AppKit/NSAttributedString.h"
#include "AppKit/NSTextView.h" #include "AppKit/NSTextView.h"
#include "AppKit/NSTextContainer.h"
#include "AppKit/NSScrollView.h" #include "AppKit/NSScrollView.h"
#include "AppKit/NSButton.h"
#include "AppKit/NSClipView.h" #include "AppKit/NSClipView.h"
#include "AppKit/NSColor.h" #include "AppKit/NSColor.h"
#include "AppKit/NSImage.h"
#include "GNUstepGUI/GSHelpManagerPanel.h" #include "GNUstepGUI/GSHelpManagerPanel.h"
#include "GSGuiPrivate.h"
@implementation GSHelpManagerPanel @implementation GSHelpManagerPanel
@ -46,68 +49,87 @@ static GSHelpManagerPanel* _GSsharedGSHelpPanel;
return _GSsharedGSHelpPanel; return _GSsharedGSHelpPanel;
} }
/* This window should not be destroyed... So we don't allow it to! */ - (id)init
- (id) retain
{ {
return self; self = [super initWithContentRect: NSMakeRect(100, 100, 470, 200)
} styleMask: NSTitledWindowMask | NSResizableWindowMask
backing: NSBackingStoreRetained
- (void) release defer: NO];
{
}
- (id) autorelease
{
return self;
}
- (id) init
{
NSScrollView *scrollView;
NSRect scrollViewRect = {{0, 0}, {470, 150}};
NSRect winRect = {{100, 100}, {470, 150}};
unsigned int style = NSTitledWindowMask | NSClosableWindowMask
| NSMiniaturizableWindowMask | NSResizableWindowMask;
[self initWithContentRect: winRect if (self) {
styleMask: style NSRect scrollViewRect = {{8, 40}, {454, 152}};
backing: NSBackingStoreRetained NSRect buttonRect = {{390, 6}, {72, 27}};
defer: NO]; NSRect r;
[self setFloatingPanel: YES]; NSScrollView *scrollView;
[self setRepresentedFilename: @"Help"]; NSButton *button;
[self setTitle: @"Help"];
[self setDocumentEdited: NO]; [self setReleasedWhenClosed: NO];
[self setFloatingPanel: YES];
scrollView = [[NSScrollView alloc] initWithFrame: scrollViewRect]; [self setTitle: NSLocalizedString(@"Help", @"")];
[scrollView setHasHorizontalScroller: NO];
[scrollView setHasVerticalScroller: YES]; scrollView = [[NSScrollView alloc] initWithFrame: scrollViewRect];
[scrollView setAutoresizingMask: NSViewHeightSizable]; [scrollView setBorderType: NSBezelBorder];
[scrollView setHasHorizontalScroller: NO];
textView = [[NSTextView alloc] initWithFrame: [scrollView setHasVerticalScroller: YES];
[[scrollView contentView] frame]]; [scrollView setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
[textView setEditable: NO];
[textView setRichText: YES]; r = [[scrollView contentView] frame];
[textView setSelectable: YES]; textView = [[NSTextView alloc] initWithFrame: r];
// off white [textView setRichText: YES];
[textView setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.85 [textView setEditable: NO];
alpha: 1.0]]; [textView setSelectable: NO];
[scrollView setDocumentView: textView]; [textView setHorizontallyResizable: NO];
[[self contentView] addSubview: scrollView]; [textView setVerticallyResizable: YES];
RELEASE(scrollView); [textView setMinSize: NSMakeSize (0, 0)];
[textView setMaxSize: NSMakeSize (1E7, 1E7)];
[textView setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
[[textView textContainer] setContainerSize: NSMakeSize(r.size.width, 1e7)];
[[textView textContainer] setWidthTracksTextView: YES];
[textView setUsesRuler: NO];
[scrollView setDocumentView: textView];
RELEASE (textView);
[[self contentView] addSubview: scrollView];
RELEASE (scrollView);
button = [[NSButton alloc] initWithFrame: buttonRect];
[button setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
[button setButtonType: NSMomentaryLight];
[button setTitle: NSLocalizedString(@"OK", @"")];
[button setKeyEquivalent: @"\r"];
[button setImagePosition: NSImageRight];
[button setImage: [NSImage imageNamed: @"common_ret"]];
[button setAlternateImage: [NSImage imageNamed: @"common_retH"]];
[button setTarget: self];
[button setAction: @selector(buttonAction:)];
[[self contentView] addSubview: button];
RELEASE (button);
[self makeFirstResponder: button];
}
return self; return self;
} }
- (void) setHelpText: (NSAttributedString*) helpText - (void)setHelpText:(NSAttributedString *)helpText
{ {
// FIXME: The attributed text should be set, but there is [[textView textStorage] setAttributedString: helpText];
// no public method for this. }
[textView setText: [helpText string]];
- (void)buttonAction:(id)sender
{
[self close];
} }
- (void) close - (void) close
{ {
[NSApp stopModal]; if ([self isVisible])
{
[NSApp stopModal];
}
[super close]; [super close];
} }
@end @end

View file

@ -874,12 +874,14 @@ restart: ;
if (g->g == GSAttachmentGlyph) if (g->g == GSAttachmentGlyph)
{ {
NSTextAttachment *attach = [curTextStorage attribute: NSAttachmentAttributeName NSTextAttachment *attach;
atIndex: g->char_index NSTextAttachmentCell *cell;
effectiveRange: NULL];
NSTextAttachmentCell *cell = [attach attachmentCell];
NSRect r; NSRect r;
attach = [curTextStorage attribute: NSAttachmentAttributeName
atIndex: g->char_index
effectiveRange: NULL];
cell = (NSTextAttachmentCell*)[attach attachmentCell];
if (!cell) if (!cell)
{ {
g->pos = p; g->pos = p;

View file

@ -157,9 +157,9 @@ Private method used internally by GSLayoutManager for sanity checking.
h = (glyph_run_t *)(glyphs + SKIP_LIST_DEPTH - 1)->next; h = (glyph_run_t *)(glyphs + SKIP_LIST_DEPTH - 1)->next;
for (; h; h = (glyph_run_t *)h->head.next) for (; h; h = (glyph_run_t *)h->head.next)
{ {
printf("%08x %i chars, %i glyphs, %i complete, prev %08x next %08x\n", printf("%8p %i chars, %i glyphs, %i complete, prev %8p next %8p\n",
(int)h, h->head.char_length, h->head.glyph_length, h->head.complete, h, h->head.char_length, h->head.glyph_length, h->head.complete,
(int)h->prev, (int)h->head.next); h->prev, h->head.next);
printf(" level %i, continued %i\n", h->level, h->continued); printf(" level %i, continued %i\n", h->level, h->continued);
if (h->head.complete) if (h->head.complete)
{ {
@ -181,14 +181,14 @@ Private method used internally by GSLayoutManager for sanity checking.
printf(" head: "); printf(" head: ");
for (i = 0, h = glyphs + SKIP_LIST_DEPTH - 1; i < SKIP_LIST_DEPTH; i++, h--) for (i = 0, h = glyphs + SKIP_LIST_DEPTH - 1; i < SKIP_LIST_DEPTH; i++, h--)
printf("%8x %i %3i %3i|", (int)h->next, h->complete, h->char_length, h->glyph_length); printf("%8p %i %3i %3i|", h->next, h->complete, h->char_length, h->glyph_length);
printf("\n"); printf("\n");
h = (glyphs + SKIP_LIST_DEPTH - 1)->next; h = (glyphs + SKIP_LIST_DEPTH - 1)->next;
for (; h; h = h->next) for (; h; h = h->next)
{ {
printf("%8x: ", (int)h); printf("%8p: ", h);
for (g = h, i = ((glyph_run_t *)h)->level; i >= 0; i--, g--) for (g = h, i = ((glyph_run_t *)h)->level; i >= 0; i--, g--)
printf("%8x %i %3i %3i|", (int)g->next, g->complete, g->char_length, g->glyph_length); printf("%8p %i %3i %3i|", g->next, g->complete, g->char_length, g->glyph_length);
printf("\n"); printf("\n");
} }
} }

View file

@ -32,8 +32,10 @@
#include <Foundation/NSArchiver.h> #include <Foundation/NSArchiver.h>
#include <Foundation/NSArray.h> #include <Foundation/NSArray.h>
#include <Foundation/NSBundle.h> #include <Foundation/NSBundle.h>
#include <Foundation/NSByteOrder.h>
#include <Foundation/NSCoder.h> #include <Foundation/NSCoder.h>
#include <Foundation/NSData.h> #include <Foundation/NSData.h>
#include <Foundation/NSDecimalNumber.h>
#include <Foundation/NSDictionary.h> #include <Foundation/NSDictionary.h>
#include <Foundation/NSDebug.h> #include <Foundation/NSDebug.h>
#include <Foundation/NSEnumerator.h> #include <Foundation/NSEnumerator.h>
@ -52,6 +54,38 @@
#include <GNUstepGUI/GSNibCompatibility.h> #include <GNUstepGUI/GSNibCompatibility.h>
#include <GNUstepGUI/GSInstantiator.h> #include <GNUstepGUI/GSInstantiator.h>
static BOOL _isInInterfaceBuilder = NO;
@interface NSView (NibCompatibility)
- (void) _fixSubviews;
@end
@implementation NSView (NibCompatibility)
- (void) _setWindow: (id) w
{
ASSIGN(_window,w);
}
- (void) _fixSubviews
{
NSEnumerator *en = [[self subviews] objectEnumerator];
id v = nil;
while((v = [en nextObject]) != nil)
{
if([v window] != [self window] ||
[v superview] != self)
{
[v _setWindow: [self window]];
RETAIN(v);
[_sub_views removeObject: v];
[self addSubview: v];
RELEASE(v);
}
[v _fixSubviews];
}
}
@end
@implementation NSWindowTemplate @implementation NSWindowTemplate
+ (void) initialize + (void) initialize
{ {
@ -71,6 +105,48 @@
[super dealloc]; [super dealloc];
} }
- (id) initWithWindow: (NSWindow *)window
className: (NSString *)windowClass
isDeferred: (BOOL) deferred
isOneShot: (BOOL) oneShot
isVisible: (BOOL) visible
wantsToBeColor: (BOOL) wantsToBeColor
autoPositionMask: (int) autoPositionMask
{
if((self = [super init]) != nil)
{
if(window != nil)
{
// object members
ASSIGN(_title, [window title]);
ASSIGN(_viewClass, NSStringFromClass([[window contentView] class]));
ASSIGN(_windowClass, windowClass);
ASSIGN(_view, [window contentView]);
ASSIGN(_autosaveName, [window frameAutosaveName]);
// style & size
_windowStyle = [window styleMask];
_backingStoreType = [window backingType];
_maxSize = [window maxSize];
_minSize = [window minSize];
_windowRect = [window frame];
_screenRect = [[NSScreen mainScreen] frame];
// flags
_flags.isHiddenOnDeactivate = [window hidesOnDeactivate];
_flags.isNotReleasedOnClose = (![window isReleasedWhenClosed]);
_flags.isDeferred = deferred;
_flags.isOneShot = oneShot;
_flags.isVisible = visible;
_flags.wantsToBeColor = wantsToBeColor;
_flags.dynamicDepthLimit = [window hasDynamicDepthLimit];
_flags.autoPositionMask = autoPositionMask;
_flags.savePosition = YES; // not yet implemented.
}
}
return self;
}
- (id) initWithCoder: (NSCoder *)coder - (id) initWithCoder: (NSCoder *)coder
{ {
if ([coder allowsKeyedCoding]) if ([coder allowsKeyedCoding])
@ -110,7 +186,7 @@
} }
if ([coder containsValueForKey: @"NSWindowRect"]) if ([coder containsValueForKey: @"NSWindowRect"])
{ {
_windowRect = [coder decodeRectForKey: @"NSWindowRect"]; _windowRect = [coder decodeRectForKey: @"NSWindowRect"];
} }
if ([coder containsValueForKey: @"NSFrameAutosaveName"]) if ([coder containsValueForKey: @"NSFrameAutosaveName"])
{ {
@ -121,10 +197,12 @@
ASSIGN(_title, [coder decodeObjectForKey: @"NSWindowTitle"]); ASSIGN(_title, [coder decodeObjectForKey: @"NSWindowTitle"]);
_windowStyle |= NSTitledWindowMask; _windowStyle |= NSTitledWindowMask;
} }
_baseWindowClass = [NSWindow class];
} }
else else
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])]; NSStringFromClass([coder class])];
} }
@ -136,7 +214,8 @@
if ([aCoder allowsKeyedCoding]) if ([aCoder allowsKeyedCoding])
{ {
unsigned long flags = 0; unsigned long flags = 0;
NSRect rect = [NSWindow contentRectForFrameRect: _windowRect
styleMask: _windowStyle];
memcpy((void *)&flags,(void *)&_flags,sizeof(unsigned long)); memcpy((void *)&flags,(void *)&_flags,sizeof(unsigned long));
[aCoder encodeObject: _viewClass forKey: @"NSViewClass"]; [aCoder encodeObject: _viewClass forKey: @"NSViewClass"];
@ -147,7 +226,7 @@
[aCoder encodeInt: flags forKey: @"NSWTFlags"]; [aCoder encodeInt: flags forKey: @"NSWTFlags"];
[aCoder encodeSize: _minSize forKey: @"NSMinSize"]; [aCoder encodeSize: _minSize forKey: @"NSMinSize"];
[aCoder encodeSize: _maxSize forKey: @"NSMaxSize"]; [aCoder encodeSize: _maxSize forKey: @"NSMaxSize"];
[aCoder encodeRect: _windowRect forKey: @"NSWindowRect"]; [aCoder encodeRect: rect forKey: @"NSWindowRect"];
[aCoder encodeObject: _title forKey: @"NSWindowTitle"]; [aCoder encodeObject: _title forKey: @"NSWindowTitle"];
[aCoder encodeObject: _autosaveName forKey: @"NSFrameAutosaveName"]; [aCoder encodeObject: _autosaveName forKey: @"NSFrameAutosaveName"];
} }
@ -157,10 +236,19 @@
{ {
if(_realObject == nil) if(_realObject == nil)
{ {
Class aClass = NSClassFromString(_windowClass); Class aClass;
NSEnumerator *en; NSEnumerator *en;
id v = nil; id v = nil;
if([NSClassSwapper isInInterfaceBuilder])
{
aClass = [self baseWindowClass];
}
else
{
aClass = NSClassFromString(_windowClass);
}
if (aClass == nil) if (aClass == nil)
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
@ -192,7 +280,14 @@
[_realObject setMinSize: _minSize]; [_realObject setMinSize: _minSize];
[_realObject setMaxSize: _maxSize]; [_realObject setMaxSize: _maxSize];
[_realObject setTitle: _title]; [_realObject setTitle: _title];
[_view _fixSubviews];
// resize the window...
[_realObject setFrame: [NSWindow frameRectForContentRect: [self windowRect]
styleMask: [self windowStyle]]
display: NO];
// swap out any views which need to be swapped... // swap out any views which need to be swapped...
en = [[[_realObject contentView] subviews] objectEnumerator]; en = [[[_realObject contentView] subviews] objectEnumerator];
while((v = [en nextObject]) != nil) while((v = [en nextObject]) != nil)
@ -321,6 +416,11 @@
{ {
return _windowClass; return _windowClass;
} }
- (Class) baseWindowClass
{
return _baseWindowClass;
}
@end @end
// Template for any classes which derive from NSView // Template for any classes which derive from NSView
@ -345,7 +445,7 @@
} }
else else
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])]; NSStringFromClass([coder class])];
} }
@ -360,7 +460,7 @@
} }
} }
- (id)nibInstantiate - (id) nibInstantiate
{ {
if(_realObject == nil) if(_realObject == nil)
{ {
@ -482,7 +582,7 @@
@implementation NSCustomObject @implementation NSCustomObject
- (void) setClassName: (NSString *)name - (void) setClassName: (NSString *)name
{ {
ASSIGN(_className, name); ASSIGNCOPY(_className, name);
} }
- (NSString *)className - (NSString *)className
@ -492,7 +592,7 @@
- (void) setExtension: (NSString *)name - (void) setExtension: (NSString *)name
{ {
ASSIGN(_extension, name); ASSIGNCOPY(_extension, name);
} }
- (NSString *)extension - (NSString *)extension
@ -519,7 +619,7 @@
} }
else else
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])]; NSStringFromClass([coder class])];
} }
@ -533,13 +633,30 @@
[coder encodeObject: (id)_className forKey: @"NSClassName"]; [coder encodeObject: (id)_className forKey: @"NSClassName"];
[coder encodeConditionalObject: (id)_extension forKey: @"NSExtension"]; [coder encodeConditionalObject: (id)_extension forKey: @"NSExtension"];
} }
else
{
[NSException raise: NSInvalidArgumentException
format: @"Keyed coding not implemented for %@.",
NSStringFromClass([self class])];
}
} }
- (id) nibInstantiate - (id) nibInstantiate
{ {
if(_object == nil) if(_object == nil)
{ {
Class aClass = NSClassFromString(_className); Class aClass;
if([NSClassSwapper isInInterfaceBuilder])
{
aClass = [self class];
}
else
{
aClass = NSClassFromString(_className);
}
if(aClass == nil) if(aClass == nil)
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
@ -550,12 +667,19 @@
} }
return _object; return _object;
} }
- (void) dealloc
{
RELEASE(_className);
RELEASE(_extension);
[super dealloc];
}
@end @end
@implementation NSCustomView @implementation NSCustomView
- (void) setClassName: (NSString *)name - (void) setClassName: (NSString *)name
{ {
ASSIGN(_className, name); ASSIGNCOPY(_className, name);
} }
- (NSString *)className - (NSString *)className
@ -564,7 +688,7 @@
} }
- (void) setExtension: (NSString *)ext; - (void) setExtension: (NSString *)ext;
{ {
ASSIGN(_extension, ext); ASSIGNCOPY(_extension, ext);
} }
- (NSString *)extension - (NSString *)extension
@ -572,11 +696,21 @@
return _extension; return _extension;
} }
- (id)nibInstantiate - (id) nibInstantiate
{ {
if(_view == nil) if(_view == nil)
{ {
Class aClass = NSClassFromString(_className); Class aClass;
if([NSClassSwapper isInInterfaceBuilder])
{
aClass = [self class];
}
else
{
aClass = NSClassFromString(_className);
}
if(aClass == nil) if(aClass == nil)
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
@ -585,6 +719,8 @@
else else
{ {
_view = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]]; _view = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
[_view setAutoresizingMask: [self autoresizingMask]];
[_view setNextResponder: [self nextResponder]];
[[self superview] replaceSubview: self with: _view]; // replace the old view... [[self superview] replaceSubview: self with: _view]; // replace the old view...
} }
} }
@ -599,7 +735,14 @@
{ {
if([coder allowsKeyedCoding]) if([coder allowsKeyedCoding])
{ {
_className = [coder decodeObjectForKey: @"NSClassName"]; ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]);
ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]);
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
} }
} }
return self; return self;
@ -607,9 +750,17 @@
- (void) encodeWithCoder: (NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{ {
[super encodeWithCoder: coder];
if([coder allowsKeyedCoding]) if([coder allowsKeyedCoding])
{ {
[coder encodeObject: (id)_className forKey: @"NSClassName"]; [coder encodeObject: _className forKey: @"NSClassName"];
[coder encodeObject: _extension forKey: @"NSExtension"];
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
} }
} }
@end @end
@ -617,7 +768,7 @@
@implementation NSCustomResource @implementation NSCustomResource
- (void) setClassName: (NSString *)className - (void) setClassName: (NSString *)className
{ {
ASSIGN(_className, className); ASSIGNCOPY(_className, className);
} }
- (NSString *)className - (NSString *)className
@ -627,7 +778,7 @@
- (void) setResourceName: (NSString *)resourceName - (void) setResourceName: (NSString *)resourceName
{ {
ASSIGN(_resourceName, resourceName); ASSIGNCOPY(_resourceName, resourceName);
} }
- (NSString *)resourceName - (NSString *)resourceName
@ -651,11 +802,11 @@
// this is a hack, but for now it should do. // this is a hack, but for now it should do.
if([_className isEqual: @"NSSound"]) if([_className isEqual: @"NSSound"])
{ {
realObject = [NSSound soundNamed: _resourceName]; realObject = RETAIN([NSSound soundNamed: _resourceName]);
} }
else if([_className isEqual: @"NSImage"]) else if([_className isEqual: @"NSImage"])
{ {
realObject = [NSImage imageNamed: _resourceName]; realObject = RETAIN([NSImage imageNamed: _resourceName]);
} }
// if an object has been substituted, then release the placeholder. // if an object has been substituted, then release the placeholder.
@ -666,7 +817,7 @@
} }
else else
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])]; NSStringFromClass([coder class])];
} }
@ -717,6 +868,29 @@
@end @end
@implementation NSClassSwapper @implementation NSClassSwapper
- (id) initWithObject: (id)object
withClassName: (NSString *)className
originalClassName: (NSString *)origClassName
{
if((self = [super init]) != nil)
{
[self setTemplate: object];
[self setClassName: className];
[self setOriginalClassName: origClassName];
}
return self;
}
+ (void) setIsInInterfaceBuilder: (BOOL)flag
{
_isInInterfaceBuilder = flag;
}
+ (BOOL) isInInterfaceBuilder
{
return _isInInterfaceBuilder;
}
- (void) setTemplate: (id)temp - (void) setTemplate: (id)temp
{ {
ASSIGN(_template, temp); ASSIGN(_template, temp);
@ -729,7 +903,7 @@
- (void) setClassName: (NSString *)className - (void) setClassName: (NSString *)className
{ {
ASSIGN(_className, className); ASSIGNCOPY(_className, className);
} }
- (NSString *)className - (NSString *)className
@ -737,19 +911,30 @@
return _className; return _className;
} }
+ (BOOL) isInInterfaceBuilder - (void) setOriginalClassName: (NSString *)className
{ {
return NO; ASSIGNCOPY(_originalClassName, className);
}
- (NSString *)originalClassName
{
return _originalClassName;
} }
- (void) instantiateRealObject: (NSCoder *)coder withClassName: (NSString *)className - (void) instantiateRealObject: (NSCoder *)coder withClassName: (NSString *)className
{ {
Class aClass = NSClassFromString(className); Class aClass = nil;
id object = nil; id object = nil;
Class newCellClass = nil; Class newCellClass = nil;
NSString *origCellClassName = nil; NSString *origCellClassName = nil;
Class origCellClass = nil; Class origCellClass = nil;
// if there is a replacement class, use it, otherwise, use the one specified.
if((aClass = [(NSKeyedUnarchiver *)coder classForClassName: className]) == nil)
{
aClass = NSClassFromString(className);
}
if(aClass == nil) if(aClass == nil)
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
@ -772,7 +957,7 @@
// swap the class... // swap the class...
object = [aClass allocWithZone: NSDefaultMallocZone()]; object = [aClass allocWithZone: NSDefaultMallocZone()];
[(NSKeyedUnarchiver *)coder replaceObject: self withObject: object]; [(NSKeyedUnarchiver *)coder replaceObject: self withObject: object];
_template = [object initWithCoder: coder]; [self setTemplate: [object initWithCoder: coder]];
if(object != _template) if(object != _template)
{ {
[(NSKeyedUnarchiver *)coder replaceObject: object withObject: _template]; [(NSKeyedUnarchiver *)coder replaceObject: object withObject: _template];
@ -803,7 +988,7 @@
} }
else else
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])]; NSStringFromClass([coder class])];
} }
@ -815,10 +1000,24 @@
{ {
if([coder allowsKeyedCoding]) if([coder allowsKeyedCoding])
{ {
NSString *originalClassName = NSStringFromClass(_template); [coder encodeObject: _originalClassName forKey: @"NSOriginalClassName"];
[coder encodeObject: (id)_className forKey: @"NSClassName"]; [coder encodeObject: _className forKey: @"NSClassName"];
[coder encodeObject: (id)originalClassName forKey: @"NSOriginalClassName"]; [_template encodeWithCoder: coder]; // encode the actual object;
} }
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
}
- (void) dealloc
{
RELEASE(_className);
RELEASE(_originalClassName);
RELEASE(_template);
[super dealloc];
} }
@end @end
@ -867,9 +1066,10 @@
- (void) nibInstantiateWithOwner: (id)owner topLevelObjects: (NSMutableArray *)topLevelObjects - (void) nibInstantiateWithOwner: (id)owner topLevelObjects: (NSMutableArray *)topLevelObjects
{ {
NSEnumerator *en = [_connections objectEnumerator]; NSEnumerator *en = [_connections objectEnumerator];
NSArray *objs = NSAllMapTableKeys([self names]);
id obj = nil; id obj = nil;
id menu = nil; id menu = nil;
// replace the owner with the actual instance provided. // replace the owner with the actual instance provided.
[_root setObject: owner]; [_root setObject: owner];
@ -883,13 +1083,37 @@
} }
} }
// instantiate all windows and fill in the top level array.
en = [objs objectEnumerator];
while((obj = [en nextObject]) != nil)
{
if([obj isKindOfClass: [NSWindowTemplate class]])
{
if([obj realObject] == nil)
{
id o = [self instantiateObject: obj];
[topLevelObjects addObject: o];
}
}
else
{
id v = NSMapGet(_objects, obj);
if(v == nil || v == owner)
{
[topLevelObjects addObject: obj];
}
}
}
// bring visible windows to front...
en = [_visibleWindows objectEnumerator]; en = [_visibleWindows objectEnumerator];
while((obj = [en nextObject]) != nil) while((obj = [en nextObject]) != nil)
{ {
id w = [self instantiateObject: obj]; id w = [obj realObject];
[w orderFront: self]; [w orderFront: self];
} }
// add the menu...
menu = [self objectForName: @"MainMenu"]; menu = [self objectForName: @"MainMenu"];
if(menu != nil) if(menu != nil)
{ {
@ -912,7 +1136,7 @@
- (NSMutableSet *) topLevelObjects - (NSMutableSet *) topLevelObjects
{ {
return nil; return _topLevelObjects;
} }
- (NSMutableDictionary *) nameTable - (NSMutableDictionary *) nameTable
@ -920,6 +1144,31 @@
return nil; return nil;
} }
- (NSMutableArray *) visibleWindows
{
return _visibleWindows;
}
- (NSMapTable *) objects
{
return _objects;
}
- (NSMapTable *) names
{
return _names;
}
- (NSMapTable *) classes
{
return _classes;
}
- (NSMapTable *) oids
{
return _oids;
}
- (id) objectForName: (NSString *)name - (id) objectForName: (NSString *)name
{ {
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names); NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
@ -944,20 +1193,38 @@
return result; return result;
} }
/**
* Get the values from the map in the same order as the keys.
*/
- (NSArray *) _valuesForKeys: (NSArray *)keys inMap: (NSMapTable *)map
{
NSMutableArray *result = [NSMutableArray array];
NSEnumerator *en = [keys objectEnumerator];
id key = nil;
while((key = [en nextObject]) != nil)
{
id value = (id)NSMapGet(map,key);
[result addObject: value];
}
return result;
}
- (void) encodeWithCoder: (NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{ {
if([coder allowsKeyedCoding]) if([coder allowsKeyedCoding])
{ {
NSArray *accessibilityOidsKeys = (NSArray *)NSAllMapTableKeys(_accessibilityOids); NSArray *accessibilityOidsKeys = (NSArray *)NSAllMapTableKeys(_accessibilityOids);
NSArray *accessibilityOidsValues = (NSArray *)NSAllMapTableValues(_accessibilityOids); NSArray *accessibilityOidsValues = [self _valuesForKeys: accessibilityOidsKeys inMap: _accessibilityOids];
NSArray *classKeys = (NSArray *)NSAllMapTableKeys(_classes); NSArray *classKeys = (NSArray *)NSAllMapTableKeys(_classes);
NSArray *classValues = (NSArray *)NSAllMapTableValues(_classes); NSArray *classValues = [self _valuesForKeys: classKeys inMap: _classes];
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names); NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
NSArray *nameValues = (NSArray *)NSAllMapTableValues(_names); NSArray *nameValues = [self _valuesForKeys: nameKeys inMap: _names];
NSArray *objectsKeys = (NSArray *)NSAllMapTableKeys(_objects); NSArray *objectsKeys = (NSArray *)NSAllMapTableKeys(_objects);
NSArray *objectsValues = (NSArray *)NSAllMapTableValues(_objects); NSArray *objectsValues = [self _valuesForKeys: objectsKeys inMap: _objects];
NSArray *oidsKeys = (NSArray *)NSAllMapTableKeys(_oids); NSArray *oidsKeys = (NSArray *)NSAllMapTableKeys(_oids);
NSArray *oidsValues = (NSArray *)NSAllMapTableValues(_oids); NSArray *oidsValues = [self _valuesForKeys: oidsKeys inMap: _oids];
[(NSKeyedArchiver *)coder setClassName: @"_NSCornerView" forClass: NSClassFromString(@"GSTableCornerView")];
[coder encodeObject: (id)_accessibilityConnectors forKey: @"NSAccessibilityConnectors"]; [coder encodeObject: (id)_accessibilityConnectors forKey: @"NSAccessibilityConnectors"];
[coder encodeObject: (id) accessibilityOidsKeys forKey: @"NSAccessibilityOidsKeys"]; [coder encodeObject: (id) accessibilityOidsKeys forKey: @"NSAccessibilityOidsKeys"];
@ -971,12 +1238,18 @@
[coder encodeObject: (id) oidsKeys forKey: @"NSOidsKeys"]; [coder encodeObject: (id) oidsKeys forKey: @"NSOidsKeys"];
[coder encodeObject: (id) oidsValues forKey: @"NSOidsValues"]; [coder encodeObject: (id) oidsValues forKey: @"NSOidsValues"];
[coder encodeObject: (id) _connections forKey: @"NSConnections"]; [coder encodeObject: (id) _connections forKey: @"NSConnections"];
[coder encodeConditionalObject: (id) _fontManager forKey: @"NSFontManager"]; [coder encodeObject: (id) _fontManager forKey: @"NSFontManager"];
[coder encodeConditionalObject: (id) _framework forKey: @"NSFramework"]; [coder encodeObject: (id) _framework forKey: @"NSFramework"];
[coder encodeObject: (id) _visibleWindows forKey: @"NSVisibleWindows"]; [coder encodeObject: (id) _visibleWindows forKey: @"NSVisibleWindows"];
[coder encodeInt: _nextOid forKey: @"NSNextOid"]; [coder encodeInt: _nextOid forKey: @"NSNextOid"];
[coder encodeConditionalObject: (id) _root forKey: @"NSRoot"]; [coder encodeConditionalObject: (id) _root forKey: @"NSRoot"];
} }
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
} }
- (void) _buildMap: (NSMapTable *)mapTable - (void) _buildMap: (NSMapTable *)mapTable
@ -1003,7 +1276,6 @@
ASSIGN(_accessibilityConnectors, (NSMutableArray *)[coder decodeObjectForKey: @"NSAccessibilityConnectors"]); ASSIGN(_accessibilityConnectors, (NSMutableArray *)[coder decodeObjectForKey: @"NSAccessibilityConnectors"]);
ASSIGN(_fontManager, [coder decodeObjectForKey: @"NSFontManager"]); ASSIGN(_fontManager, [coder decodeObjectForKey: @"NSFontManager"]);
ASSIGN(_framework, [coder decodeObjectForKey: @"NSFramework"]); ASSIGN(_framework, [coder decodeObjectForKey: @"NSFramework"]);
ASSIGN(_connections, (NSMutableArray *)[coder decodeObjectForKey: @"NSConnections"]);
_nextOid = [coder decodeIntForKey: @"NSNextOid"]; _nextOid = [coder decodeIntForKey: @"NSNextOid"];
{ {
@ -1041,16 +1313,31 @@
NSObjectMapValueCallBacks, 2); NSObjectMapValueCallBacks, 2);
// fill in the maps... // fill in the maps...
[self _buildMap: _accessibilityOids withKeys: accessibilityOidsKeys andValues: accessibilityOidsValues]; [self _buildMap: _accessibilityOids
[self _buildMap: _classes withKeys: classKeys andValues: classValues]; withKeys: accessibilityOidsKeys
[self _buildMap: _names withKeys: nameKeys andValues: nameValues]; andValues: accessibilityOidsValues];
[self _buildMap: _objects withKeys: objectsKeys andValues: objectsValues]; [self _buildMap: _classes
[self _buildMap: _oids withKeys: oidsKeys andValues: oidsValues]; withKeys: classKeys
andValues: classValues];
[self _buildMap: _names
withKeys: nameKeys
andValues: nameValues];
[self _buildMap: _objects
withKeys: objectsKeys
andValues: objectsValues];
[self _buildMap: _oids
withKeys: oidsKeys
andValues: oidsValues];
ASSIGN(_connections, [[coder decodeObjectForKey: @"NSConnections"] mutableCopy]);
// instantiate...
_topLevelObjects = [[NSMutableSet alloc] init];
} }
} }
else else
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])]; NSStringFromClass([coder class])];
} }
@ -1102,6 +1389,7 @@
RELEASE(_framework); RELEASE(_framework);
RELEASE(_visibleWindows); RELEASE(_visibleWindows);
RELEASE(_root); RELEASE(_root);
RELEASE(_topLevelObjects);
[super dealloc]; [super dealloc];
} }
@ -1114,13 +1402,16 @@
{ {
return _root; return _root;
} }
@end
@interface NSButtonImageSource : NSObject <NSCoding> - (void) setNextOid: (int)noid
{ {
NSString *imageName; _nextOid = noid;
}
- (int) nextOid
{
return _nextOid;
} }
- (NSString *)imageName;
@end @end
@implementation NSButtonImageSource @implementation NSButtonImageSource
@ -1130,6 +1421,13 @@
{ {
ASSIGN(imageName, [coder decodeObjectForKey: @"NSImageName"]); ASSIGN(imageName, [coder decodeObjectForKey: @"NSImageName"]);
} }
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
RELEASE(self); RELEASE(self);
return [NSImage imageNamed: imageName]; return [NSImage imageNamed: imageName];
} }
@ -1140,6 +1438,21 @@
{ {
[coder encodeObject: imageName forKey: @"NSImageName"]; [coder encodeObject: imageName forKey: @"NSImageName"];
} }
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
}
- (id) initWithImageNamed: (NSString *)name
{
if((self = [super init]) != nil)
{
ASSIGN(imageName,name);
}
return self;
} }
- (NSString *)imageName - (NSString *)imageName
@ -1162,3 +1475,65 @@
@implementation _NSCornerView @implementation _NSCornerView
@end @end
@implementation NSIBHelpConnector
@end
@interface NSDecimalNumberPlaceholder : NSObject
@end
@implementation NSDecimalNumberPlaceholder
- (id) initWithCoder: (NSCoder *)coder
{
NSDecimalNumber *dn = nil;
if([coder allowsKeyedCoding])
{
unsigned int len = 0;
// BOOL compact = [coder decodeBoolForKey: @"NS.compact"];
short exponent = (short)[coder decodeIntForKey: @"NS.exponent"];
// int length = [coder decodeIntForKey: @"NS.length"];
NSByteOrder bo = [coder decodeIntForKey: @"NS.mantissa.bo"];
BOOL negative = [coder decodeBoolForKey: @"NS.negative"];
void *mantissaBytes = (void *)[coder decodeBytesForKey: @"NS.mantissa" returnedLength: &len];
unsigned long long unswapped = 0;
unsigned long long mantissa = 0;
memcpy((void *)&unswapped, (void *)mantissaBytes, sizeof(unsigned long long));
switch(bo)
{
case NS_BigEndian:
mantissa = NSSwapBigLongLongToHost(unswapped);
break;
case NS_LittleEndian:
mantissa = NSSwapLittleLongLongToHost(unswapped);
break;
default:
break;
}
dn = [[NSDecimalNumber alloc] initWithMantissa: mantissa
exponent: exponent
isNegative: negative];
}
return dn;
}
@end
// class needed for nib encoding/decoding by
@implementation NSPSMatrix
- (void) encodeWithCoder: (NSCoder *)coder
{
// do nothing... just encoding the presence of the class.
}
- (id) initWithCoder: (NSCoder *)coder
{
// what's NSPSMatix all about?
// NSLog(@"NSPSMatrix = %@",[(NSKeyedUnarchiver *)coder keyMap]);
return self;
}
@end

View file

@ -90,7 +90,7 @@
NS_HANDLER NS_HANDLER
{ {
NSLog(@"Exception occured while loading model: %@",[localException reason]); NSLog(@"Exception occured while loading model: %@",[localException reason]);
TEST_RELEASE(unarchiver); // TEST_RELEASE(unarchiver);
} }
NS_ENDHANDLER NS_ENDHANDLER

View file

@ -158,7 +158,6 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
NSEnumerator *enumerator; NSEnumerator *enumerator;
NSNibConnector *connection; NSNibConnector *connection;
NSString *key; NSString *key;
NSArray *visible;
NSMenu *menu; NSMenu *menu;
NSMutableArray *topObjects; NSMutableArray *topObjects;
id obj; id obj;
@ -248,12 +247,10 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
if ([context objectForKey: key] == nil || if ([context objectForKey: key] == nil ||
[key isEqualToString: @"NSOwner"]) // we want to send the message to the owner [key isEqualToString: @"NSOwner"]) // we want to send the message to the owner
{ {
if ([key isEqualToString: @"NSWindowsMenu"] == NO && // we don't want to send a message to these menus twice, // we don't want to send a message to these menus twice, if they're custom classes.
[key isEqualToString: @"NSServicesMenu"] == NO && // if they're custom classes. if ([key isEqualToString: @"NSWindowsMenu"] == NO &&
[key isEqualToString: @"NSVisible"] == NO && // also exclude any other special parts of the nameTable. [key isEqualToString: @"NSServicesMenu"] == NO &&
[key isEqualToString: @"NSDeferred"] == NO && [key isEqualToString: @"NSTopLevelObjects"] == NO)
[key isEqualToString: @"NSTopLevelObjects"] == NO &&
[key isEqualToString: @"GSCustomClassMap"] == NO)
{ {
id o = [nameTable objectForKey: key]; id o = [nameTable objectForKey: key];
@ -305,15 +302,12 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
* This is the last thing we should do since changes might be made * This is the last thing we should do since changes might be made
* in the awakeFromNib methods which are called on all of the objects. * in the awakeFromNib methods which are called on all of the objects.
*/ */
visible = [nameTable objectForKey: @"NSVisible"]; if (visibleWindows != nil)
if (visible != nil
&& [visible isKindOfClass: [NSArray class]] == YES)
{ {
unsigned pos = [visible count]; unsigned pos = [visibleWindows count];
while (pos-- > 0) while (pos-- > 0)
{ {
NSWindow *win = [visible objectAtIndex: pos]; NSWindow *win = [visibleWindows objectAtIndex: pos];
if ([NSApp isActive]) if ([NSApp isActive])
[win orderFront: self]; [win orderFront: self];
else else
@ -331,36 +325,17 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
} }
} }
- (NSMutableArray*) connections
{
return connections;
}
- (void) dealloc - (void) dealloc
{ {
RELEASE(nameTable); RELEASE(nameTable);
RELEASE(connections); RELEASE(connections);
RELEASE(topLevelObjects); RELEASE(topLevelObjects);
RELEASE(visibleWindows);
RELEASE(deferredWindows);
RELEASE(customClasses);
[super dealloc]; [super dealloc];
} }
- (void) encodeWithCoder: (NSCoder*)aCoder
{
int version = [GSNibContainer version];
if (version == GNUSTEP_NIB_VERSION)
{
[aCoder encodeObject: nameTable];
[aCoder encodeObject: connections];
[aCoder encodeObject: topLevelObjects];
}
else
{
// encode it as a version 0 file...
[aCoder encodeObject: nameTable];
[aCoder encodeObject: connections];
}
}
- (id) init - (id) init
{ {
if ((self = [super init]) != nil) if ((self = [super init]) != nil)
@ -368,20 +343,89 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
nameTable = [[NSMutableDictionary alloc] initWithCapacity: 8]; nameTable = [[NSMutableDictionary alloc] initWithCapacity: 8];
connections = [[NSMutableArray alloc] initWithCapacity: 8]; connections = [[NSMutableArray alloc] initWithCapacity: 8];
topLevelObjects = [[NSMutableSet alloc] initWithCapacity: 8]; topLevelObjects = [[NSMutableSet alloc] initWithCapacity: 8];
customClasses = [[NSMutableDictionary alloc] initWithCapacity: 8];
deferredWindows = [[NSMutableArray alloc] initWithCapacity: 8];
visibleWindows = [[NSMutableArray alloc] initWithCapacity: 8];
} }
return self; return self;
} }
- (void) encodeWithCoder: (NSCoder*)aCoder
{
int version = [GSNibContainer version];
if (version == GNUSTEP_NIB_VERSION)
{
[aCoder encodeObject: topLevelObjects];
[aCoder encodeObject: visibleWindows];
[aCoder encodeObject: deferredWindows];
[aCoder encodeObject: nameTable];
[aCoder encodeObject: connections];
[aCoder encodeObject: customClasses];
}
else if (version == 1)
{
NSMutableDictionary *nt = [NSMutableDictionary dictionaryWithDictionary: nameTable];
[nt setObject: [NSMutableArray arrayWithArray: visibleWindows]
forKey: @"NSVisible"];
[nt setObject: [NSMutableArray arrayWithArray: deferredWindows]
forKey: @"NSDeferred"];
[nt setObject: [NSMutableDictionary dictionaryWithDictionary: customClasses]
forKey: @"GSCustomClassMap"];
[aCoder encodeObject: nt];
[aCoder encodeObject: connections];
[aCoder encodeObject: topLevelObjects];
}
else if (version == 0)
{
NSMutableDictionary *nt = [NSMutableDictionary dictionaryWithDictionary: nameTable];
[nt setObject: [NSMutableArray arrayWithArray: visibleWindows]
forKey: @"NSVisible"];
[nt setObject: [NSMutableArray arrayWithArray: deferredWindows]
forKey: @"NSDeferred"];
[nt setObject: [NSMutableDictionary dictionaryWithDictionary: customClasses]
forKey: @"GSCustomClassMap"];
[aCoder encodeObject: nt];
[aCoder encodeObject: connections];
}
else
{
[NSException raise: NSInternalInconsistencyException
format: @"Unable to write GSNibContainer version #%d. GSNibContainer version for the installed gui lib is %d.", version, GNUSTEP_NIB_VERSION];
}
}
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
int version = [aCoder versionForClassName: @"GSNibContainer"]; int version = [aCoder versionForClassName: @"GSNibContainer"];
// save the version to the ivar, we need it later. // save the version to the ivar, we need it later.
if (version == GNUSTEP_NIB_VERSION) if (version == GNUSTEP_NIB_VERSION)
{
[aCoder decodeValueOfObjCType: @encode(id) at: &topLevelObjects];
[aCoder decodeValueOfObjCType: @encode(id) at: &visibleWindows];
[aCoder decodeValueOfObjCType: @encode(id) at: &deferredWindows];
[aCoder decodeValueOfObjCType: @encode(id) at: &nameTable];
[aCoder decodeValueOfObjCType: @encode(id) at: &connections];
[aCoder decodeValueOfObjCType: @encode(id) at: &customClasses];
}
else if (version == 1)
{ {
[aCoder decodeValueOfObjCType: @encode(id) at: &nameTable]; [aCoder decodeValueOfObjCType: @encode(id) at: &nameTable];
[aCoder decodeValueOfObjCType: @encode(id) at: &connections]; [aCoder decodeValueOfObjCType: @encode(id) at: &connections];
[aCoder decodeValueOfObjCType: @encode(id) at: &topLevelObjects]; [aCoder decodeValueOfObjCType: @encode(id) at: &topLevelObjects];
// initialize with special entries...
ASSIGN(visibleWindows, [NSMutableArray arrayWithArray:
[nameTable objectForKey: @"NSVisible"]]);
ASSIGN(deferredWindows, [NSMutableArray arrayWithArray:
[nameTable objectForKey: @"NSDeferred"]]);
ASSIGN(customClasses, [NSMutableDictionary dictionaryWithDictionary:
[nameTable objectForKey: @"GSCustomClassMap"]]);
// then remove them from the name table.
[nameTable removeObjectForKey: @"NSVisible"];
[nameTable removeObjectForKey: @"NSDeferred"];
[nameTable removeObjectForKey: @"GSCustomClassMap"];
} }
else if (version == 0) else if (version == 0)
{ {
@ -409,11 +453,25 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
[topLevelObjects addObject: o]; // if it's a top level object, add it. [topLevelObjects addObject: o]; // if it's a top level object, add it.
} }
} }
// initialize with special entries...
ASSIGN(visibleWindows, [NSMutableArray arrayWithArray:
[nameTable objectForKey: @"NSVisible"]]);
ASSIGN(deferredWindows, [NSMutableArray arrayWithArray:
[nameTable objectForKey: @"NSDeferred"]]);
ASSIGN(customClasses, [NSMutableDictionary dictionaryWithDictionary:
[nameTable objectForKey: @"GSCustomClassMap"]]);
// then remove them from the name table.
[nameTable removeObjectForKey: @"NSVisible"];
[nameTable removeObjectForKey: @"NSDeferred"];
[nameTable removeObjectForKey: @"GSCustomClassMap"];
} }
else else
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
format: @"Unable to read GSNibContainer version #%d. GSNibContainer version for the installed gui lib is %d.", version, GNUSTEP_NIB_VERSION]; format: @"Unable to read GSNibContainer version #%d. GSNibContainer version for the installed gui lib is %d. Please upgrade to a more recent version of the gui library.", version, GNUSTEP_NIB_VERSION];
} }
return self; return self;
@ -428,6 +486,26 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
{ {
return topLevelObjects; return topLevelObjects;
} }
- (NSMutableArray*) connections
{
return connections;
}
- (NSMutableArray*) visibleWindows
{
return visibleWindows;
}
- (NSMutableArray*) deferredWindows
{
return visibleWindows;
}
- (NSMutableDictionary *) customClasses
{
return customClasses;
}
@end @end
// The first standin objects here are for views and normal objects like controllers // The first standin objects here are for views and normal objects like controllers

View file

@ -278,6 +278,7 @@ NSRegisterServicesProvider(id provider, NSString *name)
- (void) dealloc - (void) dealloc
{ {
GSNOSUPERDEALLOC;
} }
/** /**
@ -644,7 +645,7 @@ static NSString *disabledName = @".GNUstepDisabled";
unsigned i, j; unsigned i, j;
unsigned es = [sendTypes count]; unsigned es = [sendTypes count];
unsigned er = [returnTypes count]; unsigned er = [returnTypes count];
NSWindow *resp = [[_application keyWindow] firstResponder]; NSResponder *resp = [[_application keyWindow] firstResponder];
id obj = nil; id obj = nil;
for (i = 0; i <= es; i++) for (i = 0; i <= es; i++)
@ -1267,7 +1268,7 @@ static NSString *disabledName = @".GNUstepDisabled";
unsigned i, j; unsigned i, j;
unsigned es = [sendTypes count]; unsigned es = [sendTypes count];
unsigned er = [returnTypes count]; unsigned er = [returnTypes count];
NSWindow *resp = [[_application keyWindow] firstResponder]; NSResponder *resp = [[_application keyWindow] firstResponder];
/* /*
* If the menu item is not in our map, it must be the item containing * If the menu item is not in our map, it must be the item containing

View file

@ -120,7 +120,7 @@ static NSColor *titleColor[3];
{ {
NSMutableParagraphStyle *p; NSMutableParagraphStyle *p;
p = [NSMutableParagraphStyle defaultParagraphStyle]; p = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[p setLineBreakMode: NSLineBreakByClipping]; [p setLineBreakMode: NSLineBreakByClipping];
titleTextAttributes[0] = [[NSMutableDictionary alloc] titleTextAttributes[0] = [[NSMutableDictionary alloc]
@ -142,6 +142,7 @@ static NSColor *titleColor[3];
p, NSParagraphStyleAttributeName, p, NSParagraphStyleAttributeName,
nil]; nil];
RELEASE(p);
titleColor[0] = RETAIN([NSColor windowFrameColor]); titleColor[0] = RETAIN([NSColor windowFrameColor]);
titleColor[1] = RETAIN([NSColor lightGrayColor]); titleColor[1] = RETAIN([NSColor lightGrayColor]);
titleColor[2] = RETAIN([NSColor darkGrayColor]); titleColor[2] = RETAIN([NSColor darkGrayColor]);
@ -176,7 +177,7 @@ static NSColor *titleColor[3];
different method here. */ different method here. */
[closeButton setAction: @selector(performClose:)]; [closeButton setAction: @selector(performClose:)];
[self addSubview: closeButton]; [self addSubview: closeButton];
RELEASE(closeButton); // RELEASE(closeButton); // FIXME... causes crash when closing.
} }
if ([w styleMask] & NSMiniaturizableWindowMask) if ([w styleMask] & NSMiniaturizableWindowMask)
{ {

View file

@ -722,118 +722,248 @@
int i; int i;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfRows]; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
{ {
[aCoder encodeObject: _jails[i]]; [aCoder encodeInt: _numberOfRows forKey: @"GSNumberOfRows"];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]]; [aCoder encodeInt: _numberOfColumns forKey: @"GSNumberOfColumns"];
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
{
[aCoder encodeObject: _jails[i] forKey:
[NSString stringWithFormat: @"GSJail%d",i]];
[aCoder encodeBool: _havePrisoner[i] forKey:
[NSString stringWithFormat: @"GSHavePrisoner%d",i]];
}
[aCoder encodeFloat: _minXBorder forKey: @"GSMinXBorder"];
[aCoder encodeFloat: _maxXBorder forKey: @"GSMaxXBorder"];
[aCoder encodeFloat: _minYBorder forKey: @"GSMinYBorder"];
[aCoder encodeFloat: _maxYBorder forKey: @"GSMaxYBorder"];
for (i = 0; i < _numberOfColumns; i++)
{
[aCoder encodeBool: _expandColumn[i] forKey:
[NSString stringWithFormat: @"GSExpandColumn%d",i]];
[aCoder encodeFloat: _columnDimension[i] forKey:
[NSString stringWithFormat: @"GSColumnDimension%d",i]];
[aCoder encodeFloat: _minColumnDimension[i] forKey:
[NSString stringWithFormat: @"GSMinColumnDimension%d",i]];
}
for (i = 0; i < _numberOfRows; i++)
{
[aCoder encodeBool: _expandRow[i] forKey:
[NSString stringWithFormat: @"GSExpandRow%d",i]];
[aCoder encodeFloat: _rowDimension[i] forKey:
[NSString stringWithFormat: @"GSRowDimension%d",i]];
[aCoder encodeFloat: _minRowDimension[i] forKey:
[NSString stringWithFormat: @"GSMinRowDimension%d",i]];
}
} }
[aCoder encodeValueOfObjCType: @encode(float) at: &_minXBorder]; else
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxXBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minYBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxYBorder];
for (i = 0; i < _numberOfColumns; i++)
{ {
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]]; [aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aCoder encodeValueOfObjCType: @encode(float) at: &_columnDimension[i]]; [aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
[aCoder encodeValueOfObjCType: @encode(float) for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
at: &_minColumnDimension[i]]; {
} [aCoder encodeObject: _jails[i]];
for (i = 0; i < _numberOfRows; i++) [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]];
{ }
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]]; [aCoder encodeValueOfObjCType: @encode(float) at: &_minXBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_rowDimension[i]]; [aCoder encodeValueOfObjCType: @encode(float) at: &_maxXBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]]; [aCoder encodeValueOfObjCType: @encode(float) at: &_minYBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxYBorder];
for (i = 0; i < _numberOfColumns; i++)
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_columnDimension[i]];
[aCoder encodeValueOfObjCType: @encode(float)
at: &_minColumnDimension[i]];
}
for (i = 0; i < _numberOfRows; i++)
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_rowDimension[i]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
}
} }
} }
-(id) initWithCoder: (NSCoder*)aDecoder -(id) initWithCoder: (NSCoder*)aDecoder
{ {
int i; int i;
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
[super setAutoresizesSubviews: NO]; [super setAutoresizesSubviews: NO];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows]; if([aDecoder allowsKeyedCoding])
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
//
_jails = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (NSView *)
* (_numberOfRows * _numberOfColumns));
_havePrisoner = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL)
* (_numberOfRows * _numberOfColumns));
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
{ {
_jails[i] = [aDecoder decodeObject]; _numberOfRows = [aDecoder decodeIntForKey: @"GSNumberOfRows"];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]]; _numberOfColumns = [aDecoder decodeIntForKey: @"GSNumberOfColumns"];
}
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minXBorder]; // create the jails...
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxXBorder]; _jails = NSZoneMalloc (NSDefaultMallocZone (),
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minYBorder]; sizeof (NSView *)
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxYBorder]; * (_numberOfRows * _numberOfColumns));
_havePrisoner = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL)
* (_numberOfRows * _numberOfColumns));
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
{
_jails[i] = [aDecoder decodeObjectForKey:
[NSString stringWithFormat: @"GSJail%d",i]];
_havePrisoner[i] = [aDecoder decodeBoolForKey:
[NSString stringWithFormat: @"GSHavePrisoner%d",i]];
}
_minXBorder = [aDecoder decodeFloatForKey: @"GSMinXBorder"];
_maxXBorder = [aDecoder decodeFloatForKey: @"GSMaxXBorder"];
_minYBorder = [aDecoder decodeFloatForKey: @"GSMinYBorder"];
_maxYBorder = [aDecoder decodeFloatForKey: @"GSMaxYBorder"];
// We compute _minimumSize, _expandingRowNumber // We compute _minimumSize, _expandingRowNumber
// and _expandingColumnNumber during deconding. // and _expandingColumnNumber during deconding.
_minimumSize = NSZeroSize; _minimumSize = NSZeroSize;
_expandingRowNumber = 0; _expandingRowNumber = 0;
_expandingColumnNumber = 0; _expandingColumnNumber = 0;
// Columns // Columns
_expandColumn = NSZoneMalloc (NSDefaultMallocZone (), _expandColumn = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL) * _numberOfColumns); sizeof (BOOL) * _numberOfColumns);
_columnDimension = NSZoneMalloc (NSDefaultMallocZone (), _columnDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfColumns); sizeof (float) * _numberOfColumns);
_minColumnDimension = NSZoneMalloc (NSDefaultMallocZone (), _minColumnDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfColumns); sizeof (float) * _numberOfColumns);
_minimumSize.width += _minXBorder; _minimumSize.width += _minXBorder;
for (i = 0; i < _numberOfColumns; i++) for (i = 0; i < _numberOfColumns; i++)
{ {
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]]; _expandColumn[i] = [aDecoder decodeBoolForKey:
if (_expandColumn[i]) [NSString stringWithFormat: @"GSExpandColumn%d",i]];
_expandingColumnNumber++; if (_expandColumn[i])
[aDecoder decodeValueOfObjCType: @encode(float) at: &_columnDimension[i]]; _expandingColumnNumber++;
[aDecoder decodeValueOfObjCType: @encode(float) _columnDimension[i] = [aDecoder decodeFloatForKey:
at: &_minColumnDimension[i]]; [NSString stringWithFormat: @"GSColumnDimension%d",i]];
_minimumSize.width += _minColumnDimension[i]; _minColumnDimension[i] = [aDecoder decodeFloatForKey:
} [NSString stringWithFormat: @"GSMinColumnDimension%d",i]];
_minimumSize.width += _maxXBorder; _minimumSize.width += _minColumnDimension[i];
// Calculate column origins }
_columnXOrigin = NSZoneMalloc (NSDefaultMallocZone (), _minimumSize.width += _maxXBorder;
sizeof (float) * _numberOfColumns); // Calculate column origins
_columnXOrigin[0] = _minXBorder; _columnXOrigin = NSZoneMalloc (NSDefaultMallocZone (),
for (i = 1; i < _numberOfColumns; i++) sizeof (float) * _numberOfColumns);
_columnXOrigin[i] = _columnXOrigin[i - 1] + _columnDimension[i - 1]; _columnXOrigin[0] = _minXBorder;
for (i = 1; i < _numberOfColumns; i++)
// Rows _columnXOrigin[i] = _columnXOrigin[i - 1] + _columnDimension[i - 1];
_expandRow = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL) * _numberOfRows); // Rows
_rowDimension = NSZoneMalloc (NSDefaultMallocZone (), _expandRow = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows); sizeof (BOOL) * _numberOfRows);
_minRowDimension = NSZoneMalloc (NSDefaultMallocZone (), _rowDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_minRowDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_minimumSize.height += _minYBorder;
for (i = 0; i < _numberOfRows; i++)
{
_expandRow[i] = [aDecoder decodeBoolForKey:
[NSString stringWithFormat: @"GSExpandRow%d",i]];
if (_expandRow[i])
_expandingRowNumber++;
_rowDimension[i] = [aDecoder decodeFloatForKey:
[NSString stringWithFormat: @"GSRowDimension%d",i]];
_minRowDimension[i] = [aDecoder decodeFloatForKey:
[NSString stringWithFormat: @"GSMinRowDimension%d",i]];
_minimumSize.height += _minRowDimension[i];
}
_minimumSize.height += _maxYBorder;
// Calculate row origins
_rowYOrigin = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows); sizeof (float) * _numberOfRows);
_minimumSize.height += _minYBorder; _rowYOrigin[0] = _minYBorder;
for (i = 0; i < _numberOfRows; i++) for (i = 1; i < _numberOfRows; i++)
{ _rowYOrigin[i] = _rowYOrigin[i - 1] + _rowDimension[i - 1];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]]; }
if (_expandRow[i]) else
_expandingRowNumber++; {
[aDecoder decodeValueOfObjCType: @encode(float) at: &_rowDimension[i]]; [aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]]; [aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
_minimumSize.height += _minRowDimension[i];
//
_jails = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (NSView *)
* (_numberOfRows * _numberOfColumns));
_havePrisoner = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL)
* (_numberOfRows * _numberOfColumns));
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
{
_jails[i] = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]];
}
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minXBorder];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxXBorder];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minYBorder];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxYBorder];
// We compute _minimumSize, _expandingRowNumber
// and _expandingColumnNumber during deconding.
_minimumSize = NSZeroSize;
_expandingRowNumber = 0;
_expandingColumnNumber = 0;
// Columns
_expandColumn = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL) * _numberOfColumns);
_columnDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfColumns);
_minColumnDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfColumns);
_minimumSize.width += _minXBorder;
for (i = 0; i < _numberOfColumns; i++)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]];
if (_expandColumn[i])
_expandingColumnNumber++;
[aDecoder decodeValueOfObjCType: @encode(float) at: &_columnDimension[i]];
[aDecoder decodeValueOfObjCType: @encode(float)
at: &_minColumnDimension[i]];
_minimumSize.width += _minColumnDimension[i];
}
_minimumSize.width += _maxXBorder;
// Calculate column origins
_columnXOrigin = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfColumns);
_columnXOrigin[0] = _minXBorder;
for (i = 1; i < _numberOfColumns; i++)
_columnXOrigin[i] = _columnXOrigin[i - 1] + _columnDimension[i - 1];
// Rows
_expandRow = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL) * _numberOfRows);
_rowDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_minRowDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_minimumSize.height += _minYBorder;
for (i = 0; i < _numberOfRows; i++)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]];
if (_expandRow[i])
_expandingRowNumber++;
[aDecoder decodeValueOfObjCType: @encode(float) at: &_rowDimension[i]];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
_minimumSize.height += _minRowDimension[i];
}
_minimumSize.height += _maxYBorder;
// Calculate row origins
_rowYOrigin = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_rowYOrigin[0] = _minYBorder;
for (i = 1; i < _numberOfRows; i++)
_rowYOrigin[i] = _rowYOrigin[i - 1] + _rowDimension[i - 1];
} }
_minimumSize.height += _maxYBorder;
// Calculate row origins
_rowYOrigin = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_rowYOrigin[0] = _minYBorder;
for (i = 1; i < _numberOfRows; i++)
_rowYOrigin[i] = _rowYOrigin[i - 1] + _rowDimension[i - 1];
return self; return self;
} }

View file

@ -167,6 +167,7 @@ unCacheAttributes(NSDictionary *attrs)
{ {
[self gcFinalize]; [self gcFinalize];
NSDeallocateObject(self); NSDeallocateObject(self);
GSNOSUPERDEALLOC;
} }
- (NSString*) description - (NSString*) description
@ -177,8 +178,11 @@ unCacheAttributes(NSDictionary *attrs)
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &loc]; if([aCoder allowsKeyedCoding] == NO)
[aCoder encodeValueOfObjCType: @encode(id) at: &attrs]; {
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &loc];
[aCoder encodeValueOfObjCType: @encode(id) at: &attrs];
}
} }
- (void) gcFinalize - (void) gcFinalize
@ -189,11 +193,13 @@ unCacheAttributes(NSDictionary *attrs)
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
NSDictionary *a; if([aCoder allowsKeyedCoding] == NO)
{
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &loc]; NSDictionary *a;
a = [aCoder decodeObject]; [aCoder decodeValueOfObjCType: @encode(unsigned) at: &loc];
attrs = cacheAttributes(a); a = [aCoder decodeObject];
attrs = cacheAttributes(a);
}
return self; return self;
} }

View file

@ -115,23 +115,29 @@
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL inside = flags.inside; if([aCoder allowsKeyedCoding] == NO)
{
[aCoder encodeRect: rectangle]; BOOL inside = flags.inside;
[aCoder encodeValueOfObjCType: @encode(NSTrackingRectTag) at: &tag];
[aCoder encodeObject: owner]; [aCoder encodeRect: rectangle];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &inside]; [aCoder encodeValueOfObjCType: @encode(NSTrackingRectTag) at: &tag];
[aCoder encodeObject: owner];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &inside];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
BOOL inside; if([aDecoder allowsKeyedCoding] == NO)
{
rectangle = [aDecoder decodeRect]; BOOL inside;
[aDecoder decodeValueOfObjCType: @encode(NSTrackingRectTag) at: &tag];
[aDecoder decodeValueOfObjCType: @encode(id) at: &owner]; rectangle = [aDecoder decodeRect];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &inside]; [aDecoder decodeValueOfObjCType: @encode(NSTrackingRectTag) at: &tag];
flags.inside = inside; [aDecoder decodeValueOfObjCType: @encode(id) at: &owner];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &inside];
flags.inside = inside;
}
return self; return self;
} }

View file

@ -163,15 +163,31 @@ enablingYResizing: (BOOL)aFlag
-(void) encodeWithCoder: (NSCoder*)aCoder -(void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews]; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin]; {
[aCoder encodeBool: _haveViews forKey: @"GSHaveViews"];
[aCoder encodeFloat: _defaultMinYMargin forKey: @"GSDefaultMinYMargin"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
[aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin];
}
} }
-(id) initWithCoder: (NSCoder*)aDecoder -(id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews]; if([aDecoder allowsKeyedCoding])
[aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin]; {
_haveViews = [aDecoder decodeBoolForKey: @"GSHaveViews"];
_defaultMinYMargin = [aDecoder decodeFloatForKey: @"GSDefaultMinYMargin"];
}
else
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin];
}
return self; return self;
} }
@end @end

View file

@ -285,11 +285,21 @@ static Class controlClass;
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeValueOfObjCType: @encode(int) at: &_tag]; if([aCoder allowsKeyedCoding])
[aCoder encodeConditionalObject: _target]; {
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action]; [aCoder encodeInt: [self tag] forKey: @"NSTag"];
// This is only encoded for backward compatibility and won't be decoded. [aCoder encodeObject: [self target] forKey: @"NSTarget"];
[aCoder encodeConditionalObject: nil]; [aCoder encodeObject: NSStringFromSelector([self action]) forKey: @"NSAction"];
[aCoder encodeObject: _control_view forKey: @"NSControlView"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(int) at: &_tag];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
// This is only encoded for backward compatibility and won't be decoded.
[aCoder encodeConditionalObject: nil];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder

View file

@ -690,8 +690,7 @@ setControl(NSView* content, id control, NSString *title)
} }
else else
{ {
NSLog(@"alert panel buttonAction: from unknown sender - x%x\n", NSLog(@"alert panel buttonAction: from unknown sender - x%p\n", sender);
(unsigned)sender);
} }
[NSApp stopModalWithCode: result]; [NSApp stopModalWithCode: result];
} }

View file

@ -1829,19 +1829,9 @@ See -runModalForWindow:
case NSKeyDown: case NSKeyDown:
{ {
NSArray *window_list = [self windows];
unsigned count = [window_list count];
unsigned i;
NSDebugLLog(@"NSEvent", @"send key down event\n"); NSDebugLLog(@"NSEvent", @"send key down event\n");
for (i = 0; i < count; i++) if ([[self mainMenu] performKeyEquivalent: theEvent] == NO
{ && [[self keyWindow] performKeyEquivalent: theEvent] == NO)
NSWindow *window = [window_list objectAtIndex: i];
if ([window performKeyEquivalent: theEvent] == YES)
break;
}
if (i == count)
{ {
[[theEvent window] sendEvent: theEvent]; [[theEvent window] sendEvent: theEvent];
} }
@ -3302,10 +3292,23 @@ image.</p><p>See Also: -applicationIconImage</p>
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
[aCoder encodeConditionalObject: _delegate]; {
[aCoder encodeObject: _main_menu]; /*
[aCoder encodeConditionalObject: _windows_menu]; if(_delegate != nil)
{
[aCoder encodeObject: _delegate forKey: @"NSDelegate"];
}
[aCoder encodeObject: _main_menu forKey: @"NSMainMenu"]; // ???
[aCoder encodeObject: _windows_menu forKey: @"NSWindowsMenu"]; // ???
*/
}
else
{
[aCoder encodeConditionalObject: _delegate];
[aCoder encodeObject: _main_menu];
[aCoder encodeConditionalObject: _windows_menu];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -3313,13 +3316,29 @@ image.</p><p>See Also: -applicationIconImage</p>
id obj; id obj;
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
if([aDecoder allowsKeyedCoding])
obj = [aDecoder decodeObject]; {
[self setDelegate: obj]; /*
obj = [aDecoder decodeObject]; if([aDecoder containsValueForKey: @"NSDelegate"])
[self setMainMenu: obj]; {
obj = [aDecoder decodeObject]; obj = [aDecoder decodeObjectForKey: @"NSDelegate"];
[self setWindowsMenu: obj]; [self setDelegate: obj];
}
obj = [aDecoder decodeObjectForKey: @"NSMainMenu"];
[self setMainMenu: obj];
obj = [aDecoder decodeObjectForKey: @"NSWindowsMenu"];
[self setWindowsMenu: obj];
*/
}
else
{
obj = [aDecoder decodeObject];
[self setDelegate: obj];
obj = [aDecoder decodeObject];
[self setMainMenu: obj];
obj = [aDecoder decodeObject];
[self setWindowsMenu: obj];
}
return self; return self;
} }

View file

@ -1839,6 +1839,8 @@ static NSPoint point_on_curve(double t, NSPoint a, NSPoint b, NSPoint c,
elem.type = NSMoveToBezierPathElement; elem.type = NSMoveToBezierPathElement;
elem.points[0] = aPoint; elem.points[0] = aPoint;
elem.points[1] = NSZeroPoint;
elem.points[2] = NSZeroPoint;
GSIArrayAddItem(pathElements, (GSIArrayItem)elem); GSIArrayAddItem(pathElements, (GSIArrayItem)elem);
INVALIDATE_CACHE(); INVALIDATE_CACHE();
} }
@ -1849,6 +1851,8 @@ static NSPoint point_on_curve(double t, NSPoint a, NSPoint b, NSPoint c,
elem.type = NSLineToBezierPathElement; elem.type = NSLineToBezierPathElement;
elem.points[0] = aPoint; elem.points[0] = aPoint;
elem.points[1] = NSZeroPoint;
elem.points[2] = NSZeroPoint;
GSIArrayAddItem(pathElements, (GSIArrayItem)elem); GSIArrayAddItem(pathElements, (GSIArrayItem)elem);
INVALIDATE_CACHE(); INVALIDATE_CACHE();
} }
@ -1874,6 +1878,9 @@ static NSPoint point_on_curve(double t, NSPoint a, NSPoint b, NSPoint c,
PathElement elem; PathElement elem;
elem.type = NSClosePathBezierPathElement; elem.type = NSClosePathBezierPathElement;
elem.points[0] = NSZeroPoint;
elem.points[1] = NSZeroPoint;
elem.points[2] = NSZeroPoint;
GSIArrayAddItem(pathElements, (GSIArrayItem)elem); GSIArrayAddItem(pathElements, (GSIArrayItem)elem);
INVALIDATE_CACHE(); INVALIDATE_CACHE();
} }

View file

@ -270,7 +270,7 @@ nil. */
{ {
/* assign the description of possible occured error to errorMsg */ /* assign the description of possible occured error to errorMsg */
if (errorMsg) if (errorMsg)
*errorMsg = (jerrMgr.error ? jerrMgr.error : nil); *errorMsg = (jerrMgr.error ? (id)jerrMgr.error : (id)nil);
gs_jpeg_memory_src_destroy(&cinfo); gs_jpeg_memory_src_destroy(&cinfo);
jpeg_destroy_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
if (imgbuffer) if (imgbuffer)

View file

@ -948,7 +948,14 @@ static BOOL supports_lzw_compression = NO;
NSData *data = [self TIFFRepresentation]; NSData *data = [self TIFFRepresentation];
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeObject: data]; if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: data forKey: @"NSTIFFRepresentation"];
}
else
{
[aCoder encodeObject: data];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder

View file

@ -479,12 +479,24 @@
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeObject: _cell]; if ([aCoder allowsKeyedCoding])
[aCoder encodeSize: _offsets]; {
[aCoder encodeValueOfObjCType: @encode(NSBorderType) at: &_border_type]; [aCoder encodeObject: [self contentView] forKey: @"NSContentView"];
[aCoder encodeValueOfObjCType: @encode(NSTitlePosition) at: &_title_position]; [aCoder encodeObject: _cell forKey: @"NSTitleCell"];
// NB: the content view is our (only) subview, so it is already [aCoder encodeInt: [self borderType] forKey: @"NSBorderType"];
// encoded by NSView. [aCoder encodeInt: [self titlePosition] forKey: @"NSTitlePosition"];
[aCoder encodeBool: NO forKey: @"NSTransparent"];
[aCoder encodeSize: [self contentViewMargins] forKey: @"NSOffsets"];
}
else
{
[aCoder encodeObject: _cell];
[aCoder encodeSize: _offsets];
[aCoder encodeValueOfObjCType: @encode(NSBorderType) at: &_border_type];
[aCoder encodeValueOfObjCType: @encode(NSTitlePosition) at: &_title_position];
// NB: the content view is our (only) subview, so it is already
// encoded by NSView.
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder

View file

@ -152,30 +152,43 @@ static NSTextFieldCell *titleCell;
- (void) encodeWithCoder: (NSCoder *)aCoder - (void) encodeWithCoder: (NSCoder *)aCoder
{ {
int dummy = 0; if([aCoder allowsKeyedCoding])
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded]; }
[aCoder encodeObject: _columnScrollView]; else
[aCoder encodeObject: _columnMatrix]; {
[aCoder encodeValueOfObjCType: @encode(int) at: &dummy]; int dummy = 0;
[aCoder encodeObject: _columnTitle];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aCoder encodeObject: _columnScrollView];
[aCoder encodeObject: _columnMatrix];
[aCoder encodeValueOfObjCType: @encode(int) at: &dummy];
[aCoder encodeObject: _columnTitle];
}
} }
- (id) initWithCoder: (NSCoder *)aDecoder - (id) initWithCoder: (NSCoder *)aDecoder
{ {
int dummy = 0; if([aDecoder allowsKeyedCoding])
{
}
else
{
int dummy = 0;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
_columnScrollView = [aDecoder decodeObject]; _columnScrollView = [aDecoder decodeObject];
if (_columnScrollView) if (_columnScrollView)
RETAIN(_columnScrollView); RETAIN(_columnScrollView);
_columnMatrix = [aDecoder decodeObject]; _columnMatrix = [aDecoder decodeObject];
if (_columnMatrix) if (_columnMatrix)
RETAIN(_columnMatrix); RETAIN(_columnMatrix);
[aDecoder decodeValueOfObjCType: @encode(int) at: &dummy]; [aDecoder decodeValueOfObjCType: @encode(int) at: &dummy];
_columnTitle = [aDecoder decodeObject]; _columnTitle = [aDecoder decodeObject];
if (_columnTitle) if (_columnTitle)
RETAIN(_columnTitle); RETAIN(_columnTitle);
}
return self; return self;
} }
@ -2488,65 +2501,156 @@ static NSTextFieldCell *titleCell;
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
long flags = 0;
// Here to keep compatibility with old version //
[aCoder encodeObject: nil]; // NOTE: The browserview under GS uses an NSMatrix subview, the one under
[aCoder encodeObject:_browserCellPrototype]; // Cocoa does not. This will cause IB to issue an "inconsistency" alert
[aCoder encodeObject: NSStringFromClass (_browserMatrixClass)]; // which is minor and nothing to worry about.
//
[aCoder encodeObject: _browserCellPrototype forKey: @"NSCellPrototype"];
[aCoder encodeObject: [self _getTitleOfColumn: 0] forKey: @"NSFirstColumnTitle"];
[aCoder encodeObject: _pathSeparator forKey: @"NSPathSeparator"];
[aCoder encodeObject:_pathSeparator]; flags |= [self hasHorizontalScroller] ? 0x10000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded]; flags |= ([self allowsEmptySelection] == NO) ? 0x20000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsBranchSelection]; flags |= [self sendsActionOnArrowKeys] ? 0x40000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsEmptySelection]; flags |= [self acceptsArrowKeys] ? 0x100000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsMultipleSelection]; flags |= [self separatesColumns] ? 0x4000000 : 0;
[aCoder encodeValueOfObjCType: @encode(int) at: &_maxVisibleColumns]; flags |= [self takesTitleFromPreviousColumn] ? 0x8000000 : 0;
[aCoder encodeValueOfObjCType: @encode(float) at: &_minColumnWidth]; flags |= [self isTitled] ? 0x10000000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_reusesColumns]; flags |= [self reusesColumns] ? 0x20000000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_separatesColumns]; flags |= [self allowsBranchSelection] ? 0x40000000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_takesTitleFromPreviousColumn]; flags |= [self allowsMultipleSelection] ? 0x80000000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isTitled]; [aCoder encodeInt: flags forKey: @"NSBrFlags"];
[aCoder encodeInt: _maxVisibleColumns forKey: @"NSNumberOfVisibleColumns"];
[aCoder encodeObject:_horizontalScroller]; [aCoder encodeInt: _minColumnWidth forKey: @"NSMinColumnWidth"];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_hasHorizontalScroller];
[aCoder encodeRect: _scrollerRect];
[aCoder encodeSize: _columnSize];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsAlphaNumericalKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnAlphaNumericalKeys];
[aCoder encodeConditionalObject:_browserDelegate];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_doubleAction];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
[aCoder encodeObject: _browserColumns];
// Just encode the number of columns and the first visible
// and rebuild the browser columns on the decoding side
{
int colCount = [_browserColumns count];
[aCoder encodeValueOfObjCType: @encode(int) at: &colCount];
[aCoder encodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn];
}
//[aCoder encodeInt: columnResizingType forKey: @"NSColumnResizingType"]];
//[aCoder encodeInt: prefWidth forKey: @"NSPreferedColumnWidth"];
}
else
{
// Here to keep compatibility with old version
[aCoder encodeObject: nil];
[aCoder encodeObject:_browserCellPrototype];
[aCoder encodeObject: NSStringFromClass (_browserMatrixClass)];
[aCoder encodeObject:_pathSeparator];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsBranchSelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsEmptySelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsMultipleSelection];
[aCoder encodeValueOfObjCType: @encode(int) at: &_maxVisibleColumns];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minColumnWidth];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_reusesColumns];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_separatesColumns];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_takesTitleFromPreviousColumn];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isTitled];
[aCoder encodeObject:_horizontalScroller];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_hasHorizontalScroller];
[aCoder encodeRect: _scrollerRect];
[aCoder encodeSize: _columnSize];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsAlphaNumericalKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnAlphaNumericalKeys];
[aCoder encodeConditionalObject:_browserDelegate];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_doubleAction];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
[aCoder encodeObject: _browserColumns];
// Just encode the number of columns and the first visible
// and rebuild the browser columns on the decoding side
{
int colCount = [_browserColumns count];
[aCoder encodeValueOfObjCType: @encode(int) at: &colCount];
[aCoder encodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn];
}
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
NSCell *proto = [aDecoder decodeObjectForKey: @"NSCellPrototype"]; NSCell *proto = [aDecoder decodeObjectForKey: @"NSCellPrototype"];
NSString *title = [aDecoder decodeObjectForKey: @"NSFirstColumnTitle"]; NSString *title = [aDecoder decodeObjectForKey: @"NSFirstColumnTitle"];
NSString *sep = [aDecoder decodeObjectForKey: @"NSPathSeparator"]; NSString *sep = [aDecoder decodeObjectForKey: @"NSPathSeparator"];
int flags; long flags;
// start //
NSSize bs;
//NSScroller *hs;
/* Created the shared titleCell if it hasn't been created already. */
if (!titleCell)
{
titleCell = [GSBrowserTitleCell new];
}
// Class setting
_browserCellPrototype = [[[NSBrowser cellClass] alloc] init];
_browserMatrixClass = [NSMatrix class];
// Default values
_pathSeparator = @"/";
_allowsBranchSelection = YES;
_allowsEmptySelection = YES;
_allowsMultipleSelection = YES;
_reusesColumns = NO;
_separatesColumns = YES;
_isTitled = YES;
_takesTitleFromPreviousColumn = YES;
_hasHorizontalScroller = YES;
_isLoaded = NO;
_acceptsArrowKeys = YES;
_acceptsAlphaNumericalKeys = YES;
_lastKeyPressed = 0.;
_charBuffer = nil;
_sendsActionOnArrowKeys = YES;
_sendsActionOnAlphaNumericalKeys = YES;
_browserDelegate = nil;
_passiveDelegate = YES;
_doubleAction = NULL;
bs = _sizeForBorderType (NSBezelBorder);
_minColumnWidth = scrollerWidth + (2 * bs.width);
if (_minColumnWidth < 100.0)
_minColumnWidth = 100.0;
// Horizontal scroller
_scrollerRect.origin.x = bs.width;
_scrollerRect.origin.y = bs.height;
_scrollerRect.size.width = _frame.size.width - (2 * bs.width);
_scrollerRect.size.height = scrollerWidth;
_horizontalScroller = [[NSScroller alloc] initWithFrame: _scrollerRect];
[_horizontalScroller setTarget: self];
[_horizontalScroller setAction: @selector(scrollViaScroller:)];
[self addSubview: _horizontalScroller];
_skipUpdateScroller = NO;
// Columns
_browserColumns = [[NSMutableArray alloc] init];
// Create a single column
_lastColumnLoaded = -1;
_firstVisibleColumn = 0;
_lastVisibleColumn = 0;
_maxVisibleColumns = 3;
[self _createColumn];
// end //
self = [super initWithCoder: aDecoder];
[self setCellPrototype: proto]; [self setCellPrototype: proto];
[self setPathSeparator: sep]; [self setPathSeparator: sep];
[self setTitle: title ofColumn: 0]; [self setTitle: title ofColumn: 0];
@ -2555,16 +2659,16 @@ static NSTextFieldCell *titleCell;
{ {
flags = [aDecoder decodeIntForKey: @"NSBrFlags"]; flags = [aDecoder decodeIntForKey: @"NSBrFlags"];
[self setHasHorizontalScroller: (flags & 0x10000)]; [self setHasHorizontalScroller: ((flags & 0x10000) == 0x10000)];
[self setAllowsEmptySelection: !(flags & 0x20000)]; [self setAllowsEmptySelection: !((flags & 0x20000) == 0x20000)];
[self setSendsActionOnArrowKeys: (flags & 0x40000)]; [self setSendsActionOnArrowKeys: ((flags & 0x40000) == 0x40000)];
[self setAcceptsArrowKeys: (flags & 0x100000)]; [self setAcceptsArrowKeys: ((flags & 0x100000) == 0x100000)];
[self setSeparatesColumns: (flags & 0x4000000)]; [self setSeparatesColumns: ((flags & 0x4000000) == 0x4000000)];
[self setTakesTitleFromPreviousColumn: (flags & 0x8000000)]; [self setTakesTitleFromPreviousColumn: ((flags & 0x8000000) == 0x8000000)];
[self setTitled: (flags & 0x10000000)]; [self setTitled: ((flags & 0x10000000) == 0x10000000)];
[self setReusesColumns: (flags & 0x20000000)]; [self setReusesColumns: ((flags & 0x20000000) == 0x20000000)];
[self setAllowsBranchSelection: (flags & 0x40000000)]; [self setAllowsBranchSelection: ((flags & 0x40000000) == 0x40000000)];
[self setAllowsMultipleSelection: (flags & 0x80000000)]; [self setAllowsMultipleSelection: ((flags & 0x80000000) == 0x80000000)];
} }
if ([aDecoder containsValueForKey: @"NSNumberOfVisibleColumns"]) if ([aDecoder containsValueForKey: @"NSNumberOfVisibleColumns"])

View file

@ -338,14 +338,20 @@ static NSFont *_leafFont;
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL tmp;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
tmp = _browsercell_is_leaf; {
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; // simply encodes prescence...
tmp = _browsercell_is_loaded; }
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; else
[aCoder encodeObject: _alternateImage]; {
BOOL tmp;
tmp = _browsercell_is_leaf;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
tmp = _browsercell_is_loaded;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
[aCoder encodeObject: _alternateImage];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -354,7 +360,7 @@ static NSFont *_leafFont;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
// Nothing special // Nothing to decode...
} }
else else
{ {

View file

@ -500,10 +500,15 @@ static id buttonCellClass = nil;
[NSControl-performClick:] [NSControl-performClick:]
[NSEvent-charactersIgnoringModifiers] [NSEvent-modifierFlags]</p> [NSEvent-charactersIgnoringModifiers] [NSEvent-modifierFlags]</p>
Does nothing and returns NO if the receiver is disabled or if it is
blocked by a modal window being run.
*/ */
- (BOOL) performKeyEquivalent: (NSEvent *)anEvent - (BOOL) performKeyEquivalent: (NSEvent *)anEvent
{ {
if ([self isEnabled]) NSWindow *w = [self window];
if ([self isEnabled] && ([w worksWhenModal] || [NSApp modalWindow] == w))
{ {
NSString *key = [self keyEquivalent]; NSString *key = [self keyEquivalent];

View file

@ -52,6 +52,7 @@
#include "AppKit/NSSound.h" #include "AppKit/NSSound.h"
#include "AppKit/NSWindow.h" #include "AppKit/NSWindow.h"
#include "GNUstepGUI/GSDrawFunctions.h" #include "GNUstepGUI/GSDrawFunctions.h"
#include "GNUstepGUI/GSNibCompatibility.h"
#include <math.h> #include <math.h>
@ -75,13 +76,13 @@ typedef struct _GSButtonCellFlags
unsigned int hasKeyEquiv:1; unsigned int hasKeyEquiv:1;
unsigned int lastState:1; unsigned int lastState:1;
unsigned int isTransparent:1; unsigned int isTransparent:1;
unsigned int unused2:6; // inset:2 doesn't dim:1 gradient:3 unsigned int unused1:6; // inset:2 doesn't dim:1 gradient:3
unsigned int useButtonImageSource:1; unsigned int useButtonImageSource:1;
unsigned int unused3:8; // alt mnemonic loc. unsigned int unused2:8; // alt mnemonic loc.
#else #else
unsigned int unused3:8; // alt mnemonic loc. unsigned int unused2:8; // alt mnemonic loc.
unsigned int useButtonImageSource:1; unsigned int useButtonImageSource:1;
unsigned int unused0:6; // inset:2 doesn't dim:1 gradient:3 unsigned int unused1:6; // inset:2 doesn't dim:1 gradient:3
unsigned int isTransparent:1; unsigned int isTransparent:1;
unsigned int lastState:1; unsigned int lastState:1;
unsigned int hasKeyEquiv:1; unsigned int hasKeyEquiv:1;
@ -1445,25 +1446,110 @@ typedef struct _GSButtonCellFlags
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL tmp;
// FIXME: Add new ivars
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
GSButtonCellFlags buttonCellFlags;
unsigned int bFlags = 0;
unsigned int bFlags2 = 0;
NSImage *image = [self image];
NSButtonImageSource *bi = nil;
[aCoder encodeObject: _keyEquivalent]; if([self keyEquivalent] != nil)
[aCoder encodeObject: _keyEquivalentFont]; {
[aCoder encodeObject: _altContents]; [aCoder encodeObject: [self keyEquivalent] forKey: @"NSKeyEquivalent"];
[aCoder encodeObject: _altImage]; }
tmp = _buttoncell_is_transparent; if([self image] != nil)
[aCoder encodeValueOfObjCType: @encode(BOOL) {
at: &tmp]; [aCoder encodeObject: [self image] forKey: @"NSNormalImage"];
[aCoder encodeValueOfObjCType: @encode(unsigned int) }
at: &_keyEquivalentModifierMask]; if([self alternateTitle] != nil)
[aCoder encodeValueOfObjCType: @encode(unsigned int) {
at: &_highlightsByMask]; [aCoder encodeObject: [self alternateTitle] forKey: @"NSAlternateContents"];
[aCoder encodeValueOfObjCType: @encode(unsigned int) }
at: &_showAltStateMask];
buttonCellFlags.useButtonImageSource = (([NSImage imageNamed: @"NSSwitch"] == image) ||
([NSImage imageNamed: @"NSRadioButton"] == image));
buttonCellFlags.isTransparent = [self isTransparent];
buttonCellFlags.isBordered = [self isBordered];
buttonCellFlags.isImageAndText = (image != nil);
buttonCellFlags.hasKeyEquiv = ([self keyEquivalent] != nil);
// cell attributes...
buttonCellFlags.isPushin = [self cellAttribute: NSPushInCell];
buttonCellFlags.highlightByBackground = [self cellAttribute: NSCellLightsByBackground];
buttonCellFlags.highlightByContents = [self cellAttribute: NSCellLightsByContents];
buttonCellFlags.highlightByGray = [self cellAttribute: NSCellLightsByGray];
buttonCellFlags.changeBackground = [self cellAttribute: NSChangeBackgroundCell];
buttonCellFlags.changeContents = [self cellAttribute: NSCellChangesContents];
buttonCellFlags.changeGray = [self cellAttribute: NSChangeGrayCell];
// set these to zero...
buttonCellFlags.unused1 = 0; // 32;
buttonCellFlags.unused2 = 0; // 255;
buttonCellFlags.lastState = 0;
buttonCellFlags.isImageSizeDiff = 0;
buttonCellFlags.imageDoesOverlap = 0;
buttonCellFlags.drawing = 0;
buttonCellFlags.isBottomOrLeft = 0;
memcpy((void *)&bFlags, (void *)&buttonCellFlags,sizeof(unsigned int));
[aCoder encodeInt: bFlags forKey: @"NSButtonFlags"];
// style and border.
bFlags2 != [self showsBorderOnlyWhileMouseInside] ? 0x8 : 0;
bFlags2 |= [self bezelStyle];
[aCoder encodeInt: bFlags2 forKey: @"NSButtonFlags2"];
// alternate image encoding...
if(image != nil)
{
if ([image isKindOfClass: [NSImage class]] && buttonCellFlags.useButtonImageSource)
{
if([NSImage imageNamed: @"NSSwitch"] == image)
{
bi = [[NSButtonImageSource alloc] initWithImageNamed: @"NSHighlightedSwitch"];
}
else if([NSImage imageNamed: @"NSRadioButton"] == image)
{
bi = [[NSButtonImageSource alloc] initWithImageNamed: @"NSHighlightedRadioButton"];
}
}
}
// encode button image source, if it exists...
if(bi != nil)
{
[aCoder encodeObject: bi forKey: @"NSAlternateImage"];
}
else if(_altImage != nil)
{
[aCoder encodeObject: _altImage forKey: @"NSAlternateImage"];
}
// repeat and delay
[aCoder encodeInt: (int)_delayInterval forKey: @"NSPeriodicDelay"];
[aCoder encodeInt: (int)_repeatInterval forKey: @"NSPeriodicInterval"];
}
else
{
// FIXME: Add new ivars
[aCoder encodeObject: _keyEquivalent];
[aCoder encodeObject: _keyEquivalentFont];
[aCoder encodeObject: _altContents];
[aCoder encodeObject: _altImage];
tmp = _buttoncell_is_transparent;
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_keyEquivalentModifierMask];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_highlightsByMask];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_showAltStateMask];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -1491,36 +1577,27 @@ typedef struct _GSButtonCellFlags
if ([aDecoder containsValueForKey: @"NSButtonFlags"]) if ([aDecoder containsValueForKey: @"NSButtonFlags"])
{ {
unsigned int bFlags = [aDecoder decodeIntForKey: @"NSButtonFlags"]; unsigned int bFlags = [aDecoder decodeIntForKey: @"NSButtonFlags"];
int highlights = 0;
int show_state = NSNoCellMask;
GSButtonCellFlags buttonCellFlags; GSButtonCellFlags buttonCellFlags;
memcpy((void *)&buttonCellFlags,(void *)&bFlags,sizeof(struct _GSButtonCellFlags)); memcpy((void *)&buttonCellFlags,(void *)&bFlags,sizeof(struct _GSButtonCellFlags));
[self setTransparent: buttonCellFlags.isTransparent]; [self setTransparent: buttonCellFlags.isTransparent];
[self setBordered: buttonCellFlags.isBordered]; [self setBordered: buttonCellFlags.isBordered];
if (buttonCellFlags.highlightByBackground) [self setCellAttribute: NSPushInCell
{ to: buttonCellFlags.isPushin];
highlights |= NSChangeBackgroundCellMask; [self setCellAttribute: NSCellLightsByBackground
} to: buttonCellFlags.highlightByBackground];
if (buttonCellFlags.highlightByContents) [self setCellAttribute: NSCellLightsByContents
{ to: buttonCellFlags.highlightByContents];
highlights |= NSContentsCellMask; [self setCellAttribute: NSCellLightsByGray
} to: buttonCellFlags.highlightByGray];
if (buttonCellFlags.changeBackground) [self setCellAttribute: NSChangeBackgroundCell
{ to: buttonCellFlags.changeBackground];
show_state |= NSChangeBackgroundCellMask; [self setCellAttribute: NSCellChangesContents
} to: buttonCellFlags.changeContents];
if (buttonCellFlags.changeContents) [self setCellAttribute: NSChangeGrayCell
{ to: buttonCellFlags.changeGray];
show_state |= NSContentsCellMask;
}
if (buttonCellFlags.isPushin)
{
highlights |= NSPushInCellMask;
}
[self setHighlightsBy: highlights];
[self setShowsStateBy: show_state];
[self setImagePosition: NSImageLeft]; [self setImagePosition: NSImageLeft];
} }
if ([aDecoder containsValueForKey: @"NSButtonFlags2"]) if ([aDecoder containsValueForKey: @"NSButtonFlags2"])

View file

@ -167,16 +167,21 @@
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeObject: _window]; if([aCoder allowsKeyedCoding] == NO)
[aCoder encodeRect: _rect]; {
[aCoder encodeObject: _window];
[aCoder encodeRect: _rect];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_window]; if([aDecoder allowsKeyedCoding] == NO)
_rect = [aDecoder decodeRect]; {
[aDecoder decodeValueOfObjCType: @encode(id) at: &_window];
_rect = [aDecoder decodeRect];
}
return self; return self;
} }

View file

@ -688,30 +688,24 @@ static NSColor *shadowCol;
} }
/**<p>Sets whether the cell has a bezeled border. /**<p>Sets whether the cell has a bezeled border.
If the cell has a bezeled border, the bordered flag is turn off. If this method is called, the bordered flag is turn off.
By default a NSCell has no bezeled border</p> By default a NSCell has no bezeled border</p>
<p>See Also: -isBezeled -setBordered: -isBordered</p> <p>See Also: -isBezeled -setBordered: -isBordered</p>
*/ */
- (void) setBezeled: (BOOL)flag - (void) setBezeled: (BOOL)flag
{ {
_cell.is_bezeled = flag; _cell.is_bezeled = flag;
if (_cell.is_bezeled) _cell.is_bordered = NO;
{
_cell.is_bordered = NO;
}
} }
/**<p>Sets whether the cell has a border. If the cell has a border, /**<p>Sets whether the cell has a border. If this method is called,
the bezeled flag is turn off. By default a NSCell has no border</p> the bezeled flag is turn off. By default a NSCell has no border</p>
<p>See Also: -isBordered -setBezeled: -isBezeled</p> <p>See Also: -isBordered -setBezeled: -isBezeled</p>
*/ */
- (void) setBordered: (BOOL)flag - (void) setBordered: (BOOL)flag
{ {
_cell.is_bordered = flag; _cell.is_bordered = flag;
if (_cell.is_bordered) _cell.is_bezeled = NO;
{
_cell.is_bezeled = NO;
}
} }
/**<p>Sets the NSCell's state. Please use always symbolic constants when /**<p>Sets the NSCell's state. Please use always symbolic constants when
@ -1528,6 +1522,7 @@ static NSColor *shadowCol;
NSPoint last_point = point; NSPoint last_point = point;
BOOL done; BOOL done;
BOOL mouseWentUp; BOOL mouseWentUp;
unsigned periodCount = 0;
NSDebugLLog(@"NSCell", @"cell start tracking in rect %@ initial point %f %f", NSDebugLLog(@"NSCell", @"cell start tracking in rect %@ initial point %f %f",
NSStringFromRect(cellFrame), point.x, point.y); NSStringFromRect(cellFrame), point.x, point.y);
@ -1557,7 +1552,6 @@ static NSColor *shadowCol;
{ {
NSEventType eventType; NSEventType eventType;
BOOL pointIsInCell; BOOL pointIsInCell;
unsigned periodCount = 0;
theEvent = [theApp nextEventMatchingMask: event_mask theEvent = [theApp nextEventMatchingMask: event_mask
untilDate: nil untilDate: nil
@ -2185,75 +2179,132 @@ static NSColor *shadowCol;
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL flag; if([aCoder allowsKeyedCoding])
unsigned int tmp_int; {
unsigned long cFlags = 0;
unsigned int cFlags2 = 0;
[aCoder encodeObject: _contents]; // encode contents
[aCoder encodeObject: _cell_image]; [aCoder encodeObject: _contents forKey: @"NSContents"];
[aCoder encodeObject: _font];
[aCoder encodeObject: _objectValue]; // flags
flag = _cell.contents_is_attributed_string; cFlags |= [self wraps] ? 0x40 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; cFlags |= [self isScrollable] ? 0x100000 : 0;
flag = _cell.is_highlighted; cFlags |= [self isSelectable] ? 0x200001 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; cFlags |= [self isBezeled] ? 0x400000 : 0;
flag = _cell.is_disabled; cFlags |= [self isBordered] ? 0x800000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; cFlags |= ([self type] == NSTextCellType) ? 0x4000000 : 0;
flag = _cell.is_editable; cFlags |= [self isContinuous] ? 0x40000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; cFlags |= [self isEditable] ? 0x10000000 : 0;
flag = _cell.is_rich_text; cFlags |= ([self isEnabled] == NO) ? 0x20000000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; cFlags |= ([self state] == NSOnState) ? 0x80000000 : 0;
flag = _cell.imports_graphics; cFlags |= [self isHighlighted] ? 0x40000000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeInt: cFlags forKey: @"NSCellFlags"];
flag = _cell.shows_first_responder;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; // flags part 2
flag = _cell.refuses_first_responder; cFlags2 |= [self sendsActionOnEndEditing] ? 0x400000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; cFlags2 |= [self allowsMixedState] ? 0x1000000 : 0;
flag = _cell.sends_action_on_end_editing; cFlags2 |= [self refusesFirstResponder] ? 0x2000000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; cFlags2 |= ([self alignment] == NSRightTextAlignment) ? 0x4000000 : 0;
flag = _cell.is_bordered; cFlags2 |= ([self alignment] == NSCenterTextAlignment) ? 0x8000000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; cFlags2 |= ([self alignment] == NSJustifiedTextAlignment) ? 0xC000000 : 0;
flag = _cell.is_bezeled; cFlags2 |= ([self alignment] == NSNaturalTextAlignment) ? 0x10000000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; cFlags2 |= [self importsGraphics] ? 0x20000000 : 0;
flag = _cell.is_scrollable; cFlags2 |= [self allowsEditingTextAttributes] ? 0x40000000 : 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeInt: cFlags2 forKey: @"NSCellFlags2"];
flag = _cell.is_selectable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; // font and formatter.
// This used to be is_continuous, which has been replaced. [aCoder encodeObject: [self font] forKey: @"NSSupport"];
/* Ayers 20.03.2003: But we must continue to encode it for backward
compatibility or current releases will have undefined behavior when if([self formatter])
decoding archives (i.e. .gorm files) encoded by this version. */ {
flag = [self isContinuous]; [aCoder encodeObject: [self formatter] forKey: @"NSFormatter"];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; }
flag = _cell.allows_mixed_state; }
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; else
flag = _cell.wraps; {
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; BOOL flag;
tmp_int = _cell.text_align; unsigned int tmp_int;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.type; [aCoder encodeObject: _contents];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; [aCoder encodeObject: _cell_image];
tmp_int = _cell.image_position; [aCoder encodeObject: _font];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; [aCoder encodeObject: _objectValue];
tmp_int = _cell.entry_type; flag = _cell.contents_is_attributed_string;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
tmp_int = _cell.state; flag = _cell.is_highlighted;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mnemonic_location]; flag = _cell.is_disabled;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mouse_down_flags]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_action_mask]; flag = _cell.is_editable;
[aCoder encodeValueOfObjCType: @encode(id) at: &_formatter]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
[aCoder encodeValueOfObjCType: @encode(id) at: &_menu]; flag = _cell.is_rich_text;
[aCoder encodeValueOfObjCType: @encode(id) at: &_represented_object]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.imports_graphics;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.shows_first_responder;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.refuses_first_responder;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.sends_action_on_end_editing;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_bordered;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_bezeled;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_scrollable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_selectable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
// This used to be is_continuous, which has been replaced.
/* Ayers 20.03.2003: But we must continue to encode it for backward
compatibility or current releases will have undefined behavior when
decoding archives (i.e. .gorm files) encoded by this version. */
flag = [self isContinuous];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.allows_mixed_state;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.wraps;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
tmp_int = _cell.text_align;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.image_position;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.entry_type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.state;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mnemonic_location];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mouse_down_flags];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
[aCoder encodeValueOfObjCType: @encode(id) at: &_formatter];
[aCoder encodeValueOfObjCType: @encode(id) at: &_menu];
[aCoder encodeValueOfObjCType: @encode(id) at: &_represented_object];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
NSString *contents = [aDecoder decodeObjectForKey: @"NSContents"]; id contents = [aDecoder decodeObjectForKey: @"NSContents"];
self = [self initTextCell: contents];
// initialize based on content...
if([contents isKindOfClass: [NSString class]])
{
self = [self initTextCell: contents];
}
else if([contents isKindOfClass: [NSImage class]])
{
self = [self initImageCell: contents];
}
else
{
self = [self init];
}
if ([aDecoder containsValueForKey: @"NSCellFlags"]) if ([aDecoder containsValueForKey: @"NSCellFlags"])
{ {
unsigned long cFlags; unsigned long cFlags;

View file

@ -799,8 +799,13 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
if ([[self subviews] count] > 0) if ([[self subviews] count] > 0)
{ {
id document = [aDecoder decodeObjectForKey: @"NSDocView"]; id document = [aDecoder decodeObjectForKey: @"NSDocView"];
NSRect rect = [document frame];
rect.origin = NSZeroPoint;
[document setFrame: rect];
RETAIN(document); // prevent it from being released.
[self removeSubview: document]; [self removeSubview: document];
[self setDocumentView: document]; [self setDocumentView: document];
RELEASE(document);
} }
} }
else else

View file

@ -1253,17 +1253,17 @@ systemColorWithName(NSString *name)
if (colorSpace == 1) if (colorSpace == 1)
{ {
self = [NSColor colorWithCalibratedRed: red self = RETAIN([NSColor colorWithCalibratedRed: red
green: green green: green
blue: blue blue: blue
alpha: alpha]; alpha: alpha]);
} }
else else
{ {
self = [NSColor colorWithDeviceRed: red self = RETAIN([NSColor colorWithDeviceRed: red
green: green green: green
blue: blue blue: blue
alpha: alpha]; alpha: alpha]);
} }
} }
else if ((colorSpace == 3) || (colorSpace == 4)) else if ((colorSpace == 3) || (colorSpace == 4))
@ -1289,13 +1289,13 @@ systemColorWithName(NSString *name)
if (colorSpace == 3) if (colorSpace == 3)
{ {
self = [NSColor colorWithCalibratedWhite: white self = RETAIN([NSColor colorWithCalibratedWhite: white
alpha: alpha]; alpha: alpha]);
} }
else else
{ {
self = [NSColor colorWithDeviceWhite: white self = RETAIN([NSColor colorWithDeviceWhite: white
alpha: alpha]; alpha: alpha]);
} }
} }
else if (colorSpace == 5) else if (colorSpace == 5)
@ -1325,11 +1325,11 @@ systemColorWithName(NSString *name)
RELEASE(str); RELEASE(str);
} }
self = [NSColor colorWithDeviceCyan: cyan self = RETAIN([NSColor colorWithDeviceCyan: cyan
magenta: magenta magenta: magenta
yellow: yellow yellow: yellow
black: black black: black
alpha: alpha]; alpha: alpha]);
} }
else if (colorSpace == 6) else if (colorSpace == 6)
{ {
@ -1337,14 +1337,14 @@ systemColorWithName(NSString *name)
NSString *name = [aDecoder decodeObjectForKey: @"NSColorName"]; NSString *name = [aDecoder decodeObjectForKey: @"NSColorName"];
//NSColor *color = [aDecoder decodeObjectForKey: @"NSColor"]; //NSColor *color = [aDecoder decodeObjectForKey: @"NSColor"];
self = [NSColor colorWithCatalogName: catalog self = RETAIN([NSColor colorWithCatalogName: catalog
colorName: name]; colorName: name]);
} }
else if (colorSpace == 10) else if (colorSpace == 10)
{ {
NSImage *image = [aDecoder decodeObjectForKey: @"NSImage"]; NSImage *image = [aDecoder decodeObjectForKey: @"NSImage"];
self = [NSColor colorWithPatternImage: image]; self = RETAIN([NSColor colorWithPatternImage: image]);
} }
return self; return self;
@ -1673,7 +1673,7 @@ systemColorWithName(NSString *name)
} }
else else
{ {
GSNamedColor *aCopy = NSCopyObject(self, 0, aZone); GSNamedColor *aCopy = (GSNamedColor*)NSCopyObject(self, 0, aZone);
aCopy->_catalog_name = [_catalog_name copyWithZone: aZone]; aCopy->_catalog_name = [_catalog_name copyWithZone: aZone];
aCopy->_color_name = [_color_name copyWithZone: aZone]; aCopy->_color_name = [_color_name copyWithZone: aZone];
@ -2893,7 +2893,7 @@ systemColorWithName(NSString *name)
} }
else else
{ {
GSPatternColor *aCopy = NSCopyObject(self, 0, aZone); GSPatternColor *aCopy = (GSPatternColor*)NSCopyObject(self, 0, aZone);
aCopy->_pattern = [_pattern copyWithZone: aZone]; aCopy->_pattern = [_pattern copyWithZone: aZone];
return aCopy; return aCopy;

View file

@ -695,12 +695,12 @@ static GSComboWindow *gsWindow = nil;
{ {
if (_cell != nil) if (_cell != nil)
{ {
NSText *textObject = nil; NSText *textObject = nil;
NSControl *cv = [_cell controlView]; id cv = [_cell controlView];
if ([cv isKindOfClass: [NSControl class]]) if ([cv isKindOfClass: [NSControl class]])
{ {
textObject = [(NSControl *)cv currentEditor]; textObject = [(NSControl *)cv currentEditor];
} }
[_cell setStringValue: [_cell _stringValueAtIndex: [_cell setStringValue: [_cell _stringValueAtIndex:
@ -1654,18 +1654,26 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
{ {
[super encodeWithCoder: coder]; [super encodeWithCoder: coder];
[coder encodeValueOfObjCType: @encode(id) at: &_popUpList]; if([coder allowsKeyedCoding])
[coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource]; {
[coder encodeValueOfObjCType: @encode(BOOL) at: &_hasVerticalScroller]; [coder encodeBool: [self hasVerticalScroller] forKey: @"NSHasVerticalScroller"];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_completes]; [coder encodeInt: [self numberOfVisibleItems] forKey: @"NSVisibleItemCount"];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource]; }
[coder encodeValueOfObjCType: @encode(int) at: &_visibleItems]; else
[coder encodeValueOfObjCType: @encode(NSSize) at: &_intercellSpacing]; {
[coder encodeValueOfObjCType: @encode(float) at: &_itemHeight]; [coder encodeValueOfObjCType: @encode(id) at: &_popUpList];
[coder encodeValueOfObjCType: @encode(int) at: &_selectedItem]; [coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_hasVerticalScroller];
if (_usesDataSource == YES) [coder encodeValueOfObjCType: @encode(BOOL) at: &_completes];
[coder encodeConditionalObject: _dataSource]; [coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
[coder encodeValueOfObjCType: @encode(int) at: &_visibleItems];
[coder encodeValueOfObjCType: @encode(NSSize) at: &_intercellSpacing];
[coder encodeValueOfObjCType: @encode(float) at: &_itemHeight];
[coder encodeValueOfObjCType: @encode(int) at: &_selectedItem];
if (_usesDataSource == YES)
[coder encodeConditionalObject: _dataSource];
}
} }
/** /**

View file

@ -732,82 +732,63 @@ static Class actionCellClass;
*/ */
- (void) mouseDown: (NSEvent *)theEvent - (void) mouseDown: (NSEvent *)theEvent
{ {
NSApplication *theApp = [NSApplication sharedApplication];
BOOL mouseUp = NO, done = NO;
NSEvent *e;
int oldActionMask;
NSPoint location;
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask
| NSMouseMovedMask | NSLeftMouseDraggedMask | NSOtherMouseDraggedMask | NSMouseMovedMask | NSLeftMouseDraggedMask | NSOtherMouseDraggedMask
| NSRightMouseDraggedMask; | NSRightMouseDraggedMask;
BOOL mouseUp = NO;
// If not enabled ignore mouse clicks
if (![self isEnabled]) if (![self isEnabled])
return; return;
// Ignore multiple clicks, if configured to do so
if (_ignoresMultiClick && ([theEvent clickCount] > 1)) if (_ignoresMultiClick && ([theEvent clickCount] > 1))
{ {
[super mouseDown: theEvent]; [super mouseDown: theEvent];
return; return;
} }
if ([_cell isContinuous])
{
oldActionMask = [_cell sendActionOn: NSPeriodicMask];
}
else
{
oldActionMask = [_cell sendActionOn: 0];
}
[_window _captureMouse: self];
e = theEvent;
// loop until mouse goes up // loop until mouse goes up
while (!done) while (1)
{ {
location = [e locationInWindow]; NSPoint location = [self convertPoint: [theEvent locationInWindow]
location = [self convertPoint: location fromView: nil]; fromView: nil];
// ask the cell to track the mouse only
// ask the cell to track the mouse only,
// if the mouse is within the cell // if the mouse is within the cell
if ([self mouse: location inRect: _bounds]) if ([self mouse: location inRect: _bounds])
{ {
BOOL done;
[_cell setHighlighted: YES]; [_cell setHighlighted: YES];
[self setNeedsDisplay: YES]; [self setNeedsDisplay: YES];
if ([_cell trackMouse: e done = [_cell trackMouse: theEvent
inRect: _bounds inRect: _bounds
ofView: self ofView: self
untilMouseUp: [[_cell class] prefersTrackingUntilMouseUp]]) untilMouseUp: [[_cell class] prefersTrackingUntilMouseUp]];
done = mouseUp = YES; [_cell setHighlighted: NO];
else [self setNeedsDisplay: YES];
{
[_cell setHighlighted: NO]; if (done)
[self setNeedsDisplay: YES]; break;
}
} }
if (done) theEvent = [NSApp nextEventMatchingMask: event_mask
break; untilDate: nil
inMode: NSEventTrackingRunLoopMode
e = [theApp nextEventMatchingMask: event_mask dequeue: YES];
untilDate: nil if ([theEvent type] == NSLeftMouseUp)
inMode: NSEventTrackingRunLoopMode {
dequeue: YES]; mouseUp = YES;
if ([e type] == NSLeftMouseUp) break;
done = YES; }
} }
[_window _releaseMouse: self]; // Mouse went up inside the control but not inside the cell
if (mouseUp) if (mouseUp)
{ {
[_cell setHighlighted: NO]; [self sendAction: [self action] to: [self target]];
[self setNeedsDisplay: YES];
} }
[_cell sendActionOn: oldActionMask];
if (mouseUp)
[self sendAction: [self action] to: [self target]];
} }
- (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent - (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent
@ -843,10 +824,17 @@ static Class actionCellClass;
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(int) at: &_tag]; {
[aCoder encodeObject: _cell]; [aCoder encodeObject: [self cell] forKey: @"NSCell"];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_ignoresMultiClick]; [aCoder encodeBool: [self isEnabled] forKey: @"NSEnabled"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(int) at: &_tag];
[aCoder encodeObject: _cell];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_ignoresMultiClick];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -855,7 +843,7 @@ static Class actionCellClass;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
NSCell *cell = [aDecoder decodeObjectForKey: @"NSCell"]; NSCell *cell = RETAIN([aDecoder decodeObjectForKey: @"NSCell"]);
if (cell != nil) if (cell != nil)
{ {

View file

@ -448,6 +448,14 @@ backgroundColorHint:(NSColor *)bg
*/ */
[self pop]; [self pop];
} }
else
{
/*
* The cursor was set on entry, we reset it to the default cursor on exit.
* Using push and pop all the time would seem to be a clearer way.
*/
[[NSCursor arrowCursor] set];
}
} }
/**<p>Pops the cursor off the top of the stack and makes the previous /**<p>Pops the cursor off the top of the stack and makes the previous

View file

@ -269,79 +269,154 @@
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL flag = NO; BOOL flag = NO;
if([aCoder allowsKeyedCoding])
{
[aCoder encodeInt: linkNumber forKey: @"GSLinkNumber"];
[aCoder encodeInt: disposition forKey: @"GSUpdateMode"];
[aCoder encodeInt: updateMode forKey: @"GSLastUpdateMode"];
[aCoder encodeValueOfObjCType: @encode(int) at: &linkNumber]; [aCoder encodeObject: lastUpdateTime forKey: @"GSLastUpdateTime"];
[aCoder encodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder encodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder encodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceApplicationName]; [aCoder encodeObject: sourceApplicationName forKey: @"GSSourceApplicationName"];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceFilename]; [aCoder encodeObject: sourceFilename forKey: @"GSSourceFilename"];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceSelection]; [aCoder encodeObject: sourceSelection forKey: @"GSSourceSelection"];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceManager]; [aCoder encodeObject: sourceManager forKey: @"GSSourceManager"];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationApplicationName]; [aCoder encodeObject: destinationApplicationName forKey: @"GSDestinationApplicationName"];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationFilename]; [aCoder encodeObject: destinationFilename forKey: @"GSDestinationFilename"];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationSelection]; [aCoder encodeObject: destinationSelection forKey: @"GSDestinationSelection"];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager]; [aCoder encodeObject: destinationManager forKey: @"GSDestinationManager"];
[aCoder encodeValueOfObjCType: @encode(id) at: &types]; [aCoder encodeObject: types forKey: @"GSTypes"];
// flags... // flags...
flag = _flags.appVerifies; flag = _flags.appVerifies;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSAppVerifies"];
flag = _flags.canUpdateContinuously; flag = _flags.canUpdateContinuously;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSCanUpdateContinuously"];
flag = _flags.isDirty; flag = _flags.isDirty;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSIsDirty"];
flag = _flags.willOpenSource; flag = _flags.willOpenSource;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSWillOpenSource"];
flag = _flags.willUpdate; flag = _flags.willUpdate;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSWillUpdate"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(int) at: &linkNumber];
[aCoder encodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder encodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder encodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceFilename];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceSelection];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationApplicationName];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationFilename];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationSelection];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &types];
// flags...
flag = _flags.appVerifies;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.canUpdateContinuously;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.isDirty;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.willOpenSource;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.willUpdate;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
}
} }
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
int version = [aCoder versionForClassName: @"NSDataLink"]; if([aCoder allowsKeyedCoding])
if (version == 0)
{ {
BOOL flag = NO; id obj;
[aCoder decodeValueOfObjCType: @encode(int) at: &linkNumber]; linkNumber = [aCoder decodeIntForKey: @"GSLinkNumber"];
[aCoder decodeValueOfObjCType: @encode(int) at: &disposition]; disposition = [aCoder decodeIntForKey: @"GSDisposition"];
[aCoder decodeValueOfObjCType: @encode(int) at: &updateMode]; updateMode = [aCoder decodeIntForKey: @"GSUpdateMode"];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceApplicationName]; obj = [aCoder decodeObjectForKey: @"GSSourceManager"];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceFilename]; ASSIGN(sourceManager,obj);
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceSelection]; obj = [aCoder decodeObjectForKey: @"GSDestinationManager"];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager]; ASSIGN(destinationManager,obj);
obj = [aCoder decodeObjectForKey: @"GSLastUpdateTime"];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationApplicationName]; ASSIGN(lastUpdateTime, obj);
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationFilename]; obj = [aCoder decodeObjectForKey: @"GSSourceApplicationName"];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationSelection]; ASSIGN(sourceApplicationName,obj);
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager]; obj = [aCoder decodeObjectForKey: @"GSSourceFilename"];
ASSIGN(sourceFilename,obj);
[aCoder decodeValueOfObjCType: @encode(id) at: &types]; obj = [aCoder decodeObjectForKey: @"GSSourceSelection"];
ASSIGN(sourceSelection,obj);
obj = [aCoder decodeObjectForKey: @"GSSourceManager"];
ASSIGN(sourceManager,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationApplicationName"];
ASSIGN(destinationApplicationName,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationFilename"];
ASSIGN(destinationFilename,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationSelection"];
ASSIGN(destinationSelection,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationManager"];
ASSIGN(destinationManager,obj);
obj = [aCoder decodeObjectForKey: @"GSTypes"];
ASSIGN(types,obj);
// flags... // flags...
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; _flags.appVerifies = [aCoder decodeBoolForKey: @"GSAppVerifies"];
_flags.appVerifies = flag; _flags.canUpdateContinuously = [aCoder decodeBoolForKey: @"GSCanUpdateContinuously"];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; _flags.isDirty = [aCoder decodeBoolForKey: @"GSIsDirty"];
_flags.canUpdateContinuously = flag; _flags.willOpenSource = [aCoder decodeBoolForKey: @"GSWillOpenSource"];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; _flags.willUpdate = [aCoder decodeBoolForKey: @"GSWillUpdate"];
_flags.isDirty = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willOpenSource = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willUpdate = flag;
} }
else else
{ {
return nil; int version = [aCoder versionForClassName: @"NSDataLink"];
if (version == 0)
{
BOOL flag = NO;
[aCoder decodeValueOfObjCType: @encode(int) at: &linkNumber];
[aCoder decodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder decodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceFilename];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceSelection];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationApplicationName];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationFilename];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationSelection];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &types];
// flags...
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.appVerifies = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.canUpdateContinuously = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.isDirty = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willOpenSource = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willUpdate = flag;
}
else
return nil;
} }
return self; return self;

View file

@ -333,46 +333,84 @@
{ {
BOOL flag = NO; BOOL flag = NO;
[aCoder encodeValueOfObjCType: @encode(id) at: &filename]; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceLinks]; {
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationLinks]; [aCoder encodeObject: filename forKey: @"GSFilename"];
[aCoder encodeObject: sourceLinks forKey: @"GSSourceLinks"];
flag = _flags.areLinkOutlinesVisible; [aCoder encodeObject: destinationLinks forKey: @"GSDestinationLinks"];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.delegateVerifiesLinks; flag = _flags.areLinkOutlinesVisible;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSAreLinkOutlinesVisible"];
flag = _flags.interactsWithUser; flag = _flags.delegateVerifiesLinks;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSDelegateVerifiesLinks"];
flag = _flags.isEdited; flag = _flags.interactsWithUser;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSInteractsWithUser"];
flag = _flags.isEdited;
[aCoder encodeBool: flag forKey: @"GSIsEdited"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(id) at: &filename];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationLinks];
flag = _flags.areLinkOutlinesVisible;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.delegateVerifiesLinks;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.interactsWithUser;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.isEdited;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
}
} }
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
int version = [aCoder versionForClassName: @"NSDataLinkManager"]; if([aCoder allowsKeyedCoding])
if (version == 0)
{ {
BOOL flag = NO; BOOL flag = NO;
id obj;
obj = [aCoder decodeObjectForKey: @"GSFilename"];
ASSIGN(filename,obj);
obj = [aCoder decodeObjectForKey: @"GSSourceLinks"];
ASSIGN(sourceLinks,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationLinks"];
ASSIGN(destinationLinks,obj);
[aCoder decodeValueOfObjCType: @encode(id) at: &filename]; flag = [aCoder decodeBoolForKey: @"GSAreLinkOutlinesVisible"];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationLinks];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.areLinkOutlinesVisible = flag; _flags.areLinkOutlinesVisible = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; flag = [aCoder decodeBoolForKey: @"GSDelegateVerifiesLinks"];
_flags.delegateVerifiesLinks = flag; _flags.delegateVerifiesLinks = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; flag = [aCoder decodeBoolForKey: @"GSInteractsWithUser"];
_flags.interactsWithUser = flag; _flags.interactsWithUser = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; flag = [aCoder decodeBoolForKey: @"GSIsEdited"];
_flags.isEdited = flag; _flags.isEdited = flag;
} }
else else
{ {
return nil; int version = [aCoder versionForClassName: @"NSDataLinkManager"];
if (version == 0)
{
BOOL flag = NO;
[aCoder decodeValueOfObjCType: @encode(id) at: &filename];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationLinks];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.areLinkOutlinesVisible = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.delegateVerifiesLinks = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.interactsWithUser = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.isEdited = flag;
}
else
return nil;
} }
return self; return self;
} }

View file

@ -36,6 +36,7 @@
#include "AppKit/NSView.h" #include "AppKit/NSView.h"
#include "AppKit/NSPopUpButton.h" #include "AppKit/NSPopUpButton.h"
#include "AppKit/NSDocumentFrameworkPrivate.h" #include "AppKit/NSDocumentFrameworkPrivate.h"
#include "AppKit/NSBox.h"
#include "GSGuiPrivate.h" #include "GSGuiPrivate.h"
@ -77,6 +78,7 @@
if ([fileTypes count]) if ([fileTypes count])
{ {
[self setFileType: [fileTypes objectAtIndex: 0]]; [self setFileType: [fileTypes objectAtIndex: 0]];
ASSIGN(_saveType, [fileTypes objectAtIndex: 0]);
} }
} }
return self; return self;
@ -145,6 +147,7 @@
RELEASE(_printInfo); RELEASE(_printInfo);
RELEASE(savePanelAccessory); RELEASE(savePanelAccessory);
RELEASE(spaButton); RELEASE(spaButton);
RELEASE(_saveType);
[super dealloc]; [super dealloc];
} }
@ -207,7 +210,11 @@
_window = aWindow; _window = aWindow;
} }
//FIXME: In the later specification this method has a different return type!! /**
* Creates the window controllers for the current document. Calls
* addWindowController: on the receiver to add them to the controller
* array.
*/
- (void) makeWindowControllers - (void) makeWindowControllers
{ {
NSString *name = [self windowNibName]; NSString *name = [self windowNibName];
@ -452,7 +459,17 @@
- (IBAction)changeSaveType: (id)sender - (IBAction)changeSaveType: (id)sender
{ {
//FIXME if we have accessory -- store the desired save type somewhere. NSDocumentController *controller =
[NSDocumentController sharedDocumentController];
NSArray *extensions = nil;
ASSIGN(_saveType, [controller _nameForHumanReadableType:
[sender titleOfSelectedItem]]);
extensions = [controller fileExtensionsFromType: _saveType];
if([extensions count] > 0)
{
[(NSSavePanel *)[sender window] setRequiredFileType: [extensions objectAtIndex:0]];
}
} }
- (int)runModalSavePanel: (NSSavePanel *)savePanel - (int)runModalSavePanel: (NSSavePanel *)savePanel
@ -467,13 +484,54 @@
return YES; return YES;
} }
- (void) _loadPanelAccessoryNib - (void) _createPanelAccessory
{ {
// FIXME. We need to load the pop-up button if(savePanelAccessory == nil)
{
NSRect accessoryFrame = NSMakeRect(0,0,380,70);
NSRect spaFrame = NSMakeRect(115,14,150,22);
savePanelAccessory = [[NSBox alloc] initWithFrame: accessoryFrame];
[(NSBox *)savePanelAccessory setTitle: @"File Type"];
[savePanelAccessory setAutoresizingMask:
NSViewWidthSizable | NSViewHeightSizable];
spaButton = [[NSPopUpButton alloc] initWithFrame: spaFrame];
[spaButton setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable | NSViewMinYMargin |
NSViewMaxYMargin | NSViewMinXMargin | NSViewMaxXMargin];
[spaButton setTarget: self];
[spaButton setAction: @selector(changeSaveType:)];
[savePanelAccessory addSubview: spaButton];
}
} }
- (void) _addItemsToSpaButtonFromArray: (NSArray *)types - (void) _addItemsToSpaButtonFromArray: (NSArray *)types
{ {
// FIXME. Add types to popup. NSEnumerator *en = [types objectEnumerator];
NSString *title = nil;
int i = 0;
while((title = [en nextObject]) != nil)
{
[spaButton addItemWithTitle: title];
i++;
}
// if it's more than one, then
[spaButton setEnabled: (i > 0)];
// if we have some items, select the current filetype.
if(i > 0)
{
NSString *title = [[NSDocumentController sharedDocumentController]
displayNameForType: [self fileType]];
if([spaButton itemWithTitle: title] != nil)
{
[spaButton selectItemWithTitle: title];
}
else
{
[spaButton selectItemAtIndex: 0];
}
}
} }
- (NSString *)fileNameFromRunningSavePanelForSaveOperation: (NSSaveOperationType)saveOperation - (NSString *)fileNameFromRunningSavePanelForSaveOperation: (NSSaveOperationType)saveOperation
@ -481,25 +539,32 @@
NSView *accessory = nil; NSView *accessory = nil;
NSString *title; NSString *title;
NSString *directory; NSString *directory;
NSArray *extensions; NSArray *displayNames;
NSDocumentController *controller; NSDocumentController *controller;
NSSavePanel *savePanel = [NSSavePanel savePanel]; NSSavePanel *savePanel = [NSSavePanel savePanel];
controller = [NSDocumentController sharedDocumentController]; controller = [NSDocumentController sharedDocumentController];
extensions = [controller fileExtensionsFromType:[self fileType]]; displayNames = [controller _displayNamesForClass: [self class]];
if ([self shouldRunSavePanelWithAccessoryView]) if ([self shouldRunSavePanelWithAccessoryView])
{ {
if (savePanelAccessory == nil) if (savePanelAccessory == nil)
[self _loadPanelAccessoryNib]; [self _createPanelAccessory];
[self _addItemsToSpaButtonFromArray: extensions]; [self _addItemsToSpaButtonFromArray: displayNames];
accessory = savePanelAccessory; accessory = savePanelAccessory;
} }
if ([extensions count] > 0) if ([displayNames count] > 0)
[savePanel setRequiredFileType:[extensions objectAtIndex:0]]; {
NSArray *extensions = [[NSDocumentController sharedDocumentController]
fileExtensionsFromType: [self fileTypeFromLastRunSavePanel]];
if([extensions count] > 0)
{
[savePanel setRequiredFileType:[extensions objectAtIndex:0]];
}
}
switch (saveOperation) switch (saveOperation)
{ {
@ -641,9 +706,7 @@
- (NSString *)fileTypeFromLastRunSavePanel - (NSString *)fileTypeFromLastRunSavePanel
{ {
// FIXME this should return type picked on save accessory return _saveType;
// return [spaPopupButton title];
return [self fileType];
} }
- (NSDictionary *)fileAttributesToWriteToFile: (NSString *)fullDocumentPath - (NSDictionary *)fileAttributesToWriteToFile: (NSString *)fullDocumentPath
@ -668,54 +731,63 @@
{ {
NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *backupFilename = nil; NSString *backupFilename = nil;
BOOL isNativeType = [[self class] isNativeType: fileType];
if (fileName) if (fileName && isNativeType)
{ {
if ([fileManager fileExistsAtPath: fileName]) NSArray *extensions = [[NSDocumentController sharedDocumentController]
fileExtensionsFromType: fileType];
if([extensions count] > 0)
{ {
NSString *extension = [fileName pathExtension]; NSString *extension = [extensions objectAtIndex: 0];
NSString *newFileName = [[fileName stringByDeletingPathExtension]
stringByAppendingPathExtension: extension];
backupFilename = [fileName stringByDeletingPathExtension]; if ([fileManager fileExistsAtPath: newFileName])
backupFilename = [backupFilename stringByAppendingString:@"~"]; {
backupFilename = [backupFilename stringByAppendingPathExtension: extension]; backupFilename = [newFileName stringByDeletingPathExtension];
backupFilename = [backupFilename stringByAppendingString:@"~"];
/* Save panel has already asked if the user wants to replace it */ backupFilename = [backupFilename stringByAppendingPathExtension: extension];
/* NSFileManager movePath: will fail if destination exists */
if ([fileManager fileExistsAtPath: backupFilename])
[fileManager removeFileAtPath: backupFilename handler: nil];
// Move or copy?
if (![fileManager movePath: fileName toPath: backupFilename handler: nil] &&
[self keepBackupFile])
{
int result = NSRunAlertPanel(_(@"File Error"),
_(@"Can't create backup file. Save anyways?"),
_(@"Save"), _(@"Cancel"), nil);
if (result != NSAlertDefaultReturn) return NO; /* Save panel has already asked if the user wants to replace it */
}
} /* NSFileManager movePath: will fail if destination exists */
if ([self writeToFile: fileName if ([fileManager fileExistsAtPath: backupFilename])
ofType: fileType [fileManager removeFileAtPath: backupFilename handler: nil];
originalFile: backupFilename
saveOperation: saveOp]) // Move or copy?
{ if (![fileManager movePath: newFileName toPath: backupFilename handler: nil] &&
if (saveOp != NSSaveToOperation) [self keepBackupFile])
{ {
[self setFileName: fileName]; int result = NSRunAlertPanel(_(@"File Error"),
[self setFileType: fileType]; _(@"Can't create backup file. Save anyways?"),
[self updateChangeCount: NSChangeCleared]; _(@"Save"), _(@"Cancel"), nil);
if (result != NSAlertDefaultReturn) return NO;
}
} }
if ([self writeToFile: fileName
// FIXME: Should set the file attributes ofType: fileType
originalFile: backupFilename
if (backupFilename && ![self keepBackupFile]) saveOperation: saveOp])
{ {
[fileManager removeFileAtPath: backupFilename handler: nil]; if (saveOp != NSSaveToOperation)
{
[self setFileName: newFileName];
[self setFileType: fileType];
[self updateChangeCount: NSChangeCleared];
}
// FIXME: Should set the file attributes
if (backupFilename && ![self keepBackupFile])
{
[fileManager removeFileAtPath: backupFilename handler: nil];
}
return YES;
} }
return YES;
} }
} }

View file

@ -53,6 +53,7 @@ static NSString *NSDefaultOpenDirectory = @"NSDefaultOpenDirectory";
static NSDocumentController *sharedController = nil; static NSDocumentController *sharedController = nil;
#define TYPE_INFO(name) TypeInfoForName(_types, name) #define TYPE_INFO(name) TypeInfoForName(_types, name)
#define HR_TYPE_INFO(name) TypeInfoForHumanReadableName(_types, name)
static NSDictionary *TypeInfoForName (NSArray *types, NSString *typeName) static NSDictionary *TypeInfoForName (NSArray *types, NSString *typeName)
{ {
@ -70,6 +71,22 @@ static NSDictionary *TypeInfoForName (NSArray *types, NSString *typeName)
return nil; return nil;
} }
static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
{
int i, count = [types count];
for (i = 0; i < count; i++)
{
NSDictionary *dict = [types objectAtIndex: i];
if ([[dict objectForKey: NSHumanReadableNameKey] isEqualToString: typeName])
{
return dict;
}
}
return nil;
}
/** <p> /** <p>
NSDocumentController is a class that controls a set of NSDocuments NSDocumentController is a class that controls a set of NSDocuments
for an application. As an application delegate, it responds to the for an application. As an application delegate, it responds to the
@ -488,7 +505,7 @@ static NSDictionary *TypeInfoForName (NSArray *types, NSString *typeName)
- (BOOL) reviewUnsavedDocumentsWithAlertTitle: (NSString *)title - (BOOL) reviewUnsavedDocumentsWithAlertTitle: (NSString *)title
cancellable: (BOOL)cancellable cancellable: (BOOL)cancellable
{ {
NSString *cancelString = (cancellable)? _(@"Cancel") : nil; NSString *cancelString = (cancellable)? ((NSString *)_(@"Cancel")) : ((NSString *)nil);
int result; int result;
/* Probably as good a place as any to do this */ /* Probably as good a place as any to do this */
@ -601,13 +618,14 @@ static NSDictionary *TypeInfoForName (NSArray *types, NSString *typeName)
[[NSApplication sharedApplication] mainWindow]]; [[NSApplication sharedApplication] mainWindow]];
} }
/** Returns the current directory. This method first checks if there /**
is a current document using the -currentDocument method. If this * Returns the current directory. This method first checks if there
returns a document and the document has a filename, this method * is a current document using the -currentDocument method. If this
returns the directory this file is located in. Otherwise it * returns a document and the document has a filename, this method
returns the directory of the most recently opened document or * returns the directory this file is located in. Otherwise it
the user's home directory if no document has been opened before. * returns the directory of the most recently opened document or
*/ * the user's home directory if no document has been opened before.
*/
- (NSString *) currentDirectory - (NSString *) currentDirectory
{ {
NSFileManager *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
@ -845,5 +863,28 @@ static NSString *NSViewerRole = @"Viewer";
return [self _editorTypesForClass: documentClass]; return [self _editorTypesForClass: documentClass];
} }
- (NSString *) _nameForHumanReadableType: (NSString *)type
{
return [HR_TYPE_INFO(type) objectForKey: NSNameKey];
}
- (NSArray *) _displayNamesForTypes: (NSArray *)types
{
NSEnumerator *en = [types objectEnumerator];
NSString *type = nil;
NSMutableArray *result = [NSMutableArray arrayWithCapacity: 10];
while((type = (NSString *)[en nextObject]) != nil)
{
NSString *name = [self displayNameForType: type];
[result addObject: name];
}
return result;
}
- (NSArray *) _displayNamesForClass: (Class)documentClass
{
return [self _displayNamesForTypes:
[self _editorTypesForClass: documentClass]];
}
@end @end

View file

@ -26,6 +26,8 @@
*/ */
#include <Foundation/NSCoder.h> #include <Foundation/NSCoder.h>
#include <Foundation/NSArchiver.h>
#include <Foundation/NSKeyedArchiver.h>
#include <Foundation/NSNotification.h> #include <Foundation/NSNotification.h>
#include "AppKit/NSWindow.h" #include "AppKit/NSWindow.h"
#include "AppKit/NSView.h" #include "AppKit/NSView.h"
@ -291,12 +293,64 @@ static NSNotificationCenter *nc = nil;
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
//FIXME [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeSize: _contentSize forKey: @"NSContentSize"];
[aCoder encodeObject: _delegate forKey: @"NSDelegate"];
[aCoder encodeFloat: _leadingOffset forKey: @"NSLeadingOffset"];
[aCoder encodeSize: _maxContentSize forKey: @"NSMaxContentSize"];
[aCoder encodeSize: _minContentSize forKey: @"NSMinContentSize"];
[aCoder encodeObject: _parentWindow forKey: @"NSParentWindow"];
[aCoder encodeInt: _preferredEdge forKey: @"NSPreferredEdge"];
[aCoder encodeFloat: _trailingOffset forKey: @"NSTrailingOffset"];
}
else
{
[aCoder encodeSize: _contentSize];
[aCoder encodeObject: _delegate];
[aCoder encodeValueOfObjCType: @encode(float) at: &_leadingOffset];
[aCoder encodeSize: _maxContentSize];
[aCoder encodeSize: _minContentSize];
[aCoder encodeObject: _parentWindow];
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &_preferredEdge];
[aCoder encodeValueOfObjCType: @encode(float) at: &_trailingOffset];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
//FIXME if((self = [super initWithCoder: aDecoder]) != nil)
{
if([aDecoder allowsKeyedCoding])
{
_contentSize = [aDecoder decodeSizeForKey: @"NSContentSize"];
ASSIGN(_delegate, [aDecoder decodeObjectForKey: @"NSDelegate"]);
_leadingOffset = [aDecoder decodeFloatForKey: @"NSLeadingOffset"];
_maxContentSize = [aDecoder decodeSizeForKey: @"NSMaxContentSize"];
_minContentSize = [aDecoder decodeSizeForKey: @"NSMinContentSize"];
ASSIGN(_parentWindow, [aDecoder decodeObjectForKey: @"NSParentWindow"]);
_preferredEdge = [aDecoder decodeIntForKey: @"NSPreferredEdge"];
_trailingOffset = [aDecoder decodeFloatForKey: @"NSTrailingOffset"];
}
else
{
int version = [aDecoder versionForClassName: @"NSDrawer"];
if(version == 0)
{
_contentSize = [aDecoder decodeSize];
ASSIGN(_delegate, [aDecoder decodeObject]);
[aDecoder decodeValueOfObjCType: @encode(float) at: &_leadingOffset];
_maxContentSize = [aDecoder decodeSize];
_minContentSize = [aDecoder decodeSize];
ASSIGN(_parentWindow, [aDecoder decodeObject]);
[aDecoder decodeValueOfObjCType: @encode(unsigned) at: &_preferredEdge];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_trailingOffset];
}
else
return nil;
}
}
return self; return self;
} }

View file

@ -510,6 +510,7 @@ static Class eventClass;
RELEASE((id)event_data.tracking.user_data); RELEASE((id)event_data.tracking.user_data);
} }
NSDeallocateObject(self); NSDeallocateObject(self);
GSNOSUPERDEALLOC;
} }
/** /**

View file

@ -1137,7 +1137,7 @@ static BOOL flip_hack;
if ([aCoder allowsKeyedCoding]) if ([aCoder allowsKeyedCoding])
{ {
[aCoder encodeObject: fontName forKey: @"NSName"]; [aCoder encodeObject: fontName forKey: @"NSName"];
[aCoder encodeInt: [self pointSize] forKey: @"NSSize"]; [aCoder encodeFloat: [self pointSize] forKey: @"NSSize"];
switch (role >> 1) switch (role >> 1)
{ {
@ -1177,7 +1177,7 @@ static BOOL flip_hack;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
NSString *name = [aDecoder decodeObjectForKey: @"NSName"]; NSString *name = [aDecoder decodeObjectForKey: @"NSName"];
int size = [aDecoder decodeIntForKey: @"NSSize"]; float size = [aDecoder decodeFloatForKey: @"NSSize"];
RELEASE(self); RELEASE(self);
if ([aDecoder containsValueForKey: @"NSfFlags"]) if ([aDecoder containsValueForKey: @"NSfFlags"])
@ -1186,22 +1186,22 @@ static BOOL flip_hack;
// FIXME // FIXME
if (flags == 16) if (flags == 16)
{ {
return [NSFont controlContentFontOfSize: size]; return RETAIN([NSFont controlContentFontOfSize: size]);
} }
else if (flags == 20) else if (flags == 20)
{ {
return [NSFont labelFontOfSize: size]; return RETAIN([NSFont labelFontOfSize: size]);
} }
else if (flags == 22) else if (flags == 22)
{ {
return [NSFont titleBarFontOfSize: size]; return RETAIN([NSFont titleBarFontOfSize: size]);
} }
} }
self = [NSFont fontWithName: name size: size]; self = [NSFont fontWithName: name size: size];
if (self == nil) if (self == nil)
{ {
self = [NSFont systemFontOfSize: size]; self = RETAIN([NSFont systemFontOfSize: size]);
} }
return self; return self;

View file

@ -391,20 +391,29 @@ static NSColor *shadowCol;
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL tmp;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
tmp = _formcell_auto_title_width; {
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; /*
[aCoder encodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth]; if([self stringValue] != nil)
[aCoder encodeObject: _titleCell]; {
[aCoder encodeObject: [self stringValue] forKey: @"NSContents"];
}
*/
[aCoder encodeFloat: [self titleWidth] forKey: @"NSTitleWidth"];
[aCoder encodeObject: _titleCell forKey: @"NSTitleCell"];
}
else
{
BOOL tmp = _formcell_auto_title_width;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
[aCoder encodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth];
[aCoder encodeObject: _titleCell];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
BOOL tmp;
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
@ -423,6 +432,7 @@ static NSColor *shadowCol;
} }
else else
{ {
BOOL tmp;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
_formcell_auto_title_width = tmp; _formcell_auto_title_width = tmp;
[aDecoder decodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth]; [aDecoder decodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth];

View file

@ -26,6 +26,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSNotification.h> #include <Foundation/NSNotification.h>
#include <Foundation/NSFileManager.h> #include <Foundation/NSFileManager.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
@ -41,33 +42,107 @@
@implementation NSBundle (NSHelpManager) @implementation NSBundle (NSHelpManager)
- (NSAttributedString*) contextHelpForKey: (NSString*) key - (NSString *)pathForHelpResource:(NSString *)fileName
{ {
id helpFile = nil; NSFileManager *fm = [NSFileManager defaultManager];
NSDictionary *contextHelp = NSMutableArray *array = [NSMutableArray array];
RETAIN([NSDictionary dictionaryWithContentsOfFile: NSArray *languages = [NSUserDefaults userLanguages];
[self pathForResource: @"Help" ofType: @"plist"]]); NSString *rootPath = [self bundlePath];
NSString *primary;
NSString *language;
NSEnumerator *enumerator;
primary = [rootPath stringByAppendingPathComponent: @"Resources"];
enumerator = [languages objectEnumerator];
while ((language = [enumerator nextObject]))
{
NSString *langDir = [NSString stringWithFormat: @"%@.lproj", language];
[array addObject: [primary stringByAppendingPathComponent: langDir]];
}
[array addObject: primary];
primary = rootPath;
enumerator = [languages objectEnumerator];
while ((language = [enumerator nextObject]))
{
NSString *langDir = [NSString stringWithFormat: @"%@.lproj", language];
[array addObject: [primary stringByAppendingPathComponent: langDir]];
}
[array addObject: primary];
enumerator = [array objectEnumerator];
while ((rootPath = [enumerator nextObject]) != nil)
{
NSString *helpDir;
NSString *helpPath;
BOOL isdir;
helpPath = [rootPath stringByAppendingPathComponent: fileName];
if ([fm fileExistsAtPath: helpPath])
{
return helpPath;
}
helpDir = [rootPath stringByAppendingPathComponent: @"Help"];
if ([fm fileExistsAtPath: helpDir isDirectory: & isdir] && isdir)
{
helpPath = [helpDir stringByAppendingPathComponent: fileName];
if ([fm fileExistsAtPath: helpPath])
{
return helpPath;
}
}
}
return nil;
}
- (NSAttributedString *)contextHelpForKey:(NSString *)key
{
NSFileManager *fm = [NSFileManager defaultManager];
NSString *dictPath = [self pathForResource: @"Help" ofType: @"plist"];
NSDictionary *contextHelp = nil;
id helpFile = nil;
if (dictPath && [fm fileExistsAtPath: dictPath])
{
contextHelp = [NSDictionary dictionaryWithContentsOfFile: dictPath];
}
if (contextHelp) if (contextHelp)
{ {
helpFile = [contextHelp objectForKey: key]; helpFile = [contextHelp objectForKey: key];
} }
if (helpFile) if (helpFile)
{ {
return [NSUnarchiver unarchiveObjectWithData: NSData *data = [helpFile objectForKey: @"NSHelpRTFContents"];
[helpFile objectForKey: @"NSHelpRTFContents"]]; return ((data != nil) ? [NSUnarchiver unarchiveObjectWithData: data] :
} nil) ;
else
}
else
{ {
helpFile = [self helpFile = [self pathForHelpResource: key];
pathForResource: key
ofType: @"rtf"
inDirectory: @"Help"];
return AUTORELEASE([[NSAttributedString alloc] initWithPath: (NSString *)helpFile
documentAttributes: NULL]);
}
if (helpFile)
{
NSString *helpstr = [[NSAttributedString alloc] initWithPath: helpFile
documentAttributes: NULL];
return TEST_AUTORELEASE (helpstr);
}
}
return nil; return nil;
} }
@ -83,22 +158,33 @@
help = [info objectForKey: @"GSHelpContentsFile"]; help = [info objectForKey: @"GSHelpContentsFile"];
if (!help) if (help == nil)
{ {
help = [info objectForKey: @"NSExecutable"]; help = [info objectForKey: @"NSExecutable"];
// If there's no specification, we look for a file named "appname.rtf" // If there's no specification, we look for a files named
// "appname.rtfd" or "appname.rtf"
} }
if (help) if (help)
{ {
NSString *file = [mb pathForResource: help ofType: @"rtf"]; NSString *file;
if (file) if ([[help pathExtension] length] == 0)
{ {
[[NSWorkspace sharedWorkspace] openFile: file]; file = [mb pathForHelpResource: [help stringByAppendingPathExtension: @"rtfd"]];
return;
} if (file == nil)
{
file = [mb pathForHelpResource: [help stringByAppendingPathExtension: @"rtf"]];
}
}
if (file) {
[[NSWorkspace sharedWorkspace] openFile: file];
return;
} }
}
NSBeep(); NSBeep();
} }
@ -198,6 +284,15 @@ static BOOL _gnu_contextHelpActive = NO;
NSMapRemove(contextHelpTopics, object); NSMapRemove(contextHelpTopics, object);
} }
- (void)setContextHelp:(NSAttributedString *)help forObject:(id)object
{
NSMapInsert(contextHelpTopics, object, help);
}
/**
* Deprecated ... do not use.
* Use -setContextHelp:forObject: instead.
*/
- (void) setContextHelp: (NSAttributedString*) help withObject: (id) object - (void) setContextHelp: (NSAttributedString*) help withObject: (id) object
{ {
NSMapInsert(contextHelpTopics, object, help); NSMapInsert(contextHelpTopics, object, help);
@ -205,7 +300,7 @@ static BOOL _gnu_contextHelpActive = NO;
- (BOOL) showContextHelpForObject: (id)object locationHint: (NSPoint) point - (BOOL) showContextHelpForObject: (id)object locationHint: (NSPoint) point
{ {
id contextHelp = [self contextHelpForObject: object]; NSAttributedString *contextHelp = [self contextHelpForObject: object];
if (contextHelp) if (contextHelp)
{ {

View file

@ -127,6 +127,7 @@ BOOL NSImageForceCaching = NO; /* use on missmatch */
TEST_RELEASE(rep); TEST_RELEASE(rep);
TEST_RELEASE(bg); TEST_RELEASE(bg);
NSDeallocateObject(self); NSDeallocateObject(self);
GSNOSUPERDEALLOC;
} }
@end @end
@ -1478,63 +1479,95 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
{ {
BOOL flag; BOOL flag;
flag = _flags.archiveByName; if([coder allowsKeyedCoding])
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
if (flag == YES)
{ {
// FIXME: Not sure this is the way it goes...
/* /*
* System image - just encode the name. if(_flags.archiveByName == NO)
*/ {
[coder encodeValueOfObjCType: @encode(id) at: &_name]; NSMutableArray *container = [NSMutableArray array];
NSMutableArray *reps = [NSMutableArray array];
NSEnumerator *en = [_reps objectEnumerator];
GSRepData *rd = nil;
// add the reps to the container...
[container addObject: reps];
while((rd = [en nextObject]) != nil)
{
[reps addObject: rd->rep];
}
[coder encodeObject: container forKey: @"NSReps"];
}
else
{
[coder encodeObject: _name forKey: @"NSImageName"];
}
*/
// encode the rest...
[coder encodeObject: _color forKey: @"NSColor"];
[coder encodeInt: 0 forKey: @"NSImageFlags"]; // zero...
[coder encodeSize: _size forKey: @"NSSize"];
} }
else else
{ {
NSMutableArray *a; flag = _flags.archiveByName;
NSEnumerator *e;
NSImageRep *r;
/*
* Normal image - encode the ivars
*/
[coder encodeValueOfObjCType: @encode(NSSize) at: &_size];
[coder encodeValueOfObjCType: @encode(id) at: &_color];
flag = _flags.scalable;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.dataRetained; if (flag == YES)
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.flipDraw;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.sizeWasExplicitlySet;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.useEPSOnResolutionMismatch;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.colorMatchPreferred;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.multipleResolutionMatching;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.cacheSeparately;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.unboundedCacheDepth;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
// FIXME: The documentation says to archive only the file name,
// if not data retained!
/*
* Now encode an array of all the image reps (excluding cache)
*/
a = [NSMutableArray arrayWithCapacity: 2];
e = [[self representations] objectEnumerator];
while ((r = [e nextObject]) != nil)
{ {
if ([r isKindOfClass: cachedClass] == NO) /*
{ * System image - just encode the name.
[a addObject: r]; */
} [coder encodeValueOfObjCType: @encode(id) at: &_name];
}
else
{
NSMutableArray *a;
NSEnumerator *e;
NSImageRep *r;
/*
* Normal image - encode the ivars
*/
[coder encodeValueOfObjCType: @encode(NSSize) at: &_size];
[coder encodeValueOfObjCType: @encode(id) at: &_color];
flag = _flags.scalable;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.dataRetained;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.flipDraw;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.sizeWasExplicitlySet;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.useEPSOnResolutionMismatch;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.colorMatchPreferred;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.multipleResolutionMatching;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.cacheSeparately;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.unboundedCacheDepth;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
// FIXME: The documentation says to archive only the file name,
// if not data retained!
/*
* Now encode an array of all the image reps (excluding cache)
*/
a = [NSMutableArray arrayWithCapacity: 2];
e = [[self representations] objectEnumerator];
while ((r = [e nextObject]) != nil)
{
if ([r isKindOfClass: cachedClass] == NO)
{
[a addObject: r];
}
}
[coder encodeValueOfObjCType: @encode(id) at: &a];
} }
[coder encodeValueOfObjCType: @encode(id) at: &a];
} }
} }
- (id) initWithCoder: (NSCoder*)coder - (id) initWithCoder: (NSCoder*)coder
{ {
BOOL flag; BOOL flag;
@ -1781,7 +1814,7 @@ iterate_reps_for_types(NSArray* imageReps, SEL method)
rep = [self _cacheForRep: rep]; rep = [self _cacheForRep: rep];
repd = repd_for_rep(_reps, rep); repd = repd_for_rep(_reps, rep);
NSDebugLLog(@"NSImage", @"Cached image rep is %d", (int)rep); NSDebugLLog(@"NSImage", @"Cached image rep is %p", rep);
/* /*
* if the cache is not valid, it's background color will not exist * if the cache is not valid, it's background color will not exist
* and we must draw the background then render from the original * and we must draw the background then render from the original
@ -1811,8 +1844,8 @@ iterate_reps_for_types(NSArray* imageReps, SEL method)
{ {
[rep setOpaque: [repd->original isOpaque]]; [rep setOpaque: [repd->original isOpaque]];
} }
NSDebugLLog(@"NSImage", @"Rendered rep %d on background %@", NSDebugLLog(@"NSImage", @"Rendered rep %p on background %@",
(int)rep, repd->bg); rep, repd->bg);
} }
} }

View file

@ -369,42 +369,52 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
- (void) encodeWithCoder: (NSCoder *)aCoder - (void) encodeWithCoder: (NSCoder *)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment]; {
[aCoder encodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle]; [aCoder encodeInt: _imageAlignment forKey: @"NSAlign"];
[aCoder encodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling]; [aCoder encodeInt: _imageScaling forKey: @"NSScale"];
[aCoder encodeSize: _original_image_size]; [aCoder encodeInt: _frameStyle forKey: @"NSStyle"];
[aCoder encodeBool: NO forKey: @"NSAnimates"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment];
[aCoder encodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle];
[aCoder encodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
[aCoder encodeSize: _original_image_size];
}
} }
- (id) initWithCoder: (NSCoder *)aDecoder - (id) initWithCoder: (NSCoder *)aDecoder
{ {
self = [super initWithCoder: aDecoder]; if((self = [super initWithCoder: aDecoder]) != nil)
if ([aDecoder allowsKeyedCoding])
{ {
if ([aDecoder containsValueForKey: @"NSAlign"]) if ([aDecoder allowsKeyedCoding])
{ {
[self setImageAlignment: [aDecoder decodeIntForKey: @"NSAlign"]]; if ([aDecoder containsValueForKey: @"NSAlign"])
{
[self setImageAlignment: [aDecoder decodeIntForKey: @"NSAlign"]];
}
if ([aDecoder containsValueForKey: @"NSScale"])
{
[self setImageScaling: [aDecoder decodeIntForKey: @"NSScale"]];
}
if ([aDecoder containsValueForKey: @"NSStyle"])
{
[self setImageFrameStyle: [aDecoder decodeIntForKey: @"NSStyle"]];
}
if ([aDecoder containsValueForKey: @"NSAnimates"])
{
//BOOL animates = [aDecoder decodeBoolForKey: @"NSAnimates"];
}
} }
if ([aDecoder containsValueForKey: @"NSScale"]) else
{ {
[self setImageScaling: [aDecoder decodeIntForKey: @"NSScale"]]; [aDecoder decodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment];
[aDecoder decodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle];
[aDecoder decodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
_original_image_size = [aDecoder decodeSize];
} }
if ([aDecoder containsValueForKey: @"NSStyle"])
{
[self setImageFrameStyle: [aDecoder decodeIntForKey: @"NSStyle"]];
}
if ([aDecoder containsValueForKey: @"NSAnimates"])
{
//BOOL animates = [aDecoder decodeBoolForKey: @"NSAnimates"];
}
}
else
{
[aDecoder decodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment];
[aDecoder decodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle];
[aDecoder decodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
_original_image_size = [aDecoder decodeSize];
} }
return self; return self;
} }

View file

@ -279,8 +279,15 @@ static Class imageCellClass;
- (void) encodeWithCoder: (NSCoder *)aCoder - (void) encodeWithCoder: (NSCoder *)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeConditionalObject: _target]; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action]; {
[aCoder encodeBool: [self isEditable] forKey: @"NSEditable"];
}
else
{
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
}
} }
- (id) initWithCoder: (NSCoder *)aDecoder - (id) initWithCoder: (NSCoder *)aDecoder
@ -290,7 +297,6 @@ static Class imageCellClass;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
//NSArray *dragType = [aDecoder decodeObjectForKey: @"NSDragTypes"]; //NSArray *dragType = [aDecoder decodeObjectForKey: @"NSDragTypes"];
if ([aDecoder containsValueForKey: @"NSEditable"]) if ([aDecoder containsValueForKey: @"NSEditable"])
{ {
[self setEditable: [aDecoder decodeBoolForKey: @"NSEditable"]]; [self setEditable: [aDecoder decodeBoolForKey: @"NSEditable"]];

View file

@ -1578,12 +1578,12 @@ dictionary.
-(BOOL) layoutManagerOwnsFirstResponderInWindow: (NSWindow *)window -(BOOL) layoutManagerOwnsFirstResponderInWindow: (NSWindow *)window
{ {
int i; int i;
NSView *tv; NSResponder *tv;
NSView *v = [window firstResponder]; NSResponder *v = [window firstResponder];
for (i = 0; i < num_textcontainers; i++) for (i = 0; i < num_textcontainers; i++)
{ {
tv = (NSView *)[textcontainers[i].textContainer textView]; tv = [textcontainers[i].textContainer textView];
if (tv == v) if (tv == v)
return YES; return YES;
} }

View file

@ -2677,45 +2677,86 @@ static SEL getSel;
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
GSMatrixFlags matrixFlags;
unsigned int mFlags = 0;
[aCoder encodeValueOfObjCType: @encode (int) at: &_mode]; [aCoder encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_allowsEmptySelection]; [aCoder encodeObject: [self cellBackgroundColor] forKey: @"NSCellBackgroundColor"];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_selectionByRect]; [aCoder encodeObject: [self prototype] forKey: @"NSProtoCell"];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_autosizesCells]; [aCoder encodeObject: NSStringFromClass([self cellClass]) forKey: @"NSCellClass"];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_autoscroll]; [aCoder encodeSize: _cellSize forKey: @"NSCellSize"];
[aCoder encodeSize: _cellSize]; [aCoder encodeSize: _intercell forKey: @"NSIntercellSpacing"];
[aCoder encodeSize: _intercell];
[aCoder encodeObject: _backgroundColor]; /// set the flags...
[aCoder encodeObject: _cellBackgroundColor]; matrixFlags.isRadio = ([self mode] == NSRadioModeMatrix);
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_drawsBackground]; matrixFlags.isList = ([self mode] == NSListModeMatrix);
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_drawsCellBackground]; matrixFlags.isHighlight = ([self mode] == NSHighlightModeMatrix);
[aCoder encodeObject: NSStringFromClass (_cellClass)]; matrixFlags.allowsEmptySelection = [self allowsEmptySelection];
[aCoder encodeObject: _cellPrototype]; matrixFlags.selectionByRect = [self isSelectionByRect];
[aCoder encodeValueOfObjCType: @encode (int) at: &_numRows]; matrixFlags.drawCellBackground = [self drawsCellBackground];
[aCoder encodeValueOfObjCType: @encode (int) at: &_numCols]; matrixFlags.drawBackground = [self drawsBackground];
matrixFlags.tabKeyTraversesCells = _tabKeyTraversesCells;
/* This is slower, but does not expose NSMatrix internals and will work matrixFlags.autosizesCells = _autosizesCells;
// clear unused...
matrixFlags.autoScroll = 0;
matrixFlags.drawingAncestor = 0;
matrixFlags.tabKeyTraversesCellsExplicitly = 0;
matrixFlags.canSearchIncrementally = 0;
matrixFlags.unused = 0;
memcpy((void *)&mFlags,(void *)&matrixFlags,sizeof(unsigned int));
[aCoder encodeInt: mFlags forKey: @"NSMatrixFlags"];
[aCoder encodeInt: _numCols forKey: @"NSNumCols"];
[aCoder encodeInt: _numRows forKey: @"NSNumRows"];
[aCoder encodeObject: [self cells] forKey: @"NSCells"];
[aCoder encodeInt: _selectedColumn forKey: @"NSSelectedCol"];
[aCoder encodeInt: _selectedRow forKey: @"NSSelectedRow"];
}
else
{
[aCoder encodeValueOfObjCType: @encode (int) at: &_mode];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_allowsEmptySelection];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_selectionByRect];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_autosizesCells];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_autoscroll];
[aCoder encodeSize: _cellSize];
[aCoder encodeSize: _intercell];
[aCoder encodeObject: _backgroundColor];
[aCoder encodeObject: _cellBackgroundColor];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_drawsBackground];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_drawsCellBackground];
[aCoder encodeObject: NSStringFromClass (_cellClass)];
[aCoder encodeObject: _cellPrototype];
[aCoder encodeValueOfObjCType: @encode (int) at: &_numRows];
[aCoder encodeValueOfObjCType: @encode (int) at: &_numCols];
/* This is slower, but does not expose NSMatrix internals and will work
with subclasses */ with subclasses */
[aCoder encodeObject: [self cells]]; [aCoder encodeObject: [self cells]];
[aCoder encodeConditionalObject: _delegate]; [aCoder encodeConditionalObject: _delegate];
[aCoder encodeConditionalObject: _target]; [aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode (SEL) at: &_action]; [aCoder encodeValueOfObjCType: @encode (SEL) at: &_action];
[aCoder encodeValueOfObjCType: @encode (SEL) at: &_doubleAction]; [aCoder encodeValueOfObjCType: @encode (SEL) at: &_doubleAction];
[aCoder encodeValueOfObjCType: @encode (SEL) at: &_errorAction]; [aCoder encodeValueOfObjCType: @encode (SEL) at: &_errorAction];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_tabKeyTraversesCells]; [aCoder encodeValueOfObjCType: @encode (BOOL) at: &_tabKeyTraversesCells];
[aCoder encodeObject: [self keyCell]]; [aCoder encodeObject: [self keyCell]];
/* We do not encode information on selected cells, because this is saved /* We do not encode information on selected cells, because this is saved
with the cells themselves */ with the cells themselves */
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
Class class; Class class;
id cell; id cell;
int rows, columns; int rows = 0, columns = 0;
NSArray *array; NSArray *array;
int i, count; int i = 0, count = 0;
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
@ -2774,6 +2815,7 @@ static SEL getSel;
[self setSelectionByRect: matrixFlags.selectionByRect]; [self setSelectionByRect: matrixFlags.selectionByRect];
[self setDrawsCellBackground: matrixFlags.drawCellBackground]; [self setDrawsCellBackground: matrixFlags.drawCellBackground];
[self setDrawsBackground: matrixFlags.drawBackground]; [self setDrawsBackground: matrixFlags.drawBackground];
_autosizesCells = matrixFlags.autosizesCells;
_tabKeyTraversesCells = matrixFlags.tabKeyTraversesCells; _tabKeyTraversesCells = matrixFlags.tabKeyTraversesCells;
} }
if ([aDecoder containsValueForKey: @"NSNumCols"]) if ([aDecoder containsValueForKey: @"NSNumCols"])

View file

@ -1213,9 +1213,23 @@ static NSNotificationCenter *nc;
*/ */
- (void) encodeWithCoder: (NSCoder*)encoder - (void) encodeWithCoder: (NSCoder*)encoder
{ {
[encoder encodeObject: _title]; if([encoder allowsKeyedCoding])
[encoder encodeObject: _items]; {
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_autoenable]; [encoder encodeObject: _title forKey: @"NSTitle"];
[encoder encodeObject: _items forKey: @"NSMenuItems"];
// if there is no supermenu, make it the main menu.
if([self supermenu] == nil)
{
[encoder encodeObject: @"_NSMainMenu" forKey: @"NSName"];
}
}
else
{
[encoder encodeObject: _title];
[encoder encodeObject: _items];
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_autoenable];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder

View file

@ -476,14 +476,22 @@ static Class imageClass;
{ {
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
NSString *title = [aDecoder decodeObjectForKey: @"NSTitle"]; NSString *title;
NSString *action = [aDecoder decodeObjectForKey: @"NSAction"]; NSString *action;
NSString *key = [aDecoder decodeObjectForKey: @"NSKeyEquiv"]; NSString *key;
NSImage *mixedImage = [aDecoder decodeObjectForKey: @"NSMixedImage"]; NSImage *mixedImage;
NSImage *onImage = [aDecoder decodeObjectForKey: @"NSOnImage"]; NSImage *onImage;
id target = [aDecoder decodeObjectForKey: @"NSTarget"]; id target;
NSMenu *menu = [aDecoder decodeObjectForKey: @"NSMenu"]; NSMenu *submenu;
NSMenu *submenu = [aDecoder decodeObjectForKey: @"NSSubmenu"];
title = [aDecoder decodeObjectForKey: @"NSTitle"];
action = [aDecoder decodeObjectForKey: @"NSAction"];
key = [aDecoder decodeObjectForKey: @"NSKeyEquiv"];
mixedImage = [aDecoder decodeObjectForKey: @"NSMixedImage"];
onImage = [aDecoder decodeObjectForKey: @"NSOnImage"];
target = [aDecoder decodeObjectForKey: @"NSTarget"];
[aDecoder decodeObjectForKey: @"NSMenu"];
submenu = [aDecoder decodeObjectForKey: @"NSSubmenu"];
self = [self initWithTitle: title self = [self initWithTitle: title
action: NSSelectorFromString(action) action: NSSelectorFromString(action)

View file

@ -1572,31 +1572,34 @@ _addLeftBorderOffsetToRect(NSRect aRect)
- (void) encodeWithCoder: (NSCoder*)encoder - (void) encodeWithCoder: (NSCoder*)encoder
{ {
[super encodeWithCoder: encoder]; [super encodeWithCoder: encoder];
if([encoder allowsKeyedCoding] == NO)
[encoder encodeObject: _itemCells]; {
[encoder encodeObject: _font]; [encoder encodeObject: _itemCells];
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_horizontal]; [encoder encodeObject: _font];
[encoder encodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad]; [encoder encodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
[encoder encodeValueOfObjCType: @encode(NSSize) at: &_cellSize]; [encoder encodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
[encoder encodeValueOfObjCType: @encode(NSSize) at: &_cellSize];
}
} }
- (id) initWithCoder: (NSCoder*)decoder - (id) initWithCoder: (NSCoder*)decoder
{ {
self = [super initWithCoder: decoder]; self = [super initWithCoder: decoder];
if([decoder allowsKeyedCoding] == NO)
[decoder decodeValueOfObjCType: @encode(id) at: &_itemCells]; {
[decoder decodeValueOfObjCType: @encode(id) at: &_itemCells];
[_itemCells makeObjectsPerformSelector: @selector(setMenuView:)
withObject: self]; [_itemCells makeObjectsPerformSelector: @selector(setMenuView:)
withObject: self];
[decoder decodeValueOfObjCType: @encode(id) at: &_font];
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_horizontal]; [decoder decodeValueOfObjCType: @encode(id) at: &_font];
[decoder decodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad]; [decoder decodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
[decoder decodeValueOfObjCType: @encode(NSSize) at: &_cellSize]; [decoder decodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
[decoder decodeValueOfObjCType: @encode(NSSize) at: &_cellSize];
_highlightedItemIndex = -1;
_needsSizing = YES; _highlightedItemIndex = -1;
_needsSizing = YES;
}
return self; return self;
} }

View file

@ -208,7 +208,7 @@
// //
if([coder allowsKeyedCoding]) if([coder allowsKeyedCoding])
{ {
// Need to verify this key... // TODO_NIB: Need to verify this key...
ASSIGN(_nibData, [coder decodeObjectForKey: @"NSData"]); ASSIGN(_nibData, [coder decodeObjectForKey: @"NSData"]);
ASSIGN(_loader, [GSModelLoaderFactory modelLoaderForFileType: @"nib"]); ASSIGN(_loader, [GSModelLoaderFactory modelLoaderForFileType: @"nib"]);
} }
@ -227,7 +227,7 @@
{ {
if([coder allowsKeyedCoding]) if([coder allowsKeyedCoding])
{ {
// Need to verify this key... // TODO_NIB: Need to verify this key...
[coder encodeObject: _nibData [coder encodeObject: _nibData
forKey: @"NSData"]; forKey: @"NSData"];
} }

View file

@ -563,6 +563,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
} }
[NSApp stopModalWithCode: NSOKButton]; [NSApp stopModalWithCode: NSOKButton];
[_okButton setEnabled: NO];
[self close]; [self close];
} }

View file

@ -2,8 +2,9 @@
<abstract> <abstract>
This class is a subclass of NSTableView which provides the user with a way This class is a subclass of NSTableView which provides the user with a way
to display tree structured data in an outline format. It is particularly useful for show to display tree structured data in an outline format.
hierarchical data such as a class inheritance tree or any other set of relationships. It is particularly useful for show hierarchical data such as a
class inheritance tree or any other set of relationships.
</abstract> </abstract>
Copyright (C) 2001 Free Software Foundation, Inc. Copyright (C) 2001 Free Software Foundation, Inc.
@ -263,7 +264,7 @@ static NSImage *unexpandable = nil;
NSMutableArray *allChildren = nil; NSMutableArray *allChildren = nil;
int numchild = 0; int numchild = 0;
int index = 0; int index = 0;
id sitem = (item == nil)?[NSNull null]:item; id sitem = (item == nil) ? (id)[NSNull null] : (id)item;
allChildren = NSMapGet(_itemDict, sitem); allChildren = NSMapGet(_itemDict, sitem);
numchild = [allChildren count]; numchild = [allChildren count];
@ -298,7 +299,7 @@ static NSImage *unexpandable = nil;
* expandable children of this item all also expanded in a recursive fashion (i.e. * expandable children of this item all also expanded in a recursive fashion (i.e.
* all children, grandchildren and etc). * all children, grandchildren and etc).
*/ */
- (void)expandItem:(id)item expandChildren:(BOOL)expandChildren - (void)expandItem: (id)item expandChildren: (BOOL)expandChildren
{ {
const SEL shouldExpandSelector = @selector(outlineView:shouldExpandItem:); const SEL shouldExpandSelector = @selector(outlineView:shouldExpandItem:);
BOOL canExpand = YES; BOOL canExpand = YES;
@ -354,7 +355,7 @@ static NSImage *unexpandable = nil;
NSMutableArray *allChildren = nil; NSMutableArray *allChildren = nil;
int numchild = 0; int numchild = 0;
int index = 0; int index = 0;
id sitem = (item == nil)?[NSNull null]:item; id sitem = (item == nil) ? (id)[NSNull null] : (id)item;
allChildren = NSMapGet(_itemDict, sitem); allChildren = NSMapGet(_itemDict, sitem);
numchild = [allChildren count]; numchild = [allChildren count];
@ -456,15 +457,15 @@ static NSImage *unexpandable = nil;
* Causes an item to be reloaded. This is the equivalent of calling * Causes an item to be reloaded. This is the equivalent of calling
* [NSOutlineView-reloadItem:reloadChildren:] with reloadChildren set to NO. * [NSOutlineView-reloadItem:reloadChildren:] with reloadChildren set to NO.
*/ */
- (void)reloadItem: (id)item - (void) reloadItem: (id)item
{ {
[self reloadItem: item reloadChildren: NO]; [self reloadItem: item reloadChildren: NO];
} }
/** /**
* Causes an item and all of it's children to be reloaded if reloadChildren is * Causes an item and all of it's children to be reloaded if reloadChildren is
* set to YES, if it's set to NO, then only the item itself is refreshed from the * set to YES, if it's set to NO, then only the item itself is refreshed
* datasource. * from the datasource.
*/ */
- (void)reloadItem: (id)item reloadChildren: (BOOL)reloadChildren - (void)reloadItem: (id)item reloadChildren: (BOOL)reloadChildren
{ {
@ -472,7 +473,7 @@ static NSImage *unexpandable = nil;
id parent; id parent;
BOOL expanded; BOOL expanded;
id dsobj = nil; id dsobj = nil;
id object = (item == nil)?([NSNull null]):item; id object = (item == nil) ? (id)[NSNull null] : (id)item;
NSArray *allKeys = NSAllMapTableKeys(_itemDict); NSArray *allKeys = NSAllMapTableKeys(_itemDict);
NSEnumerator *en = [allKeys objectEnumerator]; NSEnumerator *en = [allKeys objectEnumerator];
@ -485,7 +486,7 @@ static NSImage *unexpandable = nil;
if ((index = [childArray indexOfObject: object]) != NSNotFound) if ((index = [childArray indexOfObject: object]) != NSNotFound)
{ {
parent = (parent == [NSNull null])?nil:parent; parent = (parent == [NSNull null]) ? (id)nil : (id)parent;
dsobj = [_dataSource outlineView: self dsobj = [_dataSource outlineView: self
child: index child: index
ofItem: parent]; ofItem: parent];
@ -516,10 +517,10 @@ static NSImage *unexpandable = nil;
} }
/** /**
* Returns the corresponding row in the outline view for the given item. Returns * Returns the corresponding row in the outline view for the given item.
* -1 if item is nil or not found. * Returns -1 if item is nil or not found.
*/ */
- (int)rowForItem: (id)item - (int) rowForItem: (id)item
{ {
int row; int row;
if (item == nil) if (item == nil)
@ -534,7 +535,7 @@ static NSImage *unexpandable = nil;
* the expand/collapse gadget, to resize based on the amount of space * the expand/collapse gadget, to resize based on the amount of space
* needed by widest content. * needed by widest content.
*/ */
- (void)setAutoresizesOutlineColumn: (BOOL)resize - (void) setAutoresizesOutlineColumn: (BOOL)resize
{ {
_autoResizesOutlineColumn = resize; _autoResizesOutlineColumn = resize;
} }
@ -544,7 +545,7 @@ static NSImage *unexpandable = nil;
* collapsed items in the view to the users defaults for the application the * collapsed items in the view to the users defaults for the application the
* outline view is running in. * outline view is running in.
*/ */
- (void)setAutosaveExpandedItems: (BOOL)flag - (void) setAutosaveExpandedItems: (BOOL)flag
{ {
if (flag == _autosaveExpandedItems) if (flag == _autosaveExpandedItems)
{ {
@ -679,7 +680,7 @@ static NSImage *unexpandable = nil;
// Is the data source editable? // Is the data source editable?
_dataSource_editable = [anObject respondsToSelector: _dataSource_editable = [anObject respondsToSelector:
@selector(outlineView:setObjectValue:forTableColumn:byItem:)]; @selector(outlineView:setObjectValue:forTableColumn:byItem:)];
/* We do *not* retain the dataSource, it's like a delegate */ /* We do *not* retain the dataSource, it's like a delegate */
_dataSource = anObject; _dataSource = anObject;
@ -756,15 +757,16 @@ static NSImage *unexpandable = nil;
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding]) if ([aCoder allowsKeyedCoding] == NO)
{ {
} [aCoder encodeValueOfObjCType: @encode(BOOL)
else at: &_autoResizesOutlineColumn];
{ [aCoder encodeValueOfObjCType: @encode(BOOL)
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_autoResizesOutlineColumn]; at: &_indentationMarkerFollowsCell];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_indentationMarkerFollowsCell]; [aCoder encodeValueOfObjCType: @encode(BOOL)
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_autosaveExpandedItems]; at: &_autosaveExpandedItems];
[aCoder encodeValueOfObjCType: @encode(float) at: &_indentationPerLevel]; [aCoder encodeValueOfObjCType: @encode(float)
at: &_indentationPerLevel];
[aCoder encodeConditionalObject: _outlineTableColumn]; [aCoder encodeConditionalObject: _outlineTableColumn];
} }
} }
@ -773,7 +775,7 @@ static NSImage *unexpandable = nil;
{ {
// Since we only have one version.... // Since we only have one version....
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
_itemDict = NSCreateMapTable(NSObjectMapKeyCallBacks, _itemDict = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSObjectMapValueCallBacks, NSObjectMapValueCallBacks,
@ -792,17 +794,21 @@ static NSImage *unexpandable = nil;
_autosaveExpandedItems = NO; _autosaveExpandedItems = NO;
// init the table column... (this can't be chosen on IB either)... // init the table column... (this can't be chosen on IB either)...
if([_tableColumns count] > 0) if ([_tableColumns count] > 0)
{ {
_outlineTableColumn = [_tableColumns objectAtIndex: 0]; _outlineTableColumn = [_tableColumns objectAtIndex: 0];
} }
} }
else else
{ {
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_autoResizesOutlineColumn]; [aDecoder decodeValueOfObjCType: @encode(BOOL)
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_indentationMarkerFollowsCell]; at: &_autoResizesOutlineColumn];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_autosaveExpandedItems]; [aDecoder decodeValueOfObjCType: @encode(BOOL)
[aDecoder decodeValueOfObjCType: @encode(float) at: &_indentationPerLevel]; at: &_indentationMarkerFollowsCell];
[aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &_autosaveExpandedItems];
[aDecoder decodeValueOfObjCType: @encode(float)
at: &_indentationPerLevel];
_outlineTableColumn = [aDecoder decodeObject]; _outlineTableColumn = [aDecoder decodeObject];
_itemDict = NSCreateMapTable(NSObjectMapKeyCallBacks, _itemDict = NSCreateMapTable(NSObjectMapKeyCallBacks,
@ -987,8 +993,10 @@ static NSImage *unexpandable = nil;
imageRect.size.width = [image size].width; imageRect.size.width = [image size].width;
imageRect.size.height = [image size].height; imageRect.size.height = [image size].height;
[imageCell drawWithFrame: imageRect inView: self]; [imageCell drawWithFrame: imageRect inView: self];
drawingRect.origin.x += indentationFactor + [image size].width + 5; drawingRect.origin.x
drawingRect.size.width -= indentationFactor + [image size].width + 5; += indentationFactor + [image size].width + 5;
drawingRect.size.width
-= indentationFactor + [image size].width + 5;
} }
else else
{ {
@ -1456,8 +1464,6 @@ static NSImage *unexpandable = nil;
// move the drawing rect over like in the drawRow routine... // move the drawing rect over like in the drawRow routine...
drawingRect = [self frameOfCellAtColumn: columnIndex row: rowIndex]; drawingRect = [self frameOfCellAtColumn: columnIndex row: rowIndex];
[self lockFocus];
if (tb == [self outlineTableColumn]) if (tb == [self outlineTableColumn])
{ {
level = [self levelForItem: item]; level = [self levelForItem: item];
@ -1481,7 +1487,10 @@ static NSImage *unexpandable = nil;
// draw... // draw...
imageRect.size.width = [image size].width; imageRect.size.width = [image size].width;
imageRect.size.height = [image size].height; imageRect.size.height = [image size].height;
[self lockFocus];
[imageCell drawWithFrame: imageRect inView: self]; [imageCell drawWithFrame: imageRect inView: self];
[self unlockFocus];
} }
if (flag) if (flag)
@ -1502,7 +1511,6 @@ static NSImage *unexpandable = nil;
event: theEvent]; event: theEvent];
} }
[self unlockFocus];
return; return;
} }
@ -1554,9 +1562,10 @@ static NSImage *unexpandable = nil;
- (BOOL) _shouldSelectTableColumn: (NSTableColumn *)tableColumn - (BOOL) _shouldSelectTableColumn: (NSTableColumn *)tableColumn
{ {
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector (outlineView:shouldSelectTableColumn:)] == YES) @selector (outlineView:shouldSelectTableColumn:)] == YES)
{ {
if ([_delegate outlineView: self shouldSelectTableColumn: tableColumn] == NO) if ([_delegate outlineView: self shouldSelectTableColumn: tableColumn]
== NO)
{ {
return NO; return NO;
} }
@ -1570,7 +1579,7 @@ static NSImage *unexpandable = nil;
id item = [self itemAtRow: rowIndex]; id item = [self itemAtRow: rowIndex];
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector (outlineView:shouldSelectItem:)] == YES) @selector (outlineView:shouldSelectItem:)] == YES)
{ {
if ([_delegate outlineView: self shouldSelectItem: item] == NO) if ([_delegate outlineView: self shouldSelectItem: item] == NO)
{ {
@ -1584,7 +1593,7 @@ static NSImage *unexpandable = nil;
- (BOOL) _shouldSelectionChange - (BOOL) _shouldSelectionChange
{ {
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector (selectionShouldChangeInTableView:)] == YES) @selector (selectionShouldChangeInTableView:)] == YES)
{ {
if ([_delegate selectionShouldChangeInTableView: self] == NO) if ([_delegate selectionShouldChangeInTableView: self] == NO)
{ {
@ -1599,7 +1608,7 @@ static NSImage *unexpandable = nil;
row: (int) rowIndex row: (int) rowIndex
{ {
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector(outlineView:shouldEditTableColumn:item:)]) @selector(outlineView:shouldEditTableColumn:item:)])
{ {
id item = [self itemAtRow: rowIndex]; id item = [self itemAtRow: rowIndex];
@ -1633,14 +1642,12 @@ static NSImage *unexpandable = nil;
{ {
int count = [rows count]; int count = [rows count];
int i; int i;
NSMutableArray *itemArray = [NSMutableArray NSMutableArray *itemArray = [NSMutableArray arrayWithCapacity: count];
arrayWithCapacity: count];
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
[itemArray addObject: [itemArray addObject:
[self itemAtRow: [self itemAtRow: [[rows objectAtIndex: i] intValue]]];
[[rows objectAtIndex: i] intValue]]];
} }
if ([_dataSource respondsToSelector: if ([_dataSource respondsToSelector:
@ -1665,7 +1672,7 @@ static NSImage *unexpandable = nil;
id result = nil; id result = nil;
if ([_dataSource respondsToSelector: if ([_dataSource respondsToSelector:
@selector(outlineView:objectValueForTableColumn:byItem:)]) @selector(outlineView:objectValueForTableColumn:byItem:)])
{ {
id item = [self itemAtRow: index]; id item = [self itemAtRow: index];
@ -1682,7 +1689,7 @@ static NSImage *unexpandable = nil;
row: (int) index row: (int) index
{ {
if ([_dataSource respondsToSelector: if ([_dataSource respondsToSelector:
@selector(outlineView:setObjectValue:forTableColumn:byItem:)]) @selector(outlineView:setObjectValue:forTableColumn:byItem:)])
{ {
id item = [self itemAtRow: index]; id item = [self itemAtRow: index];
@ -1721,8 +1728,8 @@ static NSImage *unexpandable = nil;
NSString *tableKey; NSString *tableKey;
defaults = [NSUserDefaults standardUserDefaults]; defaults = [NSUserDefaults standardUserDefaults];
tableKey = [NSString stringWithFormat: @"NSOutlineView Expanded Items %@", tableKey = [NSString stringWithFormat: @"NSOutlineView Expanded Items %@",
_autosaveName]; _autosaveName];
config = [defaults objectForKey: tableKey]; config = [defaults objectForKey: tableKey];
if (config != nil) if (config != nil)
{ {
@ -1743,7 +1750,7 @@ static NSImage *unexpandable = nil;
{ {
int num; int num;
int i; int i;
id sitem = (startitem == nil)?[NSNull null]:startitem; id sitem = (startitem == nil) ? (id)[NSNull null] : (id)startitem;
NSMutableArray *anarray; NSMutableArray *anarray;
anarray = NSMapGet(_itemDict, sitem); anarray = NSMapGet(_itemDict, sitem);
@ -1769,7 +1776,7 @@ static NSImage *unexpandable = nil;
int num = [_dataSource outlineView: self int num = [_dataSource outlineView: self
numberOfChildrenOfItem: startitem]; numberOfChildrenOfItem: startitem];
int i = 0; int i = 0;
id sitem = (startitem == nil)?[NSNull null]:startitem; id sitem = (startitem == nil) ? (id)[NSNull null] : (id)startitem;
NSMutableArray *anarray = nil; NSMutableArray *anarray = nil;
if (num > 0) if (num > 0)
@ -1822,7 +1829,7 @@ static NSImage *unexpandable = nil;
int i = 0; int i = 0;
int insertionPoint = 0; int insertionPoint = 0;
id object = nil; id object = nil;
id sitem = (item == nil)?[NSNull null]:item; id sitem = (item == nil) ? (id)[NSNull null] : (id)item;
object = NSMapGet(_itemDict, sitem); object = NSMapGet(_itemDict, sitem);
numchildren = [object count]; numchildren = [object count];
@ -1872,7 +1879,7 @@ static NSImage *unexpandable = nil;
{ {
int numchildren = 0; int numchildren = 0;
int i = 0; int i = 0;
id sitem = (startitem == nil)?[NSNull null]:startitem; id sitem = (startitem == nil) ? (id)[NSNull null] : (id)startitem;
NSMutableArray *anarray; NSMutableArray *anarray;
anarray = NSMapGet(_itemDict, sitem); anarray = NSMapGet(_itemDict, sitem);

View file

@ -529,8 +529,7 @@ enum {
{ {
RELEASE(customPapers); RELEASE(customPapers);
RELEASE(measurementString); RELEASE(measurementString);
[super dealloc];
[super release];
} }

View file

@ -163,12 +163,20 @@
BOOL flag; BOOL flag;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
flag = _becomesKeyOnlyIfNeeded; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; {
flag = _isFloatingPanel; // Nothing to do here, for keyed coding this is handled by NSWindowTemplate.
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; // Calling the above method should throw an NSInvalidArgumentException.
flag = _worksWhenModal; }
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; else
{
flag = _becomesKeyOnlyIfNeeded;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _isFloatingPanel;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _worksWhenModal;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -176,12 +184,20 @@
BOOL flag; BOOL flag;
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; if([aDecoder allowsKeyedCoding])
[self setBecomesKeyOnlyIfNeeded: flag]; {
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; // Nothing to do here, for keyed coding this is handled by NSWindowTemplate.
[self setFloatingPanel: flag]; // Calling the above method should throw an NSInvalidArgumentException.
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; }
[self setWorksWhenModal: flag]; else
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setBecomesKeyOnlyIfNeeded: flag];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setFloatingPanel: flag];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setWorksWhenModal: flag];
}
return self; return self;
} }

View file

@ -314,100 +314,112 @@ static NSParagraphStyle *defaultStyle = nil;
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
unsigned count; if([aCoder allowsKeyedCoding])
[aCoder decodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment];
[aCoder decodeValueOfObjCType: @encode(NSLineBreakMode)
at: &_lineBreakMode];
[aCoder decodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
[aCoder decodeValueOfObjCType: @encode(float) at: &_headIndent];
[aCoder decodeValueOfObjCType: @encode(float) at: &_lineSpacing];
[aCoder decodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
[aCoder decodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
[aCoder decodeValueOfObjCType: @encode(float) at: &_paragraphSpacing];
[aCoder decodeValueOfObjCType: @encode(float) at: &_tailIndent];
/*
* Tab stops don't conform to NSCoding - so we do it the long way.
*/
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
_tabStops = [[NSMutableArray alloc] initWithCapacity: count];
if (count > 0)
{ {
float locations[count]; // TODO_NIB: Determine keys for NSParagraphStyle, if there are any.
NSTextTabType types[count]; }
unsigned i; else
{
[aCoder decodeArrayOfObjCType: @encode(float) unsigned count;
count: count
at: locations]; [aCoder decodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment];
[aCoder decodeArrayOfObjCType: @encode(NSTextTabType) [aCoder decodeValueOfObjCType: @encode(NSLineBreakMode)
count: count at: &_lineBreakMode];
at: types]; [aCoder decodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
for (i = 0; i < count; i++) [aCoder decodeValueOfObjCType: @encode(float) at: &_headIndent];
[aCoder decodeValueOfObjCType: @encode(float) at: &_lineSpacing];
[aCoder decodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
[aCoder decodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
[aCoder decodeValueOfObjCType: @encode(float) at: &_paragraphSpacing];
[aCoder decodeValueOfObjCType: @encode(float) at: &_tailIndent];
/*
* Tab stops don't conform to NSCoding - so we do it the long way.
*/
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
_tabStops = [[NSMutableArray alloc] initWithCapacity: count];
if (count > 0)
{ {
NSTextTab *tab; float locations[count];
NSTextTabType types[count];
tab = [NSTextTab alloc]; unsigned i;
tab = [tab initWithType: types[i] location: locations[i]];
[_tabStops addObject: tab]; [aCoder decodeArrayOfObjCType: @encode(float)
RELEASE (tab); count: count
at: locations];
[aCoder decodeArrayOfObjCType: @encode(NSTextTabType)
count: count
at: types];
for (i = 0; i < count; i++)
{
NSTextTab *tab;
tab = [NSTextTab alloc];
tab = [tab initWithType: types[i] location: locations[i]];
[_tabStops addObject: tab];
RELEASE (tab);
}
}
if ([aCoder versionForClassName: @"NSParagraphStyle"] >= 2)
{
[aCoder decodeValueOfObjCType: @encode(int) at: &_baseDirection];
} }
} }
if ([aCoder versionForClassName: @"NSParagraphStyle"] >= 2)
{
[aCoder decodeValueOfObjCType: @encode(int) at: &_baseDirection];
}
return self; return self;
} }
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
unsigned count; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment];
[aCoder encodeValueOfObjCType: @encode(NSLineBreakMode)
at: &_lineBreakMode];
[aCoder encodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
[aCoder encodeValueOfObjCType: @encode(float) at: &_headIndent];
[aCoder encodeValueOfObjCType: @encode(float) at: &_lineSpacing];
[aCoder encodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
[aCoder encodeValueOfObjCType: @encode(float) at: &_paragraphSpacing];
[aCoder encodeValueOfObjCType: @encode(float) at: &_tailIndent];
/*
* Tab stops don't conform to NSCoding - so we do it the long way.
*/
count = [_tabStops count];
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
if (count > 0)
{ {
float locations[count]; // TODO_NIB: Determine keys for NSParagraphStyle, if there are any.
NSTextTabType types[count]; }
unsigned i; else
{
for (i = 0; i < count; i++) unsigned count;
{
NSTextTab *tab = [_tabStops objectAtIndex: i]; [aCoder encodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment];
[aCoder encodeValueOfObjCType: @encode(NSLineBreakMode)
locations[i] = [tab location]; at: &_lineBreakMode];
types[i] = [tab tabStopType]; [aCoder encodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
} [aCoder encodeValueOfObjCType: @encode(float) at: &_headIndent];
[aCoder encodeArrayOfObjCType: @encode(float) [aCoder encodeValueOfObjCType: @encode(float) at: &_lineSpacing];
count: count [aCoder encodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
at: locations]; [aCoder encodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
[aCoder encodeArrayOfObjCType: @encode(NSTextTabType) [aCoder encodeValueOfObjCType: @encode(float) at: &_paragraphSpacing];
count: count [aCoder encodeValueOfObjCType: @encode(float) at: &_tailIndent];
at: types];
/*
* Tab stops don't conform to NSCoding - so we do it the long way.
*/
count = [_tabStops count];
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
if (count > 0)
{
float locations[count];
NSTextTabType types[count];
unsigned i;
for (i = 0; i < count; i++)
{
NSTextTab *tab = [_tabStops objectAtIndex: i];
locations[i] = [tab location];
types[i] = [tab tabStopType];
}
[aCoder encodeArrayOfObjCType: @encode(float)
count: count
at: locations];
[aCoder encodeArrayOfObjCType: @encode(NSTextTabType)
count: count
at: types];
}
[aCoder encodeValueOfObjCType: @encode(int) at: &_baseDirection];
} }
[aCoder encodeValueOfObjCType: @encode(int) at: &_baseDirection];
} }
- (BOOL) isEqual: (id)aother - (BOOL) isEqual: (id)aother
{ {
NSParagraphStyle *other = aother; NSParagraphStyle *other = aother;

View file

@ -536,6 +536,7 @@
#include <Foundation/NSInvocation.h> #include <Foundation/NSInvocation.h>
#include <Foundation/NSLock.h> #include <Foundation/NSLock.h>
#include <Foundation/NSPathUtilities.h> #include <Foundation/NSPathUtilities.h>
#include <Foundation/NSPortCoder.h>
#include <Foundation/NSPortNameServer.h> #include <Foundation/NSPortNameServer.h>
#include <Foundation/NSProcessInfo.h> #include <Foundation/NSProcessInfo.h>
#include <Foundation/NSSerialization.h> #include <Foundation/NSSerialization.h>

View file

@ -958,21 +958,36 @@ static NSImage *_pbc_image[2];
// //
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
int flag;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
[aCoder encodeObject: _menu]; {
[aCoder encodeConditionalObject: [self selectedItem]]; [aCoder encodeBool: [self altersStateOfSelectedItem] forKey: @"NSAltersState"];
flag = _pbcFlags.pullsDown; [aCoder encodeBool: [self usesItemFromMenu] forKey: @"NSUsesItemFromMenu"];
[aCoder encodeValueOfObjCType: @encode(int) at: &flag]; [aCoder encodeInt: [self arrowPosition] forKey: @"NSArrowPosition"];
flag = _pbcFlags.preferredEdge; [aCoder encodeInt: [self preferredEdge] forKey: @"NSPreferredEdge"];
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.usesItemFromMenu; // encode the menu, if present.
[aCoder encodeValueOfObjCType: @encode(int) at: &flag]; if(_menu != nil)
flag = _pbcFlags.altersStateOfSelectedItem; {
[aCoder encodeValueOfObjCType: @encode(int) at: &flag]; [aCoder encodeObject: _menu forKey: @"NSMenu"];
flag = _pbcFlags.arrowPosition; }
[aCoder encodeValueOfObjCType: @encode(int) at: &flag]; }
else
{
int flag;
[aCoder encodeObject: _menu];
[aCoder encodeConditionalObject: [self selectedItem]];
flag = _pbcFlags.pullsDown;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.preferredEdge;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.usesItemFromMenu;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.altersStateOfSelectedItem;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.arrowPosition;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -980,7 +995,6 @@ static NSImage *_pbc_image[2];
NSMenu *menu; NSMenu *menu;
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
if ([aDecoder containsValueForKey: @"NSAltersState"]) if ([aDecoder containsValueForKey: @"NSAltersState"])

View file

@ -306,8 +306,7 @@ static NSPrintPanel *shared_instance;
} }
else else
{ {
NSLog(@"Print panel buttonAction: from unknown sender - x%x\n", NSLog(@"Print panel buttonAction: from unknown sender - x%p\n", sender);
(unsigned)sender);
} }
[NSApp stopModalWithCode: _picked]; [NSApp stopModalWithCode: _picked];
} }

View file

@ -646,21 +646,34 @@ static NSMutableDictionary* printerCache;
// //
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[aCoder encodeObject: _printerHost]; if([aCoder allowsKeyedCoding])
[aCoder encodeObject: _printerName]; {
[aCoder encodeObject: _printerNote]; // TODO: Determine keys for NSPrinter.
[aCoder encodeObject: _printerType]; }
[aCoder encodeObject: _tables]; else
{
[aCoder encodeObject: _printerHost];
[aCoder encodeObject: _printerName];
[aCoder encodeObject: _printerNote];
[aCoder encodeObject: _printerType];
[aCoder encodeObject: _tables];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
_printerHost = [aDecoder decodeObject]; if([aDecoder allowsKeyedCoding])
_printerName = [aDecoder decodeObject]; {
_printerNote = [aDecoder decodeObject]; // TODO: Determine keys for NSPrinter.
_printerType = [aDecoder decodeObject]; }
_tables = [aDecoder decodeObject]; else
{
_printerHost = [aDecoder decodeObject];
_printerName = [aDecoder decodeObject];
_printerNote = [aDecoder decodeObject];
_printerType = [aDecoder decodeObject];
_tables = [aDecoder decodeObject];
}
return self; return self;
} }
@ -1155,10 +1168,10 @@ static NSMutableDictionary* printerCache;
// The translations also have to have any hex substrings interpreted // The translations also have to have any hex substrings interpreted
if (optionTranslation) if (optionTranslation)
optionTranslation = [self interpretQuotedValue: optionTranslation]; optionTranslation = [self interpretQuotedValue: optionTranslation];
if (valueTranslation) if (valueTranslation)
valueTranslation = [self interpretQuotedValue: valueTranslation]; valueTranslation = [self interpretQuotedValue: valueTranslation];
// The keyword (or keyword/option pair, if there's a option), should only // The keyword (or keyword/option pair, if there's a option), should only
// only have one value, unless it's one of the optionless keywords which // only have one value, unless it's one of the optionless keywords which
// allow multiple instances. // allow multiple instances.
@ -1448,35 +1461,45 @@ static NSMutableDictionary* printerCache;
[scanner scanString: @"<" [scanner scanString: @"<"
intoString: NULL]; intoString: NULL];
[scanner scanCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet] // "<<" is a valid part of a PS string
intoString: NULL]; if ([scanner scanString: @"<"
intoString: NULL])
{
value = [value stringByAppendingString: @"<<"];
}
else
{
[scanner scanCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]
intoString: NULL];
while (![scanner scanString: @">"
intoString: NULL])
{
location = [scanner scanLocation];
if (location+2 > stringLength)
{
[NSException raise: NSPPDParseException
format: @"Badly formatted hexadecimal substring '%@' in \
PPD printer file.", qString];
// NOT REACHED
}
value = [value stringByAppendingFormat: @"%c",
16 * [self gethex: [qString characterAtIndex: location]]
+ [self gethex: [qString characterAtIndex: location+1]]];
[scanner setScanLocation: location+2];
[scanner scanCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]
intoString: NULL];
}
}
if ([scanner scanUpToString:@"<" intoString:&part])
{
value = [value stringByAppendingString: part];
}
}
while (![scanner scanString: @">"
intoString: NULL])
{
location = [scanner scanLocation];
if (location+2 > stringLength)
{
[NSException raise: NSPPDParseException
format: @"Badly formatted hexadecimal substring in \
PPD printer file."];
// NOT REACHED
}
value = [value stringByAppendingFormat: @"%c",
16 * [self gethex: [qString characterAtIndex: location]]
+ [self gethex: [qString characterAtIndex: location+1]]];
[scanner setScanLocation: location+2];
[scanner scanCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]
intoString: NULL];
}
if ([scanner scanUpToString:@"<" intoString:&part])
{
value = [value stringByAppendingString: part];
}
}
return value; return value;
} }
@ -1509,8 +1532,9 @@ static NSMutableDictionary* printerCache;
case 'f': return 15; case 'f': return 15;
} }
[NSException [NSException
raise:NSPPDParseException raise: NSPPDParseException
format:@"Badly formatted hexadeximal substring in PPD printer file."]; format: @"Badly formatted hexadeximal character '%d' in PPD printer file.",
character];
return 0; /* Quiet compiler warnings */ return 0; /* Quiet compiler warnings */
} }

View file

@ -28,6 +28,7 @@
#include "AppKit/NSGraphics.h" #include "AppKit/NSGraphics.h"
#include "AppKit/NSWindow.h" #include "AppKit/NSWindow.h"
#include "GNUstepGUI/GSDrawFunctions.h" #include "GNUstepGUI/GSDrawFunctions.h"
#include "GNUstepGUI/GSNibCompatibility.h"
@implementation NSProgressIndicator @implementation NSProgressIndicator
@ -289,14 +290,44 @@ static NSColor *fillColour = nil;
- (void)encodeWithCoder:(NSCoder *)aCoder - (void)encodeWithCoder:(NSCoder *)aCoder
{ {
[super encodeWithCoder:aCoder]; [super encodeWithCoder:aCoder];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isIndeterminate]; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isBezeled]; {
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_usesThreadedAnimation]; unsigned long flags = 0;
[aCoder encodeValueOfObjCType: @encode(NSTimeInterval) at:&_animationDelay]; id matrix = AUTORELEASE([[NSPSMatrix alloc] init]);
[aCoder encodeValueOfObjCType: @encode(double) at:&_doubleValue];
[aCoder encodeValueOfObjCType: @encode(double) at:&_minValue]; [aCoder encodeDouble: _minValue forKey: @"NSMinValue"];
[aCoder encodeValueOfObjCType: @encode(double) at:&_maxValue]; [aCoder encodeDouble: _maxValue forKey: @"NSMaxValue"];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isVertical]; [aCoder encodeObject: matrix forKey: @"NSDrawMatrix"];
// add flag values.
flags |= (_isIndeterminate)? 2 : 0;
//
// Hard coded... this value forces it to be a regular-sized,
// bar type progress indicator since this is the only type
// gnustep supports.
//
flags |= 8200;
[aCoder encodeInt: flags forKey: @"NSpiFlags"];
// things which Gorm encodes, but IB doesn't care about.
[aCoder encodeDouble: _doubleValue forKey: @"GSDoubleValue"];
[aCoder encodeBool: _isBezeled forKey: @"GSIsBezeled"];
[aCoder encodeBool: _isVertical forKey: @"GSIsVertical"];
[aCoder encodeBool: _usesThreadedAnimation forKey: @"GSUsesThreadAnimation"];
[aCoder encodeDouble: _animationDelay forKey: @"GSAnimationDelay"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isIndeterminate];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isBezeled];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_usesThreadedAnimation];
[aCoder encodeValueOfObjCType: @encode(NSTimeInterval) at:&_animationDelay];
[aCoder encodeValueOfObjCType: @encode(double) at:&_doubleValue];
[aCoder encodeValueOfObjCType: @encode(double) at:&_minValue];
[aCoder encodeValueOfObjCType: @encode(double) at:&_maxValue];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isVertical];
}
} }
- (id)initWithCoder:(NSCoder *)aDecoder - (id)initWithCoder:(NSCoder *)aDecoder
@ -304,18 +335,47 @@ static NSColor *fillColour = nil;
self = [super initWithCoder:aDecoder]; self = [super initWithCoder:aDecoder];
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
//id *matrix = [aDecoder decodeObjectForKey: @"NSDrawMatrix"]; // id matrix = [aDecoder decodeObjectForKey: @"NSDrawMatrix"];
if ([aDecoder containsValueForKey: @"NSMaxValue"]) if ([aDecoder containsValueForKey: @"NSMaxValue"])
{ {
int max = [aDecoder decodeIntForKey: @"NSMaxValue"]; int max = [aDecoder decodeDoubleForKey: @"NSMaxValue"];
[self setMaxValue: max]; [self setMaxValue: max];
} }
if ([aDecoder containsValueForKey: @"NSMinValue"])
{
int min = [aDecoder decodeDoubleForKey: @"NSMinValue"];
[self setMinValue: min];
}
if ([aDecoder containsValueForKey: @"NSpiFlags"]) if ([aDecoder containsValueForKey: @"NSpiFlags"])
{ {
//int flags = [aDecoder decodeIntForKey: @"NSpiFlags"]; int flags = [aDecoder decodeIntForKey: @"NSpiFlags"];
// FIXME
_isIndeterminate = ((flags & 2) == 2);
// ignore the rest, since they are not pertinent to GNUstep.
}
// things which Gorm encodes, but IB doesn't care about.
if ([aDecoder containsValueForKey: @"GSDoubleValue"])
{
_doubleValue = [aDecoder decodeDoubleForKey: @"GSDoubleValue"];
}
if ([aDecoder containsValueForKey: @"GSIsBezeled"])
{
_isBezeled = [aDecoder decodeBoolForKey: @"GSIsBezeled"];
}
if ([aDecoder containsValueForKey: @"GSIsVertical"])
{
_isVertical = [aDecoder decodeBoolForKey: @"GSIsVertical"];
}
if ([aDecoder containsValueForKey: @"GSUsesThreadAnimation"])
{
_usesThreadedAnimation = [aDecoder decodeBoolForKey: @"GSUsesThreadAnimation"];
}
if ([aDecoder containsValueForKey: @"GSAnimationDelay"])
{
_animationDelay = [aDecoder decodeDoubleForKey: @"GSAnimationDelay"];
} }
} }
else else
@ -348,3 +408,4 @@ static NSColor *fillColour = nil;
} }
@end @end

View file

@ -1067,6 +1067,7 @@ selectCellWithString: (NSString*)title
{ {
ASSIGN(_directory, [_browser pathToColumn:[_browser lastColumn]]); ASSIGN(_directory, [_browser pathToColumn:[_browser lastColumn]]);
[NSApp stopModalWithCode: NSCancelButton]; [NSApp stopModalWithCode: NSCancelButton];
[_okButton setEnabled: NO];
[self close]; [self close];
} }
@ -1179,6 +1180,7 @@ selectCellWithString: (NSString*)title
return; return;
[NSApp stopModalWithCode: NSOKButton]; [NSApp stopModalWithCode: NSOKButton];
[_okButton setEnabled: NO];
[self close]; [self close];
} }

View file

@ -1220,6 +1220,27 @@ static float scrollerWidth;
if([aCoder allowsKeyedCoding]) if([aCoder allowsKeyedCoding])
{ {
unsigned long flags = 0;
GSScrollViewFlags scrollViewFlags;
[aCoder encodeObject: _horizScroller forKey: @"NSHScroller"];
[aCoder encodeObject: _vertScroller forKey: @"NSVScroller"];
[aCoder encodeObject: _contentView forKey: @"NSContentView"];
// only encode this, if it's not null...
if(_headerClipView != nil)
{
[aCoder encodeObject: _headerClipView forKey: @"NSHeaderClipView"];
}
scrollViewFlags.hasVScroller = _hasVertScroller;
scrollViewFlags.hasHScroller = _hasHorizScroller;
scrollViewFlags.border = _borderType;
scrollViewFlags.__unused4 = 0;
scrollViewFlags.__unused0 = 0;
memcpy((void *)&flags, (void *)&scrollViewFlags,sizeof(unsigned long));
[aCoder encodeInt: flags forKey: @"NSsFlags"];
} }
else else
{ {
@ -1268,6 +1289,12 @@ static float scrollerWidth;
NSScroller *vScroller = [aDecoder decodeObjectForKey: @"NSVScroller"]; NSScroller *vScroller = [aDecoder decodeObjectForKey: @"NSVScroller"];
NSClipView *content = [aDecoder decodeObjectForKey: @"NSContentView"]; NSClipView *content = [aDecoder decodeObjectForKey: @"NSContentView"];
_hLineScroll = 10;
_hPageScroll = 10;
_vLineScroll = 10;
_vPageScroll = 10;
_scrollsDynamically = YES;
if ([aDecoder containsValueForKey: @"NSsFlags"]) if ([aDecoder containsValueForKey: @"NSsFlags"])
{ {
unsigned long flags = [aDecoder decodeIntForKey: @"NSsFlags"]; unsigned long flags = [aDecoder decodeIntForKey: @"NSsFlags"];
@ -1304,7 +1331,7 @@ static float scrollerWidth;
RETAIN(content); RETAIN(content);
[self setContentView: content]; [self setContentView: content];
RELEASE(content); RELEASE(content);
_contentView = content; ASSIGN(_contentView, content);
} }
if (hScroller != nil && _hasHorizScroller) if (hScroller != nil && _hasHorizScroller)

View file

@ -211,23 +211,46 @@ typedef enum
// //
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[aCoder encodeValueOfObjCType: @encode(BOOL) if([aCoder allowsKeyedCoding])
at: &_isWellKnownSelection]; {
[aCoder encodeValueOfObjCType: @encode(int) [aCoder encodeBool: _isWellKnownSelection
at: &_selectionType]; forKey: @"GSIsWellKnownSelection"];
[aCoder encodeValueOfObjCType: @encode(id) [aCoder encodeBool: _selectionType
at: _descriptionData]; forKey: @"GSSelectionType"];
[aCoder encodeObject: _descriptionData
forKey: @"GSDescriptionData"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &_isWellKnownSelection];
[aCoder encodeValueOfObjCType: @encode(int)
at: &_selectionType];
[aCoder encodeValueOfObjCType: @encode(id)
at: _descriptionData];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super init]; [super init];
[aDecoder decodeValueOfObjCType: @encode(BOOL) if([aDecoder allowsKeyedCoding])
at: &_isWellKnownSelection]; {
[aDecoder decodeValueOfObjCType: @encode(int) _isWellKnownSelection = [aDecoder decodeBoolForKey: @"GSIsWellKnownSelection"];
at: &_selectionType]; _selectionType = [aDecoder decodeIntForKey: @"GSSelectionType"];
[aDecoder decodeValueOfObjCType: @encode(id) ASSIGN(_descriptionData, [aDecoder decodeObjectForKey: @"GSDescriptionData"]);
at: _descriptionData]; }
else
{
id obj;
[aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &_isWellKnownSelection];
[aDecoder decodeValueOfObjCType: @encode(int)
at: &_selectionType];
[aDecoder decodeValueOfObjCType: @encode(id)
at: &obj];
ASSIGN(_descriptionData, obj);
}
// if it's a well known selection then determine which one it is. // if it's a well known selection then determine which one it is.
if (_isWellKnownSelection) if (_isWellKnownSelection)
@ -251,7 +274,7 @@ typedef enum
break; break;
} }
} }
return self; return self;
} }

View file

@ -30,62 +30,6 @@
#include "AppKit/NSSlider.h" #include "AppKit/NSSlider.h"
#include "AppKit/NSSliderCell.h" #include "AppKit/NSSliderCell.h"
#include "AppKit/NSWindow.h" #include "AppKit/NSWindow.h"
#include "AppKit/NSApplication.h"
static inline
float _floatValueForMousePoint (NSPoint point, NSRect knobRect,
NSRect slotRect, BOOL isVertical,
float minValue, float maxValue,
NSSliderCell *theCell, BOOL flipped)
{
float floatValue = 0;
float position;
// Adjust the point to lie inside the knob slot. We don't
// have to worry whether the view is flipped or not.
if (isVertical)
{
if (point.y < slotRect.origin.y + knobRect.size.height / 2)
{
position = slotRect.origin.y + knobRect.size.height / 2;
}
else if (point.y > slotRect.origin.y + slotRect.size.height
- knobRect.size.height / 2)
{
position = slotRect.origin.y + slotRect.size.height
- knobRect.size.height / 2;
}
else
position = point.y;
// Compute the float value
floatValue = (position - (slotRect.origin.y + knobRect.size.height/2))
/ (slotRect.size.height - knobRect.size.height);
if (flipped)
floatValue = 1 - floatValue;
}
else
{
if (point.x < slotRect.origin.x + knobRect.size.width / 2)
{
position = slotRect.origin.x + knobRect.size.width / 2;
}
else if (point.x > slotRect.origin.x + slotRect.size.width
- knobRect.size.width / 2)
{
position = slotRect.origin.x + slotRect.size.width
- knobRect.size.width / 2;
}
else
position = point.x;
// Compute the float value given the knob size
floatValue = (position - (slotRect.origin.x + knobRect.size.width / 2))
/ (slotRect.size.width - knobRect.size.width);
}
return floatValue * (maxValue - minValue) + minValue;
}
/** /**
<unit> <unit>
@ -361,109 +305,4 @@ static Class cellClass;
return [_cell tickMarkValueAtIndex: index]; return [_cell tickMarkValueAtIndex: index];
} }
- (void) trackKnob: (NSEvent*)theEvent knobRect: (NSRect)knobRect
{
NSApplication *app = [NSApplication sharedApplication];
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
| NSLeftMouseDraggedMask | NSMouseMovedMask
| NSPeriodicMask;
NSPoint point = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
NSEventType eventType = [theEvent type];
BOOL isContinuous = [_cell isContinuous];
float oldFloatValue = [_cell floatValue];
id target = [_cell target];
SEL action = [_cell action];
NSDate *distantFuture = [NSDate distantFuture];
NSRect slotRect = [_cell trackRect];
BOOL isVertical = [_cell isVertical];
float minValue = [_cell minValue];
float maxValue = [_cell maxValue];
[NSEvent startPeriodicEventsAfterDelay: 0.05 withPeriod: 0.05];
[[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode];
[self lockFocus];
while (eventType != NSLeftMouseUp)
{
theEvent = [app nextEventMatchingMask: eventMask
untilDate: distantFuture
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
eventType = [theEvent type];
if (eventType != NSPeriodic)
{
point = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
}
else
{
if (point.x != knobRect.origin.x || point.y != knobRect.origin.y)
{
float floatValue;
floatValue = _floatValueForMousePoint (point, knobRect,
slotRect, isVertical,
minValue, maxValue,
_cell,
_rFlags.flipped_view);
if (floatValue != oldFloatValue)
{
[_cell setFloatValue: floatValue];
[_cell drawWithFrame: _bounds inView: self];
[_window flushWindow];
if (isContinuous)
{
[self sendAction: action to: target];
}
oldFloatValue = floatValue;
}
knobRect.origin = point;
}
}
}
[self unlockFocus];
// If the control is not continuous send the action at the end of the drag
if (!isContinuous)
{
[self sendAction: action to: target];
}
[NSEvent stopPeriodicEvents];
}
- (void) mouseDown: (NSEvent *)theEvent
{
if ([_cell isEnabled])
{
NSPoint location = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
NSRect rect;
rect = [_cell knobRectFlipped: _rFlags.flipped_view];
if (![self mouse: location inRect: rect])
{
// Mouse is not on the knob, move the knob to the mouse position
float floatValue;
floatValue = _floatValueForMousePoint (location, rect,
[_cell trackRect],
[_cell isVertical],
[_cell minValue],
[_cell maxValue], _cell,
_rFlags.flipped_view);
[_cell setFloatValue: floatValue];
if ([_cell isContinuous])
{
[self sendAction: [_cell action] to: [_cell target]];
}
[self lockFocus];
[_cell drawWithFrame: _bounds inView: self];
[self unlockFocus];
[_window flushWindow];
}
[self trackKnob: theEvent knobRect: rect];
}
}
@end @end

View file

@ -29,15 +29,72 @@
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include "AppKit/NSSliderCell.h" #include "AppKit/NSApplication.h"
#include "AppKit/NSColor.h" #include "AppKit/NSColor.h"
#include "AppKit/NSGraphics.h"
#include "AppKit/NSControl.h" #include "AppKit/NSControl.h"
#include "AppKit/NSEvent.h"
#include "AppKit/NSGraphics.h"
#include "AppKit/NSImage.h" #include "AppKit/NSImage.h"
#include "AppKit/NSSliderCell.h"
#include "AppKit/NSTextFieldCell.h" #include "AppKit/NSTextFieldCell.h"
#include "AppKit/NSWindow.h"
DEFINE_RINT_IF_MISSING DEFINE_RINT_IF_MISSING
static inline
float _floatValueForMousePoint (NSPoint point, NSRect knobRect,
NSRect slotRect, BOOL isVertical,
float minValue, float maxValue,
NSSliderCell *theCell, BOOL flipped)
{
float floatValue = 0;
float position;
// Adjust the point to lie inside the knob slot. We don't
// have to worry whether the view is flipped or not.
if (isVertical)
{
if (point.y < slotRect.origin.y + knobRect.size.height / 2)
{
position = slotRect.origin.y + knobRect.size.height / 2;
}
else if (point.y > slotRect.origin.y + slotRect.size.height
- knobRect.size.height / 2)
{
position = slotRect.origin.y + slotRect.size.height
- knobRect.size.height / 2;
}
else
position = point.y;
// Compute the float value
floatValue = (position - (slotRect.origin.y + knobRect.size.height/2))
/ (slotRect.size.height - knobRect.size.height);
if (flipped)
floatValue = 1 - floatValue;
}
else
{
if (point.x < slotRect.origin.x + knobRect.size.width / 2)
{
position = slotRect.origin.x + knobRect.size.width / 2;
}
else if (point.x > slotRect.origin.x + slotRect.size.width
- knobRect.size.width / 2)
{
position = slotRect.origin.x + slotRect.size.width
- knobRect.size.width / 2;
}
else
position = point.x;
// Compute the float value given the knob size
floatValue = (position - (slotRect.origin.x + knobRect.size.width / 2))
/ (slotRect.size.width - knobRect.size.width);
}
return floatValue * (maxValue - minValue) + minValue;
}
/** /**
<unit> <unit>
<heading>Class Description</heading> <heading>Class Description</heading>
@ -561,6 +618,112 @@ DEFINE_RINT_IF_MISSING
return _minValue + index * (_maxValue - _minValue) / _numberOfTickMarks; return _minValue + index * (_maxValue - _minValue) / _numberOfTickMarks;
} }
- (BOOL) trackMouse: (NSEvent*)theEvent
inRect: (NSRect)cellFrame
ofView: (NSView*)controlView
untilMouseUp: (BOOL)flag
{
float delay;
float interval;
id target = [self target];
SEL action = [self action];
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
| NSLeftMouseDraggedMask | NSMouseMovedMask;
NSEventType eventType = [theEvent type];
BOOL isContinuous = [self isContinuous];
float oldFloatValue = [self floatValue];
NSRect slotRect = [self trackRect];
BOOL isVertical = [self isVertical];
float minValue = [self minValue];
float maxValue = [self maxValue];
BOOL isFlipped = [controlView isFlipped];
NSPoint location = [theEvent locationInWindow];
NSPoint point = [controlView convertPoint: location fromView: nil];
NSRect knobRect = [self knobRectFlipped: isFlipped];
_mouse_down_flags = [theEvent modifierFlags];
if (![self isEnabled])
{
return NO;
}
if (![controlView mouse: point inRect: knobRect])
{
// Mouse is not on the knob, move the knob to the mouse position
float floatValue;
floatValue = _floatValueForMousePoint(point, knobRect,
slotRect, isVertical,
minValue, maxValue,
self, isFlipped);
[self setFloatValue: floatValue];
if (isContinuous)
{
[(NSControl*)controlView sendAction: action to: target];
}
}
if (isContinuous)
{
[self getPeriodicDelay: &delay interval: &interval];
[NSEvent startPeriodicEventsAfterDelay: delay withPeriod: interval];
eventMask |= NSPeriodicMask;
}
while (eventType != NSLeftMouseUp)
{
theEvent = [NSApp nextEventMatchingMask: eventMask
untilDate: nil
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
eventType = [theEvent type];
if (eventType == NSPeriodic)
{
NSWindow *w = [controlView window];
location = [w mouseLocationOutsideOfEventStream];
}
else
{
location = [theEvent locationInWindow];
}
point = [controlView convertPoint: location fromView: nil];
if (point.x != knobRect.origin.x || point.y != knobRect.origin.y)
{
float floatValue;
floatValue = _floatValueForMousePoint(point, knobRect,
slotRect, isVertical,
minValue, maxValue,
self, isFlipped);
if (floatValue != oldFloatValue)
{
[self setFloatValue: floatValue];
if (isContinuous)
{
[(NSControl*)controlView sendAction: action to: target];
}
oldFloatValue = floatValue;
}
knobRect.origin = point;
}
}
// If the cell is not continuous send the action at the end of the drag
if (!isContinuous)
{
[(NSControl*)controlView sendAction: action to: target];
}
else
{
[NSEvent stopPeriodicEvents];
}
return YES;
}
- (id) initWithCoder: (NSCoder*)decoder - (id) initWithCoder: (NSCoder*)decoder
{ {
self = [super initWithCoder: decoder]; self = [super initWithCoder: decoder];
@ -580,9 +743,10 @@ DEFINE_RINT_IF_MISSING
[_titleCell setStringValue: @""]; [_titleCell setStringValue: @""];
[_titleCell setAlignment: NSCenterTextAlignment]; [_titleCell setAlignment: NSCenterTextAlignment];
// if it's from a nib, make it bordered and bezeled so it's more attractive. // if it's from a nib, make it bordered and bezeled so it's more attractive, this
// information is not in the nib.
[self setBordered: YES]; [self setBordered: YES];
[self setBezeled: YES]; [self setBezeled: NO];
_isVertical = -1; _isVertical = -1;
} }

View file

@ -667,60 +667,73 @@ return NO; \
// //
- (void) encodeWithCoder: (NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{ {
[coder encodeValueOfObjCType: @encode(BOOL) at: &_onlyReference]; if([coder allowsKeyedCoding])
[coder encodeObject: _name];
if (_onlyReference == YES)
{ {
return; // TODO_NIB: Determine keys for NSSound.
} }
else
if (_uniqueIdentifier != nil)
{ {
[coder encodeObject: _uniqueIdentifier]; [coder encodeValueOfObjCType: @encode(BOOL) at: &_onlyReference];
[coder encodeObject: _name];
if (_onlyReference == YES)
{
return;
}
if (_uniqueIdentifier != nil)
{
[coder encodeObject: _uniqueIdentifier];
}
[coder encodeConditionalObject: _delegate];
[coder encodeValueOfObjCType: @encode(long) at: &_dataLocation];
[coder encodeValueOfObjCType: @encode(long) at: &_dataSize];
[coder encodeValueOfObjCType: @encode(int) at: &_dataFormat];
[coder encodeValueOfObjCType: @encode(float) at: &_samplingRate];
[coder encodeValueOfObjCType: @encode(float) at: &_frameSize];
[coder encodeValueOfObjCType: @encode(long) at: &_frameCount];
[coder encodeValueOfObjCType: @encode(int) at: &_channelCount];
[coder encodeObject: _data];
} }
[coder encodeConditionalObject: _delegate];
[coder encodeValueOfObjCType: @encode(long) at: &_dataLocation];
[coder encodeValueOfObjCType: @encode(long) at: &_dataSize];
[coder encodeValueOfObjCType: @encode(int) at: &_dataFormat];
[coder encodeValueOfObjCType: @encode(float) at: &_samplingRate];
[coder encodeValueOfObjCType: @encode(float) at: &_frameSize];
[coder encodeValueOfObjCType: @encode(long) at: &_frameCount];
[coder encodeValueOfObjCType: @encode(int) at: &_channelCount];
[coder encodeObject: _data];
} }
- (id) initWithCoder: (NSCoder*)decoder - (id) initWithCoder: (NSCoder*)decoder
{ {
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_onlyReference]; if([decoder allowsKeyedCoding])
if (_onlyReference == YES)
{ {
NSString *theName = [decoder decodeObject]; // TODO_NIB: Determine keys for NSSound.
}
RELEASE (self); else
self = RETAIN ([NSSound soundNamed: theName]); {
[self setName: theName]; [decoder decodeValueOfObjCType: @encode(BOOL) at: &_onlyReference];
}
else if (_onlyReference == YES)
{ {
_name = TEST_RETAIN ([decoder decodeObject]); NSString *theName = [decoder decodeObject];
_uniqueIdentifier = TEST_RETAIN ([decoder decodeObject]);
[self setDelegate: [decoder decodeObject]]; RELEASE (self);
self = RETAIN ([NSSound soundNamed: theName]);
[decoder decodeValueOfObjCType: @encode(long) at: &_dataLocation]; [self setName: theName];
[decoder decodeValueOfObjCType: @encode(long) at: &_dataSize]; }
[decoder decodeValueOfObjCType: @encode(int) at: &_dataFormat]; else
[decoder decodeValueOfObjCType: @encode(float) at: &_samplingRate]; {
[decoder decodeValueOfObjCType: @encode(float) at: &_frameSize]; _name = TEST_RETAIN ([decoder decodeObject]);
[decoder decodeValueOfObjCType: @encode(long) at: &_frameCount]; _uniqueIdentifier = TEST_RETAIN ([decoder decodeObject]);
[decoder decodeValueOfObjCType: @encode(int) at: &_channelCount]; [self setDelegate: [decoder decodeObject]];
_data = RETAIN([decoder decodeObject]); [decoder decodeValueOfObjCType: @encode(long) at: &_dataLocation];
[decoder decodeValueOfObjCType: @encode(long) at: &_dataSize];
[decoder decodeValueOfObjCType: @encode(int) at: &_dataFormat];
[decoder decodeValueOfObjCType: @encode(float) at: &_samplingRate];
[decoder decodeValueOfObjCType: @encode(float) at: &_frameSize];
[decoder decodeValueOfObjCType: @encode(long) at: &_frameCount];
[decoder decodeValueOfObjCType: @encode(int) at: &_channelCount];
_data = RETAIN([decoder decodeObject]);
}
} }
return self; return self;
} }

View file

@ -78,24 +78,23 @@ GSSpellServerName(NSString *vendor, NSString *language)
NSArray *userLanguages = [NSUserDefaults userLanguages]; NSArray *userLanguages = [NSUserDefaults userLanguages];
NSString *currentLanguage = [userLanguages objectAtIndex: 0]; NSString *currentLanguage = [userLanguages objectAtIndex: 0];
[super init]; if ((self = [super init]) != nil)
{
_delegate = nil; _delegate = nil;
_ignoredWords = nil; _ignoredWords = nil;
ASSIGN(_userDictionaries, [NSMutableDictionary dictionary]); ASSIGN(_userDictionaries, [NSMutableDictionary dictionary]);
ASSIGN(_currentLanguage, currentLanguage); ASSIGN(_currentLanguage, currentLanguage);
}
RETAIN(_userDictionaries);
RETAIN(_currentLanguage);
return self; return self;
} }
// Cleanup when deallocated // Cleanup when deallocated
- (void)dealloc - (void) dealloc
{ {
RELEASE(_userDictionaries); RELEASE(_userDictionaries);
RELEASE(_currentLanguage); RELEASE(_currentLanguage);
[super dealloc];
} }
// Checking in Your Service // Checking in Your Service

View file

@ -927,6 +927,13 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
{ {
[self setVertical: [aDecoder decodeBoolForKey: @"NSIsVertical"]]; [self setVertical: [aDecoder decodeBoolForKey: @"NSIsVertical"]];
} }
_dividerWidth = [self dividerThickness];
_draggedBarWidth = 8; // default bigger than dividerThickness
ASSIGN(_dividerColor, [NSColor controlShadowColor]);
ASSIGN(_backgroundColor, [NSColor controlBackgroundColor]);
ASSIGN(_dimpleImage, [NSImage imageNamed: @"common_Dimple.tiff"]);
_never_displayed_before = YES;
} }
else else
{ {

View file

@ -29,7 +29,6 @@
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include "AppKit/NSStepper.h" #include "AppKit/NSStepper.h"
#include "AppKit/NSControl.h" #include "AppKit/NSControl.h"
#include "AppKit/NSColor.h"
#include "AppKit/NSEvent.h" #include "AppKit/NSEvent.h"
#include "AppKit/NSWindow.h" #include "AppKit/NSWindow.h"
#include "AppKit/NSApplication.h" #include "AppKit/NSApplication.h"
@ -71,11 +70,6 @@ id _nsstepperCellClass = nil;
// Instance methods // Instance methods
// //
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
{
return YES;
}
// //
// Determining the first responder // Determining the first responder
// //
@ -97,18 +91,8 @@ id _nsstepperCellClass = nil;
- (void) keyDown: (NSEvent*)theEvent - (void) keyDown: (NSEvent*)theEvent
{ {
} // FIXME
[super keyDown: theEvent];
- (void) encodeWithCoder: (NSCoder *)aCoder
{
[super encodeWithCoder: aCoder];
}
- (id) initWithCoder: (NSCoder *)aDecoder
{
[super initWithCoder: aDecoder];
return self;
} }
- (double) maxValue - (double) maxValue
@ -141,8 +125,6 @@ id _nsstepperCellClass = nil;
[_cell setIncrement: increment]; [_cell setIncrement: increment];
} }
- (BOOL)autorepeat - (BOOL)autorepeat
{ {
return [_cell autorepeat]; return [_cell autorepeat];
@ -163,199 +145,4 @@ id _nsstepperCellClass = nil;
[_cell setValueWraps: valueWraps]; [_cell setValueWraps: valueWraps];
} }
- (void) mouseDown: (NSEvent *)event
{
NSPoint point = [event locationInWindow];
NSRect upRect;
NSRect downRect;
NSRect rect;
BOOL isDirectionUp;
BOOL autorepeat = [_cell autorepeat];
if ([_cell isEnabled] == NO)
return;
if ([event type] != NSLeftMouseDown)
return;
upRect = [_cell upButtonRectWithFrame: _bounds];
downRect = [_cell downButtonRectWithFrame: _bounds];
point = [self convertPoint: point fromView: nil];
if (NSMouseInRect(point, upRect, NO))
{
isDirectionUp = YES;
rect = upRect;
}
else if (NSMouseInRect(point, downRect, NO))
{
isDirectionUp = NO;
rect = downRect;
}
else
{
return;
}
[self lockFocus];
{
BOOL overButton = YES;
int ignore = 3;
unsigned int eventMask = NSLeftMouseUpMask
| NSLeftMouseDraggedMask
| NSPeriodicMask;
NSDate *farAway = [NSDate distantFuture];
[_window flushWindow];
[_cell highlight: YES
upButton: isDirectionUp
withFrame: _bounds
inView: self];
[_window _captureMouse: self];
if (autorepeat)
{
[NSEvent startPeriodicEventsAfterDelay: 0.5 withPeriod: 0.025];
if (isDirectionUp)
[self _increment];
else
[self _decrement];
[_cell drawWithFrame:_bounds
inView:self];
[_window flushWindow];
}
else
[_window flushWindow];
event = [NSApp nextEventMatchingMask: eventMask
untilDate: farAway
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
while ([event type] != NSLeftMouseUp)
{
if ([event type] == NSPeriodic)
{
ignore ++;
if (ignore == 4) ignore = 0;
if (ignore == 0)
{
if (isDirectionUp)
[self _increment];
else
[self _decrement];
[_cell drawWithFrame:_bounds
inView:self];
[_window flushWindow];
}
}
else if (NSMouseInRect(point, rect, NO) != overButton)
{
overButton = !overButton;
if (overButton && autorepeat)
{
[NSEvent startPeriodicEventsAfterDelay: 0.5
withPeriod: 0.025];
ignore = 3;
}
else
{
[NSEvent stopPeriodicEvents];
}
[_cell highlight: overButton
upButton: isDirectionUp
withFrame: _bounds
inView: self];
[_window flushWindow];
}
event = [NSApp nextEventMatchingMask: eventMask
untilDate: farAway
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
point = [self convertPoint: [event locationInWindow]
fromView: nil];
}
if (overButton && autorepeat)
[NSEvent stopPeriodicEvents];
if (overButton && !autorepeat)
{
if (isDirectionUp)
[self _increment];
else
[self _decrement];
[_cell drawWithFrame:_bounds
inView:self];
}
[_cell highlight: NO
upButton: isDirectionUp
withFrame: _bounds
inView: self];
[_window flushWindow];
[_window _releaseMouse: self];
}
[self unlockFocus];
}
- (void)_increment
{
double newValue;
double maxValue = [_cell maxValue];
double minValue = [_cell minValue];
double increment = [_cell increment];
newValue = [_cell doubleValue] + increment;
if ([_cell valueWraps])
{
if (newValue > maxValue)
[_cell setDoubleValue:
newValue - maxValue + minValue - 1];
else if (newValue < minValue)
[_cell setDoubleValue:
newValue + maxValue - minValue + 1];
else
[_cell setDoubleValue: newValue];
}
else
{
if (newValue > maxValue)
[_cell setDoubleValue: maxValue];
else if (newValue < minValue)
[_cell setDoubleValue: minValue];
else
[_cell setDoubleValue: newValue];
}
[self sendAction: [self action] to: [self target]];
}
- (void)_decrement
{
double newValue;
double maxValue = [_cell maxValue];
double minValue = [_cell minValue];
double increment = [_cell increment];
newValue = [_cell doubleValue] - increment;
if ([_cell valueWraps])
{
if (newValue > maxValue)
[_cell setDoubleValue:
newValue - maxValue + minValue - 1];
else if (newValue < minValue)
[_cell setDoubleValue:
newValue + maxValue - minValue + 1];
else
[_cell setDoubleValue: newValue];
}
else
{
if (newValue > maxValue)
[_cell setDoubleValue: maxValue];
else if (newValue < minValue)
[_cell setDoubleValue: minValue];
else
[_cell setDoubleValue: newValue];
}
[self sendAction: [self action] to: [self target]];
}
@end @end

View file

@ -4,6 +4,8 @@
Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr> Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
Date: 2001 Date: 2001
Author: Fred Kiefer <FredKiefer@gmx.de>
Date: August 2006
This file is part of the GNUstep GUI Library. This file is part of the GNUstep GUI Library.
@ -24,17 +26,35 @@
*/ */
#include "config.h" #include "config.h"
#include "AppKit/NSGraphicsContext.h"
#include "AppKit/NSApplication.h"
#include "AppKit/NSColor.h" #include "AppKit/NSColor.h"
#include "AppKit/DPSOperators.h" #include "AppKit/NSControl.h"
#include "AppKit/PSOperators.h" #include "AppKit/NSEvent.h"
#include "AppKit/NSFont.h"
#include "AppKit/NSGraphics.h" #include "AppKit/NSGraphics.h"
#include "AppKit/NSGraphicsContext.h"
#include "AppKit/NSStepperCell.h" #include "AppKit/NSStepperCell.h"
#include "AppKit/NSText.h" #include "AppKit/NSWindow.h"
#include "AppKit/PSOperators.h"
#include "GNUstepGUI/GSDrawFunctions.h" #include "GNUstepGUI/GSDrawFunctions.h"
// Hard coded values for button sizes
#define STEPPER_WIDTH 15
#define STEPPER_HEIGHT 11
@interface NSStepperCell (Private)
- (void) _increment;
- (void) _decrement;
- (void) setHighlighted: (BOOL)highlight
upButton: (BOOL)upButton
withFrame: (NSRect)frame
inView: (NSView*)controlView;
- (NSRect) upButtonRectWithFrame: (NSRect)frame;
- (NSRect) downButtonRectWithFrame: (NSRect)frame;
@end
@implementation NSStepperCell @implementation NSStepperCell
+ (void) initialize + (void) initialize
{ {
if (self == [NSStepperCell class]) if (self == [NSStepperCell class])
@ -43,21 +63,30 @@
} }
} }
+ (BOOL) prefersTrackingUntilMouseUp
{
return YES;
}
// //
// Initialization // Initialization
// //
- (id) init - (id) init
{ {
self = [super init];
[self setIntValue: 0]; [self setIntValue: 0];
[super setAlignment: NSRightTextAlignment]; [self setAlignment: NSRightTextAlignment];
[super setWraps: NO]; [self setWraps: NO];
_autorepeat = YES; _autorepeat = YES;
_valueWraps = YES; _valueWraps = YES;
_maxValue = 59; _maxValue = 59;
_minValue = 0; _minValue = 0;
_increment = 1; _increment = 1;
highlightUp = NO; highlightUp = NO;
highlightDown = NO; highlightDown = NO;
return self; return self;
} }
@ -91,8 +120,6 @@
_increment = increment; _increment = increment;
} }
- (BOOL)autorepeat - (BOOL)autorepeat
{ {
return _autorepeat; return _autorepeat;
@ -113,18 +140,6 @@
_valueWraps = valueWraps; _valueWraps = valueWraps;
} }
- (void) dealloc
{
[super dealloc];
}
- (id) copyWithZone: (NSZone*)zone
{
NSStepperCell *c = [super copyWithZone: zone];
return c;
}
static inline NSRect DrawLightButton(NSRect border, NSRect clip) static inline NSRect DrawLightButton(NSRect border, NSRect clip)
{ {
/* /*
@ -151,21 +166,22 @@ static inline NSRect DrawLightButton(NSRect border, NSRect clip)
} }
} }
static inline void DrawUpButton(NSRect aRect) static inline void DrawUpButton(NSRect aRect)
{ {
NSRect unHighlightRect = DrawLightButton(aRect, NSZeroRect); NSRect unHighlightRect = DrawLightButton(aRect, NSZeroRect);
[[NSColor controlBackgroundColor] set]; [[NSColor controlBackgroundColor] set];
NSRectFill(unHighlightRect); NSRectFill(unHighlightRect);
PSsetgray(NSDarkGray); PSsetlinewidth(1.0);
[[NSColor controlShadowColor] set];
PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3); PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9); PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSstroke(); PSstroke();
PSsetgray(NSBlack); [[NSColor controlDarkShadowColor] set];
PSmoveto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9); PSmoveto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSlineto(NSMaxX(aRect) - 11, NSMinY(aRect) + 4); PSlineto(NSMaxX(aRect) - 11, NSMinY(aRect) + 4);
PSstroke(); PSstroke();
PSsetgray(NSWhite); [[NSColor controlLightHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 11, NSMinY(aRect) + 3); PSmoveto(NSMaxX(aRect) - 11, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3); PSlineto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSstroke(); PSstroke();
@ -177,15 +193,16 @@ static inline void HighlightUpButton(NSRect aRect)
[[NSColor selectedControlColor] set]; [[NSColor selectedControlColor] set];
NSRectFill(highlightRect); NSRectFill(highlightRect);
PSsetgray(NSLightGray); PSsetlinewidth(1.0);
[[NSColor controlHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3); PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9); PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSstroke(); PSstroke();
PSsetgray(NSBlack); [[NSColor controlDarkShadowColor] set];
PSmoveto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9); PSmoveto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSlineto(NSMaxX(aRect) - 11, NSMinY(aRect) + 4); PSlineto(NSMaxX(aRect) - 11, NSMinY(aRect) + 4);
PSstroke(); PSstroke();
PSsetgray(NSLightGray); [[NSColor controlHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 11, NSMinY(aRect) + 3); PSmoveto(NSMaxX(aRect) - 11, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3); PSlineto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSstroke(); PSstroke();
@ -198,15 +215,15 @@ static inline void DrawDownButton(NSRect aRect)
NSRectFill(unHighlightRect); NSRectFill(unHighlightRect);
PSsetlinewidth(1.0); PSsetlinewidth(1.0);
PSsetgray(NSDarkGray); [[NSColor controlShadowColor] set];
PSmoveto(NSMinX(aRect) + 4, NSMaxY(aRect) - 3); PSmoveto(NSMinX(aRect) + 4, NSMaxY(aRect) - 3);
PSlineto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8); PSlineto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSstroke(); PSstroke();
PSsetgray(NSWhite); [[NSColor controlLightHighlightColor] set];
PSmoveto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8); PSmoveto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSlineto(NSMinX(aRect) + 10, NSMaxY(aRect) - 3); PSlineto(NSMinX(aRect) + 10, NSMaxY(aRect) - 3);
PSstroke(); PSstroke();
PSsetgray(NSBlack); [[NSColor controlDarkShadowColor] set];
PSmoveto(NSMinX(aRect) + 10, NSMaxY(aRect) - 2); PSmoveto(NSMinX(aRect) + 10, NSMaxY(aRect) - 2);
PSlineto(NSMinX(aRect) + 4, NSMaxY(aRect) - 2); PSlineto(NSMinX(aRect) + 4, NSMaxY(aRect) - 2);
PSstroke(); PSstroke();
@ -219,15 +236,15 @@ static inline void HighlightDownButton(NSRect aRect)
NSRectFill(highlightRect); NSRectFill(highlightRect);
PSsetlinewidth(1.0); PSsetlinewidth(1.0);
PSsetgray(NSLightGray); [[NSColor controlHighlightColor] set];
PSmoveto(NSMinX(aRect) + 4, NSMaxY(aRect) - 3); PSmoveto(NSMinX(aRect) + 4, NSMaxY(aRect) - 3);
PSlineto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8); PSlineto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSstroke(); PSstroke();
PSsetgray(NSLightGray); [[NSColor controlHighlightColor] set];
PSmoveto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8); PSmoveto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSlineto(NSMinX(aRect) + 10, NSMaxY(aRect) - 3); PSlineto(NSMinX(aRect) + 10, NSMaxY(aRect) - 3);
PSstroke(); PSstroke();
PSsetgray(NSBlack); [[NSColor controlDarkShadowColor] set];
PSmoveto(NSMinX(aRect) + 10, NSMaxY(aRect) - 2); PSmoveto(NSMinX(aRect) + 10, NSMaxY(aRect) - 2);
PSlineto(NSMinX(aRect) + 4, NSMaxY(aRect) - 2); PSlineto(NSMinX(aRect) + 4, NSMaxY(aRect) - 2);
PSstroke(); PSstroke();
@ -246,7 +263,7 @@ static inline void HighlightDownButton(NSRect aRect)
twoButtons = downRect; twoButtons = downRect;
twoButtons.origin.y--; twoButtons.origin.y--;
twoButtons.size.width++; twoButtons.size.width++;
twoButtons.size.height = 23; twoButtons.size.height = 2 * STEPPER_HEIGHT + 1;
if (highlightUp) if (highlightUp)
HighlightUpButton(upRect); HighlightUpButton(upRect);
@ -260,49 +277,169 @@ static inline void HighlightDownButton(NSRect aRect)
{ {
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge}; NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge};
float grays[] = {NSBlack, NSBlack}; NSColor *black = [NSColor controlDarkShadowColor];
NSColor *grays[] = {black, black};
NSDrawTiledRects(twoButtons, NSZeroRect, NSDrawColorTiledRects(twoButtons, NSZeroRect,
up_sides, grays, 2); up_sides, grays, 2);
} }
} }
- (void) highlight: (BOOL) highlight - (void) getPeriodicDelay: (float*)delay interval: (float*)interval
upButton: (BOOL) upButton
withFrame: (NSRect) frame
inView: (NSView*) controlView
{ {
if (upButton) *delay = 0.5;
{ *interval = 0.025;
highlightUp = highlight; }
- (BOOL) trackMouse: (NSEvent*)theEvent
inRect: (NSRect)cellFrame
ofView: (NSView*)controlView
untilMouseUp: (BOOL)flag
{
NSPoint location = [theEvent locationInWindow];
NSPoint point = [controlView convertPoint: location fromView: nil];
NSRect upRect;
NSRect downRect;
NSRect rect;
float delay;
float interval;
BOOL overButton = YES;
unsigned int event_mask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
unsigned int periodCount = 0;
BOOL isDirectionUp;
BOOL autorepeat = [self autorepeat];
BOOL done = NO;
BOOL mouseWentUp = NO;
_mouse_down_flags = [theEvent modifierFlags];
if (![self startTrackingAt: point inView: controlView])
return NO;
if (![controlView mouse: point inRect: cellFrame])
return NO; // point is not in cell
if ([self isEnabled] == NO)
return NO;
if ([theEvent type] != NSLeftMouseDown)
return NO;
upRect = [self upButtonRectWithFrame: cellFrame];
downRect = [self downButtonRectWithFrame: cellFrame];
// Did the mouse go down in the up or in the down part?
if (NSMouseInRect(point, upRect, NO))
{
isDirectionUp = YES;
rect = upRect;
}
else if (NSMouseInRect(point, downRect, NO))
{
isDirectionUp = NO;
rect = downRect;
} }
else else
{ {
highlightDown = highlight; return mouseWentUp;
} }
[self drawWithFrame: frame inView: controlView]; [self setHighlighted: YES
} upButton: isDirectionUp
withFrame: cellFrame
inView: controlView];
- (NSRect) upButtonRectWithFrame: (NSRect) frame if (autorepeat)
{ {
NSRect upRect; [self getPeriodicDelay: &delay interval: &interval];
upRect.size.width = 15; [NSEvent startPeriodicEventsAfterDelay: delay withPeriod: interval];
upRect.size.height = 11; event_mask |= NSPeriodicMask;
upRect.origin.x = NSMaxX(frame) - 16; }
upRect.origin.y = NSMinY(frame) + ((int) frame.size.height / 2) + 1;
return upRect;
}
- (NSRect) downButtonRectWithFrame: (NSRect) frame while (!done)
{ {
NSRect downRect; NSEventType eventType;
downRect.size.width = 15;
downRect.size.height = 11; theEvent = [NSApp nextEventMatchingMask: event_mask
downRect.origin.x = NSMaxX(frame) - 16; untilDate: nil
downRect.origin.y = NSMinY(frame) + inMode: NSEventTrackingRunLoopMode
((int) frame.size.height / 2) - 10; dequeue: YES];
return downRect; eventType = [theEvent type];
// Did the mouse go up?
if (eventType == NSLeftMouseUp)
{
mouseWentUp = YES;
done = YES;
}
if (eventType == NSPeriodic)
{
periodCount++;
if (periodCount == 4)
periodCount = 0;
if (periodCount == 0)
{
if (isDirectionUp)
[self _increment];
else
[self _decrement];
[(NSControl*)controlView sendAction: [self action] to: [self target]];
}
location = [[controlView window] mouseLocationOutsideOfEventStream];
}
else
{
location = [theEvent locationInWindow];
}
point = [controlView convertPoint: location fromView: nil];
if (![controlView mouse: point inRect: cellFrame])
{
if (flag == NO)
{
done = YES;
}
}
if (NSMouseInRect(point, rect, NO) != overButton)
{
overButton = !overButton;
if (overButton && autorepeat)
{
[NSEvent startPeriodicEventsAfterDelay: delay withPeriod: interval];
periodCount = 0;
}
else
{
[NSEvent stopPeriodicEvents];
}
[self setHighlighted: overButton
upButton: isDirectionUp
withFrame: cellFrame
inView: controlView];
}
}
if (overButton && autorepeat)
{
[NSEvent stopPeriodicEvents];
}
if (overButton)
{
if (isDirectionUp)
[self _increment];
else
[self _decrement];
[(NSControl*)controlView sendAction: [self action] to: [self target]];
}
[self setHighlighted: NO
upButton: isDirectionUp
withFrame: cellFrame
inView: controlView];
return mouseWentUp;
} }
// //
@ -310,42 +447,55 @@ static inline void HighlightDownButton(NSRect aRect)
// //
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
int tmp1, tmp2;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
tmp1 = (int)_autorepeat; if([aCoder allowsKeyedCoding])
tmp2 = (int)_valueWraps; {
[aCoder encodeDouble: [self increment] forKey: @"NSIncrement"];
[aCoder encodeDouble: [self maxValue] forKey: @"NSMaxValue"];
[aCoder encodeDouble: [self minValue] forKey: @"NSMinValue"];
[aCoder encodeBool: [self autorepeat] forKey: @"NSAutorepeat"];
[aCoder encodeBool: [self valueWraps] forKey: @"NSValueWraps"];
}
else
{
int tmp1, tmp2;
[aCoder encodeValueOfObjCType: @encode(double) tmp1 = (int)_autorepeat;
at: &_maxValue]; tmp2 = (int)_valueWraps;
[aCoder encodeValueOfObjCType: @encode(double)
at: &_minValue]; [aCoder encodeValueOfObjCType: @encode(double)
[aCoder encodeValueOfObjCType: @encode(double) at: &_maxValue];
at: &_increment]; [aCoder encodeValueOfObjCType: @encode(double)
[aCoder encodeValueOfObjCType: @encode(int) at: &_minValue];
at: &tmp1]; [aCoder encodeValueOfObjCType: @encode(double)
[aCoder encodeValueOfObjCType: @encode(int) at: &_increment];
at: &tmp2]; [aCoder encodeValueOfObjCType: @encode(int)
at: &tmp1];
[aCoder encodeValueOfObjCType: @encode(int)
at: &tmp2];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
int tmp1, tmp2;
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
if([aDecoder allowsKeyedCoding]) if([aDecoder allowsKeyedCoding])
{ {
_autorepeat = [aDecoder decodeBoolForKey: @"NSAutorepeat"]; _autorepeat = [aDecoder decodeBoolForKey: @"NSAutorepeat"];
_valueWraps = [aDecoder decodeBoolForKey: @"NSValueWraps"]; _valueWraps = [aDecoder decodeBoolForKey: @"NSValueWraps"];
_increment = [aDecoder decodeIntForKey: @"NSIncrement"]; _increment = [aDecoder decodeDoubleForKey: @"NSIncrement"];
_maxValue = [aDecoder decodeIntForKey: @"NSMaxValue"]; _maxValue = [aDecoder decodeDoubleForKey: @"NSMaxValue"];
if([aDecoder containsValueForKey: @"NSMinValue"]) if([aDecoder containsValueForKey: @"NSMinValue"])
{ {
_minValue = [aDecoder decodeIntForKey: @"NSMinValue"]; _minValue = [aDecoder decodeDoubleForKey: @"NSMinValue"];
} }
} }
else else
{ {
int tmp1, tmp2;
[aDecoder decodeValueOfObjCType: @encode(double) [aDecoder decodeValueOfObjCType: @encode(double)
at: &_maxValue]; at: &_maxValue];
[aDecoder decodeValueOfObjCType: @encode(double) [aDecoder decodeValueOfObjCType: @encode(double)
@ -365,3 +515,96 @@ static inline void HighlightDownButton(NSRect aRect)
} }
@end @end
@implementation NSStepperCell (Private)
- (void) _increment
{
double newValue;
double maxValue = [self maxValue];
double minValue = [self minValue];
double increment = [self increment];
newValue = [self doubleValue] + increment;
if ([self valueWraps])
{
if (newValue > maxValue)
newValue = newValue - maxValue + minValue - 1;
else if (newValue < minValue)
newValue = newValue + maxValue - minValue + 1;
}
else
{
if (newValue > maxValue)
newValue = maxValue;
else if (newValue < minValue)
newValue = minValue;
}
[self setDoubleValue: newValue];
}
- (void) _decrement
{
double newValue;
double maxValue = [self maxValue];
double minValue = [self minValue];
double increment = [self increment];
newValue = [self doubleValue] - increment;
if ([self valueWraps])
{
if (newValue > maxValue)
newValue = newValue - maxValue + minValue - 1;
else if (newValue < minValue)
newValue = newValue + maxValue - minValue + 1;
}
else
{
if (newValue > maxValue)
newValue = maxValue;
else if (newValue < minValue)
newValue = minValue;
}
[self setDoubleValue: newValue];
}
- (void) setHighlighted: (BOOL)highlight
upButton: (BOOL)upButton
withFrame: (NSRect)frame
inView: (NSView*)controlView
{
if (upButton)
{
highlightUp = highlight;
}
else
{
highlightDown = highlight;
}
[controlView setNeedsDisplayInRect: frame];
}
- (NSRect) upButtonRectWithFrame: (NSRect)frame
{
NSRect upRect;
upRect.size.width = STEPPER_WIDTH;
upRect.size.height = STEPPER_HEIGHT;
upRect.origin.x = NSMaxX(frame) - STEPPER_WIDTH - 1;
upRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) + 1;
return upRect;
}
- (NSRect) downButtonRectWithFrame: (NSRect)frame
{
NSRect downRect;
downRect.size.width = STEPPER_WIDTH;
downRect.size.height = STEPPER_HEIGHT;
downRect.origin.x = NSMaxX(frame) - STEPPER_WIDTH - 1;
downRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) - STEPPER_HEIGHT + 1;
return downRect;
}
@end

View file

@ -700,13 +700,15 @@
// Event handling. // Event handling.
/*
* Find the tab view item containing the NSPoint point. This point
* is expected to be alreay in the coordinate system of the tab view.
*/
- (NSTabViewItem*) tabViewItemAtPoint: (NSPoint)point - (NSTabViewItem*) tabViewItemAtPoint: (NSPoint)point
{ {
int howMany = [_items count]; int howMany = [_items count];
int i; int i;
point = [self convertPoint: point fromView: nil];
for (i = 0; i < howMany; i++) for (i = 0; i < howMany; i++)
{ {
NSTabViewItem *anItem = [_items objectAtIndex: i]; NSTabViewItem *anItem = [_items objectAtIndex: i];
@ -720,7 +722,8 @@
- (void) mouseDown: (NSEvent *)theEvent - (void) mouseDown: (NSEvent *)theEvent
{ {
NSPoint location = [theEvent locationInWindow]; NSPoint location = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
NSTabViewItem *anItem = [self tabViewItemAtPoint: location]; NSTabViewItem *anItem = [self tabViewItemAtPoint: location];
if (anItem != nil && ![anItem isEqual: _selected]) if (anItem != nil && ![anItem isEqual: _selected])
@ -763,14 +766,42 @@
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if ([aCoder allowsKeyedCoding])
[aCoder encodeObject: _items]; {
[aCoder encodeObject: _font]; unsigned int type = 0;
[aCoder encodeValueOfObjCType: @encode(NSTabViewType) at: &_type]; switch(_type)
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_draws_background]; {
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_truncated_label]; case NSTopTabsBezelBorder:
[aCoder encodeConditionalObject: _delegate]; type = 0;
[aCoder encodeValueOfObjCType: "i" at: &_selected_item]; break;
case NSLeftTabsBezelBorder:
type = 1;
break;
case NSBottomTabsBezelBorder:
type = 2;
break;
case NSRightTabsBezelBorder:
type = 3;
break;
}
[aCoder encodeBool: [self allowsTruncatedLabels] forKey: @"NSAllowTruncatedLabels"];
[aCoder encodeBool: [self drawsBackground] forKey: @"NSDrawsBackground"];
[aCoder encodeObject: [self font] forKey: @"NSFont"];
[aCoder encodeObject: _items forKey: @"NSTabViewItems"];
[aCoder encodeObject: [self selectedTabViewItem] forKey: @"NSSelectedTabViewItem"];
[aCoder encodeInt: type forKey: @"NSTvFlags"]; // no flags set...
}
else
{
[aCoder encodeObject: _items];
[aCoder encodeObject: _font];
[aCoder encodeValueOfObjCType: @encode(NSTabViewType) at: &_type];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_draws_background];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_truncated_label];
[aCoder encodeConditionalObject: _delegate];
[aCoder encodeValueOfObjCType: "i" at: &_selected_item];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -795,14 +826,7 @@
} }
if ([aDecoder containsValueForKey: @"NSTabViewItems"]) if ([aDecoder containsValueForKey: @"NSTabViewItems"])
{ {
NSArray *items = [aDecoder decodeObjectForKey: @"NSTabViewItems"]; ASSIGN(_items, [aDecoder decodeObjectForKey: @"NSTabViewItems"]);
NSEnumerator *enumerator = [items objectEnumerator];
NSTabViewItem *item;
while ((item = [enumerator nextObject]) != nil)
{
[self addTabViewItem: item];
}
} }
if ([aDecoder containsValueForKey: @"NSSelectedTabViewItem"]) if ([aDecoder containsValueForKey: @"NSSelectedTabViewItem"])
{ {
@ -811,7 +835,25 @@
} }
if ([aDecoder containsValueForKey: @"NSTvFlags"]) if ([aDecoder containsValueForKey: @"NSTvFlags"])
{ {
//int flags = [aDecoder decodeObjectForKey: @"NSTvFlags"]]; unsigned int type = [aDecoder decodeIntForKey: @"NSTvFlags"];
switch(type)
{
case 0:
_type = NSTopTabsBezelBorder;
break;
case 1:
_type = NSLeftTabsBezelBorder;
break;
case 2:
_type = NSBottomTabsBezelBorder;
break;
case 3:
_type = NSRightTabsBezelBorder;
break;
default:
_type = NSTopTabsBezelBorder;
break;
}
} }
} }
else else

View file

@ -208,13 +208,24 @@
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[aCoder encodeObject:_ident]; if ([aCoder allowsKeyedCoding])
[aCoder encodeObject:_label]; {
[aCoder encodeObject:_view]; [aCoder encodeObject: _ident forKey: @"NSIdentifier"];
[aCoder encodeObject:_color]; [aCoder encodeObject: _label forKey: @"NSLabel"];
[aCoder encodeValueOfObjCType: @encode(NSTabState) at: &_state]; [aCoder encodeObject: _view forKey: @"NSView"];
[aCoder encodeObject:_first_responder]; [aCoder encodeObject: _color forKey: @"NSColor"];
[aCoder encodeObject:_tabview]; [aCoder encodeObject: _tabview forKey: @"NSTabView"];
}
else
{
[aCoder encodeObject:_ident];
[aCoder encodeObject:_label];
[aCoder encodeObject:_view];
[aCoder encodeObject:_color];
[aCoder encodeValueOfObjCType: @encode(NSTabState) at: &_state];
[aCoder encodeObject:_first_responder];
[aCoder encodeObject:_tabview];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder

View file

@ -370,16 +370,30 @@
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[aCoder encodeObject: _identifier]; if([aCoder allowsKeyedCoding])
{
[aCoder encodeValueOfObjCType: @encode(float) at: &_width]; [aCoder encodeObject: _identifier forKey: @"NSIdentifier"];
[aCoder encodeValueOfObjCType: @encode(float) at: &_min_width]; [aCoder encodeObject: _dataCell forKey: @"NSDataCell"];
[aCoder encodeValueOfObjCType: @encode(float) at: &_max_width]; [aCoder encodeObject: _headerCell forKey: @"NSHeaderCell"];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_resizable]; [aCoder encodeBool: _is_resizable forKey: @"NSIsResizable"];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_editable]; [aCoder encodeBool: _is_editable forKey: @"NSIsEditable"];
[aCoder encodeFloat: _max_width forKey: @"NSMaxWidth"];
[aCoder encodeObject: _headerCell]; [aCoder encodeFloat: _min_width forKey: @"NSMinWidth"];
[aCoder encodeObject: _dataCell]; [aCoder encodeFloat: _width forKey: @"NSWidth"];
}
else
{
[aCoder encodeObject: _identifier];
[aCoder encodeValueOfObjCType: @encode(float) at: &_width];
[aCoder encodeValueOfObjCType: @encode(float) at: &_min_width];
[aCoder encodeValueOfObjCType: @encode(float) at: &_max_width];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_resizable];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_editable];
[aCoder encodeObject: _headerCell];
[aCoder encodeObject: _dataCell];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder

View file

@ -4002,26 +4002,11 @@ static inline float computePeriod(NSPoint mouseLocationWin,
lastColumn = [_tableColumns objectAtIndex: (_numberOfColumns - 1)]; lastColumn = [_tableColumns objectAtIndex: (_numberOfColumns - 1)];
if ([lastColumn isResizable] == NO) if ([lastColumn isResizable] == NO)
return; return;
excess_width = NSMaxX ([self convertRect: [_super_view bounds] excess_width = NSMaxX([self convertRect: [_super_view bounds]
fromView: _super_view]); fromView: _super_view]) - NSMaxX(_bounds);
excess_width -= NSMaxX (_bounds); last_column_width = [lastColumn width] + excess_width;
last_column_width = [lastColumn width]; // This will automatically retile the table
last_column_width += excess_width; [lastColumn setWidth: last_column_width];
_tilingDisabled = YES;
if (last_column_width < [lastColumn minWidth])
{
[lastColumn setWidth: [lastColumn minWidth]];
}
else if (last_column_width > [lastColumn maxWidth])
{
[lastColumn setWidth: [lastColumn maxWidth]];
}
else
{
[lastColumn setWidth: last_column_width];
}
_tilingDisabled = NO;
[self tile];
} }
} }
@ -5136,48 +5121,63 @@ static inline float computePeriod(NSPoint mouseLocationWin,
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder];
if ([aCoder allowsKeyedCoding]) if ([aCoder allowsKeyedCoding])
{ {
unsigned int vFlags = 0; // (raw >> 26); // filter out settings not pertinent to us. unsigned long vFlags = 0;
NSSize intercellSpacing = [self intercellSpacing]; NSSize intercellSpacing = [self intercellSpacing];
GSTableViewFlags tableViewFlags;
// make sure the corner view is properly encoded...
[super encodeWithCoder: aCoder];
if([self dataSource])
{
[aCoder encodeObject: [self dataSource] forKey: @"NSDataSource"];
}
if([self delegate])
{
[aCoder encodeObject: [self delegate] forKey: @"NSDelegate"];
}
if([self target])
{
[aCoder encodeObject: [self target] forKey: @"NSTarget"];
}
if([self action])
{
[aCoder encodeObject: NSStringFromSelector([self action]) forKey: @"NSAction"];
}
[aCoder encodeObject: [self dataSource] forKey: @"NSDataSource"];
[aCoder encodeObject: [self delegate] forKey: @"NSDelegate"];
[aCoder encodeObject: [self target] forKey: @"NSTarget"];
[aCoder encodeObject: NSStringFromSelector([self action]) forKey: @"NSAction"];
[aCoder encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"]; [aCoder encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"];
[aCoder encodeObject: [self gridColor] forKey: @"NSGridColor"]; [aCoder encodeObject: [self gridColor] forKey: @"NSGridColor"];
[aCoder encodeFloat: intercellSpacing.height forKey: @"NSIntercellSpacingHeight"]; [aCoder encodeFloat: intercellSpacing.height forKey: @"NSIntercellSpacingHeight"];
[aCoder encodeFloat: intercellSpacing.width forKey: @"NSIntercellSpacingWidth"]; [aCoder encodeFloat: intercellSpacing.width forKey: @"NSIntercellSpacingWidth"];
[aCoder encodeFloat: [self rowHeight] forKey: @"NSRowHeight"]; [aCoder encodeFloat: [self rowHeight] forKey: @"NSRowHeight"];
[aCoder encodeObject: [self tableColumns] forKey: @"NSTableColumns"]; [aCoder encodeObject: [self tableColumns] forKey: @"NSTableColumns"];
if(_headerView)
{
[aCoder encodeObject: _headerView forKey: @"NSHeaderView"];
}
if(_cornerView)
{
[aCoder encodeObject: _cornerView forKey: @"NSCornerView"];
}
tableViewFlags.columnSelection = [self allowsColumnSelection];
tableViewFlags.multipleSelection = [self allowsMultipleSelection];
tableViewFlags.emptySelection = [self allowsEmptySelection];
tableViewFlags.drawsGrid = [self drawsGrid];
tableViewFlags.columnResizing = [self allowsColumnResizing];
tableViewFlags.columnOrdering = [self allowsColumnReordering];
if([self allowsColumnSelection]) memcpy((void *)&vFlags,(void *)&tableViewFlags,sizeof(unsigned long));
vFlags |= 1;
if([self allowsMultipleSelection])
vFlags |= 2;
if([self allowsEmptySelection])
vFlags |= 4;
if([self allowsColumnResizing])
vFlags |= 16;
if([self allowsColumnReordering])
vFlags |= 32;
// shift...
vFlags = vFlags << 26;
vFlags |= 0x2400000; // add the constant...
// encode.. // encode..
[aCoder encodeInt: vFlags forKey: @"NSTvFlags"]; [aCoder encodeInt: vFlags forKey: @"NSTvFlags"];
} }
else else
{ {
[super encodeWithCoder: aCoder];
[aCoder encodeConditionalObject: _dataSource]; [aCoder encodeConditionalObject: _dataSource];
[aCoder encodeObject: _tableColumns]; [aCoder encodeObject: _tableColumns];
[aCoder encodeObject: _gridColor]; [aCoder encodeObject: _gridColor];
@ -5215,6 +5215,32 @@ static inline float computePeriod(NSPoint mouseLocationWin,
NSEnumerator *e; NSEnumerator *e;
NSTableColumn *col; NSTableColumn *col;
// assign defaults, so that there's color in case none is specified
ASSIGN (_gridColor, [NSColor gridColor]);
ASSIGN (_backgroundColor, [NSColor controlBackgroundColor]);
ASSIGN (_tableColumns, [NSMutableArray array]);
ASSIGN (_selectedColumns, [NSMutableIndexSet indexSet]);
ASSIGN (_selectedRows, [NSMutableIndexSet indexSet]);
_autoresizesAllColumnsToFit = NO;
_clickedRow = -1;
_clickedColumn = -1;
_drawsGrid = YES;
_editedColumn = -1;
_editedRow = -1;
_highlightedTableColumn = nil;
_intercellSpacing = NSMakeSize (5.0, 2.0);
_rowHeight = 16.0;
_selectedColumn = -1;
_selectedRow = -1;
_selectingColumns = NO;
/*
_headerView = [NSTableHeaderView new];
[_headerView setFrameSize: NSMakeSize (_frame.size.width, 22.0)];
[_headerView setTableView: self];
*/
[(NSKeyedUnarchiver *)aDecoder setClass: [GSTableCornerView class] forClassName: @"_NSCornerView"]; [(NSKeyedUnarchiver *)aDecoder setClass: [GSTableCornerView class] forClassName: @"_NSCornerView"];
if ([aDecoder containsValueForKey: @"NSDataSource"]) if ([aDecoder containsValueForKey: @"NSDataSource"])
{ {
@ -5254,16 +5280,7 @@ static inline float computePeriod(NSPoint mouseLocationWin,
{ {
[self setRowHeight: [aDecoder decodeFloatForKey: @"NSRowHeight"]]; [self setRowHeight: [aDecoder decodeFloatForKey: @"NSRowHeight"]];
} }
if ([aDecoder containsValueForKey: @"NSHeaderView"])
{
NSRect viewFrame = [self frame];
float rowHeight = [self rowHeight];
_headerView = [NSTableHeaderView new];
[_headerView setFrameSize: NSMakeSize(viewFrame.size.width, rowHeight)];
[_headerView setTableView: self];
}
if ([aDecoder containsValueForKey: @"NSCornerView"]) if ([aDecoder containsValueForKey: @"NSCornerView"])
{ {
NSRect viewFrame; NSRect viewFrame;
@ -5275,6 +5292,16 @@ static inline float computePeriod(NSPoint mouseLocationWin,
[[self cornerView] setFrame: viewFrame]; [[self cornerView] setFrame: viewFrame];
} }
if ([aDecoder containsValueForKey: @"NSHeaderView"])
{
NSRect viewFrame = [self frame];
float rowHeight = [self rowHeight];
_headerView = [[NSTableHeaderView alloc] init];
[_headerView setFrameSize: NSMakeSize(viewFrame.size.width, rowHeight)];
[_headerView setTableView: self];
}
// get the table columns... // get the table columns...
columns = [aDecoder decodeObjectForKey: @"NSTableColumns"]; columns = [aDecoder decodeObjectForKey: @"NSTableColumns"];
e = [columns objectEnumerator]; e = [columns objectEnumerator];
@ -5305,14 +5332,6 @@ static inline float computePeriod(NSPoint mouseLocationWin,
_columnOrigins = NSZoneMalloc (NSDefaultMallocZone (), _columnOrigins = NSZoneMalloc (NSDefaultMallocZone (),
sizeof(float) * _numberOfColumns); sizeof(float) * _numberOfColumns);
_clickedRow = -1;
_clickedColumn = -1;
_selectingColumns = NO;
_selectedColumn = -1;
_selectedRow = -1;
_editedColumn = -1;
_editedRow = -1;
[self tile]; [self tile];
} }
else else
@ -5334,6 +5353,7 @@ static inline float computePeriod(NSPoint mouseLocationWin,
[_headerView setTableView: self]; [_headerView setTableView: self];
[_tableColumns makeObjectsPerformSelector: @selector(setTableView:) [_tableColumns makeObjectsPerformSelector: @selector(setTableView:)
withObject: self]; withObject: self];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows]; [aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns]; [aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_drawsGrid]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_drawsGrid];

View file

@ -323,17 +323,31 @@
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[aCoder encodeObject: _fileWrapper]; if([aCoder allowsKeyedCoding])
[aCoder encodeObject: _cell]; {
// TODO_NIB: Determine keys for NSTextAttachment.
}
else
{
[aCoder encodeObject: _fileWrapper];
[aCoder encodeObject: _cell];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[aDecoder decodeValueOfObjCType: @encode(id) at: &_fileWrapper]; if([aDecoder allowsKeyedCoding])
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell]; {
// TODO_NIB: Determine keys for NSTextAttachment.
// Reconnect the cell, so the cell does not have to store the attachment }
[_cell setAttachment: self]; else
{
[aDecoder decodeValueOfObjCType: @encode(id) at: &_fileWrapper];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell];
// Reconnect the cell, so the cell does not have to store the attachment
[_cell setAttachment: self];
}
return self; return self;
} }

View file

@ -462,5 +462,22 @@ framework intact.
} }
} }
- (void) encodeWithCoder: (NSCoder *)coder
{
if([coder allowsKeyedCoding])
{
NSSize size = _containerRect.size;
int flags = ((_widthTracksTextView)?1:0) |
((_heightTracksTextView)?2:0) |
((_observingFrameChanges)?4:0);
[coder encodeObject: _textView forKey: @"NSTextView"];
[coder encodeFloat: size.width forKey: @"NSWidth"];
[coder encodeInt: flags forKey: @"NSTCFlags"];
// TODO: Add layout manager encoding, if needed...
}
}
@end /* NSTextContainer */ @end /* NSTextContainer */

View file

@ -208,10 +208,19 @@ static NSColor *txtCol;
BOOL tmp; BOOL tmp;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeValueOfObjCType: @encode(id) at: &_background_color]; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(id) at: &_text_color]; {
tmp = _textfieldcell_draws_background; [aCoder encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; [aCoder encodeObject: [self textColor] forKey: @"NSTextColor"];
[aCoder encodeBool: [self drawsBackground] forKey: @"NSDrawsBackground"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(id) at: &_background_color];
[aCoder encodeValueOfObjCType: @encode(id) at: &_text_color];
tmp = _textfieldcell_draws_background;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -220,8 +229,11 @@ static NSColor *txtCol;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
[self setBackgroundColor: [aDecoder decodeObjectForKey: @"NSBackgroundColor"]]; id textColor = RETAIN([aDecoder decodeObjectForKey: @"NSTextColor"]);
[self setTextColor: [aDecoder decodeObjectForKey: @"NSTextColor"]]; id backColor = RETAIN([aDecoder decodeObjectForKey: @"NSBackgroundColor"]);
[self setBackgroundColor: backColor];
[self setTextColor: textColor];
if ([aDecoder containsValueForKey: @"NSDrawsBackground"]) if ([aDecoder containsValueForKey: @"NSDrawsBackground"])
{ {
[self setDrawsBackground: [aDecoder decodeBoolForKey: [self setDrawsBackground: [aDecoder decodeBoolForKey:

View file

@ -353,4 +353,17 @@ static NSNotificationCenter *nc = nil;
return self; return self;
} }
- (void) encodeWithCoder: (NSCoder *)coder
{
if([coder allowsKeyedCoding])
{
[coder encodeObject: [self delegate] forKey: @"NSDelegate"];
[coder encodeObject: [self string] forKey: @"NSString"];
}
else
{
[super encodeWithCoder: coder];
}
}
@end @end

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@
Author: Felipe A. Rodriguez <far@ix.netcom.com> Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: July 1998 Date: July 1998
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de> Author: Daniel Böhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998 Date: August 1998
Author: Fred Kiefer <FredKiefer@gmx.de> Author: Fred Kiefer <FredKiefer@gmx.de>
@ -111,7 +111,6 @@ send -shouldChangeTextInRange:replacementString: or -didChangeText.
*/ */
/** First some helpers **/ /** First some helpers **/
@interface NSTextView (user_action_helpers) @interface NSTextView (user_action_helpers)
@ -120,7 +119,7 @@ send -shouldChangeTextInRange:replacementString: or -didChangeText.
-(void) _changeAttribute: (NSString *)name -(void) _changeAttribute: (NSString *)name
inRange: (NSRange)r inRange: (NSRange)r
using: (id (*)(id))func; using: (NSNumber*(*)(NSNumber*))func;
@end @end
@ -164,7 +163,7 @@ send -shouldChangeTextInRange:replacementString: or -didChangeText.
- (void) _changeAttribute: (NSString *)name - (void) _changeAttribute: (NSString *)name
inRange: (NSRange)r inRange: (NSRange)r
using: (id (*)(id))func using: (NSNumber*(*)(NSNumber*))func
{ {
unsigned int i; unsigned int i;
NSRange e, r2; NSRange e, r2;
@ -624,6 +623,62 @@ static NSNumber *float_plus_one(NSNumber *cur)
[self didChangeText]; [self didChangeText];
} }
- (void) deleteToEndOfLine: (id)sender
{
NSRange range = [self rangeForUserTextChange];
NSRange linerange;
unsigned maxRange;
unsigned endCorrection = 0;
if (range.location == NSNotFound)
{
return;
}
linerange = [[_textStorage string] lineRangeForRange:
NSMakeRange(range.location, 0)];
maxRange = NSMaxRange (linerange);
if (maxRange == range.location)
{
return;
}
// Only delete the linebreak, if the line is empty.
if (linerange.length > 1)
{
// Treat the last line special, as it does not have to end in a leine break.
if (maxRange == [_textStorage length])
{
unichar u = [[_textStorage string] characterAtIndex: (maxRange - 1)];
if (u == '\n' || u == '\r')
{
endCorrection = 1;
}
else
{
endCorrection = 0;
}
}
else
{
endCorrection = 1;
}
}
range = NSMakeRange(range.location, maxRange - range.location - endCorrection);
if (![self shouldChangeTextInRange: range replacementString: @""])
{
return;
}
[_textStorage beginEditing];
[_textStorage deleteCharactersInRange: range];
[_textStorage endEditing];
[self didChangeText];
}
/* /*
TODO: find out what affinity is supposed to mean TODO: find out what affinity is supposed to mean

View file

@ -536,7 +536,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
NSAttributedString *attrString; NSAttributedString *attrString;
NSDictionary *attr; NSDictionary *attr;
NSColor *color; NSColor *color;
NSMutableParagraphStyle *pStyle = [NSMutableParagraphStyle defaultParagraphStyle]; NSMutableParagraphStyle *pStyle;
NSRect titleRect; NSRect titleRect;
NSRect viewBounds = [self bounds]; NSRect viewBounds = [self bounds];
@ -549,12 +549,15 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
color = [NSColor disabledControlTextColor]; color = [NSColor disabledControlTextColor];
} }
pStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[pStyle setAlignment: NSCenterTextAlignment]; [pStyle setAlignment: NSCenterTextAlignment];
// We draw the label // We draw the label
attr = [NSDictionary dictionaryWithObjectsAndKeys: _font, attr = [NSDictionary dictionaryWithObjectsAndKeys: _font,
NSFontAttributeName, color, NSForegroundColorAttributeName, pStyle, NSFontAttributeName, color, NSForegroundColorAttributeName, pStyle,
NSParagraphStyleAttributeName, nil]; NSParagraphStyleAttributeName, nil];
RELEASE(pStyle);
attrString = [[NSAttributedString alloc] attrString = [[NSAttributedString alloc]
initWithString: [_toolbarItem label] attributes: attr]; initWithString: [_toolbarItem label] attributes: attr];

View file

@ -1996,7 +1996,7 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
- (void) displayIfNeededInRect: (NSRect)aRect - (void) displayIfNeededInRect: (NSRect)aRect
{ {
if (_rFlags.needs_display == NO) if (_rFlags.needs_display == YES)
{ {
if ([self isOpaque] == YES) if ([self isOpaque] == YES)
{ {
@ -2625,7 +2625,25 @@ Returns YES iff any scrolling was done.
{ {
if (_rFlags.valid_rects != 0) if (_rFlags.valid_rects != 0)
{ {
[_cursor_rects makeObjectsPerformSelector: @selector(invalidate)]; unsigned count = [_cursor_rects count];
if (count > 0)
{
GSTrackingRect *rects[count];
NSPoint loc = ((struct NSWindow_struct *)_window)->_lastPoint;
unsigned i;
[_cursor_rects getObjects: rects];
for (i = 0; i < count; ++i)
{
GSTrackingRect *r = rects[i];
if (NSMouseInRect(loc, r->rectangle, NO))
{
[r->owner mouseExited: nil];
}
[r invalidate];
}
}
_rFlags.valid_rects = 0; _rFlags.valid_rects = 0;
} }
[_cursor_rects removeAllObjects]; [_cursor_rects removeAllObjects];
@ -2638,6 +2656,7 @@ Returns YES iff any scrolling was done.
id e = [_cursor_rects objectEnumerator]; id e = [_cursor_rects objectEnumerator];
GSTrackingRect *o; GSTrackingRect *o;
NSCursor *c; NSCursor *c;
NSPoint loc = [_window mouseLocationOutsideOfEventStream];
/* Base remove test upon cursor object */ /* Base remove test upon cursor object */
o = [e nextObject]; o = [e nextObject];
@ -2646,6 +2665,10 @@ Returns YES iff any scrolling was done.
c = [o owner]; c = [o owner];
if (c == anObject) if (c == anObject)
{ {
if (NSMouseInRect(loc, o->rectangle, NO))
{
[c mouseExited: nil];
}
[o invalidate]; [o invalidate];
[_cursor_rects removeObject: o]; [_cursor_rects removeObject: o];
if ([_cursor_rects count] == 0) if ([_cursor_rects count] == 0)
@ -3916,7 +3939,14 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[aCoder encodeInt: vFlags [aCoder encodeInt: vFlags
forKey: @"NSvFlags"]; forKey: @"NSvFlags"];
[aCoder encodeObject: _super_view forKey: @"NSSuperview"]; //
// Don't attempt to archive the superview of a view which is the
// content view for a window.
//
if(([[self window] contentView] != self) && _super_view != nil)
{
[aCoder encodeObject: _super_view forKey: @"NSSuperview"];
}
} }
else else
{ {
@ -3957,15 +3987,38 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
{ {
NSView *prevKeyView = nil; NSView *prevKeyView = nil;
NSView *nextKeyView = nil; NSView *nextKeyView = nil;
if ([aDecoder containsValueForKey: @"NSFrame"]) if ([aDecoder containsValueForKey: @"NSFrame"])
{ {
_frame = [aDecoder decodeRectForKey: @"NSFrame"]; _frame = [aDecoder decodeRectForKey: @"NSFrame"];
[_frameMatrix setFrameOrigin: _frame.origin];
} }
self = [self initWithFrame: _frame]; else
{
_frame = NSZeroRect;
}
subs = [aDecoder decodeObjectForKey: @"NSSubviews"]; _bounds.origin = NSZeroPoint; // Set bounds rectangle
_bounds.size = _frame.size;
[_frameMatrix setFrameOrigin: _frame.origin];
_sub_views = [NSMutableArray new];
_tracking_rects = [NSMutableArray new];
_cursor_rects = [NSMutableArray new];
_is_rotated_from_base = NO;
_is_rotated_or_scaled_from_base = NO;
_rFlags.needs_display = YES;
_post_frame_changes = NO;
_autoresizes_subviews = YES;
_autoresizingMask = NSViewNotSizable;
_coordinates_valid = NO;
_nextKeyView = 0;
_previousKeyView = 0;
_rFlags.flipped_view = [self isFlipped];
// previous and next key views...
prevKeyView = [aDecoder decodeObjectForKey: @"NSPreviousKeyView"]; prevKeyView = [aDecoder decodeObjectForKey: @"NSPreviousKeyView"];
nextKeyView = [aDecoder decodeObjectForKey: @"NSNextKeyView"]; nextKeyView = [aDecoder decodeObjectForKey: @"NSNextKeyView"];
if (nextKeyView != nil) if (nextKeyView != nil)
@ -3986,6 +4039,30 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[self setAutoresizesSubviews: ((vFlags & 0x100) == 0x100)]; [self setAutoresizesSubviews: ((vFlags & 0x100) == 0x100)];
[self setHidden: ((vFlags & 0x80000000) == 0x80000000)]; [self setHidden: ((vFlags & 0x80000000) == 0x80000000)];
} }
// iterate over subviews and put them into the view...
subs = [aDecoder decodeObjectForKey: @"NSSubviews"];
e = [subs objectEnumerator];
while ((sub = [e nextObject]) != nil)
{
NSAssert([sub window] == nil,
NSInternalInconsistencyException);
NSAssert([sub superview] == nil,
NSInternalInconsistencyException);
[sub viewWillMoveToWindow: _window];
[sub viewWillMoveToSuperview: self];
[sub setNextResponder: self];
[_sub_views addObject: sub];
_rFlags.has_subviews = 1;
[sub resetCursorRects];
[sub setNeedsDisplay: YES];
[sub _viewDidMoveToWindow];
[sub viewDidMoveToSuperview];
[self didAddSubview: sub];
}
// the superview...
[aDecoder decodeObjectForKey: @"NSSuperview"];
} }
else else
{ {
@ -4025,27 +4102,29 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[aDecoder decodeValueOfObjCType: @encode(id) at: &subs]; [aDecoder decodeValueOfObjCType: @encode(id) at: &subs];
NSDebugLLog(@"NSView", @"NSView: finish decoding\n"); NSDebugLLog(@"NSView", @"NSView: finish decoding\n");
// iterate over subviews and put them into the view...
e = [subs objectEnumerator];
while ((sub = [e nextObject]) != nil)
{
NSAssert([sub window] == nil,
NSInternalInconsistencyException);
NSAssert([sub superview] == nil,
NSInternalInconsistencyException);
[sub viewWillMoveToWindow: _window];
[sub viewWillMoveToSuperview: self];
[sub setNextResponder: self];
[_sub_views addObject: sub];
_rFlags.has_subviews = 1;
[sub resetCursorRects];
[sub setNeedsDisplay: YES];
[sub _viewDidMoveToWindow];
[sub viewDidMoveToSuperview];
[self didAddSubview: sub];
}
RELEASE(subs);
} }
// iterate over subviews and put them into the view...
e = [subs objectEnumerator];
while ((sub = [e nextObject]) != nil)
{
NSAssert([sub window] == nil, NSInternalInconsistencyException);
NSAssert([sub superview] == nil, NSInternalInconsistencyException);
[sub viewWillMoveToWindow: _window];
[sub viewWillMoveToSuperview: self];
[sub setNextResponder: self];
[_sub_views addObject: sub];
_rFlags.has_subviews = 1;
[sub resetCursorRects];
[sub setNeedsDisplay: YES];
[sub _viewDidMoveToWindow];
[sub viewDidMoveToSuperview];
[self didAddSubview: sub];
}
RELEASE(subs);
return self; return self;
} }

View file

@ -1236,9 +1236,11 @@ many times.
ASSIGN(_miniaturizedImage, image); ASSIGN(_miniaturizedImage, image);
if (_counterpart != 0 && (_styleMask & NSMiniWindowMask) == 0) if (_counterpart != 0 && (_styleMask & NSMiniWindowMask) == 0)
{ {
NSMiniWindow *mini = [NSApp windowWithWindowNumber: _counterpart]; NSMiniWindow *mini;
id v = [mini contentView]; id v;
mini = (NSMiniWindow*)[NSApp windowWithWindowNumber: _counterpart];
v = [mini contentView];
if ([v respondsToSelector: @selector(setImage:)]) if ([v respondsToSelector: @selector(setImage:)])
{ {
[v setImage: [self miniwindowImage]]; [v setImage: [self miniwindowImage]];
@ -1251,9 +1253,11 @@ many times.
ASSIGN(_miniaturizedTitle, title); ASSIGN(_miniaturizedTitle, title);
if (_counterpart != 0 && (_styleMask & NSMiniWindowMask) == 0) if (_counterpart != 0 && (_styleMask & NSMiniWindowMask) == 0)
{ {
NSMiniWindow *mini = [NSApp windowWithWindowNumber: _counterpart]; NSMiniWindow *mini;
id v = [mini contentView]; id v;
mini = (NSMiniWindow*)[NSApp windowWithWindowNumber: _counterpart];
v = [mini contentView];
if ([v respondsToSelector: @selector(setTitle:)]) if ([v respondsToSelector: @selector(setTitle:)])
{ {
[v setTitle: [self miniwindowTitle]]; [v setTitle: [self miniwindowTitle]];
@ -2344,10 +2348,25 @@ discardCursorRectsForView(NSView *theView)
{ {
if (((NSViewPtr)aView)->_rFlags.valid_rects) if (((NSViewPtr)aView)->_rFlags.valid_rects)
{ {
[((NSViewPtr)aView)->_cursor_rects [aView discardCursorRects];
makeObjectsPerformSelector: @selector(invalidate)];
((NSViewPtr)aView)->_rFlags.valid_rects = 0; if (_f.cursor_rects_valid)
_f.cursor_rects_valid = NO; {
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;
}
} }
} }
@ -2383,6 +2402,26 @@ resetCursorRectsForView(NSView *theView)
[self discardCursorRects]; [self discardCursorRects];
resetCursorRectsForView(_wv); resetCursorRectsForView(_wv);
_f.cursor_rects_valid = YES; _f.cursor_rects_valid = YES;
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;
}
}
} }
/* /*
@ -4135,6 +4174,19 @@ resetCursorRectsForView(NSView *theView)
{ {
BOOL flag; BOOL flag;
// If were're being initialized from a keyed coder...
if([aCoder allowsKeyedCoding])
{
// 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
format: @"Keyed coding not implemented for %@.",
NSStringFromClass([self class])];
}
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeRect: [[self contentView] frame]]; [aCoder encodeRect: [[self contentView] frame]];
@ -4181,6 +4233,19 @@ resetCursorRectsForView(NSView *theView)
id oldself = self; id oldself = self;
BOOL flag; BOOL flag;
// If were're being initialized from a keyed coder...
if([aDecoder allowsKeyedCoding])
{
// 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
format: @"Keyed coding not implemented for %@.",
NSStringFromClass([self class])];
}
if ((self = [super initWithCoder: aDecoder]) == oldself) if ((self = [super initWithCoder: aDecoder]) == oldself)
{ {
NSSize aSize; NSSize aSize;

View file

@ -191,7 +191,7 @@
if ([self isWindowLoaded]) if ([self isWindowLoaded])
{ {
[[self window] setFrameAutosaveName: name ? name : @""]; [[self window] setFrameAutosaveName: name ? (id)name : (id)@""];
} }
} }

View file

@ -607,6 +607,7 @@ static NSString *_rootPath = @"/";
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Attempt to call dealloc for shared worksapace"]; format: @"Attempt to call dealloc for shared worksapace"];
GSNOSUPERDEALLOC;
} }
- (id) init - (id) init
@ -1938,7 +1939,7 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
} }
else else
{ {
[inf setObject: appName forKey: (role ? role : @"Editor")]; [inf setObject: appName forKey: (role ? (id)role : (id)@"Editor")];
} }
[map setObject: inf forKey: ext]; [map setObject: inf forKey: ext];
RELEASE(inf); RELEASE(inf);