|
7 | 7 |
|
8 | 8 | import WinSDK
|
9 | 9 |
|
10 |
| -public class Label: Control { |
| 10 | +fileprivate class LabelView: View { |
11 | 11 | private static let `class`: WindowClass = WindowClass(named: WC_STATIC)
|
| 12 | + private static let style: WindowStyle = (base: 0, extended: 0) |
| 13 | + |
| 14 | + @_Win32WindowText |
| 15 | + public var text: String? |
| 16 | + |
| 17 | + public init(frame: Rect) { |
| 18 | + super.init(frame: frame, class: LabelView.class, style: LabelView.style) |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +public class Label: Control { |
| 23 | + private static let `class`: WindowClass = |
| 24 | + WindowClass(hInst: GetModuleHandleW(nil), name: "Swift.Label") |
12 | 25 | private static let style: WindowStyle = (base: WS_TABSTOP, extended: 0)
|
13 | 26 |
|
| 27 | + private let view: LabelView |
| 28 | + |
| 29 | + public override var frame: Rect { |
| 30 | + didSet { |
| 31 | + self.view.frame = Rect(origin: .zero, size: frame.size) |
| 32 | + } |
| 33 | + } |
| 34 | + |
14 | 35 | public override var font: Font! {
|
15 |
| - get { return super.font } |
16 |
| - set(value) { super.font = value } |
| 36 | + get { return self.view.font } |
| 37 | + set(value) { self.view.font = value } |
17 | 38 | }
|
18 | 39 |
|
19 |
| - @_Win32WindowText |
20 |
| - public var text: String? |
| 40 | + public var text: String? { |
| 41 | + get { return self.view.text } |
| 42 | + set(value) { self.view.text = value } |
| 43 | + } |
21 | 44 |
|
22 | 45 | public init(frame: Rect) {
|
| 46 | + self.view = LabelView(frame: Rect(origin: .zero, size: frame.size)) |
23 | 47 | super.init(frame: frame, class: Label.class, style: Label.style)
|
| 48 | + self.addSubview(self.view) |
24 | 49 | }
|
25 | 50 |
|
26 | 51 | // ContentSizeCategoryAdjusting
|
|
0 commit comments