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/speech_ui_model_observer.h" | 11 #include "ui/app_list/speech_ui_model_observer.h" |
12 #include "ui/views/controls/button/image_button.h" | 12 #include "ui/views/controls/button/image_button.h" |
13 #include "ui/views/controls/button/menu_button_listener.h" | 13 #include "ui/views/controls/button/menu_button_listener.h" |
14 #include "ui/views/controls/textfield/textfield_controller.h" | 14 #include "ui/views/controls/textfield/textfield_controller.h" |
15 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
16 | 16 |
17 namespace views { | 17 namespace views { |
18 class ImageView; | 18 class ImageView; |
19 class MenuButton; | 19 class MenuButton; |
20 class Textfield; | 20 class Textfield; |
21 } // namespace views | 21 } // namespace views |
22 | 22 |
23 namespace app_list { | 23 namespace app_list { |
24 | 24 |
25 class AppListMenuViews; | 25 class AppListMenuViews; |
26 class AppListModel; | 26 class AppListModel; |
27 class AppListViewDelegate; | 27 class AppListViewDelegate; |
28 class ContentsView; | |
29 class SearchBoxModel; | 28 class SearchBoxModel; |
30 class SearchBoxViewDelegate; | 29 class SearchBoxViewDelegate; |
31 | 30 |
32 // SearchBoxView consists of an icon and a Textfield. SearchBoxModel is its data | 31 // SearchBoxView consists of an icon and a Textfield. SearchBoxModel is its data |
33 // model that controls what icon to display, what placeholder text to use for | 32 // model that controls what icon to display, what placeholder text to use for |
34 // Textfield. The text and selection model part could be set to change the | 33 // Textfield. The text and selection model part could be set to change the |
35 // contents and selection model of the Textfield. | 34 // contents and selection model of the Textfield. |
36 class SearchBoxView : public views::View, | 35 class APP_LIST_EXPORT SearchBoxView : public views::View, |
37 public views::TextfieldController, | 36 public views::TextfieldController, |
38 public views::ButtonListener, | 37 public views::ButtonListener, |
39 public views::MenuButtonListener, | 38 public views::MenuButtonListener, |
40 public SearchBoxModelObserver, | 39 public SearchBoxModelObserver, |
41 public SpeechUIModelObserver { | 40 public SpeechUIModelObserver { |
42 public: | 41 public: |
43 SearchBoxView(SearchBoxViewDelegate* delegate, | 42 SearchBoxView(SearchBoxViewDelegate* delegate, |
44 AppListViewDelegate* view_delegate); | 43 AppListViewDelegate* view_delegate); |
45 virtual ~SearchBoxView(); | 44 virtual ~SearchBoxView(); |
46 | 45 |
47 void ModelChanged(); | 46 void ModelChanged(); |
48 bool HasSearch() const; | 47 bool HasSearch() const; |
49 void ClearSearch(); | 48 void ClearSearch(); |
50 void InvalidateMenu(); | 49 void InvalidateMenu(); |
51 | 50 |
52 views::Textfield* search_box() { return search_box_; } | 51 views::Textfield* search_box() { return search_box_; } |
53 | 52 |
54 void set_contents_view(ContentsView* contents_view) { | 53 void set_contents_view(views::View* contents_view) { |
55 contents_view_ = contents_view; | 54 contents_view_ = contents_view; |
56 } | 55 } |
57 | 56 |
58 // Overridden from views::View: | 57 // Overridden from views::View: |
59 virtual gfx::Size GetPreferredSize() OVERRIDE; | 58 virtual gfx::Size GetPreferredSize() OVERRIDE; |
60 virtual void Layout() OVERRIDE; | 59 virtual void Layout() OVERRIDE; |
61 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; | 60 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; |
62 | 61 |
63 private: | 62 private: |
64 // Updates model text and selection model with current Textfield info. | 63 // Updates model text and selection model with current Textfield info. |
(...skipping 30 matching lines...) Expand all Loading... |
95 SearchBoxViewDelegate* delegate_; // Not owned. | 94 SearchBoxViewDelegate* delegate_; // Not owned. |
96 AppListViewDelegate* view_delegate_; // Not owned. | 95 AppListViewDelegate* view_delegate_; // Not owned. |
97 AppListModel* model_; // Owned by the profile-keyed service. | 96 AppListModel* model_; // Owned by the profile-keyed service. |
98 | 97 |
99 scoped_ptr<AppListMenuViews> menu_; | 98 scoped_ptr<AppListMenuViews> menu_; |
100 | 99 |
101 views::ImageView* icon_view_; // Owned by views hierarchy. | 100 views::ImageView* icon_view_; // Owned by views hierarchy. |
102 views::ImageButton* speech_button_; // Owned by views hierarchy. | 101 views::ImageButton* speech_button_; // Owned by views hierarchy. |
103 views::MenuButton* menu_button_; // Owned by views hierarchy. | 102 views::MenuButton* menu_button_; // Owned by views hierarchy. |
104 views::Textfield* search_box_; // Owned by views hierarchy. | 103 views::Textfield* search_box_; // Owned by views hierarchy. |
105 ContentsView* contents_view_; // Owned by views hierarchy. | 104 views::View* contents_view_; // Owned by views hierarchy. |
106 | 105 |
107 DISALLOW_COPY_AND_ASSIGN(SearchBoxView); | 106 DISALLOW_COPY_AND_ASSIGN(SearchBoxView); |
108 }; | 107 }; |
109 | 108 |
110 } // namespace app_list | 109 } // namespace app_list |
111 | 110 |
112 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ | 111 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ |
OLD | NEW |