|
@@ -17,8 +17,8 @@ enum KMLineChangeAction: Int {
|
|
}
|
|
}
|
|
|
|
|
|
class KMLineInspector: NSWindowController {
|
|
class KMLineInspector: NSWindowController {
|
|
- private let LINEWIDTH_KEY = "style"
|
|
|
|
- private let STYLE_KEY = "lineWidth"
|
|
|
|
|
|
+ private let LINEWIDTH_KEY = "lineWidth"
|
|
|
|
+ private let STYLE_KEY = "style"
|
|
private let DASHPATTERN_KEY = "dashPattern"
|
|
private let DASHPATTERN_KEY = "dashPattern"
|
|
private let STARTLINESTYLE_KEY = "startLineStyle"
|
|
private let STARTLINESTYLE_KEY = "startLineStyle"
|
|
private let ENDLINESTYLE_KEY = "endLineStyle"
|
|
private let ENDLINESTYLE_KEY = "endLineStyle"
|
|
@@ -66,6 +66,8 @@ class KMLineInspector: NSWindowController {
|
|
set {
|
|
set {
|
|
if (abs(self.lineWidth - newValue) > 0.00001) {
|
|
if (abs(self.lineWidth - newValue) > 0.00001) {
|
|
self._lineWidth = newValue
|
|
self._lineWidth = newValue
|
|
|
|
+ self.lineWell?.lineWidth = newValue
|
|
|
|
+
|
|
self._notifyChangeAction(.lineWidth)
|
|
self._notifyChangeAction(.lineWidth)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -79,6 +81,8 @@ class KMLineInspector: NSWindowController {
|
|
set {
|
|
set {
|
|
if (newValue != self._style) {
|
|
if (newValue != self._style) {
|
|
self._style = newValue
|
|
self._style = newValue
|
|
|
|
+ self.lineWell?.style = CPDFBorderStyle(rawValue: newValue) ?? .solid
|
|
|
|
+
|
|
self._notifyChangeAction(.style)
|
|
self._notifyChangeAction(.style)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -92,6 +96,8 @@ class KMLineInspector: NSWindowController {
|
|
set {
|
|
set {
|
|
if (newValue != self.startLineStyle) {
|
|
if (newValue != self.startLineStyle) {
|
|
self._startLineStyle = newValue
|
|
self._startLineStyle = newValue
|
|
|
|
+ self.lineWell?.startLineStyle = CPDFLineStyle(rawValue: newValue) ?? .none
|
|
|
|
+
|
|
self._notifyChangeAction(.startLineStyle)
|
|
self._notifyChangeAction(.startLineStyle)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -105,6 +111,8 @@ class KMLineInspector: NSWindowController {
|
|
set {
|
|
set {
|
|
if (newValue != self.endLineStyle) {
|
|
if (newValue != self.endLineStyle) {
|
|
self._endLineStyle = newValue
|
|
self._endLineStyle = newValue
|
|
|
|
+ self.lineWell?.endLineStyle = CPDFLineStyle(rawValue: newValue) ?? .none
|
|
|
|
+
|
|
self._notifyChangeAction(.endLineStyle)
|
|
self._notifyChangeAction(.endLineStyle)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -117,6 +125,8 @@ class KMLineInspector: NSWindowController {
|
|
set {
|
|
set {
|
|
if newValue != self._dashPattern && (newValue.isEmpty == false || self._dashPattern.isEmpty == false) {
|
|
if newValue != self._dashPattern && (newValue.isEmpty == false || self._dashPattern.isEmpty == false) {
|
|
self._dashPattern = newValue
|
|
self._dashPattern = newValue
|
|
|
|
+
|
|
|
|
+ self.lineWell?.dashPattern = newValue as NSArray
|
|
self._notifyChangeAction(.dashPattern)
|
|
self._notifyChangeAction(.dashPattern)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -127,22 +137,24 @@ class KMLineInspector: NSWindowController {
|
|
override func windowDidLoad() {
|
|
override func windowDidLoad() {
|
|
super.windowDidLoad()
|
|
super.windowDidLoad()
|
|
|
|
|
|
- self.labelFields = [self.labelField1, self.labelField2, self.labelField3, self.labelField4, self.labelField5]
|
|
|
|
|
|
+ self._initDefalutValue()
|
|
|
|
+ self._initLayoutUI()
|
|
|
|
+ self._initValues()
|
|
|
|
+ self._initActions()
|
|
|
|
|
|
- self.style = CPDFBorderStyle.solid.rawValue
|
|
|
|
- self.lineWidth = 1.0
|
|
|
|
- self.dashPattern = []
|
|
|
|
- self.startLineStyle = CPDFLineStyle.none.rawValue
|
|
|
|
- self.endLineStyle = CPDFLineStyle.none.rawValue
|
|
|
|
- self._currentLineChangeAction = .no
|
|
|
|
|
|
+ self._initStyleImages()
|
|
|
|
+ self._initStartImages()
|
|
|
|
+ self._initEndImages()
|
|
|
|
+ }
|
|
|
|
|
|
- self.lineWell.canActivate = false
|
|
|
|
-// self.lineWell.bind(NSBindingName(rawValue: KMLineWell.widthKey), to: self, withKeyPath: LINEWIDTH_KEY)
|
|
|
|
-// self.lineWell.bind(NSBindingName(KMLineWell.styleKey), to: self, withKeyPath: STYLE_KEY)
|
|
|
|
-// self.lineWell.bind(NSBindingName(KMLineWell.dashPatternKey), to: self, withKeyPath: DASHPATTERN_KEY)
|
|
|
|
-// self.lineWell.bind(NSBindingName(KMLineWell.startLineStyleKey), to: self, withKeyPath: STARTLINESTYLE_KEY)
|
|
|
|
-// self.lineWell.bind(NSBindingName(KMLineWell.endLineStyleKey), to: self, withKeyPath: ENDLINESTYLE_KEY)
|
|
|
|
-
|
|
|
|
|
|
+ private func _initLayoutUI() {
|
|
|
|
+ let dw = KMAutoSizeLabelFields(labelFields, [lineWidthSlider, lineWidthField, styleButton, dashPatternField, startLineStyleButton, endLineStyleButton], false)
|
|
|
|
+ if (abs(dw) > 0.0) {
|
|
|
|
+ KMResizeWindow(self.window!, dw)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private func _initDefalutValue() {
|
|
self.styleButton.setHelp(KMLocalizedString("Solid line style", "Tool tip message"), for: CPDFBorderStyle.solid.rawValue)
|
|
self.styleButton.setHelp(KMLocalizedString("Solid line style", "Tool tip message"), for: CPDFBorderStyle.solid.rawValue)
|
|
self.styleButton.setHelp(KMLocalizedString("Dashed line style", "Tool tip message"), for: CPDFBorderStyle.dashed.rawValue)
|
|
self.styleButton.setHelp(KMLocalizedString("Dashed line style", "Tool tip message"), for: CPDFBorderStyle.dashed.rawValue)
|
|
self.styleButton.setHelp(KMLocalizedString("Beveled line style", "Tool tip message"), for: CPDFBorderStyle.beveled.rawValue)
|
|
self.styleButton.setHelp(KMLocalizedString("Beveled line style", "Tool tip message"), for: CPDFBorderStyle.beveled.rawValue)
|
|
@@ -163,13 +175,39 @@ class KMLineInspector: NSWindowController {
|
|
self.endLineStyleButton.setHelp(KMLocalizedString("Open arrow end line style", "Tool tip message"), for: CPDFLineStyle.openArrow.rawValue)
|
|
self.endLineStyleButton.setHelp(KMLocalizedString("Open arrow end line style", "Tool tip message"), for: CPDFLineStyle.openArrow.rawValue)
|
|
self.endLineStyleButton.setHelp(KMLocalizedString("Closed arrow end line style", "Tool tip message"), for: CPDFLineStyle.closedArrow.rawValue)
|
|
self.endLineStyleButton.setHelp(KMLocalizedString("Closed arrow end line style", "Tool tip message"), for: CPDFLineStyle.closedArrow.rawValue)
|
|
|
|
|
|
- let dw = KMAutoSizeLabelFields(labelFields, [lineWidthSlider, lineWidthField, styleButton, dashPatternField, startLineStyleButton, endLineStyleButton], false)
|
|
|
|
- if (abs(dw) > 0.0) {
|
|
|
|
- KMResizeWindow(self.window!, dw)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
self.windowFrameAutosaveName = SKLineInspectorFrameAutosaveName
|
|
self.windowFrameAutosaveName = SKLineInspectorFrameAutosaveName
|
|
-
|
|
|
|
|
|
+ self._currentLineChangeAction = .no
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private func _initValues() {
|
|
|
|
+ self.labelFields = [self.labelField1, self.labelField2, self.labelField3, self.labelField4, self.labelField5]
|
|
|
|
+
|
|
|
|
+ self.lineWell.canActivate = false
|
|
|
|
+ self.lineWell.lineWidth = self.lineWidth
|
|
|
|
+ self.lineWell.style = CPDFBorderStyle(rawValue: self.style) ?? .solid
|
|
|
|
+ self.lineWell.dashPattern = self.dashPattern as NSArray
|
|
|
|
+ self.lineWell.startLineStyle = CPDFLineStyle(rawValue: self.startLineStyle) ?? .none
|
|
|
|
+ self.lineWell.endLineStyle = CPDFLineStyle(rawValue: self.endLineStyle) ?? .none
|
|
|
|
+
|
|
|
|
+ self.lineWidthSlider.floatValue = Float(self.lineWidth)
|
|
|
|
+ self.lineWidthField.stringValue = "\(self.lineWidth)"
|
|
|
|
+ self.styleButton.selectedSegment = self.style
|
|
|
|
+ self.startLineStyleButton.selectedSegment = self.startLineStyle
|
|
|
|
+ self.endLineStyleButton.selectedSegment = self.endLineStyle
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private func _initActions() {
|
|
|
|
+ self.lineWidthSlider.target = self
|
|
|
|
+ self.lineWidthSlider.action = #selector(lineWidthSliderAction)
|
|
|
|
+ self.styleButton.target = self
|
|
|
|
+ self.styleButton.action = #selector(styleAction)
|
|
|
|
+ self.startLineStyleButton.target = self
|
|
|
|
+ self.startLineStyleButton.action = #selector(startLineStyleAction)
|
|
|
|
+ self.endLineStyleButton.target = self
|
|
|
|
+ self.endLineStyleButton.action = #selector(endLineStyleAction)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private func _initStyleImages() {
|
|
var image: NSImage?
|
|
var image: NSImage?
|
|
var size = NSMakeSize(29.0, 12.0)
|
|
var size = NSMakeSize(29.0, 12.0)
|
|
image = NSImage.image(with: size, drawingHandler: { rect in
|
|
image = NSImage.image(with: size, drawingHandler: { rect in
|
|
@@ -268,8 +306,11 @@ class KMLineInspector: NSWindowController {
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
self.styleButton.setImage(image, forSegment: CPDFBorderStyle.underline.rawValue)
|
|
self.styleButton.setImage(image, forSegment: CPDFBorderStyle.underline.rawValue)
|
|
-
|
|
|
|
- size = NSMakeSize(24.0, 12.0)
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private func _initStartImages() {
|
|
|
|
+ var image: NSImage?
|
|
|
|
+ var size = NSMakeSize(24.0, 12.0)
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
path.move(to: NSMakePoint(20.0, 6.0))
|
|
path.move(to: NSMakePoint(20.0, 6.0))
|
|
@@ -281,17 +322,6 @@ class KMLineInspector: NSWindowController {
|
|
})
|
|
})
|
|
self.startLineStyleButton.setImage(image, forSegment: CPDFLineStyle.none.rawValue)
|
|
self.startLineStyleButton.setImage(image, forSegment: CPDFLineStyle.none.rawValue)
|
|
|
|
|
|
- image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
|
|
- let path = NSBezierPath()
|
|
|
|
- path.move(to: NSMakePoint(4.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(16.0, 6.0))
|
|
|
|
- path.lineWidth = 2.0
|
|
|
|
- NSColor.black.setStroke()
|
|
|
|
- path.stroke()
|
|
|
|
- return true
|
|
|
|
- })
|
|
|
|
- self.endLineStyleButton.setImage(image, forSegment: CPDFLineStyle.none.rawValue)
|
|
|
|
-
|
|
|
|
image = NSImage.image(with: size, drawingHandler: { rect in
|
|
image = NSImage.image(with: size, drawingHandler: { rect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
path.move(to: NSMakePoint(20.0, 6.0))
|
|
path.move(to: NSMakePoint(20.0, 6.0))
|
|
@@ -302,116 +332,140 @@ class KMLineInspector: NSWindowController {
|
|
path.stroke()
|
|
path.stroke()
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
- self.startLineStyleButton.setImage(image, forSegment: CPDFLineStyle.square.rawValue)
|
|
|
|
-
|
|
|
|
|
|
+ // CPDFLineStyle.square.rawValue
|
|
|
|
+ self.startLineStyleButton.setImage(image, forSegment: 1)
|
|
|
|
+
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
- path.move(to: NSMakePoint(4.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(16.0, 6.0))
|
|
|
|
- path.appendRect(NSMakeRect(13.0, 3.0, 6.0, 6.0))
|
|
|
|
|
|
+ path.move(to: NSMakePoint(20.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(8.0, 6.0))
|
|
|
|
+ path.appendOval(in: NSMakeRect(5.0, 3.0, 6.0, 6.0))
|
|
path.lineWidth = 2.0
|
|
path.lineWidth = 2.0
|
|
NSColor.black.setStroke()
|
|
NSColor.black.setStroke()
|
|
path.stroke()
|
|
path.stroke()
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
- self.endLineStyleButton.setImage(image, forSegment: CPDFLineStyle.square.rawValue)
|
|
|
|
|
|
+ // CPDFLineStyle.circle.rawValue
|
|
|
|
+ self.startLineStyleButton.setImage(image, forSegment: 2)
|
|
|
|
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
path.move(to: NSMakePoint(20.0, 6.0))
|
|
path.move(to: NSMakePoint(20.0, 6.0))
|
|
path.line(to: NSMakePoint(8.0, 6.0))
|
|
path.line(to: NSMakePoint(8.0, 6.0))
|
|
- path.appendOval(in: NSMakeRect(5.0, 3.0, 6.0, 6.0))
|
|
|
|
|
|
+ path.move(to: NSMakePoint(12.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(8.0, 10.0))
|
|
|
|
+ path.line(to: NSMakePoint(4.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(8.0, 2.0))
|
|
|
|
+ path.close()
|
|
path.lineWidth = 2.0
|
|
path.lineWidth = 2.0
|
|
- NSColor.black.setStroke()
|
|
|
|
path.stroke()
|
|
path.stroke()
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
- self.startLineStyleButton.setImage(image, forSegment: CPDFLineStyle.circle.rawValue)
|
|
|
|
|
|
+ // CPDFLineStyle.diamond.rawValue
|
|
|
|
+ self.startLineStyleButton.setImage(image, forSegment: 3)
|
|
|
|
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
- path.move(to: NSMakePoint(4.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(16.0, 6.0))
|
|
|
|
- path.appendOval(in: NSMakeRect(13.0, 3.0, 6.0, 6.0))
|
|
|
|
|
|
+ path.move(to: NSMakePoint(20.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(8.0, 6.0))
|
|
|
|
+ path.move(to: NSMakePoint(14.0, 3.0))
|
|
|
|
+ path.line(to: NSMakePoint(8.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(14.0, 9.0))
|
|
path.lineWidth = 2.0
|
|
path.lineWidth = 2.0
|
|
NSColor.black.setStroke()
|
|
NSColor.black.setStroke()
|
|
path.stroke()
|
|
path.stroke()
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
- self.endLineStyleButton.setImage(image, forSegment: CPDFLineStyle.circle.rawValue)
|
|
|
|
|
|
+ // CPDFLineStyle.openArrow.rawValue
|
|
|
|
+ self.startLineStyleButton.setImage(image, forSegment: 4)
|
|
|
|
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
path.move(to: NSMakePoint(20.0, 6.0))
|
|
path.move(to: NSMakePoint(20.0, 6.0))
|
|
path.line(to: NSMakePoint(8.0, 6.0))
|
|
path.line(to: NSMakePoint(8.0, 6.0))
|
|
- path.move(to: NSMakePoint(12.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(8.0, 10.0))
|
|
|
|
- path.line(to: NSMakePoint(4.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(8.0, 2.0))
|
|
|
|
|
|
+ path.move(to: NSMakePoint(14.0, 3.0))
|
|
|
|
+ path.line(to: NSMakePoint(8.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(14.0, 9.0))
|
|
path.close()
|
|
path.close()
|
|
- path.lineWidth = 2.0
|
|
|
|
|
|
+ path.lineWidth = 2
|
|
|
|
+ NSColor.black.setStroke()
|
|
path.stroke()
|
|
path.stroke()
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
- self.startLineStyleButton.setImage(image, forSegment: CPDFLineStyle.diamond.rawValue)
|
|
|
|
-
|
|
|
|
|
|
+ // CPDFLineStyle.closedArrow.rawValue
|
|
|
|
+ self.startLineStyleButton.setImage(image, forSegment: 5)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private func _initEndImages() {
|
|
|
|
+ var image: NSImage?
|
|
|
|
+ var size = NSMakeSize(24.0, 12.0)
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
path.move(to: NSMakePoint(4.0, 6.0))
|
|
path.move(to: NSMakePoint(4.0, 6.0))
|
|
path.line(to: NSMakePoint(16.0, 6.0))
|
|
path.line(to: NSMakePoint(16.0, 6.0))
|
|
- path.move(to: NSMakePoint(12.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(16.0, 10.0))
|
|
|
|
- path.line(to: NSMakePoint(20.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(16.0, 2.0))
|
|
|
|
- path.close()
|
|
|
|
path.lineWidth = 2.0
|
|
path.lineWidth = 2.0
|
|
|
|
+ NSColor.black.setStroke()
|
|
path.stroke()
|
|
path.stroke()
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
- self.endLineStyleButton.setImage(image, forSegment: CPDFLineStyle.diamond.rawValue)
|
|
|
|
-
|
|
|
|
|
|
+ self.endLineStyleButton.setImage(image, forSegment: CPDFLineStyle.none.rawValue)
|
|
|
|
+
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
- path.move(to: NSMakePoint(20.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(8.0, 6.0))
|
|
|
|
- path.move(to: NSMakePoint(14.0, 3.0))
|
|
|
|
- path.line(to: NSMakePoint(8.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(14.0, 9.0))
|
|
|
|
|
|
+ path.move(to: NSMakePoint(4.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(16.0, 6.0))
|
|
|
|
+ path.appendRect(NSMakeRect(13.0, 3.0, 6.0, 6.0))
|
|
path.lineWidth = 2.0
|
|
path.lineWidth = 2.0
|
|
NSColor.black.setStroke()
|
|
NSColor.black.setStroke()
|
|
path.stroke()
|
|
path.stroke()
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
- self.startLineStyleButton.setImage(image, forSegment: CPDFLineStyle.openArrow.rawValue)
|
|
|
|
|
|
+ // CPDFLineStyle.square.rawValue
|
|
|
|
+ self.endLineStyleButton.setImage(image, forSegment: 1)
|
|
|
|
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
path.move(to: NSMakePoint(4.0, 6.0))
|
|
path.move(to: NSMakePoint(4.0, 6.0))
|
|
path.line(to: NSMakePoint(16.0, 6.0))
|
|
path.line(to: NSMakePoint(16.0, 6.0))
|
|
- path.move(to: NSMakePoint(10.0, 3.0))
|
|
|
|
- path.line(to: NSMakePoint(16.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(10.0, 9.0))
|
|
|
|
- path.lineWidth = 2
|
|
|
|
|
|
+ path.appendOval(in: NSMakeRect(13.0, 3.0, 6.0, 6.0))
|
|
|
|
+ path.lineWidth = 2.0
|
|
NSColor.black.setStroke()
|
|
NSColor.black.setStroke()
|
|
path.stroke()
|
|
path.stroke()
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
- self.endLineStyleButton.setImage(image, forSegment: CPDFLineStyle.openArrow.rawValue)
|
|
|
|
|
|
+ // CPDFLineStyle.circle.rawValue
|
|
|
|
+ self.endLineStyleButton.setImage(image, forSegment: 2)
|
|
|
|
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
- path.move(to: NSMakePoint(20.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(8.0, 6.0))
|
|
|
|
- path.move(to: NSMakePoint(14.0, 3.0))
|
|
|
|
- path.line(to: NSMakePoint(8.0, 6.0))
|
|
|
|
- path.line(to: NSMakePoint(14.0, 9.0))
|
|
|
|
|
|
+ path.move(to: NSMakePoint(4.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(16.0, 6.0))
|
|
|
|
+ path.move(to: NSMakePoint(12.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(16.0, 10.0))
|
|
|
|
+ path.line(to: NSMakePoint(20.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(16.0, 2.0))
|
|
path.close()
|
|
path.close()
|
|
|
|
+ path.lineWidth = 2.0
|
|
|
|
+ path.stroke()
|
|
|
|
+ return true
|
|
|
|
+ })
|
|
|
|
+ // CPDFLineStyle.diamond.rawValue
|
|
|
|
+ self.endLineStyleButton.setImage(image, forSegment: 3)
|
|
|
|
+
|
|
|
|
+ image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
|
|
+ let path = NSBezierPath()
|
|
|
|
+ path.move(to: NSMakePoint(4.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(16.0, 6.0))
|
|
|
|
+ path.move(to: NSMakePoint(10.0, 3.0))
|
|
|
|
+ path.line(to: NSMakePoint(16.0, 6.0))
|
|
|
|
+ path.line(to: NSMakePoint(10.0, 9.0))
|
|
path.lineWidth = 2
|
|
path.lineWidth = 2
|
|
NSColor.black.setStroke()
|
|
NSColor.black.setStroke()
|
|
path.stroke()
|
|
path.stroke()
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
- self.startLineStyleButton.setImage(image, forSegment: CPDFLineStyle.closedArrow.rawValue)
|
|
|
|
|
|
+ // CPDFLineStyle.openArrow.rawValue
|
|
|
|
+ self.endLineStyleButton.setImage(image, forSegment: 4)
|
|
|
|
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
image = NSImage.image(with: size, drawingHandler: { dstRect in
|
|
let path = NSBezierPath()
|
|
let path = NSBezierPath()
|
|
@@ -426,7 +480,8 @@ class KMLineInspector: NSWindowController {
|
|
path.stroke()
|
|
path.stroke()
|
|
return true
|
|
return true
|
|
})
|
|
})
|
|
- self.endLineStyleButton.setImage(image, forSegment: CPDFLineStyle.closedArrow.rawValue)
|
|
|
|
|
|
+ // CPDFLineStyle.closedArrow.rawValue
|
|
|
|
+ self.endLineStyleButton.setImage(image, forSegment: 5)
|
|
}
|
|
}
|
|
|
|
|
|
override func setNilValueForKey(_ key: String) {
|
|
override func setNilValueForKey(_ key: String) {
|
|
@@ -464,6 +519,51 @@ class KMLineInspector: NSWindowController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // MARK: - Actions
|
|
|
|
+
|
|
|
|
+ @objc func lineWidthSliderAction(_ sender: NSSlider) {
|
|
|
|
+ self.lineWidth = sender.floatValue.cgFloat
|
|
|
|
+ self.lineWidthField.stringValue = String(format: "%.0f", sender.floatValue)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc func styleAction(_ sender: NSSegmentedControl) {
|
|
|
|
+ self.style = sender.selectedSegment
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc func startLineStyleAction(_ sender: NSSegmentedControl) {
|
|
|
|
+ let index = sender.selectedSegment
|
|
|
|
+ if index == 0 {
|
|
|
|
+ self.startLineStyle = CPDFLineStyle.none.rawValue
|
|
|
|
+ } else if index == 1 {
|
|
|
|
+ self.startLineStyle = CPDFLineStyle.square.rawValue
|
|
|
|
+ } else if index == 2 {
|
|
|
|
+ self.startLineStyle = CPDFLineStyle.circle.rawValue
|
|
|
|
+ } else if index == 3 {
|
|
|
|
+ self.startLineStyle = CPDFLineStyle.diamond.rawValue
|
|
|
|
+ } else if index == 4 {
|
|
|
|
+ self.startLineStyle = CPDFLineStyle.openArrow.rawValue
|
|
|
|
+ } else if index == 5 {
|
|
|
|
+ self.startLineStyle = CPDFLineStyle.closedArrow.rawValue
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc func endLineStyleAction(_ sender: NSSegmentedControl) {
|
|
|
|
+ let index = sender.selectedSegment
|
|
|
|
+ if index == 0 {
|
|
|
|
+ self.endLineStyle = CPDFLineStyle.none.rawValue
|
|
|
|
+ } else if index == 1 {
|
|
|
|
+ self.endLineStyle = CPDFLineStyle.square.rawValue
|
|
|
|
+ } else if index == 2 {
|
|
|
|
+ self.endLineStyle = CPDFLineStyle.circle.rawValue
|
|
|
|
+ } else if index == 3 {
|
|
|
|
+ self.endLineStyle = CPDFLineStyle.diamond.rawValue
|
|
|
|
+ } else if index == 4 {
|
|
|
|
+ self.endLineStyle = CPDFLineStyle.openArrow.rawValue
|
|
|
|
+ } else if index == 5 {
|
|
|
|
+ self.endLineStyle = CPDFLineStyle.closedArrow.rawValue
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - Private Methods
|
|
// MARK: - Private Methods
|