| 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 false, false); | 45 false, false); |
| 46 } | 46 } |
| 47 | 47 |
| 48 - (IBAction)nextResult:(id)sender { | 48 - (IBAction)nextResult:(id)sender { |
| 49 if (findBarBridge_) | 49 if (findBarBridge_) |
| 50 findBarBridge_->GetFindBarController()->tab_contents()->StartFinding( | 50 findBarBridge_->GetFindBarController()->tab_contents()->StartFinding( |
| 51 base::SysNSStringToUTF16([findText_ stringValue]), | 51 base::SysNSStringToUTF16([findText_ stringValue]), |
| 52 true, false); | 52 true, false); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Positions the find bar view in the correct location based on the | 55 // Positions the find bar view in the correct location based on the current |
| 56 // current state of the window. Currently only the visibility of the | 56 // state of the window. The findbar is always positioned one pixel above the |
| 57 // bookmark bar can affect the find bar's position. | 57 // infobar container. Note that we are using the infobar container location as |
| 58 - (void)positionFindBarView:(NSView*)contentArea { | 58 // a proxy for the toolbar location, but we cannot position based on the toolbar |
| 59 // because the toolbar is not always present (for example in fullscreen |
| 60 // windows). |
| 61 - (void)positionFindBarView:(NSView*)infoBarContainerView { |
| 59 static const int kRightEdgeOffset = 25; | 62 static const int kRightEdgeOffset = 25; |
| 60 NSView* findBarView = [self view]; | 63 NSView* findBarView = [self view]; |
| 61 int findBarHeight = NSHeight([findBarView frame]); | 64 int findBarHeight = NSHeight([findBarView frame]); |
| 62 int findBarWidth = NSWidth([findBarView frame]); | 65 int findBarWidth = NSWidth([findBarView frame]); |
| 63 | 66 |
| 64 // Start by computing the upper right corner of the tab content | 67 // Start by computing the upper right corner of the infobar container, then |
| 65 // area, then move left by a constant offset and up one pixel. This | 68 // move left by a constant offset and up one pixel. This gives us the upper |
| 66 // gives us the upper right corner of our bounding box. We move up | 69 // right corner of our bounding box. We move up one pixel to overlap with the |
| 67 // one pixel to overlap with the toolbar area, which allows us to | 70 // toolbar area, which allows us to cover up the toolbar's border, if present. |
| 68 // cover up the toolbar's border. | 71 NSRect windowRect = [infoBarContainerView frame]; |
| 69 NSRect windowRect = [contentArea frame]; | |
| 70 int max_x = NSMaxX(windowRect) - kRightEdgeOffset; | 72 int max_x = NSMaxX(windowRect) - kRightEdgeOffset; |
| 71 int max_y = NSMaxY(windowRect) + 1; | 73 int max_y = NSMaxY(windowRect) + 1; |
| 72 | 74 |
| 73 NSRect findRect = NSMakeRect(max_x - findBarWidth, max_y - findBarHeight, | 75 NSRect findRect = NSMakeRect(max_x - findBarWidth, max_y - findBarHeight, |
| 74 findBarWidth, findBarHeight); | 76 findBarWidth, findBarHeight); |
| 75 [findBarView setFrame:findRect]; | 77 [findBarView setFrame:findRect]; |
| 76 } | 78 } |
| 77 | 79 |
| 78 // NSControl delegate method. | 80 // NSControl delegate method. |
| 79 - (void)controlTextDidChange:(NSNotification *)aNotification { | 81 - (void)controlTextDidChange:(NSNotification *)aNotification { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 182 |
| 181 // TODO(rohitrao): If the search string is too long, then it will overlap with | 183 // TODO(rohitrao): If the search string is too long, then it will overlap with |
| 182 // the results label. Fix. | 184 // the results label. Fix. |
| 183 } | 185 } |
| 184 | 186 |
| 185 - (BOOL)isFindBarVisible { | 187 - (BOOL)isFindBarVisible { |
| 186 return [[self view] isHidden] ? NO : YES; | 188 return [[self view] isHidden] ? NO : YES; |
| 187 } | 189 } |
| 188 | 190 |
| 189 @end | 191 @end |
| OLD | NEW |