123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523 |
- //
- // KMLineInspector.swift
- // PDF Master
- //
- // Created by tangchao on 2023/11/10.
- //
- import Cocoa
- class KMLineInspector: NSWindowController {
- /*
- extern NSString *SKLineInspectorLineAttributeDidChangeNotification;
- typedef NS_ENUM(NSUInteger, SKLineChangeAction) {
- SKNoLineChangeAction,
- SKLineChangeActionLineWidth,
- SKLineChangeActionStyle,
- SKLineChangeActionDashPattern,
- SKLineChangeActionStartLineStyle,
- SKLineChangeActionEndLineStyle
- };
- @class SKLineWell;
- @interface SKLineInspector : SKWindowController {
- NSSlider *lineWidthSlider;
- NSTextField *lineWidthField;
- NSSegmentedControl *styleButton;
- NSTextField *dashPatternField;
- NSSegmentedControl *startLineStyleButton;
- NSSegmentedControl *endLineStyleButton;
- SKLineWell *lineWell;
- NSTextField *lineWidthLabelField;
- NSTextField *styleLabelField;
- NSTextField *dashPatternLabelField;
- NSTextField *startLineStyleLabelField;
- NSTextField *endLineStyleLabelField;
- NSArray *labelFields;
- CGFloat lineWidth;
- PDFBorderStyle style;
- NSArray *dashPattern;
- PDFLineStyle startLineStyle;
- PDFLineStyle endLineStyle;
- SKLineChangeAction currentLineChangeAction;
- }
- @property (nonatomic, retain) IBOutlet NSArray *labelFields;
- @property (nonatomic) CGFloat lineWidth;
- @property (nonatomic) PDFBorderStyle style;
- @property (nonatomic, copy) NSArray *dashPattern;
- @property (nonatomic) PDFLineStyle startLineStyle, endLineStyle;
- @property (nonatomic, readonly) SKLineChangeAction currentLineChangeAction;
- + (id)sharedLineInspector;
- + (BOOL)sharedLineInspectorExists;
- - (void)setAnnotationStyle:(PDFAnnotation *)annotation;
- */
-
- @IBOutlet var lineWidthSlider: NSSlider!
- @IBOutlet var lineWidthField: NSTextField!
- @IBOutlet var dashPatternField: NSTextField!
- @IBOutlet var styleButton: NSSegmentedControl!
- @IBOutlet var startLineStyleButton: NSSegmentedControl!
- @IBOutlet var endLineStyleButton: NSSegmentedControl!
- @IBOutlet var lineWidthLabelField: NSTextField!
- @IBOutlet var styleLabelField: NSTextField!
- @IBOutlet var dashPatternLabelField: NSTextField!
- @IBOutlet var startLineStyleLabelField: NSTextField!
- @IBOutlet var endLineStyleLabelField: NSTextField!
- @IBOutlet var lineWell: KMLineWell!
- @IBOutlet weak var labelField1: NSTextField!
- @IBOutlet weak var labelField2: NSTextField!
- @IBOutlet weak var labelField3: NSTextField!
- @IBOutlet weak var labelField4: NSTextField!
- @IBOutlet weak var labelField5: NSTextField!
-
- static let shared = KMLineInspector(windowNibName: "LineInspector")
-
- override func windowDidLoad() {
- super.windowDidLoad()
-
- // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
- }
-
- /*
- SString *SKLineInspectorLineAttributeDidChangeNotification = @"SKLineInspectorLineAttributeDidChangeNotification";
- #define LINEWIDTH_KEY @"lineWidth"
- #define STYLE_KEY @"style"
- #define DASHPATTERN_KEY @"dashPattern"
- #define STARTLINESTYLE_KEY @"startLineStyle"
- #define ENDLINESTYLE_KEY @"endLineStyle"
- #define ACTION_KEY @"action"
- #define SKLineInspectorFrameAutosaveName @"SKLineInspector"
- @implementation SKLineInspector
- @synthesize lineWidthSlider, lineWidthField, dashPatternField, styleButton, startLineStyleButton, endLineStyleButton, lineWell, lineWidthLabelField, styleLabelField, dashPatternLabelField, startLineStyleLabelField, endLineStyleLabelField, labelFields, lineWidth, style, dashPattern, startLineStyle, endLineStyle, currentLineChangeAction;
- static SKLineInspector *sharedLineInspector = nil;
- + (id)sharedLineInspector {
- if (sharedLineInspector == nil)
- sharedLineInspector = [[self alloc] init];
- return sharedLineInspector;
- }
- + (BOOL)sharedLineInspectorExists {
- return sharedLineInspector != nil;
- }
- - (id)init {
- if (sharedLineInspector) NSLog(@"Attempt to allocate second instance of %@", [self class]);
- self = [super initWithWindowNibName:@"LineInspector"];
- if (self) {
- style = kPDFBorderStyleSolid;
- lineWidth = 1.0;
- dashPattern = nil;
- startLineStyle = kPDFLineStyleNone;
- endLineStyle = kPDFLineStyleNone;
- currentLineChangeAction = SKNoLineChangeAction;
- }
- return self;
- }
- - (void)dealloc {
- SKDESTROY(dashPattern);
- SKDESTROY(lineWidthSlider);
- SKDESTROY(lineWidthField);
- SKDESTROY(dashPatternField);
- SKDESTROY(styleButton);
- SKDESTROY(startLineStyleButton);
- SKDESTROY(endLineStyleButton);
- SKDESTROY(lineWell);
- SKDESTROY(lineWidthLabelField);
- SKDESTROY(styleLabelField);
- SKDESTROY(dashPatternLabelField);
- SKDESTROY(startLineStyleLabelField);
- SKDESTROY(endLineStyleLabelField);
- SKDESTROY(labelFields);
- [super dealloc];
- }
- - (void)windowDidLoad {
- [lineWell setCanActivate:NO];
- [lineWell bind:SKLineWellLineWidthKey toObject:self withKeyPath:LINEWIDTH_KEY options:nil];
- [lineWell bind:SKLineWellStyleKey toObject:self withKeyPath:STYLE_KEY options:nil];
- [lineWell bind:SKLineWellDashPatternKey toObject:self withKeyPath:DASHPATTERN_KEY options:nil];
- [lineWell bind:SKLineWellStartLineStyleKey toObject:self withKeyPath:STARTLINESTYLE_KEY options:nil];
- [lineWell bind:SKLineWellEndLineStyleKey toObject:self withKeyPath:ENDLINESTYLE_KEY options:nil];
-
- [styleButton setHelp:NSLocalizedString(@"Solid line style", @"Tool tip message") forSegment:kPDFBorderStyleSolid];
- [styleButton setHelp:NSLocalizedString(@"Dashed line style", @"Tool tip message") forSegment:kPDFBorderStyleDashed];
- [styleButton setHelp:NSLocalizedString(@"Beveled line style", @"Tool tip message") forSegment:kPDFBorderStyleBeveled];
- [styleButton setHelp:NSLocalizedString(@"Inset line style", @"Tool tip message") forSegment:kPDFBorderStyleInset];
- [styleButton setHelp:NSLocalizedString(@"Underline line style", @"Tool tip message") forSegment:kPDFBorderStyleUnderline];
-
- [startLineStyleButton setHelp:NSLocalizedString(@"No start line style", @"Tool tip message") forSegment:kPDFLineStyleNone];
- [startLineStyleButton setHelp:NSLocalizedString(@"Square start line style", @"Tool tip message") forSegment:kPDFLineStyleSquare];
- [startLineStyleButton setHelp:NSLocalizedString(@"Circle start line style", @"Tool tip message") forSegment:kPDFLineStyleCircle];
- [startLineStyleButton setHelp:NSLocalizedString(@"Diamond start line style", @"Tool tip message") forSegment:kPDFLineStyleDiamond];
- [startLineStyleButton setHelp:NSLocalizedString(@"Open arrow start line style", @"Tool tip message") forSegment:kPDFLineStyleOpenArrow];
- [startLineStyleButton setHelp:NSLocalizedString(@"Closed arrow start line style", @"Tool tip message") forSegment:kPDFLineStyleClosedArrow];
-
- [endLineStyleButton setHelp:NSLocalizedString(@"No end line style", @"Tool tip message") forSegment:kPDFLineStyleNone];
- [endLineStyleButton setHelp:NSLocalizedString(@"Square end line style", @"Tool tip message") forSegment:kPDFLineStyleSquare];
- [endLineStyleButton setHelp:NSLocalizedString(@"Circle end line style", @"Tool tip message") forSegment:kPDFLineStyleCircle];
- [endLineStyleButton setHelp:NSLocalizedString(@"Diamond end line style", @"Tool tip message") forSegment:kPDFLineStyleDiamond];
- [endLineStyleButton setHelp:NSLocalizedString(@"Open arrow end line style", @"Tool tip message") forSegment:kPDFLineStyleOpenArrow];
- [endLineStyleButton setHelp:NSLocalizedString(@"Closed arrow end line style", @"Tool tip message") forSegment:kPDFLineStyleClosedArrow];
-
- CGFloat dw = SKAutoSizeLabelFields(labelFields, [NSArray arrayWithObjects:lineWidthSlider, lineWidthField, styleButton, dashPatternField, startLineStyleButton, endLineStyleButton, nil], NO);
- if (fabs(dw) > 0.0)
- SKResizeWindow([self window], dw);
-
- [self setWindowFrameAutosaveName:SKLineInspectorFrameAutosaveName];
- NSImage *image = nil;
- NSSize size = NSMakeSize(29.0, 12.0);
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPathWithRect:NSMakeRect(6.0, 3.0, 17.0, 6.0)];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [styleButton setImage:image forSegment:kPDFBorderStyleSolid];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(6.0, 5.0)];
- [path lineToPoint:NSMakePoint(6.0, 3.0)];
- [path lineToPoint:NSMakePoint(9.0, 3.0)];
- [path moveToPoint:NSMakePoint(12.0, 3.0)];
- [path lineToPoint:NSMakePoint(17.0, 3.0)];
- [path moveToPoint:NSMakePoint(20.0, 3.0)];
- [path lineToPoint:NSMakePoint(23.0, 3.0)];
- [path lineToPoint:NSMakePoint(23.0, 5.0)];
- [path moveToPoint:NSMakePoint(23.0, 7.0)];
- [path lineToPoint:NSMakePoint(23.0, 9.0)];
- [path lineToPoint:NSMakePoint(20.0, 9.0)];
- [path moveToPoint:NSMakePoint(17.0, 9.0)];
- [path lineToPoint:NSMakePoint(12.0, 9.0)];
- [path moveToPoint:NSMakePoint(9.0, 9.0)];
- [path lineToPoint:NSMakePoint(6.0, 9.0)];
- [path lineToPoint:NSMakePoint(6.0, 7.0)];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [styleButton setImage:image forSegment:kPDFBorderStyleDashed];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPathWithRect:NSMakeRect(6.0, 3.0, 17.0, 6.0)];
- [path setLineWidth:2.0];
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.25] setStroke];
- [path stroke];
- path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(7.0, 3.0)];
- [path lineToPoint:NSMakePoint(23.0, 3.0)];
- [path lineToPoint:NSMakePoint(23.0, 8.0)];
- [path setLineWidth:2.0];
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.35] set];
- [path stroke];
- path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(5.0, 2.0)];
- [path lineToPoint:NSMakePoint(7.0, 4.0)];
- [path lineToPoint:NSMakePoint(7.0, 2.0)];
- [path closePath];
- [path moveToPoint:NSMakePoint(24.0, 10.0)];
- [path lineToPoint:NSMakePoint(22.0, 8.0)];
- [path lineToPoint:NSMakePoint(24.0, 8.0)];
- [path closePath];
- [path fill];
- return YES;
- }];
- [styleButton setImage:image forSegment:kPDFBorderStyleBeveled];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPathWithRect:NSMakeRect(6.0, 3.0, 17.0, 6.0)];
- [path setLineWidth:2.0];
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.25] setStroke];
- [path stroke];
- path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(6.0, 4.0)];
- [path lineToPoint:NSMakePoint(6.0, 9.0)];
- [path lineToPoint:NSMakePoint(22.0, 9.0)];
- [path setLineWidth:2.0];
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.35] set];
- [path stroke];
- path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(5.0, 2.0)];
- [path lineToPoint:NSMakePoint(7.0, 4.0)];
- [path lineToPoint:NSMakePoint(5.0, 4.0)];
- [path closePath];
- [path moveToPoint:NSMakePoint(24.0, 10.0)];
- [path lineToPoint:NSMakePoint(22.0, 8.0)];
- [path lineToPoint:NSMakePoint(22.0, 10.0)];
- [path closePath];
- [path fill];
- return YES;
- }];
- [styleButton setImage:image forSegment:kPDFBorderStyleInset];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(6.0, 3.0)];
- [path lineToPoint:NSMakePoint(23.0, 3.0)];
- [path setLineWidth:2.0];
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.5] setStroke];
- [path stroke];
- return YES;
- }];
- [styleButton setImage:image forSegment:kPDFBorderStyleUnderline];
-
- size = NSMakeSize(24.0, 12.0);
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(20.0, 6.0)];
- [path lineToPoint:NSMakePoint(8.0, 6.0)];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [startLineStyleButton setImage:image forSegment:kPDFLineStyleNone];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(4.0, 6.0)];
- [path lineToPoint:NSMakePoint(16.0, 6.0)];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [endLineStyleButton setImage:image forSegment:kPDFLineStyleNone];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(20.0, 6.0)];
- [path lineToPoint:NSMakePoint(8.0, 6.0)];
- [path appendBezierPathWithRect:NSMakeRect(5.0, 3.0, 6.0, 6.0)];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [startLineStyleButton setImage:image forSegment:kPDFLineStyleSquare];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(4.0, 6.0)];
- [path lineToPoint:NSMakePoint(16.0, 6.0)];
- [path appendBezierPathWithRect:NSMakeRect(13.0, 3.0, 6.0, 6.0)];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [endLineStyleButton setImage:image forSegment:kPDFLineStyleSquare];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(20.0, 6.0)];
- [path lineToPoint:NSMakePoint(8.0, 6.0)];
- [path appendBezierPathWithOvalInRect:NSMakeRect(5.0, 3.0, 6.0, 6.0)];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [startLineStyleButton setImage:image forSegment:kPDFLineStyleCircle];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(4.0, 6.0)];
- [path lineToPoint:NSMakePoint(16.0, 6.0)];
- [path appendBezierPathWithOvalInRect:NSMakeRect(13.0, 3.0, 6.0, 6.0)];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [endLineStyleButton setImage:image forSegment:kPDFLineStyleCircle];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(20.0, 6.0)];
- [path lineToPoint:NSMakePoint(8.0, 6.0)];
- [path moveToPoint:NSMakePoint(12.0, 6.0)];
- [path lineToPoint:NSMakePoint(8.0, 10.0)];
- [path lineToPoint:NSMakePoint(4.0, 6.0)];
- [path lineToPoint:NSMakePoint(8.0, 2.0)];
- [path closePath];
- [path setLineWidth:2.0];
- [path stroke];
- return YES;
- }];
- [startLineStyleButton setImage:image forSegment:kPDFLineStyleDiamond];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(4.0, 6.0)];
- [path lineToPoint:NSMakePoint(16.0, 6.0)];
- [path moveToPoint:NSMakePoint(12.0, 6.0)];
- [path lineToPoint:NSMakePoint(16.0, 10.0)];
- [path lineToPoint:NSMakePoint(20.0, 6.0)];
- [path lineToPoint:NSMakePoint(16.0, 2.0)];
- [path closePath];
- [path setLineWidth:2.0];
- [path stroke];
- return YES;
- }];
- [endLineStyleButton setImage:image forSegment:kPDFLineStyleDiamond];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(20.0, 6.0)];
- [path lineToPoint:NSMakePoint(8.0, 6.0)];
- [path moveToPoint:NSMakePoint(14.0, 3.0)];
- [path lineToPoint:NSMakePoint(8.0, 6.0)];
- [path lineToPoint:NSMakePoint(14.0, 9.0)];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [startLineStyleButton setImage:image forSegment:kPDFLineStyleOpenArrow];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(4.0, 6.0)];
- [path lineToPoint:NSMakePoint(16.0, 6.0)];
- [path moveToPoint:NSMakePoint(10.0, 3.0)];
- [path lineToPoint:NSMakePoint(16.0, 6.0)];
- [path lineToPoint:NSMakePoint(10.0, 9.0)];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [endLineStyleButton setImage:image forSegment:kPDFLineStyleOpenArrow];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(20.0, 6.0)];
- [path lineToPoint:NSMakePoint(8.0, 6.0)];
- [path moveToPoint:NSMakePoint(14.0, 3.0)];
- [path lineToPoint:NSMakePoint(8.0, 6.0)];
- [path lineToPoint:NSMakePoint(14.0, 9.0)];
- [path closePath];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [startLineStyleButton setImage:image forSegment:kPDFLineStyleClosedArrow];
-
- image = [NSImage imageWithSize:size drawingHandler:^(NSRect rect){
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(4.0, 6.0)];
- [path lineToPoint:NSMakePoint(16.0, 6.0)];
- [path moveToPoint:NSMakePoint(10.0, 3.0)];
- [path lineToPoint:NSMakePoint(16.0, 6.0)];
- [path lineToPoint:NSMakePoint(10.0, 9.0)];
- [path closePath];
- [path setLineWidth:2.0];
- [[NSColor blackColor] setStroke];
- [path stroke];
- return YES;
- }];
- [endLineStyleButton setImage:image forSegment:kPDFLineStyleClosedArrow];
- }
- - (void)notifyChangeAction:(SKLineChangeAction)action {
- currentLineChangeAction = action;
-
- SEL selector = @selector(changeLineAttribute:);
- NSWindow *mainWindow = [NSApp mainWindow];
- NSResponder *responder = [mainWindow firstResponder];
-
- while (responder && [responder respondsToSelector:selector] == NO)
- responder = [responder nextResponder];
-
- [responder performSelector:selector withObject:self];
-
- NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInteger:action], ACTION_KEY, nil];
- [[NSNotificationCenter defaultCenter] postNotificationName:SKLineInspectorLineAttributeDidChangeNotification object:self userInfo:userInfo];
-
- currentLineChangeAction = SKNoLineChangeAction;
- }
- #pragma mark Accessors
- - (void)setLineWidth:(CGFloat)width {
- if (fabs(lineWidth - width) > 0.00001) {
- lineWidth = width;
- [self notifyChangeAction:SKLineChangeActionLineWidth];
- }
- }
- - (void)setStyle:(PDFBorderStyle)newStyle {
- if (newStyle != style) {
- style = newStyle;
- [self notifyChangeAction:SKLineChangeActionStyle];
- }
- }
- - (void)setDashPattern:(NSArray *)pattern {
- if ([pattern isEqualToArray:dashPattern] == NO && (pattern || dashPattern)) {
- [dashPattern release];
- dashPattern = [pattern copy];
- [self notifyChangeAction:SKLineChangeActionDashPattern];
- }
- }
- - (void)setStartLineStyle:(PDFLineStyle)newStyle {
- if (newStyle != startLineStyle) {
- startLineStyle = newStyle;
- [self notifyChangeAction:SKLineChangeActionStartLineStyle];
- }
- }
- - (void)setEndLineStyle:(PDFLineStyle)newStyle {
- if (newStyle != endLineStyle) {
- endLineStyle = newStyle;
- [self notifyChangeAction:SKLineChangeActionEndLineStyle];
- }
- }
- - (void)setAnnotationStyle:(PDFAnnotation *)annotation {
- NSString *type = [annotation type];
- if ([type isEqualToString:SKNFreeTextString] || [type isEqualToString:SKNCircleString] || [type isEqualToString:SKNSquareString] || [type isEqualToString:SKNLineString] || [type isEqualToString:SKNInkString]) {
- [self setLineWidth:[annotation border] ? [[annotation border] lineWidth] : 0.0];
- [self setDashPattern:[[annotation border] dashPattern]];
- [self setStyle:[annotation border] ? [[annotation border] style] : 0];
- }
- if ([type isEqualToString:SKNLineString]) {
- [self setStartLineStyle:[(PDFAnnotationLine *)annotation startLineStyle]];
- [self setEndLineStyle:[(PDFAnnotationLine *)annotation endLineStyle]];
- }
- }
- - (void)setNilValueForKey:(NSString *)key {
- if ([key isEqualToString:LINEWIDTH_KEY]) {
- [self setValue:[NSNumber numberWithDouble:0.0] forKey:key];
- } else if ([key isEqualToString:STYLE_KEY] || [key isEqualToString:STARTLINESTYLE_KEY] || [key isEqualToString:ENDLINESTYLE_KEY]) {
- [self setValue:[NSNumber numberWithInteger:0] forKey:key];
- } else {
- [super setNilValueForKey:key];
- }
- }
- */
- }
|