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];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeBool: _haveViews forKey: @"GSHaveViews"];
[aCoder encodeFloat: _defaultMinXMargin forKey: @"GSDefaultMinXMargin"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
[aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin]; [aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin];
} }
}
-(id) initWithCoder: (NSCoder*)aDecoder -(id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
if([aDecoder allowsKeyedCoding])
{
_haveViews = [aDecoder decodeBoolForKey: @"GSHaveViews"];
_defaultMinXMargin = [aDecoder decodeFloatForKey: @"GSDefaultMinXMargin"];
}
else
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin]; [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) retain
{
return self;
}
- (void) release
{
}
- (id) autorelease
{
return self;
}
- (id)init - (id)init
{ {
NSScrollView *scrollView; self = [super initWithContentRect: NSMakeRect(100, 100, 470, 200)
NSRect scrollViewRect = {{0, 0}, {470, 150}}; styleMask: NSTitledWindowMask | NSResizableWindowMask
NSRect winRect = {{100, 100}, {470, 150}};
unsigned int style = NSTitledWindowMask | NSClosableWindowMask
| NSMiniaturizableWindowMask | NSResizableWindowMask;
[self initWithContentRect: winRect
styleMask: style
backing: NSBackingStoreRetained backing: NSBackingStoreRetained
defer: NO]; defer: NO];
if (self) {
NSRect scrollViewRect = {{8, 40}, {454, 152}};
NSRect buttonRect = {{390, 6}, {72, 27}};
NSRect r;
NSScrollView *scrollView;
NSButton *button;
[self setReleasedWhenClosed: NO];
[self setFloatingPanel: YES]; [self setFloatingPanel: YES];
[self setRepresentedFilename: @"Help"]; [self setTitle: NSLocalizedString(@"Help", @"")];
[self setTitle: @"Help"];
[self setDocumentEdited: NO];
scrollView = [[NSScrollView alloc] initWithFrame: scrollViewRect]; scrollView = [[NSScrollView alloc] initWithFrame: scrollViewRect];
[scrollView setBorderType: NSBezelBorder];
[scrollView setHasHorizontalScroller: NO]; [scrollView setHasHorizontalScroller: NO];
[scrollView setHasVerticalScroller: YES]; [scrollView setHasVerticalScroller: YES];
[scrollView setAutoresizingMask: NSViewHeightSizable]; [scrollView setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
textView = [[NSTextView alloc] initWithFrame: r = [[scrollView contentView] frame];
[[scrollView contentView] frame]]; textView = [[NSTextView alloc] initWithFrame: r];
[textView setEditable: NO];
[textView setRichText: YES]; [textView setRichText: YES];
[textView setSelectable: YES]; [textView setEditable: NO];
// off white [textView setSelectable: NO];
[textView setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.85 [textView setHorizontallyResizable: NO];
alpha: 1.0]]; [textView setVerticallyResizable: YES];
[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]; [scrollView setDocumentView: textView];
RELEASE (textView);
[[self contentView] addSubview: scrollView]; [[self contentView] addSubview: scrollView];
RELEASE (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
{
if ([self isVisible])
{ {
[NSApp stopModal]; [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])
@ -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
@ -193,6 +281,13 @@
[_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])];
} }
@ -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
@ -576,7 +700,17 @@
{ {
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,6 +1066,7 @@
- (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;
@ -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,6 +722,42 @@
int i; int i;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeInt: _numberOfRows forKey: @"GSNumberOfRows"];
[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]];
}
}
else
{
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfRows]; [aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfColumns]; [aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
for (i = 0; i < _numberOfRows * _numberOfColumns; i++) for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
@ -747,6 +783,7 @@
[aCoder encodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]]; [aCoder encodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
} }
} }
}
-(id) initWithCoder: (NSCoder*)aDecoder -(id) initWithCoder: (NSCoder*)aDecoder
{ {
@ -755,6 +792,98 @@
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
[super setAutoresizesSubviews: NO]; [super setAutoresizesSubviews: NO];
if([aDecoder allowsKeyedCoding])
{
_numberOfRows = [aDecoder decodeIntForKey: @"GSNumberOfRows"];
_numberOfColumns = [aDecoder decodeIntForKey: @"GSNumberOfColumns"];
// create the jails...
_jails = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (NSView *)
* (_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
// 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++)
{
_expandColumn[i] = [aDecoder decodeBoolForKey:
[NSString stringWithFormat: @"GSExpandColumn%d",i]];
if (_expandColumn[i])
_expandingColumnNumber++;
_columnDimension[i] = [aDecoder decodeFloatForKey:
[NSString stringWithFormat: @"GSColumnDimension%d",i]];
_minColumnDimension[i] = [aDecoder decodeFloatForKey:
[NSString stringWithFormat: @"GSMinColumnDimension%d",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++)
{
_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);
_rowYOrigin[0] = _minYBorder;
for (i = 1; i < _numberOfRows; i++)
_rowYOrigin[i] = _rowYOrigin[i - 1] + _rowDimension[i - 1];
}
else
{
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows]; [aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns]; [aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
@ -834,6 +963,7 @@
_rowYOrigin[0] = _minYBorder; _rowYOrigin[0] = _minYBorder;
for (i = 1; i < _numberOfRows; i++) for (i = 1; i < _numberOfRows; i++)
_rowYOrigin[i] = _rowYOrigin[i - 1] + _rowDimension[i - 1]; _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
@ -176,10 +177,13 @@ unCacheAttributes(NSDictionary *attrs)
} }
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{
if([aCoder allowsKeyedCoding] == NO)
{ {
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &loc]; [aCoder encodeValueOfObjCType: @encode(unsigned) at: &loc];
[aCoder encodeValueOfObjCType: @encode(id) at: &attrs]; [aCoder encodeValueOfObjCType: @encode(id) at: &attrs];
} }
}
- (void) gcFinalize - (void) gcFinalize
{ {
@ -188,12 +192,14 @@ unCacheAttributes(NSDictionary *attrs)
} }
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{
if([aCoder allowsKeyedCoding] == NO)
{ {
NSDictionary *a; NSDictionary *a;
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &loc]; [aCoder decodeValueOfObjCType: @encode(unsigned) at: &loc];
a = [aCoder decodeObject]; a = [aCoder decodeObject];
attrs = cacheAttributes(a); attrs = cacheAttributes(a);
}
return self; return self;
} }

View file

@ -114,6 +114,8 @@
* NSCoding protocol * NSCoding protocol
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{
if([aCoder allowsKeyedCoding] == NO)
{ {
BOOL inside = flags.inside; BOOL inside = flags.inside;
@ -122,8 +124,11 @@
[aCoder encodeObject: owner]; [aCoder encodeObject: owner];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &inside]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &inside];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{
if([aDecoder allowsKeyedCoding] == NO)
{ {
BOOL inside; BOOL inside;
@ -132,6 +137,7 @@
[aDecoder decodeValueOfObjCType: @encode(id) at: &owner]; [aDecoder decodeValueOfObjCType: @encode(id) at: &owner];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &inside]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &inside];
flags.inside = 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];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeBool: _haveViews forKey: @"GSHaveViews"];
[aCoder encodeFloat: _defaultMinYMargin forKey: @"GSDefaultMinYMargin"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
[aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin]; [aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin];
} }
}
-(id) initWithCoder: (NSCoder*)aDecoder -(id) initWithCoder: (NSCoder*)aDecoder
{ {
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
if([aDecoder allowsKeyedCoding])
{
_haveViews = [aDecoder decodeBoolForKey: @"GSHaveViews"];
_defaultMinYMargin = [aDecoder decodeFloatForKey: @"GSDefaultMinYMargin"];
}
else
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin]; [aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin];
}
return self; return self;
} }
@end @end

View file

@ -285,12 +285,22 @@ static Class controlClass;
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeInt: [self tag] forKey: @"NSTag"];
[aCoder encodeObject: [self target] forKey: @"NSTarget"];
[aCoder encodeObject: NSStringFromSelector([self action]) forKey: @"NSAction"];
[aCoder encodeObject: _control_view forKey: @"NSControlView"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(int) at: &_tag]; [aCoder encodeValueOfObjCType: @encode(int) at: &_tag];
[aCoder encodeConditionalObject: _target]; [aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action]; [aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
// This is only encoded for backward compatibility and won't be decoded. // This is only encoded for backward compatibility and won't be decoded.
[aCoder encodeConditionalObject: nil]; [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,24 +3292,53 @@ image.</p><p>See Also: -applicationIconImage</p>
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
/*
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 encodeConditionalObject: _delegate];
[aCoder encodeObject: _main_menu]; [aCoder encodeObject: _main_menu];
[aCoder encodeConditionalObject: _windows_menu]; [aCoder encodeConditionalObject: _windows_menu];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
id obj; id obj;
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
if([aDecoder allowsKeyedCoding])
{
/*
if([aDecoder containsValueForKey: @"NSDelegate"])
{
obj = [aDecoder decodeObjectForKey: @"NSDelegate"];
[self setDelegate: obj];
}
obj = [aDecoder decodeObjectForKey: @"NSMainMenu"];
[self setMainMenu: obj];
obj = [aDecoder decodeObjectForKey: @"NSWindowsMenu"];
[self setWindowsMenu: obj];
*/
}
else
{
obj = [aDecoder decodeObject]; obj = [aDecoder decodeObject];
[self setDelegate: obj]; [self setDelegate: obj];
obj = [aDecoder decodeObject]; obj = [aDecoder decodeObject];
[self setMainMenu: obj]; [self setMainMenu: obj];
obj = [aDecoder decodeObject]; obj = [aDecoder decodeObject];
[self setWindowsMenu: obj]; [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,8 +948,15 @@ static BOOL supports_lzw_compression = NO;
NSData *data = [self TIFFRepresentation]; NSData *data = [self TIFFRepresentation];
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: data forKey: @"NSTIFFRepresentation"];
}
else
{
[aCoder encodeObject: data]; [aCoder encodeObject: data];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {

View file

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

View file

@ -151,6 +151,11 @@ static NSTextFieldCell *titleCell;
} }
- (void) encodeWithCoder: (NSCoder *)aCoder - (void) encodeWithCoder: (NSCoder *)aCoder
{
if([aCoder allowsKeyedCoding])
{
}
else
{ {
int dummy = 0; int dummy = 0;
@ -160,8 +165,15 @@ static NSTextFieldCell *titleCell;
[aCoder encodeValueOfObjCType: @encode(int) at: &dummy]; [aCoder encodeValueOfObjCType: @encode(int) at: &dummy];
[aCoder encodeObject: _columnTitle]; [aCoder encodeObject: _columnTitle];
} }
}
- (id) initWithCoder: (NSCoder *)aDecoder - (id) initWithCoder: (NSCoder *)aDecoder
{
if([aDecoder allowsKeyedCoding])
{
}
else
{ {
int dummy = 0; int dummy = 0;
@ -176,6 +188,7 @@ static NSTextFieldCell *titleCell;
_columnTitle = [aDecoder decodeObject]; _columnTitle = [aDecoder decodeObject];
if (_columnTitle) if (_columnTitle)
RETAIN(_columnTitle); RETAIN(_columnTitle);
}
return self; return self;
} }
@ -2488,7 +2501,39 @@ static NSTextFieldCell *titleCell;
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
long flags = 0;
//
// NOTE: The browserview under GS uses an NSMatrix subview, the one under
// Cocoa does not. This will cause IB to issue an "inconsistency" alert
// 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"];
flags |= [self hasHorizontalScroller] ? 0x10000 : 0;
flags |= ([self allowsEmptySelection] == NO) ? 0x20000 : 0;
flags |= [self sendsActionOnArrowKeys] ? 0x40000 : 0;
flags |= [self acceptsArrowKeys] ? 0x100000 : 0;
flags |= [self separatesColumns] ? 0x4000000 : 0;
flags |= [self takesTitleFromPreviousColumn] ? 0x8000000 : 0;
flags |= [self isTitled] ? 0x10000000 : 0;
flags |= [self reusesColumns] ? 0x20000000 : 0;
flags |= [self allowsBranchSelection] ? 0x40000000 : 0;
flags |= [self allowsMultipleSelection] ? 0x80000000 : 0;
[aCoder encodeInt: flags forKey: @"NSBrFlags"];
[aCoder encodeInt: _maxVisibleColumns forKey: @"NSNumberOfVisibleColumns"];
[aCoder encodeInt: _minColumnWidth forKey: @"NSMinColumnWidth"];
//[aCoder encodeInt: columnResizingType forKey: @"NSColumnResizingType"]];
//[aCoder encodeInt: prefWidth forKey: @"NSPreferedColumnWidth"];
}
else
{
// Here to keep compatibility with old version // Here to keep compatibility with old version
[aCoder encodeObject: nil]; [aCoder encodeObject: nil];
[aCoder encodeObject:_browserCellPrototype]; [aCoder encodeObject:_browserCellPrototype];
@ -2532,21 +2577,80 @@ static NSTextFieldCell *titleCell;
[aCoder encodeValueOfObjCType: @encode(int) at: &colCount]; [aCoder encodeValueOfObjCType: @encode(int) at: &colCount];
[aCoder encodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn]; [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,15 +338,21 @@ static NSFont *_leafFont;
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL tmp;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
// simply encodes prescence...
}
else
{
BOOL tmp;
tmp = _browsercell_is_leaf; tmp = _browsercell_is_leaf;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
tmp = _browsercell_is_loaded; tmp = _browsercell_is_loaded;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
[aCoder encodeObject: _alternateImage]; [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,11 +1446,95 @@ 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;
if([self keyEquivalent] != nil)
{
[aCoder encodeObject: [self keyEquivalent] forKey: @"NSKeyEquivalent"];
}
if([self image] != nil)
{
[aCoder encodeObject: [self image] forKey: @"NSNormalImage"];
}
if([self alternateTitle] != nil)
{
[aCoder encodeObject: [self alternateTitle] forKey: @"NSAlternateContents"];
}
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: _keyEquivalent];
[aCoder encodeObject: _keyEquivalentFont]; [aCoder encodeObject: _keyEquivalentFont];
[aCoder encodeObject: _altContents]; [aCoder encodeObject: _altContents];
@ -1465,6 +1550,7 @@ typedef struct _GSButtonCellFlags
at: &_showAltStateMask]; 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];
if([aCoder allowsKeyedCoding] == NO)
{
[aCoder encodeObject: _window]; [aCoder encodeObject: _window];
[aCoder encodeRect: _rect]; [aCoder encodeRect: _rect];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if([aDecoder allowsKeyedCoding] == NO)
{
[aDecoder decodeValueOfObjCType: @encode(id) at: &_window]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_window];
_rect = [aDecoder decodeRect]; _rect = [aDecoder decodeRect];
}
return self; return self;
} }

View file

@ -688,31 +688,25 @@ 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
calling this method. The integer values could be changed in the this calling this method. The integer values could be changed in the this
@ -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
@ -2184,6 +2178,50 @@ static NSColor *shadowCol;
* NSCoding protocol * NSCoding protocol
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{
if([aCoder allowsKeyedCoding])
{
unsigned long cFlags = 0;
unsigned int cFlags2 = 0;
// encode contents
[aCoder encodeObject: _contents forKey: @"NSContents"];
// flags
cFlags |= [self wraps] ? 0x40 : 0;
cFlags |= [self isScrollable] ? 0x100000 : 0;
cFlags |= [self isSelectable] ? 0x200001 : 0;
cFlags |= [self isBezeled] ? 0x400000 : 0;
cFlags |= [self isBordered] ? 0x800000 : 0;
cFlags |= ([self type] == NSTextCellType) ? 0x4000000 : 0;
cFlags |= [self isContinuous] ? 0x40000 : 0;
cFlags |= [self isEditable] ? 0x10000000 : 0;
cFlags |= ([self isEnabled] == NO) ? 0x20000000 : 0;
cFlags |= ([self state] == NSOnState) ? 0x80000000 : 0;
cFlags |= [self isHighlighted] ? 0x40000000 : 0;
[aCoder encodeInt: cFlags forKey: @"NSCellFlags"];
// flags part 2
cFlags2 |= [self sendsActionOnEndEditing] ? 0x400000 : 0;
cFlags2 |= [self allowsMixedState] ? 0x1000000 : 0;
cFlags2 |= [self refusesFirstResponder] ? 0x2000000 : 0;
cFlags2 |= ([self alignment] == NSRightTextAlignment) ? 0x4000000 : 0;
cFlags2 |= ([self alignment] == NSCenterTextAlignment) ? 0x8000000 : 0;
cFlags2 |= ([self alignment] == NSJustifiedTextAlignment) ? 0xC000000 : 0;
cFlags2 |= ([self alignment] == NSNaturalTextAlignment) ? 0x10000000 : 0;
cFlags2 |= [self importsGraphics] ? 0x20000000 : 0;
cFlags2 |= [self allowsEditingTextAttributes] ? 0x40000000 : 0;
[aCoder encodeInt: cFlags2 forKey: @"NSCellFlags2"];
// font and formatter.
[aCoder encodeObject: [self font] forKey: @"NSSupport"];
if([self formatter])
{
[aCoder encodeObject: [self formatter] forKey: @"NSFormatter"];
}
}
else
{ {
BOOL flag; BOOL flag;
unsigned int tmp_int; unsigned int tmp_int;
@ -2245,14 +2283,27 @@ static NSColor *shadowCol;
[aCoder encodeValueOfObjCType: @encode(id) at: &_menu]; [aCoder encodeValueOfObjCType: @encode(id) at: &_menu];
[aCoder encodeValueOfObjCType: @encode(id) at: &_represented_object]; [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"];
// initialize based on content...
if([contents isKindOfClass: [NSString class]])
{
self = [self initTextCell: contents]; 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"])
{ {

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

@ -696,7 +696,7 @@ 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]])
{ {
@ -1654,6 +1654,13 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
{ {
[super encodeWithCoder: coder]; [super encodeWithCoder: coder];
if([coder allowsKeyedCoding])
{
[coder encodeBool: [self hasVerticalScroller] forKey: @"NSHasVerticalScroller"];
[coder encodeInt: [self numberOfVisibleItems] forKey: @"NSVisibleItemCount"];
}
else
{
[coder encodeValueOfObjCType: @encode(id) at: &_popUpList]; [coder encodeValueOfObjCType: @encode(id) at: &_popUpList];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource]; [coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_hasVerticalScroller]; [coder encodeValueOfObjCType: @encode(BOOL) at: &_hasVerticalScroller];
@ -1667,6 +1674,7 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
if (_usesDataSource == YES) if (_usesDataSource == YES)
[coder encodeConditionalObject: _dataSource]; [coder encodeConditionalObject: _dataSource];
} }
}
/** /**
* Initializes the combo box cell with data linked to <var>decoder</var>. Take * Initializes the combo box cell with data linked to <var>decoder</var>. Take

View file

@ -732,83 +732,64 @@ 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;
else
{
[_cell setHighlighted: NO]; [_cell setHighlighted: NO];
[self setNeedsDisplay: YES]; [self setNeedsDisplay: YES];
}
}
if (done) if (done)
break; break;
}
e = [theApp nextEventMatchingMask: event_mask theEvent = [NSApp nextEventMatchingMask: event_mask
untilDate: nil untilDate: nil
inMode: NSEventTrackingRunLoopMode inMode: NSEventTrackingRunLoopMode
dequeue: YES]; dequeue: YES];
if ([e type] == NSLeftMouseUp) if ([theEvent type] == NSLeftMouseUp)
done = YES; {
mouseUp = YES;
break;
}
} }
[_window _releaseMouse: self]; // Mouse went up inside the control but not inside the cell
if (mouseUp) if (mouseUp)
{ {
[_cell setHighlighted: NO];
[self setNeedsDisplay: YES];
}
[_cell sendActionOn: oldActionMask];
if (mouseUp)
[self sendAction: [self action] to: [self target]]; [self sendAction: [self action] to: [self target]];
} }
}
- (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent - (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent
{ {
@ -843,11 +824,18 @@ static Class actionCellClass;
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: [self cell] forKey: @"NSCell"];
[aCoder encodeBool: [self isEnabled] forKey: @"NSEnabled"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(int) at: &_tag]; [aCoder encodeValueOfObjCType: @encode(int) at: &_tag];
[aCoder encodeObject: _cell]; [aCoder encodeObject: _cell];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_ignoresMultiClick]; [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

@ -270,6 +270,40 @@
{ {
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 encodeObject: lastUpdateTime forKey: @"GSLastUpdateTime"];
[aCoder encodeObject: sourceApplicationName forKey: @"GSSourceApplicationName"];
[aCoder encodeObject: sourceFilename forKey: @"GSSourceFilename"];
[aCoder encodeObject: sourceSelection forKey: @"GSSourceSelection"];
[aCoder encodeObject: sourceManager forKey: @"GSSourceManager"];
[aCoder encodeObject: destinationApplicationName forKey: @"GSDestinationApplicationName"];
[aCoder encodeObject: destinationFilename forKey: @"GSDestinationFilename"];
[aCoder encodeObject: destinationSelection forKey: @"GSDestinationSelection"];
[aCoder encodeObject: destinationManager forKey: @"GSDestinationManager"];
[aCoder encodeObject: types forKey: @"GSTypes"];
// flags...
flag = _flags.appVerifies;
[aCoder encodeBool: flag forKey: @"GSAppVerifies"];
flag = _flags.canUpdateContinuously;
[aCoder encodeBool: flag forKey: @"GSCanUpdateContinuously"];
flag = _flags.isDirty;
[aCoder encodeBool: flag forKey: @"GSIsDirty"];
flag = _flags.willOpenSource;
[aCoder encodeBool: flag forKey: @"GSWillOpenSource"];
flag = _flags.willUpdate;
[aCoder encodeBool: flag forKey: @"GSWillUpdate"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(int) at: &linkNumber]; [aCoder encodeValueOfObjCType: @encode(int) at: &linkNumber];
[aCoder encodeValueOfObjCType: @encode(int) at: &disposition]; [aCoder encodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder encodeValueOfObjCType: @encode(int) at: &updateMode]; [aCoder encodeValueOfObjCType: @encode(int) at: &updateMode];
@ -299,11 +333,53 @@
flag = _flags.willUpdate; flag = _flags.willUpdate;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
} }
}
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
int version = [aCoder versionForClassName: @"NSDataLink"]; if([aCoder allowsKeyedCoding])
{
id obj;
linkNumber = [aCoder decodeIntForKey: @"GSLinkNumber"];
disposition = [aCoder decodeIntForKey: @"GSDisposition"];
updateMode = [aCoder decodeIntForKey: @"GSUpdateMode"];
obj = [aCoder decodeObjectForKey: @"GSSourceManager"];
ASSIGN(sourceManager,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationManager"];
ASSIGN(destinationManager,obj);
obj = [aCoder decodeObjectForKey: @"GSLastUpdateTime"];
ASSIGN(lastUpdateTime, obj);
obj = [aCoder decodeObjectForKey: @"GSSourceApplicationName"];
ASSIGN(sourceApplicationName,obj);
obj = [aCoder decodeObjectForKey: @"GSSourceFilename"];
ASSIGN(sourceFilename,obj);
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.appVerifies = [aCoder decodeBoolForKey: @"GSAppVerifies"];
_flags.canUpdateContinuously = [aCoder decodeBoolForKey: @"GSCanUpdateContinuously"];
_flags.isDirty = [aCoder decodeBoolForKey: @"GSIsDirty"];
_flags.willOpenSource = [aCoder decodeBoolForKey: @"GSWillOpenSource"];
_flags.willUpdate = [aCoder decodeBoolForKey: @"GSWillUpdate"];
}
else
{
int version = [aCoder versionForClassName: @"NSDataLink"];
if (version == 0) if (version == 0)
{ {
BOOL flag = NO; BOOL flag = NO;
@ -312,7 +388,7 @@
[aCoder decodeValueOfObjCType: @encode(int) at: &disposition]; [aCoder decodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder decodeValueOfObjCType: @encode(int) at: &updateMode]; [aCoder decodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager]; [aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager]; [aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &lastUpdateTime]; [aCoder decodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceApplicationName]; [aCoder decodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
@ -340,7 +416,6 @@
_flags.willUpdate = flag; _flags.willUpdate = flag;
} }
else else
{
return nil; return nil;
} }

View file

@ -333,6 +333,23 @@
{ {
BOOL flag = NO; BOOL flag = NO;
if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: filename forKey: @"GSFilename"];
[aCoder encodeObject: sourceLinks forKey: @"GSSourceLinks"];
[aCoder encodeObject: destinationLinks forKey: @"GSDestinationLinks"];
flag = _flags.areLinkOutlinesVisible;
[aCoder encodeBool: flag forKey: @"GSAreLinkOutlinesVisible"];
flag = _flags.delegateVerifiesLinks;
[aCoder encodeBool: flag forKey: @"GSDelegateVerifiesLinks"];
flag = _flags.interactsWithUser;
[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: &filename];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceLinks]; [aCoder encodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationLinks]; [aCoder encodeValueOfObjCType: @encode(id) at: &destinationLinks];
@ -346,11 +363,34 @@
flag = _flags.isEdited; flag = _flags.isEdited;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
} }
}
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
int version = [aCoder versionForClassName: @"NSDataLinkManager"]; if([aCoder allowsKeyedCoding])
{
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);
flag = [aCoder decodeBoolForKey: @"GSAreLinkOutlinesVisible"];
_flags.areLinkOutlinesVisible = flag;
flag = [aCoder decodeBoolForKey: @"GSDelegateVerifiesLinks"];
_flags.delegateVerifiesLinks = flag;
flag = [aCoder decodeBoolForKey: @"GSInteractsWithUser"];
_flags.interactsWithUser = flag;
flag = [aCoder decodeBoolForKey: @"GSIsEdited"];
_flags.isEdited = flag;
}
else
{
int version = [aCoder versionForClassName: @"NSDataLinkManager"];
if (version == 0) if (version == 0)
{ {
BOOL flag = NO; BOOL flag = NO;
@ -369,10 +409,8 @@
_flags.isEdited = flag; _flags.isEdited = flag;
} }
else else
{
return nil; 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 ([displayNames count] > 0)
{
NSArray *extensions = [[NSDocumentController sharedDocumentController]
fileExtensionsFromType: [self fileTypeFromLastRunSavePanel]];
if([extensions count] > 0) if([extensions count] > 0)
{
[savePanel setRequiredFileType:[extensions objectAtIndex: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,14 +731,22 @@
{ {
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];
NSString *extension = [fileName pathExtension];
backupFilename = [fileName stringByDeletingPathExtension]; if([extensions count] > 0)
{
NSString *extension = [extensions objectAtIndex: 0];
NSString *newFileName = [[fileName stringByDeletingPathExtension]
stringByAppendingPathExtension: extension];
if ([fileManager fileExistsAtPath: newFileName])
{
backupFilename = [newFileName stringByDeletingPathExtension];
backupFilename = [backupFilename stringByAppendingString:@"~"]; backupFilename = [backupFilename stringByAppendingString:@"~"];
backupFilename = [backupFilename stringByAppendingPathExtension: extension]; backupFilename = [backupFilename stringByAppendingPathExtension: extension];
@ -686,7 +757,7 @@
[fileManager removeFileAtPath: backupFilename handler: nil]; [fileManager removeFileAtPath: backupFilename handler: nil];
// Move or copy? // Move or copy?
if (![fileManager movePath: fileName toPath: backupFilename handler: nil] && if (![fileManager movePath: newFileName toPath: backupFilename handler: nil] &&
[self keepBackupFile]) [self keepBackupFile])
{ {
int result = NSRunAlertPanel(_(@"File Error"), int result = NSRunAlertPanel(_(@"File Error"),
@ -703,7 +774,7 @@
{ {
if (saveOp != NSSaveToOperation) if (saveOp != NSSaveToOperation)
{ {
[self setFileName: fileName]; [self setFileName: newFileName];
[self setFileType: fileType]; [self setFileType: fileType];
[self updateChangeCount: NSChangeCleared]; [self updateChangeCount: NSChangeCleared];
} }
@ -718,6 +789,7 @@
return YES; return YES;
} }
} }
}
return NO; return NO;
} }

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,12 +618,13 @@ 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
{ {
@ -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; {
/*
if([self stringValue] != nil)
{
[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(BOOL) at: &tmp];
[aCoder encodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth]; [aCoder encodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth];
[aCoder encodeObject: _titleCell]; [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,12 +42,82 @@
@implementation NSBundle (NSHelpManager) @implementation NSBundle (NSHelpManager)
- (NSString *)pathForHelpResource:(NSString *)fileName
{
NSFileManager *fm = [NSFileManager defaultManager];
NSMutableArray *array = [NSMutableArray array];
NSArray *languages = [NSUserDefaults userLanguages];
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 - (NSAttributedString *)contextHelpForKey:(NSString *)key
{ {
NSFileManager *fm = [NSFileManager defaultManager];
NSString *dictPath = [self pathForResource: @"Help" ofType: @"plist"];
NSDictionary *contextHelp = nil;
id helpFile = nil; id helpFile = nil;
NSDictionary *contextHelp =
RETAIN([NSDictionary dictionaryWithContentsOfFile: if (dictPath && [fm fileExistsAtPath: dictPath])
[self pathForResource: @"Help" ofType: @"plist"]]); {
contextHelp = [NSDictionary dictionaryWithContentsOfFile: dictPath];
}
if (contextHelp) if (contextHelp)
{ {
@ -55,17 +126,21 @@
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" if (helpFile)
inDirectory: @"Help"]; {
return AUTORELEASE([[NSAttributedString alloc] initWithPath: (NSString *)helpFile NSString *helpstr = [[NSAttributedString alloc] initWithPath: helpFile
documentAttributes: NULL]); 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)
{ {
file = [mb pathForHelpResource: [help stringByAppendingPathExtension: @"rtfd"]];
if (file == nil)
{
file = [mb pathForHelpResource: [help stringByAppendingPathExtension: @"rtf"]];
}
}
if (file) {
[[NSWorkspace sharedWorkspace] openFile: file]; [[NSWorkspace sharedWorkspace] openFile: file];
return; 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,6 +1479,38 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
{ {
BOOL flag; BOOL flag;
if([coder allowsKeyedCoding])
{
// FIXME: Not sure this is the way it goes...
/*
if(_flags.archiveByName == NO)
{
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
{
flag = _flags.archiveByName; flag = _flags.archiveByName;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
if (flag == YES) if (flag == YES)
@ -1534,7 +1567,7 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
[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,17 +369,26 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
- (void) encodeWithCoder: (NSCoder *)aCoder - (void) encodeWithCoder: (NSCoder *)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeInt: _imageAlignment forKey: @"NSAlign"];
[aCoder encodeInt: _imageScaling forKey: @"NSScale"];
[aCoder encodeInt: _frameStyle forKey: @"NSStyle"];
[aCoder encodeBool: NO forKey: @"NSAnimates"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment]; [aCoder encodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment];
[aCoder encodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle]; [aCoder encodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle];
[aCoder encodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling]; [aCoder encodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
[aCoder encodeSize: _original_image_size]; [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 allowsKeyedCoding])
{ {
if ([aDecoder containsValueForKey: @"NSAlign"]) if ([aDecoder containsValueForKey: @"NSAlign"])
@ -406,6 +415,7 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
[aDecoder decodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling]; [aDecoder decodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
_original_image_size = [aDecoder decodeSize]; _original_image_size = [aDecoder decodeSize];
} }
}
return self; return self;
} }

View file

@ -279,9 +279,16 @@ static Class imageCellClass;
- (void) encodeWithCoder: (NSCoder *)aCoder - (void) encodeWithCoder: (NSCoder *)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeBool: [self isEditable] forKey: @"NSEditable"];
}
else
{
[aCoder encodeConditionalObject: _target]; [aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action]; [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,7 +2677,47 @@ 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 encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"];
[aCoder encodeObject: [self cellBackgroundColor] forKey: @"NSCellBackgroundColor"];
[aCoder encodeObject: [self prototype] forKey: @"NSProtoCell"];
[aCoder encodeObject: NSStringFromClass([self cellClass]) forKey: @"NSCellClass"];
[aCoder encodeSize: _cellSize forKey: @"NSCellSize"];
[aCoder encodeSize: _intercell forKey: @"NSIntercellSpacing"];
/// set the flags...
matrixFlags.isRadio = ([self mode] == NSRadioModeMatrix);
matrixFlags.isList = ([self mode] == NSListModeMatrix);
matrixFlags.isHighlight = ([self mode] == NSHighlightModeMatrix);
matrixFlags.allowsEmptySelection = [self allowsEmptySelection];
matrixFlags.selectionByRect = [self isSelectionByRect];
matrixFlags.drawCellBackground = [self drawsCellBackground];
matrixFlags.drawBackground = [self drawsBackground];
matrixFlags.tabKeyTraversesCells = _tabKeyTraversesCells;
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 (int) at: &_mode];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_allowsEmptySelection]; [aCoder encodeValueOfObjCType: @encode (BOOL) at: &_allowsEmptySelection];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_selectionByRect]; [aCoder encodeValueOfObjCType: @encode (BOOL) at: &_selectionByRect];
@ -2708,14 +2748,15 @@ static SEL getSel;
/* 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

@ -1212,11 +1212,25 @@ static NSNotificationCenter *nc;
* NSCoding Protocol * NSCoding Protocol
*/ */
- (void) encodeWithCoder: (NSCoder*)encoder - (void) encodeWithCoder: (NSCoder*)encoder
{
if([encoder allowsKeyedCoding])
{
[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: _title];
[encoder encodeObject: _items]; [encoder encodeObject: _items];
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_autoenable]; [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,18 +1572,21 @@ _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: _itemCells];
[encoder encodeObject: _font]; [encoder encodeObject: _font];
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_horizontal]; [encoder encodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
[encoder encodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad]; [encoder encodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
[encoder encodeValueOfObjCType: @encode(NSSize) at: &_cellSize]; [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:) [_itemCells makeObjectsPerformSelector: @selector(setMenuView:)
@ -1596,7 +1599,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
_highlightedItemIndex = -1; _highlightedItemIndex = -1;
_needsSizing = YES; _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];
@ -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];
@ -463,8 +464,8 @@ static NSImage *unexpandable = nil;
/** /**
* 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,8 +517,8 @@ 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
{ {
@ -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];
} }
} }
@ -799,10 +801,14 @@ static NSImage *unexpandable = nil;
} }
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;
} }
@ -1556,7 +1564,8 @@ static NSImage *unexpandable = nil;
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;
} }
@ -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:
@ -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,6 +163,13 @@
BOOL flag; BOOL flag;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
// Nothing to do here, for keyed coding this is handled by NSWindowTemplate.
// Calling the above method should throw an NSInvalidArgumentException.
}
else
{
flag = _becomesKeyOnlyIfNeeded; flag = _becomesKeyOnlyIfNeeded;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _isFloatingPanel; flag = _isFloatingPanel;
@ -170,18 +177,27 @@
flag = _worksWhenModal; flag = _worksWhenModal;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
BOOL flag; BOOL flag;
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
if([aDecoder allowsKeyedCoding])
{
// Nothing to do here, for keyed coding this is handled by NSWindowTemplate.
// Calling the above method should throw an NSInvalidArgumentException.
}
else
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setBecomesKeyOnlyIfNeeded: flag]; [self setBecomesKeyOnlyIfNeeded: flag];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setFloatingPanel: flag]; [self setFloatingPanel: flag];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setWorksWhenModal: flag]; [self setWorksWhenModal: flag];
}
return self; return self;
} }

View file

@ -313,6 +313,12 @@ static NSParagraphStyle *defaultStyle = nil;
} }
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{
if([aCoder allowsKeyedCoding])
{
// TODO_NIB: Determine keys for NSParagraphStyle, if there are any.
}
else
{ {
unsigned count; unsigned count;
@ -359,11 +365,17 @@ static NSParagraphStyle *defaultStyle = nil;
{ {
[aCoder decodeValueOfObjCType: @encode(int) at: &_baseDirection]; [aCoder decodeValueOfObjCType: @encode(int) at: &_baseDirection];
} }
}
return self; return self;
} }
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{
if([aCoder allowsKeyedCoding])
{
// TODO_NIB: Determine keys for NSParagraphStyle, if there are any.
}
else
{ {
unsigned count; unsigned count;
@ -406,7 +418,7 @@ static NSParagraphStyle *defaultStyle = nil;
[aCoder encodeValueOfObjCType: @encode(int) at: &_baseDirection]; [aCoder encodeValueOfObjCType: @encode(int) at: &_baseDirection];
} }
}
- (BOOL) isEqual: (id)aother - (BOOL) isEqual: (id)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,9 +958,23 @@ 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 encodeBool: [self altersStateOfSelectedItem] forKey: @"NSAltersState"];
[aCoder encodeBool: [self usesItemFromMenu] forKey: @"NSUsesItemFromMenu"];
[aCoder encodeInt: [self arrowPosition] forKey: @"NSArrowPosition"];
[aCoder encodeInt: [self preferredEdge] forKey: @"NSPreferredEdge"];
// encode the menu, if present.
if(_menu != nil)
{
[aCoder encodeObject: _menu forKey: @"NSMenu"];
}
}
else
{
int flag;
[aCoder encodeObject: _menu]; [aCoder encodeObject: _menu];
[aCoder encodeConditionalObject: [self selectedItem]]; [aCoder encodeConditionalObject: [self selectedItem]];
flag = _pbcFlags.pullsDown; flag = _pbcFlags.pullsDown;
@ -974,13 +988,13 @@ static NSImage *_pbc_image[2];
flag = _pbcFlags.arrowPosition; flag = _pbcFlags.arrowPosition;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag]; [aCoder encodeValueOfObjCType: @encode(int) at: &flag];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
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

@ -645,6 +645,12 @@ static NSMutableDictionary* printerCache;
// NSCoding protocol // NSCoding protocol
// //
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{
if([aCoder allowsKeyedCoding])
{
// TODO: Determine keys for NSPrinter.
}
else
{ {
[aCoder encodeObject: _printerHost]; [aCoder encodeObject: _printerHost];
[aCoder encodeObject: _printerName]; [aCoder encodeObject: _printerName];
@ -652,15 +658,22 @@ static NSMutableDictionary* printerCache;
[aCoder encodeObject: _printerType]; [aCoder encodeObject: _printerType];
[aCoder encodeObject: _tables]; [aCoder encodeObject: _tables];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{
if([aDecoder allowsKeyedCoding])
{
// TODO: Determine keys for NSPrinter.
}
else
{ {
_printerHost = [aDecoder decodeObject]; _printerHost = [aDecoder decodeObject];
_printerName = [aDecoder decodeObject]; _printerName = [aDecoder decodeObject];
_printerNote = [aDecoder decodeObject]; _printerNote = [aDecoder decodeObject];
_printerType = [aDecoder decodeObject]; _printerType = [aDecoder decodeObject];
_tables = [aDecoder decodeObject]; _tables = [aDecoder decodeObject];
}
return self; return self;
} }
@ -1448,6 +1461,14 @@ static NSMutableDictionary* printerCache;
[scanner scanString: @"<" [scanner scanString: @"<"
intoString: NULL]; intoString: NULL];
// "<<" is a valid part of a PS string
if ([scanner scanString: @"<"
intoString: NULL])
{
value = [value stringByAppendingString: @"<<"];
}
else
{
[scanner scanCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet] [scanner scanCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]
intoString: NULL]; intoString: NULL];
@ -1458,8 +1479,8 @@ static NSMutableDictionary* printerCache;
if (location+2 > stringLength) if (location+2 > stringLength)
{ {
[NSException raise: NSPPDParseException [NSException raise: NSPPDParseException
format: @"Badly formatted hexadecimal substring in \ format: @"Badly formatted hexadecimal substring '%@' in \
PPD printer file."]; PPD printer file.", qString];
// NOT REACHED // NOT REACHED
} }
value = [value stringByAppendingFormat: @"%c", value = [value stringByAppendingFormat: @"%c",
@ -1471,12 +1492,14 @@ static NSMutableDictionary* printerCache;
[scanner scanCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet] [scanner scanCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]
intoString: NULL]; intoString: NULL];
} }
}
if ([scanner scanUpToString:@"<" intoString:&part]) if ([scanner scanUpToString:@"<" intoString:&part])
{ {
value = [value stringByAppendingString: part]; value = [value stringByAppendingString: part];
} }
} }
return value; return value;
} }
@ -1510,7 +1533,8 @@ static NSMutableDictionary* printerCache;
} }
[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,6 +290,35 @@ static NSColor *fillColour = nil;
- (void)encodeWithCoder:(NSCoder *)aCoder - (void)encodeWithCoder:(NSCoder *)aCoder
{ {
[super encodeWithCoder:aCoder]; [super encodeWithCoder:aCoder];
if([aCoder allowsKeyedCoding])
{
unsigned long flags = 0;
id matrix = AUTORELEASE([[NSPSMatrix alloc] init]);
[aCoder encodeDouble: _minValue forKey: @"NSMinValue"];
[aCoder encodeDouble: _maxValue forKey: @"NSMaxValue"];
[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:&_isIndeterminate];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isBezeled]; [aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isBezeled];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_usesThreadedAnimation]; [aCoder encodeValueOfObjCType: @encode(BOOL) at:&_usesThreadedAnimation];
@ -298,24 +328,54 @@ static NSColor *fillColour = nil;
[aCoder encodeValueOfObjCType: @encode(double) at:&_maxValue]; [aCoder encodeValueOfObjCType: @encode(double) at:&_maxValue];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isVertical]; [aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isVertical];
} }
}
- (id)initWithCoder:(NSCoder *)aDecoder - (id)initWithCoder:(NSCoder *)aDecoder
{ {
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

@ -210,6 +210,17 @@ typedef enum
// NSCoding protocol // NSCoding protocol
// //
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{
if([aCoder allowsKeyedCoding])
{
[aCoder encodeBool: _isWellKnownSelection
forKey: @"GSIsWellKnownSelection"];
[aCoder encodeBool: _selectionType
forKey: @"GSSelectionType"];
[aCoder encodeObject: _descriptionData
forKey: @"GSDescriptionData"];
}
else
{ {
[aCoder encodeValueOfObjCType: @encode(BOOL) [aCoder encodeValueOfObjCType: @encode(BOOL)
at: &_isWellKnownSelection]; at: &_isWellKnownSelection];
@ -218,16 +229,28 @@ typedef enum
[aCoder encodeValueOfObjCType: @encode(id) [aCoder encodeValueOfObjCType: @encode(id)
at: _descriptionData]; at: _descriptionData];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super init]; [super init];
if([aDecoder allowsKeyedCoding])
{
_isWellKnownSelection = [aDecoder decodeBoolForKey: @"GSIsWellKnownSelection"];
_selectionType = [aDecoder decodeIntForKey: @"GSSelectionType"];
ASSIGN(_descriptionData, [aDecoder decodeObjectForKey: @"GSDescriptionData"]);
}
else
{
id obj;
[aDecoder decodeValueOfObjCType: @encode(BOOL) [aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &_isWellKnownSelection]; at: &_isWellKnownSelection];
[aDecoder decodeValueOfObjCType: @encode(int) [aDecoder decodeValueOfObjCType: @encode(int)
at: &_selectionType]; at: &_selectionType];
[aDecoder decodeValueOfObjCType: @encode(id) [aDecoder decodeValueOfObjCType: @encode(id)
at: _descriptionData]; 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)

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

@ -666,6 +666,12 @@ return NO; \
// NSCoding // NSCoding
// //
- (void) encodeWithCoder: (NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{
if([coder allowsKeyedCoding])
{
// TODO_NIB: Determine keys for NSSound.
}
else
{ {
[coder encodeValueOfObjCType: @encode(BOOL) at: &_onlyReference]; [coder encodeValueOfObjCType: @encode(BOOL) at: &_onlyReference];
[coder encodeObject: _name]; [coder encodeObject: _name];
@ -691,8 +697,15 @@ return NO; \
[coder encodeObject: _data]; [coder encodeObject: _data];
} }
}
- (id) initWithCoder: (NSCoder*)decoder - (id) initWithCoder: (NSCoder*)decoder
{
if([decoder allowsKeyedCoding])
{
// TODO_NIB: Determine keys for NSSound.
}
else
{ {
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_onlyReference]; [decoder decodeValueOfObjCType: @encode(BOOL) at: &_onlyReference];
@ -720,7 +733,7 @@ return NO; \
_data = RETAIN([decoder decodeObject]); _data = RETAIN([decoder decodeObject]);
} }
}
return self; return self;
} }

View file

@ -78,15 +78,13 @@ 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;
} }
@ -96,6 +94,7 @@ GSSpellServerName(NSString *vendor, NSString *language)
{ {
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)
{ {
/* /*
@ -157,15 +172,16 @@ static inline NSRect DrawLightButton(NSRect border, NSRect clip)
[[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;
}
- (BOOL) trackMouse: (NSEvent*)theEvent
inRect: (NSRect)cellFrame
ofView: (NSView*)controlView
untilMouseUp: (BOOL)flag
{ {
highlightUp = highlight; 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,9 +447,20 @@ static inline void HighlightDownButton(NSRect aRect)
// //
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
int tmp1, tmp2;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[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;
tmp1 = (int)_autorepeat; tmp1 = (int)_autorepeat;
tmp2 = (int)_valueWraps; tmp2 = (int)_valueWraps;
@ -327,25 +475,27 @@ static inline void HighlightDownButton(NSRect aRect)
[aCoder encodeValueOfObjCType: @encode(int) [aCoder encodeValueOfObjCType: @encode(int)
at: &tmp2]; 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,7 +766,34 @@
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if ([aCoder allowsKeyedCoding])
{
unsigned int type = 0;
switch(_type)
{
case NSTopTabsBezelBorder:
type = 0;
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: _items];
[aCoder encodeObject: _font]; [aCoder encodeObject: _font];
[aCoder encodeValueOfObjCType: @encode(NSTabViewType) at: &_type]; [aCoder encodeValueOfObjCType: @encode(NSTabViewType) at: &_type];
@ -772,6 +802,7 @@
[aCoder encodeConditionalObject: _delegate]; [aCoder encodeConditionalObject: _delegate];
[aCoder encodeValueOfObjCType: "i" at: &_selected_item]; [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

@ -207,6 +207,16 @@
// NSCoding protocol. // NSCoding protocol.
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: _ident forKey: @"NSIdentifier"];
[aCoder encodeObject: _label forKey: @"NSLabel"];
[aCoder encodeObject: _view forKey: @"NSView"];
[aCoder encodeObject: _color forKey: @"NSColor"];
[aCoder encodeObject: _tabview forKey: @"NSTabView"];
}
else
{ {
[aCoder encodeObject:_ident]; [aCoder encodeObject:_ident];
[aCoder encodeObject:_label]; [aCoder encodeObject:_label];
@ -216,6 +226,7 @@
[aCoder encodeObject:_first_responder]; [aCoder encodeObject:_first_responder];
[aCoder encodeObject:_tabview]; [aCoder encodeObject:_tabview];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {

View file

@ -369,6 +369,19 @@
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{
if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: _identifier forKey: @"NSIdentifier"];
[aCoder encodeObject: _dataCell forKey: @"NSDataCell"];
[aCoder encodeObject: _headerCell forKey: @"NSHeaderCell"];
[aCoder encodeBool: _is_resizable forKey: @"NSIsResizable"];
[aCoder encodeBool: _is_editable forKey: @"NSIsEditable"];
[aCoder encodeFloat: _max_width forKey: @"NSMaxWidth"];
[aCoder encodeFloat: _min_width forKey: @"NSMinWidth"];
[aCoder encodeFloat: _width forKey: @"NSWidth"];
}
else
{ {
[aCoder encodeObject: _identifier]; [aCoder encodeObject: _identifier];
@ -381,6 +394,7 @@
[aCoder encodeObject: _headerCell]; [aCoder encodeObject: _headerCell];
[aCoder encodeObject: _dataCell]; [aCoder encodeObject: _dataCell];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {

View file

@ -4003,26 +4003,11 @@ static inline float computePeriod(NSPoint mouseLocationWin,
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;
_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]; [lastColumn setWidth: last_column_width];
} }
_tilingDisabled = NO;
[self tile];
}
} }
- (void) setFrame: (NSRect)frameRect - (void) setFrame: (NSRect)frameRect
@ -5136,17 +5121,32 @@ 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"]; [aCoder encodeObject: [self dataSource] forKey: @"NSDataSource"];
}
if([self delegate])
{
[aCoder encodeObject: [self delegate] forKey: @"NSDelegate"]; [aCoder encodeObject: [self delegate] forKey: @"NSDelegate"];
}
if([self target])
{
[aCoder encodeObject: [self target] forKey: @"NSTarget"]; [aCoder encodeObject: [self target] forKey: @"NSTarget"];
}
if([self action])
{
[aCoder encodeObject: NSStringFromSelector([self action]) forKey: @"NSAction"]; [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"];
@ -5154,30 +5154,30 @@ static inline float computePeriod(NSPoint mouseLocationWin,
[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([self allowsColumnSelection]) if(_headerView)
vFlags |= 1; {
[aCoder encodeObject: _headerView forKey: @"NSHeaderView"];
}
if(_cornerView)
{
[aCoder encodeObject: _cornerView forKey: @"NSCornerView"];
}
if([self allowsMultipleSelection]) tableViewFlags.columnSelection = [self allowsColumnSelection];
vFlags |= 2; tableViewFlags.multipleSelection = [self allowsMultipleSelection];
tableViewFlags.emptySelection = [self allowsEmptySelection];
tableViewFlags.drawsGrid = [self drawsGrid];
tableViewFlags.columnResizing = [self allowsColumnResizing];
tableViewFlags.columnOrdering = [self allowsColumnReordering];
if([self allowsEmptySelection]) memcpy((void *)&vFlags,(void *)&tableViewFlags,sizeof(unsigned long));
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

@ -322,18 +322,32 @@
* NSCoding protocol * NSCoding protocol
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{
if([aCoder allowsKeyedCoding])
{
// TODO_NIB: Determine keys for NSTextAttachment.
}
else
{ {
[aCoder encodeObject: _fileWrapper]; [aCoder encodeObject: _fileWrapper];
[aCoder encodeObject: _cell]; [aCoder encodeObject: _cell];
} }
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{
if([aDecoder allowsKeyedCoding])
{
// TODO_NIB: Determine keys for NSTextAttachment.
}
else
{ {
[aDecoder decodeValueOfObjCType: @encode(id) at: &_fileWrapper]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_fileWrapper];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_cell];
// Reconnect the cell, so the cell does not have to store the attachment // Reconnect the cell, so the cell does not have to store the attachment
[_cell setAttachment: self]; [_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,11 +208,20 @@ static NSColor *txtCol;
BOOL tmp; BOOL tmp;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"];
[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: &_background_color];
[aCoder encodeValueOfObjCType: @encode(id) at: &_text_color]; [aCoder encodeValueOfObjCType: @encode(id) at: &_text_color];
tmp = _textfieldcell_draws_background; tmp = _textfieldcell_draws_background;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; [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

View file

@ -147,22 +147,70 @@ Interface for a bunch of internal methods that need to be cleaned up.
@implementation NSTextViewSharedData @implementation NSTextViewSharedData
- (id) initWithTextView: (NSTextView *)tv
{
if((self = [super init]) != nil)
{
flags = (([tv isEditable]?0x01:0) |
([tv isSelectable]?0x02:0) |
([tv isRichText]?0x04:0) |
([tv importsGraphics]?0x08:0) |
([tv isFieldEditor]?0x10:0) |
([tv usesFontPanel]?0x20:0) |
([tv isRulerVisible]?0x40:0) |
([tv usesRuler]?0x100:0) |
([tv drawsBackground]?0x800:0) |
([tv smartInsertDeleteEnabled]?0x2000000:0) |
([tv allowsUndo]?0x40000000:0));
ASSIGN(backgroundColor,[tv backgroundColor]);
ASSIGN(paragraphStyle,[NSParagraphStyle defaultParagraphStyle]);
ASSIGN(insertionColor,[tv insertionPointColor]);
ASSIGN(markAttr,[tv markedTextAttributes]);
ASSIGN(selectedAttr,[tv selectedTextAttributes]);
linkAttr = nil;
textView = tv;
}
return self;
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
ASSIGN(backgroundColor, [aDecoder decodeObjectForKey: @"NSBackgroundColor"]); ASSIGN(backgroundColor,
ASSIGN(paragraphStyle, [aDecoder decodeObjectForKey: @"NSDefaultParagraphStyle"]); [aDecoder decodeObjectForKey: @"NSBackgroundColor"]);
ASSIGN(paragraphStyle,
[aDecoder decodeObjectForKey: @"NSDefaultParagraphStyle"]);
flags = [aDecoder decodeIntForKey: @"NSFlags"]; flags = [aDecoder decodeIntForKey: @"NSFlags"];
ASSIGN(insertionColor, [aDecoder decodeObjectForKey: @"NSInsertionColor"]); ASSIGN(insertionColor,
[aDecoder decodeObjectForKey: @"NSInsertionColor"]);
ASSIGN(linkAttr, [aDecoder decodeObjectForKey: @"NSLinkAttributes"]); ASSIGN(linkAttr, [aDecoder decodeObjectForKey: @"NSLinkAttributes"]);
ASSIGN(markAttr, [aDecoder decodeObjectForKey: @"NSMarkedAttributes"]); ASSIGN(markAttr, [aDecoder decodeObjectForKey: @"NSMarkedAttributes"]);
ASSIGN(selectedAttr, [aDecoder decodeObjectForKey: @"NSSelectedAttributes"]); ASSIGN(selectedAttr,
[aDecoder decodeObjectForKey: @"NSSelectedAttributes"]);
} }
return self; return self;
} }
- (void) encodeWithCoder: (NSCoder *)coder
{
if([coder allowsKeyedCoding])
{
[coder encodeObject: backgroundColor forKey: @"NSBackgroundColor"];
[coder encodeObject: paragraphStyle forKey: @"NSDefaultParagraphStyle"];
[coder encodeInt: flags forKey: @"NSFlags"];
[coder encodeObject: markAttr forKey: @"NSMarkedAttributes"];
[coder encodeObject: selectedAttr forKey: @"NSSelectedAttributes"];
[coder encodeObject: insertionColor forKey: @"NSInsertionColor"];
// TODO: Encode/Decode link attributes...
}
}
- (void) dealloc - (void) dealloc
{ {
RELEASE(backgroundColor); RELEASE(backgroundColor);
@ -171,6 +219,7 @@ Interface for a bunch of internal methods that need to be cleaned up.
RELEASE(linkAttr); RELEASE(linkAttr);
RELEASE(markAttr); RELEASE(markAttr);
RELEASE(selectedAttr); RELEASE(selectedAttr);
[super dealloc];
} }
- (NSColor *)backgroundColor - (NSColor *)backgroundColor
@ -647,6 +696,20 @@ that makes decoding and encoding compatible with the old code.
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
NSTextViewSharedData *tvsd = [[NSTextViewSharedData alloc] initWithTextView: self];
[aCoder encodeConditionalObject: _delegate forKey: @"NSDelegate"];
[aCoder encodeSize: [self maxSize] forKey: @"NSMaxSize"];
[aCoder encodeSize: [self minSize] forKey: @"NSMinSize"];
[aCoder encodeObject: tvsd forKey: @"NSSharedData"];
[aCoder encodeObject: [self textStorage] forKey: @"NSTextStorage"];
[aCoder encodeObject: [self textContainer] forKey: @"NSTextContainer"];
[aCoder encodeInt: 0 forKey: @"NSTVFlags"]; // no delegates, etc... set to zero.
}
else
{
[aCoder encodeConditionalObject: _delegate]; [aCoder encodeConditionalObject: _delegate];
flag = _tf.is_field_editor; flag = _tf.is_field_editor;
@ -687,14 +750,13 @@ that makes decoding and encoding compatible with the old code.
flag = [_textContainer heightTracksTextView]; flag = [_textContainer heightTracksTextView];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
} }
}
- (id) initWithCoder: (NSCoder *)aDecoder - (id) initWithCoder: (NSCoder *)aDecoder
{ {
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
NSTextContainer *aTextContainer;
if ([aDecoder containsValueForKey: @"NSDelegate"]) if ([aDecoder containsValueForKey: @"NSDelegate"])
{ {
[self setDelegate: [aDecoder decodeObjectForKey: @"NSDelegate"]]; [self setDelegate: [aDecoder decodeObjectForKey: @"NSDelegate"]];
@ -719,9 +781,11 @@ that makes decoding and encoding compatible with the old code.
if ([aDecoder containsValueForKey: @"NSSharedData"]) if ([aDecoder containsValueForKey: @"NSSharedData"])
{ {
NSTextViewSharedData *shared = [aDecoder decodeObjectForKey: @"NSSharedData"]; NSTextViewSharedData *shared;
unsigned int flags = [shared flags]; unsigned int flags;
shared = [aDecoder decodeObjectForKey: @"NSSharedData"];
flags = [shared flags];
ASSIGN(_insertionPointColor, [shared insertionColor]); ASSIGN(_insertionPointColor, [shared insertionColor]);
ASSIGN(_backgroundColor, [shared backgroundColor]); ASSIGN(_backgroundColor, [shared backgroundColor]);
@ -764,8 +828,7 @@ that makes decoding and encoding compatible with the old code.
if ([aDecoder containsValueForKey: @"NSTVFlags"]) if ([aDecoder containsValueForKey: @"NSTVFlags"])
{ {
int vFlags = [aDecoder decodeIntForKey: @"NSTVFlags"]; [aDecoder decodeIntForKey: @"NSTVFlags"];
// these flags are not used...
} }
// register for services and subscribe to notifications. // register for services and subscribe to notifications.
@ -912,7 +975,6 @@ that makes decoding and encoding compatible with the old code.
[super dealloc]; [super dealloc];
} }
/**** Managing the text network ****/ /**** Managing the text network ****/
/* This should only be called by [NSTextContainer -setTextView:]. If the /* This should only be called by [NSTextContainer -setTextView:]. If the
@ -1756,7 +1818,7 @@ or add guards
return NSMakeRange(NSNotFound, 0); return NSMakeRange(NSNotFound, 0);
} }
-(void) setMarkedText: (NSString *)aString selectedRange: (NSRange)selRange - (void) setMarkedText: (id)aString selectedRange: (NSRange)selRange
{ {
} }
@ -2700,15 +2762,34 @@ This method is for user changes; see NSTextView_actions.m.
- (void) setTypingAttributes: (NSDictionary *)attrs - (void) setTypingAttributes: (NSDictionary *)attrs
{ {
NSDictionary *old_attrs;
NSString *names[] = {NSParagraphStyleAttributeName,
NSFontAttributeName,
NSForegroundColorAttributeName};
int i;
if (attrs == nil) if (attrs == nil)
{ {
attrs = [isa defaultTypingAttributes]; attrs = [isa defaultTypingAttributes];
} }
DESTROY(_layoutManager->_typingAttributes); old_attrs = _layoutManager->_typingAttributes;
_layoutManager->_typingAttributes = [[NSMutableDictionary alloc] _layoutManager->_typingAttributes = [[NSMutableDictionary alloc]
initWithDictionary: attrs]; initWithDictionary: attrs];
// make sure to keep the main attributes set.
for (i = 0; i < 3; i++)
{
NSString *name = names[i];
if ([attrs objectForKey: name] == nil)
{
[_layoutManager->_typingAttributes setObject: [old_attrs objectForKey: name]
forKey: name];
}
}
RELEASE(old_attrs);
[self updateFontPanel]; [self updateFontPanel];
[self updateRuler]; [self updateRuler];
} }
@ -3361,7 +3442,7 @@ Figure out how the additional layout stuff is supposed to work.
- (void) rulerView: (NSRulerView *)ruler - (void) rulerView: (NSRulerView *)ruler
didMoveMarker: (NSRulerMarker *)marker didMoveMarker: (NSRulerMarker *)marker
{ {
NSTextTab *old_tab = [marker representedObject]; NSTextTab *old_tab = (NSTextTab*)[marker representedObject];
NSTextTab *new_tab = [[NSTextTab alloc] initWithType: [old_tab tabStopType] NSTextTab *new_tab = [[NSTextTab alloc] initWithType: [old_tab tabStopType]
location: [marker markerLocation]]; location: [marker markerLocation]];
NSRange range = [self rangeForUserParagraphAttributeChange]; NSRange range = [self rangeForUserParagraphAttributeChange];
@ -3430,7 +3511,7 @@ Figure out how the additional layout stuff is supposed to work.
- (void) rulerView: (NSRulerView *)ruler - (void) rulerView: (NSRulerView *)ruler
didRemoveMarker: (NSRulerMarker *)marker didRemoveMarker: (NSRulerMarker *)marker
{ {
NSTextTab *tab = [marker representedObject]; NSTextTab *tab = (NSTextTab *)[marker representedObject];
NSRange range = [self rangeForUserParagraphAttributeChange]; NSRange range = [self rangeForUserParagraphAttributeChange];
unsigned loc = range.location; unsigned loc = range.location;
NSParagraphStyle *style; NSParagraphStyle *style;
@ -3489,7 +3570,7 @@ Figure out how the additional layout stuff is supposed to work.
- (void) rulerView: (NSRulerView *)ruler - (void) rulerView: (NSRulerView *)ruler
didAddMarker: (NSRulerMarker *)marker didAddMarker: (NSRulerMarker *)marker
{ {
NSTextTab *old_tab = [marker representedObject]; NSTextTab *old_tab = (NSTextTab *)[marker representedObject];
NSTextTab *new_tab = [[NSTextTab alloc] initWithType: [old_tab tabStopType] NSTextTab *new_tab = [[NSTextTab alloc] initWithType: [old_tab tabStopType]
location: [marker markerLocation]]; location: [marker markerLocation]];
NSRange range = [self rangeForUserParagraphAttributeChange]; NSRange range = [self rangeForUserParagraphAttributeChange];

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,8 +3939,15 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[aCoder encodeInt: vFlags [aCoder encodeInt: vFlags
forKey: @"NSvFlags"]; forKey: @"NSvFlags"];
//
// 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"]; [aCoder encodeObject: _super_view forKey: @"NSSuperview"];
} }
}
else else
{ {
NSDebugLLog(@"NSView", @"NSView: start encoding\n"); NSDebugLLog(@"NSView", @"NSView: start encoding\n");
@ -3961,11 +3991,34 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
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,14 +4102,15 @@ 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... // iterate over subviews and put them into the view...
e = [subs objectEnumerator]; e = [subs objectEnumerator];
while ((sub = [e nextObject]) != nil) while ((sub = [e nextObject]) != nil)
{ {
NSAssert([sub window] == nil, NSInternalInconsistencyException); NSAssert([sub window] == nil,
NSAssert([sub superview] == nil, NSInternalInconsistencyException); NSInternalInconsistencyException);
NSAssert([sub superview] == nil,
NSInternalInconsistencyException);
[sub viewWillMoveToWindow: _window]; [sub viewWillMoveToWindow: _window];
[sub viewWillMoveToSuperview: self]; [sub viewWillMoveToSuperview: self];
[sub setNextResponder: self]; [sub setNextResponder: self];
@ -4045,6 +4123,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[self didAddSubview: sub]; [self didAddSubview: sub];
} }
RELEASE(subs); 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,12 +2348,27 @@ 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)
{
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; _f.cursor_rects_valid = NO;
} }
} }
}
static void static void
resetCursorRectsForView(NSView *theView) resetCursorRectsForView(NSView *theView)
@ -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);