From 536aff10704059c941101a7bd3d799dd253c561d Mon Sep 17 00:00:00 2001 From: zonble Date: Fri, 14 Jan 2022 01:38:32 +0800 Subject: [PATCH] Removes unused files. --- Packages/NonModalAlertWindow/.gitignore | 7 - Packages/NonModalAlertWindow/Package.swift | 25 --- Packages/NonModalAlertWindow/README.md | 3 - .../NonModalAlertWindowController.swift | 147 ------------------ .../NonModalAlertWindowController.xib | 85 ---------- 5 files changed, 267 deletions(-) delete mode 100644 Packages/NonModalAlertWindow/.gitignore delete mode 100644 Packages/NonModalAlertWindow/Package.swift delete mode 100644 Packages/NonModalAlertWindow/README.md delete mode 100644 Packages/NonModalAlertWindow/Sources/NonModalAlertWindow/NonModalAlertWindowController.swift delete mode 100644 Packages/NonModalAlertWindow/Sources/NonModalAlertWindow/Resources/NonModalAlertWindowController.xib diff --git a/Packages/NonModalAlertWindow/.gitignore b/Packages/NonModalAlertWindow/.gitignore deleted file mode 100644 index bb460e7b..00000000 --- a/Packages/NonModalAlertWindow/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.DS_Store -/.build -/Packages -/*.xcodeproj -xcuserdata/ -DerivedData/ -.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata diff --git a/Packages/NonModalAlertWindow/Package.swift b/Packages/NonModalAlertWindow/Package.swift deleted file mode 100644 index 7e9a84ed..00000000 --- a/Packages/NonModalAlertWindow/Package.swift +++ /dev/null @@ -1,25 +0,0 @@ -// swift-tools-version:5.5 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "NonModalAlertWindow", - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "NonModalAlertWindow", - targets: ["NonModalAlertWindow"]), - ], - dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "NonModalAlertWindow", - dependencies: []), - ] -) diff --git a/Packages/NonModalAlertWindow/README.md b/Packages/NonModalAlertWindow/README.md deleted file mode 100644 index 93b2b884..00000000 --- a/Packages/NonModalAlertWindow/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# NonModalAlertWindow - -A description of this package. diff --git a/Packages/NonModalAlertWindow/Sources/NonModalAlertWindow/NonModalAlertWindowController.swift b/Packages/NonModalAlertWindow/Sources/NonModalAlertWindow/NonModalAlertWindowController.swift deleted file mode 100644 index 936250e9..00000000 --- a/Packages/NonModalAlertWindow/Sources/NonModalAlertWindow/NonModalAlertWindowController.swift +++ /dev/null @@ -1,147 +0,0 @@ -// -// NonModalAlertWindowController.swift -// -// Copyright (c) 2011 The McBopomofo Project. -// -// Contributors: -// Mengjuei Hsieh (@mjhsieh) -// Weizhong Yang (@zonble) -// -// Based on the Syrup Project and the Formosana Library -// by Lukhnos Liu (@lukhnos). -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -import Cocoa - -@objc public protocol NonModalAlertWindowControllerDelegate: AnyObject { - func nonModalAlertWindowControllerDidConfirm(_ controller: NonModalAlertWindowController) - func nonModalAlertWindowControllerDidCancel(_ controller: NonModalAlertWindowController) -} - -@objc public class NonModalAlertWindowController: NSWindowController { - @objc (sharedInstance) - public static let shared: NonModalAlertWindowController = { - NSLog("shaerd???") - guard let path = Bundle.main.path(forResource: "NonModalAlertWindow_NonModalAlertWindow", ofType: "bundle"), - let modelBudle = Bundle(path: path), - let xibPath = modelBudle.path(forResource: "NonModalAlertWindowController", ofType: "nib") - else { - let controller = NonModalAlertWindowController(windowNibName: "NonModalAlertWindowController") - return controller - } - NSLog("shared path \(path)") - NSLog("shared modelBudle \(modelBudle)") - NSLog("shared xibPath \(xibPath)") - let controller = NonModalAlertWindowController(windowNibPath: xibPath, owner: self) - return controller - }() - - @IBOutlet weak var titleTextField: NSTextField! - @IBOutlet weak var contentTextField: NSTextField! - @IBOutlet weak var confirmButton: NSButton! - @IBOutlet weak var cancelButton: NSButton! - weak var delegate: NonModalAlertWindowControllerDelegate? - - @objc public func show(title: String, content: String, confirmButtonTitle: String, cancelButtonTitle: String?, cancelAsDefault: Bool, delegate: NonModalAlertWindowControllerDelegate?) { - if window?.isVisible == true { - self.delegate?.nonModalAlertWindowControllerDidCancel(self) - } - - self.delegate = delegate - - var oldFrame = confirmButton.frame - confirmButton.title = confirmButtonTitle - confirmButton.sizeToFit() - - var newFrame = confirmButton.frame - newFrame.size.width = max(90, newFrame.size.width + 10) - newFrame.origin.x += oldFrame.size.width - newFrame.size.width - confirmButton.frame = newFrame - - if let cancelButtonTitle = cancelButtonTitle { - cancelButton.title = cancelButtonTitle - cancelButton.sizeToFit() - var adjustFrame = cancelButton.frame - adjustFrame.size.width = max(90, adjustFrame.size.width + 10) - adjustFrame.origin.x = newFrame.origin.x - adjustFrame.size.width - confirmButton.frame = adjustFrame - cancelButton.isHidden = false - } else { - cancelButton.isHidden = true - } - - cancelButton.nextKeyView = confirmButton - confirmButton.nextKeyView = cancelButton - - if cancelButtonTitle != nil { - if cancelAsDefault { - window?.defaultButtonCell = cancelButton.cell as? NSButtonCell - } else { - cancelButton.keyEquivalent = " " - window?.defaultButtonCell = confirmButton.cell as? NSButtonCell - } - } else { - window?.defaultButtonCell = confirmButton.cell as? NSButtonCell - } - - titleTextField.stringValue = title - - oldFrame = contentTextField.frame - contentTextField.stringValue = content - - var infiniteHeightFrame = oldFrame - infiniteHeightFrame.size.width -= 4.0 - infiniteHeightFrame.size.height = 10240 - newFrame = (content as NSString).boundingRect(with: infiniteHeightFrame.size, options: [.usesLineFragmentOrigin], attributes: [.font: contentTextField.font!]) - newFrame.size.width = max(newFrame.size.width, oldFrame.size.width) - newFrame.size.height += 4.0 - newFrame.origin = oldFrame.origin - newFrame.origin.y -= (newFrame.size.height - oldFrame.size.height) - contentTextField.frame = newFrame - - var windowFrame = window?.frame ?? NSRect.zero - windowFrame.size.height += (newFrame.size.height - oldFrame.size.height) - window?.level = NSWindow.Level(Int(CGShieldingWindowLevel()) + 1) - window?.setFrame(windowFrame, display: true) - window?.center() - window?.makeKeyAndOrderFront(self) - NSApp.activate(ignoringOtherApps: true) - } - - @IBAction func confirmButtonAction(_ sender: Any) { - delegate?.nonModalAlertWindowControllerDidConfirm(self) - window?.orderOut(self) - } - - @IBAction func cancelButtonAction(_ sender: Any) { - cancel(sender) - } - - @objc public func cancel(_ sender: Any) { - delegate?.nonModalAlertWindowControllerDidCancel(self) - delegate = nil - window?.orderOut(self) - } - -} diff --git a/Packages/NonModalAlertWindow/Sources/NonModalAlertWindow/Resources/NonModalAlertWindowController.xib b/Packages/NonModalAlertWindow/Sources/NonModalAlertWindow/Resources/NonModalAlertWindowController.xib deleted file mode 100644 index 8c378007..00000000 --- a/Packages/NonModalAlertWindow/Sources/NonModalAlertWindow/Resources/NonModalAlertWindowController.xib +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -