123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- //
- // SelectVC.swift
- // PDF Reader Pro Edition
- //
- // Created by Niehaoyu on 2024/9/3.
- //
- import Cocoa
- import KMComponentLibrary
- class SelectVC: NSViewController {
- @IBOutlet weak var selectItemView: ComponentSelect!
-
- @IBOutlet weak var selectZoom: ComponentSelectZoom!
-
-
- @IBOutlet weak var sizeBox: NSComboBox!
-
- @IBOutlet weak var disableBtn: NSButton!
- @IBOutlet weak var errorBtn: NSButton!
- @IBOutlet weak var showLeftIcon: NSButton!
- @IBOutlet weak var placeholderField: NSTextField!
- @IBOutlet weak var errorField: NSTextField!
- @IBOutlet weak var createableBtn: NSButton!
-
- @IBOutlet weak var itemheightConst: NSLayoutConstraint!
-
- @IBOutlet weak var zoomDisableBtn: NSButton!
-
-
-
- var groupView: ComponentGroup!
-
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- self.sizeBox.selectItem(at: 0)
- self.reloadData()
-
-
-
- }
-
- func reloadData() {
-
- var size: ComponentSize = .m
- if self.sizeBox.indexOfSelectedItem == 0 {
- size = .m
- } else if self.sizeBox.indexOfSelectedItem == 1 {
- size = .s
- } else if self.sizeBox.indexOfSelectedItem == 2 {
- size = .xs
- } else if self.sizeBox.indexOfSelectedItem == 3 {
- size = .xxs
- }
- let disable = self.disableBtn.state == .on
- let isError = self.errorBtn.state == .on
- let lefticon = self.showLeftIcon.state == .on
- let placeholder = self.placeholderField.stringValue
- let errorText = self.errorField.stringValue
-
-
- let properties: ComponentSelectProperties = ComponentSelectProperties.init(size: size,
- state: .normal,
- isDisabled: disable,
- isError: isError,
- leftIcon: lefticon,
- placeholder: placeholder,
- errorText: errorText,
- creatable: self.createableBtn.state == .on)
-
- selectItemView.properties = properties
-
- self.itemheightConst.constant = selectItemView.properties.propertyInfo.viewHeight
-
- var menuItemArr: [ComponentMenuitemProperty] = []
- for i in 0...5 {
- let properties_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, keyEquivalent: nil, text: "menu item - " + String(i))
- menuItemArr.append(properties_Menuitem)
- }
- selectItemView.updateMenuItemsArr(menuItemArr)
-
- selectZoom.properties = ComponentSelectZoomProperty(state: .normal,
- isDisabled: zoomDisableBtn.state == .on,
- text: "100")
-
- }
-
- @IBAction func boxAction(_ sender: Any) {
- self.reloadData()
- }
-
- @IBAction func btnAction(_ sender: Any) {
- self.reloadData()
- }
-
- }
|