forked from IntelliScape/caffeine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ISToggleSwitch.m
46 lines (36 loc) · 1.02 KB
/
ISToggleSwitch.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// ISToggleSwitch.m
// Caffeine
//
// Created by Michael Jones on 2/2/20.
//
#import "ISToggleSwitch.h"
@implementation ISToggleSwitch
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
// Drawing code here.
}
@end
@implementation ISToggleSwitchCell
- (void)drawSegment:(NSInteger)segment inFrame:(NSRect)frame withView:(NSView *)controlView
{
[controlView setNeedsDisplay:YES];
[super drawSegment:segment inFrame:frame withView:controlView];
}
- (void)drawWithFrame:(NSRect)frame inView:(NSView *)view
{
if([self selectedSegment] == 0) {
[self setLabel:@"" forSegment:0];
[self setLabel:@"OFF" forSegment:1];
[self setWidth:16.0f forSegment:0];
[self setWidth:40.0f forSegment:1];
}
if([self selectedSegment] == 1) {
[self setLabel:@"ON" forSegment:0];
[self setLabel:@"" forSegment:1];
[self setWidth:40.0f forSegment:0];
[self setWidth:16.0f forSegment:1];
}
[super drawWithFrame:frame inView:view];
}
@end