Skip to content

Commit a796eec

Browse files
committed
Slider: documentation comments and formatting (NFC)
Add some documentation comments to the Slider implementation. Take the opportunity to clean up some of the text to fit better in 80-columns, and make ignored results explicit.
1 parent 57ee494 commit a796eec

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

Sources/SwiftWin32/Views and Controls/Slider.swift

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,52 @@
33

44
import WinSDK
55

6+
/// A control for selecting a single value from a continuous range of values.
67
public class Slider: Control {
78
private static let `class`: WindowClass = WindowClass(named: TRACKBAR_CLASS)
89
private static let style: WindowStyle =
910
(base: WS_POPUP | DWORD(TBS_HORZ | TBS_TRANSPARENTBKGND), extended: 0)
1011

12+
// MARK - Accessing the Slider's Value
13+
14+
/// The slider’s current value.
1115
public var value: Float {
12-
get { Float(SendMessageW(hWnd, UINT(TBM_GETPOS), 0, 0)) / 100.0 }
16+
get {
17+
Float(SendMessageW(hWnd, UINT(TBM_GETPOS), 0, 0)) / 100.0
18+
}
1319
set(value) {
14-
SendMessageW(hWnd, UINT(TBM_SETPOS), WPARAM(1), LPARAM(value * 100.0))
20+
_ = SendMessageW(hWnd, UINT(TBM_SETPOS), WPARAM(1), LPARAM(value * 100.0))
1521
}
1622
}
1723

24+
// MARK - Accessing the Slider's Value Limits
25+
26+
/// The minimum value of the slider.
1827
public var minimumValue: Float {
19-
get { Float(SendMessageW(hWnd, UINT(TBM_GETRANGEMIN), 0, 0)) / 100.0 }
28+
get {
29+
Float(SendMessageW(self.hWnd, UINT(TBM_GETRANGEMIN), 0, 0)) / 100.0
30+
}
2031
set(value) {
21-
SendMessageW(hWnd, UINT(TBM_SETRANGEMIN), WPARAM(1), LPARAM(value * 100.0))
32+
_ = SendMessageW(self.hWnd, UINT(TBM_SETRANGEMIN),
33+
WPARAM(1), LPARAM(value * 100.0))
2234
}
2335
}
2436

37+
/// The maximum value of the slider.
2538
public var maximumValue: Float {
26-
get { Float(SendMessageW(hWnd, UINT(TBM_GETRANGEMAX), 0, 0)) / 100.0 }
39+
get {
40+
Float(SendMessageW(self.hWnd, UINT(TBM_GETRANGEMAX), 0, 0)) / 100.0
41+
}
2742
set(value) {
28-
SendMessageW(hWnd, UINT(TBM_SETRANGEMAX), WPARAM(1), LPARAM(value * 100.0))
43+
_ = SendMessageW(self.hWnd, UINT(TBM_SETRANGEMAX),
44+
WPARAM(1), LPARAM(value * 100.0))
2945
}
3046
}
3147

48+
// MARK -
49+
3250
public init(frame: Rect) {
3351
super.init(frame: frame, class: Slider.class, style: Slider.style)
34-
SendMessageW(hWnd, UINT(TBM_SETLINESIZE), WPARAM(1), LPARAM(100))
52+
_ = SendMessageW(self.hWnd, UINT(TBM_SETLINESIZE), WPARAM(1), LPARAM(100))
3553
}
3654
}

0 commit comments

Comments
 (0)