| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field_cell.h" | 5 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field_cell.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // How far to offset the keyword token into the field. | 16 // How far to offset the keyword token into the field. |
| 17 const NSInteger kResultsXOffset = 3; | 17 const NSInteger kResultsXOffset = 3; |
| 18 | 18 |
| 19 // How much width (beyond text) to add to the keyword token on each | 19 // How much width (beyond text) to add to the keyword token on each |
| 20 // side. | 20 // side. |
| 21 const NSInteger kResultsTokenInset = 3; | 21 const NSInteger kResultsTokenInset = 3; |
| 22 | 22 |
| 23 // How far to shift bounding box of hint down from top of field. | 23 // How far to shift bounding box of hint down from top of field. |
| 24 // Assumes -setFlipped:YES. | 24 // Assumes -setFlipped:YES. |
| 25 const NSInteger kResultsYOffset = 4; | 25 const NSInteger kResultsYOffset = 4; |
| 26 | 26 |
| 27 // How far the editor insets itself, for purposes of determining if | |
| 28 // decorations need to be trimmed. | |
| 29 const CGFloat kEditorHorizontalInset = 3.0; | |
| 30 | |
| 31 // Conveniences to centralize width+offset calculations. | 27 // Conveniences to centralize width+offset calculations. |
| 32 CGFloat WidthForResults(NSAttributedString* resultsString) { | 28 CGFloat WidthForResults(NSAttributedString* resultsString) { |
| 33 return kResultsXOffset + ceil([resultsString size].width) + | 29 return kResultsXOffset + ceil([resultsString size].width) + |
| 34 2 * kResultsTokenInset; | 30 2 * kResultsTokenInset; |
| 35 } | 31 } |
| 36 | 32 |
| 37 } // namespace | 33 } // namespace |
| 38 | 34 |
| 39 @implementation FindBarTextFieldCell | 35 @implementation FindBarTextFieldCell |
| 40 | 36 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 [resultsString_.get() drawInRect:infoFrame]; | 107 [resultsString_.get() drawInRect:infoFrame]; |
| 112 } | 108 } |
| 113 | 109 |
| 114 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { | 110 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { |
| 115 if (resultsString_) | 111 if (resultsString_) |
| 116 [self drawResultsWithFrame:cellFrame inView:controlView]; | 112 [self drawResultsWithFrame:cellFrame inView:controlView]; |
| 117 [super drawInteriorWithFrame:cellFrame inView:controlView]; | 113 [super drawInteriorWithFrame:cellFrame inView:controlView]; |
| 118 } | 114 } |
| 119 | 115 |
| 120 @end | 116 @end |
| OLD | NEW |