Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef UI_APP_LIST_SEARCH_BOX_MODEL_H_ | |
| 6 #define UI_APP_LIST_SEARCH_BOX_MODEL_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/observer_list.h" | |
| 11 #include "base/string16.h" | |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | |
| 13 #include "ui/app_list/app_list_export.h" | |
| 14 #include "ui/gfx/selection_model.h" | |
| 15 | |
| 16 namespace app_list { | |
| 17 | |
| 18 class SearchBoxModelObserver; | |
| 19 | |
| 20 // SearchBoxModel consisits of an icon, a hint text, a user text and a selection | |
| 21 // model. The icon is rendered at side of the query edit control. The hint text | |
|
sky
2012/05/22 22:16:06
at -> to the
xiyuan
2012/05/23 21:25:22
Done.
| |
| 22 // is used as query edit control's placeholder text and displayed when there is | |
| 23 // no user text in the control. The selection model and the text represents the | |
| 24 // text, cursor position and selected text in edit control. | |
| 25 class APP_LIST_EXPORT SearchBoxModel { | |
| 26 public: | |
| 27 SearchBoxModel(); | |
| 28 ~SearchBoxModel(); | |
| 29 | |
| 30 // Sets the icon on side of edit box. | |
| 31 void SetIcon(const SkBitmap& icon); | |
| 32 | |
| 33 // Sets the hint text to display when there is in input. | |
| 34 void SetHintText(const string16& hint_text); | |
| 35 | |
| 36 // Sets the selection model for the search box's Textfield. | |
| 37 void SetSelectionModel(const gfx::SelectionModel& sel); | |
| 38 | |
| 39 // Sets the text for the search box's Textfield. | |
| 40 void SetText(const string16& text); | |
| 41 | |
| 42 void AddObserver(SearchBoxModelObserver* observer); | |
| 43 void RemoveObserver(SearchBoxModelObserver* observer); | |
| 44 | |
| 45 const SkBitmap& icon() const { | |
| 46 return icon_; | |
| 47 } | |
| 48 | |
| 49 const string16& hint_text() const { | |
| 50 return hint_text_; | |
| 51 } | |
| 52 | |
| 53 const gfx::SelectionModel& selection_model() const { | |
| 54 return selection_model_; | |
| 55 } | |
| 56 | |
| 57 const string16& text() const { | |
| 58 return text_; | |
| 59 } | |
| 60 | |
| 61 private: | |
| 62 SkBitmap icon_; | |
|
sky
2012/05/22 22:16:06
Use ImageSkia
xiyuan
2012/05/23 21:25:22
Done.
| |
| 63 string16 hint_text_; | |
| 64 | |
| 65 gfx::SelectionModel selection_model_; | |
| 66 string16 text_; | |
| 67 | |
| 68 ObserverList<SearchBoxModelObserver> observers_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(SearchBoxModel); | |
| 71 }; | |
| 72 | |
| 73 } // namespace app_list | |
| 74 | |
| 75 #endif // UI_APP_LIST_SEARCH_BOX_MODEL_H_ | |
| OLD | NEW |