gdb po and -description method will return UTF8 strings

X11 socket set to non blocking
X11 font config via libfontconfig
font drawing clip fix
NSObjectController and NSArrayController -selectedObjects returns NSArray like Apple implementation
Unit test for NSObjectController
This commit is contained in:
Johannes Fortmann 2009-02-16 15:18:36 +00:00
parent d6919c0d25
commit 3226b44ae2
30 changed files with 1171 additions and 135 deletions

View File

@ -6912,6 +6912,7 @@
/Developer/Cocotron/1.0/Darwin/i386/include/X11,
/Developer/Cocotron/1.0/Darwin/i386/include/cairo,
/Developer/Cocotron/1.0/Darwin/i386/include/freetype2,
/Developer/Cocotron/1.0/Darwin/i386/include/X11/fontconfig,
);
INFOPLIST_FILE = Info.plist;
INSTALL_MODE_FLAG = "og-w,a+rX";
@ -6926,6 +6927,7 @@
"-Wreturn-type",
);
OTHER_LDFLAGS = (
/Developer/Cocotron/1.0/Darwin/i386/lib/libfontconfig.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libcairo.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libfreetype.a,
"$(OTHER_LDFLAGS_QUOTED_FOR_TARGET_1)",
@ -6933,7 +6935,6 @@
/Developer/Cocotron/1.0/Darwin/i386/lib/libX11.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libXrender.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libXext.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libfontconfig.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libexpat.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libGL.a,
"-lz",
@ -6967,6 +6968,7 @@
/Developer/Cocotron/1.0/Darwin/i386/include/X11,
/Developer/Cocotron/1.0/Darwin/i386/include/cairo,
/Developer/Cocotron/1.0/Darwin/i386/include/freetype2,
/Developer/Cocotron/1.0/Darwin/i386/include/X11/fontconfig,
);
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = /Developer/Cocotron/1.0/Darwin/i386/Frameworks;
@ -6980,6 +6982,7 @@
"-Wreturn-type",
);
OTHER_LDFLAGS = (
/Developer/Cocotron/1.0/Darwin/i386/lib/libfontconfig.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libcairo.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libfreetype.a,
"$(OTHER_LDFLAGS_QUOTED_FOR_TARGET_1)",
@ -6987,7 +6990,6 @@
/Developer/Cocotron/1.0/Darwin/i386/lib/libX11.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libXrender.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libXext.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libfontconfig.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libexpat.a,
/Developer/Cocotron/1.0/Darwin/i386/lib/libGL.a,
"-lz",

View File

@ -250,8 +250,8 @@ triggerChangeNotificationsForDependentKey:@"selectionIndex"];
{
id idxs=[self selectionIndexes];
if(idxs)
return [_NSObservableArray arrayWithArray:[[self arrangedObjects] objectsAtIndexes:idxs]];
return [_NSObservableArray array];
return [[self arrangedObjects] objectsAtIndexes:idxs];
return [NSArray array];
}
- (BOOL)setSelectedObjects:(NSArray *)objects

View File

@ -15,6 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
{
id _controller;
NSMutableDictionary *_cachedValues;
id _observableSelection;
NSMutableArray *_observationProxies;
id _cachedKeysForKVO;
}

View File

@ -14,7 +14,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/NSKeyValueObserving.h>
#import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSString+KVCAdditions.h>
#import "NSObservationProxy.h"
#import <AppKit/NSObservationProxy.h>
#import <Foundation/NSException.h>
@implementation NSControllerSelectionProxy
@ -29,11 +29,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return self;
}
-(id)observableSelection {
if(!_observableSelection)
_observableSelection = [[_NSObservableArray alloc] initWithArray:[_controller selectedObjects]];
return _observableSelection;
}
-(void)dealloc
{
[_cachedKeysForKVO release];
[_cachedValues release];
[_controller release];
[_observableSelection release];
if([_observationProxies count]>0)
[NSException raise:NSInvalidArgumentException
@ -98,7 +105,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-(void)setValue:(id)value forKey:(NSString *)key
{
[[_controller selectedObjects] setValue:value forKey:key];
[[self observableSelection] setValue:value forKey:key];
}
-(NSString*)description
@ -118,6 +125,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[self willChangeValueForKey:key];
}
[_cachedValues removeAllObjects];
[_observableSelection release];
_observableSelection=nil;
}
-(void)controllerDidChange
@ -146,7 +155,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[proxy setNotifyObject:YES];
[_observationProxies addObject:proxy];
[[_controller selectedObjects] addObserver:proxy forKeyPath:keyPath options:options context:context];
[[self observableSelection] addObserver:proxy forKeyPath:keyPath options:options context:context];
[proxy release];
}
@ -162,7 +171,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[proxy release];
if(idx!=NSNotFound) {
[[_controller selectedObjects] removeObserver:[_observationProxies objectAtIndex:idx] forKeyPath:keyPath];
[[self observableSelection] removeObserver:[_observationProxies objectAtIndex:idx] forKeyPath:keyPath];
[_observationProxies removeObjectAtIndex:idx];
}

View File

@ -73,7 +73,7 @@ triggerChangeNotificationsForDependentKey:@"contentObject"];
-(NSArray *)selectedObjects
{
return [_NSObservableArray arrayWithObject:_content];
return [NSArray arrayWithObject:_content];
}
-(id)selection

View File

@ -1,34 +1,493 @@
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
ACTIONS = {
clickFamilyMatrix = id;
clickSizeMatrix = id;
clickSizeText = id;
clickTypefaceMatrix = id;
revert = id;
set = id;
};
CLASS = NSFontPanel;
LANGUAGE = ObjC;
OUTLETS = {
"_familyMatrix" = id;
"_revertButton" = id;
"_sampleTextField" = id;
"_setButton" = id;
"_sizeMatrix" = id;
"_sizeTextField" = id;
"_typefaceMatrix" = id;
};
SUPERCLASS = NSPanel;
},
{
CLASS = Owner;
LANGUAGE = ObjC;
OUTLETS = {fontPanel = id; };
SUPERCLASS = NSObject;
}
);
IBVersion = 1;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBClasses</key>
<array>
<dict>
<key>ACTIONS</key>
<dict>
<key>selectAll</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSMatrix</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSControl</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>activateContextHelpMode</key>
<string>id</string>
<key>arrangeInFront</key>
<string>id</string>
<key>hide</key>
<string>id</string>
<key>hideOtherApplications</key>
<string>id</string>
<key>miniaturizeAll</key>
<string>id</string>
<key>orderFrontCharacterPalette</key>
<string>id</string>
<key>orderFrontColorPanel</key>
<string>id</string>
<key>orderFrontStandardAboutPanel</key>
<string>id</string>
<key>runPageLayout</key>
<string>id</string>
<key>showHelp</key>
<string>id</string>
<key>stop</key>
<string>id</string>
<key>terminate</key>
<string>id</string>
<key>unhide</key>
<string>id</string>
<key>unhideAllApplications</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSApplication</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSResponder</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSSplitView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSView</string>
</dict>
<dict>
<key>CLASS</key>
<string>Owner</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>fontPanel</key>
<string>id</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>selectText</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSTextField</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSControl</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSMenu</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>performClick</key>
<string>id</string>
<key>takeDoubleValueFrom</key>
<string>id</string>
<key>takeFloatValueFrom</key>
<string>id</string>
<key>takeIntValueFrom</key>
<string>id</string>
<key>takeObjectValueFrom</key>
<string>id</string>
<key>takeStringValueFrom</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSControl</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSView</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSScroller</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSControl</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>changeColor</key>
<string>id</string>
<key>concludeDragOperation</key>
<string>id</string>
<key>draggingExited</key>
<string>id</string>
<key>pasteboardChangedOwner</key>
<string>NSPasteboard</string>
</dict>
<key>CLASS</key>
<string>NSObject</string>
<key>LANGUAGE</key>
<string>ObjC</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>deminiaturize</key>
<string>id</string>
<key>makeKeyAndOrderFront</key>
<string>id</string>
<key>miniaturize</key>
<string>id</string>
<key>orderBack</key>
<string>id</string>
<key>orderFront</key>
<string>id</string>
<key>orderOut</key>
<string>id</string>
<key>performClose</key>
<string>id</string>
<key>performMiniaturize</key>
<string>id</string>
<key>performZoom</key>
<string>id</string>
<key>print</key>
<string>id</string>
<key>runToolbarCustomizationPalette</key>
<string>id</string>
<key>selectNextKeyView</key>
<string>id</string>
<key>selectPreviousKeyView</key>
<string>id</string>
<key>toggleToolbarShown</key>
<string>id</string>
<key>zoom</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSWindow</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSResponder</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSScrollView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSView</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSBox</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSView</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>print</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSResponder</string>
</dict>
<dict>
<key>CLASS</key>
<string>FirstResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>takeFloatValueFrom</key>
<string>id</string>
<key>takeIntValueFrom</key>
<string>id</string>
<key>takeObjectValueFrom</key>
<string>id</string>
<key>takeStringValueFrom</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSCell</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSPasteboard</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>performClick</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSButton</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSControl</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>capitalizeWord</key>
<string>id</string>
<key>centerSelectionInVisibleArea</key>
<string>id</string>
<key>changeCaseOfLetter</key>
<string>id</string>
<key>complete</key>
<string>id</string>
<key>deleteBackward</key>
<string>id</string>
<key>deleteForward</key>
<string>id</string>
<key>deleteToBeginningOfLine</key>
<string>id</string>
<key>deleteToBeginningOfParagraph</key>
<string>id</string>
<key>deleteToEndOfLine</key>
<string>id</string>
<key>deleteToEndOfParagraph</key>
<string>id</string>
<key>deleteToMark</key>
<string>id</string>
<key>deleteWordBackward</key>
<string>id</string>
<key>deleteWordForward</key>
<string>id</string>
<key>indent</key>
<string>id</string>
<key>insertBacktab</key>
<string>id</string>
<key>insertNewline</key>
<string>id</string>
<key>insertNewlineIgnoringFieldEditor</key>
<string>id</string>
<key>insertParagraphSeparator</key>
<string>id</string>
<key>insertTab</key>
<string>id</string>
<key>insertTabIgnoringFieldEditor</key>
<string>id</string>
<key>lowercaseWord</key>
<string>id</string>
<key>moveBackward</key>
<string>id</string>
<key>moveBackwardAndModifySelection</key>
<string>id</string>
<key>moveDown</key>
<string>id</string>
<key>moveDownAndModifySelection</key>
<string>id</string>
<key>moveForward</key>
<string>id</string>
<key>moveForwardAndModifySelection</key>
<string>id</string>
<key>moveLeft</key>
<string>id</string>
<key>moveLeftAndModifySelection</key>
<string>id</string>
<key>moveRight</key>
<string>id</string>
<key>moveRightAndModifySelection</key>
<string>id</string>
<key>moveToBeginningOfDocument</key>
<string>id</string>
<key>moveToBeginningOfDocumentAndModifySelection</key>
<string>id</string>
<key>moveToBeginningOfLine</key>
<string>id</string>
<key>moveToBeginningOfParagraph</key>
<string>id</string>
<key>moveToEndOfDocument</key>
<string>id</string>
<key>moveToEndOfDocumentAndModifySelection</key>
<string>id</string>
<key>moveToEndOfLine</key>
<string>id</string>
<key>moveToEndOfParagraph</key>
<string>id</string>
<key>moveUp</key>
<string>id</string>
<key>moveUpAndModifySelection</key>
<string>id</string>
<key>moveWordBackward</key>
<string>id</string>
<key>moveWordBackwardAndModifySelection</key>
<string>id</string>
<key>moveWordForward</key>
<string>id</string>
<key>moveWordForwardAndModifySelection</key>
<string>id</string>
<key>moveWordLeft</key>
<string>id</string>
<key>moveWordLeftAndModifySelection</key>
<string>id</string>
<key>moveWordRight</key>
<string>id</string>
<key>moveWordRightAndModifySelection</key>
<string>id</string>
<key>noop</key>
<string>id</string>
<key>pageDown</key>
<string>id</string>
<key>pageUp</key>
<string>id</string>
<key>scrollLineDown</key>
<string>id</string>
<key>scrollLineUp</key>
<string>id</string>
<key>scrollPageDown</key>
<string>id</string>
<key>scrollPageUp</key>
<string>id</string>
<key>selectAll</key>
<string>id</string>
<key>selectLine</key>
<string>id</string>
<key>selectParagraph</key>
<string>id</string>
<key>selectToMark</key>
<string>id</string>
<key>selectWord</key>
<string>id</string>
<key>setMark</key>
<string>id</string>
<key>swapWithMark</key>
<string>id</string>
<key>transpose</key>
<string>id</string>
<key>transposeWords</key>
<string>id</string>
<key>uppercaseWord</key>
<string>id</string>
<key>yank</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSTextFieldCell</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSActionCell</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>clickFamilyMatrix</key>
<string>id</string>
<key>clickSizeMatrix</key>
<string>id</string>
<key>clickSizeText</key>
<string>id</string>
<key>clickTypefaceMatrix</key>
<string>id</string>
<key>revert</key>
<string>id</string>
<key>set</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSFontPanel</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>_familyMatrix</key>
<string>id</string>
<key>_revertButton</key>
<string>id</string>
<key>_sampleTextField</key>
<string>id</string>
<key>_setButton</key>
<string>id</string>
<key>_sizeMatrix</key>
<string>id</string>
<key>_sizeTextField</key>
<string>id</string>
<key>_typefaceMatrix</key>
<string>id</string>
</dict>
<key>SUPERCLASS</key>
<string>NSPanel</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>performClick</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>NSButtonCell</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSActionCell</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSPanel</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSWindow</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSActionCell</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSCell</string>
</dict>
</array>
<key>IBVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,16 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>169 129 356 240 0 0 1680 1028 </string>
<key>IBFramework Version</key>
<string>446.1</string>
<string>677</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>AppKit.xcodeproj</string>
<key>IBOldestOS</key>
<integer>5</integer>
<key>IBOpenObjects</key>
<array>
<integer>5</integer>
<integer>6</integer>
</array>
<key>IBSystem Version</key>
<string>8R2232</string>
<string>9G55</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
</plist>

Binary file not shown.

View File

@ -219,6 +219,13 @@ APPKIT_EXPORT NSString *NSViewFocusDidChangeNotification;
-(BOOL)dragFile:(NSString *)path fromRect:(NSRect)rect slideBack:(BOOL)slideBack event:(NSEvent *)event;
-(NSPoint)convertPointFromBase:(NSPoint)aPoint;
-(NSPoint)convertPointToBase:(NSPoint)aPoint;
-(NSSize)convertSizeFromBase:(NSSize)aSize;
-(NSSize)convertSizeToBase:(NSSize)aSize;
-(NSRect)convertRectFromBase:(NSRect)aRect;
-(NSRect)convertRectToBase:(NSRect)aRect;
// private,move
-(NSArray *)_draggedTypes;
-(void)_setWindow:(NSWindow *)window;

View File

@ -1299,6 +1299,30 @@ static inline void buildTransformsIfNeeded(NSView *self) {
return nil;
}
-(NSPoint)convertPointFromBase:(NSPoint)aPoint; {
return aPoint;
}
-(NSPoint)convertPointToBase:(NSPoint)aPoint; {
return aPoint;
}
-(NSSize)convertSizeFromBase:(NSSize)aSize {
return aSize;
}
-(NSSize)convertSizeToBase:(NSSize)aSize {
return aSize;
}
-(NSRect)convertRectFromBase:(NSRect)aRect {
return aRect;
}
-(NSRect)convertRectToBase:(NSRect)aRect {
return aRect;
}
-(NSString *)description {
return [NSString stringWithFormat:@"<%@[0x%lx] frame: %@>", [self class], self, NSStringFromRect(_frame)];
}

View File

@ -425,7 +425,7 @@
cairo_set_font_size(_context, [fontState pointSize]);
cairo_identity_matrix(_context);
cairo_reset_clip(_context);
[self appendFlip];
[self appendCTM];
@ -435,16 +435,6 @@
cairo_show_glyphs(_context, cg, count);
{
/*double x,y,x2,y2;
CGAffineTransform ctm=[[self currentState] textMatrix];
cairo_glyph_path(_context, cg, count);
cairo_stroke_extents(_context, &x, &y, &x2, &y2);
NSRect rect=NSMakeRect(x, y, x2-x, y2-y);
rect=NSOffsetRect(rect, ctm.tx, ctm.ty);
_dirtyRect=NSUnionRect(_dirtyRect, rect);*/
}
}
-(void)showText:(const char *)text length:(unsigned)length {
@ -452,9 +442,8 @@
CGGlyph glyphs[length];
int i;
// FIX, encoding
for(i=0;i<length;i++)
unicode[i]=text[i];
id str=[NSString stringWithUTF8String:text];
[str getCharacters:unicode range:NSMakeRange(0, length)];
[(KTFont*)[[self currentState] fontState] getGlyphs:glyphs forCharacters:unicode length:length];
[self showGlyphs:glyphs count:length];
@ -493,8 +482,6 @@ cairo_status_t writeToData(void *closure,
cairo_destroy(ctx);
cairo_surface_write_to_png_stream(surf, writeToData, ret);
cairo_surface_write_to_png(surf, "/tmp/out.png");
cairo_surface_destroy(surf);
return ret;
}

View File

@ -19,6 +19,8 @@
id _name;
void *_platformFont;
}
+(NSSet*)allFontFamilyNames;
+(NSArray *)fontTypefacesForFamilyName:(NSString *)name;
-(CGPoint)positionOfGlyph:(CGGlyph)current precededByGlyph:(CGGlyph)previous isNominal:(BOOL *)isNominalp;
-(void)getAdvancements:(CGSize *)advancements forGlyphs:(const CGGlyph *)glyphs count:(unsigned)count;
-(float)pointSize;

View File

@ -9,6 +9,8 @@
#import "TTFFont.h"
#import <AppKit/KTFont.h>
#import <AppKit/KGFont.h>
#import <AppKit/NSFontTypeface.h>
#import <fontconfig.h>
@implementation KTFont(TTFFont)
+(id)allocWithZone:(NSZone*)zone
@ -19,10 +21,116 @@
@implementation TTFFont
FT_Library library;
FcConfig *fontConfig;
+(NSSet*)allFontFamilyNames {
int i;
FcPattern *pat=FcPatternCreate();
FcObjectSet *props=FcObjectSetBuild(FC_FAMILY, 0);
FcFontSet *set = FcFontList (fontConfig, pat, props);
NSMutableSet* ret=[NSMutableSet set];
for(i = 0; i < set->nfont; i++)
{
FcChar8 *family;
if (FcPatternGetString (set->fonts[i], FC_FAMILY, 0, &family) == FcResultMatch) {
[ret addObject:[NSString stringWithUTF8String:(char*)family]];
}
}
FcPatternDestroy(pat);
FcObjectSetDestroy(props);
FcFontSetDestroy(set);
return ret;
}
+(NSArray *)fontTypefacesForFamilyName:(NSString *)familyName {
int i;
FcPattern *pat=FcPatternCreate();
FcPatternAddString(pat, FC_FAMILY, (unsigned char*)[familyName UTF8String]);
FcObjectSet *props=FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_SLANT, FC_WIDTH, FC_WEIGHT, 0);
FcFontSet *set = FcFontList (fontConfig, pat, props);
NSMutableArray* ret=[NSMutableArray array];
for(i = 0; i < set->nfont; i++)
{
FcChar8 *typeface;
FcPattern *p=set->fonts[i];
if (FcPatternGetString (p, FC_STYLE, 0, &typeface) == FcResultMatch) {
NSString* traitName=[NSString stringWithUTF8String:(char*)typeface];
FcChar8* pattern=FcNameUnparse(p);
NSString* name=[NSString stringWithUTF8String:(char*)pattern];
FcStrFree(pattern);
NSFontTraitMask traits=0;
int slant, width, weight;
FcPatternGetInteger(p, FC_SLANT, FC_SLANT_ROMAN, &slant);
FcPatternGetInteger(p, FC_WIDTH, FC_WIDTH_NORMAL, &width);
FcPatternGetInteger(p, FC_WEIGHT, FC_WEIGHT_REGULAR, &weight);
switch(slant) {
case FC_SLANT_OBLIQUE:
case FC_SLANT_ITALIC:
traits|=NSItalicFontMask;
break;
default:
traits|=NSUnitalicFontMask;
break;
}
if(weight<=FC_WEIGHT_LIGHT)
traits|=NSUnboldFontMask;
else if(weight>=FC_WEIGHT_SEMIBOLD)
traits|=NSBoldFontMask;
if(width<=FC_WIDTH_SEMICONDENSED)
traits|=NSNarrowFontMask;
else if(width>=FC_WIDTH_SEMIEXPANDED)
traits|=NSExpandedFontMask;
NSFontTypeface *face=[[NSFontTypeface alloc] initWithName:name traitName:traitName traits:traits];
[ret addObject:face];
[face release];
}
}
FcPatternDestroy(pat);
FcObjectSetDestroy(props);
FcFontSetDestroy(set);
return ret;
}
+(NSString*)filenameForPattern:(NSString *)pattern {
int i;
FcPattern *pat=FcNameParse((unsigned char*)[pattern UTF8String]);
FcObjectSet *props=FcObjectSetBuild(FC_FILE, 0);
FcFontSet *set = FcFontList (fontConfig, pat, props);
NSString* ret=NULL;
for(i = 0; i < set->nfont && !ret; i++) {
FcChar8 *filename;
if (FcPatternGetString (set->fonts[i], FC_FILE, 0, &filename) == FcResultMatch) {
ret=[NSString stringWithUTF8String:(char*)filename];
}
}
FcPatternDestroy(pat);
FcObjectSetDestroy(props);
FcFontSetDestroy(set);
return ret;
}
+(void)initialize {
int ret=FT_Init_FreeType(&library);
NSAssert(ret==0, nil);
fontConfig=FcInitLoadConfigAndFonts();
}
-(float)pointSize
@ -67,15 +175,22 @@ FT_Library library;
if(self=[super init])
{
id pattern=[font fontName];
NSLog(@"%@",pattern);
id filename=[isa filenameForPattern:pattern];
if(!filename) {
filename=@"/Library/Fonts/Arial";
}
FT_Error ret=FT_New_Face(library,
"/Library/Fonts/Tahoma.ttf",
[filename fileSystemRepresentation],
0,
&_face);
FT_Select_Charmap(_face, FT_ENCODING_UNICODE);
// NSAssert(ret==0, nil);
_size=size;
_name=@"FreeSans";
@ -103,7 +218,7 @@ FT_Library library;
case kCTFontMenuItemFontType:
if(size==0)
size=12;
font=[KGFont createWithFontName:@"Vera"];
font=[KGFont createWithFontName:@"Arial"];
break;
default:

View File

@ -11,11 +11,7 @@
@implementation X11AsyncInputSource
-(BOOL)processInputImmediately {
if(XPending([_display display])) {
[_display processX11Event];
return YES;
}
return NO;
return [_display processX11Event];
}

View File

@ -15,6 +15,6 @@
}
-(Display*)display;
-(void)setWindow:(id)window forID:(XID)i;
-(void)processX11Event;
-(BOOL)processX11Event;
-(float)doubleClickInterval;
@end

View File

@ -15,7 +15,7 @@
#import <AppKit/X11InputSource.h>
#import <AppKit/NSColor.h>
#import <AppKit/NSImage.h>
#import <AppKit/TTFFont.h>
@implementation X11Display
@ -24,8 +24,10 @@
{
if(self=[super init])
{
//XInitThreads();
_display=XOpenDisplay(NULL);
if(!_display)
_display=XOpenDisplay(":0");
NSAssert(_display, nil);
_windowsByID=[NSMutableDictionary new];
[self performSelector:@selector(setupEventHandling) withObject:nil afterDelay:0.0];
}
@ -142,13 +144,11 @@
}
-(NSSet *)allFontFamilyNames {
NSUnimplementedMethod();
return nil;
return [TTFFont allFontFamilyNames];
}
-(NSArray *)fontTypefacesForFamilyName:(NSString *)name {
NSUnimplementedMethod();
return nil;
return [TTFFont fontTypefacesForFamilyName:name];
}
-(float)scrollerWidth {
@ -204,24 +204,28 @@
-(void)setupEventHandling {
[X11InputSource addInputSourceWithDisplay:self];
}
-(void)doNothing {
-(NSEvent *)nextEventMatchingMask:(unsigned)mask untilDate:(NSDate *)untilDate inMode:(NSString *)mode dequeue:(BOOL)dequeue;
{
[self processX11Event];
return [super nextEventMatchingMask:mask untilDate:untilDate inMode:mode dequeue:dequeue];
}
-(void)processX11Event {
-(BOOL)processX11Event {
XEvent e;
int i;
int numEvents;
while(numEvents=XEventsQueued(_display, QueuedAfterReading)) {
BOOL ret=NO;
while(numEvents=XEventsQueued(_display, QueuedAfterFlush)) {
for(i=0; i<numEvents; i++) {
XNextEvent(_display, &e);
id window=[self windowForID:e.xany.window];
[window handleEvent:&e fromDisplay:self];
ret=YES;
}
}
return ret;
}
@end

View File

@ -15,12 +15,18 @@
#import <AppKit/NSApplication.h>
#import <AppKit/X11AsyncInputSource.h>
#import <X11/Xlib.h>
#import <fcntl.h>
@implementation X11InputSource
+(void)addInputSourceWithDisplay:(X11Display*)display {
int connectionNumber=ConnectionNumber([display display]);
int flags=fcntl(connectionNumber, F_GETFL);
flags&=~O_NONBLOCK;
fcntl(connectionNumber, F_SETFL, flags & ~O_NONBLOCK);
X11InputSource* synchro = [X11InputSource socketInputSourceWithSocket:
[NSSocket_bsd socketWithDescriptor:ConnectionNumber([display display])]];
[NSSocket_bsd socketWithDescriptor:connectionNumber]];
X11AsyncInputSource* async=[X11AsyncInputSource new];
[synchro setDelegate:synchro];
@ -35,10 +41,6 @@
}
-(BOOL)processImmediateEvents:(unsigned)selectEvent; {
if((selectEvent && XEventsQueued([_display display], QueuedAfterReading)) ||
XPending([_display display])) {
[_display processX11Event];
return YES;
}
return [_display processX11Event];
}
@end

View File

@ -14,6 +14,35 @@
@implementation X11Window
+(Visual*)visual {
static Visual* ret=NULL;
if(!ret) {
int visuals_matched, i;
XVisualInfo match={0};
Display *dpy=[(X11Display*)[NSDisplay currentDisplay] display];
XVisualInfo *info=XGetVisualInfo(dpy,
0, &match, &visuals_matched);
for(i=0; i<visuals_matched; i++) {
if(info[i].depth == 32 &&
(info[i].red_mask == 0xff0000 &&
info[i].green_mask == 0x00ff00 &&
info[i].blue_mask == 0x0000ff)) {
ret=info[i].visual;
}
}
XFree(info);
if(!ret)
ret=DefaultVisual(dpy, DefaultScreen(dpy));
}
return ret;
}
-initWithFrame:(NSRect)frame styleMask:(unsigned)styleMask isPanel:(BOOL)isPanel backingType:(NSUInteger)backingType;
{
if(self=[super init])
@ -22,21 +51,21 @@
_dpy=[(X11Display*)[NSDisplay currentDisplay] display];
int s = DefaultScreen(_dpy);
_frame=[self transformFrame:frame];
_window = XCreateSimpleWindow(_dpy, DefaultRootWindow(_dpy),
_frame.origin.x, _frame.origin.y, _frame.size.width, _frame.size.height,
1, 0, 0);
XSelectInput(_dpy, _window, ExposureMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask |
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PointerMotionMask | VisibilityChangeMask | FocusChangeMask);
XSetWindowAttributes xattr;
unsigned long xattr_mask;
xattr.override_redirect = styleMask == NSBorderlessWindowMask ? True : False;
xattr_mask = CWOverrideRedirect;
XChangeWindowAttributes(_dpy, _window, xattr_mask, &xattr);
XMoveWindow(_dpy, _window, _frame.origin.x, _frame.origin.y);
_window = XCreateWindow(_dpy, DefaultRootWindow(_dpy),
_frame.origin.x, _frame.origin.y, _frame.size.width, _frame.size.height,
0, CopyFromParent, InputOutput,
CopyFromParent,
xattr_mask, &xattr);
XSelectInput(_dpy, _window, ExposureMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask |
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PointerMotionMask | VisibilityChangeMask | FocusChangeMask);
Atom atm=XInternAtom(_dpy, "WM_DELETE_WINDOW", False);
XSetWMProtocols(_dpy, _window, &atm , 1);

View File

@ -20,7 +20,7 @@ BOOL NSDebugEnabled=NO;
const char* _NSPrintForDebugger(id object) {
if(object && [object respondsToSelector:@selector(description)]) {
return [[object description] cString];
return [[object description] UTF8String];
}
return NULL;
}

View File

@ -195,7 +195,7 @@ static struct passwd *pwent = NULL;
}
-(void)logString:(NSString *)string {
fprintf(stderr, "%s\n", [string cString]);
fprintf(stderr, "%s\n", [string UTF8String]);
}
-(void *)contentsOfFile:(NSString *)path length:(unsigned *)lengthp {

View File

@ -13,6 +13,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSDate.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDebug.h>
#import <errno.h>
#import <sys/select.h>
@ -144,15 +145,14 @@ static void transferNativeToSetWithOriginals(native_set *sset,NSMutableSet *set,
struct timeval timeval;
NSTimeInterval interval=-1.0;
transferSetToNative(_readSet,activeRead);
transferSetToNative(_writeSet,activeWrite);
transferSetToNative(_exceptionSet,activeExcept);
// See NSTask_linux.m
int numFds=0;
while(result==nil && numFds==0 && interval!=0.0)
{
transferSetToNative(_readSet,activeRead);
transferSetToNative(_writeSet,activeWrite);
transferSetToNative(_exceptionSet,activeExcept);
interval=[beforeDate timeIntervalSinceNow];
if(interval>1000000)
@ -169,6 +169,12 @@ static void transferNativeToSetWithOriginals(native_set *sset,NSMutableSet *set,
if(errno!=EINTR)
result=[NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:nil];
}
if(NSDebugEnabled) {
interval=[beforeDate timeIntervalSinceNow];
if(interval>0.0)
NSLog(@"in %@: select returned 0 before timeout ended. Did you wait on a non-blocking socket?");
}
}
if(result==nil){

View File

@ -7,7 +7,7 @@
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <SenTestingKit/SenTestingKit.h>
#import <AppKit/AppKit.h>
@interface NibBasedTest : SenTestCase {
NSArray* _topLevelObjects;

View File

@ -0,0 +1,18 @@
/* Copyright (c) 2009 Johannes Fortmann
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import "NibBasedTest.h"
@interface ObjectController : NibBasedTest {
float _floatValue;
NSObjectController* _objectController;
NSSlider *_slider;
}
@end

View File

@ -0,0 +1,28 @@
/* Copyright (c) 2009 Johannes Fortmann
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import "ObjectController.h"
@implementation ObjectController
-(void)testSetting {
[self setValue:[NSNumber numberWithFloat:20.0f] forKey:@"floatValue"];
STAssertEquals([_slider floatValue], 20.0f, nil);
STAssertEquals(_floatValue, 20.0f, nil);
}
-(void)testGetting {
[_slider setFloatValue:40.0];
STAssertEquals([_slider floatValue], 40.0f, nil);
STAssertEquals(_floatValue, 40.0f, nil);
}
@end

View File

@ -0,0 +1,313 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">9G55</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.43</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
<string key="NSClassName">ObjectController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSObjectController" id="446924318">
<object class="NSMutableArray" key="NSDeclaredKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>radius</string>
<string>value</string>
<string>floatValue</string>
</object>
<bool key="NSEditable">YES</bool>
<object class="_NSManagedProxy" key="_NSManagedProxy"/>
</object>
<object class="NSWindowTemplate" id="1012788753">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{196, 353}, {275, 157}}</string>
<int key="NSWTFlags">603979776</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
<object class="NSView" key="NSWindowView" id="837192152">
<nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSSlider" id="717492001">
<reference key="NSNextResponder" ref="837192152"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{46, 104}, {96, 21}}</string>
<reference key="NSSuperview" ref="837192152"/>
<bool key="NSEnabled">YES</bool>
<object class="NSSliderCell" key="NSCell" id="704314619">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">0</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport">
<string key="NSName">Helvetica</string>
<double key="NSSize">1.200000e+01</double>
<int key="NSfFlags">16</int>
</object>
<reference key="NSControlView" ref="717492001"/>
<double key="NSMaxValue">1.000000e+02</double>
<double key="NSMinValue">0.000000e+00</double>
<double key="NSValue">0.000000e+00</double>
<double key="NSAltIncValue">0.000000e+00</double>
<int key="NSNumberOfTickMarks">0</int>
<int key="NSTickMarkPosition">1</int>
<bool key="NSAllowsTickMarkValuesOnly">NO</bool>
<bool key="NSVertical">NO</bool>
</object>
</object>
</object>
<string key="NSFrameSize">{275, 157}</string>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">_slider</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="717492001"/>
</object>
<int key="connectionID">6</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">_objectController</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="446924318"/>
</object>
<int key="connectionID">7</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">contentObject: self</string>
<reference key="source" ref="446924318"/>
<reference key="destination" ref="1001"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="446924318"/>
<reference key="NSDestination" ref="1001"/>
<string key="NSLabel">contentObject: self</string>
<string key="NSBinding">contentObject</string>
<string key="NSKeyPath">self</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">8</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: selection.floatValue</string>
<reference key="source" ref="717492001"/>
<reference key="destination" ref="446924318"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="717492001"/>
<reference key="NSDestination" ref="446924318"/>
<string key="NSLabel">value: selection.floatValue</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">selection.floatValue</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<object class="NSArray" key="object" id="1002">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
<reference key="parent" ref="1002"/>
<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
<reference key="parent" ref="1002"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
<reference key="parent" ref="1002"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">1</int>
<reference key="object" ref="446924318"/>
<reference key="parent" ref="1002"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="1012788753"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="837192152"/>
</object>
<reference key="parent" ref="1002"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="837192152"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="717492001"/>
</object>
<reference key="parent" ref="1012788753"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="717492001"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="704314619"/>
</object>
<reference key="parent" ref="837192152"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">5</int>
<reference key="object" ref="704314619"/>
<reference key="parent" ref="717492001"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>1.IBPluginDependency</string>
<string>2.IBEditorWindowLastContentRect</string>
<string>2.IBPluginDependency</string>
<string>2.IBWindowTemplateEditedContentRect</string>
<string>2.NSWindowTemplate.visibleAtLaunch</string>
<string>3.IBPluginDependency</string>
<string>4.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{0, 688}, {275, 157}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{0, 688}, {275, 157}}</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">12</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">NibBasedTest</string>
<string key="superclassName">SenTestCase</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Bindings/NibBasedTest.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">ObjectController</string>
<string key="superclassName">NibBasedTest</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Bindings/ObjectController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">ObjectController</string>
<string key="superclassName">NibBasedTest</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>_objectController</string>
<string>_slider</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.LastKnownRelativeProjectPath">../UnitTests.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>

View File

@ -1,10 +1,10 @@
//
// ObservableArray.h
// UnitTests
//
// Created by Johannes Fortmann on 10.02.09.
// Copyright 2009 -. All rights reserved.
//
/* Copyright (c) 2009 Johannes Fortmann
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <SenTestingKit/SenTestingKit.h>

View File

@ -1,10 +1,10 @@
//
// ObservableArray.m
// UnitTests
//
// Created by Johannes Fortmann on 10.02.09.
// Copyright 2009 -. All rights reserved.
//
/* Copyright (c) 2009 Johannes Fortmann
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import "ObservableArray.h"
@ -36,14 +36,13 @@ void* ObservableArrayTestContext;
[NSNumber numberWithInt:50], @"value",
nil]];
[_array addObserver:self forKeyPath:@"name" options:0 context:&ObservableArrayTestContext];
[_array addObserver:self forKeyPath:@"value" options:0 context:&ObservableArrayTestContext];
}
-(void)testArrayMutation {
if(!_array)
return;
[_array addObserver:self forKeyPath:@"@count" options:0 context:&ObservableArrayTestContext];
[_array addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"Sixth", @"name",
@ -64,6 +63,9 @@ void* ObservableArrayTestContext;
}
-(void)testArrayOperatorMutation {
if(!_array)
return;
[_array addObserver:self forKeyPath:@"@avg.value" options:0 context:&ObservableArrayTestContext];
[_array addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"Sixth", @"name",
@ -80,6 +82,9 @@ void* ObservableArrayTestContext;
}
-(void)testArraySimpleMutation {
if(!_array)
return;
[_array addObserver:self forKeyPath:@"value" options:0 context:&ObservableArrayTestContext];
[[_array objectAtIndex:0] setValue:[NSNumber numberWithInt:0] forKey:@"value"];
@ -90,6 +95,9 @@ void* ObservableArrayTestContext;
}
-(void)testROI {
if(!_array)
return;
[_array addObserver:self forKeyPath:@"value" options:0 context:&ObservableArrayTestContext];
id indexes=[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(2, 2)];
id irrelevant=[NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)];
@ -150,9 +158,9 @@ void* ObservableArrayTestContext;
-(void)tearDown {
self.lastObservedKey=nil;
[_array removeObserver:self forKeyPath:@"name"];
[_array removeObserver:self forKeyPath:@"value"];
if(!_array)
return;
for(id item in _array) {
STAssertEqualObjects([item observationInfo], nil, nil);
}

View File

@ -19,7 +19,7 @@
-(void)setUp {
[super setUp];
[_arrayController bind:@"contentObject" toObject:self withKeyPath:@"table" options:nil];
[_arrayController bind:@"contentArray" toObject:self withKeyPath:@"table" options:nil];
id table=[NSMutableArray array];

View File

@ -557,7 +557,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">43</int>
<int key="maxID">44</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">

View File

@ -44,11 +44,8 @@
C8794B910EE4727C00539601 /* Properties.m in Sources */ = {isa = PBXBuildFile; fileRef = C827EB3A0DB63FFA00360D99 /* Properties.m */; };
C8794B920EE4727C00539601 /* ForEach.m in Sources */ = {isa = PBXBuildFile; fileRef = C88B859B0DB90282000A8500 /* ForEach.m */; };
C88255850F419397002ED1DA /* ObservableArray.m in Sources */ = {isa = PBXBuildFile; fileRef = C88255840F419397002ED1DA /* ObservableArray.m */; };
C88255860F419397002ED1DA /* ObservableArray.m in Sources */ = {isa = PBXBuildFile; fileRef = C88255840F419397002ED1DA /* ObservableArray.m */; };
C88255870F419397002ED1DA /* ObservableArray.m in Sources */ = {isa = PBXBuildFile; fileRef = C88255840F419397002ED1DA /* ObservableArray.m */; };
C88255880F419397002ED1DA /* ObservableArray.m in Sources */ = {isa = PBXBuildFile; fileRef = C88255840F419397002ED1DA /* ObservableArray.m */; };
C88256C00F41A869002ED1DA /* KVO.m in Sources */ = {isa = PBXBuildFile; fileRef = C88470DA0DD3A9F600853747 /* KVO.m */; };
C882579D0F42CFF0002ED1DA /* TableViewTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C8DA2D210F407516006E73E9 /* TableViewTest.m */; };
C88257A40F42D053002ED1DA /* NibBasedTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C8DA2D2C0F40757F006E73E9 /* NibBasedTest.m */; };
C897902C0ECA1E5400C3E5EE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C897902B0ECA1E5400C3E5EE /* main.m */; };
C897902E0ECA1E5400C3E5EE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C897902B0ECA1E5400C3E5EE /* main.m */; };
@ -83,6 +80,17 @@
C8DA2EC30F408EAB006E73E9 /* Predicate.m in Sources */ = {isa = PBXBuildFile; fileRef = C8DA2EC20F408EAB006E73E9 /* Predicate.m */; };
C8DA2EC40F408EAB006E73E9 /* Predicate.m in Sources */ = {isa = PBXBuildFile; fileRef = C8DA2EC20F408EAB006E73E9 /* Predicate.m */; };
C8DA2EC60F408EAB006E73E9 /* Predicate.m in Sources */ = {isa = PBXBuildFile; fileRef = C8DA2EC20F408EAB006E73E9 /* Predicate.m */; };
C8E2B7AC0F48C69000C070F5 /* ObjectController.m in Sources */ = {isa = PBXBuildFile; fileRef = C8E2B7AB0F48C69000C070F5 /* ObjectController.m */; };
C8E2B7AD0F48C69000C070F5 /* ObjectController.m in Sources */ = {isa = PBXBuildFile; fileRef = C8E2B7AB0F48C69000C070F5 /* ObjectController.m */; };
C8E2B7AE0F48C69000C070F5 /* ObjectController.m in Sources */ = {isa = PBXBuildFile; fileRef = C8E2B7AB0F48C69000C070F5 /* ObjectController.m */; };
C8E2B7AF0F48C69000C070F5 /* ObjectController.m in Sources */ = {isa = PBXBuildFile; fileRef = C8E2B7AB0F48C69000C070F5 /* ObjectController.m */; };
C8E2B7B40F48C6AE00C070F5 /* ObjectController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C8E2B7B30F48C6AE00C070F5 /* ObjectController.xib */; };
C8E2B7B50F48C6AE00C070F5 /* ObjectController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C8E2B7B30F48C6AE00C070F5 /* ObjectController.xib */; };
C8E2B7B60F48C6AE00C070F5 /* ObjectController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C8E2B7B30F48C6AE00C070F5 /* ObjectController.xib */; };
C8E2B7B70F48C6AE00C070F5 /* ObjectController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C8E2B7B30F48C6AE00C070F5 /* ObjectController.xib */; };
C8E2B8360F48CEAA00C070F5 /* TableViewTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C8DA2D210F407516006E73E9 /* TableViewTest.m */; };
C8E2B8370F48CEB100C070F5 /* TextFieldBindings.m in Sources */ = {isa = PBXBuildFile; fileRef = C8294FF50F2CC47700F0DAF2 /* TextFieldBindings.m */; };
C8E2B8380F48CEB100C070F5 /* ObservableArray.m in Sources */ = {isa = PBXBuildFile; fileRef = C88255840F419397002ED1DA /* ObservableArray.m */; };
C8EA126C0E8941490051F4DF /* CrashCatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = C80F9D160E59E45100ECD487 /* CrashCatcher.m */; };
C8EA126E0E89414E0051F4DF /* Binary.plist in Resources */ = {isa = PBXBuildFile; fileRef = C8A392D70E48B26200A9C289 /* Binary.plist */; };
C8EA126F0E8941580051F4DF /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C827EA560DB62A9200360D99 /* SenTestingKit.framework */; };
@ -210,6 +218,9 @@
C8DA2D520F40761B006E73E9 /* TableViewTest.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TableViewTest.xib; sourceTree = "<group>"; };
C8DA2EC10F408EAB006E73E9 /* Predicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Predicate.h; sourceTree = "<group>"; };
C8DA2EC20F408EAB006E73E9 /* Predicate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Predicate.m; sourceTree = "<group>"; };
C8E2B7AA0F48C69000C070F5 /* ObjectController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectController.h; sourceTree = "<group>"; };
C8E2B7AB0F48C69000C070F5 /* ObjectController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectController.m; sourceTree = "<group>"; };
C8E2B7B30F48C6AE00C070F5 /* ObjectController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ObjectController.xib; sourceTree = "<group>"; };
C8EA0F850E85665B0051F4DF /* RetainRelease.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RetainRelease.h; sourceTree = "<group>"; };
C8EA0F860E85665B0051F4DF /* RetainRelease.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RetainRelease.m; sourceTree = "<group>"; };
C8EA12240E893B1F0051F4DF /* MessageSendTorture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageSendTorture.h; sourceTree = "<group>"; };
@ -396,6 +407,9 @@
C8DA2D2C0F40757F006E73E9 /* NibBasedTest.m */,
C88255830F419397002ED1DA /* ObservableArray.h */,
C88255840F419397002ED1DA /* ObservableArray.m */,
C8E2B7AA0F48C69000C070F5 /* ObjectController.h */,
C8E2B7AB0F48C69000C070F5 /* ObjectController.m */,
C8E2B7B30F48C6AE00C070F5 /* ObjectController.xib */,
);
path = Bindings;
sourceTree = "<group>";
@ -564,6 +578,7 @@
C81373B80F3A15D2001D4AFB /* Apple.bplist.keyedArchive in Resources */,
C81373E20F3A165C001D4AFB /* Cocotron.keyedArchive in Resources */,
C8DA2D530F40761B006E73E9 /* TableViewTest.xib in Resources */,
C8E2B7B50F48C6AE00C070F5 /* ObjectController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -577,6 +592,7 @@
C81373B90F3A15D2001D4AFB /* Apple.bplist.keyedArchive in Resources */,
C81373E30F3A165C001D4AFB /* Cocotron.keyedArchive in Resources */,
C8DA2D550F40761B006E73E9 /* TableViewTest.xib in Resources */,
C8E2B7B70F48C6AE00C070F5 /* ObjectController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -591,6 +607,7 @@
C81373B60F3A15D2001D4AFB /* Apple.bplist.keyedArchive in Resources */,
C81373E00F3A165C001D4AFB /* Cocotron.keyedArchive in Resources */,
C8DA2D560F40761B006E73E9 /* TableViewTest.xib in Resources */,
C8E2B7B60F48C6AE00C070F5 /* ObjectController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -606,6 +623,7 @@
C81373B70F3A15D2001D4AFB /* Apple.bplist.keyedArchive in Resources */,
C81373E10F3A165C001D4AFB /* Cocotron.keyedArchive in Resources */,
C8DA2D540F40761B006E73E9 /* TableViewTest.xib in Resources */,
C8E2B7B40F48C6AE00C070F5 /* ObjectController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -675,6 +693,7 @@
C8DA2D2D0F40757F006E73E9 /* NibBasedTest.m in Sources */,
C8DA2EC30F408EAB006E73E9 /* Predicate.m in Sources */,
C88255870F419397002ED1DA /* ObservableArray.m in Sources */,
C8E2B7AD0F48C69000C070F5 /* ObjectController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -684,10 +703,11 @@
files = (
C81371EE0F38FF9A001D4AFB /* CrashCatcher.m in Sources */,
C81371F10F38FF9A001D4AFB /* main.m in Sources */,
C88255860F419397002ED1DA /* ObservableArray.m in Sources */,
C88256C00F41A869002ED1DA /* KVO.m in Sources */,
C882579D0F42CFF0002ED1DA /* TableViewTest.m in Sources */,
C88257A40F42D053002ED1DA /* NibBasedTest.m in Sources */,
C8E2B7AF0F48C69000C070F5 /* ObjectController.m in Sources */,
C8E2B8360F48CEAA00C070F5 /* TableViewTest.m in Sources */,
C8E2B8370F48CEB100C070F5 /* TextFieldBindings.m in Sources */,
C8E2B8380F48CEB100C070F5 /* ObservableArray.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -704,6 +724,7 @@
C8DA2D300F40757F006E73E9 /* NibBasedTest.m in Sources */,
C8DA2EC60F408EAB006E73E9 /* Predicate.m in Sources */,
C88255880F419397002ED1DA /* ObservableArray.m in Sources */,
C8E2B7AE0F48C69000C070F5 /* ObjectController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -723,6 +744,7 @@
C8DA2D2E0F40757F006E73E9 /* NibBasedTest.m in Sources */,
C8DA2EC40F408EAB006E73E9 /* Predicate.m in Sources */,
C88255850F419397002ED1DA /* ObservableArray.m in Sources */,
C8E2B7AC0F48C69000C070F5 /* ObjectController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};