aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/BWToolkitFramework.framework/BWTexturedSliderCell.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/BWTexturedSliderCell.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/BWTexturedSliderCell.m')
-rwxr-xr-xFrameworks/BWToolkitFramework.framework/BWTexturedSliderCell.m125
1 files changed, 125 insertions, 0 deletions
diff --git a/Frameworks/BWToolkitFramework.framework/BWTexturedSliderCell.m b/Frameworks/BWToolkitFramework.framework/BWTexturedSliderCell.m
new file mode 100755
index 00000000..e28aee86
--- /dev/null
+++ b/Frameworks/BWToolkitFramework.framework/BWTexturedSliderCell.m
@@ -0,0 +1,125 @@
+//
+// BWTexturedSliderCell.m
+// BWToolkit
+//
+// Created by Brandon Walkin (www.brandonwalkin.com)
+// All code is provided under the New BSD license.
+//
+
+#import "BWTexturedSliderCell.h"
+
+@implementation BWTexturedSliderCell
+@synthesize trackHeight;
+
+static NSImage *trackLeftImage, *trackFillImage, *trackRightImage, *thumbPImage, *thumbNImage;
+
++ (void)initialize
+{
+ if([BWTexturedSliderCell class] == [self class])
+ {
+ NSBundle *bundle = [NSBundle bundleForClass:[BWTexturedSliderCell class]];
+
+ trackLeftImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TexturedSliderTrackLeft.tiff"]];
+ trackFillImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TexturedSliderTrackFill.tiff"]];
+ trackRightImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TexturedSliderTrackRight.tiff"]];
+ thumbPImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TexturedSliderThumbP.tiff"]];
+ thumbNImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TexturedSliderThumbN.tiff"]];
+ }
+}
+
+- (id)initWithCoder:(NSCoder *)decoder;
+{
+ if ((self = [super initWithCoder:decoder]) != nil)
+ {
+ [self setTrackHeight:[decoder decodeBoolForKey:@"BWTSTrackHeight"]];
+ [self setControlSize:NSSmallControlSize];
+ isPressed = NO;
+ }
+ return self;
+}
+
+- (void)encodeWithCoder:(NSCoder*)coder
+{
+ [super encodeWithCoder:coder];
+
+ [coder encodeBool:[self trackHeight] forKey:@"BWTSTrackHeight"];
+}
+
+- (NSControlSize)controlSize
+{
+ return NSRegularControlSize;
+}
+
+- (void)setControlSize:(NSControlSize)size
+{
+
+}
+
+- (NSInteger)numberOfTickMarks
+{
+ return 0;
+}
+
+- (void)setNumberOfTickMarks:(NSInteger)numberOfTickMarks
+{
+
+}
+
+- (void)drawBarInside:(NSRect)cellFrame flipped:(BOOL)flipped
+{
+ NSRect slideRect = cellFrame;
+
+ if (trackHeight == 0)
+ slideRect.size.height = trackFillImage.size.height;
+ else
+ slideRect.size.height = trackFillImage.size.height + 1;
+
+ slideRect.origin.y += roundf((cellFrame.size.height - slideRect.size.height) / 2);
+
+ // Inset the bar so the knob goes all the way to both ends
+ slideRect.size.width -= 9;
+ slideRect.origin.x += 5;
+
+ if ([self isEnabled])
+ NSDrawThreePartImage(slideRect, trackLeftImage, trackFillImage, trackRightImage, NO, NSCompositeSourceOver, 1, flipped);
+ else
+ NSDrawThreePartImage(slideRect, trackLeftImage, trackFillImage, trackRightImage, NO, NSCompositeSourceOver, 0.5, flipped);
+}
+
+- (void)drawKnob:(NSRect)rect
+{
+ NSImage *drawImage;
+
+ if (isPressed)
+ drawImage = thumbPImage;
+ else
+ drawImage = thumbNImage;
+
+ NSPoint drawPoint;
+ drawPoint.x = rect.origin.x + roundf((rect.size.width - drawImage.size.width) / 2);
+ drawPoint.y = NSMaxY(rect) - roundf((rect.size.height - drawImage.size.height) / 2);
+
+ if (trackHeight == 0)
+ drawPoint.y++;
+
+ [drawImage compositeToPoint:drawPoint operation:NSCompositeSourceOver];
+}
+
+- (BOOL)_usesCustomTrackImage
+{
+ return YES;
+}
+
+- (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];
+}
+
+@end