- Large number of missing AppKit constant/methods added, most of the simpler ones implemented. Cleanup and instance size changes.

- Some existing implementation updated for new methods, primarily NSDocument
- Removed legacy keyed encoding/decoding functionality in AppKit
This commit is contained in:
Christopher Lloyd 2007-11-08 15:58:54 +00:00
parent c320e2d204
commit fcda3ab7d9
135 changed files with 5698 additions and 1682 deletions

View File

@ -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 = "<group>"; };
FE57FAB50C47F2010078FFC1 /* NSPrintPanel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NSPrintPanel.h; sourceTree = "<group>"; };
FE57FAB60C47F2010078FFC1 /* NSPrintPanel.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = NSPrintPanel.m; sourceTree = "<group>"; };
FE5C6E2C0CD97D2800893B56 /* StandardAboutPanel.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = StandardAboutPanel.nib; sourceTree = "<group>"; };
FE6466E10B2C611D00B302B0 /* NSMutableParagraphStyle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NSMutableParagraphStyle.h; sourceTree = "<group>"; };
FE6466E20B2C611D00B302B0 /* NSMutableParagraphStyle.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = NSMutableParagraphStyle.m; sourceTree = "<group>"; };
FE64B8A70B81239D007EE513 /* KGColorSpace.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KGColorSpace.h; sourceTree = "<group>"; };
@ -2163,6 +2168,7 @@
FE8BAF220BC9EC680007FACA /* NSObject+BindingSupport.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BindingSupport.m"; sourceTree = "<group>"; };
FE8F9F260C9C5D0000270AEE /* KGzlib.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KGzlib.h; sourceTree = "<group>"; };
FE8F9F270C9C5D0000270AEE /* KGzlib.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = KGzlib.m; sourceTree = "<group>"; };
FEA8A98B0CD2CBC000E1E936 /* NSUserInterfaceValidation.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NSUserInterfaceValidation.h; sourceTree = "<group>"; };
FEABD5E80CB9CEE40035F828 /* KGLayer_gdi.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KGLayer_gdi.h; sourceTree = "<group>"; };
FEABD5E90CB9CEE40035F828 /* KGLayer_gdi.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = KGLayer_gdi.m; sourceTree = "<group>"; };
FEABD6030CB9D0C90035F828 /* KGContext_gdi.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KGContext_gdi.h; sourceTree = "<group>"; };
@ -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 = "<group>";
@ -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",

View File

@ -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);

View File

@ -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];
}

View File

@ -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) {

View File

@ -12,27 +12,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/CGFont.h>
#import <AppKit/CGContext.h>
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;

View File

@ -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 {

View File

@ -1,7 +1,7 @@
#import <Foundation/NSObject.h>
#import <AppKit/CGFont.h>
@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

View File

@ -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

View File

@ -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;

View File

@ -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 {

View File

@ -280,6 +280,7 @@ const char *KGImageNameWithIntent(CGColorRenderingIntent intent){
return image;
}
return nil;
}
@end

View File

@ -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 {

View File

@ -9,6 +9,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import "KGPath.h"
#import <AppKit/CGAffineTransform.h>
void KGMutablePathEllipseToBezier(NSPoint *cp,float x,float y,float xradius,float yradius);
@interface KGMutablePath : KGPath <NSCopying> {
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

View File

@ -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<count;i++)
_points[index+i]=points[i];
}
@end

View File

@ -399,6 +399,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[self contentWithString:@"Q "];
}
-(void)setCTM:(CGAffineTransform)matrix {
[super setCTM:matrix];
NSUnimplementedMethod();
}
-(void)concatCTM:(CGAffineTransform)matrix {
[super concatCTM:matrix];
[self contentWithFormat:@"%f %f %f %f %f %f cm ",matrix.a,matrix.b,matrix.c,matrix.d,matrix.tx,matrix.ty];
@ -683,7 +688,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
-(void)endPage {
KGPDFObject *ref;
KGPDFInteger pageCount=0;
[_contentStreamStack removeLastObject];

View File

@ -14,6 +14,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import "KGPDFDictionary.h"
#import "KGPDFArray.h"
#import "KGPDFString.h"
#import "KGPDFScanner.h"
#import <limits.h>

View File

@ -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);
}

View File

@ -1071,7 +1071,7 @@ BOOL KGPDFParseIndirectObject(NSData *data,KGPDFInteger position,KGPDFObject **o
NSArray *streams=[_stream streams];
int i,count=[streams count];
for(i=0;i<count & result;i++){
for(i=0;(i<count) && result;i++){
KGPDFObject *object=[streams objectAtIndex:i];
KGPDFStream *scan;

View File

@ -39,7 +39,7 @@ enum {
-(BOOL)isEqualToPath:(KGPath *)other;
-(BOOL)isEmpty;
-(BOOL)isRect;
-(BOOL)isRect:(CGRect *)rect;
-(BOOL)containsPoint:(NSPoint)point evenOdd:(BOOL)evenOdd withTransform:(CGAffineTransform *)matrix;

View File

@ -99,9 +99,33 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return _numberOfOperators==0;
}
-(BOOL)isRect {
NSUnimplementedMethod();
return NO;
-(BOOL)isRect:(CGRect *)rect {
if(_numberOfOperators!=5)
return NO;
if(_operators[0]!=kCGPathOperatorMoveToPoint)
return NO;
if(_operators[1]!=kCGPathOperatorLineToPoint)
return NO;
if(_operators[2]!=kCGPathOperatorLineToPoint)
return NO;
if(_operators[3]!=kCGPathOperatorLineToPoint)
return NO;
if(_operators[4]!=kCGPathOperatorCloseSubpath)
return NO;
if(_points[0].y!=_points[1].y)
return NO;
if(_points[1].x!=_points[2].x)
return NO;
if(_points[3].y!=_points[3].y)
return NO;
if(_points[3].x!=_points[0].x)
return NO;
rect->origin=_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.x<result.origin.x){
result.size.width=NSMaxX(result)-point.x;
result.origin.x=point.x;
}
if(point.y>NSMaxY(result))
result.size.height=point.y-NSMinY(result);
else if(point.y<result.origin.y){
result.size.height=NSMaxY(result)-point.y;
result.origin.y=point.y;
}
}
return result;
}
@end

View File

@ -112,10 +112,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
coordsCount=6;
}
[result setIntegerForKey:"ShadingType" value:type];
[result setObjectForKey:"ColorSpace" value:[_colorSpace encodeReferenceWithContext:context]];
[result setObjectForKey:"Coords" value:[KGPDFArray pdfArrayWithNumbers:coords count:coordsCount]];
[result setObjectForKey:"Domain" value:[KGPDFArray pdfArrayWithNumbers:_domain count:2]];
[result setObjectForKey:"ColorSpace" value:[_colorSpace encodeReferenceWithContext:context]];
[result setObjectForKey:"Function" value:[_function encodeReferenceWithContext:context]];
KGPDFArray *extend=[KGPDFArray pdfArray];
@ -298,7 +299,7 @@ KGShading *radialShading(KGPDFDictionary *dictionary,KGColorSpace *colorSpace){
return nil;
}
if((colorSpace=[KGColorSpace colorSpaceFromPDFObject:colorSpaceObject])==nil)
return;
return nil;
switch(shadingType){
case 1: // Function-base shading

View File

@ -88,12 +88,6 @@ static int get16(void)
return (z << 8) + get8();
}
static uint32 get32(void)
{
uint32 z = get16();
return (z << 16) + get16();
}
static void skip(int n)
{
img_buffer += n;

View File

@ -15,4 +15,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
int _tag;
}
-(NSView *)controlView;
-target;
-(SEL)action;
-(int)tag;
-(void)setControlView:(NSView *)value;
-(void)setTarget:target;
-(void)setAction:(SEL)action;
-(void)setTag:(int)tag;
@end

View File

@ -26,7 +26,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_tag=[keyed decodeIntForKey:@"NSTag"];
}
else {
_tag=[coder decodeIntForKey:@"NSActionCell tag"];
[NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]];
}
return self;
}
@ -39,22 +39,27 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return _target;
}
-(void)setTarget:target {
_target=target;
}
-(SEL)action {
return _action;
}
-(void)setAction:(SEL)action {
_action=action;
}
-(int)tag {
return _tag;
}
-(void)setControlView:(NSView *)value {
_controlView=value;
}
-(void)setTarget:target {
_target=target;
}
-(void)setAction:(SEL)action {
_action=action;
}
-(void)setTag:(int)tag {
_tag=tag;
}

View File

@ -1 +1,12 @@
#import <Foundation/NSAffineTransform.h>
@class NSBezierPath;
@interface NSAffineTransform(AppKit)
-(void)concat;
-(void)set;
-(NSBezierPath *)transformBezierPath:(NSBezierPath *)bezierPath;
@end

View File

@ -0,0 +1,44 @@
#import <AppKit/NSAffineTransform.h>
#import <AppKit/NSBezierPath.h>
#import <AppKit/CGContext.h>
#import <AppKit/NSGraphicsContext.h>
@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

View File

@ -9,6 +9,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/NSDate.h>
#import <AppKit/AppKitExport.h>
@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;
}

View File

@ -9,6 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/NSString.h>
#import <Foundation/NSRaise.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSNumber.h>
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();
}

View File

@ -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[]);

View File

@ -22,6 +22,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSPageLayout.h>
#import <AppKit/NSPlatform.h>
#import <AppKit/NSDocumentController.h>
#import <AppKit/NSImage.h>
#import <AppKit/NSSheetContext.h>
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<count;i++){
NSWindow *check=[_windows objectAtIndex:i];
if([check windowNumber]==number)
return check;
}
return nil;
}
-(NSMenu *)mainMenu {
return _mainMenu;
}
@ -84,7 +119,6 @@ id NSApp=nil;
return [self mainMenu];
}
-(NSMenu *)windowsMenu {
if(_windowsMenu==nil)
_windowsMenu=[[NSApp mainMenu] _menuWithName:@"_NSWindowsMenu"];
@ -113,8 +147,7 @@ id NSApp=nil;
}
-(NSImage *)applicationIconImage {
NSUnimplementedMethod();
return nil;
return _applicationIconImage;
}
-(BOOL)isActiveExcludingWindow:(NSWindow *)exclude {
@ -137,6 +170,41 @@ id NSApp=nil;
return [self isActiveExcludingWindow:nil];
}
-(BOOL)isHidden {
NSUnimplementedMethod();
return NO;
}
-(BOOL)isRunning {
return _isRunning;
}
-(NSWindow *)makeWindowsPerform:(SEL)selector inOrder:(BOOL)inOrder {
NSUnimplementedMethod();
return nil;
}
-(void)miniaturizeAll:sender {
int count=[_windows count];
while(--count>=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])

View File

@ -8,31 +8,103 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/Foundation.h>
#import <AppKit/AppKitExport.h>
#import <AppKit/NSStringDrawing.h>
@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

View File

@ -14,20 +14,84 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSTextAttachment.h>
#import <AppKit/NSRichTextReader.h>
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

View File

@ -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<index;i++)
pi+=numberOfPointsForOperator(operators[i]);
pcount=numberOfPointsForOperator(operators[i]);
for(i=0;i<pcount;i++,pi++)
associated[i]=points[pi];
return operators[index];
}
-(void)setLineWidth:(float)width {
@ -309,6 +339,7 @@ static NSLineJoinStyle _defaultLineJoinStyle=NSMiterLineJoinStyle;
-(NSRect)bounds {
NSUnimplementedMethod();
return NSMakeRect(0,0,0,0);
}
-(NSRect)controlPointBounds {
@ -418,18 +449,30 @@ static NSLineJoinStyle _defaultLineJoinStyle=NSMiterLineJoinStyle;
}
-(void)setAssociatedPoints:(NSPoint *)points atIndex:(int)index {
NSUnimplementedMethod();
const unsigned char *operators=[_path operators];
int i,pi=0,pcount;
if(index>=[_path numberOfOperators])
[NSException raise:NSInvalidArgumentException format:@"index (%d) >= numberOfOperators (%d)",index,[_path numberOfOperators]];
for(i=0;i<index;i++)
pi+=numberOfPointsForOperator(operators[i]);
pcount=numberOfPointsForOperator(operators[i]);
[_path setPoints:points count:pcount atIndex:pi];
}
-(NSBezierPath *)bezierPathByFlatteningPath {
NSUnimplementedMethod();
return nil;
}
-(NSBezierPath *)bezierPathByReversingPath {
NSUnimplementedMethod();
return nil;
}
-(void)stroke {
KGContext *context=[[NSGraphicsContext currentContext] graphicsPort];
@ -457,12 +500,11 @@ static NSLineJoinStyle _defaultLineJoinStyle=NSMiterLineJoinStyle;
CGContextEOFillPath(context);
}
-(void)addClip {
KGContext *context=[[NSGraphicsContext currentContext] graphicsPort];
if(CGContextIsPathEmpty(context))
CGContextBeginPath(context);
if(CGContextIsPathEmpty(context))
CGContextBeginPath(context);
CGContextAddPath(context,_path);
CGContextClip(context);
}
@ -470,10 +512,9 @@ static NSLineJoinStyle _defaultLineJoinStyle=NSMiterLineJoinStyle;
-(void)setClip {
KGContext *context=[[NSGraphicsContext currentContext] graphicsPort];
CGContextBeginPath(context);
CGContextBeginPath(context);
CGContextAddPath(context,_path);
CGContextClip(context);
}
@end

View File

@ -11,15 +11,100 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@class KGImage;
typedef enum {
NSTIFFFileType,
NSBMPFileType,
NSGIFFileType,
NSJPEGFileType,
NSPNGFileType,
NSJPEG2000FileType,
} NSBitmapImageFileType;
typedef enum {
NSTIFFCompressionNone=1,
NSTIFFCompressionCCITTFAX3=3,
NSTIFFCompressionCCITTFAX4=4,
NSTIFFCompressionLZW=5,
NSTIFFCompressionJPEG=6,
NSTIFFCompressionNEXT=32766,
NSTIFFCompressionPackBits=32773,
NSTIFFCompressionOldJPEG=32865,
} NSTIFFCompression;
typedef enum {
NSAlphaFirstBitmapFormat=0x01,
NSAlphaNonpremultipliedBitmapFormat=0x02,
NSFloatingPointSamplesBitmapFormat=0x04,
} NSBitmapFormat;
@interface NSBitmapImageRep : NSImageRep {
int _samplesPerPixel;
int _bitsPerPixel;
int _bytesPerRow;
int _numberOfPlanes;
int _bytesPerPlane;
NSBitmapFormat _bitmapFormat;
BOOL _freeWhenDone;
BOOL _isPlanar;
unsigned char **_bitmapPlanes;
NSMutableDictionary *_properties;
KGImage *_image;
}
+(void)getTIFFCompressionTypes:(const NSTIFFCompression **)types count:(int *)count;
+(NSString *)localizedNameForTIFFCompressionType:(NSTIFFCompression)type;
+(NSData *)TIFFRepresentationOfImageRepsInArray:(NSArray *)array;
+(NSData *)TIFFRepresentationOfImageRepsInArray:(NSArray *)array usingCompression:(NSTIFFCompression)compression factor:(float)factor;
+(NSData *)representationOfImageRepsInArray:(NSArray *)array usingType:(NSBitmapImageFileType)type properties:(NSDictionary *)properties;
+imageRepWithData:(NSData *)data;
-initWithBitmapDataPlanes:(unsigned char **)planes pixelsWide:(int)width pixelsHigh:(int)height bitsPerSample:(int)bitsPerSample samplesPerPixel:(int)samplesPerPixel hasAlpha:(BOOL)hasAlpha isPlanar:(BOOL)isPlanar colorSpaceName:(NSString *)colorSpaceName bitmapFormat:(NSBitmapFormat)bitmapFormat bytesPerRow:(int)bytesPerRow bitsPerPixel:(int)bitsPerPixel;
-initWithBitmapDataPlanes:(unsigned char **)planes pixelsWide:(int)width pixelsHigh:(int)height bitsPerSample:(int)bitsPerSample samplesPerPixel:(int)samplesPerPixel hasAlpha:(BOOL)hasAlpha isPlanar:(BOOL)isPlanar colorSpaceName:(NSString *)colorSpaceName bytesPerRow:(int)bytesPerRow bitsPerPixel:(int)bitsPerPixel;
-initForIncrementalLoad;
-initWithFocusedViewRect:(NSRect)rect;
-initWithData:(NSData *)data;
-initWithContentsOfFile:(NSString *)path;
+imageRepWithData:(NSData *)data;
-(int)incrementalLoadFromData:(NSData *)data complete:(BOOL)complete;
-(void)compositeToPoint:(NSPoint)point operation:(NSCompositingOperation)operation fraction:(float)fraction;
-(int)bitsPerPixel;
-(int)samplesPerPixel;
-(int)bytesPerRow;
-(BOOL)isPlanar;
-(int)numberOfPlanes;
-(int)bytesPerPlane;
-(NSBitmapFormat)bitmapFormat;
-(unsigned char *)bitmapData;
-(void)getBitmapDataPlanes:(unsigned char **)planes;
-(void)getPixel:(unsigned int[])pixel atX:(int)x y:(int)y;
-(void)setPixel:(unsigned int[])pixel atX:(int)x y:(int)y;
-(NSColor *)colorAtX:(int)x y:(int)y;
-(void)setColor:(NSColor *)color atX:(int)x y:(int)y;
-valueForProperty:(NSString *)property;
-(void)setProperty:(NSString *)property withValue:value;
-(void)colorizeByMappingGray:(float)gray toColor:(NSColor *)color blackMapping:(NSColor *)blackMapping whiteMapping:(NSColor *)whiteMapping;
-(void)getCompression:(NSTIFFCompression *)compression factor:(float *)factor;
-(void)setCompression:(NSTIFFCompression)compression factor:(float)factor;
-(BOOL)canBeCompressedUsing:(NSTIFFCompression)compression;
-(NSData *)representationUsingType:(NSBitmapImageFileType)type properties:(NSDictionary *)properties;
-(NSData *)TIFFRepresentation;
-(NSData *)TIFFRepresentationUsingCompression:(NSTIFFCompression)compression factor:(float)factor;
@end

View File

@ -27,6 +27,95 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return result;
}
+(void)getTIFFCompressionTypes:(const NSTIFFCompression **)types count:(int *)count {
NSUnimplementedMethod();
}
+(NSString *)localizedNameForTIFFCompressionType:(NSTIFFCompression)type {
NSUnimplementedMethod();
return nil;
}
+(NSData *)TIFFRepresentationOfImageRepsInArray:(NSArray *)array {
NSUnimplementedMethod();
return nil;
}
+(NSData *)TIFFRepresentationOfImageRepsInArray:(NSArray *)array usingCompression:(NSTIFFCompression)compression factor:(float)factor {
NSUnimplementedMethod();
return nil;
}
+(NSData *)representationOfImageRepsInArray:(NSArray *)array usingType:(NSBitmapImageFileType)type properties:(NSDictionary *)properties {
NSUnimplementedMethod();
return nil;
}
+imageRepWithData:(NSData *)data {
return [[[self alloc] initWithData:data] autorelease];
}
-initWithBitmapDataPlanes:(unsigned char **)planes pixelsWide:(int)width pixelsHigh:(int)height bitsPerSample:(int)bitsPerSample samplesPerPixel:(int)samplesPerPixel hasAlpha:(BOOL)hasAlpha isPlanar:(BOOL)isPlanar colorSpaceName:(NSString *)colorSpaceName bitmapFormat:(NSBitmapFormat)bitmapFormat bytesPerRow:(int)bytesPerRow bitsPerPixel:(int)bitsPerPixel {
int i,numberOfPlanes=isPlanar?1:samplesPerPixel;
_pixelsWide=width;
_pixelsHigh=height;
_bitsPerSample=bitsPerSample;
_samplesPerPixel=samplesPerPixel;
_hasAlpha=hasAlpha;
_isPlanar=isPlanar;
_colorSpaceName=[colorSpaceName copy];
_bitmapFormat=bitmapFormat;
if(bitsPerPixel!=0)
_bitsPerPixel=bitsPerPixel;
else
_bitsPerPixel=_bitsPerSample*_samplesPerPixel;
if(bytesPerRow!=0)
_bytesPerRow=bytesPerRow;
else
_bytesPerRow=(_bitsPerPixel*_pixelsWide+7)/8;
_freeWhenDone=NO;
if(planes==NULL)
_freeWhenDone=YES;
else {
int i;
for(i=0;i<numberOfPlanes;i++)
if(planes[i]!=NULL)
break;
if(i==numberOfPlanes)
_freeWhenDone=YES;
}
_bitmapPlanes=NSZoneCalloc(NULL,numberOfPlanes,sizeof(unsigned char *));
for(i=0;i<numberOfPlanes;i++){
if(!_freeWhenDone)
_bitmapPlanes[i]=planes[i];
else
_bitmapPlanes[i]=NSZoneCalloc(NULL,_bytesPerRow,1);
}
return self;
}
-initWithBitmapDataPlanes:(unsigned char **)planes pixelsWide:(int)width pixelsHigh:(int)height bitsPerSample:(int)bitsPerSample samplesPerPixel:(int)samplesPerPixel hasAlpha:(BOOL)hasAlpha isPlanar:(BOOL)isPlanar colorSpaceName:(NSString *)colorSpaceName bytesPerRow:(int)bytesPerRow bitsPerPixel:(int)bitsPerPixel {
return [self initWithBitmapDataPlanes:planes pixelsWide:width pixelsHigh:height bitsPerSample:bitsPerSample samplesPerPixel:samplesPerPixel hasAlpha:hasAlpha isPlanar:isPlanar colorSpaceName:colorSpaceName bitmapFormat:0 bytesPerRow:bytesPerRow bitsPerPixel:bitsPerPixel];
}
-initForIncrementalLoad {
NSUnimplementedMethod();
return nil;
}
-initWithFocusedViewRect:(NSRect)rect {
NSUnimplementedMethod();
return nil;
}
-initWithData:(NSData *)data {
KGImageSource *imageSource=[KGImageSource newImageSourceWithData:data options:nil];
@ -54,25 +143,118 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[super dealloc];
}
+imageRepWithData:(NSData *)data {
return [[[self alloc] initWithData:data] autorelease];
-(int)incrementalLoadFromData:(NSData *)data complete:(BOOL)complete {
NSUnimplementedMethod();
return 0;
}
-(BOOL)drawInRect:(NSRect)rect {
CGContextRef context=NSCurrentGraphicsPort();
CGContextSaveGState(context);
CGContextDrawImage(context,rect,_image);
CGContextRestoreGState(context);
-(int)bitsPerPixel {
return _bitsPerPixel;
}
-(void)compositeToPoint:(NSPoint)point operation:(NSCompositingOperation)operation fraction:(float)fraction {
-(int)samplesPerPixel {
return _samplesPerPixel;
}
-(int)bytesPerRow {
return _bytesPerRow;
}
-(BOOL)isPlanar {
return _isPlanar;
}
-(int)numberOfPlanes {
return _numberOfPlanes;
}
-(int)bytesPerPlane {
return _bytesPerPlane;
}
-(NSBitmapFormat)bitmapFormat {
return _bitmapFormat;
}
-(unsigned char *)bitmapData {
return _bitmapPlanes[0];
}
-(void)getBitmapDataPlanes:(unsigned char **)planes {
int i,numberOfPlanes=_isPlanar?1:_samplesPerPixel;
for(i=0;i<numberOfPlanes;i++)
planes[i]=_bitmapPlanes[i];
for(;i<5;i++)
planes[i]=NULL;
}
-(void)getPixel:(unsigned int[])pixel atX:(int)x y:(int)y {
NSUnimplementedMethod();
}
-(void)setPixel:(unsigned int[])pixel atX:(int)x y:(int)y {
NSUnimplementedMethod();
}
-(NSColor *)colorAtX:(int)x y:(int)y {
NSUnimplementedMethod();
return nil;
}
-(void)setColor:(NSColor *)color atX:(int)x y:(int)y {
NSUnimplementedMethod();
}
-valueForProperty:(NSString *)property {
return [_properties objectForKey:property];
}
-(void)setProperty:(NSString *)property withValue:value {
[_properties setObject:value forKey:property];
}
-(void)colorizeByMappingGray:(float)gray toColor:(NSColor *)color blackMapping:(NSColor *)blackMapping whiteMapping:(NSColor *)whiteMapping {
NSUnimplementedMethod();
}
-(void)getCompression:(NSTIFFCompression *)compression factor:(float *)factor {
NSUnimplementedMethod();
}
-(void)setCompression:(NSTIFFCompression)compression factor:(float)factor {
NSUnimplementedMethod();
}
-(BOOL)canBeCompressedUsing:(NSTIFFCompression)compression {
NSUnimplementedMethod();
return NO;
}
-(NSData *)representationUsingType:(NSBitmapImageFileType)type properties:(NSDictionary *)properties {
NSUnimplementedMethod();
return nil;
}
-(NSData *)TIFFRepresentation {
NSUnimplementedMethod();
return nil;
}
-(NSData *)TIFFRepresentationUsingCompression:(NSTIFFCompression)compression factor:(float)factor {
NSUnimplementedMethod();
return nil;
}
-(BOOL)draw {
CGContextRef context=NSCurrentGraphicsPort();
NSSize size=[self size];
CGContextSaveGState(context);
CGContextSetAlpha(context,fraction);
CGContextDrawImage(context,NSMakeRect(point.x,point.y,_size.width,_size.height),_image);
CGContextRestoreGState(context);
CGContextDrawImage(context,NSMakeRect(0,0,size.width,size.height),_image);
return YES;
}
@end

View File

@ -17,25 +17,46 @@ typedef enum {
NSBelowTop,
NSAboveBottom,
NSAtBottom,
NSBelowBottom
NSBelowBottom,
} NSTitlePosition;
typedef enum {
NSBoxPrimary,
NSBoxSecondary,
NSBoxSeparator,
NSBoxOldStyle,
} NSBoxType;
@interface NSBox : NSView {
id _titleCell;
int _borderType;
int _titlePosition;
NSSize _contentViewMargins;
NSBoxType _boxType;
NSBorderType _borderType;
NSTitlePosition _titlePosition;
id _titleCell;
NSSize _contentViewMargins;
}
-contentView;
-(NSBoxType)boxType;
-(NSBorderType)borderType;
-(NSString *)title;
-(NSFont *)titleFont;
-(NSRect)titleRect;
-contentView;
-(NSSize)contentViewMargins;
-(NSTitlePosition)titlePosition;
-(void)setContentView:(NSView *)view;
-(void)setBoxType:(NSBoxType)value;
-(void)setBorderType:(NSBorderType)value;
-(void)setTitle:(NSString *)title;
-(void)setTitleFont:(NSFont *)font;
-(void)setContentView:(NSView *)view;
-(void)setContentViewMargins:(NSSize)value;
-(void)setTitlePosition:(NSTitlePosition)value;
-(void)setTitleWithMnemonic:(NSString *)value;
-(NSRect)titleRect;
-(NSRect)borderRect;
-titleCell;
-(void)setFrameFromContentFrame:(NSRect)content;
-(void)sizeToFit;
@end

View File

@ -44,10 +44,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[[_subviews lastObject] setAutoresizesSubviews:YES];
}
else {
_borderType=[coder decodeIntForKey:@"NSBox borderType"];
_titlePosition=[coder decodeIntForKey:@"NSBox titlePosition"];
_contentViewMargins=[coder decodeSizeForKey:@"NSBox contentViewMargins"];
_titleCell=[[coder decodeObjectForKey:@"NSBox titleCell"] retain];
[NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]];
}
return self;
}
@ -57,20 +54,42 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[super dealloc];
}
-contentView {
return [[self subviews] lastObject];
-(NSBoxType)boxType {
return _boxType;
}
-(NSBorderType)borderType {
return _borderType;
}
-(NSString *)title {
return [_titleCell stringValue];
}
-(void)setContentView:(NSView *)view {
if(![[self subviews] containsObject:view]){
[[self subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
// FIX, adjust size
[self addSubview:view];
}
-(NSFont *)titleFont {
return [_titleCell font];
}
-contentView {
return [[self subviews] lastObject];
}
-(NSSize)contentViewMargins {
return _contentViewMargins;
}
-(NSTitlePosition)titlePosition {
return _titlePosition;
}
-(void)setBoxType:(NSBoxType)value {
_boxType=value;
[self setNeedsDisplay:YES];
}
-(void)setBorderType:(NSBorderType)value {
_borderType=value;
[self setNeedsDisplay:YES];
}
-(void)setTitle:(NSString *)title {
@ -82,7 +101,29 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[_titleCell setFont:font];
}
-(NSAttributedString *)attributedTitle {
-(void)setContentView:(NSView *)view {
if(![[self subviews] containsObject:view]){
[[self subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
// FIX, adjust size
[self addSubview:view];
}
}
-(void)setContentViewMargins:(NSSize)value {
_contentViewMargins=value;
[self setNeedsDisplay:YES];
}
-(void)setTitlePosition:(NSTitlePosition)value {
_titlePosition=value;
[self setNeedsDisplay:YES];
}
-(void)setTitleWithMnemonic:(NSString *)value {
NSUnimplementedMethod();
}
-(NSAttributedString *)_attributedTitle {
NSMutableDictionary *attributes=[NSMutableDictionary dictionary];
NSMutableParagraphStyle *paraStyle=[[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
NSFont *font=[_titleCell font];
@ -105,16 +146,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#define TEXTGAP 4
-(BOOL)isOpaque {
return YES;
}
-(NSFont *)titleFont {
return [_titleCell font];
}
-(NSRect)titleRect {
NSAttributedString *title=[self attributedTitle];
NSAttributedString *title=[self _attributedTitle];
NSSize size=[title size];
NSRect bounds=[self bounds];
NSRect result=NSZeroRect;
@ -155,9 +188,31 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return result;
}
-(NSRect)borderRect {
NSUnimplementedMethod();
return NSMakeRect(0,0,0,0);
}
-titleCell {
return _titleCell;
}
-(void)setFrameFromContentFrame:(NSRect)content {
// FIX, adjust content frame size to accomodate border/title
[self setFrame:content];
}
-(void)sizeToFit {
NSUnimplementedMethod();
}
-(BOOL)isOpaque {
return YES;
}
-(void)drawRect:(NSRect)rect {
NSAttributedString *title=[self attributedTitle];
NSAttributedString *title=[self _attributedTitle];
NSRect grooveRect=_bounds;
NSRect titleRect=[self titleRect];
BOOL drawTitle=YES;
@ -225,9 +280,4 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
}
-(void)setFrameFromContentFrame:(NSRect)content {
// FIX, adjust content frame size to accomodate border/title
[self setFrame:content];
}
@end

View File

@ -9,6 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSCell.h>
@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

View File

@ -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;

View File

@ -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;
}

View File

@ -9,18 +9,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSImageRep.h>
#import <AppKit/NSWindow.h>
@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

View File

@ -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};

View File

@ -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 <AppKit/NSText.h>
#import <AppKit/NSGraphics.h>
@class NSFont,NSImage,NSView;

View File

@ -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]])

View File

@ -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

View File

@ -12,6 +12,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSGraphics.h>
#import <AppKit/NSScrollView.h>
#import <AppKit/NSEvent.h>
#import <AppKit/NSCursor.h>
#import <AppKit/NSNibKeyedUnarchiver.h>
@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

View File

@ -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;
}
}

View File

@ -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 // <NSCoding>
{
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;

View File

@ -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];
}

View File

@ -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

View File

@ -17,6 +17,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSDragging.h>
#import <AppKit/NSNibKeyedUnarchiver.h>
#import <AppKit/NSGraphicsStyle.h>
#import <AppKit/NSController.h>
#import <Foundation/NSKeyValueObserving.h>
@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])

View File

@ -8,18 +8,59 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSTextField.h>
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

View File

@ -12,8 +12,100 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSApplication.h>
#import <AppKit/NSTextView.h>
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 {

View File

@ -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 <NSCoding> {
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;

View File

@ -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

View File

@ -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;

View File

@ -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];
}

View File

@ -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 <Foundation/Foundation.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSGeometry.h>
@interface NSCursor : NSObject {
@class NSImage,NSColor,NSEvent;
@interface NSCursor : NSObject <NSCoding> {
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;

View File

@ -9,32 +9,27 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// Original - Christopher Lloyd <cjwl@objc.net>
#import <AppKit/NSCursor.h>
#import <AppKit/NSDisplay.h>
#import <AppKit/NSImage.h>
#import <Foundation/NSNull.h>
@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];
}

View File

@ -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 {

View File

@ -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 <Foundation/Foundation.h>
#import <AppKit/NSUserInterfaceValidation.h>
@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 <NSValidatedUserInterfaceItem>)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

File diff suppressed because it is too large Load Diff

View File

@ -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 <Foundation/Foundation.h>
#import <AppKit/NSUserInterfaceValidation.h>
@class NSDocument,NSOpenPanel;
@class NSDocument,NSOpenPanel,NSWindow,NSMenuItem;
@interface NSDocumentController : NSObject {
@interface NSDocumentController : NSObject <NSCoding> {
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 <NSValidatedUserInterfaceItem>)item;
// deprecated
-(BOOL)closeAllDocuments;
-(BOOL)reviewUnsavedDocumentsWithAlertTitle:(NSString *)title cancellable:(BOOL)cancellable;
@end

View File

@ -13,6 +13,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSMenu.h>
#import <AppKit/NSMenuItem.h>
#import <AppKit/NSApplication.h>
#import <AppKit/NSWindowController.h>
@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<count;i++){
NSDocument *document=[_documents objectAtIndex:i];
NSURL *check=[document fileURL];
if(check!=nil && [check isEqual:url])
return document;
}
return nil;
}
-makeDocumentWithContentsOfFile:(NSString *)path ofType:(NSString *)type {
id result;
Class class=[self documentClassForType:type];
result=[[[class alloc] initWithContentsOfFile:path ofType:type] autorelease];
[result setFileType:type];
return result;
}
-makeDocumentWithContentsOfURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error {
id result;
Class class=[self documentClassForType:type];
result=[[[class alloc] initWithContentsOfURL:url ofType:type] autorelease];
[result setFileType:type];
return result;
}
-makeUntitledDocumentOfType:(NSString *)type {
static int nextUntitledNumber=1;
id result;
Class class=[self documentClassForType:type];
result=[[[class alloc] init] autorelease];
[result setFileType:type];
[result _setUntitledNumber:nextUntitledNumber++];
return result;
}
-openUntitledDocumentOfType:(NSString *)type display:(BOOL)display {
NSDocument *result=[self makeUntitledDocumentOfType:type];
if(result!=nil)
[self addDocument:result];
[result makeWindowControllers];
if(display)
[result showWindows];
return result;
}
-openDocumentWithContentsOfFile:(NSString *)path display:(BOOL)display {
NSString *extension=[path pathExtension];
NSString *type=[self typeFromFileExtension:extension];
NSDocument *result=[self makeDocumentWithContentsOfFile:path ofType:type];
if(result!=nil)
[self addDocument:result];
[result makeWindowControllers];
if(display)
[result showWindows];
[self noteNewRecentDocument:result];
return result;
}
-openDocumentWithContentsOfURL:(NSURL *)url display:(BOOL)display error:(NSError **)error {
IMP mine=[NSDocumentController instanceMethodForSelector:@selector(openDocumentWithContentsOfFile:display:)];
IMP theirs=[self methodForSelector:@selector(openDocumentWithContentsOfFile:display:)];
if([url isFileURL] && mine!=theirs)
return [self openDocumentWithContentsOfFile:[url path] display:display];
else {
NSDocument *result=[self documentForURL:url];
if(result==nil){
NSString *extension=[[url path] pathExtension];
NSString *type=[self typeFromFileExtension:extension];
result=[self makeDocumentWithContentsOfURL:url ofType:type error:error];
if(result!=nil){
[self addDocument:result];
[result makeWindowControllers];
[self noteNewRecentDocument:result];
}
}
if(display)
[result showWindows];
return result;
}
}
-(NSString *)currentDirectory {
-initWithCoder:(NSCoder *)coder {
NSUnimplementedMethod();
return nil;
}
-(id)currentDocument {
-(void)encodeWithCoder:(NSCoder *)coder {
NSUnimplementedMethod();
return nil;
}
-(NSString *)defaultType {
if([_fileTypes count]==0)
return nil;
return [(NSDictionary *)[_fileTypes objectAtIndex:0] objectForKey:@"CFBundleTypeName"];
}
-(NSArray *)documentClassNames {
NSMutableSet *result=[NSMutableSet set];
int i,count=[_fileTypes count];
for(i=0;i<count;i++)
[result addObject:[(NSDictionary *)[_fileTypes objectAtIndex:i] objectForKey:@"NSDocumentClass"]];
return [result allObjects];
}
-(NSTimeInterval)autosavingDelay {
return _autosavingDelay;
}
-(NSDictionary *)_infoForType:(NSString *)type {
@ -228,41 +137,251 @@ static NSDocumentController *shared=nil;
return nil;
}
-(void)setAutosavingDelay:(NSTimeInterval)value {
_autosavingDelay=value;
NSUnimplementedMethod();
}
-(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<count;i++){
NSDocument *document=[_documents objectAtIndex:i];
NSURL *check=[document fileURL];
if(check!=nil && [check isEqual:url])
return document;
}
return nil;
}
-currentDocument {
return [[[NSApp mainWindow] windowController] document];
}
-(NSString *)currentDirectory {
NSDocument *current=[self currentDocument];
NSURL *url=[current fileURL];
if(url!=nil && [url isFileURL]){
NSString *check=[[url path] stringByDeletingLastPathComponent];
BOOL isDirectory;
if([[NSFileManager defaultManager] fileExistsAtPath:check isDirectory:&isDirectory])
if(isDirectory)
return check;
}
if(_lastOpenPanelDirectory!=nil)
return _lastOpenPanelDirectory;
return NSHomeDirectory();
}
-(BOOL)hasEditedDocuments {
int count=[_documents count];
while(--count)
if([[_documents objectAtIndex:count] isDocumentEdited])
return YES;
return NO;
}
-documentForWindow:(NSWindow *)window {
return [[window windowController] document];
}
-(NSString *)typeForContentsOfURL:(NSURL *)url error:(NSError **)error {
if(![url isFileURL])
return nil;
NSString *extension=[[url path] lastPathComponent];
if(extension==nil)
return nil;
return [self typeFromFileExtension:extension];
}
-makeDocumentWithContentsOfFile:(NSString *)path ofType:(NSString *)type {
id result;
Class class=[self documentClassForType:type];
result=[[[class alloc] initWithContentsOfFile:path ofType:type] autorelease];
return result;
}
-makeDocumentWithContentsOfURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error {
id result;
Class class=[self documentClassForType:type];
result=[[[class alloc] initWithContentsOfURL:url ofType:type] autorelease];
return result;
}
-makeDocumentForURL:(NSURL *)url withContentsOfURL:(NSURL *)contentsURL ofType:(NSString *)type error:(NSError **)error {
id result;
Class class=[self documentClassForType:type];
result=[[[class alloc] initForURL:url withContentsOfURL:contentsURL ofType:type error:error] autorelease];
return result;
}
-makeUntitledDocumentOfType:(NSString *)type {
static int nextUntitledNumber=1;
id result;
Class class=[self documentClassForType:type];
result=[[[class alloc] init] autorelease];
[result setFileType:type];
[result _setUntitledNumber:nextUntitledNumber++];
return result;
}
-openUntitledDocumentOfType:(NSString *)type display:(BOOL)display {
NSDocument *result=[self makeUntitledDocumentOfType:type];
if(result!=nil)
[self addDocument:result];
[result makeWindowControllers];
if(display)
[result showWindows];
return result;
}
-openUntitledDocumentAndDisplay:(BOOL)display error:(NSError **)error {
NSString *type=[self defaultType];
NSDocument *result=[self makeUntitledDocumentOfType:type];
if(result!=nil)
[self addDocument:result];
[result makeWindowControllers];
if(display)
[result showWindows];
return result;
}
-openDocumentWithContentsOfFile:(NSString *)path display:(BOOL)display {
NSString *extension=[path pathExtension];
NSString *type=[self typeFromFileExtension:extension];
NSDocument *result=[self makeDocumentWithContentsOfFile:path ofType:type];
if(result!=nil)
[self addDocument:result];
[result makeWindowControllers];
if(display)
[result showWindows];
[self noteNewRecentDocument:result];
return result;
}
-openDocumentWithContentsOfURL:(NSURL *)url display:(BOOL)display error:(NSError **)error {
IMP mine=[NSDocumentController instanceMethodForSelector:@selector(openDocumentWithContentsOfFile:display:)];
IMP theirs=[self methodForSelector:@selector(openDocumentWithContentsOfFile:display:)];
if([url isFileURL] && mine!=theirs)
return [self openDocumentWithContentsOfFile:[url path] display:display];
else {
NSDocument *result=[self documentForURL:url];
if(result==nil){
NSString *extension=[[url path] pathExtension];
NSString *type=[self typeFromFileExtension:extension];
result=[self makeDocumentWithContentsOfURL:url ofType:type error:error];
if(result!=nil){
[self addDocument:result];
[result makeWindowControllers];
[self noteNewRecentDocument:result];
}
}
if(display)
[result showWindows];
return result;
}
}
-(BOOL)reopenDocumentForURL:(NSURL *)url withContentsOfURL:(NSURL *)contentsUL error:(NSError **)error {
NSUnimplementedMethod();
return 0;
}
-(void)closeAllDocumentsWithDelegate:delegate didCloseAllSelector:(SEL)selector info:(void *)info {
NSUnimplementedMethod();
}
-(void)reviewUnsavedDocumentsWithAlertTitle:(NSString *)title cancellable:(BOOL)cancellable delegate:delegate didReviewAllSelector:(SEL)selector info:(void *)info {
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 info:(void *)info {
NSUnimplementedMethod();
}
-(int)runModalOpenPanel:(NSOpenPanel *)openPanel forTypes:(NSArray *)extensions {
return [openPanel runModalForTypes:extensions];
}
-(NSArray *)fileNamesFromRunningOpenPanel {
-(NSOpenPanel *)_runOpenPanel {
NSOpenPanel *openPanel=[NSOpenPanel openPanel];
[openPanel setAllowsMultipleSelection:YES];
if([self runModalOpenPanel:openPanel forTypes:[self _allFileExtensions]])
return [openPanel filenames];
if([self runModalOpenPanel:openPanel forTypes:[self _allFileExtensions]]){
[_lastOpenPanelDirectory autorelease];
_lastOpenPanelDirectory=[[openPanel directory] copy];
return openPanel;
}
return nil;
}
-(void)newDocument:sender {
NSString *type=[(NSDictionary *)[_fileTypes objectAtIndex:0] objectForKey:@"CFBundleTypeName"];
[self openUntitledDocumentOfType:type display:YES];
-(NSArray *)fileNamesFromRunningOpenPanel {
return [[self _runOpenPanel] filenames];
}
-(void)openDocument:sender {
NSArray *files=[self fileNamesFromRunningOpenPanel];
int i,count=[files count];
for(i=0;i<count;i++){
NSError *error=nil;
NSURL *url=[NSURL fileURLWithPath:[files objectAtIndex:i]];
[self openDocumentWithContentsOfURL:url display:YES error:&error];
}
}
-(void)saveAllDocuments:sender {
-(NSArray *)URLsFromRunningOpenPanel {
return [[self _runOpenPanel] URLs];
}
-(NSArray *)_recentDocumentPaths {
@ -332,6 +451,12 @@ static NSDocumentController *shared=nil;
return result;
}
-(unsigned)maximumRecentDocumentCount {
NSString *value=[[NSUserDefaults standardUserDefaults] stringForKey:@"NSRecentDocumentMaximum"];
return (value==nil)?10:[value intValue];
}
-(void)noteNewRecentDocumentURL:(NSURL *)url {
NSString *path=[url path];
NSMutableArray *array=[NSMutableArray arrayWithArray:[self _recentDocumentPaths]];
@ -353,12 +478,6 @@ static NSDocumentController *shared=nil;
[self noteNewRecentDocumentURL:url];
}
-(unsigned)maximumRecentDocumentCount {
NSString *value=[[NSUserDefaults standardUserDefaults] stringForKey:@"NSRecentDocumentMaximum"];
return (value==nil)?10:[value intValue];
}
-(void)clearRecentDocuments:sender {
NSArray *array=[NSArray array];
@ -366,6 +485,58 @@ static NSDocumentController *shared=nil;
[self _updateRecentDocumentsMenu];
}
-(void)newDocument:sender {
NSString *type=[(NSDictionary *)[_fileTypes objectAtIndex:0] objectForKey:@"CFBundleTypeName"];
[self openUntitledDocumentOfType:type display:YES];
}
-(void)openDocument:sender {
NSArray *files=[self fileNamesFromRunningOpenPanel];
int i,count=[files count];
for(i=0;i<count;i++){
NSError *error=nil;
NSURL *url=[NSURL fileURLWithPath:[files objectAtIndex:i]];
[self openDocumentWithContentsOfURL:url display:YES error:&error];
}
}
-(void)saveAllDocuments:sender {
int i,count=[_documents count];
while(--count>=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 <NSValidatedUserInterfaceItem>)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

View File

@ -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 <NSDraggingInfo>)sender;
-(void)draggingExited:(id <NSDraggingInfo>)sender;
-(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)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

View File

@ -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 <Foundation/Foundation.h>
@interface NSEPSImageRep : NSObject {
#import <AppKit/NSImageRep.h>
@interface NSEPSImageRep : NSImageRep {
NSData *_data;
}
+imageRepWithData:(NSData *)data;
-initWithData:(NSData *)data;
-(NSData *)EPSRepresentation;
-(NSRect)boundingBox;
-(void)prepareGState;
@end

View File

@ -8,7 +8,42 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// Original - Christopher Lloyd <cjwl@objc.net>
#import <AppKit/NSEPSImageRep.h>
#import <Foundation/NSData.h>
#import <Foundation/NSRaise.h>
@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

View File

@ -8,36 +8,49 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/Foundation.h>
#import <AppKit/CoreGraphics.h>
#import <AppKit/NSCell.h>
@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 <NSCopying> {
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

View File

@ -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<count;i++)
cgGlyphs[i]=glyphs[i];
[_kgFont getAdvancements:advancements forGlyphs:cgGlyphs count:count];
}
-(void)getAdvancements:(NSSize *)advancements forPackedGlyphs:(const void *)packed length:(unsigned)length {
[_kgFont getAdvancements:advancements forGlyphs:packed count:length];
}
-(void)getBoundingRects:(NSRect *)rects forGlyphs:(const NSGlyph *)glyphs count:(unsigned)count {
NSUnimplementedMethod();
}
-(unsigned)getGlyphs:(NSGlyph *)glyphs forCharacters:(unichar *)characters length:(unsigned)length {
CGGlyph cgGlyphs[length];
int i;
@ -281,18 +403,10 @@ FOUNDATION_EXPORT char *NSUnicodeToSymbol(const unichar *characters,unsigned len
return length;
}
-(void)getAdvancements:(NSSize *)advancements forGlyphs:(const NSGlyph *)glyphs count:(unsigned)count {
CGGlyph cgGlyphs[count];
int i;
for(i=0;i<count;i++)
cgGlyphs[i]=glyphs[i];
[_kgFont getAdvancements:advancements forGlyphs:cgGlyphs count:count];
-(NSString *)description {
return [NSString stringWithFormat:@"<%@ %@ %f>",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

View File

@ -9,7 +9,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// Original - Christopher Lloyd <cjwl@objc.net>
#import <AppKit/NSFontFamily.h>
#import <AppKit/NSFontTypeface.h>
#import <AppKit/NSFontMetric.h>
#import <AppKit/NSGraphicsContext.h>
#import <AppKit/NSDisplay.h>

View File

@ -8,8 +8,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/Foundation.h>
@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

View File

@ -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;i<count;i++){
NSMenuItem *item=[items objectAtIndex:i];
if([item hasSubmenu])
[self _configureMenu:[item submenu] forFont:font];
else if([item action]==@selector(addFontTrait:) && [item target]==self){
unsigned tag=[item tag];
NSFontTraitMask traits=[self traitsOfFont:font];
if(tag&(NSItalicFontMask|NSUnitalicFontMask)){
if(traits&NSItalicFontMask){
[item setTag:NSUnitalicFontMask];
[item setTitle:@"Unitalic"];
}
else {
[item setTag:NSItalicFontMask];
[item setTitle:@"Italic"];
}
}
if(tag&(NSBoldFontMask|NSUnboldFontMask)){
if(traits& NSBoldFontMask){
[item setTag:NSUnboldFontMask];
[item setTitle:@"Unbold"];
}
else {
[item setTag:NSBoldFontMask];
[item setTitle:@"Bold"];
}
}
}
}
-(BOOL)removeCollection:(NSString *)name {
NSUnimplementedMethod();
return 0;
}
-(void)setSelectedFont:(NSFont *)font isMultiple:(BOOL)flag {
[_selectedFont autorelease];
_selectedFont=[font retain];
_isMultiple=flag;
[[self fontPanel:NO] setPanelFont:font isMultiple:flag];
[self _configureMenu:[NSApp mainMenu] forFont:font];
}
-(void)setDelegate:delegate {
_delegate=delegate;
-(NSArray *)fontDescriptorsInCollection:(NSString *)name {
NSUnimplementedMethod();
return nil;
}
-(NSArray *)availableFonts {
@ -229,15 +156,259 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return result;
}
-(NSArray *)availableFontNamesMatchingFontDescriptor:(NSFontDescriptor *)descriptor {
NSUnimplementedMethod();
return nil;
}
-(NSArray *)availableFontNamesWithTraits:(NSFontTraitMask)traits {
NSUnimplementedMethod();
return nil;
}
-(BOOL)fontNamed:(NSString *)name hasTraits:(NSFontTraitMask)traits {
NSUnimplementedMethod();
return 0;
}
-(NSFont *)fontWithFamily:(NSString *)family traits:(NSFontTraitMask)traits weight:(int)weight size:(float)size {
NSUnimplementedMethod();
return nil;
}
-(int)weightOfFont:(NSFont *)font {
NSUnimplementedMethod();
return 0;
}
-(NSFontTraitMask)traitsOfFont:(NSFont *)font {
NSFontTypeface *typeface=[NSFontFamily fontTypefaceWithName:[font fontName]];
return [typeface traits];
}
-(NSString *)localizedNameForFamily:(NSString *)family face:(NSString *)face {
NSUnimplementedMethod();
return 0;
}
-(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;
}
-(BOOL)sendAction {
return [NSApp sendAction:_action to:nil from:[NSFontManager sharedFontManager]];
}
-(BOOL)isEnabled {
NSUnimplementedMethod();
return 0;
}
-(BOOL)isMultiple {
return _isMultiple;
}
-(NSFont *)selectedFont {
return _selectedFont;
}
-(void)_configureMenu:(NSMenu *)menu forFont:(NSFont *)font {
NSArray *items=[menu itemArray];
int i,count=[items count];
for(i=0;i<count;i++){
NSMenuItem *item=[items objectAtIndex:i];
if([item hasSubmenu])
[self _configureMenu:[item submenu] forFont:font];
else if([item action]==@selector(addFontTrait:) && [item target]==self){
unsigned tag=[item tag];
NSFontTraitMask traits=[self traitsOfFont:font];
if(tag&(NSItalicFontMask|NSUnitalicFontMask)){
if(traits&NSItalicFontMask){
[item setTag:NSUnitalicFontMask];
[item setTitle:@"Unitalic"];
}
else {
[item setTag:NSItalicFontMask];
[item setTitle:@"Italic"];
}
}
if(tag&(NSBoldFontMask|NSUnboldFontMask)){
if(traits& NSBoldFontMask){
[item setTag:NSUnboldFontMask];
[item setTitle:@"Unbold"];
}
else {
[item setTag:NSBoldFontMask];
[item setTitle:@"Bold"];
}
}
}
}
}
-(void)setSelectedFont:(NSFont *)font isMultiple:(BOOL)flag {
[_selectedFont autorelease];
_selectedFont=[font retain];
_isMultiple=flag;
[[self fontPanel:NO] setPanelFont:font isMultiple:flag];
[self _configureMenu:[NSApp mainMenu] forFont:font];
}
-(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);
NSUnimplementedMethod();
return font;
}
-(NSFont *)convertFont:(NSFont *)font toNotHaveTrait:(NSFontTraitMask)trait {
NSUnimplementedMethod();
return nil;
}
-(NSFont *)convertFont:(NSFont *)font toFace:(NSString *)typeface {
NSUnimplementedMethod();
return nil;
}
-(NSFont *)convertFont:(NSFont *)font toFamily:(NSString *)family {
NSUnimplementedMethod();
return nil;
}
-(NSFont *)convertWeight:(BOOL)heavierNotLighter ofFont:(NSFont *)font {
NSUnimplementedMethod();
return nil;
}
-(NSDictionary *)convertAttributes:(NSDictionary *)attributes {
NSUnimplementedMethod();
return nil;
}
-(void)addFontTrait:sender {
NSFont *font=[self convertFont:[self selectedFont] toHaveTrait:[sender tag]];
[self setSelectedFont:font isMultiple:NO];
[NSApp sendAction:@selector(changeFont:) to:nil from:[NSFontManager sharedFontManager]];
[self sendAction];
}
-(void)modifyFont:sender {
NSFont *font=[self selectedFont];
_currentFontAction=[sender tag];
switch(_currentFontAction){
case NSNoFontChangeAction:
break;
case NSViaPanelFontAction:
font=[_panel panelConvertFont:font];
break;
case NSAddTraitFontAction:
NSUnimplementedMethod();
font=[self convertFont:font toHaveTrait:0];
break;
case NSSizeUpFontAction:
font=[self convertFont:font toSize:[font pointSize]+1];
break;
case NSSizeDownFontAction:{
float ps=[font pointSize];
if(ps>1)
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

View File

@ -8,7 +8,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSPanel.h>
@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

View File

@ -15,6 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSFont.h>
#import <AppKit/NSTextField.h>
#import <AppKit/NSApplication.h>
#import <AppKit/NSButton.h>
#import <AppKit/NSFontFamily.h>
#import <AppKit/NSFontTypeface.h>
@ -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

View File

@ -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

View File

@ -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];

View File

@ -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<numberOfCharacters && characterIndex<length;){
@ -50,7 +50,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
characterIndex+=chunkSize;
glyphIndex+=chunkSize;
i+chunkSize;
i+=chunkSize;
}
*glyphIndexp=glyphIndex;
*characterIndexp=characterIndex;

View File

@ -34,6 +34,18 @@ typedef enum {
NSWindowAbove=1
} NSWindowOrderingMode;
typedef enum {
NSFocusRingOnly,
NSFocusRingBelow,
NSFocusRingAbove
} NSFocusRingPlacement;
typedef enum {
NSFocusRingTypeDefault,
NSFocusRingTypeNone,
NSFocusRingTypeExterior
} NSFocusRingType;
typedef int NSWindowDepth;
APPKIT_EXPORT const float NSBlack;
@ -50,6 +62,13 @@ APPKIT_EXPORT NSString *NSCalibratedWhiteColorSpace;
APPKIT_EXPORT NSString *NSCalibratedRGBColorSpace;
APPKIT_EXPORT NSString *NSNamedColorSpace;
APPKIT_EXPORT NSString *NSDeviceIsScreen;
APPKIT_EXPORT NSString *NSDeviceIsPrinter;
APPKIT_EXPORT NSString *NSDeviceSize;
APPKIT_EXPORT NSString *NSDeviceResolution;
APPKIT_EXPORT NSString *NSDeviceColorSpaceName;
APPKIT_EXPORT NSString *NSDeviceBitsPerSample;
APPKIT_EXPORT void NSRectClipList(const NSRect *rects,int count);
APPKIT_EXPORT void NSRectClip(NSRect rect);
@ -58,7 +77,8 @@ APPKIT_EXPORT void NSRectFillListWithGrays(const NSRect *rects,const float *gray
APPKIT_EXPORT void NSRectFillList(const NSRect *rects,int count);
APPKIT_EXPORT void NSRectFill(NSRect rect);
APPKIT_EXPORT void NSRectFillUsingOperation(NSRect rect,NSCompositingOperation op);
APPKIT_EXPORT void NSRectFillListUsingOperation(const NSRect *rects,int count,NSCompositingOperation operation);
APPKIT_EXPORT void NSRectFillUsingOperation(NSRect rect,NSCompositingOperation operation);
APPKIT_EXPORT void NSFrameRectWithWidth(NSRect rect,float width);
APPKIT_EXPORT void NSFrameRect(NSRect rect);

View File

@ -29,6 +29,13 @@ NSString *NSCalibratedWhiteColorSpace=@"NSCalibratedWhiteColorSpace";
NSString *NSCalibratedRGBColorSpace=@"NSCalibratedRGBColorSpace";
NSString *NSNamedColorSpace=@"NSNamedColorSpace";
NSString *NSDeviceIsScreen=@"NSDeviceIsScreen";
NSString *NSDeviceIsPrinter=@"NSDeviceIsPrinter";
NSString *NSDeviceSize=@"NSDeviceSize";
NSString *NSDeviceResolution=@"NSDeviceResolution";
NSString *NSDeviceColorSpaceName=@"NSDeviceColorSpaceName";
NSString *NSDeviceBitsPerSample=@"NSDeviceBitsPerSample";
void NSRectClipList(const NSRect *rects, int count) {
CGContextRef graphicsPort=NSCurrentGraphicsPort();

View File

@ -7,44 +7,111 @@ 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 <AppKit/NSGraphics.h>
#import <AppKit/NSBitmapImageRep.h>
@class NSImageRep;
typedef enum {
NSImageCacheDefault,
NSImageCacheAlways,
NSImageCacheBySize,
NSImageCacheNever,
} NSImageCacheMode;
@interface NSImage : NSObject <NSCopying> {
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

View File

@ -11,12 +11,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSImageRep.h>
#import <AppKit/NSBitmapImageRep.h>
#import <AppKit/NSCachedImageRep.h>
#import <AppKit/NSPasteboard.h>
#import <AppKit/NSColor.h>
#import <AppKit/NSGraphicsContextFunctions.h>
#import <AppKit/NSNibKeyedUnarchiver.h>
@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<count;i++)
[result addObjectsFromArray:[[allClasses objectAtIndex:i] imageUnfilteredPasteboardTypes]];
return result;
}
+(BOOL)canInitWithPasteboard:(NSPasteboard *)pasteboard {
NSString *available=[pasteboard availableTypeFromArray:[self imageUnfilteredPasteboardTypes]];
return (available!=nil)?YES:NO;
}
+(NSArray *)_checkBundles {
return [NSArray arrayWithObjects:
[NSBundle bundleForClass:self],
[NSBundle mainBundle],
@ -53,7 +76,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
NSImage *image=[[self allImages] objectForKey:name];
if(image==nil){
NSArray *bundles=[self checkBundles];
NSArray *bundles=[self _checkBundles];
int i,count=[bundles count];
for(i=0;i<count;i++){
@ -104,6 +127,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return nil;
}
-initWithSize:(NSSize)size {
_name=nil;
_size=size;
_representations=[NSMutableArray new];
return self;
}
-initWithData:(NSData *)data {
NSUnimplementedMethod();
return nil;
}
-initWithContentsOfFile:(NSString *)path {
NSArray *reps=[NSImageRep imageRepsWithContentsOfFile:path];
@ -121,16 +156,24 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return self;
}
-initWithContentsOfURL:(NSURL *)url {
NSUnimplementedMethod();
return 0;
}
-initWithPasteboard:(NSPasteboard *)pasteboard {
NSUnimplementedMethod();
return 0;
}
-initByReferencingFile:(NSString *)path {
NSUnimplementedMethod();
return nil;
}
-initWithSize:(NSSize)size {
_name=nil;
_size=size;
_representations=[NSMutableArray new];
return self;
-initByReferencingURL:(NSURL *)url {
NSUnimplementedMethod();
return 0;
}
-(void)dealloc {
@ -151,13 +194,48 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return _size;
}
-(NSArray *)representations {
return _representations;
-(NSColor *)backgroundColor {
return _backgroundColor;
}
-(BOOL)isFlipped {
return _isFlipped;
}
-(BOOL)scalesWhenResized {
return _scalesWhenResized;
}
-(BOOL)matchesOnMultipleResolution {
return _matchesOnMultipleResolution;
}
-(BOOL)usesEPSOnResolutionMismatch {
return _usesEPSOnResolutionMismatch;
}
-(BOOL)prefersColorMatch {
return _prefersColorMatch;
}
-(NSImageCacheMode)cacheMode {
return _cacheMode;
}
-(BOOL)isCachedSeparately {
NSUnimplementedMethod();
return NO;
return _isCachedSeparately;
}
-(BOOL)cacheDepthMatchesImageDepth {
return _cacheDepthMatchesImageDepth;
}
-(BOOL)isDataRetained {
return _isDataRetained;
}
-delegate {
return _delegate;
}
-(BOOL)setName:(NSString *)name {
@ -177,23 +255,100 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-(void)setSize:(NSSize)size {
_size=size;
// FIX, clear cache
[self recache];
}
-(void)addRepresentation:(NSImageRep *)imageRep {
[_representations addObject:imageRep];
-(void)setBackgroundColor:(NSColor *)value {
value=[value copy];
[_backgroundColor release];
_backgroundColor=value;
}
-(void)setScalesWhenResized:(BOOL)flag {
-(void)setFlipped:(BOOL)value {
_isFlipped=value;
}
-(void)setScalesWhenResized:(BOOL)value {
_scalesWhenResized=value;
}
-(void)setMatchesOnMultipleResolution:(BOOL)value {
_matchesOnMultipleResolution=value;
}
-(void)setUsesEPSOnResolutionMismatch:(BOOL)value {
_usesEPSOnResolutionMismatch=value;
}
-(void)setPrefersColorMatch:(BOOL)value {
_prefersColorMatch=value;
}
-(void)setCacheMode:(NSImageCacheMode)value {
_cacheMode=value;
}
-(void)setCachedSeparately:(BOOL)value {
_isCachedSeparately=value;
}
-(void)setCacheDepthMatchesImageDepth:(BOOL)value {
_cacheDepthMatchesImageDepth=value;
}
-(void)setDataRetained:(BOOL)value {
_isDataRetained=value;
}
-(void)setDelegate:delegate {
_delegate=delegate;
}
-(BOOL)isValid {
NSUnimplementedMethod();
return 0;
}
-(NSArray *)representations {
return _representations;
}
-(void)addRepresentation:(NSImageRep *)representation {
[_representations addObject:representation];
}
-(void)addRepresentations:(NSArray *)array {
int i,count=[array count];
for(i=0;i<count;i++)
[self addRepresentation:[array objectAtIndex:i]];
}
-(void)removeRepresentation:(NSImageRep *)representation {
[_representations removeObjectIdenticalTo:representation];
}
-(NSImageRep *)bestRepresentationForDevice:(NSDictionary *)device {
NSUnimplementedMethod();
return 0;
}
-(void)recache {
NSUnimplementedMethod();
}
-(void)setCachedSeparately:(BOOL)flag {
//NSUnimplementedMethod();
-(void)cancelIncrementalLoad {
NSUnimplementedMethod();
}
-(void)setBackgroundColor:(NSColor *)color {
-(NSData *)TIFFRepresentation {
NSUnimplementedMethod();
return nil;
}
-(NSData *)TIFFRepresentationUsingCompression:(NSTIFFCompression)compression factor:(float)factor {
NSUnimplementedMethod();
return nil;
}
-(NSCachedImageRep *)_cachedImageRep {
@ -240,20 +395,49 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[NSGraphicsContext restoreGraphicsState];
}
-(BOOL)drawRepresentation:(NSImageRep *)representation inRect:(NSRect)rect {
[[self backgroundColor] set];
NSRectFill(rect);
return [representation drawInRect:rect];
}
-(void)compositeToPoint:(NSPoint)point fromRect:(NSRect)rect operation:(NSCompositingOperation)operation {
[self compositeToPoint:point fromRect:rect operation:operation fraction:1.0];
}
-(void)compositeToPoint:(NSPoint)point fromRect:(NSRect)rect operation:(NSCompositingOperation)operation fraction:(float)fraction {
CGContextRef context=NSCurrentGraphicsPort();
CGContextSaveGState(context);
CGContextSetAlpha(context,fraction);
[[_representations lastObject] drawAtPoint:point];
CGContextRestoreGState(context);
}
-(void)compositeToPoint:(NSPoint)point operation:(NSCompositingOperation)operation {
[self compositeToPoint:point operation:operation fraction:1.0];
}
-(void)compositeToPoint:(NSPoint)point operation:(NSCompositingOperation)operation fraction:(float)fraction {
NSImageRep *rep=[_representations lastObject];
if([rep isKindOfClass:[NSBitmapImageRep class]])
[(NSBitmapImageRep *)rep compositeToPoint:point operation:operation fraction:fraction];
else
[rep drawAtPoint:point];
NSSize size=[self size];
[self compositeToPoint:point fromRect:NSMakeRect(0,0,size.width,size.height) operation:operation fraction:1.0];
}
-(void)compositeToPoint:(NSPoint)point fromRect:(NSRect)rect operation:(NSCompositingOperation)operation {
-(void)dissolveToPoint:(NSPoint)point fraction:(float)fraction {
NSUnimplementedMethod();
}
-(void)dissolveToPoint:(NSPoint)point fromRect:(NSRect)rect fraction:(float)fraction {
NSUnimplementedMethod();
}
-(void)drawAtPoint:(NSPoint)point fromRect:(NSRect)source operation:(NSCompositingOperation)operation fraction:(float)fraction {
NSUnimplementedMethod();
}
-(void)drawInRect:(NSRect)rect fromRect:(NSRect)source operation:(NSCompositingOperation)operation fraction:(float)fraction {
NSUnimplementedMethod();
}

View File

@ -6,7 +6,10 @@ 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 <Foundation/Foundation.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSGeometry.h>
@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;

View File

@ -10,6 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSImageRep.h>
#import <AppKit/NSBitmapImageRep.h>
#import <AppKit/NSPDFImageRep.h>
#import <AppKit/NSPasteboard.h>
#import <AppKit/NSGraphicsContextFunctions.h>
@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<count;i++){
Class cls=[_registeredClasses objectAtIndex:i];
[result addObjectsFromArray:[cls imageUnfilteredFileTypes]];
}
return [result allObjects];
}
+(NSArray *)imageUnfilteredFileTypes {
return [NSArray array];
}
+(NSArray *)imagePasteboardTypes {
NSMutableSet *result=[NSMutableSet set];
int i,count=[_registeredClasses count];
for(i=0;i<count;i++){
Class cls=[_registeredClasses objectAtIndex:i];
[result addObjectsFromArray:[cls imageUnfilteredPasteboardTypes]];
}
return [result allObjects];
}
+(NSArray *)imageUnfilteredPasteboardTypes {
return [NSArray array];
}
+(BOOL)canInitWithData:(NSData *)data {
return NO;
}
+(BOOL)canInitWithPasteboard:(NSPasteboard *)pasteboard {
NSString *available=[pasteboard availableTypeFromArray:[self imageUnfilteredPasteboardTypes]];
return (available!=nil)?YES:NO;
}
+(Class)imageRepClassForData:(NSData *)data {
int count=[_registeredClasses count];
while(--count>=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 {

View File

@ -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];

View File

@ -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 {

View File

@ -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;

View File

@ -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<count;i++)
if([[(NSMenuItem *)[_itemArray objectAtIndex:i] representedObject] isEqual:object])
return i;
return -1;
}
// needed this for NSApplication windowsMenu stuff, so i did 'em all..

View File

@ -44,11 +44,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
}
else {
_atitle=[[NSAttributedString alloc] initWithString:[coder decodeObjectForKey:@"NSMenuItem title"]];
_keyEquivalent=[[coder decodeObjectForKey:@"NSMenuItem keyEquivalent"] retain];
_keyEquivalentModifierMask=[coder decodeIntForKey:@"NSMenuItem keyEquivalentModifierMask"];
_submenu=[[coder decodeObjectForKey:@"NSMenuItem submenu"] retain];
_tag=[coder decodeIntForKey:@"NSMenuItem tag"];
[NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]];
}
return self;

View File

@ -18,6 +18,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
+(NSOpenPanel *)openPanel;
-(NSArray *)filenames;
-(NSArray *)URLs;
-(int)runModalForDirectory:(NSString *)directory file:(NSString *)file types:(NSArray *)types;
-(int)runModalForTypes:(NSArray *)types;

View File

@ -10,6 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSOpenPanel.h>
#import <AppKit/NSApplication.h>
#import <AppKit/NSDisplay.h>
#import <Foundation/NSURL.h>
@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<count;i++)
[result addObject:[NSURL fileURLWithPath:[paths objectAtIndex:i]]];
return result;
}
-(int)runModalForDirectory:(NSString *)directory file:(NSString *)file types:(NSArray *)types {
return [[NSDisplay currentDisplay] openPanel:self runModalForDirectory:directory file:file types:types];
}

View File

@ -87,6 +87,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
CGContextConcatCTM(context,[page drawingTransformForBox:kKGPDFMediaBox inRect:rect rotate:0 preserveAspectRatio:NO]);
CGContextDrawPDFPage(context,page);
CGContextRestoreGState(context);
return YES;
}
@end

View File

@ -62,8 +62,6 @@ 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;
[self _initWithDefaults];
}
else {

View File

@ -18,18 +18,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@implementation NSPopUpButtonCell
-(void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
[coder encodeBool:_pullsDown forKey:@"NSPopUpButtonCell pullsDown"];
[coder encodeInt:_selectedIndex forKey:@"NSPopUpButtonCell selectedIndex"];
[coder encodeObject:_menu forKey:@"NSPopUpButtonCell menu"];
NSUnimplementedMethod();
}
-initWithCoder:(NSCoder *)coder {
[super initWithCoder:coder];
if([coder isKindOfClass:[NSNibKeyedUnarchiver class]]){
NSNibKeyedUnarchiver *keyed=(NSNibKeyedUnarchiver *)coder;
if([coder isKindOfClass:[NSNibKeyedUnarchiver class]]){
_pullsDown=[coder decodeBoolForKey:@"NSPullDown"];
_menu=[[coder decodeObjectForKey:@"NSMenu"] retain];
_selectedIndex=[[_menu itemArray] indexOfObjectIdenticalTo:[coder decodeObjectForKey:@"NSMenuItem"]];
@ -38,9 +33,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_selectedIndex=0;
}
else {
_pullsDown=[coder decodeBoolForKey:@"NSPopUpButtonCell pullsDown"];
_selectedIndex=[coder decodeIntForKey:@"NSPopUpButtonCell selectedIndex"];
_menu=[[coder decodeObjectForKey:@"NSPopUpButtonCell menu"] retain];
[NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]];
}
return self;
}

View File

@ -13,6 +13,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@interface NSPrintOperation : NSObject {
NSView *_view;
NSPrintInfo *_printInfo;
NSView *_accessoryView;
NSPrintPanel *_printPanel;
BOOL _showsPrintPanel;
int _currentPage;

View File

@ -88,7 +88,9 @@ static NSPrintOperation *_currentOperation=nil;
}
-(void)setAccessoryView:(NSView *)view {
NSUnimplementedMethod();
view=[view retain];
[_accessoryView release];
_accessoryView=view;
}
-(NSView *)view {
@ -176,7 +178,7 @@ static NSPrintOperation *_currentOperation=nil;
*rangep=result;
}
-(BOOL)_paginateWithPageRange:(NSRange)pageRange context:(KGContext *)context {
-(void)_paginateWithPageRange:(NSRange)pageRange context:(KGContext *)context {
int i;
for(i=0,_currentPage=pageRange.location;i<pageRange.length;i++,_currentPage++){
@ -215,7 +217,9 @@ static NSPrintOperation *_currentOperation=nil;
else if(_type==NSPrintOperationPDFInRect){
context=[[[KGPDFContext alloc] initWithMutableData:_mutableData] autorelease];
}
else
return nil;
return [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO];
}
@ -256,9 +260,7 @@ static NSPrintOperation *_currentOperation=nil;
[context beginPrintingWithDocumentName:[[_view window] title]];
[_view beginDocument];
if(_type==NSPrintOperationPDFInRect){
KGPDFContext *pdf=(KGPDFContext *)context;
if(_type==NSPrintOperationPDFInRect){
[_view beginPageInRect:_insideRect atPlacement:NSMakePoint(0,0)];
[_view drawRect:_insideRect];
[_view endPage];

View File

@ -13,6 +13,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSKeyBinding.h>
#import <AppKit/NSApplication.h>
#import <AppKit/NSNibKeyedUnarchiver.h>
#import <AppKit/NSGraphics.h>
@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"];
}

View File

@ -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;

View File

@ -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<count;i++)
if([[_segments objectAtIndex:i] tag]==tag)
if([[_segments objectAtIndex:i] tag]==tag){
[self setSelected:YES forSegment:i];
return YES;
}
return NO;
}
-(void)setSelected:(BOOL)flag forSegment:(int)segment {

View File

@ -93,13 +93,24 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
- (int)isVertical { return _isVertical; }
-(int)indexOfTickMarkAtPoint:(NSPoint)point {
NSUnimplementedMethod();
return 0;
int i;
for(i=0;i<_numberOfTickMarks;i++){
NSRect check=[self rectOfTickMarkAtIndex:i];
check=NSInsetRect(check,-1,-1);
if(NSPointInRect(point,check))
return i;
}
return NSNotFound;
}
-(double)tickMarkValueAtIndex:(int)index {
NSUnimplementedMethod();
return 0;
double length=(_isVertical?_lastRect.size.height:_lastRect.size.width)-2*PIXELINSET;
return (_numberOfTickMarks==1)?length/2:index*(length/(_numberOfTickMarks-1));
}
-(double)closestTickMarkValueToValue:(double)value {

View File

@ -370,9 +370,9 @@ static float constrainTo(float value,float min,float max){
NSCursor *cursor;
if([self isVertical])
cursor=[NSCursor _verticalResizeCursor];
cursor=[NSCursor resizeLeftRightCursor];
else
cursor=[NSCursor _horizontalResizeCursor];
cursor=[NSCursor resizeUpDownCursor];
for(i=0;i<count-1;i++){
NSRect rect=[self dividerRectAtIndex:i];

Some files were not shown because too many files have changed in this diff Show More