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_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_
6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_
8 #include "base/strings/string16.h"
9 #include "ui/gfx/insets.h"
10 #include "ui/message_center/message_center_export.h"
11 #include "ui/message_center/notification.h"
12 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/slide_out_view.h"
20 namespace message_center
{
23 class MessageCenterTray
;
24 class MessageViewContextMenuController
;
26 // Individual notifications constants.
27 const int kPaddingBetweenItems
= 10;
28 const int kPaddingHorizontal
= 18;
29 const int kWebNotificationButtonWidth
= 32;
30 const int kWebNotificationIconSize
= 40;
32 // An abstract class that forms the basis of a view for a notification entry.
33 class MESSAGE_CENTER_EXPORT MessageView
: public views::SlideOutView
,
34 public views::ButtonListener
{
36 MessageView(const Notification
& notification
,
37 MessageCenter
* message_center
,
38 MessageCenterTray
* tray
,
40 virtual ~MessageView();
42 // Returns the insets for the shadow it will have for rich notification.
43 static gfx::Insets
GetShadowInsets();
45 // Creates a shadow around the notification.
46 void CreateShadowBorder();
48 bool IsCloseButtonFocused();
49 void RequestFocusOnCloseButton();
51 void set_accessible_name(const string16
& name
) { accessible_name_
= name
; }
53 // Overridden from views::View:
54 virtual void GetAccessibleState(ui::AccessibleViewState
* state
) OVERRIDE
;
55 virtual bool OnMousePressed(const ui::MouseEvent
& event
) OVERRIDE
;
56 virtual bool OnKeyPressed(const ui::KeyEvent
& event
) OVERRIDE
;
57 virtual bool OnKeyReleased(const ui::KeyEvent
& event
) OVERRIDE
;
58 virtual void OnPaintFocusBorder(gfx::Canvas
* canvas
) OVERRIDE
;
60 // Overridden from ui::EventHandler:
61 virtual void OnGestureEvent(ui::GestureEvent
* event
) OVERRIDE
;
63 // Overridden from ButtonListener:
64 virtual void ButtonPressed(views::Button
* sender
,
65 const ui::Event
& event
) OVERRIDE
;
67 const std::string
& notification_id() { return notification_id_
; }
68 void set_scroller(views::ScrollView
* scroller
) { scroller_
= scroller
; }
73 // Overridden from views::SlideOutView:
74 virtual void OnSlideOut() OVERRIDE
;
76 MessageCenter
* message_center() { return message_center_
; }
77 views::ImageButton
* close_button() { return close_button_
.get(); }
78 views::ImageButton
* expand_button() { return expand_button_
.get(); }
79 views::ScrollView
* scroller() { return scroller_
; }
80 const bool is_expanded() { return is_expanded_
; }
83 MessageCenter
* message_center_
; // Weak reference.
84 std::string notification_id_
;
86 scoped_ptr
<MessageViewContextMenuController
> context_menu_controller_
;
87 scoped_ptr
<views::ImageButton
> close_button_
;
88 scoped_ptr
<views::ImageButton
> expand_button_
;
89 views::ScrollView
* scroller_
;
91 string16 accessible_name_
;
95 DISALLOW_COPY_AND_ASSIGN(MessageView
);
98 } // namespace message_center
100 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_