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 \
NSScrollView.h \
NSScroller.h \
NSSearchField.h \
NSSearchFieldCell.h \
NSSecureTextField.h \
NSSelection.h \
NSSlider.h \

View file

@ -80,7 +80,7 @@ GSServerForWindow(NSWindow *window)
/* Backend window hasn't been initialized yet, assume current server. */
return GSCurrentServer();
}
return NSMapGet(windowmaps, (void *)num);
return NSMapGet(windowmaps, (void *)(intptr_t)num);
}
/** Returns the current GSDisplayServer */
@ -511,7 +511,7 @@ GSCurrentServer(void)
for a window that has already been created */
- (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

View file

@ -543,7 +543,7 @@ static GSDragView *sharedDragView = nil;
NSEvent *e;
NSGraphicsContext *context = GSCurrentContext();
// 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];
e = [NSEvent otherEventWithType: NSAppKitDefined

View file

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

View file

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

View file

@ -874,12 +874,14 @@ restart: ;
if (g->g == GSAttachmentGlyph)
{
NSTextAttachment *attach = [curTextStorage attribute: NSAttachmentAttributeName
atIndex: g->char_index
effectiveRange: NULL];
NSTextAttachmentCell *cell = [attach attachmentCell];
NSTextAttachment *attach;
NSTextAttachmentCell *cell;
NSRect r;
attach = [curTextStorage attribute: NSAttachmentAttributeName
atIndex: g->char_index
effectiveRange: NULL];
cell = (NSTextAttachmentCell*)[attach attachmentCell];
if (!cell)
{
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;
for (; h; h = (glyph_run_t *)h->head.next)
{
printf("%08x %i chars, %i glyphs, %i complete, prev %08x next %08x\n",
(int)h, h->head.char_length, h->head.glyph_length, h->head.complete,
(int)h->prev, (int)h->head.next);
printf("%8p %i chars, %i glyphs, %i complete, prev %8p next %8p\n",
h, h->head.char_length, h->head.glyph_length, h->head.complete,
h->prev, h->head.next);
printf(" level %i, continued %i\n", h->level, h->continued);
if (h->head.complete)
{
@ -181,14 +181,14 @@ Private method used internally by GSLayoutManager for sanity checking.
printf(" head: ");
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");
h = (glyphs + SKIP_LIST_DEPTH - 1)->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--)
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");
}
}

View file

@ -32,8 +32,10 @@
#include <Foundation/NSArchiver.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSBundle.h>
#include <Foundation/NSByteOrder.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSData.h>
#include <Foundation/NSDecimalNumber.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSEnumerator.h>
@ -52,6 +54,38 @@
#include <GNUstepGUI/GSNibCompatibility.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
+ (void) initialize
{
@ -71,6 +105,48 @@
[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
{
if ([coder allowsKeyedCoding])
@ -110,7 +186,7 @@
}
if ([coder containsValueForKey: @"NSWindowRect"])
{
_windowRect = [coder decodeRectForKey: @"NSWindowRect"];
_windowRect = [coder decodeRectForKey: @"NSWindowRect"];
}
if ([coder containsValueForKey: @"NSFrameAutosaveName"])
{
@ -121,10 +197,12 @@
ASSIGN(_title, [coder decodeObjectForKey: @"NSWindowTitle"]);
_windowStyle |= NSTitledWindowMask;
}
_baseWindowClass = [NSWindow class];
}
else
{
[NSException raise: NSInternalInconsistencyException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -136,7 +214,8 @@
if ([aCoder allowsKeyedCoding])
{
unsigned long flags = 0;
NSRect rect = [NSWindow contentRectForFrameRect: _windowRect
styleMask: _windowStyle];
memcpy((void *)&flags,(void *)&_flags,sizeof(unsigned long));
[aCoder encodeObject: _viewClass forKey: @"NSViewClass"];
@ -147,7 +226,7 @@
[aCoder encodeInt: flags forKey: @"NSWTFlags"];
[aCoder encodeSize: _minSize forKey: @"NSMinSize"];
[aCoder encodeSize: _maxSize forKey: @"NSMaxSize"];
[aCoder encodeRect: _windowRect forKey: @"NSWindowRect"];
[aCoder encodeRect: rect forKey: @"NSWindowRect"];
[aCoder encodeObject: _title forKey: @"NSWindowTitle"];
[aCoder encodeObject: _autosaveName forKey: @"NSFrameAutosaveName"];
}
@ -157,10 +236,19 @@
{
if(_realObject == nil)
{
Class aClass = NSClassFromString(_windowClass);
Class aClass;
NSEnumerator *en;
id v = nil;
if([NSClassSwapper isInInterfaceBuilder])
{
aClass = [self baseWindowClass];
}
else
{
aClass = NSClassFromString(_windowClass);
}
if (aClass == nil)
{
[NSException raise: NSInternalInconsistencyException
@ -192,7 +280,14 @@
[_realObject setMinSize: _minSize];
[_realObject setMaxSize: _maxSize];
[_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...
en = [[[_realObject contentView] subviews] objectEnumerator];
while((v = [en nextObject]) != nil)
@ -321,6 +416,11 @@
{
return _windowClass;
}
- (Class) baseWindowClass
{
return _baseWindowClass;
}
@end
// Template for any classes which derive from NSView
@ -345,7 +445,7 @@
}
else
{
[NSException raise: NSInternalInconsistencyException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -360,7 +460,7 @@
}
}
- (id)nibInstantiate
- (id) nibInstantiate
{
if(_realObject == nil)
{
@ -482,7 +582,7 @@
@implementation NSCustomObject
- (void) setClassName: (NSString *)name
{
ASSIGN(_className, name);
ASSIGNCOPY(_className, name);
}
- (NSString *)className
@ -492,7 +592,7 @@
- (void) setExtension: (NSString *)name
{
ASSIGN(_extension, name);
ASSIGNCOPY(_extension, name);
}
- (NSString *)extension
@ -519,7 +619,7 @@
}
else
{
[NSException raise: NSInternalInconsistencyException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -533,13 +633,30 @@
[coder encodeObject: (id)_className forKey: @"NSClassName"];
[coder encodeConditionalObject: (id)_extension forKey: @"NSExtension"];
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Keyed coding not implemented for %@.",
NSStringFromClass([self class])];
}
}
- (id) nibInstantiate
{
if(_object == nil)
{
Class aClass = NSClassFromString(_className);
Class aClass;
if([NSClassSwapper isInInterfaceBuilder])
{
aClass = [self class];
}
else
{
aClass = NSClassFromString(_className);
}
if(aClass == nil)
{
[NSException raise: NSInternalInconsistencyException
@ -550,12 +667,19 @@
}
return _object;
}
- (void) dealloc
{
RELEASE(_className);
RELEASE(_extension);
[super dealloc];
}
@end
@implementation NSCustomView
- (void) setClassName: (NSString *)name
{
ASSIGN(_className, name);
ASSIGNCOPY(_className, name);
}
- (NSString *)className
@ -564,7 +688,7 @@
}
- (void) setExtension: (NSString *)ext;
{
ASSIGN(_extension, ext);
ASSIGNCOPY(_extension, ext);
}
- (NSString *)extension
@ -572,11 +696,21 @@
return _extension;
}
- (id)nibInstantiate
- (id) nibInstantiate
{
if(_view == nil)
{
Class aClass = NSClassFromString(_className);
Class aClass;
if([NSClassSwapper isInInterfaceBuilder])
{
aClass = [self class];
}
else
{
aClass = NSClassFromString(_className);
}
if(aClass == nil)
{
[NSException raise: NSInternalInconsistencyException
@ -585,6 +719,8 @@
else
{
_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...
}
}
@ -599,7 +735,14 @@
{
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;
@ -607,9 +750,17 @@
- (void) encodeWithCoder: (NSCoder *)coder
{
[super encodeWithCoder: coder];
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
@ -617,7 +768,7 @@
@implementation NSCustomResource
- (void) setClassName: (NSString *)className
{
ASSIGN(_className, className);
ASSIGNCOPY(_className, className);
}
- (NSString *)className
@ -627,7 +778,7 @@
- (void) setResourceName: (NSString *)resourceName
{
ASSIGN(_resourceName, resourceName);
ASSIGNCOPY(_resourceName, resourceName);
}
- (NSString *)resourceName
@ -651,11 +802,11 @@
// this is a hack, but for now it should do.
if([_className isEqual: @"NSSound"])
{
realObject = [NSSound soundNamed: _resourceName];
realObject = RETAIN([NSSound soundNamed: _resourceName]);
}
else if([_className isEqual: @"NSImage"])
{
realObject = [NSImage imageNamed: _resourceName];
realObject = RETAIN([NSImage imageNamed: _resourceName]);
}
// if an object has been substituted, then release the placeholder.
@ -666,7 +817,7 @@
}
else
{
[NSException raise: NSInternalInconsistencyException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -717,6 +868,29 @@
@end
@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
{
ASSIGN(_template, temp);
@ -729,7 +903,7 @@
- (void) setClassName: (NSString *)className
{
ASSIGN(_className, className);
ASSIGNCOPY(_className, className);
}
- (NSString *)className
@ -737,19 +911,30 @@
return _className;
}
+ (BOOL) isInInterfaceBuilder
- (void) setOriginalClassName: (NSString *)className
{
return NO;
ASSIGNCOPY(_originalClassName, className);
}
- (NSString *)originalClassName
{
return _originalClassName;
}
- (void) instantiateRealObject: (NSCoder *)coder withClassName: (NSString *)className
{
Class aClass = NSClassFromString(className);
Class aClass = nil;
id object = nil;
Class newCellClass = nil;
NSString *origCellClassName = 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)
{
[NSException raise: NSInternalInconsistencyException
@ -772,7 +957,7 @@
// swap the class...
object = [aClass allocWithZone: NSDefaultMallocZone()];
[(NSKeyedUnarchiver *)coder replaceObject: self withObject: object];
_template = [object initWithCoder: coder];
[self setTemplate: [object initWithCoder: coder]];
if(object != _template)
{
[(NSKeyedUnarchiver *)coder replaceObject: object withObject: _template];
@ -803,7 +988,7 @@
}
else
{
[NSException raise: NSInternalInconsistencyException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -815,10 +1000,24 @@
{
if([coder allowsKeyedCoding])
{
NSString *originalClassName = NSStringFromClass(_template);
[coder encodeObject: (id)_className forKey: @"NSClassName"];
[coder encodeObject: (id)originalClassName forKey: @"NSOriginalClassName"];
[coder encodeObject: _originalClassName forKey: @"NSOriginalClassName"];
[coder encodeObject: _className forKey: @"NSClassName"];
[_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
@ -867,9 +1066,10 @@
- (void) nibInstantiateWithOwner: (id)owner topLevelObjects: (NSMutableArray *)topLevelObjects
{
NSEnumerator *en = [_connections objectEnumerator];
NSArray *objs = NSAllMapTableKeys([self names]);
id obj = nil;
id menu = nil;
// replace the owner with the actual instance provided.
[_root setObject: owner];
@ -883,13 +1083,37 @@
}
}
// instantiate all windows and fill in the top level array.
en = [objs objectEnumerator];
while((obj = [en nextObject]) != nil)
{
if([obj isKindOfClass: [NSWindowTemplate class]])
{
if([obj realObject] == nil)
{
id o = [self instantiateObject: obj];
[topLevelObjects addObject: o];
}
}
else
{
id v = NSMapGet(_objects, obj);
if(v == nil || v == owner)
{
[topLevelObjects addObject: obj];
}
}
}
// bring visible windows to front...
en = [_visibleWindows objectEnumerator];
while((obj = [en nextObject]) != nil)
{
id w = [self instantiateObject: obj];
id w = [obj realObject];
[w orderFront: self];
}
// add the menu...
menu = [self objectForName: @"MainMenu"];
if(menu != nil)
{
@ -912,7 +1136,7 @@
- (NSMutableSet *) topLevelObjects
{
return nil;
return _topLevelObjects;
}
- (NSMutableDictionary *) nameTable
@ -920,6 +1144,31 @@
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
{
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
@ -944,20 +1193,38 @@
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
{
if([coder allowsKeyedCoding])
{
NSArray *accessibilityOidsKeys = (NSArray *)NSAllMapTableKeys(_accessibilityOids);
NSArray *accessibilityOidsValues = (NSArray *)NSAllMapTableValues(_accessibilityOids);
NSArray *accessibilityOidsValues = [self _valuesForKeys: accessibilityOidsKeys inMap: _accessibilityOids];
NSArray *classKeys = (NSArray *)NSAllMapTableKeys(_classes);
NSArray *classValues = (NSArray *)NSAllMapTableValues(_classes);
NSArray *classValues = [self _valuesForKeys: classKeys inMap: _classes];
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
NSArray *nameValues = (NSArray *)NSAllMapTableValues(_names);
NSArray *nameValues = [self _valuesForKeys: nameKeys inMap: _names];
NSArray *objectsKeys = (NSArray *)NSAllMapTableKeys(_objects);
NSArray *objectsValues = (NSArray *)NSAllMapTableValues(_objects);
NSArray *objectsValues = [self _valuesForKeys: objectsKeys inMap: _objects];
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) accessibilityOidsKeys forKey: @"NSAccessibilityOidsKeys"];
@ -971,12 +1238,18 @@
[coder encodeObject: (id) oidsKeys forKey: @"NSOidsKeys"];
[coder encodeObject: (id) oidsValues forKey: @"NSOidsValues"];
[coder encodeObject: (id) _connections forKey: @"NSConnections"];
[coder encodeConditionalObject: (id) _fontManager forKey: @"NSFontManager"];
[coder encodeConditionalObject: (id) _framework forKey: @"NSFramework"];
[coder encodeObject: (id) _fontManager forKey: @"NSFontManager"];
[coder encodeObject: (id) _framework forKey: @"NSFramework"];
[coder encodeObject: (id) _visibleWindows forKey: @"NSVisibleWindows"];
[coder encodeInt: _nextOid forKey: @"NSNextOid"];
[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
@ -1003,7 +1276,6 @@
ASSIGN(_accessibilityConnectors, (NSMutableArray *)[coder decodeObjectForKey: @"NSAccessibilityConnectors"]);
ASSIGN(_fontManager, [coder decodeObjectForKey: @"NSFontManager"]);
ASSIGN(_framework, [coder decodeObjectForKey: @"NSFramework"]);
ASSIGN(_connections, (NSMutableArray *)[coder decodeObjectForKey: @"NSConnections"]);
_nextOid = [coder decodeIntForKey: @"NSNextOid"];
{
@ -1041,16 +1313,31 @@
NSObjectMapValueCallBacks, 2);
// fill in the maps...
[self _buildMap: _accessibilityOids withKeys: accessibilityOidsKeys andValues: accessibilityOidsValues];
[self _buildMap: _classes 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];
[self _buildMap: _accessibilityOids
withKeys: accessibilityOidsKeys
andValues: accessibilityOidsValues];
[self _buildMap: _classes
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
{
[NSException raise: NSInternalInconsistencyException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -1102,6 +1389,7 @@
RELEASE(_framework);
RELEASE(_visibleWindows);
RELEASE(_root);
RELEASE(_topLevelObjects);
[super dealloc];
}
@ -1114,13 +1402,16 @@
{
return _root;
}
@end
@interface NSButtonImageSource : NSObject <NSCoding>
- (void) setNextOid: (int)noid
{
NSString *imageName;
_nextOid = noid;
}
- (int) nextOid
{
return _nextOid;
}
- (NSString *)imageName;
@end
@implementation NSButtonImageSource
@ -1130,6 +1421,13 @@
{
ASSIGN(imageName, [coder decodeObjectForKey: @"NSImageName"]);
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
RELEASE(self);
return [NSImage imageNamed: imageName];
}
@ -1140,6 +1438,21 @@
{
[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
@ -1162,3 +1475,65 @@
@implementation _NSCornerView
@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
{
NSLog(@"Exception occured while loading model: %@",[localException reason]);
TEST_RELEASE(unarchiver);
// TEST_RELEASE(unarchiver);
}
NS_ENDHANDLER

View file

@ -158,7 +158,6 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
NSEnumerator *enumerator;
NSNibConnector *connection;
NSString *key;
NSArray *visible;
NSMenu *menu;
NSMutableArray *topObjects;
id obj;
@ -248,12 +247,10 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
if ([context objectForKey: key] == nil ||
[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,
[key isEqualToString: @"NSServicesMenu"] == NO && // if they're custom classes.
[key isEqualToString: @"NSVisible"] == NO && // also exclude any other special parts of the nameTable.
[key isEqualToString: @"NSDeferred"] == NO &&
[key isEqualToString: @"NSTopLevelObjects"] == NO &&
[key isEqualToString: @"GSCustomClassMap"] == NO)
// we don't want to send a message to these menus twice, if they're custom classes.
if ([key isEqualToString: @"NSWindowsMenu"] == NO &&
[key isEqualToString: @"NSServicesMenu"] == NO &&
[key isEqualToString: @"NSTopLevelObjects"] == NO)
{
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
* in the awakeFromNib methods which are called on all of the objects.
*/
visible = [nameTable objectForKey: @"NSVisible"];
if (visible != nil
&& [visible isKindOfClass: [NSArray class]] == YES)
if (visibleWindows != nil)
{
unsigned pos = [visible count];
unsigned pos = [visibleWindows count];
while (pos-- > 0)
{
NSWindow *win = [visible objectAtIndex: pos];
NSWindow *win = [visibleWindows objectAtIndex: pos];
if ([NSApp isActive])
[win orderFront: self];
else
@ -331,36 +325,17 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
}
}
- (NSMutableArray*) connections
{
return connections;
}
- (void) dealloc
{
RELEASE(nameTable);
RELEASE(connections);
RELEASE(topLevelObjects);
RELEASE(visibleWindows);
RELEASE(deferredWindows);
RELEASE(customClasses);
[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
{
if ((self = [super init]) != nil)
@ -368,20 +343,89 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
nameTable = [[NSMutableDictionary alloc] initWithCapacity: 8];
connections = [[NSMutableArray 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;
}
- (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
{
int version = [aCoder versionForClassName: @"GSNibContainer"];
// save the version to the ivar, we need it later.
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: &connections];
[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)
{
@ -409,11 +453,25 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
[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
{
[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;
@ -428,6 +486,26 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
{
return topLevelObjects;
}
- (NSMutableArray*) connections
{
return connections;
}
- (NSMutableArray*) visibleWindows
{
return visibleWindows;
}
- (NSMutableArray*) deferredWindows
{
return visibleWindows;
}
- (NSMutableDictionary *) customClasses
{
return customClasses;
}
@end
// 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
{
GSNOSUPERDEALLOC;
}
/**
@ -644,7 +645,7 @@ static NSString *disabledName = @".GNUstepDisabled";
unsigned i, j;
unsigned es = [sendTypes count];
unsigned er = [returnTypes count];
NSWindow *resp = [[_application keyWindow] firstResponder];
NSResponder *resp = [[_application keyWindow] firstResponder];
id obj = nil;
for (i = 0; i <= es; i++)
@ -1267,7 +1268,7 @@ static NSString *disabledName = @".GNUstepDisabled";
unsigned i, j;
unsigned es = [sendTypes 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

View file

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

View file

@ -722,118 +722,248 @@
int i;
[super encodeWithCoder: aCoder];
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: _jails[i]];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]];
[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]];
}
}
[aCoder encodeValueOfObjCType: @encode(float) at: &_minXBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxXBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minYBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxYBorder];
for (i = 0; i < _numberOfColumns; i++)
else
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_columnDimension[i]];
[aCoder encodeValueOfObjCType: @encode(float)
at: &_minColumnDimension[i]];
}
for (i = 0; i < _numberOfRows; i++)
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_rowDimension[i]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
{
[aCoder encodeObject: _jails[i]];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]];
}
[aCoder encodeValueOfObjCType: @encode(float) at: &_minXBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxXBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minYBorder];
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxYBorder];
for (i = 0; i < _numberOfColumns; i++)
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_columnDimension[i]];
[aCoder encodeValueOfObjCType: @encode(float)
at: &_minColumnDimension[i]];
}
for (i = 0; i < _numberOfRows; i++)
{
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_rowDimension[i]];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
}
}
}
-(id) initWithCoder: (NSCoder*)aDecoder
{
int i;
[super initWithCoder: aDecoder];
[super setAutoresizesSubviews: NO];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
//
_jails = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (NSView *)
* (_numberOfRows * _numberOfColumns));
_havePrisoner = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL)
* (_numberOfRows * _numberOfColumns));
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
if([aDecoder allowsKeyedCoding])
{
_jails[i] = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]];
}
_numberOfRows = [aDecoder decodeIntForKey: @"GSNumberOfRows"];
_numberOfColumns = [aDecoder decodeIntForKey: @"GSNumberOfColumns"];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minXBorder];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxXBorder];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minYBorder];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxYBorder];
// 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++)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]];
if (_expandColumn[i])
_expandingColumnNumber++;
[aDecoder decodeValueOfObjCType: @encode(float) at: &_columnDimension[i]];
[aDecoder decodeValueOfObjCType: @encode(float)
at: &_minColumnDimension[i]];
_minimumSize.width += _minColumnDimension[i];
}
_minimumSize.width += _maxXBorder;
// Calculate column origins
_columnXOrigin = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfColumns);
_columnXOrigin[0] = _minXBorder;
for (i = 1; i < _numberOfColumns; i++)
_columnXOrigin[i] = _columnXOrigin[i - 1] + _columnDimension[i - 1];
// Rows
_expandRow = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL) * _numberOfRows);
_rowDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_minRowDimension = NSZoneMalloc (NSDefaultMallocZone (),
// 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);
_minimumSize.height += _minYBorder;
for (i = 0; i < _numberOfRows; i++)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]];
if (_expandRow[i])
_expandingRowNumber++;
[aDecoder decodeValueOfObjCType: @encode(float) at: &_rowDimension[i]];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
_minimumSize.height += _minRowDimension[i];
_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: &_numberOfColumns];
//
_jails = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (NSView *)
* (_numberOfRows * _numberOfColumns));
_havePrisoner = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL)
* (_numberOfRows * _numberOfColumns));
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
{
_jails[i] = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]];
}
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minXBorder];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxXBorder];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minYBorder];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxYBorder];
// We compute _minimumSize, _expandingRowNumber
// and _expandingColumnNumber during deconding.
_minimumSize = NSZeroSize;
_expandingRowNumber = 0;
_expandingColumnNumber = 0;
// Columns
_expandColumn = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL) * _numberOfColumns);
_columnDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfColumns);
_minColumnDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfColumns);
_minimumSize.width += _minXBorder;
for (i = 0; i < _numberOfColumns; i++)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]];
if (_expandColumn[i])
_expandingColumnNumber++;
[aDecoder decodeValueOfObjCType: @encode(float) at: &_columnDimension[i]];
[aDecoder decodeValueOfObjCType: @encode(float)
at: &_minColumnDimension[i]];
_minimumSize.width += _minColumnDimension[i];
}
_minimumSize.width += _maxXBorder;
// Calculate column origins
_columnXOrigin = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfColumns);
_columnXOrigin[0] = _minXBorder;
for (i = 1; i < _numberOfColumns; i++)
_columnXOrigin[i] = _columnXOrigin[i - 1] + _columnDimension[i - 1];
// Rows
_expandRow = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (BOOL) * _numberOfRows);
_rowDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_minRowDimension = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_minimumSize.height += _minYBorder;
for (i = 0; i < _numberOfRows; i++)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]];
if (_expandRow[i])
_expandingRowNumber++;
[aDecoder decodeValueOfObjCType: @encode(float) at: &_rowDimension[i]];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
_minimumSize.height += _minRowDimension[i];
}
_minimumSize.height += _maxYBorder;
// Calculate row origins
_rowYOrigin = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_rowYOrigin[0] = _minYBorder;
for (i = 1; i < _numberOfRows; i++)
_rowYOrigin[i] = _rowYOrigin[i - 1] + _rowDimension[i - 1];
}
_minimumSize.height += _maxYBorder;
// Calculate row origins
_rowYOrigin = NSZoneMalloc (NSDefaultMallocZone (),
sizeof (float) * _numberOfRows);
_rowYOrigin[0] = _minYBorder;
for (i = 1; i < _numberOfRows; i++)
_rowYOrigin[i] = _rowYOrigin[i - 1] + _rowDimension[i - 1];
return self;
}

View file

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

View file

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

View file

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

View file

@ -285,11 +285,21 @@ static Class controlClass;
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
[aCoder encodeValueOfObjCType: @encode(int) at: &_tag];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
// This is only encoded for backward compatibility and won't be decoded.
[aCoder encodeConditionalObject: nil];
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 encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
// This is only encoded for backward compatibility and won't be decoded.
[aCoder encodeConditionalObject: nil];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder

View file

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

View file

@ -1829,19 +1829,9 @@ See -runModalForWindow:
case NSKeyDown:
{
NSArray *window_list = [self windows];
unsigned count = [window_list count];
unsigned i;
NSDebugLLog(@"NSEvent", @"send key down event\n");
for (i = 0; i < count; i++)
{
NSWindow *window = [window_list objectAtIndex: i];
if ([window performKeyEquivalent: theEvent] == YES)
break;
}
if (i == count)
if ([[self mainMenu] performKeyEquivalent: theEvent] == NO
&& [[self keyWindow] performKeyEquivalent: theEvent] == NO)
{
[[theEvent window] sendEvent: theEvent];
}
@ -3302,10 +3292,23 @@ image.</p><p>See Also: -applicationIconImage</p>
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
[aCoder encodeConditionalObject: _delegate];
[aCoder encodeObject: _main_menu];
[aCoder encodeConditionalObject: _windows_menu];
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 encodeObject: _main_menu];
[aCoder encodeConditionalObject: _windows_menu];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -3313,13 +3316,29 @@ image.</p><p>See Also: -applicationIconImage</p>
id obj;
[super initWithCoder: aDecoder];
obj = [aDecoder decodeObject];
[self setDelegate: obj];
obj = [aDecoder decodeObject];
[self setMainMenu: obj];
obj = [aDecoder decodeObject];
[self setWindowsMenu: obj];
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];
[self setDelegate: obj];
obj = [aDecoder decodeObject];
[self setMainMenu: obj];
obj = [aDecoder decodeObject];
[self setWindowsMenu: obj];
}
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.points[0] = aPoint;
elem.points[1] = NSZeroPoint;
elem.points[2] = NSZeroPoint;
GSIArrayAddItem(pathElements, (GSIArrayItem)elem);
INVALIDATE_CACHE();
}
@ -1849,6 +1851,8 @@ static NSPoint point_on_curve(double t, NSPoint a, NSPoint b, NSPoint c,
elem.type = NSLineToBezierPathElement;
elem.points[0] = aPoint;
elem.points[1] = NSZeroPoint;
elem.points[2] = NSZeroPoint;
GSIArrayAddItem(pathElements, (GSIArrayItem)elem);
INVALIDATE_CACHE();
}
@ -1874,6 +1878,9 @@ static NSPoint point_on_curve(double t, NSPoint a, NSPoint b, NSPoint c,
PathElement elem;
elem.type = NSClosePathBezierPathElement;
elem.points[0] = NSZeroPoint;
elem.points[1] = NSZeroPoint;
elem.points[2] = NSZeroPoint;
GSIArrayAddItem(pathElements, (GSIArrayItem)elem);
INVALIDATE_CACHE();
}

View file

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

View file

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

View file

@ -479,12 +479,24 @@
{
[super encodeWithCoder: aCoder];
[aCoder encodeObject: _cell];
[aCoder encodeSize: _offsets];
[aCoder encodeValueOfObjCType: @encode(NSBorderType) at: &_border_type];
[aCoder encodeValueOfObjCType: @encode(NSTitlePosition) at: &_title_position];
// NB: the content view is our (only) subview, so it is already
// encoded by NSView.
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 encodeSize: _offsets];
[aCoder encodeValueOfObjCType: @encode(NSBorderType) at: &_border_type];
[aCoder encodeValueOfObjCType: @encode(NSTitlePosition) at: &_title_position];
// NB: the content view is our (only) subview, so it is already
// encoded by NSView.
}
}
- (id) initWithCoder: (NSCoder*)aDecoder

View file

@ -152,30 +152,43 @@ static NSTextFieldCell *titleCell;
- (void) encodeWithCoder: (NSCoder *)aCoder
{
int dummy = 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aCoder encodeObject: _columnScrollView];
[aCoder encodeObject: _columnMatrix];
[aCoder encodeValueOfObjCType: @encode(int) at: &dummy];
[aCoder encodeObject: _columnTitle];
if([aCoder allowsKeyedCoding])
{
}
else
{
int dummy = 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aCoder encodeObject: _columnScrollView];
[aCoder encodeObject: _columnMatrix];
[aCoder encodeValueOfObjCType: @encode(int) at: &dummy];
[aCoder encodeObject: _columnTitle];
}
}
- (id) initWithCoder: (NSCoder *)aDecoder
{
int dummy = 0;
if([aDecoder allowsKeyedCoding])
{
}
else
{
int dummy = 0;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
_columnScrollView = [aDecoder decodeObject];
if (_columnScrollView)
RETAIN(_columnScrollView);
_columnMatrix = [aDecoder decodeObject];
if (_columnMatrix)
RETAIN(_columnMatrix);
[aDecoder decodeValueOfObjCType: @encode(int) at: &dummy];
_columnTitle = [aDecoder decodeObject];
if (_columnTitle)
RETAIN(_columnTitle);
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
_columnScrollView = [aDecoder decodeObject];
if (_columnScrollView)
RETAIN(_columnScrollView);
_columnMatrix = [aDecoder decodeObject];
if (_columnMatrix)
RETAIN(_columnMatrix);
[aDecoder decodeValueOfObjCType: @encode(int) at: &dummy];
_columnTitle = [aDecoder decodeObject];
if (_columnTitle)
RETAIN(_columnTitle);
}
return self;
}
@ -2488,65 +2501,156 @@ static NSTextFieldCell *titleCell;
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
long flags = 0;
// Here to keep compatibility with old version
[aCoder encodeObject: nil];
[aCoder encodeObject:_browserCellPrototype];
[aCoder encodeObject: NSStringFromClass (_browserMatrixClass)];
//
// 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"];
[aCoder encodeObject:_pathSeparator];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsBranchSelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsEmptySelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsMultipleSelection];
[aCoder encodeValueOfObjCType: @encode(int) at: &_maxVisibleColumns];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minColumnWidth];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_reusesColumns];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_separatesColumns];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_takesTitleFromPreviousColumn];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isTitled];
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 encodeObject:_horizontalScroller];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_hasHorizontalScroller];
[aCoder encodeRect: _scrollerRect];
[aCoder encodeSize: _columnSize];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsAlphaNumericalKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnAlphaNumericalKeys];
[aCoder encodeConditionalObject:_browserDelegate];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_doubleAction];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
[aCoder encodeObject: _browserColumns];
// Just encode the number of columns and the first visible
// and rebuild the browser columns on the decoding side
{
int colCount = [_browserColumns count];
[aCoder encodeValueOfObjCType: @encode(int) at: &colCount];
[aCoder encodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn];
}
[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
[aCoder encodeObject: nil];
[aCoder encodeObject:_browserCellPrototype];
[aCoder encodeObject: NSStringFromClass (_browserMatrixClass)];
[aCoder encodeObject:_pathSeparator];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsBranchSelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsEmptySelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsMultipleSelection];
[aCoder encodeValueOfObjCType: @encode(int) at: &_maxVisibleColumns];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minColumnWidth];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_reusesColumns];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_separatesColumns];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_takesTitleFromPreviousColumn];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isTitled];
[aCoder encodeObject:_horizontalScroller];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_hasHorizontalScroller];
[aCoder encodeRect: _scrollerRect];
[aCoder encodeSize: _columnSize];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsAlphaNumericalKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnAlphaNumericalKeys];
[aCoder encodeConditionalObject:_browserDelegate];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_doubleAction];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
[aCoder encodeObject: _browserColumns];
// Just encode the number of columns and the first visible
// and rebuild the browser columns on the decoding side
{
int colCount = [_browserColumns count];
[aCoder encodeValueOfObjCType: @encode(int) at: &colCount];
[aCoder encodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn];
}
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
self = [super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding])
{
NSCell *proto = [aDecoder decodeObjectForKey: @"NSCellPrototype"];
NSString *title = [aDecoder decodeObjectForKey: @"NSFirstColumnTitle"];
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 setPathSeparator: sep];
[self setTitle: title ofColumn: 0];
@ -2555,16 +2659,16 @@ static NSTextFieldCell *titleCell;
{
flags = [aDecoder decodeIntForKey: @"NSBrFlags"];
[self setHasHorizontalScroller: (flags & 0x10000)];
[self setAllowsEmptySelection: !(flags & 0x20000)];
[self setSendsActionOnArrowKeys: (flags & 0x40000)];
[self setAcceptsArrowKeys: (flags & 0x100000)];
[self setSeparatesColumns: (flags & 0x4000000)];
[self setTakesTitleFromPreviousColumn: (flags & 0x8000000)];
[self setTitled: (flags & 0x10000000)];
[self setReusesColumns: (flags & 0x20000000)];
[self setAllowsBranchSelection: (flags & 0x40000000)];
[self setAllowsMultipleSelection: (flags & 0x80000000)];
[self setHasHorizontalScroller: ((flags & 0x10000) == 0x10000)];
[self setAllowsEmptySelection: !((flags & 0x20000) == 0x20000)];
[self setSendsActionOnArrowKeys: ((flags & 0x40000) == 0x40000)];
[self setAcceptsArrowKeys: ((flags & 0x100000) == 0x100000)];
[self setSeparatesColumns: ((flags & 0x4000000) == 0x4000000)];
[self setTakesTitleFromPreviousColumn: ((flags & 0x8000000) == 0x8000000)];
[self setTitled: ((flags & 0x10000000) == 0x10000000)];
[self setReusesColumns: ((flags & 0x20000000) == 0x20000000)];
[self setAllowsBranchSelection: ((flags & 0x40000000) == 0x40000000)];
[self setAllowsMultipleSelection: ((flags & 0x80000000) == 0x80000000)];
}
if ([aDecoder containsValueForKey: @"NSNumberOfVisibleColumns"])

View file

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

View file

@ -500,10 +500,15 @@ static id buttonCellClass = nil;
[NSControl-performClick:]
[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
{
if ([self isEnabled])
NSWindow *w = [self window];
if ([self isEnabled] && ([w worksWhenModal] || [NSApp modalWindow] == w))
{
NSString *key = [self keyEquivalent];

View file

@ -52,6 +52,7 @@
#include "AppKit/NSSound.h"
#include "AppKit/NSWindow.h"
#include "GNUstepGUI/GSDrawFunctions.h"
#include "GNUstepGUI/GSNibCompatibility.h"
#include <math.h>
@ -75,13 +76,13 @@ typedef struct _GSButtonCellFlags
unsigned int hasKeyEquiv:1;
unsigned int lastState: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 unused3:8; // alt mnemonic loc.
unsigned int unused2:8; // alt mnemonic loc.
#else
unsigned int unused3:8; // alt mnemonic loc.
unsigned int unused2:8; // alt mnemonic loc.
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 lastState:1;
unsigned int hasKeyEquiv:1;
@ -1445,25 +1446,110 @@ typedef struct _GSButtonCellFlags
*/
- (void) encodeWithCoder: (NSCoder*)aCoder
{
BOOL tmp;
// FIXME: Add new ivars
[super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
GSButtonCellFlags buttonCellFlags;
unsigned int bFlags = 0;
unsigned int bFlags2 = 0;
NSImage *image = [self image];
NSButtonImageSource *bi = nil;
[aCoder encodeObject: _keyEquivalent];
[aCoder encodeObject: _keyEquivalentFont];
[aCoder encodeObject: _altContents];
[aCoder encodeObject: _altImage];
tmp = _buttoncell_is_transparent;
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_keyEquivalentModifierMask];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_highlightsByMask];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_showAltStateMask];
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: _keyEquivalentFont];
[aCoder encodeObject: _altContents];
[aCoder encodeObject: _altImage];
tmp = _buttoncell_is_transparent;
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &tmp];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_keyEquivalentModifierMask];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_highlightsByMask];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_showAltStateMask];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -1491,36 +1577,27 @@ typedef struct _GSButtonCellFlags
if ([aDecoder containsValueForKey: @"NSButtonFlags"])
{
unsigned int bFlags = [aDecoder decodeIntForKey: @"NSButtonFlags"];
int highlights = 0;
int show_state = NSNoCellMask;
GSButtonCellFlags buttonCellFlags;
memcpy((void *)&buttonCellFlags,(void *)&bFlags,sizeof(struct _GSButtonCellFlags));
[self setTransparent: buttonCellFlags.isTransparent];
[self setBordered: buttonCellFlags.isBordered];
if (buttonCellFlags.highlightByBackground)
{
highlights |= NSChangeBackgroundCellMask;
}
if (buttonCellFlags.highlightByContents)
{
highlights |= NSContentsCellMask;
}
if (buttonCellFlags.changeBackground)
{
show_state |= NSChangeBackgroundCellMask;
}
if (buttonCellFlags.changeContents)
{
show_state |= NSContentsCellMask;
}
if (buttonCellFlags.isPushin)
{
highlights |= NSPushInCellMask;
}
[self setHighlightsBy: highlights];
[self setShowsStateBy: show_state];
[self setCellAttribute: NSPushInCell
to: buttonCellFlags.isPushin];
[self setCellAttribute: NSCellLightsByBackground
to: buttonCellFlags.highlightByBackground];
[self setCellAttribute: NSCellLightsByContents
to: buttonCellFlags.highlightByContents];
[self setCellAttribute: NSCellLightsByGray
to: buttonCellFlags.highlightByGray];
[self setCellAttribute: NSChangeBackgroundCell
to: buttonCellFlags.changeBackground];
[self setCellAttribute: NSCellChangesContents
to: buttonCellFlags.changeContents];
[self setCellAttribute: NSChangeGrayCell
to: buttonCellFlags.changeGray];
[self setImagePosition: NSImageLeft];
}
if ([aDecoder containsValueForKey: @"NSButtonFlags2"])

View file

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

View file

@ -688,30 +688,24 @@ static NSColor *shadowCol;
}
/**<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>
<p>See Also: -isBezeled -setBordered: -isBordered</p>
*/
- (void) setBezeled: (BOOL)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>
<p>See Also: -isBordered -setBezeled: -isBezeled</p>
*/
- (void) setBordered: (BOOL)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
@ -1528,6 +1522,7 @@ static NSColor *shadowCol;
NSPoint last_point = point;
BOOL done;
BOOL mouseWentUp;
unsigned periodCount = 0;
NSDebugLLog(@"NSCell", @"cell start tracking in rect %@ initial point %f %f",
NSStringFromRect(cellFrame), point.x, point.y);
@ -1557,7 +1552,6 @@ static NSColor *shadowCol;
{
NSEventType eventType;
BOOL pointIsInCell;
unsigned periodCount = 0;
theEvent = [theApp nextEventMatchingMask: event_mask
untilDate: nil
@ -2185,75 +2179,132 @@ static NSColor *shadowCol;
*/
- (void) encodeWithCoder: (NSCoder*)aCoder
{
BOOL flag;
unsigned int tmp_int;
if([aCoder allowsKeyedCoding])
{
unsigned long cFlags = 0;
unsigned int cFlags2 = 0;
[aCoder encodeObject: _contents];
[aCoder encodeObject: _cell_image];
[aCoder encodeObject: _font];
[aCoder encodeObject: _objectValue];
flag = _cell.contents_is_attributed_string;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_highlighted;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_disabled;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_editable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_rich_text;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.imports_graphics;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.shows_first_responder;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.refuses_first_responder;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.sends_action_on_end_editing;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_bordered;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_bezeled;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_scrollable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_selectable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
// This used to be is_continuous, which has been replaced.
/* Ayers 20.03.2003: But we must continue to encode it for backward
compatibility or current releases will have undefined behavior when
decoding archives (i.e. .gorm files) encoded by this version. */
flag = [self isContinuous];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.allows_mixed_state;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.wraps;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
tmp_int = _cell.text_align;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.image_position;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.entry_type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.state;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mnemonic_location];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mouse_down_flags];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
[aCoder encodeValueOfObjCType: @encode(id) at: &_formatter];
[aCoder encodeValueOfObjCType: @encode(id) at: &_menu];
[aCoder encodeValueOfObjCType: @encode(id) at: &_represented_object];
// 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;
unsigned int tmp_int;
[aCoder encodeObject: _contents];
[aCoder encodeObject: _cell_image];
[aCoder encodeObject: _font];
[aCoder encodeObject: _objectValue];
flag = _cell.contents_is_attributed_string;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_highlighted;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_disabled;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_editable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_rich_text;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.imports_graphics;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.shows_first_responder;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.refuses_first_responder;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.sends_action_on_end_editing;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_bordered;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_bezeled;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_scrollable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_selectable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
// This used to be is_continuous, which has been replaced.
/* Ayers 20.03.2003: But we must continue to encode it for backward
compatibility or current releases will have undefined behavior when
decoding archives (i.e. .gorm files) encoded by this version. */
flag = [self isContinuous];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.allows_mixed_state;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.wraps;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
tmp_int = _cell.text_align;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.image_position;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.entry_type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.state;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mnemonic_location];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mouse_down_flags];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
[aCoder encodeValueOfObjCType: @encode(id) at: &_formatter];
[aCoder encodeValueOfObjCType: @encode(id) at: &_menu];
[aCoder encodeValueOfObjCType: @encode(id) at: &_represented_object];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
if ([aDecoder allowsKeyedCoding])
{
NSString *contents = [aDecoder decodeObjectForKey: @"NSContents"];
self = [self initTextCell: contents];
id contents = [aDecoder decodeObjectForKey: @"NSContents"];
// initialize based on content...
if([contents isKindOfClass: [NSString class]])
{
self = [self initTextCell: contents];
}
else if([contents isKindOfClass: [NSImage class]])
{
self = [self initImageCell: contents];
}
else
{
self = [self init];
}
if ([aDecoder containsValueForKey: @"NSCellFlags"])
{
unsigned long cFlags;

View file

@ -799,8 +799,13 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
if ([[self subviews] count] > 0)
{
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 setDocumentView: document];
RELEASE(document);
}
}
else

View file

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

View file

@ -695,12 +695,12 @@ static GSComboWindow *gsWindow = nil;
{
if (_cell != nil)
{
NSText *textObject = nil;
NSControl *cv = [_cell controlView];
NSText *textObject = nil;
id cv = [_cell controlView];
if ([cv isKindOfClass: [NSControl class]])
{
textObject = [(NSControl *)cv currentEditor];
textObject = [(NSControl *)cv currentEditor];
}
[_cell setStringValue: [_cell _stringValueAtIndex:
@ -1654,18 +1654,26 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
{
[super encodeWithCoder: coder];
[coder encodeValueOfObjCType: @encode(id) at: &_popUpList];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_hasVerticalScroller];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_completes];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
[coder encodeValueOfObjCType: @encode(int) at: &_visibleItems];
[coder encodeValueOfObjCType: @encode(NSSize) at: &_intercellSpacing];
[coder encodeValueOfObjCType: @encode(float) at: &_itemHeight];
[coder encodeValueOfObjCType: @encode(int) at: &_selectedItem];
if (_usesDataSource == YES)
[coder encodeConditionalObject: _dataSource];
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(BOOL) at: &_usesDataSource];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_hasVerticalScroller];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_completes];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
[coder encodeValueOfObjCType: @encode(int) at: &_visibleItems];
[coder encodeValueOfObjCType: @encode(NSSize) at: &_intercellSpacing];
[coder encodeValueOfObjCType: @encode(float) at: &_itemHeight];
[coder encodeValueOfObjCType: @encode(int) at: &_selectedItem];
if (_usesDataSource == YES)
[coder encodeConditionalObject: _dataSource];
}
}
/**

View file

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

View file

@ -448,6 +448,14 @@ backgroundColorHint:(NSColor *)bg
*/
[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

View file

@ -269,79 +269,154 @@
- (void) encodeWithCoder: (NSCoder*)aCoder
{
BOOL flag = NO;
if([aCoder allowsKeyedCoding])
{
[aCoder encodeInt: linkNumber forKey: @"GSLinkNumber"];
[aCoder encodeInt: disposition forKey: @"GSUpdateMode"];
[aCoder encodeInt: updateMode forKey: @"GSLastUpdateMode"];
[aCoder encodeValueOfObjCType: @encode(int) at: &linkNumber];
[aCoder encodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder encodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder encodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder encodeObject: lastUpdateTime forKey: @"GSLastUpdateTime"];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceFilename];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceSelection];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder encodeObject: sourceApplicationName forKey: @"GSSourceApplicationName"];
[aCoder encodeObject: sourceFilename forKey: @"GSSourceFilename"];
[aCoder encodeObject: sourceSelection forKey: @"GSSourceSelection"];
[aCoder encodeObject: sourceManager forKey: @"GSSourceManager"];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationApplicationName];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationFilename];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationSelection];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &types];
// flags...
flag = _flags.appVerifies;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.canUpdateContinuously;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.isDirty;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.willOpenSource;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.willUpdate;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
[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: &disposition];
[aCoder encodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder encodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceFilename];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceSelection];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationApplicationName];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationFilename];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationSelection];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &types];
// flags...
flag = _flags.appVerifies;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.canUpdateContinuously;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.isDirty;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.willOpenSource;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.willUpdate;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
}
}
- (id) initWithCoder: (NSCoder*)aCoder
{
int version = [aCoder versionForClassName: @"NSDataLink"];
if (version == 0)
if([aCoder allowsKeyedCoding])
{
BOOL flag = NO;
id obj;
[aCoder decodeValueOfObjCType: @encode(int) at: &linkNumber];
[aCoder decodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder decodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
linkNumber = [aCoder decodeIntForKey: @"GSLinkNumber"];
disposition = [aCoder decodeIntForKey: @"GSDisposition"];
updateMode = [aCoder decodeIntForKey: @"GSUpdateMode"];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceFilename];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceSelection];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationApplicationName];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationFilename];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationSelection];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &types];
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...
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.appVerifies = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.canUpdateContinuously = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.isDirty = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willOpenSource = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willUpdate = flag;
_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
{
return nil;
int version = [aCoder versionForClassName: @"NSDataLink"];
if (version == 0)
{
BOOL flag = NO;
[aCoder decodeValueOfObjCType: @encode(int) at: &linkNumber];
[aCoder decodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder decodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceFilename];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceSelection];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationApplicationName];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationFilename];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationSelection];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &types];
// flags...
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.appVerifies = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.canUpdateContinuously = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.isDirty = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willOpenSource = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willUpdate = flag;
}
else
return nil;
}
return self;

View file

@ -333,46 +333,84 @@
{
BOOL flag = NO;
[aCoder encodeValueOfObjCType: @encode(id) at: &filename];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationLinks];
flag = _flags.areLinkOutlinesVisible;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.delegateVerifiesLinks;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.interactsWithUser;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.isEdited;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
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: &sourceLinks];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationLinks];
flag = _flags.areLinkOutlinesVisible;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.delegateVerifiesLinks;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.interactsWithUser;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.isEdited;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
}
}
- (id) initWithCoder: (NSCoder*)aCoder
{
int version = [aCoder versionForClassName: @"NSDataLinkManager"];
if (version == 0)
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);
[aCoder decodeValueOfObjCType: @encode(id) at: &filename];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationLinks];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = [aCoder decodeBoolForKey: @"GSAreLinkOutlinesVisible"];
_flags.areLinkOutlinesVisible = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = [aCoder decodeBoolForKey: @"GSDelegateVerifiesLinks"];
_flags.delegateVerifiesLinks = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = [aCoder decodeBoolForKey: @"GSInteractsWithUser"];
_flags.interactsWithUser = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = [aCoder decodeBoolForKey: @"GSIsEdited"];
_flags.isEdited = flag;
}
else
{
return nil;
int version = [aCoder versionForClassName: @"NSDataLinkManager"];
if (version == 0)
{
BOOL flag = NO;
[aCoder decodeValueOfObjCType: @encode(id) at: &filename];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationLinks];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.areLinkOutlinesVisible = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.delegateVerifiesLinks = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.interactsWithUser = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.isEdited = flag;
}
else
return nil;
}
return self;
}

View file

@ -36,6 +36,7 @@
#include "AppKit/NSView.h"
#include "AppKit/NSPopUpButton.h"
#include "AppKit/NSDocumentFrameworkPrivate.h"
#include "AppKit/NSBox.h"
#include "GSGuiPrivate.h"
@ -77,6 +78,7 @@
if ([fileTypes count])
{
[self setFileType: [fileTypes objectAtIndex: 0]];
ASSIGN(_saveType, [fileTypes objectAtIndex: 0]);
}
}
return self;
@ -145,6 +147,7 @@
RELEASE(_printInfo);
RELEASE(savePanelAccessory);
RELEASE(spaButton);
RELEASE(_saveType);
[super dealloc];
}
@ -207,7 +210,11 @@
_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
{
NSString *name = [self windowNibName];
@ -452,7 +459,17 @@
- (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
@ -467,13 +484,54 @@
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
{
// 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
@ -481,25 +539,32 @@
NSView *accessory = nil;
NSString *title;
NSString *directory;
NSArray *extensions;
NSArray *displayNames;
NSDocumentController *controller;
NSSavePanel *savePanel = [NSSavePanel savePanel];
controller = [NSDocumentController sharedDocumentController];
extensions = [controller fileExtensionsFromType:[self fileType]];
displayNames = [controller _displayNamesForClass: [self class]];
if ([self shouldRunSavePanelWithAccessoryView])
{
if (savePanelAccessory == nil)
[self _loadPanelAccessoryNib];
[self _createPanelAccessory];
[self _addItemsToSpaButtonFromArray: extensions];
[self _addItemsToSpaButtonFromArray: displayNames];
accessory = savePanelAccessory;
}
if ([extensions count] > 0)
[savePanel setRequiredFileType:[extensions objectAtIndex:0]];
if ([displayNames count] > 0)
{
NSArray *extensions = [[NSDocumentController sharedDocumentController]
fileExtensionsFromType: [self fileTypeFromLastRunSavePanel]];
if([extensions count] > 0)
{
[savePanel setRequiredFileType:[extensions objectAtIndex:0]];
}
}
switch (saveOperation)
{
@ -641,9 +706,7 @@
- (NSString *)fileTypeFromLastRunSavePanel
{
// FIXME this should return type picked on save accessory
// return [spaPopupButton title];
return [self fileType];
return _saveType;
}
- (NSDictionary *)fileAttributesToWriteToFile: (NSString *)fullDocumentPath
@ -668,54 +731,63 @@
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *backupFilename = nil;
BOOL isNativeType = [[self class] isNativeType: fileType];
if (fileName)
if (fileName && isNativeType)
{
if ([fileManager fileExistsAtPath: fileName])
NSArray *extensions = [[NSDocumentController sharedDocumentController]
fileExtensionsFromType: fileType];
if([extensions count] > 0)
{
NSString *extension = [fileName pathExtension];
NSString *extension = [extensions objectAtIndex: 0];
NSString *newFileName = [[fileName stringByDeletingPathExtension]
stringByAppendingPathExtension: extension];
backupFilename = [fileName stringByDeletingPathExtension];
backupFilename = [backupFilename stringByAppendingString:@"~"];
backupFilename = [backupFilename stringByAppendingPathExtension: extension];
/* Save panel has already asked if the user wants to replace it */
/* NSFileManager movePath: will fail if destination exists */
if ([fileManager fileExistsAtPath: backupFilename])
[fileManager removeFileAtPath: backupFilename handler: nil];
// Move or copy?
if (![fileManager movePath: fileName toPath: backupFilename handler: nil] &&
[self keepBackupFile])
{
int result = NSRunAlertPanel(_(@"File Error"),
_(@"Can't create backup file. Save anyways?"),
_(@"Save"), _(@"Cancel"), nil);
if ([fileManager fileExistsAtPath: newFileName])
{
backupFilename = [newFileName stringByDeletingPathExtension];
backupFilename = [backupFilename stringByAppendingString:@"~"];
backupFilename = [backupFilename stringByAppendingPathExtension: extension];
if (result != NSAlertDefaultReturn) return NO;
}
}
if ([self writeToFile: fileName
ofType: fileType
originalFile: backupFilename
saveOperation: saveOp])
{
if (saveOp != NSSaveToOperation)
{
[self setFileName: fileName];
[self setFileType: fileType];
[self updateChangeCount: NSChangeCleared];
/* Save panel has already asked if the user wants to replace it */
/* NSFileManager movePath: will fail if destination exists */
if ([fileManager fileExistsAtPath: backupFilename])
[fileManager removeFileAtPath: backupFilename handler: nil];
// Move or copy?
if (![fileManager movePath: newFileName toPath: backupFilename handler: nil] &&
[self keepBackupFile])
{
int result = NSRunAlertPanel(_(@"File Error"),
_(@"Can't create backup file. Save anyways?"),
_(@"Save"), _(@"Cancel"), nil);
if (result != NSAlertDefaultReturn) return NO;
}
}
// FIXME: Should set the file attributes
if (backupFilename && ![self keepBackupFile])
if ([self writeToFile: fileName
ofType: fileType
originalFile: backupFilename
saveOperation: saveOp])
{
[fileManager removeFileAtPath: backupFilename handler: nil];
if (saveOp != NSSaveToOperation)
{
[self setFileName: newFileName];
[self setFileType: fileType];
[self updateChangeCount: NSChangeCleared];
}
// FIXME: Should set the file attributes
if (backupFilename && ![self keepBackupFile])
{
[fileManager removeFileAtPath: backupFilename handler: nil];
}
return YES;
}
return YES;
}
}

View file

@ -53,6 +53,7 @@ static NSString *NSDefaultOpenDirectory = @"NSDefaultOpenDirectory";
static NSDocumentController *sharedController = nil;
#define TYPE_INFO(name) TypeInfoForName(_types, name)
#define HR_TYPE_INFO(name) TypeInfoForHumanReadableName(_types, name)
static NSDictionary *TypeInfoForName (NSArray *types, NSString *typeName)
{
@ -70,6 +71,22 @@ static NSDictionary *TypeInfoForName (NSArray *types, NSString *typeName)
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>
NSDocumentController is a class that controls a set of NSDocuments
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
cancellable: (BOOL)cancellable
{
NSString *cancelString = (cancellable)? _(@"Cancel") : nil;
NSString *cancelString = (cancellable)? ((NSString *)_(@"Cancel")) : ((NSString *)nil);
int result;
/* Probably as good a place as any to do this */
@ -601,13 +618,14 @@ static NSDictionary *TypeInfoForName (NSArray *types, NSString *typeName)
[[NSApplication sharedApplication] mainWindow]];
}
/** Returns the current directory. This method first checks if there
is a current document using the -currentDocument method. If this
returns a document and the document has a filename, this method
returns the directory this file is located in. Otherwise it
returns the directory of the most recently opened document or
the user's home directory if no document has been opened before.
*/
/**
* Returns the current directory. This method first checks if there
* is a current document using the -currentDocument method. If this
* returns a document and the document has a filename, this method
* returns the directory this file is located in. Otherwise it
* returns the directory of the most recently opened document or
* the user's home directory if no document has been opened before.
*/
- (NSString *) currentDirectory
{
NSFileManager *manager = [NSFileManager defaultManager];
@ -845,5 +863,28 @@ static NSString *NSViewerRole = @"Viewer";
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

View file

@ -26,6 +26,8 @@
*/
#include <Foundation/NSCoder.h>
#include <Foundation/NSArchiver.h>
#include <Foundation/NSKeyedArchiver.h>
#include <Foundation/NSNotification.h>
#include "AppKit/NSWindow.h"
#include "AppKit/NSView.h"
@ -291,12 +293,64 @@ static NSNotificationCenter *nc = nil;
*/
- (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
{
//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;
}

View file

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

View file

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

View file

@ -391,20 +391,29 @@ static NSColor *shadowCol;
- (void) encodeWithCoder: (NSCoder*)aCoder
{
BOOL tmp;
[super encodeWithCoder: aCoder];
tmp = _formcell_auto_title_width;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
[aCoder encodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth];
[aCoder encodeObject: _titleCell];
if([aCoder allowsKeyedCoding])
{
/*
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(float) at: &_displayedTitleWidth];
[aCoder encodeObject: _titleCell];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
BOOL tmp;
[super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding])
{
@ -423,6 +432,7 @@ static NSColor *shadowCol;
}
else
{
BOOL tmp;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
_formcell_auto_title_width = tmp;
[aDecoder decodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth];

View file

@ -26,6 +26,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSFileManager.h>
#include <Foundation/NSString.h>
@ -41,33 +42,107 @@
@implementation NSBundle (NSHelpManager)
- (NSAttributedString*) contextHelpForKey: (NSString*) key
- (NSString *)pathForHelpResource:(NSString *)fileName
{
id helpFile = nil;
NSDictionary *contextHelp =
RETAIN([NSDictionary dictionaryWithContentsOfFile:
[self pathForResource: @"Help" ofType: @"plist"]]);
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
{
NSFileManager *fm = [NSFileManager defaultManager];
NSString *dictPath = [self pathForResource: @"Help" ofType: @"plist"];
NSDictionary *contextHelp = nil;
id helpFile = nil;
if (dictPath && [fm fileExistsAtPath: dictPath])
{
contextHelp = [NSDictionary dictionaryWithContentsOfFile: dictPath];
}
if (contextHelp)
{
helpFile = [contextHelp objectForKey: key];
}
if (helpFile)
{
return [NSUnarchiver unarchiveObjectWithData:
[helpFile objectForKey: @"NSHelpRTFContents"]];
}
else
NSData *data = [helpFile objectForKey: @"NSHelpRTFContents"];
return ((data != nil) ? [NSUnarchiver unarchiveObjectWithData: data] :
nil) ;
}
else
{
helpFile = [self
pathForResource: key
ofType: @"rtf"
inDirectory: @"Help"];
return AUTORELEASE([[NSAttributedString alloc] initWithPath: (NSString *)helpFile
documentAttributes: NULL]);
}
helpFile = [self pathForHelpResource: key];
if (helpFile)
{
NSString *helpstr = [[NSAttributedString alloc] initWithPath: helpFile
documentAttributes: NULL];
return TEST_AUTORELEASE (helpstr);
}
}
return nil;
}
@ -83,22 +158,33 @@
help = [info objectForKey: @"GSHelpContentsFile"];
if (!help)
if (help == nil)
{
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)
{
NSString *file = [mb pathForResource: help ofType: @"rtf"];
if (file)
NSString *file;
if ([[help pathExtension] length] == 0)
{
[[NSWorkspace sharedWorkspace] openFile: file];
return;
}
file = [mb pathForHelpResource: [help stringByAppendingPathExtension: @"rtfd"]];
if (file == nil)
{
file = [mb pathForHelpResource: [help stringByAppendingPathExtension: @"rtf"]];
}
}
if (file) {
[[NSWorkspace sharedWorkspace] openFile: file];
return;
}
}
NSBeep();
}
@ -198,6 +284,15 @@ static BOOL _gnu_contextHelpActive = NO;
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
{
NSMapInsert(contextHelpTopics, object, help);
@ -205,7 +300,7 @@ static BOOL _gnu_contextHelpActive = NO;
- (BOOL) showContextHelpForObject: (id)object locationHint: (NSPoint) point
{
id contextHelp = [self contextHelpForObject: object];
NSAttributedString *contextHelp = [self contextHelpForObject: object];
if (contextHelp)
{

View file

@ -127,6 +127,7 @@ BOOL NSImageForceCaching = NO; /* use on missmatch */
TEST_RELEASE(rep);
TEST_RELEASE(bg);
NSDeallocateObject(self);
GSNOSUPERDEALLOC;
}
@end
@ -1478,63 +1479,95 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
{
BOOL flag;
flag = _flags.archiveByName;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
if (flag == YES)
if([coder allowsKeyedCoding])
{
// FIXME: Not sure this is the way it goes...
/*
* System image - just encode the name.
*/
[coder encodeValueOfObjCType: @encode(id) at: &_name];
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
{
NSMutableArray *a;
NSEnumerator *e;
NSImageRep *r;
/*
* Normal image - encode the ivars
*/
[coder encodeValueOfObjCType: @encode(NSSize) at: &_size];
[coder encodeValueOfObjCType: @encode(id) at: &_color];
flag = _flags.scalable;
flag = _flags.archiveByName;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.dataRetained;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.flipDraw;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.sizeWasExplicitlySet;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.useEPSOnResolutionMismatch;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.colorMatchPreferred;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.multipleResolutionMatching;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.cacheSeparately;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.unboundedCacheDepth;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
// FIXME: The documentation says to archive only the file name,
// if not data retained!
/*
* Now encode an array of all the image reps (excluding cache)
*/
a = [NSMutableArray arrayWithCapacity: 2];
e = [[self representations] objectEnumerator];
while ((r = [e nextObject]) != nil)
if (flag == YES)
{
if ([r isKindOfClass: cachedClass] == NO)
{
[a addObject: r];
}
/*
* System image - just encode the name.
*/
[coder encodeValueOfObjCType: @encode(id) at: &_name];
}
else
{
NSMutableArray *a;
NSEnumerator *e;
NSImageRep *r;
/*
* Normal image - encode the ivars
*/
[coder encodeValueOfObjCType: @encode(NSSize) at: &_size];
[coder encodeValueOfObjCType: @encode(id) at: &_color];
flag = _flags.scalable;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.dataRetained;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.flipDraw;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.sizeWasExplicitlySet;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.useEPSOnResolutionMismatch;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.colorMatchPreferred;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.multipleResolutionMatching;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.cacheSeparately;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.unboundedCacheDepth;
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
// FIXME: The documentation says to archive only the file name,
// if not data retained!
/*
* Now encode an array of all the image reps (excluding cache)
*/
a = [NSMutableArray arrayWithCapacity: 2];
e = [[self representations] objectEnumerator];
while ((r = [e nextObject]) != nil)
{
if ([r isKindOfClass: cachedClass] == NO)
{
[a addObject: r];
}
}
[coder encodeValueOfObjCType: @encode(id) at: &a];
}
[coder encodeValueOfObjCType: @encode(id) at: &a];
}
}
- (id) initWithCoder: (NSCoder*)coder
{
BOOL flag;
@ -1781,7 +1814,7 @@ iterate_reps_for_types(NSArray* imageReps, SEL method)
rep = [self _cacheForRep: 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
* 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]];
}
NSDebugLLog(@"NSImage", @"Rendered rep %d on background %@",
(int)rep, repd->bg);
NSDebugLLog(@"NSImage", @"Rendered rep %p on background %@",
rep, repd->bg);
}
}

View file

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

View file

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

View file

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

View file

@ -2677,45 +2677,86 @@ static SEL getSel;
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
GSMatrixFlags matrixFlags;
unsigned int mFlags = 0;
[aCoder encodeValueOfObjCType: @encode (int) at: &_mode];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_allowsEmptySelection];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_selectionByRect];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_autosizesCells];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_autoscroll];
[aCoder encodeSize: _cellSize];
[aCoder encodeSize: _intercell];
[aCoder encodeObject: _backgroundColor];
[aCoder encodeObject: _cellBackgroundColor];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_drawsBackground];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_drawsCellBackground];
[aCoder encodeObject: NSStringFromClass (_cellClass)];
[aCoder encodeObject: _cellPrototype];
[aCoder encodeValueOfObjCType: @encode (int) at: &_numRows];
[aCoder encodeValueOfObjCType: @encode (int) at: &_numCols];
/* This is slower, but does not expose NSMatrix internals and will work
[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 (BOOL) at: &_allowsEmptySelection];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_selectionByRect];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_autosizesCells];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_autoscroll];
[aCoder encodeSize: _cellSize];
[aCoder encodeSize: _intercell];
[aCoder encodeObject: _backgroundColor];
[aCoder encodeObject: _cellBackgroundColor];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_drawsBackground];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_drawsCellBackground];
[aCoder encodeObject: NSStringFromClass (_cellClass)];
[aCoder encodeObject: _cellPrototype];
[aCoder encodeValueOfObjCType: @encode (int) at: &_numRows];
[aCoder encodeValueOfObjCType: @encode (int) at: &_numCols];
/* This is slower, but does not expose NSMatrix internals and will work
with subclasses */
[aCoder encodeObject: [self cells]];
[aCoder encodeConditionalObject: _delegate];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode (SEL) at: &_action];
[aCoder encodeValueOfObjCType: @encode (SEL) at: &_doubleAction];
[aCoder encodeValueOfObjCType: @encode (SEL) at: &_errorAction];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_tabKeyTraversesCells];
[aCoder encodeObject: [self keyCell]];
/* We do not encode information on selected cells, because this is saved
with the cells themselves */
[aCoder encodeObject: [self cells]];
[aCoder encodeConditionalObject: _delegate];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode (SEL) at: &_action];
[aCoder encodeValueOfObjCType: @encode (SEL) at: &_doubleAction];
[aCoder encodeValueOfObjCType: @encode (SEL) at: &_errorAction];
[aCoder encodeValueOfObjCType: @encode (BOOL) at: &_tabKeyTraversesCells];
[aCoder encodeObject: [self keyCell]];
/* We do not encode information on selected cells, because this is saved
with the cells themselves */
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
Class class;
id cell;
int rows, columns;
int rows = 0, columns = 0;
NSArray *array;
int i, count;
int i = 0, count = 0;
[super initWithCoder: aDecoder];
@ -2774,6 +2815,7 @@ static SEL getSel;
[self setSelectionByRect: matrixFlags.selectionByRect];
[self setDrawsCellBackground: matrixFlags.drawCellBackground];
[self setDrawsBackground: matrixFlags.drawBackground];
_autosizesCells = matrixFlags.autosizesCells;
_tabKeyTraversesCells = matrixFlags.tabKeyTraversesCells;
}
if ([aDecoder containsValueForKey: @"NSNumCols"])

View file

@ -1213,9 +1213,23 @@ static NSNotificationCenter *nc;
*/
- (void) encodeWithCoder: (NSCoder*)encoder
{
[encoder encodeObject: _title];
[encoder encodeObject: _items];
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_autoenable];
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: _items];
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_autoenable];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -163,12 +163,20 @@
BOOL flag;
[super encodeWithCoder: aCoder];
flag = _becomesKeyOnlyIfNeeded;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _isFloatingPanel;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _worksWhenModal;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
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;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _isFloatingPanel;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _worksWhenModal;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -176,12 +184,20 @@
BOOL flag;
[super initWithCoder: aDecoder];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setBecomesKeyOnlyIfNeeded: flag];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setFloatingPanel: flag];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setWorksWhenModal: flag];
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];
[self setBecomesKeyOnlyIfNeeded: flag];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setFloatingPanel: flag];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
[self setWorksWhenModal: flag];
}
return self;
}

View file

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

View file

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

View file

@ -958,21 +958,36 @@ static NSImage *_pbc_image[2];
//
- (void) encodeWithCoder: (NSCoder*)aCoder
{
int flag;
[super encodeWithCoder: aCoder];
[aCoder encodeObject: _menu];
[aCoder encodeConditionalObject: [self selectedItem]];
flag = _pbcFlags.pullsDown;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.preferredEdge;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.usesItemFromMenu;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.altersStateOfSelectedItem;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.arrowPosition;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
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 encodeConditionalObject: [self selectedItem]];
flag = _pbcFlags.pullsDown;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.preferredEdge;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.usesItemFromMenu;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.altersStateOfSelectedItem;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.arrowPosition;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -980,7 +995,6 @@ static NSImage *_pbc_image[2];
NSMenu *menu;
self = [super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding])
{
if ([aDecoder containsValueForKey: @"NSAltersState"])

View file

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

View file

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

View file

@ -28,6 +28,7 @@
#include "AppKit/NSGraphics.h"
#include "AppKit/NSWindow.h"
#include "GNUstepGUI/GSDrawFunctions.h"
#include "GNUstepGUI/GSNibCompatibility.h"
@implementation NSProgressIndicator
@ -289,14 +290,44 @@ static NSColor *fillColour = nil;
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isIndeterminate];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isBezeled];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_usesThreadedAnimation];
[aCoder encodeValueOfObjCType: @encode(NSTimeInterval) at:&_animationDelay];
[aCoder encodeValueOfObjCType: @encode(double) at:&_doubleValue];
[aCoder encodeValueOfObjCType: @encode(double) at:&_minValue];
[aCoder encodeValueOfObjCType: @encode(double) at:&_maxValue];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isVertical];
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:&_isBezeled];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_usesThreadedAnimation];
[aCoder encodeValueOfObjCType: @encode(NSTimeInterval) at:&_animationDelay];
[aCoder encodeValueOfObjCType: @encode(double) at:&_doubleValue];
[aCoder encodeValueOfObjCType: @encode(double) at:&_minValue];
[aCoder encodeValueOfObjCType: @encode(double) at:&_maxValue];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&_isVertical];
}
}
- (id)initWithCoder:(NSCoder *)aDecoder
@ -304,18 +335,47 @@ static NSColor *fillColour = nil;
self = [super initWithCoder:aDecoder];
if ([aDecoder allowsKeyedCoding])
{
//id *matrix = [aDecoder decodeObjectForKey: @"NSDrawMatrix"];
// id matrix = [aDecoder decodeObjectForKey: @"NSDrawMatrix"];
if ([aDecoder containsValueForKey: @"NSMaxValue"])
{
int max = [aDecoder decodeIntForKey: @"NSMaxValue"];
int max = [aDecoder decodeDoubleForKey: @"NSMaxValue"];
[self setMaxValue: max];
}
if ([aDecoder containsValueForKey: @"NSMinValue"])
{
int min = [aDecoder decodeDoubleForKey: @"NSMinValue"];
[self setMinValue: min];
}
if ([aDecoder containsValueForKey: @"NSpiFlags"])
{
//int flags = [aDecoder decodeIntForKey: @"NSpiFlags"];
// FIXME
int flags = [aDecoder decodeIntForKey: @"NSpiFlags"];
_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
@ -348,3 +408,4 @@ static NSColor *fillColour = nil;
}
@end

View file

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

View file

@ -1220,6 +1220,27 @@ static float scrollerWidth;
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
{
@ -1268,6 +1289,12 @@ static float scrollerWidth;
NSScroller *vScroller = [aDecoder decodeObjectForKey: @"NSVScroller"];
NSClipView *content = [aDecoder decodeObjectForKey: @"NSContentView"];
_hLineScroll = 10;
_hPageScroll = 10;
_vLineScroll = 10;
_vPageScroll = 10;
_scrollsDynamically = YES;
if ([aDecoder containsValueForKey: @"NSsFlags"])
{
unsigned long flags = [aDecoder decodeIntForKey: @"NSsFlags"];
@ -1304,7 +1331,7 @@ static float scrollerWidth;
RETAIN(content);
[self setContentView: content];
RELEASE(content);
_contentView = content;
ASSIGN(_contentView, content);
}
if (hScroller != nil && _hasHorizScroller)

View file

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

View file

@ -30,62 +30,6 @@
#include "AppKit/NSSlider.h"
#include "AppKit/NSSliderCell.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>
@ -361,109 +305,4 @@ static Class cellClass;
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

View file

@ -29,15 +29,72 @@
#include <Foundation/NSString.h>
#include <Foundation/NSException.h>
#include "AppKit/NSSliderCell.h"
#include "AppKit/NSApplication.h"
#include "AppKit/NSColor.h"
#include "AppKit/NSGraphics.h"
#include "AppKit/NSControl.h"
#include "AppKit/NSEvent.h"
#include "AppKit/NSGraphics.h"
#include "AppKit/NSImage.h"
#include "AppKit/NSSliderCell.h"
#include "AppKit/NSTextFieldCell.h"
#include "AppKit/NSWindow.h"
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>
<heading>Class Description</heading>
@ -561,6 +618,112 @@ DEFINE_RINT_IF_MISSING
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
{
self = [super initWithCoder: decoder];
@ -580,9 +743,10 @@ DEFINE_RINT_IF_MISSING
[_titleCell setStringValue: @""];
[_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 setBezeled: YES];
[self setBezeled: NO];
_isVertical = -1;
}

View file

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

View file

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

View file

@ -927,6 +927,13 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
{
[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
{

View file

@ -29,7 +29,6 @@
#include <Foundation/NSException.h>
#include "AppKit/NSStepper.h"
#include "AppKit/NSControl.h"
#include "AppKit/NSColor.h"
#include "AppKit/NSEvent.h"
#include "AppKit/NSWindow.h"
#include "AppKit/NSApplication.h"
@ -71,11 +70,6 @@ id _nsstepperCellClass = nil;
// Instance methods
//
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
{
return YES;
}
//
// Determining the first responder
//
@ -97,18 +91,8 @@ id _nsstepperCellClass = nil;
- (void) keyDown: (NSEvent*)theEvent
{
}
- (void) encodeWithCoder: (NSCoder *)aCoder
{
[super encodeWithCoder: aCoder];
}
- (id) initWithCoder: (NSCoder *)aDecoder
{
[super initWithCoder: aDecoder];
return self;
// FIXME
[super keyDown: theEvent];
}
- (double) maxValue
@ -141,8 +125,6 @@ id _nsstepperCellClass = nil;
[_cell setIncrement: increment];
}
- (BOOL)autorepeat
{
return [_cell autorepeat];
@ -163,199 +145,4 @@ id _nsstepperCellClass = nil;
[_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

View file

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

View file

@ -208,13 +208,24 @@
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[aCoder encodeObject:_ident];
[aCoder encodeObject:_label];
[aCoder encodeObject:_view];
[aCoder encodeObject:_color];
[aCoder encodeValueOfObjCType: @encode(NSTabState) at: &_state];
[aCoder encodeObject:_first_responder];
[aCoder encodeObject:_tabview];
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:_label];
[aCoder encodeObject:_view];
[aCoder encodeObject:_color];
[aCoder encodeValueOfObjCType: @encode(NSTabState) at: &_state];
[aCoder encodeObject:_first_responder];
[aCoder encodeObject:_tabview];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder

View file

@ -370,16 +370,30 @@
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[aCoder encodeObject: _identifier];
[aCoder encodeValueOfObjCType: @encode(float) at: &_width];
[aCoder encodeValueOfObjCType: @encode(float) at: &_min_width];
[aCoder encodeValueOfObjCType: @encode(float) at: &_max_width];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_resizable];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_editable];
[aCoder encodeObject: _headerCell];
[aCoder encodeObject: _dataCell];
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 encodeValueOfObjCType: @encode(float) at: &_width];
[aCoder encodeValueOfObjCType: @encode(float) at: &_min_width];
[aCoder encodeValueOfObjCType: @encode(float) at: &_max_width];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_resizable];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_editable];
[aCoder encodeObject: _headerCell];
[aCoder encodeObject: _dataCell];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder

View file

@ -4002,26 +4002,11 @@ static inline float computePeriod(NSPoint mouseLocationWin,
lastColumn = [_tableColumns objectAtIndex: (_numberOfColumns - 1)];
if ([lastColumn isResizable] == NO)
return;
excess_width = NSMaxX ([self convertRect: [_super_view bounds]
fromView: _super_view]);
excess_width -= NSMaxX (_bounds);
last_column_width = [lastColumn width];
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];
}
_tilingDisabled = NO;
[self tile];
excess_width = NSMaxX([self convertRect: [_super_view bounds]
fromView: _super_view]) - NSMaxX(_bounds);
last_column_width = [lastColumn width] + excess_width;
// This will automatically retile the table
[lastColumn setWidth: last_column_width];
}
}
@ -5136,48 +5121,63 @@ static inline float computePeriod(NSPoint mouseLocationWin,
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
if ([aCoder allowsKeyedCoding])
{
unsigned int vFlags = 0; // (raw >> 26); // filter out settings not pertinent to us.
unsigned long vFlags = 0;
NSSize intercellSpacing = [self intercellSpacing];
GSTableViewFlags tableViewFlags;
// make sure the corner view is properly encoded...
[super encodeWithCoder: aCoder];
if([self dataSource])
{
[aCoder encodeObject: [self dataSource] forKey: @"NSDataSource"];
}
if([self delegate])
{
[aCoder encodeObject: [self delegate] forKey: @"NSDelegate"];
}
if([self target])
{
[aCoder encodeObject: [self target] forKey: @"NSTarget"];
}
if([self action])
{
[aCoder encodeObject: NSStringFromSelector([self action]) forKey: @"NSAction"];
}
[aCoder encodeObject: [self dataSource] forKey: @"NSDataSource"];
[aCoder encodeObject: [self delegate] forKey: @"NSDelegate"];
[aCoder encodeObject: [self target] forKey: @"NSTarget"];
[aCoder encodeObject: NSStringFromSelector([self action]) forKey: @"NSAction"];
[aCoder encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"];
[aCoder encodeObject: [self gridColor] forKey: @"NSGridColor"];
[aCoder encodeFloat: intercellSpacing.height forKey: @"NSIntercellSpacingHeight"];
[aCoder encodeFloat: intercellSpacing.width forKey: @"NSIntercellSpacingWidth"];
[aCoder encodeFloat: [self rowHeight] forKey: @"NSRowHeight"];
[aCoder encodeObject: [self tableColumns] forKey: @"NSTableColumns"];
if(_headerView)
{
[aCoder encodeObject: _headerView forKey: @"NSHeaderView"];
}
if(_cornerView)
{
[aCoder encodeObject: _cornerView forKey: @"NSCornerView"];
}
tableViewFlags.columnSelection = [self allowsColumnSelection];
tableViewFlags.multipleSelection = [self allowsMultipleSelection];
tableViewFlags.emptySelection = [self allowsEmptySelection];
tableViewFlags.drawsGrid = [self drawsGrid];
tableViewFlags.columnResizing = [self allowsColumnResizing];
tableViewFlags.columnOrdering = [self allowsColumnReordering];
if([self allowsColumnSelection])
vFlags |= 1;
if([self allowsMultipleSelection])
vFlags |= 2;
if([self allowsEmptySelection])
vFlags |= 4;
if([self allowsColumnResizing])
vFlags |= 16;
if([self allowsColumnReordering])
vFlags |= 32;
// shift...
vFlags = vFlags << 26;
vFlags |= 0x2400000; // add the constant...
memcpy((void *)&vFlags,(void *)&tableViewFlags,sizeof(unsigned long));
// encode..
[aCoder encodeInt: vFlags forKey: @"NSTvFlags"];
}
else
{
[super encodeWithCoder: aCoder];
[aCoder encodeConditionalObject: _dataSource];
[aCoder encodeObject: _tableColumns];
[aCoder encodeObject: _gridColor];
@ -5215,6 +5215,32 @@ static inline float computePeriod(NSPoint mouseLocationWin,
NSEnumerator *e;
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"];
if ([aDecoder containsValueForKey: @"NSDataSource"])
{
@ -5254,16 +5280,7 @@ static inline float computePeriod(NSPoint mouseLocationWin,
{
[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"])
{
NSRect viewFrame;
@ -5275,6 +5292,16 @@ static inline float computePeriod(NSPoint mouseLocationWin,
[[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...
columns = [aDecoder decodeObjectForKey: @"NSTableColumns"];
e = [columns objectEnumerator];
@ -5305,14 +5332,6 @@ static inline float computePeriod(NSPoint mouseLocationWin,
_columnOrigins = NSZoneMalloc (NSDefaultMallocZone (),
sizeof(float) * _numberOfColumns);
_clickedRow = -1;
_clickedColumn = -1;
_selectingColumns = NO;
_selectedColumn = -1;
_selectedRow = -1;
_editedColumn = -1;
_editedRow = -1;
[self tile];
}
else
@ -5334,6 +5353,7 @@ static inline float computePeriod(NSPoint mouseLocationWin,
[_headerView setTableView: self];
[_tableColumns makeObjectsPerformSelector: @selector(setTableView:)
withObject: self];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_drawsGrid];

View file

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

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 */

View file

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

View file

@ -353,4 +353,17 @@ static NSNotificationCenter *nc = nil;
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

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@
Author: Felipe A. Rodriguez <far@ix.netcom.com>
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
Author: Fred Kiefer <FredKiefer@gmx.de>
@ -111,7 +111,6 @@ send -shouldChangeTextInRange:replacementString: or -didChangeText.
*/
/** First some helpers **/
@interface NSTextView (user_action_helpers)
@ -120,7 +119,7 @@ send -shouldChangeTextInRange:replacementString: or -didChangeText.
-(void) _changeAttribute: (NSString *)name
inRange: (NSRange)r
using: (id (*)(id))func;
using: (NSNumber*(*)(NSNumber*))func;
@end
@ -164,7 +163,7 @@ send -shouldChangeTextInRange:replacementString: or -didChangeText.
- (void) _changeAttribute: (NSString *)name
inRange: (NSRange)r
using: (id (*)(id))func
using: (NSNumber*(*)(NSNumber*))func
{
unsigned int i;
NSRange e, r2;
@ -624,6 +623,62 @@ static NSNumber *float_plus_one(NSNumber *cur)
[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

View file

@ -536,7 +536,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
NSAttributedString *attrString;
NSDictionary *attr;
NSColor *color;
NSMutableParagraphStyle *pStyle = [NSMutableParagraphStyle defaultParagraphStyle];
NSMutableParagraphStyle *pStyle;
NSRect titleRect;
NSRect viewBounds = [self bounds];
@ -549,12 +549,15 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
color = [NSColor disabledControlTextColor];
}
pStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[pStyle setAlignment: NSCenterTextAlignment];
// We draw the label
attr = [NSDictionary dictionaryWithObjectsAndKeys: _font,
NSFontAttributeName, color, NSForegroundColorAttributeName, pStyle,
NSParagraphStyleAttributeName, nil];
RELEASE(pStyle);
attrString = [[NSAttributedString alloc]
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
{
if (_rFlags.needs_display == NO)
if (_rFlags.needs_display == YES)
{
if ([self isOpaque] == YES)
{
@ -2625,7 +2625,25 @@ Returns YES iff any scrolling was done.
{
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;
}
[_cursor_rects removeAllObjects];
@ -2638,6 +2656,7 @@ Returns YES iff any scrolling was done.
id e = [_cursor_rects objectEnumerator];
GSTrackingRect *o;
NSCursor *c;
NSPoint loc = [_window mouseLocationOutsideOfEventStream];
/* Base remove test upon cursor object */
o = [e nextObject];
@ -2646,6 +2665,10 @@ Returns YES iff any scrolling was done.
c = [o owner];
if (c == anObject)
{
if (NSMouseInRect(loc, o->rectangle, NO))
{
[c mouseExited: nil];
}
[o invalidate];
[_cursor_rects removeObject: o];
if ([_cursor_rects count] == 0)
@ -3916,7 +3939,14 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[aCoder encodeInt: vFlags
forKey: @"NSvFlags"];
[aCoder encodeObject: _super_view forKey: @"NSSuperview"];
//
// Don't attempt to archive the superview of a view which is the
// content view for a window.
//
if(([[self window] contentView] != self) && _super_view != nil)
{
[aCoder encodeObject: _super_view forKey: @"NSSuperview"];
}
}
else
{
@ -3957,15 +3987,38 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
{
NSView *prevKeyView = nil;
NSView *nextKeyView = nil;
if ([aDecoder containsValueForKey: @"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"];
nextKeyView = [aDecoder decodeObjectForKey: @"NSNextKeyView"];
if (nextKeyView != nil)
@ -3986,6 +4039,30 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[self setAutoresizesSubviews: ((vFlags & 0x100) == 0x100)];
[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
{
@ -4025,27 +4102,29 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[aDecoder decodeValueOfObjCType: @encode(id) at: &subs];
NSDebugLLog(@"NSView", @"NSView: finish decoding\n");
// iterate over subviews and put them into the view...
e = [subs objectEnumerator];
while ((sub = [e nextObject]) != nil)
{
NSAssert([sub window] == nil,
NSInternalInconsistencyException);
NSAssert([sub superview] == nil,
NSInternalInconsistencyException);
[sub viewWillMoveToWindow: _window];
[sub viewWillMoveToSuperview: self];
[sub setNextResponder: self];
[_sub_views addObject: sub];
_rFlags.has_subviews = 1;
[sub resetCursorRects];
[sub setNeedsDisplay: YES];
[sub _viewDidMoveToWindow];
[sub viewDidMoveToSuperview];
[self didAddSubview: sub];
}
RELEASE(subs);
}
// iterate over subviews and put them into the view...
e = [subs objectEnumerator];
while ((sub = [e nextObject]) != nil)
{
NSAssert([sub window] == nil, NSInternalInconsistencyException);
NSAssert([sub superview] == nil, NSInternalInconsistencyException);
[sub viewWillMoveToWindow: _window];
[sub viewWillMoveToSuperview: self];
[sub setNextResponder: self];
[_sub_views addObject: sub];
_rFlags.has_subviews = 1;
[sub resetCursorRects];
[sub setNeedsDisplay: YES];
[sub _viewDidMoveToWindow];
[sub viewDidMoveToSuperview];
[self didAddSubview: sub];
}
RELEASE(subs);
return self;
}

View file

@ -1236,9 +1236,11 @@ many times.
ASSIGN(_miniaturizedImage, image);
if (_counterpart != 0 && (_styleMask & NSMiniWindowMask) == 0)
{
NSMiniWindow *mini = [NSApp windowWithWindowNumber: _counterpart];
id v = [mini contentView];
NSMiniWindow *mini;
id v;
mini = (NSMiniWindow*)[NSApp windowWithWindowNumber: _counterpart];
v = [mini contentView];
if ([v respondsToSelector: @selector(setImage:)])
{
[v setImage: [self miniwindowImage]];
@ -1251,9 +1253,11 @@ many times.
ASSIGN(_miniaturizedTitle, title);
if (_counterpart != 0 && (_styleMask & NSMiniWindowMask) == 0)
{
NSMiniWindow *mini = [NSApp windowWithWindowNumber: _counterpart];
id v = [mini contentView];
NSMiniWindow *mini;
id v;
mini = (NSMiniWindow*)[NSApp windowWithWindowNumber: _counterpart];
v = [mini contentView];
if ([v respondsToSelector: @selector(setTitle:)])
{
[v setTitle: [self miniwindowTitle]];
@ -2344,10 +2348,25 @@ discardCursorRectsForView(NSView *theView)
{
if (((NSViewPtr)aView)->_rFlags.valid_rects)
{
[((NSViewPtr)aView)->_cursor_rects
makeObjectsPerformSelector: @selector(invalidate)];
((NSViewPtr)aView)->_rFlags.valid_rects = 0;
_f.cursor_rects_valid = NO;
[aView discardCursorRects];
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;
}
}
}
@ -2383,6 +2402,26 @@ resetCursorRectsForView(NSView *theView)
[self discardCursorRects];
resetCursorRectsForView(_wv);
_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;
// 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];
[aCoder encodeRect: [[self contentView] frame]];
@ -4181,6 +4233,19 @@ resetCursorRectsForView(NSView *theView)
id oldself = self;
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)
{
NSSize aSize;

View file

@ -191,7 +191,7 @@
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
format: @"Attempt to call dealloc for shared worksapace"];
GSNOSUPERDEALLOC;
}
- (id) init
@ -1938,7 +1939,7 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
}
else
{
[inf setObject: appName forKey: (role ? role : @"Editor")];
[inf setObject: appName forKey: (role ? (id)role : (id)@"Editor")];
}
[map setObject: inf forKey: ext];
RELEASE(inf);