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_RESULT_VIEW_H_ | |
6 #define UI_APP_LIST_SEARCH_RESULT_VIEW_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "ui/app_list/search_result_observer.h" | |
14 #include "ui/views/controls/button/custom_button.h" | |
15 | |
16 namespace gfx { | |
17 class RenderText; | |
18 } | |
19 | |
20 namespace views { | |
21 class ImageButton; | |
22 class ImageView; | |
23 } | |
24 | |
25 namespace app_list { | |
26 | |
27 class SearchResult; | |
28 class SearchResultListView; | |
29 class SearchResultViewDelegate; | |
30 | |
31 // SearchResultView displays a SearchResult. | |
32 class SearchResultView : public views::CustomButton, | |
33 public views::ButtonListener, | |
34 public SearchResultObserver { | |
35 public: | |
36 // Internal class name. | |
37 static const char kViewClassName[]; | |
38 | |
39 SearchResultView(SearchResultListView* list_view, | |
40 SearchResultViewDelegate* delegate); | |
41 virtual ~SearchResultView(); | |
42 | |
43 // Sets/gets SearchResult displayed by this view. | |
44 void SetResult(SearchResult* result); | |
45 const SearchResult* result() const { return result_; } | |
46 | |
47 // Clears reference to SearchResult but don't schedule repaint. | |
48 void ClearResultNoRepaint(); | |
49 | |
50 private: | |
51 void UpdateTitleText(); | |
52 void UpdateDetailsText(); | |
53 | |
54 // views::View overrides: | |
55 virtual std::string GetClassName() const OVERRIDE; | |
56 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
57 virtual void Layout() OVERRIDE; | |
58 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
59 | |
60 // views::ButtonListener overrides: | |
61 virtual void ButtonPressed(views::Button* sender, | |
62 const ui::Event& event) OVERRIDE; | |
63 | |
64 // SearchResultObserver overrides: | |
65 virtual void OnIconChanged() OVERRIDE; | |
66 virtual void OnActionIconsChanged() OVERRIDE; | |
67 | |
68 SearchResult* result_; // Owned by AppListModel::SearchResults. | |
69 | |
70 // Parent list view. Owned by views hierarchy. | |
71 SearchResultListView* list_view_; | |
72 | |
73 // Not owned by us. | |
74 SearchResultViewDelegate* delegate_; | |
75 | |
76 views::ImageView* icon_; // Owned by views hierarchy. | |
77 scoped_ptr<gfx::RenderText> title_text_; | |
78 scoped_ptr<gfx::RenderText> details_text_; | |
79 | |
80 // Owned by the views hierarchy. | |
81 std::vector<views::ImageButton*> action_buttons_; | |
82 | |
83 DISALLOW_COPY_AND_ASSIGN(SearchResultView); | |
84 }; | |
85 | |
86 } // namespace app_list | |
87 | |
88 #endif // UI_APP_LIST_SEARCH_RESULT_VIEW_H_ | |
OLD | NEW |