-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathWCBadgedTableCellView.m
48 lines (34 loc) · 1 KB
/
WCBadgedTableCellView.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
47
48
//
// WCBadgedTableCellView.m
// WiredClient
//
// Created by nark on 21/10/13.
//
//
#import "WCBadgedTableCellView.h"
@implementation WCBadgedTableCellView
@synthesize button = _button;
#pragma mark -
- (void)awakeFromNib {
// We want it to appear "inline"
[[self.button cell] setBezelStyle:NSInlineBezelStyle];
}
- (void)dealloc {
self.button = nil;
[super dealloc];
}
#pragma mark -
// The standard rowSizeStyle does some specific layout for us. To customize layout for our button, we first call super and then modify things
- (void)viewWillDraw {
[super viewWillDraw];
if (![self.button isHidden]) {
[self.button sizeToFit];
NSRect textFrame = self.textField.frame;
NSRect buttonFrame = self.button.frame;
buttonFrame.origin.x = NSWidth(self.frame) - NSWidth(buttonFrame);
self.button.frame = buttonFrame;
textFrame.size.width = NSMinX(buttonFrame) - NSMinX(textFrame);
self.textField.frame = textFrame;
}
}
@end