Warn about missing newline.
[MacTF.git] / iLifeControls / NFHUDSliderCell.m
blob91279f28c222b54b04da35609ced6d235d479aab
1 //
2 //  NFHUDSliderCell.m
3 //  iLife HUD Slider
4 //
5 //  Created by Sean Patrick O'Brien on 9/23/06.
6 //  Copyright 2006 Sean Patrick O'Brien. All rights reserved.
7 //
9 #import "NFHUDSliderCell.h"
10 #import "NSImage+FrameworkImage.h"
12 @implementation NFHUDSliderCell
14 - (void)drawBarInside:(NSRect)cellFrame flipped:(BOOL)flipped
16         NSImage *leftImage = [NSImage frameworkImageNamed:@"HUDSliderTrackLeft.tiff"];
17         NSImage *fillImage = [NSImage frameworkImageNamed:@"HUDSliderTrackFill.tiff"];
18         NSImage *rightImage = [NSImage frameworkImageNamed:@"HUDSliderTrackRight.tiff"];
19                                 
20         NSSize size = [leftImage size];
21         float addX = size.width / 2.0;
22         float y = NSMaxY(cellFrame) - (cellFrame.size.height-size.height)/2.0 - 1;
23         float x = cellFrame.origin.x+addX;
24         float fillX = x + size.width;
25         float fillWidth = cellFrame.size.width - size.width - addX;
26         
27         [leftImage compositeToPoint:NSMakePoint(x, y) operation:NSCompositeSourceOver];
29         size = [rightImage size];
30         addX = size.width / 2.0;
31         x = NSMaxX(cellFrame) - size.width - addX;
32         fillWidth -= size.width+addX;
33         
34         [rightImage compositeToPoint:NSMakePoint(x, y) operation:NSCompositeSourceOver];
35         
36         [fillImage setScalesWhenResized:YES];
37         [fillImage setSize:NSMakeSize(fillWidth, [fillImage size].height)];
38         [fillImage compositeToPoint:NSMakePoint(fillX, y) operation:NSCompositeSourceOver];
41 - (void)drawKnob:(NSRect)rect
43         NSImage *knob;
44         
45         if([self numberOfTickMarks] == 0)
46                 knob = [NSImage frameworkImageNamed:@"HUDSliderKnobRound.tiff"];
47         else
48                 knob = [NSImage frameworkImageNamed:@"HUDSliderKnob.tiff"];
49         
50         float x = rect.origin.x + (rect.size.width - [knob size].width) / 2;
51         float y = NSMaxY(rect) - (rect.size.height - [knob size].height) / 2 ;
52         
53         [knob compositeToPoint:NSMakePoint(x, y) operation:NSCompositeSourceOver];
56 -(NSRect)knobRectFlipped:(BOOL)flipped
58         NSRect rect = [super knobRectFlipped:flipped];
59         if([self numberOfTickMarks] > 0){
60                 rect.size.height+=2;
61                 return NSOffsetRect(rect, 0, flipped ? 2 : -2);
62                 }
63         return rect;
66 - (BOOL)_usesCustomTrackImage
68         return YES;
71 @end