Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: chrome/browser/cocoa/autocomplete_text_field_cell.mm

Issue 495010: Mac: fix/implement app windows (not app mode), popups, drawing; refactor code. (Closed)
Patch Set: Updated per pink's review. Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/autocomplete_text_field_cell.mm
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
index 5afcf109b6a254f3fd390d1866252c0d8a51c204..1cb9d966a14010a8948f090e0048da714c364551 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
@@ -405,6 +405,48 @@ CGFloat WidthForKeyword(NSAttributedString* keywordString) {
fraction:1.0];
}
+- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
+ [NSGraphicsContext saveGraphicsState];
+
+ GTMTheme* theme = [controlView gtm_theme];
+
+ NSRect drawFrame = NSInsetRect(cellFrame, 0.5, 1.5);
+ // TODO(viettrungluu): It's hard to do pixel-perfect drawing in Cocoa 'cause
+ // rounding kills you (obviously, the constants below should be 0.5, but then
+ // it doesn't draw correctly).
+ NSRect innerFrame = NSInsetRect(drawFrame, 0.5001, 0.5001);
+ NSBezierPath* innerPath = [NSBezierPath bezierPathWithRect:drawFrame];
+
+ // Paint button background image if there is one (otherwise the border won't
+ // look right).
+ NSImage* backgroundImage =
+ [theme backgroundImageForStyle:GTMThemeStyleToolBarButton state:YES];
+ if (backgroundImage) {
+ NSColor* patternColor = [NSColor colorWithPatternImage:backgroundImage];
+ [patternColor set];
+ // Set the phase to match window.
+ NSRect trueRect = [controlView convertRectToBase:cellFrame];
+ [[NSGraphicsContext currentContext]
+ setPatternPhase:NSMakePoint(NSMinX(trueRect), NSMaxY(trueRect))];
+ [innerPath fill];
+ }
+
+ // Draw the outer stroke (over the background).
+ [[theme strokeColorForStyle:GTMThemeStyleToolBarButton state:YES] setStroke];
+ [innerPath setLineWidth:1];
+ [innerPath stroke];
+
+ // Fill the inside if we're told to.
+ if ([self drawsBackground]) {
+ [[self backgroundColor] setFill];
+ [NSBezierPath fillRect:innerFrame];
+ }
+
+ [NSGraphicsContext restoreGraphicsState];
+
+ [self drawInteriorWithFrame:cellFrame inView:controlView];
+}
+
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
if (hintString_) {
[self drawHintWithFrame:cellFrame inView:controlView];
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698