Home | History | Annotate | Download | only in find_bar
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #import <Cocoa/Cocoa.h>
      6 
      7 #include "base/memory/scoped_nsobject.h"
      8 #include "base/string16.h"
      9 #include "ui/gfx/point.h"
     10 
     11 @class BrowserWindowController;
     12 class FindBarBridge;
     13 @class FindBarTextField;
     14 class FindNotificationDetails;
     15 @class FocusTracker;
     16 
     17 // A controller for the find bar in the browser window.  Manages
     18 // updating the state of the find bar and provides a target for the
     19 // next/previous/close buttons.  Certain operations require a pointer
     20 // to the cross-platform FindBarController, so be sure to call
     21 // setFindBarBridge: after creating this controller.
     22 
     23 @interface FindBarCocoaController : NSViewController {
     24  @private
     25   IBOutlet NSView* findBarView_;
     26   IBOutlet FindBarTextField* findText_;
     27   IBOutlet NSButton* nextButton_;
     28   IBOutlet NSButton* previousButton_;
     29 
     30   // Needed to call methods on FindBarController.
     31   FindBarBridge* findBarBridge_;  // weak
     32 
     33   // Needed to request a layout of the FindBar view.
     34   BrowserWindowController* browserWindowController_;  // weak
     35 
     36   scoped_nsobject<FocusTracker> focusTracker_;
     37 
     38   // The show/hide animation. This is defined to be non-nil if the
     39   // animation is running, and is always nil otherwise.  The
     40   // FindBarCocoaController should not be deallocated while an animation is
     41   // running (stopAnimation is currently called before the last tab in a
     42   // window is removed).
     43   scoped_nsobject<NSViewAnimation> showHideAnimation_;
     44 
     45   // The horizontal-moving animation, to avoid occluding find results. This
     46   // is nil when the animation is not running, and is also stopped by
     47   // stopAnimation.
     48   scoped_nsobject<NSViewAnimation> moveAnimation_;
     49 
     50   // If YES, do nothing as a result of find pasteboard update notifications.
     51   BOOL suppressPboardUpdateActions_;
     52 
     53   // Vertical point of attachment of the FindBar.
     54   CGFloat maxY_;
     55 };
     56 
     57 // Initializes a new FindBarCocoaController.
     58 - (id)init;
     59 
     60 - (void)setFindBarBridge:(FindBarBridge*)findBar;
     61 - (void)setBrowserWindowController:(BrowserWindowController*)controller;
     62 
     63 - (IBAction)close:(id)sender;
     64 
     65 - (IBAction)nextResult:(id)sender;
     66 
     67 - (IBAction)previousResult:(id)sender;
     68 
     69 // Position the find bar at the given maximum y-coordinate (the min-y of the
     70 // bar -- toolbar + possibly bookmark bar, but not including the infobars) with
     71 // the given maximum width (i.e., the find bar should fit between 0 and
     72 // |maxWidth|).
     73 - (void)positionFindBarViewAtMaxY:(CGFloat)maxY maxWidth:(CGFloat)maxWidth;
     74 
     75 // Methods called from FindBarBridge.
     76 - (void)showFindBar:(BOOL)animate;
     77 - (void)hideFindBar:(BOOL)animate;
     78 - (void)stopAnimation;
     79 - (void)setFocusAndSelection;
     80 - (void)restoreSavedFocus;
     81 - (void)setFindText:(NSString*)findText;
     82 
     83 - (void)clearResults:(const FindNotificationDetails&)results;
     84 - (void)updateUIForFindResult:(const FindNotificationDetails&)results
     85                      withText:(const string16&)findText;
     86 - (BOOL)isFindBarVisible;
     87 - (BOOL)isFindBarAnimating;
     88 
     89 // Returns the FindBar's position in the superview's coordinates, but with
     90 // the Y coordinate growing down.
     91 - (gfx::Point)findBarWindowPosition;
     92 
     93 @end
     94