summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/gradient_button_cell.mm
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-21 19:15:04 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-21 19:15:04 +0000
commit355284254f9997a21409da26b58f25f34bfd5d64 (patch)
tree3766ef18ae0b112a5c8953b9e624595e4f5e06b7 /chrome/browser/cocoa/gradient_button_cell.mm
parentcf3ac1f27fcd2986b62262f4f458dc9c2a519732 (diff)
downloadchromium_src-355284254f9997a21409da26b58f25f34bfd5d64.zip
chromium_src-355284254f9997a21409da26b58f25f34bfd5d64.tar.gz
chromium_src-355284254f9997a21409da26b58f25f34bfd5d64.tar.bz2
Add theme support for the yellow star on the Mac.
BUG=none TEST=go to a bookmarked page; the outline of the yellow star should be themed Review URL: http://codereview.chromium.org/155851 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21199 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/gradient_button_cell.mm')
-rw-r--r--chrome/browser/cocoa/gradient_button_cell.mm33
1 files changed, 33 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/gradient_button_cell.mm b/chrome/browser/cocoa/gradient_button_cell.mm
index ac7b65b..dbc80af 100644
--- a/chrome/browser/cocoa/gradient_button_cell.mm
+++ b/chrome/browser/cocoa/gradient_button_cell.mm
@@ -6,6 +6,12 @@
#import "third_party/GTM/AppKit/GTMTheme.h"
#import "base/scoped_nsobject.h"
+@interface GradientButtonCell (Private)
+- (void)drawUnderlayImageWithFrame:(NSRect)cellFrame
+ inView:(NSView*)controlView;
+@end
+
+
@implementation GradientButtonCell
// For nib instantiations
@@ -28,6 +34,16 @@
shouldTheme_ = shouldTheme;
}
+- (NSImage*)underlayImage {
+ return underlayImage_;
+}
+
+- (void)setUnderlayImage:(NSImage*)image {
+ underlayImage_.reset([image retain]);
+
+ [[self controlView] setNeedsDisplay:YES];
+}
+
- (NSBackgroundStyle)interiorBackgroundStyle {
return [self isHighlighted] ?
NSBackgroundStyleLowered : NSBackgroundStyleRaised;
@@ -207,6 +223,8 @@
[shadow set];
}
+ [self drawUnderlayImageWithFrame:cellFrame inView:controlView];
+
CGContextBeginTransparencyLayer(context, 0);
NSRect imageRect = NSZeroRect;
imageRect.size = [[self image] size];
@@ -225,6 +243,8 @@
CGContextEndTransparencyLayer(context);
[NSGraphicsContext restoreGraphicsState];
} else {
+ [self drawUnderlayImageWithFrame:cellFrame inView:controlView];
+
// NSCell draws these uncentered for some reason, probably because of the
// of control in the xib
[super drawInteriorWithFrame:NSOffsetRect(cellFrame, 0, 1)
@@ -232,4 +252,17 @@
}
}
+- (void)drawUnderlayImageWithFrame:(NSRect)cellFrame
+ inView:(NSView*)controlView {
+ if (underlayImage_) {
+ NSRect imageRect = NSZeroRect;
+ imageRect.size = [underlayImage_ size];
+ [underlayImage_ setFlipped:[controlView isFlipped]];
+ [underlayImage_ drawInRect:[self imageRectForBounds:cellFrame]
+ fromRect:imageRect
+ operation:NSCompositeSourceOver
+ fraction:[self isEnabled] ? 1.0 : 0.5];
+ }
+}
+
@end