|
@@ -13,13 +13,195 @@
|
|
|
#import "NSCursor_CExtensions.h"
|
|
|
|
|
|
#import "NSImage_CExtensions.h"
|
|
|
+#import "CStringConstants.h"
|
|
|
+#import "NSUserDefaults_Extensions.h"
|
|
|
+
|
|
|
+static NSCursor *strikeOutNoteCursor = nil;
|
|
|
+static NSCursor *highlightNoteCursor = nil;
|
|
|
+static NSCursor *underlineNoteCursor = nil;
|
|
|
+static NSCursor *inkNoteCursor = nil;
|
|
|
+static NSCursor *squareCursor = nil;
|
|
|
+static NSCursor *circleCursor = nil;
|
|
|
+static NSCursor *arrowCursor = nil;
|
|
|
+static NSCursor *lineCursor = nil;
|
|
|
+
|
|
|
+static NSCursor *radioFormCursor = nil;
|
|
|
+static NSCursor *checkFormCursor = nil;
|
|
|
+static NSCursor *textFieldFormCursor = nil;
|
|
|
+static NSCursor *listBoxFormCursor = nil;
|
|
|
+static NSCursor *comboBoxFormCursor = nil;
|
|
|
+static NSCursor *actionButtonFormCursor = nil;
|
|
|
+static NSCursor *signatureFormCursor = nil;
|
|
|
+
|
|
|
+static NSCursor *dotSelfSignCursor = nil;
|
|
|
+static NSCursor *circelSelfSignCursor = nil;
|
|
|
+static NSCursor *lineSelfSignCursor = nil;
|
|
|
+static NSCursor *tureSelfSignCursor = nil;
|
|
|
+static NSCursor *falseSelfSignCursor = nil;
|
|
|
+static NSCursor *dateSelfSignCursor = nil;
|
|
|
+static NSCursor *textSelfSignCursor = nil;
|
|
|
|
|
|
@implementation NSCursor (SKExtensions)
|
|
|
|
|
|
++ (void)addObserverForUserDefault {
|
|
|
+ NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
|
|
+ [center addObserver:[NSCursor class]
|
|
|
+ selector:@selector(defaultsChanged:)
|
|
|
+ name:NSUserDefaultsDidChangeNotification
|
|
|
+ object:nil];
|
|
|
+}
|
|
|
+
|
|
|
++ (void)addObserverForScaleChanged {
|
|
|
+ NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
|
|
+ [center addObserver:[NSCursor class]
|
|
|
+ selector:@selector(scaleChanged:)
|
|
|
+ name:@"PDFViewScaleChanged"
|
|
|
+ object:nil];
|
|
|
+}
|
|
|
+
|
|
|
++ (void)defaultsChanged:(id)sender {
|
|
|
+ highlightNoteCursor = nil;
|
|
|
+ underlineNoteCursor = nil;
|
|
|
+ strikeOutNoteCursor = nil;
|
|
|
+ inkNoteCursor = nil;
|
|
|
+ squareCursor = nil;
|
|
|
+ circleCursor = nil;
|
|
|
+ arrowCursor = nil;
|
|
|
+ lineCursor = nil;
|
|
|
+ [[NSNotificationCenter defaultCenter] removeObserver:[NSCursor class]];
|
|
|
+}
|
|
|
+
|
|
|
++ (void)scaleChanged:(id)sender {
|
|
|
+ radioFormCursor = nil;
|
|
|
+ checkFormCursor = nil;
|
|
|
+ textFieldFormCursor = nil;
|
|
|
+ listBoxFormCursor = nil;
|
|
|
+ comboBoxFormCursor = nil;
|
|
|
+ actionButtonFormCursor = nil;
|
|
|
+ signatureFormCursor = nil;
|
|
|
+
|
|
|
+ dotSelfSignCursor = nil;
|
|
|
+ circelSelfSignCursor = nil;
|
|
|
+ lineSelfSignCursor = nil;
|
|
|
+ tureSelfSignCursor = nil;
|
|
|
+ falseSelfSignCursor = nil;
|
|
|
+ dateSelfSignCursor = nil;
|
|
|
+ textSelfSignCursor = nil;
|
|
|
+
|
|
|
+ [[NSNotificationCenter defaultCenter] removeObserver:[NSCursor class]];
|
|
|
+}
|
|
|
+
|
|
|
++ (NSImage *)chairCursorImage:(NSImage *)image {
|
|
|
+ NSSize cursorSize = NSMakeSize(28, 40);
|
|
|
+ NSImage *cursorImage = [NSImage bitmapCImageWithSize:cursorSize scale:2.0 drawingHandler:^(NSRect rect){
|
|
|
+ NSImage *arrowCursor = [[NSCursor crosshairCursor] image];
|
|
|
+ [arrowCursor drawAtPoint:NSMakePoint(0.0, cursorSize.height - arrowCursor.size.height)
|
|
|
+ fromRect:NSZeroRect
|
|
|
+ operation:NSCompositeSourceOver
|
|
|
+ fraction:1.0];
|
|
|
+
|
|
|
+ CGFloat deltaX = 3.0;
|
|
|
+ NSAffineTransform *transform = [NSAffineTransform transform];
|
|
|
+ [transform translateXBy:deltaX yBy:0.0];
|
|
|
+ [transform concat];
|
|
|
+
|
|
|
+ NSSize size = NSMakeSize(cursorSize.width - deltaX, cursorSize.height - arrowCursor.size.height);
|
|
|
+ if (image.size.width/image.size.height < size.width/size.height) {
|
|
|
+ size.width = image.size.width/image.size.height*size.height;
|
|
|
+ } else {
|
|
|
+ size.height = image.size.height/image.size.width*size.width;
|
|
|
+ }
|
|
|
+ [image drawInRect:NSMakeRect(cursorSize.width - deltaX - size.width,
|
|
|
+ cursorSize.height - arrowCursor.size.height - size.height,
|
|
|
+ size.width, size.height)
|
|
|
+ fromRect:NSZeroRect
|
|
|
+ operation:NSCompositeSourceOver
|
|
|
+ fraction:1.0];
|
|
|
+ }];
|
|
|
+ return cursorImage;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSImage *)IBeamCursorImage:(NSImage *)image {
|
|
|
+ NSSize cursorSize = NSMakeSize(28
|
|
|
+ , 35);
|
|
|
+ NSImage *cursorImage = [NSImage bitmapCImageWithSize:cursorSize scale:2.0 drawingHandler:^(NSRect rect){
|
|
|
+ NSImage *arrowCursor = [[NSCursor IBeamCursor] image];
|
|
|
+ [arrowCursor drawAtPoint:NSMakePoint(0.0, cursorSize.height - arrowCursor.size.height)
|
|
|
+ fromRect:NSZeroRect
|
|
|
+ operation:NSCompositeSourceOver
|
|
|
+ fraction:1.0];
|
|
|
+
|
|
|
+ CGFloat deltaX = 3.0;
|
|
|
+ NSAffineTransform *transform = [NSAffineTransform transform];
|
|
|
+ [transform translateXBy:deltaX yBy:0.0];
|
|
|
+ [transform concat];
|
|
|
+
|
|
|
+ NSSize size = NSMakeSize(cursorSize.width - deltaX, cursorSize.height - arrowCursor.size.height);
|
|
|
+ if (image.size.width/image.size.height < size.width/size.height) {
|
|
|
+ size.width = image.size.width/image.size.height*size.height;
|
|
|
+ } else {
|
|
|
+ size.height = image.size.height/image.size.width*size.width;
|
|
|
+ }
|
|
|
+ [image drawInRect:NSMakeRect(cursorSize.width - deltaX - size.width,
|
|
|
+ cursorSize.height - arrowCursor.size.height - size.height,
|
|
|
+ size.width, size.height)
|
|
|
+ fromRect:NSZeroRect
|
|
|
+ operation:NSCompositeSourceOver
|
|
|
+ fraction:1.0];
|
|
|
+ }];
|
|
|
+ return cursorImage;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSImage *)arrowCursorImage:(NSImage *)image {
|
|
|
+ NSSize cursorSize = NSMakeSize(28, 40);
|
|
|
+ NSImage *cursorImage = [NSImage bitmapCImageWithSize:cursorSize scale:2.0 drawingHandler:^(NSRect rect){
|
|
|
+ NSImage *arrowCursor = [[NSCursor arrowCursor] image];
|
|
|
+ [arrowCursor drawAtPoint:NSMakePoint(0.0, cursorSize.height - arrowCursor.size.height)
|
|
|
+ fromRect:NSZeroRect
|
|
|
+ operation:NSCompositeSourceOver
|
|
|
+ fraction:1.0];
|
|
|
+
|
|
|
+ CGFloat deltaX = 3.0;
|
|
|
+ NSAffineTransform *transform = [NSAffineTransform transform];
|
|
|
+ [transform translateXBy:deltaX yBy:0.0];
|
|
|
+ [transform concat];
|
|
|
+
|
|
|
+ NSSize size = NSMakeSize(cursorSize.width - deltaX, cursorSize.height - arrowCursor.size.height);
|
|
|
+ if (image.size.width/image.size.height < size.width/size.height) {
|
|
|
+ size.width = image.size.width/image.size.height*size.height;
|
|
|
+ } else {
|
|
|
+ size.height = image.size.height/image.size.width*size.width;
|
|
|
+ }
|
|
|
+ [image drawInRect:NSMakeRect(cursorSize.width - deltaX - size.width,
|
|
|
+ cursorSize.height - arrowCursor.size.height - size.height,
|
|
|
+ size.width, size.height)
|
|
|
+ fromRect:NSZeroRect
|
|
|
+ operation:NSCompositeSourceOver
|
|
|
+ fraction:1.0];
|
|
|
+ }];
|
|
|
+ return cursorImage;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSImage *)scaleImage:(NSImage *)sourceImage scaleFactor:(CGFloat)scaleFactor {
|
|
|
+ CGFloat width = sourceImage.size.width;
|
|
|
+ CGFloat height = sourceImage.size.height;
|
|
|
+ CGFloat scaledWidth = width * scaleFactor;
|
|
|
+ CGFloat scaledHeight = height * scaleFactor;
|
|
|
+ NSImage *newImage = [[NSImage alloc] initWithSize:NSMakeSize(scaledWidth, scaledHeight)];
|
|
|
+ CGRect thumbnailRect = {0,0, {scaledWidth, scaledHeight}};
|
|
|
+ NSRect imageRect = NSMakeRect(0.0, 0.0, width, height);
|
|
|
+
|
|
|
+ [newImage lockFocus];
|
|
|
+ [sourceImage drawInRect:thumbnailRect fromRect:imageRect operation:NSCompositeCopy fraction:1.0];
|
|
|
+ [newImage unlockFocus];
|
|
|
+
|
|
|
+ return newImage;
|
|
|
+}
|
|
|
+
|
|
|
+ (NSCursor *)zoomInCursor {
|
|
|
static NSCursor *zoomInCursor = nil;
|
|
|
if (nil == zoomInCursor) {
|
|
|
- NSImage *cursorImage = [[NSImage imageNamed:CImageNameZoomInCursor] copy];
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameZoomInCursor] copy];
|
|
|
zoomInCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:NSMakePoint(6.0, 6.0)];
|
|
|
}
|
|
|
return zoomInCursor;
|
|
@@ -28,10 +210,459 @@
|
|
|
+ (NSCursor *)zoomOutCursor {
|
|
|
static NSCursor *zoomOutCursor = nil;
|
|
|
if (nil == zoomOutCursor) {
|
|
|
- NSImage *cursorImage = [[NSImage imageNamed:CImageNameZoomOutCursor] copy];
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameZoomOutCursor] copy];
|
|
|
zoomOutCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:NSMakePoint(6.0, 6.0)];
|
|
|
}
|
|
|
return zoomOutCursor;
|
|
|
}
|
|
|
|
|
|
++ (NSCursor *)resizeDiagonal45Cursor {
|
|
|
+ static NSCursor *resizeDiagonal45Cursor = nil;
|
|
|
+ if (nil == resizeDiagonal45Cursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameResizeDiagonal45Cursor] copy];
|
|
|
+ resizeDiagonal45Cursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:NSMakePoint(8.0, 8.0)];
|
|
|
+ }
|
|
|
+ return resizeDiagonal45Cursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)resizeDiagonal135Cursor {
|
|
|
+ static NSCursor *resizeDiagonal135Cursor = nil;
|
|
|
+ if (nil == resizeDiagonal135Cursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameResizeDiagonal135Cursor] copy];
|
|
|
+ resizeDiagonal135Cursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:NSMakePoint(8.0, 8.0)];
|
|
|
+ }
|
|
|
+ return resizeDiagonal135Cursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)textNoteCursor {
|
|
|
+ static NSCursor *textNoteCursor = nil;
|
|
|
+ if (nil == textNoteCursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsText] copy];
|
|
|
+ cursorImage = [NSCursor arrowCursorImage:cursorImage];
|
|
|
+ textNoteCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return textNoteCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)anchoredNoteCursor {
|
|
|
+ static NSCursor *anchoredNoteCursor = nil;
|
|
|
+ if (nil == anchoredNoteCursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsNote] copy];
|
|
|
+ cursorImage = [NSCursor arrowCursorImage:cursorImage];
|
|
|
+ anchoredNoteCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return anchoredNoteCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)circleNoteCursor {
|
|
|
+ if (circleCursor == nil) {
|
|
|
+ [NSCursor addObserverForUserDefault];
|
|
|
+ NSImage *image = [[NSImage alloc] initWithSize:CGSizeMake(12, 12)];
|
|
|
+ NSColor *color = [[NSUserDefaults standardUserDefaults] colorForKey:CCircleNoteColorKey];
|
|
|
+ color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+ color = [NSColor colorWithRed:color.redComponent green:color.greenComponent blue:color.blueComponent alpha:0.7];
|
|
|
+ [image lockFocus];
|
|
|
+
|
|
|
+
|
|
|
+ CGContextRef ref2 = [NSGraphicsContext currentContext].graphicsPort;
|
|
|
+
|
|
|
+ CGContextSaveGState(ref2);
|
|
|
+ CGContextAddArc(ref2, 6, 6, 5, 0, M_PI * 2, 0);
|
|
|
+ CGContextSetLineWidth(ref2, 2);
|
|
|
+ CGContextSetStrokeColorWithColor(ref2, [NSColor whiteColor].CGColor);
|
|
|
+ CGContextSetLineWidth(ref2, 2);
|
|
|
+ CGContextStrokePath(ref2);
|
|
|
+ CGContextRestoreGState(ref2);
|
|
|
+
|
|
|
+ CGContextSaveGState(ref2);
|
|
|
+ CGContextAddArc(ref2, 6, 6, 5, 0, M_PI * 2, 0);
|
|
|
+ CGContextSetLineWidth(ref2, 1);
|
|
|
+ CGContextSetStrokeColorWithColor(ref2, color.CGColor);
|
|
|
+ CGContextStrokePath(ref2);
|
|
|
+ CGContextRestoreGState(ref2);
|
|
|
+
|
|
|
+ [image unlockFocus];
|
|
|
+
|
|
|
+ image = [NSCursor chairCursorImage:image];
|
|
|
+ circleCursor = [[NSCursor alloc] initWithImage:image hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return circleCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)squareNoteCursor {
|
|
|
+ if (nil == squareCursor) {
|
|
|
+ [NSCursor addObserverForUserDefault];
|
|
|
+ NSImage *image = [[NSImage alloc] initWithSize:CGSizeMake(12, 12)];
|
|
|
+
|
|
|
+ NSColor *color = [[NSUserDefaults standardUserDefaults] colorForKey:CSquareNoteColorKey];
|
|
|
+ color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+ color = [NSColor colorWithRed:color.redComponent green:color.greenComponent blue:color.blueComponent alpha:0.7];
|
|
|
+ [image lockFocus];
|
|
|
+ CGContextRef ref2 = [NSGraphicsContext currentContext].graphicsPort;
|
|
|
+
|
|
|
+ CGContextSaveGState(ref2);
|
|
|
+ CGContextTranslateCTM(ref2, 2, 2);
|
|
|
+ CGContextAddRect(ref2, CGRectMake(0, 0, 8, 6));
|
|
|
+ CGContextSetStrokeColorWithColor(ref2, [NSColor whiteColor].CGColor);
|
|
|
+ CGContextSetLineWidth(ref2, 2);
|
|
|
+ CGContextStrokePath(ref2);
|
|
|
+ CGContextRestoreGState(ref2);
|
|
|
+
|
|
|
+ CGContextSaveGState(ref2);
|
|
|
+ CGContextTranslateCTM(ref2, 2, 2);
|
|
|
+ CGContextAddRect(ref2, CGRectMake(0, 0, 8, 6));
|
|
|
+ CGContextSetStrokeColorWithColor(ref2, color.CGColor);
|
|
|
+ CGContextSetLineWidth(ref2, 1);
|
|
|
+ CGContextStrokePath(ref2);
|
|
|
+ CGContextSaveGState(ref2);
|
|
|
+ [image unlockFocus];
|
|
|
+ image = [NSCursor chairCursorImage:image];
|
|
|
+ squareCursor = [[NSCursor alloc] initWithImage:image hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return squareCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)highlightNoteCursor {
|
|
|
+ if (nil == highlightNoteCursor) {
|
|
|
+ [NSCursor addObserverForUserDefault];
|
|
|
+
|
|
|
+ NSColor *color = [[NSUserDefaults standardUserDefaults] colorForKey:CHighlightNoteColorKey];
|
|
|
+ color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+ color = [NSColor colorWithRed:color.redComponent green:color.greenComponent blue:color.blueComponent alpha:0.7];
|
|
|
+
|
|
|
+ NSImage *baseImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsHighlight] copy];
|
|
|
+ NSImage *image = [[NSImage alloc] initWithSize:baseImage.size];
|
|
|
+
|
|
|
+ [image lockFocus];
|
|
|
+ CGContextRef ref2 = [NSGraphicsContext currentContext].graphicsPort;
|
|
|
+ CGContextSaveGState(ref2);;
|
|
|
+ [color setFill];
|
|
|
+
|
|
|
+ CGContextMoveToPoint(ref2, 0, 1);
|
|
|
+ CGContextAddLineToPoint(ref2, 1.5, image.size.height -1);
|
|
|
+ CGContextAddLineToPoint(ref2, image.size.width, image.size.height -1);
|
|
|
+ CGContextAddLineToPoint(ref2, image.size.width - 1.5, 1);
|
|
|
+ CGContextFillPath(ref2);
|
|
|
+
|
|
|
+ [baseImage drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
|
|
|
+ CGContextRestoreGState(ref2);
|
|
|
+ [image unlockFocus];
|
|
|
+ NSImage *cursorImage = image;
|
|
|
+ cursorImage = [NSCursor IBeamCursorImage:cursorImage];
|
|
|
+ highlightNoteCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return highlightNoteCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)underlineNoteCursor {
|
|
|
+ if (nil == underlineNoteCursor) {
|
|
|
+ [NSCursor addObserverForUserDefault];
|
|
|
+ NSColor *underlineColor = [[NSUserDefaults standardUserDefaults] colorForKey:CUnderlineNoteColorKey];
|
|
|
+
|
|
|
+ NSImage *image = [[NSImage imageNamed:CPDFListViewImageNameCursorsUnderline] copy];
|
|
|
+ [image lockFocus];
|
|
|
+ CGContextRef ref1 = [NSGraphicsContext currentContext].graphicsPort;
|
|
|
+ CGContextSaveGState(ref1);
|
|
|
+ CGContextBeginPath(ref1);
|
|
|
+ CGContextMoveToPoint(ref1, 0, 1);
|
|
|
+ CGContextAddLineToPoint(ref1, image.size.width, 1);
|
|
|
+ underlineColor = [underlineColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+ NSColor *newUnderlineColor = [NSColor colorWithRed:underlineColor.redComponent green:underlineColor.greenComponent blue:underlineColor.blueComponent alpha:1];
|
|
|
+ [newUnderlineColor set];
|
|
|
+ CGContextSetLineWidth(ref1, 2);
|
|
|
+ CGContextStrokePath(ref1);
|
|
|
+ CGContextRestoreGState(ref1);
|
|
|
+ [image unlockFocus];
|
|
|
+
|
|
|
+ NSImage *cursorImage = image;
|
|
|
+ cursorImage = [NSCursor IBeamCursorImage:cursorImage];
|
|
|
+ underlineNoteCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return underlineNoteCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)strikeOutNoteCursor {
|
|
|
+ if (nil == strikeOutNoteCursor) {
|
|
|
+ [NSCursor addObserverForUserDefault];
|
|
|
+ NSColor *strikenOutColor = [[NSUserDefaults standardUserDefaults] colorForKey:CStrikeOutNoteColorKey];
|
|
|
+ NSImage *image = [[NSImage imageNamed:CPDFListViewImageNameCursorsStrikeout] copy];
|
|
|
+ [image lockFocus];
|
|
|
+ CGContextRef ref = [NSGraphicsContext currentContext].graphicsPort;
|
|
|
+ CGContextSaveGState(ref);
|
|
|
+ CGContextBeginPath(ref);
|
|
|
+ CGContextMoveToPoint(ref, 0, image.size.height/2);
|
|
|
+ CGContextAddLineToPoint(ref, image.size.width, image.size.height/2);
|
|
|
+ strikenOutColor = [strikenOutColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+ NSColor *strikenColor = [NSColor colorWithRed:strikenOutColor.redComponent green:strikenOutColor.greenComponent blue:strikenOutColor.blueComponent alpha:1];
|
|
|
+ [strikenColor set];
|
|
|
+ CGContextSetLineWidth(ref, 1);
|
|
|
+ CGContextStrokePath(ref);
|
|
|
+ CGContextRestoreGState(ref);
|
|
|
+ [image unlockFocus];
|
|
|
+ NSImage *cursorImage = image;
|
|
|
+ cursorImage = [NSCursor IBeamCursorImage:cursorImage];
|
|
|
+ strikeOutNoteCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return strikeOutNoteCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)arrowNoteCursor {
|
|
|
+ if (nil == arrowCursor) {
|
|
|
+ [NSCursor addObserverForUserDefault];
|
|
|
+ NSImage *image = [[NSImage alloc] initWithSize:CGSizeMake(12, 12)];;
|
|
|
+ NSColor *color = [[NSUserDefaults standardUserDefaults] colorForKey:CLineNoteColorKey];
|
|
|
+ color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+ color = [NSColor colorWithRed:color.redComponent green:color.greenComponent blue:color.blueComponent alpha:1];
|
|
|
+
|
|
|
+ [image lockFocus];
|
|
|
+ CGContextRef ref2 = [NSGraphicsContext currentContext].graphicsPort;
|
|
|
+ CGContextSaveGState(ref2);
|
|
|
+ CGContextTranslateCTM(ref2, 2, 2);
|
|
|
+ CGContextMoveToPoint(ref2, 0, 0);
|
|
|
+ CGContextAddLineToPoint(ref2, 8, 8);
|
|
|
+ CGContextSetStrokeColorWithColor(ref2, [NSColor whiteColor].CGColor);
|
|
|
+ CGContextMoveToPoint(ref2, 4, 8);
|
|
|
+ CGContextAddLineToPoint(ref2, 8, 8);
|
|
|
+ CGContextAddLineToPoint(ref2, 8, 4);
|
|
|
+ CGContextSetLineWidth(ref2, 2);
|
|
|
+ CGContextStrokePath(ref2);
|
|
|
+ CGContextRestoreGState(ref2);
|
|
|
+
|
|
|
+ CGContextSaveGState(ref2);
|
|
|
+ CGContextTranslateCTM(ref2, 2, 2);
|
|
|
+ CGContextMoveToPoint(ref2, 0, 0);
|
|
|
+ CGContextAddLineToPoint(ref2, 8, 8);
|
|
|
+ CGContextSetStrokeColorWithColor(ref2, color.CGColor);
|
|
|
+ CGContextMoveToPoint(ref2, 4, 8);
|
|
|
+ CGContextAddLineToPoint(ref2, 8, 8);
|
|
|
+ CGContextAddLineToPoint(ref2, 8, 4);
|
|
|
+ CGContextStrokePath(ref2);
|
|
|
+ CGContextRestoreGState(ref2);
|
|
|
+
|
|
|
+ [image unlockFocus];
|
|
|
+
|
|
|
+ image = [NSCursor arrowCursorImage:image];
|
|
|
+ arrowCursor = [[NSCursor alloc] initWithImage:image hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return arrowCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)lineNoteCursor {
|
|
|
+ if (nil == lineCursor) {
|
|
|
+ [NSCursor addObserverForUserDefault];
|
|
|
+ NSImage *image = [[NSImage alloc] initWithSize:CGSizeMake(12, 12)];;
|
|
|
+ NSColor *color = [[NSUserDefaults standardUserDefaults] colorForKey:CArrowNoteColorKey];
|
|
|
+ color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+ color = [NSColor colorWithRed:color.redComponent green:color.greenComponent blue:color.blueComponent alpha:1];
|
|
|
+
|
|
|
+ [image lockFocus];
|
|
|
+
|
|
|
+ CGContextRef ref2 = [NSGraphicsContext currentContext].graphicsPort;
|
|
|
+ CGContextSaveGState(ref2);
|
|
|
+ CGContextTranslateCTM(ref2, 2, 2);
|
|
|
+ CGContextMoveToPoint(ref2, 0, 0);
|
|
|
+ CGContextAddLineToPoint(ref2, 8, 8);
|
|
|
+ CGContextSetStrokeColorWithColor(ref2, [NSColor whiteColor].CGColor);
|
|
|
+ CGContextSetLineWidth(ref2, 2);
|
|
|
+ CGContextStrokePath(ref2);
|
|
|
+
|
|
|
+ CGContextMoveToPoint(ref2, 0, 0);
|
|
|
+ CGContextAddLineToPoint(ref2, 8, 8);
|
|
|
+ CGContextSetStrokeColorWithColor(ref2, color.CGColor);
|
|
|
+ CGContextSetLineWidth(ref2, 1);
|
|
|
+ CGContextStrokePath(ref2);
|
|
|
+
|
|
|
+
|
|
|
+ CGContextRestoreGState(ref2);
|
|
|
+
|
|
|
+ [image unlockFocus];
|
|
|
+ image = [NSCursor arrowCursorImage:image];
|
|
|
+ lineCursor = [[NSCursor alloc] initWithImage:image hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return lineCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)inkNoteCursor {
|
|
|
+ if (nil == inkNoteCursor) {
|
|
|
+ [NSCursor addObserverForUserDefault];
|
|
|
+ NSColor *inkColor = [[NSUserDefaults standardUserDefaults] colorForKey:CInkNoteColorKey];
|
|
|
+ NSImage *image = [[NSImage imageNamed:CPDFListViewImageNameCursorsFreehand] copy];
|
|
|
+
|
|
|
+ [image lockFocus];
|
|
|
+ CGContextRef ref3 = [NSGraphicsContext currentContext].graphicsPort;
|
|
|
+ CGContextSaveGState(ref3);
|
|
|
+ CGContextBeginPath(ref3);
|
|
|
+ CGContextMoveToPoint(ref3, 3, 4);
|
|
|
+ CGContextAddCurveToPoint(ref3, image.size.width/2, -5, 3 * image.size.width/4, 3 * image.size.width/4, image.size.width, 4);
|
|
|
+ CGContextSetLineWidth(ref3, 1);
|
|
|
+ inkColor = [inkColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+ NSColor *newInkColor = [NSColor colorWithRed:inkColor.redComponent green:inkColor.greenComponent blue:inkColor.blueComponent alpha:1];
|
|
|
+ [newInkColor set];
|
|
|
+ CGContextStrokePath(ref3);
|
|
|
+ CGContextRestoreGState(ref3);
|
|
|
+ [image unlockFocus];
|
|
|
+
|
|
|
+
|
|
|
+ NSImage *cursorImage = image;
|
|
|
+ cursorImage = [NSCursor arrowCursorImage:cursorImage];
|
|
|
+ inkNoteCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return inkNoteCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)linkNoteCursor {
|
|
|
+ static NSCursor *linkNoteCursor = nil;
|
|
|
+ if (nil == linkNoteCursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsLink] copy];
|
|
|
+ cursorImage = [NSCursor arrowCursorImage:cursorImage];
|
|
|
+ linkNoteCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return linkNoteCursor;
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - Form cursor
|
|
|
+
|
|
|
++ (NSCursor *)radioFormCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (nil == radioFormCursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsRadiobutton] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ radioFormCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return radioFormCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)checkFormCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (nil == checkFormCursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsCheckbox] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ checkFormCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return checkFormCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)textFieldFormCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (nil == textFieldFormCursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsTextfield] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ textFieldFormCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return textFieldFormCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)listBoxFormCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (nil == listBoxFormCursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsListbox] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ listBoxFormCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return listBoxFormCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)comboBoxFormCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (nil == comboBoxFormCursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsPulldownmenu] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ comboBoxFormCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return comboBoxFormCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)actionButtonFormCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (nil == actionButtonFormCursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsButton] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ actionButtonFormCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return actionButtonFormCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)signatureFormCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (nil == signatureFormCursor) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsSign] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ signatureFormCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return signatureFormCursor;
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - selfSignCursor
|
|
|
+
|
|
|
++ (NSCursor *)dotSelfSignCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (dotSelfSignCursor == nil) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsPoint] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ dotSelfSignCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return dotSelfSignCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)circelSelfSignCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (circelSelfSignCursor == nil) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsRoundedrec] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ circelSelfSignCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return circelSelfSignCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)lineSelfSignCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (lineSelfSignCursor == nil) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsFormLine] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ lineSelfSignCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return lineSelfSignCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)tureSelfSignCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (tureSelfSignCursor == nil) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsTick] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ tureSelfSignCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return tureSelfSignCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)falseSelfSignCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (falseSelfSignCursor == nil) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsFork] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ falseSelfSignCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return falseSelfSignCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)dateSelfSignCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (dateSelfSignCursor == nil) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsDate] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ dateSelfSignCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return dateSelfSignCursor;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSCursor *)textSelfSignCursor:(CGFloat)scaleFactor {
|
|
|
+ [NSCursor addObserverForScaleChanged];
|
|
|
+ if (textSelfSignCursor == nil) {
|
|
|
+ NSImage *cursorImage = [[NSImage imageNamed:CPDFListViewImageNameCursorsText] copy];
|
|
|
+ cursorImage = [NSCursor scaleImage:cursorImage scaleFactor:scaleFactor];
|
|
|
+ textSelfSignCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[self arrowCursor] hotSpot]];
|
|
|
+ }
|
|
|
+ return textSelfSignCursor;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
@end
|