|
@@ -308,6 +308,36 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
self.imageAlpha = 1.0
|
|
|
}
|
|
|
|
|
|
+ func stampStyle(stampColor: KMAnnotationStampColorType) -> CPDFStampStyle {
|
|
|
+ switch stampColor {
|
|
|
+ case .RedColor, .LeftStampRedColor, .RightStampRedColor:
|
|
|
+ return .red
|
|
|
+ case .GreenColor, .LeftStampGreenColor, .RightStampGreenColor:
|
|
|
+ return .green
|
|
|
+ case .BlueColor, .LeftStampBlueColor, .RightStampBlueColor:
|
|
|
+ return .blue
|
|
|
+ case .BlackColor, .Normal:
|
|
|
+ return .white
|
|
|
+ default:
|
|
|
+ return .white
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func stampShape(stampColor: KMAnnotationStampColorType) -> CPDFStampShape {
|
|
|
+ switch stampColor {
|
|
|
+ case .RedColor, .GreenColor, .BlueColor, .BlackColor:
|
|
|
+ return .rectangle
|
|
|
+ case .LeftStampRedColor, .LeftStampGreenColor, .LeftStampBlueColor:
|
|
|
+ return .arrowLeft
|
|
|
+ case .RightStampRedColor, .RightStampGreenColor, .RightStampBlueColor:
|
|
|
+ return .arrowRight
|
|
|
+ case .Normal:
|
|
|
+ return .none
|
|
|
+ default:
|
|
|
+ return .rectangle
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
func sizeOfString(string: String, witFontSize fontSize: CGFloat) -> NSSize {
|
|
|
let font = NSFont(name: "Helvetica", size: fontSize)
|
|
|
|
|
@@ -329,6 +359,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
|
|
|
return size
|
|
|
}
|
|
|
+
|
|
|
func stampPreviewImage() -> NSImage? {
|
|
|
if !self.isStandardStamp {
|
|
|
self.setCustomStampString(self.contentStr, dateString: self.dateString)
|
|
@@ -353,6 +384,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
|
|
|
return image
|
|
|
}
|
|
|
+
|
|
|
func drawPreviewTextWithContextRef(_ context: CGContext?) {
|
|
|
NSGraphicsContext.saveGraphicsState()
|
|
|
if context != nil {
|
|
@@ -483,6 +515,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
}
|
|
|
NSGraphicsContext.restoreGraphicsState()
|
|
|
}
|
|
|
+
|
|
|
func stampStringDefaultFontSize() -> CGFloat {
|
|
|
var tSize = StampStringDefaultFontSize
|
|
|
if self.needExchangeFontSize {
|
|
@@ -490,6 +523,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
}
|
|
|
return tSize
|
|
|
}
|
|
|
+
|
|
|
func stampDateStringDefaultFontSize() -> CGFloat {
|
|
|
var tSize = StampDateStringDefaultFontSize
|
|
|
if self.needExchangeFontSize {
|
|
@@ -497,10 +531,10 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
}
|
|
|
return tSize
|
|
|
}
|
|
|
+
|
|
|
func setCustomStampString(_ string: String, dateString: String) {
|
|
|
isStandardStamp = false
|
|
|
isCustomImageStamp = false
|
|
|
-// self.setName("")
|
|
|
self.contentStr = string
|
|
|
self.dateString = dateString
|
|
|
|
|
@@ -559,6 +593,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
self.bounds = bounds
|
|
|
self.borderBounds = self.bounds
|
|
|
}
|
|
|
+
|
|
|
func getBtnStampImage() -> NSImage? {
|
|
|
if self.isCustomImageStamp {
|
|
|
return self.image
|
|
@@ -587,6 +622,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
return image
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
func drawBorderWithContext(context: CGContext) {
|
|
|
if .Witness == self.customStampType {
|
|
|
c01 = 1-0.0274506
|
|
@@ -702,6 +738,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
func drawArrowsBorder(context: CGContext, withBounds tmpBounds: NSRect) { context.beginPath()
|
|
|
let tmpHeight = 11.0 * tmpBounds.size.height/50
|
|
|
let tmpWidth = 3.0 * tmpBounds.size.height/50
|
|
@@ -757,6 +794,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
|
|
|
context.strokePath()
|
|
|
}
|
|
|
+
|
|
|
func drawTextWithContextRef(context: CGContext?) {
|
|
|
NSGraphicsContext.saveGraphicsState()
|
|
|
if context != nil {
|
|
@@ -934,6 +972,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
func drawTickBorder(context: CGContext, withBounds tmpBounds: CGRect) {
|
|
|
let w = tmpBounds.size.height / 23
|
|
|
let h1 = 20.05784 * w
|
|
@@ -985,6 +1024,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
context.addCurve(to: CGPoint(x: tmpBounds.origin.x + w6, y: tmpBounds.origin.y + h6), control1: CGPoint(x: tmpBounds.origin.x + w6 - 2.57129 * w, y: tmpBounds.origin.y + h6 + 1.68213 * w), control2: CGPoint(x: tmpBounds.origin.x + w1 - 0.05078 * w, y: tmpBounds.origin.y + h1 - 0.02491 * w))
|
|
|
context.strokePath()
|
|
|
}
|
|
|
+
|
|
|
func drawCrossBorder(context: CGContext, withBounds tmpBoundsOring: NSRect) {
|
|
|
let w = tmpBoundsOring.size.height / 23
|
|
|
let tmpBounds = tmpBoundsOring.insetBy(dx: 2 * w, dy: 2 * w)
|
|
@@ -1048,6 +1088,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
|
|
|
context.strokePath()
|
|
|
}
|
|
|
+
|
|
|
func drawBlackCross(context: CGContext, withBounds tmpBounds: CGRect) {
|
|
|
let w = tmpBounds.size.height / 18
|
|
|
let insetBounds = tmpBounds.insetBy(dx: 2 * w, dy: 2 * w)
|
|
@@ -1064,6 +1105,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
|
|
|
context.strokePath()
|
|
|
}
|
|
|
+
|
|
|
func drawBlackChick(context: CGContext, withBounds tmpBounds: CGRect) {
|
|
|
let w = tmpBounds.size.height / 18
|
|
|
let insetBounds = tmpBounds.insetBy(dx: 2 * w, dy: 2 * w)
|
|
@@ -1078,6 +1120,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
|
|
|
context.strokePath()
|
|
|
}
|
|
|
+
|
|
|
func drawBlackCircle(context: CGContext, withBounds tmpBounds: CGRect) {
|
|
|
let w = tmpBounds.size.height / 18
|
|
|
let magicNumber: CGFloat = 0.551784
|
|
@@ -1097,6 +1140,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
context.drawPath(using: .fillStroke)
|
|
|
context.strokePath()
|
|
|
}
|
|
|
+
|
|
|
func drawLeftCommonBorder(context: CGContext, withBounds tmpBounds: CGRect) {
|
|
|
drawLeftBounds(context: context, withBounds: tmpBounds)
|
|
|
context.clip()
|
|
@@ -1122,6 +1166,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
|
|
|
context.strokePath()
|
|
|
}
|
|
|
+
|
|
|
func drawLeftBounds(context: CGContext, withBounds tmpBounds: CGRect) {
|
|
|
let tmpHeight = 11.0 * tmpBounds.size.height / 50
|
|
|
let tmpWidth = 3.0 * tmpBounds.size.height / 50
|
|
@@ -1150,6 +1195,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
|
|
|
context.closePath()
|
|
|
}
|
|
|
+
|
|
|
func drawRightCommonBorder(context: CGContext, withBounds tmpBounds: CGRect) { drawRightBounds(context: context, withBounds: tmpBounds)
|
|
|
context.clip()
|
|
|
|
|
@@ -1174,6 +1220,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
drawRightBounds(context: context, withBounds: tmpBounds)
|
|
|
context.strokePath()
|
|
|
}
|
|
|
+
|
|
|
func drawRightBounds(context: CGContext, withBounds tmpBounds: NSRect) {
|
|
|
let tmpHeight = 11.0 * tmpBounds.size.height/50
|
|
|
let tmpWidth = 3.0 * tmpBounds.size.height/50
|
|
@@ -1202,6 +1249,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
|
|
|
context.closePath()
|
|
|
}
|
|
|
+
|
|
|
func drawNormalBorder(context: CGContext, withBounds tmpBounds: NSRect) {
|
|
|
context.beginPath()
|
|
|
let tmpHeight = 11.0 * tmpBounds.size.height/50
|
|
@@ -1254,6 +1302,7 @@ let StampStringEdgeSizeScale = 0.1
|
|
|
|
|
|
context.strokePath()
|
|
|
}
|
|
|
+
|
|
|
func drawCommonBorder(context: CGContext, withBounds tmpBounds: CGRect) {
|
|
|
context.beginPath()
|
|
|
let tmpHeight = 11.0 * tmpBounds.size.height/50
|