diff --git a/AppKit/AppKit.xcodeproj/project.pbxproj b/AppKit/AppKit.xcodeproj/project.pbxproj index 2627e8fe..7d00eac9 100644 --- a/AppKit/AppKit.xcodeproj/project.pbxproj +++ b/AppKit/AppKit.xcodeproj/project.pbxproj @@ -1278,6 +1278,8 @@ FE57F8D30C46B68C0078FFC1 /* KGDeviceContext_gdi.m in Sources */ = {isa = PBXBuildFile; fileRef = FE57F8D10C46B68C0078FFC1 /* KGDeviceContext_gdi.m */; }; FE57FAB70C47F2010078FFC1 /* NSPrintPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = FE57FAB50C47F2010078FFC1 /* NSPrintPanel.h */; settings = {ATTRIBUTES = (Public, ); }; }; FE57FAB80C47F2010078FFC1 /* NSPrintPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = FE57FAB60C47F2010078FFC1 /* NSPrintPanel.m */; }; + FE5C6E2D0CD97D2800893B56 /* StandardAboutPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = FE5C6E2C0CD97D2800893B56 /* StandardAboutPanel.nib */; }; + FE5C6E2E0CD97D2800893B56 /* StandardAboutPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = FE5C6E2C0CD97D2800893B56 /* StandardAboutPanel.nib */; }; FE6466E30B2C611D00B302B0 /* NSMutableParagraphStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6466E10B2C611D00B302B0 /* NSMutableParagraphStyle.h */; settings = {ATTRIBUTES = (Public, ); }; }; FE6466E40B2C611D00B302B0 /* NSMutableParagraphStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = FE6466E20B2C611D00B302B0 /* NSMutableParagraphStyle.m */; }; FE64B8E10B81239D007EE513 /* KGColorSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = FE64B8A70B81239D007EE513 /* KGColorSpace.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -1369,6 +1371,8 @@ FE8F9F290C9C5D0000270AEE /* KGzlib.m in Sources */ = {isa = PBXBuildFile; fileRef = FE8F9F270C9C5D0000270AEE /* KGzlib.m */; }; FE8F9F2A0C9C5D0000270AEE /* KGzlib.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8F9F260C9C5D0000270AEE /* KGzlib.h */; settings = {ATTRIBUTES = (Private, ); }; }; FE8F9F2B0C9C5D0000270AEE /* KGzlib.m in Sources */ = {isa = PBXBuildFile; fileRef = FE8F9F270C9C5D0000270AEE /* KGzlib.m */; }; + FEA8A98C0CD2CBC000E1E936 /* NSUserInterfaceValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA8A98B0CD2CBC000E1E936 /* NSUserInterfaceValidation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FEA8A98D0CD2CBC000E1E936 /* NSUserInterfaceValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA8A98B0CD2CBC000E1E936 /* NSUserInterfaceValidation.h */; settings = {ATTRIBUTES = (Public, ); }; }; FEABD5EA0CB9CEE40035F828 /* KGLayer_gdi.h in Headers */ = {isa = PBXBuildFile; fileRef = FEABD5E80CB9CEE40035F828 /* KGLayer_gdi.h */; }; FEABD5EB0CB9CEE40035F828 /* KGLayer_gdi.m in Sources */ = {isa = PBXBuildFile; fileRef = FEABD5E90CB9CEE40035F828 /* KGLayer_gdi.m */; }; FEABD5EC0CB9CEE40035F828 /* KGLayer_gdi.h in Headers */ = {isa = PBXBuildFile; fileRef = FEABD5E80CB9CEE40035F828 /* KGLayer_gdi.h */; }; @@ -2074,6 +2078,7 @@ FE57F8D10C46B68C0078FFC1 /* KGDeviceContext_gdi.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = KGDeviceContext_gdi.m; sourceTree = ""; }; FE57FAB50C47F2010078FFC1 /* NSPrintPanel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NSPrintPanel.h; sourceTree = ""; }; FE57FAB60C47F2010078FFC1 /* NSPrintPanel.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = NSPrintPanel.m; sourceTree = ""; }; + FE5C6E2C0CD97D2800893B56 /* StandardAboutPanel.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = StandardAboutPanel.nib; sourceTree = ""; }; FE6466E10B2C611D00B302B0 /* NSMutableParagraphStyle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NSMutableParagraphStyle.h; sourceTree = ""; }; FE6466E20B2C611D00B302B0 /* NSMutableParagraphStyle.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = NSMutableParagraphStyle.m; sourceTree = ""; }; FE64B8A70B81239D007EE513 /* KGColorSpace.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KGColorSpace.h; sourceTree = ""; }; @@ -2163,6 +2168,7 @@ FE8BAF220BC9EC680007FACA /* NSObject+BindingSupport.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BindingSupport.m"; sourceTree = ""; }; FE8F9F260C9C5D0000270AEE /* KGzlib.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KGzlib.h; sourceTree = ""; }; FE8F9F270C9C5D0000270AEE /* KGzlib.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = KGzlib.m; sourceTree = ""; }; + FEA8A98B0CD2CBC000E1E936 /* NSUserInterfaceValidation.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NSUserInterfaceValidation.h; sourceTree = ""; }; FEABD5E80CB9CEE40035F828 /* KGLayer_gdi.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KGLayer_gdi.h; sourceTree = ""; }; FEABD5E90CB9CEE40035F828 /* KGLayer_gdi.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = KGLayer_gdi.m; sourceTree = ""; }; FEABD6030CB9D0C90035F828 /* KGContext_gdi.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KGContext_gdi.h; sourceTree = ""; }; @@ -2501,6 +2507,7 @@ 6E2B53F10976075200DA0954 /* NSToolTipWindow.m */, 6E2B54BC0976075300DA0954 /* NSTrackingRect.h */, 6E2B53DD0976075200DA0954 /* NSTrackingRect.m */, + FEA8A98B0CD2CBC000E1E936 /* NSUserInterfaceValidation.h */, 6E2B54BE0976075300DA0954 /* NSView.h */, 6E2B53DF0976075200DA0954 /* NSView.m */, 6E2B54DC0976075300DA0954 /* NSWindow-Drag.h */, @@ -2530,6 +2537,7 @@ 6E2B54DF0976075300DA0954 /* NSFontPanel.nib */, 6E2B54E10976075300DA0954 /* NSColorPanel.nib */, 6E2B54E30976075300DA0954 /* NSToolbarCustomizationPalette.nib */, + FE5C6E2C0CD97D2800893B56 /* StandardAboutPanel.nib */, ); name = Interfaces; sourceTree = ""; @@ -3551,6 +3559,7 @@ FEABD5EA0CB9CEE40035F828 /* KGLayer_gdi.h in Headers */, FEABD6050CB9D0C90035F828 /* KGContext_gdi.h in Headers */, FE311FA60CCC430200EBD696 /* KGFont_gdi.h in Headers */, + FEA8A98C0CD2CBC000E1E936 /* NSUserInterfaceValidation.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3891,6 +3900,7 @@ FEABD5EC0CB9CEE40035F828 /* KGLayer_gdi.h in Headers */, FEABD6070CB9D0C90035F828 /* KGContext_gdi.h in Headers */, FE311FA80CCC430200EBD696 /* KGFont_gdi.h in Headers */, + FEA8A98D0CD2CBC000E1E936 /* NSUserInterfaceValidation.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4052,6 +4062,7 @@ FE8688800BC3FFA4009F515C /* NSButtonCell_disclosure_normal.tif in Resources */, FE8688810BC3FFA4009F515C /* NSButtonCell_disclosure_selected.tif in Resources */, C8B239A30BF8EEB500CA33AF /* defaultBindingOptions.plist in Resources */, + FE5C6E2E0CD97D2800893B56 /* StandardAboutPanel.nib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4097,6 +4108,7 @@ FE01AAB80C5D9BCB00AEA51A /* NSButtonCell_disclosure_normal.tif in Resources */, FE01AAB90C5D9BCB00AEA51A /* NSButtonCell_disclosure_selected.tif in Resources */, FE01AABA0C5D9BCB00AEA51A /* defaultBindingOptions.plist in Resources */, + FE5C6E2D0CD97D2800893B56 /* StandardAboutPanel.nib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4877,6 +4889,7 @@ OTHER_CFLAGS = ( "-DAPPKIT_INSIDE_BUILD", "-D__LITTLE_ENDIAN__", + "-Wreturn-type", ); OTHER_LDFLAGS = ( "-shared", diff --git a/AppKit/CoreGraphics.subproj/CGContext.h b/AppKit/CoreGraphics.subproj/CGContext.h index 82645f10..4e235ad4 100755 --- a/AppKit/CoreGraphics.subproj/CGContext.h +++ b/AppKit/CoreGraphics.subproj/CGContext.h @@ -43,7 +43,40 @@ typedef enum { kCGInterpolationHigh, } CGInterpolationQuality; -typedef int CGBlendMode; +typedef enum { +// seperable + kCGBlendModeNormal, + kCGBlendModeMultiply, + kCGBlendModeScreen, + kCGBlendModeOverlay, + kCGBlendModeDarken, + kCGBlendModeLighten, + kCGBlendModeColorDodge, + kCGBlendModeColorBurn, + kCGBlendModeHardLight, + kCGBlendModeSoftLight, + kCGBlendModeDifference, + kCGBlendModeExclusion, +// nonseperable + kCGBlendModeHue, + kCGBlendModeSaturation, + kCGBlendModeColor, + kCGBlendModeLuminosity, +// Porter-Duff + kCGBlendModeClear, + kCGBlendModeCopy, + kCGBlendModeSourceIn, + kCGBlendModeSourceOut, + kCGBlendModeSourceAtop, + kCGBlendModeDestinationOver, + kCGBlendModeDestinationIn, + kCGBlendModeDestinationOut, + kCGBlendModeDestinationAtop, + kCGBlendModeXOR, + kCGBlendModePlusDarker, + kCGBlendModePlusLighter, +} CGBlendMode; + typedef int CGTextDrawingMode; @class KGContext; @@ -204,6 +237,9 @@ APPKIT_EXPORT void CGContextSynchronize(CGContextRef context); APPKIT_EXPORT void CGContextBeginPage(CGContextRef context,const CGRect *mediaBox); APPKIT_EXPORT void CGContextEndPage(CGContextRef context); +// private for NSAffineTransform +APPKIT_EXPORT void CGContextSetCTM(CGContextRef context,CGAffineTransform matrix); + // Temporary hacks APPKIT_EXPORT void CGContextDrawContextInRect(CGContextRef context,CGContextRef other,CGRect rect); diff --git a/AppKit/CoreGraphics.subproj/CGContext.m b/AppKit/CoreGraphics.subproj/CGContext.m index 2f42341e..6fc48778 100755 --- a/AppKit/CoreGraphics.subproj/CGContext.m +++ b/AppKit/CoreGraphics.subproj/CGContext.m @@ -158,6 +158,10 @@ CGRect CGContextConvertRectToUserSpace(CGContextRef context,CGRect rect) { return [context convertRectToUserSpace:rect]; } +void CGContextSetCTM(CGContextRef context,CGAffineTransform matrix) { + [context setCTM:matrix]; +} + void CGContextConcatCTM(CGContextRef context,CGAffineTransform matrix) { [context concatCTM:matrix]; } diff --git a/AppKit/CoreGraphics.subproj/CGFunction.m b/AppKit/CoreGraphics.subproj/CGFunction.m index 3f715acd..780f0dcd 100644 --- a/AppKit/CoreGraphics.subproj/CGFunction.m +++ b/AppKit/CoreGraphics.subproj/CGFunction.m @@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import "KGFunction.h" CGFunctionRef CGFunctionRetain(CGFunctionRef self) { - [self retain]; + return [self retain]; } void CGFunctionRelease(CGFunctionRef self) { diff --git a/AppKit/CoreGraphics.subproj/KGContext.h b/AppKit/CoreGraphics.subproj/KGContext.h index 98a5d5f4..d3717f8c 100644 --- a/AppKit/CoreGraphics.subproj/KGContext.h +++ b/AppKit/CoreGraphics.subproj/KGContext.h @@ -12,27 +12,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import -enum { -// seperable - KGBlendModeNormal, - KGBlendModeMultiply, - KGBlendModeScreen, - KGBlendModeOverlay, - KGBlendModeDarken, - KGBlendModeLighten, - KGBlendModeColorDodge, - KGBlendModeColorBurn, - KGBlendModeHardLight, - KGBlendModeSoftLight, - KGBlendModeDifference, - KGBlendModeExclusion, -// nonseperable - KGBlendModeHue, - KGBlendModeSaturation, - KGBlendModeColor, - KGBlendModeLuminosity, -}; - @class KGColor,KGColorSpace,KGShading,KGImage,KGGraphicsState,KGMutablePath,KGPath,KGPattern,KGLayer,KGPDFPage,NSMutableArray; @interface KGContext : NSObject { @@ -87,6 +66,7 @@ enum { -(NSRect)convertRectToDeviceSpace:(NSRect)rect; -(NSRect)convertRectToUserSpace:(NSRect)rect; +-(void)setCTM:(CGAffineTransform)matrix; -(void)concatCTM:(CGAffineTransform)matrix; -(void)translateCTM:(float)translatex:(float)translatey; -(void)scaleCTM:(float)scalex:(float)scaley; diff --git a/AppKit/CoreGraphics.subproj/KGContext.m b/AppKit/CoreGraphics.subproj/KGContext.m index ff44261d..73309a06 100644 --- a/AppKit/CoreGraphics.subproj/KGContext.m +++ b/AppKit/CoreGraphics.subproj/KGContext.m @@ -166,7 +166,7 @@ static inline KGGraphicsState *currentState(KGContext *self){ } -(CGAffineTransform)userSpaceToDeviceSpaceTransform { - [currentState(self) userSpaceToDeviceSpaceTransform]; + return [currentState(self) userSpaceToDeviceSpaceTransform]; } -(void)getCTM:(CGAffineTransform *)matrix { @@ -178,7 +178,7 @@ static inline KGGraphicsState *currentState(KGContext *self){ } -(NSRect)clipBoundingBox { - [currentState(self) clipBoundingBox]; + return [currentState(self) clipBoundingBox]; } -(CGAffineTransform)textMatrix { @@ -217,6 +217,10 @@ static inline KGGraphicsState *currentState(KGContext *self){ return [currentState(self) convertRectToUserSpace:rect]; } +-(void)setCTM:(CGAffineTransform)matrix { + [currentState(self) setCTM:matrix]; +} + -(void)concatCTM:(CGAffineTransform)transform { [currentState(self) concatCTM:transform]; } @@ -690,15 +694,16 @@ static inline KGGraphicsState *currentState(KGContext *self){ } -(KGLayer *)layerWithSize:(NSSize)size unused:(NSDictionary *)unused { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); + return nil; } -(void)beginPrintingWithDocumentName:(NSString *)documentName { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); } -(void)endPrinting { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); } -(BOOL)getImageableRect:(NSRect *)rect { @@ -708,7 +713,7 @@ static inline KGGraphicsState *currentState(KGContext *self){ // temporary -(void)drawContext:(KGContext *)other inRect:(CGRect)rect { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); } -(void)resetClip { diff --git a/AppKit/CoreGraphics.subproj/KGFont.h b/AppKit/CoreGraphics.subproj/KGFont.h index 029816a2..a443c6a6 100644 --- a/AppKit/CoreGraphics.subproj/KGFont.h +++ b/AppKit/CoreGraphics.subproj/KGFont.h @@ -1,7 +1,7 @@ #import #import -@class KGPDFObject,KGPDFContext; +@class KGPDFObject,KGPDFContext,KGMutablePath; enum { CGNullGlyph=0x0 @@ -16,6 +16,7 @@ typedef struct CGFontMetrics { float leading; float italicAngle; float capHeight; + float xHeight; float stemV; float stemH; float underlineThickness; @@ -74,6 +75,10 @@ typedef struct CGGlyphMetricsSet { -(float)underlineThickness; -(float)underlinePosition; -(BOOL)isFixedPitch; +-(float)italicAngle; +-(float)leading; +-(float)xHeight; +-(float)capHeight; -(unsigned)numberOfGlyphs; -(BOOL)glyphIsEncoded:(CGGlyph)glyph; @@ -98,5 +103,5 @@ typedef struct CGGlyphMetricsSet { -(void)loadGlyphRangeTable; -(void)fetchGlyphKerning; -(void)fetchAdvancementsForGlyph:(CGGlyph)glyph; - +-(void)appendCubicOutlinesToPath:(KGMutablePath *)path glyphs:(CGGlyph *)glyphs length:(unsigned)length; @end diff --git a/AppKit/CoreGraphics.subproj/KGFont.m b/AppKit/CoreGraphics.subproj/KGFont.m index a692274f..fe5a0f9e 100644 --- a/AppKit/CoreGraphics.subproj/KGFont.m +++ b/AppKit/CoreGraphics.subproj/KGFont.m @@ -169,6 +169,18 @@ static inline CGGlyphMetrics *fetchGlyphAdvancementIfNeeded(KGFont *self,CGGlyph return _metrics.isFixedPitch; } +-(float)italicAngle { + return _metrics.italicAngle; +} + +-(float)xHeight { + return _metrics.xHeight/_metrics.emsquare*_metrics.scale; +} + +-(float)capHeight { + return _metrics.capHeight/_metrics.emsquare*_metrics.scale; +} + -(unsigned)numberOfGlyphs { return _glyphInfoSet->numberOfGlyphs; } @@ -412,4 +424,8 @@ static inline CGGlyphMetrics *fetchGlyphAdvancementIfNeeded(KGFont *self,CGGlyph NSInvalidAbstractInvocation(); } +-(void)appendCubicOutlinesToPath:(KGMutablePath *)path glyphs:(CGGlyph *)glyphs length:(unsigned)length { + NSInvalidAbstractInvocation(); +} + @end diff --git a/AppKit/CoreGraphics.subproj/KGGraphicsState.h b/AppKit/CoreGraphics.subproj/KGGraphicsState.h index bff76c17..7625acad 100755 --- a/AppKit/CoreGraphics.subproj/KGGraphicsState.h +++ b/AppKit/CoreGraphics.subproj/KGGraphicsState.h @@ -37,7 +37,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI CGColorRenderingIntent _renderingIntent; int _blendMode; float _flatness; - int _interpolationQuality; + CGInterpolationQuality _interpolationQuality; NSSize _shadowOffset; float _shadowBlur; KGColor *_shadowColor; @@ -57,7 +57,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(CGAffineTransform)ctm; -(NSRect)clipBoundingBox; -(CGAffineTransform)textMatrix; --(int)interpolationQuality; +-(CGInterpolationQuality)interpolationQuality; -(NSPoint)textPosition; -(NSPoint)convertPointToDeviceSpace:(NSPoint)point; -(NSPoint)convertPointToUserSpace:(NSPoint)point; @@ -66,6 +66,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(NSRect)convertRectToDeviceSpace:(NSRect)rect; -(NSRect)convertRectToUserSpace:(NSRect)rect; +-(void)setCTM:(CGAffineTransform)transform; -(void)concatCTM:(CGAffineTransform)transform; -(void)clipToPath:(KGPath *)path; diff --git a/AppKit/CoreGraphics.subproj/KGGraphicsState.m b/AppKit/CoreGraphics.subproj/KGGraphicsState.m index b68368f7..25969b14 100755 --- a/AppKit/CoreGraphics.subproj/KGGraphicsState.m +++ b/AppKit/CoreGraphics.subproj/KGGraphicsState.m @@ -68,6 +68,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(CGAffineTransform)userSpaceToDeviceSpaceTransform { NSUnimplementedMethod(); + return CGAffineTransformIdentity; } -(CGAffineTransform)ctm { @@ -83,10 +84,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return _textTransform; } --(int)interpolationQuality { +-(CGInterpolationQuality)interpolationQuality { + return _interpolationQuality; } -(NSPoint)textPosition { +// FIX, is this right? + return NSMakePoint(_textTransform.tx,_textTransform.ty); } -(NSPoint)convertPointToDeviceSpace:(NSPoint)point { @@ -106,9 +110,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI } -(NSRect)convertRectToDeviceSpace:(NSRect)rect { + NSUnimplementedMethod(); + return NSMakeRect(0,0,0,0); } -(NSRect)convertRectToUserSpace:(NSRect)rect { + NSUnimplementedMethod(); + return NSMakeRect(0,0,0,0); +} + +-(void)setCTM:(CGAffineTransform)transform { + _ctm=transform; } -(void)concatCTM:(CGAffineTransform)transform { diff --git a/AppKit/CoreGraphics.subproj/KGImage.m b/AppKit/CoreGraphics.subproj/KGImage.m index 49e2c748..f02a7240 100644 --- a/AppKit/CoreGraphics.subproj/KGImage.m +++ b/AppKit/CoreGraphics.subproj/KGImage.m @@ -280,6 +280,7 @@ const char *KGImageNameWithIntent(CGColorRenderingIntent intent){ return image; } + return nil; } @end diff --git a/AppKit/CoreGraphics.subproj/KGLayer.m b/AppKit/CoreGraphics.subproj/KGLayer.m index 2f957414..87d77f67 100644 --- a/AppKit/CoreGraphics.subproj/KGLayer.m +++ b/AppKit/CoreGraphics.subproj/KGLayer.m @@ -26,6 +26,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(KGContext *)cgContext { NSInvalidAbstractInvocation(); + return nil; } -(NSSize)size { diff --git a/AppKit/CoreGraphics.subproj/KGMutablePath.h b/AppKit/CoreGraphics.subproj/KGMutablePath.h index 2644d41d..0700fb1e 100644 --- a/AppKit/CoreGraphics.subproj/KGMutablePath.h +++ b/AppKit/CoreGraphics.subproj/KGMutablePath.h @@ -9,6 +9,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import "KGPath.h" #import +void KGMutablePathEllipseToBezier(NSPoint *cp,float x,float y,float xradius,float yradius); + @interface KGMutablePath : KGPath { unsigned _capacityOfOperators; unsigned _capacityOfPoints; @@ -40,4 +42,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(void)applyTransform:(CGAffineTransform)matrix; +-(void)setPoints:(NSPoint *)points count:(unsigned)count atIndex:(unsigned)index; + @end diff --git a/AppKit/CoreGraphics.subproj/KGMutablePath.m b/AppKit/CoreGraphics.subproj/KGMutablePath.m index 46ddef7e..85e261cf 100644 --- a/AppKit/CoreGraphics.subproj/KGMutablePath.m +++ b/AppKit/CoreGraphics.subproj/KGMutablePath.m @@ -10,12 +10,41 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import "KGMutablePath.h" #import "KGPath.h" -// Bezier and arc to bezier algorithms from: Windows Graphics Programming by Feng Yuan +// ellipse to 4 spline bezier, http://www.tinaja.com/glib/ellipse4.pdf +void KGMutablePathEllipseToBezier(NSPoint *cp,float x,float y,float xrad,float yrad){ + float magic=0.551784; + float xmag=xrad*magic; + float ymag=yrad*magic; + int i=0; + + cp[i++]=NSMakePoint(-xrad,0); + + cp[i++]=NSMakePoint(-xrad,ymag); + cp[i++]=NSMakePoint(-xmag,yrad); + cp[i++]=NSMakePoint(0,yrad); + + cp[i++]=NSMakePoint(xmag,yrad); + cp[i++]=NSMakePoint(xrad,ymag); + cp[i++]=NSMakePoint(xrad,0); + + cp[i++]=NSMakePoint(xrad,-ymag); + cp[i++]=NSMakePoint(xmag,-yrad); + cp[i++]=NSMakePoint(0,-yrad); + + cp[i++]=NSMakePoint(-xmag,-yrad); + cp[i++]=NSMakePoint(-xrad,-ymag); + cp[i++]=NSMakePoint(-xrad,0); + + for(i=0;i<13;i++){ + cp[i].x+=x; + cp[i].y+=y; + } +} @implementation KGMutablePath +// Bezier and arc to bezier algorithms from: Windows Graphics Programming by Feng Yuan #if 0 -// this should go in a rendering context static void bezier(KGGraphicsState *self,double x1,double y1,double x2, double y2,double x3,double y3,double x4,double y4){ // Ax+By+C=0 is the line (x1,y1) (x4,y4); double A=y4-y1; @@ -236,7 +265,18 @@ static void expandPointCapacity(KGMutablePath *self,unsigned delta){ } -(void)addEllipseInRect:(NSRect)rect withTransform:(CGAffineTransform *)matrix { - NSUnimplementedMethod(); + float xradius=rect.size.width/2; + float yradius=rect.size.height/2; + float x=rect.origin.x+xradius; + float y=rect.origin.y+yradius; + NSPoint cp[13]; + int i; + + KGMutablePathEllipseToBezier(cp,x,y,xradius,yradius); + + [self moveToPoint:cp[0] withTransform:matrix]; + for(i=0;i<12;i+=3) + [self addCurveToControlPoint:cp[i] controlPoint:cp[i+1] endPoint:cp[i+2] withTransform:matrix]; } -(void)addPath:(KGPath *)path withTransform:(CGAffineTransform *)matrix { @@ -269,4 +309,11 @@ static void expandPointCapacity(KGMutablePath *self,unsigned delta){ _points[i]=CGPointApplyAffineTransform(_points[i],matrix); } +-(void)setPoints:(NSPoint *)points count:(unsigned)count atIndex:(unsigned)index { + int i; + + for(i=0;i diff --git a/AppKit/CoreGraphics.subproj/KGPDFOperators.m b/AppKit/CoreGraphics.subproj/KGPDFOperators.m index e0a0f63a..f4a7d90a 100644 --- a/AppKit/CoreGraphics.subproj/KGPDFOperators.m +++ b/AppKit/CoreGraphics.subproj/KGPDFOperators.m @@ -424,37 +424,37 @@ void KGPDF_render_gs(KGPDFScanner *scanner,void *info) { if([graphicsState getNameForKey:"BM" value:&name]){ if(strcmp(name,"Normal")==0) - [context setBlendMode:KGBlendModeNormal]; + [context setBlendMode:kCGBlendModeNormal]; else if(strcmp(name,"Multiply")==0) - [context setBlendMode:KGBlendModeMultiply]; + [context setBlendMode:kCGBlendModeMultiply]; else if(strcmp(name,"Screen")==0) - [context setBlendMode:KGBlendModeScreen]; + [context setBlendMode:kCGBlendModeScreen]; else if(strcmp(name,"Overlay")==0) - [context setBlendMode:KGBlendModeOverlay]; + [context setBlendMode:kCGBlendModeOverlay]; else if(strcmp(name,"Darken")==0) - [context setBlendMode:KGBlendModeDarken]; + [context setBlendMode:kCGBlendModeDarken]; else if(strcmp(name,"Lighten")==0) - [context setBlendMode:KGBlendModeLighten]; + [context setBlendMode:kCGBlendModeLighten]; else if(strcmp(name,"ColorDodge")==0) - [context setBlendMode:KGBlendModeColorDodge]; + [context setBlendMode:kCGBlendModeColorDodge]; else if(strcmp(name,"ColorBurn")==0) - [context setBlendMode:KGBlendModeColorBurn]; + [context setBlendMode:kCGBlendModeColorBurn]; else if(strcmp(name,"HardLight")==0) - [context setBlendMode:KGBlendModeHardLight]; + [context setBlendMode:kCGBlendModeHardLight]; else if(strcmp(name,"SoftLight")==0) - [context setBlendMode:KGBlendModeSoftLight]; + [context setBlendMode:kCGBlendModeSoftLight]; else if(strcmp(name,"Difference")==0) - [context setBlendMode:KGBlendModeDifference]; + [context setBlendMode:kCGBlendModeDifference]; else if(strcmp(name,"Exclusion")==0) - [context setBlendMode:KGBlendModeExclusion]; + [context setBlendMode:kCGBlendModeExclusion]; else if(strcmp(name,"Hue")==0) - [context setBlendMode:KGBlendModeHue]; + [context setBlendMode:kCGBlendModeHue]; else if(strcmp(name,"Saturation")==0) - [context setBlendMode:KGBlendModeSaturation]; + [context setBlendMode:kCGBlendModeSaturation]; else if(strcmp(name,"Color")==0) - [context setBlendMode:KGBlendModeColor]; + [context setBlendMode:kCGBlendModeColor]; else if(strcmp(name,"Luminosity")==0) - [context setBlendMode:KGBlendModeLuminosity]; + [context setBlendMode:kCGBlendModeLuminosity]; else NSLog(@"Unknown blend mode %s",name); } diff --git a/AppKit/CoreGraphics.subproj/KGPDFScanner.m b/AppKit/CoreGraphics.subproj/KGPDFScanner.m index d7651376..33c12da2 100644 --- a/AppKit/CoreGraphics.subproj/KGPDFScanner.m +++ b/AppKit/CoreGraphics.subproj/KGPDFScanner.m @@ -1071,7 +1071,7 @@ BOOL KGPDFParseIndirectObject(NSData *data,KGPDFInteger position,KGPDFObject **o NSArray *streams=[_stream streams]; int i,count=[streams count]; - for(i=0;iorigin=_points[0]; + rect->size=NSMakeSize(_points[1].x-_points[0].x,_points[2].y-_points[0].y); + + return YES; } -(BOOL)containsPoint:(NSPoint)point evenOdd:(BOOL)evenOdd withTransform:(CGAffineTransform *)matrix { @@ -110,8 +134,33 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI } -(NSRect)boundingBox { - NSUnimplementedMethod(); - return NSZeroRect; + NSRect result; + int i; + + if(_numberOfPoints==0) + return NSZeroRect; + + result.origin=_points[0]; + result.size=NSMakeSize(0,0); + for(i=1;i<_numberOfPoints;i++){ + NSPoint point=_points[i]; + + if(point.x>NSMaxX(result)) + result.size.width=point.x-NSMinX(result); + else if(point.xNSMaxY(result)) + result.size.height=point.y-NSMinY(result); + else if(point.y + +@class NSBezierPath; + +@interface NSAffineTransform(AppKit) + +-(void)concat; +-(void)set; + +-(NSBezierPath *)transformBezierPath:(NSBezierPath *)bezierPath; + +@end diff --git a/AppKit/NSAffineTransform.m b/AppKit/NSAffineTransform.m index e69de29b..24016e75 100644 --- a/AppKit/NSAffineTransform.m +++ b/AppKit/NSAffineTransform.m @@ -0,0 +1,44 @@ +#import +#import +#import +#import + +@implementation NSAffineTransform(AppKit) + +-(void)concat { + NSAffineTransformStruct atStruct=[self transformStruct]; + CGAffineTransform cgMatrix; + + cgMatrix.a=atStruct.m11; + cgMatrix.b=atStruct.m12; + cgMatrix.c=atStruct.m21; + cgMatrix.d=atStruct.m22; + cgMatrix.tx=atStruct.tX; + cgMatrix.ty=atStruct.tY; + + CGContextConcatCTM([[NSGraphicsContext currentContext] graphicsPort],cgMatrix); +} + +-(void)set { + NSAffineTransformStruct atStruct=[self transformStruct]; + CGAffineTransform cgMatrix; + + cgMatrix.a=atStruct.m11; + cgMatrix.b=atStruct.m12; + cgMatrix.c=atStruct.m21; + cgMatrix.d=atStruct.m22; + cgMatrix.tx=atStruct.tX; + cgMatrix.ty=atStruct.tY; + + CGContextSetCTM([[NSGraphicsContext currentContext] graphicsPort],cgMatrix); +} + +-(NSBezierPath *)transformBezierPath:(NSBezierPath *)bezierPath { + NSBezierPath *result=[[bezierPath copy] autorelease]; + + [result transformUsingAffineTransform:self]; + + return result; +} + +@end diff --git a/AppKit/NSAnimation/NSAnimation.h b/AppKit/NSAnimation/NSAnimation.h index ad518041..d4720e47 100644 --- a/AppKit/NSAnimation/NSAnimation.h +++ b/AppKit/NSAnimation/NSAnimation.h @@ -9,6 +9,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import +@class NSMutableArray; + typedef enum { NSAnimationEaseInOut, NSAnimationEaseIn, @@ -32,7 +34,7 @@ APPKIT_EXPORT NSString *NSAnimationProgressMarkNotification; float _frameRate; NSAnimationBlockingMode _blockingMode; id _delegate; - NSArray *_progressMarks; + NSMutableArray *_progressMarks; float _currentValue; NSArray *_runLoopModes; } diff --git a/AppKit/NSAnimation/NSAnimation.m b/AppKit/NSAnimation/NSAnimation.m index 9863aab6..9db3ad57 100644 --- a/AppKit/NSAnimation/NSAnimation.m +++ b/AppKit/NSAnimation/NSAnimation.m @@ -9,6 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import NSString *NSAnimationProgressMarkNotification=@"NSAnimationProgressMarkNotification"; @@ -20,7 +21,7 @@ NSString *NSAnimationProgressMarkNotification=@"NSAnimationProgressMarkNotificat _frameRate=30; _blockingMode=NSAnimationBlocking; _delegate=nil; - _progressMarks=nil; + _progressMarks=[NSMutableArray new]; _currentValue=0; _runLoopModes=nil; // nil== default, modal and event tracking return self; @@ -77,12 +78,18 @@ NSString *NSAnimationProgressMarkNotification=@"NSAnimationProgressMarkNotificat } -(void)setProgressMarks:(NSArray *)marks { - marks=[marks copy]; + NSMutableArray *mcopy=[marks mutableCopy]; [_progressMarks release]; - _progressMarks=marks; + _progressMarks=mcopy; } -(void)addProgressMark:(NSAnimationProgress)mark { + if(mark<0) + mark=0; + else if(mark>1) + mark=1; + + [_progressMarks addObject:[NSNumber numberWithFloat:mark]]; NSUnimplementedMethod(); } diff --git a/AppKit/NSApplication.h b/AppKit/NSApplication.h index 263e32a4..745a349c 100755 --- a/AppKit/NSApplication.h +++ b/AppKit/NSApplication.h @@ -22,6 +22,18 @@ APPKIT_EXPORT NSString *NSApplicationDidBecomeActiveNotification; APPKIT_EXPORT NSString *NSApplicationWillResignActiveNotification; APPKIT_EXPORT NSString *NSApplicationDidResignActiveNotification; +APPKIT_EXPORT NSString *NSApplicationWillUpdateNotification; +APPKIT_EXPORT NSString *NSApplicationDidUpdateNotification; + +APPKIT_EXPORT NSString *NSApplicationWillHideNotification; +APPKIT_EXPORT NSString *NSApplicationDidHideNotification; +APPKIT_EXPORT NSString *NSApplicationWillUnhideNotification; +APPKIT_EXPORT NSString *NSApplicationDidUnhideNotification; + +APPKIT_EXPORT NSString *NSApplicationWillTerminateNotification; + +APPKIT_EXPORT NSString *NSApplicationDidChangeScreenParametersNotification; + APPKIT_EXPORT id NSApp; typedef id NSModalSession; @@ -35,8 +47,26 @@ enum { typedef enum { NSTerminateCancel, NSTerminateNow, + NSTerminateLater, } NSApplicationTerminateReply; +typedef enum { + NSCriticalRequest, + NSInformationalRequest, +} NSRequestUserAttentionType; + +typedef enum { + NSApplicationDelegateReplySuccess, + NSApplicationDelegateReplyCancel, + NSApplicationDelegateReplyFailure, +} NSApplicationDelegateReply; + +typedef enum { + NSPrintingCancelled, + NSPrintingSuccess, + NSPrintingReplyLater, + NSPrintingFailure, +} NSApplicationPrintReply; @interface NSApplication : NSResponder { NSDisplay *_display; @@ -47,7 +77,9 @@ typedef enum { NSImage *_applicationIconImage; + BOOL _isRunning; BOOL _isActive; + BOOL _windowsNeedUpdate; NSEvent *_currentEvent; NSMutableArray *_modalStack; @@ -55,16 +87,31 @@ typedef enum { +(NSApplication *)sharedApplication; ++(void)detachDrawingThread:(SEL)selector toTarget:target withObject:object; + -init; +-(NSGraphicsContext *)context; + -delegate; -(NSArray *)windows; +-(NSWindow *)windowWithWindowNumber:(int)number; + -(NSMenu *)mainMenu; -(NSMenu *)windowsMenu; -(NSWindow *)mainWindow; -(NSWindow *)keyWindow; -(NSImage *)applicationIconImage; -(BOOL)isActive; +-(BOOL)isHidden; +-(BOOL)isRunning; + +-(NSWindow *)makeWindowsPerform:(SEL)selector inOrder:(BOOL)inOrder; +-(void)miniaturizeAll:sender; + +-(NSArray *)orderedDocuments; +-(NSArray *)orderedWindows; +-(void)preventWindowOrdering; -(void)setDelegate:delegate; -(void)setMainMenu:(NSMenu *)menu; @@ -74,6 +121,7 @@ typedef enum { -(void)addWindowsItem:(NSWindow *)window title:(NSString *)title filename:(BOOL)filename; -(void)changeWindowsItem:(NSWindow *)window title:(NSString *)title filename:(BOOL)filename; -(void)removeWindowsItem:(NSWindow *)window; +-(void)updateWindowsItem:(NSWindow *)window; -(void)finishLaunching; -(void)run; @@ -86,11 +134,15 @@ typedef enum { -(void)postEvent:(NSEvent *)event atStart:(BOOL)atStart; -targetForAction:(SEL)action; +-targetForAction:(SEL)action to:target from:sender; -(BOOL)sendAction:(SEL)action to:target from:sender; +-(BOOL)tryToPerform:(SEL)selector with:object; +-(void)setWindowsNeedUpdate:(BOOL)value; -(void)updateWindows; -(void)activateIgnoringOtherApps:(BOOL)flag; +-(void)deactivate; -(NSWindow *)modalWindow; -(NSModalSession)beginModalSessionForWindow:(NSWindow *)window; @@ -108,14 +160,24 @@ typedef enum { -(void)reportException:(NSException *)exception; +-(int)requestUserAttention:(NSRequestUserAttentionType)attentionType; +-(void)cancelUserAttentionRequest:(int)requestNumber; + -(void)runPageLayout:sender; -(void)orderFrontColorPanel:sender; +-(void)orderFrontCharacterPalette:sender; -(void)hide:sender; +-(void)hideOtherApplications:sender; -(void)unhide:sender; +-(void)unhideAllApplications:sender; +-(void)unhideWithoutActivation; -(void)stop:sender; -(void)terminate:sender; +-(void)replyToApplicationShouldTerminate:(BOOL)terminate; +-(void)replyToOpenOrPrint:(NSApplicationDelegateReply)reply; + -(void)arrangeInFront:sender; -(NSMenu *)servicesMenu; @@ -123,9 +185,12 @@ typedef enum { -servicesProvider; -(void)setServicesProvider:provider; -(void)registerServicesMenuSendTypes:(NSArray *)sendTypes returnTypes:(NSArray *)returnTypes; +-validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType; -(void)orderFrontStandardAboutPanel:sender; -(void)orderFrontStandardAboutPanelWithOptions:(NSDictionary *)options; +-(void)activateContextHelpMode:sender; +-(void)showHelp:sender; // private -(void)_addWindow:(NSWindow *)window; @@ -143,13 +208,45 @@ typedef enum { @interface NSObject(NSApplication_notifications) -(void)applicationWillFinishLaunching:(NSNotification *)note; -(void)applicationDidFinishLaunching:(NSNotification *)note; + +-(void)applicationWillBecomeActive:(NSNotification *)note; -(void)applicationDidBecomeActive:(NSNotification *)note; +-(void)applicationWillResignActive:(NSNotification *)note; +-(void)applicationDidResignActive:(NSNotification *)note; + +-(void)applicationWillUpdate:(NSNotification *)note; +-(void)applicationDidUpdate:(NSNotification *)note; + +-(void)applicationWillHide:(NSNotification *)note; +-(void)applicationDidHide:(NSNotification *)note; +-(void)applicationWillUnhide:(NSNotification *)note; +-(void)applicationDidUnhide:(NSNotification *)note; + +-(void)applicationWillTerminate:(NSNotification *)note; + +-(void)applicationDidChangeScreenParameters:(NSNotification *)note; @end @interface NSObject(NSApplication_delegate) --(BOOL)application:sender openFile:(NSString *)path; --(BOOL)application:sender openTempFile:(NSString *)path; +-(BOOL)applicationShouldOpenUntitledFile:(NSApplication *)application; +-(BOOL)applicationOpenUntitledFile:(NSApplication *)application; +-(BOOL)application:(NSApplication *)application openFile:(NSString *)path; +-(void)application:(NSApplication *)application openFiles:(NSArray *)pathArray; +-(BOOL)application:(NSApplication *)application openFileWithoutUI:(NSString *)path; +-(BOOL)application:(NSApplication *)applicationsender openTempFile:(NSString *)path; +-(BOOL)applicationShouldHandleReopen:(NSApplication *)application hasVisibleWindows:(BOOL)visible; + +-(BOOL)application:(NSApplication *)application printFile:(NSString *)path; +-(NSApplicationPrintReply)application:(NSApplication *)application printFiles:(NSArray *)pathArray withSettings:(NSDictionary *)settings showPrintPanels:(BOOL)showPanel; + +-(NSMenu *)applicationDockMenu:(NSApplication *)application; +-(BOOL)application:(NSApplication *)application delegateHandlesKey:(NSString *)key; + +-(NSError *)application:(NSApplication *)application willPresentError:(NSError *)error; + +-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)application; -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)application; + @end APPKIT_EXPORT int NSApplicationMain(int argc, const char *argv[]); diff --git a/AppKit/NSApplication.m b/AppKit/NSApplication.m index 3f98b492..e4859788 100755 --- a/AppKit/NSApplication.m +++ b/AppKit/NSApplication.m @@ -22,6 +22,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import #import NSString *NSModalPanelRunLoopMode=@"NSModalPanelRunLoopMode"; @@ -35,6 +36,18 @@ NSString *NSApplicationDidBecomeActiveNotification=@"NSApplicationDidBecomeActiv NSString *NSApplicationWillResignActiveNotification=@"NSApplicationWillResignActiveNotification"; NSString *NSApplicationDidResignActiveNotification=@"NSApplicationDidResignActiveNotification"; +NSString *NSApplicationWillUpdateNotification=@"NSApplicationWillUpdateNotification"; +NSString *NSApplicationDidUpdateNotification=@"NSApplicationDidUpdateNotification"; + +NSString *NSApplicationWillHideNotification=@"NSApplicationWillHideNotification"; +NSString *NSApplicationDidHideNotification=@"NSApplicationDidHideNotification"; +NSString *NSApplicationWillUnhideNotification=@"NSApplicationWillUnhideNotification"; +NSString *NSApplicationDidUnhideNotification=@"NSApplicationDidUnhideNotification"; + +NSString *NSApplicationWillTerminateNotification=@"NSApplicationWillTerminateNotification"; + +NSString *NSApplicationDidChangeScreenParametersNotification=@"NSApplicationDidChangeScreenParametersNotification"; + @implementation NSApplication id NSApp=nil; @@ -56,6 +69,10 @@ id NSApp=nil; return NSApp; } ++(void)detachDrawingThread:(SEL)selector toTarget:target withObject:object { + NSUnimplementedMethod(); +} + -init { _display=[[NSDisplay currentDisplay] retain]; [_display showSplashImage]; @@ -68,6 +85,11 @@ id NSApp=nil; return self; } +-(NSGraphicsContext *)context { + NSUnimplementedMethod(); + return nil; +} + -delegate { return _delegate; } @@ -76,6 +98,19 @@ id NSApp=nil; return _windows; } +-(NSWindow *)windowWithWindowNumber:(int)number { + int i,count=[_windows count]; + + for(i=0;i=0) + [[_windows objectAtIndex:count] miniaturize:sender]; +} + +-(NSArray *)orderedDocuments { + NSUnimplementedMethod(); + return nil; +} + +-(NSArray *)orderedWindows { + NSUnimplementedMethod(); + return nil; +} + +-(void)preventWindowOrdering { + NSUnimplementedMethod(); +} + -(void)registerDelegate { if([_delegate respondsToSelector:@selector(applicationWillFinishLaunching:)]){ [[NSNotificationCenter defaultCenter] addObserver:_delegate @@ -179,6 +247,10 @@ id NSApp=nil; } -(void)setApplicationIconImage:(NSImage *)image { + image=[image retain]; + [_applicationIconImage release]; + _applicationIconImage=image; + NSUnimplementedMethod(); } @@ -189,60 +261,64 @@ id NSApp=nil; } -(void)addWindowsItem:(NSWindow *)window title:(NSString *)title filename:(BOOL)isFilename { - NSMenuItem *windowItem; + NSMenuItem *item; if ([[self windowsMenu] indexOfItemWithTarget:window andAction:@selector(makeKeyAndOrderFront:)] != -1) return; - // separator management... shouldn't +separatorItem be a singleton? i dunno.. - // e.g. here, lastObject] == [NSMenuItem separatorItem] ? - windowItem = [[[self windowsMenu] itemArray] lastObject]; - if ([windowItem title] != nil && ![[windowItem target] isKindOfClass:[NSWindow class]]) + if (![[[[self windowsMenu] itemArray] lastObject] isSeparatorItem]) [[self windowsMenu] addItem:[NSMenuItem separatorItem]]; if (isFilename) - title = [NSString stringWithFormat:@"%@ -- %@", [title lastPathComponent], - [title stringByDeletingLastPathComponent]]; + title = [NSString stringWithFormat:@"%@ -- %@", [title lastPathComponent],[title stringByDeletingLastPathComponent]]; - windowItem = [[[NSMenuItem alloc] initWithTitle:title - action:@selector(makeKeyAndOrderFront:) - keyEquivalent:@""] autorelease]; - [windowItem setTarget:window]; + item = [[[NSMenuItem alloc] initWithTitle:title action:@selector(makeKeyAndOrderFront:) keyEquivalent:@""] autorelease]; + [item setTarget:window]; - [[self windowsMenu] addItem:windowItem]; - //NSLog(@"add: %@ %@ %@", [self windowsMenu], title, windowItem); + [[self windowsMenu] addItem:item]; } -(void)changeWindowsItem:(NSWindow *)window title:(NSString *)title filename:(BOOL)isFilename { - int itemIndex = [[self windowsMenu] indexOfItemWithTarget:window - andAction:@selector(makeKeyAndOrderFront:)]; + int itemIndex = [[self windowsMenu] indexOfItemWithTarget:window andAction:@selector(makeKeyAndOrderFront:)]; if (itemIndex != -1) { - NSMenuItem *windowItem = [[self windowsMenu] itemAtIndex:itemIndex]; + NSMenuItem *item = [[self windowsMenu] itemAtIndex:itemIndex]; if (isFilename) - title = [NSString stringWithFormat:@"%@ -- %@", - [title lastPathComponent], [title stringByDeletingLastPathComponent]]; + title = [NSString stringWithFormat:@"%@ -- %@",[title lastPathComponent], [title stringByDeletingLastPathComponent]]; - [windowItem setTitle:title]; - [[self windowsMenu] itemChanged:windowItem]; + [item setTitle:title]; + [[self windowsMenu] itemChanged:item]; } else [self addWindowsItem:window title:title filename:isFilename]; } -(void)removeWindowsItem:(NSWindow *)window { - int itemIndex = [[self windowsMenu] indexOfItemWithTarget:window - andAction:@selector(makeKeyAndOrderFront:)]; + int itemIndex = [[self windowsMenu] indexOfItemWithTarget:window andAction:@selector(makeKeyAndOrderFront:)]; + if (itemIndex != -1) { [[self windowsMenu] removeItemAtIndex:itemIndex]; - // separator - if ([[[[self windowsMenu] itemArray] lastObject] title] == nil) + if ([[[[self windowsMenu] itemArray] lastObject] isSeparatorItem]) [[self windowsMenu] removeItem:[[[self windowsMenu] itemArray] lastObject]]; } } +-(void)updateWindowsItem:(NSWindow *)window { +#if 0 + NSUnimplementedMethod(); +#else + NSMenu *menu=[self windowsMenu]; + int itemIndex=[[self windowsMenu] indexOfItemWithTarget:window andAction:@selector(makeKeyAndOrderFront:)]; + + if(itemIndex!=-1){ + NSMenuItem *item=[menu itemAtIndex:itemIndex]; + + } +#endif +} + -(void)finishLaunching { NSAutoreleasePool *pool=[NSAutoreleasePool new]; BOOL needsUntitled=YES; @@ -324,7 +400,9 @@ id NSApp=nil; -(void)run { [self finishLaunching]; - + + _isRunning=YES; + do { NSAutoreleasePool *pool=[NSAutoreleasePool new]; NSEvent *event; @@ -345,7 +423,7 @@ id NSApp=nil; [self _checkForTerminate]; [pool release]; - }while(YES); + }while(_isRunning); } -(BOOL)_performKeyEquivalent:(NSEvent *)event { @@ -447,6 +525,11 @@ id NSApp=nil; return nil; } +-targetForAction:(SEL)action to:target from:sender { + NSUnimplementedMethod(); + return nil; +} + -(BOOL)sendAction:(SEL)action to:target from:sender { //NSLog(@"%s %s %@ %@",SELNAME(_cmd),action,target,sender); @@ -465,6 +548,16 @@ id NSApp=nil; return NO; } +-(BOOL)tryToPerform:(SEL)selector with:object { + NSUnimplementedMethod(); + return NO; +} + +-(void)setWindowsNeedUpdate:(BOOL)value { + _windowsNeedUpdate=value; + NSUnimplementedMethod(); +} + -(void)updateWindows { [_windows makeObjectsPerformSelector:@selector(update)]; } @@ -473,6 +566,10 @@ id NSApp=nil; NSUnimplementedMethod(); } +-(void)deactivate { + NSUnimplementedMethod(); +} + -(NSWindow *)modalWindow { return [[_modalStack lastObject] modalWindow]; } @@ -590,6 +687,15 @@ id NSApp=nil; NSLog(@"NSApplication got exception: %@",exception); } +-(int)requestUserAttention:(NSRequestUserAttentionType)attentionType { + NSUnimplementedMethod(); + return 0; +} + +-(void)cancelUserAttentionRequest:(int)requestNumber { + NSUnimplementedMethod(); +} + -(void)runPageLayout:sender { [[NSPageLayout pageLayout] runModal]; } @@ -598,18 +704,39 @@ id NSApp=nil; [[NSColorPanel sharedColorPanel] orderFront:sender]; } +-(void)orderFrontCharacterPalette:sender { + NSUnimplementedMethod(); +} + -(void)hide:sender { NSUnimplementedMethod(); } +-(void)hideOtherApplications:sender { + NSUnimplementedMethod(); +} + -(void)unhide:sender { NSUnimplementedMethod(); } --(void)stop:sender { +-(void)unhideAllApplications:sender { NSUnimplementedMethod(); } +-(void)unhideWithoutActivation { + NSUnimplementedMethod(); +} + +-(void)stop:sender { + if([_modalStack lastObject]!=nil){ + [self stopModal]; + return; + } + + _isRunning=NO; +} + -(void)terminate:sender { if([_delegate respondsToSelector:@selector(applicationShouldTerminate:)]){ if(![_delegate applicationShouldTerminate:self]){ @@ -622,6 +749,14 @@ id NSApp=nil; exit(0); } +-(void)replyToApplicationShouldTerminate:(BOOL)terminate { + NSUnimplementedMethod(); +} + +-(void)replyToOpenOrPrint:(NSApplicationDelegateReply)reply { + NSUnimplementedMethod(); +} + -(void)arrangeInFront:sender { #define CASCADE_DELTA 20 // ? isn't there a call for this? NSMutableArray *visibleWindows = [NSMutableArray new]; @@ -660,10 +795,6 @@ id NSApp=nil; } } --(void)showHelp:sender { - NSUnimplementedMethod(); -} - -(NSMenu *)servicesMenu { return [[NSApp mainMenu] _menuWithName:@"_NSServicesMenu"]; } @@ -683,6 +814,12 @@ id NSApp=nil; //tiredofthesewarnings NSUnsupportedMethod(); } +-validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType { + NSUnimplementedMethod(); + return nil; +} + + -(void)orderFrontStandardAboutPanel:sender { [self orderFrontStandardAboutPanelWithOptions:nil]; } @@ -691,6 +828,13 @@ id NSApp=nil; NSUnimplementedMethod(); } +-(void)activateContextHelpMode:sender { + NSUnimplementedMethod(); +} + +-(void)showHelp:sender { + NSUnimplementedMethod(); +} - (void)doCommandBySelector:(SEL)selector { if ([_delegate respondsToSelector:selector]) diff --git a/AppKit/NSAttributedString.h b/AppKit/NSAttributedString.h index 1d2e8ecb..18d4af47 100755 --- a/AppKit/NSAttributedString.h +++ b/AppKit/NSAttributedString.h @@ -8,31 +8,103 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import +#import -@class NSFont,NSColor,NSParagraphStyle,NSTextAttachment; +@class NSFont,NSColor,NSParagraphStyle,NSTextAttachment,NSFileWrapper,NSTextList,NSTextBlock,NSTextTable; APPKIT_EXPORT NSString *NSFontAttributeName; APPKIT_EXPORT NSString *NSParagraphStyleAttributeName; APPKIT_EXPORT NSString *NSForegroundColorAttributeName; APPKIT_EXPORT NSString *NSBackgroundColorAttributeName; - APPKIT_EXPORT NSString *NSUnderlineStyleAttributeName; +APPKIT_EXPORT NSString *NSUnderlineColorAttributeName; APPKIT_EXPORT NSString *NSAttachmentAttributeName; APPKIT_EXPORT NSString *NSKernAttributeName; APPKIT_EXPORT NSString *NSLigatureAttributeName; - +APPKIT_EXPORT NSString *NSStrikethroughStyleAttributeName; +APPKIT_EXPORT NSString *NSStrikethroughColorAttributeName; +APPKIT_EXPORT NSString *NSObliquenessAttributeName; +APPKIT_EXPORT NSString *NSStrokeWidthAttributeName; +APPKIT_EXPORT NSString *NSStrokeColorAttributeName; +APPKIT_EXPORT NSString *NSBaselineOffsetAttributeName; +APPKIT_EXPORT NSString *NSSuperscriptAttributeName; +APPKIT_EXPORT NSString *NSLinkAttributeName; +APPKIT_EXPORT NSString *NSShadowAttributeName; +APPKIT_EXPORT NSString *NSExpansionAttributeName; +APPKIT_EXPORT NSString *NSCursorAttributeName; +APPKIT_EXPORT NSString *NSToolTipAttributeName; APPKIT_EXPORT NSString *NSBackgroundColorDocumentAttribute; enum { - NSNoUnderlineStyle, - NSSingleUnderlineStyle + NSUnderlineStyleNone, + NSUnderlineStyleSingle, + NSUnderlineStyleThick, + NSUnderlineStyleDouble, +}; + +enum { + NSUnderlinePatternSolid=0x000, + NSUnderlinePatternDot=0x100, + NSUnderlinePatternDash=0x200, + NSUnderlinePatternDashDot=0x300, + NSUnderlinePatternDashDotDot=0x400, }; @interface NSAttributedString(NSAttributedString_AppKit) --initWithPath:(NSString *)path documentAttributes:(NSDictionary **)attributes; --(NSRange)doubleClickAtIndex:(unsigned)location; --(unsigned)nextWordFromIndex:(unsigned)location forward:(BOOL)forward; + ++(NSArray *)textFileTypes; ++(NSArray *)textPasteboardTypes; + ++(NSArray *)textUnfilteredFileTypes; ++(NSArray *)textUnfilteredPasteboardTypes; + +(NSAttributedString *)attributedStringWithAttachment:(NSTextAttachment *)attachment; + +-initWithData:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary **)attributes error:(NSError **)error; +-initWithDocFormat:(NSData *)werd documentAttributes:(NSDictionary **)attributes; + +-initWithHTML:(NSData *)html baseURL:(NSURL *)url documentAttributes:(NSDictionary **)attributes; +-initWithHTML:(NSData *)html documentAttributes:(NSDictionary **)attributes; +-initWithHTML:(NSData *)html options:(NSDictionary *)options documentAttributes:(NSDictionary **)attributes; +-initWithPath:(NSString *)path documentAttributes:(NSDictionary **)attributes; + +-initWithRTF:(NSData *)rtf documentAttributes:(NSDictionary **)attributes; + +-initWithRTFD:(NSData *)rtfd documentAttributes:(NSDictionary **)attributes; +-initWithRTFDFileWrapper:(NSFileWrapper *)wrapper documentAttributes:(NSDictionary **)attributes; + +-initWithURL:(NSURL *)url documentAttributes:(NSDictionary **)attributes; +-initWithURL:(NSURL *)url options:(NSDictionary *)options documentAttributes:(NSDictionary **)attributes error:(NSError **)error; + +-(int)itemNumberInTextList:(NSTextList *)list atIndex:(unsigned)index; +-(unsigned)lineBreakBeforeIndex:(unsigned)index withinRange:(NSRange)range; +-(unsigned)lineBreakByHyphenatingBeforeIndex:(unsigned)index withinRange:(NSRange)range; +-(NSRange)rangeOfTextBlock:(NSTextBlock *)block atIndex:(unsigned)index; + +-(NSRange)rangeOfTextList:(NSTextList *)list atIndex:(unsigned)index; +-(NSRange)rangeOfTextTable:(NSTextTable *)table atIndex:(unsigned)index; + +-(NSFileWrapper *)RTFDFileWrapperFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes; + +-(NSData *)RTFDFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes; + +-(NSData *)RTFFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes; + +-(NSDictionary *)rulerAttributesInRange:(NSRange)range; + +-(NSRange)doubleClickAtIndex:(unsigned)index; +-(unsigned)nextWordFromIndex:(unsigned)index forward:(BOOL)forward; + +-(NSRect)boundingRectWithSize:(NSSize)size options:(NSStringDrawingOptions)options; + +-(BOOL)containsAttachments; + +-(NSData *)dataFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes error:(NSError **)error; + +-(NSData *)docFormatFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes; +-(NSFileWrapper *)fileWrapperFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes error:(NSError **)error; +-(NSDictionary *)fontAttributesInRange:(NSRange)range; + @end // private diff --git a/AppKit/NSAttributedString.m b/AppKit/NSAttributedString.m index 5850652c..e48c1209 100755 --- a/AppKit/NSAttributedString.m +++ b/AppKit/NSAttributedString.m @@ -14,20 +14,84 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import -NSString *NSFontAttributeName=@"NSFontAttributeName"; +NSString *NSFontAttributeName=@"NSFontAttributeName"; NSString *NSParagraphStyleAttributeName=@"NSParagraphStyleAttributeName"; NSString *NSForegroundColorAttributeName=@"NSForegroundColorAttributeName"; NSString *NSBackgroundColorAttributeName=@"NSBackgroundColorAttributeName"; - NSString *NSUnderlineStyleAttributeName=@"NSUnderlineStyleAttributeName"; +NSString *NSUnderlineColorAttributeName=@"NSUnderlineColorAttributeName"; NSString *NSAttachmentAttributeName=@"NSAttachmentAttributeName"; NSString *NSKernAttributeName=@"NSKernAttributeName"; NSString *NSLigatureAttributeName=@"NSLigatureAttributeName"; - +NSString *NSStrikethroughStyleAttributeName=@"NSStrikethroughStyleAttributeName"; +NSString *NSStrikethroughColorAttributeName=@"NSStrikethroughColorAttributeName"; +NSString *NSObliquenessAttributeName=@"NSObliquenessAttributeName"; +NSString *NSStrokeWidthAttributeName=@"NSStrokeWidthAttributeName"; +NSString *NSStrokeColorAttributeName=@"NSStrokeColorAttributeName"; +NSString *NSBaselineOffsetAttributeName=@"NSBaselineOffsetAttributeName"; +NSString *NSSuperscriptAttributeName=@"NSSuperscriptAttributeName"; +NSString *NSLinkAttributeName=@"NSLinkAttributeName"; +NSString *NSShadowAttributeName=@"NSShadowAttributeName"; +NSString *NSExpansionAttributeName=@"NSExpansionAttributeName"; +NSString *NSCursorAttributeName=@"NSCursorAttributeName"; +NSString *NSToolTipAttributeName=@"NSToolTipAttributeName"; NSString *NSBackgroundColorDocumentAttribute=@"NSBackgroundColorDocumentAttribute"; @implementation NSAttributedString(NSAttributedString_AppKit) ++(NSArray *)textFileTypes { + NSUnimplementedMethod(); + return nil; +} + ++(NSArray *)textPasteboardTypes { + NSUnimplementedMethod(); + return nil; +} + ++(NSArray *)textUnfilteredFileTypes { + NSUnimplementedMethod(); + return nil; +} + ++(NSArray *)textUnfilteredPasteboardTypes { + NSUnimplementedMethod(); + return nil; +} + ++(NSAttributedString *)attributedStringWithAttachment:(NSTextAttachment *)attachment { + unichar unicode=NSAttachmentCharacter; + NSString *string=[NSString stringWithCharacters:&unicode length:1]; + NSDictionary *attributes=[NSDictionary dictionaryWithObject:attachment forKey:NSAttachmentAttributeName]; + + return [[[self alloc] initWithString:string attributes:attributes] autorelease]; +} + +-initWithData:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary **)attributes error:(NSError **)error { + NSUnimplementedMethod(); + return nil; +} + +-initWithDocFormat:(NSData *)werd documentAttributes:(NSDictionary **)attributes { + NSUnimplementedMethod(); + return nil; +} + +-initWithHTML:(NSData *)html baseURL:(NSURL *)url documentAttributes:(NSDictionary **)attributes { + NSUnimplementedMethod(); + return nil; +} + +-initWithHTML:(NSData *)html documentAttributes:(NSDictionary **)attributes { + NSUnimplementedMethod(); + return nil; +} + +-initWithHTML:(NSData *)html options:(NSDictionary *)options documentAttributes:(NSDictionary **)attributes { + NSUnimplementedMethod(); + return nil; +} + -initWithPath:(NSString *)path documentAttributes:(NSDictionary **)attributes { NSAttributedString *string=[NSRichTextReader attributedStringWithContentsOfFile:path]; if(string==nil){ @@ -37,6 +101,81 @@ NSString *NSBackgroundColorDocumentAttribute=@"NSBackgroundColorDocumentAttribut return [self initWithAttributedString:string]; } +-initWithRTF:(NSData *)rtf documentAttributes:(NSDictionary **)attributes { + NSUnimplementedMethod(); + return nil; +} + +-initWithRTFD:(NSData *)rtfd documentAttributes:(NSDictionary **)attributes { + NSUnimplementedMethod(); + return nil; +} + +-initWithRTFDFileWrapper:(NSFileWrapper *)wrapper documentAttributes:(NSDictionary **)attributes { + NSUnimplementedMethod(); + return nil; +} + +-initWithURL:(NSURL *)url documentAttributes:(NSDictionary **)attributes { + NSUnimplementedMethod(); + return nil; +} + +-initWithURL:(NSURL *)url options:(NSDictionary *)options documentAttributes:(NSDictionary **)attributes error:(NSError **)error { + NSUnimplementedMethod(); + return nil; +} + +-(int)itemNumberInTextList:(NSTextList *)list atIndex:(unsigned)index { + NSUnimplementedMethod(); + return 0; +} + +-(unsigned)lineBreakBeforeIndex:(unsigned)index withinRange:(NSRange)range { + NSUnimplementedMethod(); + return 0; +} + +-(unsigned)lineBreakByHyphenatingBeforeIndex:(unsigned)index withinRange:(NSRange)range { + NSUnimplementedMethod(); + return 0; +} + +-(NSRange)rangeOfTextBlock:(NSTextBlock *)block atIndex:(unsigned)index { + NSUnimplementedMethod(); + return NSMakeRange(0,0); +} + +-(NSRange)rangeOfTextList:(NSTextList *)list atIndex:(unsigned)index { + NSUnimplementedMethod(); + return NSMakeRange(0,0); +} + +-(NSRange)rangeOfTextTable:(NSTextTable *)table atIndex:(unsigned)index { + NSUnimplementedMethod(); + return NSMakeRange(0,0); +} + +-(NSFileWrapper *)RTFDFileWrapperFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes { + NSUnimplementedMethod(); + return nil; +} + +-(NSData *)RTFDFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes { + NSUnimplementedMethod(); + return nil; +} + +-(NSData *)RTFFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes { + NSUnimplementedMethod(); + return nil; +} + +-(NSDictionary *)rulerAttributesInRange:(NSRange)range { + NSUnimplementedMethod(); + return nil; +} + -(NSRange)doubleClickAtIndex:(unsigned)location { NSRange result=NSMakeRange(location,0); NSString *string=[self string]; @@ -145,12 +284,34 @@ NSString *NSBackgroundColorDocumentAttribute=@"NSBackgroundColorDocumentAttribut return NSNotFound; } -+(NSAttributedString *)attributedStringWithAttachment:(NSTextAttachment *)attachment { - unichar unicode=NSAttachmentCharacter; - NSString *string=[NSString stringWithCharacters:&unicode length:1]; - NSDictionary *attributes=[NSDictionary dictionaryWithObject:attachment forKey:NSAttachmentAttributeName]; - - return [[[self alloc] initWithString:string attributes:attributes] autorelease]; +-(NSRect)boundingRectWithSize:(NSSize)size options:(NSStringDrawingOptions)options { + NSUnimplementedMethod(); + return NSMakeRect(0,0,0,0); +} + +-(BOOL)containsAttachments { + NSUnimplementedMethod(); + return NO; +} + +-(NSData *)dataFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes error:(NSError **)error { + NSUnimplementedMethod(); + return 0; +} + +-(NSData *)docFormatFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes { + NSUnimplementedMethod(); + return 0; +} + +-(NSFileWrapper *)fileWrapperFromRange:(NSRange)range documentAttributes:(NSDictionary *)attributes error:(NSError **)error { + NSUnimplementedMethod(); + return nil; +} + +-(NSDictionary *)fontAttributesInRange:(NSRange)range { + NSUnimplementedMethod(); + return nil; } @end diff --git a/AppKit/NSBezierPath.m b/AppKit/NSBezierPath.m index 6fa1fd8c..18ecc2b5 100644 --- a/AppKit/NSBezierPath.m +++ b/AppKit/NSBezierPath.m @@ -166,11 +166,13 @@ static NSLineJoinStyle _defaultLineJoinStyle=NSMiterLineJoinStyle; } +(void)drawPackedGlyphs:(const char *)packed atPoint:(NSPoint)point { - KGContext *context=[[NSGraphicsContext currentContext] graphicsPort]; - CGGlyph *glyphs; - unsigned count=0; + KGContext *context=[[NSGraphicsContext currentContext] graphicsPort]; + const CGGlyph *glyphs=(const CGGlyph *)packed; + unsigned count; -// FIX, unpack glyphs + for(count=0;glyphs[count]!=0;count++) + ; + CGContextShowGlyphsAtPoint(context,point.x,point.y,glyphs,count); } @@ -244,11 +246,39 @@ static NSLineJoinStyle _defaultLineJoinStyle=NSMiterLineJoinStyle; } -(NSBezierPathElement)elementAtIndex:(int)index { + if(index>=[_path numberOfOperators]) + [NSException raise:NSInvalidArgumentException format:@"index (%d) >= numberOfOperators (%d)",index,[_path numberOfOperators]]; + return [_path operators][index]; } --(NSBezierPathElement)elementAtIndex:(int)index associatedPoints:(NSPoint *)points { - NSUnimplementedMethod(); +static int numberOfPointsForOperator(int op){ + switch(op){ + case kCGPathOperatorMoveToPoint: return 1; + case kCGPathOperatorLineToPoint: return 1; + case kCGPathOperatorCurveToPoint: return 3; + case kCGPathOperatorCloseSubpath: return 0; + case kCGPathOperatorQuadCurveToPoint: return 2; + } + return 0; +} + +-(NSBezierPathElement)elementAtIndex:(int)index associatedPoints:(NSPoint *)associated { + const unsigned char *operators=[_path operators]; + const CGPoint *points=[_path points]; + int i,pi=0,pcount; + + if(index>=[_path numberOfOperators]) + [NSException raise:NSInvalidArgumentException format:@"index (%d) >= numberOfOperators (%d)",index,[_path numberOfOperators]]; + + for(i=0;i=[_path numberOfOperators]) + [NSException raise:NSInvalidArgumentException format:@"index (%d) >= numberOfOperators (%d)",index,[_path numberOfOperators]]; + + for(i=0;i @interface NSBrowserCell : NSCell { + NSImage *_alternateImage; BOOL _isLeaf; BOOL _isLoaded; } @@ -18,11 +19,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(BOOL)isLeaf; -(BOOL)isLoaded; +-(NSImage *)image; +-(NSImage *)alternateImage; --(void)setLeaf:(BOOL)flag; --(void)setLoaded:(BOOL)flag; +-(void)setLeaf:(BOOL)value; +-(void)setLoaded:(BOOL)value; +-(void)setImage:(NSImage *)value; +-(void)setAlternateImage:(NSImage *)value; -(void)set; -(void)reset; +-(NSColor *)highlightColorInView:(NSView *)view; + @end diff --git a/AppKit/NSBrowserCell.m b/AppKit/NSBrowserCell.m index 0e3a1bc4..4535a80c 100755 --- a/AppKit/NSBrowserCell.m +++ b/AppKit/NSBrowserCell.m @@ -33,12 +33,31 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return _isLoaded; } --(void)setLeaf:(BOOL)flag { - _isLeaf=flag; +-(NSImage *)image { + NSUnimplementedMethod(); + return nil; } --(void)setLoaded:(BOOL)flag { - _isLoaded=flag; +-(NSImage *)alternateImage { + return _alternateImage; +} + +-(void)setLeaf:(BOOL)value { + _isLeaf=value; +} + +-(void)setLoaded:(BOOL)value { + _isLoaded=value; +} + +-(void)setImage:(NSImage *)value { + NSUnimplementedMethod(); +} + +-(void)setAlternateImage:(NSImage *)value { + value=[value retain]; + [_alternateImage release]; + _alternateImage=value; } -(void)setState:(int)value { @@ -56,6 +75,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI _isHighlighted=NO; } +-(NSColor *)highlightColorInView:(NSView *)view { + NSUnimplementedMethod(); + return nil; +} + -(NSImage *)branchImage { if([self isLeaf]) return nil; diff --git a/AppKit/NSButtonCell.m b/AppKit/NSButtonCell.m index 7e3da50e..87a50035 100755 --- a/AppKit/NSButtonCell.m +++ b/AppKit/NSButtonCell.m @@ -89,7 +89,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI _isBordered=(flags&0x00800000)?YES:NO; // err, this flag is in NSCell too - _bezelStyle=flags2&0x7|(flags2&0x20>>2); + _bezelStyle=(flags2&0x7)|(flags2&0x20>>2); _isTransparent=(flags&0x00008000)?YES:NO; _imageDimsWhenDisabled=(flags&0x00002000)?NO:YES; @@ -111,16 +111,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI _keyEquivalentModifierMask=flags2>>8; } else { - _title=[[coder decodeObjectForKey:@"NSButtonCell title"] retain]; - _alternateTitle=[[coder decodeObjectForKey:@"NSButtonCell alternateTitle"] retain]; - _imagePosition=[coder decodeIntForKey:@"NSButtonCell imagePosition"]; - _highlightsBy=[coder decodeIntForKey:@"NSButtonCell highlightsBy"]; - _showsStateBy=[coder decodeIntForKey:@"NSButtonCell showsStateBy"]; - _isTransparent=[coder decodeBoolForKey:@"NSButtonCell transparent"]; - _imageDimsWhenDisabled=[coder decodeBoolForKey:@"NSButtonCell imageDimsWhenDisabled"]; - _alternateImage=[[coder decodeObjectForKey:@"NSButtonCell alternateImage"] retain]; - _keyEquivalent=[[coder decodeObjectForKey:@"NSButtonCell keyEquivalent"] retain]; - _keyEquivalentModifierMask=[coder decodeIntForKey:@"NSButtonCell keyEquivalentModifierMask"]; + [NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]]; } return self; } diff --git a/AppKit/NSCachedImageRep.h b/AppKit/NSCachedImageRep.h index b0470516..c6e9c781 100755 --- a/AppKit/NSCachedImageRep.h +++ b/AppKit/NSCachedImageRep.h @@ -9,18 +9,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import -@class KGContext,KGLayer; - @interface NSCachedImageRep : NSImageRep { NSWindow *_window; NSPoint _origin; } +-initWithWindow:(NSWindow *)window rect:(NSRect)rect; -initWithSize:(NSSize)size depth:(NSWindowDepth)windowDepth separate:(BOOL)separateWindow alpha:(BOOL)hasAlpha; -(NSWindow *)window; -(NSRect)rect; --(KGContext *)cgContext; - @end diff --git a/AppKit/NSCachedImageRep.m b/AppKit/NSCachedImageRep.m index 71436b5b..92ce853c 100755 --- a/AppKit/NSCachedImageRep.m +++ b/AppKit/NSCachedImageRep.m @@ -14,18 +14,23 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @implementation NSCachedImageRep --initWithSize:(NSSize)size depth:(NSWindowDepth)windowDepth separate:(BOOL)separateWindow alpha:(BOOL)hasAlpha { - _size=size; - _origin=NSMakePoint(0,0); - _window=[[NSWindow alloc] initWithContentRect:NSMakeRect(_origin.x,_origin.y,size.width,size.height) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; +-initWithWindow:(NSWindow *)window rect:(NSRect)rect { + _size=rect.size; + _window=[window retain]; + _origin=rect.origin; // this is a little broken, the windows get resized to larger size when on-screen if([[NSUserDefaults standardUserDefaults] boolForKey:@"NSShowAllWindows"]) [_window orderFront:nil]; - return self; } +-initWithSize:(NSSize)size depth:(NSWindowDepth)windowDepth separate:(BOOL)separateWindow alpha:(BOOL)hasAlpha { + NSWindow *window=[[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,size.width,size.height) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; + + return [self initWithWindow:window rect:NSMakeRect(0,0,size.width,size.height)]; +} + -(void)dealloc { [_window release]; [super dealloc]; @@ -39,10 +44,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return NSMakeRect(_origin.x,_origin.y,_size.width,_size.height); } --(KGContext *)cgContext { - return [[_window graphicsContext] graphicsPort]; -} - -(BOOL)drawAtPoint:(NSPoint)point { NSRect rect={point,_size}; diff --git a/AppKit/NSCell.h b/AppKit/NSCell.h index 8614017c..b6d9b528 100755 --- a/AppKit/NSCell.h +++ b/AppKit/NSCell.h @@ -7,6 +7,7 @@ The above copyright notice and this permission notice shall be included in all c 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 +#import @class NSFont,NSImage,NSView; diff --git a/AppKit/NSCell.m b/AppKit/NSCell.m index 49285dac..dff250e6 100755 --- a/AppKit/NSCell.m +++ b/AppKit/NSCell.m @@ -25,21 +25,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @implementation NSCell -(void)encodeWithCoder:(NSCoder *)coder { - [coder encodeInt:_state forKey:@"NSCell state"]; - [coder encodeInt:_cellType forKey:@"NSCell type"]; - [coder encodeInt:_textAlignment forKey:@"NSCell alignment"]; - [coder encodeBool:_wraps forKey:@"NSCell wraps"]; - [coder encodeBool:_isEnabled forKey:@"NSCell enabled"]; - [coder encodeBool:_isEditable forKey:@"NSCell editable"]; - [coder encodeBool:_isSelectable forKey:@"NSCell selectable"]; - [coder encodeBool:_isScrollable forKey:@"NSCell scrollable"]; - [coder encodeBool:_isBordered forKey:@"NSCell bordered"]; - [coder encodeBool:_isBezeled forKey:@"NSCell bezeled"]; - [coder encodeBool:_isHighlighted forKey:@"NSCell highlighted"]; - [coder encodeBool:_isContinuous forKey:@"NSCell continuous"]; - [coder encodeObject:_font forKey:@"NSCell font"]; - [coder encodeObject:_objectValue forKey:@"NSCell objectValue"]; - [coder encodeObject:_image forKey:@"NSCell image"]; + NSUnimplementedMethod(); } -initWithCoder:(NSCoder *)coder { @@ -84,22 +70,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI _font=[[NSFont userFontOfSize:13 - _controlSize*2] retain]; } else { - _state=[coder decodeIntForKey:@"NSCell state"]; - _cellType=[coder decodeIntForKey:@"NSCell type"]; - _textAlignment=[coder decodeIntForKey:@"NSCell alignment"]; - _writingDirection=NSWritingDirectionNatural; - _wraps=[coder decodeBoolForKey:@"NSCell wraps"]; - _isEnabled=[coder decodeBoolForKey:@"NSCell enabled"]; - _isEditable=[coder decodeBoolForKey:@"NSCell editable"]; - _isSelectable=[coder decodeBoolForKey:@"NSCell selectable"]; - _isScrollable=[coder decodeBoolForKey:@"NSCell scrollable"]; - _isBordered=[coder decodeBoolForKey:@"NSCell bordered"]; - _isBezeled=[coder decodeBoolForKey:@"NSCell bezeled"]; - _isHighlighted=[coder decodeBoolForKey:@"NSCell highlighted"]; - _isContinuous=[coder decodeBoolForKey:@"NSCell continuous"]; - _font=[[coder decodeObjectForKey:@"NSCell font"] retain]; - _objectValue=[[coder decodeObjectForKey:@"NSCell objectValue"] retain]; - _image=[[coder decodeObjectForKey:@"NSCell image"] retain]; + [NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]]; } return self; } @@ -278,7 +249,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI NSString *formatted; if (_formatter != nil) - if (formatted = [_formatter stringForObjectValue:_objectValue]) + if ((formatted = [_formatter stringForObjectValue:_objectValue])!=nil) return formatted; if([_objectValue isKindOfClass:[NSAttributedString class]]) diff --git a/AppKit/NSClipView.h b/AppKit/NSClipView.h index 52ab1239..04c480b2 100755 --- a/AppKit/NSClipView.h +++ b/AppKit/NSClipView.h @@ -11,20 +11,37 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @class NSColor; @interface NSClipView : NSView { - NSColor *_backgroundColor; - + NSColor *_backgroundColor; + NSCursor *_documentCursor; + NSView *_docView; NSRect _docRect; + + BOOL _drawsBackground; + BOOL _copiesOnScroll; } +-(BOOL)drawsBackground; +-(BOOL)copiesOnScroll; -(NSColor *)backgroundColor; --(id)documentView; --(NSRect)documentVisibleRect; +-(NSCursor *)documentCursor; +-documentView; +-(void)setDrawsBackground:(BOOL)value; +-(void)setCopiesOnScroll:(BOOL)value; -(void)setBackgroundColor:(NSColor *)color; +-(void)setDocumentCursor:(NSCursor *)value; -(void)setDocumentView:(NSView *)view; +-(NSRect)documentRect; +-(NSRect)documentVisibleRect; + -(NSPoint)constrainScrollPoint:(NSPoint)point; + +-(void)viewBoundsChanged:(NSNotification *)note; +-(void)viewFrameChanged:(NSNotification *)note; + +-(BOOL)autoscroll:(NSEvent *)event; -(void)scrollToPoint:(NSPoint)point; @end diff --git a/AppKit/NSClipView.m b/AppKit/NSClipView.m index c29bd4dc..1bb08d20 100755 --- a/AppKit/NSClipView.m +++ b/AppKit/NSClipView.m @@ -12,6 +12,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import #import @implementation NSClipView @@ -53,16 +54,33 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [super dealloc]; } +-(BOOL)drawsBackground { + return _drawsBackground; +} + +-(BOOL)copiesOnScroll { + return _copiesOnScroll; +} + -(NSColor *)backgroundColor { return _backgroundColor; } +-(NSCursor *)documentCursor { + return _documentCursor; +} + -(id)documentView { return _docView; } --(NSRect)documentVisibleRect { - return [self convertRect:[self bounds] toView:_docView]; +-(void)setDrawsBackground:(BOOL)value { + _drawsBackground=value; + [self setNeedsDisplay:YES]; +} + +-(void)setCopiesOnScroll:(BOOL)value { + _copiesOnScroll=value; } -(void)setBackgroundColor:(NSColor *)color { @@ -71,6 +89,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI _backgroundColor=color; } +-(void)setDocumentCursor:(NSCursor *)value { + value=[value retain]; + [_documentCursor release]; + _documentCursor=value; + NSUnimplementedMethod(); +} + -(void)setDocumentView:(NSView *)view { if(_docView!=nil){ [[NSNotificationCenter defaultCenter] removeObserver:self @@ -97,16 +122,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI } } --(NSPoint)_scrollPoint { - return [self bounds].origin; +-(NSRect)documentRect { + NSUnimplementedMethod(); + return NSMakeRect(0,0,0,0); } --(void)viewBoundsChanged:(NSNotification *)note { - [self scrollToPoint:[self _scrollPoint]]; -} - --(void)viewFrameChanged:(NSNotification *)note { - [self scrollToPoint:[self _scrollPoint]]; +-(NSRect)documentVisibleRect { + return [self convertRect:[self bounds] toView:_docView]; } -(NSPoint)constrainScrollPoint:(NSPoint)point { @@ -132,6 +154,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return point; } +-(NSPoint)_scrollPoint { + return [self bounds].origin; +} + +-(void)viewBoundsChanged:(NSNotification *)note { + [self scrollToPoint:[self _scrollPoint]]; +} + +-(void)viewFrameChanged:(NSNotification *)note { + [self scrollToPoint:[self _scrollPoint]]; +} + -(BOOL)isOpaque { return YES; } @@ -153,17 +187,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI NSRectFill(rect); } --(void)scrollToPoint:(NSPoint)point { - NSPoint original=[self bounds].origin; - - point=[self constrainScrollPoint:point]; - [self setBoundsOrigin:point]; - [self setNeedsDisplay:YES]; - - if([[self superview] isKindOfClass:[NSScrollView class]]) - [[self superview] reflectScrolledClipView:self]; -} - -(BOOL)autoscroll:(NSEvent *)event { NSRect bounds=[self bounds]; NSPoint point=[self convertPoint:[event locationInWindow] fromView:nil]; @@ -204,4 +227,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return YES; } +-(void)scrollToPoint:(NSPoint)point { + point=[self constrainScrollPoint:point]; + [self setBoundsOrigin:point]; + [self setNeedsDisplay:YES]; + + if([[self superview] isKindOfClass:[NSScrollView class]]) + [[self superview] reflectScrolledClipView:self]; +} + @end diff --git a/AppKit/NSColor.subproj/NSColor.m b/AppKit/NSColor.subproj/NSColor.m index 4f45c1db..88924919 100755 --- a/AppKit/NSColor.subproj/NSColor.m +++ b/AppKit/NSColor.subproj/NSColor.m @@ -133,55 +133,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return [result retain]; } else { - NSString *space=[coder decodeObject]; - - [self dealloc]; - - if([space isEqualToString:@"NSDeviceCMYKColorSpace"]){ - float c,m,y,k,a; - - [coder decodeValuesOfObjCTypes:"fffff",&c,&m,&y,&k,&a]; - - return [[NSColor colorWithDeviceCyan:c magenta:m yellow:y black:k alpha:a] retain]; - } - else if([space isEqualToString:@"NSDeviceWhiteColorSpace"]){ - float w,a; - - [coder decodeValuesOfObjCTypes:"ff",&w,&a]; - - return [[NSColor colorWithDeviceWhite:w alpha:a] retain]; - } - else if([space isEqualToString:@"NSCalibratedWhiteColorSpace"]){ - float w,a; - - [coder decodeValuesOfObjCTypes:"ff",&w,&a]; - - return [[NSColor colorWithCalibratedWhite:w alpha:a] retain]; - } - else if([space isEqualToString:@"NSDeviceRGBColorSpace"]){ - float r,g,b,a; - - [coder decodeValuesOfObjCTypes:"ffff",&r,&g,&b,&a]; - - return [[NSColor colorWithDeviceRed:r green:g blue:b alpha:a] retain]; - } - else if([space isEqualToString:@"NSCalibratedRGBColorSpace"]){ - float r,g,b,a; - - [coder decodeValuesOfObjCTypes:"ffff",&r,&g,&b,&a]; - - return [[NSColor colorWithCalibratedRed:r green:g blue:b alpha:a] retain]; - } - else if([space isEqualToString:@"NSNamedColorSpace"]){ - NSString *catalog=[coder decodeObject]; - NSString *color=[coder decodeObject]; - - return [[NSColor colorWithCatalogName:catalog colorName:color] retain]; - } - else { - [NSException raise:@"UnknownColor" format:@"Unknown color space %@",space]; - return nil; - } + [NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]]; + return nil; } } diff --git a/AppKit/NSColorList.h b/AppKit/NSColorList.h index 976d8e56..28a6d99c 100755 --- a/AppKit/NSColorList.h +++ b/AppKit/NSColorList.h @@ -12,12 +12,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI APPKIT_EXPORT NSString *NSColorListDidChangeNotification; -@interface NSColorList : NSObject // -{ - NSMutableArray *_keys; - NSMutableArray *_colors; - NSString *_name; - NSString *_path; +@interface NSColorList : NSObject { + NSMutableArray *_keys; + NSMutableArray *_colors; + NSString *_name; + NSString *_path; } +(NSArray *)availableColorLists; @@ -27,6 +26,7 @@ APPKIT_EXPORT NSString *NSColorListDidChangeNotification; +(NSColorList *)colorListNamed:(NSString *)name; +-(BOOL)isEditable; -(NSString *)name; -(NSArray *)allKeys; -(NSColor *)colorWithKey:(NSString *)key; diff --git a/AppKit/NSColorList.m b/AppKit/NSColorList.m index 4a3d0a1c..969bc5ab 100755 --- a/AppKit/NSColorList.m +++ b/AppKit/NSColorList.m @@ -221,7 +221,7 @@ static NSMutableDictionary *_namedColorLists = nil; return [_namedColorLists allValues]; } -- (id)initWithName:(NSString *)name fromFile:(NSString *)path +-initWithName:(NSString *)name fromFile:(NSString *)path { _keys = [[NSMutableArray alloc] init]; _colors = [[NSMutableArray alloc] init]; @@ -236,12 +236,12 @@ static NSMutableDictionary *_namedColorLists = nil; return self; } -- (id)initWithName:(NSString *)name +-initWithName:(NSString *)name { return [self initWithName:name fromFile:nil]; } -- (void)dealloc +-(void)dealloc { [_keys release]; [_colors release]; @@ -259,17 +259,22 @@ static NSMutableDictionary *_namedColorLists = nil; return [_namedColorLists objectForKey:name]; } -- (NSString *)name { return _name; } +-(BOOL)isEditable { + NSUnimplementedMethod(); + return NO; +} -- (NSArray *)allKeys { return _keys; } +-(NSString *)name { return _name; } -- (NSColor *)colorWithKey:(NSString *)soughtKey indexPtr:(unsigned *)index +-(NSArray *)allKeys { return _keys; } + +-(NSColor *)colorWithKey:(NSString *)soughtKey indexPtr:(unsigned *)index { NSEnumerator *keyEnumerator = [_keys objectEnumerator]; NSString *thisKey; *index = 0; - while (thisKey = [keyEnumerator nextObject]) { + while ((thisKey = [keyEnumerator nextObject])!=nil) { if ([thisKey isEqualToString:soughtKey]) return [_colors objectAtIndex:*index]; (*index)++; @@ -278,13 +283,13 @@ static NSMutableDictionary *_namedColorLists = nil; return nil; } -- (NSColor *)colorWithKey:(NSString *)soughtKey +-(NSColor *)colorWithKey:(NSString *)soughtKey { unsigned index; // unused return [self colorWithKey:soughtKey indexPtr:&index]; } -- (void)setColor:(NSColor *)color forKey:(NSString *)key +-(void)setColor:(NSColor *)color forKey:(NSString *)key { unsigned index; @@ -299,7 +304,7 @@ static NSMutableDictionary *_namedColorLists = nil; [[NSNotificationCenter defaultCenter] postNotificationName:NSColorListDidChangeNotification object:self]; } -- (void)removeColorWithKey:(NSString *)key +-(void)removeColorWithKey:(NSString *)key { unsigned index; @@ -311,7 +316,7 @@ static NSMutableDictionary *_namedColorLists = nil; } } -- (void)insertColor:(NSColor *)color key:(NSString *)key atIndex:(unsigned)index +-(void)insertColor:(NSColor *)color key:(NSString *)key atIndex:(unsigned)index { [_colors insertObject:color atIndex:index]; [_keys insertObject:key atIndex:index]; @@ -319,12 +324,12 @@ static NSMutableDictionary *_namedColorLists = nil; [[NSNotificationCenter defaultCenter] postNotificationName:NSColorListDidChangeNotification object:self]; } -- (void)writeToFile:(NSString *)path +-(void)writeToFile:(NSString *)path { NSUnimplementedMethod(); } -- (void)removeFile +-(void)removeFile { [[NSFileManager defaultManager] removeFileAtPath:_path handler:nil]; } diff --git a/AppKit/NSColorWell.h b/AppKit/NSColorWell.h index 7c73186e..8577136f 100755 --- a/AppKit/NSColorWell.h +++ b/AppKit/NSColorWell.h @@ -32,4 +32,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(void)drawWellInside:(NSRect)rect; +-(void)takeColorFrom:sender; + @end diff --git a/AppKit/NSColorWell.m b/AppKit/NSColorWell.m index 33ee5bd8..6241e250 100755 --- a/AppKit/NSColorWell.m +++ b/AppKit/NSColorWell.m @@ -17,6 +17,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import #import @implementation NSColorWell @@ -201,6 +202,10 @@ NSString *_NSColorWellDidBecomeExclusiveNotification=@"_NSColorWellDidBecomeExcl [self drawWellInside:rect]; } +-(void)takeColorFrom:sender { + [self setColor:[sender color]]; +} + -(void)mouseDown:(NSEvent *)event { if(![self isEnabled]) diff --git a/AppKit/NSComboBox.h b/AppKit/NSComboBox.h index 61edd7f5..351cf1c6 100755 --- a/AppKit/NSComboBox.h +++ b/AppKit/NSComboBox.h @@ -8,18 +8,59 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import +APPKIT_EXPORT NSString *NSComboBoxSelectionDidChangeNotification; +APPKIT_EXPORT NSString *NSComboBoxSelectionIsChangingNotification; +APPKIT_EXPORT NSString *NSComboBoxWillDismissNotification; +APPKIT_EXPORT NSString *NSComboBoxWillPopUpNotification; + @interface NSComboBox : NSTextField --(void)addItemWithObjectValue:(id)object; +-dataSource; +-(BOOL)usesDataSource; +-(BOOL)isButtonBordered; +-(float)itemHeight; +-(BOOL)hasVerticalScroller; +-(NSSize)intercellSpacing; +-(BOOL)completes; +-(int)numberOfVisibleItems; + +-(void)setDataSource:value; +-(void)setUsesDataSource:(BOOL)value; +-(void)setButtonBordered:(BOOL)value; +-(void)setItemHeight:(float)value; +-(void)setHasVerticalScroller:(BOOL)value; +-(void)setIntercellSpacing:(NSSize)value; +-(void)setCompletes:(BOOL)completes; +-(void)setNumberOfVisibleItems:(int)value; + +-(int)numberOfItems; +-(NSArray *)objectValues; +-itemObjectValueAtIndex:(int)index; +-(int)indexOfItemWithObjectValue:object; +-(void)addItemWithObjectValue:object; -(void)addItemsWithObjectValues:(NSArray *)objects; -(void)removeAllItems; --(int)indexOfItemWithObjectValue:(id)object; +-(void)removeItemAtIndex:(int)index; +-(void)removeItemWithObjectValue:value; +-(void)insertItemWithObjectValue:value atIndex:(int)index; +-(int)indexOfSelectedItem; +-objectValueOfSelectedItem; +-(void)selectItemAtIndex:(int)index; +-(void)selectItemWithObjectValue:value; +-(void)deselectItemAtIndex:(int)index; + +-(void)scrollItemAtIndexToTop:(int)index; -(void)scrollItemAtIndexToVisible:(int)index; --(void)selectItemAtIndex:(int)index; - --(BOOL)completes; --(void)setCompletes:(BOOL)completes; +-(void)noteNumberOfItemsChanged; +-(void)reloadData; @end + +@interface NSObject(NSComboBox) +-(void)comboBoxWillPopUp:(NSNotification *)note; +-(void)comboBoxWillDismiss:(NSNotification *)note; +-(void)comboBoxSelectionDidChange:(NSNotification *)note; +-(void)comboBoxSelectionIsChanging:(NSNotification *)note; +@end diff --git a/AppKit/NSComboBox.m b/AppKit/NSComboBox.m index ecb0d6be..b0aa219b 100755 --- a/AppKit/NSComboBox.m +++ b/AppKit/NSComboBox.m @@ -12,8 +12,100 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import +NSString *NSComboBoxSelectionDidChangeNotification=@"NSComboBoxSelectionDidChangeNotification"; +NSString *NSComboBoxSelectionIsChangingNotification=@"NSComboBoxSelectionIsChangingNotification"; +NSString *NSComboBoxWillDismissNotification=@"NSComboBoxWillDismissNotification"; +NSString *NSComboBoxWillPopUpNotification=@"NSComboBoxWillPopUpNotification"; + @implementation NSComboBox +-dataSource { + return [[self cell] dataSource]; +} + +-(BOOL)usesDataSource { + return [[self cell] usesDataSource]; +} + +-(BOOL)isButtonBordered { + return [[self cell] isButtonBordered]; +} + +-(float)itemHeight { + return [[self cell] itemHeight]; +} + +-(BOOL)hasVerticalScroller { + return [[self cell] hasVerticalScroller]; +} + +-(NSSize)intercellSpacing { + return [[self cell] intercellSpacing]; +} + +-(BOOL)completes { + return [[self cell] completes]; +} + +-(int)numberOfVisibleItems { + return [[self cell] numberOfVisibleItems]; +} + +-(void)setDataSource:value { + [[self cell] setDataSource:value]; + [self setNeedsDisplay:YES]; +} + +-(void)setUsesDataSource:(BOOL)value { + [[self cell] setUsesDataSource:value]; + [self setNeedsDisplay:YES]; +} + +-(void)setButtonBordered:(BOOL)value { + [[self cell] setButtonBordered:value]; + [self setNeedsDisplay:YES]; +} + +-(void)setItemHeight:(float)value { + [[self cell] setItemHeight:value]; + [self setNeedsDisplay:YES]; +} + +-(void)setHasVerticalScroller:(BOOL)value { + [[self cell] setHasVerticalScroller:value]; + [self setNeedsDisplay:YES]; +} + +-(void)setIntercellSpacing:(NSSize)value { + [[self cell] setIntercellSpacing:value]; + [self setNeedsDisplay:YES]; +} + +-(void)setCompletes:(BOOL)completes { + [[self cell] setCompletes:completes]; +} + +-(void)setNumberOfVisibleItems:(int)value { + [[self cell] setNumberOfVisibleItems:value]; + [self setNeedsDisplay:YES]; +} + +-(int)numberOfItems { + return [[self cell] numberOfItems]; +} + +-(NSArray *)objectValues { + return [[self cell] objectValues]; +} + +-itemObjectValueAtIndex:(int)index { + return [[self cell] itemObjectValueAtIndex:index]; +} + +-(int)indexOfItemWithObjectValue:(id)object { + return [[self cell] indexOfItemWithObjectValue:object]; +} + -(void)addItemWithObjectValue:(id)object { [[self cell] addItemWithObjectValue:object]; } @@ -26,24 +118,52 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [[self cell] removeAllItems]; } --(int)indexOfItemWithObjectValue:(id)object { - return [_cell indexOfItemWithObjectValue:object]; +-(void)removeItemAtIndex:(int)index { + [[self cell] removeItemAtIndex:index]; } --(void)scrollItemAtIndexToVisible:(int)index { - [[self cell] scrollItemAtIndexToVisible:index]; +-(void)removeItemWithObjectValue:value { + [[self cell] removeItemWithObjectValue:value]; +} + +-(void)insertItemWithObjectValue:value atIndex:(int)index { + [[self cell] insertItemWithObjectValue:value atIndex:index]; +} + +-(int)indexOfSelectedItem { + return [[self cell] indexOfSelectedItem]; +} + +-objectValueOfSelectedItem { + return [[self cell] objectValueOfSelectedItem]; } -(void)selectItemAtIndex:(int)index { [[self cell] selectItemAtIndex:index]; } --(BOOL)completes { - return [[self cell] completes]; +-(void)selectItemWithObjectValue:value { + [[self cell] selectItemWithObjectValue:value]; } --(void)setCompletes:(BOOL)completes { - [[self cell] setCompletes:completes]; +-(void)deselectItemAtIndex:(int)index { + [[self cell] deselectItemAtIndex:index]; +} + +-(void)scrollItemAtIndexToTop:(int)index { + [[self cell] scrollItemAtIndexToTop:index]; +} + +-(void)scrollItemAtIndexToVisible:(int)index { + [[self cell] scrollItemAtIndexToVisible:index]; +} + +-(void)noteNumberOfItemsChanged { + [[self cell] noteNumberOfItemsChanged]; +} + +-(void)reloadData { + [[self cell] reloadData]; } -(void)mouseDown:(NSEvent *)event { diff --git a/AppKit/NSComboBoxCell.h b/AppKit/NSComboBoxCell.h index b621b7e5..643624bb 100755 --- a/AppKit/NSComboBoxCell.h +++ b/AppKit/NSComboBoxCell.h @@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @class NSButtonCell; -@interface NSComboBoxCell : NSTextFieldCell { +@interface NSComboBoxCell : NSTextFieldCell { id _dataSource; NSSize _intercellSpacing; float _itemHeight; @@ -19,26 +19,53 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI BOOL _usesDataSource; BOOL _hasVerticalScroller; BOOL _completes; - BOOL _buttonBordered; + BOOL _isButtonBordered; BOOL _buttonEnabled; BOOL _buttonPressed; NSMutableArray *_objectValues; } --(void)addItemWithObjectValue:(id)object; +-dataSource; +-(BOOL)usesDataSource; +-(BOOL)isButtonBordered; +-(float)itemHeight; +-(BOOL)hasVerticalScroller; +-(NSSize)intercellSpacing; +-(BOOL)completes; +-(int)numberOfVisibleItems; + +-(void)setDataSource:value; +-(void)setUsesDataSource:(BOOL)value; +-(void)setButtonBordered:(BOOL)value; +-(void)setItemHeight:(float)value; +-(void)setHasVerticalScroller:(BOOL)value; +-(void)setIntercellSpacing:(NSSize)value; +-(void)setCompletes:(BOOL)completes; +-(void)setNumberOfVisibleItems:(int)value; + +-(int)numberOfItems; +-(NSArray *)objectValues; +-itemObjectValueAtIndex:(int)index; +-(int)indexOfItemWithObjectValue:object; +-(void)addItemWithObjectValue:object; -(void)addItemsWithObjectValues:(NSArray *)objects; -(void)removeAllItems; --(int)indexOfItemWithObjectValue:(id)object; +-(void)removeItemAtIndex:(int)index; +-(void)removeItemWithObjectValue:value; +-(void)insertItemWithObjectValue:value atIndex:(int)index; --(void)insertItemWithObjectValue:(id)object atIndex:(int)index; +-(int)indexOfSelectedItem; +-objectValueOfSelectedItem; +-(void)selectItemAtIndex:(int)index; +-(void)selectItemWithObjectValue:value; +-(void)deselectItemAtIndex:(int)index; +-(void)scrollItemAtIndexToTop:(int)index; -(void)scrollItemAtIndexToVisible:(int)index; --(void)selectItemAtIndex:(int)index; - --(BOOL)completes; --(void)setCompletes:(BOOL)flag; +-(void)noteNumberOfItemsChanged; +-(void)reloadData; -(NSString *)completedString:(NSString *)string; diff --git a/AppKit/NSComboBoxCell.m b/AppKit/NSComboBoxCell.m index 9a6ce5d1..3e5ff314 100755 --- a/AppKit/NSComboBoxCell.m +++ b/AppKit/NSComboBoxCell.m @@ -29,7 +29,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI _objectValues=[[NSMutableArray alloc] initWithArray:[keyed decodeObjectForKey:@"NSPopUpListData"]]; _numberOfVisibleItems=[keyed decodeIntForKey:@"NSVisibleItemCount"]; _completes=[keyed decodeBoolForKey:@"NSCompletes"]; - _buttonBordered=YES; + _isButtonBordered=YES; _buttonEnabled=YES; _buttonPressed=NO; } @@ -53,6 +53,86 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return copy; } +-dataSource { + return _dataSource; +} + +-(BOOL)usesDataSource { + return _usesDataSource; +} + +-(BOOL)isButtonBordered { + return _isButtonBordered; +} + +-(float)itemHeight { + return _itemHeight; +} + +-(BOOL)hasVerticalScroller { + return _hasVerticalScroller; +} + +-(NSSize)intercellSpacing { + return _intercellSpacing; +} + +-(BOOL)completes { + return _completes; +} + +-(int)numberOfVisibleItems { + return _numberOfVisibleItems; +} + +-(void)setDataSource:value { + _dataSource=value; +} + +-(void)setUsesDataSource:(BOOL)value { + _usesDataSource=value; +} + +-(void)setButtonBordered:(BOOL)value { + _isButtonBordered=value; +} + +-(void)setItemHeight:(float)value { + _itemHeight=value; +} + +-(void)setHasVerticalScroller:(BOOL)value { + _hasVerticalScroller=value; +} + +-(void)setIntercellSpacing:(NSSize)value { + _intercellSpacing=value; +} + +-(void)setCompletes:(BOOL)flag { + _completes=flag; +} + +-(void)setNumberOfVisibleItems:(int)value { + _numberOfVisibleItems=value; +} + +-(int)numberOfItems { + return [_objectValues count]; +} + +-(NSArray *)objectValues { + return _objectValues; +} + +-itemObjectValueAtIndex:(int)index { + return [_objectValues objectAtIndex:index]; +} + +-(int)indexOfItemWithObjectValue:(id)object { + return [_objectValues indexOfObjectIdenticalTo:object]; +} + -(void)addItemWithObjectValue:(id)object { [_objectValues addObject:object]; _buttonEnabled=([_objectValues count]>0)?YES:NO; @@ -63,21 +143,34 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI _buttonEnabled=([_objectValues count]>0)?YES:NO; } -- (void)insertItemWithObjectValue:(id)object atIndex:(int)index { - [_objectValues insertObject:object atIndex:index]; - _buttonEnabled=([_objectValues count]>0)?YES:NO; -} - -(void)removeAllItems { [_objectValues removeAllObjects]; _buttonEnabled=([_objectValues count]>0)?YES:NO; } --(int)indexOfItemWithObjectValue:(id)object { - return [_objectValues indexOfObjectIdenticalTo:object]; +-(void)removeItemAtIndex:(int)index { + [_objectValues removeObjectAtIndex:index]; + _buttonEnabled=([_objectValues count]>0)?YES:NO; } --(void)scrollItemAtIndexToVisible:(int)index { +-(void)removeItemWithObjectValue:value { + [_objectValues removeObject:value]; + _buttonEnabled=([_objectValues count]>0)?YES:NO; +} + +-(void)insertItemWithObjectValue:(id)object atIndex:(int)index { + [_objectValues insertObject:object atIndex:index]; + _buttonEnabled=([_objectValues count]>0)?YES:NO; +} + +-(int)indexOfSelectedItem { + NSUnimplementedMethod(); + return 0; +} + +-objectValueOfSelectedItem { + NSUnimplementedMethod(); + return 0; } -(void)selectItemAtIndex:(int)index { @@ -87,12 +180,28 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [self setObjectValue:[_objectValues objectAtIndex:index]]; } --(BOOL)completes { - return _completes; +-(void)selectItemWithObjectValue:value { + NSUnimplementedMethod(); } --(void)setCompletes:(BOOL)flag { - _completes=flag; +-(void)deselectItemAtIndex:(int)index { + NSUnimplementedMethod(); +} + +-(void)scrollItemAtIndexToTop:(int)index { + NSUnimplementedMethod(); +} + +-(void)scrollItemAtIndexToVisible:(int)index { + NSUnimplementedMethod(); +} + +-(void)noteNumberOfItemsChanged { + NSUnimplementedMethod(); +} + +-(void)reloadData { + NSUnimplementedMethod(); } - (NSString *)completedString:(NSString *)string { @@ -175,7 +284,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(void)drawWithFrame:(NSRect)frame inView:(NSView *)controlView { [super drawWithFrame:frame inView:controlView]; - [[controlView graphicsStyle] drawComboBoxButtonInRect:[self buttonRectForBounds:frame] enabled:_buttonEnabled bordered:_buttonBordered pressed:_buttonPressed]; + [[controlView graphicsStyle] drawComboBoxButtonInRect:[self buttonRectForBounds:frame] enabled:_buttonEnabled bordered:_isButtonBordered pressed:_buttonPressed]; } @end diff --git a/AppKit/NSControl.m b/AppKit/NSControl.m index 28c1b69e..7eda94f3 100755 --- a/AppKit/NSControl.m +++ b/AppKit/NSControl.m @@ -54,7 +54,7 @@ static NSMutableDictionary *cellClassDictionary = nil; _cell=[[keyed decodeObjectForKey:@"NSCell"] retain]; } else { - _cell=[[coder decodeObjectForKey:@"NSControl cell"] retain]; + [NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]]; } return self; diff --git a/AppKit/NSController/NSArrayController.m b/AppKit/NSController/NSArrayController.m index 7ca9f7a3..4bf04250 100644 --- a/AppKit/NSController/NSArrayController.m +++ b/AppKit/NSController/NSArrayController.m @@ -71,7 +71,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [super dealloc]; } --(id)awakeFromNib +-(void)awakeFromNib { [self _selectionMayHaveChanged]; } diff --git a/AppKit/NSCursor.h b/AppKit/NSCursor.h index 7d3645df..1c4054c2 100755 --- a/AppKit/NSCursor.h +++ b/AppKit/NSCursor.h @@ -6,22 +6,57 @@ The above copyright notice and this permission notice shall be included in all c 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 +#import +#import -@interface NSCursor : NSObject { +@class NSImage,NSColor,NSEvent; + +@interface NSCursor : NSObject { + NSImage *_image; + NSPoint _hotSpot; + BOOL _isSetOnMouseEntered; + BOOL _isSetOnMouseExited; id _cursor; } ++(NSCursor *)currentCursor; + +(NSCursor *)arrowCursor; ++(NSCursor *)closedHandCursor; ++(NSCursor *)crosshairCursor; ++(NSCursor *)disappearingItemCursor; +(NSCursor *)IBeamCursor; -+(NSCursor *)_horizontalResizeCursor; -+(NSCursor *)_verticalResizeCursor; ++(NSCursor *)openHandCursor; ++(NSCursor *)pointingHandCursor; ++(NSCursor *)resizeDownCursor; ++(NSCursor *)resizeLeftCursor; ++(NSCursor *)resizeLeftRightCursor; ++(NSCursor *)resizeRightCursor; ++(NSCursor *)resizeUpCursor; ++(NSCursor *)resizeUpDownCursor; +(void)hide; +(void)unhide; +(void)setHiddenUntilMouseMoves:(BOOL)flag; +-initWithImage:(NSImage *)image foregroundColorHint:(NSColor *)foregroundHint backgroundColorHint:(NSColor *)backgroundHint hotSpot:(NSPoint)hotSpot; +-initWithImage:(NSImage *)image hotSpot:(NSPoint)hotSpot; + +-(NSImage *)image; +-(NSPoint)hotSpot; + +-(BOOL)isSetOnMouseEntered; +-(BOOL)isSetOnMouseExited; + +-(void)setOnMouseEntered:(BOOL)value; +-(void)setOnMouseExited:(BOOL)value; + +-(void)mouseEntered:(NSEvent *)event; +-(void)mouseExited:(NSEvent *)event; + +-(void)pop; + -(void)set; -(void)push; diff --git a/AppKit/NSCursor.m b/AppKit/NSCursor.m index 991f74db..5b2d5e43 100755 --- a/AppKit/NSCursor.m +++ b/AppKit/NSCursor.m @@ -9,32 +9,27 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI // Original - Christopher Lloyd #import #import +#import #import @implementation NSCursor ++(NSCursor *)currentCursor { + NSUnimplementedMethod(); + return 0; +} + -initWithCoder:(NSCoder *)coder { [self dealloc]; return [NSNull null]; } --initWithIBeam { - _cursor=[[[NSDisplay currentDisplay] cursorWithName:@"IBeam"] retain]; - return self; +-(void)encodeWithCoder:(NSCoder *)coder { + NSUnimplementedMethod(); } --initWithArrow { - _cursor=[[[NSDisplay currentDisplay] cursorWithName:@"Arrow"] retain]; - return self; -} - --initWithHorizontalResize { - _cursor=[[[NSDisplay currentDisplay] cursorWithName:@"HorizontalResize"] retain]; - return self; -} - --initWithVerticalResize { - _cursor=[[[NSDisplay currentDisplay] cursorWithName:@"VerticalResize"] retain]; +-initWithName:(NSString *)name { + _cursor=[[[NSDisplay currentDisplay] cursorWithName:name] retain]; return self; } @@ -42,7 +37,34 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI static NSCursor *shared=nil; if(shared==nil) - shared=[[self alloc] initWithArrow]; + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; + + return shared; +} + ++(NSCursor *)closedHandCursor { + static NSCursor *shared=nil; + + if(shared==nil) + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; + + return shared; +} + ++(NSCursor *)crosshairCursor { + static NSCursor *shared=nil; + + if(shared==nil) + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; + + return shared; +} + ++(NSCursor *)disappearingItemCursor { + static NSCursor *shared=nil; + + if(shared==nil) + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; return shared; } @@ -51,25 +73,79 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI static NSCursor *shared=nil; if(shared==nil) - shared=[[self alloc] initWithIBeam]; + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; return shared; } -+(NSCursor *)_horizontalResizeCursor { ++(NSCursor *)openHandCursor { static NSCursor *shared=nil; if(shared==nil) - shared=[[self alloc] initWithHorizontalResize]; + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; return shared; } -+(NSCursor *)_verticalResizeCursor { ++(NSCursor *)pointingHandCursor { static NSCursor *shared=nil; if(shared==nil) - shared=[[self alloc] initWithVerticalResize]; + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; + + return shared; +} + ++(NSCursor *)resizeDownCursor { + static NSCursor *shared=nil; + + if(shared==nil) + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; + + return shared; +} + ++(NSCursor *)resizeLeftCursor { + static NSCursor *shared=nil; + + if(shared==nil) + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; + + return shared; +} + ++(NSCursor *)resizeLeftRightCursor { + static NSCursor *shared=nil; + + if(shared==nil) + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; + + return shared; +} + ++(NSCursor *)resizeRightCursor { + static NSCursor *shared=nil; + + if(shared==nil) + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; + + return shared; +} + ++(NSCursor *)resizeUpCursor { + static NSCursor *shared=nil; + + if(shared==nil) + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; + + return shared; +} + ++(NSCursor *)resizeUpDownCursor { + static NSCursor *shared=nil; + + if(shared==nil) + shared=[[self alloc] initWithName:NSStringFromSelector(_cmd)]; return shared; } @@ -89,6 +165,58 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [self unhide]; } +-initWithImage:(NSImage *)image foregroundColorHint:(NSColor *)foregroundHint backgroundColorHint:(NSColor *)backgroundHint hotSpot:(NSPoint)hotSpot { + NSUnimplementedMethod(); + return nil; +} + +-initWithImage:(NSImage *)image hotSpot:(NSPoint)hotSpot { + _image=[image retain]; + _hotSpot=hotSpot; + return self; +} + +-(void)dealloc { + [_image release]; + [super dealloc]; +} + +-(NSImage *)image { + return _image; +} + +-(NSPoint)hotSpot { + return _hotSpot; +} + +-(BOOL)isSetOnMouseEntered { + return _isSetOnMouseEntered; +} + +-(BOOL)isSetOnMouseExited { + return _isSetOnMouseExited; +} + +-(void)setOnMouseEntered:(BOOL)value { + _isSetOnMouseEntered=value; +} + +-(void)setOnMouseExited:(BOOL)value { + _isSetOnMouseExited=value; +} + +-(void)mouseEntered:(NSEvent *)event { + NSUnimplementedMethod(); +} + +-(void)mouseExited:(NSEvent *)event { + NSUnimplementedMethod(); +} + +-(void)pop { + NSUnimplementedMethod(); +} + -(void)set { [[NSDisplay currentDisplay] setCursor:_cursor]; } diff --git a/AppKit/NSDisplay.m b/AppKit/NSDisplay.m index 66b08813..634a5d99 100755 --- a/AppKit/NSDisplay.m +++ b/AppKit/NSDisplay.m @@ -199,7 +199,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI int count=[_eventQueue count]; while(--count>=0){ - if([[_eventQueue objectAtIndex:count] type]==NSPeriodic){ + if([(NSEvent *)[_eventQueue objectAtIndex:count] type]==NSPeriodic){ result=YES; [_eventQueue removeObjectAtIndex:count]; } @@ -290,6 +290,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(int)runModalPrintPanelWithPrintInfoDictionary:(NSMutableDictionary *)attributes { NSInvalidAbstractInvocation(); + return 0; } -(KGContext *)graphicsPortForPrintOperationWithView:(NSView *)view printInfo:(NSPrintInfo *)printInfo pageRange:(NSRange)pageRange { diff --git a/AppKit/NSDocument.h b/AppKit/NSDocument.h index 7080b2de..037a0a6e 100755 --- a/AppKit/NSDocument.h +++ b/AppKit/NSDocument.h @@ -7,99 +7,164 @@ The above copyright notice and this permission notice shall be included in all c 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 +#import -@class NSWindow,NSWindowController,NSSavePanel, NSMenuItem,NSFileWrapper,NSPrintOperation; +@class NSWindow,NSWindowController,NSSavePanel,NSMenuItem,NSFileWrapper,NSPrintOperation,NSPrintInfo,NSPageLayout,NSView; typedef enum { NSChangeDone, NSChangeUndone, - NSChangeCleared + NSChangeCleared, + NSChangeReadOtherContents, + NSChangeAutosaved, } NSDocumentChangeType; typedef enum { NSSaveOperation, NSSaveAsOperation, - NSSaveToOperation + NSSaveToOperation, + NSAutosaveOperation, } NSSaveOperationType; @interface NSDocument : NSObject { NSMutableArray *_windowControllers; - NSString *_path; - NSString *_type; + NSURL *_fileURL; + NSString *_fileType; + NSDate *_fileModificationDate; + NSString *_lastComponentOfFileName; + NSURL *_autosavedContentsFileURL; + NSPrintInfo *_printInfo; int _changeCount; unsigned _untitledNumber; NSUndoManager *_undoManager; BOOL _hasUndoManager; } ++(NSArray *)readableTypes; ++(NSArray *)writableTypes; + ++(BOOL)isNativeType:(NSString *)type; + -init; --initWithContentsOfFile:(NSString *)path ofType:(NSString *)type; --initWithContentsOfURL:(NSURL *)url ofType:(NSString *)type; +-initWithType:(NSString *)type error:(NSError **)error; +-initWithContentsOfURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error; +-initForURL:(NSURL *)url withContentsOfURL:(NSURL *)contentsURL ofType:(NSString *)type error:(NSError **)error; --(NSData *)dataRepresentationOfType:(NSString *)type; --(BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)type; +-(NSURL *)autosavedContentsFileURL; +-(NSDate *)fileModificationDate; +-(NSURL *)fileURL; +-(NSPrintInfo *)printInfo; +-(NSString *)fileType; +-(BOOL)hasUndoManager; +-(NSUndoManager *)undoManager; --(void)makeWindowControllers; +-(void)setAutosavedContentsFileURL:(NSURL *)url; +-(void)setFileModificationDate:(NSDate *)value; +-(void)setFileURL:(NSURL *)url; +-(void)setPrintInfo:(NSPrintInfo *)value; +-(void)setFileType:(NSString *)value; +-(void)setHasUndoManager:(BOOL)value; +-(void)setUndoManager:(NSUndoManager *)value; + +-(BOOL)hasUnautosavedChanges; +-(NSString *)autosavingFileType; + +-(void)setLastComponentOfFileName:(NSString *)name; -(NSString *)windowNibName; +-(void)setWindow:(NSWindow *)window; -(void)windowControllerDidLoadNib:(NSWindowController *)controller; -(void)windowControllerWillLoadNib:(NSWindowController *)controller; +-(void)showWindows; +-(void)makeWindowControllers; -(NSArray *)windowControllers; -(void)addWindowController:(NSWindowController *)controller; -(void)removeWindowController:(NSWindowController *)controller; --(void)showWindows; -(NSString *)displayName; --(void)setWindow:(NSWindow *)window; - --(BOOL)readFromData:(NSData *)data ofType:(NSString *)type error:(NSError **)error; --(BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)type error:(NSError **)error; --(BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error; - --(BOOL)readFromFile:(NSString *)path ofType:(NSString *)type; --(BOOL)writeToFile:(NSString *)path ofType:(NSString *)type; --(BOOL)writeWithBackupToFile:(NSString *)path ofType:(NSString *)type saveOperation:(NSSaveOperationType)operation; --(NSString *)fileName; --(NSURL *)fileURL; --(void)setFileName:(NSString *)path; --(BOOL)keepBackupFile; +-(NSWindow *)windowForSheet; -(BOOL)isDocumentEdited; -(void)updateChangeCount:(NSDocumentChangeType)changeType; --(NSUndoManager *)undoManager; --(void)setUndoManager:(NSUndoManager *)undoManager; --(BOOL)hasUndoManager; --(void)setHasUndoManager:(BOOL)flag; +-(BOOL)readFromData:(NSData *)data ofType:(NSString *)type error:(NSError **)error; +-(BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)type error:(NSError **)error; +-(BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error; +-(BOOL)revertToContentsOfURL:(NSURL *)ul ofType:(NSString *)type error:(NSError **)error; --(BOOL)prepareSavePanel:(NSSavePanel *)savePanel; --(void)runModalSavePanelForSaveOperation:(NSSaveOperationType)operation delegate:delegate didSaveSelector:(SEL)selector contextInfo:(void *)context; +-(NSData *)dataOfType:(NSString *)type error:(NSError **)error; +-(NSFileWrapper *)fileWrapperOfType:(NSString *)type error:(NSError **)error; +-(BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error; +-(BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)operation originalContentsURL:(NSURL *)contentsURL error:(NSError **)error; +-(BOOL)writeSafelyToURL:(NSURL *)url ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)operation error:(NSError **)error; +-(NSDictionary *)fileAttributesToWriteToURL:(NSURL *)url ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)operation originalContentsURL:(NSURL *)contentsURL error:(NSError **)error; + +-(BOOL)keepBackupFile; + +-(void)autosaveDocumentWithDelegate:delegate didAutosaveSelector:(SEL)selector contextInfo:(void *)info; + +-(NSError *)willPresentError:(NSError *)error; +-(BOOL)presentError:(NSError *)error; +-(void)presentError:(NSError *)error modalForWindow:(NSWindow *)window delegate:delegate didPresentSelector:(SEL)selector contextInfo:(void *)info; + +-(NSArray *)writableTypesForSaveOperation:(NSSaveOperationType)operation; +-(BOOL)shouldRunSavePanelWithAccessoryView; +-(BOOL)prepareSavePanel:(NSSavePanel *)panel; +-(BOOL)fileNameExtensionWasHiddenInLastRunSavePanel; +-(NSString *)fileTypeFromLastRunSavePanel; +-(void)runModalSavePanelForSaveOperation:(NSSaveOperationType)operation delegate:delegate didSaveSelector:(SEL)selector contextInfo:(void *)info; +-(void)saveDocumentWithDelegate:delegate didSaveSelector:(SEL)selector contextInfo:(void *)info; +-(BOOL)saveToURL:(NSURL *)url ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)operation error:(NSError **)error; +-(void)saveToURL:(NSURL *)url ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)operation delegate:delegate didSaveSelector:(SEL)selector contextInfo:(void *)info; + +-(BOOL)preparePageLayout:(NSPageLayout *)pageLayout; +-(BOOL)shouldChangePrintInfo:(NSPrintInfo *)printInfo; +-(void)runModalPageLayoutWithPrintInfo:(NSPrintInfo *)printInfo delegate:delegate didRunSelector:(SEL)selector contextInfo:(void *)info; +-(void)runModalPrintOperation:(NSPrintOperation *)printOperation delegate:delegate didRunSelector:(SEL)selector contextInfo:(void *)info; -(NSPrintOperation *)printOperationWithSettings:(NSDictionary *)settings error:(NSError **)error; --(void)printDocumentWithSettings:(NSDictionary *)settings showPrintPanel:(BOOL)showPanel delegate:delegate didPrintSelector:(SEL)selector contextInfo:(void *)contextInfo; +-(void)printDocumentWithSettings:(NSDictionary *)settings showPrintPanel:(BOOL)showPanel delegate:delegate didPrintSelector:(SEL)selector contextInfo:(void *)info; --(void)printDocument:sender; +-(void)close; +-(void)canCloseDocumentWithDelegate:delegate shouldCloseSelector:(SEL)selector contextInfo:(void *)info; +-(void)shouldCloseWindowController:(NSWindowController *)controller delegate:delegate shouldCloseSelector:(SEL)selector contextInfo:(void *)info; --(void)runPageLayout:sender; -(void)revertDocumentToSaved:sender; -(void)saveDocument:sender; -(void)saveDocumentAs:sender; -(void)saveDocumentTo:sender; +-(void)printDocument:sender; +-(void)runPageLayout:sender; --(BOOL)revertToSavedFromFile:(NSString *)path ofType:(NSString *)type; +-(BOOL)validateUserInterfaceItem:(id )item; --(void)setFileType:(NSString *)type; --(NSString *)fileType; +// deprecated -(BOOL)validateMenuItem:(NSMenuItem *)item; - --(void)close; - -// deprecated, avoid - -(BOOL)canCloseDocument; +-(NSData *)dataRepresentationOfType:(NSString *)type; +-(NSDictionary *)fileAttributesToWriteToFile:(NSString *)path ofType:(NSString *)type saveOperation:(NSSaveOperationType)operation; +-(NSString *)fileName; +-(NSString *)fileNameFromRunningSavePanelForSaveOperation:(NSSaveOperationType)operation; +-(NSFileWrapper *)fileWrapperRepresentationOfType:(NSString *)type; +-initWithContentsOfFile:(NSString *)path ofType:(NSString *)type; +-initWithContentsOfURL:(NSURL *)url ofType:(NSString *)type; +-(BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)type; +-(BOOL)loadFileWrapperRepresentation:(NSFileWrapper *)wrapper ofType:(NSString *)type; +-(void)printShowingPrintPanel:(BOOL)flag; +-(BOOL)readFromFile:(NSString *)path ofType:(NSString *)type; +-(BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type; +-(BOOL)revertToSavedFromFile:(NSString *)path ofType:(NSString *)type; +-(BOOL)revertToSavedFromURL:(NSURL *)url ofType:(NSString *)type; +-(int)runModalSavePanel:(NSSavePanel *)savePanel withAccessoryView:(NSView *)accessoryView; +-(int)runModalPageLayoutWithPrintInfo:(NSPrintInfo *)printInfo; +-(void)setFileName:(NSString *)path; +-(void)saveToFile:(NSString *)path saveOperation:(NSSaveOperationType)operation delegate:delegate didSaveSelector:(SEL)selector contextInfo:(void *)info; +-(BOOL)shouldCloseWindowController:(NSWindowController *)controller; +-(BOOL)writeToFile:(NSString *)path ofType:(NSString *)type; +-(BOOL)writeToFile:(NSString *)path ofType:(NSString *)type originalFile:(NSString *)original saveOperation:(NSSaveOperationType)operation; +-(BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type; +-(BOOL)writeWithBackupToFile:(NSString *)path ofType:(NSString *)type saveOperation:(NSSaveOperationType)operation; -// private --(void)_setUntitledNumber:(int)number; @end diff --git a/AppKit/NSDocument.m b/AppKit/NSDocument.m index 57cb8272..df8dcc29 100755 --- a/AppKit/NSDocument.m +++ b/AppKit/NSDocument.m @@ -17,13 +17,36 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import @implementation NSDocument ++(NSArray *)readableTypes { + NSUnimplementedMethod(); + return 0; +} + ++(NSArray *)writableTypes { + NSUnimplementedMethod(); + return 0; +} + ++(BOOL)isNativeType:(NSString *)type { + NSUnimplementedMethod(); + return 0; +} + +-(BOOL)_isSelectorOverridden:(SEL)selector { + IMP mine=[NSDocument instanceMethodForSelector:selector]; + IMP theirs=[self methodForSelector:selector]; + + return (mine!=theirs)?YES:NO; +} + -init { _windowControllers=[NSMutableArray new]; - _path=nil; - _type=nil; + _fileURL=nil; + _fileType=nil; _changeCount=0; _untitledNumber=0; _hasUndoManager=YES; @@ -31,240 +54,69 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return self; } --initWithContentsOfFile:(NSString *)path ofType:(NSString *)type { - NSURL *url=[NSURL fileURLWithPath:path]; - NSError *error; - +-initWithType:(NSString *)type error:(NSError **)error { [self init]; - - error=nil; - if(![self readFromURL:url ofType:type error:&error]){ - NSRunAlertPanel(nil,@"Can't open file '%@'. Error = %@",@"Ok",nil,nil,path,error); - [self dealloc]; - return nil; - } - else { - [self setFileName:path]; - [self setFileType:type]; - } - + [self setFileType:type]; return self; } --initWithContentsOfURL:(NSURL *)url ofType:(NSString *)type { - NSString *path=[url path]; - NSError *error; - - [self init]; - - error=nil; - if(![self readFromURL:url ofType:type error:&error]){ - NSRunAlertPanel(nil,@"Can't open file '%@'. Error = %@",@"Ok",nil,nil,path,error); - [self dealloc]; - return nil; +-initWithContentsOfURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error { + if([self _isSelectorOverridden:@selector(initWithContentsOfFile:ofType:)]){ + if([self initWithContentsOfFile:[url path] ofType:type]==nil) + return nil; } else { - [self setFileName:path]; + [self init]; + if(![self readFromURL:url ofType:type error:error]){ + [self dealloc]; + return nil; + } + [self setFileURL:url]; [self setFileType:type]; } - + [self setFileModificationDate:[NSDate date]]; return self; } --(void)_setUntitledNumber:(int)number { - _untitledNumber=number; -} - --(NSData *)dataRepresentationOfType:(NSString *)type { - [NSException raise:NSInternalInconsistencyException format:@"-[%@ %s]",isa,SELNAME(_cmd)]; - return nil; -} - --(BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)type { - [NSException raise:NSInternalInconsistencyException format:@"-[%@ %s]",isa,SELNAME(_cmd)]; - return NO; -} - --(BOOL)loadFileWrapperRepresentation:(NSFileWrapper *)fileWrapper ofType:(NSString *)type { - - if([fileWrapper isRegularFile]) - return [self loadDataRepresentation:[fileWrapper regularFileContents] ofType:type]; - - return NO; -} - --(void)makeWindowControllers { - NSString *nibName=[self windowNibName]; - - if(nibName!=nil){ - NSWindowController *controller=[[[NSWindowController alloc] initWithWindowNibName:nibName owner:self] autorelease]; - - [self addWindowController:controller]; - } -} - --(NSString *)windowNibName { - return nil; -} - --(void)windowControllerDidLoadNib:(NSWindowController *)controller { - // do nothing -} - --(void)windowControllerWillLoadNib:(NSWindowController *)controller { - // do nothing -} - --(NSArray *)windowControllers { - return _windowControllers; -} - --(void)addWindowController:(NSWindowController *)controller { - [_windowControllers addObject:controller]; - if([controller document]==nil) - [controller setDocument:self]; -} - --(void)removeWindowController:(NSWindowController *)controller { - [_windowControllers removeObjectIdenticalTo:controller]; -} - --(void)showWindows { - [_windowControllers makeObjectsPerformSelector:@selector(showWindow:) withObject:self]; -} - --(NSString *)displayName { - if(_path==nil) - return [NSString stringWithFormat:@"Untitled-%d",_untitledNumber]; - else - return [_path lastPathComponent]; -} - --(void)setWindow:(NSWindow *)window { - [[_windowControllers objectAtIndex:0] setWindow:window]; - [window release]; -} - --(BOOL)readFromData:(NSData *)data ofType:(NSString *)type error:(NSError **)error { - IMP mine=[NSDocument instanceMethodForSelector:@selector(loadDataRepresentation:ofType:)]; - IMP theirs=[self methodForSelector:@selector(loadDataRepresentation:ofType:)]; - - if(mine!=theirs) - return [self loadDataRepresentation:data ofType:type]; - else { - [NSException raise:NSInternalInconsistencyException format:@"-[%@ %s]",isa,SELNAME(_cmd)]; - return NO; - } -} - --(BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)type error:(NSError **)error { - IMP mine=[NSDocument instanceMethodForSelector:@selector(loadFileWrapperRepresentation:ofType:)]; - IMP theirs=[self methodForSelector:@selector(loadFileWrapperRepresentation:ofType:)]; - - if(mine!=theirs) - return [self loadFileWrapperRepresentation:fileWrapper ofType:type]; - else - return [self readFromData:[fileWrapper regularFileContents] ofType:type error:error]; -} - --(BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error { - if([url isFileURL]){ - IMP mine=[NSDocument instanceMethodForSelector:@selector(readFromFile:ofType:)]; - IMP theirs=[self methodForSelector:@selector(readFromFile:ofType:)]; - - if(mine!=theirs){ - return [self readFromFile:[url path] ofType:type]; - } - else { - NSFileWrapper *fileWrapper=[[[NSFileWrapper alloc] initWithPath:[url path]] autorelease]; - - return [self readFromFileWrapper:fileWrapper ofType:type error:error]; +-initForURL:(NSURL *)url withContentsOfURL:(NSURL *)contentsURL ofType:(NSString *)type error:(NSError **)error { + [self init]; + if(contentsURL!=nil){ + if(![self readFromURL:contentsURL ofType:type error:error]){ + [self dealloc]; + return nil; } } - - return NO; + [self setFileURL:url]; + [self setFileType:type]; + [self setFileModificationDate:[NSDate date]]; + return self; } --(BOOL)readFromFile:(NSString *)path ofType:(NSString *)type { - NSData *data=[[NSData alloc] initWithContentsOfFile:path]; - - if(data==nil) - return NO; - - if(![self loadDataRepresentation:data ofType:type]){ - [data release]; - return NO; - } - - [data release]; - return YES; +-(NSURL *)autosavedContentsFileURL { + return _autosavedContentsFileURL; } --(BOOL)writeToFile:(NSString *)path ofType:(NSString *)type { - NSData *data=[self dataRepresentationOfType:type]; - - return [data writeToFile:path atomically:YES]; -} - --(BOOL)writeWithBackupToFile:(NSString *)path ofType:(NSString *)type saveOperation:(NSSaveOperationType)operation { - // move original to backup - - if(![self writeToFile:path ofType:type]) - return NO; - - if(![self keepBackupFile]){ - // delete backup - } - return YES; -} - --(NSString *)fileName { - return _path; +-(NSDate *)fileModificationDate { + return _fileModificationDate; } -(NSURL *)fileURL { - if(_path==nil) - return nil; - - return [NSURL fileURLWithPath:_path]; + return _fileURL; } --(void)setFileName:(NSString *)path { - path=[path copy]; - [_path release]; - _path=path; - [_windowControllers makeObjectsPerformSelector:@selector(synchronizeWindowTitleWithDocumentName)]; +-(NSPrintInfo *)printInfo { + return _printInfo; } --(BOOL)keepBackupFile { - return NO; +-(NSString *)fileType { + return _fileType; } --(BOOL)isDocumentEdited { - return (_changeCount>0)?YES:NO; +-(BOOL)hasUndoManager { + return _hasUndoManager; } --(void)updateChangeCount:(NSDocumentChangeType)changeType { - int count=[_windowControllers count]; - - switch(changeType){ - case NSChangeDone: - _changeCount++; - break; - - case NSChangeUndone: - _changeCount--; - break; - - case NSChangeCleared: - _changeCount=0; - break; - } - - while(--count>=0) - [[_windowControllers objectAtIndex:count] setDocumentEdited:(_changeCount!=0)?YES:NO]; -} -(NSUndoManager *)undoManager { if (_undoManager == nil && _hasUndoManager == YES) { @@ -275,16 +127,43 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return _undoManager; } --(void)_undoManagerDidUndoChange:(NSNotification *)note { - [self updateChangeCount:NSChangeUndone]; +-(void)setAutosavedContentsFileURL:(NSURL *)url { + url=[url copy]; + [_autosavedContentsFileURL release]; + _autosavedContentsFileURL=url; } --(void)_undoManagerDidRedoChange:(NSNotification *)note { - [self updateChangeCount:NSChangeDone]; +-(void)setFileModificationDate:(NSDate *)value { + value=[value copy]; + [_fileModificationDate release]; + _fileModificationDate=value; } --(void)_undoManagerDidCloseGroup:(NSNotification *)note { - [self updateChangeCount:NSChangeDone]; +-(void)setFileURL:(NSURL *)url { + url=[url copy]; + [_fileURL release]; + _fileURL=url; + [_windowControllers makeObjectsPerformSelector:@selector(synchronizeWindowTitleWithDocumentName)]; +} + +-(void)setPrintInfo:(NSPrintInfo *)value { + value=[value copy]; + [_printInfo release]; + _printInfo=value; +} + +-(void)setFileType:(NSString *)type { + type=[type copy]; + [_fileType release]; + _fileType=type; +} + +-(void)setHasUndoManager:(BOOL)flag { + _hasUndoManager = flag; + if (flag == YES && _undoManager == nil) + [self undoManager]; + else if (flag == NO && _undoManager != nil) + [self setUndoManager:nil]; } -(void)setUndoManager:(NSUndoManager *)undoManager { @@ -324,40 +203,286 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return nil; } --(BOOL)hasUndoManager { - return _hasUndoManager; +-(BOOL)hasUnautosavedChanges { + NSUnimplementedMethod(); + return 0; } --(void)setHasUndoManager:(BOOL)flag { - _hasUndoManager = flag; - if (flag == YES && _undoManager == nil) - [self undoManager]; - else if (flag == NO && _undoManager != nil) - [self setUndoManager:nil]; +-(NSString *)autosavingFileType { + return [self fileType]; +} + +-(void)setLastComponentOfFileName:(NSString *)name { + name=[name copy]; + [_lastComponentOfFileName release]; + _lastComponentOfFileName=name; +} + +-(NSString *)windowNibName { + return nil; +} + +-(void)setWindow:(NSWindow *)window { + [[_windowControllers objectAtIndex:0] setWindow:window]; + [window release]; +} + +-(void)windowControllerDidLoadNib:(NSWindowController *)controller { + // do nothing +} + +-(void)windowControllerWillLoadNib:(NSWindowController *)controller { + // do nothing +} + +-(void)showWindows { + [_windowControllers makeObjectsPerformSelector:@selector(showWindow:) withObject:self]; +} + +-(void)makeWindowControllers { + NSString *nibName=[self windowNibName]; + + if(nibName!=nil){ + NSWindowController *controller=[[[NSWindowController alloc] initWithWindowNibName:nibName owner:self] autorelease]; + + [self addWindowController:controller]; + } +} + +-(NSArray *)windowControllers { + return _windowControllers; +} + +-(void)addWindowController:(NSWindowController *)controller { + [_windowControllers addObject:controller]; + if([controller document]==nil) + [controller setDocument:self]; +} + +-(void)removeWindowController:(NSWindowController *)controller { + [_windowControllers removeObjectIdenticalTo:controller]; +} + +-(NSString *)displayName { + if(_fileURL==nil) + return [NSString stringWithFormat:@"Untitled-%d",_untitledNumber]; + else + return [[_fileURL path] lastPathComponent]; +} + +-(NSWindow *)windowForSheet { + if([_windowControllers count]>0){ + NSWindow *check=[[_windowControllers objectAtIndex:0] window]; + + if(check!=nil) + return check; + } + + return [NSApp mainWindow]; +} + +-(BOOL)isDocumentEdited { + return (_changeCount>0)?YES:NO; +} + +-(void)updateChangeCount:(NSDocumentChangeType)changeType { + int count=[_windowControllers count]; + + switch(changeType){ + case NSChangeDone: + _changeCount++; + break; + + case NSChangeUndone: + _changeCount--; + break; + + case NSChangeCleared: + _changeCount=0; + break; + } + + while(--count>=0) + [[_windowControllers objectAtIndex:count] setDocumentEdited:(_changeCount!=0)?YES:NO]; +} + +-(BOOL)readFromData:(NSData *)data ofType:(NSString *)type error:(NSError **)error { + if([self _isSelectorOverridden:@selector(loadDataRepresentation:ofType:)]) + return [self loadDataRepresentation:data ofType:type]; + else { + [NSException raise:NSInternalInconsistencyException format:@"-[%@ %s]",isa,SELNAME(_cmd)]; + return NO; + } +} + +-(BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)type error:(NSError **)error { + if([self _isSelectorOverridden:@selector(loadFileWrapperRepresentation:ofType:)]) + return [self loadFileWrapperRepresentation:fileWrapper ofType:type]; + else + return [self readFromData:[fileWrapper regularFileContents] ofType:type error:error]; +} + +-(BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error { + if([url isFileURL]){ + if([self _isSelectorOverridden:@selector(readFromFile:ofType:)]){ + return [self readFromFile:[url path] ofType:type]; + } + else { + NSFileWrapper *fileWrapper=[[[NSFileWrapper alloc] initWithPath:[url path]] autorelease]; + + return [self readFromFileWrapper:fileWrapper ofType:type error:error]; + } + } + + return NO; +} + +-(BOOL)revertToContentsOfURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error { + if(![self readFromURL:url ofType:type error:error]) + return NO; + + [self setFileModificationDate:[NSDate date]]; + [self updateChangeCount:NSChangeCleared]; + return YES; +} + + +-(NSData *)dataOfType:(NSString *)type error:(NSError **)error { + if([self _isSelectorOverridden:@selector(dataRepresentationOfType:)]) + return [self dataRepresentationOfType:type]; + + [NSException raise:NSInternalInconsistencyException format:@"-[%@ %s]",isa,SELNAME(_cmd)]; + return nil; +} + +-(NSFileWrapper *)fileWrapperOfType:(NSString *)type error:(NSError **)error { + if([self _isSelectorOverridden:@selector(fileWrapperRepresentationOfType:)]) + return [self fileWrapperRepresentationOfType:type]; + else { + NSData *data=[self dataOfType:type error:error]; + + if(data==nil) + return nil; + + return [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease]; + } +} + +-(BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error { + if([self _isSelectorOverridden:@selector(writeToFile:ofType:)]){ + return [self writeToFile:[url path] ofType:type]; + } + else { + NSFileWrapper *wrapper=[self fileWrapperOfType:type error:error]; + + if(wrapper==nil) + return NO; + + if(![wrapper writeToFile:[url path] atomically:YES updateFilenames:YES]) + return NO; + + return YES; + } +} + +-(BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)operation originalContentsURL:(NSURL *)contentsURL error:(NSError **)error { + if([self _isSelectorOverridden:@selector(writeToFile:ofType:originalFile:saveOperation:)]){ + return [self writeToFile:[url path] ofType:type originalFile:[contentsURL path] saveOperation:operation]; + } + else { + return [self writeToURL:url ofType:type error:error]; + } +} + +-(BOOL)writeSafelyToURL:(NSURL *)url ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)operation error:(NSError **)error { + if(![self writeToURL:url ofType:type forSaveOperation:operation originalContentsURL:url error:error]) + return NO; + + NSDictionary *attributes=[self fileAttributesToWriteToURL:url ofType:type forSaveOperation:operation originalContentsURL:url error:error]; + + if([attributes count]) + [[NSFileManager defaultManager] changeFileAttributes:attributes atPath:[url path]]; + + return YES; +} + +-(NSDictionary *)fileAttributesToWriteToURL:(NSURL *)url ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)operation originalContentsURL:(NSURL *)contentsURL error:(NSError **)error { + NSMutableDictionary *result=[NSMutableDictionary dictionary]; + + + return result; +} + +-(BOOL)keepBackupFile { + return NO; +} + +-(void)autosaveDocumentWithDelegate:delegate didAutosaveSelector:(SEL)selector contextInfo:(void *)info { + NSError *error; + + if(![self writeToURL:[self autosavedContentsFileURL] ofType:[self autosavingFileType] forSaveOperation:NSAutosaveOperation originalContentsURL:[self fileURL] error:&error]){ + } + + NSUnimplementedMethod(); +} + + +-(NSError *)willPresentError:(NSError *)error { +// do nothing + return error; +} + +-(BOOL)presentError:(NSError *)error { + NSUnimplementedMethod(); + return 0; +} + +-(void)presentError:(NSError *)error modalForWindow:(NSWindow *)window delegate:delegate didPresentSelector:(SEL)selector contextInfo:(void *)info { + NSUnimplementedMethod(); +} + + +-(NSArray *)writableTypesForSaveOperation:(NSSaveOperationType)operation { + NSArray *result=[[self class] writableTypes]; + + if(operation==NSSaveToOperation){ + NSMutableArray *filtered=[NSMutableArray array]; + int i,count=[result count]; + + for(i=0;i=0) + [[_windowControllers objectAtIndex:count] close]; + + [[NSDocumentController sharedDocumentController] removeDocument:self]; } --(void)runPageLayout:sender { - [[NSPageLayout pageLayout] runModal]; +-(void)canCloseDocumentWithDelegate:delegate shouldCloseSelector:(SEL)selector contextInfo:(void *)info { + NSUnimplementedMethod(); } +-(void)shouldCloseWindowController:(NSWindowController *)controller delegate:delegate shouldCloseSelector:(SEL)selector contextInfo:(void *)info { + NSUnimplementedMethod(); +} + + -(void)revertDocumentToSaved:sender { int result=NSRunAlertPanel(nil,@"%@ has been edited. Are you sure you want to undo changes?", @"Revert",@"Cancel",nil,[self displayName]); @@ -416,24 +610,155 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI } -(void)saveDocument:sender { - if(_path!=nil){ - [self saveToFile:_path saveOperation:NSSaveOperation - delegate:nil didSaveSelector:NULL contextInfo:NULL]; + if(_fileURL!=nil){ + if([self _isSelectorOverridden:@selector(saveToFile:saveOperation:delegate:didSaveSelector:contextInfo:)]){ + [self saveToFile:[_fileURL path] saveOperation:NSSaveOperation delegate:nil didSaveSelector:NULL contextInfo:NULL]; + } + else { + [self saveToURL:_fileURL ofType:[self fileType] forSaveOperation:NSSaveOperation delegate:nil didSaveSelector:NULL contextInfo:NULL]; + } } else { - [self runModalSavePanelForSaveOperation:NSSaveOperation - delegate:nil didSaveSelector:NULL contextInfo:NULL]; + [self runModalSavePanelForSaveOperation:NSSaveOperation delegate:nil didSaveSelector:NULL contextInfo:NULL]; } } -(void)saveDocumentAs:sender { - [self runModalSavePanelForSaveOperation:NSSaveAsOperation - delegate:nil didSaveSelector:NULL contextInfo:NULL]; + [self runModalSavePanelForSaveOperation:NSSaveAsOperation delegate:nil didSaveSelector:NULL contextInfo:NULL]; } -(void)saveDocumentTo:sender { - [self runModalSavePanelForSaveOperation:NSSaveToOperation - delegate:nil didSaveSelector:NULL contextInfo:NULL]; + [self runModalSavePanelForSaveOperation:NSSaveToOperation delegate:nil didSaveSelector:NULL contextInfo:NULL]; +} + +-(void)printDocument:sender { + [self printDocumentWithSettings:nil showPrintPanel:YES delegate:nil didPrintSelector:NULL contextInfo:NULL]; +} + + +-(void)runPageLayout:sender { + [[NSPageLayout pageLayout] runModal]; +} + +-(BOOL)validateUserInterfaceItem:(id )item { + if([item action]==@selector(revertDocumentToSaved:)) + return (_fileURL!=nil)?YES:NO; + if([item action]==@selector(saveDocument:)) + return YES; + + return NO; +} + +-(BOOL)validateMenuItem:(NSMenuItem *)item { + if([item action]==@selector(revertDocumentToSaved:)) + return (_fileURL!=nil)?YES:NO; + if([item action]==@selector(saveDocument:)) + return YES; + + return NO; +} + +-(BOOL)canCloseDocument { + return YES; +} + +-(NSData *)dataRepresentationOfType:(NSString *)type { + [NSException raise:NSInternalInconsistencyException format:@"-[%@ %s]",isa,SELNAME(_cmd)]; + return nil; +} + +-(NSDictionary *)fileAttributesToWriteToFile:(NSString *)path ofType:(NSString *)type saveOperation:(NSSaveOperationType)operation { + return [NSDictionary dictionary]; +} + +-(NSString *)fileName { + return [_fileURL path]; +} + +-(NSString *)fileNameFromRunningSavePanelForSaveOperation:(NSSaveOperationType)operation { + NSUnimplementedMethod(); + return nil; +} + +-(NSFileWrapper *)fileWrapperRepresentationOfType:(NSString *)type { + NSData *data=[self dataRepresentationOfType:type]; + + if(data==nil) + return nil; + + return [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease]; +} + +-initWithContentsOfFile:(NSString *)path ofType:(NSString *)type { + NSURL *url=[NSURL fileURLWithPath:path]; + NSError *error; + + [self init]; + + error=nil; + if(![self readFromURL:url ofType:type error:&error]){ + NSRunAlertPanel(nil,@"Can't open file '%@'. Error = %@",@"Ok",nil,nil,path,error); + [self dealloc]; + return nil; + } + [self setFileName:path]; + [self setFileType:type]; + + return self; +} + + +-initWithContentsOfURL:(NSURL *)url ofType:(NSString *)type { + NSError *error; + + [self init]; + + error=nil; + if(![self readFromURL:url ofType:type error:&error]){ + NSRunAlertPanel(nil,@"Can't open URL '%@'. Error = %@",@"Ok",nil,nil,url,error); + [self dealloc]; + return nil; + } + [self setFileURL:url]; + [self setFileType:type]; + + return self; +} + +-(BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)type { + [NSException raise:NSInternalInconsistencyException format:@"-[%@ %s]",isa,SELNAME(_cmd)]; + return NO; +} + +-(BOOL)loadFileWrapperRepresentation:(NSFileWrapper *)fileWrapper ofType:(NSString *)type { + + if([fileWrapper isRegularFile]) + return [self loadDataRepresentation:[fileWrapper regularFileContents] ofType:type]; + + return NO; +} + +-(void)printShowingPrintPanel:(BOOL)flag { + // do nothing +} + +-(BOOL)readFromFile:(NSString *)path ofType:(NSString *)type { + NSData *data=[[NSData alloc] initWithContentsOfFile:path]; + + if(data==nil) + return NO; + + if(![self loadDataRepresentation:data ofType:type]){ + [data release]; + return NO; + } + + [data release]; + return YES; +} + +-(BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type { + return [self readFromFile:[url path] ofType:type]; } -(BOOL)revertToSavedFromFile:(NSString *)path ofType:(NSString *)type { @@ -445,28 +770,99 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return NO; } --(void)setFileType:(NSString *)type { - type=[type copy]; - [_type release]; - _type=type; +-(BOOL)revertToSavedFromURL:(NSURL *)url ofType:(NSString *)type { + if([self readFromURL:url ofType:type]){ + [self updateChangeCount:NSChangeCleared]; + return YES; + } + + return NO; } --(NSString *)fileType { - return _type; -} - --(BOOL)validateMenuItem:(NSMenuItem *)item { - return YES; -} - --(void)close { +-(int)runModalSavePanel:(NSSavePanel *)savePanel withAccessoryView:(NSView *)accessoryView { NSUnimplementedMethod(); + return 0; } --(BOOL)canCloseDocument { +-(int)runModalPageLayoutWithPrintInfo:(NSPrintInfo *)printInfo { + return [[NSPageLayout pageLayout] runModalWithPrintInfo:printInfo]; +} + +-(void)setFileName:(NSString *)path { + [self setFileURL:[NSURL fileURLWithPath:path]]; +} + +-(void)saveToFile:(NSString *)path saveOperation:(NSSaveOperationType)operation delegate:delegate didSaveSelector:(SEL)selector contextInfo:(void *)context { + if(path!=nil){ + BOOL success=[self writeWithBackupToFile:path ofType:_fileType saveOperation:operation]; + + if(success){ + if(operation!=NSSaveToOperation) + [self setFileName:path]; + } + + // send delegate message with success + + [self updateChangeCount:NSChangeCleared]; + } +} + + +-(BOOL)shouldCloseWindowController:(NSWindowController *)controller { + if(![controller shouldCloseDocument]) + return NO; + + [self canCloseDocumentWithDelegate:nil shouldCloseSelector:NULL contextInfo:NULL]; return YES; } +-(BOOL)writeToFile:(NSString *)path ofType:(NSString *)type { + NSData *data=[self dataRepresentationOfType:type]; + + return [data writeToFile:path atomically:YES]; +} + +-(BOOL)writeToFile:(NSString *)path ofType:(NSString *)type originalFile:(NSString *)original saveOperation:(NSSaveOperationType)operation { + NSUnimplementedMethod(); + return 0; +} + +-(BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type { + NSUnimplementedMethod(); + return 0; +} + +-(BOOL)writeWithBackupToFile:(NSString *)path ofType:(NSString *)type saveOperation:(NSSaveOperationType)operation { + // move original to backup + + if(![self writeToFile:path ofType:type]) + return NO; + + if(![self keepBackupFile]){ + // delete backup + } + return YES; +} + +-(void)_setUntitledNumber:(int)number { + _untitledNumber=number; +} + + + +-(void)_undoManagerDidUndoChange:(NSNotification *)note { + [self updateChangeCount:NSChangeUndone]; +} + +-(void)_undoManagerDidRedoChange:(NSNotification *)note { + [self updateChangeCount:NSChangeDone]; +} + +-(void)_undoManagerDidCloseGroup:(NSNotification *)note { + [self updateChangeCount:NSChangeDone]; +} + + -(BOOL)windowShouldClose:sender { if([[NSUserDefaults standardUserDefaults] boolForKey:@"useSheets"]){ NSBeginAlertSheet(nil,@"Save",@"Don't Save",@"Cancel",sender,self,@selector(didEndShouldCloseSheet:returnCode:contextInfo:),NULL,sender,@"%@ has changed. Save?",[self displayName]); diff --git a/AppKit/NSDocumentController.h b/AppKit/NSDocumentController.h index fec4deca..66435795 100755 --- a/AppKit/NSDocumentController.h +++ b/AppKit/NSDocumentController.h @@ -7,50 +7,83 @@ The above copyright notice and this permission notice shall be included in all c 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 +#import -@class NSDocument,NSOpenPanel; +@class NSDocument,NSOpenPanel,NSWindow,NSMenuItem; -@interface NSDocumentController : NSObject { +@interface NSDocumentController : NSObject { NSMutableArray *_documents; NSArray *_fileTypes; + NSTimeInterval _autosavingDelay; + NSString *_lastOpenPanelDirectory; } +sharedDocumentController; -init; --(NSArray *)documents; --(void)addDocument:(NSDocument *)document; --(void)removeDocument:(NSDocument *)document; --documentForURL:(NSURL *)url; - --makeDocumentWithContentsOfFile:(NSString *)path ofType:(NSString *)type; --makeDocumentWithContentsOfURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error; --makeUntitledDocumentOfType:(NSString *)type; - --openUntitledDocumentOfType:(NSString *)type display:(BOOL)display; --openDocumentWithContentsOfFile:(NSString *)path display:(BOOL)display; --openDocumentWithContentsOfURL:(NSURL *)url display:(BOOL)display error:(NSError **)error; - --(NSString *)currentDirectory; - --(id)currentDocument; +-(NSString *)defaultType; +-(NSArray *)documentClassNames; +-(NSTimeInterval)autosavingDelay; -(NSString *)displayNameForType:(NSString *)type; -(Class)documentClassForType:(NSString *)type; -(NSArray *)fileExtensionsFromType:(NSString *)type; -(NSString *)typeFromFileExtension:(NSString *)extension; +-(void)setAutosavingDelay:(NSTimeInterval)value; + +-(NSArray *)documents; +-(void)addDocument:(NSDocument *)document; +-(void)removeDocument:(NSDocument *)document; +-documentForURL:(NSURL *)url; + +-currentDocument; +-(NSString *)currentDirectory; +-(BOOL)hasEditedDocuments; +-documentForWindow:(NSWindow *)window; + +-(NSString *)typeForContentsOfURL:(NSURL *)url error:(NSError **)error; + +-makeDocumentWithContentsOfFile:(NSString *)path ofType:(NSString *)type; +-makeDocumentWithContentsOfURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error; +-makeDocumentForURL:(NSURL *)url withContentsOfURL:(NSURL *)contentsURL ofType:(NSString *)type error:(NSError **)error; +-makeUntitledDocumentOfType:(NSString *)type; + +-openUntitledDocumentOfType:(NSString *)type display:(BOOL)display; +-openUntitledDocumentAndDisplay:(BOOL)display error:(NSError **)error; +-openDocumentWithContentsOfFile:(NSString *)path display:(BOOL)display; +-openDocumentWithContentsOfURL:(NSURL *)url display:(BOOL)display error:(NSError **)error; + +-(BOOL)reopenDocumentForURL:(NSURL *)url withContentsOfURL:(NSURL *)contentsUL error:(NSError **)error; + +-(void)closeAllDocumentsWithDelegate:delegate didCloseAllSelector:(SEL)selector info:(void *)info; + +-(void)reviewUnsavedDocumentsWithAlertTitle:(NSString *)title cancellable:(BOOL)cancellable delegate:delegate didReviewAllSelector:(SEL)selector info:(void *)info; + +-(NSError *)willPresentError:(NSError *)error; +-(BOOL)presentError:(NSError *)error; +-(void)presentError:(NSError *)error modalForWindow:(NSWindow *)window delegate:delegate didPresentSelector:(SEL)selector info:(void *)info; + -(int)runModalOpenPanel:(NSOpenPanel *)openPanel forTypes:(NSArray *)extensions; -(NSArray *)fileNamesFromRunningOpenPanel; +-(NSArray *)URLsFromRunningOpenPanel; + +-(NSArray *)recentDocumentURLs; +-(unsigned)maximumRecentDocumentCount; +-(void)noteNewRecentDocumentURL:(NSURL *)url; +-(void)noteNewRecentDocument:(NSDocument *)document; +-(void)clearRecentDocuments:sender; + -(void)newDocument:sender; -(void)openDocument:sender; -(void)saveAllDocuments:sender; --(NSArray *)recentDocumentURLs; --(void)noteNewRecentDocumentURL:(NSURL *)url; --(void)noteNewRecentDocument:(NSDocument *)document; --(unsigned)maximumRecentDocumentCount; --(void)clearRecentDocuments:sender; +-(BOOL)validateMenuItem:(NSMenuItem *)item; +-(BOOL)validateUserInterfaceItem:(id )item; + +// deprecated +-(BOOL)closeAllDocuments; +-(BOOL)reviewUnsavedDocumentsWithAlertTitle:(NSString *)title cancellable:(BOOL)cancellable; @end diff --git a/AppKit/NSDocumentController.m b/AppKit/NSDocumentController.m index fbfa66e2..adfb266d 100755 --- a/AppKit/NSDocumentController.m +++ b/AppKit/NSDocumentController.m @@ -13,6 +13,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import + +@interface NSDocument(private) +-(void)_setUntitledNumber:(int)number; +@end @interface NSDocumentController(forward) -(void)_updateRecentDocumentsMenu; @@ -35,136 +40,40 @@ static NSDocumentController *shared=nil; _documents=[NSMutableArray new]; _fileTypes=[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDocumentTypes"] retain]; - + _autosavingDelay=0; + [self _updateRecentDocumentsMenu]; return self; } --(NSArray *)documents { - return _documents; -} - --(void)addDocument:(NSDocument *)document { - [_documents addObject:document]; -} - --(void)removeDocument:(NSDocument *)document { - [_documents removeObjectIdenticalTo:document]; -} - --documentForURL:(NSURL *)url { - int i,count=[_documents count]; - - for(i=0;i=0){ + NSDocument *document=[_documents objectAtIndex:count]; + + if([document isDocumentEdited]) + [document saveDocument:sender]; + } +} + +static BOOL actionIsDocumentController(SEL selector){ + if(selector==@selector(saveAllDocuments:)) + return YES; + if(selector==@selector(openDocument:)) + return YES; + if(selector==@selector(newDocument:)) + return YES; + if(selector==@selector(clearRecentDocuments:)) + return YES; + if(selector==@selector(_openRecentDocument:)) + return YES; + + return NO; +} + +-(BOOL)validateMenuItem:(NSMenuItem *)item { + return actionIsDocumentController([item action]); +} + +-(BOOL)validateUserInterfaceItem:(id )item { + return actionIsDocumentController([item action]); +} + -(BOOL)application:sender openFile:(NSString *)path { NSError *error=nil; NSURL *url=[NSURL fileURLWithPath:path]; @@ -374,4 +545,14 @@ static NSDocumentController *shared=nil; return (document!=nil)?YES:NO; } +-(BOOL)closeAllDocuments { + NSUnimplementedMethod(); + return NO; +} + +-(BOOL)reviewUnsavedDocumentsWithAlertTitle:(NSString *)title cancellable:(BOOL)cancellable { + NSUnimplementedMethod(); + return 0; +} + @end diff --git a/AppKit/NSDragging.h b/AppKit/NSDragging.h index 47e1daa5..5cbd56d3 100755 --- a/AppKit/NSDragging.h +++ b/AppKit/NSDragging.h @@ -33,6 +33,7 @@ enum { -(id)draggingSource; -(void)slideDraggedImageTo:(NSPoint)point; -(int)draggingSequenceNumber; +-(NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)destination; @end @interface NSObject(NSDragging_destination) @@ -43,11 +44,15 @@ enum { -(NSDragOperation)draggingEntered:(id )sender; -(void)draggingExited:(id )sender; -(NSDragOperation)draggingUpdated:(id )sender; + +-(BOOL)wantsPeriodicDraggingUpdates; @end @interface NSObject(NSDragging_source) -(BOOL)ignoreModifierKeysWhileDragging; -(NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag; -(void)draggedImage:(NSImage *)image beganAt:(NSPoint)point; +-(void)draggedImage:(NSImage *)image movedTo:(NSPoint)point; -(void)draggedImage:(NSImage *)image endedAt:(NSPoint)point operation:(NSDragOperation)operation; +-(NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)destination; @end diff --git a/AppKit/NSEPSImageRep.h b/AppKit/NSEPSImageRep.h index 350b2f62..ce0be7e1 100755 --- a/AppKit/NSEPSImageRep.h +++ b/AppKit/NSEPSImageRep.h @@ -6,10 +6,20 @@ The above copyright notice and this permission notice shall be included in all c 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 - -@interface NSEPSImageRep : NSObject { +#import +@interface NSEPSImageRep : NSImageRep { + NSData *_data; } ++imageRepWithData:(NSData *)data; + +-initWithData:(NSData *)data; + +-(NSData *)EPSRepresentation; + +-(NSRect)boundingBox; + +-(void)prepareGState; + @end diff --git a/AppKit/NSEPSImageRep.m b/AppKit/NSEPSImageRep.m index 9e83a9e2..a0041372 100755 --- a/AppKit/NSEPSImageRep.m +++ b/AppKit/NSEPSImageRep.m @@ -8,7 +8,42 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI // Original - Christopher Lloyd #import +#import +#import @implementation NSEPSImageRep ++imageRepWithData:(NSData *)data { + return [[[self alloc] initWithData:data] autorelease]; +} + +-initWithData:(NSData *)data { + _data=[data retain]; + return self; +} + +-(void)dealloc { + [_data release]; + [super dealloc]; +} + +-(NSData *)EPSRepresentation { + return _data; +} + +-(NSRect)boundingBox { + NSUnimplementedMethod(); + return NSMakeRect(0,0,0,0); +} + +-(void)prepareGState { + // do nothing +} + +-(BOOL)draw { + [self prepareGState]; + NSUnimplementedMethod(); + return NO; +} + @end diff --git a/AppKit/NSFont.h b/AppKit/NSFont.h index c2d15989..4d8027be 100755 --- a/AppKit/NSFont.h +++ b/AppKit/NSFont.h @@ -8,36 +8,49 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import +#import -@class KGFont; +@class NSFontDescriptor,KGFont; typedef unsigned NSGlyph; enum { - NSNullGlyph=0x0, - NSControlGlyph=0x00FFFFFF + NSNullGlyph=0, + NSControlGlyph=0xFFFFFF, }; typedef enum { - NSCoreGraphicsGlyphPacking, + NSNativeShortGlyphPacking, } NSMultibyteGlyphPacking; +typedef enum { + NSFontDefaultRenderingMode, + NSFontAntialiasedRenderingMode, + NSFontIntegerAdvancementsRenderingMode, + NSFontAntialiasedIntegerAdvancementsRenderingMode, +} NSFontRenderingMode; + @interface NSFont : NSObject { NSString *_name; float _pointSize; float _matrix[6]; NSStringEncoding _encoding; - + KGFont *_kgFont; } -+(NSFont *)fontWithName:(NSString *)name size:(float)size; -+(NSFont *)fontWithName:(NSString *)name matrix:(const float *)matrix; ++(float)systemFontSize; ++(float)smallSystemFontSize; ++(float)labelFontSize; ++(float)systemFontSizeForControlSize:(NSControlSize)size; +(NSFont *)boldSystemFontOfSize:(float)size; +(NSFont *)controlContentFontOfSize:(float)size; + +(NSFont *)labelFontOfSize:(float)size; +(NSFont *)menuFontOfSize:(float)size; ++(NSFont *)menuBarFontOfSize:(float)size; + +(NSFont *)messageFontOfSize:(float)size; +(NSFont *)paletteFontOfSize:(float)size; +(NSFont *)systemFontOfSize:(float)size; @@ -46,17 +59,39 @@ typedef enum { +(NSFont *)userFontOfSize:(float)size; +(NSFont *)userFixedPitchFontOfSize:(float)size; ++(void)setUserFont:(NSFont *)value; ++(void)setUserFixedPitchFont:(NSFont *)value; + ++(NSFont *)fontWithName:(NSString *)name size:(float)size; ++(NSFont *)fontWithName:(NSString *)name matrix:(const float *)matrix; ++(NSFont *)fontWithDescriptor:(NSFontDescriptor *)descriptor size:(float)size; ++(NSFont *)fontWithDescriptor:(NSFontDescriptor *)descriptor size:(float)size textTransform:(NSAffineTransform *)transform; + -(float)pointSize; -(NSString *)fontName; -(const float *)matrix; +-(NSAffineTransform *)textTransform; +-(NSFontRenderingMode)renderingMode; +-(NSCharacterSet *)coveredCharacterSet; +-(NSStringEncoding)mostCompatibleStringEncoding; +-(NSString *)familyName; +-(NSString *)displayName; +-(NSFontDescriptor *)fontDescriptor; + +-(NSFont *)printerFont; +-(NSFont *)screenFont; +-(NSFont *)screenFontWithRenderingMode:(NSFontRenderingMode)mode; -(NSRect)boundingRectForFont; +-(NSRect)boundingRectForGlyph:(NSGlyph)glyph; +-(NSMultibyteGlyphPacking)glyphPacking; -(unsigned)numberOfGlyphs; +-(NSGlyph)glyphWithName:(NSString *)name; -(BOOL)glyphIsEncoded:(NSGlyph)glyph; -(NSSize)advancementForGlyph:(NSGlyph)glyph; + -(NSSize)maximumAdvancement; --(NSFont *)screenFont; -(float)underlinePosition; -(float)underlineThickness; -(float)ascender; @@ -64,17 +99,23 @@ typedef enum { -(float)leading; -(float)defaultLineHeightForFont; -(BOOL)isFixedPitch; +-(float)italicAngle; +-(float)leading; +-(float)xHeight; +-(float)capHeight; +-(void)setInContext:(NSGraphicsContext *)context; -(void)set; --(NSStringEncoding)mostCompatibleStringEncoding; --(NSMultibyteGlyphPacking)glyphPacking; - -(NSPoint)positionOfGlyph:(NSGlyph)current precededByGlyph:(NSGlyph)previous isNominal:(BOOL *)isNominalp; --(unsigned)getGlyphs:(NSGlyph *)glyphs forCharacters:(unichar *)characters length:(unsigned)length; - -(void)getAdvancements:(NSSize *)advancements forGlyphs:(const NSGlyph *)glyphs count:(unsigned)count; +-(void)getAdvancements:(NSSize *)advancements forPackedGlyphs:(const void *)packed length:(unsigned)length; +-(void)getBoundingRects:(NSRect *)rects forGlyphs:(const NSGlyph *)glyphs count:(unsigned)count; + +// private + +-(unsigned)getGlyphs:(NSGlyph *)glyphs forCharacters:(unichar *)characters length:(unsigned)length; @end diff --git a/AppKit/NSFont.m b/AppKit/NSFont.m index 4656e7f2..fd1bd292 100755 --- a/AppKit/NSFont.m +++ b/AppKit/NSFont.m @@ -20,9 +20,85 @@ FOUNDATION_EXPORT char *NSUnicodeToSymbol(const unichar *characters,unsigned len @implementation NSFont ++(float)systemFontSize { + return 12.0; +} + ++(float)smallSystemFontSize { + NSUnimplementedMethod(); + return 0; +} + ++(float)labelFontSize { + return 12.0; +} + ++(float)systemFontSizeForControlSize:(NSControlSize)size { + NSUnimplementedMethod(); + return 0; +} + ++(NSFont *)boldSystemFontOfSize:(float)size { + return [NSFont fontWithName:@"Arial Bold" size:(size==0)?[self systemFontSize]:size]; +} + ++(NSFont *)controlContentFontOfSize:(float)size { + return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; +} + ++(NSFont *)labelFontOfSize:(float)size { + return [NSFont fontWithName:@"Arial" size:(size==0)?[self labelFontSize]:size]; +} + ++(NSFont *)menuFontOfSize:(float)size { + float pointSize=0; + NSString *name=[[NSDisplay currentDisplay] menuFontNameAndSize:&pointSize]; + + return [NSFont fontWithName:name size:(size==0)?pointSize:size]; +} + ++(NSFont *)menuBarFontOfSize:(float)size { + return [self menuFontOfSize:size]; +} + ++(NSFont *)messageFontOfSize:(float)size { + return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; +} + ++(NSFont *)paletteFontOfSize:(float)size { + return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; +} + ++(NSFont *)systemFontOfSize:(float)size { + return [self messageFontOfSize:size]; +} + ++(NSFont *)titleBarFontOfSize:(float)size { + return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; +} + ++(NSFont *)toolTipsFontOfSize:(float)size { + return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; +} + ++(NSFont *)userFontOfSize:(float)size { + return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; +} + ++(NSFont *)userFixedPitchFontOfSize:(float)size { + return [NSFont fontWithName:@"Courier New" size:(size==0)?12.0:size]; +} + ++(void)setUserFont:(NSFont *)value { + NSUnimplementedMethod(); +} + ++(void)setUserFixedPitchFont:(NSFont *)value { + NSUnimplementedMethod(); +} + -(void)encodeWithCoder:(NSCoder *)coder { - [coder encodeObject:_name forKey:@"NSFont name"]; - [coder encodeFloat:_pointSize forKey:@"NSFont pointSize"]; + NSUnimplementedMethod(); } -(NSString *)_translateNibFontName:(NSString *)name { @@ -54,19 +130,14 @@ FOUNDATION_EXPORT char *NSUnicodeToSymbol(const unichar *characters,unsigned len NSNibKeyedUnarchiver *keyed=(NSNibKeyedUnarchiver *)coder; NSString *name=[self _translateNibFontName:[keyed decodeObjectForKey:@"NSName"]]; float size=[keyed decodeFloatForKey:@"NSSize"]; - int flags=[keyed decodeIntForKey:@"NSfFlags"]; // ? + // int flags=[keyed decodeIntForKey:@"NSfFlags"]; // ? [self dealloc]; return [[NSFont fontWithName:name size:size] retain]; } else { - NSString *name=[coder decodeObjectForKey:@"NSFont name"]; - float size=[coder decodeFloatForKey:@"NSFont pointSize"]; - - [self dealloc]; - - return [[NSFont fontWithName:name size:size] retain]; + [NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]]; } return nil; } @@ -95,8 +166,6 @@ FOUNDATION_EXPORT char *NSUnicodeToSymbol(const unichar *characters,unsigned len } -(void)dealloc { -//NSLog(@"dealloc'ing font %@ %f",_name,_pointSize); - [[NSDisplay currentDisplay] removeFontFromCache:self]; [_name release]; @@ -104,10 +173,6 @@ FOUNDATION_EXPORT char *NSUnicodeToSymbol(const unichar *characters,unsigned len [super dealloc]; } --copyWithZone:(NSZone *)zone { - return [self retain]; -} - +(NSFont *)fontWithName:(NSString *)name size:(float)size { NSFont *result; @@ -126,55 +191,18 @@ FOUNDATION_EXPORT char *NSUnicodeToSymbol(const unichar *characters,unsigned len return [self fontWithName:name size:matrix[0]]; } -+(NSFont *)boldSystemFontOfSize:(float)size { - return [NSFont fontWithName:@"Arial Bold" size:(size==0)?12.0:size]; ++(NSFont *)fontWithDescriptor:(NSFontDescriptor *)descriptor size:(float)size { + NSUnimplementedMethod(); + return 0; } -+(NSFont *)controlContentFontOfSize:(float)size { - return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; ++(NSFont *)fontWithDescriptor:(NSFontDescriptor *)descriptor size:(float)size textTransform:(NSAffineTransform *)transform { + NSUnimplementedMethod(); + return 0; } -+(NSFont *)labelFontOfSize:(float)size { - return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; -} - -+(NSFont *)menuFontOfSize:(float)size { - float pointSize=0; - NSString *name=[[NSDisplay currentDisplay] menuFontNameAndSize:&pointSize]; - - return [NSFont fontWithName:name size:(size==0)?pointSize:size]; -} - -+(NSFont *)messageFontOfSize:(float)size { - return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; -} - -+(NSFont *)paletteFontOfSize:(float)size { - return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; -} - -+(NSFont *)systemFontOfSize:(float)size { - return [self messageFontOfSize:size]; -} - -+(NSFont *)titleBarFontOfSize:(float)size { - return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; -} - -+(NSFont *)toolTipsFontOfSize:(float)size { - return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; -} - -+(NSFont *)userFontOfSize:(float)size { - return [NSFont fontWithName:@"Arial" size:(size==0)?12.0:size]; -} - -+(NSFont *)userFixedPitchFontOfSize:(float)size { - return [NSFont fontWithName:@"Courier New" size:(size==0)?12.0:size]; -} - --(NSString *)description { - return [NSString stringWithFormat:@"<%@ %@ %f>",isa,_name,_pointSize]; +-copyWithZone:(NSZone *)zone { + return [self retain]; } -(float)pointSize { @@ -189,14 +217,83 @@ FOUNDATION_EXPORT char *NSUnicodeToSymbol(const unichar *characters,unsigned len return _matrix; } +-(NSAffineTransform *)textTransform { + NSAffineTransform *result=[NSAffineTransform transform]; + NSAffineTransformStruct fields={ + _matrix[0],_matrix[1],_matrix[2], + _matrix[3],_matrix[4],_matrix[5], + }; + + [result setTransformStruct:fields]; + + return result; +} + +-(NSFontRenderingMode)renderingMode { + NSUnimplementedMethod(); + return 0; +} + +-(NSCharacterSet *)coveredCharacterSet { + NSUnimplementedMethod(); + return nil; +} + +-(NSStringEncoding)mostCompatibleStringEncoding { + return _encoding; +} + +-(NSString *)familyName { + NSUnimplementedMethod(); + return nil; +} + +-(NSString *)displayName { + NSUnimplementedMethod(); + return nil; +} + +-(NSFontDescriptor *)fontDescriptor { + NSUnimplementedMethod(); + return nil; +} + +-(NSFont *)printerFont { + NSUnimplementedMethod(); + return nil; +} + +-(NSFont *)screenFont { + return self; +} + +-(NSFont *)screenFontWithRenderingMode:(NSFontRenderingMode)mode { + NSUnimplementedMethod(); + return nil; +} + -(NSRect)boundingRectForFont { return [_kgFont boundingRect]; } +-(NSRect)boundingRectForGlyph:(NSGlyph)glyph { + NSUnimplementedMethod(); + return NSMakeRect(0,0,0,0); +} + +-(NSMultibyteGlyphPacking)glyphPacking { + return NSNativeShortGlyphPacking; +} + -(unsigned)numberOfGlyphs { return [_kgFont numberOfGlyphs]; } +-(NSGlyph)glyphWithName:(NSString *)name { + NSUnimplementedMethod(); + return 0; +} + -(BOOL)glyphIsEncoded:(NSGlyph)glyph { return [_kgFont glyphIsEncoded:glyph]; } @@ -209,10 +306,6 @@ FOUNDATION_EXPORT char *NSUnicodeToSymbol(const unichar *characters,unsigned len return [_kgFont maximumAdvancement]; } --(NSFont *)screenFont { - return self; -} - -(float)underlinePosition { return [_kgFont underlinePosition]; } @@ -241,28 +334,57 @@ FOUNDATION_EXPORT char *NSUnicodeToSymbol(const unichar *characters,unsigned len return [_kgFont isFixedPitch]; } --(void)set { - CGContextSetFont(NSCurrentGraphicsPort(),_kgFont); +-(float)italicAngle { + return [_kgFont italicAngle]; +} + +-(float)xHeight { + return [_kgFont xHeight]; +} + +-(float)capHeight { + return [_kgFont capHeight]; +} + +-(void)setInContext:(NSGraphicsContext *)context { + CGContextRef cgContext=[context graphicsPort]; + CGContextSetFont(cgContext,_kgFont); + +// FIX, should check the focusView in the context instead of NSView's if([[NSView focusView] isFlipped]){ CGAffineTransform flip={1,0,0,-1,0,0}; - CGContextSetTextMatrix(NSCurrentGraphicsPort(),flip); + CGContextSetTextMatrix(cgContext,flip); } } --(NSStringEncoding)mostCompatibleStringEncoding { - return _encoding; -} - --(NSMultibyteGlyphPacking)glyphPacking { - return NSCoreGraphicsGlyphPacking; +-(void)set { + [self setInContext:[NSGraphicsContext currentContext]]; } -(NSPoint)positionOfGlyph:(NSGlyph)current precededByGlyph:(NSGlyph)previous isNominal:(BOOL *)isNominalp { return [_kgFont positionOfGlyph:current precededByGlyph:previous isNominal:isNominalp]; } +-(void)getAdvancements:(NSSize *)advancements forGlyphs:(const NSGlyph *)glyphs count:(unsigned)count { + CGGlyph cgGlyphs[count]; + int i; + + for(i=0;i",isa,_name,_pointSize]; } -@end - int NSConvertGlyphsToPackedGlyphs(NSGlyph *glyphs,int length,NSMultibyteGlyphPacking packing,char *outputX) { int i,result=0; CGGlyph *output=(CGGlyph *)outputX; @@ -307,3 +421,5 @@ int NSConvertGlyphsToPackedGlyphs(NSGlyph *glyphs,int length,NSMultibyteGlyphPac return result*2; } +@end + diff --git a/AppKit/NSFontFamily.m b/AppKit/NSFontFamily.m index 592d7832..d542dbf6 100755 --- a/AppKit/NSFontFamily.m +++ b/AppKit/NSFontFamily.m @@ -9,7 +9,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI // Original - Christopher Lloyd #import #import -#import #import #import diff --git a/AppKit/NSFontManager.h b/AppKit/NSFontManager.h index f44d2379..8d98ab0b 100755 --- a/AppKit/NSFontManager.h +++ b/AppKit/NSFontManager.h @@ -8,8 +8,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import -@class NSFont, NSFontPanel; -typedef unsigned int NSFontTraitMask; +@class NSFont,NSFontDescriptor,NSFontPanel; + +typedef unsigned NSFontTraitMask; + +typedef enum { + NSNoFontChangeAction=0, + NSViaPanelFontAction=1, + NSAddTraitFontAction=2, + NSSizeUpFontAction=3, + NSSizeDownFontAction=4, + NSHeavierFontAction=5, + NSLighterFontAction=6, + NSRemoveTraitFontAction=7, +} NSFontAction; enum { NSItalicFontMask=0x00000001, @@ -23,7 +35,7 @@ enum { NSPosterFontMask=0x00000100, NSCompressedFontMask=0x00000200, NSFixedPitchFontMask=0x00000400, - NSUnitalicFontMask=0x01000000 + NSUnitalicFontMask=0x01000000, }; @interface NSFontManager : NSObject { @@ -33,35 +45,68 @@ enum { NSFont *_selectedFont; BOOL _isMultiple; + NSFontAction _currentFontAction; } +(NSFontManager *)sharedFontManager; ++(void)setFontManagerFactory:(Class)value; ++(void)setFontPanelFactory:(Class)value; + -delegate; -(SEL)action; + +-(void)setDelegate:delegate; -(void)setAction:(SEL)value; +-(NSArray *)collectionNames; +-(BOOL)addCollection:(NSString *)name options:(int)options; +-(void)addFontDescriptors:(NSArray *)descriptors toCollection:(NSString *)name; +-(BOOL)removeCollection:(NSString *)name; + +-(NSArray *)fontDescriptorsInCollection:(NSString *)name; + +-(NSArray *)availableFonts; +-(NSArray *)availableFontFamilies; +-(NSArray *)availableMembersOfFontFamily:(NSString *)name; +-(NSArray *)availableFontNamesMatchingFontDescriptor:(NSFontDescriptor *)descriptor; +-(NSArray *)availableFontNamesWithTraits:(NSFontTraitMask)traits; + +-(BOOL)fontNamed:(NSString *)name hasTraits:(NSFontTraitMask)traits; +-(NSFont *)fontWithFamily:(NSString *)family traits:(NSFontTraitMask)traits weight:(int)weight size:(float)size; +-(int)weightOfFont:(NSFont *)font; +-(NSFontTraitMask)traitsOfFont:(NSFont *)font; + +-(NSString *)localizedNameForFamily:(NSString *)family face:(NSString *)face; + -(NSFontPanel *)fontPanel:(BOOL)create; --(NSFontTraitMask)traitsOfFont:(NSFont *)font; +-(BOOL)sendAction; + +-(BOOL)isEnabled; +-(BOOL)isMultiple; +-(NSFont *)selectedFont; + +-(void)setSelectedFont:(NSFont *)font isMultiple:(BOOL)isMultiple; -(NSFont *)convertFont:(NSFont *)font; -(NSFont *)convertFont:(NSFont *)font toSize:(float)size; -(NSFont *)convertFont:(NSFont *)font toHaveTrait:(NSFontTraitMask)trait; +-(NSFont *)convertFont:(NSFont *)font toNotHaveTrait:(NSFontTraitMask)trait; --(BOOL)isMultiple; --(NSFont *)selectedFont; --(void)setSelectedFont:(NSFont *)font isMultiple:(BOOL)flag; +-(NSFont *)convertFont:(NSFont *)font toFace:(NSString *)typeface; +-(NSFont *)convertFont:(NSFont *)font toFamily:(NSString *)family; +-(NSFont *)convertWeight:(BOOL)heavierNotLighter ofFont:(NSFont *)font; --(void)setDelegate:delegate; - --(NSArray *)availableFonts; --(NSArray *)availableFontFamilies; --(NSArray *)availableMembersOfFontFamily:(NSString *)familyName; +-(NSDictionary *)convertAttributes:(NSDictionary *)attributes; -(void)addFontTrait:sender; +-(void)modifyFont:sender; +-(void)modifyFontViaPanel:sender; +-(void)removeFontTrait:sender; -(void)orderFrontFontPanel:sender; +-(void)orderFrontStylesPanel:sender; @end diff --git a/AppKit/NSFontManager.m b/AppKit/NSFontManager.m index dcf2a8b7..f09c146e 100755 --- a/AppKit/NSFontManager.m +++ b/AppKit/NSFontManager.m @@ -19,12 +19,29 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @implementation NSFontManager +static Class _fontManagerFactory; +static Class _fontPanelFactory; + +(NSFontManager *)sharedFontManager { - return NSThreadSharedInstance(@"NSFontManager"); + NSString *name=@"NSFontManager"; + + if(_fontManagerFactory!=Nil) + name=NSStringFromClass(_fontManagerFactory); + + return NSThreadSharedInstance(name); +} + ++(void)setFontManagerFactory:(Class)value { + _fontManagerFactory=value; +} + ++(void)setFontPanelFactory:(Class)value { + _fontPanelFactory=value; } -init { _panel=nil; + _action=@selector(changeFont:); _selectedFont=[[NSFont userFontOfSize:0] retain]; _isMultiple=NO; return self; @@ -38,126 +55,36 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return _action; } +-(void)setDelegate:delegate { + _delegate=delegate; +} + -(void)setAction:(SEL)value { _action=value; } --(void)setFontPanel:(NSFontPanel *)panel { - panel=[panel retain]; - [_panel release]; - _panel=panel; -} - --(NSFontPanel *)fontPanel:(BOOL)create { - if(_panel==nil && create){ - [NSBundle loadNibNamed:@"NSFontPanel" owner:self]; - } - - [_panel setPanelFont:_selectedFont isMultiple:_isMultiple]; - return _panel; -} - --(NSFontTraitMask)traitsOfFont:(NSFont *)font { - NSFontTypeface *typeface=[NSFontFamily fontTypefaceWithName:[font fontName]]; - - return [typeface traits]; -} - --(NSFont *)convertFont:(NSFont *)font { - if(_panel==nil) - return _selectedFont; - - return [_panel panelConvertFont:font]; -} - --(NSFont *)convertFont:(NSFont *)font toSize:(float)size { - if(size==[font pointSize]) - return font; - - return [NSFont fontWithName:[font fontName] size:size]; -} - --(NSFont *)convertFont:(NSFont *)font toHaveTrait:(NSFontTraitMask)addTraits { - NSFontFamily *family=[NSFontFamily fontFamilyWithTypefaceName:[font fontName]]; - NSFontTypeface *typeface=[family typefaceWithName:[font fontName]]; - NSFontTraitMask traits=[typeface traits]; - NSFontTypeface *newface; - - if(addTraits&NSItalicFontMask) - traits|=NSItalicFontMask; - if(addTraits&NSBoldFontMask) - traits|=NSBoldFontMask; - if(addTraits&NSUnboldFontMask) - traits&=~NSBoldFontMask; - if(addTraits&NSUnitalicFontMask) - traits&=~NSItalicFontMask; - - newface=[family typefaceWithTraits:traits]; - - if(newface!=nil) - return [NSFont fontWithName:[newface name] size:[font pointSize]]; - - NSLog(@"%s failed, %@ %d",SELNAME(_cmd),[font fontName],addTraits); +-(NSArray *)collectionNames { NSUnimplementedMethod(); - return font; + return nil; } --(BOOL)isMultiple { - return _isMultiple; +-(BOOL)addCollection:(NSString *)name options:(int)options { + NSUnimplementedMethod(); + return 0; } --(NSFont *)selectedFont { - return _selectedFont; +-(void)addFontDescriptors:(NSArray *)descriptors toCollection:(NSString *)name { + NSUnimplementedMethod(); } --(void)_configureMenu:(NSMenu *)menu forFont:(NSFont *)font { - NSArray *items=[menu itemArray]; - int i,count=[items count]; - - for(i=0;i1) + ps-=1; + + font=[self convertFont:font toSize:ps]; + } + break; + + case NSHeavierFontAction: + font=[self convertWeight:YES ofFont:font]; + break; + + case NSLighterFontAction: + font=[self convertWeight:NO ofFont:font]; + break; + + case NSRemoveTraitFontAction: + NSUnimplementedMethod(); +// font=[self convertFont:font toNotHaveTrait:]; + break; + } + + NSUnimplementedMethod(); +} + +-(void)modifyFontViaPanel:sender { + NSUnimplementedMethod(); +} + +-(void)removeFontTrait:sender { + NSFont *font=[self convertFont:[self selectedFont] toNotHaveTrait:[sender tag]]; + + [self setSelectedFont:font isMultiple:NO]; + [self sendAction]; } -(void)orderFrontFontPanel:sender { [[NSFontPanel sharedFontPanel] orderFront:sender]; } +-(void)orderFrontStylesPanel:sender { + NSUnimplementedMethod(); +} + @end diff --git a/AppKit/NSFontPanel.h b/AppKit/NSFontPanel.h index 34f12667..2dcc2f4d 100755 --- a/AppKit/NSFontPanel.h +++ b/AppKit/NSFontPanel.h @@ -8,7 +8,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import -@class NSTextField, NSMatrix,NSButton,NSFont; +@class NSTextField,NSMatrix,NSButton,NSFont; @interface NSFontPanel : NSPanel { NSTextField *_sampleTextField; @@ -19,17 +19,26 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI NSButton *_setButton; NSButton *_revertButton; + NSView *_accessoryView; } ++(BOOL)sharedFontPanelExists; +(NSFontPanel *)sharedFontPanel; + +-(BOOL)isEnabled; +-(NSView *)accessoryView; + +-(void)setEnabled:(BOOL)value; +-(void)setAccessoryView:(NSView *)view; + +-(BOOL)worksWhenModal; +-(void)reloadDefaultFontFamilies; + -(void)setPanelFont:(NSFont *)font isMultiple:(BOOL)isMultiple; -(NSFont *)panelConvertFont:(NSFont *)font; -(void)set:sender; -(void)revert:sender; --(void)setAccessoryView:(NSView *)view; --(NSView *)accessoryView; - @end diff --git a/AppKit/NSFontPanel.m b/AppKit/NSFontPanel.m index f83cfc69..b5729a21 100755 --- a/AppKit/NSFontPanel.m +++ b/AppKit/NSFontPanel.m @@ -15,6 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import #import #import @@ -68,10 +69,41 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [self buildFamilyMatrix]; } ++(BOOL)sharedFontPanelExists { + return ([[NSFontManager sharedFontManager] fontPanel:NO]!=nil)?YES:NO; +} + +(NSFontPanel *)sharedFontPanel { return [[NSFontManager sharedFontManager] fontPanel:YES]; } +-(BOOL)isEnabled { + return [_setButton isEnabled]; +} + +-(NSView *)accessoryView { + return _accessoryView; +} + +-(void)setEnabled:(BOOL)value { + [_setButton setEnabled:value]; +} + +-(void)setAccessoryView:(NSView *)view { + view=[view retain]; + [_accessoryView release]; + _accessoryView=view; + NSUnimplementedMethod(); +} + +-(BOOL)worksWhenModal { + return YES; +} + +-(void)reloadDefaultFontFamilies { + NSUnimplementedMethod(); +} + -(NSString *)selectedFamilyName { NSArray *names=[[NSFontManager sharedFontManager] availableFontFamilies]; int row=[_familyMatrix selectedRow]; @@ -105,6 +137,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return [NSFont fontWithName:[self selectedFontName] size:[self selectedPointSize]]; } + -(void)buildTypefaceMatrix { NSArray *traits=[self availableTraitsInFamily:[self selectedFamilyName]]; int i,count=[traits count]; @@ -147,51 +180,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [_sampleTextField setFont:[self selectedFont]]; } --(void)clickFamilyMatrix:sender { - [self buildTypefaceMatrix]; - [self buildSizeMatrix]; - [self buildSampleTextField]; -} - --(void)clickTypefaceMatrix:sender { - [self buildSizeMatrix]; - [self buildSampleTextField]; -} - --(void)clickSizeText:sender { - [self buildSampleTextField]; -} - --(void)clickSizeMatrix:sender { - NSArray *sizes=[self availablePointSizes]; - int row=[_sizeMatrix selectedRow]; - - if(row>=0){ - [_sizeTextField setStringValue:[NSString stringWithFormat:@"%g",[[sizes objectAtIndex:row] floatValue]]]; - } - - [self buildSampleTextField]; -} - --(void)set:sender { - [NSApp sendAction:@selector(changeFont:) to:nil from:[NSFontManager sharedFontManager]]; -} - --(void)revert:sender { - NSFontManager *manager=[NSFontManager sharedFontManager]; - - [self setPanelFont:[manager selectedFont] isMultiple:[manager isMultiple]]; -} - --(void)setAccessoryView:(NSView *)view { - NSUnimplementedMethod(); -} - --(NSView *)accessoryView { - NSUnimplementedMethod(); - return nil; -} - -(void)setPanelFont:(NSFont *)font isMultiple:(BOOL)isMultiple { NSFontFamily *family=[NSFontFamily fontFamilyWithTypefaceName:[font fontName]]; NSFontTypeface *typeface=[family typefaceWithName:[font fontName]]; @@ -220,5 +208,43 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return [self selectedFont]; } +-(void)set:sender { + [NSApp sendAction:@selector(changeFont:) to:nil from:[NSFontManager sharedFontManager]]; +} + +-(void)revert:sender { + NSFontManager *manager=[NSFontManager sharedFontManager]; + + [self setPanelFont:[manager selectedFont] isMultiple:[manager isMultiple]]; +} + +-(void)clickFamilyMatrix:sender { + [self buildTypefaceMatrix]; + [self buildSizeMatrix]; + [self buildSampleTextField]; +} + +-(void)clickTypefaceMatrix:sender { + [self buildSizeMatrix]; + [self buildSampleTextField]; +} + +-(void)clickSizeText:sender { + [self buildSampleTextField]; +} + +-(void)clickSizeMatrix:sender { + NSArray *sizes=[self availablePointSizes]; + int row=[_sizeMatrix selectedRow]; + + if(row>=0){ + [_sizeTextField setStringValue:[NSString stringWithFormat:@"%g",[[sizes objectAtIndex:row] floatValue]]]; + } + + [self buildSampleTextField]; +} + + + @end diff --git a/AppKit/NSFormCell.h b/AppKit/NSFormCell.h index 4bb9b32f..0a7995bf 100755 --- a/AppKit/NSFormCell.h +++ b/AppKit/NSFormCell.h @@ -13,8 +13,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @interface NSFormCell : NSActionCell { float _titleWidth; NSTextFieldCell *_titleCell; + id _placeholder; } +-initTextCell:(NSString *)value; + +-(BOOL)isOpaque; -(float)titleWidth; -(float)titleWidth:(NSSize)size; -(NSString *)title; @@ -22,6 +26,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(NSFont *)titleFont; -(NSTextAlignment)titleAlignment; -(NSWritingDirection)titleBaseWritingDirection; +-(NSString *)placeholderString; +-(NSAttributedString *)placeholderAttributedString; -(void)setTitleWidth:(float)value; -(void)setTitle:(NSString *)value; @@ -30,5 +36,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(void)setTitleFont:(NSFont *)value; -(void)setTitleAlignment:(NSTextAlignment)value; -(void)setTitleBaseWritingDirection:(NSWritingDirection)value; +-(void)setPlaceholderString:(NSString *)value; +-(void)setPlaceholderAttributedString:(NSAttributedString *)value; +-(void)setTitleWithMnemonic:(NSString *)value; @end diff --git a/AppKit/NSFormCell.m b/AppKit/NSFormCell.m index faf3232e..a8210ec9 100755 --- a/AppKit/NSFormCell.m +++ b/AppKit/NSFormCell.m @@ -46,6 +46,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return copy; } +-initTextCell:(NSString *)value { + [super initTextCell:value]; + NSUnimplementedMethod(); + return self; +} -(void)dealloc { [_titleCell release]; @@ -56,6 +61,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return NSTextCellType; } +-(BOOL)isOpaque { + if(_titleWidth==0 && [self isBezeled]) + return YES; + + return NO; +} + -(float)titleWidth { return _titleWidth; } @@ -85,6 +97,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return [_titleCell baseWritingDirection]; } +-(NSString *)placeholderString { + if([_placeholder isKindOfClass:[NSString class]]) + return _placeholder; + + return nil; +} + +-(NSAttributedString *)placeholderAttributedString { + if([_placeholder isKindOfClass:[NSAttributedString class]]) + return _placeholder; + + return nil; +} + -(void)setTitleWidth:(float)value { _titleWidth=value; } @@ -97,11 +123,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [_titleCell setAttributedStringValue:value]; } --(void)setTitleWithMnemonic:(NSString *)value { -// FIX, wrong - [_titleCell setStringValue:value]; -} - -(void)setTitleFont:(NSFont *)value { [_titleCell setFont:value]; } @@ -114,6 +135,23 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [_titleCell setBaseWritingDirection:value]; } +-(void)setPlaceholderString:(NSString *)value { + value=[value copy]; + [_placeholder release]; + _placeholder=value; +} + +-(void)setPlaceholderAttributedString:(NSAttributedString *)value { + value=[value copy]; + [_placeholder release]; + _placeholder=value; +} + +-(void)setTitleWithMnemonic:(NSString *)value { +// FIX, wrong + [_titleCell setStringValue:value]; +} + -(void)setEnabled:(BOOL)enabled { [super setEnabled:enabled]; [_titleCell setEnabled:enabled]; diff --git a/AppKit/NSGlyphGenerator.m b/AppKit/NSGlyphGenerator.m index 22371c24..d1d0efbf 100644 --- a/AppKit/NSGlyphGenerator.m +++ b/AppKit/NSGlyphGenerator.m @@ -27,8 +27,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI unsigned characterIndex=*characterIndexp; unsigned glyphIndex=*glyphIndexp; NSRange effectiveRange=NSMakeRange(0,0); - NSDictionary *attributes; - NSFont *font; + NSDictionary *attributes=nil; + NSFont *font=nil; int i; for(i=0;i +#import @class NSImageRep; +typedef enum { + NSImageCacheDefault, + NSImageCacheAlways, + NSImageCacheBySize, + NSImageCacheNever, +} NSImageCacheMode; + @interface NSImage : NSObject { NSString *_name; NSSize _size; + NSColor *_backgroundColor; NSMutableArray *_representations; + id _delegate; + BOOL _isFlipped; + BOOL _scalesWhenResized; + BOOL _matchesOnMultipleResolution; + BOOL _usesEPSOnResolutionMismatch; + BOOL _prefersColorMatch; + BOOL _isCachedSeparately; + BOOL _cacheDepthMatchesImageDepth; + BOOL _isDataRetained; + NSImageCacheMode _cacheMode; } +(NSArray *)imageFileTypes; +(NSArray *)imageUnfilteredFileTypes; ++(NSArray *)imagePasteboardTypes; ++(NSArray *)imageUnfilteredPasteboardTypes; + ++(BOOL)canInitWithPasteboard:(NSPasteboard *)pasteboard; +imageNamed:(NSString *)name; --initWithContentsOfFile:(NSString *)path; --initByReferencingFile:(NSString *)path; -initWithSize:(NSSize)size; +-initWithData:(NSData *)data; +-initWithContentsOfFile:(NSString *)path; +-initWithContentsOfURL:(NSURL *)url; + +-initWithPasteboard:(NSPasteboard *)pasteboard; +-initByReferencingFile:(NSString *)path; +-initByReferencingURL:(NSURL *)url; -(NSString *)name; -(NSSize)size; --(NSArray *)representations; +-(NSColor *)backgroundColor; +-(BOOL)isFlipped; +-(BOOL)scalesWhenResized; +-(BOOL)matchesOnMultipleResolution; +-(BOOL)usesEPSOnResolutionMismatch; +-(BOOL)prefersColorMatch; +-(NSImageCacheMode)cacheMode; -(BOOL)isCachedSeparately; +-(BOOL)cacheDepthMatchesImageDepth; +-(BOOL)isDataRetained; +-delegate; --(BOOL)setName:(NSString *)string; --(void)setSize:(NSSize)size; --(void)addRepresentation:(NSImageRep *)imageRep; --(void)setScalesWhenResized:(BOOL)flag; --(void)setCachedSeparately:(BOOL)flag; --(void)setBackgroundColor:(NSColor *)color; +-(BOOL)setName:(NSString *)value; +-(void)setSize:(NSSize)value; +-(void)setBackgroundColor:(NSColor *)value; +-(void)setFlipped:(BOOL)value; +-(void)setScalesWhenResized:(BOOL)value; +-(void)setMatchesOnMultipleResolution:(BOOL)value; +-(void)setUsesEPSOnResolutionMismatch:(BOOL)value; +-(void)setPrefersColorMatch:(BOOL)value; +-(void)setCacheMode:(NSImageCacheMode)value; +-(void)setCachedSeparately:(BOOL)value; +-(void)setCacheDepthMatchesImageDepth:(BOOL)value; +-(void)setDataRetained:(BOOL)value; +-(void)setDelegate:delegate; + +-(BOOL)isValid; + +-(NSArray *)representations; +-(void)addRepresentation:(NSImageRep *)representation; +-(void)addRepresentations:(NSArray *)array; +-(void)removeRepresentation:(NSImageRep *)representation; +-(NSImageRep *)bestRepresentationForDevice:(NSDictionary *)device; + +-(void)recache; +-(void)cancelIncrementalLoad; + +-(NSData *)TIFFRepresentation; +-(NSData *)TIFFRepresentationUsingCompression:(NSTIFFCompression)compression factor:(float)factor; -(void)lockFocus; -(void)lockFocusOnRepresentation:(NSImageRep *)representation; -(void)unlockFocus; +-(BOOL)drawRepresentation:(NSImageRep *)representation inRect:(NSRect)rect; + +-(void)compositeToPoint:(NSPoint)point fromRect:(NSRect)rect operation:(NSCompositingOperation)operation; +-(void)compositeToPoint:(NSPoint)point fromRect:(NSRect)rect operation:(NSCompositingOperation)operation fraction:(float)fraction; + -(void)compositeToPoint:(NSPoint)point operation:(NSCompositingOperation)operation; -(void)compositeToPoint:(NSPoint)point operation:(NSCompositingOperation)operation fraction:(float)fraction; --(void)compositeToPoint:(NSPoint)point fromRect:(NSRect)rect operation:(NSCompositingOperation)operation; +-(void)dissolveToPoint:(NSPoint)point fraction:(float)fraction; +-(void)dissolveToPoint:(NSPoint)point fromRect:(NSRect)rect fraction:(float)fraction; + +-(void)drawAtPoint:(NSPoint)point fromRect:(NSRect)source operation:(NSCompositingOperation)operation fraction:(float)fraction; +-(void)drawInRect:(NSRect)rect fromRect:(NSRect)source operation:(NSCompositingOperation)operation fraction:(float)fraction; @end diff --git a/AppKit/NSImage.m b/AppKit/NSImage.m index adb58f95..33a37ed3 100755 --- a/AppKit/NSImage.m +++ b/AppKit/NSImage.m @@ -11,12 +11,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import +#import #import #import @implementation NSImage +(NSArray *)imageFileTypes { + return [self imageUnfilteredFileTypes]; +} + ++(NSArray *)imageUnfilteredFileTypes { NSMutableArray *result=[NSMutableArray array]; NSArray *allClasses=[NSImageRep registeredImageRepClasses]; int i,count=[allClasses count]; @@ -27,11 +33,28 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return result; } -+(NSArray *)imageUnfilteredFileTypes { - return [NSImageRep imageUnfilteredFileTypes]; ++(NSArray *)imagePasteboardTypes { + return [self imageUnfilteredPasteboardTypes]; } -+(NSArray *)checkBundles { ++(NSArray *)imageUnfilteredPasteboardTypes{ + NSMutableArray *result=[NSMutableArray array]; + NSArray *allClasses=[NSImageRep registeredImageRepClasses]; + int i,count=[allClasses count]; + + for(i=0;i +#import +#import + +@class NSArray,NSData,NSPasteboard,NSURL; @interface NSImageRep : NSObject { NSSize _size; @@ -22,14 +25,43 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI +(NSArray *)registeredImageRepClasses; +(void)registerImageRepClass:(Class)aClass; +(void)unregisterImageRepClass:(Class)aClass; -+(Class)imageRepClassForFileType:(NSString *)type; ++(NSArray *)imageFileTypes; +(NSArray *)imageUnfilteredFileTypes; ++(NSArray *)imagePasteboardTypes; ++(NSArray *)imageUnfilteredPasteboardTypes; + ++(BOOL)canInitWithData:(NSData *)data; ++(BOOL)canInitWithPasteboard:(NSPasteboard *)pasteboard; + ++(Class)imageRepClassForData:(NSData *)data; ++(Class)imageRepClassForFileType:(NSString *)type; ++(Class)imageRepClassForPasteboardType:(NSString *)type; +(NSArray *)imageRepsWithContentsOfFile:(NSString *)path; ++(NSArray *)imageRepsWithContentsOfURL:(NSURL *)url; ++(NSArray *)imageRepsWithPasteboard:(NSPasteboard *)pasteboard; ++imageRepWithContentsOfFile:(NSString *)path; ++imageRepWithContentsOfURL:(NSURL *)url; ++imageRepWithPasteboard:(NSPasteboard *)pasteboard; -(NSSize)size; +-(int)pixelsWide; +-(int)pixelsHigh; +-(BOOL)isOpaque; +-(BOOL)hasAlpha; +-(NSString *)colorSpaceName; +-(int)bitsPerSample; +-(void)setSize:(NSSize)value; +-(void)setPixelsWide:(int)value; +-(void)setPixelsHigh:(int)value; +-(void)setOpaque:(BOOL)value; +-(void)setAlpha:(BOOL)value; +-(void)setColorSpaceName:(NSString *)value; +-(void)setBitsPerSample:(int)value; + +-(BOOL)draw; -(BOOL)drawAtPoint:(NSPoint)point; -(BOOL)drawInRect:(NSRect)rect; diff --git a/AppKit/NSImageRep.m b/AppKit/NSImageRep.m index 84f7437b..5332f438 100755 --- a/AppKit/NSImageRep.m +++ b/AppKit/NSImageRep.m @@ -10,6 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import +#import @implementation NSImageRep @@ -35,6 +37,63 @@ static NSMutableArray *_registeredClasses=nil; [_registeredClasses removeObjectIdenticalTo:class]; } ++(NSArray *)imageFileTypes { + NSMutableSet *result=[NSMutableSet set]; + int i,count=[_registeredClasses count]; + + for(i=0;i=0){ + Class check=[_registeredClasses objectAtIndex:count]; + + if([check canInitWithData:data]) + return check; + } + + return nil; +} + +(Class)imageRepClassForFileType:(NSString *)type { int count=[_registeredClasses count]; @@ -49,7 +108,17 @@ static NSMutableArray *_registeredClasses=nil; return nil; } -+(NSArray *)imageUnfilteredFileTypes { ++(Class)imageRepClassForPasteboardType:(NSString *)type { + int count=[_registeredClasses count]; + + while(--count>=0){ + Class checkClass=[_registeredClasses objectAtIndex:count]; + NSArray *types=[checkClass imageUnfilteredPasteboardTypes]; + + if([types containsObject:type]) + return checkClass; + } + return nil; } @@ -60,19 +129,118 @@ static NSMutableArray *_registeredClasses=nil; return [class imageRepsWithContentsOfFile:path]; } ++(NSArray *)imageRepsWithContentsOfURL:(NSURL *)url { + NSUnimplementedMethod(); + return nil; +} + ++(NSArray *)imageRepsWithPasteboard:(NSPasteboard *)pasteboard { + NSUnimplementedMethod(); + return nil; +} + ++imageRepWithContentsOfFile:(NSString *)path { + NSUnimplementedMethod(); + return nil; +} + ++imageRepWithContentsOfURL:(NSURL *)url { + NSUnimplementedMethod(); + return nil; +} + ++imageRepWithPasteboard:(NSPasteboard *)pasteboard { + NSUnimplementedMethod(); + return nil; +} + -(NSSize)size { return _size; } +-(int)pixelsWide { + return _pixelsWide; +} + +-(int)pixelsHigh { + return _pixelsHigh; +} + +-(BOOL)isOpaque { + return _isOpaque; +} + +-(BOOL)hasAlpha { + return _hasAlpha; +} + +-(NSString *)colorSpaceName { + return _colorSpaceName; +} + +-(int)bitsPerSample { + return _bitsPerSample; +} + +-(void)setSize:(NSSize)value { + _size=value; +} + +-(void)setPixelsWide:(int)value { + _pixelsWide=value; +} + +-(void)setPixelsHigh:(int)value { + _pixelsHigh=value; +} + +-(void)setOpaque:(BOOL)value { + _isOpaque=value; +} + +-(void)setAlpha:(BOOL)value { + _hasAlpha=value; +} + +-(void)setColorSpaceName:(NSString *)value { + value=[value copy]; + [_colorSpaceName release]; + _colorSpaceName=value; +} + +-(void)setBitsPerSample:(int)value { + _bitsPerSample=value; +} + +-(BOOL)draw { +// do nothing + return YES; +} + -(BOOL)drawAtPoint:(NSPoint)point { - NSSize size=[self size]; + CGContextRef context=NSCurrentGraphicsPort(); + BOOL result; - return [self drawInRect:NSMakeRect(point.x,point.y,size.width,size.height)]; + CGContextSaveGState(context); + CGContextTranslateCTM(context,point.x,point.y); + result=[self draw]; + CGContextRestoreGState(context); + + return result; } -(BOOL)drawInRect:(NSRect)rect { - NSInvalidAbstractInvocation(); - return NO; + CGContextRef context=NSCurrentGraphicsPort(); + NSSize size=[self size]; + BOOL result; + + CGContextSaveGState(context); + CGContextTranslateCTM(context,rect.origin.x,rect.origin.y); + CGContextScaleCTM(context,rect.size.width/size.width,rect.size.height/size.height); + result=[self draw]; + CGContextRestoreGState(context); + + return result; } -(NSString *)description { diff --git a/AppKit/NSKeyValueBinding/NSBinder.m b/AppKit/NSKeyValueBinding/NSBinder.m index cf12b358..69a61c67 100644 --- a/AppKit/NSKeyValueBinding/NSBinder.m +++ b/AppKit/NSKeyValueBinding/NSBinder.m @@ -191,7 +191,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI id binders=[[source _allUsedBinders] objectEnumerator]; id binder; id ret=[NSMutableArray array]; - while(binder=[binders nextObject]) + while((binder=[binders nextObject])!=nil) { if([[binder binding] hasPrefix:baseName]) [ret addObject:binder]; diff --git a/AppKit/NSMatrix.m b/AppKit/NSMatrix.m index 6c78c87a..6b3912de 100755 --- a/AppKit/NSMatrix.m +++ b/AppKit/NSMatrix.m @@ -312,6 +312,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI } -(NSString *)toolTipForCell:(NSCell *)cell { + NSUnimplementedMethod(); + return nil; } -keyCell { diff --git a/AppKit/NSMenu.subproj/NSMenu.h b/AppKit/NSMenu.subproj/NSMenu.h index 828f29f4..f17d23ea 100755 --- a/AppKit/NSMenu.subproj/NSMenu.h +++ b/AppKit/NSMenu.subproj/NSMenu.h @@ -35,7 +35,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(int)indexOfItem:(NSMenuItem *)item; -(int)indexOfItemWithTag:(int)tag; -(int)indexOfItemWithTitle:(NSString *)title; --(int)indexOfItemWithRepresentedObject:(id)object; +-(int)indexOfItemWithRepresentedObject:object; -(int)indexOfItemWithTarget:(id)target andAction:(SEL)action; -(int)indexOfItemWithSubmenu:(NSMenu *)menu; diff --git a/AppKit/NSMenu.subproj/NSMenu.m b/AppKit/NSMenu.subproj/NSMenu.m index a82010f3..2d4ba205 100755 --- a/AppKit/NSMenu.subproj/NSMenu.m +++ b/AppKit/NSMenu.subproj/NSMenu.m @@ -57,9 +57,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI _autoenablesItems=![keyed decodeBoolForKey:@"NSNoAutoenable"]; } else { - _title=[[coder decodeObjectForKey:@"NSMenu title"] retain]; - _itemArray=[[coder decodeObjectForKey:@"NSMenu itemArray"] retain]; - _autoenablesItems=[coder decodeBoolForKey:@"NSMenu autoenablesItems"]; + [NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]]; } return self; } @@ -161,9 +159,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return -1; } --(int)indexOfItemWithRepresentedObject:(id)object { - NSUnimplementedMethod(); // hmmm... - return -1; +-(int)indexOfItemWithRepresentedObject:object { + int i,count=[_itemArray count]; + + for(i=0;i #import #import +#import @implementation NSOpenPanel @@ -37,6 +38,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return _filenames; } +-(NSArray *)URLs { + NSArray *paths=[self filenames]; + NSMutableArray *result=[NSMutableArray arrayWithCapacity:[paths count]]; + int i,count=[paths count]; + + for(i=0;i #import #import +#import @implementation NSResponder @@ -21,7 +22,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -initWithCoder:(NSCoder *)coder { if([coder isKindOfClass:[NSNibKeyedUnarchiver class]]){ - NSNibKeyedUnarchiver *keyed=(NSNibKeyedUnarchiver *)coder; + // NSNibKeyedUnarchiver *keyed=(NSNibKeyedUnarchiver *)coder; //; _nextResponder=[keyed decodeObjectForKey:@"NSNextResponder"]; } diff --git a/AppKit/NSScroller.m b/AppKit/NSScroller.m index eb8ec5a2..efbb1da6 100755 --- a/AppKit/NSScroller.m +++ b/AppKit/NSScroller.m @@ -32,8 +32,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [super initWithCoder:coder]; if([coder isKindOfClass:[NSNibKeyedUnarchiver class]]){ - NSNibKeyedUnarchiver *keyed=(NSNibKeyedUnarchiver *)coder; - _isVertical=(_bounds.size.width<_bounds.size.height)?YES:NO; _floatValue=0; _knobProportion=0; diff --git a/AppKit/NSSegmentedControl/NSSegmentedCell.m b/AppKit/NSSegmentedControl/NSSegmentedCell.m index a8086e55..120b4cb1 100644 --- a/AppKit/NSSegmentedControl/NSSegmentedCell.m +++ b/AppKit/NSSegmentedControl/NSSegmentedCell.m @@ -102,8 +102,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI int i,count=[_segments count]; for(i=0;i horizontal steppers? -(void)drawWithFrame:(NSRect)frame inView:(NSView *)controlView { BOOL drawDottedRect = NO; - NSRect rect; _controlView=controlView; [[_controlView graphicsStyle] drawStepperButtonInRect:[self _upArrowFrameForFrame:frame] clipRect:frame enabled:[self isEnabled] highlighted:_isUpHighlighted upNotDown:YES]; diff --git a/AppKit/NSStringDrawing.h b/AppKit/NSStringDrawing.h index bcafefc6..d4a2a780 100755 --- a/AppKit/NSStringDrawing.h +++ b/AppKit/NSStringDrawing.h @@ -8,6 +8,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import +typedef unsigned NSStringDrawingOptions; + @interface NSString(NSStringDrawing) -(void)drawAtPoint:(NSPoint)point withAttributes:(NSDictionary *)attributes; -(void)drawInRect:(NSRect)rect withAttributes:(NSDictionary *)attributes; @@ -18,6 +20,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @interface NSAttributedString(NSStringDrawing) -(void)drawAtPoint:(NSPoint)point; -(void)drawInRect:(NSRect)rect; +-(void)drawWithRect:(NSRect)rect options:(NSStringDrawingOptions)options; -(NSSize)size; @end diff --git a/AppKit/NSStringDrawing.m b/AppKit/NSStringDrawing.m index 33084caf..f2dc5802 100755 --- a/AppKit/NSStringDrawing.m +++ b/AppKit/NSStringDrawing.m @@ -9,6 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI // Original - Christopher Lloyd #import #import +#import @implementation NSString(NSStringDrawing) @@ -40,4 +41,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return [NSCurrentStringDrawer() sizeOfAttributedString:self]; } +-(void)drawWithRect:(NSRect)rect options:(NSStringDrawingOptions)options { + NSUnimplementedMethod(); +} + @end diff --git a/AppKit/NSTabView.m b/AppKit/NSTabView.m index 1f8a426a..87da65a3 100755 --- a/AppKit/NSTabView.m +++ b/AppKit/NSTabView.m @@ -350,7 +350,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI case NSBottomTabsBezelBorder: case NSRightTabsBezelBorder: { int i,count=[_items count]; - NSRect erase; for(i=0;i)info { BOOL result; int proposedRow = [self _getDraggedRow:info]; - if(result = [_dataSource tableView:self validateDrop:info proposedRow:proposedRow -proposedDropOperation:NSTableViewDropAbove]) + if((result = [_dataSource tableView:self validateDrop:info proposedRow:proposedRow +proposedDropOperation:NSTableViewDropAbove])) _draggingRow = proposedRow; else _draggingRow = -1; diff --git a/AppKit/NSText.m b/AppKit/NSText.m index ba30b549..93d2d798 100755 --- a/AppKit/NSText.m +++ b/AppKit/NSText.m @@ -21,17 +21,17 @@ NSString *NSTextDidChangeNotification=@"NSTextDidChangeNotification"; } -(NSString *)string { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); return nil; } -(NSData *)RTFFromRange:(NSRange)range { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); return nil; } -(NSData *)RTFDFromRange:(NSRange)range { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); return nil; } @@ -119,20 +119,20 @@ NSString *NSTextDidChangeNotification=@"NSTextDidChangeNotification"; } -(void)replaceCharactersInRange:(NSRange)range withString:(NSString *)string { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); } -(BOOL)readRTFDFromFile:(NSString *)path { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); return NO; } -(void)replaceCharactersInRange:(NSRange)range withRTF:(NSData *)rtf { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); } -(void)replaceCharactersInRange:(NSRange)range withRTFD:(NSData *)rtfd { - NSUnimplementedMethod(); + NSInvalidAbstractInvocation(); } -(void)setEditable:(BOOL)flag { diff --git a/AppKit/NSTextFieldCell.m b/AppKit/NSTextFieldCell.m index 0a3b9fec..9072d14d 100755 --- a/AppKit/NSTextFieldCell.m +++ b/AppKit/NSTextFieldCell.m @@ -23,10 +23,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @implementation NSTextFieldCell -(void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - [coder encodeBool:_drawsBackground forKey:@"NSTextFieldCell drawsBackground"]; - [coder encodeObject:_backgroundColor forKey:@"NSTextFieldCell backgroundColor"]; - [coder encodeObject:_textColor forKey:@"NSTextFieldCell textColor"]; + NSUnimplementedMethod(); } -initWithCoder:(NSCoder *)coder { @@ -40,9 +37,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI _textColor=[[keyed decodeObjectForKey:@"NSTextColor"] retain]; } else { - _drawsBackground=[coder decodeBoolForKey:@"NSTextFieldCell drawsBackground"]; - _backgroundColor=[[coder decodeObjectForKey:@"NSTextFieldCell backgroundColor"] retain]; - _textColor=[[coder decodeObjectForKey:@"NSTextFieldCell textColor"] retain]; + [NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]]; } return self; diff --git a/AppKit/NSTextTable/NSTextBlock.m b/AppKit/NSTextTable/NSTextBlock.m index fb523af1..2471d748 100644 --- a/AppKit/NSTextTable/NSTextBlock.m +++ b/AppKit/NSTextTable/NSTextBlock.m @@ -43,6 +43,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI } -(NSTextBlockValueType)valueTypeForDimension:(NSTextBlockDimension)dimension { + NSUnimplementedMethod(); + return 0; } -(float)widthForLayer:(NSTextBlockLayer)layer edge:(NSRectEdge)edge { diff --git a/AppKit/NSTextView.subproj/NSLayoutManager.h b/AppKit/NSTextView.subproj/NSLayoutManager.h index 39292d43..f0c7d15b 100755 --- a/AppKit/NSTextView.subproj/NSLayoutManager.h +++ b/AppKit/NSTextView.subproj/NSLayoutManager.h @@ -39,7 +39,7 @@ typedef enum { NSTextContainer *_extraLineFragmentTextContainer; unsigned _rectCacheCapacity,_rectCacheCount; - NSRectArray _rectCache; + NSRect * _rectCache; } -init; @@ -116,11 +116,11 @@ typedef enum { -(NSRange)rangeOfNominallySpacedGlyphsContainingIndex:(unsigned)glyphIndex; -(NSRect)boundingRectForGlyphRange:(NSRange)glyphRange inTextContainer:(NSTextContainer *)container; --(NSRectArray)rectArrayForGlyphRange:(NSRange)glyphRange withinSelectedGlyphRange:(NSRange)selectedGlyphRange inTextContainer:(NSTextContainer *)container rectCount:(unsigned *)rectCount; +-(NSRect *)rectArrayForGlyphRange:(NSRange)glyphRange withinSelectedGlyphRange:(NSRange)selectedGlyphRange inTextContainer:(NSTextContainer *)container rectCount:(unsigned *)rectCount; -(unsigned)characterIndexForGlyphAtIndex:(unsigned)glyphIndex; -(NSRange)characterRangeForGlyphRange:(NSRange)glyphRange actualGlyphRange:(NSRange *)actualGlyphRange; --(NSRectArray)rectArrayForCharacterRange:(NSRange)characterRange withinSelectedCharacterRange:(NSRange)selectedCharRange inTextContainer:(NSTextContainer *)container rectCount:(unsigned *)rectCount; +-(NSRect *)rectArrayForCharacterRange:(NSRange)characterRange withinSelectedCharacterRange:(NSRange)selectedCharRange inTextContainer:(NSTextContainer *)container rectCount:(unsigned *)rectCount; -(unsigned)firstUnlaidGlyphIndex; -(unsigned)firstUnlaidCharacterIndex; diff --git a/AppKit/NSTextView.subproj/NSLayoutManager.m b/AppKit/NSTextView.subproj/NSLayoutManager.m index 2227c7a6..2c7ef8e3 100755 --- a/AppKit/NSTextView.subproj/NSLayoutManager.m +++ b/AppKit/NSTextView.subproj/NSLayoutManager.m @@ -15,6 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import #import #import @@ -133,7 +134,13 @@ static inline NSGlyphFragment *fragmentAtGlyphIndex(NSLayoutManager *self,unsign } -(BOOL)layoutManagerOwnsFirstResponderInWindow:(NSWindow *)window { - NSUnimplementedMethod(); + NSResponder *first=[window firstResponder]; + int i,count=[_textContainers count]; + + for(i=0;i_rectCache[self->_rectCacheCount++]=rect; } --(NSRectArray)rectArrayForGlyphRange:(NSRange)glyphRange withinSelectedGlyphRange:(NSRange)selGlyphRange inTextContainer:(NSTextContainer *)container rectCount:(unsigned *)rectCount { +-(NSRect *)rectArrayForGlyphRange:(NSRange)glyphRange withinSelectedGlyphRange:(NSRange)selGlyphRange inTextContainer:(NSTextContainer *)container rectCount:(unsigned *)rectCount { NSRange remainder=(selGlyphRange.location==NSNotFound)?glyphRange:selGlyphRange; _rectCacheCount=0; @@ -670,7 +677,7 @@ static inline void _appendRectToCache(NSLayoutManager *self,NSRect rect){ return glyphRange; } --(NSRectArray)rectArrayForCharacterRange:(NSRange)characterRange withinSelectedCharacterRange:(NSRange)selectedCharRange inTextContainer:(NSTextContainer *)container rectCount:(unsigned *)rectCount { +-(NSRect *)rectArrayForCharacterRange:(NSRange)characterRange withinSelectedCharacterRange:(NSRange)selectedCharRange inTextContainer:(NSTextContainer *)container rectCount:(unsigned *)rectCount { NSRange glyphRange=[self glyphRangeForCharacterRange:characterRange actualCharacterRange:NULL]; NSRange glyphSelRange=[self glyphRangeForCharacterRange:selectedCharRange actualCharacterRange:NULL]; @@ -703,7 +710,7 @@ static inline void _appendRectToCache(NSLayoutManager *self,NSRect rect){ NSTextView *textView=[self textViewForBeginningOfSelection]; NSColor *selectedColor=[[textView selectedTextAttributes] objectForKey:NSBackgroundColorAttributeName]; NSRange range; - NSRectArray rectArray; + NSRect * rectArray; unsigned i,rectCount=0; if(textView==nil) @@ -746,7 +753,7 @@ static inline void _appendRectToCache(NSLayoutManager *self,NSRect rect){ if(color!=nil){ unsigned i,rectCount; - NSRectArray rects=[self rectArrayForCharacterRange:effectiveRange withinSelectedCharacterRange:NSMakeRange(NSNotFound,0) inTextContainer:container rectCount:&rectCount]; + NSRect * rects=[self rectArrayForCharacterRange:effectiveRange withinSelectedCharacterRange:NSMakeRange(NSNotFound,0) inTextContainer:container rectCount:&rectCount]; [color set]; diff --git a/AppKit/NSTextView.subproj/NSTextView.m b/AppKit/NSTextView.subproj/NSTextView.m index a72a6503..f97a33e8 100755 --- a/AppKit/NSTextView.subproj/NSTextView.m +++ b/AppKit/NSTextView.subproj/NSTextView.m @@ -509,7 +509,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI result=[[self layoutManager] extraLineFragmentRect]; else { unsigned rectCount=0; - NSRectArray rectArray=[[self layoutManager] rectArrayForCharacterRange:range withinSelectedCharacterRange:range inTextContainer:[self textContainer] rectCount:&rectCount]; + NSRect * rectArray=[[self layoutManager] rectArrayForCharacterRange:range withinSelectedCharacterRange:range inTextContainer:[self textContainer] rectCount:&rectCount]; if(rectCount==0) NSLog(@"rectCount==0!"); @@ -1941,7 +1941,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI NSRange range = [self selectedRange]; [[self textStorage] addAttribute:NSUnderlineStyleAttributeName - value:[NSNumber numberWithInt:NSSingleUnderlineStyle] + value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:range]; [self setSelectedRange:range]; diff --git a/AppKit/NSTextView.subproj/NSTypesetter.m b/AppKit/NSTextView.subproj/NSTypesetter.m index 17b8e55f..2a09cfec 100644 --- a/AppKit/NSTextView.subproj/NSTypesetter.m +++ b/AppKit/NSTextView.subproj/NSTypesetter.m @@ -141,10 +141,12 @@ -(BOOL)shouldBreakLineByHyphenatingBeforeCharacterAtIndex:(unsigned)characterIndex { NSInvalidAbstractInvocation(); + return NO; } -(BOOL)shouldBreakLineByWordBeforeCharacterAtIndex:(unsigned)characterIndex { NSInvalidAbstractInvocation(); + return NO; } -(float)hyphenationFactorForGlyphAtIndex:(unsigned)glyphIndex { @@ -157,6 +159,7 @@ -(NSRect)boundingBoxForControlGlyphAtIndex:(unsigned)glyphIndex forTextContainer:(NSTextContainer *)textContainer proposedLineFragment:(NSRect)proposedRect glyphPosition:(NSPoint)glyphPosition characterIndex:(unsigned)characterIndex { NSInvalidAbstractInvocation(); + return NSMakeRect(0,0,0,0); } -(NSAttributedString *)attributedString { @@ -165,6 +168,7 @@ -(NSDictionary *)attributesForExtraLineFragment { NSInvalidAbstractInvocation(); + return nil; } -(NSLayoutManager *)layoutManager { @@ -185,18 +189,22 @@ -(NSRange)paragraphCharacterRange { NSInvalidAbstractInvocation(); + return NSMakeRange(0,0); } -(NSRange)paragraphGlyphRange { NSInvalidAbstractInvocation(); + return NSMakeRange(0,0); } -(NSRange)paragraphSeparatorCharacterRange { NSInvalidAbstractInvocation(); + return NSMakeRange(0,0); } -(NSRange)paragraphSeparatorGlyphRange { NSInvalidAbstractInvocation(); + return NSMakeRange(0,0); } -(NSTypesetterControlCharacterAction)actionForControlCharacterAtIndex:(unsigned)characterIndex { @@ -253,6 +261,7 @@ -(float)baselineOffsetInLayoutManager:(NSLayoutManager *)layoutManager glyphIndex:(unsigned)glyphIndex { NSInvalidAbstractInvocation(); + return 0; } -(NSTextTab *)textTabForGlyphLocation:(float)location writingDirection:(NSWritingDirection)direction maxLocation:(float)maxLocation { @@ -305,6 +314,7 @@ NSInvalidAbstractInvocation(); [self endParagraph]; + return 0; } -(void)layoutGlyphsInLayoutManager:(NSLayoutManager *)layoutManager startingAtGlyphIndex:(unsigned)startGlyphIndex maxNumberOfLineFragments:(unsigned)maxNumLines nextGlyphIndex:(unsigned *)nextGlyph { diff --git a/AppKit/NSToolbar.subproj/NSToolbarItem.h b/AppKit/NSToolbar.subproj/NSToolbarItem.h index d4986e5d..aa234cc1 100755 --- a/AppKit/NSToolbar.subproj/NSToolbarItem.h +++ b/AppKit/NSToolbar.subproj/NSToolbarItem.h @@ -65,7 +65,7 @@ APPKIT_EXPORT NSString *NSToolbarSpaceItemIdentifier; -(BOOL)isEnabled; -(NSString *)toolTip; --(void)setImage:(NSImage*)image; +-(void)setImage:(NSImage *)image; -(void)setTarget:target; -(void)setAction:(SEL)action; -(void)setTag:(int)tag; diff --git a/AppKit/NSToolbar.subproj/NSToolbarItem.m b/AppKit/NSToolbar.subproj/NSToolbarItem.m index 30994aa3..4c193df7 100755 --- a/AppKit/NSToolbar.subproj/NSToolbarItem.m +++ b/AppKit/NSToolbar.subproj/NSToolbarItem.m @@ -243,7 +243,7 @@ extern NSSize _NSToolbarIconSizeSmall; return nil; } -- (void)setImage:(NSImage*)image +- (void)setImage:(NSImage *)image { [_image release]; _image = [image retain]; diff --git a/AppKit/NSUserInterfaceValidation.h b/AppKit/NSUserInterfaceValidation.h new file mode 100644 index 00000000..9f27b262 --- /dev/null +++ b/AppKit/NSUserInterfaceValidation.h @@ -0,0 +1,6 @@ +#import + +@protocol NSValidatedUserInterfaceItem +-(int)tag; +-(SEL)action; +@end diff --git a/AppKit/NSView.m b/AppKit/NSView.m index 0e2c6ab9..b82be557 100755 --- a/AppKit/NSView.m +++ b/AppKit/NSView.m @@ -45,11 +45,7 @@ NSString *NSViewFocusDidChangeNotification=@"NSViewFocusDidChangeNotification"; } -(void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - [coder encodeRect:_frame forKey:@"NSView frame"]; - [coder encodeInt:_autoresizingMask forKey:@"NSView autoresizingMask"]; - [coder encodeInt:_tag forKey:@"NSView tag"]; - [coder encodeObject:_subviews forKey:@"NSView subviews"]; + NSUnimplementedMethod(); } -initWithCoder:(NSCoder *)coder { @@ -83,22 +79,7 @@ NSString *NSViewFocusDidChangeNotification=@"NSViewFocusDidChangeNotification"; _defaultToolTipTag=-1; } else { - _frame=[coder decodeRectForKey:@"NSView frame"]; - _bounds.origin=NSMakePoint(0,0); - _bounds.size=_frame.size; - _window=nil; - _superview=nil; - _subviews=[NSMutableArray new]; - _postsNotificationOnFrameChange=YES; - _postsNotificationOnBoundsChange=YES; - _autoresizesSubviews=YES; - - _autoresizingMask=[coder decodeIntForKey:@"NSView autoresizingMask"]; - _tag=[coder decodeIntForKey:@"NSView tag"]; - [_subviews addObjectsFromArray:[coder decodeObjectForKey:@"NSView subviews"]]; - [_subviews makeObjectsPerformSelector:@selector(_setSuperview:) withObject:self]; - _invalidRect=_bounds; - _defaultToolTipTag=-1; + [NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]]; } return self; diff --git a/AppKit/NSWindow.h b/AppKit/NSWindow.h index 378d1e3d..05873c35 100755 --- a/AppKit/NSWindow.h +++ b/AppKit/NSWindow.h @@ -10,22 +10,33 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import -@class NSView, NSEvent, NSColor, NSCursor, NSImage, NSScreen, NSText, NSTextView, CGWindow, NSPasteboard, NSSheetContext, NSUndoManager, NSButtonCell, NSDrawer, NSToolbar, NSWindowAnimationContext, NSTrackingRect, NSWindowBackgroundView,NSWindowController; +@class NSView, NSEvent, NSColor, NSCursor, NSImage, NSScreen, NSText, NSTextView, CGWindow, NSPasteboard, NSSheetContext, NSUndoManager, NSButton,NSButtonCell, NSDrawer, NSToolbar, NSWindowAnimationContext, NSTrackingRect, NSWindowBackgroundView,NSWindowController; enum { NSBorderlessWindowMask=0x00, NSTitledWindowMask=0x01, NSClosableWindowMask=0x02, NSMiniaturizableWindowMask=0x04, - NSResizableWindowMask=0x08 + NSResizableWindowMask=0x08, + NSTexturedBackgroundWindowMask=0x100, }; typedef enum { NSBackingStoreRetained=0, NSBackingStoreNonretained=1, - NSBackingStoreBuffered=2 + NSBackingStoreBuffered=2, } NSBackingStoreType; +typedef enum { + NSWindowCloseButton, + NSWindowMiniaturizeButton, + NSWindowZoomButton, + NSWindowToolbarButton, + NSWindowDocumentIconButton, +} NSWindowButton; + +typedef int NSSelectionDirection; + APPKIT_EXPORT NSString *NSWindowDidBecomeKeyNotification; APPKIT_EXPORT NSString *NSWindowDidResignKeyNotification; APPKIT_EXPORT NSString *NSWindowDidBecomeMainNotification; @@ -39,19 +50,21 @@ APPKIT_EXPORT NSString *NSWindowDidResizeNotification; APPKIT_EXPORT NSString *NSWindowDidUpdateNotification; APPKIT_EXPORT NSString *NSWindowWillCloseNotification; -// Hmm. I needed something like this, I think it kind of makes sense, it's not in AppKit 10.3 though. -APPKIT_EXPORT NSString *NSWindowWillAnimateNotification; -APPKIT_EXPORT NSString *NSWindowAnimatingNotification; -APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; - @interface NSWindow : NSResponder { NSRect _frame; unsigned _styleMask; NSBackingStoreType _backingType; - + int _level; + NSSize _minSize; NSSize _maxSize; - + NSSize _contentMinSize; + NSSize _contentMaxSize; + + NSWindow *_parentWindow; + NSMutableArray *_childWindows; + + NSString *_representedFilename; NSString *_title; NSString *_miniwindowTitle; NSImage *_miniwindowImage; @@ -80,6 +93,7 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; int _cursorRectsDisabled; int _flushDisabled; + BOOL _isOpaque; BOOL _isVisible; BOOL _isKeyWindow; BOOL _isMainWindow; @@ -90,6 +104,7 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; BOOL _excludedFromWindowsMenu; BOOL _isDeferred; BOOL _dynamicDepthLimit; + BOOL _canStoreColor; BOOL _isOneShot; BOOL _useOptimizedDrawing; BOOL _releaseWhenClosed; @@ -98,13 +113,28 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; BOOL _isActive; BOOL _viewsNeedDisplay; BOOL _flushNeeded; + BOOL _isFlushWindowDisabled; BOOL _isAutodisplay; + BOOL _canHide; + BOOL _displaysWhenScreenProfileChanges; + BOOL _alphaValue; + BOOL _hasShadow; + BOOL _showsResizeIndicator; + BOOL _showsToolbarButton; + BOOL _ignoresMouseEvents; + BOOL _isMovableByWindowBackground; + BOOL _allowsToolTipsWhenApplicationIsInactive; BOOL _defaultButtonCellKeyEquivalentDisabled; + BOOL _autorecalculatesKeyViewLoop; + BOOL _preservesContentDuringLiveResize; BOOL _useAspectRatio; BOOL _aspectRatioIsContent; NSSize _aspectRatio; + NSSize _contentAspectRatio; + NSSize _resizeIncrements; + NSSize _contentResizeIncrements; NSString *_autosaveFrameName; @@ -121,27 +151,41 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; } +(NSWindowDepth)defaultDepthLimit; + +(NSRect)frameRectForContentRect:(NSRect)contentRect styleMask:(unsigned)styleMask; +(NSRect)contentRectForFrameRect:(NSRect)frameRect styleMask:(unsigned)styleMask; --initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(unsigned)backing defer:(BOOL)defer; --initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(unsigned)backing defer:(BOOL)defer screen:(NSScreen *)screen; ++(float)minFrameWidthWithTitle:(NSString *)title styleMask:(unsigned)styleMask; + ++(void)removeFrameUsingName:(NSString *)name; + ++(NSButton *)standardWindowButton:(NSWindowButton)button forStyleMask:(unsigned)styleMask; + +-initWithContentRect:(NSRect)contentRect styleMask:(unsigned)styleMask backing:(unsigned)backing defer:(BOOL)defer; +-initWithContentRect:(NSRect)contentRect styleMask:(unsigned)styleMask backing:(unsigned)backing defer:(BOOL)defer screen:(NSScreen *)screen; -(NSGraphicsContext *)graphicsContext; +-(NSDictionary *)deviceDescription; --(NSString *)title; -contentView; - -delegate; --(NSRect)frame; --(NSSize)minSize; --(NSSize)maxSize; +-(NSString *)title; +-(NSString *)representedFilename; +-(int)level; +-(NSRect)frame; -(unsigned)styleMask; -(NSBackingStoreType)backingType; --(BOOL)hasDynamicDepthLimit; + +-(NSSize)minSize; +-(NSSize)maxSize; +-(NSSize)contentMinSize; +-(NSSize)contentMaxSize; + -(BOOL)isOneShot; +-(BOOL)isOpaque; +-(BOOL)hasDynamicDepthLimit; -(BOOL)isReleasedWhenClosed; -(BOOL)hidesOnDeactivate; -(BOOL)worksWhenModal; @@ -149,19 +193,95 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; -(BOOL)acceptsMouseMovedEvents; -(BOOL)isExcludedFromWindowsMenu; -(BOOL)isAutodisplay; +-(BOOL)isFlushWindowDisabled; -(NSString *)frameAutosaveName; - --(NSResponder *)firstResponder; --(NSView *)initialFirstResponder; - +-(BOOL)hasShadow; +-(BOOL)ignoresMouseEvents; +-(NSSize)aspectRatio; +-(NSSize)contentAspectRatio; +-(BOOL)autorecalculatesKeyViewLoop; +-(BOOL)canHide; +-(BOOL)canStoreColor; +-(BOOL)showsResizeIndicator; +-(BOOL)showsToolbarButton; +-(BOOL)displaysWhenScreenProfileChanges; +-(BOOL)isMovableByWindowBackground; +-(BOOL)allowsToolTipsWhenApplicationIsInactive; -(NSImage *)miniwindowImage; -(NSString *)miniwindowTitle; -(NSColor *)backgroundColor; -(float)alphaValue; -(NSWindowDepth)depthLimit; - +-(NSSize)resizeIncrements; +-(NSSize)contentResizeIncrements; +-(BOOL)preservesContentDuringLiveResize; -(NSToolbar *)toolbar; +-(NSView *)initialFirstResponder; +-(void)setDelegate:delegate; +-(void)setFrame:(NSRect)frame display:(BOOL)display; +-(void)setFrame:(NSRect)frame display:(BOOL)display animate:(BOOL)flag; +-(void)setContentSize:(NSSize)contentSize; +-(void)setFrameOrigin:(NSPoint)point; +-(void)setFrameTopLeftPoint:(NSPoint)point; +-(void)setMinSize:(NSSize)size; +-(void)setMaxSize:(NSSize)size; +-(void)setContentMinSize:(NSSize)value; +-(void)setContentMaxSize:(NSSize)value; + +-(void)setBackingType:(NSBackingStoreType)value; +-(void)setDynamicDepthLimit:(BOOL)value; +-(void)setOneShot:(BOOL)flag; +-(void)setReleasedWhenClosed:(BOOL)flag; +-(void)setHidesOnDeactivate:(BOOL)flag; +-(void)setAcceptsMouseMovedEvents:(BOOL)flag; +-(void)setExcludedFromWindowsMenu:(BOOL)value; +-(void)setAutodisplay:(BOOL)value; +-(void)setTitle:(NSString *)title; +-(void)setTitleWithRepresentedFilename:(NSString *)filename; +-(void)setContentView:(NSView *)view; + +-(void)setInitialFirstResponder:(NSView *)view; +-(void)setMiniwindowImage:(NSImage *)image; +-(void)setMiniwindowTitle:(NSString *)title; +-(void)setBackgroundColor:(NSColor *)color; +-(void)setAlphaValue:(float)value; +-(void)setToolbar:(NSToolbar *)toolbar; +-(void)setDefaultButtonCell:(NSButtonCell *)cell; +-(void)setWindowController:(NSWindowController *)value; +-(void)setDocumentEdited:(BOOL)flag; +-(void)setContentAspectRatio:(NSSize)value; +-(void)setHasShadow:(BOOL)value; +-(void)setIgnoresMouseEvents:(BOOL)value; +-(void)setAspectRatio:(NSSize)value; +-(void)setAutorecalculatesKeyViewLoop:(BOOL)value; +-(void)setCanHide:(BOOL)value; +-(void)setLevel:(int)value; +-(void)setOpaque:(BOOL)value; +-(void)setParentWindow:(NSWindow *)value; +-(void)setPreservesContentDuringLiveResize:(BOOL)value; +-(void)setRepresentedFilename:(NSString *)value; +-(void)setResizeIncrements:(NSSize)value; +-(void)setShowsResizeIndicator:(BOOL)value; +-(void)setShowsToolbarButton:(BOOL)value; +-(void)setContentResizeIncrements:(NSSize)value; +-(void)setDepthLimit:(NSWindowDepth)value; +-(void)setDisplaysWhenScreenProfileChanges:(BOOL)value; +-(void)setMovableByWindowBackground:(BOOL)value; +-(void)setAllowsToolTipsWhenApplicationIsInactive:(BOOL)value; + +-(BOOL)setFrameUsingName:(NSString *)name; +-(BOOL)setFrameUsingName:(NSString *)name force:(BOOL)force; +-(BOOL)setFrameAutosaveName:(NSString *)name; +-(void)saveFrameUsingName:(NSString *)name; +-(void)setFrameFromString:(NSString *)value; +-(NSString *)stringWithSavedFrame; + +-(int)resizeFlags; +-(float)userSpaceScaleFactor; +-(NSResponder *)firstResponder; + +-(NSButton *)standardWindowButton:(NSWindowButton)value; -(NSButtonCell *)defaultButtonCell; -(NSWindow *)attachedSheet; @@ -171,8 +291,10 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; -(int)windowNumber; -(int)gState; -(NSScreen *)screen; +-(NSScreen *)deepestScreen; -(BOOL)isDocumentEdited; +-(BOOL)isZoomed; -(BOOL)isVisible; -(BOOL)isKeyWindow; -(BOOL)isMainWindow; @@ -183,41 +305,14 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; -(NSPoint)convertBaseToScreen:(NSPoint)point; -(NSPoint)convertScreenToBase:(NSPoint)point; --(void)setTitle:(NSString *)title; --(void)setTitleWithRepresentedFilename:(NSString *)filename; --(void)setContentView:(NSView *)view; +-(NSRect)frameRectForContentRect:(NSRect)rect; +-(NSRect)contentRectForFrameRect:(NSRect)rect; +-(NSRect)constrainFrameRect:(NSRect)rect toScreen:(NSScreen *)screen; --(void)setDelegate:delegate; - --(void)setFrame:(NSRect)frame display:(BOOL)display; --(void)setFrame:(NSRect)frame display:(BOOL)display animate:(BOOL)flag; --(void)setContentSize:(NSSize)contentSize; --(void)setFrameOrigin:(NSPoint)point; --(void)setFrameTopLeftPoint:(NSPoint)point; --(NSPoint)cascadeTopLeftFromPoint:(NSPoint)topLeftPoint; --(void)setMinSize:(NSSize)size; --(void)setMaxSize:(NSSize)size; - --(void)setDynamicDepthLimit:(BOOL)value; --(void)setOneShot:(BOOL)flag; --(void)setReleasedWhenClosed:(BOOL)flag; --(void)setHidesOnDeactivate:(BOOL)flag; --(void)setAcceptsMouseMovedEvents:(BOOL)flag; --(void)setExcludedFromWindowsMenu:(BOOL)value; --(void)setAutodisplay:(BOOL)value; - --(void)setInitialFirstResponder:(NSView *)view; --(void)setMiniwindowImage:(NSImage *)image; --(void)setMiniwindowTitle:(NSString *)title; --(void)setBackgroundColor:(NSColor *)color; --(void)setToolbar:(NSToolbar*)toolbar; --(void)setDefaultButtonCell:(NSButtonCell *)buttonCell; --(void)setWindowController:(NSWindowController *)value; --(void)setDocumentEdited:(BOOL)flag; --(void)setContentAspectRatio:(NSSize)value; - --(BOOL)setFrameUsingName:(NSString *)name; --(BOOL)setFrameAutosaveName:(NSString *)name; +-(NSWindow *)parentWindow; +-(NSArray *)childWindows; +-(void)addChildWindow:(NSWindow *)child ordered:(NSWindowOrderingMode)ordered; +-(void)removeChildWindow:(NSWindow *)child; -(BOOL)makeFirstResponder:(NSResponder *)responder; @@ -235,6 +330,8 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; -(void)selectPreviousKeyView:sender; -(void)selectKeyViewFollowingView:(NSView *)view; -(void)selectKeyViewPrecedingView:(NSView *)view; +-(void)recalculateKeyViewLoop; +-(NSSelectionDirection)keyViewSelectionDirection; -(void)disableKeyEquivalentForDefaultButtonCell; -(void)enableKeyEquivalentForDefaultButtonCell; @@ -242,6 +339,7 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; -(NSText *)fieldEditor:(BOOL)create forObject:object; -(void)endEditingFor:object; +-(void)disableScreenUpdatesUntilFlush; -(void)useOptimizedDrawing:(BOOL)flag; -(BOOL)viewsNeedDisplay; -(void)setViewsNeedDisplay:(BOOL)flag; @@ -252,42 +350,63 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; -(void)displayIfNeeded; -(void)display; +-(void)invalidateShadow; + +-(void)cacheImageInRect:(NSRect)rect; +-(void)restoreCachedImage; +-(void)discardCachedImage; + -(BOOL)areCursorRectsEnabled; -(void)disableCursorRects; -(void)enableCursorRects; - -(void)discardCursorRects; -(void)resetCursorRects; - -(void)invalidateCursorRectsForView:(NSView *)view; + -(void)close; -(void)center; --(void)makeKeyAndOrderFront:sender; --(void)orderFront:sender; --(void)orderBack:sender; --(void)orderOut:sender; -(void)orderWindow:(NSWindowOrderingMode)place relativeTo:(int)relativeTo; +-(void)orderFrontRegardless; + +-(NSPoint)mouseLocationOutsideOfEventStream; -(NSEvent *)currentEvent; --(NSEvent *)nextEventMatchingMask:(unsigned int)mask; --(NSEvent *)nextEventMatchingMask:(unsigned int)mask untilDate:(NSDate *)untilDate inMode:(NSString *)mode dequeue:(BOOL)dequeue; +-(NSEvent *)nextEventMatchingMask:(unsigned)mask; +-(NSEvent *)nextEventMatchingMask:(unsigned)mask untilDate:(NSDate *)untilDate inMode:(NSString *)mode dequeue:(BOOL)dequeue; +-(void)discardEventsMatchingMask:(unsigned)mask beforeEvent:(NSEvent *)event; -(void)sendEvent:(NSEvent *)event; -(void)postEvent:(NSEvent *)event atStart:(BOOL)atStart; --(NSPoint)mouseLocationOutsideOfEventStream; +-(BOOL)tryToPerform:(SEL)selector with:object; + +-(NSPoint)cascadeTopLeftFromPoint:(NSPoint)topLeftPoint; + +-(NSData *)dataWithEPSInsideRect:(NSRect)rect; +-(NSData *)dataWithPDFInsideRect:(NSRect)rect; -(void)registerForDraggedTypes:(NSArray *)types; -(void)unregisterDraggedTypes; -(void)dragImage:(NSImage *)image at:(NSPoint)location offset:(NSSize)offset event:(NSEvent *)event pasteboard:(NSPasteboard *)pasteboard source:source slideBack:(BOOL)slideBack; +-validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType; + -(void)update; +-(void)makeKeyAndOrderFront:sender; +-(void)orderFront:sender; +-(void)orderBack:sender; +-(void)orderOut:sender; + -(void)performClose:sender; -(void)performMiniaturize:sender; +-(void)performZoom:sender; + +-(void)zoom:sender; -(void)miniaturize:sender; -(void)deminiaturize:sender; +-(void)print:sender; -(void)toggleToolbarShown:sender; -(void)runToolbarCustomizationPalette:sender; @@ -295,6 +414,20 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; @end @interface NSObject(NSWindow_delegate) + +-(void)windowWillBeginSheet:(NSNotification *)note; +-(void)windowDidEndSheet:(NSNotification *)note; +-(NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect; + +-(void)windowDidChangeScreen:(NSNotification *)note; +-(void)windowDidChangeScreenProfile:(NSNotification *)note; +-(void)windowDidExpose:(NSNotification *)note; +-(BOOL)windowShouldZoom:(NSWindow *)sender toFrame:(NSRect)frame; + +-windowWillReturnFieldEditor:(NSWindow *)sender toObject:object; + +-(NSRect)windowWillUseStandardFrame:(NSWindow *)sender defaultFrame:(NSRect)frame; + -(NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window; -(void)windowDidBecomeKey:(NSNotification *)note; -(void)windowDidResignKey:(NSNotification *)note; @@ -312,3 +445,7 @@ APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; -(void)windowWillClose:(NSNotification *)note; @end +//private +APPKIT_EXPORT NSString *NSWindowWillAnimateNotification; +APPKIT_EXPORT NSString *NSWindowAnimatingNotification; +APPKIT_EXPORT NSString *NSWindowDidAnimateNotification; diff --git a/AppKit/NSWindow.m b/AppKit/NSWindow.m index aa5f4a1e..f150516f 100755 --- a/AppKit/NSWindow.m +++ b/AppKit/NSWindow.m @@ -66,19 +66,31 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; } +(NSRect)frameRectForContentRect:(NSRect)contentRect styleMask:(unsigned)styleMask { - contentRect.size.height; if(styleMask!=0) contentRect.size.height+=[NSMainMenuView menuHeight]; return contentRect; } +(NSRect)contentRectForFrameRect:(NSRect)frameRect styleMask:(unsigned)styleMask { - frameRect.size.height; if(styleMask!=0) frameRect.size.height-=[NSMainMenuView menuHeight]; return frameRect; } ++(float)minFrameWidthWithTitle:(NSString *)title styleMask:(unsigned)styleMask { + NSUnimplementedMethod(); + return 0; +} + ++(void)removeFrameUsingName:(NSString *)name { + NSUnimplementedMethod(); +} + ++(NSButton *)standardWindowButton:(NSWindowButton)button forStyleMask:(unsigned)styleMask { + NSUnimplementedMethod(); + return nil; +} + -(void)encodeWithCoder:(NSCoder *)coder { NSUnimplementedMethod(); } @@ -173,7 +185,7 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; -initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(unsigned)backing defer:(BOOL)defer screen:(NSScreen *)screen { // FIX, relocate contentRect - return [self initWithContentRect:contentRect styleMask:styleMask backing:backing defer:defer screen:screen]; + return [self initWithContentRect:contentRect styleMask:styleMask backing:backing defer:defer]; } -(void)dealloc { @@ -251,8 +263,9 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; return [NSGraphicsContext graphicsContextWithWindow:self]; } --(NSString *)title { - return _title; +-(NSDictionary *)deviceDescription { + NSUnimplementedMethod(); + return nil; } -contentView { @@ -263,18 +276,22 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; return _delegate; } +-(NSString *)title { + return _title; +} + +-(NSString *)representedFilename { + return _representedFilename; +} + +-(int)level { + return _level; +} + -(NSRect)frame { return _frame; } --(NSSize)minSize { - return _minSize; -} - --(NSSize)maxSize { - return _maxSize; -} - -(unsigned)styleMask { return _styleMask; } @@ -283,14 +300,34 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; return _backingType; } --(BOOL)hasDynamicDepthLimit { - return _dynamicDepthLimit; +-(NSSize)minSize { + return _minSize; +} + +-(NSSize)maxSize { + return _maxSize; +} + +-(NSSize)contentMinSize { + return _contentMinSize; +} + +-(NSSize)contentMaxSize { + return _contentMaxSize; } -(BOOL)isOneShot { return _isOneShot; } +-(BOOL)isOpaque { + return _isOpaque; +} + +-(BOOL)hasDynamicDepthLimit { + return _dynamicDepthLimit; +} + -(BOOL)isReleasedWhenClosed { return _releaseWhenClosed; } @@ -319,16 +356,60 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; return _isAutodisplay; } +-(BOOL)isFlushWindowDisabled { + return _isFlushWindowDisabled; +} + -(NSString *)frameAutosaveName { return _autosaveFrameName; } --(NSResponder *)firstResponder { - return _firstResponder; +-(BOOL)hasShadow { + return _hasShadow; } --(NSView *)initialFirstResponder { - return _initialFirstResponder; +-(BOOL)ignoresMouseEvents { + return _ignoresMouseEvents; +} + +-(NSSize)aspectRatio { + return _aspectRatio; +} + +-(NSSize)contentAspectRatio { + return _contentAspectRatio; +} + +-(BOOL)autorecalculatesKeyViewLoop { + return _autorecalculatesKeyViewLoop; +} + +-(BOOL)canHide { + return _canHide; +} + +-(BOOL)canStoreColor { + return _canStoreColor; +} + +-(BOOL)showsResizeIndicator { + return _showsResizeIndicator; +} + +-(BOOL)showsToolbarButton { + return _showsToolbarButton; +} + +-(BOOL)displaysWhenScreenProfileChanges { + return _displaysWhenScreenProfileChanges; +} + +-(BOOL)isMovableByWindowBackground { + return _isMovableByWindowBackground; +} + +-(BOOL)allowsToolTipsWhenApplicationIsInactive { + return _allowsToolTipsWhenApplicationIsInactive; } -(NSImage *)miniwindowImage { @@ -343,133 +424,32 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; return _backgroundColor; } +-(float)alphaValue { + return _alphaValue; +} + +-(NSWindowDepth)depthLimit { + return 0; +} + +-(NSSize)resizeIncrements { + return _resizeIncrements; +} + +-(NSSize)contentResizeIncrements { + return _contentResizeIncrements; +} + +-(BOOL)preservesContentDuringLiveResize { + return _preservesContentDuringLiveResize; +} + -(NSToolbar *)toolbar { return _toolbar; } -- (NSButtonCell *)defaultButtonCell { - return _defaultButtonCell; -} - --(NSWindow *)attachedSheet { - return [_sheetContext sheet]; -} - --(NSArray *)drawers { - return _drawers; -} - --(NSWindowController *)windowController { - return _windowController; -} - --(int)windowNumber { - return (int)self; -} - --(int)gState { - NSUnimplementedMethod(); - return 0; -} - --(NSScreen *)screen { - NSArray *screens=[NSScreen screens]; - int i,count=[screens count]; - NSRect mostRect=NSZeroRect; - NSScreen *mostScreen=nil; - - for(i=0;imostRect.size.width*mostRect.size.height){ - mostRect=intersect; - mostScreen=check; - } - } - - return mostScreen; -} - --(BOOL)isDocumentEdited { - return _isDocumentEdited; -} - --(BOOL)isVisible { - return _isVisible; -} - --(BOOL)isKeyWindow { - return _isKeyWindow; -} - --(BOOL)isMainWindow { - return _isMainWindow; -} - --(BOOL)isMiniaturized { - return [_platformWindow isMiniaturized]; -} - --(BOOL)canBecomeKeyWindow { - return YES; -} - --(BOOL)canBecomeMainWindow { - return YES; -} - --(NSPoint)convertBaseToScreen:(NSPoint)point { - NSRect frame=[self frame]; - - point.x+=frame.origin.x; - point.y+=frame.origin.y; - - return point; -} - --(NSPoint)convertScreenToBase:(NSPoint)point { - NSRect frame=[self frame]; - - point.x-=frame.origin.x; - point.y-=frame.origin.y; - - return point; -} - --(void)setTitle:(NSString *)title { - title=[title copy]; - [_title release]; - _title=title; - - [_miniwindowTitle release]; - _miniwindowTitle=[title copy]; - - [self _updatePlatformWindowTitle]; - - if (![self isKindOfClass:[NSPanel class]] && [self isVisible] && ![self isExcludedFromWindowsMenu]) - [NSApp changeWindowsItem:self title:title filename:NO]; -} - --(void)setTitleWithRepresentedFilename:(NSString *)filename { - [self setTitle:[NSString stringWithFormat:@"%@ -- %@", - [filename lastPathComponent], - [filename stringByDeletingLastPathComponent]]]; - - if (![self isKindOfClass:[NSPanel class]] && [self isVisible] && ![self isExcludedFromWindowsMenu]) - [NSApp changeWindowsItem:self title:filename filename:YES]; -} - --(void)setContentView:(NSView *)view { - view=[view retain]; - [view setFrame:[_contentView frame]]; - - [_contentView removeFromSuperview]; - [_contentView release]; - - _contentView=view; - - [_backgroundView addSubview:_contentView]; +-(NSView *)initialFirstResponder { + return _initialFirstResponder; } -(void)removeObserver:(NSString *)name selector:(SEL)selector { @@ -725,28 +705,6 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [self setFrame:frame display:YES]; } --(NSPoint)cascadeTopLeftFromPoint:(NSPoint)topLeftPoint { - NSSize screenSize = [[self screen] frame].size; - NSRect frame = [self frame]; - - if (topLeftPoint.x + topLeftPoint.y == 0.0 || topLeftPoint.x > 0.5*screenSize.width || topLeftPoint.y < 0.5*screenSize.height) - { - topLeftPoint.x = frame.origin.x; - topLeftPoint.y = frame.origin.y + frame.size.height; - } - - else - { - topLeftPoint.x += 18; - topLeftPoint.y -= 21; - frame.origin.x=topLeftPoint.x; - frame.origin.y=topLeftPoint.y - frame.size.height; - [self setFrame:frame display:YES]; - } - - return topLeftPoint; -} - -(void)setMinSize:(NSSize)size { _minSize=size; } @@ -755,6 +713,21 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; _maxSize=size; } +-(void)setContentMinSize:(NSSize)value { + _contentMinSize=value; + NSUnimplementedMethod(); +} + +-(void)setContentMaxSize:(NSSize)value { + _contentMaxSize=value; + NSUnimplementedMethod(); +} + +-(void)setBackingType:(NSBackingStoreType)value { + _backingType=value; + NSUnimplementedMethod(); +} + -(void)setDynamicDepthLimit:(BOOL)value { _dynamicDepthLimit=value; } @@ -783,6 +756,41 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; _isAutodisplay=value; } +-(void)setTitle:(NSString *)title { + title=[title copy]; + [_title release]; + _title=title; + + [_miniwindowTitle release]; + _miniwindowTitle=[title copy]; + + [self _updatePlatformWindowTitle]; + + if (![self isKindOfClass:[NSPanel class]] && [self isVisible] && ![self isExcludedFromWindowsMenu]) + [NSApp changeWindowsItem:self title:title filename:NO]; +} + +-(void)setTitleWithRepresentedFilename:(NSString *)filename { + [self setTitle:[NSString stringWithFormat:@"%@ -- %@", + [filename lastPathComponent], + [filename stringByDeletingLastPathComponent]]]; + + if (![self isKindOfClass:[NSPanel class]] && [self isVisible] && ![self isExcludedFromWindowsMenu]) + [NSApp changeWindowsItem:self title:filename filename:YES]; +} + +-(void)setContentView:(NSView *)view { + view=[view retain]; + [view setFrame:[_contentView frame]]; + + [_contentView removeFromSuperview]; + [_contentView release]; + + _contentView=view; + + [_backgroundView addSubview:_contentView]; +} + -(void)setInitialFirstResponder:(NSView *)view { _initialFirstResponder = view; } @@ -807,15 +815,12 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; _backgroundColor=color; } --(float)alphaValue { - return 1; +-(void)setAlphaValue:(float)value { + _alphaValue=value; + NSUnimplementedMethod(); } --(NSWindowDepth)depthLimit { - return 0; -} - --(void)setToolbar:(NSToolbar*)toolbar { +-(void)setToolbar:(NSToolbar *)toolbar { [_toolbar _setWindow:nil]; [_toolbar release]; _toolbar = [toolbar retain]; @@ -842,6 +847,88 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; _useAspectRatio=YES; _aspectRatioIsContent=YES; _aspectRatio=value; + NSUnimplementedMethod(); +} + +-(void)setHasShadow:(BOOL)value { + _hasShadow=value; + NSUnimplementedMethod(); +} + +-(void)setIgnoresMouseEvents:(BOOL)value { + _ignoresMouseEvents=value; +} + +-(void)setAspectRatio:(NSSize)value { + _useAspectRatio=YES; + _aspectRatioIsContent=NO; + _aspectRatio=value; + NSUnimplementedMethod(); +} + +-(void)setAutorecalculatesKeyViewLoop:(BOOL)value { + _autorecalculatesKeyViewLoop=value; +} + +-(void)setCanHide:(BOOL)value { + _canHide=value; +} + +-(void)setLevel:(int)value { + _level=value; + NSUnimplementedMethod(); +} + +-(void)setOpaque:(BOOL)value { + _isOpaque=value; +} + +-(void)setParentWindow:(NSWindow *)value { + _parentWindow=value; +} + +-(void)setPreservesContentDuringLiveResize:(BOOL)value { + _preservesContentDuringLiveResize=value; +} + +-(void)setRepresentedFilename:(NSString *)value { + value=[value copy]; + [_representedFilename release]; + _representedFilename=value; +} + +-(void)setResizeIncrements:(NSSize)value { + _resizeIncrements=value; +} + +-(void)setShowsResizeIndicator:(BOOL)value { + _showsResizeIndicator=value; + NSUnimplementedMethod(); +} + +-(void)setShowsToolbarButton:(BOOL)value { + _showsToolbarButton=value; + NSUnimplementedMethod(); +} + +-(void)setContentResizeIncrements:(NSSize)value { + _contentResizeIncrements=value; +} + +-(void)setDepthLimit:(NSWindowDepth)value { + NSUnimplementedMethod(); +} + +-(void)setDisplaysWhenScreenProfileChanges:(BOOL)value { + _displaysWhenScreenProfileChanges=value; +} + +-(void)setMovableByWindowBackground:(BOOL)value { + _isMovableByWindowBackground=value; +} + +-(void)setAllowsToolTipsWhenApplicationIsInactive:(BOOL)value { + _allowsToolTipsWhenApplicationIsInactive=value; } -(NSString *)_autosaveFrameKeyWithName:(NSString *)name { @@ -849,24 +936,19 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; } -(BOOL)setFrameUsingName:(NSString *)name { - NSString *key=[self _autosaveFrameKeyWithName:name]; - NSString *value=[[NSUserDefaults standardUserDefaults] objectForKey:key]; - NSRect rect=NSRectFromString(value); - - if(!NSIsEmptyRect(rect)){ - [self setFrame:rect display:YES]; - return YES; - } - - return NO; + return [self setFrameUsingName:name force:NO]; } --(void)_autosaveFrame { - if([_autosaveFrameName length]>0){ - NSString *key=[self _autosaveFrameKeyWithName:_autosaveFrameName]; - NSString *value=NSStringFromRect([self frame]); - [[NSUserDefaults standardUserDefaults] setObject:value forKey:key]; - } +-(BOOL)setFrameUsingName:(NSString *)name force:(BOOL)force { + NSString *key=[self _autosaveFrameKeyWithName:name]; + NSString *value=[[NSUserDefaults standardUserDefaults] objectForKey:key]; + + if([value length]==0) + return NO; + + [self setFrameFromString:value]; + + return YES; } -(BOOL)setFrameAutosaveName:(NSString *)name { @@ -874,10 +956,178 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [_autosaveFrameName release]; _autosaveFrameName=name; // check if this name is in use by any other windows - [self _autosaveFrame]; + [self saveFrameUsingName:_autosaveFrameName]; return YES; } +-(void)saveFrameUsingName:(NSString *)name { + if([name length]>0){ + NSString *key=[self _autosaveFrameKeyWithName:name]; + NSString *value=[self stringWithSavedFrame]; + + [[NSUserDefaults standardUserDefaults] setObject:value forKey:key]; + } +} + +-(void)setFrameFromString:(NSString *)value { + NSRect rect=NSRectFromString(value); + + if(!NSIsEmptyRect(rect)){ + [self setFrame:rect display:YES]; + } +} + +-(NSString *)stringWithSavedFrame { + return NSStringFromRect([self frame]); +} + +-(int)resizeFlags { + NSUnimplementedMethod(); + return 0; +} + +-(float)userSpaceScaleFactor { + return 1.0; +} + +-(NSResponder *)firstResponder { + return _firstResponder; +} + +-(NSButton *)standardWindowButton:(NSWindowButton)value { + NSUnimplementedMethod(); + return nil; +} + +-(NSButtonCell *)defaultButtonCell { + return _defaultButtonCell; +} + +-(NSWindow *)attachedSheet { + return [_sheetContext sheet]; +} + +-(NSWindowController *)windowController { + return _windowController; +} + +-(NSArray *)drawers { + return _drawers; +} + +-(int)windowNumber { + return (int)self; +} + +-(int)gState { + NSUnimplementedMethod(); + return 0; +} + +-(NSScreen *)screen { + NSArray *screens=[NSScreen screens]; + int i,count=[screens count]; + NSRect mostRect=NSZeroRect; + NSScreen *mostScreen=nil; + + for(i=0;imostRect.size.width*mostRect.size.height){ + mostRect=intersect; + mostScreen=check; + } + } + + return mostScreen; +} + +-(NSScreen *)deepestScreen { + NSUnimplementedMethod(); + return 0; +} + +-(BOOL)isDocumentEdited { + return _isDocumentEdited; +} + +-(BOOL)isZoomed { + NSUnimplementedMethod(); + return 0; +} + +-(BOOL)isVisible { + return _isVisible; +} + +-(BOOL)isKeyWindow { + return _isKeyWindow; +} + +-(BOOL)isMainWindow { + return _isMainWindow; +} + +-(BOOL)isMiniaturized { + return [_platformWindow isMiniaturized]; +} + +-(BOOL)canBecomeKeyWindow { + return YES; +} + +-(BOOL)canBecomeMainWindow { + return YES; +} + +-(NSPoint)convertBaseToScreen:(NSPoint)point { + NSRect frame=[self frame]; + + point.x+=frame.origin.x; + point.y+=frame.origin.y; + + return point; +} + +-(NSPoint)convertScreenToBase:(NSPoint)point { + NSRect frame=[self frame]; + + point.x-=frame.origin.x; + point.y-=frame.origin.y; + + return point; +} + +-(NSRect)frameRectForContentRect:(NSRect)rect { + return [isa frameRectForContentRect:rect styleMask:[self styleMask]]; +} + +-(NSRect)contentRectForFrameRect:(NSRect)rect { + return [isa contentRectForFrameRect:rect styleMask:[self styleMask]]; +} + +-(NSRect)constrainFrameRect:(NSRect)rect toScreen:(NSScreen *)screen { + NSUnimplementedMethod(); + return NSMakeRect(0,0,0,0); +} + +-(NSWindow *)parentWindow { + return _parentWindow; +} + +-(NSArray *)childWindows { + return _childWindows; +} + +-(void)addChildWindow:(NSWindow *)child ordered:(NSWindowOrderingMode)ordered { + NSUnimplementedMethod(); +} + +-(void)removeChildWindow:(NSWindow *)child { + NSUnimplementedMethod(); +} + -(BOOL)acceptsFirstResponder { return YES; } @@ -988,6 +1238,16 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [self makeFirstResponder:next]; } +-(void)recalculateKeyViewLoop { + NSUnimplementedMethod(); +} + +-(NSSelectionDirection)keyViewSelectionDirection { + NSUnimplementedMethod(); + return 0; +} + + - (void)disableKeyEquivalentForDefaultButtonCell { _defaultButtonCellKeyEquivalentDisabled = YES; } @@ -1019,6 +1279,10 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [_fieldEditor setString:@""]; } +-(void)disableScreenUpdatesUntilFlush { + NSUnimplementedMethod(); +} + -(void)useOptimizedDrawing:(BOOL)flag { // do nothing } @@ -1093,6 +1357,22 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [pool release]; } +-(void)invalidateShadow { + NSUnimplementedMethod(); +} + +-(void)cacheImageInRect:(NSRect)rect { + NSUnimplementedMethod(); +} + +-(void)restoreCachedImage { + NSUnimplementedMethod(); +} + +-(void)discardCachedImage { + NSUnimplementedMethod(); +} + -(BOOL)areCursorRectsEnabled { return (_cursorRectsDisabled<=0)?YES:NO; } @@ -1166,30 +1446,6 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [self setFrame:frame display:YES]; } --(void)makeKeyAndOrderFront:sender { - if ([self isMiniaturized]) - [_platformWindow deminiaturize]; - - [self makeKeyWindow]; - - if(![self isKindOfClass:[NSPanel class]]) - [self makeMainWindow]; - - [self orderWindow:NSWindowAbove relativeTo:0]; -} - --(void)orderFront:sender { - [self orderWindow:NSWindowAbove relativeTo:0]; -} - --(void)orderBack:sender { - [self orderWindow:NSWindowBelow relativeTo:0]; -} - --(void)orderOut:sender { - [self orderWindow:NSWindowOut relativeTo:0]; -} - -(void)orderWindow:(NSWindowOrderingMode)place relativeTo:(int)relativeTo { // The move notifications are sent under unknown conditions around orderFront: in the Apple AppKit, we do them all the time here until it's figured out. I suspect it is a side effect of off-screen windows being at off-screen coordinates (as opposed to just being hidden) @@ -1239,6 +1495,16 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [self postNotificationName:NSWindowDidMoveNotification]; } +-(void)orderFrontRegardless { + NSUnimplementedMethod(); +} + +-(NSPoint)mouseLocationOutsideOfEventStream { + NSPoint point=[_platformWindow mouseLocationOutsideOfEventStream]; + + return [self convertScreenToBase:point]; +} + -(NSEvent *)currentEvent { return [NSApp currentEvent]; } @@ -1263,6 +1529,10 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; return event; } +-(void)discardEventsMatchingMask:(unsigned)mask beforeEvent:(NSEvent *)event { + NSUnimplementedMethod(); +} + -(void)sendEvent:(NSEvent *)event { if (_sheetContext != nil) { NSView *view = [_backgroundView hitTest:[event locationInWindow]]; @@ -1371,10 +1641,46 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [NSApp postEvent:event atStart:atStart]; } --(NSPoint)mouseLocationOutsideOfEventStream { - NSPoint point=[_platformWindow mouseLocationOutsideOfEventStream]; +-(BOOL)tryToPerform:(SEL)selector with:object { + if([super tryToPerform:selector with:object]) + return YES; + + if([_delegate respondsToSelector:selector]){ + [_delegate performSelector:selector withObject:object]; + return YES; + } + + return NO; +} - return [self convertScreenToBase:point]; +-(NSPoint)cascadeTopLeftFromPoint:(NSPoint)topLeftPoint { + NSSize screenSize = [[self screen] frame].size; + NSRect frame = [self frame]; + + if (topLeftPoint.x + topLeftPoint.y == 0.0 || topLeftPoint.x > 0.5*screenSize.width || topLeftPoint.y < 0.5*screenSize.height) + { + topLeftPoint.x = frame.origin.x; + topLeftPoint.y = frame.origin.y + frame.size.height; + } + + else + { + topLeftPoint.x += 18; + topLeftPoint.y -= 21; + frame.origin.x=topLeftPoint.x; + frame.origin.y=topLeftPoint.y - frame.size.height; + [self setFrame:frame display:YES]; + } + + return topLeftPoint; +} + +-(NSData *)dataWithEPSInsideRect:(NSRect)rect { + return [_backgroundView dataWithEPSInsideRect:rect]; +} + +-(NSData *)dataWithPDFInsideRect:(NSRect)rect { + return [_backgroundView dataWithPDFInsideRect:rect]; } -(void)registerForDraggedTypes:(NSArray *)types { @@ -1390,12 +1696,41 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [[NSDraggingManager draggingManager] dragImage:image at:location offset:offset event:event pasteboard:pasteboard source:source slideBack:slideBack]; } +-validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType { + NSUnimplementedMethod(); + return nil; +} + -(void)update { [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidUpdateNotification object:self]; } +-(void)makeKeyAndOrderFront:sender { + if ([self isMiniaturized]) + [_platformWindow deminiaturize]; + + [self makeKeyWindow]; + + if(![self isKindOfClass:[NSPanel class]]) + [self makeMainWindow]; + + [self orderWindow:NSWindowAbove relativeTo:0]; +} + +-(void)orderFront:sender { + [self orderWindow:NSWindowAbove relativeTo:0]; +} + +-(void)orderBack:sender { + [self orderWindow:NSWindowBelow relativeTo:0]; +} + +-(void)orderOut:sender { + [self orderWindow:NSWindowOut relativeTo:0]; +} + -(void)performClose:sender { if([_delegate respondsToSelector:@selector(windowShouldClose:)]) if(![_delegate windowShouldClose:self]) @@ -1408,6 +1743,14 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [self miniaturize:sender]; } +-(void)performZoom:sender { + NSUnimplementedMethod(); +} + +-(void)zoom:sender { + NSUnimplementedMethod(); +} + -(void)miniaturize:sender { [[self platformWindow] miniaturize]; } @@ -1416,6 +1759,10 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [[self platformWindow] deminiaturize]; } +-(void)print:sender { + [_backgroundView print:sender]; +} + -(void)toggleToolbarShown:sender { [_toolbar setVisible:![_toolbar isVisible]]; [sender setTitle:[NSString stringWithFormat:@"%@ Toolbar", [_toolbar isVisible] ? @"Hide" : @"Show"]]; @@ -1462,7 +1809,7 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; while(--count>=0){ NSCursorRect *check=[_cursorRects objectAtIndex:count]; - if([check view]==view && [check cursor]==cursor & NSEqualRects([check rect],rect)) + if(([check view]==view) && ([check cursor]==cursor) & NSEqualRects([check rect],rect)) [_cursorRects removeObjectAtIndex:count]; } } @@ -1532,8 +1879,6 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; } } - - -(BOOL)performKeyEquivalent:(NSEvent *)event { return [_backgroundView performKeyEquivalent:event]; } @@ -1776,7 +2121,7 @@ NSString *NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification"; [_backgroundView setFrameSize:_frame.size]; [_backgroundView setNeedsDisplay:YES]; - [self _autosaveFrame]; + [self saveFrameUsingName:_autosaveFrameName]; [self resetCursorRects]; } diff --git a/AppKit/NSWindowController.h b/AppKit/NSWindowController.h index 79742864..5ec12a5e 100755 --- a/AppKit/NSWindowController.h +++ b/AppKit/NSWindowController.h @@ -37,7 +37,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(void)showWindow:sender; -(void)setDocument:(NSDocument *)document; --(id)document; +-document; -(void)setDocumentEdited:(BOOL)flag; -(void)close; diff --git a/AppKit/NSWorkspace.h b/AppKit/NSWorkspace.h index 19032309..225adafb 100755 --- a/AppKit/NSWorkspace.h +++ b/AppKit/NSWorkspace.h @@ -9,7 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import -@class NSImage; +@class NSImage, NSView; APPKIT_EXPORT NSString *NSWorkspaceWillPowerOffNotification; @@ -21,15 +21,56 @@ APPKIT_EXPORT NSString *NSWorkspaceWillPowerOffNotification; -(NSNotificationCenter *)notificationCenter; --(BOOL)selectFile:(NSString *)path inFileViewerRootedAtPath:(NSString *)rootedAtPath; +-(NSImage *)iconForFile:(NSString *)path; +-(NSImage *)iconForFiles:(NSArray *)array; +-(NSImage *)iconForFileType:(NSString *)type; +-(NSString *)localizedDescriptionForType:(NSString *)type; +-(BOOL)filenameExtension:(NSString *)extension isValidForType:(NSString *)type; +-(NSString *)preferredFilenameExtensionForType:(NSString *)type; +-(BOOL)type:(NSString *)type conformsToType:(NSString *)conformsToType; +-(NSString *)typeOfFile:(NSString *)path error:(NSError **)error; -(BOOL)openFile:(NSString *)path; -(BOOL)openFile:(NSString *)path withApplication:(NSString *)application; -(BOOL)openTempFile:(NSString *)path; +-(BOOL)openFile:(NSString *)path fromImage:(NSImage *)image at:(NSPoint)point inView:(NSView *)view; +-(BOOL)openFile:(NSString *)path withApplication:(NSString *)application andDeactivate:(BOOL)deactivate; +-(BOOL)openURL:(NSURL *)url; --(int)extendPowerOffBy:(int)seconds; +-(BOOL)selectFile:(NSString *)path inFileViewerRootedAtPath:(NSString *)rootedAtPath; +-(void)slideImage:(NSImage *)image from:(NSPoint)from to:(NSPoint)to; +-(BOOL)performFileOperation:(NSString *)operation source:(NSString *)source destination:(NSString *)destination files:(NSArray *)files tag:(int *)tag; --(void)slideImage:(NSImage *)image from:(NSPoint)fromPoint to:(NSPoint)toPoint; +-(BOOL)getFileSystemInfoForPath:(NSString *)path isRemovable:(BOOL *)isRemovable isWritable:(BOOL *)isWritable isUnmountable:(BOOL *)isUnmountable description:(NSString **)description type:(NSString **)type; + +-(BOOL)getInfoForFile:(NSString *)path application:(NSString **)application type:(NSString **)type; + +-(void)checkForRemovableMedia; +-(NSArray *)mountNewRemovableMedia; +-(NSArray *)mountedRemovableMedia; +-(NSArray *)mountedLocalVolumePaths; + +-(BOOL)unmountAndEjectDeviceAtPath:(NSString *)path; + +-(BOOL)fileSystemChanged; +-(BOOL)userDefaultsChanged; + +-(void)noteFileSystemChanged; +-(void)noteFileSystemChanged:(NSString *)path; +-(void)noteUserDefaultsChanged; + +-(BOOL)isFilePackageAtPath:(NSString *)path; +-(NSString *)absolutePathForAppBundleWithIdentifier:(NSString *)identifier; +-(NSString *)pathForApplication:(NSString *)application; +-(NSArray *)launchedApplications; +-(BOOL)launchApplication:(NSString *)application; +-(BOOL)launchApplication:(NSString *)application showIcon:(BOOL)showIcon autolaunch:(BOOL)autolaunch; + +-(void)findApplications; +-(NSDictionary *)activeApplication; +-(void)hideOtherApplications; + +-(int)extendPowerOffBy:(int)milliseconds; @end diff --git a/AppKit/NSWorkspace.m b/AppKit/NSWorkspace.m index 10cee720..58b6fbd1 100755 --- a/AppKit/NSWorkspace.m +++ b/AppKit/NSWorkspace.m @@ -27,33 +27,192 @@ NSString *NSWorkspaceWillPowerOffNotification=@"NSWorkspaceWillPowerOffNotificat return _notificationCenter; } --(BOOL)selectFile:(NSString *)path inFileViewerRootedAtPath:(NSString *)rootedAtPath { - NSInvalidAbstractInvocation(); - return NO; -} - --(BOOL)openFile:(NSString *)path { - NSInvalidAbstractInvocation(); - return NO; -} - --(BOOL)openFile:(NSString *)path withApplication:(NSString *)application { - NSInvalidAbstractInvocation(); - return NO; -} - --(BOOL)openTempFile:(NSString *)path { - NSInvalidAbstractInvocation(); - return NO; -} - --(int)extendPowerOffBy:(int)seconds { +-(NSImage *)iconForFile:(NSString *)path { NSInvalidAbstractInvocation(); return 0; } --(void)slideImage:(NSImage *)image from:(NSPoint)fromPoint to:(NSPoint)toPoint { +-(NSImage *)iconForFiles:(NSArray *)array { + NSInvalidAbstractInvocation(); + return 0; +} + +-(NSImage *)iconForFileType:(NSString *)type { + NSInvalidAbstractInvocation(); + return 0; +} + +-(NSString *)localizedDescriptionForType:(NSString *)type { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)filenameExtension:(NSString *)extension isValidForType:(NSString *)type { + NSInvalidAbstractInvocation(); + return 0; +} + +-(NSString *)preferredFilenameExtensionForType:(NSString *)type { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)type:(NSString *)type conformsToType:(NSString *)conformsToType { + NSInvalidAbstractInvocation(); + return 0; +} + +-(NSString *)typeOfFile:(NSString *)path error:(NSError **)error { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)openFile:(NSString *)path { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)openFile:(NSString *)path withApplication:(NSString *)application { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)openTempFile:(NSString *)path { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)openFile:(NSString *)path fromImage:(NSImage *)image at:(NSPoint)point inView:(NSView *)view { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)openFile:(NSString *)path withApplication:(NSString *)application andDeactivate:(BOOL)deactivate { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)openURL:(NSURL *)url { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)selectFile:(NSString *)path inFileViewerRootedAtPath:(NSString *)rootedAtPath { + NSInvalidAbstractInvocation(); + return 0; +} + +-(void)slideImage:(NSImage *)image from:(NSPoint)from to:(NSPoint)to { NSInvalidAbstractInvocation(); } +-(BOOL)performFileOperation:(NSString *)operation source:(NSString *)source destination:(NSString *)destination files:(NSArray *)files tag:(int *)tag { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)getFileSystemInfoForPath:(NSString *)path isRemovable:(BOOL *)isRemovable isWritable:(BOOL *)isWritable isUnmountable:(BOOL *)isUnmountable description:(NSString **)description type:(NSString **)type { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)getInfoForFile:(NSString *)path application:(NSString **)application type:(NSString **)type { + NSInvalidAbstractInvocation(); + return 0; +} + +-(void)checkForRemovableMedia { + NSInvalidAbstractInvocation(); +} + +-(NSArray *)mountNewRemovableMedia { + NSInvalidAbstractInvocation(); + return 0; +} + +-(NSArray *)mountedRemovableMedia { + NSInvalidAbstractInvocation(); + return 0; +} + +-(NSArray *)mountedLocalVolumePaths { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)unmountAndEjectDeviceAtPath:(NSString *)path { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)fileSystemChanged { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)userDefaultsChanged { + NSInvalidAbstractInvocation(); + return 0; +} + +-(void)noteFileSystemChanged { + NSInvalidAbstractInvocation(); +} + +-(void)noteFileSystemChanged:(NSString *)path { + NSInvalidAbstractInvocation(); +} + +-(void)noteUserDefaultsChanged { + NSInvalidAbstractInvocation(); +} + +-(BOOL)isFilePackageAtPath:(NSString *)path { + NSInvalidAbstractInvocation(); + return 0; +} + +-(NSString *)absolutePathForAppBundleWithIdentifier:(NSString *)identifier { + NSInvalidAbstractInvocation(); + return 0; +} + +-(NSString *)pathForApplication:(NSString *)application { + NSInvalidAbstractInvocation(); + return 0; +} + +-(NSArray *)launchedApplications { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)launchApplication:(NSString *)application { + NSInvalidAbstractInvocation(); + return 0; +} + +-(BOOL)launchApplication:(NSString *)application showIcon:(BOOL)showIcon autolaunch:(BOOL)autolaunch { + NSInvalidAbstractInvocation(); + return 0; +} + +-(void)findApplications { + NSInvalidAbstractInvocation(); +} + +-(NSDictionary *)activeApplication { + NSInvalidAbstractInvocation(); + return 0; +} + +-(void)hideOtherApplications { + NSInvalidAbstractInvocation(); +} + +-(int)extendPowerOffBy:(int)milliseconds { + NSInvalidAbstractInvocation(); + return 0; +} + @end diff --git a/AppKit/OpenGL.subproj/NSOpenGLContext.m b/AppKit/OpenGL.subproj/NSOpenGLContext.m index 30c10a45..81e6870c 100755 --- a/AppKit/OpenGL.subproj/NSOpenGLContext.m +++ b/AppKit/OpenGL.subproj/NSOpenGLContext.m @@ -93,6 +93,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(int)currentVirtualScreen { NSUnimplementedMethod(); + return 0; } -(void)setCurrentVirtualScreen:(int)screen { diff --git a/AppKit/OpenGL.subproj/NSOpenGLPixelBuffer.m b/AppKit/OpenGL.subproj/NSOpenGLPixelBuffer.m index cc745466..1e25628b 100644 --- a/AppKit/OpenGL.subproj/NSOpenGLPixelBuffer.m +++ b/AppKit/OpenGL.subproj/NSOpenGLPixelBuffer.m @@ -18,19 +18,27 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -(unsigned)textureTarget { NSUnimplementedMethod(); + return 0; } + -(unsigned long)textureInternalFormat { NSUnimplementedMethod(); + return 0; } + -(long)textureMaxMipMapLevel { NSUnimplementedMethod(); + return 0; } -(int)pixelsWide { NSUnimplementedMethod(); + return 0; } + -(int)pixelsHigh { NSUnimplementedMethod(); + return 0; } @end diff --git a/AppKit/OpenGL.subproj/NSOpenGLPixelFormat.m b/AppKit/OpenGL.subproj/NSOpenGLPixelFormat.m index 60ccdfa4..2af67575 100755 --- a/AppKit/OpenGL.subproj/NSOpenGLPixelFormat.m +++ b/AppKit/OpenGL.subproj/NSOpenGLPixelFormat.m @@ -84,10 +84,12 @@ static inline BOOL attributeHasArgument(NSOpenGLPixelFormatAttribute attribute){ -(void *)CGLPixelFormatObj { NSUnimplementedMethod(); + return 0; } -(int)numberOfVirtualScreens { NSUnimplementedMethod(); + return 0; } -(void)getValues:(long *)values forAttribute:(NSOpenGLPixelFormatAttribute)attribute forVirtualScreen:(int)screen { diff --git a/AppKit/Win32.subproj/KGFont_gdi.m b/AppKit/Win32.subproj/KGFont_gdi.m index 6ac4df6b..d5386ff2 100644 --- a/AppKit/Win32.subproj/KGFont_gdi.m +++ b/AppKit/Win32.subproj/KGFont_gdi.m @@ -31,7 +31,7 @@ } } --(HDC)deviceContext { +-(HDC)deviceContextSelfSelected { KGRenderingContext_gdi *rc=[[Win32Display currentDisplay] renderingContextOnPrimaryScreen]; [rc selectFontWithName:[_name cString] pointSize:[self pointSize]]; @@ -39,6 +39,7 @@ return [rc dc]; } + static inline NSGlyph glyphForCharacter(CGGlyphRangeTable *table,unichar character){ unsigned range=character>>8; unsigned index=character&0xFF; @@ -57,7 +58,7 @@ static inline CGGlyphMetrics *glyphInfoForGlyph(CGGlyphMetricsSet *infoSet,NSGly } -(void)fetchMetrics { - HDC dc=[self deviceContext]; + HDC dc=[self deviceContextSelfSelected]; TEXTMETRIC gdiMetrics; GetTextMetrics(dc,&gdiMetrics); @@ -72,6 +73,8 @@ static inline CGGlyphMetrics *glyphInfoForGlyph(CGGlyphMetricsSet *infoSet,NSGly _metrics.descender=-gdiMetrics.tmDescent; _metrics.italicAngle=0; _metrics.capHeight=0; + _metrics.leading=0; + _metrics.xHeight=0; _metrics.stemV=0; _metrics.stemH=0; _metrics.underlineThickness=_size/24.0; @@ -145,6 +148,8 @@ static inline CGGlyphMetrics *glyphInfoForGlyph(CGGlyphMetricsSet *infoSet,NSGly _metrics.italicAngle=ttMetrics->otmItalicAngle; _metrics.capHeight=ttMetrics->otmsCapEmHeight; + _metrics.xHeight=ttMetrics->otmsXHeight; + _metrics.underlineThickness=ttMetrics->otmsUnderscoreSize; if(_metrics.underlineThickness<0) _metrics.underlineThickness=1; @@ -152,7 +157,7 @@ static inline CGGlyphMetrics *glyphInfoForGlyph(CGGlyphMetricsSet *infoSet,NSGly } -(void)loadGlyphRangeTable { - HDC dc=[self deviceContext]; + HDC dc=[self deviceContextSelfSelected]; NSRange range=NSMakeRange(0,MAXUNICHAR); unichar characters[range.length]; unsigned short glyphs[range.length]; @@ -209,7 +214,7 @@ static inline CGGlyphMetrics *glyphInfoForGlyph(CGGlyphMetricsSet *infoSet,NSGly } -(void)fetchGlyphKerning { - HDC dc=[self deviceContext]; + HDC dc=[self deviceContextSelfSelected]; int i,numberOfPairs=GetKerningPairs(dc,0,NULL); KERNINGPAIR pairs[numberOfPairs]; @@ -250,7 +255,7 @@ static inline CGGlyphMetrics *glyphInfoForGlyph(CGGlyphMetricsSet *infoSet,NSGly } -(void)fetchAdvancementsForGlyph:(CGGlyph)glyph { - HDC dc=[self deviceContext]; + HDC dc=[self deviceContextSelfSelected]; ABCFLOAT *abc; int i,max; @@ -292,4 +297,44 @@ static inline CGGlyphMetrics *glyphInfoForGlyph(CGGlyphMetricsSet *infoSet,NSGly } } +// not complete +-(void)appendCubicOutlinesToPath:(KGMutablePath *)path glyphs:(CGGlyph *)glyphs length:(unsigned)length { + HDC dc=[self deviceContextSelfSelected]; + int size=GetOutlineTextMetricsA(dc,0,NULL); + + if(size<=0) + return; + + OUTLINETEXTMETRICA *ttMetrics=__builtin_alloca(size); + + ttMetrics->otmSize=sizeof(OUTLINETEXTMETRICA); + if(!GetOutlineTextMetricsA(dc,size,ttMetrics)) + return; + +/* P. 931 "Windows Graphics Programming" by Feng Yuan, 1st Ed. + A font with height of negative otmEMSquare will have precise metrics */ + + HFONT fontHandle=[[[[Win32Display currentDisplay] renderingContextOnPrimaryScreen] currentFont] fontHandle]; + LOGFONT logFont; + + GetObject(fontHandle,sizeof(logFont),&logFont); + logFont.lfHeight=-ttMetrics->otmEMSquare; + logFont.lfWidth=0; + + fontHandle=CreateFontIndirect(&logFont); + SelectObject(dc,fontHandle); + DeleteObject(fontHandle); + + int i; + for(i=0;i #import -#import +#import #import #import #import @@ -301,7 +301,6 @@ static RECT NSRectToRECT(NSRect rect) { int dx=dstRect.origin.x-srcRect.origin.x; int dy=dstRect.origin.y-srcRect.origin.y; RECT winScrollRect=NSRectToRECT(scrollRect); - int di; ScrollDC(dc,dx,dy,&winScrollRect,&winScrollRect,NULL,NULL); } @@ -375,6 +374,7 @@ static RECT NSRectToRECT(NSRect rect) { } break; +// FIX, this is wrong case kCGPathOperatorQuadCurveToPoint:{ NSPoint cp1=points[pointIndex++]; NSPoint cp2=points[pointIndex++]; @@ -866,35 +866,14 @@ static inline void CMYKAToRGBA(float *input,float *output){ } } -// ellipse to 4 spline bezier, http://www.tinaja.com/glib/ellipse4.pdf static int appendCircle(NSPoint *cp,int position,float x,float y,float radius,CGAffineTransform matrix){ - float magic=0.551784; - float xrad=radius; - float yrad=radius; - float xmag=xrad*magic; - float ymag=yrad*magic; - - matrix=CGAffineTransformConcat(matrix,CGAffineTransformMakeTranslation(x,y)); - - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(-xrad,0),matrix); - - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(-xrad,ymag),matrix); - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(-xmag,yrad),matrix); - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(0,yrad),matrix); + int i; - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(xmag,yrad),matrix); - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(xrad,ymag),matrix); - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(xrad,0),matrix); - - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(xrad,-ymag),matrix); - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(xmag,-yrad),matrix); - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(0,-yrad),matrix); - - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(-xmag,-yrad),matrix); - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(-xrad,-ymag),matrix); - cp[position++]=CGPointApplyAffineTransform(NSMakePoint(-xrad,0),matrix); - - return position; + KGMutablePathEllipseToBezier(cp+position,x,y,radius,radius); + for(i=0;i<13;i++) + cp[position+i]=CGPointApplyAffineTransform(cp[position+i],matrix); + + return position+13; } static void appendCircleToDC(HDC dc,NSPoint *cp){ diff --git a/AppKit/Win32.subproj/Win32Cursor.m b/AppKit/Win32.subproj/Win32Cursor.m index 7e310a2f..2c5e7fdd 100755 --- a/AppKit/Win32.subproj/Win32Cursor.m +++ b/AppKit/Win32.subproj/Win32Cursor.m @@ -14,14 +14,32 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -initWithName:(NSString *)name { LPCSTR idc=NULL; - if([name isEqualToString:@"IBeam"]) - idc=IDC_IBEAM; - else if([name isEqualToString:@"Arrow"]) + if([name isEqualToString:@"arrowCursor"]) idc=IDC_ARROW; - else if([name isEqualToString:@"HorizontalResize"]) - idc=IDC_SIZENS; - else if([name isEqualToString:@"VerticalResize"]) + else if([name isEqualToString:@"closedHandCursor"]) + idc=IDC_ARROW; + else if([name isEqualToString:@"crosshairCursor"]) + idc=IDC_CROSS; + else if([name isEqualToString:@"disappearingItemCursor"]) + idc=IDC_ARROW; + else if([name isEqualToString:@"IBeamCursor"]) + idc=IDC_IBEAM; + else if([name isEqualToString:@"openHandCursor"]) + idc=IDC_ARROW; + else if([name isEqualToString:@"pointingHandCursor"]) + idc=IDC_HAND; + else if([name isEqualToString:@"resizeDownCursor"]) + idc=IDC_ARROW; + else if([name isEqualToString:@"resizeLeftCursor"]) + idc=IDC_ARROW; + else if([name isEqualToString:@"resizeLeftRightCursor"]) idc=IDC_SIZEWE; + else if([name isEqualToString:@"resizeRightCursor"]) + idc=IDC_ARROW; + else if([name isEqualToString:@"resizeUpCursor"]) + idc=IDC_ARROW; + else if([name isEqualToString:@"resizeUpDownCursor"]) + idc=IDC_SIZENS; _handle=LoadCursor(NULL,idc); return self; diff --git a/AppKit/Win32.subproj/Win32Display.m b/AppKit/Win32.subproj/Win32Display.m index c86d1a93..1cc1419b 100755 --- a/AppKit/Win32.subproj/Win32Display.m +++ b/AppKit/Win32.subproj/Win32Display.m @@ -87,14 +87,9 @@ static DWORD WINAPI runWaitCursor(LPVOID arg){ } -init { - HWND handle=CreateWindow("Win32Window","", - WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_BORDER, - 0,0,100,100, - NULL,NULL,GetModuleHandle (NULL),NULL); - [super init]; - _renderingContextOnPrimaryScreen=[[KGRenderingContext_gdi renderingContextWithWindowHWND:handle] retain]; + _renderingContextOnPrimaryScreen=[[KGRenderingContext_gdi renderingContextWithWindowHWND:NULL] retain]; _eventInputSource=[Win32EventInputSource new]; [[NSRunLoop currentRunLoop] addInputSource:_eventInputSource forMode:NSDefaultRunLoopMode]; [[NSRunLoop currentRunLoop] addInputSource:_eventInputSource forMode:NSModalPanelRunLoopMode]; @@ -311,7 +306,7 @@ NSLog(@"name=%@,size=%f",[NSString stringWithCString:fontData. elfLogFont.lfFace [self unhideCursor]; } --(id)cursorWithName:(NSString *)name { +-cursorWithName:(NSString *)name { id result=[_cursorCache objectForKey:name]; if(result==nil){ diff --git a/AppKit/Win32.subproj/Win32DraggingManager.subproj/Win32DragSession.m b/AppKit/Win32.subproj/Win32DraggingManager.subproj/Win32DragSession.m index 68583f23..8da8bcc9 100755 --- a/AppKit/Win32.subproj/Win32DraggingManager.subproj/Win32DragSession.m +++ b/AppKit/Win32.subproj/Win32DraggingManager.subproj/Win32DragSession.m @@ -84,4 +84,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI NSUnimplementedMethod(); } +-(NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)destination { + NSUnimplementedMethod(); + return nil; +} + @end diff --git a/AppKit/nib.subproj/NSWindowTemplate.m b/AppKit/nib.subproj/NSWindowTemplate.m index e49129a1..f434f261 100644 --- a/AppKit/nib.subproj/NSWindowTemplate.m +++ b/AppKit/nib.subproj/NSWindowTemplate.m @@ -36,7 +36,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI _windowRect.origin.y -= [NSMainMenuView menuHeight]; // compensation for the additional menu bar } else { - [NSException raise:NSInvalidArgumentException format:@"NSWindowTemplate can not initWithCoder:%@",[coder class]]; + [NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]]; } return self; } diff --git a/Foundation/NSAffineTransform.h b/Foundation/NSAffineTransform.h index aaecbba8..3d516972 100755 --- a/Foundation/NSAffineTransform.h +++ b/Foundation/NSAffineTransform.h @@ -17,7 +17,7 @@ typedef struct { float tY; } NSAffineTransformStruct; -@interface NSAffineTransform : NSObject { +@interface NSAffineTransform : NSObject { NSAffineTransformStruct _matrix; } diff --git a/Foundation/NSAffineTransform.m b/Foundation/NSAffineTransform.m index 7f42830d..25909f65 100755 --- a/Foundation/NSAffineTransform.m +++ b/Foundation/NSAffineTransform.m @@ -8,6 +8,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI // Original - Christopher Lloyd #import +#import #import @implementation NSAffineTransform @@ -51,6 +52,15 @@ static inline NSAffineTransformStruct invertStruct(NSAffineTransformStruct matri return self; } +-(void)encodeWithCoder:(NSCoder *)coder { + NSUnimplementedMethod(); +} + +-initWithCoder:(NSCoder *)coder { + NSUnimplementedMethod(); + return self; +} + -initWithTransform:(NSAffineTransform *)other { _matrix=[other transformStruct]; return self; diff --git a/Foundation/NSURL/NSURL.h b/Foundation/NSURL/NSURL.h index cfaae5e8..4a9f2374 100644 --- a/Foundation/NSURL/NSURL.h +++ b/Foundation/NSURL/NSURL.h @@ -9,7 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @class NSURLHandle,NSNumber,NSData; -@interface NSURL : NSObject { +@interface NSURL : NSObject { NSString *_scheme; NSString *_path; } diff --git a/Foundation/NSURL/NSURL.m b/Foundation/NSURL/NSURL.m index a3141af2..d2731956 100644 --- a/Foundation/NSURL/NSURL.m +++ b/Foundation/NSURL/NSURL.m @@ -49,6 +49,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [super dealloc]; } +-copyWithZone:(NSZone *)zone { + NSURL *copy=NSCopyObject(self,0,zone); + + copy->_scheme=[_scheme copy]; + copy->_path=[_path copy]; + + return copy; +} + -(BOOL)isEqual:other { NSURL *otherURL;