123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- //
- // KMPDFToolbarManager.swift
- // PDF Reader Pro
- //
- // Created by Niehaoyu on 2024/10/22.
- //
- import Foundation
- import KMComponentLibrary
- class KMPDFToolbarManager: NSObject {
- @objc public static let manager = KMPDFToolbarManager()
-
- var toolsType: KMPDFViewToolsType = .Select
-
- var viewProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true)
-
- var pageProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true)
-
- var toolsProperty: ComponentDropdownToolProperty = ComponentDropdownToolProperty(state: .normal, leftIcon: NSImage(named: "toolbar_Tools_select"), showDropdown: true)
- var tools_selectProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "toolbar_Tools_select"), keyEquivalent: KMLocalizedString("⌘ 1"), text: KMLocalizedString("Select"))
- var tools_scrollProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "toolbar_Tools_scroll"), keyEquivalent: KMLocalizedString("⌘ 2"), text: KMLocalizedString("Scroll"))
- var tools_contentProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "toolbar_Tools_content"), keyEquivalent: KMLocalizedString("⌘ 3"), text: KMLocalizedString("Content Selection"))
- var tools_magnifyProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "toolbar_Tools_magnify"), keyEquivalent: KMLocalizedString("⌘ 4"), text: KMLocalizedString("Magnify"))
- var tools_areaProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "toolbar_Tools_zoom"), keyEquivalent: KMLocalizedString("⌘ 5"), text: KMLocalizedString("Area Zoom"))
-
- var selectZoomProperty: ComponentSelectZoomProperty = ComponentSelectZoomProperty(state: .normal, isDisabled: false, text: "100%")
-
- override init() {
- super.init()
-
- self.initData()
-
- }
-
- func initData() {
- viewProperty.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_View")
-
- pageProperty.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_Page")
-
- reloadToolsData()
- var menuItemArr: [ComponentMenuitemProperty] = []
- if true {
- menuItemArr.append(tools_selectProperty)
- menuItemArr.append(tools_scrollProperty)
- menuItemArr.append(tools_contentProperty)
- menuItemArr.append(tools_magnifyProperty)
- menuItemArr.append(tools_areaProperty)
- toolsProperty.menuItemArr = menuItemArr
- }
-
- }
-
-
- //MARK: - 刷新tools工具
- func reloadToolsData() {
- if toolsType == .Select {
- toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_select")
- } else if toolsType == .Scroll {
- toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_scroll")
- } else if toolsType == .Content_Selection {
- toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_content")
- } else if toolsType == .Magnify {
- toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_magnify")
- } else if toolsType == .AreaZoom {
- toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_zoom")
- }
- }
- }
|