forked from chbeer/MGScopeBar
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MGRecessedPopUpButtonCell.m
54 lines (41 loc) · 1.32 KB
/
MGRecessedPopUpButtonCell.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
49
50
51
52
53
54
//
// MGRecessedPopUpButtonCell.m
// MGScopeBar
//
// Created by Matt Gemmell on 20/03/2008.
// Copyright 2008 Instinctive Code.
//
#import "MGRecessedPopUpButtonCell.h"
@implementation MGRecessedPopUpButtonCell
- (id)initTextCell:(NSString *)title pullsDown:(BOOL)pullsDown
{
if ((self = [super initTextCell:title pullsDown:pullsDown])) {
recessedButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 30, 20)]; // arbitrary frame.
[recessedButton setTitle:@""];
[recessedButton setBezelStyle:NSRecessedBezelStyle];
[recessedButton setButtonType:NSPushOnPushOffButton];
[[recessedButton cell] setHighlightsBy:NSCellIsBordered | NSCellIsInsetButton];
[recessedButton setShowsBorderOnlyWhileMouseInside:NO];
[recessedButton setState:NSOnState]; // ensures it looks pushed-in.
}
return self;
}
- (void)dealloc
{
[recessedButton release];
[super dealloc];
}
- (void)drawTitleWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
// Inset title rect since its position is broken when NSPopUpButton
// isn't using its selected item as its title.
NSRect titleFrame = cellFrame;
titleFrame.origin.y += 1.0;
[super drawTitleWithFrame:titleFrame inView:controlView];
}
- (void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView
{
[recessedButton setFrame:frame];
[recessedButton drawRect:frame];
}
@end