1 #import "ITButtonCell.h"
2 #import "ITTextFieldCell.h"
5 #define GRAY_EXTRA_PAD_H 60.0
8 @interface ITButtonCell (Private)
9 - (void)drawGrayRoundedBezelWithFrame:(NSRect)rect inView:(NSView *)controlView;
13 @implementation ITButtonCell
17 if ( ( self = [super init] ) ) {
26 /*************************************************************************/
28 #pragma mark INSTANCE METHODS
29 /*************************************************************************/
31 - (void)setBezelStyle:(NSBezelStyle)bezelStyle
33 if ( bezelStyle == ITGrayRoundedBezelStyle ) {
34 _subStyle = bezelStyle;
35 bezelStyle = NSRegularSquareBezelStyle;
40 [super setBezelStyle:bezelStyle];
44 /*************************************************************************/
46 #pragma mark DRAWING METHODS
47 /*************************************************************************/
49 - (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView
51 if ( _subStyle == ITGrayRoundedBezelStyle ) {
52 [self drawGrayRoundedBezelWithFrame:rect inView:controlView];
53 if ( [self attributedTitle] ) {
56 stringSize = [[self attributedTitle] size];
57 stringOrigin.x = rect.origin.x + (rect.size.width - stringSize.width)/2;
58 stringOrigin.y = (rect.origin.y + (rect.size.height - stringSize.height)/2) - 2;
59 [controlView lockFocus];
60 [[self attributedTitle] drawAtPoint:stringOrigin];
61 [controlView unlockFocus];
63 [super drawInteriorWithFrame:rect inView:controlView];
65 [[controlView superview] setNeedsDisplay:YES];
67 [super drawWithFrame:rect inView:controlView];
71 - (void)drawGrayRoundedBezelWithFrame:(NSRect)rect inView:(NSView *)controlView
73 NSBezierPath *path = [NSBezierPath bezierPath];
74 float ch = rect.size.height;
75 float cw = rect.size.width;
76 float radius = ( ch / 2 );
77 NSPoint pointA = NSMakePoint( (ch / 2) , 0.0 );
78 NSPoint pointB = NSMakePoint( (cw - (ch / 2)) , 0.0 );
79 // NSPoint pointC = NSMakePoint( (cw - (ch / 2)) , ch );
80 NSPoint pointD = NSMakePoint( (ch / 2) , ch );
81 NSPoint lCtr = NSMakePoint( (ch / 2) , (ch / 2) );
82 NSPoint rCtr = NSMakePoint( (cw - (ch / 2)) , (ch / 2) );
85 [path moveToPoint:pointA];
86 [path lineToPoint:pointB];
87 [path appendBezierPathWithArcWithCenter:rCtr
91 [path lineToPoint:pointD];
92 [path appendBezierPathWithArcWithCenter:lCtr
97 if ( [self isHighlighted] ) {
101 [[NSColor colorWithCalibratedWhite:0.15 alpha:alpha] set];