summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/location_bar_cell.mm
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 23:22:33 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 23:22:33 +0000
commit0735266658f996210b6f43142ce7f4c55f47ae13 (patch)
treed4e2c01970b8c7df5f6428f2aac188515a4ea509 /chrome/browser/cocoa/location_bar_cell.mm
parent9993401b31ffd1b18f100982f8d75824019f9a11 (diff)
downloadchromium_src-0735266658f996210b6f43142ce7f4c55f47ae13.zip
chromium_src-0735266658f996210b6f43142ce7f4c55f47ae13.tar.gz
chromium_src-0735266658f996210b6f43142ce7f4c55f47ae13.tar.bz2
Initial support for theming on Mac OS X.
Patch by alcor. Original review: http://codereview.chromium.org/149204 BUG=http://crbug.com/14451 TEST=Open a theme, watch it apply. Review URL: http://codereview.chromium.org/155355 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/location_bar_cell.mm')
-rw-r--r--chrome/browser/cocoa/location_bar_cell.mm49
1 files changed, 42 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/location_bar_cell.mm b/chrome/browser/cocoa/location_bar_cell.mm
index 2f8698da..e033d61 100644
--- a/chrome/browser/cocoa/location_bar_cell.mm
+++ b/chrome/browser/cocoa/location_bar_cell.mm
@@ -3,23 +3,58 @@
// found in the LICENSE file.
#import "chrome/browser/cocoa/location_bar_cell.h"
+#import "third_party/GTM/AppKit/GTMTheme.h"
-const NSInteger kBaselineOffset = 1;
+const NSInteger kBaselineOffset = 2;
@implementation LocationBarCell
+- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
+ [[NSColor colorWithCalibratedWhite:1.0 alpha:0.25] set];
+ NSFrameRectWithWidthUsingOperation(cellFrame, 1, NSCompositeSourceOver);
+
+ NSRect frame = NSInsetRect(cellFrame, 0, 1);
+ [[NSColor whiteColor] setFill];
+ NSRect innerFrame = NSInsetRect(frame, 1, 1);
+ NSRectFill(innerFrame);
+
+ NSRect shadowFrame, restFrame;
+ NSDivideRect(innerFrame, &shadowFrame, &restFrame, 1, NSMinYEdge);
+
+ BOOL isMainWindow = [[controlView window] isMainWindow];
+ GTMTheme *theme = [controlView gtm_theme];
+ NSColor* stroke = [theme strokeColorForStyle:GTMThemeStyleToolBarButton
+ state:isMainWindow];
+ [stroke set];
+ NSFrameRectWithWidthUsingOperation(frame, 1.0, NSCompositeSourceOver);
+
+ // Draw the location bar shadow.
+ [[NSColor colorWithCalibratedWhite:0.0 alpha:0.05] setFill];
+ NSRectFillUsingOperation(shadowFrame, NSCompositeSourceOver);
+
+ if ([self showsFirstResponder]) {
+ [[[NSColor keyboardFocusIndicatorColor] colorWithAlphaComponent:0.5] set];
+ NSFrameRectWithWidthUsingOperation(NSInsetRect(frame, 0, 0), 2,
+ NSCompositeSourceOver);
+ }
+
+ [self drawInteriorWithFrame:cellFrame
+ inView:controlView];
+
+}
+
- (void)drawInteriorWithFrame:(NSRect)cellFrame
- inView:(NSView *)controlView {
+ inView:(NSView*)controlView {
[super drawInteriorWithFrame:NSInsetRect(cellFrame, 0, kBaselineOffset)
inView:controlView];
}
// Override these methods so that the field editor shows up in the right place
- (void)editWithFrame:(NSRect)cellFrame
- inView:(NSView *)controlView
- editor:(NSText *)textObj
+ inView:(NSView*)controlView
+ editor:(NSText*)textObj
delegate:(id)anObject
- event:(NSEvent *)theEvent {
+ event:(NSEvent*)theEvent {
[super editWithFrame:NSInsetRect(cellFrame, 0, kBaselineOffset)
inView:controlView
editor:textObj
@@ -30,8 +65,8 @@ const NSInteger kBaselineOffset = 1;
// Override these methods so that the field editor shows up in the right place
- (void)selectWithFrame:(NSRect)cellFrame
- inView:(NSView *)controlView
- editor:(NSText *)textObj
+ inView:(NSView*)controlView
+ editor:(NSText*)textObj
delegate:(id)anObject
start:(NSInteger)selStart
length:(NSInteger)selLength {