1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- //
- // KMComboBox.swift
- // PDF Master
- //
- // Created by wanjun on 2022/11/29.
- //
- import Cocoa
- enum KMComboBoxType : Int {
- case none = 0
- }
- class KMComboBox: NSComboBox {
-
- var comboxRect: CGRect = CGRect(x: 0, y: 0, width: 0, height: 0)
- var _type: KMComboBoxType = .none
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- switch type {
- case .none:
- var p = comboxRect.origin
- p.x += comboxRect.width - 20
- p.y += (comboxRect.height - 16) / 2
- NSColor.clear.setFill()
- NSRect(x: p.x, y: 0, width: 16.0, height: comboxRect.height).fill()
- let image = NSImage(named: "KMImageNameUXIconBtnArrowDown")
- var rect = NSRect.zero
- rect.size = CGSize(width: 16.0, height: 16.0)
- image!.draw(in: NSRect(x: p.x, y: p.y, width: 16.0, height: 16.0), from: rect, operation: .sourceOver, fraction: 1.0, respectFlipped: true, hints: nil)
- default:
- break
- }
- }
-
- var type: KMComboBoxType {
- get {
- return _type
- }
- set {
- _type = newValue
- switch newValue {
- case .none:
- self.wantsLayer = true
- self.layer?.cornerRadius = 1.0
- self.layer?.borderWidth = 0.5
- self.layer?.borderColor = .black
- self.backgroundColor = .white
- self.isButtonBordered = false
- default:
- break
- }
- }
- }
- }
|