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_VIEWS_SEARCH_RESULT_VIEW_H_
6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_VIEW_H_
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/app_list/search_result_observer.h"
14 #include "ui/app_list/views/search_result_actions_view_delegate.h"
15 #include "ui/views/context_menu_controller.h"
16 #include "ui/views/controls/button/custom_button.h"
30 class ProgressBarView;
32 class SearchResultListView;
33 class SearchResultViewDelegate;
34 class SearchResultActionsView;
36 // SearchResultView displays a SearchResult.
37 class SearchResultView : public views::CustomButton,
38 public views::ButtonListener,
39 public views::ContextMenuController,
40 public SearchResultObserver,
41 public SearchResultActionsViewDelegate {
43 // Internal class name.
44 static const char kViewClassName[];
46 SearchResultView(SearchResultListView* list_view,
47 SearchResultViewDelegate* delegate);
48 virtual ~SearchResultView();
50 // Sets/gets SearchResult displayed by this view.
51 void SetResult(SearchResult* result);
52 SearchResult* result() { return result_; }
54 // Clears reference to SearchResult but don't schedule repaint.
55 void ClearResultNoRepaint();
58 void UpdateTitleText();
59 void UpdateDetailsText();
61 // views::View overrides:
62 virtual const char* GetClassName() const OVERRIDE;
63 virtual gfx::Size GetPreferredSize() OVERRIDE;
64 virtual void Layout() OVERRIDE;
65 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
66 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
68 // views::ButtonListener overrides:
69 virtual void ButtonPressed(views::Button* sender,
70 const ui::Event& event) OVERRIDE;
72 // views::ContextMenuController overrides:
73 virtual void ShowContextMenuForView(views::View* source,
74 const gfx::Point& point,
75 ui::MenuSourceType source_type) OVERRIDE;
77 // SearchResultObserver overrides:
78 virtual void OnIconChanged() OVERRIDE;
79 virtual void OnActionsChanged() OVERRIDE;
80 virtual void OnIsInstallingChanged() OVERRIDE;
81 virtual void OnPercentDownloadedChanged() OVERRIDE;
82 virtual void OnItemInstalled() OVERRIDE;
83 virtual void OnItemUninstalled() OVERRIDE;
85 // SearchResultActionsViewDelegate overrides:
86 virtual void OnSearchResultActionActivated(size_t index,
87 int event_flags) OVERRIDE;
89 SearchResult* result_; // Owned by AppListModel::SearchResults.
91 // Parent list view. Owned by views hierarchy.
92 SearchResultListView* list_view_;
95 SearchResultViewDelegate* delegate_;
97 views::ImageView* icon_; // Owned by views hierarchy.
98 scoped_ptr<gfx::RenderText> title_text_;
99 scoped_ptr<gfx::RenderText> details_text_;
100 SearchResultActionsView* actions_view_; // Owned by the views hierarchy.
101 ProgressBarView* progress_bar_; // Owned by views hierarchy.
103 scoped_ptr<views::MenuRunner> context_menu_runner_;
105 DISALLOW_COPY_AND_ASSIGN(SearchResultView);
108 } // namespace app_list
110 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_VIEW_H_