| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ |
| 6 #define UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ui/app_list/search_box_model_observer.h" | 10 #include "ui/app_list/search_box_model_observer.h" |
| 11 #include "ui/app_list/views/app_list_menu_views.h" | |
| 12 #include "ui/views/controls/button/menu_button_listener.h" | 11 #include "ui/views/controls/button/menu_button_listener.h" |
| 13 #include "ui/views/controls/textfield/textfield_controller.h" | 12 #include "ui/views/controls/textfield/textfield_controller.h" |
| 14 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
| 15 | 14 |
| 16 namespace views { | 15 namespace views { |
| 17 class ImageView; | 16 class ImageView; |
| 18 class MenuButton; | 17 class MenuButton; |
| 19 class Textfield; | 18 class Textfield; |
| 20 } // namespace views | 19 } // namespace views |
| 21 | 20 |
| 22 namespace app_list { | 21 namespace app_list { |
| 23 | 22 |
| 23 class AppListMenuViews; |
| 24 class AppListViewDelegate; | 24 class AppListViewDelegate; |
| 25 class SearchBoxModel; | 25 class SearchBoxModel; |
| 26 class SearchBoxViewDelegate; | 26 class SearchBoxViewDelegate; |
| 27 | 27 |
| 28 // SearchBoxView consists of an icon and a Textfield. SearchBoxModel is its data | 28 // SearchBoxView consists of an icon and a Textfield. SearchBoxModel is its data |
| 29 // model that controls what icon to display, what placeholder text to use for | 29 // model that controls what icon to display, what placeholder text to use for |
| 30 // Textfield. The text and selection model part could be set to change the | 30 // Textfield. The text and selection model part could be set to change the |
| 31 // contents and selection model of the Textfield. | 31 // contents and selection model of the Textfield. |
| 32 class SearchBoxView : public views::View, | 32 class SearchBoxView : public views::View, |
| 33 public views::TextfieldController, | 33 public views::TextfieldController, |
| 34 public views::MenuButtonListener, | 34 public views::MenuButtonListener, |
| 35 public SearchBoxModelObserver { | 35 public SearchBoxModelObserver { |
| 36 public: | 36 public: |
| 37 SearchBoxView(SearchBoxViewDelegate* delegate, | 37 explicit SearchBoxView(SearchBoxViewDelegate* delegate); |
| 38 AppListViewDelegate* view_delegate); | |
| 39 virtual ~SearchBoxView(); | 38 virtual ~SearchBoxView(); |
| 40 | 39 |
| 41 void SetModel(SearchBoxModel* model); | 40 void SetModel(SearchBoxModel* model); |
| 42 | 41 |
| 43 bool HasSearch() const; | 42 bool HasSearch() const; |
| 44 void ClearSearch(); | 43 void ClearSearch(); |
| 44 void UpdateMenu(AppListViewDelegate* view_delegate); |
| 45 | 45 |
| 46 views::Textfield* search_box() { return search_box_; } | 46 views::Textfield* search_box() { return search_box_; } |
| 47 | 47 |
| 48 void set_contents_view(View* contents_view) { | 48 void set_contents_view(View* contents_view) { |
| 49 contents_view_ = contents_view; | 49 contents_view_ = contents_view; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Overridden from views::View: | 52 // Overridden from views::View: |
| 53 virtual gfx::Size GetPreferredSize() OVERRIDE; | 53 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 54 virtual void Layout() OVERRIDE; | 54 virtual void Layout() OVERRIDE; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 73 | 73 |
| 74 // Overridden from SearchBoxModelObserver: | 74 // Overridden from SearchBoxModelObserver: |
| 75 virtual void IconChanged() OVERRIDE; | 75 virtual void IconChanged() OVERRIDE; |
| 76 virtual void HintTextChanged() OVERRIDE; | 76 virtual void HintTextChanged() OVERRIDE; |
| 77 virtual void SelectionModelChanged() OVERRIDE; | 77 virtual void SelectionModelChanged() OVERRIDE; |
| 78 virtual void TextChanged() OVERRIDE; | 78 virtual void TextChanged() OVERRIDE; |
| 79 | 79 |
| 80 SearchBoxViewDelegate* delegate_; // Not owned. | 80 SearchBoxViewDelegate* delegate_; // Not owned. |
| 81 SearchBoxModel* model_; // Owned by AppListModel. | 81 SearchBoxModel* model_; // Owned by AppListModel. |
| 82 | 82 |
| 83 AppListMenuViews menu_; | 83 scoped_ptr<AppListMenuViews> menu_; |
| 84 | 84 |
| 85 views::ImageView* icon_view_; // Owned by views hierarchy. | 85 views::ImageView* icon_view_; // Owned by views hierarchy. |
| 86 views::MenuButton* menu_button_; // Owned by views hierarchy. | 86 views::MenuButton* menu_button_; // Owned by views hierarchy. |
| 87 views::Textfield* search_box_; // Owned by views hierarchy. | 87 views::Textfield* search_box_; // Owned by views hierarchy. |
| 88 views::View* contents_view_; // Owned by views hierarchy. | 88 views::View* contents_view_; // Owned by views hierarchy. |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(SearchBoxView); | 90 DISALLOW_COPY_AND_ASSIGN(SearchBoxView); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // namespace app_list | 93 } // namespace app_list |
| 94 | 94 |
| 95 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ | 95 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ |
| OLD | NEW |