aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/BWToolkitFramework.framework/BWTransparentSliderCell.m
diff options
context:
space:
mode:
authoravenjamin <avenjamin@gmail.com>2009-06-24 15:46:27 +0000
committeravenjamin <avenjamin@gmail.com>2009-06-24 15:46:27 +0000
commit5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40 (patch)
treef0eaf423f2c13f2091fe9cfceaa2e0a6f2169723 /Frameworks/BWToolkitFramework.framework/BWTransparentSliderCell.m
parent37bd86b2879c107ebb026954693540979cf25e2a (diff)
downloadsequelpro-5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40.tar.gz
sequelpro-5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40.tar.bz2
sequelpro-5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40.zip
- Changed the way the BWToolkit framework was included to allow modifications to be made easily.
- Fixed show/hide info pane toggle button image states to now show correctly
Diffstat (limited to 'Frameworks/BWToolkitFramework.framework/BWTransparentSliderCell.m')
-rw-r--r--Frameworks/BWToolkitFramework.framework/BWTransparentSliderCell.m152
1 files changed, 152 insertions, 0 deletions
diff --git a/Frameworks/BWToolkitFramework.framework/BWTransparentSliderCell.m b/Frameworks/BWToolkitFramework.framework/BWTransparentSliderCell.m
new file mode 100644
index 00000000..a08a1e57
--- /dev/null
+++ b/Frameworks/BWToolkitFramework.framework/BWTransparentSliderCell.m
@@ -0,0 +1,152 @@
+//
+// BWTransparentSliderCell.m
+// BWToolkit
+//
+// Created by Brandon Walkin (www.brandonwalkin.com)
+// All code is provided under the New BSD license.
+//
+
+#import "BWTransparentSliderCell.h"
+
+@implementation BWTransparentSliderCell
+
+static NSImage *trackLeftImage, *trackFillImage, *trackRightImage, *thumbPImage, *thumbNImage, *triangleThumbNImage, *triangleThumbPImage;
+
++ (void)initialize
+{
+ if([BWTransparentSliderCell class] == [self class])
+ {
+ NSBundle *bundle = [NSBundle bundleForClass:[BWTransparentSliderCell class]];
+
+ trackLeftImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderTrackLeft.tiff"]];
+ trackFillImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderTrackFill.tiff"]];
+ trackRightImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderTrackRight.tiff"]];
+ thumbPImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderThumbP.tiff"]];
+ thumbNImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderThumbN.tiff"]];
+ triangleThumbNImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderTriangleThumbN.tiff"]];
+ triangleThumbPImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderTriangleThumbP.tiff"]];
+ }
+}
+
+- (id)initWithCoder:(NSCoder *)decoder;
+{
+ self = [super initWithCoder:decoder];
+
+ [self setControlSize:NSSmallControlSize];
+ isPressed = NO;
+ [super setTickMarkPosition:NSTickMarkBelow];
+
+ return self;
+}
+
+- (void)drawBarInside:(NSRect)cellFrame flipped:(BOOL)flipped
+{
+ NSRect slideRect = cellFrame;
+ slideRect.size.height = [trackFillImage size].height;
+ if(cellFrame.size.height > slideRect.size.height)
+ slideRect.origin.y += roundf((cellFrame.size.height - slideRect.size.height) * 0.5f);
+
+ slideRect.size.width -= 5;
+ slideRect.origin.x += 2;
+
+ if ([self numberOfTickMarks] > 0)
+ {
+ slideRect.origin.y--;
+ slideRect.size.width++;
+ }
+
+ CGFloat alpha = 1.0;
+
+ if (![self isEnabled])
+ alpha = 0.6;
+
+ NSDrawThreePartImage(slideRect, trackLeftImage, trackFillImage, trackRightImage, NO, NSCompositeSourceOver, alpha, flipped);
+
+ // Draw solid white on top of all of the ticks
+ if ([self numberOfTickMarks] > 0)
+ {
+ int i;
+ for (i=0; i < [self numberOfTickMarks]; i++)
+ {
+ NSRect tickRect = [self rectOfTickMarkAtIndex:i];
+ [[NSColor whiteColor] set];
+ NSRectFill(tickRect);
+ }
+ }
+}
+
+- (void)drawKnob:(NSRect)rect
+{
+ NSImage *drawImage;
+
+ if ([self numberOfTickMarks] == 0)
+ {
+ if (isPressed)
+ drawImage = thumbPImage;
+ else
+ drawImage = thumbNImage;
+ }
+ else
+ {
+ if (isPressed)
+ drawImage = triangleThumbPImage;
+ else
+ drawImage = triangleThumbNImage;
+ }
+
+ NSPoint drawPoint;
+ drawPoint.x = rect.origin.x + roundf((rect.size.width - drawImage.size.width) / 2) - 1;
+ drawPoint.y = NSMaxY(rect) - roundf((rect.size.height - drawImage.size.height) / 2) + 2;
+
+ if ([self numberOfTickMarks] > 0)
+ {
+ drawPoint.y -= 2;
+ drawPoint.x++;
+ }
+
+ [drawImage compositeToPoint:drawPoint operation:NSCompositeSourceOver];
+}
+
+- (BOOL)_usesCustomTrackImage
+{
+ return YES;
+}
+
+-(NSRect)knobRectFlipped:(BOOL)flipped
+{
+ NSRect rect = [super knobRectFlipped:flipped];
+ if([self numberOfTickMarks] > 0){
+ rect.size.height+=2;
+ return NSOffsetRect(rect, 0, flipped ? 2 : -2);
+ }
+ return rect;
+}
+
+- (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView
+{
+ isPressed = YES;
+ return [super startTrackingAt:startPoint inView:controlView];
+}
+
+- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag
+{
+ isPressed = NO;
+ [super stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag];
+}
+
+- (void)setTickMarkPosition:(NSTickMarkPosition)position
+{
+
+}
+
+- (NSControlSize)controlSize
+{
+ return NSSmallControlSize;
+}
+
+- (void)setControlSize:(NSControlSize)size
+{
+
+}
+
+@end