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_MESSAGE_CENTER_MESSAGE_VIEW_H_ | 5 #ifndef UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ |
6 #define UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ | 6 #define UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ |
7 | 7 |
8 #include "ui/message_center/notification_list.h" | 8 #include "ui/message_center/notification_list.h" |
9 #include "ui/views/controls/button/button.h" | 9 #include "ui/views/controls/button/button.h" |
10 #include "ui/views/controls/slide_out_view.h" | 10 #include "ui/views/controls/slide_out_view.h" |
11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 class ImageButton; | 14 class ImageButton; |
15 class ScrollView; | 15 class ScrollView; |
16 } | 16 } |
17 | 17 |
18 namespace message_center { | 18 namespace message_center { |
19 | 19 |
| 20 #ifdef USE_AURA |
| 21 typedef views::SlideOutView MessageViewBase; |
| 22 #else |
| 23 typedef views::View MessageViewBase; |
| 24 #endif |
| 25 |
20 // Individual notifications constants. | 26 // Individual notifications constants. |
21 const int kPaddingBetweenItems = 10; | 27 const int kPaddingBetweenItems = 10; |
22 const int kPaddingHorizontal = 18; | 28 const int kPaddingHorizontal = 18; |
23 const int kWebNotificationButtonWidth = 32; | 29 const int kWebNotificationButtonWidth = 32; |
24 const int kWebNotificationIconSize = 40; | 30 const int kWebNotificationIconSize = 40; |
25 const int kWebNotificationWidth = 300; | 31 const int kWebNotificationWidth = 300; |
26 | 32 |
27 // An abstract class that forms the basis of a view for a notification entry. | 33 // An abstract class that forms the basis of a view for a notification entry. |
28 class MessageView : public views::SlideOutView, | 34 class MessageView |
29 public views::ButtonListener { | 35 : public views::ButtonListener, |
| 36 public MessageViewBase { |
30 public: | 37 public: |
31 MessageView(NotificationList::Delegate* list_delegate, | 38 MessageView(NotificationList::Delegate* list_delegate, |
32 const NotificationList::Notification& notification); | 39 const NotificationList::Notification& notification); |
33 | 40 |
34 virtual ~MessageView(); | 41 virtual ~MessageView(); |
35 | 42 |
36 // Creates the elements that make up the view layout. Must be called | 43 // Creates the elements that make up the view layout. Must be called |
37 // immediately after construction. | 44 // immediately after construction. |
38 virtual void SetUpView() = 0; | 45 virtual void SetUpView() = 0; |
39 | 46 |
40 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } | 47 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } |
41 | 48 |
42 // Overridden from views::View. | 49 // Overridden from views::View. |
43 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 50 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
44 | 51 |
45 // Overridden from ui::EventHandler. | 52 // Overridden from ui::EventHandler. |
46 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 53 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
47 | 54 |
48 // Overridden from ButtonListener. | 55 // Overridden from ButtonListener. |
49 virtual void ButtonPressed(views::Button* sender, | 56 virtual void ButtonPressed(views::Button* sender, |
50 const ui::Event& event) OVERRIDE; | 57 const ui::Event& event) OVERRIDE; |
51 | 58 |
52 protected: | 59 protected: |
53 MessageView(); | 60 MessageView(); |
54 | 61 |
55 // Shows the menu for the notification. | 62 // Shows the menu for the notification. |
56 void ShowMenu(gfx::Point screen_location); | 63 void ShowMenu(gfx::Point screen_location); |
57 | 64 |
| 65 #ifdef USE_AURA |
58 // Overridden from views::SlideOutView. | 66 // Overridden from views::SlideOutView. |
59 virtual void OnSlideOut() OVERRIDE; | 67 virtual void OnSlideOut() OVERRIDE; |
| 68 #endif |
60 | 69 |
61 NotificationList::Delegate* list_delegate_; | 70 NotificationList::Delegate* list_delegate_; |
62 NotificationList::Notification notification_; | 71 NotificationList::Notification notification_; |
63 views::ImageButton* close_button_; | 72 views::ImageButton* close_button_; |
64 | 73 |
65 views::ScrollView* scroller_; | 74 views::ScrollView* scroller_; |
66 | 75 |
67 DISALLOW_COPY_AND_ASSIGN(MessageView); | 76 DISALLOW_COPY_AND_ASSIGN(MessageView); |
68 }; | 77 }; |
69 | 78 |
70 } // namespace message_center | 79 } // namespace message_center |
71 | 80 |
72 #endif // UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ | 81 #endif // UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ |
OLD | NEW |