- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / find_bar / find_bar_cocoa_controller.h
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/mac/scoped_nsobject.h"
8 #include "base/strings/string16.h"
9 #include "ui/gfx/point.h"
10
11 class Browser;
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   IBOutlet NSButton* closeButton_;
30
31   // Needed to call methods on FindBarController.
32   FindBarBridge* findBarBridge_;  // weak
33
34   Browser* browser_;
35
36   base::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   base::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   base::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   // Default width of FindBar.
57   CGFloat defaultWidth_;
58 };
59
60 @property (readonly, nonatomic) NSView* findBarView;
61
62 // Initializes a new FindBarCocoaController.
63 - (id)initWithBrowser:(Browser*)browser;
64
65 - (void)setFindBarBridge:(FindBarBridge*)findBar;
66
67 - (IBAction)close:(id)sender;
68
69 - (IBAction)nextResult:(id)sender;
70
71 - (IBAction)previousResult:(id)sender;
72
73 // Position the find bar at the given maximum y-coordinate (the min-y of the
74 // bar -- toolbar + possibly bookmark bar, but not including the infobars) with
75 // the given maximum width (i.e., the find bar should fit between 0 and
76 // |maxWidth|).
77 - (void)positionFindBarViewAtMaxY:(CGFloat)maxY maxWidth:(CGFloat)maxWidth;
78
79 // Methods called from FindBarBridge.
80 - (void)showFindBar:(BOOL)animate;
81 - (void)hideFindBar:(BOOL)animate;
82 - (void)stopAnimation;
83 - (void)setFocusAndSelection;
84 - (void)restoreSavedFocus;
85 - (void)setFindText:(NSString*)findText
86       selectedRange:(const NSRange&)selectedRange;
87 - (NSString*)findText;
88 - (NSRange)selectedRange;
89 - (NSString*)matchCountText;
90 - (void)updateFindBarForChangedWebContents;
91
92 - (void)clearResults:(const FindNotificationDetails&)results;
93 - (void)updateUIForFindResult:(const FindNotificationDetails&)results
94                      withText:(const string16&)findText;
95 - (BOOL)isFindBarVisible;
96 - (BOOL)isFindBarAnimating;
97
98 // Returns the FindBar's position in the superview's coordinates, but with
99 // the Y coordinate growing down.
100 - (gfx::Point)findBarWindowPosition;
101
102 // Returns the width of the FindBar.
103 - (int)findBarWidth;
104
105 @end