Bläddra i källkod

【注释】修复Table注释标题与表尾功能效果

wanjun 10 månader sedan
förälder
incheckning
2f16e5f66e

+ 14 - 10
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMAnnotationTableViewController.swift

@@ -550,19 +550,19 @@ class KMAnnotationTableViewController: NSViewController {
         pdfView!.needsDisplay = true
     }
 
-    @IBAction func titleEndTablePopUpButtonAction(_ sender: NSPopUpButton) {
+    @IBAction func titleEndTablePopUpButtonAction(_ sender: KMPopUpButton) {
         guard let table = self.annotation else {
             return
         }
         
         let bounds = self.annotation!.bounds
-        guard let popButton = sender as? NSPopUpButton else {
+        guard let popButton = sender as? KMPopUpButton else {
             return
         }
         
         switch popButton.tag {
         case 100:
-            let count = (popButton.titleOfSelectedItem as NSString?)?.integerValue ?? 0 - table.sidebarCount()
+            let count = (Int(popButton.titleOfSelectedItem ?? "0") ?? 0) - table.sidebarCount()
             if count > 0 {
                 for _ in 0..<count {
                     table.insertColumnAtIndex(before: 0, with: .round)
@@ -572,24 +572,28 @@ class KMAnnotationTableViewController: NSViewController {
                     table.removeColumn(at: 0)
                 }
             }
-            table.bounds.origin.x -= (bounds.size.width - table.bounds.size.width)
+            table.bounds = NSRectFromCGRect(CGRect(x: table.bounds.origin.x - (bounds.size.width - table.bounds.size.width),
+                                                   y: table.bounds.origin.y,
+                                                   width: table.bounds.size.width, height: table.bounds.size.height))
         case 101:
-            let count = (popButton.titleOfSelectedItem as NSString?)?.integerValue ?? 0 - table.headerCount()
+            let count = (Int(popButton.titleOfSelectedItem ?? "0") ?? 0) - table.headerCount()
             if count > 0 {
                 for _ in 0..<count {
-                    table.insertColumnAtIndex(before: 0, with: .round)
+                    table.insertRowAtIndex(before: 0, with: .round)
                 }
             } else if count < 0 {
                 for _ in count..<0 {
                     table.removeRow(at: 0)
                 }
             }
-            table.bounds.origin.y -= (table.bounds.size.height - bounds.size.height)
+            table.bounds = NSRectFromCGRect(CGRect(x: table.bounds.origin.x,
+                                                   y: table.bounds.origin.y - (table.bounds.size.height - bounds.size.height),
+                                                   width: table.bounds.size.width, height: table.bounds.size.height))
         case 102:
-            let count = (popButton.titleOfSelectedItem as NSString?)?.integerValue ?? 0 - table.footerCount()
+            let count = (Int(popButton.titleOfSelectedItem ?? "0") ?? 0) - table.footerCount()
             if count > 0 {
                 for _ in 0..<count {
-                    table.insertColumnAtIndex(before: table.rowNumber - 1, with: .bevel)
+                    table.insertRow(atIndexBehind: table.rowNumber - 1, with: .bevel)
                 }
             } else if count < 0 {
                 for _ in count..<0 {
@@ -602,7 +606,7 @@ class KMAnnotationTableViewController: NSViewController {
         
         table.drawLine(self.point)
         reloadData(with: self.point)
-        pdfView!.needsDisplay = true
+        pdfView?.setNeedsDisplayAnnotationViewFor(table.page)
     }
     
     @IBAction func widthPopUpButtonAction(_ sender: NSPopUpButton) {