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 ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEW_H_ | |
6 #define ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEWS_H_ | |
7 #pragma once | |
8 | |
9 #include "ui/views/controls/button/image_button.h" | |
10 #include "ui/views/view.h" | |
11 | |
12 namespace gfx { | |
13 class ImageSkia; | |
14 } | |
15 | |
16 namespace views { | |
17 class ImageView; | |
18 } | |
19 | |
20 namespace ash { | |
21 | |
22 class SystemTrayItem; | |
23 | |
24 namespace internal { | |
25 | |
26 // A view for closable notification views, laid out like: | |
27 // ------------------- | |
28 // | icon contents x | | |
29 // ----------------v-- | |
30 // The close button will call OnClose() when clicked. | |
31 class TrayNotificationView : public views::View, | |
32 public views::ButtonListener { | |
33 public: | |
34 // If icon_id is 0, no icon image will be set. SetIconImage can be called | |
35 // to later set the icon image. | |
36 TrayNotificationView(SystemTrayItem* tray, int icon_id); | |
37 virtual ~TrayNotificationView(); | |
38 | |
39 // InitView must be called once with the contents to be displayed. | |
40 void InitView(views::View* contents); | |
41 | |
42 // Sets/updates the icon image. | |
43 void SetIconImage(const gfx::ImageSkia& image); | |
44 | |
45 // Replaces the contents view. | |
46 void UpdateView(views::View* new_contents); | |
47 | |
48 // Replaces the contents view and updates the icon image. | |
49 void UpdateViewAndImage(views::View* new_contents, | |
50 const gfx::ImageSkia& image); | |
51 | |
52 // Overridden from ButtonListener. | |
53 virtual void ButtonPressed(views::Button* sender, | |
54 const views::Event& event) OVERRIDE; | |
55 | |
56 // Overridden from views::View. | |
57 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | |
58 virtual ui::GestureStatus OnGestureEvent( | |
59 const views::GestureEvent& event) OVERRIDE; | |
60 | |
61 | |
sadrul
2012/07/03 02:27:53
remove empty line.
| |
62 protected: | |
63 // Called when the close button is pressed. Does nothing by default. | |
64 virtual void OnClose(); | |
65 // Called when the notification is clicked on. Does nothing by default. | |
66 virtual void OnClickAction(); | |
67 | |
68 SystemTrayItem* tray() { return tray_; } | |
69 | |
70 private: | |
71 void HandleClose(); | |
72 void HandleClickAction(); | |
73 | |
74 SystemTrayItem* tray_; | |
75 int icon_id_; | |
76 views::ImageView* icon_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(TrayNotificationView); | |
79 }; | |
80 | |
81 } // namespace internal | |
82 } // namespace ash | |
83 | |
84 #endif // ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEWS_H_ | |
OLD | NEW |