Chromium Code Reviews| 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_SEARCH_BOX_MODEL_H_ | 5 #ifndef UI_APP_LIST_SEARCH_BOX_MODEL_H_ |
| 6 #define UI_APP_LIST_SEARCH_BOX_MODEL_H_ | 6 #define UI_APP_LIST_SEARCH_BOX_MODEL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "ui/app_list/app_list_export.h" | 11 #include "ui/app_list/app_list_export.h" |
| 12 #include "ui/gfx/image/image_skia.h" | 12 #include "ui/gfx/image/image_skia.h" |
| 13 #include "ui/gfx/selection_model.h" | 13 #include "ui/gfx/selection_model.h" |
| 14 | 14 |
| 15 namespace app_list { | 15 namespace app_list { |
| 16 | 16 |
| 17 class SearchBoxModelObserver; | 17 class SearchBoxModelObserver; |
| 18 | 18 |
| 19 // SearchBoxModel consisits of an icon, a hint text, a user text and a selection | 19 // SearchBoxModel consisits of an icon, a hint text, a user text and a selection |
| 20 // model. The icon is rendered to the side of the query editor. The hint text | 20 // model. The icon is rendered to the side of the query editor. The hint text |
| 21 // is used as query edit control's placeholder text and displayed when there is | 21 // is used as query edit control's placeholder text and displayed when there is |
| 22 // no user text in the control. The selection model and the text represents the | 22 // no user text in the control. The selection model and the text represents the |
| 23 // text, cursor position and selected text in edit control. | 23 // text, cursor position and selected text in edit control. |
| 24 class APP_LIST_EXPORT SearchBoxModel { | 24 class APP_LIST_EXPORT SearchBoxModel { |
| 25 public: | 25 public: |
| 26 // The properties of the button on the right side of edit box. | |
| 27 struct RightButtonProperty { | |
|
xiyuan
2013/11/12 03:09:25
nit: Can we use a more specific name? RightButton
Jun Mukai
2013/11/12 19:24:09
Done.
| |
| 28 gfx::ImageSkia icon; | |
| 29 gfx::ImageSkia toggled_icon; | |
| 30 base::string16 tooltip; | |
| 31 base::string16 toggled_tooltip; | |
| 32 | |
| 33 RightButtonProperty(const gfx::ImageSkia& icon, | |
| 34 const gfx::ImageSkia& toggled_icon, | |
| 35 const base::string16& tooltip, | |
| 36 const base::string16& toggled_tooltip); | |
| 37 ~RightButtonProperty(); | |
|
xiyuan
2013/11/12 03:09:25
nit: Move ctor and dtor before the member variable
Jun Mukai
2013/11/12 19:24:09
Done.
| |
| 38 }; | |
| 39 | |
| 26 SearchBoxModel(); | 40 SearchBoxModel(); |
| 27 ~SearchBoxModel(); | 41 ~SearchBoxModel(); |
| 28 | 42 |
| 29 // Sets/gets the icon on side of edit box. | 43 // Sets/gets the icon on the left side of edit box. |
| 30 void SetIcon(const gfx::ImageSkia& icon); | 44 void SetIcon(const gfx::ImageSkia& icon); |
| 31 const gfx::ImageSkia& icon() const { return icon_; } | 45 const gfx::ImageSkia& icon() const { return icon_; } |
| 32 | 46 |
| 47 // Sets/gets the properties for the button on the right side of edit box. | |
| 48 void SetRightButton(scoped_ptr<RightButtonProperty> right_button_prop); | |
| 49 const RightButtonProperty* right_button() const { | |
| 50 return right_button_prop_.get(); | |
| 51 } | |
| 52 | |
| 53 // Sets the right button state. | |
| 54 void SetRightButtonState(bool toggled); | |
| 55 | |
| 33 // Sets/gets the hint text to display when there is in input. | 56 // Sets/gets the hint text to display when there is in input. |
| 34 void SetHintText(const base::string16& hint_text); | 57 void SetHintText(const base::string16& hint_text); |
| 35 const base::string16& hint_text() const { return hint_text_; } | 58 const base::string16& hint_text() const { return hint_text_; } |
| 36 | 59 |
| 37 // Sets/gets the selection model for the search box's Textfield. | 60 // Sets/gets the selection model for the search box's Textfield. |
| 38 void SetSelectionModel(const gfx::SelectionModel& sel); | 61 void SetSelectionModel(const gfx::SelectionModel& sel); |
| 39 const gfx::SelectionModel& selection_model() const { | 62 const gfx::SelectionModel& selection_model() const { |
| 40 return selection_model_; | 63 return selection_model_; |
| 41 } | 64 } |
| 42 | 65 |
| 43 // Sets/gets the text for the search box's Textfield. | 66 // Sets/gets the text for the search box's Textfield. |
| 44 void SetText(const base::string16& text); | 67 void SetText(const base::string16& text); |
| 45 const base::string16& text() const { return text_; } | 68 const base::string16& text() const { return text_; } |
| 46 | 69 |
| 47 void AddObserver(SearchBoxModelObserver* observer); | 70 void AddObserver(SearchBoxModelObserver* observer); |
| 48 void RemoveObserver(SearchBoxModelObserver* observer); | 71 void RemoveObserver(SearchBoxModelObserver* observer); |
| 49 | 72 |
| 50 private: | 73 private: |
| 51 gfx::ImageSkia icon_; | 74 gfx::ImageSkia icon_; |
| 75 scoped_ptr<RightButtonProperty> right_button_prop_; | |
| 52 base::string16 hint_text_; | 76 base::string16 hint_text_; |
| 53 gfx::SelectionModel selection_model_; | 77 gfx::SelectionModel selection_model_; |
| 54 base::string16 text_; | 78 base::string16 text_; |
| 55 | 79 |
| 56 ObserverList<SearchBoxModelObserver> observers_; | 80 ObserverList<SearchBoxModelObserver> observers_; |
| 57 | 81 |
| 58 DISALLOW_COPY_AND_ASSIGN(SearchBoxModel); | 82 DISALLOW_COPY_AND_ASSIGN(SearchBoxModel); |
| 59 }; | 83 }; |
| 60 | 84 |
| 61 } // namespace app_list | 85 } // namespace app_list |
| 62 | 86 |
| 63 #endif // UI_APP_LIST_SEARCH_BOX_MODEL_H_ | 87 #endif // UI_APP_LIST_SEARCH_BOX_MODEL_H_ |
| OLD | NEW |