Mailbox support for texture layers.
[chromium-blink-merge.git] / ui / app_list / search_box_view.h
blob50f6f3aef4dd77a32d523c2918a6931789ac75f6
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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_SEARCH_BOX_VIEW_H_
6 #define UI_APP_LIST_SEARCH_BOX_VIEW_H_
8 #include <string>
10 #include "ui/app_list/search_box_model_observer.h"
11 #include "ui/views/view.h"
12 #include "ui/views/controls/textfield/textfield_controller.h"
14 namespace views {
15 class ImageView;
16 class Textfield;
17 } // namespace views
19 namespace app_list {
21 class SearchBoxModel;
22 class SearchBoxViewDelegate;
24 // SearchBoxView consists of an icon and a Textfield. SearchBoxModel is its data
25 // model that controls what icon to display, what placeholder text to use for
26 // Textfield. The text and selection model part could be set to change the
27 // contents and selection model of the Textfield.
28 class SearchBoxView : public views::View,
29 public views::TextfieldController,
30 public SearchBoxModelObserver {
31 public:
32 explicit SearchBoxView(SearchBoxViewDelegate* delegate);
33 virtual ~SearchBoxView();
35 void SetModel(SearchBoxModel* model);
37 views::Textfield* search_box() { return search_box_; }
39 void set_contents_view(View* contents_view) {
40 contents_view_ = contents_view;
43 // Overridden from views::View:
44 virtual gfx::Size GetPreferredSize() OVERRIDE;
45 virtual void Layout() OVERRIDE;
46 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE;
48 private:
49 // Updates model text and selection model with current Textfield info.
50 void UpdateModel();
52 // Fires query change notification.
53 void NotifyQueryChanged();
55 // Overridden from views::TextfieldController:
56 virtual void ContentsChanged(views::Textfield* sender,
57 const string16& new_contents) OVERRIDE;
58 virtual bool HandleKeyEvent(views::Textfield* sender,
59 const ui::KeyEvent& key_event) OVERRIDE;
61 // Overridden from SearchBoxModelObserver:
62 virtual void IconChanged() OVERRIDE;
63 virtual void HintTextChanged() OVERRIDE;
64 virtual void SelectionModelChanged() OVERRIDE;
65 virtual void TextChanged() OVERRIDE;
67 SearchBoxViewDelegate* delegate_; // Not owned.
68 SearchBoxModel* model_; // Owned by AppListModel.
70 views::ImageView* icon_view_; // Owned by views hierarchy.
71 views::Textfield* search_box_; // Owned by views hierarchy.
72 views::View* contents_view_; // Owned by views hierarchy.
74 DISALLOW_COPY_AND_ASSIGN(SearchBoxView);
77 } // namespace app_list
79 #endif // UI_APP_LIST_SEARCH_BOX_VIEW_H_