2011-01-19 23:19:43 +03:00
|
|
|
//
|
|
|
|
// PSMTabDragView.m
|
|
|
|
// PSMTabBarControl
|
|
|
|
//
|
|
|
|
// Created by Kent Sutherland on 6/17/07.
|
|
|
|
// Copyright 2007 Kent Sutherland. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "PSMTabDragView.h"
|
|
|
|
|
|
|
|
|
|
|
|
@implementation PSMTabDragView
|
|
|
|
|
|
|
|
- (id)initWithFrame:(NSRect)frame {
|
2011-01-26 13:52:13 +03:00
|
|
|
if((self = [super initWithFrame:frame])) {
|
2011-01-19 23:19:43 +03:00
|
|
|
_alpha = 1.0;
|
2011-01-26 13:52:13 +03:00
|
|
|
}
|
|
|
|
return self;
|
2011-01-19 23:19:43 +03:00
|
|
|
}
|
|
|
|
|
2011-01-26 13:52:13 +03:00
|
|
|
- (void)dealloc {
|
2011-01-19 23:19:43 +03:00
|
|
|
[_image release];
|
|
|
|
[_alternateImage release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)drawRect:(NSRect)rect {
|
|
|
|
//1.0 fade means show the primary image
|
|
|
|
//0.0 fade means show the secondary image
|
|
|
|
CGFloat primaryAlpha = _alpha + 0.001f, alternateAlpha = 1.001f - _alpha;
|
|
|
|
NSRect srcRect;
|
|
|
|
srcRect.origin = NSZeroPoint;
|
|
|
|
srcRect.size = [_image size];
|
2011-01-26 13:52:13 +03:00
|
|
|
|
2011-01-19 23:19:43 +03:00
|
|
|
[_image drawInRect:[self bounds] fromRect:srcRect operation:NSCompositeSourceOver fraction:primaryAlpha];
|
|
|
|
srcRect.size = [_alternateImage size];
|
|
|
|
[_alternateImage drawInRect:[self bounds] fromRect:srcRect operation:NSCompositeSourceOver fraction:alternateAlpha];
|
|
|
|
}
|
|
|
|
|
2011-01-26 13:52:13 +03:00
|
|
|
- (void)setFadeValue:(CGFloat)value {
|
2011-01-19 23:19:43 +03:00
|
|
|
_alpha = value;
|
|
|
|
}
|
|
|
|
|
2011-01-26 13:52:13 +03:00
|
|
|
- (NSImage *)image {
|
2011-01-19 23:19:43 +03:00
|
|
|
return _image;
|
|
|
|
}
|
|
|
|
|
2011-01-26 13:52:13 +03:00
|
|
|
- (void)setImage:(NSImage *)image {
|
2011-01-19 23:19:43 +03:00
|
|
|
[_image release];
|
|
|
|
_image = [image retain];
|
|
|
|
}
|
|
|
|
|
2011-01-26 13:52:13 +03:00
|
|
|
- (NSImage *)alternateImage {
|
2011-01-19 23:19:43 +03:00
|
|
|
return _alternateImage;
|
|
|
|
}
|
|
|
|
|
2011-01-26 13:52:13 +03:00
|
|
|
- (void)setAlternateImage:(NSImage *)image {
|
2011-01-19 23:19:43 +03:00
|
|
|
[_alternateImage release];
|
|
|
|
_alternateImage = [image retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|