OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 10 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
11 #include "chrome/browser/ui/views/dropdown_bar_view.h" | 11 #include "chrome/browser/ui/views/dropdown_bar_view.h" |
12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
13 #include "views/controls/button/button.h" | 13 #include "views/controls/button/button.h" |
14 #include "views/controls/textfield/textfield.h" | 14 #include "views/controls/textfield/textfield.h" |
sky
2011/03/09 17:02:33
Can you nuke the textfield include now?
tfarina
2011/03/09 17:31:06
No, we inherit from views::Textfield at line 114.
| |
15 #include "views/controls/textfield/textfield_controller.h" | |
15 | 16 |
16 class FindBarHost; | 17 class FindBarHost; |
17 | 18 |
18 namespace views { | 19 namespace views { |
19 class ImageButton; | 20 class ImageButton; |
20 class Label; | 21 class Label; |
21 class MouseEvent; | 22 class MouseEvent; |
22 class View; | 23 class View; |
23 } | 24 } |
24 | 25 |
25 //////////////////////////////////////////////////////////////////////////////// | 26 //////////////////////////////////////////////////////////////////////////////// |
26 // | 27 // |
27 // The FindBarView is responsible for drawing the UI controls of the | 28 // The FindBarView is responsible for drawing the UI controls of the |
28 // FindBar, the find text box, the 'Find' button and the 'Close' | 29 // FindBar, the find text box, the 'Find' button and the 'Close' |
29 // button. It communicates the user search words to the FindBarHost. | 30 // button. It communicates the user search words to the FindBarHost. |
30 // | 31 // |
31 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
32 class FindBarView : public DropdownBarView, | 33 class FindBarView : public DropdownBarView, |
33 public views::ButtonListener, | 34 public views::ButtonListener, |
34 public views::Textfield::Controller { | 35 public views::TextfieldController { |
35 public: | 36 public: |
36 // A tag denoting which button the user pressed. | 37 // A tag denoting which button the user pressed. |
37 enum ButtonTag { | 38 enum ButtonTag { |
38 FIND_PREVIOUS_TAG = 0, // The Find Previous button. | 39 FIND_PREVIOUS_TAG = 0, // The Find Previous button. |
39 FIND_NEXT_TAG, // The Find Next button. | 40 FIND_NEXT_TAG, // The Find Next button. |
40 CLOSE_TAG, // The Close button (the 'X'). | 41 CLOSE_TAG, // The Close button (the 'X'). |
41 }; | 42 }; |
42 | 43 |
43 explicit FindBarView(FindBarHost* host); | 44 explicit FindBarView(FindBarHost* host); |
44 virtual ~FindBarView(); | 45 virtual ~FindBarView(); |
(...skipping 12 matching lines...) Expand all Loading... | |
57 // active item and how many matches were found. | 58 // active item and how many matches were found. |
58 void UpdateForResult(const FindNotificationDetails& result, | 59 void UpdateForResult(const FindNotificationDetails& result, |
59 const string16& find_text); | 60 const string16& find_text); |
60 | 61 |
61 // Clears the current Match Count value in the Find text box. | 62 // Clears the current Match Count value in the Find text box. |
62 void ClearMatchCount(); | 63 void ClearMatchCount(); |
63 | 64 |
64 // Claims focus for the text field and selects its contents. | 65 // Claims focus for the text field and selects its contents. |
65 virtual void SetFocusAndSelection(bool select_all); | 66 virtual void SetFocusAndSelection(bool select_all); |
66 | 67 |
67 // Overridden from views::View: | 68 // views::View: |
68 virtual void OnPaint(gfx::Canvas* canvas); | 69 virtual void OnPaint(gfx::Canvas* canvas); |
69 virtual void Layout(); | 70 virtual void Layout(); |
70 virtual gfx::Size GetPreferredSize(); | 71 virtual gfx::Size GetPreferredSize(); |
71 virtual void ViewHierarchyChanged(bool is_add, | 72 virtual void ViewHierarchyChanged(bool is_add, |
72 views::View* parent, | 73 views::View* parent, |
73 views::View* child); | 74 views::View* child); |
74 | 75 |
75 // Overridden from views::ButtonListener: | 76 // views::ButtonListener: |
76 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 77 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
77 | 78 |
78 // Overridden from views::Textfield::Controller: | 79 // views::TextfieldController: |
79 virtual void ContentsChanged(views::Textfield* sender, | 80 virtual void ContentsChanged(views::Textfield* sender, |
80 const string16& new_contents); | 81 const string16& new_contents); |
81 virtual bool HandleKeyEvent(views::Textfield* sender, | 82 virtual bool HandleKeyEvent(views::Textfield* sender, |
82 const views::KeyEvent& key_event); | 83 const views::KeyEvent& key_event); |
83 | 84 |
84 private: | 85 private: |
85 // Update the appearance for the match count label. | 86 // Update the appearance for the match count label. |
86 void UpdateMatchCountAppearance(bool no_match); | 87 void UpdateMatchCountAppearance(bool no_match); |
87 | 88 |
88 // Overridden from views::View. | 89 // Overridden from views::View. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 views::Label* match_count_text_; | 140 views::Label* match_count_text_; |
140 FocusForwarderView* focus_forwarder_view_; | 141 FocusForwarderView* focus_forwarder_view_; |
141 views::ImageButton* find_previous_button_; | 142 views::ImageButton* find_previous_button_; |
142 views::ImageButton* find_next_button_; | 143 views::ImageButton* find_next_button_; |
143 views::ImageButton* close_button_; | 144 views::ImageButton* close_button_; |
144 | 145 |
145 DISALLOW_COPY_AND_ASSIGN(FindBarView); | 146 DISALLOW_COPY_AND_ASSIGN(FindBarView); |
146 }; | 147 }; |
147 | 148 |
148 #endif // CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ | 149 #endif // CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ |
OLD | NEW |