2016-06-15 23:11:35 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
2016-06-16 19:36:26 +03:00
|
|
|
extension CGRect {
|
|
|
|
|
|
|
|
func fill() {
|
|
|
|
NSRectFill(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-24 22:08:34 +03:00
|
|
|
extension NSRange: CustomStringConvertible {
|
|
|
|
|
|
|
|
public var description: String {
|
|
|
|
var location = ""
|
|
|
|
if self.location == NSNotFound {
|
|
|
|
location = "NotFound"
|
|
|
|
} else {
|
|
|
|
location = String(self.location)
|
|
|
|
}
|
|
|
|
return "NSRange<\(location), \(self.length)>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-15 23:11:35 +03:00
|
|
|
extension NSView {
|
|
|
|
|
|
|
|
/// - Returns: Rects currently being drawn
|
|
|
|
/// - Warning: Call only in drawRect()
|
|
|
|
func rectsBeingDrawn() -> [CGRect] {
|
2016-09-25 18:50:33 +03:00
|
|
|
var rectsPtr: UnsafePointer<CGRect>? = nil
|
2016-06-15 23:11:35 +03:00
|
|
|
var count: Int = 0
|
|
|
|
self.getRectsBeingDrawn(&rectsPtr, count: &count)
|
|
|
|
|
|
|
|
return Array(UnsafeBufferPointer(start: rectsPtr, count: count))
|
|
|
|
}
|
2016-06-16 19:36:26 +03:00
|
|
|
}
|