| 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 #ifndef CHROME_BROWSER_VIEWS_FIND_BAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_FIND_BAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_FIND_BAR_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_FIND_BAR_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/gfx/size.h" | 8 #include "base/gfx/size.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "chrome/browser/find_notification_details.h" | 10 #include "chrome/browser/find_notification_details.h" |
| 11 #include "views/controls/button/button.h" | 11 #include "views/controls/button/button.h" |
| 12 #include "views/controls/text_field.h" | 12 #include "views/controls/textfield/textfield.h" |
| 13 | 13 |
| 14 class FindBarWin; | 14 class FindBarWin; |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 class ImageButton; | 17 class ImageButton; |
| 18 class Label; | 18 class Label; |
| 19 class MouseEvent; | 19 class MouseEvent; |
| 20 class View; | 20 class View; |
| 21 } | 21 } |
| 22 | 22 |
| 23 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
| 24 // | 24 // |
| 25 // The FindInPageView is responsible for drawing the UI controls of the | 25 // The FindInPageView is responsible for drawing the UI controls of the |
| 26 // FindInPage window, the find text box, the 'Find' button and the 'Close' | 26 // FindInPage window, the find text box, the 'Find' button and the 'Close' |
| 27 // button. It communicates the user search words to the FindBarWin. | 27 // button. It communicates the user search words to the FindBarWin. |
| 28 // | 28 // |
| 29 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
| 30 class FindBarView : public views::View, | 30 class FindBarView : public views::View, |
| 31 public views::ButtonListener, | 31 public views::ButtonListener, |
| 32 public views::TextField::Controller { | 32 public views::Textfield::Controller { |
| 33 public: | 33 public: |
| 34 // A tag denoting which button the user pressed. | 34 // A tag denoting which button the user pressed. |
| 35 enum ButtonTag { | 35 enum ButtonTag { |
| 36 FIND_PREVIOUS_TAG = 0, // The Find Previous button. | 36 FIND_PREVIOUS_TAG = 0, // The Find Previous button. |
| 37 FIND_NEXT_TAG, // The Find Next button. | 37 FIND_NEXT_TAG, // The Find Next button. |
| 38 CLOSE_TAG, // The Close button (the 'X'). | 38 CLOSE_TAG, // The Close button (the 'X'). |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 explicit FindBarView(FindBarWin* container); | 41 explicit FindBarView(FindBarWin* container); |
| 42 virtual ~FindBarView(); | 42 virtual ~FindBarView(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 58 | 58 |
| 59 // Overridden from views::View: | 59 // Overridden from views::View: |
| 60 virtual void Paint(gfx::Canvas* canvas); | 60 virtual void Paint(gfx::Canvas* canvas); |
| 61 virtual void Layout(); | 61 virtual void Layout(); |
| 62 virtual gfx::Size GetPreferredSize(); | 62 virtual gfx::Size GetPreferredSize(); |
| 63 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); | 63 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); |
| 64 | 64 |
| 65 // Overridden from views::ButtonListener: | 65 // Overridden from views::ButtonListener: |
| 66 virtual void ButtonPressed(views::Button* sender); | 66 virtual void ButtonPressed(views::Button* sender); |
| 67 | 67 |
| 68 // Overridden from views::TextField::Controller: | 68 // Overridden from views::Textfield::Controller: |
| 69 virtual void ContentsChanged(views::TextField* sender, | 69 virtual void ContentsChanged(views::Textfield* sender, |
| 70 const std::wstring& new_contents); | 70 const std::wstring& new_contents); |
| 71 virtual bool HandleKeystroke(views::TextField* sender, | 71 virtual bool HandleKeystroke(views::Textfield* sender, |
| 72 const views::TextField::Keystroke& key); | 72 const views::Textfield::Keystroke& key); |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 // Resets the background for the match count label. | 75 // Resets the background for the match count label. |
| 76 void ResetMatchCountBackground(); | 76 void ResetMatchCountBackground(); |
| 77 | 77 |
| 78 // We use a hidden view to grab mouse clicks and bring focus to the find | 78 // We use a hidden view to grab mouse clicks and bring focus to the find |
| 79 // text box. This is because although the find text box may look like it | 79 // text box. This is because although the find text box may look like it |
| 80 // extends all the way to the find button, it only goes as far as to the | 80 // extends all the way to the find button, it only goes as far as to the |
| 81 // match_count label. The user, however, expects being able to click anywhere | 81 // match_count label. The user, however, expects being able to click anywhere |
| 82 // inside what looks like the find text box (including on or around the | 82 // inside what looks like the find text box (including on or around the |
| 83 // match_count label) and have focus brought to the find box. | 83 // match_count label) and have focus brought to the find box. |
| 84 class FocusForwarderView : public views::View { | 84 class FocusForwarderView : public views::View { |
| 85 public: | 85 public: |
| 86 explicit FocusForwarderView( | 86 explicit FocusForwarderView( |
| 87 views::TextField* view_to_focus_on_mousedown) | 87 views::Textfield* view_to_focus_on_mousedown) |
| 88 : view_to_focus_on_mousedown_(view_to_focus_on_mousedown) {} | 88 : view_to_focus_on_mousedown_(view_to_focus_on_mousedown) {} |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 virtual bool OnMousePressed(const views::MouseEvent& event); | 91 virtual bool OnMousePressed(const views::MouseEvent& event); |
| 92 | 92 |
| 93 views::TextField* view_to_focus_on_mousedown_; | 93 views::Textfield* view_to_focus_on_mousedown_; |
| 94 | 94 |
| 95 DISALLOW_COPY_AND_ASSIGN(FocusForwarderView); | 95 DISALLOW_COPY_AND_ASSIGN(FocusForwarderView); |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 // Manages the OS-specific view for the find bar and acts as an intermediary | 98 // Manages the OS-specific view for the find bar and acts as an intermediary |
| 99 // between us and the TabContentsView. | 99 // between us and the TabContentsView. |
| 100 FindBarWin* container_; | 100 FindBarWin* container_; |
| 101 | 101 |
| 102 // The controls in the window. | 102 // The controls in the window. |
| 103 views::TextField* find_text_; | 103 views::Textfield* find_text_; |
| 104 views::Label* match_count_text_; | 104 views::Label* match_count_text_; |
| 105 FocusForwarderView* focus_forwarder_view_; | 105 FocusForwarderView* focus_forwarder_view_; |
| 106 views::ImageButton* find_previous_button_; | 106 views::ImageButton* find_previous_button_; |
| 107 views::ImageButton* find_next_button_; | 107 views::ImageButton* find_next_button_; |
| 108 views::ImageButton* close_button_; | 108 views::ImageButton* close_button_; |
| 109 | 109 |
| 110 // While animating, the controller clips the window and draws only the bottom | 110 // While animating, the controller clips the window and draws only the bottom |
| 111 // part of it. The view needs to know the pixel offset at which we are drawing | 111 // part of it. The view needs to know the pixel offset at which we are drawing |
| 112 // the window so that we can draw the curved edges that attach to the toolbar | 112 // the window so that we can draw the curved edges that attach to the toolbar |
| 113 // in the right location. | 113 // in the right location. |
| 114 int animation_offset_; | 114 int animation_offset_; |
| 115 | 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(FindBarView); | 116 DISALLOW_COPY_AND_ASSIGN(FindBarView); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 #endif // CHROME_BROWSER_VIEWS_FIND_BAR_VIEW_H_ | 119 #endif // CHROME_BROWSER_VIEWS_FIND_BAR_VIEW_H_ |
| OLD | NEW |