@implementation InfoTabButtonBack
+- (id) initWithFrame: (NSRect) rect
+{
+ if ((self = [super initWithFrame: rect]))
+ {
+ NSColor * lightColor = [NSColor colorWithCalibratedRed: 255.0/255.0 green: 255.0/255.0 blue: 255.0/255.0 alpha: 1.0];
+ NSColor * darkColor = [NSColor colorWithCalibratedRed: 225.0/255.0 green: 225.0/255.0 blue: 225.0/255.0 alpha: 1.0];
+ fGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
+ }
+ return self;
+}
+
+- (void) dealloc
+{
+ [fGradient release];
+ [super dealloc];
+}
+
- (void) drawRect: (NSRect) rect
{
- NSColor * lightColor = [NSColor colorWithCalibratedRed: 255.0/255.0 green: 255.0/255.0 blue: 255.0/255.0 alpha: 1.0];
- NSColor * darkColor = [NSColor colorWithCalibratedRed: 225.0/255.0 green: 225.0/255.0 blue: 225.0/255.0 alpha: 1.0];
- NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: darkColor endingColor: lightColor];
- [gradient drawInRect: rect angle: 90.0];
- [gradient release];
+ NSInteger count = 0;
+ NSRect gridRects[2];
+ NSColor * colorRects[2];
+
+ NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
+ if (NSIntersectsRect(lineBorderRect, rect))
+ {
+ gridRects[count] = lineBorderRect;
+ colorRects[count] = [NSColor grayColor];
+ ++count;
+
+ rect.size.height -= 1.0;
+ }
+
+ lineBorderRect.origin.y = 0.0;
+ if (NSIntersectsRect(lineBorderRect, rect))
+ {
+ gridRects[count] = lineBorderRect;
+ colorRects[count] = [NSColor grayColor];
+ ++count;
+
+ rect.origin.y += 1.0;
+ rect.size.height -= 1.0;
+ }
+
+ NSRectFillListWithColors(gridRects, colorRects, count);
- [[NSColor grayColor] set];
- NSRectFill(NSMakeRect(0.0, 0.0, NSWidth(rect), 1.0));
- NSRectFill(NSMakeRect(0.0, NSHeight(rect) - 1.0, NSWidth(rect), 1.0));
+ [fGradient drawInRect: rect angle: 270.0];
}
@end
- (void) awakeFromNib
{
[(NSMatrix *)[self controlView] setToolTip: [self title] forCell: self];
+
+ NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
+ [nc addObserver: self selector: @selector(updateControlTint:)
+ name: NSControlTintDidChangeNotification object: NSApp];
fSelected = NO;
- (void) dealloc
{
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+
[fIcon release];
[super dealloc];
}
NSInteger row, col;
[(NSMatrix *)[self controlView] getRow: &row column: &col ofCell: self];
- const NSSize tabSize = [(NSMatrix *)[self controlView] cellFrameAtRow: row column: col].size;
- const NSRect tabRect = NSMakeRect(0.0, 0.0, tabSize.width, tabSize.height);
+ NSRect tabRect = [(NSMatrix *)[self controlView] cellFrameAtRow: row column: col];
+ tabRect.origin.x = 0.0;
+ tabRect.origin.y = 0.0;
- NSImage * tabImage = [[NSImage alloc] initWithSize: tabSize];
+ NSImage * tabImage = [[NSImage alloc] initWithSize: tabRect.size];
[tabImage lockFocus];
- if (!fSelected)
+ if (fSelected)
{
- NSColor * lightColor = [NSColor colorWithCalibratedRed: 255.0/255.0 green: 255.0/255.0 blue: 255.0/255.0 alpha: 1.0];
- NSColor * darkColor = [NSColor colorWithCalibratedRed: 225.0/255.0 green: 225.0/255.0 blue: 225.0/255.0 alpha: 1.0];
- NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: darkColor endingColor: lightColor];
- [gradient drawInRect: tabRect angle: 90.0];
+ NSColor * lightColor = [NSColor colorForControlTint: [NSColor currentControlTint]];
+ NSColor * darkColor = [lightColor blendedColorWithFraction: 0.2 ofColor: [NSColor blackColor]];
+ NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
+ [gradient drawInRect: tabRect angle: 270.0];
[gradient release];
}
else
{
- NSColor * lightColor = [NSColor colorWithCalibratedRed: 160.0/255.0 green: 160.0/255.0 blue: 160.0/255.0 alpha: 1.0];
- NSColor * darkColor = [NSColor colorWithCalibratedRed: 150.0/255.0 green: 150.0/255.0 blue: 150.0/255.0 alpha: 1.0];
- NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: darkColor endingColor: lightColor];
- [gradient drawInRect: tabRect angle: 90.0];
+ NSColor * lightColor = [NSColor colorWithCalibratedRed: 255.0/255.0 green: 255.0/255.0 blue: 255.0/255.0 alpha: 1.0];
+ NSColor * darkColor = [NSColor colorWithCalibratedRed: 225.0/255.0 green: 225.0/255.0 blue: 225.0/255.0 alpha: 1.0];
+ NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
+ [gradient drawInRect: tabRect angle: 270.0];
[gradient release];
}
{
const NSSize iconSize = [fIcon size];
- const NSRect iconRect = NSMakeRect(floor((tabSize.width - iconSize.width) * 0.5),
- floor((tabSize.height - iconSize.height) * 0.5),
+ const NSRect iconRect = NSMakeRect(floor((NSWidth(tabRect) - iconSize.width) * 0.5),
+ floor((NSHeight(tabRect) - iconSize.height) * 0.5),
iconSize.width, iconSize.height);
[fIcon drawInRect: iconRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
[tabImage release];
}
+- (void) updateControlTint: (NSNotification *) notification
+{
+ if (fSelected)
+ [self setSelectedTab: YES];
+}
+
@end